Skip to content

Commit

Permalink
Use SymPy version 1.9 (#138)
Browse files Browse the repository at this point in the history
- Adapt SymPDE for working with new versions of SymPy (up to 1.9)
- Increase minimum required version of SymPy from 1.2 to 1.5
- Change SymPDE library version to 0.18.0

For now, SymPy 1.10 is not supported yet.

---------

Co-authored-by: Yaman Güçlü <yaman.guclu@gmail.com>
  • Loading branch information
tomcaruso and yguclu authored Jul 18, 2023
1 parent d56e612 commit 3dec079
Show file tree
Hide file tree
Showing 34 changed files with 223 additions and 68 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sympde"
version = "0.17.2"
version = "0.18.0"
description = "Symbolic calculus for partial differential equations (and variational forms)"
readme = "README.rst"
requires-python = ">= 3.8, < 3.12"
Expand All @@ -17,7 +17,7 @@ maintainers = [
keywords = ["math"]
classifiers = ["Programming Language :: Python :: 3"]
dependencies = [
'sympy >= 1.2, < 1.7',
'sympy >= 1.5, < 1.10',
'h5py',
'pytest',
'pyyaml',
Expand Down
13 changes: 7 additions & 6 deletions sympde/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .version import __version__
from .core import *
from .topology import *
from .exterior import *
from .printing import *
from .utilities import *
from .version import __version__
from .old_sympy_utilities import with_metaclass
from .core import *
from .topology import *
from .exterior import *
from .printing import *
from .utilities import *
2 changes: 1 addition & 1 deletion sympde/calculus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
from sympy.core.containers import Tuple
from sympy.core.singleton import S
from sympy.core.decorators import call_highest_priority
from sympy.core.compatibility import is_sequence

from sympde.old_sympy_utilities import is_sequence
from sympde.core.basic import CalculusFunction
from sympde.core.basic import _coeffs_registery
from sympde.topology.space import ScalarFunction, VectorFunction
Expand Down
4 changes: 2 additions & 2 deletions sympde/calculus/tests/test_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ def test_calculus_2d_5():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

#test_calculus_2d_1()
Expand Down
4 changes: 1 addition & 3 deletions sympde/core/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
from sympy import Mul, Add
from sympy import postorder_traversal
from sympy import preorder_traversal

from sympy.core.expr import Expr
from sympy.core.containers import Tuple
from sympy import Integer, Float

from sympy import Add, Mul
from sympy import simplify
from sympy import S
from sympy.core.compatibility import is_sequence
from sympy import Basic
from sympy import Indexed, IndexedBase

from sympde.old_sympy_utilities import is_sequence
from .basic import CalculusFunction
from .basic import _coeffs_registery

Expand Down
13 changes: 7 additions & 6 deletions sympde/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from sympy.core import Expr, Add, Mul
from sympy.core.numbers import Zero as sy_Zero
from sympy.core.containers import Tuple
from sympy.core.compatibility import is_sequence

from sympde.old_sympy_utilities import is_sequence
from sympde.core.basic import CalculusFunction
from sympde.core.basic import Constant
from sympde.core.utils import random_string
Expand Down Expand Up @@ -396,7 +396,7 @@ def __call__(self, *tests, **kwargs):
# Make sure that 'values' is always a list
if len(tests) == 1:
values = tests[0]
if not is_sequence(values):
if not is_sequence(values, vector=isinstance(values, VectorFunction)):
values = [values]
else:
values = tests
Expand Down Expand Up @@ -502,8 +502,8 @@ def __call__(self, trials, tests, **kwargs):
expr = self._update_free_variables(**kwargs)

# If needed, convert positional arguments to lists
if not is_sequence(trials): trials = [trials]
if not is_sequence(tests ): tests = [tests ]
if not is_sequence(trials, vector=isinstance(trials, VectorFunction)): trials = [trials]
if not is_sequence(tests, vector=isinstance(tests, VectorFunction)): tests = [tests ]

# Concatenate input values into single list
values = [*trials, *tests]
Expand Down Expand Up @@ -652,8 +652,9 @@ def linearize(form, fields, trials=None):
for I in integrals:

g0 = I.expr
g1 = I.expr.subs(zip(fields, new_fields)).expand()
dg_du = ((g1-g0)/eps).series(eps, 0, 2).subs(eps, 0)
g1 = I.expr.subs(zip(fields, new_fields))
temp=((g1-g0)/eps).expand()
dg_du = (temp).series(eps, 0, 2).subs(eps, 0)

if dg_du:
new_I = integral(I.domain, dg_du)
Expand Down
4 changes: 2 additions & 2 deletions sympde/expr/tests/test_equation_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ def test_equation_2d_6():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

4 changes: 2 additions & 2 deletions sympde/expr/tests/test_essential_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def test_essential_bc_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()
6 changes: 3 additions & 3 deletions sympde/expr/tests/test_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def test_area_2d_1():

mu = Constant('mu' , is_real=True)

e = ElementDomain(domain)
e = ElementDomain()
area = Area(e)

V = ScalarFunctionSpace('V', domain)
Expand Down Expand Up @@ -1896,9 +1896,9 @@ def test_interface_integral_4():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()
4 changes: 2 additions & 2 deletions sympde/expr/tests/test_find_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def test_find_2d_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()
4 changes: 2 additions & 2 deletions sympde/expr/tests/test_newton_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def test_newton_2d_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()
4 changes: 2 additions & 2 deletions sympde/expr/tests/test_tensor_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def test_tensorize_2d_3():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()
1 change: 0 additions & 1 deletion sympde/exterior/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from sympy import Function
from sympy import Integer, Float
from sympy.core.singleton import Singleton
from sympy.core.compatibility import with_metaclass
from sympy.core import Add, Mul
from sympy.core.singleton import S

Expand Down
3 changes: 1 addition & 2 deletions sympde/exterior/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
from sympy import Function
from sympy import Integer, Float
from sympy.core.singleton import Singleton
from sympy.core.compatibility import with_metaclass
from sympy.core import Add, Mul
from sympy.core.singleton import S

from sympde.old_sympy_utilities import with_metaclass
from sympde.core.basic import _coeffs_registery
from sympde.core import LinearOperator


#==============================================================================
class FormType(with_metaclass(Singleton, Basic)):
"""Base class representing differential form types"""
Expand Down
1 change: 0 additions & 1 deletion sympde/exterior/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from sympy import Function
from sympy import Integer, Float
from sympy.core.singleton import Singleton
from sympy.core.compatibility import with_metaclass
from sympy.core import Add, Mul
from sympy.core.singleton import S

Expand Down
1 change: 0 additions & 1 deletion sympde/exterior/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from sympy import Function
from sympy import Integer, Float
from sympy.core.singleton import Singleton
from sympy.core.compatibility import with_metaclass
from sympy.core import Add, Mul
from sympy.core.singleton import S

Expand Down
4 changes: 2 additions & 2 deletions sympde/exterior/tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ def test_compiler_3d_stokes():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

#test_compiler_3d_1()
Expand Down
4 changes: 2 additions & 2 deletions sympde/exterior/tests/test_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def test_datatype_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

#test_datatype_1()
4 changes: 2 additions & 2 deletions sympde/exterior/tests/test_exterior.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def test_exterior_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

#test_exterior_1()
4 changes: 2 additions & 2 deletions sympde/exterior/tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def test_type_inference_1():
#==============================================================================

def teardown_module():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

def teardown_function():
from sympy import cache
from sympy.core import cache
cache.clear_cache()

#test_type_inference_1()
Loading

0 comments on commit 3dec079

Please sign in to comment.