>> Any ideas of why _repr_ might not be working inside the class?
> Was this class that of the category or the parent?

I made a copy of AlgebrasWithBasis.py (so that's the category isnt it?)
and placed my version of _repr_ is various places within that code but
it didnt override the  default _repr_

> If you do (with x some of your elements):
>        sage: x.__class__.mro()
> you will see that the category classes appear quite late there, and in
> particular after Parent. Hence, it is (currently) not possible to
> override _repr_, or anything else implemented in Parent, by code in 
> categories.

I called mro on an element P, as suggested...

(P,Q,R)= MtxAlgebrasWithBasis(QQ).example(('P','Q','R')).algebra_generators()
P.__class__.mro()

Does the output (at the end of this reply) mean: _repr_ cant be
overridden somehere as you stated above?
(It would be a huge shame. I checked with support from both commercial
players (Mma & Mple) and both said
they dont support this but have been asked for it multiple times. I
understand its been asked by our users also.
And now that I need it, Im highly motivated to implement it :-)
As a last resort - just to get some of my work progressing for now -
Im happy to copy and customize enough
existing categories code to make matrices work it but if I can do this
properly it could end up in the sage code base for others to use.
Question is is: it possible to implement this "properly"?

All that is needed, to make a basic prototype matrix algebra, is

Distributivity == P(Q+R) => PQ + QR (already working thanks to
existing categories code)
Non-commutivity PQ does not equal QR (also is working)
Printing i.e. show "P Q + Q R" rather than "B[word: PQ] + B[word: PR]"
(by overloading _repr_ or by some other means?)
Substitution i.e. P^-1 * P results in identity  - And - (P *
Q).Transpose() results in Q.Transpose() + P.Transpose()

So two tasks done - two to go if possible! Keen to hear your thoughts
when you have time

cheers and thanks

[<class
'sage.combinat.free_module.FreeAlgebra_with_category.element_class'>,
<class
'sage.combinat.free_module.CombinatorialFreeModuleElement'>, <type
'sage.structure.element.Element'>, <type
'sage.structure.sage_object.SageObject'>, <class
'sage.categories.algebras_with_basis.AlgebrasWithBasis.element_class'>\
;, <class
'sage.categories.modules_with_basis.ModulesWithBasis.element_class'>,
<class
sage.categories.tensor.CategoryWithTensorProduct.ElementMethods at
0xaba7bfc>, <class
sage.categories.cartesian_product.CategoryWithCartesianProduct.ElementMe\
thods at 0xaba7d7c>, <class
'sage.categories.vector_spaces.VectorSpaces.element_class'>,
<class 'sage.categories.algebras.Algebras.element_class'>,
<class 'sage.categories.rings.Rings.element_class'>, <class
'sage.categories.rngs.Rngs.element_class'>, <class
'sage.categories.modules.Modules.element_class'>, <class
'sage.categories.bimodules.Bimodules.element_class'>, <class
'sage.categories.left_modules.LeftModules.element_class'>, <class
'sage.categories.right_modules.RightModules.element_class'>,
<class
'sage.categories.commutative_additive_groups.CommutativeAdditiveGroups.e\
lement_class'>, <class
'sage.categories.commutative_additive_monoids.CommutativeAdditiveMonoids\
.element_class'>, <class
'sage.categories.commutative_additive_semigroups.CommutativeAdditiveSemi\
groups.element_class'>, <class
'sage.categories.monoids.Monoids.element_class'>, <class
'sage.categories.semigroups.Semigroups.element_class'>, <class
'sage.categories.sets_cat.Sets.element_class'>, <class
'sage.categories.objects.Objects.element_class'>, <type
'object'>]

-- 
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