Open vbraun opened 13 years ago
This is sad, but I have no idea why this is happening and would claim that this is an error related to general tachyon code, since jmol plots work fine and look exactly the same, as they should.
Tachyon also handles alpha on a totally different scale, our default 0.4 looks awful (but works great in both jmol and matplotlib with similar effect).
I think this is the issue:
sage: (point([0,1,1])).show(viewer='tachyon')
works, while
sage: (point([0,1,1]) + Graphics()).show(viewer='tachyon')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_55.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("KHBvaW50KFswLDEsMV0pICsgR3JhcGhpY3MoKSkuc2hvdyh2aWV3ZXI9J3RhY2h5b24nKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpEJzM5T/___code___.py", line 3, in <module>
exec compile(u"(point([_sage_const_0 ,_sage_const_1 ,_sage_const_1 ]) + Graphics()).show(viewer='tachyon')" + '\n', '', 'single')
File "", line 1, in <module>
File "base.pyx", line 1081, in sage.plot.plot3d.base.Graphics3d.show (sage/plot/plot3d/base.c:9834)
File "base.pyx", line 524, in sage.plot.plot3d.base.Graphics3d.tachyon (sage/plot/plot3d/base.c:4743)
File "base.pyx", line 1410, in sage.plot.plot3d.base.Graphics3dGroup.texture_set (sage/plot/plot3d/base.c:13141)
File "base.pyx", line 1410, in sage.plot.plot3d.base.Graphics3dGroup.texture_set (sage/plot/plot3d/base.c:13141)
File "base.pyx", line 1410, in sage.plot.plot3d.base.Graphics3dGroup.texture_set (sage/plot/plot3d/base.c:13141)
File "base.pyx", line 1410, in sage.plot.plot3d.base.Graphics3dGroup.texture_set (sage/plot/plot3d/base.c:13157)
TypeError: reduce() of empty sequence with no initial value
In cones plotting of labels and rays was separated for the sake of non-strictly convex cones (I assume that you have that patch applied, since in plain sage-4.6 there are no problems, unless you add, say, ray_label=None
option). It may lead to addition of an empty graphics object to the final plot. I do NOT consider it a bug of cones as I think that empty plots are exactly what should be returned by plotting functions if there is nothing to plot and viewers should handle it correctly, as jmol and matplotlib do:
sage: (point([0,1,1]) + Graphics()).show(viewer='jmol')
sage: (point([0,1]) + Graphics()).show()
sage: (Graphics()).show()
All of these work as expected.
This looks to me like an easy fix.
In 6.1.1, the Graphics3dGroup.texture_set() method is defined by line sage/plot/plot3d/base.pyx:1501:
return reduce(set.union, [g.texture_set() for g in self.all])
It chokes on empty graphics because reduce() chokes on an empty list. Adding an initializer resolves the issue:
return reduce(set.union, [g.texture_set() for g in self.all], set())
Being in a hurry at the moment, I just used an external workaround:
def texture_set(g):
try:
return g.texture_set()
except TypeError:
return reduce(set.union, [texture_set(gi) for gi in g.all], set())
I get the following error when trying to plot 3d cones with the taychon raytracer (which is the default for 3d plots in SageTeX):
Somewhat puzzling, the following work fine:
so its the combination of a
Cone
(not aFan
) with tachyon that causes this.CC: @novoselt @nilesjohnson
Component: graphics
Issue created by migration from https://trac.sagemath.org/ticket/10442