diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4959dfa..d656046 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,8 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] - + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -36,6 +35,6 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - coverage run --source=maxsmooth -m py.test + coverage run --source=maxsmooth -m pytest - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/README.rst b/README.rst index 794e237..e553dd5 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ Introduction :maxsmooth: Derivative Constrained Function Fitting :Author: Harry Thomas Jones Bevins -:Version: 1.2.1 +:Version: 1.2.2 :Homepage: https://github.com/htjb/maxsmooth :Documentation: https://maxsmooth.readthedocs.io/ diff --git a/maxsmooth/derivatives.py b/maxsmooth/derivatives.py index b6b99a3..00767ee 100755 --- a/maxsmooth/derivatives.py +++ b/maxsmooth/derivatives.py @@ -1,5 +1,6 @@ import numpy as np from scipy.special import lpmv +import math class derivative_class(object): @@ -33,38 +34,38 @@ def mth_order_derivatives(m): mth_order_derivative_term = ( self.y[self.pivot_point] / self.x[self.pivot_point]) * \ - np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + math.factorial(m+i) / \ + math.factorial(i) * \ self.params[int(m)+i]*(self.x)**i / \ (self.x[self.pivot_point])**(i+1) mth_order_derivative.append( mth_order_derivative_term) if self.model_type == 'polynomial': mth_order_derivative_term = \ - np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + math.factorial(m+i) / \ + math.factorial(i) * \ self.params[int(m)+i]*(self.x)**i mth_order_derivative.append( mth_order_derivative_term) if self.model_type == 'log_polynomial': mth_order_derivative_term = \ - np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + math.factorial(m+i) / \ + math.factorial(i) * \ self.params[int(m) + i] * \ np.log10(self.x/self.x[self.pivot_point])**i mth_order_derivative.append( mth_order_derivative_term) if self.model_type == 'loglog_polynomial': mth_order_derivative_term = \ - np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + math.factorial(m+i) / \ + math.factorial(i) * \ self.params[int(m)+i]*np.log10(self.x)**i mth_order_derivative.append( mth_order_derivative_term) if self.model_type == 'difference_polynomial': mth_order_derivative_term = \ - np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + math.factorial(m+i) / \ + math.factorial(i) * \ self.params[int(m)+i] * \ (self.x-self.x[self.pivot_point])**i mth_order_derivative.append( diff --git a/maxsmooth/qp.py b/maxsmooth/qp.py index e1283db..00618c9 100755 --- a/maxsmooth/qp.py +++ b/maxsmooth/qp.py @@ -4,6 +4,7 @@ import numpy as np import warnings from scipy.special import legendre, lpmv +import math warnings.simplefilter('always', UserWarning) @@ -49,26 +50,26 @@ def constraint_prefactors(m): mth_order_derivative_term = ( self.y[self.pivot_point] / self.x[self.pivot_point]) \ - * np.math.factorial(m + i) \ - / np.math.factorial(i) * \ + * math.factorial(m + i) \ + / math.factorial(i) * \ (self.x)**i/(self.x[self.pivot_point])**(i + 1) derivatives.append(mth_order_derivative_term) if self.model_type == 'polynomial': - mth_order_derivative_term = np.math.factorial(m+i)\ - / np.math.factorial(i) * (self.x)**i + mth_order_derivative_term = math.factorial(m+i)\ + / math.factorial(i) * (self.x)**i derivatives.append(mth_order_derivative_term) if self.model_type == 'log_polynomial': - mth_order_derivative_term = np.math.factorial(m+i)\ - / np.math.factorial(i) * \ + mth_order_derivative_term = math.factorial(m+i)\ + / math.factorial(i) * \ np.log10(self.x/self.x[self.pivot_point])**i derivatives.append(mth_order_derivative_term) if self.model_type == 'loglog_polynomial': - mth_order_derivative_term = np.math.factorial(m+i)\ - / np.math.factorial(i) * np.log10(self.x)**i + mth_order_derivative_term = math.factorial(m+i)\ + / math.factorial(i) * np.log10(self.x)**i derivatives.append(mth_order_derivative_term) if self.model_type == 'difference_polynomial': - mth_order_derivative_term = np.math.factorial(m+i)\ - / np.math.factorial(i) * ( + mth_order_derivative_term = math.factorial(m+i)\ + / math.factorial(i) * ( self.x - self.x[self.pivot_point])**i derivatives.append(mth_order_derivative_term) diff --git a/setup.py b/setup.py index d59754f..5420251 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def readme(short=False): setup( name='maxsmooth', - version='1.2.1', + version='1.2.2', description='maxsmooth:Derivative Constrained Function Fitting', long_description=readme(), author='Harry T. J. Bevins', diff --git a/tests/test_param_plotter.py b/tests/test_param_plotter.py index 1f7a756..869d422 100644 --- a/tests/test_param_plotter.py +++ b/tests/test_param_plotter.py @@ -1,4 +1,5 @@ import numpy as np +import math import pytest import os import shutil @@ -152,8 +153,8 @@ def derivative(m, x, y, N, pivot_point, params, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = args[1]*np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = args[1]*math.factorial(m+i) / \ + math.factorial(i) * \ params[int(m)+i]*(x)**i / \ (args[0])**(i + 1) mth_order_derivative.append( @@ -168,8 +169,8 @@ def derivative_pre(m, x, y, N, pivot_point, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = args[1]*np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = args[1]*math.factorial(m+i) / \ + math.factorial(i) * \ (x)**i / \ (args[0])**(i + 1) mth_order_derivative.append( @@ -234,8 +235,8 @@ def derivative(m, x, y, N, pivot_point, params, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = math.factorial(m+i) / \ + math.factorial(i) * \ params[int(m)+i]*(x)**i mth_order_derivative.append( mth_order_derivative_term) @@ -249,8 +250,8 @@ def derivative_pre(m, x, y, N, pivot_point, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = math.factorial(m+i) / \ + math.factorial(i) * \ (x)**i mth_order_derivative.append( mth_order_derivative_term) diff --git a/tests/test_smooth.py b/tests/test_smooth.py index e827d4f..5738c8c 100644 --- a/tests/test_smooth.py +++ b/tests/test_smooth.py @@ -1,4 +1,5 @@ import numpy as np +import math import pytest import os import shutil @@ -207,8 +208,8 @@ def derivative(m, x, y, N, pivot_point, params, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = args[1]*np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = args[1]*math.factorial(m+i) / \ + math.factorial(i) * \ params[int(m)+i]*(x)**i / \ (args[0])**(i + 1) mth_order_derivative.append( @@ -224,8 +225,8 @@ def derivative_pre(m, x, y, N, pivot_point, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = args[1]*np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = args[1]*math.factorial(m+i) / \ + math.factorial(i) * \ (x)**i / \ (args[0])**(i + 1) mth_order_derivative.append( @@ -277,8 +278,8 @@ def derivative(m, x, y, N, pivot_point, params, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = math.factorial(m+i) / \ + math.factorial(i) * \ params[int(m)+i]*(x)**i mth_order_derivative.append( mth_order_derivative_term) @@ -292,8 +293,8 @@ def derivative_pre(m, x, y, N, pivot_point, *args): if i <= m - 1: mth_order_derivative.append([0]*len(x)) for i in range(N - m): - mth_order_derivative_term = np.math.factorial(m+i) / \ - np.math.factorial(i) * \ + mth_order_derivative_term = math.factorial(m+i) / \ + math.factorial(i) * \ (x)**i mth_order_derivative.append( mth_order_derivative_term)