From e385e2fc12944733f7b3429f79e1de9edb57c823 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 4 May 2023 13:10:58 -0500 Subject: [PATCH 01/92] Add as_powers_dict --- symengine/lib/symengine_wrapper.pyx | 37 +++++++++++++++++++++++++++++ symengine/tests/test_expr.py | 15 +++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index 24b52c0e..f3cd0417 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -1169,6 +1169,11 @@ cdef class Basic(object): raise TypeError("Can't convert expression to float") return complex(f) + def as_powers_dict(self): + d = collections.defaultdict(int) + d[self] = 1 + return d + def series(ex, x=None, x0=0, n=6, as_deg_coef_pair=False): # TODO: check for x0 an infinity, see sympy/core/expr.py @@ -1345,6 +1350,11 @@ cdef class ImaginaryUnit(Complex): def __cinit__(Basic self): self.thisptr = symengine.I + def as_powers_dict(self): + d = collections.defaultdict(int) + d[minus_one] = half + return d + I = ImaginaryUnit() @@ -2078,6 +2088,13 @@ cdef class NegativeInfinity(Number): import sage.all as sage return -sage.oo + def as_powers_dict(self): + d = collections.defaultdict(int) + d[minus_one] = 1 + d[oo] = 1 + return d + + minus_oo = NegativeInfinity() @@ -2276,6 +2293,21 @@ class Mul(AssocOp): c2py(deref(X).get_coef()) return d + def as_powers_dict(Basic self): + cdef RCP[const symengine.Mul] X = symengine.rcp_static_cast_Mul(self.thisptr) + cdef rcp_const_basic coef = (deref(X).get_coef()) + cdef map_basic_basic m = deref(X).get_dict() + d = c2py(coef).as_powers_dict() + + it = m.begin() + it_end = m.end() + while it != it_end: + d[c2py((deref(it).first))] =\ + c2py((deref(it).second)) + inc(it) + + return d + class Pow(Expr): @@ -2319,6 +2351,11 @@ class Pow(Expr): def func(self): return self.__class__ + def as_powers_dict(self): + d = collections.defaultdict(int) + d[self.base] = self.exp + return d + class Function(Expr): diff --git a/symengine/tests/test_expr.py b/symengine/tests/test_expr.py index f69099a5..e75e3d4c 100644 --- a/symengine/tests/test_expr.py +++ b/symengine/tests/test_expr.py @@ -1,4 +1,4 @@ -from symengine import Symbol, Integer +from symengine import Symbol, Integer, oo from symengine.test_utilities import raises @@ -12,3 +12,16 @@ def test_as_coefficients_dict(): [0, 0, 3, 0] assert (3.0*x*y).as_coefficients_dict()[3.0*x*y] == 0 assert (3.0*x*y).as_coefficients_dict()[x*y] == 3.0 + + +def test_as_powers_dict(): + x = Symbol('x') + y = Symbol('y') + + assert (2*x**y).as_coefficients_dict() == {2: 1, x: y} + assert (2*x**2*y**3).as_coefficients_dict() == {2: 1, x: 2, y: 3} + assert (-oo).as_coefficients_dict() == {-1: 1, oo: 1} + assert (x**y).as_coefficients_dict() == {x: y} + assert ((1/Integer(2))**y).as_coefficients_dict() == {2: -y} + assert (2**y).as_coefficients_dict() == {2: y} + assert (2**-y).as_coefficients_dict() == {2: -y} From dc8fd64296da7924646a4cec46946c630fb947ab Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 4 May 2023 17:55:22 -0500 Subject: [PATCH 02/92] Fix rational and mul --- symengine/lib/symengine_wrapper.pyx | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index f3cd0417..1210a171 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -2295,15 +2295,22 @@ class Mul(AssocOp): def as_powers_dict(Basic self): cdef RCP[const symengine.Mul] X = symengine.rcp_static_cast_Mul(self.thisptr) - cdef rcp_const_basic coef = (deref(X).get_coef()) cdef map_basic_basic m = deref(X).get_dict() - d = c2py(coef).as_powers_dict() + coef = c2py((deref(X).get_coef())) + if coef == 1: + d = collections.defaultdict(int) + else: + d = coef.as_powers_dict() it = m.begin() it_end = m.end() while it != it_end: - d[c2py((deref(it).first))] =\ - c2py((deref(it).second)) + base = c2py((deref(it).first)) + exp = c2py((deref(it).second)) + if base.is_Rational and base.p < base.q and base.p > 0: + d[1/base] -= exp + else: + d[base] += exp inc(it) return d @@ -2351,9 +2358,13 @@ class Pow(Expr): def func(self): return self.__class__ - def as_powers_dict(self): + def as_powers_dict(Basic self): d = collections.defaultdict(int) - d[self.base] = self.exp + base, exp = self.as_base_exp() + if base.is_Rational and base.p < base.q and base.p > 0: + d[1/base] = -exp + else: + d[base] = exp return d From 0c1111c720829afea5d03b9b3f1ff7aec374d0f2 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 4 May 2023 18:07:24 -0500 Subject: [PATCH 03/92] Fix tests --- symengine/tests/test_expr.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/symengine/tests/test_expr.py b/symengine/tests/test_expr.py index e75e3d4c..8cbf4ab7 100644 --- a/symengine/tests/test_expr.py +++ b/symengine/tests/test_expr.py @@ -18,10 +18,11 @@ def test_as_powers_dict(): x = Symbol('x') y = Symbol('y') - assert (2*x**y).as_coefficients_dict() == {2: 1, x: y} - assert (2*x**2*y**3).as_coefficients_dict() == {2: 1, x: 2, y: 3} - assert (-oo).as_coefficients_dict() == {-1: 1, oo: 1} - assert (x**y).as_coefficients_dict() == {x: y} - assert ((1/Integer(2))**y).as_coefficients_dict() == {2: -y} - assert (2**y).as_coefficients_dict() == {2: y} - assert (2**-y).as_coefficients_dict() == {2: -y} + assert (2*x**y).as_powers_dict() == {2: 1, x: y} + assert (2*x**2*y**3).as_powers_dict() == {2: 1, x: 2, y: 3} + assert (-oo).as_powers_dict() == {Integer(-1): 1, oo: 1} + assert (x**y).as_powers_dict() == {x: y} + assert ((1/Integer(2))**y).as_powers_dict() == {Integer(2): -y} + assert (x*(1/Integer(2))**y).as_powers_dict() == {x: Integer(1), Integer(2): -y} + assert (2**y).as_powers_dict() == {2: y} + assert (2**-y).as_powers_dict() == {2: -y} From 625004b50186945fa01b9a0c87b58281ac645a11 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 11 May 2023 14:39:27 -0500 Subject: [PATCH 04/92] Define __floor__, __mod__, __divmod__ for basic --- symengine/lib/symengine_wrapper.pyx | 19 ++++++++++--------- symengine/tests/test_arit.py | 13 ++++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index 1210a171..b6a34e60 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -890,6 +890,16 @@ cdef class Basic(object): if A is None or B is None: return NotImplemented return c2py(symengine.div(A.thisptr, B.thisptr)) + def __floordiv__(x, y): + return floor(x/y) + + def __mod__(x, y): + return x - y * floor(x/y) + + def __divmod__(x, y): + f = floor(x/y) + return f, x - y * f + def __pow__(a, b, c): if c is not None: return powermod(a, b, c) @@ -1830,15 +1840,6 @@ class Integer(Rational): else: return NotImplemented - def __floordiv__(x, y): - return quotient(x, y) - - def __mod__(x, y): - return mod(x, y) - - def __divmod__(x, y): - return quotient_mod(x, y) - def _sympy_(Basic self): import sympy return sympy.Integer(int(self)) diff --git a/symengine/tests/test_arit.py b/symengine/tests/test_arit.py index b8116514..e6ff192b 100644 --- a/symengine/tests/test_arit.py +++ b/symengine/tests/test_arit.py @@ -1,7 +1,7 @@ from symengine.test_utilities import raises from symengine import (Symbol, Integer, Add, Mul, Pow, Rational, sqrt, - symbols, S, I, count_ops) + symbols, S, I, count_ops, floor) def test_arit1(): @@ -165,12 +165,23 @@ def test_as_numer_denom(): assert x == Integer(-5) assert y == Integer(1) + +def test_floor(): + exprs = [Symbol("x"), Symbol("y"), Integer(2), Rational(-3, 5), Integer(-3)] + + for x in exprs: + for y in exprs: + assert x // y == floor(x / y) + assert x == y * (x // y) + x % y + + def test_as_real_imag(): x, y = (5 + 6 * I).as_real_imag() assert x == 5 assert y == 6 + def test_from_args(): x = Symbol("x") y = Symbol("y") From 4fba9a6db38a268666903c724a5a15e7d7cb2264 Mon Sep 17 00:00:00 2001 From: Bjorn Date: Sat, 24 Jun 2023 12:14:28 +0200 Subject: [PATCH 05/92] Tentative fix of .has for FunctionSymbol (#446) * Tentative fix of .has for FunctionSymbol * SymEngine supports FunctionSymbol in has_symbol --- CMakeLists.txt | 3 +++ symengine/__init__.py | 3 ++- symengine/lib/symengine.pxd | 2 +- symengine/lib/symengine_wrapper.pyx | 5 ++--- symengine/tests/test_functions.py | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cf3c25c..418b6704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8.12) if (POLICY CMP0057) cmake_policy(SET CMP0057 NEW) # needed for llvm >= 16 endif () +if (POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) # allow user to set *_ROOT variables +endif() project(python_wrapper) diff --git a/symengine/__init__.py b/symengine/__init__.py index 19c0d69b..fa72ded4 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -26,7 +26,7 @@ Gt, Lt, And, Or, Not, Nand, Nor, Xor, Xnor, perfect_power, integer_nthroot, isprime, sqrt_mod, Expr, cse, count_ops, ccode, Piecewise, Contains, Interval, FiniteSet, linsolve, - FunctionSymbol as AppliedUndef, + FunctionSymbol, golden_ratio as GoldenRatio, catalan as Catalan, eulergamma as EulerGamma, @@ -37,6 +37,7 @@ from .printing import init_printing +AppliedUndef = FunctionSymbol # an alias EmptySet = wrapper.S.EmptySet UniversalSet = wrapper.S.UniversalSet Reals = wrapper.S.Reals diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 449ffc01..ff5cd772 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -930,7 +930,7 @@ cdef extern from "" namespace "SymEngine": unsigned next_prime() nogil cdef extern from "" namespace "SymEngine": - bool has_symbol(const Basic &b, const Symbol &x) nogil except + + bool has_symbol(const Basic &b, const Basic &x) nogil except + rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except + set_basic free_symbols(const Basic &b) nogil except + set_basic free_symbols(const MatrixBase &b) nogil except + diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index b6a34e60..de90b2cb 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -4846,12 +4846,11 @@ def powermod_list(a, b, m): def has_symbol(obj, symbol=None): cdef Basic b = _sympify(obj) cdef Basic s = _sympify(symbol) - require(s, Symbol) + require(s, (Symbol, FunctionSymbol)) if (not symbol): return not b.free_symbols.empty() else: - return symengine.has_symbol(deref(b.thisptr), - deref(symengine.rcp_static_cast_Symbol(s.thisptr))) + return symengine.has_symbol(deref(b.thisptr), deref(s.thisptr)) cdef class _Lambdify(object): diff --git a/symengine/tests/test_functions.py b/symengine/tests/test_functions.py index 267506da..3a19b122 100644 --- a/symengine/tests/test_functions.py +++ b/symengine/tests/test_functions.py @@ -85,6 +85,7 @@ def test_derivative(): assert s.variables == (x,) fxy = Function("f")(x, y) + assert (1+fxy).has(fxy) g = Derivative(Function("f")(x, y), x, 2, y, 1) assert g == fxy.diff(x, x, y) assert g == fxy.diff(y, 1, x, 2) From 4f168559c28852f7d0eaa6f664d270e91fcb0800 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 09:44:54 -0500 Subject: [PATCH 06/92] cython 3 compatibility --- symengine/lib/symengine.pxd | 407 +++++++++++++++--------------------- 1 file changed, 163 insertions(+), 244 deletions(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index ff5cd772..b70b7a0d 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -4,6 +4,8 @@ from libcpp.map cimport map from libcpp.vector cimport vector from cpython.ref cimport PyObject from libcpp.pair cimport pair +from libcpp.set cimport multiset, set +from libcpp.unordered_map cimport unordered_map include "config.pxi" @@ -31,94 +33,6 @@ cdef extern from 'symengine/mp_class.h' namespace "SymEngine": rational_class(mpq_t) const mpq_t get_mpq_t(const rational_class &a) -cdef extern from "" namespace "std": -# Cython's libcpp.set does not support two template arguments to set. -# Methods to declare and iterate a set with a custom compare are given here - cdef cppclass set[T, U]: - cppclass iterator: - T& operator*() - iterator operator++() nogil - iterator operator--() nogil - bint operator==(iterator) nogil - bint operator!=(iterator) nogil - iterator begin() nogil - iterator end() nogil - iterator insert(T&) nogil - - cdef cppclass multiset[T, U]: - cppclass iterator: - T& operator*() - iterator operator++() nogil - iterator operator--() nogil - bint operator==(iterator) nogil - bint operator!=(iterator) nogil - iterator begin() nogil - iterator end() nogil - iterator insert(T&) nogil - -cdef extern from "" namespace "std" nogil: - cdef cppclass unordered_map[T, U]: - cppclass iterator: - pair[T, U]& operator*() - iterator operator++() - iterator operator--() - bint operator==(iterator) - bint operator!=(iterator) - cppclass reverse_iterator: - pair[T, U]& operator*() - iterator operator++() - iterator operator--() - bint operator==(reverse_iterator) - bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass - unordered_map() except + - unordered_map(unordered_map&) except + - #unordered_map(key_compare&) - U& operator[](T&) - #unordered_map& operator=(unordered_map&) - bint operator==(unordered_map&, unordered_map&) - bint operator!=(unordered_map&, unordered_map&) - bint operator<(unordered_map&, unordered_map&) - bint operator>(unordered_map&, unordered_map&) - bint operator<=(unordered_map&, unordered_map&) - bint operator>=(unordered_map&, unordered_map&) - U& at(T&) - iterator begin() - const_iterator const_begin "begin"() - void clear() - size_t count(T&) - bint empty() - iterator end() - const_iterator const_end "end"() - pair[iterator, iterator] equal_range(T&) - #pair[const_iterator, const_iterator] equal_range(key_type&) - void erase(iterator) - void erase(iterator, iterator) - size_t erase(T&) - iterator find(T&) - const_iterator const_find "find"(T&) - pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& - iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& - #void insert(input_iterator, input_iterator) - #key_compare key_comp() - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) - size_t max_size() - reverse_iterator rbegin() - const_reverse_iterator const_rbegin "rbegin"() - reverse_iterator rend() - const_reverse_iterator const_rend "rend"() - size_t size() - void swap(unordered_map&) - iterator upper_bound(T&) - const_iterator const_upper_bound "upper_bound"(T&) - #value_compare value_comp() - void max_load_factor(float) - float max_load_factor() - cdef extern from "" namespace "SymEngine": cdef enum ENull: null @@ -126,17 +40,22 @@ cdef extern from "" namespace "SymEngine": cdef cppclass RCP[T]: T& operator*() nogil # Not yet supported in Cython: -# RCP[T]& operator=(RCP[T] &r_ptr) nogil except + - void reset() nogil except + +# RCP[T]& operator=(RCP[T] &r_ptr) except+ nogil + void reset() except+ nogil cdef cppclass Ptr[T]: - T& operator*() nogil except + + T& operator*() except+ nogil void print_stack_on_segfault() nogil cdef extern from "" namespace "SymEngine": ctypedef Basic const_Basic "const SymEngine::Basic" - ctypedef RCP[const Basic] rcp_const_basic "SymEngine::RCP" + # RCP[const_Basic] instead of RCP[const Basic] is because of https://github.com/cython/cython/issues/5478 + ctypedef RCP[const_Basic] rcp_const_basic "SymEngine::RCP" + #cdef cppclass rcp_const_basic "SymEngine::RCP": + # Basic& operator*() nogil + # void reset() except+ nogil + # pass # Cython has broken support for the following: # ctypedef map[rcp_const_basic, rcp_const_basic] map_basic_basic # So instead we replicate the map features we need here @@ -178,11 +97,11 @@ cdef extern from "" namespace "SymEngine": ctypedef map[RCP[Integer], unsigned] map_integer_uint "SymEngine::map_integer_uint" cdef struct RCPIntegerKeyLess cdef struct RCPBasicKeyLess - ctypedef set[rcp_const_basic, RCPBasicKeyLess] set_basic "SymEngine::set_basic" - ctypedef multiset[rcp_const_basic, RCPBasicKeyLess] multiset_basic "SymEngine::multiset_basic" + ctypedef set[rcp_const_basic] set_basic "SymEngine::set_basic" + ctypedef multiset[rcp_const_basic] multiset_basic "SymEngine::multiset_basic" cdef cppclass Basic: - string __str__() nogil except + - unsigned int hash() nogil except + + string __str__() except+ nogil + unsigned int hash() except+ nogil vec_basic get_args() nogil int __cmp__(const Basic &o) nogil @@ -193,11 +112,11 @@ cdef extern from "" namespace "SymEngine": ctypedef unordered_map[rcp_const_basic, rcp_const_number].iterator umap_basic_num_iterator "SymEngine::umap_basic_num::iterator" ctypedef vector[pair[rcp_const_basic, rcp_const_basic]] vec_pair "SymEngine::vec_pair" - bool eq(const Basic &a, const Basic &b) nogil except + - bool neq(const Basic &a, const Basic &b) nogil except + + bool eq(const Basic &a, const Basic &b) except+ nogil + bool neq(const Basic &a, const Basic &b) except+ nogil RCP[const Symbol] rcp_static_cast_Symbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil except + + RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) except+ nogil RCP[const Integer] rcp_static_cast_Integer "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Rational] rcp_static_cast_Rational "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Complex] rcp_static_cast_Complex "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil @@ -319,10 +238,10 @@ cdef extern from "" namespace "SymEngine": bool is_a_Not "SymEngine::is_a"(const Basic &b) nogil bool is_a_Or "SymEngine::is_a"(const Basic &b) nogil bool is_a_Xor "SymEngine::is_a"(const Basic &b) nogil - rcp_const_basic expand(rcp_const_basic &o, bool deep) nogil except + + rcp_const_basic expand(rcp_const_basic &o, bool deep) except+ nogil void as_numer_denom(rcp_const_basic &x, const Ptr[RCP[Basic]] &numer, const Ptr[RCP[Basic]] &denom) nogil void as_real_imag(rcp_const_basic &x, const Ptr[RCP[Basic]] &real, const Ptr[RCP[Basic]] &imag) nogil - void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) nogil except + + void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) except+ nogil cdef extern from "" namespace "SymEngine": rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil @@ -330,7 +249,7 @@ cdef extern from "" namespace "SymEngine": rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil cdef extern from "" namespace "SymEngine": - rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) nogil except + + rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) except+ nogil cdef extern from "" namespace "SymEngine": cdef cppclass Symbol(Basic): @@ -372,8 +291,8 @@ cdef extern from "pywrapper.h" namespace "SymEngine": PySymbol(string name, PyObject* pyobj, bool use_pickle) except + PyObject* get_py_object() except + - string wrapper_dumps(const Basic &x) nogil except + - rcp_const_basic wrapper_loads(const string &s) nogil except + + string wrapper_dumps(const Basic &x) except+ nogil + rcp_const_basic wrapper_loads(const string &s) except+ nogil cdef extern from "" namespace "SymEngine": cdef cppclass Integer(Number): @@ -443,9 +362,9 @@ cdef extern from "" namespace "SymEngine": pass cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) nogil except+ - cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) nogil except+ - cdef rcp_const_basic add(const vec_basic &a) nogil except+ + cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) except+ nogil + cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) except+ nogil + cdef rcp_const_basic add(const vec_basic &a) except+ nogil cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -453,10 +372,10 @@ cdef extern from "" namespace "SymEngine": const umap_basic_num &get_dict() cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) nogil except+ - cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) nogil except+ - cdef rcp_const_basic neg(rcp_const_basic &a) nogil except+ - cdef rcp_const_basic mul(const vec_basic &a) nogil except+ + cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) except+ nogil + cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) except+ nogil + cdef rcp_const_basic neg(rcp_const_basic &a) except+ nogil + cdef rcp_const_basic mul(const vec_basic &a) except+ nogil cdef cppclass Mul(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -465,9 +384,9 @@ cdef extern from "" namespace "SymEngine": cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &&d) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) nogil except+ - cdef rcp_const_basic sqrt(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic exp(rcp_const_basic &x) nogil except+ + cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) except+ nogil + cdef rcp_const_basic sqrt(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic exp(rcp_const_basic &x) except+ nogil cdef cppclass Pow(Basic): rcp_const_basic get_base() nogil @@ -491,9 +410,9 @@ cdef extern from "" namespace "SymEngine": void (*dec_ref)(void *), int (*comp)(void *, void *)) nogil rcp_const_basic make_rcp_RealDouble "SymEngine::make_rcp"(double x) nogil rcp_const_basic make_rcp_ComplexDouble "SymEngine::make_rcp"(double complex x) nogil - RCP[const PyModule] make_rcp_PyModule "SymEngine::make_rcp"(PyObject* (*) (rcp_const_basic x), \ - rcp_const_basic (*)(PyObject*), RCP[const Number] (*)(PyObject*, long bits), - rcp_const_basic (*)(PyObject*, rcp_const_basic)) nogil + RCP[const PyModule] make_rcp_PyModule "SymEngine::make_rcp"(PyObject* (*) (rcp_const_basic x) except +, \ + rcp_const_basic (*)(PyObject*) except +, RCP[const Number] (*)(PyObject*, long bits) except +, + rcp_const_basic (*)(PyObject*, rcp_const_basic) except +) except + rcp_const_basic make_rcp_PyNumber "SymEngine::make_rcp"(PyObject*, RCP[const PyModule] x) nogil RCP[const PyFunctionClass] make_rcp_PyFunctionClass "SymEngine::make_rcp"(PyObject* pyobject, string name, RCP[const PyModule] pymodule) nogil @@ -501,58 +420,58 @@ cdef extern from "" namespace "SymEngine": RCP[const PyFunctionClass] pyfunc_class, const PyObject* pyobject) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic sin(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic cos(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic tan(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic cot(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic csc(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic sec(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic asin(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acos(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic atan(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acot(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acsc(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic asec(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic sinh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic cosh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic tanh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic coth(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic csch(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic sech(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic asinh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acosh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic atanh(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acoth(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic acsch(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic asech(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) nogil except+ - cdef rcp_const_basic abs(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic max(const vec_basic &arg) nogil except+ - cdef rcp_const_basic min(const vec_basic &arg) nogil except+ - cdef rcp_const_basic gamma(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) nogil except+ - cdef rcp_const_basic lambertw(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic zeta(rcp_const_basic &s) nogil except+ - cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) nogil except+ - cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) nogil except+ - cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) nogil except+ - cdef rcp_const_basic levi_civita(const vec_basic &arg) nogil except+ - cdef rcp_const_basic erf(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic erfc(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except+ - cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except+ - cdef rcp_const_basic loggamma(rcp_const_basic &arg) nogil except+ - cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) nogil except+ - cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) nogil except+ - cdef rcp_const_basic digamma(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic trigamma(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic sign(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic floor(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic ceiling(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic conjugate(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic log(rcp_const_basic &x) nogil except+ - cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) nogil except+ - cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) nogil except+ + cdef rcp_const_basic sin(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic cos(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic tan(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic cot(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic csc(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic sec(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic asin(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acos(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic atan(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acot(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acsc(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic asec(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic sinh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic cosh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic tanh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic coth(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic csch(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic sech(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic asinh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acosh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic atanh(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acoth(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic acsch(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic asech(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) except+ nogil + cdef rcp_const_basic abs(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic max(const vec_basic &arg) except+ nogil + cdef rcp_const_basic min(const vec_basic &arg) except+ nogil + cdef rcp_const_basic gamma(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) except+ nogil + cdef rcp_const_basic lambertw(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic zeta(rcp_const_basic &s) except+ nogil + cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) except+ nogil + cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) except+ nogil + cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) except+ nogil + cdef rcp_const_basic levi_civita(const vec_basic &arg) except+ nogil + cdef rcp_const_basic erf(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic erfc(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil + cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil + cdef rcp_const_basic loggamma(rcp_const_basic &arg) except+ nogil + cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) except+ nogil + cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) except+ nogil + cdef rcp_const_basic digamma(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic trigamma(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic sign(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic floor(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic ceiling(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic conjugate(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic log(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) except+ nogil + cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) except+ nogil cdef cppclass Function(Basic): pass @@ -792,7 +711,7 @@ cdef extern from "" namespace "SymEngine": const unsigned ncols() nogil rcp_const_basic get(unsigned i, unsigned j) nogil rcp_const_basic set(unsigned i, unsigned j, rcp_const_basic e) nogil - string __str__() nogil except+ + string __str__() except+ nogil bool eq(const MatrixBase &) nogil rcp_const_basic det() nogil void inv(MatrixBase &) @@ -842,20 +761,20 @@ cdef extern from "" namespace "SymEngine": bool is_a_DenseMatrix "SymEngine::is_a"(const MatrixBase &b) nogil DenseMatrix* static_cast_DenseMatrix "static_cast"(const MatrixBase *a) void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A, - DenseMatrix &B) nogil except + - void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil except + + DenseMatrix &B) except+ nogil + void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) except+ nogil void inverse_GJ "SymEngine::inverse_gauss_jordan"(const DenseMatrix &A, - DenseMatrix &B) nogil except + + DenseMatrix &B) except+ nogil void FFLU_solve "SymEngine::fraction_free_LU_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) nogil except + + const DenseMatrix &b, DenseMatrix &x) except+ nogil void FFGJ_solve "SymEngine::fraction_free_gauss_jordan_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) nogil except + + const DenseMatrix &b, DenseMatrix &x) except+ nogil void LDL_solve "SymEngine::LDL_solve"(const DenseMatrix &A, const DenseMatrix &b, - DenseMatrix &x) nogil except + + DenseMatrix &x) except+ nogil void jacobian "SymEngine::sjacobian"(const DenseMatrix &A, - const DenseMatrix &x, DenseMatrix &result) nogil except + + const DenseMatrix &x, DenseMatrix &result) except+ nogil void diff "SymEngine::sdiff"(const DenseMatrix &A, - rcp_const_basic &x, DenseMatrix &result) nogil except + + rcp_const_basic &x, DenseMatrix &result) except+ nogil void eye (DenseMatrix &A, int k) nogil void diag(DenseMatrix &A, vec_basic &v, int k) nogil void ones(DenseMatrix &A) nogil @@ -868,7 +787,7 @@ cdef extern from "" namespace "SymEngine": void cross(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C) nogil cdef extern from "": - void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) nogil except + + void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) except+ nogil cdef extern from "" namespace "SymEngine": int probab_prime_p(const Integer &a, int reps) @@ -877,10 +796,10 @@ cdef extern from "" namespace "SymEngine": RCP[const Integer] lcm(const Integer &a, const Integer &b) nogil void gcd_ext(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, const Ptr[RCP[Integer]] &t, const Integer &a, const Integer &b) nogil - RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) nogil except + - RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) nogil except + + RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) except+ nogil + RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) except+ nogil void quotient_mod "SymEngine::quotient_mod_f"(const Ptr[RCP[Integer]] &q, const Ptr[RCP[Integer]] &mod, - const Integer &n, const Integer &d) nogil except + + const Integer &n, const Integer &d) except+ nogil int mod_inverse(const Ptr[RCP[Integer]] &b, const Integer &a, const Integer &m) nogil bool crt(const Ptr[RCP[Integer]] &R, const vec_integer &rem, @@ -900,9 +819,9 @@ cdef extern from "" namespace "SymEngine": unsigned B, unsigned retries) nogil int factor_pollard_rho_method(const Ptr[RCP[Integer]] &f, const Integer &n, unsigned retries) nogil - void prime_factors(vec_integer &primes, const Integer &n) nogil except + - void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) nogil except + - RCP[const Number] bernoulli(unsigned long n) nogil except + + void prime_factors(vec_integer &primes, const Integer &n) except+ nogil + void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) except+ nogil + RCP[const Number] bernoulli(unsigned long n) except+ nogil bool primitive_root(const Ptr[RCP[Integer]] &g, const Integer &n) nogil void primitive_root_list(vec_integer &roots, const Integer &n) nogil RCP[const Integer] totient(RCP[const Integer] n) nogil @@ -930,15 +849,15 @@ cdef extern from "" namespace "SymEngine": unsigned next_prime() nogil cdef extern from "" namespace "SymEngine": - bool has_symbol(const Basic &b, const Basic &x) nogil except + - rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except + - set_basic free_symbols(const Basic &b) nogil except + - set_basic free_symbols(const MatrixBase &b) nogil except + + bool has_symbol(const Basic &b, const Basic &x) except+ nogil + rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) except+ nogil + set_basic free_symbols(const Basic &b) except+ nogil + set_basic free_symbols(const MatrixBase &b) except+ nogil unsigned count_ops(const vec_basic &a) nogil cdef extern from "" namespace "SymEngine": cdef cppclass Boolean(Basic): - RCP[const Boolean] logical_not() nogil except+ + RCP[const Boolean] logical_not() except+ nogil cdef cppclass BooleanAtom(Boolean): bool get_val() nogil cdef cppclass Relational(Boolean): @@ -967,25 +886,25 @@ cdef extern from "" namespace "SymEngine": rcp_const_basic boolTrue rcp_const_basic boolFalse bool is_a_Relational(const Basic &b) nogil - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) nogil except+ - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ - cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ - cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ - cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ - cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ - cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except+ + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) except+ nogil + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil ctypedef Boolean const_Boolean "const SymEngine::Boolean" ctypedef vector[pair[rcp_const_basic, RCP[const_Boolean]]] PiecewiseVec; ctypedef vector[RCP[Boolean]] vec_boolean "SymEngine::vec_boolean" - ctypedef set[RCP[Boolean], RCPBasicKeyLess] set_boolean "SymEngine::set_boolean" - cdef RCP[const Boolean] logical_and(set_boolean &s) nogil except+ - cdef RCP[const Boolean] logical_nand(set_boolean &s) nogil except+ - cdef RCP[const Boolean] logical_or(set_boolean &s) nogil except+ - cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) nogil except+ - cdef RCP[const Boolean] logical_nor(set_boolean &s) nogil except+ - cdef RCP[const Boolean] logical_xor(vec_boolean &s) nogil except+ - cdef RCP[const Boolean] logical_xnor(vec_boolean &s) nogil except+ - cdef rcp_const_basic piecewise(PiecewiseVec vec) nogil except + + ctypedef set[RCP[Boolean]] set_boolean "SymEngine::set_boolean" + cdef RCP[const Boolean] logical_and(set_boolean &s) except+ nogil + cdef RCP[const Boolean] logical_nand(set_boolean &s) except+ nogil + cdef RCP[const Boolean] logical_or(set_boolean &s) except+ nogil + cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) except+ nogil + cdef RCP[const Boolean] logical_nor(set_boolean &s) except+ nogil + cdef RCP[const Boolean] logical_xor(vec_boolean &s) except+ nogil + cdef RCP[const Boolean] logical_xnor(vec_boolean &s) except+ nogil + cdef rcp_const_basic piecewise(PiecewiseVec vec) except+ nogil cdef RCP[const Boolean] contains(rcp_const_basic &expr, RCP[const Set] &set) nogil @@ -1004,26 +923,26 @@ cdef extern from "" namespace "SymEngine": cdef EvalfDomain EvalfComplex "SymEngine::EvalfDomain::Complex" cdef EvalfDomain EvalfReal "SymEngine::EvalfDomain::Real" cdef EvalfDomain EvalfSymbolic "SymEngine::EvalfDomain::Symbolic" - rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) nogil except + + rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) except+ nogil cdef extern from "" namespace "SymEngine": - double eval_double(const Basic &b) nogil except + - double complex eval_complex_double(const Basic &b) nogil except + + double eval_double(const Basic &b) except+ nogil + double complex eval_complex_double(const Basic &b) except+ nogil cdef extern from "" namespace "SymEngine": cdef cppclass LambdaRealDoubleVisitor: LambdaRealDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + + void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil void call(double *r, const double *x) nogil cdef cppclass LambdaComplexDoubleVisitor: LambdaComplexDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + + void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil void call(double complex *r, const double complex *x) nogil cdef extern from "" namespace "SymEngine": cdef cppclass LLVMVisitor: LLVMVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except + + void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) except+ nogil const string& dumps() nogil void loads(const string&) nogil @@ -1039,29 +958,29 @@ cdef extern from "" namespace "SymEngine": cdef extern from "" namespace "SymEngine": cdef cppclass SeriesCoeffInterface: - rcp_const_basic as_basic() nogil except + - umap_int_basic as_dict() nogil except + - rcp_const_basic get_coeff(int) nogil except + + rcp_const_basic as_basic() except+ nogil + umap_int_basic as_dict() except+ nogil + rcp_const_basic get_coeff(int) except+ nogil ctypedef RCP[const SeriesCoeffInterface] rcp_const_seriescoeffinterface "SymEngine::RCP" - rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) nogil except + + rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) except+ nogil IF HAVE_SYMENGINE_MPFR: cdef extern from "" namespace "SymEngine": - void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + + void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil IF HAVE_SYMENGINE_MPC: cdef extern from "" namespace "SymEngine": - void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + + void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil cdef extern from "" namespace "SymEngine": - rcp_const_basic parse(const string &n) nogil except + + rcp_const_basic parse(const string &n) except+ nogil cdef extern from "" namespace "SymEngine": cdef cppclass Set(Basic): - RCP[const Set] set_intersection(RCP[const Set] &o) nogil except + - RCP[const Set] set_union(RCP[const Set] &o) nogil except + - RCP[const Set] set_complement(RCP[const Set] &o) nogil except + - RCP[const Boolean] contains(rcp_const_basic &a) nogil except + + RCP[const Set] set_intersection(RCP[const Set] &o) except+ nogil + RCP[const Set] set_union(RCP[const Set] &o) except+ nogil + RCP[const Set] set_complement(RCP[const Set] &o) except+ nogil + RCP[const Boolean] contains(rcp_const_basic &a) except+ nogil cdef cppclass Interval(Set): pass cdef cppclass EmptySet(Set): @@ -1084,25 +1003,25 @@ cdef extern from "" namespace "SymEngine": pass cdef cppclass ImageSet(Set): pass - ctypedef set[RCP[Set], RCPBasicKeyLess] set_set "SymEngine::set_set" - cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) nogil except + - cdef RCP[const EmptySet] emptyset() nogil except + - cdef RCP[const Reals] reals() nogil except + - cdef RCP[const Rationals] rationals() nogil except + - cdef RCP[const Integers] integers() nogil except + - cdef RCP[const UniversalSet] universalset() nogil except + - cdef RCP[const Set] finiteset(set_basic &container) nogil except + - cdef RCP[const Set] set_union(set_set &a) nogil except + - cdef RCP[const Set] set_intersection(set_set &a) nogil except + - cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) nogil except + - cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) nogil except + - cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) nogil except + - cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) nogil except + + ctypedef set[RCP[Set]] set_set "SymEngine::set_set" + cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) except+ nogil + cdef RCP[const EmptySet] emptyset() except+ nogil + cdef RCP[const Reals] reals() except+ nogil + cdef RCP[const Rationals] rationals() except+ nogil + cdef RCP[const Integers] integers() except+ nogil + cdef RCP[const UniversalSet] universalset() except+ nogil + cdef RCP[const Set] finiteset(set_basic &container) except+ nogil + cdef RCP[const Set] set_union(set_set &a) except+ nogil + cdef RCP[const Set] set_intersection(set_set &a) except+ nogil + cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) except+ nogil + cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) except+ nogil + cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) except+ nogil + cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) except+ nogil cdef extern from "" namespace "SymEngine": - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) nogil except + - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) nogil except + - cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) nogil except + + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) except+ nogil + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) except+ nogil + cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) except+ nogil cdef extern from "symengine/tribool.h" namespace "SymEngine": cdef cppclass tribool: @@ -1118,10 +1037,10 @@ cdef extern from "symengine/tribool.h" namespace "SymEngine::tribool": cdef tribool tritrue cdef extern from "" namespace "SymEngine": - string ccode(const Basic &x) nogil except + - string latex(const Basic &x) nogil except + - string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) nogil except + - string unicode(const Basic &x) nogil except + + string ccode(const Basic &x) except+ nogil + string latex(const Basic &x) except+ nogil + string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) except+ nogil + string unicode(const Basic &x) except+ nogil ## Defined in 'symengine/cwrapper.cpp' cdef struct CRCPBasic: From f09fb79def999451476f1dce77d3f4c0e9494e06 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 10:04:08 -0500 Subject: [PATCH 07/92] reversed methods for cython 3 --- symengine/lib/symengine_wrapper.pyx | 115 ++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 16 deletions(-) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index de90b2cb..8d24fb43 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -870,6 +870,12 @@ cdef class Basic(object): cdef Basic B = B_ return c2py(symengine.add(A.thisptr, B.thisptr)) + def __radd__(Basic self, b): + B_ = _sympify(b, False) + if B_ is None or isinstance(B_, MatrixBase): return NotImplemented + cdef Basic B = B_ + return c2py(symengine.add(B.thisptr, self.thisptr)) + def __sub__(a, b): cdef Basic A = _sympify(a, False) B_ = _sympify(b, False) @@ -877,6 +883,12 @@ cdef class Basic(object): cdef Basic B = B_ return c2py(symengine.sub(A.thisptr, B.thisptr)) + def __rsub__(Basic self, b): + B_ = _sympify(b, False) + if B_ is None or isinstance(B_, MatrixBase): return NotImplemented + cdef Basic B = B_ + return c2py(symengine.sub(B.thisptr, self.thisptr)) + def __mul__(a, b): cdef Basic A = _sympify(a, False) B_ = _sympify(b, False) @@ -884,22 +896,45 @@ cdef class Basic(object): cdef Basic B = B_ return c2py(symengine.mul(A.thisptr, B.thisptr)) + def __rmul__(Basic self, b): + B_ = _sympify(b, False) + if B_ is None or isinstance(B_, MatrixBase): return NotImplemented + cdef Basic B = B_ + return c2py(symengine.mul(B.thisptr, self.thisptr)) + def __truediv__(a, b): cdef Basic A = _sympify(a, False) - cdef Basic B = _sympify(b, False) - if A is None or B is None: return NotImplemented + B_ = _sympify(b, False) + if A is None or B_ is None or isinstance(B_, MatrixBase): return NotImplemented + cdef Basic B = B_ return c2py(symengine.div(A.thisptr, B.thisptr)) + def __rtruediv__(Basic self, b): + B_ = _sympify(b, False) + if B_ is None or isinstance(B_, MatrixBase): return NotImplemented + cdef Basic B = B_ + return c2py(symengine.div(B.thisptr, self.thisptr)) + def __floordiv__(x, y): return floor(x/y) + def __rfloordiv__(y, x): + return floor(x/y) + def __mod__(x, y): return x - y * floor(x/y) + def __rmod__(y, x): + return x - y * floor(x/y) + def __divmod__(x, y): f = floor(x/y) return f, x - y * f + def __rdivmod__(y, x): + f = floor(x/y) + return f, x - y * f + def __pow__(a, b, c): if c is not None: return powermod(a, b, c) @@ -908,6 +943,11 @@ cdef class Basic(object): if A is None or B is None: return NotImplemented return c2py(symengine.pow(A.thisptr, B.thisptr)) + def __rpow__(Basic self, b): + cdef Basic B = _sympify(b, False) + if B is None: return NotImplemented + return c2py(symengine.pow(B.thisptr, self.thisptr)) + def __neg__(Basic self not None): return c2py(symengine.neg(self.thisptr)) @@ -3392,6 +3432,19 @@ cdef class DenseMatrixBase(MatrixBase): raise ShapeError("Invalid shapes for matrix addition. Got %s %s" % (a_.shape, b_.shape)) return a_.add_matrix(b_) + def __radd__(MatrixBase self, a): + a = _sympify(a, False) + if not isinstance(a, MatrixBase): + return NotImplemented + cdef MatrixBase a_ = a + if (a_.shape == (0, 0)): + return self + if (self.shape == (0, 0)): + return a_ + if (self.shape != a_.shape): + raise ShapeError("Invalid shapes for matrix addition. Got %s %s" % (a_.shape, self.shape)) + return a_.add_matrix(self) + def __mul__(a, b): a = _sympify(a, False) b = _sympify(b, False) @@ -3409,6 +3462,17 @@ cdef class DenseMatrixBase(MatrixBase): else: return NotImplemented + def __rmul__(Basic self, a): + a = _sympify(a, False) + if isinstance(a, MatrixBase): + if (a.ncols() != self.nrows()): + raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, self.shape)) + return a.mul_matrix(self) + elif isinstance(a, Basic): + return self.mul_scalar(a) + else: + return NotImplemented + def __matmul__(a, b): a = _sympify(a, False) b = _sympify(b, False) @@ -3416,8 +3480,31 @@ cdef class DenseMatrixBase(MatrixBase): raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, b.shape)) return a.mul_matrix(b) + def __rmatmul__(Basic self, a): + a = _sympify(a, False) + if (a.ncols() != self.nrows()): + raise ShapeError("Invalid shapes for matrix multiplication. Got %s %s" % (a.shape, self.shape)) + return a.mul_matrix(self) + def __truediv__(a, b): - return div_matrices(a, b) + a = _sympify(a, False) + b = _sympify(b, False) + if isinstance(a, MatrixBase): + if isinstance(b, MatrixBase): + return a.mul_matrix(b.inv()) + elif isinstance(b, Basic): + return a.mul_scalar(1/b) + else: + return NotImplemented + else: + return NotImplemented + + def __rtruediv__(Basic self, a): + a = _sympify(a, False) + if isinstance(a, MatrixBase): + return a.mul_matrix(self.inv()) + else: + return NotImplemented def __sub__(a, b): a = _sympify(a, False) @@ -3430,6 +3517,15 @@ cdef class DenseMatrixBase(MatrixBase): raise ShapeError("Invalid shapes for matrix subtraction. Got %s %s" % (a.shape, b.shape)) return a_.add_matrix(-b_) + def __rsub__(MatrixBase self, a): + a = _sympify(a, False) + if not isinstance(a, MatrixBase): + return NotImplemented + cdef MatrixBase a_ = a + if (a_.shape != self.shape): + raise ShapeError("Invalid shapes for matrix subtraction. Got %s %s" % (a.shape, self.shape)) + return a_.add_matrix(-self) + def __neg__(self): return self.mul_scalar(-1) @@ -4038,19 +4134,6 @@ cdef class DenseMatrixBase(MatrixBase): return self.applyfunc(lambda x : x.expand(*args, **kwargs)) -def div_matrices(a, b): - a = _sympify(a, False) - b = _sympify(b, False) - if isinstance(a, MatrixBase): - if isinstance(b, MatrixBase): - return a.mul_matrix(b.inv()) - elif isinstance(b, Basic): - return a.mul_scalar(1/b) - else: - return NotImplemented - else: - return NotImplemented - class DenseMatrixBaseIter(object): def __init__(self, d): From a73e5c370eeec7586e823a7ab47f9e1cec3cf04b Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 10:20:07 -0500 Subject: [PATCH 08/92] bring back multiset --- symengine/lib/symengine.pxd | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index b70b7a0d..01478860 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -4,11 +4,24 @@ from libcpp.map cimport map from libcpp.vector cimport vector from cpython.ref cimport PyObject from libcpp.pair cimport pair -from libcpp.set cimport multiset, set +from libcpp.set cimport set from libcpp.unordered_map cimport unordered_map include "config.pxi" +cdef extern from "" namespace "std": + # Cython's libcpp.set does not support multiset in 0.29.x + cdef cppclass multiset[T]: + cppclass iterator: + T& operator*() + iterator operator++() nogil + iterator operator--() nogil + bint operator==(iterator) nogil + bint operator!=(iterator) nogil + iterator begin() nogil + iterator end() nogil + iterator insert(T&) nogil + cdef extern from 'symengine/mp_class.h' namespace "SymEngine": ctypedef unsigned long mp_limb_t ctypedef struct __mpz_struct: From 42887ce09ffdcf1de515d8c227a076ee404b0d4b Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 10:48:12 -0500 Subject: [PATCH 09/92] remove some IF statements --- symengine/lib/symengine.pxd | 134 +++++++++++++++++------------------- 1 file changed, 62 insertions(+), 72 deletions(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 01478860..47894daf 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -655,68 +655,62 @@ cdef extern from "" namespace "SymEngine": cdef cppclass Log(Function): pass -IF HAVE_SYMENGINE_MPFR: - cdef extern from "mpfr.h": - ctypedef struct __mpfr_struct: - pass - ctypedef __mpfr_struct mpfr_t[1] - ctypedef __mpfr_struct* mpfr_ptr - ctypedef const __mpfr_struct* mpfr_srcptr - ctypedef long mpfr_prec_t - ctypedef enum mpfr_rnd_t: - MPFR_RNDN - MPFR_RNDZ - MPFR_RNDU - MPFR_RNDD - MPFR_RNDA - MPFR_RNDF - MPFR_RNDNA - - cdef extern from "" namespace "SymEngine": - cdef cppclass mpfr_class: - mpfr_class() nogil - mpfr_class(mpfr_prec_t prec) nogil - mpfr_class(string s, mpfr_prec_t prec, unsigned base) nogil - mpfr_class(mpfr_t m) nogil - mpfr_ptr get_mpfr_t() nogil - - cdef cppclass RealMPFR(Number): - RealMPFR(mpfr_class) nogil - mpfr_class as_mpfr() nogil - mpfr_prec_t get_prec() nogil - - RCP[const RealMPFR] real_mpfr(mpfr_class t) nogil -ELSE: - cdef extern from "" namespace "SymEngine": - cdef cppclass RealMPFR(Number): - pass - -IF HAVE_SYMENGINE_MPC: - cdef extern from "mpc.h": - ctypedef struct __mpc_struct: - pass - ctypedef __mpc_struct mpc_t[1] - ctypedef __mpc_struct* mpc_ptr - ctypedef const __mpc_struct* mpc_srcptr - - cdef extern from "" namespace "SymEngine": - cdef cppclass mpc_class: - mpc_class() nogil - mpc_class(mpfr_prec_t prec) nogil - mpc_class(mpc_t m) nogil - mpc_ptr get_mpc_t() nogil - mpc_class(string s, mpfr_prec_t prec, unsigned base) nogil - - cdef cppclass ComplexMPC(ComplexBase): - ComplexMPC(mpc_class) nogil - mpc_class as_mpc() nogil - mpfr_prec_t get_prec() nogil - - RCP[const ComplexMPC] complex_mpc(mpc_class t) nogil -ELSE: - cdef extern from "" namespace "SymEngine": - cdef cppclass ComplexMPC(Number): - pass +cdef extern from "": + # These come from mpfr.h, but don't include mpfr.h to not break + # builds without mpfr + ctypedef struct __mpfr_struct: + pass + ctypedef __mpfr_struct mpfr_t[1] + ctypedef __mpfr_struct* mpfr_ptr + ctypedef const __mpfr_struct* mpfr_srcptr + ctypedef long mpfr_prec_t + ctypedef enum mpfr_rnd_t: + MPFR_RNDN + MPFR_RNDZ + MPFR_RNDU + MPFR_RNDD + MPFR_RNDA + MPFR_RNDF + MPFR_RNDNA + +cdef extern from "" namespace "SymEngine": + cdef cppclass mpfr_class: + mpfr_class() nogil + mpfr_class(mpfr_prec_t prec) nogil + mpfr_class(string s, mpfr_prec_t prec, unsigned base) nogil + mpfr_class(mpfr_t m) nogil + mpfr_ptr get_mpfr_t() nogil + + cdef cppclass RealMPFR(Number): + RealMPFR(mpfr_class) nogil + mpfr_class as_mpfr() nogil + mpfr_prec_t get_prec() nogil + + RCP[const RealMPFR] real_mpfr(mpfr_class t) nogil + +cdef extern from "": + # These come from mpc.h, but don't include mpc.h to not break + # builds without mpc + ctypedef struct __mpc_struct: + pass + ctypedef __mpc_struct mpc_t[1] + ctypedef __mpc_struct* mpc_ptr + ctypedef const __mpc_struct* mpc_srcptr + +cdef extern from "" namespace "SymEngine": + cdef cppclass mpc_class: + mpc_class() nogil + mpc_class(mpfr_prec_t prec) nogil + mpc_class(mpc_t m) nogil + mpc_ptr get_mpc_t() nogil + mpc_class(string s, mpfr_prec_t prec, unsigned base) nogil + + cdef cppclass ComplexMPC(ComplexBase): + ComplexMPC(mpc_class) nogil + mpc_class as_mpc() nogil + mpfr_prec_t get_prec() nogil + + RCP[const ComplexMPC] complex_mpc(mpc_class t) nogil cdef extern from "" namespace "SymEngine": cdef cppclass MatrixBase: @@ -923,10 +917,8 @@ cdef extern from "" namespace "SymEngine": cdef extern from "" namespace "std": cdef integer_class std_move_mpz "std::move" (integer_class) nogil - IF HAVE_SYMENGINE_MPFR: - cdef mpfr_class std_move_mpfr "std::move" (mpfr_class) nogil - IF HAVE_SYMENGINE_MPC: - cdef mpc_class std_move_mpc "std::move" (mpc_class) nogil + cdef mpfr_class std_move_mpfr "std::move" (mpfr_class) nogil + cdef mpc_class std_move_mpc "std::move" (mpc_class) nogil cdef map_basic_basic std_move_map_basic_basic "std::move" (map_basic_basic) nogil cdef PiecewiseVec std_move_PiecewiseVec "std::move" (PiecewiseVec) nogil @@ -977,13 +969,11 @@ cdef extern from "" namespace "SymEngine": ctypedef RCP[const SeriesCoeffInterface] rcp_const_seriescoeffinterface "SymEngine::RCP" rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) except+ nogil -IF HAVE_SYMENGINE_MPFR: - cdef extern from "" namespace "SymEngine": - void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil +cdef extern from "" namespace "SymEngine": + void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil -IF HAVE_SYMENGINE_MPC: - cdef extern from "" namespace "SymEngine": - void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil +cdef extern from "" namespace "SymEngine": + void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil cdef extern from "" namespace "SymEngine": rcp_const_basic parse(const string &n) except+ nogil From d1d4de804004151694e29742578cfd777bc8ab6e Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 10:56:46 -0500 Subject: [PATCH 10/92] rename file --- symengine/lib/{symengine_wrapper.pyx => symengine_wrapper.in.pyx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename symengine/lib/{symengine_wrapper.pyx => symengine_wrapper.in.pyx} (100%) diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.in.pyx similarity index 100% rename from symengine/lib/symengine_wrapper.pyx rename to symengine/lib/symengine_wrapper.in.pyx From 1d63ae406c2788b52a6e99156c93873ea091ac0c Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 8 Jun 2023 13:05:48 -0500 Subject: [PATCH 11/92] Replace the use of conditional statements by a preprocessing program --- .gitignore | 2 + cmake/FindCython.cmake | 23 ++-------- cmake/preprocess.py | 38 +++++++++++++++ symengine/lib/CMakeLists.txt | 46 +++++++++++++++---- symengine/lib/config.pxi.in | 1 + symengine/lib/symengine.pxd | 4 +- ...e_wrapper.pxd => symengine_wrapper.in.pxd} | 2 - symengine/lib/symengine_wrapper.in.pyx | 2 +- 8 files changed, 85 insertions(+), 33 deletions(-) create mode 100644 cmake/preprocess.py rename symengine/lib/{symengine_wrapper.pxd => symengine_wrapper.in.pxd} (99%) diff --git a/.gitignore b/.gitignore index 1ef1e18e..f93c0227 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ cython_test.cpp *.vcxproj *.filters symengine/lib/symengine_wrapper.cpp +symengine/lib/symengine_wrapper.pyx +symengine/lib/symengine_wrapper.pxd # Config Files symengine/lib/config.pxi diff --git a/cmake/FindCython.cmake b/cmake/FindCython.cmake index 318f58e4..073e561d 100644 --- a/cmake/FindCython.cmake +++ b/cmake/FindCython.cmake @@ -63,26 +63,13 @@ if(NOT CYTHON_INCLUDE_DIRECTORIES) endif(NOT CYTHON_INCLUDE_DIRECTORIES) # Cythonizes the .pyx files into .cpp file (but doesn't compile it) -macro(CYTHON_ADD_MODULE_PYX name) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pxd) - set(DEPENDS ${name}.pyx ${name}.pxd) - else(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pxd) - set(DEPENDS ${name}.pyx) - endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pxd) +macro(CYTHON_ADD_MODULE_PYX name filename) # Allow the user to specify dependencies as optional arguments set(DEPENDS ${DEPENDS} ${ARGN}) add_custom_command( - OUTPUT ${name}.cpp + OUTPUT ${name} COMMAND ${CYTHON_BIN} - ARGS ${CYTHON_FLAGS} -I ${CYTHON_INCLUDE_DIRECTORIES} -o ${name}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pyx - DEPENDS ${DEPENDS} - COMMENT "Cythonizing ${name}.pyx") + ARGS ${CYTHON_FLAGS} -I ${CYTHON_INCLUDE_DIRECTORIES} -o ${name} ${filename} + DEPENDS ${DEPENDS} ${filename} + COMMENT "Cythonizing ${filename}") endmacro(CYTHON_ADD_MODULE_PYX) - -# Cythonizes and compiles a .pyx file -macro(CYTHON_ADD_MODULE name) - CYTHON_ADD_MODULE_PYX(${name}) - # We need Python for this: - find_package(Python REQUIRED) - add_python_library(${name} ${name}.cpp ${ARGN}) -endmacro(CYTHON_ADD_MODULE) diff --git a/cmake/preprocess.py b/cmake/preprocess.py new file mode 100644 index 00000000..a99d2489 --- /dev/null +++ b/cmake/preprocess.py @@ -0,0 +1,38 @@ +import sys + + +def main(input_name, output_name, replacements): + replacements = dict((item.split("=")[0], item.split("=")[1] == "True") for item in replacements) + with open(input_name, "r") as inp: + text = inp.readlines() + + new_text = [] + in_cond = [True] + nspaces = [0] + for i, line in enumerate(text): + if line.strip().startswith("IF"): + s = len(line) - len(line.lstrip()) + while s <= nspaces[-1] and len(in_cond) > 1: + in_cond = in_cond[:-1] + nspaces = nspaces[:-1] + + cond = line.lstrip()[3:-2] + in_cond.append(replacements[cond]) + nspaces.append(s) + elif line.strip().startswith("ELSE"): + in_cond[-1] = not in_cond[-1] and in_cond[-2] + + if len(line) > 1 and not line.strip().startswith(("IF", "ELSE")): + while len(in_cond) > 1 and (len(line) <= nspaces[-1] or not line.startswith(" "*nspaces[-1]) or line[nspaces[-1]] != " "): + in_cond = in_cond[:-1] + nspaces = nspaces[:-1] + if len(line) == 1: + new_text.append(line) + elif in_cond[-1] and not line.strip().startswith(("IF", "ELSE")): + new_text.append(line[4*(len(in_cond) - 1):]) + + with open(output_name, "w") as out: + out.writelines(new_text) + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2], sys.argv[3:]) diff --git a/symengine/lib/CMakeLists.txt b/symengine/lib/CMakeLists.txt index bf5cc9f8..d37d94dc 100644 --- a/symengine/lib/CMakeLists.txt +++ b/symengine/lib/CMakeLists.txt @@ -1,13 +1,46 @@ set(SRC - symengine_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.cpp pywrapper.cpp ) -configure_file(config.pxi.in config.pxi) +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(BEFORE ${python_wrapper_BINARY_DIR}/symengine/lib) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd + ${PROJECT_SOURCE_DIR}/cmake/preprocess.py + COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.pxd + HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} + HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} + HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} + HAVE_SYMENGINE_FLINT=${HAVE_SYMENGINE_FLINT} + HAVE_SYMENGINE_LLVM=${HAVE_SYMENGINE_LLVM} + HAVE_SYMENGINE_LLVM_LONG_DOUBLE=${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} + COMMENT "Preprocessing symengine_wrapper.in.pxd" +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd + ${PROJECT_SOURCE_DIR}/cmake/preprocess.py + COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.pyx + HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} + HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} + HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} + HAVE_SYMENGINE_FLINT=${HAVE_SYMENGINE_FLINT} + HAVE_SYMENGINE_LLVM=${HAVE_SYMENGINE_LLVM} + HAVE_SYMENGINE_LLVM_LONG_DOUBLE=${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} + COMMENT "Preprocessing symengine_wrapper.in.pyx" +) -cython_add_module_pyx(symengine_wrapper symengine.pxd) +cython_add_module_pyx(symengine_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd + ${CMAKE_CURRENT_SOURCE_DIR}/symengine.pxd) add_python_library(symengine_wrapper ${SRC}) target_link_libraries(symengine_wrapper ${SYMENGINE_LIBRARIES}) if (CMAKE_CXX_COMPILER_ID MATCHES GNU|Clang) @@ -18,10 +51,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU|Clang) ) endif() -add_custom_target(cython - COMMAND cython symengine_wrapper.pyx - ) - set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine/lib) install(TARGETS symengine_wrapper RUNTIME DESTINATION ${PY_PATH} @@ -29,7 +58,6 @@ install(TARGETS symengine_wrapper LIBRARY DESTINATION ${PY_PATH} ) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/config.pxi symengine.pxd symengine_wrapper.pxd pywrapper.h diff --git a/symengine/lib/config.pxi.in b/symengine/lib/config.pxi.in index 26a33012..5ae5675f 100644 --- a/symengine/lib/config.pxi.in +++ b/symengine/lib/config.pxi.in @@ -4,3 +4,4 @@ DEF HAVE_SYMENGINE_PIRANHA = ${HAVE_SYMENGINE_PIRANHA} DEF HAVE_SYMENGINE_FLINT = ${HAVE_SYMENGINE_FLINT} DEF HAVE_SYMENGINE_LLVM = ${HAVE_SYMENGINE_LLVM} DEF HAVE_SYMENGINE_LLVM_LONG_DOUBLE = ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} +DEF ENDIF = 1 diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 47894daf..94a66759 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -7,8 +7,6 @@ from libcpp.pair cimport pair from libcpp.set cimport set from libcpp.unordered_map cimport unordered_map -include "config.pxi" - cdef extern from "" namespace "std": # Cython's libcpp.set does not support multiset in 0.29.x cdef cppclass multiset[T]: @@ -394,7 +392,7 @@ cdef extern from "" namespace "SymEngine": void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) RCP[const Number] get_coef() const map_basic_basic &get_dict() - cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &&d) nogil + cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &d) nogil cdef extern from "" namespace "SymEngine": cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) except+ nogil diff --git a/symengine/lib/symengine_wrapper.pxd b/symengine/lib/symengine_wrapper.in.pxd similarity index 99% rename from symengine/lib/symengine_wrapper.pxd rename to symengine/lib/symengine_wrapper.in.pxd index 0728c42b..3712e17c 100644 --- a/symengine/lib/symengine_wrapper.pxd +++ b/symengine/lib/symengine_wrapper.in.pxd @@ -6,8 +6,6 @@ from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool as cppbool -include "config.pxi" - cdef class Basic(object): cdef rcp_const_basic thisptr diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8d24fb43..7ea7f1de 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -30,7 +30,7 @@ try: except ImportError: have_numpy = False -include "config.pxi" +# include "config.pxi" class SympifyError(Exception): pass From 07f7342884809f9947a246e0d5db502884e4d0d1 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 12 Jun 2023 16:13:48 -0500 Subject: [PATCH 12/92] use is_a template function --- symengine/lib/symengine.pxd | 98 +------------- symengine/lib/symengine_wrapper.in.pyx | 180 ++++++++++++------------- 2 files changed, 96 insertions(+), 182 deletions(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 94a66759..2b9cfc3b 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -110,6 +110,7 @@ cdef extern from "" namespace "SymEngine": cdef struct RCPBasicKeyLess ctypedef set[rcp_const_basic] set_basic "SymEngine::set_basic" ctypedef multiset[rcp_const_basic] multiset_basic "SymEngine::multiset_basic" + cdef cppclass Basic: string __str__() except+ nogil unsigned int hash() except+ nogil @@ -159,96 +160,8 @@ cdef extern from "" namespace "SymEngine": Ptr[RCP[Basic]] outArg(rcp_const_basic &arg) nogil Ptr[RCP[Integer]] outArg_Integer "SymEngine::outArg>"(RCP[const Integer] &arg) nogil - bool is_a_Add "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Mul "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Pow "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Integer "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Rational "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Complex "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Symbol "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Dummy "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Constant "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Infty "SymEngine::is_a"(const Basic &b) nogil - bool is_a_NaN "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Sin "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Cos "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Tan "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Cot "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Csc "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Sec "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ASin "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACos "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ATan "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACot "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACsc "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ASec "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Sinh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Cosh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Tanh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Coth "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Csch "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Sech "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ASinh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACosh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ATanh "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACoth "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ACsch "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ASech "SymEngine::is_a"(const Basic &b) nogil - bool is_a_FunctionSymbol "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Abs "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Max "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Min "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Gamma "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Derivative "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Subs "SymEngine::is_a"(const Basic &b) nogil - bool is_a_PyFunction "SymEngine::is_a"(const Basic &b) nogil - bool is_a_RealDouble "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ComplexDouble "SymEngine::is_a"(const Basic &b) nogil - bool is_a_RealMPFR "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ComplexMPC "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Log "SymEngine::is_a"(const Basic &b) nogil - bool is_a_BooleanAtom "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Equality "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Unequality "SymEngine::is_a"(const Basic &b) nogil - bool is_a_LessThan "SymEngine::is_a"(const Basic &b) nogil - bool is_a_StrictLessThan "SymEngine::is_a"(const Basic &b) nogil - bool is_a_PyNumber "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ATan2 "SymEngine::is_a"(const Basic &b) nogil - bool is_a_LambertW "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Zeta "SymEngine::is_a"(const Basic &b) nogil - bool is_a_DirichletEta "SymEngine::is_a"(const Basic &b) nogil - bool is_a_KroneckerDelta "SymEngine::is_a"(const Basic &b) nogil - bool is_a_LeviCivita "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Erf "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Erfc "SymEngine::is_a"(const Basic &b) nogil - bool is_a_LowerGamma "SymEngine::is_a"(const Basic &b) nogil - bool is_a_UpperGamma "SymEngine::is_a"(const Basic &b) nogil - bool is_a_LogGamma "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Beta "SymEngine::is_a"(const Basic &b) nogil - bool is_a_PolyGamma "SymEngine::is_a"(const Basic &b) nogil - bool is_a_PySymbol "SymEngine::is_a_sub"(const Basic &b) nogil - bool is_a_Sign "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Floor "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Ceiling "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Conjugate "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Interval "SymEngine::is_a"(const Basic &b) nogil - bool is_a_EmptySet "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Reals "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Rationals "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Integers "SymEngine::is_a"(const Basic &b) nogil - bool is_a_UniversalSet "SymEngine::is_a"(const Basic &b) nogil - bool is_a_FiniteSet "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Union "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Complement "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ConditionSet "SymEngine::is_a"(const Basic &b) nogil - bool is_a_ImageSet "SymEngine::is_a"(const Basic &b) nogil - bool is_a_UnevaluatedExpr "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Piecewise "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Contains "SymEngine::is_a"(const Basic &b) nogil - bool is_a_And "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Not "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Or "SymEngine::is_a"(const Basic &b) nogil - bool is_a_Xor "SymEngine::is_a"(const Basic &b) nogil + bool is_a[T] (const Basic &b) nogil + bool is_a_sub[T] (const Basic &b) nogil rcp_const_basic expand(rcp_const_basic &o, bool deep) except+ nogil void as_numer_denom(rcp_const_basic &x, const Ptr[RCP[Basic]] &numer, const Ptr[RCP[Basic]] &denom) nogil void as_real_imag(rcp_const_basic &x, const Ptr[RCP[Basic]] &real, const Ptr[RCP[Basic]] &imag) nogil @@ -650,6 +563,9 @@ cdef extern from "" namespace "SymEngine": cdef cppclass Conjugate(OneArgFunction): pass + cdef cppclass UnevaluatedExpr(OneArgFunction): + pass + cdef cppclass Log(Function): pass @@ -763,7 +679,6 @@ cdef extern from "" namespace "SymEngine": tribool is_positive_definite() nogil tribool is_negative_definite() nogil - bool is_a_DenseMatrix "SymEngine::is_a"(const MatrixBase &b) nogil DenseMatrix* static_cast_DenseMatrix "static_cast"(const MatrixBase *a) void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A, DenseMatrix &B) except+ nogil @@ -890,7 +805,6 @@ cdef extern from "" namespace "SymEngine": rcp_const_basic boolTrue rcp_const_basic boolFalse - bool is_a_Relational(const Basic &b) nogil cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) except+ nogil cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 7ea7f1de..325033e4 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -47,13 +47,13 @@ cpdef void assign_to_capsule(object capsule, object value): cdef object c2py(rcp_const_basic o): cdef Basic r cdef PyObject *obj - if (symengine.is_a_Add(deref(o))): + if (symengine.is_a[symengine.Add](deref(o))): r = Expr.__new__(Add) - elif (symengine.is_a_Mul(deref(o))): + elif (symengine.is_a[symengine.Mul](deref(o))): r = Expr.__new__(Mul) - elif (symengine.is_a_Pow(deref(o))): + elif (symengine.is_a[symengine.Pow](deref(o))): r = Expr.__new__(Pow) - elif (symengine.is_a_Integer(deref(o))): + elif (symengine.is_a[symengine.Integer](deref(o))): if (deref(symengine.rcp_static_cast_Integer(o)).is_zero()): return S.Zero elif (deref(symengine.rcp_static_cast_Integer(o)).is_one()): @@ -61,26 +61,26 @@ cdef object c2py(rcp_const_basic o): elif (deref(symengine.rcp_static_cast_Integer(o)).is_minus_one()): return S.NegativeOne r = Number.__new__(Integer) - elif (symengine.is_a_Rational(deref(o))): + elif (symengine.is_a[symengine.Rational](deref(o))): r = S.Half if (symengine.eq(deref(o), deref(r.thisptr))): return S.Half r = Number.__new__(Rational) - elif (symengine.is_a_Complex(deref(o))): + elif (symengine.is_a[symengine.Complex](deref(o))): r = S.ImaginaryUnit if (symengine.eq(deref(o), deref(r.thisptr))): return S.ImaginaryUnit r = Complex.__new__(Complex) - elif (symengine.is_a_Dummy(deref(o))): + elif (symengine.is_a[symengine.Dummy](deref(o))): r = Dummy.__new__(Dummy) - elif (symengine.is_a_Symbol(deref(o))): - if (symengine.is_a_PySymbol(deref(o))): + elif (symengine.is_a[symengine.Symbol](deref(o))): + if (symengine.is_a_sub[symengine.PySymbol](deref(o))): obj = deref(symengine.rcp_static_cast_PySymbol(o)).get_py_object() result = (obj) Py_XDECREF(obj); return result r = Symbol.__new__(Symbol) - elif (symengine.is_a_Constant(deref(o))): + elif (symengine.is_a[symengine.Constant](deref(o))): r = S.Pi if (symengine.eq(deref(o), deref(r.thisptr))): return S.Pi @@ -97,171 +97,171 @@ cdef object c2py(rcp_const_basic o): if (symengine.eq(deref(o), deref(r.thisptr))): return S.EulerGamma r = Constant.__new__(Constant) - elif (symengine.is_a_Infty(deref(o))): + elif (symengine.is_a[symengine.Infty](deref(o))): if (deref(symengine.rcp_static_cast_Infty(o)).is_positive()): return S.Infinity elif (deref(symengine.rcp_static_cast_Infty(o)).is_negative()): return S.NegativeInfinity return S.ComplexInfinity - elif (symengine.is_a_NaN(deref(o))): + elif (symengine.is_a[symengine.NaN](deref(o))): return S.NaN - elif (symengine.is_a_PyFunction(deref(o))): + elif (symengine.is_a[symengine.PyFunction](deref(o))): r = PyFunction.__new__(PyFunction) - elif (symengine.is_a_FunctionSymbol(deref(o))): + elif (symengine.is_a[symengine.FunctionSymbol](deref(o))): r = FunctionSymbol.__new__(FunctionSymbol) - elif (symengine.is_a_Abs(deref(o))): + elif (symengine.is_a[symengine.Abs](deref(o))): r = Function.__new__(Abs) - elif (symengine.is_a_Max(deref(o))): + elif (symengine.is_a[symengine.Max](deref(o))): r = Function.__new__(Max) - elif (symengine.is_a_Min(deref(o))): + elif (symengine.is_a[symengine.Min](deref(o))): r = Function.__new__(Min) - elif (symengine.is_a_BooleanAtom(deref(o))): + elif (symengine.is_a[symengine.BooleanAtom](deref(o))): if (deref(symengine.rcp_static_cast_BooleanAtom(o)).get_val()): return S.true return S.false - elif (symengine.is_a_Equality(deref(o))): + elif (symengine.is_a[symengine.Equality](deref(o))): r = Relational.__new__(Equality) - elif (symengine.is_a_Unequality(deref(o))): + elif (symengine.is_a[symengine.Unequality](deref(o))): r = Relational.__new__(Unequality) - elif (symengine.is_a_LessThan(deref(o))): + elif (symengine.is_a[symengine.LessThan](deref(o))): r = Relational.__new__(LessThan) - elif (symengine.is_a_StrictLessThan(deref(o))): + elif (symengine.is_a[symengine.StrictLessThan](deref(o))): r = Relational.__new__(StrictLessThan) - elif (symengine.is_a_Gamma(deref(o))): + elif (symengine.is_a[symengine.Gamma](deref(o))): r = Function.__new__(Gamma) - elif (symengine.is_a_Derivative(deref(o))): + elif (symengine.is_a[symengine.Derivative](deref(o))): r = Expr.__new__(Derivative) - elif (symengine.is_a_Subs(deref(o))): + elif (symengine.is_a[symengine.Subs](deref(o))): r = Expr.__new__(Subs) - elif (symengine.is_a_RealDouble(deref(o))): + elif (symengine.is_a[symengine.RealDouble](deref(o))): r = Number.__new__(RealDouble) - elif (symengine.is_a_ComplexDouble(deref(o))): + elif (symengine.is_a[symengine.ComplexDouble](deref(o))): r = ComplexDouble.__new__(ComplexDouble) - elif (symengine.is_a_RealMPFR(deref(o))): + elif (symengine.is_a[symengine.RealMPFR](deref(o))): r = Number.__new__(RealMPFR) - elif (symengine.is_a_ComplexMPC(deref(o))): + elif (symengine.is_a[symengine.ComplexMPC](deref(o))): r = ComplexMPC.__new__(ComplexMPC) - elif (symengine.is_a_Log(deref(o))): + elif (symengine.is_a[symengine.Log](deref(o))): r = Function.__new__(Log) - elif (symengine.is_a_Sin(deref(o))): + elif (symengine.is_a[symengine.Sin](deref(o))): r = Function.__new__(Sin) - elif (symengine.is_a_Cos(deref(o))): + elif (symengine.is_a[symengine.Cos](deref(o))): r = Function.__new__(Cos) - elif (symengine.is_a_Tan(deref(o))): + elif (symengine.is_a[symengine.Tan](deref(o))): r = Function.__new__(Tan) - elif (symengine.is_a_Cot(deref(o))): + elif (symengine.is_a[symengine.Cot](deref(o))): r = Function.__new__(Cot) - elif (symengine.is_a_Csc(deref(o))): + elif (symengine.is_a[symengine.Csc](deref(o))): r = Function.__new__(Csc) - elif (symengine.is_a_Sec(deref(o))): + elif (symengine.is_a[symengine.Sec](deref(o))): r = Function.__new__(Sec) - elif (symengine.is_a_ASin(deref(o))): + elif (symengine.is_a[symengine.ASin](deref(o))): r = Function.__new__(ASin) - elif (symengine.is_a_ACos(deref(o))): + elif (symengine.is_a[symengine.ACos](deref(o))): r = Function.__new__(ACos) - elif (symengine.is_a_ATan(deref(o))): + elif (symengine.is_a[symengine.ATan](deref(o))): r = Function.__new__(ATan) - elif (symengine.is_a_ACot(deref(o))): + elif (symengine.is_a[symengine.ACot](deref(o))): r = Function.__new__(ACot) - elif (symengine.is_a_ACsc(deref(o))): + elif (symengine.is_a[symengine.ACsc](deref(o))): r = Function.__new__(ACsc) - elif (symengine.is_a_ASec(deref(o))): + elif (symengine.is_a[symengine.ASec](deref(o))): r = Function.__new__(ASec) - elif (symengine.is_a_Sinh(deref(o))): + elif (symengine.is_a[symengine.Sinh](deref(o))): r = Function.__new__(Sinh) - elif (symengine.is_a_Cosh(deref(o))): + elif (symengine.is_a[symengine.Cosh](deref(o))): r = Function.__new__(Cosh) - elif (symengine.is_a_Tanh(deref(o))): + elif (symengine.is_a[symengine.Tanh](deref(o))): r = Function.__new__(Tanh) - elif (symengine.is_a_Coth(deref(o))): + elif (symengine.is_a[symengine.Coth](deref(o))): r = Function.__new__(Coth) - elif (symengine.is_a_Csch(deref(o))): + elif (symengine.is_a[symengine.Csch](deref(o))): r = Function.__new__(Csch) - elif (symengine.is_a_Sech(deref(o))): + elif (symengine.is_a[symengine.Sech](deref(o))): r = Function.__new__(Sech) - elif (symengine.is_a_ASinh(deref(o))): + elif (symengine.is_a[symengine.ASinh](deref(o))): r = Function.__new__(ASinh) - elif (symengine.is_a_ACosh(deref(o))): + elif (symengine.is_a[symengine.ACosh](deref(o))): r = Function.__new__(ACosh) - elif (symengine.is_a_ATanh(deref(o))): + elif (symengine.is_a[symengine.ATanh](deref(o))): r = Function.__new__(ATanh) - elif (symengine.is_a_ACoth(deref(o))): + elif (symengine.is_a[symengine.ACoth](deref(o))): r = Function.__new__(ACoth) - elif (symengine.is_a_ACsch(deref(o))): + elif (symengine.is_a[symengine.ACsch](deref(o))): r = Function.__new__(ACsch) - elif (symengine.is_a_ASech(deref(o))): + elif (symengine.is_a[symengine.ASech](deref(o))): r = Function.__new__(ASech) - elif (symengine.is_a_ATan2(deref(o))): + elif (symengine.is_a[symengine.ATan2](deref(o))): r = Function.__new__(ATan2) - elif (symengine.is_a_LambertW(deref(o))): + elif (symengine.is_a[symengine.LambertW](deref(o))): r = Function.__new__(LambertW) - elif (symengine.is_a_Zeta(deref(o))): + elif (symengine.is_a[symengine.Zeta](deref(o))): r = Function.__new__(zeta) - elif (symengine.is_a_DirichletEta(deref(o))): + elif (symengine.is_a[symengine.Dirichlet_eta](deref(o))): r = Function.__new__(dirichlet_eta) - elif (symengine.is_a_KroneckerDelta(deref(o))): + elif (symengine.is_a[symengine.KroneckerDelta](deref(o))): r = Function.__new__(KroneckerDelta) - elif (symengine.is_a_LeviCivita(deref(o))): + elif (symengine.is_a[symengine.LeviCivita](deref(o))): r = Function.__new__(LeviCivita) - elif (symengine.is_a_Erf(deref(o))): + elif (symengine.is_a[symengine.Erf](deref(o))): r = Function.__new__(erf) - elif (symengine.is_a_Erfc(deref(o))): + elif (symengine.is_a[symengine.Erfc](deref(o))): r = Function.__new__(erfc) - elif (symengine.is_a_LowerGamma(deref(o))): + elif (symengine.is_a[symengine.LowerGamma](deref(o))): r = Function.__new__(lowergamma) - elif (symengine.is_a_UpperGamma(deref(o))): + elif (symengine.is_a[symengine.UpperGamma](deref(o))): r = Function.__new__(uppergamma) - elif (symengine.is_a_LogGamma(deref(o))): + elif (symengine.is_a[symengine.LogGamma](deref(o))): r = Function.__new__(loggamma) - elif (symengine.is_a_Beta(deref(o))): + elif (symengine.is_a[symengine.Beta](deref(o))): r = Function.__new__(beta) - elif (symengine.is_a_PolyGamma(deref(o))): + elif (symengine.is_a[symengine.PolyGamma](deref(o))): r = Function.__new__(polygamma) - elif (symengine.is_a_Sign(deref(o))): + elif (symengine.is_a[symengine.Sign](deref(o))): r = Function.__new__(sign) - elif (symengine.is_a_Floor(deref(o))): + elif (symengine.is_a[symengine.Floor](deref(o))): r = Function.__new__(floor) - elif (symengine.is_a_Ceiling(deref(o))): + elif (symengine.is_a[symengine.Ceiling](deref(o))): r = Function.__new__(ceiling) - elif (symengine.is_a_Conjugate(deref(o))): + elif (symengine.is_a[symengine.Conjugate](deref(o))): r = Function.__new__(conjugate) - elif (symengine.is_a_PyNumber(deref(o))): + elif (symengine.is_a[symengine.PyNumber](deref(o))): r = PyNumber.__new__(PyNumber) - elif (symengine.is_a_Piecewise(deref(o))): + elif (symengine.is_a[symengine.Piecewise](deref(o))): r = Function.__new__(Piecewise) - elif (symengine.is_a_Contains(deref(o))): + elif (symengine.is_a[symengine.Contains](deref(o))): r = Boolean.__new__(Contains) - elif (symengine.is_a_Interval(deref(o))): + elif (symengine.is_a[symengine.Interval](deref(o))): r = Set.__new__(Interval) - elif (symengine.is_a_EmptySet(deref(o))): + elif (symengine.is_a[symengine.EmptySet](deref(o))): r = Set.__new__(EmptySet) - elif (symengine.is_a_Reals(deref(o))): + elif (symengine.is_a[symengine.Reals](deref(o))): r = Set.__new__(Reals) - elif (symengine.is_a_Integers(deref(o))): + elif (symengine.is_a[symengine.Integers](deref(o))): r = Set.__new__(Integers) - elif (symengine.is_a_Rationals(deref(o))): + elif (symengine.is_a[symengine.Rationals](deref(o))): r = Set.__new__(Rationals) - elif (symengine.is_a_UniversalSet(deref(o))): + elif (symengine.is_a[symengine.UniversalSet](deref(o))): r = Set.__new__(UniversalSet) - elif (symengine.is_a_FiniteSet(deref(o))): + elif (symengine.is_a[symengine.FiniteSet](deref(o))): r = Set.__new__(FiniteSet) - elif (symengine.is_a_Union(deref(o))): + elif (symengine.is_a[symengine.Union](deref(o))): r = Set.__new__(Union) - elif (symengine.is_a_Complement(deref(o))): + elif (symengine.is_a[symengine.Complement](deref(o))): r = Set.__new__(Complement) - elif (symengine.is_a_ConditionSet(deref(o))): + elif (symengine.is_a[symengine.ConditionSet](deref(o))): r = Set.__new__(ConditionSet) - elif (symengine.is_a_ImageSet(deref(o))): + elif (symengine.is_a[symengine.ImageSet](deref(o))): r = Set.__new__(ImageSet) - elif (symengine.is_a_And(deref(o))): + elif (symengine.is_a[symengine.And](deref(o))): r = Boolean.__new__(And) - elif (symengine.is_a_Not(deref(o))): + elif (symengine.is_a[symengine.Not](deref(o))): r = Boolean.__new__(Not) - elif (symengine.is_a_Or(deref(o))): + elif (symengine.is_a[symengine.Or](deref(o))): r = Boolean.__new__(Or) - elif (symengine.is_a_Xor(deref(o))): + elif (symengine.is_a[symengine.Xor](deref(o))): r = Boolean.__new__(Xor) - elif (symengine.is_a_UnevaluatedExpr(deref(o))): + elif (symengine.is_a[symengine.UnevaluatedExpr](deref(o))): r = Function.__new__(UnevaluatedExpr) else: raise Exception("Unsupported SymEngine class.") From d7c6e4f4abc07e38bb0aaa8bf170b10cda703989 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 12 Jun 2023 16:35:55 -0500 Subject: [PATCH 13/92] use move template --- symengine/lib/symengine.pxd | 7 ------- symengine/lib/symengine_wrapper.in.pyx | 9 +++++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 2b9cfc3b..ee96731b 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -827,13 +827,6 @@ cdef extern from "" namespace "SymEngine": cdef RCP[const Boolean] contains(rcp_const_basic &expr, RCP[const Set] &set) nogil -cdef extern from "" namespace "std": - cdef integer_class std_move_mpz "std::move" (integer_class) nogil - cdef mpfr_class std_move_mpfr "std::move" (mpfr_class) nogil - cdef mpc_class std_move_mpc "std::move" (mpc_class) nogil - cdef map_basic_basic std_move_map_basic_basic "std::move" (map_basic_basic) nogil - cdef PiecewiseVec std_move_PiecewiseVec "std::move" (PiecewiseVec) nogil - cdef extern from "" namespace "SymEngine": cdef cppclass EvalfDomain: pass diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 325033e4..0ac4cb0a 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -5,6 +5,7 @@ from symengine cimport (RCP, pair, map_basic_basic, umap_int_basic, rcp_const_basic, std_pair_short_rcp_const_basic, rcp_const_seriescoeffinterface, CRCPBasic, tribool, is_indeterminate, is_true, is_false) from libcpp cimport bool as cppbool +from libcpp.utility cimport move from libcpp.string cimport string from libcpp.vector cimport vector from cpython cimport PyObject, Py_XINCREF, Py_XDECREF, \ @@ -2035,7 +2036,7 @@ class RealMPFR(Float): cdef string i_ = str(i).encode("utf-8") cdef symengine.mpfr_class m m = symengine.mpfr_class(i_, prec, base) - return c2py(symengine.real_mpfr(symengine.std_move_mpfr(m))) + return c2py(symengine.real_mpfr(move[symengine.mpfr](m))) def get_prec(Basic self): return Integer(deref(symengine.rcp_static_cast_RealMPFR(self.thisptr)).get_prec()) @@ -2064,7 +2065,7 @@ cdef class ComplexMPC(ComplexBase): return cdef string i_ = ("(" + str(i) + " " + str(j) + ")").encode("utf-8") cdef symengine.mpc_class m = symengine.mpc_class(i_, prec, base) - self.thisptr = symengine.complex_mpc(symengine.std_move_mpc(m)) + self.thisptr = symengine.complex_mpc(move[symengine.mpc](m)) def _sympy_(self): import sympy @@ -2330,7 +2331,7 @@ class Mul(AssocOp): d = collections.defaultdict(int) d[c2py(symengine.mul_from_dict(\ (one), - symengine.std_move_map_basic_basic(dict)))] =\ + move[symengine.map_basic_basic](dict)))] =\ c2py(deref(X).get_coef()) return d @@ -5457,7 +5458,7 @@ def piecewise(*v): p.first = e.thisptr p.second = symengine.rcp_static_cast_Boolean(b.thisptr) vec.push_back(p) - return c2py(symengine.piecewise(symengine.std_move_PiecewiseVec(vec))) + return c2py(symengine.piecewise(move[symengine.PiecewiseVec](vec))) def interval(start, end, left_open=False, right_open=False): From 2798227928c572d7a72e080c4672f7faf01cae84 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 16:03:00 -0500 Subject: [PATCH 14/92] remmina --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 30da13f3..cabc616b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -132,5 +132,5 @@ test_script: # Enable this to be able to login to the build worker. You can use the # `remmina` program in Ubuntu, use the login information that the line below # prints into the log. -# #on_finish: -#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +on_finish: +- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) From 4816650f697cb9bf6c752f39cfb56d9e0d1087ad Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 16:40:25 -0500 Subject: [PATCH 15/92] Fix compilation --- symengine/lib/symengine_wrapper.in.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 0ac4cb0a..c368355f 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -2036,7 +2036,7 @@ class RealMPFR(Float): cdef string i_ = str(i).encode("utf-8") cdef symengine.mpfr_class m m = symengine.mpfr_class(i_, prec, base) - return c2py(symengine.real_mpfr(move[symengine.mpfr](m))) + return c2py(symengine.real_mpfr(move[symengine.mpfr_class](m))) def get_prec(Basic self): return Integer(deref(symengine.rcp_static_cast_RealMPFR(self.thisptr)).get_prec()) @@ -2065,7 +2065,7 @@ cdef class ComplexMPC(ComplexBase): return cdef string i_ = ("(" + str(i) + " " + str(j) + ")").encode("utf-8") cdef symengine.mpc_class m = symengine.mpc_class(i_, prec, base) - self.thisptr = symengine.complex_mpc(move[symengine.mpc](m)) + self.thisptr = symengine.complex_mpc(move[symengine.mpc_class](m)) def _sympy_(self): import sympy From 17b7c89949da37a38cd4aa0b4d891b5c5b56bf03 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 17:38:19 -0500 Subject: [PATCH 16/92] Fix output --- symengine/lib/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/symengine/lib/CMakeLists.txt b/symengine/lib/CMakeLists.txt index d37d94dc..34e38a46 100644 --- a/symengine/lib/CMakeLists.txt +++ b/symengine/lib/CMakeLists.txt @@ -11,7 +11,7 @@ add_custom_command( ${PROJECT_SOURCE_DIR}/cmake/preprocess.py COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.pxd + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} @@ -23,11 +23,12 @@ add_custom_command( add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd + ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pxd + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd ${PROJECT_SOURCE_DIR}/cmake/preprocess.py COMMAND ${PYTHON_BIN} ${PROJECT_SOURCE_DIR}/cmake/preprocess.py ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.in.pyx - ${CMAKE_CURRENT_SOURCE_DIR}/symengine_wrapper.pyx + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pyx HAVE_SYMENGINE_MPFR=${HAVE_SYMENGINE_MPFR} HAVE_SYMENGINE_MPC=${HAVE_SYMENGINE_MPC} HAVE_SYMENGINE_PIRANHA=${HAVE_SYMENGINE_PIRANHA} From 41d9d11cc4ab35f9ee485ebcf3951d39196aabc9 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 17:38:30 -0500 Subject: [PATCH 17/92] Revert "remmina" This reverts commit a5974ea630b267f7bf8f97b2ce5f007c9eb096fc. --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cabc616b..30da13f3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -132,5 +132,5 @@ test_script: # Enable this to be able to login to the build worker. You can use the # `remmina` program in Ubuntu, use the login information that the line below # prints into the log. -on_finish: -- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# #on_finish: +#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) From 2315247f6acc8fbc41d6c2adfebb8b77c5f0aa4b Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 17:39:23 -0500 Subject: [PATCH 18/92] remove symengine/lib/config.pxi.in --- symengine/lib/config.pxi.in | 7 ------- symengine/lib/symengine_wrapper.in.pyx | 1 - 2 files changed, 8 deletions(-) delete mode 100644 symengine/lib/config.pxi.in diff --git a/symengine/lib/config.pxi.in b/symengine/lib/config.pxi.in deleted file mode 100644 index 5ae5675f..00000000 --- a/symengine/lib/config.pxi.in +++ /dev/null @@ -1,7 +0,0 @@ -DEF HAVE_SYMENGINE_MPFR = ${HAVE_SYMENGINE_MPFR} -DEF HAVE_SYMENGINE_MPC = ${HAVE_SYMENGINE_MPC} -DEF HAVE_SYMENGINE_PIRANHA = ${HAVE_SYMENGINE_PIRANHA} -DEF HAVE_SYMENGINE_FLINT = ${HAVE_SYMENGINE_FLINT} -DEF HAVE_SYMENGINE_LLVM = ${HAVE_SYMENGINE_LLVM} -DEF HAVE_SYMENGINE_LLVM_LONG_DOUBLE = ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE} -DEF ENDIF = 1 diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index c368355f..e10d1476 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -31,7 +31,6 @@ try: except ImportError: have_numpy = False -# include "config.pxi" class SympifyError(Exception): pass From c3d89d406aae8c2dbe577d403efbcd3a0fa3eaa7 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 17:55:25 -0500 Subject: [PATCH 19/92] fix install --- symengine/lib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine/lib/CMakeLists.txt b/symengine/lib/CMakeLists.txt index 34e38a46..7683d4aa 100644 --- a/symengine/lib/CMakeLists.txt +++ b/symengine/lib/CMakeLists.txt @@ -60,7 +60,7 @@ install(TARGETS symengine_wrapper ) install(FILES symengine.pxd - symengine_wrapper.pxd + ${CMAKE_CURRENT_BINARY_DIR}/symengine_wrapper.pxd pywrapper.h DESTINATION ${PY_PATH} ) From 33ab529b783f56228a4373165a5c48e7cc9a7e98 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 15 Jun 2023 19:47:05 -0500 Subject: [PATCH 20/92] better names for CYTHON_ADD_MODULE_PYX args --- cmake/FindCython.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/FindCython.cmake b/cmake/FindCython.cmake index 073e561d..beac6c56 100644 --- a/cmake/FindCython.cmake +++ b/cmake/FindCython.cmake @@ -63,13 +63,13 @@ if(NOT CYTHON_INCLUDE_DIRECTORIES) endif(NOT CYTHON_INCLUDE_DIRECTORIES) # Cythonizes the .pyx files into .cpp file (but doesn't compile it) -macro(CYTHON_ADD_MODULE_PYX name filename) +macro(CYTHON_ADD_MODULE_PYX cpp_name pyx_name) # Allow the user to specify dependencies as optional arguments set(DEPENDS ${DEPENDS} ${ARGN}) add_custom_command( - OUTPUT ${name} + OUTPUT ${cpp_name} COMMAND ${CYTHON_BIN} - ARGS ${CYTHON_FLAGS} -I ${CYTHON_INCLUDE_DIRECTORIES} -o ${name} ${filename} - DEPENDS ${DEPENDS} ${filename} - COMMENT "Cythonizing ${filename}") + ARGS ${CYTHON_FLAGS} -I ${CYTHON_INCLUDE_DIRECTORIES} -o ${cpp_name} ${pyx_name} + DEPENDS ${DEPENDS} ${pyx_name} + COMMENT "Cythonizing ${pyx_name}") endmacro(CYTHON_ADD_MODULE_PYX) From a22115c91779e8fe356d4923e0f7da915942cd37 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 1 Oct 2023 18:28:40 +0200 Subject: [PATCH 21/92] ci: Add Python 3.11 to the testing * #427 * #425 --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4916921c..324d6ad2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,13 @@ jobs: fail-fast: false matrix: include: + - BUILD_TYPE: Debug + WITH_BFD: yes + PYTHON_VERSION: '3.12' + TEST_SYMPY: yes + OS: ubuntu-20.04 + CC: gcc + - BUILD_TYPE: Debug WITH_BFD: yes PYTHON_VERSION: '3.11' @@ -138,7 +145,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build and test symengine shell: bash From 701366408a8fa4f220fe77516d0eb39bdf4049fc Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 2 Oct 2023 17:32:36 -0500 Subject: [PATCH 22/92] Require python>=3.8 and bump version to 0.11 --- setup.py | 11 ++++++----- symengine/__init__.py | 4 ++-- symengine_version.txt | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 88f2d1c7..1c5e9207 100644 --- a/setup.py +++ b/setup.py @@ -5,8 +5,8 @@ import platform # Make sure the system has the right Python version. -if sys.version_info[:2] < (3, 7): - print("SymEngine requires Python 3.7 or newer. " +if sys.version_info[:2] < (3, 8): + print("SymEngine requires Python 3.8 or newer. " "Python %d.%d detected" % sys.version_info[:2]) sys.exit(-1) @@ -222,7 +222,7 @@ def finalize_options(self): ''' setup(name="symengine", - version="0.10.0", + version="0.11.0", description="Python library providing wrappers to SymEngine", setup_requires=['cython>=0.29.24'], long_description=long_description, @@ -230,7 +230,7 @@ def finalize_options(self): author_email="symengine@googlegroups.com", license="MIT", url="https://github.com/symengine/symengine.py", - python_requires='>=3.7,<4', + python_requires='>=3.8,<4', zip_safe=False, packages=['symengine', 'symengine.lib', 'symengine.tests'], cmdclass = cmdclass, @@ -241,9 +241,10 @@ def finalize_options(self): 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Scientific/Engineering :: Physics', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ] ) diff --git a/symengine/__init__.py b/symengine/__init__.py index fa72ded4..b6002a28 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -1,7 +1,7 @@ import os import sys -if sys.version_info >= (3, 8, 0) and sys.platform == 'win32' \ +if sys.platform == 'win32' \ and 'SYMENGINE_PY_ADD_PATH_TO_SEARCH_DIRS' in os.environ: for directory in os.environ['PATH'].split(';'): if os.path.isdir(directory): @@ -63,7 +63,7 @@ def __getattr__(name): raise AttributeError(f"module 'symengine' has no attribute '{name}'") -__version__ = "0.10.0" +__version__ = "0.11.0" # To not expose internals diff --git a/symengine_version.txt b/symengine_version.txt index c91125db..4f7638fd 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.10.1 +v0.11.1 From 2a3f762bf1c9e5e5e92efbbb1a824c8f3e29e915 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 2 Oct 2023 18:17:17 -0500 Subject: [PATCH 23/92] update appveyor --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 30da13f3..cb17323e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,14 +24,14 @@ environment: CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 - BUILD_TYPE: "Debug" COMPILER: MinGW-w64 - PYTHON_VERSION: 37-x64 + PYTHON_VERSION: 39-x64 WITH_NUMPY: no - BUILD_TYPE: "Release" COMPILER: MinGW-w64 - PYTHON_VERSION: 37-x64 + PYTHON_VERSION: 39-x64 - BUILD_TYPE: "Debug" COMPILER: MinGW-w64 - PYTHON_VERSION: 37-x64 + PYTHON_VERSION: 39-x64 WITH_SYMPY: no - BUILD_TYPE: "Release" COMPILER: MSVC15 From 2bdf33ff9c8b546ce883dcb944a771ad72f9494b Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 2 Oct 2023 18:50:24 -0500 Subject: [PATCH 24/92] Fix GHA yaml --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 324d6ad2..6993dd9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,13 +37,13 @@ jobs: CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.7' + PYTHON_VERSION: '3.8' BUILD_SHARED_LIBS: yes OS: ubuntu-20.04 CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.7' + PYTHON_VERSION: '3.8' WITH_MPFR: yes INTEGER_CLASS: gmpxx WITH_NUMPY: no @@ -91,7 +91,7 @@ jobs: CC: clang - BUILD_TYPE: Release - PYTHON_VERSION: '3.7' + PYTHON_VERSION: '3.8' WITH_NUMPY: yes OS: ubuntu-20.04 CC: clang @@ -108,7 +108,7 @@ jobs: EXTRA_APT_PACKAGES: 'llvm-14' - BUILD_TYPE: Debug - PYTHON_VERSION: '3.7' + PYTHON_VERSION: '3.8' WITH_SCIPY: yes WITH_LLVM: 5.0 OS: macos-latest @@ -121,7 +121,7 @@ jobs: CC: clang - BUILD_TYPE: Debug - PYTHON_VERSION: '3.7' + PYTHON_VERSION: '3.8' WITH_NUMPY: no OS: macos-latest CC: gcc @@ -183,6 +183,7 @@ jobs: WITH_MPC: ${{ matrix.WITH_MPC }} MAKEFLAGS: ${{ matrix.MAKEFLAGS }} BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }} + PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} - name: Deploy Documentation if: ${{ (github.ref == 'refs/heads/main' && github.repository == 'Symengine/symengine.py') || (github.ref == 'refs/heads/master' && github.repository == 'Symengine/symengine.py')}} From 7e7b9df9d11b326fc450c7faf7097905c39967fe Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 7 Oct 2023 04:01:56 -0500 Subject: [PATCH 25/92] Fix appveyor tests --- appveyor.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cb17323e..69467fd4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,6 @@ version: '{build}' -# Uncomment this to enable the fast build environment if your account does not -# support it automatically: -#os: Visual Studio 2015 RC +image: Visual Studio 2019 environment: global: @@ -16,7 +14,6 @@ environment: CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 WITH_MPFR: yes WITH_MPC: yes - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" @@ -45,7 +42,6 @@ environment: PLATFORM: "x64" PYTHON_VERSION: 310-x64 CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 WITH_MPFR: yes WITH_MPC: yes WITH_LLVM: yes @@ -103,15 +99,16 @@ install: - if [%COMPILER%]==[MinGW] set "CMAKE_GENERATOR=MinGW Makefiles" - if [%COMPILER%]==[MinGW-w64] set "CMAKE_GENERATOR=MinGW Makefiles" -- if [%COMPILER%]==[MSVC15] cmake -DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\Library .. -- if [%COMPILER%]==[MinGW] cmake -DCMAKE_PREFIX_PATH=C:\MinGW -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. -- if [%COMPILER%]==[MinGW-w64] cmake -DCMAKE_PREFIX_PATH=C:\mingw64 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. +- if [%COMPILER%]==[MSVC15] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\\Library" +- if [%COMPILER%]==[MinGW] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:\MinGW -DCMAKE_BUILD_TYPE=%BUILD_TYPE%" +- if [%COMPILER%]==[MinGW-w64] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:\mingw64 -DCMAKE_BUILD_TYPE=%BUILD_TYPE%" -- if [%WITH_MPFR%]==[yes] cmake -DWITH_MPFR=yes .. -- if [%WITH_MPC%]==[yes] cmake -DWITH_MPC=yes .. -- if [%WITH_LLVM%]==[yes] cmake -DWITH_LLVM=yes -DMSVC_USE_MT=no .. +- if [%WITH_MPFR%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_MPFR=yes" +- if [%WITH_MPC%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_MPC=yes" +- if [%WITH_LLVM%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_LLVM=yes -DMSVC_USE_MT=no" -- cmake -DBUILD_SHARED_LIBS=yes -DBUILD_TESTS=no -DBUILD_BENCHMARKS=no -DCMAKE_INSTALL_PREFIX=C:\symengine .. +- echo "CMAKE_ARGS: %CMAKE_ARGS%" +- cmake %CMAKE_ARGS% -DBUILD_SHARED_LIBS=yes -DBUILD_TESTS=no -DBUILD_BENCHMARKS=no -DCMAKE_INSTALL_PREFIX=C:\symengine .. - cmake --build . --config %BUILD_TYPE% --target install - cd ../../ From 557c231a9c8bcc13ef0aae0ee34195f09b693d59 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 7 Oct 2023 04:02:53 -0500 Subject: [PATCH 26/92] Fix syntax --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 69467fd4..3c5b227b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ version: '{build}' -image: Visual Studio 2019 +image: "Visual Studio 2019" environment: global: From 26aeb30336f3538ed0ee7be8dd0177efb03561e0 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 7 Oct 2023 04:04:04 -0500 Subject: [PATCH 27/92] Try to fix yaml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 3c5b227b..40fd5ab3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -107,7 +107,7 @@ install: - if [%WITH_MPC%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_MPC=yes" - if [%WITH_LLVM%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_LLVM=yes -DMSVC_USE_MT=no" -- echo "CMAKE_ARGS: %CMAKE_ARGS%" +- echo "CMAKE_ARGS=%CMAKE_ARGS%" - cmake %CMAKE_ARGS% -DBUILD_SHARED_LIBS=yes -DBUILD_TESTS=no -DBUILD_BENCHMARKS=no -DCMAKE_INSTALL_PREFIX=C:\symengine .. - cmake --build . --config %BUILD_TYPE% --target install From 696676efb221948960e68e23f359d91edb4510a6 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Oct 2023 21:01:23 -0500 Subject: [PATCH 28/92] Update for new requirements --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 40fd5ab3..0966b24a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,7 @@ environment: - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "Win32" - PYTHON_VERSION: 37 + PYTHON_VERSION: 39 CONDA_INSTALL_LOCN: C:\\Miniconda36 WITH_MPFR: yes WITH_MPC: yes @@ -61,7 +61,7 @@ install: - if [%COMPILER%]==[MSVC15] echo %PATH% - if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] conda install --yes mpfr=3.1.5 - if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] conda install --yes mpc=1.0.3 -- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] conda install --yes llvmdev=3.9 +- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] conda install --yes llvmdev=4.0 - if [%COMPILER%]==[MinGW] set "PATH=C:\MinGW\bin;%PATH%" - if [%COMPILER%]==[MinGW] mingw-get update From ea09366f72de6397e9c66db10f5dd0373202b7c8 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Oct 2023 21:17:05 -0500 Subject: [PATCH 29/92] Install cython with wheels --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0966b24a..bde013d2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -83,8 +83,7 @@ install: - set "PATH=C:\Python%PYTHON_VERSION%;C:\Python%PYTHON_VERSION%\Scripts;%PATH%" - echo %PATH% -- pip install nose pytest -- pip install --install-option="--no-cython-compile" cython +- pip install nose pytest cython - if NOT [%WITH_NUMPY%]==[no] pip install numpy - if NOT [%WITH_SYMPY%]==[no] pip install sympy From 946e6612194cd0d2f7883e080061afe994c6d6ec Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 31 Oct 2023 07:41:11 -0500 Subject: [PATCH 30/92] Disable MinGW-w64 builds for now This was using MSVC built python with a non-UCRT based MinGW-w64 and it was a hack anyway. To get it properly working we probably need a MinGW-w64 based python or a UCRT based MinGW-w64. --- appveyor.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bde013d2..05e6b6eb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,17 +19,29 @@ environment: PLATFORM: "x64" PYTHON_VERSION: 38-x64 CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 - - BUILD_TYPE: "Debug" - COMPILER: MinGW-w64 - PYTHON_VERSION: 39-x64 - WITH_NUMPY: no - BUILD_TYPE: "Release" - COMPILER: MinGW-w64 - PYTHON_VERSION: 39-x64 - - BUILD_TYPE: "Debug" - COMPILER: MinGW-w64 + COMPILER: MSVC15 + PLATFORM: "x64" PYTHON_VERSION: 39-x64 WITH_SYMPY: no + CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + - BUILD_TYPE: "Release" + COMPILER: MSVC15 + PLATFORM: "x64" + PYTHON_VERSION: 311-x64 + WITH_NUMPY: no + CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + #- BUILD_TYPE: "Debug" + # COMPILER: MinGW-w64 + # PYTHON_VERSION: 39-x64 + # WITH_NUMPY: no + #- BUILD_TYPE: "Release" + # COMPILER: MinGW-w64 + # PYTHON_VERSION: 39-x64 + #- BUILD_TYPE: "Debug" + # COMPILER: MinGW-w64 + # PYTHON_VERSION: 39-x64 + # WITH_SYMPY: no - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "Win32" From 1d65600ec6197b3969e1399b807711e3328c17e3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 5 Nov 2023 09:35:08 +0545 Subject: [PATCH 31/92] README.md: Set minimum Python >= 3.8 https://github.com/symengine/symengine.py/blob/810ef475f34388bb63ae366bf6b238762b5c2d62/setup.py#L8 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6fc3742..847af7d6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ optionally, you may choose to install an early [developer preview](https://githu Install prerequisites. CMake >= 2.8.12 - Python3 >= 3.7 + Python3 >= 3.8 Cython >= 0.29.24 SymEngine >= 0.7.0 From fd81a6c907ef3ac0cef9d5fef0016b8ff57ac0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 17 Nov 2023 21:20:53 +0100 Subject: [PATCH 32/92] add DenseMatrixBase.__abs__ --- symengine/lib/symengine_wrapper.in.pyx | 3 +++ symengine/tests/test_matrices.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index e10d1476..8974b7d9 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -3529,6 +3529,9 @@ cdef class DenseMatrixBase(MatrixBase): def __neg__(self): return self.mul_scalar(-1) + def __abs__(self): + return self.applyfunc(abs) + def __getitem__(self, item): if isinstance(item, slice): if (self.ncols() == 0 or self.nrows() == 0): diff --git a/symengine/tests/test_matrices.py b/symengine/tests/test_matrices.py index de997529..9733e10b 100644 --- a/symengine/tests/test_matrices.py +++ b/symengine/tests/test_matrices.py @@ -286,11 +286,13 @@ def test_mul_scalar(): assert a * A == DenseMatrix(2, 2, [a, 2*a, 3*a, 4*a]) -def test_neg(): +def test_neg_abs(): A = DenseMatrix(2, 3, [1, 2, 3, 4, 5, 6]) B = DenseMatrix(2, 3, [-1, -2, -3, -4, -5, -6]) assert -A == B + assert A == abs(B) + def test_sub(): A = DenseMatrix(2, 2, [1, 2, 3, 4]) From 42ee1435fd7a91c91aabbd7aedaff8c3eafd1853 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 20 Jan 2024 13:59:15 -0600 Subject: [PATCH 33/92] Implement unary addition --- symengine/lib/symengine_wrapper.in.pyx | 3 +++ symengine/tests/test_arit.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8974b7d9..71b4734b 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -951,6 +951,9 @@ cdef class Basic(object): def __neg__(Basic self not None): return c2py(symengine.neg(self.thisptr)) + def __pos__(self): + return self + def __abs__(Basic self not None): return c2py(symengine.abs(self.thisptr)) diff --git a/symengine/tests/test_arit.py b/symengine/tests/test_arit.py index e6ff192b..931b8adb 100644 --- a/symengine/tests/test_arit.py +++ b/symengine/tests/test_arit.py @@ -95,6 +95,12 @@ def test_arit8(): assert (2*y**(-2*x**2)) * (3*y**(2*x**2)) == 6 +def test_unary(): + x = Symbol("x") + assert -x == 0 - x + assert +x == x + + def test_expand1(): x = Symbol("x") y = Symbol("y") From a7136d7890d8fbd439719bccfbc6c7b4ede70e9d Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 22 Jan 2024 21:38:36 -0600 Subject: [PATCH 34/92] Raise error on wrong number of arguments to Function --- symengine/lib/symengine_wrapper.in.pyx | 11 +++++++++-- symengine/tests/test_functions.py | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8974b7d9..4fdc0f9c 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -2412,8 +2412,15 @@ class Pow(Expr): class Function(Expr): def __new__(cls, *args, **kwargs): - if cls == Function and len(args) == 1: - return UndefFunction(args[0]) + if cls == Function: + nargs = len(args) + if nargs == 0: + raise TypeError("Required at least one argument to Function") + elif nargs == 1: + return UndefFunction(args[0]) + elif nargs > 1: + raise TypeError(f"Unexpected extra arguments {args[1:]}.") + return super(Function, cls).__new__(cls) @property diff --git a/symengine/tests/test_functions.py b/symengine/tests/test_functions.py index 3a19b122..c5241ad4 100644 --- a/symengine/tests/test_functions.py +++ b/symengine/tests/test_functions.py @@ -103,6 +103,15 @@ def test_derivative(): assert i == fxy.diff(y, 1, x) +def test_function(): + x = Symbol("x") + assert Function("f")(x) == function_symbol("f", x) + + raises(TypeError, lambda: Function("f", "x")) + raises(TypeError, lambda: Function("f", x)) + raises(TypeError, lambda: Function()) + + def test_abs(): x = Symbol("x") e = abs(x) From a165060bd2fb2d3e64770fa68ad6968689f06f38 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 22 Jan 2024 21:43:00 -0600 Subject: [PATCH 35/92] add name property to FunctionSymbol --- symengine/lib/symengine_wrapper.in.pyx | 4 ++++ symengine/tests/test_functions.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 4fdc0f9c..06b85266 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -2841,6 +2841,10 @@ class FunctionSymbol(Function): name = deref(X).get_name().decode("utf-8") return str(name) + @property + def name(Basic self): + return self.get_name() + def _sympy_(self): import sympy name = self.get_name() diff --git a/symengine/tests/test_functions.py b/symengine/tests/test_functions.py index c5241ad4..207add98 100644 --- a/symengine/tests/test_functions.py +++ b/symengine/tests/test_functions.py @@ -105,12 +105,15 @@ def test_derivative(): def test_function(): x = Symbol("x") - assert Function("f")(x) == function_symbol("f", x) + fx = Function("f")(x) + assert fx == function_symbol("f", x) raises(TypeError, lambda: Function("f", "x")) raises(TypeError, lambda: Function("f", x)) raises(TypeError, lambda: Function()) + assert fx.name == "f" + def test_abs(): x = Symbol("x") From e72006d5f7425cd50c54b22766e0ed4bcd2dca85 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Tue, 21 May 2024 14:33:35 +0800 Subject: [PATCH 36/92] build(cmake): avoid the usage of distutils distutils has been removed since python 3.12 --- cmake/FindPython.cmake | 6 +++--- cmake/get_suffix.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index 52539cb7..f3381327 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -1,7 +1,7 @@ set(PYTHON_BIN python CACHE STRING "Python executable name") execute_process( - COMMAND ${PYTHON_BIN} -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())" + COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['include'])" OUTPUT_VARIABLE PYTHON_SYS_PATH ) string(STRIP ${PYTHON_SYS_PATH} PYTHON_SYS_PATH) @@ -16,7 +16,7 @@ set(PYTHON_INSTALL_HEADER_PATH ${PYTHON_INCLUDE_PATH}/symengine CACHE BOOL "Python install headers path") execute_process( - COMMAND ${PYTHON_BIN} -c "from distutils.sysconfig import get_config_var; print(get_config_var('LIBDIR'))" + COMMAND ${PYTHON_BIN} -c "from sysconfig import get_config_var; print(get_config_var('LIBDIR'))" OUTPUT_VARIABLE PYTHON_LIB_PATH ) string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH) @@ -50,7 +50,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") endif() execute_process( - COMMAND ${PYTHON_BIN} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" + COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])" OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp ) string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) diff --git a/cmake/get_suffix.py b/cmake/get_suffix.py index 8fc5b105..42470fce 100644 --- a/cmake/get_suffix.py +++ b/cmake/get_suffix.py @@ -1,4 +1,4 @@ -from distutils.sysconfig import get_config_var +from sysconfig import get_config_var extsuffix = get_config_var('EXT_SUFFIX') if extsuffix is None: print("") From f6426fc4019a1edc2d8e61d4bb91ad72f14250ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Mon, 27 May 2024 21:55:22 +0200 Subject: [PATCH 37/92] Fix cython syntax, add tests --- symengine/lib/symengine_wrapper.in.pyx | 8 ++++++-- symengine/tests/test_logic.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index e10d1476..c29c8978 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -1627,7 +1627,9 @@ class Equality(Relational): def is_Equality(self): return True - func = __class__ + @property + def func(self): + return self.__class__ Eq = Equality @@ -1648,7 +1650,9 @@ class Unequality(Relational): s = self.args_as_sage() return sage.ne(*s) - func = __class__ + @property + def func(self): + return self.__class__ Ne = Unequality diff --git a/symengine/tests/test_logic.py b/symengine/tests/test_logic.py index 7c01f8e9..3d0c3391 100644 --- a/symengine/tests/test_logic.py +++ b/symengine/tests/test_logic.py @@ -27,6 +27,10 @@ def test_relationals(): assert Ge(1, 1) == true assert Eq(I, 2) == false assert Ne(I, 2) == true + eq = Eq(x, y) + assert eq.func(*eq.args) == eq + ne = Ne(x, y) + assert ne.func(*ne.args) == ne def test_rich_cmp(): @@ -118,4 +122,3 @@ def test_Contains(): assert Contains(x, Interval(1, 1)) != false assert Contains(oo, Interval(-oo, oo)) == false assert Contains(-oo, Interval(-oo, oo)) == false - From b131af835fbb1e4b7df38615d199b6e535c26b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Tue, 28 May 2024 16:41:21 +0200 Subject: [PATCH 38/92] Bump one CI config to ubuntu-24.04 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6993dd9e..33c2dceb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: WITH_BFD: yes PYTHON_VERSION: '3.12' TEST_SYMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-24.04 CC: gcc - BUILD_TYPE: Debug From 02bd6d4a37ef62a9bd8588e100b040459f70b40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Tue, 28 May 2024 16:49:43 +0200 Subject: [PATCH 39/92] try to work around hardcoded versions in symengine's install_travis.sh --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33c2dceb..4a44aa8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: PYTHON_VERSION: '3.12' TEST_SYMPY: yes OS: ubuntu-24.04 - CC: gcc + CC: 'ccache gcc' # symengine's bin/install_travis.sh needs refactoring... - BUILD_TYPE: Debug WITH_BFD: yes From fdff48def4d936eb9f7935b3bfef35096aadd83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Tue, 28 May 2024 16:54:42 +0200 Subject: [PATCH 40/92] try another workaround --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a44aa8a..9cddcb2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: PYTHON_VERSION: '3.12' TEST_SYMPY: yes OS: ubuntu-24.04 - CC: 'ccache gcc' # symengine's bin/install_travis.sh needs refactoring... + CC: 'gcc -v' # symengine's bin/install_travis.sh needs refactoring... - BUILD_TYPE: Debug WITH_BFD: yes From 8a4f3b895050c6164ba5ee1ee19d7fa13238d1c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Tue, 28 May 2024 16:58:18 +0200 Subject: [PATCH 41/92] also set CXX --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cddcb2b..b4156101 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: TEST_SYMPY: yes OS: ubuntu-24.04 CC: 'gcc -v' # symengine's bin/install_travis.sh needs refactoring... + CXX: 'g++ -v' - BUILD_TYPE: Debug WITH_BFD: yes From de69b995e9116356823960253de046fee294f43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 10:19:53 +0200 Subject: [PATCH 42/92] test against symengine/symengine#2026 --- .github/workflows/ci.yml | 3 +-- bin/test_symengine_unix.sh | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4156101..33c2dceb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,7 @@ jobs: PYTHON_VERSION: '3.12' TEST_SYMPY: yes OS: ubuntu-24.04 - CC: 'gcc -v' # symengine's bin/install_travis.sh needs refactoring... - CXX: 'g++ -v' + CC: gcc - BUILD_TYPE: Debug WITH_BFD: yes diff --git a/bin/test_symengine_unix.sh b/bin/test_symengine_unix.sh index 976f305d..63e3f6ca 100644 --- a/bin/test_symengine_unix.sh +++ b/bin/test_symengine_unix.sh @@ -2,10 +2,10 @@ export PYTHON_SOURCE_DIR=`pwd` export TEST_CPP="no" export MAKEFLAGS="-j2" -git clone https://github.com/symengine/symengine symengine-cpp +git clone -b update-CI https://github.com/bjodah/symengine symengine-cpp cd symengine-cpp export SOURCE_DIR=`pwd` -git checkout `cat ../symengine_version.txt` +#git checkout `cat ../symengine_version.txt` cd .. # Setup travis for C++ library From b4933abc696fcd7d68dc999db66888b264cad26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 10:50:21 +0200 Subject: [PATCH 43/92] use gcc-13 & llvm-18 under ubuntu-24.04 --- .github/workflows/ci.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33c2dceb..55c844f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: WITH_BFD: yes PYTHON_VERSION: '3.12' TEST_SYMPY: yes - OS: ubuntu-24.04 + OS: ubuntu-20.04 CC: gcc - BUILD_TYPE: Debug @@ -97,15 +97,16 @@ jobs: CC: clang - BUILD_TYPE: Debug - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.12' WITH_SYMPY: yes - WITH_LLVM: 14 + WITH_LLVM: 18 WITH_SCIPY: yes INTEGER_CLASS: 'boostmp' PYTEST_ADDOPTS: '-k "not integer_nthroot"' - OS: ubuntu-22.04 - EXTRA_APT_REPOSITORY: 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' - EXTRA_APT_PACKAGES: 'llvm-14' + OS: ubuntu-24.04 + CC: gcc # ubuntu nobel uses gcc-13 + #EXTRA_APT_REPOSITORY: 'deb http://apt.llvm.org/jammy/ llvm-toolchain-nobel-18 main' + EXTRA_APT_PACKAGES: 'llvm-18' - BUILD_TYPE: Debug PYTHON_VERSION: '3.8' From 43f282a8111970ed06ee813f75bf591edd257338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 11:16:29 +0200 Subject: [PATCH 44/92] long is not a built-in --- symengine/lib/symengine_wrapper.in.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 76b8288d..61cb4d6b 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -1214,7 +1214,7 @@ cdef class Basic(object): return int(float(self)) def __long__(self): - return long(float(self)) + return int(float(self)) def __complex__(self): f = self.n(real=False) From 7472cce6f326ad53ca25ccc541198497cc2edb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 11:16:29 +0200 Subject: [PATCH 45/92] long is not a built-in --- symengine/lib/symengine_wrapper.in.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index c29c8978..34c11e9f 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -1211,7 +1211,7 @@ cdef class Basic(object): return int(float(self)) def __long__(self): - return long(float(self)) + return int(float(self)) def __complex__(self): f = self.n(real=False) From dd3dc6efc228c9193088e3b284fa88faf920b393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 11:41:58 +0200 Subject: [PATCH 46/92] vector lambda_double -> unique_ptr lambda_visitor --- symengine/lib/symengine_wrapper.in.pxd | 11 +++-- symengine/lib/symengine_wrapper.in.pyx | 66 +++++++++++++------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/symengine/lib/symengine_wrapper.in.pxd b/symengine/lib/symengine_wrapper.in.pxd index 3712e17c..03dbf1f0 100644 --- a/symengine/lib/symengine_wrapper.in.pxd +++ b/symengine/lib/symengine_wrapper.in.pxd @@ -2,6 +2,7 @@ cimport symengine from symengine cimport RCP, map_basic_basic, rcp_const_basic +from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool as cppbool @@ -44,7 +45,7 @@ cdef class _Lambdify(object): cpdef unsafe_eval(sef, inp, out, unsigned nbroadcast=*) cdef class LambdaDouble(_Lambdify): - cdef vector[symengine.LambdaRealDoubleVisitor] lambda_double + cdef unique_ptr[symengine.LambdaRealDoubleVisitor] lambda_visitor cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*) cpdef as_scipy_low_level_callable(self) @@ -54,7 +55,7 @@ cdef class LambdaDouble(_Lambdify): int inp_offset=*, int out_offset=*) cdef class LambdaComplexDouble(_Lambdify): - cdef vector[symengine.LambdaComplexDoubleVisitor] lambda_double + cdef unique_ptr[symengine.LambdaComplexDoubleVisitor] lambda_visitor cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=*, int out_offset=*) @@ -63,7 +64,7 @@ IF HAVE_SYMENGINE_LLVM: cdef int opt_level cdef class LLVMDouble(_LLVMLambdify): - cdef vector[symengine.LLVMDoubleVisitor] lambda_double + cdef unique_ptr[symengine.LLVMDoubleVisitor] lambda_visitor cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) cdef _load(self, const string &s) cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=*, int out_offset=*) @@ -71,14 +72,14 @@ IF HAVE_SYMENGINE_LLVM: cpdef as_ctypes(self) cdef class LLVMFloat(_LLVMLambdify): - cdef vector[symengine.LLVMFloatVisitor] lambda_double + cdef unique_ptr[symengine.LLVMFloatVisitor] lambda_visitor cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) cdef _load(self, const string &s) cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=*, int out_offset=*) IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: cdef class LLVMLongDouble(_LLVMLambdify): - cdef vector[symengine.LLVMLongDoubleVisitor] lambda_double + cdef unique_ptr[symengine.LLVMLongDoubleVisitor] lambda_visitor cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse) cdef _load(self, const string &s) cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=*, int out_offset=*) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 34c11e9f..44688fbe 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -5156,11 +5156,11 @@ cdef class LambdaDouble(_Lambdify): pass cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_double.resize(1) - self.lambda_double[0].init(args_, outs_, cse) + self.lambda_visitor.reset(new symengine.LambdaRealDoubleVisitor()) + deref(self.lambda_visitor).init(args_, outs_, cse) cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=0, int out_offset=0): - self.lambda_double[0].call(&out[out_offset], &inp[inp_offset]) + deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): cdef double[::1] c_inp, c_out @@ -5168,7 +5168,7 @@ cdef class LambdaDouble(_Lambdify): c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) c_out = out for idx in range(nbroadcast): - self.lambda_double[0].call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) + deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) cpdef as_scipy_low_level_callable(self): from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE @@ -5176,7 +5176,7 @@ cdef class LambdaDouble(_Lambdify): raise RuntimeError("SciPy LowLevelCallable supports only functions with 1 output") addr1 = cast(&_scipy_callback_lambda_real, CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p)) - addr2 = cast(&self.lambda_double[0], c_void_p) + addr2 = cast(self.lambda_visitor.get(), c_void_p) return create_low_level_callable(self, addr1, addr2) cpdef as_ctypes(self): @@ -5191,7 +5191,7 @@ cdef class LambdaDouble(_Lambdify): from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE addr1 = cast(&_ctypes_callback_lambda_real, CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p)) - addr2 = cast(&self.lambda_double[0], c_void_p) + addr2 = cast(self.lambda_visitor.get(), c_void_p) return addr1, addr2 @@ -5201,11 +5201,11 @@ cdef class LambdaComplexDouble(_Lambdify): pass cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_double.resize(1) - self.lambda_double[0].init(args_, outs_, cse) + self.lambda_visitor.reset(new symengine.LambdaComplexDoubleVisitor()) + deref(self.lambda_visitor).init(args_, outs_, cse) cpdef unsafe_complex(self, double complex[::1] inp, double complex[::1] out, int inp_offset=0, int out_offset=0): - self.lambda_double[0].call(&out[out_offset], &inp[inp_offset]) + deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): cdef double complex[::1] c_inp, c_out @@ -5213,7 +5213,7 @@ cdef class LambdaComplexDouble(_Lambdify): c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) c_out = out for idx in range(nbroadcast): - self.lambda_double[0].call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) + deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) IF HAVE_SYMENGINE_LLVM: @@ -5222,23 +5222,23 @@ IF HAVE_SYMENGINE_LLVM: self.opt_level = opt_level cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_double.resize(1) - self.lambda_double[0].init(args_, outs_, cse, self.opt_level) + self.lambda_visitor.reset(new symengine.LLVMDoubleVisitor()) + deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) cdef _load(self, const string &s): - self.lambda_double.resize(1) - self.lambda_double[0].loads(s) + self.lambda_visitor.reset(new symengine.LLVMDoubleVisitor()) + deref(self.lambda_visitor).loads(s) def __reduce__(self): """ Interface for pickle. Note that the resulting object is platform dependent. """ - cdef bytes s = self.lambda_double[0].dumps() + cdef bytes s = deref(self.lambda_visitor).dumps() return llvm_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) cpdef unsafe_real(self, double[::1] inp, double[::1] out, int inp_offset=0, int out_offset=0): - self.lambda_double[0].call(&out[out_offset], &inp[inp_offset]) + deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): cdef double[::1] c_inp, c_out @@ -5246,7 +5246,7 @@ IF HAVE_SYMENGINE_LLVM: c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) c_out = out for idx in range(nbroadcast): - self.lambda_double[0].call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) + deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) cpdef as_scipy_low_level_callable(self): from ctypes import c_double, c_void_p, c_int, cast, POINTER, CFUNCTYPE @@ -5256,7 +5256,7 @@ IF HAVE_SYMENGINE_LLVM: raise RuntimeError("SciPy LowLevelCallable supports only functions with 1 output") addr1 = cast(&_scipy_callback_llvm_real, CFUNCTYPE(c_double, c_int, POINTER(c_double), c_void_p)) - addr2 = cast(&self.lambda_double[0], c_void_p) + addr2 = cast(self.lambda_visitor.get(), c_void_p) return create_low_level_callable(self, addr1, addr2) cpdef as_ctypes(self): @@ -5273,7 +5273,7 @@ IF HAVE_SYMENGINE_LLVM: raise RuntimeError("Lambda function has to be real") addr1 = cast(&_ctypes_callback_llvm_real, CFUNCTYPE(c_void_p, POINTER(c_double), POINTER(c_double), c_void_p)) - addr2 = cast(&self.lambda_double[0], c_void_p) + addr2 = cast(self.lambda_visitor.get(), c_void_p) return addr1, addr2 cdef class LLVMFloat(_LLVMLambdify): @@ -5281,23 +5281,23 @@ IF HAVE_SYMENGINE_LLVM: self.opt_level = opt_level cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_double.resize(1) - self.lambda_double[0].init(args_, outs_, cse, self.opt_level) + self.lambda_visitor.reset(new symengine.LLVMFloatVisitor()) + deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) cdef _load(self, const string &s): - self.lambda_double.resize(1) - self.lambda_double[0].loads(s) + self.lambda_visitor.reset(new symengine.LLVMFloatVisitor()) + deref(self.lambda_visitor).loads(s) def __reduce__(self): """ Interface for pickle. Note that the resulting object is platform dependent. """ - cdef bytes s = self.lambda_double[0].dumps() + cdef bytes s = deref(self.lambda_visitor).dumps() return llvm_float_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) cpdef unsafe_real(self, float[::1] inp, float[::1] out, int inp_offset=0, int out_offset=0): - self.lambda_double[0].call(&out[out_offset], &inp[inp_offset]) + deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): cdef float[::1] c_inp, c_out @@ -5305,7 +5305,7 @@ IF HAVE_SYMENGINE_LLVM: c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) c_out = out for idx in range(nbroadcast): - self.lambda_double[0].call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) + deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) IF HAVE_SYMENGINE_LLVM_LONG_DOUBLE: cdef class LLVMLongDouble(_LLVMLambdify): @@ -5313,23 +5313,23 @@ IF HAVE_SYMENGINE_LLVM: self.opt_level = opt_level cdef _init(self, symengine.vec_basic& args_, symengine.vec_basic& outs_, cppbool cse): - self.lambda_double.resize(1) - self.lambda_double[0].init(args_, outs_, cse, self.opt_level) + self.lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor()) + deref(self.lambda_visitor).init(args_, outs_, cse, self.opt_level) cdef _load(self, const string &s): - self.lambda_double.resize(1) - self.lambda_double[0].loads(s) + self.lambda_visitor.reset(new symengine.LLVMLongDoubleVisitor()) + deref(self.lambda_visitor).loads(s) def __reduce__(self): """ Interface for pickle. Note that the resulting object is platform dependent. """ - cdef bytes s = self.lambda_double[0].dumps() + cdef bytes s = deref(self.lambda_visitor).dumps() return llvm_long_double_loading_func, (self.args_size, self.tot_out_size, self.out_shapes, self.real, \ self.n_exprs, self.order, self.accum_out_sizes, self.numpy_dtype, s) cpdef unsafe_real(self, long double[::1] inp, long double[::1] out, int inp_offset=0, int out_offset=0): - self.lambda_double[0].call(&out[out_offset], &inp[inp_offset]) + deref(self.lambda_visitor).call(&out[out_offset], &inp[inp_offset]) cpdef unsafe_eval(self, inp, out, unsigned nbroadcast=1): cdef long double[::1] c_inp, c_out @@ -5337,7 +5337,7 @@ IF HAVE_SYMENGINE_LLVM: c_inp = np.ascontiguousarray(inp.ravel(order=self.order), dtype=self.numpy_dtype) c_out = out for idx in range(nbroadcast): - self.lambda_double[0].call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) + deref(self.lambda_visitor).call(&c_out[idx*self.tot_out_size], &c_inp[idx*self.args_size]) def llvm_loading_func(*args): return LLVMDouble(args, _load=True) From 4204b2dca364c47d9b32be99bd7e58430d39397e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 15:34:33 +0200 Subject: [PATCH 47/92] Try to add work-around for sympy/sympy#26645 --- symengine/lib/symengine_wrapper.in.pyx | 18 ++++++++++++++++++ symengine/tests/test_sympy_conv.py | 1 + 2 files changed, 19 insertions(+) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 44688fbe..8fa62c83 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -31,6 +31,13 @@ try: except ImportError: have_numpy = False +try: + import flint as _flint + have_flint_py = True +except ImportError: + _flint = None + have_flint_py = False + class SympifyError(Exception): pass @@ -499,6 +506,17 @@ def sympy2symengine(a, raise_error=False): elif isinstance(a, sympy.ConditionSet): return conditionset(*(a.args)) + if have_flint_py: + if isinstance(a, _flint.types.nmod.nmod): + # Work around for sympy/sympy#26645 + class _modular_integer(sympy.polys.domains.modularinteger.ModularInteger): + mod = int(a.modulus()) + dom = sympy.polys.domains.ZZ + sym = True + + b = _modular_integer(int(a)) + return PyNumber(b, sympy_module) + if raise_error: raise SympifyError(("sympy2symengine: Cannot convert '%r' (of type %s)" " to a symengine type.") % (a, type(a))) diff --git a/symengine/tests/test_sympy_conv.py b/symengine/tests/test_sympy_conv.py index 5d173dc4..fbba8179 100644 --- a/symengine/tests/test_sympy_conv.py +++ b/symengine/tests/test_sympy_conv.py @@ -778,6 +778,7 @@ def test_pynumber(): assert isinstance(b, PyNumber) assert b == a # Check equality via SymEngine assert a == b # Check equality via SymPy + assert (b-a).simplify() == 0 assert str(a) == str(b) a = 1 - a From 14cd07d8c81f3c2c220e9fc894927465ca0177a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 15:37:21 +0200 Subject: [PATCH 48/92] bump symengine version to v0.12.0 --- symengine_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine_version.txt b/symengine_version.txt index 4f7638fd..87a1cf59 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.11.1 +v0.12.0 From 1618a867fa40c7f82dc9ccbdc2e711d97365c598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 16:33:35 +0200 Subject: [PATCH 49/92] Add python-flint to one CI config --- .github/workflows/ci.yml | 3 ++- bin/install_travis.sh | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6993dd9e..8b9877b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,11 +132,12 @@ jobs: CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.11' OS: ubuntu-20.04 WITH_MPC: yes WITH_MPFR: yes WITH_FLINT: yes + WITH_FLINT_PY: yes WITH_SCIPY: yes WITH_DOCS: yes INTEGER_CLASS: flint diff --git a/bin/install_travis.sh b/bin/install_travis.sh index 581354a0..8176202d 100644 --- a/bin/install_travis.sh +++ b/bin/install_travis.sh @@ -16,6 +16,10 @@ if [[ "${WITH_DOCS}" == "yes" ]]; then export conda_pkgs="${conda_pkgs} sphinx recommonmark"; fi +if [[ "${WITH_FLINT_PY}" == "yes" ]]; then + export conda_pkgs="${conda_pkgs} python-flint"; # python-flint affects sympy, see e.g. sympy/sympy#26645 +fi + if [[ "${WITH_SAGE}" == "yes" ]]; then # This is split to avoid the 10 minute limit conda install -q sagelib=8.1 From c6f95e3a3fe6ca3a1398830fc2e792f7e88794e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 31 May 2024 16:44:17 +0200 Subject: [PATCH 50/92] Revert adaptions to flint.types.nmod.nmod Following the explanation in https://github.com/sympy/sympy/issues/26645#issuecomment-2142388813 --- symengine/lib/symengine_wrapper.in.pyx | 18 ------------------ symengine/tests/test_sympy_conv.py | 1 - 2 files changed, 19 deletions(-) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8fa62c83..44688fbe 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -31,13 +31,6 @@ try: except ImportError: have_numpy = False -try: - import flint as _flint - have_flint_py = True -except ImportError: - _flint = None - have_flint_py = False - class SympifyError(Exception): pass @@ -506,17 +499,6 @@ def sympy2symengine(a, raise_error=False): elif isinstance(a, sympy.ConditionSet): return conditionset(*(a.args)) - if have_flint_py: - if isinstance(a, _flint.types.nmod.nmod): - # Work around for sympy/sympy#26645 - class _modular_integer(sympy.polys.domains.modularinteger.ModularInteger): - mod = int(a.modulus()) - dom = sympy.polys.domains.ZZ - sym = True - - b = _modular_integer(int(a)) - return PyNumber(b, sympy_module) - if raise_error: raise SympifyError(("sympy2symengine: Cannot convert '%r' (of type %s)" " to a symengine type.") % (a, type(a))) diff --git a/symengine/tests/test_sympy_conv.py b/symengine/tests/test_sympy_conv.py index fbba8179..5d173dc4 100644 --- a/symengine/tests/test_sympy_conv.py +++ b/symengine/tests/test_sympy_conv.py @@ -778,7 +778,6 @@ def test_pynumber(): assert isinstance(b, PyNumber) assert b == a # Check equality via SymEngine assert a == b # Check equality via SymPy - assert (b-a).simplify() == 0 assert str(a) == str(b) a = 1 - a From 621141b2fc0182a045e9d6a22db778065839626e Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 8 Jul 2024 21:10:20 -0500 Subject: [PATCH 51/92] update CI --- .github/workflows/ci.yml | 8 ++++---- appveyor.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b9877b1..2763750c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,24 +111,24 @@ jobs: PYTHON_VERSION: '3.8' WITH_SCIPY: yes WITH_LLVM: 5.0 - OS: macos-latest + OS: macos-13 CC: clang - BUILD_TYPE: Release PYTHON_VERSION: '3.9' WITH_NUMPY: no - OS: macos-latest + OS: macos-13 CC: clang - BUILD_TYPE: Debug PYTHON_VERSION: '3.8' WITH_NUMPY: no - OS: macos-latest + OS: macos-13 CC: gcc - BUILD_TYPE: Release PYTHON_VERSION: '3.8' - OS: macos-latest + OS: macos-13 CC: gcc - BUILD_TYPE: Release diff --git a/appveyor.yml b/appveyor.yml index 05e6b6eb..24947d3b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -63,7 +63,7 @@ install: - git clone https://github.com/sympy/symengine symengine-cpp - if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat -- if [%COMPILER%]==[MSVC15] conda install --yes --quiet conda python=3.6 +- if [%COMPILER%]==[MSVC15] conda install --yes --quiet conda - if [%COMPILER%]==[MSVC15] conda config --add channels conda-forge - if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] conda config --add channels symengine/label/debug - if [%COMPILER%]==[MSVC15] conda install --yes mpir=3.0.0 vc=14 From a23b620dd3d671f4a19944153cffb2506815aaa3 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 8 Jul 2024 21:23:05 -0500 Subject: [PATCH 52/92] updat eappveyor --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 24947d3b..91abed7b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -63,7 +63,6 @@ install: - git clone https://github.com/sympy/symengine symengine-cpp - if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat -- if [%COMPILER%]==[MSVC15] conda install --yes --quiet conda - if [%COMPILER%]==[MSVC15] conda config --add channels conda-forge - if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] conda config --add channels symengine/label/debug - if [%COMPILER%]==[MSVC15] conda install --yes mpir=3.0.0 vc=14 From 25ee71fc89d79d015fac09271804a031ddbdaa51 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 8 Jul 2024 21:37:11 -0500 Subject: [PATCH 53/92] update appveyor 2 --- appveyor.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 91abed7b..f82bda2a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,26 +11,26 @@ environment: COMPILER: MSVC15 PLATFORM: "x64" PYTHON_VERSION: 310-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 WITH_MPFR: yes WITH_MPC: yes - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" PYTHON_VERSION: 38-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" PYTHON_VERSION: 39-x64 WITH_SYMPY: no - CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" PYTHON_VERSION: 311-x64 WITH_NUMPY: no - CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 #- BUILD_TYPE: "Debug" # COMPILER: MinGW-w64 # PYTHON_VERSION: 39-x64 @@ -46,14 +46,14 @@ environment: COMPILER: MSVC15 PLATFORM: "Win32" PYTHON_VERSION: 39 - CONDA_INSTALL_LOCN: C:\\Miniconda36 + CONDA_INSTALL_LOCN: C:\\Miniconda38 WITH_MPFR: yes WITH_MPC: yes - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" PYTHON_VERSION: 310-x64 - CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 WITH_MPFR: yes WITH_MPC: yes WITH_LLVM: yes From 4e85a86849e4c68048033f589c0abb8efb99c46c Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 8 Jul 2024 21:45:00 -0500 Subject: [PATCH 54/92] refactor appveyor --- appveyor.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f82bda2a..514d9107 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,14 +65,15 @@ install: - if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat - if [%COMPILER%]==[MSVC15] conda config --add channels conda-forge - if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] conda config --add channels symengine/label/debug -- if [%COMPILER%]==[MSVC15] conda install --yes mpir=3.0.0 vc=14 +- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=mpir=3.0.0 vc=14" +- if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpfr=3.1.5" +- if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpc=1.0.3" +- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% llvmdev=4.0" +- if [%COMPILER%]==[MSVC15] conda install --yes %CONDA_DEPS% - if [%COMPILER%]==[MSVC15] echo %CONDA_PREFIX% - if [%COMPILER%]==[MSVC15] echo %PATH% - if [%COMPILER%]==[MSVC15] set "PATH=%PATH%;%CONDA_PREFIX%\\Library\\bin;%CONDA_PREFIX%" - if [%COMPILER%]==[MSVC15] echo %PATH% -- if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] conda install --yes mpfr=3.1.5 -- if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] conda install --yes mpc=1.0.3 -- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] conda install --yes llvmdev=4.0 - if [%COMPILER%]==[MinGW] set "PATH=C:\MinGW\bin;%PATH%" - if [%COMPILER%]==[MinGW] mingw-get update From 3eaf92179d5a9c74ac4ff60ee009ece2a79ff103 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 8 Jul 2024 22:58:03 -0500 Subject: [PATCH 55/92] Fix 32 bit appveyor --- appveyor.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 514d9107..f21df0ae 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,13 @@ environment: PLATFORMTOOLSET: "v140" matrix: + - BUILD_TYPE: "Release" + COMPILER: MSVC15 + PLATFORM: "Win32" + PYTHON_VERSION: 39 + CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 + WITH_MPFR: yes + WITH_MPC: yes - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" @@ -42,13 +49,6 @@ environment: # COMPILER: MinGW-w64 # PYTHON_VERSION: 39-x64 # WITH_SYMPY: no - - BUILD_TYPE: "Release" - COMPILER: MSVC15 - PLATFORM: "Win32" - PYTHON_VERSION: 39 - CONDA_INSTALL_LOCN: C:\\Miniconda38 - WITH_MPFR: yes - WITH_MPC: yes - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" @@ -61,15 +61,17 @@ environment: install: - set PYTHON_SOURCE_DIR=%CD% - git clone https://github.com/sympy/symengine symengine-cpp +- if [%PLATFORM%]==[Win32] set "CONDA_SUBDIR=win-32" - if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat -- if [%COMPILER%]==[MSVC15] conda config --add channels conda-forge -- if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] conda config --add channels symengine/label/debug - if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=mpir=3.0.0 vc=14" - if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpfr=3.1.5" - if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpc=1.0.3" - if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% llvmdev=4.0" -- if [%COMPILER%]==[MSVC15] conda install --yes %CONDA_DEPS% +- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=%CONDA_DEPS% -c conda-forge" +- if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] set "CONDA_DEPS=%CONDA_DEPS% -c symengine/label/debug" +- if [%COMPILER%]==[MSVC15] conda create -n deps --yes %CONDA_DEPS% +- if [%COMPILER%]==[MSVC15] call conda activate deps - if [%COMPILER%]==[MSVC15] echo %CONDA_PREFIX% - if [%COMPILER%]==[MSVC15] echo %PATH% - if [%COMPILER%]==[MSVC15] set "PATH=%PATH%;%CONDA_PREFIX%\\Library\\bin;%CONDA_PREFIX%" From 8f6f7a371e8cf915d4f6f779bff16b8a73415090 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 25 Jul 2024 10:30:10 -0500 Subject: [PATCH 56/92] Mark subs as throwing exceptions --- symengine/lib/symengine.pxd | 6 +++--- symengine/tests/test_subs.py | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index ee96731b..3e2b5d08 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -168,9 +168,9 @@ cdef extern from "" namespace "SymEngine": void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) except+ nogil cdef extern from "" namespace "SymEngine": - rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil - rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) nogil - rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil + rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil + rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil + rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) except+ nogil cdef extern from "" namespace "SymEngine": rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) except+ nogil diff --git a/symengine/tests/test_subs.py b/symengine/tests/test_subs.py index 4d8c6f0a..b346659b 100644 --- a/symengine/tests/test_subs.py +++ b/symengine/tests/test_subs.py @@ -1,7 +1,7 @@ import unittest from symengine.test_utilities import raises -from symengine import Symbol, sin, cos, sqrt, Add, function_symbol, have_numpy +from symengine import Symbol, sin, cos, sqrt, Add, function_symbol, have_numpy, log def test_basic(): @@ -24,6 +24,12 @@ def test_sin(): assert e.subs(x, 0) == 1 +def test_subs_exception(): + x = Symbol("x") + expr = sin(log(x)) + raises(RuntimeError, lambda: expr.subs({x: 0})) + + def test_args(): x = Symbol("x") e = cos(x) From f09067861cbd99538508932e57ac29191a80eaa1 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 25 Aug 2024 18:44:49 -0500 Subject: [PATCH 57/92] Bump version --- setup.py | 2 +- symengine/__init__.py | 2 +- symengine_version.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 1c5e9207..f105b328 100644 --- a/setup.py +++ b/setup.py @@ -222,7 +222,7 @@ def finalize_options(self): ''' setup(name="symengine", - version="0.11.0", + version="0.13.0", description="Python library providing wrappers to SymEngine", setup_requires=['cython>=0.29.24'], long_description=long_description, diff --git a/symengine/__init__.py b/symengine/__init__.py index b6002a28..97e9afd0 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -63,7 +63,7 @@ def __getattr__(name): raise AttributeError(f"module 'symengine' has no attribute '{name}'") -__version__ = "0.11.0" +__version__ = "0.13.0" # To not expose internals diff --git a/symengine_version.txt b/symengine_version.txt index 87a1cf59..b78dbf25 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.12.0 +ed1e3e4fd8260097fa25aa1282e1d3a4ac4527f3 From d60e88e3e2a7eea03f0d09bfcc1c28710664ec75 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 28 Sep 2024 10:47:02 -0500 Subject: [PATCH 58/92] Add Moraxyc to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index b0719fd5..427f83ad 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,3 +35,4 @@ Garming Sam Pieter Eendebak Ayush Kumar Christian Clauss +Moraxyc From 282d13486b8784b60927c17aba0f608a59da137a Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 28 Sep 2024 10:47:11 -0500 Subject: [PATCH 59/92] Bump symengine version --- symengine_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine_version.txt b/symengine_version.txt index b78dbf25..6345c216 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -ed1e3e4fd8260097fa25aa1282e1d3a4ac4527f3 +v0.13.0 From 1e47d959c4edd9c15e1f893a570e4b0082a39501 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 29 Sep 2024 16:25:26 -0500 Subject: [PATCH 60/92] cython 3.1 fixes --- cmake/cython_test.pyx | 3 --- symengine/lib/symengine_wrapper.in.pyx | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index 22cdb17c..cb803c60 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -1,6 +1,3 @@ -# Test that numpy works in Cython: -from numpy cimport ndarray - # Test that libcpp module is present: from libcpp.vector cimport vector from libcpp.string cimport string diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 8bb9f9cb..26c31ad8 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -5135,24 +5135,24 @@ cdef class _Lambdify(object): return result -cdef double _scipy_callback_lambda_real(int n, double *x, void *user_data) nogil: +cdef double _scipy_callback_lambda_real(int n, double *x, void *user_data) noexcept nogil: cdef symengine.LambdaRealDoubleVisitor* lamb = user_data cdef double result deref(lamb).call(&result, x) return result -cdef void _ctypes_callback_lambda_real(double *output, const double *input, void *user_data) nogil: +cdef void _ctypes_callback_lambda_real(double *output, const double *input, void *user_data) noexcept nogil: cdef symengine.LambdaRealDoubleVisitor* lamb = user_data deref(lamb).call(output, input) IF HAVE_SYMENGINE_LLVM: - cdef double _scipy_callback_llvm_real(int n, double *x, void *user_data) nogil: + cdef double _scipy_callback_llvm_real(int n, double *x, void *user_data) noexcept nogil: cdef symengine.LLVMDoubleVisitor* lamb = user_data cdef double result deref(lamb).call(&result, x) return result - cdef void _ctypes_callback_llvm_real(double *output, const double *input, void *user_data) nogil: + cdef void _ctypes_callback_llvm_real(double *output, const double *input, void *user_data) noexcept nogil: cdef symengine.LLVMDoubleVisitor* lamb = user_data deref(lamb).call(output, input) From 845168d3683f28781b32577abf4f38ed93f0bc79 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Sep 2024 11:38:54 -0500 Subject: [PATCH 61/92] Another cython 3.1 fix --- cmake/cython_test.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index cb803c60..47f98476 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -75,8 +75,8 @@ cdef extern from "" namespace "SymEngine": string get_name() nogil cdef extern from "" namespace "SymEngine": - cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except+ - cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except+ + cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil + cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) From 170e7ded46b60ee43ec1e6ee997fd95205cad2f4 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Sep 2024 11:39:06 -0500 Subject: [PATCH 62/92] freethreading support --- cmake/FindPython.cmake | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index f3381327..2f54f509 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -22,26 +22,36 @@ execute_process( string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH) execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" - OUTPUT_VARIABLE PYTHON_PREFIX_PATH - ) + COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" + OUTPUT_VARIABLE PYTHON_PREFIX_PATH +) string(STRIP ${PYTHON_PREFIX_PATH} PYTHON_PREFIX_PATH) execute_process( - COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" + COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" OUTPUT_VARIABLE PYTHON_VERSION - ) +) string(STRIP ${PYTHON_VERSION} PYTHON_VERSION) message(STATUS "Python version: ${PYTHON_VERSION}") string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION}) +execute_process( + COMMAND ${PYTHON_BIN} -c "import sysconfig;print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))" + OUTPUT_VARIABLE PY_GIL_DISABLED +) +string(STRIP ${PY_GIL_DISABLED} PY_GIL_DISABLED) + +if ("${PY_GIL_DISABLED}" STREQUAL "True") + set (PY_THREAD "t") +endif() + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") FIND_LIBRARY(PYTHON_LIBRARY NAMES - python${PYTHON_VERSION} + python${PYTHON_VERSION}${PY_THREAD} python${PYTHON_VERSION}m - python${PYTHON_VERSION_WITHOUT_DOTS} + python${PYTHON_VERSION_WITHOUT_DOTS}${PY_THREAD} PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} NO_DEFAULT_PATH @@ -51,8 +61,8 @@ endif() execute_process( COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])" - OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp - ) + OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp +) string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp} CACHE BOOL "Python install path") @@ -129,5 +139,9 @@ macro(ADD_PYTHON_LIBRARY name) IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(${name} ${PYTHON_LIBRARY}) set_target_properties(${name} PROPERTIES SUFFIX ".pyd") + IF("${PY_GIL_DISABLED}" STREQUAL "True") + target_compile_definitions(${name} PRIVATE Py_GIL_DISABLED=1) + ENDIF() ENDIF() + endmacro(ADD_PYTHON_LIBRARY) From 8157e6a483b72a6278606ebf5c53f2fae414e734 Mon Sep 17 00:00:00 2001 From: Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:18:50 -0800 Subject: [PATCH 63/92] Fix build with spaces Building symenginepy as part of the SymForce build, I get an error currently if I try to build under a source directory with a space in the path: ``` [100%] Linking CXX shared library symengine_wrapper.cpython-38-x86_64-linux-gnu.so c++: error: test/build/symenginepy-prefix/src/symenginepy-build/build/lib.linux-x86_64-cpython-38/symengine/lib/version_script_symengine_wrapper.txt: No such file or directory make[5]: *** [symengine/lib/CMakeFiles/symengine_wrapper.dir/build.make:121: symengine/lib/symengine_wrapper.cpython-38-x86_64-linux-gnu.so] Error 1 make[4]: *** [CMakeFiles/Makefile2:132: symengine/lib/CMakeFiles/symengine_wrapper.dir/all] Error 2 make[3]: *** [Makefile:136: all] Error 2 error: error building project make[2]: *** [CMakeFiles/symenginepy.dir/build.make:86: symenginepy-prefix/src/symenginepy-stamp/symenginepy-build] Error 1 ``` This change seems to fix that. I'm not 100% sure in what scenarios this applies to a standalone build of symengine? But I figured I'd open a PR and propose this change Coming from here on the SymForce repo: https://github.com/symforce-org/symforce/pull/414 --- cmake/FindPython.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index 2f54f509..df8bfdc1 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -130,7 +130,7 @@ macro(ADD_PYTHON_LIBRARY name) configure_file(${CMAKE_SOURCE_DIR}/cmake/version_script.txt ${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt @ONLY) set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt") + LINK_FLAGS " \"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script_${name}.txt\"") ELSE() add_library(${name} SHARED ${ARGN}) ENDIF() From 0bc912b865cc4ce643011c92d93c9ffb7670c67a Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 21 Dec 2024 14:46:10 +0530 Subject: [PATCH 64/92] Fix CI --- bin/install_travis.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install_travis.sh b/bin/install_travis.sh index 8176202d..572bb0d2 100644 --- a/bin/install_travis.sh +++ b/bin/install_travis.sh @@ -2,7 +2,7 @@ # symengine's bin/install_travis.sh will install miniconda -export conda_pkgs="python=${PYTHON_VERSION} pip 'cython>=0.29.24' pytest gmp mpfr" +export conda_pkgs="python=${PYTHON_VERSION} pip pytest gmp mpfr" if [[ "${WITH_NUMPY}" != "no" ]]; then export conda_pkgs="${conda_pkgs} numpy"; @@ -27,7 +27,7 @@ if [[ "${WITH_SAGE}" == "yes" ]]; then export conda_pkgs="${conda_pkgs} sage=8.1"; fi -conda install -q ${conda_pkgs} +conda install -q ${conda_pkgs} "cython>=0.29.24" if [[ "${WITH_SYMPY}" != "no" ]]; then pip install sympy; From 21485318d0ba4ece84df8fb9b2cc646fd2fea06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Mon, 13 Jan 2025 15:16:48 +0100 Subject: [PATCH 65/92] normlize cython syntax: cython/cython#5430 --- cmake/cython_test.pyx | 4 +- symengine/lib/symengine.pxd | 304 ++++++++++++++++++------------------ 2 files changed, 154 insertions(+), 154 deletions(-) diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx index 47f98476..e97be0b4 100644 --- a/cmake/cython_test.pyx +++ b/cmake/cython_test.pyx @@ -75,8 +75,8 @@ cdef extern from "" namespace "SymEngine": string get_name() nogil cdef extern from "" namespace "SymEngine": - cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil - cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil + cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except + + cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except + cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) diff --git a/symengine/lib/symengine.pxd b/symengine/lib/symengine.pxd index 3e2b5d08..65b3456a 100644 --- a/symengine/lib/symengine.pxd +++ b/symengine/lib/symengine.pxd @@ -51,11 +51,11 @@ cdef extern from "" namespace "SymEngine": cdef cppclass RCP[T]: T& operator*() nogil # Not yet supported in Cython: -# RCP[T]& operator=(RCP[T] &r_ptr) except+ nogil - void reset() except+ nogil +# RCP[T]& operator=(RCP[T] &r_ptr) nogil except + + void reset() nogil except + cdef cppclass Ptr[T]: - T& operator*() except+ nogil + T& operator*() nogil except + void print_stack_on_segfault() nogil @@ -65,7 +65,7 @@ cdef extern from "" namespace "SymEngine": ctypedef RCP[const_Basic] rcp_const_basic "SymEngine::RCP" #cdef cppclass rcp_const_basic "SymEngine::RCP": # Basic& operator*() nogil - # void reset() except+ nogil + # void reset() nogil except + # pass # Cython has broken support for the following: # ctypedef map[rcp_const_basic, rcp_const_basic] map_basic_basic @@ -112,8 +112,8 @@ cdef extern from "" namespace "SymEngine": ctypedef multiset[rcp_const_basic] multiset_basic "SymEngine::multiset_basic" cdef cppclass Basic: - string __str__() except+ nogil - unsigned int hash() except+ nogil + string __str__() nogil except + + unsigned int hash() nogil except + vec_basic get_args() nogil int __cmp__(const Basic &o) nogil @@ -124,11 +124,11 @@ cdef extern from "" namespace "SymEngine": ctypedef unordered_map[rcp_const_basic, rcp_const_number].iterator umap_basic_num_iterator "SymEngine::umap_basic_num::iterator" ctypedef vector[pair[rcp_const_basic, rcp_const_basic]] vec_pair "SymEngine::vec_pair" - bool eq(const Basic &a, const Basic &b) except+ nogil - bool neq(const Basic &a, const Basic &b) except+ nogil + bool eq(const Basic &a, const Basic &b) nogil except + + bool neq(const Basic &a, const Basic &b) nogil except + RCP[const Symbol] rcp_static_cast_Symbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil - RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) except+ nogil + RCP[const PySymbol] rcp_static_cast_PySymbol "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil except + RCP[const Integer] rcp_static_cast_Integer "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Rational] rcp_static_cast_Rational "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil RCP[const Complex] rcp_static_cast_Complex "SymEngine::rcp_static_cast"(rcp_const_basic &b) nogil @@ -162,18 +162,18 @@ cdef extern from "" namespace "SymEngine": bool is_a[T] (const Basic &b) nogil bool is_a_sub[T] (const Basic &b) nogil - rcp_const_basic expand(rcp_const_basic &o, bool deep) except+ nogil + rcp_const_basic expand(rcp_const_basic &o, bool deep) nogil except + void as_numer_denom(rcp_const_basic &x, const Ptr[RCP[Basic]] &numer, const Ptr[RCP[Basic]] &denom) nogil void as_real_imag(rcp_const_basic &x, const Ptr[RCP[Basic]] &real, const Ptr[RCP[Basic]] &imag) nogil - void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) except+ nogil + void cse(vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil - rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) except+ nogil - rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) except+ nogil + rcp_const_basic msubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + + rcp_const_basic ssubs (rcp_const_basic &x, const map_basic_basic &x) nogil except + + rcp_const_basic xreplace (rcp_const_basic &x, const map_basic_basic &x) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) except+ nogil + rcp_const_basic diff "SymEngine::sdiff"(rcp_const_basic &arg, rcp_const_basic &x) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Symbol(Basic): @@ -215,8 +215,8 @@ cdef extern from "pywrapper.h" namespace "SymEngine": PySymbol(string name, PyObject* pyobj, bool use_pickle) except + PyObject* get_py_object() except + - string wrapper_dumps(const Basic &x) except+ nogil - rcp_const_basic wrapper_loads(const string &s) except+ nogil + string wrapper_dumps(const Basic &x) nogil except + + rcp_const_basic wrapper_loads(const string &s) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Integer(Number): @@ -286,9 +286,9 @@ cdef extern from "" namespace "SymEngine": pass cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic add(const vec_basic &a) except+ nogil + cdef rcp_const_basic add(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic sub(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic add(const vec_basic &a) nogil except + cdef cppclass Add(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -296,10 +296,10 @@ cdef extern from "" namespace "SymEngine": const umap_basic_num &get_dict() cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic neg(rcp_const_basic &a) except+ nogil - cdef rcp_const_basic mul(const vec_basic &a) except+ nogil + cdef rcp_const_basic mul(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic div(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic neg(rcp_const_basic &a) nogil except + + cdef rcp_const_basic mul(const vec_basic &a) nogil except + cdef cppclass Mul(Basic): void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) @@ -308,9 +308,9 @@ cdef extern from "" namespace "SymEngine": cdef RCP[const Mul] mul_from_dict "SymEngine::Mul::from_dict"(RCP[const Number] coef, map_basic_basic &d) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) except+ nogil - cdef rcp_const_basic sqrt(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic exp(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic pow(rcp_const_basic &a, rcp_const_basic &b) nogil except + + cdef rcp_const_basic sqrt(rcp_const_basic &x) nogil except + + cdef rcp_const_basic exp(rcp_const_basic &x) nogil except + cdef cppclass Pow(Basic): rcp_const_basic get_base() nogil @@ -344,58 +344,58 @@ cdef extern from "" namespace "SymEngine": RCP[const PyFunctionClass] pyfunc_class, const PyObject* pyobject) nogil cdef extern from "" namespace "SymEngine": - cdef rcp_const_basic sin(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cos(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic tan(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cot(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic csc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sec(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asin(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acos(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atan(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acot(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acsc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asec(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sinh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic cosh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic tanh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic coth(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic csch(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic sech(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asinh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acosh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atanh(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acoth(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic acsch(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic asech(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) except+ nogil - cdef rcp_const_basic abs(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic max(const vec_basic &arg) except+ nogil - cdef rcp_const_basic min(const vec_basic &arg) except+ nogil - cdef rcp_const_basic gamma(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) except+ nogil - cdef rcp_const_basic lambertw(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic zeta(rcp_const_basic &s) except+ nogil - cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) except+ nogil - cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) except+ nogil - cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) except+ nogil - cdef rcp_const_basic levi_civita(const vec_basic &arg) except+ nogil - cdef rcp_const_basic erf(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic erfc(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic loggamma(rcp_const_basic &arg) except+ nogil - cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) except+ nogil - cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) except+ nogil - cdef rcp_const_basic digamma(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic trigamma(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic sign(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic floor(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic ceiling(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic conjugate(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic log(rcp_const_basic &x) except+ nogil - cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) except+ nogil - cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) except+ nogil + cdef rcp_const_basic sin(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cos(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic tan(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cot(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic csc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sec(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asin(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acos(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atan(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acot(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acsc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asec(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sinh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic cosh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic tanh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic coth(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic csch(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic sech(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asinh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acosh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atanh(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acoth(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic acsch(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic asech(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic function_symbol(string name, const vec_basic &arg) nogil except + + cdef rcp_const_basic abs(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic max(const vec_basic &arg) nogil except + + cdef rcp_const_basic min(const vec_basic &arg) nogil except + + cdef rcp_const_basic gamma(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic atan2(rcp_const_basic &num, rcp_const_basic &den) nogil except + + cdef rcp_const_basic lambertw(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic zeta(rcp_const_basic &s) nogil except + + cdef rcp_const_basic zeta(rcp_const_basic &s, rcp_const_basic &a) nogil except + + cdef rcp_const_basic dirichlet_eta(rcp_const_basic &s) nogil except + + cdef rcp_const_basic kronecker_delta(rcp_const_basic &i, rcp_const_basic &j) nogil except + + cdef rcp_const_basic levi_civita(const vec_basic &arg) nogil except + + cdef rcp_const_basic erf(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic erfc(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic lowergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + + cdef rcp_const_basic uppergamma(rcp_const_basic &s, rcp_const_basic &x) nogil except + + cdef rcp_const_basic loggamma(rcp_const_basic &arg) nogil except + + cdef rcp_const_basic beta(rcp_const_basic &x, rcp_const_basic &y) nogil except + + cdef rcp_const_basic polygamma(rcp_const_basic &n, rcp_const_basic &x) nogil except + + cdef rcp_const_basic digamma(rcp_const_basic &x) nogil except + + cdef rcp_const_basic trigamma(rcp_const_basic &x) nogil except + + cdef rcp_const_basic sign(rcp_const_basic &x) nogil except + + cdef rcp_const_basic floor(rcp_const_basic &x) nogil except + + cdef rcp_const_basic ceiling(rcp_const_basic &x) nogil except + + cdef rcp_const_basic conjugate(rcp_const_basic &x) nogil except + + cdef rcp_const_basic log(rcp_const_basic &x) nogil except + + cdef rcp_const_basic log(rcp_const_basic &x, rcp_const_basic &y) nogil except + + cdef rcp_const_basic unevaluated_expr(rcp_const_basic &x) nogil except + cdef cppclass Function(Basic): pass @@ -632,7 +632,7 @@ cdef extern from "" namespace "SymEngine": const unsigned ncols() nogil rcp_const_basic get(unsigned i, unsigned j) nogil rcp_const_basic set(unsigned i, unsigned j, rcp_const_basic e) nogil - string __str__() except+ nogil + string __str__() nogil except + bool eq(const MatrixBase &) nogil rcp_const_basic det() nogil void inv(MatrixBase &) @@ -681,20 +681,20 @@ cdef extern from "" namespace "SymEngine": DenseMatrix* static_cast_DenseMatrix "static_cast"(const MatrixBase *a) void inverse_FFLU "SymEngine::inverse_fraction_free_LU"(const DenseMatrix &A, - DenseMatrix &B) except+ nogil - void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) except+ nogil + DenseMatrix &B) nogil except + + void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x) nogil except + void inverse_GJ "SymEngine::inverse_gauss_jordan"(const DenseMatrix &A, - DenseMatrix &B) except+ nogil + DenseMatrix &B) nogil except + void FFLU_solve "SymEngine::fraction_free_LU_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) except+ nogil + const DenseMatrix &b, DenseMatrix &x) nogil except + void FFGJ_solve "SymEngine::fraction_free_gauss_jordan_solve"(const DenseMatrix &A, - const DenseMatrix &b, DenseMatrix &x) except+ nogil + const DenseMatrix &b, DenseMatrix &x) nogil except + void LDL_solve "SymEngine::LDL_solve"(const DenseMatrix &A, const DenseMatrix &b, - DenseMatrix &x) except+ nogil + DenseMatrix &x) nogil except + void jacobian "SymEngine::sjacobian"(const DenseMatrix &A, - const DenseMatrix &x, DenseMatrix &result) except+ nogil + const DenseMatrix &x, DenseMatrix &result) nogil except + void diff "SymEngine::sdiff"(const DenseMatrix &A, - rcp_const_basic &x, DenseMatrix &result) except+ nogil + rcp_const_basic &x, DenseMatrix &result) nogil except + void eye (DenseMatrix &A, int k) nogil void diag(DenseMatrix &A, vec_basic &v, int k) nogil void ones(DenseMatrix &A) nogil @@ -707,7 +707,7 @@ cdef extern from "" namespace "SymEngine": void cross(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C) nogil cdef extern from "": - void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) except+ nogil + void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, vector[pair[int, int]] &P) nogil except + cdef extern from "" namespace "SymEngine": int probab_prime_p(const Integer &a, int reps) @@ -716,10 +716,10 @@ cdef extern from "" namespace "SymEngine": RCP[const Integer] lcm(const Integer &a, const Integer &b) nogil void gcd_ext(const Ptr[RCP[Integer]] &g, const Ptr[RCP[Integer]] &s, const Ptr[RCP[Integer]] &t, const Integer &a, const Integer &b) nogil - RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) except+ nogil - RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) except+ nogil + RCP[const Integer] mod "SymEngine::mod_f"(const Integer &n, const Integer &d) nogil except + + RCP[const Integer] quotient "SymEngine::quotient_f"(const Integer &n, const Integer &d) nogil except + void quotient_mod "SymEngine::quotient_mod_f"(const Ptr[RCP[Integer]] &q, const Ptr[RCP[Integer]] &mod, - const Integer &n, const Integer &d) except+ nogil + const Integer &n, const Integer &d) nogil except + int mod_inverse(const Ptr[RCP[Integer]] &b, const Integer &a, const Integer &m) nogil bool crt(const Ptr[RCP[Integer]] &R, const vec_integer &rem, @@ -739,9 +739,9 @@ cdef extern from "" namespace "SymEngine": unsigned B, unsigned retries) nogil int factor_pollard_rho_method(const Ptr[RCP[Integer]] &f, const Integer &n, unsigned retries) nogil - void prime_factors(vec_integer &primes, const Integer &n) except+ nogil - void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) except+ nogil - RCP[const Number] bernoulli(unsigned long n) except+ nogil + void prime_factors(vec_integer &primes, const Integer &n) nogil except + + void prime_factor_multiplicities(map_integer_uint &primes, const Integer &n) nogil except + + RCP[const Number] bernoulli(unsigned long n) nogil except + bool primitive_root(const Ptr[RCP[Integer]] &g, const Integer &n) nogil void primitive_root_list(vec_integer &roots, const Integer &n) nogil RCP[const Integer] totient(RCP[const Integer] n) nogil @@ -769,15 +769,15 @@ cdef extern from "" namespace "SymEngine": unsigned next_prime() nogil cdef extern from "" namespace "SymEngine": - bool has_symbol(const Basic &b, const Basic &x) except+ nogil - rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) except+ nogil - set_basic free_symbols(const Basic &b) except+ nogil - set_basic free_symbols(const MatrixBase &b) except+ nogil + bool has_symbol(const Basic &b, const Basic &x) nogil except + + rcp_const_basic coeff(const Basic &b, const Basic &x, const Basic &n) nogil except + + set_basic free_symbols(const Basic &b) nogil except + + set_basic free_symbols(const MatrixBase &b) nogil except + unsigned count_ops(const vec_basic &a) nogil cdef extern from "" namespace "SymEngine": cdef cppclass Boolean(Basic): - RCP[const Boolean] logical_not() except+ nogil + RCP[const Boolean] logical_not() nogil except + cdef cppclass BooleanAtom(Boolean): bool get_val() nogil cdef cppclass Relational(Boolean): @@ -805,25 +805,25 @@ cdef extern from "" namespace "SymEngine": rcp_const_basic boolTrue rcp_const_basic boolFalse - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) except+ nogil - cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil - cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) except+ nogil + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs) nogil except + + cdef RCP[const Boolean] Eq(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Ne(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Ge(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Gt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Le(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + + cdef RCP[const Boolean] Lt(rcp_const_basic &lhs, rcp_const_basic &rhs) nogil except + ctypedef Boolean const_Boolean "const SymEngine::Boolean" ctypedef vector[pair[rcp_const_basic, RCP[const_Boolean]]] PiecewiseVec; ctypedef vector[RCP[Boolean]] vec_boolean "SymEngine::vec_boolean" ctypedef set[RCP[Boolean]] set_boolean "SymEngine::set_boolean" - cdef RCP[const Boolean] logical_and(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_nand(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_or(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) except+ nogil - cdef RCP[const Boolean] logical_nor(set_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_xor(vec_boolean &s) except+ nogil - cdef RCP[const Boolean] logical_xnor(vec_boolean &s) except+ nogil - cdef rcp_const_basic piecewise(PiecewiseVec vec) except+ nogil + cdef RCP[const Boolean] logical_and(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_nand(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_or(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_not(RCP[const Boolean] &s) nogil except + + cdef RCP[const Boolean] logical_nor(set_boolean &s) nogil except + + cdef RCP[const Boolean] logical_xor(vec_boolean &s) nogil except + + cdef RCP[const Boolean] logical_xnor(vec_boolean &s) nogil except + + cdef rcp_const_basic piecewise(PiecewiseVec vec) nogil except + cdef RCP[const Boolean] contains(rcp_const_basic &expr, RCP[const Set] &set) nogil @@ -833,26 +833,26 @@ cdef extern from "" namespace "SymEngine": cdef EvalfDomain EvalfComplex "SymEngine::EvalfDomain::Complex" cdef EvalfDomain EvalfReal "SymEngine::EvalfDomain::Real" cdef EvalfDomain EvalfSymbolic "SymEngine::EvalfDomain::Symbolic" - rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) except+ nogil + rcp_const_basic evalf(const Basic &b, unsigned long bits, EvalfDomain domain) nogil except + cdef extern from "" namespace "SymEngine": - double eval_double(const Basic &b) except+ nogil - double complex eval_complex_double(const Basic &b) except+ nogil + double eval_double(const Basic &b) nogil except + + double complex eval_complex_double(const Basic &b) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass LambdaRealDoubleVisitor: LambdaRealDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + void call(double *r, const double *x) nogil cdef cppclass LambdaComplexDoubleVisitor: LambdaComplexDoubleVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse) nogil except + void call(double complex *r, const double complex *x) nogil cdef extern from "" namespace "SymEngine": cdef cppclass LLVMVisitor: LLVMVisitor() nogil - void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) except+ nogil + void init(const vec_basic &x, const vec_basic &b, bool cse, int opt_level) nogil except + const string& dumps() nogil void loads(const string&) nogil @@ -868,27 +868,27 @@ cdef extern from "" namespace "SymEngine": cdef extern from "" namespace "SymEngine": cdef cppclass SeriesCoeffInterface: - rcp_const_basic as_basic() except+ nogil - umap_int_basic as_dict() except+ nogil - rcp_const_basic get_coeff(int) except+ nogil + rcp_const_basic as_basic() nogil except + + umap_int_basic as_dict() nogil except + + rcp_const_basic get_coeff(int) nogil except + ctypedef RCP[const SeriesCoeffInterface] rcp_const_seriescoeffinterface "SymEngine::RCP" - rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) except+ nogil + rcp_const_seriescoeffinterface series "SymEngine::series"(rcp_const_basic &ex, RCP[const Symbol] &var, unsigned int prec) nogil except + cdef extern from "" namespace "SymEngine": - void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil + void eval_mpfr(mpfr_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + cdef extern from "" namespace "SymEngine": - void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) except+ nogil + void eval_mpc(mpc_t result, const Basic &b, mpfr_rnd_t rnd) nogil except + cdef extern from "" namespace "SymEngine": - rcp_const_basic parse(const string &n) except+ nogil + rcp_const_basic parse(const string &n) nogil except + cdef extern from "" namespace "SymEngine": cdef cppclass Set(Basic): - RCP[const Set] set_intersection(RCP[const Set] &o) except+ nogil - RCP[const Set] set_union(RCP[const Set] &o) except+ nogil - RCP[const Set] set_complement(RCP[const Set] &o) except+ nogil - RCP[const Boolean] contains(rcp_const_basic &a) except+ nogil + RCP[const Set] set_intersection(RCP[const Set] &o) nogil except + + RCP[const Set] set_union(RCP[const Set] &o) nogil except + + RCP[const Set] set_complement(RCP[const Set] &o) nogil except + + RCP[const Boolean] contains(rcp_const_basic &a) nogil except + cdef cppclass Interval(Set): pass cdef cppclass EmptySet(Set): @@ -912,24 +912,24 @@ cdef extern from "" namespace "SymEngine": cdef cppclass ImageSet(Set): pass ctypedef set[RCP[Set]] set_set "SymEngine::set_set" - cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) except+ nogil - cdef RCP[const EmptySet] emptyset() except+ nogil - cdef RCP[const Reals] reals() except+ nogil - cdef RCP[const Rationals] rationals() except+ nogil - cdef RCP[const Integers] integers() except+ nogil - cdef RCP[const UniversalSet] universalset() except+ nogil - cdef RCP[const Set] finiteset(set_basic &container) except+ nogil - cdef RCP[const Set] set_union(set_set &a) except+ nogil - cdef RCP[const Set] set_intersection(set_set &a) except+ nogil - cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) except+ nogil - cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) except+ nogil - cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) except+ nogil - cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) except+ nogil + cdef rcp_const_basic interval(RCP[const Number] &start, RCP[const Number] &end, bool l, bool r) nogil except + + cdef RCP[const EmptySet] emptyset() nogil except + + cdef RCP[const Reals] reals() nogil except + + cdef RCP[const Rationals] rationals() nogil except + + cdef RCP[const Integers] integers() nogil except + + cdef RCP[const UniversalSet] universalset() nogil except + + cdef RCP[const Set] finiteset(set_basic &container) nogil except + + cdef RCP[const Set] set_union(set_set &a) nogil except + + cdef RCP[const Set] set_intersection(set_set &a) nogil except + + cdef RCP[const Set] set_complement_helper(RCP[const Set] &container, RCP[const Set] &universe) nogil except + + cdef RCP[const Set] set_complement(RCP[const Set] &universe, RCP[const Set] &container) nogil except + + cdef RCP[const Set] conditionset(rcp_const_basic &sym, RCP[const Boolean] &condition) nogil except + + cdef RCP[const Set] imageset(rcp_const_basic &sym, rcp_const_basic &expr, RCP[const Set] &base) nogil except + cdef extern from "" namespace "SymEngine": - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) except+ nogil - cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) except+ nogil - cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) except+ nogil + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym) nogil except + + cdef RCP[const Set] solve(rcp_const_basic &f, RCP[const Symbol] &sym, RCP[const Set] &domain) nogil except + + cdef vec_basic linsolve(const vec_basic &eqs, const vec_sym &syms) nogil except + cdef extern from "symengine/tribool.h" namespace "SymEngine": cdef cppclass tribool: @@ -945,10 +945,10 @@ cdef extern from "symengine/tribool.h" namespace "SymEngine::tribool": cdef tribool tritrue cdef extern from "" namespace "SymEngine": - string ccode(const Basic &x) except+ nogil - string latex(const Basic &x) except+ nogil - string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) except+ nogil - string unicode(const Basic &x) except+ nogil + string ccode(const Basic &x) nogil except + + string latex(const Basic &x) nogil except + + string latex(const DenseMatrix &x, unsigned max_rows, unsigned max_cols) nogil except + + string unicode(const Basic &x) nogil except + ## Defined in 'symengine/cwrapper.cpp' cdef struct CRCPBasic: From cb92ff6a9190ada12daaff78ca31cb97bad2b618 Mon Sep 17 00:00:00 2001 From: firatbezir Date: Mon, 10 Feb 2025 22:01:51 +0300 Subject: [PATCH 66/92] Update README with verification instructions --- README.md | 108 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 847af7d6..d9141c7c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ + # SymEngine Python Wrappers -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), +Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), a fast C++ symbolic manipulation library. -[![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) [![Build status](https://ci.appveyor.com/api/projects/status/sl189l9ck3gd8qvk/branch/master?svg=true)](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) +[![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) +[![Build status](https://ci.appveyor.com/api/projects/status/sl189l9ck3gd8qvk/branch/master?svg=true)](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) ## Installation @@ -11,71 +13,91 @@ a fast C++ symbolic manipulation library. See License section for information about wheels - pip install symengine --user +```bash +pip install symengine --user +``` ### Conda package manager - conda install python-symengine -c symengine -c conda-forge +```bash +conda install python-symengine -c symengine -c conda-forge +``` -optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): +Optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): - conda install python-symengine -c symengine/label/dev -c conda-forge +```bash +conda install python-symengine -c symengine/label/dev -c conda-forge +``` ### Build from source Install prerequisites. - CMake >= 2.8.12 - Python3 >= 3.8 - Cython >= 0.29.24 - SymEngine >= 0.7.0 +```bash +CMake >= 2.8.12 +Python3 >= 3.8 +Cython >= 0.29.24 +SymEngine >= 0.7.0 +``` -For SymEngine, only a specific commit/tag (see symengine_version.txt) is supported. -Latest git master branch may not work as there may be breaking changes in SymEngine. +For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is supported. +The latest git master branch may not work as there may be breaking changes in **SymEngine**. Python wrappers can be installed by, - python setup.py install +```bash +python setup.py install +``` + +Additional options to `setup.py` are: + +```bash +python setup.py install build_ext + --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory + --compiler=mingw32|msvc|cygwin # Select the compiler for Windows + --generator=cmake-generator # CMake Generator + --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC + --define="var1=value1;var2=value2" # Give options to CMake + --inplace # Build the extension in source tree +``` + +Standard options to `setup.py` like `--user`, `--prefix` can be used to configure install location. +NumPy is used if found by default, if you wish to make your choice of NumPy use explicit: then add e.g. `WITH_NUMPY=False` to `--define`. + +### Notes on Dependencies -Additional options to setup.py are +If you intend to evaluate floating-point expressions (using **lambdify**), you should consider linking against **LLVM**. Many users might also benefit from linking against **FLINT**, as it is now LGPL-licensed. - python setup.py install build_ext - --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory - --compiler=mingw32|msvc|cygwin # Select the compiler for Windows - --generator=cmake-generator # CMake Generator - --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC - --define="var1=value1;var2=value2" # Give options to CMake - --inplace # Build the extension in source tree +In general, **sudo** is only required if you are installing to the default prefix (`/usr/local`). We recommend specifying a custom prefix (`--prefix=$HOME/.local`) to avoid requiring administrative privileges, which most users can do without using **sudo**. -Standard options to setup.py like `--user`, `--prefix` can be used to -configure install location. NumPy is used if found by default, if you wish -to make your choice of NumPy use explicit: then add -e.g. ``WITH_NUMPY=False`` to ``--define``. +If you're uncomfortable specifying the prefix manually, we suggest using **Conda** or installing the pre-built wheels via **pip** instead of building from source. -Use SymEngine from Python as follows: +## Verification - >>> from symengine import var - >>> var("x y z") - (x, y, z) - >>> e = (x+y+z)**2 - >>> e.expand() - 2*x*y + 2*x*z + 2*y*z + x**2 + y**2 + z**2 +You can verify the installation of **SymEngine** by using the provided code snippet in this README. This snippet ensures that the installation works as expected and that basic functionality is available. -You can read Python tests in `symengine/tests` to see what features are -implemented. +```python +from symengine import var +x, y, z = var('x y z') +e = (x + y + z)**2 +expanded_e = e.expand() +print(expanded_e) +``` +This will output: +```python +x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z +``` +Note: The verification code provided above checks the functionality of SymEngine. For additional verification specific to SymEngine, please refer to the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) for further tests and examples. ## License -symengine.py is MIT licensed and uses several LGPL, BSD-3 and MIT licensed libraries +symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed libraries. -Licenses for the dependencies of pip wheels are as follows, +Licenses for the dependencies of pip wheels are as follows: -pip wheels on Unix use GMP (LGPL-3.0-or-later), MPFR (LGPL-3.0-or-later), -MPC (LGPL-3.0-or-later), LLVM (Apache-2.0), zlib (Zlib), libxml2 (MIT), -zstd (BSD-3-Clause) and symengine (MIT AND BSD-3-Clause). -pip wheels on Windows use MPIR (LGPL-3.0-or-later) instead of GMP above and -pthreads-win32 (LGPL-3.0-or-later) additionally. -NumPy (BSD-3-Clause) and SymPy (BSD-3-Clause) are optional dependencies. -Sources for these binary dependencies can be found on https://github.com/symengine/symengine-wheels/releases +- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). +- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** above and **pthreads-win32** (LGPL-3.0-or-later) additionally. +- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional dependencies. +- Sources for these binary dependencies can be found on [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). From 984cb44b9b85c55b6e375b548b5665fd9183dece Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:30:19 -0600 Subject: [PATCH 67/92] Remove symengine conda channel from isntructions --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index d9141c7c..6e6e624f 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,7 @@ pip install symengine --user ### Conda package manager ```bash -conda install python-symengine -c symengine -c conda-forge -``` - -Optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): - -```bash -conda install python-symengine -c symengine/label/dev -c conda-forge +conda install python-symengine -c conda-forge ``` ### Build from source From 63a7a0f6d3bde94b1fb21cd87874935478ee4875 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:35:57 -0600 Subject: [PATCH 68/92] Update README.md --- README.md | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6e6e624f..2a89249e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SymEngine Python Wrappers -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), +Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), a fast C++ symbolic manipulation library. [![Build Status](https://travis-ci.org/symengine/symengine.py.svg)](https://travis-ci.org/symengine/symengine.py) @@ -34,8 +34,9 @@ Cython >= 0.29.24 SymEngine >= 0.7.0 ``` -For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is supported. -The latest git master branch may not work as there may be breaking changes in **SymEngine**. +For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is +supported. The latest git master branch may not work as there may be breaking +changes in **SymEngine**. Python wrappers can be installed by, @@ -55,20 +56,31 @@ python setup.py install build_ext --inplace # Build the extension in source tree ``` -Standard options to `setup.py` like `--user`, `--prefix` can be used to configure install location. -NumPy is used if found by default, if you wish to make your choice of NumPy use explicit: then add e.g. `WITH_NUMPY=False` to `--define`. +Standard options to `setup.py` like `--user`, `--prefix` can be used to +configure install location. NumPy is used if found by default, if you wish +to make your choice of NumPy use explicit: then add +e.g. `WITH_NUMPY=False` to `--define`. ### Notes on Dependencies -If you intend to evaluate floating-point expressions (using **lambdify**), you should consider linking against **LLVM**. Many users might also benefit from linking against **FLINT**, as it is now LGPL-licensed. +If you intend to evaluate floating-point expressions (using **lambdify**), +you should consider linking against **LLVM**. Many users might also benefit +from linking against **FLINT**, as it is now LGPL-licensed. -In general, **sudo** is only required if you are installing to the default prefix (`/usr/local`). We recommend specifying a custom prefix (`--prefix=$HOME/.local`) to avoid requiring administrative privileges, which most users can do without using **sudo**. +In general, **sudo** is only required if you are installing to the default +prefix (`/usr/local`). We recommend specifying a custom prefix +(`--prefix=$HOME/.local`) to avoid requiring administrative privileges, +which most users can do without using **sudo**. -If you're uncomfortable specifying the prefix manually, we suggest using **Conda** or installing the pre-built wheels via **pip** instead of building from source. +If you're uncomfortable specifying the prefix manually, we suggest using +**Conda** or installing the pre-built wheels via **pip** instead of building +from source. ## Verification -You can verify the installation of **SymEngine** by using the provided code snippet in this README. This snippet ensures that the installation works as expected and that basic functionality is available. +You can verify the installation of **SymEngine** by using the provided code +snippet in this README. This snippet ensures that the installation works as +expected and that basic functionality is available. ```python from symengine import var @@ -82,16 +94,26 @@ This will output: x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z ``` -Note: The verification code provided above checks the functionality of SymEngine. For additional verification specific to SymEngine, please refer to the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) for further tests and examples. +Note: The verification code provided above checks the functionality of +SymEngine. For additional verification specific to SymEngine, please refer to +the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) +for further tests and examples. ## License -symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed libraries. +symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed +libraries. Licenses for the dependencies of pip wheels are as follows: -- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). -- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** above and **pthreads-win32** (LGPL-3.0-or-later) additionally. -- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional dependencies. -- Sources for these binary dependencies can be found on [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). +- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), + **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), + **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), + **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). +- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** + above and **pthreads-win32** (LGPL-3.0-or-later) additionally. +- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional + dependencies. +- Sources for these binary dependencies can be found on + [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). From a3a9ce81796a2b4defdc2b7f074d440c58158e39 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 18:38:47 -0600 Subject: [PATCH 69/92] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2a89249e..e13eb727 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # SymEngine Python Wrappers Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), From 7c48a0d75dcdd543486587584ecaa0643fa9d6d4 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 19:56:16 -0600 Subject: [PATCH 70/92] Update version --- CMakeLists.txt | 2 +- symengine_version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 418b6704..3c83e7cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH}) include(GNUInstallDirs) -find_package(SymEngine 0.8.1 REQUIRED CONFIG +find_package(SymEngine 0.14.0 REQUIRED CONFIG PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/) message("SymEngine_DIR : " ${SymEngine_DIR}) message("SymEngine Version : " ${SymEngine_VERSION}) diff --git a/symengine_version.txt b/symengine_version.txt index 6345c216..6718d65f 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.13.0 +fac9314c78f2809570494017efc6603befeb4eda From 0a3e0af889785cb7ec489da2a96dd98b9a2aa138 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 20:06:48 -0600 Subject: [PATCH 71/92] Use RCPBasicAware{Output,Input}Archive --- symengine/lib/pywrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/symengine/lib/pywrapper.cpp b/symengine/lib/pywrapper.cpp index 4f45a0b7..5ab5e586 100644 --- a/symengine/lib/pywrapper.cpp +++ b/symengine/lib/pywrapper.cpp @@ -292,7 +292,7 @@ PyObject* pickle_loads(const std::string &pickle_str) { return obj; } -RCP load_basic(cereal::PortableBinaryInputArchive &ar, RCP &) +RCP load_basic(RCPBasicAwareInputArchive &ar, RCP &) { bool is_pysymbol; bool store_pickle; @@ -324,7 +324,7 @@ std::string pickle_dumps(const PyObject * obj) { return std::string(buffer, size); } -void save_basic(cereal::PortableBinaryOutputArchive &ar, const Symbol &b) +void save_basic(RCPBasicAwareOutputArchive &ar, const Symbol &b) { bool is_pysymbol = is_a_sub(b); ar(is_pysymbol); @@ -344,7 +344,7 @@ std::string wrapper_dumps(const Basic &x) std::ostringstream oss; unsigned short major = SYMENGINE_MAJOR_VERSION; unsigned short minor = SYMENGINE_MINOR_VERSION; - cereal::PortableBinaryOutputArchive{oss}(major, minor, + RCPBasicAwareOutputArchive{oss}(major, minor, x.rcp_from_this()); return oss.str(); } @@ -354,7 +354,7 @@ RCP wrapper_loads(const std::string &serialized) unsigned short major, minor; RCP obj; std::istringstream iss(serialized); - cereal::PortableBinaryInputArchive iarchive{iss}; + RCPBasicAwareInputArchive iarchive{iss}; iarchive(major, minor); if (major != SYMENGINE_MAJOR_VERSION or minor != SYMENGINE_MINOR_VERSION) { throw SerializationError(StreamFmt() From 320c984c1a196c03dd8c9442935db9f610022737 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sun, 16 Feb 2025 20:18:34 -0600 Subject: [PATCH 72/92] update version to 0.14.0 --- setup.py | 2 +- symengine/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f105b328..035471db 100644 --- a/setup.py +++ b/setup.py @@ -222,7 +222,7 @@ def finalize_options(self): ''' setup(name="symengine", - version="0.13.0", + version="0.14.0", description="Python library providing wrappers to SymEngine", setup_requires=['cython>=0.29.24'], long_description=long_description, diff --git a/symengine/__init__.py b/symengine/__init__.py index 97e9afd0..4ca4dd7c 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -63,7 +63,7 @@ def __getattr__(name): raise AttributeError(f"module 'symengine' has no attribute '{name}'") -__version__ = "0.13.0" +__version__ = "0.14.0" # To not expose internals From 248e6dc1747c8e69633fde3072527a61abe9049d Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 17 Feb 2025 08:04:59 -0600 Subject: [PATCH 73/92] update symengine c++ to 0.14.0 --- symengine_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine_version.txt b/symengine_version.txt index 6718d65f..4a29f93b 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -fac9314c78f2809570494017efc6603befeb4eda +v0.14.0 From df4081db4a0167862e959cf3190e4dd54a269165 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 17 Feb 2025 12:15:17 -0600 Subject: [PATCH 74/92] Add Aaron and Firat to README. Welcome to SymEngine!! --- .mailmap | 1 + AUTHORS | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.mailmap b/.mailmap index 71840613..5a35cee3 100644 --- a/.mailmap +++ b/.mailmap @@ -21,3 +21,4 @@ Abhinav Agarwal Nilay Pochhi Björn Dahlgren Richard Otis richardotis +Firat Bezir diff --git a/AUTHORS b/AUTHORS index 427f83ad..19d0bd08 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,3 +36,5 @@ Pieter Eendebak Ayush Kumar Christian Clauss Moraxyc +Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> +Firat Bezir From e108841338568d5bc8f2034aa70722d9b221c982 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 17 Feb 2025 15:33:22 -0600 Subject: [PATCH 75/92] Drop python 3.8 --- .github/workflows/ci.yml | 18 +++++++++--------- appveyor.yml | 2 +- setup.py | 8 ++++---- symengine/lib/symengine_wrapper.in.pyx | 6 ------ 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2763750c..ec7dc82a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,13 +37,13 @@ jobs: CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' BUILD_SHARED_LIBS: yes OS: ubuntu-20.04 CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_MPFR: yes INTEGER_CLASS: gmpxx WITH_NUMPY: no @@ -51,14 +51,14 @@ jobs: CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_MPC: yes OS: ubuntu-20.04 CC: gcc - BUILD_TYPE: Release WITH_MPFR: yes - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' OS: ubuntu-20.04 CC: gcc @@ -84,14 +84,14 @@ jobs: # CC: gcc - BUILD_TYPE: Debug - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_BFD: yes BUILD_SHARED_LIBS: yes OS: ubuntu-20.04 CC: clang - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_NUMPY: yes OS: ubuntu-20.04 CC: clang @@ -108,7 +108,7 @@ jobs: EXTRA_APT_PACKAGES: 'llvm-14' - BUILD_TYPE: Debug - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_SCIPY: yes WITH_LLVM: 5.0 OS: macos-13 @@ -121,13 +121,13 @@ jobs: CC: clang - BUILD_TYPE: Debug - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' WITH_NUMPY: no OS: macos-13 CC: gcc - BUILD_TYPE: Release - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.13' OS: macos-13 CC: gcc diff --git a/appveyor.yml b/appveyor.yml index f21df0ae..1f02ccd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,7 @@ environment: - BUILD_TYPE: "Release" COMPILER: MSVC15 PLATFORM: "x64" - PYTHON_VERSION: 38-x64 + PYTHON_VERSION: 312-x64 CONDA_INSTALL_LOCN: C:\\Miniconda38-x64 - BUILD_TYPE: "Release" COMPILER: MSVC15 diff --git a/setup.py b/setup.py index 035471db..f76c5a0d 100644 --- a/setup.py +++ b/setup.py @@ -5,8 +5,8 @@ import platform # Make sure the system has the right Python version. -if sys.version_info[:2] < (3, 8): - print("SymEngine requires Python 3.8 or newer. " +if sys.version_info[:2] < (3, 9): + print("SymEngine requires Python 3.9 or newer. " "Python %d.%d detected" % sys.version_info[:2]) sys.exit(-1) @@ -230,7 +230,7 @@ def finalize_options(self): author_email="symengine@googlegroups.com", license="MIT", url="https://github.com/symengine/symengine.py", - python_requires='>=3.8,<4', + python_requires='>=3.9,<4', zip_safe=False, packages=['symengine', 'symengine.lib', 'symengine.tests'], cmdclass = cmdclass, @@ -241,10 +241,10 @@ def finalize_options(self): 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Scientific/Engineering :: Physics', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', ] ) diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index 26c31ad8..6fe0ffa5 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -1213,9 +1213,6 @@ cdef class Basic(object): def __int__(self): return int(float(self)) - def __long__(self): - return int(float(self)) - def __complex__(self): f = self.n(real=False) if not isinstance(f, (ComplexDouble, RealDouble)): @@ -1523,9 +1520,6 @@ cdef class BooleanTrue(BooleanAtom): def _sage_(self): return True - def __nonzero__(self): - return True - def __bool__(self): return True From 08f04ec1341b49e4562fc87fb9cc2140e7702dcb Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 Feb 2025 07:20:04 -0600 Subject: [PATCH 76/92] install setuptools --- bin/install_travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install_travis.sh b/bin/install_travis.sh index 572bb0d2..0460c58a 100644 --- a/bin/install_travis.sh +++ b/bin/install_travis.sh @@ -2,7 +2,7 @@ # symengine's bin/install_travis.sh will install miniconda -export conda_pkgs="python=${PYTHON_VERSION} pip pytest gmp mpfr" +export conda_pkgs="python=${PYTHON_VERSION} pip pytest setuptools gmp mpfr" if [[ "${WITH_NUMPY}" != "no" ]]; then export conda_pkgs="${conda_pkgs} numpy"; From 0fcebccafdbb35cc82ab1fcdbddd964dfdc65c6a Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 Feb 2025 08:09:39 -0600 Subject: [PATCH 77/92] install setuptools on win --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1f02ccd7..ce1c487c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -97,7 +97,7 @@ install: - set "PATH=C:\Python%PYTHON_VERSION%;C:\Python%PYTHON_VERSION%\Scripts;%PATH%" - echo %PATH% -- pip install nose pytest cython +- pip install nose pytest cython setuptools - if NOT [%WITH_NUMPY%]==[no] pip install numpy - if NOT [%WITH_SYMPY%]==[no] pip install sympy From ec3a60522c84ed2b2942dab67ca77a03d6cbbb73 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 Feb 2025 11:24:18 -0600 Subject: [PATCH 78/92] add setuptools to setup_requires --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f76c5a0d..c082f3ea 100644 --- a/setup.py +++ b/setup.py @@ -224,7 +224,7 @@ def finalize_options(self): setup(name="symengine", version="0.14.0", description="Python library providing wrappers to SymEngine", - setup_requires=['cython>=0.29.24'], + setup_requires=['cython>=0.29.24', 'setuptools'], long_description=long_description, author="SymEngine development team", author_email="symengine@googlegroups.com", From 5f924464cbf300748c3b9e4aebf32d78d54d1b5b Mon Sep 17 00:00:00 2001 From: Adrian Ostrowski <81568391+aostrowski-hbn@users.noreply.github.com> Date: Mon, 31 Mar 2025 13:25:46 -0700 Subject: [PATCH 79/92] Fix Fedora/RedHat installation location Those OSes have separate platlib and purelib directories. Symengine was installed partially into both from version 0.10.0 onwards. This change marks some of it's packages as ext_modules, which makes setuptools treat the wheel as platform specific and install if fully into platlib (lib64) instead of purelib (lib). This should solve #474. --- cmake/FindPython.cmake | 2 +- setup.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index df8bfdc1..c1f6c439 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -60,7 +60,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") endif() execute_process( - COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])" + COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['platlib'])" OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp ) string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) diff --git a/setup.py b/setup.py index c082f3ea..fcd97ec9 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ if use_setuptools: try: - from setuptools import setup + from setuptools import Extension, setup from setuptools.command.install import install as _install from setuptools.command.build_ext import build_ext as _build_ext except ImportError: @@ -36,7 +36,7 @@ from distutils.command.build import build as _build if not use_setuptools: - from distutils.core import setup + from distutils.core import Extension, setup from distutils.command.install import install as _install from distutils.command.build_ext import build_ext as _build_ext from distutils.command.build import build as _build @@ -232,7 +232,8 @@ def finalize_options(self): url="https://github.com/symengine/symengine.py", python_requires='>=3.9,<4', zip_safe=False, - packages=['symengine', 'symengine.lib', 'symengine.tests'], + ext_modules=[Extension(name='symengine.lib', sources=[])], + packages=['symengine', 'symengine.tests'], cmdclass = cmdclass, classifiers=[ 'License :: OSI Approved :: MIT License', From 6da52ebc8687f6477d54963524c8c841ce37f582 Mon Sep 17 00:00:00 2001 From: Adrian Ostrowski Date: Tue, 1 Apr 2025 16:34:43 +0200 Subject: [PATCH 80/92] Fix CMake 4.0.0 build break --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fcd97ec9..5adb759f 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,8 @@ from distutils.command.build import build as _build cmake_opts = [("PYTHON_BIN", sys.executable), - ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")] + ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes"), + ("CMAKE_POLICY_VERSION_MINIMUM", "3.5")] cmake_generator = [None] cmake_build_type = ["Release"] From 03918d1183d65a2cde1fb8809f2467ebed633257 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 1 Apr 2025 10:34:11 -0500 Subject: [PATCH 81/92] install py files from cmake --- setup.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 5adb759f..28d05bce 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ if use_setuptools: try: - from setuptools import Extension, setup + from setuptools import setup from setuptools.command.install import install as _install from setuptools.command.build_ext import build_ext as _build_ext except ImportError: @@ -36,14 +36,13 @@ from distutils.command.build import build as _build if not use_setuptools: - from distutils.core import Extension, setup + from distutils.core import setup from distutils.command.install import install as _install from distutils.command.build_ext import build_ext as _build_ext from distutils.command.build import build as _build cmake_opts = [("PYTHON_BIN", sys.executable), - ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes"), - ("CMAKE_POLICY_VERSION_MINIMUM", "3.5")] + ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")] cmake_generator = [None] cmake_build_type = ["Release"] @@ -118,7 +117,7 @@ def cmake_build(self): cmake_cmd = ["cmake", source_dir, "-DCMAKE_BUILD_TYPE=" + cmake_build_type[0], - "-DSYMENGINE_INSTALL_PY_FILES=OFF", + "-DSYMENGINE_INSTALL_PY_FILES=ON", ] cmake_cmd.extend(process_opts(cmake_opts)) if not path.exists(path.join(build_dir, "CMakeCache.txt")): @@ -233,8 +232,7 @@ def finalize_options(self): url="https://github.com/symengine/symengine.py", python_requires='>=3.9,<4', zip_safe=False, - ext_modules=[Extension(name='symengine.lib', sources=[])], - packages=['symengine', 'symengine.tests'], + packages=[], cmdclass = cmdclass, classifiers=[ 'License :: OSI Approved :: MIT License', From fe654772f35b6bd2d285d26e6136ab3dd081a903 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 1 Apr 2025 10:39:47 -0500 Subject: [PATCH 82/92] fix cmake_minimum_required --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c83e7cf..e83c95b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8.12...4.0.0) if (POLICY CMP0057) cmake_policy(SET CMP0057 NEW) # needed for llvm >= 16 From b93259288c8e36ff22d43c17d35e3a42e442ce0e Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 1 Apr 2025 22:12:45 -0500 Subject: [PATCH 83/92] fix installing --- symengine/CMakeLists.txt | 19 +++++++++++++------ symengine/tests/CMakeLists.txt | 19 ++++++++++++------- symengine_version.txt | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/symengine/CMakeLists.txt b/symengine/CMakeLists.txt index 907e6f64..bedec397 100644 --- a/symengine/CMakeLists.txt +++ b/symengine/CMakeLists.txt @@ -1,10 +1,17 @@ add_subdirectory(lib) if (SYMENGINE_INSTALL_PY_FILES) - add_subdirectory(tests) - - set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine) - install(FILES __init__.py utilities.py sympy_compat.py functions.py printing.py - DESTINATION ${PY_PATH} - ) + add_subdirectory(tests) + set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine) + install( + FILES + __init__.py + functions.py + printing.py + sympy_compat.py + test_utilities.py + utilities.py + DESTINATION + ${PY_PATH} +) endif () diff --git a/symengine/tests/CMakeLists.txt b/symengine/tests/CMakeLists.txt index ebd4dfaa..4f19093b 100644 --- a/symengine/tests/CMakeLists.txt +++ b/symengine/tests/CMakeLists.txt @@ -1,13 +1,19 @@ set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine/tests) -install(FILES __init__.py +install( + FILES + __init__.py test_arit.py + test_cse.py test_dict_basic.py test_eval.py test_expr.py test_functions.py - test_number.py + test_lambdify.py + test_logic.py test_matrices.py test_ntheory.py + test_number.py + test_pickling.py test_printing.py test_sage.py test_series_expansion.py @@ -16,10 +22,9 @@ install(FILES __init__.py test_subs.py test_symbol.py test_sympify.py + test_sympy_compat.py test_sympy_conv.py test_var.py - test_lambdify.py - test_sympy_compat.py - test_logic.py - DESTINATION ${PY_PATH} - ) + DESTINATION + ${PY_PATH} +) diff --git a/symengine_version.txt b/symengine_version.txt index 4a29f93b..549ada38 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -v0.14.0 +153b7e98f310bccaae586dab6b49284ccd5f4174 From a924eeffc62a094a58f976b5213bf3d1d83fb099 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 3 Apr 2025 11:35:59 -0500 Subject: [PATCH 84/92] bump to 0.14.1 --- setup.py | 2 +- symengine/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 28d05bce..23d948ef 100644 --- a/setup.py +++ b/setup.py @@ -222,7 +222,7 @@ def finalize_options(self): ''' setup(name="symengine", - version="0.14.0", + version="0.14.1", description="Python library providing wrappers to SymEngine", setup_requires=['cython>=0.29.24', 'setuptools'], long_description=long_description, diff --git a/symengine/__init__.py b/symengine/__init__.py index 4ca4dd7c..e9545baf 100644 --- a/symengine/__init__.py +++ b/symengine/__init__.py @@ -63,7 +63,7 @@ def __getattr__(name): raise AttributeError(f"module 'symengine' has no attribute '{name}'") -__version__ = "0.14.0" +__version__ = "0.14.1" # To not expose internals From 6b35fd056a976d002d71c45ae233ab095563f056 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Thu, 3 Apr 2025 11:37:15 -0500 Subject: [PATCH 85/92] Add Adrian to AUTHORS. Welcome to SymEngine!! --- .mailmap | 1 + AUTHORS | 1 + 2 files changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index 5a35cee3..11654a9b 100644 --- a/.mailmap +++ b/.mailmap @@ -22,3 +22,4 @@ Nilay Pochhi Björn Dahlgren Richard Otis richardotis Firat Bezir +Adrian Ostrowski <81568391+aostrowski-hbn@users.noreply.github.com> diff --git a/AUTHORS b/AUTHORS index 19d0bd08..484d38be 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,3 +38,4 @@ Christian Clauss Moraxyc Aaron Miller <78561124+aaron-skydio@users.noreply.github.com> Firat Bezir +Adrian Ostrowski From 4a8b629da7b5d14901f129de6eee4379d17cf654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 11 Jul 2025 17:52:59 +0200 Subject: [PATCH 86/92] bump ubuntu-20.04 -> 22.04 --- .github/workflows/ci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13e3399b..d8a8f085 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,34 +12,34 @@ jobs: WITH_BFD: yes PYTHON_VERSION: '3.12' TEST_SYMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Debug WITH_BFD: yes PYTHON_VERSION: '3.11' TEST_SYMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Debug WITH_BFD: yes PYTHON_VERSION: '3.10' TEST_SYMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Debug WITH_BFD: yes PYTHON_VERSION: '3.9' TEST_SYMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release PYTHON_VERSION: '3.13' BUILD_SHARED_LIBS: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release @@ -47,25 +47,25 @@ jobs: WITH_MPFR: yes INTEGER_CLASS: gmpxx WITH_NUMPY: no - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release PYTHON_VERSION: '3.13' WITH_MPC: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release WITH_MPFR: yes PYTHON_VERSION: '3.13' - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release PYTHON_VERSION: '3.9' WITH_MPC: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc - BUILD_TYPE: Release @@ -73,27 +73,27 @@ jobs: WITH_MPC: yes INTEGER_CLASS: flint WITH_FLINT: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: gcc #- BUILD_TYPE: Debug # PYTHON_VERSION: '3.9' # WITH_BFD: yes # WITH_PIRANHA: yes - # OS: ubuntu-20.04 + # OS: ubuntu-22.04 # CC: gcc - BUILD_TYPE: Debug PYTHON_VERSION: '3.13' WITH_BFD: yes BUILD_SHARED_LIBS: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: clang - BUILD_TYPE: Release PYTHON_VERSION: '3.13' WITH_NUMPY: yes - OS: ubuntu-20.04 + OS: ubuntu-22.04 CC: clang - BUILD_TYPE: Debug @@ -134,7 +134,7 @@ jobs: - BUILD_TYPE: Release PYTHON_VERSION: '3.11' - OS: ubuntu-20.04 + OS: ubuntu-22.04 WITH_MPC: yes WITH_MPFR: yes WITH_FLINT: yes From a42760575fa06aa608222372456fe68dbda28126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Fri, 11 Jul 2025 20:36:23 +0200 Subject: [PATCH 87/92] revert temporary changes in ci script --- bin/test_symengine_unix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/test_symengine_unix.sh b/bin/test_symengine_unix.sh index 63e3f6ca..976f305d 100644 --- a/bin/test_symengine_unix.sh +++ b/bin/test_symengine_unix.sh @@ -2,10 +2,10 @@ export PYTHON_SOURCE_DIR=`pwd` export TEST_CPP="no" export MAKEFLAGS="-j2" -git clone -b update-CI https://github.com/bjodah/symengine symengine-cpp +git clone https://github.com/symengine/symengine symengine-cpp cd symengine-cpp export SOURCE_DIR=`pwd` -#git checkout `cat ../symengine_version.txt` +git checkout `cat ../symengine_version.txt` cd .. # Setup travis for C++ library From 0cf427709abe1ce45a1998ff804e2cb1c5312445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ingvar=20Dahlgren?= Date: Sat, 12 Jul 2025 11:19:56 +0200 Subject: [PATCH 88/92] attempt updating CI scripts to match upstream --- .github/workflows/ci.yml | 10 ++++++++++ bin/test_symengine_unix.sh | 2 +- symengine_version.txt | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8a8f085..d0954617 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,6 +146,16 @@ jobs: CC: gcc steps: + + - uses: conda-incubator/setup-miniconda@v3 + if: matrix.MSYS_ENV == '' + with: + activate-environment: symengine + channel-priority: strict + architecture: x86_64 + channels: conda-forge + conda-remove-defaults: "true" + - name: Checkout code uses: actions/checkout@v4 diff --git a/bin/test_symengine_unix.sh b/bin/test_symengine_unix.sh index 976f305d..0c62b7d1 100644 --- a/bin/test_symengine_unix.sh +++ b/bin/test_symengine_unix.sh @@ -10,7 +10,7 @@ cd .. # Setup travis for C++ library cd $SOURCE_DIR -source bin/test_symengine_unix.sh +source bin/test_symengine.sh # Setup travis for Python wrappers cd $PYTHON_SOURCE_DIR diff --git a/symengine_version.txt b/symengine_version.txt index 549ada38..52a9266b 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -153b7e98f310bccaae586dab6b49284ccd5f4174 +17871adbd8366d18fc8f372f23f07e508571de46 From 6b920b63966d784e3c0eba9932adb35379d0e665 Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Mon, 14 Jul 2025 13:50:22 +0200 Subject: [PATCH 89/92] add -el {0} to bash command (required by setup-miniconda) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0954617..77578d0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,7 +160,7 @@ jobs: uses: actions/checkout@v4 - name: Build and test symengine - shell: bash + shell: bash -el {0} run: | source bin/test_symengine_unix.sh env: From 40a91073c35f85cff54a5632a12b3c6675349dba Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Mon, 14 Jul 2025 13:59:31 +0200 Subject: [PATCH 90/92] remove activate - conda env should already be active --- bin/install_travis.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/install_travis.sh b/bin/install_travis.sh index 0460c58a..f63a4747 100644 --- a/bin/install_travis.sh +++ b/bin/install_travis.sh @@ -33,5 +33,4 @@ if [[ "${WITH_SYMPY}" != "no" ]]; then pip install sympy; fi -conda clean --all -source activate $our_install_dir; +conda clean --all \ No newline at end of file From 94e136126075daa4263d676d68bd0d400f99c09c Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Mon, 14 Jul 2025 14:05:58 +0200 Subject: [PATCH 91/92] use WITH_LATEST_GCC on ubuntu-24.04 job to avoid symengine CI script trying to use gcc-9 --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77578d0d..c176f13e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,6 +101,7 @@ jobs: WITH_SYMPY: yes WITH_LLVM: 18 WITH_SCIPY: yes + WITH_LATEST_GCC: yes INTEGER_CLASS: 'boostmp' PYTEST_ADDOPTS: '-k "not integer_nthroot"' OS: ubuntu-24.04 From 50682e97e748c135d0143ce02a830b080fff2730 Mon Sep 17 00:00:00 2001 From: Bjorn Date: Mon, 14 Jul 2025 14:41:00 +0200 Subject: [PATCH 92/92] Update symengine_version.txt --- symengine_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symengine_version.txt b/symengine_version.txt index 52a9266b..e49372be 100644 --- a/symengine_version.txt +++ b/symengine_version.txt @@ -1 +1 @@ -17871adbd8366d18fc8f372f23f07e508571de46 +c9510fb4b5c30b84adb993573a51f2a9a38a4cfe