On 9 Feb., 05:22, "Aaron S. Meurer" <asmeu...@gmail.com> wrote:
> I am trying to create a branch that backports all of my non-Risch Algorithm 
> commits from my integration3 branch.  One 
> commit,https://github.com/asmeurer/sympy/commit/846af4a187800a97520d771dc9e1...,
>  which is related tohttp://code.google.com/p/sympy/issues/detail?id=1991, 
> changes the exceptions in the code of matrices.py a little bit.  I am not so 
> sure now what the best way to have things is, though.  
>
> Currently, there is a MatrixError exception, which is only used in one place 
> in matrices.py, and there I believe ShapeError should be used instead.  All 
> over the code there is "assert self.cols == self.rows".  I have replaced all 
> of these with NonSquareMatrixError, which I for some reason have renamed 
> NonSquareMatrixException to.  So my questions are:
>
> 1. Should we have MatrixError, and if so, how should it be structured?
>
> 2. Should it be called NonSquareMatrixError or NonSquareMatrixException?  It 
> is raised in those cases where only a square matrix makes sense but a 
> non-square matrix was given (like Matrix.det()).
>
> The current structure of the exceptions is
>
> class NonSquareMatrixException(Exception):
>     pass
>
> class ShapeError(ValueError):
>     """Wrong matrix shape"""
>     pass
>
> class MatrixError(Exception):
>     pass
>
> but I think it should be more like
>
> class MatrixError(Exception):
>     """
>     If this is never raised directly, is it needed?
>     """
>     pass
>
> class ShapeError(ValueError, MatrixError):
>     """Wrong matrix shape"""
>     pass
>
> class NonSquareMatrixException(ShapeError):
>     pass


I would drop NonSquareMatrixException() completely, in my opinion this
is overkill. Maybe just replace it with something like

    raise ShapeError('square matrix expected, got %i x %i matrix')

MatrixError() makes sense when you want to catch matrix-related errors
only and ShapeError() is to specific.

But I wonder, in which case a "MatrixError" is not a "ShapeError"? If
there is none, MatrixError should be dropped too.


Vinzent

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to