Replies: 3 comments 4 replies
-
There is an But I wouldn't call this As a prototype, this works. But keep in mind that in the long term this increases pressure on an existing problem that we do too many conversions into and out of Sympy. In cases where we are slow, not saving the intermediate Sympy form which causes recalculation of the same SymPy expression (possibly different values bound to symbols, but from SymPy's standpoint the SymPy expression with respect to symbols is the same). |
Beta Was this translation helpful? Give feedback.
-
Filling in more detail above. I made this patch: --- a/mathics/builtin/arithmetic.py
+++ b/mathics/builtin/arithmetic.py
@@ -103,6 +103,8 @@ class _MPMathFunction(SympyFunction):
# if no arguments are inexact attempt to use sympy
if all(not x.is_inexact() for x in args):
result = Expression(self.get_name(), *args).to_sympy()
+ from sympy import pprint
+ pprint(result)
result = self.prepare_mathics(result)
result = from_sympy(result)
# evaluate leaves to convert e.g. Plus[2, I] -> Complex[2, 1] And then ran mathics:
I should note that to change the symbols back into their simple form, e.g. z instead of The above points out the kind of thing I alluded to earlier in that we have this sympy object |
Beta Was this translation helpful? Give feedback.
-
Let me also say that this discussion I understood it to be about using SymPy's pprint to handle Then all of a sudden we are into talking about MakeBox.
I would maintain the tricky part is to focus on conceptually simple solutions that are clean, general, easy to implement but also leaves room for scaling to more complex situations. We aren't going to solve the general 2D situation on terminals or the general Boxing problems any time soon. Sheesh, we haven't been even able to isolate all of the leaf elements/objects properly and that's a prerequisite for being able to handle Boxing. |
Beta Was this translation helpful? Give feedback.
-
In WMA,
OutputForm
produces a "2D" text representation of the expression. I guess that this could be accomplished by using the low-level interface of pretty-print in Sympy. The tricky part here would be to convert a box structure into something that pretty print can handle...Beta Was this translation helpful? Give feedback.
All reactions