From 5d6ef36e2fb03604f853ae23ebf564a8b58425d1 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Thu, 21 Nov 2024 17:24:15 +0100 Subject: [PATCH 1/9] Add ruff configuration --- .editorconfig | 20 ++++++++++++++++++++ pyproject.toml | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e269037 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig - http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = false + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{c,py}] +charset = utf-8 + +# tab indentation +[*.py] +indent_style = tab +indent_size = 4 diff --git a/pyproject.toml b/pyproject.toml index da97c6d..faaaba0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,3 +43,44 @@ include = [ [tool.setuptools_scm] write_to = "chspy/version.py" + +[tool.ruff] +target-version = "py37" + +[tool.ruff.lint] +select = [ + "A", # flake8-builtins + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "E", # flake8 + "F", # flake8 + "I", # flake8-isort + "NPY", # numpy + "Q", # flake8-quotes + "RUF", # ruff + "UP", # pyupgrade + "W", # flake8 +] +ignore = [ + "A001", # shadowing-builtin-variable + "A005", # shadowing-builtin-module + "C409", # incorrectly-parenthesized-tuple-in-subscript + "E203", # whitespace-before-punctuation + "E402", # module-import-not-at-top-of-file + "E501", # line-too-long + "E731", # assign-to-lambda + "RUF001", # ambiguous-unicode-character-string + "RUF002", # ambiguous-unicode-character-docstring + "W191", # indentation-contains-tabs + "W293", # blank-line-with-whitespace +] + +[tool.ruff.lint.flake8-quotes] +docstring-quotes = "double" +inline-quotes = "double" +multiline-quotes = "double" + +[tool.ruff.lint.isort] +combine-as-imports = true +known-local-folder = [ "CHSPy" ] +lines-after-imports = 2 From 409c5ea0a32ca71aa716e2d66d675efa877f925a Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Thu, 21 Nov 2024 17:40:16 +0100 Subject: [PATCH 2/9] Add ruff CI job --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd3f8cd..e802ac4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,20 @@ concurrency: cancel-in-progress: true jobs: + typos: + name: Spelling (typos) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@master + + ruff: + name: Linting (ruff) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + test: name: Unittest (${{ matrix.os }}/py${{ matrix.python-version }}) runs-on: ${{ matrix.os }} From dee66ed2cb12aab9730b50c9ab571d3c4bf8a961 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Mon, 6 Jan 2025 10:11:26 +0200 Subject: [PATCH 3/9] Fix ruff NPY (numpy) errors --- tests/test_hermite_spline.py | 51 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/tests/test_hermite_spline.py b/tests/test_hermite_spline.py index c13ea81..875f097 100644 --- a/tests/test_hermite_spline.py +++ b/tests/test_hermite_spline.py @@ -17,8 +17,9 @@ def test_rel_dist(self): m = 4 +rng = np.random.default_rng() -coeff = np.random.random((m,4)) +coeff = rng.random((m,4)) poly = [lambda x, j=j: sum(coeff[j]*(x**np.arange(4))) for j in range(m)] diff = [lambda x, j=j: sum(np.arange(1,4)*coeff[j,1:]*(x**np.arange(3))) for j in range(m)] @@ -38,8 +39,8 @@ def test_rel_dist(self): ), ( 2.0, - np.random.random(m), - np.random.random(m), + rng.random(m), + rng.random(m), ), ]) @@ -86,17 +87,17 @@ def test_interpolation(self): def test_interpolate_anchors(self): copy = spline.copy() - for t in np.random.uniform( spline[0].time-1, spline[-1].time+1, 20 ): + for t in rng.uniform( spline[0].time-1, spline[-1].time+1, 20 ): copy.interpolate_anchor(t) - for t in np.random.uniform( spline[0].time-2, spline[-1].time+2, 40 ): + for t in rng.uniform( spline[0].time-2, spline[-1].time+2, 40 ): assert_allclose( copy.get_state(t), spline.get_state(t) ) class get_anchors_test(unittest.TestCase): def test_get_anchors(self): for s in range(len(spline)-1): - r = np.random.random() + r = rng.random() t = r*spline[s][0] + (1-r)*spline[s+1][0] anchors = spline.get_anchors(t) self.assertEqual(anchors[0], spline[s]) @@ -120,7 +121,7 @@ def setUpClass(self): self.spline = spline.copy() def test_compare_norm_with_brute_force(self): - delay = np.random.uniform(0.0,2.0) + delay = rng.uniform(0.0,2.0) end = spline[-1][0] start = end - delay @@ -138,7 +139,7 @@ def test_compare_norm_with_brute_force(self): self.assertAlmostEqual(norm, np.sqrt(bf_norm_sq),4) def test_compare_sp_with_brute_force(self): - delay = np.random.uniform(0.0,2.0) + delay = rng.uniform(0.0,2.0) end = spline[-1][0] start = end - delay @@ -164,8 +165,8 @@ def test_compare_sp_with_brute_force(self): def test_untrue_partials_norms(self): for i in range(len(self.spline)-1): anchors = (self.spline[i], self.spline[i+1]) - start = np.random.randint(0,m-1) - length = np.random.randint(1,m-start) + start = rng.integers(0,m-1) + length = rng.integers(1,m-start) indizes = list(range(start, start+length)) norm = norm_sq_interval(anchors, indizes) partial_norm = norm_sq_partial(anchors, indizes, anchors[0][0]) @@ -174,9 +175,9 @@ def test_untrue_partials_norms(self): def test_untrue_partials_sp(self): for i in range(len(self.spline)-1): anchors = (self.spline[i], self.spline[i+1]) - start_1 = np.random.randint(0,m-1) - start_2 = np.random.randint(0,m-1) - length = np.random.randint(1,m-max(start_1, start_2)) + start_1 = rng.integers(0,m-1) + start_2 = rng.integers(0,m-1) + length = rng.integers(1,m-max(start_1, start_2)) indizes_1 = list(range(start_1, start_1+length)) indizes_2 = list(range(start_2, start_2+length)) sp = scalar_product_interval(anchors, indizes_1, indizes_2) @@ -185,7 +186,7 @@ def test_untrue_partials_sp(self): class truncation_test(unittest.TestCase): def test_truncation(self): - truncation_time = np.random.uniform(spline[-2][0],spline[-1][0]) + truncation_time = rng.uniform(spline[-2][0],spline[-1][0]) truncated_spline = spline.copy() truncated_spline.truncate(truncation_time) @@ -207,11 +208,11 @@ def test_truncation(self): class extrema_test(unittest.TestCase): def test_given_extrema(self): n = 100 - positions = sorted(np.random.random(2)) - state = np.random.random(n) + positions = sorted(rng.random(2)) + state = rng.random(n) spline = CubicHermiteSpline(n, [ ( positions[0], state , np.zeros(n) ), - ( positions[1], state+np.random.uniform(0,5), np.zeros(n) ), + ( positions[1], state+rng.uniform(0,5), np.zeros(n) ), ]) result = extrema_from_anchors(spline) assert_allclose(result.arg_min,spline[0].time) @@ -237,8 +238,8 @@ def test_simple_polynomial(self): def test_arbitrary_anchors(self): n = 100 spline = CubicHermiteSpline(n, [ - (time,np.random.normal(0,1,n),np.random.normal(0,0.1,n)) - for time in sorted(np.random.uniform(-10,10,2)) + (time,rng.normal(0,1,n),rng.normal(0,0.1,n)) + for time in sorted(rng.uniform(-10,10,2)) ]) times = np.linspace(spline[0].time,spline[1].time,10000) @@ -254,11 +255,11 @@ def test_multiple_anchors(self): for _ in range(10): n = 100 spline = CubicHermiteSpline(n, [ - (time,np.random.normal(0,1,n),np.random.normal(0,0.1,n)) - for time in sorted(np.random.uniform(-10,10,3)) + (time,rng.normal(0,1,n),rng.normal(0,0.1,n)) + for time in sorted(rng.uniform(-10,10,3)) ]) - beginning, end = sorted(np.random.uniform(spline[0].time,spline[-1].time,2)) + beginning, end = sorted(rng.uniform(spline[0].time,spline[-1].time,2)) times = np.linspace(beginning,end,10000) values = np.vstack([ spline.get_state(time) for time in times ]) @@ -271,12 +272,12 @@ def test_multiple_anchors(self): class TestSolving(unittest.TestCase): def test_random_function(self): for solve_derivative in [False,True]: - roots = np.sort(np.random.normal(size=5)) - value = np.random.normal() + roots = np.sort(rng.normal(size=5)) + value = rng.normal() t = symengine.Symbol("t") function = np.prod([t-root for root in roots]) + value if solve_derivative: - function = sympy.integrate(function,[t]) + np.random.random() + function = sympy.integrate(function,[t]) + rng.random() i = 1 spline = CubicHermiteSpline.from_func( From 4a2f1bebfcb3d113d8220c8f04dcecde232d785d Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 19:49:00 +0200 Subject: [PATCH 4/9] Fix ruff I (isort) errors --- chspy/__init__.py | 9 ++------- chspy/_chspy.py | 6 ++++-- docs/conf.py | 6 ++++-- examples/simple_example.py | 4 +++- pyproject.toml | 1 + tests/test_hermite_spline.py | 10 ++++++---- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/chspy/__init__.py b/chspy/__init__.py index 49b5d34..11ad1aa 100644 --- a/chspy/__init__.py +++ b/chspy/__init__.py @@ -1,10 +1,5 @@ -from ._chspy import ( - Anchor, CubicHermiteSpline, Extrema, - interpolate, interpolate_vec, interpolate_diff, interpolate_diff_vec, - extrema_from_anchors, - norm_sq_interval, norm_sq_partial, scalar_product_interval, scalar_product_partial, - match_anchors, join, - ) +from ._chspy import Anchor, CubicHermiteSpline, Extrema, extrema_from_anchors, interpolate, interpolate_diff, interpolate_diff_vec, interpolate_vec, join, match_anchors, norm_sq_interval, norm_sq_partial, scalar_product_interval, scalar_product_partial + try: from .version import version as __version__ diff --git a/chspy/_chspy.py b/chspy/_chspy.py index 5f668ff..be274e9 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -1,10 +1,12 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -import numpy as np -from bisect import insort, bisect_left, bisect_right +from bisect import bisect_left, bisect_right, insort from warnings import warn +import numpy as np + + def rel_dist(x,y): x = np.asarray(x) y = np.asarray(y) diff --git a/docs/conf.py b/docs/conf.py index f81b77e..2320d81 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,10 @@ -import sys import os -from setuptools_scm import get_version +import sys from unittest.mock import MagicMock as Mock +from setuptools_scm import get_version + + # Mocking to make RTD autobuild the documentation. autodoc_mock_imports = ['numpy'] #sys.modules.update([("numpy", Mock())]) diff --git a/examples/simple_example.py b/examples/simple_example.py index b344415..a72efe6 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -1,6 +1,8 @@ -from chspy import CubicHermiteSpline from matplotlib.pyplot import subplots +from chspy import CubicHermiteSpline + + spline = CubicHermiteSpline(n=3) # time state slope diff --git a/pyproject.toml b/pyproject.toml index faaaba0..0d33e7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ write_to = "chspy/version.py" [tool.ruff] target-version = "py37" +line-length = 320 [tool.ruff.lint] select = [ diff --git a/tests/test_hermite_spline.py b/tests/test_hermite_spline.py index 875f097..b42b3b3 100644 --- a/tests/test_hermite_spline.py +++ b/tests/test_hermite_spline.py @@ -1,14 +1,16 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -from chspy import CubicHermiteSpline, scalar_product_interval, scalar_product_partial, norm_sq_interval, norm_sq_partial, interpolate, interpolate_diff, extrema_from_anchors, join -from chspy._chspy import rel_dist +import unittest +import numpy as np import symengine import sympy -import numpy as np from numpy.testing import assert_allclose -import unittest + +from chspy import CubicHermiteSpline, extrema_from_anchors, interpolate, interpolate_diff, join, norm_sq_interval, norm_sq_partial, scalar_product_interval, scalar_product_partial +from chspy._chspy import rel_dist + class rel_dist_test(unittest.TestCase): def test_rel_dist(self): From eadd888c05296a3b68277da80d417ed1d8beebee Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 19:55:31 +0200 Subject: [PATCH 5/9] Fix ruff UP (pyupgrade) errors --- chspy/_chspy.py | 3 +-- tests/test_hermite_spline.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/chspy/_chspy.py b/chspy/_chspy.py index be274e9..5df1f20 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -1,5 +1,4 @@ #!/usr/bin/python3 -# -*- coding: utf-8 -*- from bisect import bisect_left, bisect_right, insort from warnings import warn @@ -203,7 +202,7 @@ def scalar_product_partial(anchors, indices_1, indices_2, start): vector_2, [1,2] )*q -class Extrema(object): +class Extrema: """ Class for containing the extrema and their positions in `n` dimensions. These can be accessed via the attributes `minima`, `maxima`, `arg_min`, and `arg_max`. """ diff --git a/tests/test_hermite_spline.py b/tests/test_hermite_spline.py index b42b3b3..ea3b4b8 100644 --- a/tests/test_hermite_spline.py +++ b/tests/test_hermite_spline.py @@ -1,5 +1,4 @@ #!/usr/bin/python3 -# -*- coding: utf-8 -*- import unittest From 5ea49cebb15e9a0b5c8f5bd84a917580065dc6e1 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 20:00:10 +0200 Subject: [PATCH 6/9] Fix ruff F+E (flake8) errors --- chspy/__init__.py | 4 ++-- chspy/_chspy.py | 6 ++---- docs/conf.py | 1 - tests/test_hermite_spline.py | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/chspy/__init__.py b/chspy/__init__.py index 11ad1aa..e6c7a88 100644 --- a/chspy/__init__.py +++ b/chspy/__init__.py @@ -1,8 +1,8 @@ -from ._chspy import Anchor, CubicHermiteSpline, Extrema, extrema_from_anchors, interpolate, interpolate_diff, interpolate_diff_vec, interpolate_vec, join, match_anchors, norm_sq_interval, norm_sq_partial, scalar_product_interval, scalar_product_partial +from ._chspy import Anchor, CubicHermiteSpline, Extrema, extrema_from_anchors, interpolate, interpolate_diff, interpolate_diff_vec, interpolate_vec, join, match_anchors, norm_sq_interval, norm_sq_partial, scalar_product_interval, scalar_product_partial # noqa: F401 try: - from .version import version as __version__ + from .version import version as __version__ # noqa: F401 except ImportError: from warnings import warn warn('Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.') diff --git a/chspy/_chspy.py b/chspy/_chspy.py index 5df1f20..dce8b4c 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -624,7 +624,7 @@ def from_data(cls,times,states): t_2 = times [1:-1] t_3 = times [2: ] diffs[1:-1] = ( - y_1 * ((t_2-t_3)/(t_2-t_1)/(t_3-t_1))[:,None] + y_1 * ((t_2-t_3)/(t_2-t_1)/(t_3-t_1))[:,None] + y_2 / (t_2-t_3)[:,None] + y_2 / (t_2-t_1)[:,None] + y_3 * ((t_2-t_1)/(t_3-t_1)/(t_3-t_2))[:,None] @@ -664,7 +664,7 @@ def get_recent_state(self,t): """ anchors = self[-2], self[-1] output = interpolate_vec(t,anchors) - assert type(output) == np.ndarray + assert type(output) is np.ndarray return output def get_current_state(self): @@ -745,8 +745,6 @@ def solve(self,i,value,beginning=None,end=None,solve_derivative=False): if not self[0].time <= beginning < end <= self[-1].time: raise ValueError("Beginning and end must in the time interval spanned by the anchors.") - extrema = Extrema(self.n) - sols = [] for j in range(self.last_index_before(beginning),len(self)-1): diff --git a/docs/conf.py b/docs/conf.py index 2320d81..d9123ba 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,5 @@ import os import sys -from unittest.mock import MagicMock as Mock from setuptools_scm import get_version diff --git a/tests/test_hermite_spline.py b/tests/test_hermite_spline.py index ea3b4b8..8e154a2 100644 --- a/tests/test_hermite_spline.py +++ b/tests/test_hermite_spline.py @@ -151,11 +151,11 @@ def test_compare_sp_with_brute_force(self): for t in np.linspace(start,end,N): anchors = self.spline.get_anchors(t) bf_sp_sq += ( - interpolate(t, 0, anchors) + interpolate(t, 0, anchors) * interpolate(t, 2, anchors) * factor) bf_sp_sq += ( - interpolate(t, 1, anchors) + interpolate(t, 1, anchors) * interpolate(t, 3, anchors) * factor) From a1a868b8ecb821b8e9a1c4603175f84645936468 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 20:04:04 +0200 Subject: [PATCH 7/9] Fix ruff B (bugbear) errors --- chspy/__init__.py | 2 +- chspy/_chspy.py | 16 ++++++++-------- tests/test_hermite_spline.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/chspy/__init__.py b/chspy/__init__.py index e6c7a88..327ad5d 100644 --- a/chspy/__init__.py +++ b/chspy/__init__.py @@ -5,4 +5,4 @@ from .version import version as __version__ # noqa: F401 except ImportError: from warnings import warn - warn('Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.') + warn('Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.', stacklevel=1) diff --git a/chspy/_chspy.py b/chspy/_chspy.py index dce8b4c..cad3b04 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -480,7 +480,7 @@ def constant(self,state,time=0): """ if self: - warn("The spline already contains points. This will remove them. Be sure that you really want this.") + warn("The spline already contains points. This will remove them. Be sure that you really want this.", stacklevel=2) self.clear() self.append(( time-1., state, np.zeros_like(state) )) @@ -496,7 +496,7 @@ def from_function(self,function,times_of_interest=None,max_anchors=100,tol=5): assert len(times_of_interest)>=2, "I need at least two time points of interest." if self: - warn("The spline already contains points. This will remove them. Be sure that you really want this. If not, consider using `from_func`.") + warn("The spline already contains points. This will remove them. Be sure that you really want this. If not, consider using `from_func`.", stacklevel=2) self.clear() # A happy anchor is sufficiently interpolated by its neighbours, temporally close to them, or at the border of the interval. @@ -778,8 +778,8 @@ def norm(self, delay, indices): norm_sq = norm_sq_partial(anchors, indices, threshold) # full norms of all others - for i in range(i+1, len(self)-1): - anchors = (self[i],self[i+1]) + for j in range(i+1, len(self)-1): + anchors = (self[j],self[j+1]) norm_sq += norm_sq_interval(anchors, indices) return np.sqrt(norm_sq) @@ -796,8 +796,8 @@ def scalar_product(self, delay, indices_1, indices_2): sp = scalar_product_partial(anchors, indices_1, indices_2, threshold) # full scalar product of all others - for i in range(i+1, len(self)-1): - anchors = (self[i],self[i+1]) + for j in range(i+1, len(self)-1): + anchors = (self[j],self[j+1]) sp += scalar_product_interval(anchors, indices_1, indices_2) return sp @@ -852,7 +852,7 @@ def plus(self,other): match_anchors(self,other) assert self.times == other.times - for i,anchor in enumerate(other): + for i,_anchor in enumerate(other): self[i].state += other[i].state self[i].diff += other[i].diff @@ -891,7 +891,7 @@ def plot(self,axes,components="all",resolution=20,*args,**kwargs): kwargs.setdefault("markevery",resolution) values = self.get_state(plot_times) return [ - axes.plot( plot_times, values[:,c], label=f"Component {c}", *args, **kwargs ) + axes.plot( plot_times, values[:,c], *args, label=f"Component {c}", **kwargs ) for c in (components) ] diff --git a/tests/test_hermite_spline.py b/tests/test_hermite_spline.py index 8e154a2..0b96a9d 100644 --- a/tests/test_hermite_spline.py +++ b/tests/test_hermite_spline.py @@ -292,7 +292,7 @@ def test_random_function(self): sol_times = [ sol[0] for sol in solutions ] assert_allclose( sol_times, roots, atol=1e-3 ) if solve_derivative: - for time,diff in solutions: + for _time,diff in solutions: self.assertAlmostEqual( value, diff, places=5 ) else: assert_allclose( spline.get_state(sol_times)[:,i], value ) From d19e31d54698fad959e48f1c45224fb183ae73ed Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 20:05:17 +0200 Subject: [PATCH 8/9] Fix ruff Q (quotes) errors --- chspy/__init__.py | 2 +- chspy/_chspy.py | 2 +- docs/conf.py | 38 +++++++++++++++++++------------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/chspy/__init__.py b/chspy/__init__.py index 327ad5d..f3af4aa 100644 --- a/chspy/__init__.py +++ b/chspy/__init__.py @@ -5,4 +5,4 @@ from .version import version as __version__ # noqa: F401 except ImportError: from warnings import warn - warn('Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.', stacklevel=1) + warn("Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.", stacklevel=1) diff --git a/chspy/_chspy.py b/chspy/_chspy.py index cad3b04..12ebc1e 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -270,7 +270,7 @@ def extrema_from_anchors(anchors,beginning=None,end=None,target=None): A = 1/(2*a + b - 2*c + d) B = a + 2*b/3 - c + d/3 for sign in (-1,1): - with np.errstate(invalid='ignore'): + with np.errstate(invalid="ignore"): x = (B+sign*np.sqrt(radicant)/3)*A extrema.update( retransform(x), diff --git a/docs/conf.py b/docs/conf.py index d9123ba..845245c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,29 +5,29 @@ # Mocking to make RTD autobuild the documentation. -autodoc_mock_imports = ['numpy'] +autodoc_mock_imports = ["numpy"] #sys.modules.update([("numpy", Mock())]) sys.path.insert(0,os.path.abspath("../chspy")) sys.path.insert(0,os.path.abspath("../examples")) -needs_sphinx = '1.6' +needs_sphinx = "1.6" extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.mathjax', - 'matplotlib.sphinxext.plot_directive', - 'numpydoc', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.mathjax", + "matplotlib.sphinxext.plot_directive", + "numpydoc", ] -source_suffix = '.rst' +source_suffix = ".rst" -master_doc = 'index' +master_doc = "index" -project = 'CHSPy' -copyright = '2019, Gerrit Ansmann' +project = "CHSPy" +copyright = "2019, Gerrit Ansmann" -release = version = get_version(root='..', relative_to=__file__) +release = version = get_version(root="..", relative_to=__file__) default_role = "any" @@ -35,23 +35,23 @@ add_module_names = False -html_theme = 'nature' -pygments_style = 'colorful' -htmlhelp_basename = 'CHSPydoc' +html_theme = "nature" +pygments_style = "colorful" +htmlhelp_basename = "CHSPydoc" plot_html_show_formats = False plot_html_show_source_link = False numpydoc_show_class_members = False -autodoc_member_order = 'bysource' +autodoc_member_order = "bysource" -toc_object_entries_show_parents = 'hide' +toc_object_entries_show_parents = "hide" def on_missing_reference(app, env, node, contnode): - if node['reftype'] == 'any': + if node["reftype"] == "any": return contnode else: return None def setup(app): - app.connect('missing-reference', on_missing_reference) + app.connect("missing-reference", on_missing_reference) From d7585c9bd67e1a1074ef572bec9b21e7706f9e47 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Tue, 7 Jan 2025 20:10:32 +0200 Subject: [PATCH 9/9] Fix some typos --- chspy/_chspy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chspy/_chspy.py b/chspy/_chspy.py index 12ebc1e..6f01268 100644 --- a/chspy/_chspy.py +++ b/chspy/_chspy.py @@ -132,7 +132,7 @@ def norm_sq_interval(anchors, indices): def norm_sq_partial(anchors, indices, start): """ - Returns the sqared norm of the interpolant of `anchors` for the `indices`, but only taking into account the time after `start`. + Returns the squared norm of the interpolant of `anchors` for the `indices`, but only taking into account the time after `start`. """ q = (anchors[1].time-anchors[0].time) z = (start-anchors[1].time) / q @@ -812,7 +812,7 @@ def scale(self, indices, factor): def subtract(self, indices_1, indices_2, factor): """ - Substract the spline for `indices_2` multiplied by `factor` from the spline for `indices_1`. + Subtract the spline for `indices_2` multiplied by `factor` from the spline for `indices_1`. """ for anchor in self: anchor.state[indices_1] -= factor*anchor.state[indices_2]