@@ -1174,92 +1174,96 @@ cdef class Constant(Basic):
1174
1174
self .thisptr = symengine.make_rcp_Constant(name.encode(" utf-8" ))
1175
1175
1176
1176
def _sympy_ (self ):
1177
- import sympy
1178
- if self == E:
1179
- return sympy.E
1180
- elif self == pi:
1181
- return sympy.pi
1182
- elif self == golden_ratio:
1183
- return sympy.GoldenRatio
1184
- elif self == catalan:
1185
- return sympy.Catalan
1186
- elif self == eulergamma:
1187
- return sympy.EulerGamma
1188
- else :
1189
- raise Exception (" Unknown Constant" )
1177
+ raise Exception (" Unknown Constant" )
1190
1178
1191
1179
def _sage_ (self ):
1192
- import sage.all as sage
1193
- if self == E:
1194
- return sage.e
1195
- elif self == pi:
1196
- return sage.pi
1197
- elif self == golden_ratio:
1198
- return sage.golden_ratio
1199
- elif self == catalan:
1200
- return sage.catalan
1201
- elif self == eulergamma:
1202
- return sage.euler_gamma
1203
- else :
1204
- raise Exception (" Unknown Constant" )
1180
+ raise Exception (" Unknown Constant" )
1205
1181
1206
1182
1207
- class ImaginaryUnit (Complex ):
1183
+ cdef class ImaginaryUnit(Complex):
1208
1184
1209
- def __new__ (cls ):
1210
- cdef Basic r = Complex.__new__ (ImaginaryUnit)
1211
- r.thisptr = symengine.I
1212
- return r
1185
+ def __cinit__ (Basic self ):
1186
+ self .thisptr = symengine.I
1213
1187
1214
1188
I = ImaginaryUnit()
1215
1189
1216
1190
1217
- class Pi (Constant ):
1191
+ cdef class Pi(Constant):
1218
1192
1219
- def __new__ (cls ):
1220
- cdef Basic r = Constant.__new__ (Pi)
1221
- r.thisptr = symengine.pi
1222
- return r
1193
+ def __cinit__ (Basic self ):
1194
+ self .thisptr = symengine.pi
1195
+
1196
+ def _sympy_ (self ):
1197
+ import sympy
1198
+ return sympy.pi
1199
+
1200
+ def _sage_ (self ):
1201
+ import sage.all as sage
1202
+ return sage.pi
1223
1203
1224
1204
pi = Pi()
1225
1205
1226
1206
1227
- class Exp1 (Constant ):
1207
+ cdef class Exp1(Constant):
1228
1208
1229
- def __new__ (cls ):
1230
- cdef Basic r = Constant.__new__ (Exp1)
1231
- r.thisptr = symengine.E
1232
- return r
1209
+ def __cinit__ (Basic self ):
1210
+ self .thisptr = symengine.E
1211
+
1212
+ def _sympy_ (self ):
1213
+ import sympy
1214
+ return sympy.E
1215
+
1216
+ def _sage_ (self ):
1217
+ import sage.all as sage
1218
+ return sage.e
1233
1219
1234
1220
E = Exp1()
1235
1221
1236
1222
1237
- class GoldenRatio (Constant ):
1223
+ cdef class GoldenRatio(Constant):
1238
1224
1239
- def __new__ (cls ):
1240
- cdef Basic r = Constant.__new__ (GoldenRatio)
1241
- r.thisptr = symengine.GoldenRatio
1242
- return r
1225
+ def __cinit__ (Basic self ):
1226
+ self .thisptr = symengine.GoldenRatio
1227
+
1228
+ def _sympy_ (self ):
1229
+ import sympy
1230
+ return sympy.GoldenRatio
1231
+
1232
+ def _sage_ (self ):
1233
+ import sage.all as sage
1234
+ return sage.golden_ratio
1243
1235
1244
1236
golden_ratio = GoldenRatio()
1245
1237
1246
1238
1247
- class Catalan (Constant ):
1239
+ cdef class Catalan(Constant):
1248
1240
1249
- def __new__ (cls ):
1250
- cdef Basic r = Constant.__new__ (Catalan)
1251
- r.thisptr = symengine.Catalan
1252
- return r
1241
+ def __cinit__ (Basic self ):
1242
+ self .thisptr = symengine.Catalan
1243
+
1244
+ def _sympy_ (self ):
1245
+ import sympy
1246
+ return sympy.Catalan
1247
+
1248
+ def _sage_ (self ):
1249
+ import sage.all as sage
1250
+ return sage.catalan
1253
1251
1254
1252
catalan = Catalan()
1255
1253
1256
1254
1257
- class EulerGamma (Constant ):
1255
+ cdef class EulerGamma(Constant):
1258
1256
1259
- def __new__ (cls ):
1260
- cdef Basic r = Constant.__new__ (EulerGamma)
1261
- r.thisptr = symengine.EulerGamma
1262
- return r
1257
+ def __cinit__ (Basic self ):
1258
+ self .thisptr = symengine.EulerGamma
1259
+
1260
+ def _sympy_ (self ):
1261
+ import sympy
1262
+ return sympy.EulerGamma
1263
+
1264
+ def _sage_ (self ):
1265
+ import sage.all as sage
1266
+ return sage.euler_gamma
1263
1267
1264
1268
eulergamma = EulerGamma()
1265
1269
@@ -1270,7 +1274,7 @@ cdef class Boolean(Basic):
1270
1274
return c2py(< RCP[const symengine.Basic]> (deref(symengine.rcp_static_cast_Boolean(self .thisptr)).logical_not()))
1271
1275
1272
1276
1273
- class BooleanAtom (Boolean ):
1277
+ cdef class BooleanAtom(Boolean):
1274
1278
1275
1279
@property
1276
1280
def is_Boolean (self ):
@@ -1281,12 +1285,10 @@ class BooleanAtom(Boolean):
1281
1285
return True
1282
1286
1283
1287
1284
- class BooleanTrue (BooleanAtom ):
1288
+ cdef class BooleanTrue(BooleanAtom):
1285
1289
1286
- def __new__ (cls ):
1287
- cdef Basic r = BooleanAtom.__new__ (BooleanTrue)
1288
- r.thisptr = symengine.boolTrue
1289
- return r
1290
+ def __cinit__ (Basic self ):
1291
+ self .thisptr = symengine.boolTrue
1290
1292
1291
1293
def _sympy_ (self ):
1292
1294
import sympy
@@ -1298,12 +1300,10 @@ class BooleanTrue(BooleanAtom):
1298
1300
true = BooleanTrue()
1299
1301
1300
1302
1301
- class BooleanFalse (BooleanAtom ):
1303
+ cdef class BooleanFalse(BooleanAtom):
1302
1304
1303
- def __new__ (cls ):
1304
- cdef Basic r = BooleanAtom.__new__ (BooleanFalse)
1305
- r.thisptr = symengine.boolFalse
1306
- return r
1305
+ def __cinit__ (Basic self ):
1306
+ self .thisptr = symengine.boolFalse
1307
1307
1308
1308
def _sympy_ (self ):
1309
1309
import sympy
@@ -1842,16 +1842,14 @@ cdef class Complex(Number):
1842
1842
return self .real_part()._sage_() + sage.I * self .imaginary_part()._sage_()
1843
1843
1844
1844
1845
- class Infinity (Number ):
1845
+ cdef class Infinity(Number):
1846
1846
1847
1847
@property
1848
1848
def is_infinite (self ):
1849
1849
return True
1850
1850
1851
- def __new__ (cls ):
1852
- cdef Basic r = Number.__new__ (Infinity)
1853
- r.thisptr = symengine.Inf
1854
- return r
1851
+ def __cinit__ (Basic self ):
1852
+ self .thisptr = symengine.Inf
1855
1853
1856
1854
def _sympy_ (self ):
1857
1855
import sympy
@@ -1864,16 +1862,14 @@ class Infinity(Number):
1864
1862
oo = Infinity()
1865
1863
1866
1864
1867
- class NegativeInfinity (Number ):
1865
+ cdef class NegativeInfinity(Number):
1868
1866
1869
1867
@property
1870
1868
def is_infinite (self ):
1871
1869
return True
1872
1870
1873
- def __new__ (cls ):
1874
- cdef Basic r = Number.__new__ (NegativeInfinity)
1875
- r.thisptr = symengine.neg(symengine.Inf)
1876
- return r
1871
+ def __cinit__ (Basic self ):
1872
+ self .thisptr = symengine.neg(symengine.Inf)
1877
1873
1878
1874
def _sympy_ (self ):
1879
1875
import sympy
@@ -1886,16 +1882,14 @@ class NegativeInfinity(Number):
1886
1882
minus_oo = NegativeInfinity()
1887
1883
1888
1884
1889
- class ComplexInfinity (Number ):
1885
+ cdef class ComplexInfinity(Number):
1890
1886
1891
1887
@property
1892
1888
def is_infinite (self ):
1893
1889
return True
1894
1890
1895
- def __new__ (cls ):
1896
- cdef Basic r = Number.__new__ (ComplexInfinity)
1897
- r.thisptr = symengine.ComplexInf
1898
- return r
1891
+ def __cinit__ (Basic self ):
1892
+ self .thisptr = symengine.ComplexInf
1899
1893
1900
1894
def _sympy_ (self ):
1901
1895
import sympy
@@ -1908,7 +1902,7 @@ class ComplexInfinity(Number):
1908
1902
zoo = ComplexInfinity()
1909
1903
1910
1904
1911
- class NaN (Number ):
1905
+ cdef class NaN(Number):
1912
1906
1913
1907
@property
1914
1908
def is_rational (self ):
@@ -1926,10 +1920,8 @@ class NaN(Number):
1926
1920
def is_finite (self ):
1927
1921
return None
1928
1922
1929
- def __new__ (cls ):
1930
- cdef Basic r = Number.__new__ (NaN)
1931
- r.thisptr = symengine.Nan
1932
- return r
1923
+ def __cinit__ (Basic self ):
1924
+ self .thisptr = symengine.Nan
1933
1925
1934
1926
def _sympy_ (self ):
1935
1927
import sympy
@@ -1971,12 +1963,8 @@ minus_one = NegativeOne()
1971
1963
1972
1964
class Half (Rational ):
1973
1965
def __new__ (cls ):
1974
- cdef Basic r = Number.__new__ (Integer)
1975
- cdef Basic s = Number.__new__ (Integer)
1976
1966
cdef Basic q = Number.__new__ (Half)
1977
- r.thisptr = < RCP[const symengine.Basic]> symengine.integer(1 )
1978
- s.thisptr = < RCP[const symengine.Basic]> symengine.integer(2 )
1979
- q.thisptr = symengine.div(r.thisptr, s.thisptr)
1967
+ q.thisptr = < RCP[const symengine.Basic]> symengine.rational(1 , 2 )
1980
1968
return q
1981
1969
1982
1970
half = Half()
@@ -3698,9 +3686,9 @@ cdef class Sieve_iterator:
3698
3686
3699
3687
3700
3688
def module_cleanup ():
3701
- global I, E, pi, oo, zoo, nan, true, false, golden_ratio, catalan, eulergamma, sympy_module, sage_module
3689
+ global I, E, pi, oo, minus_oo, zoo, nan, true, false, golden_ratio, catalan, eulergamma, sympy_module, sage_module
3702
3690
funcs.clear()
3703
- del I, E, pi, oo, zoo, nan, true, false, golden_ratio, catalan, eulergamma, sympy_module, sage_module
3691
+ del I, E, pi, oo, minus_oo, zoo, nan, true, false, golden_ratio, catalan, eulergamma, sympy_module, sage_module
3704
3692
3705
3693
import atexit
3706
3694
atexit.register(module_cleanup)
0 commit comments