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,28 @@
|
|
1
|
+
from symengine import Symbol, Integer, oo
|
2
|
+
from symengine.test_utilities import raises
|
3
|
+
|
4
|
+
|
5
|
+
def test_as_coefficients_dict():
|
6
|
+
x = Symbol('x')
|
7
|
+
y = Symbol('y')
|
8
|
+
check = [x, y, x*y, Integer(1)]
|
9
|
+
assert [(3*x + 2*x + y + 3).as_coefficients_dict()[i] for i in check] == \
|
10
|
+
[5, 1, 0, 3]
|
11
|
+
assert [(3*x*y).as_coefficients_dict()[i] for i in check] == \
|
12
|
+
[0, 0, 3, 0]
|
13
|
+
assert (3.0*x*y).as_coefficients_dict()[3.0*x*y] == 0
|
14
|
+
assert (3.0*x*y).as_coefficients_dict()[x*y] == 3.0
|
15
|
+
|
16
|
+
|
17
|
+
def test_as_powers_dict():
|
18
|
+
x = Symbol('x')
|
19
|
+
y = Symbol('y')
|
20
|
+
|
21
|
+
assert (2*x**y).as_powers_dict() == {2: 1, x: y}
|
22
|
+
assert (2*x**2*y**3).as_powers_dict() == {2: 1, x: 2, y: 3}
|
23
|
+
assert (-oo).as_powers_dict() == {Integer(-1): 1, oo: 1}
|
24
|
+
assert (x**y).as_powers_dict() == {x: y}
|
25
|
+
assert ((1/Integer(2))**y).as_powers_dict() == {Integer(2): -y}
|
26
|
+
assert (x*(1/Integer(2))**y).as_powers_dict() == {x: Integer(1), Integer(2): -y}
|
27
|
+
assert (2**y).as_powers_dict() == {2: y}
|
28
|
+
assert (2**-y).as_powers_dict() == {2: -y}
|
@@ -0,0 +1,432 @@
|
|
1
|
+
from symengine import (
|
2
|
+
Symbol, sin, cos, sqrt, Add, Mul, function_symbol, Integer, log, E, symbols, I,
|
3
|
+
Rational, EulerGamma, Function, Subs, Derivative, LambertW, zeta, dirichlet_eta,
|
4
|
+
zoo, pi, KroneckerDelta, LeviCivita, erf, erfc, oo, lowergamma, uppergamma, exp,
|
5
|
+
loggamma, beta, polygamma, digamma, trigamma, sign, floor, ceiling, conjugate,
|
6
|
+
nan, Float, UnevaluatedExpr
|
7
|
+
)
|
8
|
+
from symengine.test_utilities import raises
|
9
|
+
|
10
|
+
import unittest
|
11
|
+
|
12
|
+
try:
|
13
|
+
import sympy
|
14
|
+
from sympy.core.cache import clear_cache
|
15
|
+
import atexit
|
16
|
+
atexit.register(clear_cache)
|
17
|
+
have_sympy = True
|
18
|
+
except ImportError:
|
19
|
+
have_sympy = False
|
20
|
+
|
21
|
+
def test_sin():
|
22
|
+
x = Symbol("x")
|
23
|
+
e = sin(x)
|
24
|
+
assert e == sin(x)
|
25
|
+
assert e != cos(x)
|
26
|
+
|
27
|
+
assert sin(x).diff(x) == cos(x)
|
28
|
+
assert cos(x).diff(x) == -sin(x)
|
29
|
+
|
30
|
+
e = sqrt(x).diff(x).diff(x)
|
31
|
+
f = sin(e)
|
32
|
+
g = f.diff(x).diff(x)
|
33
|
+
assert isinstance(g, Add)
|
34
|
+
|
35
|
+
|
36
|
+
def test_f():
|
37
|
+
x = Symbol("x")
|
38
|
+
y = Symbol("y")
|
39
|
+
z = Symbol("z")
|
40
|
+
f = function_symbol("f", x)
|
41
|
+
g = function_symbol("g", x)
|
42
|
+
assert f != g
|
43
|
+
|
44
|
+
f = function_symbol("f", x)
|
45
|
+
g = function_symbol("f", x)
|
46
|
+
assert f == g
|
47
|
+
|
48
|
+
f = function_symbol("f", x, y)
|
49
|
+
g = function_symbol("f", y, x)
|
50
|
+
assert f != g
|
51
|
+
|
52
|
+
f = function_symbol("f", x, y)
|
53
|
+
g = function_symbol("f", x, y)
|
54
|
+
assert f == g
|
55
|
+
|
56
|
+
|
57
|
+
def test_derivative():
|
58
|
+
x = Symbol("x")
|
59
|
+
y = Symbol("y")
|
60
|
+
f = function_symbol("f", x)
|
61
|
+
assert f.diff(x) == function_symbol("f", x).diff(x)
|
62
|
+
assert f.diff(x).diff(x) == function_symbol("f", x).diff(x).diff(x)
|
63
|
+
assert f.diff(y) == 0
|
64
|
+
assert f.diff(x).args == (f, x)
|
65
|
+
assert f.diff(x).diff(x).args == (f, x, x)
|
66
|
+
assert f.diff(x, 0) == f
|
67
|
+
assert f.diff(x, 0) == Derivative(function_symbol("f", x), x, 0)
|
68
|
+
raises(ValueError, lambda: f.diff(0))
|
69
|
+
raises(ValueError, lambda: f.diff(x, 0, 0))
|
70
|
+
raises(ValueError, lambda: f.diff(x, y, 0, 0, x))
|
71
|
+
|
72
|
+
g = function_symbol("f", y)
|
73
|
+
assert g.diff(x) == 0
|
74
|
+
assert g.diff(y) == function_symbol("f", y).diff(y)
|
75
|
+
assert g.diff(y).diff(y) == function_symbol("f", y).diff(y).diff(y)
|
76
|
+
|
77
|
+
assert f - function_symbol("f", x) == 0
|
78
|
+
|
79
|
+
f = function_symbol("f", x, y)
|
80
|
+
assert f.diff(x).diff(y) == function_symbol("f", x, y).diff(x).diff(y)
|
81
|
+
assert f.diff(Symbol("z")) == 0
|
82
|
+
|
83
|
+
s = Derivative(function_symbol("f", x), x)
|
84
|
+
assert s.expr == function_symbol("f", x)
|
85
|
+
assert s.variables == (x,)
|
86
|
+
|
87
|
+
fxy = Function("f")(x, y)
|
88
|
+
assert (1+fxy).has(fxy)
|
89
|
+
g = Derivative(Function("f")(x, y), x, 2, y, 1)
|
90
|
+
assert g == fxy.diff(x, x, y)
|
91
|
+
assert g == fxy.diff(y, 1, x, 2)
|
92
|
+
assert g == fxy.diff(y, x, 2)
|
93
|
+
|
94
|
+
h = Derivative(Function("f")(x, y), x, 0, y, 1)
|
95
|
+
assert h == fxy.diff(x, 0, y)
|
96
|
+
assert h == fxy.diff(y, x, 0)
|
97
|
+
|
98
|
+
i = Derivative(Function("f")(x, y), x, 0, y, 1, x, 1)
|
99
|
+
assert i == fxy.diff(x, 0, y, x, 1)
|
100
|
+
assert i == fxy.diff(x, 0, y, x)
|
101
|
+
assert i == fxy.diff(y, x)
|
102
|
+
assert i == fxy.diff(y, 1, x, 1)
|
103
|
+
assert i == fxy.diff(y, 1, x)
|
104
|
+
|
105
|
+
|
106
|
+
def test_function():
|
107
|
+
x = Symbol("x")
|
108
|
+
fx = Function("f")(x)
|
109
|
+
assert fx == function_symbol("f", x)
|
110
|
+
|
111
|
+
raises(TypeError, lambda: Function("f", "x"))
|
112
|
+
raises(TypeError, lambda: Function("f", x))
|
113
|
+
raises(TypeError, lambda: Function())
|
114
|
+
|
115
|
+
assert fx.name == "f"
|
116
|
+
|
117
|
+
|
118
|
+
def test_abs():
|
119
|
+
x = Symbol("x")
|
120
|
+
e = abs(x)
|
121
|
+
assert e == abs(x)
|
122
|
+
assert e != cos(x)
|
123
|
+
|
124
|
+
assert abs(5) == 5
|
125
|
+
assert abs(-5) == 5
|
126
|
+
assert abs(Integer(5)/3) == Integer(5)/3
|
127
|
+
assert abs(-Integer(5)/3) == Integer(5)/3
|
128
|
+
assert abs(Integer(5)/3+x) != Integer(5)/3
|
129
|
+
assert abs(Integer(5)/3+x) == abs(Integer(5)/3+x)
|
130
|
+
|
131
|
+
|
132
|
+
def test_abs_diff():
|
133
|
+
x = Symbol("x")
|
134
|
+
y = Symbol("y")
|
135
|
+
e = abs(x)
|
136
|
+
assert e.diff(x) != e
|
137
|
+
assert e.diff(x) != 0
|
138
|
+
assert e.diff(y) == 0
|
139
|
+
|
140
|
+
|
141
|
+
def test_Subs():
|
142
|
+
x = Symbol("x")
|
143
|
+
y = Symbol("y")
|
144
|
+
_x = Symbol("_xi_1")
|
145
|
+
f = function_symbol("f", 2*x)
|
146
|
+
assert str(f.diff(x)) == "2*Subs(Derivative(f(_xi_1), _xi_1), (_xi_1), (2*x))"
|
147
|
+
# TODO: fix me
|
148
|
+
# assert f.diff(x) == 2 * Subs(Derivative(function_symbol("f", _x), _x), [_x], [2 * x])
|
149
|
+
assert Subs(Derivative(function_symbol("f", x, y), x), [x, y], [_x, x]) \
|
150
|
+
== Subs(Derivative(function_symbol("f", x, y), x), [y, x], [x, _x])
|
151
|
+
|
152
|
+
s = f.diff(x)/2
|
153
|
+
_xi_1 = Symbol("_xi_1")
|
154
|
+
assert s.expr == Derivative(function_symbol("f", _xi_1), _xi_1)
|
155
|
+
assert s.variables == (_xi_1,)
|
156
|
+
assert s.point == (2*x,)
|
157
|
+
|
158
|
+
|
159
|
+
@unittest.skipUnless(have_sympy, "SymPy not installed")
|
160
|
+
def test_FunctionWrapper():
|
161
|
+
import sympy
|
162
|
+
n, m, theta, phi = sympy.symbols("n, m, theta, phi")
|
163
|
+
r = sympy.Ynm(n, m, theta, phi)
|
164
|
+
s = Integer(2)*r
|
165
|
+
assert isinstance(s, Mul)
|
166
|
+
assert isinstance(s.args[1]._sympy_(), sympy.Ynm)
|
167
|
+
|
168
|
+
x = symbols("x")
|
169
|
+
e = x + sympy.Mod(x, 2)
|
170
|
+
assert str(e) == "x + Mod(x, 2)"
|
171
|
+
assert isinstance(e, Add)
|
172
|
+
assert e + sympy.Mod(x, 2) == x + 2*sympy.Mod(x, 2)
|
173
|
+
|
174
|
+
f = e.subs({x : 10})
|
175
|
+
assert f == 10
|
176
|
+
|
177
|
+
f = e.subs({x : 2})
|
178
|
+
assert f == 2
|
179
|
+
|
180
|
+
f = e.subs({x : 100});
|
181
|
+
v = f.n(53, real=True);
|
182
|
+
assert abs(float(v) - 100.00000000) < 1e-7
|
183
|
+
|
184
|
+
|
185
|
+
def test_log():
|
186
|
+
x = Symbol("x")
|
187
|
+
y = Symbol("y")
|
188
|
+
assert log(E) == 1
|
189
|
+
assert log(x, x) == 1
|
190
|
+
assert log(x, y) == log(x) / log(y)
|
191
|
+
|
192
|
+
|
193
|
+
def test_lambertw():
|
194
|
+
assert LambertW(0) == 0
|
195
|
+
assert LambertW(E) == 1
|
196
|
+
assert LambertW(-1/E) == -1
|
197
|
+
assert LambertW(-log(2)/2) == -log(2)
|
198
|
+
|
199
|
+
|
200
|
+
def test_zeta():
|
201
|
+
x = Symbol("x")
|
202
|
+
assert zeta(1) == zoo
|
203
|
+
assert zeta(1, x) == zoo
|
204
|
+
|
205
|
+
assert zeta(0) == Rational(-1, 2)
|
206
|
+
assert zeta(0, x) == Rational(1, 2) - x
|
207
|
+
|
208
|
+
assert zeta(1, 2) == zoo
|
209
|
+
assert zeta(1, -7) == zoo
|
210
|
+
|
211
|
+
assert zeta(2, 1) == pi**2/6
|
212
|
+
|
213
|
+
assert zeta(2) == pi**2/6
|
214
|
+
assert zeta(4) == pi**4/90
|
215
|
+
assert zeta(6) == pi**6/945
|
216
|
+
|
217
|
+
assert zeta(2, 2) == pi**2/6 - 1
|
218
|
+
assert zeta(4, 3) == pi**4/90 - Rational(17, 16)
|
219
|
+
assert zeta(6, 4) == pi**6/945 - Rational(47449, 46656)
|
220
|
+
|
221
|
+
assert zeta(-1) == -Rational(1, 12)
|
222
|
+
assert zeta(-2) == 0
|
223
|
+
assert zeta(-3) == Rational(1, 120)
|
224
|
+
assert zeta(-4) == 0
|
225
|
+
assert zeta(-5) == -Rational(1, 252)
|
226
|
+
|
227
|
+
assert zeta(-1, 3) == -Rational(37, 12)
|
228
|
+
assert zeta(-1, 7) == -Rational(253, 12)
|
229
|
+
assert zeta(-1, -4) == Rational(119, 12)
|
230
|
+
assert zeta(-1, -9) == Rational(539, 12)
|
231
|
+
|
232
|
+
assert zeta(-4, 3) == -17
|
233
|
+
assert zeta(-4, -8) == 8772
|
234
|
+
|
235
|
+
assert zeta(0, 1) == -Rational(1, 2)
|
236
|
+
assert zeta(0, -1) == Rational(3, 2)
|
237
|
+
|
238
|
+
assert zeta(0, 2) == -Rational(3, 2)
|
239
|
+
assert zeta(0, -2) == Rational(5, 2)
|
240
|
+
|
241
|
+
|
242
|
+
def test_dirichlet_eta():
|
243
|
+
assert dirichlet_eta(0) == Rational(1, 2)
|
244
|
+
assert dirichlet_eta(-1) == Rational(1, 4)
|
245
|
+
assert dirichlet_eta(1) == log(2)
|
246
|
+
assert dirichlet_eta(2) == pi**2/12
|
247
|
+
assert dirichlet_eta(4) == pi**4*Rational(7, 720)
|
248
|
+
|
249
|
+
|
250
|
+
def test_kronecker_delta():
|
251
|
+
x = Symbol("x")
|
252
|
+
y = Symbol("y")
|
253
|
+
assert KroneckerDelta(1, 1) == 1
|
254
|
+
assert KroneckerDelta(1, 2) == 0
|
255
|
+
assert KroneckerDelta(x, x) == 1
|
256
|
+
assert KroneckerDelta(x**2 - y**2, x**2 - y**2) == 1
|
257
|
+
assert KroneckerDelta(0, 0) == 1
|
258
|
+
assert KroneckerDelta(0, 1) == 0
|
259
|
+
|
260
|
+
|
261
|
+
def test_levi_civita():
|
262
|
+
i = Symbol("i")
|
263
|
+
j = Symbol("j")
|
264
|
+
assert LeviCivita(1, 2, 3) == 1
|
265
|
+
assert LeviCivita(1, 3, 2) == -1
|
266
|
+
assert LeviCivita(1, 2, 2) == 0
|
267
|
+
assert LeviCivita(i, j, i) == 0
|
268
|
+
assert LeviCivita(1, i, i) == 0
|
269
|
+
assert LeviCivita(1, 2, 3, 1) == 0
|
270
|
+
assert LeviCivita(4, 5, 1, 2, 3) == 1
|
271
|
+
assert LeviCivita(4, 5, 2, 1, 3) == -1
|
272
|
+
|
273
|
+
|
274
|
+
def test_erf():
|
275
|
+
x = Symbol("x")
|
276
|
+
y = Symbol("y")
|
277
|
+
assert erf(nan) == nan
|
278
|
+
assert erf(oo) == 1
|
279
|
+
assert erf(-oo) == -1
|
280
|
+
assert erf(0) == 0
|
281
|
+
assert erf(-2) == -erf(2)
|
282
|
+
assert erf(-x*y) == -erf(x*y)
|
283
|
+
assert erf(-x - y) == -erf(x + y)
|
284
|
+
|
285
|
+
|
286
|
+
def test_erfc():
|
287
|
+
assert erfc(nan) == nan
|
288
|
+
assert erfc(oo) == 0
|
289
|
+
assert erfc(-oo) == 2
|
290
|
+
assert erfc(0) == 1
|
291
|
+
|
292
|
+
|
293
|
+
def test_lowergamma():
|
294
|
+
assert lowergamma(1, 2) == 1 - exp(-2)
|
295
|
+
|
296
|
+
|
297
|
+
def test_uppergamma():
|
298
|
+
assert uppergamma(1, 2) == exp(-2)
|
299
|
+
assert uppergamma(4, 0) == 6
|
300
|
+
|
301
|
+
|
302
|
+
def test_loggamma():
|
303
|
+
assert loggamma(-1) == oo
|
304
|
+
assert loggamma(-2) == oo
|
305
|
+
assert loggamma(0) == oo
|
306
|
+
assert loggamma(1) == 0
|
307
|
+
assert loggamma(2) == 0
|
308
|
+
assert loggamma(3) == log(2)
|
309
|
+
|
310
|
+
|
311
|
+
def test_beta():
|
312
|
+
assert beta(3, 2) == beta(2, 3)
|
313
|
+
|
314
|
+
|
315
|
+
def test_polygamma():
|
316
|
+
assert polygamma(0, -9) == zoo
|
317
|
+
assert polygamma(0, -9) == zoo
|
318
|
+
assert polygamma(0, -1) == zoo
|
319
|
+
assert polygamma(0, 0) == zoo
|
320
|
+
assert polygamma(0, 1) == -EulerGamma
|
321
|
+
assert polygamma(0, 7) == Rational(49, 20) - EulerGamma
|
322
|
+
assert polygamma(1, 1) == pi**2/6
|
323
|
+
assert polygamma(1, 2) == pi**2/6 - 1
|
324
|
+
assert polygamma(1, 3) == pi**2/6 - Rational(5, 4)
|
325
|
+
assert polygamma(3, 1) == pi**4 / 15
|
326
|
+
assert polygamma(3, 5) == 6*(Rational(-22369, 20736) + pi**4/90)
|
327
|
+
assert polygamma(5, 1) == 8 * pi**6 / 63
|
328
|
+
|
329
|
+
|
330
|
+
def test_digamma():
|
331
|
+
x = Symbol("x")
|
332
|
+
assert digamma(x) == polygamma(0, x)
|
333
|
+
assert digamma(0) == zoo
|
334
|
+
assert digamma(1) == -EulerGamma
|
335
|
+
|
336
|
+
|
337
|
+
def test_trigamma():
|
338
|
+
x = Symbol("x")
|
339
|
+
assert trigamma(-2) == zoo
|
340
|
+
assert trigamma(x) == polygamma(1, x)
|
341
|
+
|
342
|
+
|
343
|
+
def test_sign():
|
344
|
+
assert sign(1.2) == 1
|
345
|
+
assert sign(-1.2) == -1
|
346
|
+
assert sign(3*I) == I
|
347
|
+
assert sign(-3*I) == -I
|
348
|
+
assert sign(0) == 0
|
349
|
+
assert sign(nan) == nan
|
350
|
+
|
351
|
+
|
352
|
+
def test_floor():
|
353
|
+
x = Symbol("x")
|
354
|
+
y = Symbol("y")
|
355
|
+
assert floor(nan) == nan
|
356
|
+
assert floor(oo) == oo
|
357
|
+
assert floor(-oo) == -oo
|
358
|
+
assert floor(0) == 0
|
359
|
+
assert floor(1) == 1
|
360
|
+
assert floor(-1) == -1
|
361
|
+
assert floor(E) == 2
|
362
|
+
assert floor(pi) == 3
|
363
|
+
assert floor(Rational(1, 2)) == 0
|
364
|
+
assert floor(-Rational(1, 2)) == -1
|
365
|
+
assert floor(Rational(7, 3)) == 2
|
366
|
+
assert floor(-Rational(7, 3)) == -3
|
367
|
+
assert floor(Float(17.0)) == 17
|
368
|
+
assert floor(-Float(17.0)) == -17
|
369
|
+
assert floor(Float(7.69)) == 7
|
370
|
+
assert floor(-Float(7.69)) == -8
|
371
|
+
assert floor(I) == I
|
372
|
+
assert floor(-I) == -I
|
373
|
+
assert floor(2*I) == 2*I
|
374
|
+
assert floor(-2*I) == -2*I
|
375
|
+
assert floor(E + pi) == floor(E + pi)
|
376
|
+
assert floor(I + pi) == floor(I + pi)
|
377
|
+
assert floor(floor(pi)) == 3
|
378
|
+
assert floor(floor(y)) == floor(y)
|
379
|
+
assert floor(floor(x)) == floor(floor(x))
|
380
|
+
assert floor(x) == floor(x)
|
381
|
+
assert floor(2*x) == floor(2*x)
|
382
|
+
|
383
|
+
|
384
|
+
def test_ceiling():
|
385
|
+
x = Symbol("x")
|
386
|
+
y = Symbol("y")
|
387
|
+
assert ceiling(nan) == nan
|
388
|
+
assert ceiling(oo) == oo
|
389
|
+
assert ceiling(-oo) == -oo
|
390
|
+
assert ceiling(0) == 0
|
391
|
+
assert ceiling(1) == 1
|
392
|
+
assert ceiling(-1) == -1
|
393
|
+
assert ceiling(E) == 3
|
394
|
+
assert ceiling(pi) == 4
|
395
|
+
assert ceiling(Rational(1, 2)) == 1
|
396
|
+
assert ceiling(-Rational(1, 2)) == 0
|
397
|
+
assert ceiling(Rational(7, 3)) == 3
|
398
|
+
assert ceiling(-Rational(7, 3)) == -2
|
399
|
+
assert ceiling(Float(17.0)) == 17
|
400
|
+
assert ceiling(-Float(17.0)) == -17
|
401
|
+
assert ceiling(Float(7.69)) == 8
|
402
|
+
assert ceiling(-Float(7.69)) == -7
|
403
|
+
assert ceiling(I) == I
|
404
|
+
assert ceiling(-I) == -I
|
405
|
+
assert ceiling(2*I) == 2*I
|
406
|
+
assert ceiling(-2*I) == -2*I
|
407
|
+
assert ceiling(E + pi) == ceiling(E + pi)
|
408
|
+
assert ceiling(I + pi) == ceiling(I + pi)
|
409
|
+
assert ceiling(ceiling(pi)) == 4
|
410
|
+
assert ceiling(ceiling(y)) == ceiling(y)
|
411
|
+
assert ceiling(ceiling(x)) == ceiling(ceiling(x))
|
412
|
+
assert ceiling(x) == ceiling(x)
|
413
|
+
assert ceiling(2*x) == ceiling(2*x)
|
414
|
+
|
415
|
+
|
416
|
+
def test_conjugate():
|
417
|
+
assert conjugate(pi) == pi
|
418
|
+
assert conjugate(I) == -I
|
419
|
+
|
420
|
+
|
421
|
+
def test_unevaluated_expr():
|
422
|
+
x = Symbol("x")
|
423
|
+
t = UnevaluatedExpr(x)
|
424
|
+
assert x + t != 2 * x
|
425
|
+
assert not t.is_number
|
426
|
+
assert not t.is_integer
|
427
|
+
assert not t.is_finite
|
428
|
+
|
429
|
+
t = UnevaluatedExpr(1)
|
430
|
+
assert t.is_number
|
431
|
+
assert t.is_integer
|
432
|
+
assert t.is_finite
|