> For trying to invert a non-square matrix, I think the error should be > a ValueError, since you're inputing an improper value so that the > operation is meaningless. > > >From http://docs.python.org/library/exceptions.html > > 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.
I was specifically speaking about non square matrices. Note that I'm pretty sure that for some kind of square matrices, you'll get an error different that DivisionbyZero. Here is an example: sage: x = Mat(CDF,1,1)(0) sage: x [0] sage: x.__class__ <type 'sage.matrix.matrix_complex_double_dense.Matrix_complex_double_dense'> sage: M.inverse() --------------------------------------------------------------------------- LinAlgError Traceback (most recent call last) [...] LinAlgError: singular matrix This makes also sense, and seems even better to me. > > My opinion is that this is not the right way to do. I think it fits > > perfectly > > into Nicolas check_... framework. So that in the top class Matrix in > > matrix0.py one can make a check_trivial_matrices(self) methods and call > > check > > for all the doc. Unfortunately for this we have to wait for this device to > > be > > integrated. Any though ? > I don't really understand what you just wrote. Sorry, my English is not very good. I was refering to Nicolas e-mail about [sage-devel] Re: Generic tests and categories (was doctesting __hash__ ?) I'd like to see for any Matrix space M the following ***...*** >> sage: P.check(verbose = True) >> running test_an_element ... >> running test_some_elements ... >> running test_pickling ... >> running test_element_pickling ... >> running test_associativity ... >> ***running test_trivial_matrices*** > However, factoring out the preconditions for checking whether, e.g., > __invert__ should work seems like a good idea to me. This could be > either in another file, or just in a cpdef'd method that is defined in > matrix0.pyx. > > self._check_invert_conditions() Ok. Good idea... But that's for the code. I was speaking about tests. > Using cpdef is a good idea for speed purposes. Ok. Sorry for this avalanche of e-mails. Florent --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
