#7315: Can only forget one GenericDeclaration at a time for some reason
------------------------+---------------------------------------------------
Reporter: kcrisman | Owner: burcin
Type: defect | Status: new
Priority: major | Milestone: sage-4.2.1
Component: calculus | Keywords:
Work_issues: | Author:
Reviewer: | Merged:
------------------------+---------------------------------------------------
Old description:
> From [ this thread]:
> {{{
> sage: var('m')
> m
> sage: var('n')
> n
> sage: assume(n, 'integer'); assume(m, 'integer')
> sage: sin(n*pi).simplify()
> 0
> sage: sin(m*pi).simplify()
> 0
> sage: forget()
> sage: sin(m*pi).simplify()
> 0
> sage: sin(n*pi).simplify()
> sin(pi*n)
> }}}
> The problem seems to lie in the last few lines of _forget_all in
> sage.symbolic.assumptions.py, where for some reason the loop isn't doing
> what it should.
New description:
From [http://groups.google.com/group/sage-
devel/browse_thread/thread/862e9bfd7c6c999e# this thread]:
{{{
sage: var('m')
m
sage: var('n')
n
sage: assume(n, 'integer'); assume(m, 'integer')
sage: sin(n*pi).simplify()
0
sage: sin(m*pi).simplify()
0
sage: forget()
sage: sin(m*pi).simplify()
0
sage: sin(n*pi).simplify()
sin(pi*n)
}}}
The problem seems to lie in the last few lines of _forget_all in
sage.symbolic.assumptions.py, where for some reason the loop isn't doing
what it should.
--
Comment(by kcrisman):
The problem is actually because list removal is called in
GenericDeclaration.forget(), so this is about behavior of list iteration
in Python when you remove elements:
{{{
>>> L=[1,2,3,4]
>>> for x in L:
... L.remove(x)
... x
... L
...
1
[2, 3, 4]
3
[2, 4]
}}}
So this piece of code is apparently using the wrong/un-Pythonic way of
removing items from a list.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7315#comment:2>
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
-~----------~----~----~----~------~----~------~--~---