#10963: More functorial constructions
-------------------------------------+-------------------------------------
Reporter: nthiery | Owner: stumpc5
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.1
Component: categories | Resolution:
Keywords: days54 | Merged in:
Authors: Nicolas M. Thiéry | Reviewers: Simon King, Frédéric
Report Upstream: N/A | Chapoton
Branch: | Work issues:
public/ticket/10963 | Commit:
Dependencies: #11224, #8327, | 8045aa4a4b7ada735b3eb6055382f9b341a39f1e
#10193, #12895, #14516, #14722, | Stopgaps:
#13589, #14471, #15069, #15094, |
#11688, #13394, #15150, #15506 |
-------------------------------------+-------------------------------------
Comment (by vbraun):
Replying to [comment:398 nbruin]:
> > {{{
> > sage: class Cs(Category):
> > ....: class Finite_or_any_other_name(axioms.Finite):
> > ....: class ParentMethods:
> > ....: def foo(self):
> > ....: print "I am a method on finite C's"
> > }}}
> There might be something to that, but if the `or_any_other_name` option
gets
> excercises, how would you tell efficiently whether `Cs` can have
`axioms.Finite`
> applied to it? See if there are any attributes that are subtypes of
> axioms.Finite?
Exactly, that would be the implementation. And that can easily be cached
in the unlikely case that it would ever be a speed problem to extract the
attributes that are subclasses of the base `Axiom` class. Also
* Independent axioms make them easier to implement since you don't need to
figure out the most basic category that can carry the axiom. I.e. you
don't need a global understanding of the existing categories. You never
have to "move it up the category hierarchy" either.
* It gives you additional freedom to only implement methods when certain
combinations of axioms are applied (for breverity as decorator, same
argument applies to contained-class syntax):
{{{
@require_axiom(Foo)
def foo() [...]
@require_axiom(Bar)
def bar() [...]
@require_axiom(Foo, Bar)
def baz() [...]
}}}
* You don't have to decide who owns a particular adjective. E.g. "Rigid"
for differential operators is not the "Rigid" in the category theory
sense, at least I don't think so. (Exercise: Find your own rarely-
used/obscure adjective with conflicting meanings).
* Its actually a pretty minimal change of the existing code, the only
thing that really changes is that we look for attributes that are tagged
by being subclasses of the axiom class (i.e. in code) instead of having a
blessed adjective as name.
> There is precedency in Python for "magic" attribute names. For instance,
an
> object gets a length by implementing a `__len__` method on it.
True, and it is really unfair that if Guido van Rossum blesses a name with
magical properties then that is automatically good Python and people
explain it in every book about Python. Whereas if one of us declares a
name special then it is bad practice and no Python book in the world gives
a hoot about it.
--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:402>
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/groups/opt_out.