Dima Pasechnik wrote: > > On Fri, Jan 3, 2020 at 8:52 PM Donald Munro <[email protected] > <javascript:>> wrote: > > > > Running: > >> > >> from sage.plot.plot3d.shapes2 import Line > >> X = Line([(-1, 0, 0), (0, 0, 0), (1, 0, 0)], color='red') > >> Y = Line([(0, -1, 0), (0, 0, 0), (0, -1,0)], color='green') > >> Z = Line([(0, 0, -1), (0, 0, 0), (0, 0, -1)], color='green') > >> show(X+Y+Z, figsize=8) > > > > > > results in a > >> > >> TypeError: Object of type Integer is not JSON serializable > > the problem is that Sage's type Integer cannot be used in Line() > You'd need to use Python types, e.g. int(), float(), etc > E.g. > > Line([(int(-1), int(0), int(0)), (int(0), int(0), int(0)), (int(1), > > Thanks, replacing the above code with
> def to_float(v): > vv = [None] * len(v) > for i in range(0, len(v)): > vv[i] = float(v[i]) > return vv > from sage.plot.plot3d.shapes2 import Line > X = Line([to_float((-1, 0, 0)), to_float((0, 0, 0)), to_float((1, 0, 0))], > color='red') > Y = Line([to_float((0, -1, 0)), to_float((0, 0, 0)), to_float((0, -1,0))], > color='green') > Z = Line([to_float((0, 0, -1)), to_float((0, 0, 0)), to_float((0, 0, > -1))], color='green') > show(X+Y+Z, figsize=8) > does solve the problem or at least provide a work-around. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/9cabc26f-30f3-4233-a8a9-cd182d6b34ed%40googlegroups.com.
