Skip to content

Commit

Permalink
Update elements.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lyxal committed Sep 28, 2023
1 parent 5c2d6fd commit 2c3fd89
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions vyxal/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5884,9 +5884,7 @@ def round_to(lhs, rhs, ctx):
"""
ts = vy_type(lhs, rhs)
return {
(NUMBER_TYPE, NUMBER_TYPE): lambda: sympy.nsimplify(
round(lhs, rhs), rational=True
),
(NUMBER_TYPE, NUMBER_TYPE): lambda: sympy.Rational(str(lhs.round(rhs))),
(NUMBER_TYPE, str): lambda: -1,
(str, NUMBER_TYPE): lambda: -1,
(str, str): lambda: -1,
Expand Down Expand Up @@ -7454,15 +7452,15 @@ def vy_print(lhs, end="\n", ctx=None):
# Determine if the number is a imaginary sympy literal
if not lhs.is_real:
if ctx.print_decimals:
lhs = sympy.nsimplify(lhs)
lhs = sympy.S(lhs)
else:
lhs = (
str(lhs.as_real_imag()[0])
+ "°"
+ str(lhs.as_real_imag()[1])
)
else:
lhs = sympy.nsimplify(lhs.round(20), rational=True)
lhs = sympy.Rational(str(lhs.round(20)))
if ctx.online:
ctx.online_output[1] += vy_str(lhs, ctx=ctx) + end
else:
Expand Down Expand Up @@ -7569,7 +7567,7 @@ def vy_str(lhs, ctx=None):
"""
ts = vy_type(lhs)
return {
(NUMBER_TYPE): lambda: str(sympy.nsimplify(lhs, rational=True)),
(NUMBER_TYPE): lambda: str(sympy.sympify(lhs, rational=True)),
(str): lambda: lhs, # wow so complex and hard to understand /s
(types.FunctionType): lambda: vy_str(
safe_apply(lhs, *ctx.stacks[-1], ctx=ctx), ctx
Expand Down

0 comments on commit 2c3fd89

Please sign in to comment.