On 12/04/2021 06:53, 'Bruce Allen' via sympy wrote:
Hi David,

Thanks for picking this up.  I wanted to comment that in your example, the two symbols are defined differently:

Symbol("x", positive=True)
Symbol("x")

that is to say, with different assumptions. For the issue that I was reporting, the two symbols that were defined with identical assumptions, but were nevertheless being treated differently.

Well yes, my example was contrived, as I said. It mimicked what you encountered because of the pickling fault.

However, my feeling is that some proportion of SymPy users will work interactively - in one scope - without defining any Python functions. So they might calculate a polynomial without regard to any assumptions, and then wish to apply an assumption for one specific calculation and hit the problem you encountered.


I do agree that if it's possible for a user to declare two different symbols that have the same name (as the first argument of Symbol) but which are not the same, this is likely to lead to confusion. On the other hand, there must be a notion of the scope of a declaration.
I think all you need to do is redefine x using inconsistent assumptions. This can be done in the same scope - there is no analogy with C or Fortran, where you can't declare a variable twice in the same scope. Indeed, you can call Symbol as many times as you like - it doesn't define anything, it just sets up an instance of a class.

I would have thought that it would not be hard for the SymPy developers to provide a switch that could fault the situation where a symbol is redefined with the same name but different assumptions. I fully accept that this would be mostly useful for interactive work.

I feel that gotchas of this sort could cause some real disaster because it might be burried in a mass of algebra, and not be noticed before papers or theses had been written.

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/72cd5ae1-2637-2420-a6cd-e6bad2f817c5%40dbailey.co.uk.

Reply via email to