symengine 0.14.0__cp313-cp313t-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- symengine/lib/flint-19.dll +0 -0
- symengine/lib/libgcc_s_seh-1.dll +0 -0
- symengine/lib/libgmp-10.dll +0 -0
- symengine/lib/libmpc-3.dll +0 -0
- symengine/lib/libmpfr-6.dll +0 -0
- symengine/lib/libwinpthread-1.dll +0 -0
- symengine/lib/pywrapper.h +220 -0
- symengine/lib/symengine.pxd +955 -0
- symengine/lib/symengine_wrapper.cp313t-win_amd64.lib +0 -0
- symengine/lib/symengine_wrapper.cp313t-win_amd64.pyd +0 -0
- symengine/lib/symengine_wrapper.pxd +78 -0
- symengine/lib/zlib.dll +0 -0
- symengine/lib/zstd.dll +0 -0
- symengine-0.14.0.data/purelib/symengine/__init__.py +79 -0
- symengine-0.14.0.data/purelib/symengine/functions.py +10 -0
- symengine-0.14.0.data/purelib/symengine/lib/__init__.py +0 -0
- symengine-0.14.0.data/purelib/symengine/printing.py +33 -0
- symengine-0.14.0.data/purelib/symengine/sympy_compat.py +4 -0
- symengine-0.14.0.data/purelib/symengine/test_utilities.py +95 -0
- symengine-0.14.0.data/purelib/symengine/tests/__init__.py +0 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_arit.py +261 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_cse.py +17 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_dict_basic.py +28 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_eval.py +67 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_expr.py +28 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_functions.py +432 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_lambdify.py +863 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_logic.py +124 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_matrices.py +757 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_ntheory.py +254 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_number.py +186 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_pickling.py +59 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_printing.py +38 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_sage.py +175 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_series_expansion.py +22 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_sets.py +118 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_solve.py +25 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_subs.py +82 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_symbol.py +179 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_sympify.py +63 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_sympy_compat.py +200 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_sympy_conv.py +835 -0
- symengine-0.14.0.data/purelib/symengine/tests/test_var.py +68 -0
- symengine-0.14.0.data/purelib/symengine/utilities.py +280 -0
- symengine-0.14.0.dist-info/AUTHORS +40 -0
- symengine-0.14.0.dist-info/LICENSE +430 -0
- symengine-0.14.0.dist-info/METADATA +39 -0
- symengine-0.14.0.dist-info/RECORD +50 -0
- symengine-0.14.0.dist-info/WHEEL +5 -0
- symengine-0.14.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,835 @@
|
|
1
|
+
from symengine import (Symbol, Integer, sympify, SympifyError, log,
|
2
|
+
function_symbol, I, E, pi, oo, zoo, nan, true, false,
|
3
|
+
exp, gamma, have_mpfr, have_mpc, DenseMatrix, sin, cos, tan, cot,
|
4
|
+
csc, sec, asin, acos, atan, acot, acsc, asec, sinh, cosh, tanh, coth,
|
5
|
+
asinh, acosh, atanh, acoth, atan2, Add, Mul, Pow, diff, GoldenRatio,
|
6
|
+
Catalan, EulerGamma, UnevaluatedExpr, RealDouble)
|
7
|
+
from symengine.lib.symengine_wrapper import (Subs, Derivative, RealMPFR,
|
8
|
+
ComplexMPC, PyNumber, Function, LambertW, zeta, dirichlet_eta,
|
9
|
+
KroneckerDelta, LeviCivita, erf, erfc, lowergamma, uppergamma,
|
10
|
+
loggamma, beta, polygamma, sign, floor, ceiling, conjugate, And,
|
11
|
+
Or, Not, Xor, Piecewise, Interval, EmptySet, FiniteSet, Contains,
|
12
|
+
Union, Complement, UniversalSet, Reals, Rationals, Integers)
|
13
|
+
import unittest
|
14
|
+
|
15
|
+
# Note: We test _sympy_() for SymEngine -> SymPy conversion, as those are
|
16
|
+
# methods that are implemented in this library. Users can simply use
|
17
|
+
# sympy.sympify(...). To do this conversion, as this function will call
|
18
|
+
# our _sympy_() methods under the hood.
|
19
|
+
#
|
20
|
+
# For SymPy -> SymEngine, we test symengine.sympify(...) which
|
21
|
+
# does the conversion.
|
22
|
+
|
23
|
+
try:
|
24
|
+
import sympy
|
25
|
+
from sympy.core.cache import clear_cache
|
26
|
+
import atexit
|
27
|
+
atexit.register(clear_cache)
|
28
|
+
have_sympy = True
|
29
|
+
except ImportError:
|
30
|
+
have_sympy = False
|
31
|
+
|
32
|
+
|
33
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
34
|
+
def test_conv1():
|
35
|
+
x = Symbol("x")
|
36
|
+
assert x._sympy_() == sympy.Symbol("x")
|
37
|
+
assert x._sympy_() != sympy.Symbol("y")
|
38
|
+
x = Symbol("y")
|
39
|
+
assert x._sympy_() != sympy.Symbol("x")
|
40
|
+
assert x._sympy_() == sympy.Symbol("y")
|
41
|
+
|
42
|
+
|
43
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
44
|
+
def test_conv1b():
|
45
|
+
x = sympy.Symbol("x")
|
46
|
+
assert sympify(x) == Symbol("x")
|
47
|
+
assert sympify(x) != Symbol("y")
|
48
|
+
x = sympy.Symbol("y")
|
49
|
+
assert sympify(x) != Symbol("x")
|
50
|
+
assert sympify(x) == Symbol("y")
|
51
|
+
|
52
|
+
|
53
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
54
|
+
def test_conv2():
|
55
|
+
x = Symbol("x")
|
56
|
+
y = Symbol("y")
|
57
|
+
z = Symbol("z")
|
58
|
+
e = x*y
|
59
|
+
assert e._sympy_() == sympy.Symbol("x")*sympy.Symbol("y")
|
60
|
+
e = x*y*z
|
61
|
+
assert e._sympy_() == sympy.Symbol("x")*sympy.Symbol("y")*sympy.Symbol("z")
|
62
|
+
|
63
|
+
|
64
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
65
|
+
def test_conv2b():
|
66
|
+
x = sympy.Symbol("x")
|
67
|
+
y = sympy.Symbol("y")
|
68
|
+
z = sympy.Symbol("z")
|
69
|
+
e = x*y
|
70
|
+
assert sympify(e) == Symbol("x")*Symbol("y")
|
71
|
+
e = x*y*z
|
72
|
+
assert sympify(e) == Symbol("x")*Symbol("y")*Symbol("z")
|
73
|
+
|
74
|
+
|
75
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
76
|
+
def test_conv3():
|
77
|
+
x = Symbol("x")
|
78
|
+
y = Symbol("y")
|
79
|
+
z = Symbol("z")
|
80
|
+
e = x+y
|
81
|
+
assert e._sympy_() == sympy.Symbol("x")+sympy.Symbol("y")
|
82
|
+
e = x+y+z
|
83
|
+
assert e._sympy_() == sympy.Symbol("x")+sympy.Symbol("y")+sympy.Symbol("z")
|
84
|
+
|
85
|
+
|
86
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
87
|
+
def test_conv3b():
|
88
|
+
x = sympy.Symbol("x")
|
89
|
+
y = sympy.Symbol("y")
|
90
|
+
z = sympy.Symbol("z")
|
91
|
+
e = x+y
|
92
|
+
assert sympify(e) == Symbol("x")+Symbol("y")
|
93
|
+
e = x+y+z
|
94
|
+
assert sympify(e) == Symbol("x")+Symbol("y")+Symbol("z")
|
95
|
+
|
96
|
+
|
97
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
98
|
+
def test_conv4():
|
99
|
+
x = Symbol("x")
|
100
|
+
y = Symbol("y")
|
101
|
+
z = Symbol("z")
|
102
|
+
e = x**y
|
103
|
+
assert e._sympy_() == sympy.Symbol("x")**sympy.Symbol("y")
|
104
|
+
e = (x+y)**z
|
105
|
+
assert (e._sympy_() ==
|
106
|
+
(sympy.Symbol("x")+sympy.Symbol("y"))**sympy.Symbol("z"))
|
107
|
+
|
108
|
+
|
109
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
110
|
+
def test_conv4b():
|
111
|
+
x = sympy.Symbol("x")
|
112
|
+
y = sympy.Symbol("y")
|
113
|
+
z = sympy.Symbol("z")
|
114
|
+
e = x**y
|
115
|
+
assert sympify(e) == Symbol("x")**Symbol("y")
|
116
|
+
e = (x+y)**z
|
117
|
+
assert sympify(e) == (Symbol("x")+Symbol("y"))**Symbol("z")
|
118
|
+
|
119
|
+
|
120
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
121
|
+
def test_conv5():
|
122
|
+
x = Integer(5)
|
123
|
+
y = Integer(6)
|
124
|
+
assert x._sympy_() == sympy.Integer(5)
|
125
|
+
assert (x/y)._sympy_() == sympy.Integer(5) / sympy.Integer(6)
|
126
|
+
|
127
|
+
|
128
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
129
|
+
def test_conv5b():
|
130
|
+
x = sympy.Integer(5)
|
131
|
+
y = sympy.Integer(6)
|
132
|
+
assert sympify(x) == Integer(5)
|
133
|
+
assert sympify(x/y) == Integer(5) / Integer(6)
|
134
|
+
|
135
|
+
|
136
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
137
|
+
def test_conv6():
|
138
|
+
x = Symbol("x")
|
139
|
+
y = Symbol("y")
|
140
|
+
assert (x/3)._sympy_() == sympy.Symbol("x") / 3
|
141
|
+
assert (3*x)._sympy_() == 3*sympy.Symbol("x")
|
142
|
+
assert (3+x)._sympy_() == 3+sympy.Symbol("x")
|
143
|
+
assert (3-x)._sympy_() == 3-sympy.Symbol("x")
|
144
|
+
assert (x/y)._sympy_() == sympy.Symbol("x") / sympy.Symbol("y")
|
145
|
+
|
146
|
+
|
147
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
148
|
+
def test_conv6b():
|
149
|
+
x = sympy.Symbol("x")
|
150
|
+
y = sympy.Symbol("y")
|
151
|
+
assert sympify(x/3) == Symbol("x") / 3
|
152
|
+
assert sympify(3*x) == 3*Symbol("x")
|
153
|
+
assert sympify(3+x) == 3+Symbol("x")
|
154
|
+
assert sympify(3-x) == 3-Symbol("x")
|
155
|
+
assert sympify(x/y) == Symbol("x") / Symbol("y")
|
156
|
+
|
157
|
+
|
158
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
159
|
+
def test_conv7():
|
160
|
+
x = Symbol("x")
|
161
|
+
y = Symbol("y")
|
162
|
+
assert sin(x/3) == sin(sympy.Symbol("x") / 3)
|
163
|
+
assert cos(x/3) == cos(sympy.Symbol("x") / 3)
|
164
|
+
assert tan(x/3) == tan(sympy.Symbol("x") / 3)
|
165
|
+
assert cot(x/3) == cot(sympy.Symbol("x") / 3)
|
166
|
+
assert csc(x/3) == csc(sympy.Symbol("x") / 3)
|
167
|
+
assert sec(x/3) == sec(sympy.Symbol("x") / 3)
|
168
|
+
assert asin(x/3) == asin(sympy.Symbol("x") / 3)
|
169
|
+
assert acos(x/3) == acos(sympy.Symbol("x") / 3)
|
170
|
+
assert atan(x/3) == atan(sympy.Symbol("x") / 3)
|
171
|
+
assert acot(x/3) == acot(sympy.Symbol("x") / 3)
|
172
|
+
assert acsc(x/3) == acsc(sympy.Symbol("x") / 3)
|
173
|
+
assert asec(x/3) == asec(sympy.Symbol("x") / 3)
|
174
|
+
assert atan2(x/3, y) == atan2(sympy.Symbol("x") / 3, sympy.Symbol("y"))
|
175
|
+
|
176
|
+
assert sin(x/3)._sympy_() == sympy.sin(sympy.Symbol("x") / 3)
|
177
|
+
assert sin(x/3)._sympy_() != sympy.cos(sympy.Symbol("x") / 3)
|
178
|
+
assert cos(x/3)._sympy_() == sympy.cos(sympy.Symbol("x") / 3)
|
179
|
+
assert tan(x/3)._sympy_() == sympy.tan(sympy.Symbol("x") / 3)
|
180
|
+
assert cot(x/3)._sympy_() == sympy.cot(sympy.Symbol("x") / 3)
|
181
|
+
assert csc(x/3)._sympy_() == sympy.csc(sympy.Symbol("x") / 3)
|
182
|
+
assert sec(x/3)._sympy_() == sympy.sec(sympy.Symbol("x") / 3)
|
183
|
+
assert asin(x/3)._sympy_() == sympy.asin(sympy.Symbol("x") / 3)
|
184
|
+
assert acos(x/3)._sympy_() == sympy.acos(sympy.Symbol("x") / 3)
|
185
|
+
assert atan(x/3)._sympy_() == sympy.atan(sympy.Symbol("x") / 3)
|
186
|
+
assert acot(x/3)._sympy_() == sympy.acot(sympy.Symbol("x") / 3)
|
187
|
+
assert acsc(x/3)._sympy_() == sympy.acsc(sympy.Symbol("x") / 3)
|
188
|
+
assert asec(x/3)._sympy_() == sympy.asec(sympy.Symbol("x") / 3)
|
189
|
+
assert atan2(x/3, y)._sympy_() == sympy.atan2(sympy.Symbol("x") / 3, sympy.Symbol("y"))
|
190
|
+
|
191
|
+
assert sympy.sympify(sin(x/3)) == sympy.sin(sympy.Symbol("x") / 3)
|
192
|
+
assert sympy.sympify(sin(x/3)) != sympy.cos(sympy.Symbol("x") / 3)
|
193
|
+
assert sympy.sympify(cos(x/3)) == sympy.cos(sympy.Symbol("x") / 3)
|
194
|
+
assert sympy.sympify(tan(x/3)) == sympy.tan(sympy.Symbol("x") / 3)
|
195
|
+
assert sympy.sympify(cot(x/3)) == sympy.cot(sympy.Symbol("x") / 3)
|
196
|
+
assert sympy.sympify(csc(x/3)) == sympy.csc(sympy.Symbol("x") / 3)
|
197
|
+
assert sympy.sympify(sec(x/3)) == sympy.sec(sympy.Symbol("x") / 3)
|
198
|
+
assert sympy.sympify(asin(x/3)) == sympy.asin(sympy.Symbol("x") / 3)
|
199
|
+
assert sympy.sympify(acos(x/3)) == sympy.acos(sympy.Symbol("x") / 3)
|
200
|
+
assert sympy.sympify(atan(x/3)) == sympy.atan(sympy.Symbol("x") / 3)
|
201
|
+
assert sympy.sympify(acot(x/3)) == sympy.acot(sympy.Symbol("x") / 3)
|
202
|
+
assert sympy.sympify(acsc(x/3)) == sympy.acsc(sympy.Symbol("x") / 3)
|
203
|
+
assert sympy.sympify(asec(x/3)) == sympy.asec(sympy.Symbol("x") / 3)
|
204
|
+
assert sympy.sympify(atan2(x/3, y)) == sympy.atan2(sympy.Symbol("x") / 3, sympy.Symbol("y"))
|
205
|
+
|
206
|
+
|
207
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
208
|
+
def test_conv7b():
|
209
|
+
x = sympy.Symbol("x")
|
210
|
+
y = sympy.Symbol("y")
|
211
|
+
assert sympify(sympy.sin(x/3)) == sin(Symbol("x") / 3)
|
212
|
+
assert sympify(sympy.sin(x/3)) != cos(Symbol("x") / 3)
|
213
|
+
assert sympify(sympy.cos(x/3)) == cos(Symbol("x") / 3)
|
214
|
+
assert sympify(sympy.tan(x/3)) == tan(Symbol("x") / 3)
|
215
|
+
assert sympify(sympy.cot(x/3)) == cot(Symbol("x") / 3)
|
216
|
+
assert sympify(sympy.csc(x/3)) == csc(Symbol("x") / 3)
|
217
|
+
assert sympify(sympy.sec(x/3)) == sec(Symbol("x") / 3)
|
218
|
+
assert sympify(sympy.asin(x/3)) == asin(Symbol("x") / 3)
|
219
|
+
assert sympify(sympy.acos(x/3)) == acos(Symbol("x") / 3)
|
220
|
+
assert sympify(sympy.atan(x/3)) == atan(Symbol("x") / 3)
|
221
|
+
assert sympify(sympy.acot(x/3)) == acot(Symbol("x") / 3)
|
222
|
+
assert sympify(sympy.acsc(x/3)) == acsc(Symbol("x") / 3)
|
223
|
+
assert sympify(sympy.asec(x/3)) == asec(Symbol("x") / 3)
|
224
|
+
assert sympify(sympy.atan2(x/3, y)) == atan2(Symbol("x") / 3, Symbol("y"))
|
225
|
+
|
226
|
+
|
227
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
228
|
+
def test_conv8():
|
229
|
+
e1 = function_symbol("f", Symbol("x"))
|
230
|
+
e2 = function_symbol("g", Symbol("x"), Symbol("y"))
|
231
|
+
assert e1._sympy_() == sympy.Function("f")(sympy.Symbol("x"))
|
232
|
+
assert e2._sympy_() != sympy.Function("f")(sympy.Symbol("x"))
|
233
|
+
assert (e2._sympy_() ==
|
234
|
+
sympy.Function("g")(sympy.Symbol("x"), sympy.Symbol("y")))
|
235
|
+
|
236
|
+
e3 = function_symbol("q", Symbol("t"))
|
237
|
+
assert e3._sympy_() == sympy.Function("q")(sympy.Symbol("t"))
|
238
|
+
assert e3._sympy_() != sympy.Function("f")(sympy.Symbol("t"))
|
239
|
+
assert (e3._sympy_() !=
|
240
|
+
sympy.Function("q")(sympy.Symbol("t"), sympy.Symbol("t")))
|
241
|
+
|
242
|
+
|
243
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
244
|
+
def test_conv8b():
|
245
|
+
e1 = sympy.Function("f")(sympy.Symbol("x"))
|
246
|
+
e2 = sympy.Function("g")(sympy.Symbol("x"), sympy.Symbol("y"))
|
247
|
+
assert sympify(e1) == function_symbol("f", Symbol("x"))
|
248
|
+
assert sympify(e2) != function_symbol("f", Symbol("x"))
|
249
|
+
assert sympify(e2) == function_symbol("g", Symbol("x"), Symbol("y"))
|
250
|
+
|
251
|
+
e3 = sympy.Function("q")(sympy.Symbol("t"))
|
252
|
+
assert sympify(e3) == function_symbol("q", Symbol("t"))
|
253
|
+
assert sympify(e3) != function_symbol("f", Symbol("t"))
|
254
|
+
assert sympify(e3) != function_symbol("q", Symbol("t"), Symbol("t"))
|
255
|
+
|
256
|
+
|
257
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
258
|
+
def test_conv9():
|
259
|
+
x = Symbol("x")
|
260
|
+
y = Symbol("y")
|
261
|
+
assert (I)._sympy_() == sympy.I
|
262
|
+
assert (2*I+3)._sympy_() == 2*sympy.I+3
|
263
|
+
assert (2*I/5+Integer(3)/5)._sympy_() == 2*sympy.I/5+sympy.S(3)/5
|
264
|
+
assert (x*I+3)._sympy_() == sympy.Symbol("x")*sympy.I + 3
|
265
|
+
assert (x+I*y)._sympy_() == sympy.Symbol("x") + sympy.I*sympy.Symbol("y")
|
266
|
+
|
267
|
+
|
268
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
269
|
+
def test_conv9b():
|
270
|
+
x = Symbol("x")
|
271
|
+
y = Symbol("y")
|
272
|
+
assert sympify(sympy.I) == I
|
273
|
+
assert sympify(2*sympy.I+3) == 2*I+3
|
274
|
+
assert sympify(2*sympy.I/5+sympy.S(3)/5) == 2*I/5+Integer(3)/5
|
275
|
+
assert sympify(sympy.Symbol("x")*sympy.I + 3) == x*I+3
|
276
|
+
assert sympify(sympy.Symbol("x") + sympy.I*sympy.Symbol("y")) == x+I*y
|
277
|
+
|
278
|
+
|
279
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
280
|
+
def test_conv10():
|
281
|
+
A = DenseMatrix(1, 4, [Integer(1), Integer(2), Integer(3), Integer(4)])
|
282
|
+
assert (A._sympy_() == sympy.Matrix(1, 4,
|
283
|
+
[sympy.Integer(1), sympy.Integer(2),
|
284
|
+
sympy.Integer(3), sympy.Integer(4)]))
|
285
|
+
|
286
|
+
B = DenseMatrix(4, 1, [Symbol("x"), Symbol("y"), Symbol("z"), Symbol("t")])
|
287
|
+
assert (B._sympy_() == sympy.Matrix(4, 1,
|
288
|
+
[sympy.Symbol("x"), sympy.Symbol("y"),
|
289
|
+
sympy.Symbol("z"), sympy.Symbol("t")])
|
290
|
+
)
|
291
|
+
|
292
|
+
C = DenseMatrix(2, 2,
|
293
|
+
[Integer(5), Symbol("x"),
|
294
|
+
function_symbol("f", Symbol("x")), 1 + I])
|
295
|
+
|
296
|
+
assert (C._sympy_() ==
|
297
|
+
sympy.Matrix([[5, sympy.Symbol("x")],
|
298
|
+
[sympy.Function("f")(sympy.Symbol("x")),
|
299
|
+
1 + sympy.I]]))
|
300
|
+
|
301
|
+
|
302
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
303
|
+
def test_conv10b():
|
304
|
+
A = sympy.Matrix([[sympy.Symbol("x"), sympy.Symbol("y")],
|
305
|
+
[sympy.Symbol("z"), sympy.Symbol("t")]])
|
306
|
+
assert sympify(A) == DenseMatrix(2, 2, [Symbol("x"), Symbol("y"),
|
307
|
+
Symbol("z"), Symbol("t")])
|
308
|
+
|
309
|
+
B = sympy.Matrix([[1, 2], [3, 4]])
|
310
|
+
assert sympify(B) == DenseMatrix(2, 2, [Integer(1), Integer(2), Integer(3),
|
311
|
+
Integer(4)])
|
312
|
+
|
313
|
+
C = sympy.Matrix([[7, sympy.Symbol("y")],
|
314
|
+
[sympy.Function("g")(sympy.Symbol("z")), 3 + 2*sympy.I]])
|
315
|
+
assert sympify(C) == DenseMatrix(2, 2, [Integer(7), Symbol("y"),
|
316
|
+
function_symbol("g",
|
317
|
+
Symbol("z")),
|
318
|
+
3 + 2*I])
|
319
|
+
|
320
|
+
|
321
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
322
|
+
def test_conv11():
|
323
|
+
x = sympy.Symbol("x")
|
324
|
+
y = sympy.Symbol("y")
|
325
|
+
x1 = Symbol("x")
|
326
|
+
y1 = Symbol("y")
|
327
|
+
f = sympy.Function("f")
|
328
|
+
f1 = Function("f")
|
329
|
+
|
330
|
+
e1 = diff(f(2*x, y), x)
|
331
|
+
e2 = diff(f1(2*x1, y1), x1)
|
332
|
+
e3 = diff(f1(2*x1, y1), y1)
|
333
|
+
|
334
|
+
assert sympify(e1) == e2
|
335
|
+
assert sympify(e1) != e3
|
336
|
+
|
337
|
+
assert e2._sympy_() == e1
|
338
|
+
assert e3._sympy_() != e1
|
339
|
+
|
340
|
+
|
341
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
342
|
+
def test_conv12():
|
343
|
+
x = Symbol("x")
|
344
|
+
y = Symbol("y")
|
345
|
+
assert sinh(x/3) == sinh(sympy.Symbol("x") / 3)
|
346
|
+
assert cosh(x/3) == cosh(sympy.Symbol("x") / 3)
|
347
|
+
assert tanh(x/3) == tanh(sympy.Symbol("x") / 3)
|
348
|
+
assert coth(x/3) == coth(sympy.Symbol("x") / 3)
|
349
|
+
assert asinh(x/3) == asinh(sympy.Symbol("x") / 3)
|
350
|
+
assert acosh(x/3) == acosh(sympy.Symbol("x") / 3)
|
351
|
+
assert atanh(x/3) == atanh(sympy.Symbol("x") / 3)
|
352
|
+
assert acoth(x/3) == acoth(sympy.Symbol("x") / 3)
|
353
|
+
|
354
|
+
assert sinh(x/3)._sympy_() == sympy.sinh(sympy.Symbol("x") / 3)
|
355
|
+
assert cosh(x/3)._sympy_() == sympy.cosh(sympy.Symbol("x") / 3)
|
356
|
+
assert tanh(x/3)._sympy_() == sympy.tanh(sympy.Symbol("x") / 3)
|
357
|
+
assert coth(x/3)._sympy_() == sympy.coth(sympy.Symbol("x") / 3)
|
358
|
+
assert asinh(x/3)._sympy_() == sympy.asinh(sympy.Symbol("x") / 3)
|
359
|
+
assert acosh(x/3)._sympy_() == sympy.acosh(sympy.Symbol("x") / 3)
|
360
|
+
assert atanh(x/3)._sympy_() == sympy.atanh(sympy.Symbol("x") / 3)
|
361
|
+
assert acoth(x/3)._sympy_() == sympy.acoth(sympy.Symbol("x") / 3)
|
362
|
+
|
363
|
+
|
364
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
365
|
+
def test_conv12b():
|
366
|
+
x = sympy.Symbol("x")
|
367
|
+
y = sympy.Symbol("y")
|
368
|
+
assert sympify(sympy.sinh(x/3)) == sinh(Symbol("x") / 3)
|
369
|
+
assert sympify(sympy.cosh(x/3)) == cosh(Symbol("x") / 3)
|
370
|
+
assert sympify(sympy.tanh(x/3)) == tanh(Symbol("x") / 3)
|
371
|
+
assert sympify(sympy.coth(x/3)) == coth(Symbol("x") / 3)
|
372
|
+
assert sympify(sympy.asinh(x/3)) == asinh(Symbol("x") / 3)
|
373
|
+
assert sympify(sympy.acosh(x/3)) == acosh(Symbol("x") / 3)
|
374
|
+
assert sympify(sympy.atanh(x/3)) == atanh(Symbol("x") / 3)
|
375
|
+
assert sympify(sympy.acoth(x/3)) == acoth(Symbol("x") / 3)
|
376
|
+
|
377
|
+
|
378
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
379
|
+
def test_tuples_lists():
|
380
|
+
x = sympy.Symbol("x")
|
381
|
+
y = sympy.Symbol("y")
|
382
|
+
z = sympy.Symbol("z")
|
383
|
+
L = [x, y, z, x*y, z**y]
|
384
|
+
t = (x, y, z, x*y, z**y)
|
385
|
+
x = Symbol("x")
|
386
|
+
y = Symbol("y")
|
387
|
+
z = Symbol("z")
|
388
|
+
l2 = [x, y, z, x*y, z**y]
|
389
|
+
t2 = (x, y, z, x*y, z**y)
|
390
|
+
assert sympify(L) == l2
|
391
|
+
assert sympify(t) == t2
|
392
|
+
assert sympify(L) != t2
|
393
|
+
assert sympify(t) != l2
|
394
|
+
|
395
|
+
assert L == l2
|
396
|
+
assert t == t2
|
397
|
+
assert L != t2
|
398
|
+
assert t != l2
|
399
|
+
|
400
|
+
|
401
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
402
|
+
def test_exp():
|
403
|
+
x = Symbol("x")
|
404
|
+
e1 = sympy.exp(sympy.Symbol("x"))
|
405
|
+
e2 = exp(x)
|
406
|
+
assert sympify(e1) == e2
|
407
|
+
assert e1 == e2._sympy_()
|
408
|
+
|
409
|
+
e1 = sympy.exp(sympy.Symbol("x")).diff(sympy.Symbol("x"))
|
410
|
+
e2 = exp(x).diff(x)
|
411
|
+
assert sympify(e1) == e2
|
412
|
+
assert e1 == e2._sympy_()
|
413
|
+
|
414
|
+
|
415
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
416
|
+
def test_gamma():
|
417
|
+
x = Symbol("x")
|
418
|
+
e1 = sympy.gamma(sympy.Symbol("x"))
|
419
|
+
e2 = gamma(x)
|
420
|
+
assert sympify(e1) == e2
|
421
|
+
assert e1 == e2._sympy_()
|
422
|
+
|
423
|
+
|
424
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
425
|
+
def test_constants():
|
426
|
+
assert sympify(sympy.E) == E
|
427
|
+
assert sympy.E == E._sympy_()
|
428
|
+
|
429
|
+
assert sympify(sympy.pi) == pi
|
430
|
+
assert sympy.pi == pi._sympy_()
|
431
|
+
|
432
|
+
assert sympify(sympy.GoldenRatio) == GoldenRatio
|
433
|
+
assert sympy.GoldenRatio == GoldenRatio._sympy_()
|
434
|
+
|
435
|
+
assert sympify(sympy.Catalan) == Catalan
|
436
|
+
assert sympy.Catalan == Catalan._sympy_()
|
437
|
+
|
438
|
+
assert sympify(sympy.EulerGamma) == EulerGamma
|
439
|
+
assert sympy.EulerGamma == EulerGamma._sympy_()
|
440
|
+
|
441
|
+
assert sympify(sympy.oo) == oo
|
442
|
+
assert sympy.oo == oo._sympy_()
|
443
|
+
|
444
|
+
assert sympify(sympy.zoo) == zoo
|
445
|
+
assert sympy.zoo == zoo._sympy_()
|
446
|
+
|
447
|
+
assert sympify(sympy.nan) == nan
|
448
|
+
assert sympy.nan == nan._sympy_()
|
449
|
+
|
450
|
+
|
451
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
452
|
+
def test_booleans():
|
453
|
+
assert sympify(sympy.S.true) == true
|
454
|
+
assert sympy.S.true == true._sympy_()
|
455
|
+
|
456
|
+
assert sympify(sympy.S.false) == false
|
457
|
+
assert sympy.S.false == false._sympy_()
|
458
|
+
|
459
|
+
|
460
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
461
|
+
def test_abs():
|
462
|
+
x = Symbol("x")
|
463
|
+
e1 = abs(sympy.Symbol("x"))
|
464
|
+
e2 = abs(x)
|
465
|
+
assert sympify(e1) == e2
|
466
|
+
assert e1 == e2._sympy_()
|
467
|
+
|
468
|
+
e1 = abs(2*sympy.Symbol("x"))
|
469
|
+
e2 = 2*abs(x)
|
470
|
+
assert sympify(e1) == e2
|
471
|
+
assert e1 == e2._sympy_()
|
472
|
+
|
473
|
+
y = Symbol("y")
|
474
|
+
e1 = abs(sympy.Symbol("y")*sympy.Symbol("x"))
|
475
|
+
e2 = abs(y*x)
|
476
|
+
assert sympify(e1) == e2
|
477
|
+
assert e1 == e2._sympy_()
|
478
|
+
|
479
|
+
|
480
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
481
|
+
def test_mpfr():
|
482
|
+
if have_mpfr:
|
483
|
+
a = RealMPFR('100', 100)
|
484
|
+
b = sympy.Float('100', 29)
|
485
|
+
assert sympify(b) == a
|
486
|
+
assert b == a._sympy_()
|
487
|
+
|
488
|
+
|
489
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
490
|
+
def test_mpc():
|
491
|
+
if have_mpc:
|
492
|
+
a = ComplexMPC('1', '2', 100)
|
493
|
+
b = sympy.Float(1, 29) + sympy.Float(2, 29) * sympy.I
|
494
|
+
assert sympify(b) == a
|
495
|
+
assert b == a._sympy_()
|
496
|
+
|
497
|
+
|
498
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
499
|
+
def test_log():
|
500
|
+
x = Symbol("x")
|
501
|
+
x1 = sympy.Symbol("x")
|
502
|
+
|
503
|
+
assert log(x) == log(x1)
|
504
|
+
assert log(x)._sympy_() == sympy.log(x1)
|
505
|
+
assert sympify(sympy.log(x1)) == log(x)
|
506
|
+
|
507
|
+
y = Symbol("y")
|
508
|
+
y1 = sympy.Symbol("y")
|
509
|
+
|
510
|
+
assert log(x, y) == log(x, y1)
|
511
|
+
assert log(x1, y) == log(x1, y1)
|
512
|
+
assert log(x, y)._sympy_() == sympy.log(x1, y1)
|
513
|
+
assert sympify(sympy.log(x1, y1)) == log(x, y)
|
514
|
+
|
515
|
+
|
516
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
517
|
+
def test_lambertw():
|
518
|
+
x = Symbol("x")
|
519
|
+
e1 = sympy.LambertW(sympy.Symbol("x"))
|
520
|
+
e2 = LambertW(x)
|
521
|
+
assert sympify(e1) == e2
|
522
|
+
assert e2._sympy_() == e1
|
523
|
+
|
524
|
+
|
525
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
526
|
+
def test_zeta():
|
527
|
+
x = Symbol("x")
|
528
|
+
y = Symbol("y")
|
529
|
+
e1 = sympy.zeta(sympy.Symbol("x"))
|
530
|
+
e2 = zeta(x)
|
531
|
+
assert sympify(e1) == e2
|
532
|
+
assert e2._sympy_() == e1
|
533
|
+
e1 = sympy.zeta(sympy.Symbol("x"), sympy.Symbol("y"))
|
534
|
+
e2 = zeta(x, y)
|
535
|
+
assert sympify(e1) == e2
|
536
|
+
assert e2._sympy_() == e1
|
537
|
+
|
538
|
+
|
539
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
540
|
+
def test_dirichlet_eta():
|
541
|
+
x = Symbol("x")
|
542
|
+
e1 = sympy.dirichlet_eta(sympy.Symbol("x"))
|
543
|
+
e2 = dirichlet_eta(x)
|
544
|
+
assert sympify(e1) == e2
|
545
|
+
assert e2._sympy_() == e1
|
546
|
+
|
547
|
+
|
548
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
549
|
+
def test_kronecker_delta():
|
550
|
+
x = Symbol("x")
|
551
|
+
y = Symbol("y")
|
552
|
+
e1 = sympy.KroneckerDelta(sympy.Symbol("x"), sympy.Symbol("y"))
|
553
|
+
e2 = KroneckerDelta(x, y)
|
554
|
+
assert sympify(e1) == e2
|
555
|
+
assert e2._sympy_() == e1
|
556
|
+
|
557
|
+
|
558
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
559
|
+
def test_levi_civita():
|
560
|
+
x = Symbol("x")
|
561
|
+
y = Symbol("y")
|
562
|
+
z = Symbol("z")
|
563
|
+
e1 = sympy.LeviCivita(sympy.Symbol("x"), sympy.Symbol("y"), sympy.Symbol("z"))
|
564
|
+
e2 = LeviCivita(x, y, z)
|
565
|
+
assert sympify(e1) == e2
|
566
|
+
assert e2._sympy_() == e1
|
567
|
+
|
568
|
+
|
569
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
570
|
+
def test_erf():
|
571
|
+
x = Symbol("x")
|
572
|
+
e1 = sympy.erf(sympy.Symbol("x"))
|
573
|
+
e2 = erf(x)
|
574
|
+
assert sympify(e1) == e2
|
575
|
+
assert e2._sympy_() == e1
|
576
|
+
|
577
|
+
|
578
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
579
|
+
def test_erfc():
|
580
|
+
x = Symbol("x")
|
581
|
+
e1 = sympy.erfc(sympy.Symbol("x"))
|
582
|
+
e2 = erfc(x)
|
583
|
+
assert sympify(e1) == e2
|
584
|
+
assert e2._sympy_() == e1
|
585
|
+
|
586
|
+
|
587
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
588
|
+
def test_lowergamma():
|
589
|
+
x = Symbol("x")
|
590
|
+
y = Symbol("y")
|
591
|
+
e1 = sympy.lowergamma(sympy.Symbol("x"), sympy.Symbol("y"))
|
592
|
+
e2 = lowergamma(x, y)
|
593
|
+
assert sympify(e1) == e2
|
594
|
+
assert e2._sympy_() == e1
|
595
|
+
|
596
|
+
|
597
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
598
|
+
def test_uppergamma():
|
599
|
+
x = Symbol("x")
|
600
|
+
y = Symbol("y")
|
601
|
+
e1 = sympy.uppergamma(sympy.Symbol("x"), sympy.Symbol("y"))
|
602
|
+
e2 = uppergamma(x, y)
|
603
|
+
assert sympify(e1) == e2
|
604
|
+
assert e2._sympy_() == e1
|
605
|
+
|
606
|
+
|
607
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
608
|
+
def test_loggamma():
|
609
|
+
x = Symbol("x")
|
610
|
+
e1 = sympy.loggamma(sympy.Symbol("x"))
|
611
|
+
e2 = loggamma(x)
|
612
|
+
assert sympify(e1) == e2
|
613
|
+
assert e2._sympy_() == e1
|
614
|
+
|
615
|
+
|
616
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
617
|
+
def test_beta():
|
618
|
+
x = Symbol("x")
|
619
|
+
y = Symbol("y")
|
620
|
+
e1 = sympy.beta(sympy.Symbol("y"), sympy.Symbol("x"))
|
621
|
+
e2 = beta(y, x)
|
622
|
+
assert sympify(e1) == e2
|
623
|
+
assert e2._sympy_() == e1
|
624
|
+
|
625
|
+
|
626
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
627
|
+
def test_polygamma():
|
628
|
+
x = Symbol("x")
|
629
|
+
y = Symbol("y")
|
630
|
+
e1 = sympy.polygamma(sympy.Symbol("x"), sympy.Symbol("y"))
|
631
|
+
e2 = polygamma(x, y)
|
632
|
+
assert sympify(e1) == e2
|
633
|
+
assert e2._sympy_() == e1
|
634
|
+
|
635
|
+
|
636
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
637
|
+
def test_sign():
|
638
|
+
x = Symbol("x")
|
639
|
+
e1 = sympy.sign(sympy.Symbol("x"))
|
640
|
+
e2 = sign(x)
|
641
|
+
assert sympify(e1) == e2
|
642
|
+
assert e2._sympy_() == e1
|
643
|
+
|
644
|
+
|
645
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
646
|
+
def test_floor():
|
647
|
+
x = Symbol("x")
|
648
|
+
e1 = sympy.floor(sympy.Symbol("x"))
|
649
|
+
e2 = floor(x)
|
650
|
+
assert sympify(e1) == e2
|
651
|
+
assert e2._sympy_() == e1
|
652
|
+
|
653
|
+
|
654
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
655
|
+
def test_ceiling():
|
656
|
+
x = Symbol("x")
|
657
|
+
e1 = sympy.ceiling(sympy.Symbol("x"))
|
658
|
+
e2 = ceiling(x)
|
659
|
+
assert sympify(e1) == e2
|
660
|
+
assert e2._sympy_() == e1
|
661
|
+
|
662
|
+
|
663
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
664
|
+
def test_conjugate():
|
665
|
+
x = Symbol("x")
|
666
|
+
e1 = sympy.conjugate(sympy.Symbol("x"))
|
667
|
+
e2 = conjugate(x)
|
668
|
+
assert sympify(e1) == e2
|
669
|
+
assert e2._sympy_() == e1
|
670
|
+
|
671
|
+
|
672
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
673
|
+
def test_unevaluated_expr():
|
674
|
+
x = Symbol("x")
|
675
|
+
e1 = sympy.UnevaluatedExpr(sympy.Symbol("x"))
|
676
|
+
e2 = UnevaluatedExpr(x)
|
677
|
+
assert sympify(e1) == e2
|
678
|
+
assert e2._sympy_() == e1
|
679
|
+
|
680
|
+
|
681
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
682
|
+
def test_logic():
|
683
|
+
x = true
|
684
|
+
y = false
|
685
|
+
x1 = sympy.true
|
686
|
+
y1 = sympy.false
|
687
|
+
|
688
|
+
assert And(x, y) == And(x1, y1)
|
689
|
+
assert And(x1, y) == And(x1, y1)
|
690
|
+
assert And(x, y)._sympy_() == sympy.And(x1, y1)
|
691
|
+
assert sympify(sympy.And(x1, y1)) == And(x, y)
|
692
|
+
|
693
|
+
assert Or(x, y) == Or(x1, y1)
|
694
|
+
assert Or(x1, y) == Or(x1, y1)
|
695
|
+
assert Or(x, y)._sympy_() == sympy.Or(x1, y1)
|
696
|
+
assert sympify(sympy.Or(x1, y1)) == Or(x, y)
|
697
|
+
|
698
|
+
assert Not(x) == Not(x1)
|
699
|
+
assert Not(x1) == Not(x1)
|
700
|
+
assert Not(x)._sympy_() == sympy.Not(x1)
|
701
|
+
assert sympify(sympy.Not(x1)) == Not(x)
|
702
|
+
|
703
|
+
assert Xor(x, y) == Xor(x1, y1)
|
704
|
+
assert Xor(x1, y) == Xor(x1, y1)
|
705
|
+
assert Xor(x, y)._sympy_() == sympy.Xor(x1, y1)
|
706
|
+
assert sympify(sympy.Xor(x1, y1)) == Xor(x, y)
|
707
|
+
|
708
|
+
x = Symbol("x")
|
709
|
+
x1 = sympy.Symbol("x")
|
710
|
+
|
711
|
+
assert Piecewise((x, x < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True))
|
712
|
+
assert Piecewise((x, x1 < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True))
|
713
|
+
assert Piecewise((x, x < 1), (0, True))._sympy_() == sympy.Piecewise((x1, x1 < 1), (0, True))
|
714
|
+
assert sympify(sympy.Piecewise((x1, x1 < 1), (0, True))) == Piecewise((x, x < 1), (0, True))
|
715
|
+
|
716
|
+
assert Contains(x, Interval(1, 1)) == Contains(x1, Interval(1, 1))
|
717
|
+
assert Contains(x, Interval(1, 1))._sympy_() == sympy.Contains(x1, Interval(1, 1))
|
718
|
+
assert sympify(sympy.Contains(x1, Interval(1, 1))) == Contains(x, Interval(1, 1))
|
719
|
+
|
720
|
+
|
721
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
722
|
+
def test_sets():
|
723
|
+
x = Integer(2)
|
724
|
+
y = Integer(3)
|
725
|
+
x1 = sympy.Integer(2)
|
726
|
+
y1 = sympy.Integer(3)
|
727
|
+
|
728
|
+
assert Interval(x, y) == Interval(x1, y1)
|
729
|
+
assert Interval(x1, y) == Interval(x1, y1)
|
730
|
+
assert Interval(x, y)._sympy_() == sympy.Interval(x1, y1)
|
731
|
+
assert sympify(sympy.Interval(x1, y1)) == Interval(x, y)
|
732
|
+
|
733
|
+
assert sympify(sympy.S.EmptySet) == EmptySet()
|
734
|
+
assert sympy.S.EmptySet == EmptySet()._sympy_()
|
735
|
+
|
736
|
+
assert sympify(sympy.S.UniversalSet) == UniversalSet()
|
737
|
+
assert sympy.S.UniversalSet == UniversalSet()._sympy_()
|
738
|
+
|
739
|
+
assert sympify(sympy.S.Reals) == Reals()
|
740
|
+
assert sympy.S.Reals == Reals()._sympy_()
|
741
|
+
|
742
|
+
assert sympify(sympy.S.Rationals) == Rationals()
|
743
|
+
assert sympy.S.Rationals == Rationals()._sympy_()
|
744
|
+
|
745
|
+
assert sympify(sympy.S.Integers) == Integers()
|
746
|
+
assert sympy.S.Integers == Integers()._sympy_()
|
747
|
+
|
748
|
+
assert FiniteSet(x, y) == FiniteSet(x1, y1)
|
749
|
+
assert FiniteSet(x1, y) == FiniteSet(x1, y1)
|
750
|
+
assert FiniteSet(x, y)._sympy_() == sympy.FiniteSet(x1, y1)
|
751
|
+
assert sympify(sympy.FiniteSet(x1, y1)) == FiniteSet(x, y)
|
752
|
+
|
753
|
+
x = Interval(1, 2)
|
754
|
+
y = Interval(2, 3)
|
755
|
+
x1 = sympy.Interval(1, 2)
|
756
|
+
y1 = sympy.Interval(2, 3)
|
757
|
+
|
758
|
+
assert Union(x, y) == Union(x1, y1)
|
759
|
+
assert Union(x1, y) == Union(x1, y1)
|
760
|
+
assert Union(x, y)._sympy_() == sympy.Union(x1, y1)
|
761
|
+
assert sympify(sympy.Union(x1, y1)) == Union(x, y)
|
762
|
+
|
763
|
+
assert Complement(x, y) == Complement(x1, y1)
|
764
|
+
assert Complement(x1, y) == Complement(x1, y1)
|
765
|
+
assert Complement(x, y)._sympy_() == sympy.Complement(x1, y1)
|
766
|
+
assert sympify(sympy.Complement(x1, y1)) == Complement(x, y)
|
767
|
+
|
768
|
+
|
769
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
770
|
+
def test_pynumber():
|
771
|
+
a = sympy.FF(7)(3)
|
772
|
+
b = sympify(a)
|
773
|
+
|
774
|
+
assert isinstance(b, PyNumber)
|
775
|
+
|
776
|
+
a = a + 1
|
777
|
+
b = b + 1
|
778
|
+
assert isinstance(b, PyNumber)
|
779
|
+
assert b == a # Check equality via SymEngine
|
780
|
+
assert a == b # Check equality via SymPy
|
781
|
+
assert str(a) == str(b)
|
782
|
+
|
783
|
+
a = 1 - a
|
784
|
+
b = 1 - b
|
785
|
+
assert isinstance(b, PyNumber)
|
786
|
+
assert b == a # Check equality via SymEngine
|
787
|
+
assert a == b # Check equality via SymPy
|
788
|
+
|
789
|
+
a = 2 * a
|
790
|
+
b = 2 * b
|
791
|
+
assert isinstance(b, PyNumber)
|
792
|
+
assert b == a # Check equality via SymEngine
|
793
|
+
assert a == b # Check equality via SymPy
|
794
|
+
|
795
|
+
if sympy.__version__ != '1.2':
|
796
|
+
a = 2 / a
|
797
|
+
b = 2 / b
|
798
|
+
assert isinstance(b, PyNumber)
|
799
|
+
assert b == a # Check equality via SymEngine
|
800
|
+
assert a == b # Check equality via SymPy
|
801
|
+
|
802
|
+
x = Symbol("x")
|
803
|
+
b = x * sympy.FF(7)(3)
|
804
|
+
assert isinstance(b, Mul)
|
805
|
+
|
806
|
+
b = b / x
|
807
|
+
assert isinstance(b, PyNumber)
|
808
|
+
|
809
|
+
|
810
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
811
|
+
def test_construct_dense_matrix():
|
812
|
+
# Test for issue #347
|
813
|
+
A = sympy.Matrix([[1, 2], [3, 5]])
|
814
|
+
B = DenseMatrix(A)
|
815
|
+
assert B.shape == (2, 2)
|
816
|
+
assert list(B) == [1, 2, 3, 5]
|
817
|
+
|
818
|
+
|
819
|
+
@unittest.skipIf(not have_sympy, "SymPy not installed")
|
820
|
+
def test_conv_doubles():
|
821
|
+
f = 4.347249999999999
|
822
|
+
a = sympify(f)
|
823
|
+
assert isinstance(a, RealDouble)
|
824
|
+
assert sympify(a._sympy_()) == a
|
825
|
+
assert float(a) == f
|
826
|
+
assert float(a._sympy_()) == f
|
827
|
+
|
828
|
+
def test_conv_large_integers():
|
829
|
+
a = Integer(10)**10000
|
830
|
+
# check that convert to python int does not throw
|
831
|
+
b = int(a)
|
832
|
+
# check that convert to sympy int does not throw
|
833
|
+
if have_sympy:
|
834
|
+
c = a._sympy_()
|
835
|
+
d = sympify(c)
|