Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-06 Thread David Roe
You can't inherit from both dense and sparse, but you can probably create a PoolingMatrix class that doesn't inherit from either then a PoolingMatrix_dense and PoolingMatrix_sparse that inherit from both the relevant matrix class and your generic PoolingMatrix class. David On Thu, Jun 6, 2013 at

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-06 Thread Rob
But there's always another problem right? I need to prepare to use some pretty big matrices, so I'd like to make Pooling_Matrix be a subclass of either - sage.matrix.matrix_integer_dense.Matrix_integer_dense, if the call is through Pooling_Matrix(parent, entries, copy, coerce) where p

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread Rob
Thanks David, I am getting the following to work. def make_pool(data): rows = len(data) cols = len(data[0]) parent_arg = parent(matrix(ZZ, data)) return Pool(parent_arg, flatten(data), False, False) class Pool(sage.matrix.matrix_integer_dense.Matrix_integer_dense): def __init_

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread David Roe
The issue is that Matrix_integer_dense has a __cinit__ method, which means that all subclasses must conform to the same inputs for their __init__ methods. So you need to do def __init__(self, parent, entries, coerce, copy): sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init_

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread Rob
Here is a kluge that is closer to what I want. Can be copied into and run in a Sage cell. The deficiency in the construction is on lines 6-8 (within commented section). class PoolingMatrix(sage.matrix.matrix_integer_dense.Matrix_integer_dense): # Example construction: #a = matrix(Z

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread Rob
Thanks for the responses. Probably the answer is I don't know what __init__ method to call within the inheriting __init__ method. Maybe I'd like to say: class PoolingMatrix(parent_class): def __init__(self, ring_arg, 2D_list_arg): parent_class.__init__(self, ring_arg, 2D_list_arg)

Re: [sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread David Roe
Are you calling some_matrix_thingy.__init__ inside your __init__ method? David On Tue, Jun 4, 2013 at 8:10 PM, 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

[sage-devel] inheriting from a matrix class, adding attributes

2013-06-05 Thread Rob
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 Tru