#6947 closed defect (fixed)
[with patch, positive review] make complex_plot() work for for fast_callable functions
Reported by: | bober | Owned by: | was |
---|---|---|---|
Priority: | minor | Milestone: | sage-4.1.2 |
Component: | graphics | Keywords: | |
Cc: | Merged in: | Sage 4.1.2.alpha4 | |
Authors: | Jonathan Bober | Reviewers: | Jason Grout |
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
This current behavior of Sage demonstrates a bug, which probably also affects other complex valued functions that cannot be converted into real valued functions.
sage: f(x) = x^2 sage: g = fast_callable(f, domain=CC, vars='x') sage: P = complex_plot(f, (-10, 10), (-10, 10)) sage: Q = complex_plot(g, (-10, 10), (-10, 10)) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (35, 0)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/bober/.sage/temp/bober/1740/_home_bober__sage_init_sage_0.py in <module>() /home/bober/sage/local/lib/python2.6/site-packages/sage/plot/misc.pyc in wrapper(*args, **kwds) 133 options['__original_opts'] = kwds 134 options.update(kwds) --> 135 return func(*args, **options) 136 137 /home/bober/sage/local/lib/python2.6/site-packages/sage/plot/complex_plot.so in sage.plot.complex_plot.complex_plot (sage/plot/complex_plot.c:4104)() /home/bober/sage/local/lib/python2.6/site-packages/sage/plot/plot.pyc in setup_for_eval_on_grid(v, xrange, yrange, plot_points) 2874 from sage.plot.plot3d.parametric_plot3d import adapt_to_callable 2875 if xvar is None: -> 2876 k, _ = adapt_to_callable([f], 2) 2877 g.append(k[0]) 2878 else: /home/bober/sage/local/lib/python2.6/site-packages/sage/plot/plot3d/parametric_plot3d.pyc in adapt_to_callable(f, nargs) 649 except TypeError: 650 vars = () --> 651 f = [fast_float_constant(x) for x in f] 652 653 if nargs is not None and len(vars) != nargs: /home/bober/sage/local/lib/python2.6/site-packages/sage/ext/fast_eval.so in sage.ext.fast_eval.fast_float_constant (sage/ext/fast_eval.c:8030)() /home/bober/sage/local/lib/python2.6/site-packages/sage/ext/fast_eval.so in sage.ext.fast_eval.FastDoubleFunc.__init__ (sage/ext/fast_eval.c:3492)() TypeError: a float is required
The attached patch fixes this. (It is a one character fix, but someone who knows the plotting code should make sure it is the right fix.)
Attachments (2)
Change History (5)
Changed 13 years ago by
comment:1 Changed 13 years ago by
- Summary changed from [with patch, needs review] make complex_plot() work for for fast_callable functions to [with patch, positive review] make complex_plot() work for for fast_callable functions
comment:2 Changed 13 years ago by
- Merged in set to Sage 4.1.2.alpha3
- Resolution set to fixed
- Reviewers set to Jason Grout
- Status changed from new to closed
comment:3 Changed 13 years ago by
- Merged in changed from Sage 4.1.2.alpha3 to Sage 4.1.2.alpha4
There is no 4.1.2.alpha3. Sage 4.1.2.alpha3 was William Stein's release for working on making the notebook a standalone package.
Note: See
TracTickets for help on using
tickets.
This looks great. The reviewer patch just adds the tests above as doctests.
As another ticket, complex_plot really needs to convert it's arguments to fast_callable(..., domain=CDF). See #6985 for timing examples.