I seek a functionality in sympy that can provide descriptions to symbols when needed. This would be something along the lines of
>>> x = symbols(\'
You may inherit Symbol
class and add your own custom property like here:
from sympy import Symbol, simplify
# my custom class with description attribute
class MySymbol(Symbol):
def __new__(self, name, description=''):
obj = Symbol.__new__(self, name)
obj.description = description
return obj
# make new objects with description
x = MySymbol('x')
x.description = 'Distance (m)'
t = MySymbol('t', 'Time (s)')
print( x.description, t.description)
# test
expr = (x*t + 2*t)/t
print (simplify(expr))
Output:
Distance (m) Time (s)
x + 2