Ticket #6905 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[with patch, positive review] real(0.0r) is broken

Reported by: nthiery Owned by: mhansen
Priority: major Milestone: sage-4.1.2
Component: symbolics Keywords: real, symbolic, plot
Cc: Work issues:
Report Upstream: Reviewers: Nicolas M. Thiéry
Authors: Mike Hansen Merged in: Sage 4.1.2.alpha2
Dependencies: Stopgaps:

Description

Implement:

sage: real(0.0r)

Note: imag(0.0r) seems to readily work (using Maxima if I read it well)!

Found after getting the following bug report from Francois Maltey:

sage: parametric_plot ((real(exp(i*a)),imag(exp(i*a))),(a,-5,5))

Raises the following warning:

verbose 0 (2999: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points. verbose 0 (2999: plot.py, generate_plot_points) Last error message: float' object is not callable'

and yield an empty plot. Investing this further, I got that

sage: var('a'); f = fast_float(real(exp(i*a)),a)

Yields a non callable object. Finally Mike H traced it back on IRC to real(0.0r) being broken, because 0.0r.real is an attribute, not a method.

Attachments

trac_6905.patch Download (786 bytes) - added by mhansen 4 years ago.

Change History

Changed 4 years ago by mhansen

comment:1 Changed 4 years ago by mhansen

  • Owner set to mhansen
  • Status changed from new to assigned
  • Summary changed from real(0.0r) is broken to [with patch, needs review] real(0.0r) is broken
  • Authors set to Mike Hansen

comment:2 Changed 4 years ago by nthiery

  • Reviewers set to Nicolas M. Thiéry
  • Summary changed from [with patch, needs review] real(0.0r) is broken to [with patch, positive review] real(0.0r) is broken

This trivial patch applies smoothly, passes all test in sage/functions (and most likely elsewhere).

I am no expert of this part of sage, and from the outside it sounds a bit like a workaround. In the long run, it would sound better to fix float to have a "real" method, and have a consistent implementation of real and imag. But it is simple enough to be safe,and it solves the original problem which hurts casual users. So I put a positive review. If anyone cares, please create a new ticket.

comment:3 Changed 4 years ago by mvngu

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Merged in set to Sage 4.1.2.alpha2
Note: See TracTickets for help on using tickets.