Skip to content

Commit 9e90e7e

Browse files
committed
make xref = np.broadcast_to(xref, (N, 3)) handling simpler and more elegant
as proposed by mgeier
1 parent a50ca73 commit 9e90e7e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

doc/examples/wfs-referencing.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
" sfs.plot2d.amplitude(p, grid, vmax=2, vmin=-2, ax=ax_amp)\n",
6161
" sfs.plot2d.level(p, grid, vmax=6, vmin=-6, ax=ax_lvl)\n",
6262
" sfs.plot2d.level_contour(p, grid, levels=[0], colors='w', ax=ax_lvl)\n",
63-
" if xref.shape[0] != N:\n",
64-
" xref = np.broadcast_to(xref, (N, 3))\n",
63+
" xref = np.broadcast_to(xref, array.x.shape)\n",
6564
" for ax in ax_amp, ax_lvl:\n",
6665
" sfs.plot2d.loudspeakers(array.x, array.n, selection, size=0.125, ax=ax)\n",
6766
" ax_lvl.scatter(*xref[selection, :2].T, marker='o', s=20, c='lightsalmon',\n",
@@ -177,7 +176,7 @@
177176
" omega, array.x, array.n, xs)\n",
178177
"p_point = sound_field(\n",
179178
" d * normalize_gain, selection, array, secondary_source,\n",
180-
" grid, np.array([[0, 0, 0]]))"
179+
" grid, [0, 0, 0])"
181180
]
182181
},
183182
{
@@ -208,7 +207,7 @@
208207
" omega, array.x, array.n, xs, xref=xref)\n",
209208
"p_point = sound_field(\n",
210209
" d * normalize_gain, selection, array, secondary_source,\n",
211-
" grid, np.array([xref]))\n",
210+
" grid, xref)\n",
212211
"\n",
213212
"# plot stationary phase rays\n",
214213
"# one ray connects the virtual source with one activate loudspeaker\n",

0 commit comments

Comments
 (0)