diff --git a/CHANGES.rst b/CHANGES.rst index f0825b123..057e6594b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,17 @@ CHANGES ======= +New Builtins +++++++++++++ + +* ``SetEnvironment`` + +Compatibility +------------- + +* ``GetEnvironment`` expanded to handle ``[]`` and ``{var1, var2,...}`` forms + + 7.0.0 ----- diff --git a/mathics/builtin/numbers/algebra.py b/mathics/builtin/numbers/algebra.py index 0d1b7d741..1a6df8541 100644 --- a/mathics/builtin/numbers/algebra.py +++ b/mathics/builtin/numbers/algebra.py @@ -231,9 +231,11 @@ def unconvert_subexprs(expr): elements = sub_expr.elements if target_pat: elements = [ - element - if element.is_free(target_pat, evaluation) - else _expand(element) + ( + element + if element.is_free(target_pat, evaluation) + else _expand(element) + ) for element in elements ] else: @@ -248,9 +250,11 @@ def unconvert_subexprs(expr): elements = sub_expr.elements if target_pat: elements = [ - element - if element.is_free(target_pat, evaluation) - else _expand(element) + ( + element + if element.is_free(target_pat, evaluation) + else _expand(element) + ) for element in elements ] else: @@ -335,9 +339,11 @@ def get_exponents_sorted(expr, var) -> list: # find exponent of terms multiplied with functions: sin, cos, log, exp, ... # e.g: x^3 * Sin[x^2] should give 3 muls = [ - term.as_coeff_mul(x)[1] - if term.as_coeff_mul(x)[1] - else (sympy.Integer(0),) + ( + term.as_coeff_mul(x)[1] + if term.as_coeff_mul(x)[1] + else (sympy.Integer(0),) + ) for term in coeff.as_ordered_terms() ] expos = [term.as_coeff_exponent(x)[1] for mul in muls for term in mul] diff --git a/mathics/builtin/numbers/numbertheory.py b/mathics/builtin/numbers/numbertheory.py index f718af00a..b227a77cf 100644 --- a/mathics/builtin/numbers/numbertheory.py +++ b/mathics/builtin/numbers/numbertheory.py @@ -508,7 +508,7 @@ class PartitionsP(SympyFunction): ) def eval(self, n, evaluation: Evaluation): - "PartitionsP[n_Integer]" + """PartitionsP[n_Integer]""" return super().eval(n, evaluation) diff --git a/mathics/core/convert/sympy.py b/mathics/core/convert/sympy.py index be34c247e..27cb5253c 100644 --- a/mathics/core/convert/sympy.py +++ b/mathics/core/convert/sympy.py @@ -8,9 +8,7 @@ import sympy from sympy import Symbol as Sympy_Symbol, false as SympyFalse, true as SympyTrue - -# Import the singleton class -from sympy.core.numbers import S +from sympy.core.singleton import S from mathics.core.atoms import ( MATHICS3_COMPLEX_I, diff --git a/mathics/core/symbols.py b/mathics/core/symbols.py index 1be4ce772..3aa20adb5 100644 --- a/mathics/core/symbols.py +++ b/mathics/core/symbols.py @@ -14,7 +14,11 @@ # I put this constants here instead of inside `mathics.core.convert.sympy` # to avoid a circular reference. Maybe they should be in its own module. -sympy_symbol_prefix = "_Mathics_User_" +# Prefix used for Sympy variables. +# We wan t this to be short to keep variable names short. +# In tracing values, long names make output messy. +sympy_symbol_prefix = "_m_" + sympy_slot_prefix = "_Mathics_Slot_" diff --git a/test/core/test_sympy_python_convert.py b/test/core/test_sympy_python_convert.py index a6f4668e3..0c7f4778e 100644 --- a/test/core/test_sympy_python_convert.py +++ b/test/core/test_sympy_python_convert.py @@ -42,10 +42,10 @@ def compare(self, mathics_expr, sympy_expr, **kwargs): self.compare_to_mathics(mathics_expr, sympy_expr) def testSymbol(self): - self.compare(Symbol("Global`x"), sympy.Symbol("_Mathics_User_Global`x")) + self.compare(Symbol("Global`x"), sympy.Symbol("_mg`x")) self.compare( - Symbol("_Mathics_User_x"), - sympy.Symbol("_Mathics_User_System`_Mathics_User_x"), + Symbol("_mu_x"), + sympy.Symbol("_mu`x"), ) def testReal(self):