In situations where it is natural to generate dummy symbols with Symbol.as_dummy(), the reverse process may also be useful.
Uncommented two tests for this. --- sympy/core/symbol.py | 11 +++++++++++ sympy/core/tests/test_symbol.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sympy/core/symbol.py b/sympy/core/symbol.py index e405fbb..641bba8 100644 --- a/sympy/core/symbol.py +++ b/sympy/core/symbol.py @@ -104,6 +104,17 @@ def __new__(cls, name, commutative=True, **assumptions): obj.dummy_index = Dummy.dummycount return obj + def as_nondummy(self): + """ + Returns the corresponding non-dummy symbol + + >>> from sympy import Symbol + >>> x1 = Symbol('x', dummy = True) + >>> x1.as_nondummy() == Symbol('x') + True + """ + return Symbol(self.name, self.is_commutative, **self.assumptions0) + def _hashable_content(self): return Symbol._hashable_content(self) + (self.dummy_index,) diff --git a/sympy/core/tests/test_symbol.py b/sympy/core/tests/test_symbol.py index 5fb82ff..f0e8b6e 100644 --- a/sympy/core/tests/test_symbol.py +++ b/sympy/core/tests/test_symbol.py @@ -23,13 +23,13 @@ def test_as_dummy_nondummy(): x1 = x.as_dummy() assert x1 != x assert x1 != x.as_dummy() - # assert x == x1.as_nondummy() + assert x == x1.as_nondummy() x = Symbol('x', commutative = False) x1 = x.as_dummy() assert x1 != x assert x1.is_commutative == False - # assert x == x1.as_nondummy() + assert x == x1.as_nondummy() def test_lt_gt(): x, y = Symbol('x'), Symbol('y') -- 1.6.5 -- You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patc...@googlegroups.com. To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en.