From bca5ca125b9bddb694920db54474d23456adc109 Mon Sep 17 00:00:00 2001 From: Mauro Silberberg Date: Thu, 13 Jun 2024 19:47:05 -0300 Subject: [PATCH] pre-commit run --all-files --- .coveragerc | 1 - .github/workflows/docs.yml | 1 - .github/workflows/lint.yml | 2 +- CHANGES | 4 +-- benchmarks/__init__.py | 10 +++--- benchmarks/against_scipy.py | 10 +++--- benchmarks/common.py | 9 +++-- benchmarks/nbcompat.py | 9 +++-- benchmarks/numba.py | 10 +++--- docs/_templates/sidebarintro.html | 2 -- docs/_themes/flask/static/flasky.css_t | 50 +++++++++++++------------- docs/_themes/flask/theme.conf | 2 +- docs/conf.py | 2 +- docs/developers_reference.rst | 1 - docs/events.rst | 4 +-- docs/faq.rst | 2 -- docs/requirements.txt | 6 ++-- docs/tutorial.rst | 3 +- nbkode/__init__.py | 14 ++++---- nbkode/core.py | 12 +++---- nbkode/euler.py | 16 ++++----- nbkode/event_handler.py | 12 +++---- nbkode/multistep/adams_moulton.py | 23 ++++++------ nbkode/multistep/core.py | 2 -- nbkode/nbcompat/__init__.py | 20 +++++------ nbkode/nbcompat/common.py | 10 +++--- nbkode/nbcompat/nb_to_import.py | 14 ++++---- nbkode/nbcompat/numbasub.py | 14 ++++---- nbkode/nbcompat/zeros.py | 12 +++---- nbkode/runge_kutta/implicit.py | 2 -- nbkode/testsuite/__init__.py | 14 ++++---- nbkode/testsuite/test_against_scipy.py | 10 +++--- nbkode/testsuite/test_introspection.py | 12 +++---- nbkode/testsuite/test_nbcompat.py | 26 +++++++------- nbkode/testsuite/test_solver.py | 11 +++--- nbkode/testsuite/test_solver_fs.py | 18 +++++----- nbkode/testsuite/test_util.py | 13 ++++--- nbkode/util.py | 10 +++--- pyproject.toml | 2 ++ requirements_docs.txt | 10 +++--- 40 files changed, 192 insertions(+), 213 deletions(-) diff --git a/.coveragerc b/.coveragerc index 49d1476..3fb11e5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,2 @@ [run] omit = nbkode/testsuite/* - diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5ed4fe7..48f9bd8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -43,4 +43,3 @@ jobs: - name: Doc Tests run: sphinx-build -a -j auto -b doctest -d build/doctrees docs build/doctest - \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b10a674..e2d2638 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,4 +14,4 @@ jobs: - name: Lint uses: pre-commit/action@v2.0.0 with: - extra_args: --all-files --show-diff-on-failure \ No newline at end of file + extra_args: --all-files --show-diff-on-failure diff --git a/CHANGES b/CHANGES index f8b5459..5cc3a31 100644 --- a/CHANGES +++ b/CHANGES @@ -22,9 +22,9 @@ numbakit-ode Changelog ---------------- - Moved t_bound check to Solver class. -- Created ALIAS API to allow multiple names for solvers while keeping +- Created ALIAS API to allow multiple names for solvers while keeping a preferred one. -- Changed import system in module.. +- Changed import system in module.. - Reorganized solvers into multistep and rungekutta. diff --git a/benchmarks/__init__.py b/benchmarks/__init__.py index dd224e3..445aafd 100644 --- a/benchmarks/__init__.py +++ b/benchmarks/__init__.py @@ -1,9 +1,9 @@ """ - benchmarks - ~~~~~~~~~~ +benchmarks +~~~~~~~~~~ - Measure, as much as you can. +Measure, as much as you can. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ diff --git a/benchmarks/against_scipy.py b/benchmarks/against_scipy.py index b7c7a5b..afa1dde 100644 --- a/benchmarks/against_scipy.py +++ b/benchmarks/against_scipy.py @@ -1,11 +1,11 @@ """ - benchmarks.against_scipy - ~~~~~~~~~~~~~~~~~~~~~~~~ +benchmarks.against_scipy +~~~~~~~~~~~~~~~~~~~~~~~~ - Comparisons using SciPy as a gold standard. +Comparisons using SciPy as a gold standard. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import numpy as np diff --git a/benchmarks/common.py b/benchmarks/common.py index 03df242..6add6a5 100644 --- a/benchmarks/common.py +++ b/benchmarks/common.py @@ -1,12 +1,11 @@ """ - benchmarks.common - ~~~~~~~~~~~~~~~~~ +benchmarks.common +~~~~~~~~~~~~~~~~~ - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ - from enum import IntEnum, auto diff --git a/benchmarks/nbcompat.py b/benchmarks/nbcompat.py index fa70f82..54cb081 100644 --- a/benchmarks/nbcompat.py +++ b/benchmarks/nbcompat.py @@ -1,9 +1,9 @@ """ - benchmarks.nbcompat - ~~~~~~~~~~~~~~~~~~~ +benchmarks.nbcompat +~~~~~~~~~~~~~~~~~~~ - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ from numba import njit @@ -35,7 +35,6 @@ def njit_newton(func, x0, fprime): class Suite: - param_names = "variant", "numba" params = (["scipy", "simple", "nbkode"], [True, False]) diff --git a/benchmarks/numba.py b/benchmarks/numba.py index 0afa422..bc78ef3 100644 --- a/benchmarks/numba.py +++ b/benchmarks/numba.py @@ -1,11 +1,11 @@ """ - benchmarks.against_scipy - ~~~~~~~~~~~~~~~~~~~~~~~~ +benchmarks.against_scipy +~~~~~~~~~~~~~~~~~~~~~~~~ - Comparisons of the different methods with and without numba. +Comparisons of the different methods with and without numba. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import os diff --git a/docs/_templates/sidebarintro.html b/docs/_templates/sidebarintro.html index 2634108..07943e6 100644 --- a/docs/_templates/sidebarintro.html +++ b/docs/_templates/sidebarintro.html @@ -16,5 +16,3 @@

Useful Links

  • Code in GitHub
  • Issue Tracker
  • - - diff --git a/docs/_themes/flask/static/flasky.css_t b/docs/_themes/flask/static/flasky.css_t index b5ca39b..4f78308 100644 --- a/docs/_themes/flask/static/flasky.css_t +++ b/docs/_themes/flask/static/flasky.css_t @@ -8,11 +8,11 @@ {% set page_width = '940px' %} {% set sidebar_width = '220px' %} - + @import url("basic.css"); - + /* -- page layout ----------------------------------------------------------- */ - + body { font-family: 'Georgia', serif; font-size: 17px; @@ -43,7 +43,7 @@ div.sphinxsidebar { hr { border: 1px solid #B1B4B6; } - + div.body { background-color: #ffffff; color: #3E4349; @@ -54,7 +54,7 @@ img.floatingflask { padding: 0 0 10px 10px; float: right; } - + div.footer { width: {{ page_width }}; margin: 20px auto 30px auto; @@ -70,7 +70,7 @@ div.footer a { div.related { display: none; } - + div.sphinxsidebar a { color: #444; text-decoration: none; @@ -80,7 +80,7 @@ div.sphinxsidebar a { div.sphinxsidebar a:hover { border-bottom: 1px solid #999; } - + div.sphinxsidebar { font-size: 14px; line-height: 1.5; @@ -95,7 +95,7 @@ div.sphinxsidebarwrapper p.logo { margin: 0; text-align: center; } - + div.sphinxsidebar h3, div.sphinxsidebar h4 { font-family: 'Garamond', 'Georgia', serif; @@ -109,7 +109,7 @@ div.sphinxsidebar h4 { div.sphinxsidebar h4 { font-size: 20px; } - + div.sphinxsidebar h3 a { color: #444; } @@ -120,7 +120,7 @@ div.sphinxsidebar p.logo a:hover, div.sphinxsidebar h3 a:hover { border: none; } - + div.sphinxsidebar p { color: #555; margin: 10px 0; @@ -131,25 +131,25 @@ div.sphinxsidebar ul { padding: 0; color: #000; } - + div.sphinxsidebar input { border: 1px solid #ccc; font-family: 'Georgia', serif; font-size: 1em; } - + /* -- body styles ----------------------------------------------------------- */ - + a { color: #004B6B; text-decoration: underline; } - + a:hover { color: #6D4100; text-decoration: underline; } - + div.body h1, div.body h2, div.body h3, @@ -169,25 +169,25 @@ div.indexwrapper h1 { height: {{ theme_index_logo_height }}; } {% endif %} - + div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; } div.body h2 { font-size: 180%; } div.body h3 { font-size: 150%; } div.body h4 { font-size: 130%; } div.body h5 { font-size: 100%; } div.body h6 { font-size: 100%; } - + a.headerlink { color: #ddd; padding: 0 4px; text-decoration: none; } - + a.headerlink:hover { color: #444; background: #eaeaea; } - + div.body p, div.body dd, div.body li { line-height: 1.4em; } @@ -234,20 +234,20 @@ div.note { background-color: #eee; border: 1px solid #ccc; } - + div.seealso { background-color: #ffc; border: 1px solid #ff6; } - + div.topic { background-color: #eee; } - + p.admonition-title { display: inline; } - + p.admonition-title:after { content: ":"; } @@ -341,7 +341,7 @@ ul, ol { margin: 10px 0 10px 30px; padding: 0; } - + pre { background: #eee; padding: 7px 30px; @@ -358,7 +358,7 @@ dl dl pre { margin-left: -90px; padding-left: 90px; } - + tt { background-color: #ecf0f3; color: #222; diff --git a/docs/_themes/flask/theme.conf b/docs/_themes/flask/theme.conf index 771ffa9..d413a85 100644 --- a/docs/_themes/flask/theme.conf +++ b/docs/_themes/flask/theme.conf @@ -6,5 +6,5 @@ pygments_style = flask_theme_support.FlaskyStyle [options] index_logo = '' index_logo_height = 120px -touch_icon = +touch_icon = github_fork = hgrecco/numbakit-ode diff --git a/docs/conf.py b/docs/conf.py index bb90838..04c1d2b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,13 +11,13 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import datetime import warnings import numba warnings.filterwarnings("ignore", category=numba.NumbaExperimentalFeatureWarning) -import datetime try: from importlib.metadata import version diff --git a/docs/developers_reference.rst b/docs/developers_reference.rst index e4cba24..98d9cfe 100644 --- a/docs/developers_reference.rst +++ b/docs/developers_reference.rst @@ -77,4 +77,3 @@ Variable step | .. autoclass:: nbkode.RungeKutta45 - diff --git a/docs/events.rst b/docs/events.rst index 3574b21..39bdd81 100644 --- a/docs/events.rst +++ b/docs/events.rst @@ -82,9 +82,9 @@ are found. >>> print(t_events[0]) # hit ground time # doctest: +SKIP >>> print(t_events[1]) # apex time # doctest: +SKIP -.. note:: +.. note:: **Important** Event callables are compiled into the tight loop that runs the simulation using Numba. Therefore, just like the ODE rhs, these callables **must** - compatible with Numba jit in nopython mode (`njit`) \ No newline at end of file + compatible with Numba jit in nopython mode (`njit`) diff --git a/docs/faq.rst b/docs/faq.rst index 8d3aa43..2106b6d 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -74,5 +74,3 @@ code. .. _`SciPy Integrate`: https://docs.scipy.org/doc/scipy/reference/integrate.html .. _`Numba`: https://numba.pydata.org/ .. _`benchmarks`: https://hgrecco.github.io/numbakit-ode/ - - diff --git a/docs/requirements.txt b/docs/requirements.txt index afc6dbb..8a23487 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,7 @@ matplotlib nbsphinx -numpy numba -scipy -pytest +numpy pygments>=2.4 +pytest +scipy diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 4eebf8b..e22ef4c 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -124,7 +124,7 @@ the integrator. .. doctest:: - >>> y0 = 1. + >>> y0 = 1. >>> p = -0.1 >>> t0 = 0 >>> solver = nbkode.RungeKutta45(rhs, t0, y0, params=p) @@ -220,4 +220,3 @@ To get a list of the groups: >>> nbkode.get_groups() ('Adams-Bashforth', 'Adams-Moulton', 'BDF', 'Euler', 'Runge-Kutta') - diff --git a/nbkode/__init__.py b/nbkode/__init__.py index 153aea2..90d8914 100644 --- a/nbkode/__init__.py +++ b/nbkode/__init__.py @@ -1,13 +1,13 @@ """ - nbkode - ~~~~~~ +nbkode +~~~~~~ - numbakit-ode (nbkode) is a Python package to solve - **ordinary differential equations (ODE)** that uses - numba to compile code and therefore speed up calculations. +numbakit-ode (nbkode) is a Python package to solve +**ordinary differential equations (ODE)** that uses +numba to compile code and therefore speed up calculations. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ # These imports are necessary as only when corresponding module is imported diff --git a/nbkode/core.py b/nbkode/core.py index abf87d0..82180bc 100644 --- a/nbkode/core.py +++ b/nbkode/core.py @@ -1,15 +1,14 @@ """ - nbkode.core - ~~~~~~~~~~~ +nbkode.core +~~~~~~~~~~~ - Definition for Solver base class. +Definition for Solver base class. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ - from __future__ import annotations import warnings @@ -529,7 +528,6 @@ def _nsteps(n_steps, t_end, step, rhs, cache, *args): y_out = np.empty((n_steps, cache.y.size)) for ndx in range(n_steps): - if not step(t_end, rhs, cache, *args): return t_out[:ndx], y_out[:ndx], True diff --git a/nbkode/euler.py b/nbkode/euler.py index 5d84837..80b9be6 100644 --- a/nbkode/euler.py +++ b/nbkode/euler.py @@ -1,15 +1,15 @@ """ - nbkode.euler - ~~~~~~~~~~~~ +nbkode.euler +~~~~~~~~~~~~ - Methods of the Adams–Moulton family (implicit methods). - - ForwardEuler (Euler) - - BackwardEuler +Methods of the Adams–Moulton family (implicit methods). +- ForwardEuler (Euler) +- BackwardEuler - See: https://en.wikipedia.org/wiki/Linear_multistep_method +See: https://en.wikipedia.org/wiki/Linear_multistep_method - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ from .multistep.adams_bashforth import AdamsBashforth1 diff --git a/nbkode/event_handler.py b/nbkode/event_handler.py index fae6a2b..118818f 100644 --- a/nbkode/event_handler.py +++ b/nbkode/event_handler.py @@ -1,13 +1,13 @@ """ - nbkode.events - ~~~~~~~~~~~~ +nbkode.events +~~~~~~~~~~~~ - Methods for dealing with events. +Methods for dealing with events. - Adapted from: https://github.com/scipy/scipy/blob/v1.5.4/scipy/integrate/_ivp/ivp.py +Adapted from: https://github.com/scipy/scipy/blob/v1.5.4/scipy/integrate/_ivp/ivp.py - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ from typing import Callable, Iterable diff --git a/nbkode/multistep/adams_moulton.py b/nbkode/multistep/adams_moulton.py index d186bbb..60fa9df 100644 --- a/nbkode/multistep/adams_moulton.py +++ b/nbkode/multistep/adams_moulton.py @@ -1,21 +1,20 @@ """ - nbkode.adams_moulton - ~~~~~~~~~~~~~~~~~~~~ +nbkode.adams_moulton +~~~~~~~~~~~~~~~~~~~~ - Methods of the Adams–Moulton family (implicit methods). - - AdamsMoulton1 - - AdamsMoulton2 - - AdamsMoulton3 - - AdamsMoulton4 - - AdamsMoulton5 +Methods of the Adams–Moulton family (implicit methods). +- AdamsMoulton1 +- AdamsMoulton2 +- AdamsMoulton3 +- AdamsMoulton4 +- AdamsMoulton5 - See: https://en.wikipedia.org/wiki/Linear_multistep_method +See: https://en.wikipedia.org/wiki/Linear_multistep_method - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ - import numpy as np from ..util import classproperty diff --git a/nbkode/multistep/core.py b/nbkode/multistep/core.py index 4571964..a21c9a3 100644 --- a/nbkode/multistep/core.py +++ b/nbkode/multistep/core.py @@ -92,7 +92,6 @@ def _fixed_step_builder(cls): A, B = cls.A, cls.B if A.size < cls.LEN_HISTORY or B.size < cls.LEN_HISTORY: - deltaA = cls.LEN_HISTORY - A.size deltaB = cls.LEN_HISTORY - B.size @@ -123,7 +122,6 @@ def implicit_root(y, rhs, t, h_Bn, K): return y - h_Bn * rhs(t, y) - K if A.size < cls.LEN_HISTORY or B.size < cls.LEN_HISTORY: - deltaA = cls.LEN_HISTORY - A.size deltaB = cls.LEN_HISTORY - B.size diff --git a/nbkode/nbcompat/__init__.py b/nbkode/nbcompat/__init__.py index 7780d7e..c2c4e14 100644 --- a/nbkode/nbcompat/__init__.py +++ b/nbkode/nbcompat/__init__.py @@ -1,17 +1,17 @@ """ - nbkode.nbcompat - ~~~~~~~~~~~~~~~ +nbkode.nbcompat +~~~~~~~~~~~~~~~ - Numba compatible functions. Hopefully, some of these will be unnecessary - in the future as Numba continues to grow. +Numba compatible functions. Hopefully, some of these will be unnecessary +in the future as Numba continues to grow. - Current functions and their origin: - - newton: scipy.optimize.newton - - isclose: numpy.isclose - - clip: numpy.clip +Current functions and their origin: +- newton: scipy.optimize.newton +- isclose: numpy.isclose +- clip: numpy.clip - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ from .common import clip, isclose diff --git a/nbkode/nbcompat/common.py b/nbkode/nbcompat/common.py index 03b4826..d81e2bd 100644 --- a/nbkode/nbcompat/common.py +++ b/nbkode/nbcompat/common.py @@ -1,11 +1,11 @@ """ - nbkode.nbcompat.common - ~~~~~~~~~~~~~~~~~~~~~~ +nbkode.nbcompat.common +~~~~~~~~~~~~~~~~~~~~~~ - Common methods. +Common methods. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import numpy as np diff --git a/nbkode/nbcompat/nb_to_import.py b/nbkode/nbcompat/nb_to_import.py index f15b2c2..fa00d5d 100644 --- a/nbkode/nbcompat/nb_to_import.py +++ b/nbkode/nbcompat/nb_to_import.py @@ -1,14 +1,14 @@ """ - nbkode.nb_to_import - ~~~~~~~~~~~~~~~~~~~ +nbkode.nb_to_import +~~~~~~~~~~~~~~~~~~~ - Select which numba to import based on NBKODE_NONUMBA environmental variable. +Select which numba to import based on NBKODE_NONUMBA environmental variable. - We keep this here to allow importing within nbkode.nbcompat module - and avoid circular imports. +We keep this here to allow importing within nbkode.nbcompat module +and avoid circular imports. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import os diff --git a/nbkode/nbcompat/numbasub.py b/nbkode/nbcompat/numbasub.py index b1ae7c1..69e00eb 100644 --- a/nbkode/nbcompat/numbasub.py +++ b/nbkode/nbcompat/numbasub.py @@ -1,15 +1,15 @@ """ - nbkode.nbcompat.numbasub - ~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.nbcompat.numbasub +~~~~~~~~~~~~~~~~~~~~~~~~ - Noop decorators disguised as numba. +Noop decorators disguised as numba. - Copied from https://github.com/ptooley/numbasub +Copied from https://github.com/ptooley/numbasub - See also: https://stackoverflow.com/questions/3888158 +See also: https://stackoverflow.com/questions/3888158 - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import functools diff --git a/nbkode/nbcompat/zeros.py b/nbkode/nbcompat/zeros.py index 91eae2d..57c938b 100644 --- a/nbkode/nbcompat/zeros.py +++ b/nbkode/nbcompat/zeros.py @@ -1,11 +1,11 @@ """ - nbkode.nbcompat.newton - ~~~~~~~~~~~~~~~~~~~~~~ +nbkode.nbcompat.newton +~~~~~~~~~~~~~~~~~~~~~~ - Newton methods. +Newton methods. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import enum @@ -240,7 +240,6 @@ class of similar problems can be solved together. ) if my_flag is not NewtonEnum.OK: - if my_flag is NewtonEnum.DERIVATIVE_WAS_ZERO: msg = "Derivative was zero." elif my_flag is NewtonEnum.TOLERANCE_REACHED: @@ -440,7 +439,6 @@ def j_newton( @numba.njit() def jacobian(func, x, args=()): - eps = 1e-10 J = np.zeros((len(x), len(x)), dtype=np.float64) diff --git a/nbkode/runge_kutta/implicit.py b/nbkode/runge_kutta/implicit.py index 5848927..162a03d 100644 --- a/nbkode/runge_kutta/implicit.py +++ b/nbkode/runge_kutta/implicit.py @@ -118,8 +118,6 @@ class AdaptiveRadauIIA(RadauIIA, AdaptiveFIRK): pass -from ..nbcompat import numba - func = numba.njit(lambda t, y: -y) s = RadauIIA(func, 0, np.array([1]), h=0.1, root_solver=newton_hd) diff --git a/nbkode/testsuite/__init__.py b/nbkode/testsuite/__init__.py index 7946684..7f9ebc3 100644 --- a/nbkode/testsuite/__init__.py +++ b/nbkode/testsuite/__init__.py @@ -1,13 +1,13 @@ """ - nbkode.testsuite - ~~~~~~~~~~~~~~~~ +nbkode.testsuite +~~~~~~~~~~~~~~~~ - numbakit-ode (nbkode) is a Python package to solve - **ordinary differential equations (ODE)** that uses - numba to compile code and therefore speed up calculations. +numbakit-ode (nbkode) is a Python package to solve +**ordinary differential equations (ODE)** that uses +numba to compile code and therefore speed up calculations. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ diff --git a/nbkode/testsuite/test_against_scipy.py b/nbkode/testsuite/test_against_scipy.py index cef3b25..12b49a8 100644 --- a/nbkode/testsuite/test_against_scipy.py +++ b/nbkode/testsuite/test_against_scipy.py @@ -1,11 +1,11 @@ """ - nbkode.testsuite.test_against_scipy - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.test_against_scipy +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Comparisons using SciPy as a gold standard. +Comparisons using SciPy as a gold standard. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import numpy as np diff --git a/nbkode/testsuite/test_introspection.py b/nbkode/testsuite/test_introspection.py index 34a3eb7..1a476bd 100644 --- a/nbkode/testsuite/test_introspection.py +++ b/nbkode/testsuite/test_introspection.py @@ -1,12 +1,12 @@ """ - nbkode.testsuite.test_introspections - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.test_introspections +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Capabilities of the package provide information about - the different solvers. +Capabilities of the package provide information about +the different solvers. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import pytest diff --git a/nbkode/testsuite/test_nbcompat.py b/nbkode/testsuite/test_nbcompat.py index 2f885e0..b728e5e 100644 --- a/nbkode/testsuite/test_nbcompat.py +++ b/nbkode/testsuite/test_nbcompat.py @@ -1,15 +1,14 @@ """ - nbkode.testsuite.test_nbcompat - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.test_nbcompat +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Test for non-trivial implementation of python/numpy/scipy functions - which are not njitable (yet). +Test for non-trivial implementation of python/numpy/scipy functions +which are not njitable (yet). - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ - import numpy as np import pytest from numpy.testing import ( @@ -20,7 +19,7 @@ assert_warns, suppress_warnings, ) - +from scipy.optimize import root from nbkode.nbcompat import numba, zeros from nbkode.nbcompat.zeros import zeros as sp_zeros @@ -249,8 +248,12 @@ def test_newton_full_output(self): x, r = zeros.newton(self.f1, x0, maxiter=iters, disp=True, **kwargs) def test_deriv_zero_warning(self): - func = lambda x: x**2 - 2.0 - dfunc = lambda x: 2 * x + def func(x): + return x**2 - 2.0 + + def dfunc(x): + return 2 * x + assert_warns(RuntimeWarning, zeros.newton, func, 0.0, dfunc, disp=False) with pytest.raises(RuntimeError, match="Derivative was zero"): zeros.newton(func, 0.0, dfunc) @@ -500,9 +503,6 @@ def test_jitted(): assert_allclose(zeros.j_newton(f1j, 0), zeros.newton(f1, 0)) -from scipy.optimize import root - - def test_ndnewton(): @numba.njit() def fff(x): diff --git a/nbkode/testsuite/test_solver.py b/nbkode/testsuite/test_solver.py index 9cfda71..de8beff 100644 --- a/nbkode/testsuite/test_solver.py +++ b/nbkode/testsuite/test_solver.py @@ -1,11 +1,11 @@ """ - nbkode.testsuite.solver - ~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.solver +~~~~~~~~~~~~~~~~~~~~~~~~~~ - Test solvers methods +Test solvers methods - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import numpy as np @@ -27,7 +27,6 @@ def f1(t, x, k): @pytest.mark.parametrize("solver", solvers) def test_f1_public_api(solver): - kwargs = dict(h=0.1) if issubclass(solver, nbkode.multistep.core.Multistep): diff --git a/nbkode/testsuite/test_solver_fs.py b/nbkode/testsuite/test_solver_fs.py index 294d63c..3496ee0 100644 --- a/nbkode/testsuite/test_solver_fs.py +++ b/nbkode/testsuite/test_solver_fs.py @@ -1,14 +1,14 @@ """ - nbkode.testsuite.solver_fs - ~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.solver_fs +~~~~~~~~~~~~~~~~~~~~~~~~~~ - Test fixed step solvers for: - - argument handling - - jittability - - running different methods. +Test fixed step solvers for: +- argument handling +- jittability +- running different methods. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import numpy as np @@ -41,7 +41,6 @@ def f2(t, x, k): @pytest.mark.parametrize("solver", solvers) def test_f1(solver): - solver = solver(f1, 0.0, y0_1, params=(0.01,), h=0.01) solver.skip(upto_t=10) @@ -51,7 +50,6 @@ def test_f1(solver): @pytest.mark.parametrize("solver", solvers) def test_f2(solver): - solver = solver(f2, 0.0, y0_2, params=(0.01, 0.05), h=0.01) solver.skip(upto_t=10) diff --git a/nbkode/testsuite/test_util.py b/nbkode/testsuite/test_util.py index 436e449..7f5478e 100644 --- a/nbkode/testsuite/test_util.py +++ b/nbkode/testsuite/test_util.py @@ -1,12 +1,12 @@ """ - nbkode.testsuite.solver_fs - ~~~~~~~~~~~~~~~~~~~~~~~~~~ +nbkode.testsuite.solver_fs +~~~~~~~~~~~~~~~~~~~~~~~~~~ - Test fixed step solvers for: - - CaseInsensitiveDict +Test fixed step solvers for: +- CaseInsensitiveDict - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import pytest @@ -15,7 +15,6 @@ class TestCaseInsensitiveDict: - # Adapted from https://github.com/psf/requests/blob/master/tests/test_structures.py @pytest.fixture(autouse=True) diff --git a/nbkode/util.py b/nbkode/util.py index 59d6976..c43c862 100644 --- a/nbkode/util.py +++ b/nbkode/util.py @@ -1,11 +1,11 @@ """ - nbkode.util - ~~~~~~~~~~~ +nbkode.util +~~~~~~~~~~~ - Useful functions and classes. +Useful functions and classes. - :copyright: 2020 by nbkode Authors, see AUTHORS for more details. - :license: BSD, see LICENSE for more details. +:copyright: 2020 by nbkode Authors, see AUTHORS for more details. +:license: BSD, see LICENSE for more details. """ import collections diff --git a/pyproject.toml b/pyproject.toml index 02beec1..8dda4e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,5 +7,7 @@ filterwarnings = [ "ignore::numba.NumbaExperimentalFeatureWarning", ] +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] [tool.setuptools_scm] diff --git a/requirements_docs.txt b/requirements_docs.txt index 9fcffeb..61bc8a0 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,9 +1,9 @@ +graphviz matplotlib nbsphinx -pytest -graphviz -setuptools>=41.2 -pygments>=2.4 +numba numpy +pygments>=2.4 +pytest scipy -numba +setuptools>=41.2