DedalusProject / dedalus

A flexible framework for solving PDEs with modern spectral methods.
http://dedalus-project.org/
GNU General Public License v3.0
513 stars 121 forks source link

Operator printing #178

Open kburns opened 2 years ago

kburns commented 2 years ago

Currently any field or operator can have a name manually assigned via its name attribute. If this is not specified at operator instantiation, it will be created based on the name of the operator and operands. When the operator is evaluated, the resulting field inherits the same name. This is useful for keeping track of how operators are created, but can make it confusing to identify the structure of a complicated operation (e.g. what exactly are the operands) just from the string form.

One idea would be to introduce brackets, or some other notation to distinguish operators from the resulting operands. E.g.

>>> f = u + v
>>> print(f)
u + v
>>> g = 2 * f
>>> print(g)
2 * (u + v)
>>> g_eval = g.evaluate()
>>> print(g_eval)
[2 * (u + v)]

Other suggestions are welcome.