#7921: Categories for extension types via __getattr___
-------------------------------------+---------------------------------
Reporter: nthiery | Owner: nthiery
Type: enhancement | Status: closed
Priority: major | Milestone: sage-4.3.2
Component: categories | Resolution: fixed
Keywords: | Merged in: sage-4.3.2.alpha0
Authors: Nicolas M. ThiƩry | Reviewers: Robert Bradshaw
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------------+---------------------------------
Comment (by saraedum):
I have a question regarding this old ticket. The following fails:
{{{
sage: a = ModularForms(11,4).an_element()
sage: a._test_category()
}}}
The reason for this is that `a` is not an extension class so
`_test_category` expects that the type of a inherits from
`a.parent().category().element_class`. Now if I try to do such inheritance
{{{
class HeckeModuleElement(sage.modules.module_element.ModuleElement,
HeckeModules.element_class):
}}}
I get a
{{{
metaclass conflict: the metaclass of a derived class must be a (non-
strict) subclass of the metaclasses of all its base
}}}
Anyway, I'm getting the feeling that such inheritance does not happen
anywhere (partly because most element classes are extension classes). The
methods from the element_class are available anyway (just like for
extension classes). So is it safe to remove this check from
`_test_category`? I.e. should we change
{{{
if not is_extension_type(self.__class__):
# For usual Python classes, that should be done with
# standard inheritance
tester.assert_(isinstance(self,
self.parent().category().element_class))
else:
# For extension types we just check that inheritance
# occurs on a dummy attribute of Sets().ElementMethods
tester.assert_(hasattr(self, "_dummy_attribute"))
}}}
into
{{{
tester.assert_(hasattr(self, "_dummy_attribute"))
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/7921#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.