Subclassing ValueError to DomainError (or so) with additional information about the domain (if available) would make sense. The information in the exception could be automatically generated from a domain() method.
The plot function should of course be able to deal with ValueError Just providing the domain in a method or exception is not the solution to the plot issue as plot(lambda x:arcsec(x-100)) can't know about the argument shift. On Thursday, February 13, 2014 7:23:42 AM UTC, vdelecroix wrote: > > 2014-02-13 0:38 UTC+01:00, William Stein <wst...@gmail.com <javascript:>>: > > > On Wed, Feb 12, 2014 at 2:50 PM, Jason Grout > > <jason...@creativetrax.com <javascript:>> wrote: > >> David Smith just pointed this out: arcsec(float(.1)) throws an error > that > >> doesn't make much sense. Yes, it's outside of the domain, but it > should > >> probably deal with this by returning NaN or something rather than a > type > >> error. This came up when David was trying to plot arcsec. > >> > >> On a related note, maybe we should have some sort of error that can be > >> thrown for values outside of domains? Plot could catch an > out-of-domain > >> error and break the drawing there, so you wouldn't end up with > something > >> like http://sagecell.sagemath.org/?q=llweji > >> > > > > What about ValueError? > > > > > http://docs.python.org/2/library/exceptions.html#exceptions.ValueError > > > > +1 > > > On the other hand, it would be very nice and meaningful to have > > sage: arcsec.domain() > (-infty; -1] u [1; +infty) > > That kind of information can then be used by call to plot. > > Vincent > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.