On Mon, Feb 9, 2009 at 7:39 AM, Florent Hivert
<[email protected]> wrote:
>
> Dear William,
>
> Sorry to bother you again with those stupid error messages... You'll
> probably think I'm a kind of lawyer after that :-) I still needs a
> confirmation... We agreed that:
>
>> 2. Any nx0 or 0xn (n != 0) matrix is not invertible and should raise a
>> **ValueError** "matrix must be square" if one tries to invert it. I'll add
>> support for this in the file matrix0.pyx. I'll also try to make generic
>> test for this behavior.
>
> Which contradict the following doc from matrix0.pyx(2688):
>
> Raises a \code{ZeroDivisionError} if the matrix has zero
> determinant, and raises an \code{**ArithmeticError**}, if the
> inverse doesn't exist because the matrix is nonsquare. Also,
> note, e.g., that the inverse of a matrix over $\ZZ$ is always
> a matrix defined over $\Q$ (even if the entries are integers).
>
> I'm reluctant to change this behavior for backward compatibility reasons...
ValueError derives from ArithmeticError, so if anybody wrote
try: something...
except ArithmeticError:
..
and you change the ArithmeticError to ValueError, then their code will
still work fine.
So I think the impact of making this change isn't too bad.
> So are you ok to change the code and the doc ? Or should I follow the doc and
> raise an ArithmeticError. Note that the same question holds for power,
> determinants and characteristic polynomials...
Well I wish I had used ValueError when I wrote that in matrix0.pyx, at
least based
on what Python's docs define ValueError and ArithmeticError to be:
exception ValueError
Raised when a built-in operation or function receives an argument
that has the right type but an inappropriate value, and the situation
is not described by a more precise exception such as IndexError.
exception ArithmeticError
The base class for those built-in exceptions that are raised for
various arithmetic errors: OverflowError, ZeroDivisionError,
FloatingPointError.
So personally, I'm OK with changing to ValueError.
William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---