Re: [sage-support] How to catch exceptional values (+ in plot3d, one exceptional point ruins the whole plot).

2016-10-16 Thread Emmanuel Charpentier
Thank you, Jeroen ! That is indeed much better. I'm still a bit wet behind 
the ears about Python...

Too bad I didn't see this until after posting this 
 ...

--
Emmanuel Charpentier

Le mercredi 12 octobre 2016 08:01:54 UTC+2, Jeroen Demeyer a écrit :
>
> On 2016-10-11 22:07, William Stein wrote: 
> >  try: return abs(gamma(x+I*y)) 
> >  except: return 0 
>
> That is almost never what you want, since this will also catch things 
> like KeyboardInterrupt. Better use 
>
> try: 
>  ... 
> except Exception: 
>  ... 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to catch exceptional values (+ in plot3d, one exceptional point ruins the whole plot).

2016-10-11 Thread Jeroen Demeyer

On 2016-10-11 22:07, William Stein wrote:

 try: return abs(gamma(x+I*y))
 except: return 0


That is almost never what you want, since this will also catch things 
like KeyboardInterrupt. Better use


try:
...
except Exception:
...

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to catch exceptional values (+ in plot3d, one exceptional point ruins the whole plot).

2016-10-11 Thread Emmanuel Charpentier
Okay : you catch *all* exceptions. I didn't know you could do that. I tried 
to filter on the nature of the exception (didn't work : catching ValueError 
raised a TypeError later) or the value (how to do the comparison ?).

[ Brown paper bag goes on head... ]

Thank you !

--
Emmanuel Charpentier

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.