complex_plot and fractals

1 view
Skip to first unread message

Jason Grout

unread,
Jun 15, 2009, 3:09:32 PM6/15/09
to sage-...@googlegroups.com
I just tried to implement a quick, fast mandelbrot set plot. I posted
my results (with the puzzling error) here: http://sagenb.org/home/pub/578/

The error that I get is that when passing a Cython-created CC number to
complex_plot, I get an error "float required"---something about the
fast_float stuff. However, when I wrap that in a Python function which
merely returns the exact same thing, there is no error.

Can someone look at the worksheet and see offhand what the problem is?
Is it an error in my code, in fast_float, complex_plot, or something else?

Thanks,

Jason

Tom Boothby

unread,
Jun 15, 2009, 6:08:51 PM6/15/09
to sage-...@googlegroups.com
The error isn't in your code, I've duplicated this with much simpler code.

{{{
%cython
from sage.rings.all import CC
def foo(z):
return CC(z)
}}}

{{{
complex_plot(foo,(0,1),(0,1))
///
Traceback (click to the left for traceback)
...
TypeError: a float is required
}}}

{{{
complex_plot(lambda z: foo(z),(0,1),(0,1))
///
[pretty picture]

Robert Bradshaw

unread,
Jun 17, 2009, 2:58:16 AM6/17/09
to sage-...@googlegroups.com
On Jun 15, 2009, at 3:08 PM, Tom Boothby wrote:

>
> The error isn't in your code, I've duplicated this with much
> simpler code.
>
> {{{
> %cython
> from sage.rings.all import CC
> def foo(z):
> return CC(z)
> }}}
>
> {{{
> complex_plot(foo,(0,1),(0,1))
> ///
> Traceback (click to the left for traceback)
> ...
> TypeError: a float is required
> }}}
>
> {{{
> complex_plot(lambda z: foo(z),(0,1),(0,1))
> ///
> [pretty picture]
> }}}

It looks like error is in adapt_to_callable, which probably doesn't
recognize "builtin" (i.e. c defined) functions (being a different
type than Python-defined ones). It should be converted to used
fast_callable rather than fast_float anyways.

- Robert
Reply all
Reply to author
Forward
0 new messages