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

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 11, 2022
1 parent 46e96e2 commit 56a0cb5
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion labs/approximation/approximation_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions labs/integration/integration_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions labs/linear_equations/linear_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion labs/nonlinear_equations/nonlinear_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions labs/nonlinear_equations/nonlinear_algorithms_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions labs/nonlinear_equations/nonlinear_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions labs/nonlinear_equations/nonlinear_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions labs/nonlinear_equations/nonlinear_solutions_exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion labs/optimization/optimization_solutions_exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56a0cb5

Please sign in to comment.