diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index 38959f4a8c..553fbccb15 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -32,7 +32,7 @@ jobs: name: [ pytest-ubuntu-py311-gcc11-noomp, pytest-ubuntu-py38-gcc12-omp, - pytest-ubuntu-py37-gcc7-omp, + pytest-ubuntu-py38-gcc7-omp, pytest-ubuntu-py310-gcc10-noomp, pytest-ubuntu-py312-gcc13-omp, pytest-ubuntu-py39-gcc9-omp, @@ -56,8 +56,8 @@ jobs: language: "openmp" sympy: "1.10" - - name: pytest-ubuntu-py37-gcc7-omp - python-version: '3.7' + - name: pytest-ubuntu-py38-gcc7-omp + python-version: '3.8' os: ubuntu-20.04 arch: "gcc-7" language: "openmp" diff --git a/devito/arch/archinfo.py b/devito/arch/archinfo.py index fe0a15c3e0..562a5dc6de 100644 --- a/devito/arch/archinfo.py +++ b/devito/arch/archinfo.py @@ -2,7 +2,7 @@ from subprocess import PIPE, Popen, DEVNULL, run -from cached_property import cached_property +from functools import cached_property import cpuinfo import ctypes import numpy as np diff --git a/devito/data/decomposition.py b/devito/data/decomposition.py index 532e03e3c6..7fad455d33 100644 --- a/devito/data/decomposition.py +++ b/devito/data/decomposition.py @@ -1,7 +1,7 @@ from collections.abc import Iterable +from functools import cached_property import numpy as np -from cached_property import cached_property from devito.data.meta import LEFT from devito.tools import is_integer, as_tuple diff --git a/devito/finite_differences/coefficients.py b/devito/finite_differences/coefficients.py index 5ad167b8d5..0d7b7213a1 100644 --- a/devito/finite_differences/coefficients.py +++ b/devito/finite_differences/coefficients.py @@ -1,5 +1,6 @@ +from functools import cached_property + import numpy as np -from cached_property import cached_property from devito.finite_differences import Weights, generate_indices from devito.finite_differences.tools import numeric_weights diff --git a/devito/finite_differences/derivative.py b/devito/finite_differences/derivative.py index a32acce34c..c65d06790d 100644 --- a/devito/finite_differences/derivative.py +++ b/devito/finite_differences/derivative.py @@ -1,7 +1,7 @@ from collections import OrderedDict from collections.abc import Iterable +from functools import cached_property -from cached_property import cached_property import sympy from .finite_difference import generic_derivative, first_derivative, cross_derivative diff --git a/devito/finite_differences/differentiable.py b/devito/finite_differences/differentiable.py index c9264ddb41..9eabef12d1 100644 --- a/devito/finite_differences/differentiable.py +++ b/devito/finite_differences/differentiable.py @@ -1,8 +1,7 @@ from collections import ChainMap from itertools import product -from functools import singledispatch +from functools import singledispatch, cached_property -from cached_property import cached_property import numpy as np import sympy from sympy.core.add import _addsort diff --git a/devito/ir/clusters/cluster.py b/devito/ir/clusters/cluster.py index 2e3699fe5e..2964ce25f8 100644 --- a/devito/ir/clusters/cluster.py +++ b/devito/ir/clusters/cluster.py @@ -1,7 +1,7 @@ from itertools import chain +from functools import cached_property import numpy as np -from cached_property import cached_property from devito.ir.equations import ClusterizedEq from devito.ir.support import (PARALLEL, PARALLEL_IF_PVT, BaseGuardBoundNext, diff --git a/devito/ir/equations/equation.py b/devito/ir/equations/equation.py index e1e487df46..8e478fe1d7 100644 --- a/devito/ir/equations/equation.py +++ b/devito/ir/equations/equation.py @@ -1,4 +1,5 @@ -from cached_property import cached_property +from functools import cached_property + import sympy from devito.ir.equations.algorithms import dimension_sort, lower_exprs diff --git a/devito/ir/iet/efunc.py b/devito/ir/iet/efunc.py index a8450bc4aa..67f58c8d2e 100644 --- a/devito/ir/iet/efunc.py +++ b/devito/ir/iet/efunc.py @@ -1,4 +1,4 @@ -from cached_property import cached_property +from functools import cached_property from devito.ir.iet.nodes import Call, Callable from devito.ir.iet.utils import derive_parameters diff --git a/devito/ir/iet/nodes.py b/devito/ir/iet/nodes.py index 305f5291f2..4f1d2727be 100644 --- a/devito/ir/iet/nodes.py +++ b/devito/ir/iet/nodes.py @@ -2,7 +2,7 @@ import abc import inspect -from cached_property import cached_property +from functools import cached_property from collections import OrderedDict, namedtuple from collections.abc import Iterable diff --git a/devito/ir/support/basic.py b/devito/ir/support/basic.py index 30a0923fb0..8aedf970d9 100644 --- a/devito/ir/support/basic.py +++ b/devito/ir/support/basic.py @@ -1,6 +1,6 @@ from itertools import chain, product +from functools import cached_property -from cached_property import cached_property from sympy import S from devito.ir.support.space import Backward, null_ispace diff --git a/devito/ir/support/space.py b/devito/ir/support/space.py index c1170839b8..2c773e08a5 100644 --- a/devito/ir/support/space.py +++ b/devito/ir/support/space.py @@ -1,9 +1,8 @@ import abc from collections import OrderedDict -from functools import reduce +from functools import reduce, cached_property from operator import mul -from cached_property import cached_property from sympy import Expr from devito.ir.support.utils import minimum, maximum diff --git a/devito/mpi/distributed.py b/devito/mpi/distributed.py index b1b0d6de1a..6baf924dae 100644 --- a/devito/mpi/distributed.py +++ b/devito/mpi/distributed.py @@ -1,12 +1,13 @@ from abc import ABC, abstractmethod from ctypes import c_int, c_void_p, sizeof from itertools import groupby, product +from functools import cached_property + from math import ceil, pow from sympy import factorint import atexit -from cached_property import cached_property import numpy as np from cgen import Struct, Value diff --git a/devito/mpi/halo_scheme.py b/devito/mpi/halo_scheme.py index b8b689296f..745024a35d 100644 --- a/devito/mpi/halo_scheme.py +++ b/devito/mpi/halo_scheme.py @@ -1,8 +1,8 @@ from collections import OrderedDict, namedtuple, defaultdict from itertools import product from operator import attrgetter +from functools import cached_property -from cached_property import cached_property from sympy import Max, Min import sympy diff --git a/devito/operations/interpolators.py b/devito/operations/interpolators.py index 8983b3acef..52501c54c4 100644 --- a/devito/operations/interpolators.py +++ b/devito/operations/interpolators.py @@ -1,9 +1,8 @@ from abc import ABC, abstractmethod -from functools import wraps +from functools import wraps, cached_property import sympy import numpy as np -from cached_property import cached_property try: from scipy.special import i0 diff --git a/devito/operator/operator.py b/devito/operator/operator.py index 462e5b335b..3b3290f621 100644 --- a/devito/operator/operator.py +++ b/devito/operator/operator.py @@ -1,9 +1,9 @@ from collections import OrderedDict, namedtuple +from functools import cached_property import ctypes from operator import attrgetter from math import ceil -from cached_property import cached_property from sympy import sympify from devito.arch import compiler_registry, platform_registry diff --git a/devito/passes/clusters/aliases.py b/devito/passes/clusters/aliases.py index 7814ecd67f..0b4c7dd782 100644 --- a/devito/passes/clusters/aliases.py +++ b/devito/passes/clusters/aliases.py @@ -1,8 +1,7 @@ from collections import Counter, OrderedDict, defaultdict, namedtuple -from functools import singledispatch +from functools import singledispatch, cached_property from itertools import groupby -from cached_property import cached_property import numpy as np import sympy diff --git a/devito/passes/clusters/buffering.py b/devito/passes/clusters/buffering.py index 48a7b27b31..aff349ea1a 100644 --- a/devito/passes/clusters/buffering.py +++ b/devito/passes/clusters/buffering.py @@ -1,7 +1,7 @@ from collections import OrderedDict, defaultdict, namedtuple from itertools import combinations +from functools import cached_property -from cached_property import cached_property import numpy as np from devito.ir import (Cluster, Forward, GuardBound, Interval, IntervalGroup, diff --git a/devito/passes/iet/parpragma.py b/devito/passes/iet/parpragma.py index cc5d5dd5f9..195069d8e7 100644 --- a/devito/passes/iet/parpragma.py +++ b/devito/passes/iet/parpragma.py @@ -1,8 +1,8 @@ from collections import defaultdict +from functools import cached_property import numpy as np import cgen as c -from cached_property import cached_property from sympy import And, Max, true from devito.data import FULL diff --git a/devito/tools/utils.py b/devito/tools/utils.py index e89a1aaa4e..57fc1573b7 100644 --- a/devito/tools/utils.py +++ b/devito/tools/utils.py @@ -3,7 +3,6 @@ from functools import reduce from itertools import chain, combinations, groupby, product, zip_longest from operator import attrgetter, mul -import sys import types import numpy as np @@ -16,11 +15,6 @@ 'humanbytes', 'contains_val', 'sorted_priority'] -# Some utils run faster with Python>=3.7 -vi = sys.version_info -py_ge_37 = (vi.major, vi.minor) >= (3, 7) - - def prod(iterable, initial=1): return reduce(mul, iterable, initial) @@ -163,49 +157,33 @@ def single_or(l): return any(i) and not any(i) -if py_ge_37: - def filter_ordered(elements, key=None): - # This method exploits the fact that dictionary keys are unique and ordered - # (since Python 3.7). It's concise and often faster for larger lists +def filter_ordered(elements, key=None): + """ + Filter elements in a list while preserving order. - if isinstance(elements, types.GeneratorType): - elements = list(elements) + Parameters + ---------- + key : callable, optional + Conversion key used during equality comparison. + """ + if isinstance(elements, types.GeneratorType): + elements = list(elements) - if key is None: - return list(dict.fromkeys(elements)) - else: - return list(dict(zip([key(i) for i in elements], elements)).values()) - -else: - def filter_ordered(elements, key=None): - if isinstance(elements, types.GeneratorType): - elements = list(elements) - - seen = set() - if key is None: - try: - unordered, inds = np.unique(elements, return_index=True) - return unordered[np.argsort(inds)].tolist() - except: - return sorted(list(set(elements)), key=elements.index) - else: - ret = [] - for e in elements: - k = key(e) - if k not in seen: - ret.append(e) - seen.add(k) - return ret - - -filter_ordered.__doc__ = """\ -Filter elements in a list while preserving order. - -Parameters ----------- -key : callable, optional - Conversion key used during equality comparison. -""" + seen = set() + if key is None: + try: + unordered, inds = np.unique(elements, return_index=True) + return unordered[np.argsort(inds)].tolist() + except: + return sorted(list(set(elements)), key=elements.index) + else: + ret = [] + for e in elements: + k = key(e) + if k not in seen: + ret.append(e) + seen.add(k) + return ret def filter_sorted(elements, key=None): diff --git a/devito/types/array.py b/devito/types/array.py index 0cfc754bd6..82ef432d65 100644 --- a/devito/types/array.py +++ b/devito/types/array.py @@ -1,7 +1,7 @@ from ctypes import POINTER, Structure, c_void_p, c_ulong +from functools import cached_property import numpy as np -from cached_property import cached_property from sympy import Expr from devito.tools import (Reconstructable, as_tuple, c_restrict_void_p, diff --git a/devito/types/basic.py b/devito/types/basic.py index 9bb9334c4a..5ca2be984d 100644 --- a/devito/types/basic.py +++ b/devito/types/basic.py @@ -1,7 +1,7 @@ import abc from collections import namedtuple from ctypes import POINTER, _Pointer, c_char_p, c_char -from functools import reduce +from functools import reduce, cached_property from operator import mul import numpy as np @@ -9,7 +9,6 @@ from sympy.core.assumptions import _assume_rules from sympy.core.decorators import call_highest_priority -from cached_property import cached_property from devito.data import default_allocator from devito.parameters import configuration diff --git a/devito/types/dense.py b/devito/types/dense.py index 74baeab3d0..0a5385b7a5 100644 --- a/devito/types/dense.py +++ b/devito/types/dense.py @@ -6,7 +6,7 @@ import numpy as np import sympy from psutil import virtual_memory -from cached_property import cached_property +from functools import cached_property from devito.builtins import assign from devito.data import (DOMAIN, OWNED, HALO, NOPAD, FULL, LEFT, CENTER, RIGHT, @@ -30,6 +30,7 @@ RegionMeta = namedtuple('RegionMeta', 'offset size') +Offset = namedtuple('Offset', 'left right') class DiscreteFunction(AbstractFunction, ArgProvider, Differentiable): @@ -203,6 +204,10 @@ def coefficients(self): """Form of the coefficients of the function.""" return self._coefficients + @property + def _shape_with_outhalo(self): + return self.shape_with_halo + @cached_property def shape(self): """ @@ -243,8 +248,6 @@ def shape_with_halo(self): """ return tuple(j + i + k for i, (j, k) in zip(self.shape, self._size_outhalo)) - _shape_with_outhalo = shape_with_halo - @cached_property def _shape_with_inhalo(self): """ @@ -310,8 +313,13 @@ def size_global(self): """ return reduce(mul, self.shape_global) - _offset_inhalo = AbstractFunction._offset_halo - _size_inhalo = AbstractFunction._size_halo + @property + def _offset_inhalo(self): + return super()._offset_halo + + @property + def _size_inhalo(self): + return super()._size_halo @cached_property def _size_outhalo(self): diff --git a/devito/types/dimension.py b/devito/types/dimension.py index cf0749e777..df412db0d6 100644 --- a/devito/types/dimension.py +++ b/devito/types/dimension.py @@ -1,10 +1,10 @@ from collections import namedtuple +from functools import cached_property import math import sympy from sympy.core.decorators import call_highest_priority import numpy as np -from cached_property import cached_property from devito.data import LEFT, RIGHT from devito.exceptions import InvalidArgument diff --git a/devito/types/equation.py b/devito/types/equation.py index eb786b632c..c4af3385c3 100644 --- a/devito/types/equation.py +++ b/devito/types/equation.py @@ -2,7 +2,7 @@ import sympy -from cached_property import cached_property +from functools import cached_property from devito.finite_differences import default_rules from devito.tools import as_tuple diff --git a/devito/types/grid.py b/devito/types/grid.py index 7bc3492ef1..8dbc4767ef 100644 --- a/devito/types/grid.py +++ b/devito/types/grid.py @@ -1,10 +1,10 @@ from abc import ABC from collections import namedtuple +from functools import cached_property from math import floor import numpy as np from sympy import prod -from cached_property import cached_property from devito.data import LEFT, RIGHT from devito.logger import warning diff --git a/devito/types/lazy.py b/devito/types/lazy.py index e96a081ecf..f4279327d9 100644 --- a/devito/types/lazy.py +++ b/devito/types/lazy.py @@ -1,4 +1,4 @@ -from cached_property import cached_property +from functools import cached_property from devito.tools import Reconstructable diff --git a/devito/types/parallel.py b/devito/types/parallel.py index 0b7c3f9271..fe195e9c06 100644 --- a/devito/types/parallel.py +++ b/devito/types/parallel.py @@ -8,8 +8,8 @@ import os from ctypes import POINTER, c_void_p +from functools import cached_property -from cached_property import cached_property import numpy as np from devito.exceptions import InvalidArgument diff --git a/devito/types/sparse.py b/devito/types/sparse.py index dfc193e72c..094ec7dd98 100644 --- a/devito/types/sparse.py +++ b/devito/types/sparse.py @@ -8,7 +8,7 @@ import sympy import numpy as np -from cached_property import cached_property +from functools import cached_property from devito.finite_differences import generate_fd_shortcuts from devito.mpi import MPI, SparseDistributor diff --git a/devito/types/tensor.py b/devito/types/tensor.py index 0ca08b44b1..ae69ba8899 100644 --- a/devito/types/tensor.py +++ b/devito/types/tensor.py @@ -1,5 +1,5 @@ from collections import OrderedDict -from cached_property import cached_property +from functools import cached_property import numpy as np from sympy.core.sympify import converter as sympify_converter diff --git a/examples/seismic/source.py b/examples/seismic/source.py index a736c5bb4f..94297296e1 100644 --- a/examples/seismic/source.py +++ b/examples/seismic/source.py @@ -1,5 +1,5 @@ +from functools import cached_property from scipy import interpolate -from cached_property import cached_property import numpy as np try: import matplotlib.pyplot as plt diff --git a/requirements.txt b/requirements.txt index 3f780bd6aa..61a9636de7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ pip>=9.0.1 numpy>1.16 sympy>=1.9,<1.13 -cached-property psutil>=5.1.0,<6.0 py-cpuinfo<10 cgen>=2020.1 diff --git a/setup.py b/setup.py index 85f165c78c..5d22060ba0 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,7 @@ }, url='http://www.devitoproject.org', platforms=["Linux", "Mac OS-X", "Unix"], - python_requires=">=3.7", + python_requires=">=3.8", classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -82,7 +82,6 @@ 'Operating System :: Unix', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', diff --git a/tests/test_dse.py b/tests/test_dse.py index eaab3dcee6..0f0fcff31a 100644 --- a/tests/test_dse.py +++ b/tests/test_dse.py @@ -1,6 +1,7 @@ +from functools import cached_property + import numpy as np import pytest -from cached_property import cached_property from sympy import Mul # noqa from sympy.core.mul import _mulsort diff --git a/tests/test_mpi.py b/tests/test_mpi.py index 4096fb9c46..4602810292 100644 --- a/tests/test_mpi.py +++ b/tests/test_mpi.py @@ -1,6 +1,6 @@ import numpy as np import pytest -from cached_property import cached_property +from functools import cached_property from conftest import _R, assert_blocking, assert_structure from devito import (Grid, Constant, Function, TimeFunction, SparseFunction, diff --git a/versioneer.py b/versioneer.py index 1e3753e63f..c44e729860 100644 --- a/versioneer.py +++ b/versioneer.py @@ -10,7 +10,7 @@ * https://github.com/python-versioneer/python-versioneer * Brian Warner * License: Public Domain (Unlicense) -* Compatible with: Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3 +* Compatible with: Python 3.8, 3.9, 3.10, 3.11, 3.12 and pypy3 * [![Latest Version][pypi-image]][pypi-url] * [![Build Status][travis-image]][travis-url]