David, Oscar,

Thank you for your help.

Oscar, the list 'u' was created in the course of a calculation, and saved as a .pkl file. I then reloaded it and want to manipulate the saved equations, of which u[7] is an example. I found an even cleaner example, see below.

I have the impression that when the .pkl file was reloaded, the identity of the object

Symbol('a', real=True, positive=True)

contained within u[3] was set to a memory address and when I created the object

Symbol('a', real=True, positive=True)

in the current session, that was left pointing to a *different* address. (See below.)

I can use "id(a)" to see what address the "current session variable a" is pointing to. Is there a simple way for me to understand what address a=Symbol('a',real=True,positive=True) in the u[3] object is pointing to? Presumably these are different, even though the two variables have the same name and the same properties.

If that behavior is correct, I may need some help to revise my mental model of how sympy/python works (:-).

Cheers,
        Bruce


>>> u[3]
2*a

>>> srepr(u[3])
"Mul(Integer(2), Symbol('a', real=True, positive=True))"

>>> x=2*a

>>> srepr(x)

"Mul(Integer(2), Symbol('a', real=True, positive=True))"

>>> x==u[3]
False




On 07.04.21 14:05, David Bailey wrote:
On 07/04/2021 12:28, Oscar Benjamin wrote:

In Bruce's example both symbols seem to have the same assumptions so
this shouldn't be the issue.


Oscar

I just checked and you can make two non-identical symbols that way:

Symbol('a')+Symbol('a',Positive=True)
a + a

I almost wonder if that should not flag an error.

David



--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/3dd26e3e-c827-5e29-c086-29accd4baf65%40googlemail.com.

Reply via email to