#9652: Unnecesary and buggy code in arith.py
------------------------+---------------------------------------------------
Reporter: mderickx | Owner: AlexGhitza
Type: defect | Status: needs_review
Priority: minor | Milestone:
Component: algebra | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------+---------------------------------------------------
Comment(by mderickx):
The code is indeed for python integers, and produces the right output in
that case as the following shows.
{{{
sage: a=344r
sage: type(a)
<type 'int'>
sage: hasattr(a,"valuation")
False
sage: valuation(a,2)
3
}}}
I agree with you that that code should not be excecuted on general ring
elements.
It crashes on local elements of the symbolic ring for example.
{{{
sage: var("z")
z
sage: valuation(z^2,z)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/Applications/sage/devel/sage-mderickx/<ipython console> in <module>()
/Applications/sage/local/lib/python2.6/site-packages/sage/rings/arith.pyc
in valuation(m, p)
604 r = 0
605 power = p
--> 606 while not (m % power): # m % power == 0
607 r += 1
608 power *= p
TypeError: unsupported operand type(s) for %:
'sage.symbolic.expression.Expression' and
'sage.symbolic.expression.Expression'
}}}
.
In your remark 2. The code could also crash, for example try (1/2) % 2.
I tried to find some real examples in sage, but I can't seem to find how
to localize rings in sage. Maybe it's not implemented yet. The only thing
I could find is:
http://www.sagemath.org/doc/reference/coercion.html#example.
My failing quest to find other examples than python integers lead me to
believe that this code should indeed only be excecuted on python integers.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9652#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.