Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using subs() with tuples doesn't work when called as a method #460

Open
DonSheddow opened this issue Apr 9, 2022 · 1 comment
Open

Using subs() with tuples doesn't work when called as a method #460

DonSheddow opened this issue Apr 9, 2022 · 1 comment

Comments

@DonSheddow
Copy link

@syms x, y, z
ex = x + y + z
ex.subs((x, 1), (y, pi))

should return 1 + pi + z, but it returns x + y + z. Similarly, ex.subs((x, 1)) throws an error.

If you write subs(ex, (x, 1), (y, pi)) instead, it works as expected. I think the method call doesn't dispatch to the correct implementation, so the only method call that works is ex.subs(var, replacement), but I'm not that familiar with Julia, so I'm not sure.

If it's not possible to fix this, the documentation at https://docs.juliahub.com/SymPy/KzewI/1.1.4/introduction/#Substitution-1 should be changed to use the subs(ex, (x, 1), (y, pi)) style instead, and maybe add a note that the method-call syntax doesn't work with tuples.

Thanks for working on this library, it's awesome! :)

@jverzani
Copy link
Collaborator

jverzani commented Apr 9, 2022

Thanks, that is a documentation error. The underlying sympy call would need to be

ex.subs([(x, 1), (y, PI)])

(the tuples are in some container and not just part of the variadic arguments. The subs(ex, ...) is a julia interface which makes this a bit more natural (in my opinion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants