#9138: Categories for all rings
--------------------------+-------------------------------------------------
Reporter: jbandlow | Owner: nthiery
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.7
Component: categories | Keywords: introspection, categories for rings
Author: Simon King | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
--------------------------+-------------------------------------------------
Changes (by SimonKing):
* status: needs_work => needs_review
* work_issues: Improve Monsky-Washnitzer =>
Old description:
> Introspection is failing on polynomial rings:
> {{{
> sage: R.<x> = QQ[]
> sage: R.su<tab>
> R.sum R.summation
> R.summation_from_element_class_add
> sage: R.sum?
> Object `R.sum` not found.
> sage: R.sum()
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call
> last)
> }}}
>
> This is because polynomial rings do not yet set their category properly:
> {{{
> sage: QQ[x]._test_category()
> ------------------------------------------------------------
> Traceback (most recent call last):
> ...
> AssertionError: category of self improperly initialized
> }}}
>
> See http://groups.google.com/group/sage-
> devel/browse_thread/thread/4780192a11a8b591 for more discussion.
>
> Depends on #9944
New description:
Introspection is failing on polynomial rings:
{{{
sage: R.<x> = QQ[]
sage: R.su<tab>
R.sum R.summation
R.summation_from_element_class_add
sage: R.sum?
Object `R.sum` not found.
sage: R.sum()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
}}}
This is because polynomial rings do not yet set their category properly:
{{{
sage: QQ[x]._test_category()
------------------------------------------------------------
Traceback (most recent call last):
...
AssertionError: category of self improperly initialized
}}}
See http://groups.google.com/group/sage-
devel/browse_thread/thread/4780192a11a8b591 for more discussion.
Many other rings are not properly initialised as well. The aim of this
ticket is to change that.
Depends on #9944 #11115 #9976
--
Comment:
I just found that the problem with `modulus` is an excellent use case for
the improved cached methods provided by #11115!
Namely, instead of caching the modulus in a Python attribute `__modulus`
and have `self.modulus()` return `self.__modulus`, I define
`self.modulus()` as a cached method -- and that is a lot faster:
With the patches:
{{{
sage: B.<t> = PolynomialRing(Integers(125))
sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + B(1/4))
sage: P = R.poly_ring()
sage: timeit('P.modulus()',number=10^6)
1000000 loops, best of 3: 226 ns per loop
sage: x, T = R.gens()
sage: timeit('x*T')
625 loops, best of 3: 234 µs per loop
}}}
Without the patches (and without the quick cached methods):
{{{
sage: B.<t> = PolynomialRing(Integers(125))
sage: R = monsky_washnitzer.SpecialCubicQuotientRing(t^3 - t + B(1/4))
sage: P = R.poly_ring()
sage: timeit('P.modulus()',number=10^6)
1000000 loops, best of 3: 647 ns per loop
sage: x, T = R.gens()
sage: timeit('x*T')
625 loops, best of 3: 495 µs per loop
}}}
So, the slow-down turned into a speed-up. I don't know if the doc tests
will all pass, but I put it as "needs review".
Depends on #9944 #11115 #9976
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9138#comment:31>
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.