diff --git a/findiff/legacy/operators.py b/findiff/legacy/operators.py index 7aba623..061ba01 100644 --- a/findiff/legacy/operators.py +++ b/findiff/legacy/operators.py @@ -119,34 +119,16 @@ def _eval_args(self, args, kwargs): if "acc" in kwargs: self.acc = kwargs["acc"] - if isinstance(args[0], tuple): # mixed partial derivative - pds = None - - for arg in args: - if len(arg) == 3: - axis, h, order = arg - elif len(arg) == 2: - axis, h = arg - order = 1 - else: - raise ValueError("Format: (axis, spacing, order=1)") - spac[axis] = h - if pds is None: - pds = _Diff(axis, order) - else: - pd = _Diff(axis, order) - pds = pds * pd + if len(args) == 3: + axis, h, order = args + elif len(args) == 2: + axis, h = args + order = 1 else: - if len(args) == 3: - axis, h, order = args - elif len(args) == 2: - axis, h = args - order = 1 - else: - raise ValueError("Format: (axis, spacing, order=1)") - pds = _Diff(axis, order) + raise ValueError("Format: (axis, spacing, order=1)") + pds = _Diff(axis, order) - spac[axis] = h + spac[axis] = h # Check if spac is really the spacing and not the coordinates (nonuniform case) for a, s in spac.items(): diff --git a/findiff/utils.py b/findiff/utils.py index 20672c2..2bf3f06 100644 --- a/findiff/utils.py +++ b/findiff/utils.py @@ -41,33 +41,36 @@ def to_index_tuple(long_idx, shape): return tuple(idx) -def deprecated(reason="This feature is deprecated."): - def decorator(func_or_class): - if isinstance(func_or_class, type): # Handle classes - original_init = func_or_class.__init__ - - @wraps(original_init) - def new_init(self, *args, **kwargs): - warnings.warn( - f"{func_or_class.__name__} is deprecated and will be removed in future versions: {reason}", - category=DeprecationWarning, - stacklevel=2, - ) - original_init(self, *args, **kwargs) - - func_or_class.__init__ = new_init - return func_or_class - - # Handle functions - @wraps(func_or_class) - def wrapped(*args, **kwargs): - warnings.warn( - f"{func_or_class.__name__} is deprecated: {reason}", - category=DeprecationWarning, - stacklevel=2, - ) - return func_or_class(*args, **kwargs) - - return wrapped - - return decorator +# +# The following is working, but unused yet. Commented because there are no tests yet. +# +# def deprecated(reason="This feature is deprecated."): +# def decorator(func_or_class): +# if isinstance(func_or_class, type): # Handle classes +# original_init = func_or_class.__init__ +# +# @wraps(original_init) +# def new_init(self, *args, **kwargs): +# warnings.warn( +# f"{func_or_class.__name__} is deprecated and will be removed in future versions: {reason}", +# category=DeprecationWarning, +# stacklevel=2, +# ) +# original_init(self, *args, **kwargs) +# +# func_or_class.__init__ = new_init +# return func_or_class +# +# # Handle functions +# @wraps(func_or_class) +# def wrapped(*args, **kwargs): +# warnings.warn( +# f"{func_or_class.__name__} is deprecated: {reason}", +# category=DeprecationWarning, +# stacklevel=2, +# ) +# return func_or_class(*args, **kwargs) +# +# return wrapped +# +# return decorator diff --git a/tests/test_coefs.py b/tests/test_coefs.py index 61e497d..64637a8 100644 --- a/tests/test_coefs.py +++ b/tests/test_coefs.py @@ -1,6 +1,7 @@ import unittest import numpy as np +import pytest from sympy import Rational from findiff import coefficients @@ -169,6 +170,10 @@ def test_calc_coefs_from_offsets_no_central_point(self): coefs["coefficients"], [-1.0 / 4, 0, 1.0 / 4] ) + def test_calc_coefs_from_offsets_not_enough_points(self): + with pytest.raises(ValueError): + coefficients(2, offsets=[-2, 2], analytic_inv=False) + def test_calc_coefs_symbolic(self): for analytic_inv in [True, False]: coefs = calc_coefs(1, [-2, 0, 1], symbolic=True, analytic_inv=analytic_inv)