#11900: Serious regression caused by #9138
----------------------------------------------------------------------------------------+
Reporter: SimonKing
| Owner: tbd
Type: defect
| Status: needs_work
Priority: critical
| Milestone: sage-4.8
Component: performance
| Keywords: categories regression
Work_issues: Laurent series rings are fields. Add docs. Don't use is_ring and
friends | Upstream: N/A
Reviewer: Jeroen Demeyer, Nicolas M. ThiƩry
| Author: Simon King
Merged:
| Dependencies: #9138 #11911
----------------------------------------------------------------------------------------+
Comment(by SimonKing):
Most doctest errors are easy to fix. So, let us discuss the errors for
polynomial quotient rings.
I guess polynomial quotient rings are the reason why `is_field` and the
custom implementation of `sage.categories.fields.Fields.__contains__`
(which does call `is_field`) have originally been introduced: It is often
a waste of time to test ''during initialisation'' whether a polyonomial
quotient ring is a field or not.
By the way, `is_field` is currently not cached, but of course should be.
So, what shall we do? Perhaps this is one of the cases where we don't want
to fully initialise the category during `__init__`?
I would argue as follows:
* If we do `Q in Fields()` for a polynomial quotient ring Q, then
currently (that's to say: before my patch) `Q.is_field()` is called. In
other words: Currently, `Q in Fields()` does trigger a potentially
expensive computation, but that computation is not done during
initialisation.
* Our aim is to get rid of the custom `Fields.__contains__`. Since `Q in
Fields()` currently triggers a potentially expensive test, it should be OK
if this is also done in future.
* When using the default `Category_singleton.__contains__` for
`Fields()`, then `Q in Fields()` involves calling
`Q.category().parent_class`. Hence, `Q.category()` could be the right spot
for triggering the field test.
__Suggestion__
During `__init__`, a polynomial quotient ring should be initialised as an
object in the category of commutative algebras (not rings, as it is now).
Moreover, polynomial quotient rings should have a custom `category()`
method, different from the one inherited from `CategoryObject`.
If `Q.category()` is called, then it shall be tested whether Q is a field.
If it is, then the category initialisation is repeated with the correct
category.
__Implementation__
For that purpose I'd implement a new method (perhaps called
`_refine_category(self, category)`) for category objects:
`P._refine_category(C)` will change the original category into its join
with `C`.
After using this method, the custom `Q.category()` method would override
itself by the usual one. In other words, I imagine something like the
following for polynomial quotient rings:
{{{
#!python
import types
def category(self):
if self.is_field():
self._refine_category(Fields())
cat = CategoryObject.category(self)
self.category = types.MethodType(CategoryObject.category, self,
CategoryObject)
return cat
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11900#comment:117>
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.