Ticket #11648 (new defect)

Opened 22 months ago

Last modified 11 months ago

Contour plot cannot deal with non-real numbers

Reported by: eviatarbach Owned by: jason, was
Priority: major Milestone: sage-5.10
Component: graphics Keywords:
Cc: kcrisman Work issues:
Report Upstream: N/A Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

When trying to contour_plot a function that can return non-real numbers, such as

sage: contour_plot(log(x) + log(y), (-1000, 1000), (-1000, 1000))

the following error is returned:

TypeError: can't convert complex to float

Sage should print a warning and skip over the those points. This is the way R behaves.

Attachments

example.png Download (18.1 KB) - added by eviatarbach 11 months ago.

Change History

comment:1 Changed 22 months ago by kcrisman

  • Cc kcrisman added

comment:2 Changed 11 months ago by eviatarbach

I don't know how, but it seems that this was fixed sometime. It now skips non-real points. Can someone close this ticket? Thanks.

comment:3 Changed 11 months ago by kcrisman

Nope! Now we need a patch that adds a doctest in that file that confirms that this one doesn't return an error. I think you know how to do this, right?

Can you try some other possible contour plots like that, to make sure it wasn't just this particular one that did it? What does the graph look like? (You should be able to attach a png file and then refer to it here with the wiki syntax.)

Changed 11 months ago by eviatarbach

comment:4 Changed 11 months ago by eviatarbach

Sure! I do know how to do this, but Mercurial queues are so aggravating that I'm going to have to put it off until I have time to re-learn them.

I did try several different functions. Attached is the example given in the description.

comment:5 Changed 11 months ago by kcrisman

Seems like a reasonable pic.

Totally don't do Mercurial queues, it's not worth it unless you're going to be doing a lot of development; for once-off stuff it's not needed, especially if there is only one patch involved. See this part of the developer guide - I used this hg_sage functionality for years. Looking forward to it.

comment:6 follow-up: ↓ 7 Changed 11 months ago by eviatarbach

Okay.

Another issue is whether the real part of the complex number should be plotted, like  Wolfram Alpha does.

comment:7 in reply to: ↑ 6 Changed 11 months ago by kcrisman

Another issue is whether the real part of the complex number should be plotted, like  Wolfram Alpha does.

I'd say no, because those are very clearly labeled as "real part" and so forth, which we don't do. As long as we aren't doing something wrong, I think that the picture you have and similar behavior is ok; it's understood that one doesn't plot complex values.

Note: See TracTickets for help on using tickets.