diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55e5d5b..94d5550 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.3.0 hooks: - id: check-added-large-files args: ['--maxkb=1000'] @@ -10,25 +10,25 @@ repos: - id: debug-statements - id: end-of-file-fixer - repo: https://github.com/asottile/pyupgrade - rev: v2.29.1 + rev: v3.2.2 hooks: - id: pyupgrade args: [--py36-plus] - repo: https://github.com/asottile/reorder_python_imports - rev: v2.6.0 + rev: v3.9.0 hooks: - id: reorder-python-imports - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.10.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: v1.12.0 + rev: v1.12.1 hooks: - id: blacken-docs additional_dependencies: [black==20.8b1] - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 types: [python] @@ -38,7 +38,7 @@ repos: flake8-todo, flake8-unused-arguments, pep8-naming, pydocstyle, Pygments, ] - repo: https://github.com/PyCQA/doc8 - rev: 0.10.1 + rev: v1.0.0 hooks: - id: doc8 #- repo: local diff --git a/labs/approximation/approximation_plots.py b/labs/approximation/approximation_plots.py index 92aa79f..5d8edd7 100755 --- a/labs/approximation/approximation_plots.py +++ b/labs/approximation/approximation_plots.py @@ -51,7 +51,7 @@ def plot_basis_functions(name="monomial"): if name == "chebychev": yvals = np.polynomial.Chebyshev.basis(i)(x) elif name == "monomial": - yvals = x ** i + yvals = x**i elif name == "linear": a, b = 0, 1 diff --git a/labs/integration/integration_algorithms.py b/labs/integration/integration_algorithms.py index a5d9159..1cbd5eb 100755 --- a/labs/integration/integration_algorithms.py +++ b/labs/integration/integration_algorithms.py @@ -59,8 +59,8 @@ def quadrature_gauss_legendre_two(f, a=-1, b=1, n=10): xvals, weight_uni = np.polynomial.legendre.leggauss(n_dim) xvals_transformed = (b - a) * (xvals + 1.0) / 2.0 + a - weights = np.tile(np.nan, n_dim ** 2) - fvals = np.tile(np.nan, n_dim ** 2) + weights = np.tile(np.nan, n_dim**2) + fvals = np.tile(np.nan, n_dim**2) counter = 0 for i, x in enumerate(xvals_transformed): diff --git a/labs/linear_equations/linear_plots.py b/labs/linear_equations/linear_plots.py index 3b2e924..0b79010 100644 --- a/labs/linear_equations/linear_plots.py +++ b/labs/linear_equations/linear_plots.py @@ -15,7 +15,7 @@ def plot_operation_count(): """Plot operation count.""" dim = np.arange(10) + 1 fig, ax = plt.subplots() - ax.plot(dim, dim / 3 + dim ** 2, label="LU") - ax.plot(dim, dim ** 3 + dim ** 2, label="Inverse") + ax.plot(dim, dim / 3 + dim**2, label="LU") + ax.plot(dim, dim**3 + dim**2, label="Inverse") ax.set_xlabel("Dimension") ax.legend() diff --git a/labs/nonlinear_equations/nonlinear_algorithms.py b/labs/nonlinear_equations/nonlinear_algorithms.py index 157cd0c..a701d5a 100644 --- a/labs/nonlinear_equations/nonlinear_algorithms.py +++ b/labs/nonlinear_equations/nonlinear_algorithms.py @@ -167,4 +167,4 @@ def fischer(u, v, sign): callable """ - return u + v + sign * np.sqrt(u ** 2 + v ** 2) + return u + v + sign * np.sqrt(u**2 + v**2) diff --git a/labs/nonlinear_equations/nonlinear_algorithms_tests.py b/labs/nonlinear_equations/nonlinear_algorithms_tests.py index 9e7aa27..d3f6d96 100644 --- a/labs/nonlinear_equations/nonlinear_algorithms_tests.py +++ b/labs/nonlinear_equations/nonlinear_algorithms_tests.py @@ -11,7 +11,7 @@ def test_1(): """Bisection method is working.""" def example(x): - return x ** 3 - 2 + return x**3 - 2 y = bisect(example, 1, 2)[0] @@ -33,10 +33,10 @@ def test_3(): """Newton method is working.""" def _jacobian(x): - return 3 * x ** 2 + return 3 * x**2 def _value(x): - return x ** 3 - 2 + return x**3 - 2 def f(x): return _value(x), _jacobian(x) diff --git a/labs/nonlinear_equations/nonlinear_plots.py b/labs/nonlinear_equations/nonlinear_plots.py index 8b2a421..3e54b26 100644 --- a/labs/nonlinear_equations/nonlinear_plots.py +++ b/labs/nonlinear_equations/nonlinear_plots.py @@ -107,7 +107,7 @@ def plot_newtons_method(): """ # Define function for illustration. def f(x): - return x ** 5 - 3, 5 * x ** 4 + return x**5 - 3, 5 * x**4 # Set axis limits and get function values. xmin, xmax = 1.0, 2.55 @@ -170,7 +170,7 @@ def plot_secant_method(): # Define function for illustration. def f(x): - return x ** 5 - 3 + return x**5 - 3 # Set axis limits and get function values. xmin, xmax = 1.0, 2.55 diff --git a/labs/nonlinear_equations/nonlinear_problems.py b/labs/nonlinear_equations/nonlinear_problems.py index 41e7e06..b28b7ef 100644 --- a/labs/nonlinear_equations/nonlinear_problems.py +++ b/labs/nonlinear_equations/nonlinear_problems.py @@ -10,7 +10,7 @@ def function_iteration_test_function(x): def bisection_test_function(x): """Get test function for bisection.""" - return x ** 3 - 2 + return x**3 - 2 def newton_pathological_example_fjac(x, f): @@ -20,7 +20,7 @@ def newton_pathological_example_fjac(x, f): def newton_pathological_example_fval(x): """Get Newton Pathological example function value.""" - return np.cbrt(x) * np.exp(-(x ** 2)) + return np.cbrt(x) * np.exp(-(x**2)) def newton_pathological_example(x): diff --git a/labs/nonlinear_equations/nonlinear_solutions_exercises.py b/labs/nonlinear_equations/nonlinear_solutions_exercises.py index e36009a..db8ce68 100644 --- a/labs/nonlinear_equations/nonlinear_solutions_exercises.py +++ b/labs/nonlinear_equations/nonlinear_solutions_exercises.py @@ -43,7 +43,7 @@ def test_exercise_3(): """Test for exercise 3.""" def func(x): - return x ** 4 - 2 + return x**4 - 2 fig, ax = plt.subplots() grid = np.linspace(1.1, 1.2) @@ -53,7 +53,7 @@ def func(x): x = 2.3 for it in range(50): print(it, x) - step = -(x ** 4 - 2) / (4 * x ** 3) + step = -(x**4 - 2) / (4 * x**3) x += step if abs(step) < 1e-10: break diff --git a/labs/optimization/optimization_solutions_exercises.py b/labs/optimization/optimization_solutions_exercises.py index 54dd3c1..8319d1c 100644 --- a/labs/optimization/optimization_solutions_exercises.py +++ b/labs/optimization/optimization_solutions_exercises.py @@ -27,7 +27,7 @@ def test_exercise_2(): df = pd.read_pickle(f"{dirname}/material/data-consumption-function.pkl") def construct_predicted_values(income, alpha, beta, gamma): - return alpha + beta * income ** gamma + return alpha + beta * income**gamma mock_rslt = [-91.1933, 0.5691, 1.0204] income = df["realgdp"].values