Skip to content

Commit f8f973d

Browse files
committed
Zero Division & Deprecation Warning Removal
1 parent 251c9be commit f8f973d

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

tutorials-v5/lectures/Lecture-14-Kerr-nonlinearities.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def plot_wigner(rho, fig=None, ax=None):
123123
W,
124124
100,
125125
norm=mpl.colors.Normalize(-wlim, wlim),
126-
cmap=mpl.cm.get_cmap("RdBu"),
126+
cmap=mpl.colormaps["RdBu"],
127127
)
128128
ax.set_xlabel(r"$x_1$", fontsize=16)
129129
ax.set_ylabel(r"$x_2$", fontsize=16)
@@ -148,7 +148,7 @@ def plot_fock_distribution_vs_time(tlist, states, fig=None, ax=None):
148148
Y,
149149
Z.T,
150150
norm=mpl.colors.Normalize(0, 0.5),
151-
cmap=mpl.cm.get_cmap("Reds"),
151+
cmap=mpl.colormaps["RdBu"],
152152
edgecolors="k",
153153
)
154154
ax.set_xlabel(r"$N$", fontsize=16)

tutorials-v5/lectures/Lecture-5-Parametric-Amplifier.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ for idx, psi in enumerate(output.states):
190190
cs_lhs[idx] = expect(ad_a_bd_b, psi)
191191
cs_rhs[idx] = expect(ad_ad_a_a, psi)
192192

193-
# normalize the correlation functions
194-
g2_1 = g2_1 / (na_e**2)
195-
g2_2 = g2_2 / (nb_e**2)
196-
g2_12 = g2_12 / (na_e * nb_e)
193+
# normalize setting inf to nan
194+
def safe_divide(a, b):
195+
with np.errstate(divide='ignore', invalid='ignore'):
196+
result = np.true_divide(a, b)
197+
result[~np.isfinite(result)] = np.nan
198+
return result
199+
200+
g2_1 = safe_divide(g2_1, na_e**2)
201+
g2_2 = safe_divide(g2_2, nb_e**2)
202+
g2_12 = safe_divide(g2_12, na_e * nb_e)
197203
```
198204

199205
### Second-order coherence functions: Cauchy-Schwarz inequality
@@ -416,12 +422,11 @@ def plot_covariance_matrix(V, ax):
416422

417423
ax.view_init(azim=-40, elev=60)
418424
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color=colors)
419-
ax.axes.xaxis.set_major_locator(plt.IndexLocator(1, -0.5))
420-
ax.axes.yaxis.set_major_locator(plt.IndexLocator(1, -0.5))
421-
ax.axes.xaxis.set_ticklabels(("$q_-$", "$p_-$", "$q_+$", "$p_+$"),
422-
fontsize=12)
423-
ax.axes.yaxis.set_ticklabels(("$q_-$", "$p_-$", "$q_+$", "$p_+$"),
424-
fontsize=12)
425+
# Set tick locations before setting tick labels
426+
ax.axes.xaxis.set_ticks([0, 1, 2, 3])
427+
ax.axes.yaxis.set_ticks([0, 1, 2, 3])
428+
ax.axes.xaxis.set_ticklabels(("$q_-$", "$p_-$", "$q_+$", "$p_+$"), fontsize=12)
429+
ax.axes.yaxis.set_ticklabels(("$q_-$", "$p_-$", "$q_+$", "$p_+$"), fontsize=12)
425430
```
426431

427432
```python
@@ -440,7 +445,7 @@ for idx, t_idx in enumerate(t_idx_vec):
440445

441446
plot_covariance_matrix(V, axes[idx])
442447

443-
fig.tight_layout()
448+
fig.subplots_adjust(left=0.15, right=0.85, top=0.9, bottom=0.1)
444449
```
445450

446451
```python

0 commit comments

Comments
 (0)