#8800: Doctest coverage of categories
--------------------------+-------------------------------------------------
Reporter: SimonKing | Owner: Simon King
Type: defect | Status: new
Priority: major | Milestone: sage-4.4.1
Component: categories | Keywords: categories doctests
Author: Simon King | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
--------------------------+-------------------------------------------------
Comment(by SimonKing):
I think the call method of the class Functor is not cleanly implemented.
It seems intended that the user does not implement the call method.
Instead s/he should implement _apply_functor, which is supposed to return
an object in the functor's codomain.
Before using _apply_functor, the default call method tests whether the
argument belongs to the domain. If this is not the case, it '''coerces'''
the argument into the domain. I don't think that this is always wanted.
E.g., the forgetful functor from fields to rings, when applied to the
integer ring, currently returns the rational field (so, the forgetful
functor ''adds'' structure), since the default call method first coerces
the integer ring into the category of fields (which is done by the
fraction field construction functor).
I suggest to introduce a method _coerce_into_domain. By default, it
returns its argument without change. If the user wants coercion into the
domain (e.g. Integer Ring --> Rational Field), then s/he must implement it
here.
The default call method should first apply _coerce_into_domain, check
whether the result is in the domain (raise an error if this is not the
case), then use _apply_functor, and check whether the result is in the
codomain (and raise an error otherwise). And of course it should return
the result (which was forgotten!).
Thoughts?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8800#comment:5>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.