Hi

Sorry for replying to myself.

> In order to sanitize the behavior of objects, parents and elements in sage,
> I'm about to add some tests to the framework. I think they are all reasonable
> but I may be asking to much. Please comment about the following:
> 
>  1 - Any SageObject must have an equality methods such that
>       self == self and self != None
> 
>  2 - Element construction should be idempotent. More precisely, for any
>      element e within parent P, the equality P(e) == e must hold.
>      This is for example needed by the constructor of many Parent with a base
>      ring, such as matrices.
> 
>  3 - .zero() and .one() must never be mutable. I'd like to enforce this by
>      computing .__hash__(). Here I see two possibilities:
>         * decide that for any monoid M, if M.one() implement __hash__ it must
>           returns an int (not an Integer) and not raise an exception like in
>         sage: m = matrix([1]).__hash__()
>         ...
>         TypeError: mutable matrices are unhashable

The following sentence is ambiguous:
>         * decide that any element of a monoid must be hashable.
Please replace it by:

          * decide that element of any monoid must have a __hash__ method,
            which may raise an error for mutable element but never on .one()
            (and .zero() in a commutative monoid).

>      Do you think this is asking too much ?
> 
> By the way, if you have ideas of other basic sanity checks which must be added
> please tell me.

Cheers,

Florent

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to