Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ repos:
| advanced/interfacing_with_c/numpy_c_api/test_cos_module_np\.py$
| intro/numpy/solutions/2_a_call_fortran\.py$
| advanced/advanced_numpy/examples/mandelplot\.py$
| intro/numpy/solutions/2_5_markov_chain\.py$
| intro/matplotlib/examples/plot_bar\.py$
)

- repo: https://github.com/codespell-project/codespell
Expand Down
2 changes: 1 addition & 1 deletion advanced/optimizing/ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _ica_par(X, tol, g, gprime, fun_args, maxit, w_init):

W1 = _sym_decorrelation(W1)

lim = max(abs(abs(np.diag(W1 @ W.T)) - 1))
lim = np.max(np.abs(np.abs(np.diag(W1 @ W.T)) - 1))
W = W1
it = it + 1

Expand Down
12 changes: 6 additions & 6 deletions intro/matplotlib/examples/plot_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
n = 12
X = np.arange(n)
rng = np.random.default_rng()
Y1 = (1 - X / float(n)) * rng.uniform(0.5, 1.0, n)
Y2 = (1 - X / float(n)) * rng.uniform(0.5, 1.0, n)
Y1 = (1 - X / n) * rng.uniform(0.5, 1.0, n)
Y2 = (1 - X / n) * rng.uniform(0.5, 1.0, n)

plt.axes((0.025, 0.025, 0.95, 0.95))
plt.bar(X, +Y1, facecolor="#9999ff", edgecolor="white")
plt.bar(X, -Y2, facecolor="#ff9999", edgecolor="white")

for x, y in zip(X, Y1, strict=True):
plt.text(x + 0.4, y + 0.05, f"{y:.2f}", ha="center", va="bottom")
for x, y in zip(X, Y1):
plt.text(x, y + 0.05, f"{y:.2f}", ha="center", va="bottom")

for x, y in zip(X, Y2, strict=True):
plt.text(x + 0.4, -y - 0.05, f"{y:.2f}", ha="center", va="top")
for x, y in zip(X, Y2):
plt.text(x, -y - 0.05, f"{y:.2f}", ha="center", va="top")

plt.xlim(-0.5, n)
plt.xticks([])
Expand Down
6 changes: 3 additions & 3 deletions intro/matplotlib/examples/plot_plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from mpl_toolkits.mplot3d import Axes3D

ax: Axes3D = plt.figure().add_subplot(projection="3d")
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
x = np.arange(-4, 4, 0.25)
y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(x, y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

Expand Down
12 changes: 7 additions & 5 deletions intro/matplotlib/examples/pretty_plots/plot_plot3d_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
x = np.arange(-4, 4, 0.25)
y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(x, y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

fig = plt.figure()
ax: Axes3D = fig.add_subplot(111, projection="3d")

ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap="hot")
ax.contourf(X, Y, Z, zdir="z", offset=-2, cmap="hot")

ax.set_zlim(-2, 2)
plt.xticks([])
plt.yticks([])
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ exclude = '''
| advanced/interfacing_with_c/numpy_c_api/test_cos_module_np\.py$
| intro/numpy/solutions/2_a_call_fortran\.py$
| advanced/advanced_numpy/examples/mandelplot\.py$
| intro/numpy/solutions/2_5_markov_chain\.py$
| intro/matplotlib/examples/plot_bar\.py$
)
'''
# intro/numpy/solutions/2_5_markov_chain.py -> https://github.com/numpy/numpy/issues/27957
# intro/matplotliub/examples/plot_bar.py -> https://github.com/matplotlib/matplotlib/issues/29332

# Can make these more strict over time
allow_untyped_defs = true
Expand Down Expand Up @@ -109,6 +113,7 @@ ignore = [
"B006", # Do not use mutable data structures for argument defaults
"B007", # Loop control variable {name} not used within loop body
"B018", # Found useless expression. Either assign it to a variable or remove it.
"B905", # Zip without explicit `strict` keyword
"E402", # Module level import not at top of file
"E501", # Line too long
"E741", # Ambiguous variable name
Expand Down
Loading