You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If one tries to plot a modular form the plot code tries to evaluate the modular form as a function on floats, which fails. Essentially this boils down to floats not having a .parent() (see traceback at end).
There are two potential fixes, neither of which I had opportunity to test yet, but would like thoughts on:
Modify the line Q = a.parent() of src/sage/rings/power_series_poly.pyx to something like
from sage.structure import parent
Q = parent(a)
which might make power series a bit more resilient to being passed python types as input, this might be a change which should be made across a lot of Sage in that case?
Or modify plotting code (generate_plot_points) to not use floats, I guess this might come with some performance hit to plotting.
sage: modf = ModularForms(12).basis()[0]
sage: plot(modf)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-f871686f0b17> in <module>()
----> 1 plot(modf)
/Users/alex/sage/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
565 options['__original_opts'] = kwds
566 options.update(kwds)
--> 567 return func(*args, **options)
568
569 #Add the options specified by @options to the signature of the wrapped
/Users/alex/sage/local/lib/python2.7/site-packages/sage/plot/plot.pyc in plot(funcs, *args, **kwds)
1954 xmin = kwds.pop('xmin', -1)
1955 xmax = kwds.pop('xmax', 1)
-> 1956 G = _plot(funcs, (xmin, xmax), **kwds)
1957
1958 # if there is one extra arg, then it had better be a tuple
/Users/alex/sage/local/lib/python2.7/site-packages/sage/plot/plot.pyc in _plot(funcs, xrange, parametric, polar, fill, label, randomize, **options)
2264 data = generate_plot_points(f, xrange, plot_points,
2265 adaptive_tolerance, adaptive_recursion,
-> 2266 randomize)
2267
2268
/Users/alex/sage/local/lib/python2.7/site-packages/sage/plot/plot.pyc in generate_plot_points(f, xrange, plot_points, adaptive_tolerance, adaptive_recursion, randomize, initial_points)
3862
3863 try:
-> 3864 data[i] = (float(xi), float(f(xi)))
3865 if str(data[i][1]) in ['nan', 'NaN', 'inf', '-inf']:
3866 msg = "Unable to compute f(%s)" % xi
/Users/alex/sage/local/lib/python2.7/site-packages/sage/modular/modform/element.pyc in __call__(self, x, prec)
174 0
175 """
--> 176 return self.q_expansion(prec)(x)
177
178 @cached_method
/Users/alex/sage/local/lib/python2.7/site-packages/sage/rings/power_series_poly.pyx in sage.rings.power_series_poly.PowerSeries_poly.__call__ (build/cythonized/sage/rings/power_series_poly.c:5702)()
320 return self.__f(x)
321
--> 322 Q = a.parent()
323
324 from sage.rings.padics.padic_generic import pAdicGeneric
AttributeError: 'float' object has no attribute 'parent'
alexjbest
changed the title
Modular form printing fails because modular forms cannot be evaluated at floats
Modular form plotting fails because modular forms (power series) cannot be evaluated at floats
Sep 21, 2018
If one tries to
plot
a modular form the plot code tries to evaluate the modular form as a function on floats, which fails. Essentially this boils down to floats not having a.parent()
(see traceback at end).There are two potential fixes, neither of which I had opportunity to test yet, but would like thoughts on:
Q = a.parent()
ofsrc/sage/rings/power_series_poly.pyx
to something likewhich might make power series a bit more resilient to being passed python types as input, this might be a change which should be made across a lot of Sage in that case?
generate_plot_points
) to not use floats, I guess this might come with some performance hit to plotting.Component: graphics
Keywords: plotting, modular forms, python types
Issue created by migration from https://trac.sagemath.org/ticket/26317
The text was updated successfully, but these errors were encountered: