Skip to content

Commit

Permalink
replace f-strings (>=3.6) and @ infix operator (>=3.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Mar 29, 2019
1 parent 18db015 commit 9eb2b1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/heat_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
fig, axes = plt.subplots(2, len(times), figsize=(12, 5))
for i, t in enumerate(times):
g = pg.filters.Heat(G, scale=t)
title = fr'$\hat{{f}}({t}) = g_{{1,{t}}} \odot \hat{{f}}(0)$'
title = r'$\hat{{f}}({0}) = g_{{1,{0}}} \odot \hat{{f}}(0)$'.format(t)
g.plot(alpha=1, ax=axes[0, i], title=title)
axes[0, i].set_xlabel(r'$\lambda$')
# axes[0, i].set_ylabel(r'$g(\lambda)$')
if i > 0:
axes[0, i].set_ylabel('')
y = g.filter(x)
line, = axes[0, i].plot(G.e, G.gft(y))
labels = [fr'$\hat{{f}}({t})$', fr'$g_{{1,{t}}}$']
labels = [r'$\hat{{f}}({})$'.format(t), r'$g_{{1,{}}}$'.format(t)]
axes[0, i].legend([line, axes[0, i].lines[-3]], labels, loc='lower right')
G.plot(y, edges=False, highlight=sources, ax=axes[1, i], title=fr'$f({t})$')
G.plot(y, edges=False, highlight=sources, ax=axes[1, i], title=r'$f({})$'.format(t))
axes[1, i].set_aspect('equal', 'box')
axes[1, i].set_axis_off()

Expand Down
6 changes: 3 additions & 3 deletions examples/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
delta = np.zeros(graph.N)
delta[N//2*N + N//2] = 1

probability = sparse.diags(graph.dw**(-1)) @ graph.W
probability = sparse.diags(graph.dw**(-1)).dot(graph.W)

fig, axes = plt.subplots(1, len(steps), figsize=(12, 3))
for step, ax in zip(steps, axes):
state = delta @ probability**step
state = (probability**step).__rmatmul__(delta) ## = delta @ probability**step
graph.plot(state, ax=ax, title=r'$\delta P^{}$'.format(step))
ax.set_axis_off()

Expand All @@ -47,7 +47,7 @@
if not hasattr(graph, 'coords'):
graph.set_coordinates(seed=10)

P = sparse.diags(graph.dw**(-1)) @ graph.W
P = sparse.diags(graph.dw**(-1)).dot(graph.W)

# e, u = np.linalg.eig(P.T.toarray())
# np.testing.assert_allclose(np.linalg.inv(u.T) @ np.diag(e) @ u.T,
Expand Down
6 changes: 3 additions & 3 deletions examples/wave_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
fig, axes = plt.subplots(2, len(times), figsize=(12, 5))
for i, t in enumerate(times):
g = pg.filters.Wave(G, time=t, speed=1)
title = fr'$\hat{{f}}({t}) = g_{{1,{t}}} \odot \hat{{f}}(0)$'
title = r'$\hat{{f}}({0}) = g_{{1,{0}}} \odot \hat{{f}}(0)$'.format(t)
g.plot(alpha=1, ax=axes[0, i], title=title)
axes[0, i].set_xlabel(r'$\lambda$')
# axes[0, i].set_ylabel(r'$g(\lambda)$')
if i > 0:
axes[0, i].set_ylabel('')
y = g.filter(x)
line, = axes[0, i].plot(G.e, G.gft(y))
labels = [fr'$\hat{{f}}({t})$', fr'$g_{{1,{t}}}$']
labels = [r'$\hat{{f}}({})$'.format(t), r'$g_{{1,{}}}$'.format(t)]
axes[0, i].legend([line, axes[0, i].lines[-3]], labels, loc='lower right')
G.plot(y, edges=False, highlight=sources, ax=axes[1, i], title=fr'$f({t})$')
G.plot(y, edges=False, highlight=sources, ax=axes[1, i], title=r'$f({})$'.format(t))
axes[1, i].set_aspect('equal', 'box')
axes[1, i].set_axis_off()

Expand Down

0 comments on commit 9eb2b1d

Please sign in to comment.