Skip to content

Commit 955b24f

Browse files
committed
Fix linting errors
1 parent b11d24e commit 955b24f

10 files changed

+31
-18
lines changed

numdiff/conditions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections.abc import Callable
21
from dataclasses import dataclass
32
from typing import Any
43

numdiff/examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
from .conditions import Dirichlet, Neumann
5-
from .equations import HeatEquation, InviscidBurgers, InviscidBurgers2, PeriodicKdV
5+
from .equations import HeatEquation, InviscidBurgers, PeriodicKdV
66
from .plotting import solve_and_plot
77
from .poisson import amr, poisson
88
from .refine import refine_mesh

numdiff/helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def central_difference(N, power=2, format="lil"):
2121

2222
def l2(v, axis=None):
2323
"""Calculate the discrete l2 norm of the vector v"""
24-
l = v.shape[0]
25-
return np.sqrt(np.sum(np.square(v), axis=axis) / l)
24+
length = v.shape[0]
25+
return np.sqrt(np.sum(np.square(v), axis=axis) / length)
2626

2727

2828
def relative_l2_error(u, U):

numdiff/laplace.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
2-
This module considers the following 2D Laplace equation on the unit square (x,y) ∈ [0,1]^2 = Ω
3-
u_xx + u_yy = 0
2+
This module considers an instance of the 2D Laplace equation
3+
4+
Specifically it solves
5+
u_xx + u_yy = 0, on the unit square (x,y) ∈ [0,1]^2 = Ω
6+
with boundary conditions:
47
u(0,y) = 0, 0≤y≤1
58
u(x,0) = 0, 0≤x≤1
69
u(1,y) = 0, 0≤y≤1

tasks/advection_diffusion.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class Scheme(ThetaMethod, PeriodicAdvectionDiffusion2ndOrder):
6161
f"Periodic advection diffusion - numerical solution with $M={M}, N={N}$"
6262
)
6363
plt.title(
64-
r"$u_t = c u_x + d u_{xx}, u(x, 0) = \sin{\left( 4 \pi x\right)}, u(x, t) = u(x+1, t)$"
64+
r"$u_t = c u_x + d u_{xx}, u(x, 0) = \sin{\left( 4 \pi x\right)}, "
65+
"u(x, t) = u(x+1, t)$"
6566
)
6667
plt.xlabel("$x$")
6768
plt.ylabel("Time $t$")
@@ -223,7 +224,8 @@ def u(x, t):
223224
)
224225

225226
plt.suptitle(
226-
fr"Periodic advection diffusion - refinement with constant $r=\frac{{k}}{{h^2}}={r}$"
227+
"Periodic advection diffusion - refinement "
228+
fr"with constant $r=\frac{{k}}{{h^2}}={r}$"
227229
)
228230

229231
plt.subplot(121)

tasks/burgers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
from numdiff.conditions import Dirichlet
5-
from numdiff.equations import InviscidBurgers, InviscidBurgers2
5+
from numdiff.equations import InviscidBurgers
66
from numdiff.schemes import RK4
77
from numdiff.settings import FINE_PARAMETERS
88

tasks/heat_eqn.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def f(x):
6767

6868
plt.suptitle(f"The heat equation - numerical solution with $M={M}, N={N}$")
6969
plt.title(
70-
r"$u_t = u_{xx}, u(x, 0) = 2 \pi x + \sin{\left( 2 \pi x\right)}, u_x(0, t) = u_x(1, t) = 0$"
70+
r"$u_t = u_{xx}, u(x, 0) = 2 \pi x + \sin{\left( 2 \pi x\right)}, "
71+
"u_x(0, t) = u_x(1, t) = 0$"
7172
)
7273
plt.xlabel("$x$")
7374
plt.ylabel("Time $t$")
@@ -157,7 +158,8 @@ def f(x):
157158

158159
plt.suptitle("The heat equation - discretization of the boundary conditions")
159160
plt.title(
160-
f"Comparison with reference solution with $M^* = {M_star}$ at $t = {T}$. $N = {N}$"
161+
"Comparison with reference solution with "
162+
f"$M^* = {M_star}$ at $t = {T}$. $N = {N}$"
161163
)
162164
plt.xlabel("Internal nodes $M$")
163165
plt.ylabel(r"Relative $l_2$ error $\frac{\|U-u\|}{\|u\|}$")
@@ -275,7 +277,8 @@ def task_2bh():
275277

276278
plt.suptitle("The heat equation - $h$-refinement")
277279
plt.title(
278-
f"Backwards Euler vs Crank Nicholson with $N={TASK_2B_PARAMS['N']}$ at $t = {TASK_2B_PARAMS['T']}$"
280+
"Backwards Euler vs Crank Nicholson with "
281+
f"$N={TASK_2B_PARAMS['N']}$ at $t = {TASK_2B_PARAMS['T']}$"
279282
)
280283
plt.xlabel("Internal nodes $M$")
281284
plt.ylabel(r"Relative error $\frac{\|U-u\|}{\|u\|}$")
@@ -315,7 +318,8 @@ def task_2bk():
315318

316319
plt.suptitle("The heat equation - $k$-refinement")
317320
plt.title(
318-
f"Backwards Euler vs Crank Nicholson with $M={TASK_2B_PARAMS['M']}$ at $t = {TASK_2B_PARAMS['T']}$"
321+
"Backwards Euler vs Crank Nicholson with "
322+
f"$M={TASK_2B_PARAMS['M']}$ at $t = {TASK_2B_PARAMS['T']}$"
319323
)
320324
plt.xlabel("Time steps $N$")
321325
plt.ylabel(r"Relative error $\frac{\|U-u\|}{\|u\|}$")

tasks/kdv.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def task_4_solution():
5858
f"Linearized Korteweg-deVries - numerical solution with $M={M}, N={N}$"
5959
)
6060
plt.title(
61-
r"$u_t + \left(1 + \pi^2\right) u_x + u_{xxx} = 0, u(x, 0) = \sin{\left( \pi x\right)}, u(x, t) = u(x+2, t)$"
61+
r"$u_t + \left(1 + \pi^2\right) u_x + u_{xxx} = 0, "
62+
r"u(x, 0) = \sin{\left( \pi x\right)}, u(x, t) = u(x+2, t)$"
6263
)
6364
plt.xlabel("$x$")
6465
plt.ylabel("Time $t$")

tasks/laplace_2D.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def task_3_solution():
2121
c = plt.pcolormesh(x, y, U, cmap="hot", shading="nearest")
2222
plt.colorbar(c, ax=plt.gca())
2323
plt.title(
24-
r"$u_{xx} + u_{yy} = 0, \> u(x, 1) = \sin{\left( 2 \pi x\right)}, u(0, y) = u(x, 0) = u(1, y) = 0$"
24+
r"$u_{xx} + u_{yy} = 0, \> u(x, 1) = \sin{\left( 2 \pi x\right)}, "
25+
"u(0, y) = u(x, 0) = u(1, y) = 0$"
2526
)
2627
plt.xlabel("$x$")
2728
plt.ylabel("$y$")

tasks/poisson_1D.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def u(x):
7777

7878
plt.suptitle(f"Poisson's equation - Analytical vs numerical with $M={M}$")
7979
plt.title(
80-
fr"$u_{{xx}} = f(x) = \cos{{\left( 2 \pi x \right)}} + x, u(0, t) = {alpha}, u_x(1, t) = {sigma}$"
80+
r"$u_{xx} = f(x) = \cos{\left( 2 \pi x \right)} + x, "
81+
f"u(0, t) = {alpha}, u_x(1, t) = {sigma}$"
8182
)
8283
plt.xlabel("$x$")
8384
plt.ylabel("$y$")
@@ -169,7 +170,8 @@ def u(x):
169170

170171
plt.suptitle(f"Poisson's equation - Analytical vs numerical with $M={M}$")
171172
plt.title(
172-
fr"$u_{{xx}} = f(x) = \cos{{\left( 2 \pi x \right)}} + x, u(0, t) = {alpha}, u(1, t) = {beta}$"
173+
r"$u_{xx} = f(x) = \cos{\left( 2 \pi x \right)} + x, "
174+
f"u(0, t) = {alpha}, u(1, t) = {beta}$"
173175
)
174176
plt.xlabel("$x$")
175177
plt.ylabel("$y$")
@@ -268,7 +270,8 @@ def u(x):
268270

269271
plt.suptitle(f"Poisson's equation - ill posed problem with $M={M}$")
270272
plt.title(
271-
fr"$u_{{xx}} = f(x) = \cos{{\left( 2 \pi x \right)}} + x, u_x(0) = {sigma1}, u_x(1) = {sigma2}$"
273+
r"$u_{xx} = f(x) = \cos{\left( 2 \pi x \right)} + x, "
274+
f"u_x(0) = {sigma1}, u_x(1) = {sigma2}$"
272275
)
273276
plt.xlabel("$x$")
274277
plt.ylabel("$y$")

0 commit comments

Comments
 (0)