@@ -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