I would be vague about a TypeError versus a ValueError. These are used in 
various ways by different authors over different periods. It can also be 
very hard to make this rigorous. For example, for something accepting 
integer inputs, then 2/2 fails the isinstance() check but shouldn't throw 
an error. Likewise 1/2 is a bad value that cannot be tested by the 
isinstance() check alone. Actually, I might consider putting them together 
and letting the programmer decide which is most appropriate (of course, 
there are clear cases, such as a list compared to a number).

The ArithmeticError and ZeroDivisionError are fine with me.

I think NotImplementedError is obvious and should be stated in such a way: 
"the input is for a feature not yet implemented"

For RuntimeError, I would make it sound like it tells you there is serious 
error occurring as it doesn't fall into any other error categories. This 
actually makes it the opposite of a catchall error.

Best,
Travis


On Thursday, February 8, 2024 at 11:15:34 AM UTC+9 Kwankyu Lee wrote:

> A method (or function) takes objects as input and computes an output.  The 
> INPUT block defines coarsely  the intended class of mathematical objects. 
>
> TypeError: the type (that can be checked by isinstance(obj, class)) of the 
> input object does not belong to the intended class of mathematical objects
> ValueError: the particular input object is not suitable as input
> ArithmeticError: the particular input object is not suitable for 
> arithmetic (sum, product, quotient, and the like) operation 
> ZeroDivisionError: the method performs division but the input is zero
> NotImplementedError: there is no problem with the input object but the 
> method is incapable to compute appropriate output.
> RuntimeError: The method somehow cannot perform the computation. Perhaps a 
> catchall error.
>
>
> I may add the above to the developer guide. Any comments? 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/fc6d3662-1d8e-41a4-98ec-4509e2547b71n%40googlegroups.com.

Reply via email to