Skip to content

Commit 94d26c2

Browse files
authored
adding a test (#1158)
By now, just adding a test for #1156 to see what does the CI
1 parent 6495274 commit 94d26c2

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

mathics/eval/numbers/algebra/simplify.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ def _default_complexity_function(x):
8080
.to_python()
8181
)
8282

83-
# At this point, ``complexity_function`` is a function that takes a
84-
# sympy expression and returns an integer.
85-
sympy_result = simplify(sympy_expr, measure=complexity_function, doit=False)
86-
sympy_result = sympy_result.doit(roots=False) # Don't expand RootSum
87-
88-
# and bring it back
89-
result = from_sympy(sympy_result).evaluate(evaluation)
83+
try:
84+
# At this point, ``complexity_function`` is a function that takes a
85+
# sympy expression and returns an integer.
86+
sympy_result = simplify(sympy_expr, measure=complexity_function, doit=False)
87+
sympy_result = sympy_result.doit(roots=False) # Don't expand RootSum
88+
# and bring it back
89+
result = from_sympy(sympy_result).evaluate(evaluation)
90+
except ValueError:
91+
return expr
9092
return result

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
"requests",
2727
"scipy",
2828
"setuptools",
29-
"sympy>=1.11,<1.14",
29+
"sympy>=1.13,<1.14",
3030
]
3131
license = {text = "GPL"}
3232
name = "Mathics3"

test/builtin/numbers/test_linalg.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ def test_inverse(str_expr, str_expected, fail_msg, warnings):
211211
"SingularValueDecomposition[{1, {2}}]",
212212
None,
213213
),
214+
(
215+
"A = Array[a, {2,2}]; eigvals=Eigenvalues[A.ConjugateTranspose[A]][[1]]",
216+
None,
217+
(
218+
"-Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] "
219+
"+ a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 "
220+
"- 4 (a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]]) "
221+
"(a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) + 4 "
222+
"(a[1, 1] Conjugate[a[2, 1]] + a[1, 2] Conjugate[a[2, 2]]) "
223+
"(a[2, 1] Conjugate[a[1, 1]] + a[2, 2] Conjugate[a[1, 2]])] / 2 "
224+
"+ a[1, 1] Conjugate[a[1, 1]] / 2 + a[1, 2] Conjugate[a[1, 2]] / 2 "
225+
"+ a[2, 1] Conjugate[a[2, 1]] / 2 + a[2, 2] Conjugate[a[2, 2]] / 2"
226+
),
227+
None, # "Sympy issue #1156",
228+
),
229+
(
230+
"eigvals[[1]] // FullSimplify",
231+
None,
232+
(
233+
"-Sqrt[(a[1, 1] Conjugate[a[1, 1]] + a[1, 2] Conjugate[a[1, 2]] + "
234+
"a[2, 1] Conjugate[a[2, 1]] + a[2, 2] Conjugate[a[2, 2]]) ^ 2 - "
235+
"4 a[1, 1] a[2, 2] Conjugate[a[1, 1]] Conjugate[a[2, 2]] - "
236+
"4 a[1, 2] a[2, 1] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + "
237+
"4 a[1, 1] a[2, 2] Conjugate[a[1, 2]] Conjugate[a[2, 1]] + "
238+
"4 a[1, 2] a[2, 1] Conjugate[a[1, 1]] Conjugate[a[2, 2]]] / 2"
239+
),
240+
None, # "Sympy issue #1156",
241+
),
214242
],
215243
)
216244
def test_private_doctests_linalg(str_expr, msgs, str_expected, fail_msg):

0 commit comments

Comments
 (0)