Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change plot to use fast_callable #7614

Closed
williamstein opened this issue Dec 6, 2009 · 10 comments
Closed

change plot to use fast_callable #7614

williamstein opened this issue Dec 6, 2009 · 10 comments

Comments

@williamstein
Copy link
Contributor

From this sage-support thread:

On Sun, Dec 6, 2009 at 4:51 PM, Michel <vdbergh@gmail.com> wrote:
> Thanks for the reply. But no. The problem is not due to the fact that
> the function has a singularity. Indeed.
>
> plot(20*log(abs((1+I*x)^4),10),(x,0,3))
>
> fails with the same error which is incomprehensible to me.
>
> On the other hand turning the expression into a lambda function made
> it possible to plot it. Thanks for this practical advice.
>
> I wish someone could explain this rationally to me.
>
> 20*log(abs((1+I*x)^4),10)
>
> seems to be a perfectly fine symbolic expression so IMHO it should be
> possible to plot it.

This is a bug.  There absolutely no reason that plotting should give the error
   "float() argument must be a string or a number".
We could give an error about not being able to evaluate the function at certain
points.  However, the above error is not OK.    The error in fact is not in plotting
but in making a fast_float compiled version of the expression:

sage: s = 20*log(abs((1+I*x)^4),10)
sage: fast_float(s,x)
Traceback (most recent call last):
...
TypeError: float() argument must be a string or a number

In fact, SAge *should* be using fast_callable, not fast_float.  This works
just fine if you force it manually:

s = 20*log(abs((1+I*x)^4),10)
plot(fast_callable(s,vars=[x]), (x,0,3))
[[nice picture as output]]

Many, many thanks for your bug report.  It is bug reports from users like
you that really helps Sage to be a first-rate mathematical software system.

Component: graphics

Author: William Stein

Reviewer: Jason Grout

Merged: sage-4.3.rc1

Issue created by migration from https://trac.sagemath.org/ticket/7614

@williamstein williamstein added this to the sage-4.3.1 milestone Dec 6, 2009
@williamstein williamstein self-assigned this Dec 6, 2009
@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Dec 7, 2009

comment:1

From this sage-support thread:

On Sun, Dec 6, 2009 at 4:51 PM, Michel <vdbergh@gmail.com> wrote:
> Thanks for the reply. But no. The problem is not due to the fact that
> the function has a singularity. Indeed.
>
> plot(20*log(abs((1+I*x)^4),10),(x,0,3))
>
> fails with the same error which is incomprehensible to me.
>
> On the other hand turning the expression into a lambda function made
> it possible to plot it. Thanks for this practical advice.
>
> I wish someone could explain this rationally to me.
>
> 20*log(abs((1+I*x)^4),10)
>
> seems to be a perfectly fine symbolic expression so IMHO it should be
> possible to plot it.

This is a bug.  There absolutely no reason that plotting should give the error
   "float() argument must be a string or a number".
We could give an error about not being able to evaluate the function at certain
points.  However, the above error is not OK.    The error in fact is not in plotting
but in making a fast_float compiled version of the expression:

sage: s = 20*log(abs((1+I*x)^4),10)
sage: fast_float(s,x)
Traceback (most recent call last):
...
TypeError: float() argument must be a string or a number

In fact, SAge *should* be using fast_callable, not fast_float.  This works
just fine if you force it manually:

s = 20*log(abs((1+I*x)^4),10)
plot(fast_callable(s,vars=[x]), (x,0,3))
[[nice picture as output]]

Many, many thanks for your bug report.  It is bug reports from users like
you that really helps Sage to be a first-rate mathematical software system.

@sagetrac-mvngu

This comment has been minimized.

@sagetrac-mvngu

This comment has been minimized.

@jasongrout
Copy link
Member

comment:3

Some of the things at #5572 need to be fixed (like constant functions) before this switch. Right now, fast_float handles things like constant functions, but fast_callable does not.

@williamstein
Copy link
Contributor Author

comment:4

Replying to @jasongrout:

Some of the things at #5572 need to be fixed (like constant functions) before this switch. Right now, fast_float handles things like constant functions, but fast_callable does not.

  1. fast_float is just as bad as fast_callable, IMHO, since fast_float fails to handle many things too.

  2. Nobody is working on fast_callable, as far as I know, since Carl Witty is no longer working on Sage.

  3. The specific problem under consideration could nicely by solved with a simple try/except:

try: 
    fast_float(...)
except:
    fast_callable(...)

@williamstein
Copy link
Contributor Author

Attachment: trac_7614.patch.gz

@jasongrout
Copy link
Member

comment:6

passes doctests, fixes the problem above.

@jasongrout
Copy link
Member

Reviewer: Jason Grout

@jasongrout
Copy link
Member

Author: William Stein

@mwhansen
Copy link
Contributor

Merged: sage-4.3.rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants