Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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:

Status badges

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)

trac6947.patch (908 bytes) - added by bober 13 years ago.
trac-6947-review.patch (1.1 KB) - added by jason 13 years ago.
apply on top of previous patch

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by bober

comment:1 Changed 13 years ago by jason

  • 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

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.

Changed 13 years ago by jason

apply on top of previous patch

comment:2 Changed 13 years ago by mvngu

  • Authors changed from Bober to Jonathan Bober
  • 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 mvngu

  • 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.