Hey Rob,
    Here's a patch where I made CartanMatrix inherit from regular matrices: 
http://trac.sagemath.org/sage_trac/ticket/14137. Although it is slightly 
bad as there is not a proper parent, but here's the short version:

    __metaclass__ = ClasscallMetaclass

    @staticmethod
    def __classcall_private__(cls, *args, **kwds):
        """
        Normalize input so we can inherit from spare integer matrix.

        .. NOTE::

            To disable the Cartan type check, use the optional argument
            ``cartan_type_check = False``.

        EXAMPLES::

            sage: C = CartanMatrix(['A',1,1])
            sage: C2 = CartanMatrix([[2, -2], [-2, 2]])
            sage: C3 = CartanMatrix(matrix([[2, -2], [-2, 2]]), [0, 1])
            sage: C == C2 and C == C3
            True
        """
        # Some processing to get the variables I need
        mat = typecall(cls, MatrixSpace(ZZ, n, sparse=True), data,cartan_type
, index_set)
        mat._subdivisions = subdivisions
        return mat

    def __init__(self, parent, data, cartan_type, index_set):
        """
        Initialize ``self``.

        TESTS::

            sage: C = CartanMatrix(['A',1,1])

        We skip the category test since it doesn't have its own parent, in 
this context
        because we have a fixed ring, the change ring test doesn't make 
sense.

            sage: TestSuite(C).run(skip=["_test_category", "
_test_change_ring"])
        """
        Matrix_integer_sparse.__init__(self, parent, data, False, False)
        self._cartan_type = cartan_type
        self._index_set = index_set
        self.set_immutable()

I forget if the the change ring test worked...

Hope that helps.

Best,
Travis


On Tuesday, June 4, 2013 5:10:35 PM UTC-7, Rob wrote:
>
> I am trying to make a class PoolingMatrix, which needs to be an 
> (binary) integer matrix with extra attributes and functions.  For 
> example, I'd like to say: 
>
> sage: m = PoolingMatrix(ZZ, [[1,0,0],[0,1,0],[0,0,1]]) 
> sage: m.nrows() 
> 2 
> sage: m.is_disjunct(2)    # the 3x3 identity matrix is 2-disjunct 
> True 
>
> But the init specification for PoolingMatrix is tripping me up.  Can 
> anyone provide a suggestion? 
>
> I'm trying something like: 
> class PoolingMatrix(some_matrix_thingy): 
>     def __init__(self, input_ring, input_array): 
> ... 
>
> Thanks for any assistance 
> -Rob 
>

-- 
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 post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to