Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
21 changes: 11 additions & 10 deletions maxsmooth/derivatives.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from scipy.special import lpmv
import math


class derivative_class(object):
Expand Down Expand Up @@ -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(
Expand Down
21 changes: 11 additions & 10 deletions maxsmooth/qp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import warnings
from scipy.special import legendre, lpmv
import math

warnings.simplefilter('always', UserWarning)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 9 additions & 8 deletions tests/test_param_plotter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import math
import pytest
import os
import shutil
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
17 changes: 9 additions & 8 deletions tests/test_smooth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import math
import pytest
import os
import shutil
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down