Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 56a0cb5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 46e96e2 commit 56a0cb5

9 files changed

+16
-16
lines changed

labs/approximation/approximation_plots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def plot_basis_functions(name="monomial"):
5151
if name == "chebychev":
5252
yvals = np.polynomial.Chebyshev.basis(i)(x)
5353
elif name == "monomial":
54-
yvals = x ** i
54+
yvals = x**i
5555

5656
elif name == "linear":
5757
a, b = 0, 1

labs/integration/integration_algorithms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def quadrature_gauss_legendre_two(f, a=-1, b=1, n=10):
5959
xvals, weight_uni = np.polynomial.legendre.leggauss(n_dim)
6060
xvals_transformed = (b - a) * (xvals + 1.0) / 2.0 + a
6161

62-
weights = np.tile(np.nan, n_dim ** 2)
63-
fvals = np.tile(np.nan, n_dim ** 2)
62+
weights = np.tile(np.nan, n_dim**2)
63+
fvals = np.tile(np.nan, n_dim**2)
6464

6565
counter = 0
6666
for i, x in enumerate(xvals_transformed):

labs/linear_equations/linear_plots.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def plot_operation_count():
1515
"""Plot operation count."""
1616
dim = np.arange(10) + 1
1717
fig, ax = plt.subplots()
18-
ax.plot(dim, dim / 3 + dim ** 2, label="LU")
19-
ax.plot(dim, dim ** 3 + dim ** 2, label="Inverse")
18+
ax.plot(dim, dim / 3 + dim**2, label="LU")
19+
ax.plot(dim, dim**3 + dim**2, label="Inverse")
2020
ax.set_xlabel("Dimension")
2121
ax.legend()

labs/nonlinear_equations/nonlinear_algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ def fischer(u, v, sign):
167167
callable
168168
169169
"""
170-
return u + v + sign * np.sqrt(u ** 2 + v ** 2)
170+
return u + v + sign * np.sqrt(u**2 + v**2)

labs/nonlinear_equations/nonlinear_algorithms_tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_1():
1111
"""Bisection method is working."""
1212

1313
def example(x):
14-
return x ** 3 - 2
14+
return x**3 - 2
1515

1616
y = bisect(example, 1, 2)[0]
1717

@@ -33,10 +33,10 @@ def test_3():
3333
"""Newton method is working."""
3434

3535
def _jacobian(x):
36-
return 3 * x ** 2
36+
return 3 * x**2
3737

3838
def _value(x):
39-
return x ** 3 - 2
39+
return x**3 - 2
4040

4141
def f(x):
4242
return _value(x), _jacobian(x)

labs/nonlinear_equations/nonlinear_plots.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def plot_newtons_method():
107107
"""
108108
# Define function for illustration.
109109
def f(x):
110-
return x ** 5 - 3, 5 * x ** 4
110+
return x**5 - 3, 5 * x**4
111111

112112
# Set axis limits and get function values.
113113
xmin, xmax = 1.0, 2.55
@@ -170,7 +170,7 @@ def plot_secant_method():
170170
# Define function for illustration.
171171

172172
def f(x):
173-
return x ** 5 - 3
173+
return x**5 - 3
174174

175175
# Set axis limits and get function values.
176176
xmin, xmax = 1.0, 2.55

labs/nonlinear_equations/nonlinear_problems.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def function_iteration_test_function(x):
1010

1111
def bisection_test_function(x):
1212
"""Get test function for bisection."""
13-
return x ** 3 - 2
13+
return x**3 - 2
1414

1515

1616
def newton_pathological_example_fjac(x, f):
@@ -20,7 +20,7 @@ def newton_pathological_example_fjac(x, f):
2020

2121
def newton_pathological_example_fval(x):
2222
"""Get Newton Pathological example function value."""
23-
return np.cbrt(x) * np.exp(-(x ** 2))
23+
return np.cbrt(x) * np.exp(-(x**2))
2424

2525

2626
def newton_pathological_example(x):

labs/nonlinear_equations/nonlinear_solutions_exercises.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_exercise_3():
4343
"""Test for exercise 3."""
4444

4545
def func(x):
46-
return x ** 4 - 2
46+
return x**4 - 2
4747

4848
fig, ax = plt.subplots()
4949
grid = np.linspace(1.1, 1.2)
@@ -53,7 +53,7 @@ def func(x):
5353
x = 2.3
5454
for it in range(50):
5555
print(it, x)
56-
step = -(x ** 4 - 2) / (4 * x ** 3)
56+
step = -(x**4 - 2) / (4 * x**3)
5757
x += step
5858
if abs(step) < 1e-10:
5959
break

labs/optimization/optimization_solutions_exercises.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_exercise_2():
2727
df = pd.read_pickle(f"{dirname}/material/data-consumption-function.pkl")
2828

2929
def construct_predicted_values(income, alpha, beta, gamma):
30-
return alpha + beta * income ** gamma
30+
return alpha + beta * income**gamma
3131

3232
mock_rslt = [-91.1933, 0.5691, 1.0204]
3333
income = df["realgdp"].values

0 commit comments

Comments
 (0)