Skip to content

Commit c420d98

Browse files
committed
Keyword-only arguments everywhere
1 parent 4f83604 commit c420d98

File tree

15 files changed

+125
-112
lines changed

15 files changed

+125
-112
lines changed

doc/examples/horizontal_plane_arrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def compute_and_plot_soundfield(title):
2929
"""Compute and plot synthesized sound field."""
3030
print('Computing', title)
3131

32-
twin = tapering(selection, talpha)
32+
twin = tapering(selection, alpha=talpha)
3333
p = sfs.fd.synthesize(d, twin, array, secondary_source, grid=grid)
3434

3535
plt.figure(figsize=(15, 15))
3636
plt.cla()
37-
sfs.plot2d.amplitude(p, grid, xnorm)
37+
sfs.plot2d.amplitude(p, grid, xnorm=xnorm)
3838
sfs.plot2d.loudspeakers(array.x, array.n, twin)
3939
sfs.plot2d.virtualsource(xs)
4040
sfs.plot2d.virtualsource([0, 0], npw, type='plane')

doc/examples/mirror-image-source-model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"source": [
9595
"grid = sfs.util.xyz_grid([0, L[0]], [0, L[1]], 1.5, spacing=0.02)\n",
9696
"P = sfs.fd.source.point_image_sources(omega, x0, grid, L,\n",
97-
" max_order, coeffs=coeffs)"
97+
" max_order=max_order, coeffs=coeffs)"
9898
]
9999
},
100100
{

doc/examples/sound_field_synthesis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#d, selection, secondary_source = sfs.fd.wfs.line_2d(omega, array.x, array.n, xs)
5050

5151
#d, selection, secondary_source = sfs.fd.wfs.plane_2d(omega, array.x, array.n, npw)
52-
d, selection, secondary_source = sfs.fd.wfs.plane_25d(omega, array.x, array.n, npw, xref)
52+
d, selection, secondary_source = sfs.fd.wfs.plane_25d(omega, array.x, array.n, npw, xref=xref)
5353
#d, selection, secondary_source = sfs.fd.wfs.plane_3d(omega, array.x, array.n, npw)
5454

5555
#d, selection, secondary_source = sfs.fd.wfs.point_2d(omega, array.x, array.n, xs)
@@ -64,16 +64,16 @@
6464

6565
# === compute tapering window ===
6666
#twin = sfs.tapering.none(selection)
67-
#twin = sfs.tapering.kaiser(selection, 8.6)
68-
twin = sfs.tapering.tukey(selection, 0.3)
67+
#twin = sfs.tapering.kaiser(selection, beta=8.6)
68+
twin = sfs.tapering.tukey(selection, alpha=0.3)
6969

7070
# === compute synthesized sound field ===
7171
p = sfs.fd.synthesize(d, twin, array, secondary_source, grid=grid)
7272

7373

7474
# === plot synthesized sound field ===
7575
plt.figure(figsize=(10, 10))
76-
sfs.plot2d.amplitude(p, grid, [0, 0, 0])
76+
sfs.plot2d.amplitude(p, grid, xnorm=[0, 0, 0])
7777
sfs.plot2d.loudspeakers(array.x, array.n, twin)
7878
plt.grid()
7979
plt.savefig('soundfield.png')

doc/examples/time_domain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)
3030

3131
# test soundfield
32-
twin = sfs.tapering.tukey(selection, .3)
32+
twin = sfs.tapering.tukey(selection, alpha=0.3)
3333

3434
p = sfs.td.synthesize(d, twin, array,
3535
secondary_source, observation_time=t, grid=grid)
@@ -54,7 +54,7 @@
5454
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)
5555

5656
# test soundfield
57-
twin = sfs.tapering.tukey(selection, .3)
57+
twin = sfs.tapering.tukey(selection, alpha=0.3)
5858
p = sfs.td.synthesize(d, twin, array,
5959
secondary_source, observation_time=t, grid=grid)
6060

@@ -76,7 +76,7 @@
7676
d = sfs.td.wfs.driving_signals(d_delay, d_weight, signal)
7777

7878
# test soundfield
79-
twin = sfs.tapering.tukey(selection, .3)
79+
twin = sfs.tapering.tukey(selection, alpha=0.3)
8080
p = sfs.td.synthesize(d, twin, array,
8181
secondary_source, observation_time=t, grid=grid)
8282
p = p * 100 # scale absolute amplitude

sfs/array.py

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def as_secondary_source_distribution(arg, **kwargs):
8484
return SecondarySourceDistribution(x, n, a)
8585

8686

87-
def linear(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
87+
def linear(N, spacing, *, center=[0, 0, 0], orientation=[1, 0, 0]):
8888
"""Return linear, equidistantly sampled secondary source distribution.
8989
9090
Parameters
@@ -119,7 +119,7 @@ def linear(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
119119
return _linear_helper(np.arange(N) * spacing, center, orientation)
120120

121121

122-
def linear_diff(distances, center=[0, 0, 0], orientation=[1, 0, 0]):
122+
def linear_diff(distances, *, center=[0, 0, 0], orientation=[1, 0, 0]):
123123
"""Return linear secondary source distribution from a list of distances.
124124
125125
Parameters
@@ -152,7 +152,7 @@ def linear_diff(distances, center=[0, 0, 0], orientation=[1, 0, 0]):
152152
return _linear_helper(ycoordinates, center, orientation)
153153

154154

155-
def linear_random(N, min_spacing, max_spacing, center=[0, 0, 0],
155+
def linear_random(N, min_spacing, max_spacing, *, center=[0, 0, 0],
156156
orientation=[1, 0, 0], seed=None):
157157
"""Return randomly sampled linear array.
158158
@@ -190,10 +190,10 @@ def linear_random(N, min_spacing, max_spacing, center=[0, 0, 0],
190190
"""
191191
r = np.random.RandomState(seed)
192192
distances = r.uniform(min_spacing, max_spacing, size=N-1)
193-
return linear_diff(distances, center, orientation)
193+
return linear_diff(distances, center=center, orientation=orientation)
194194

195195

196-
def circular(N, R, center=[0, 0, 0]):
196+
def circular(N, R, *, center=[0, 0, 0]):
197197
"""Return circular secondary source distribution parallel to the xy-plane.
198198
199199
Parameters
@@ -235,7 +235,7 @@ def circular(N, R, center=[0, 0, 0]):
235235
return SecondarySourceDistribution(positions, normals, weights)
236236

237237

238-
def rectangular(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
238+
def rectangular(N, spacing, *, center=[0, 0, 0], orientation=[1, 0, 0]):
239239
"""Return rectangular secondary source distribution.
240240
241241
Parameters
@@ -272,18 +272,22 @@ def rectangular(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
272272
offset1 = spacing * (N2 - 1) / 2 + spacing / np.sqrt(2)
273273
offset2 = spacing * (N1 - 1) / 2 + spacing / np.sqrt(2)
274274
positions, normals, weights = concatenate(
275-
linear(N1, spacing, [-offset1, 0, 0], [1, 0, 0]), # left
276-
linear(N2, spacing, [0, offset2, 0], [0, -1, 0]), # upper
277-
linear(N1, spacing, [offset1, 0, 0], [-1, 0, 0]), # right
278-
linear(N2, spacing, [0, -offset2, 0], [0, 1, 0]), # lower
275+
# left
276+
linear(N1, spacing, center=[-offset1, 0, 0], orientation=[1, 0, 0]),
277+
# upper
278+
linear(N2, spacing, center=[0, offset2, 0], orientation=[0, -1, 0]),
279+
# right
280+
linear(N1, spacing, center=[offset1, 0, 0], orientation=[-1, 0, 0]),
281+
# lower
282+
linear(N2, spacing, center=[0, -offset2, 0], orientation=[0, 1, 0]),
279283
)
280284
positions, normals = _rotate_array(positions, normals,
281285
[1, 0, 0], orientation)
282286
positions += center
283287
return SecondarySourceDistribution(positions, normals, weights)
284288

285289

286-
def rounded_edge(Nxy, Nr, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
290+
def rounded_edge(Nxy, Nr, dx, *, center=[0, 0, 0], orientation=[1, 0, 0]):
287291
"""Return SSD along the xy-axis with rounded edge at the origin.
288292
289293
Parameters
@@ -357,7 +361,7 @@ def rounded_edge(Nxy, Nr, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
357361
return SecondarySourceDistribution(positions, directions, weights)
358362

359363

360-
def edge(Nxy, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
364+
def edge(Nxy, dx, *, center=[0, 0, 0], orientation=[1, 0, 0]):
361365
"""Return SSD along the xy-axis with sharp edge at the origin.
362366
363367
Parameters
@@ -409,7 +413,7 @@ def edge(Nxy, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
409413
return SecondarySourceDistribution(positions, directions, weights)
410414

411415

412-
def planar(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
416+
def planar(N, spacing, *, center=[0, 0, 0], orientation=[1, 0, 0]):
413417
"""Return planar secondary source distribtion.
414418
415419
Parameters
@@ -460,7 +464,7 @@ def planar(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
460464
return SecondarySourceDistribution(positions, normals, weights)
461465

462466

463-
def cube(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
467+
def cube(N, spacing, *, center=[0, 0, 0], orientation=[1, 0, 0]):
464468
"""Return cube-shaped secondary source distribtion.
465469
466470
Parameters
@@ -496,24 +500,31 @@ def cube(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
496500
497501
"""
498502
N1, N2, N3 = (N, N, N) if np.isscalar(N) else N
499-
offset1 = spacing * (N2 - 1) / 2 + spacing / np.sqrt(2)
500-
offset2 = spacing * (N1 - 1) / 2 + spacing / np.sqrt(2)
501-
offset3 = spacing * (N3 - 1) / 2 + spacing / np.sqrt(2)
503+
d = spacing
504+
offset1 = d * (N2 - 1) / 2 + d / np.sqrt(2)
505+
offset2 = d * (N1 - 1) / 2 + d / np.sqrt(2)
506+
offset3 = d * (N3 - 1) / 2 + d / np.sqrt(2)
502507
positions, directions, weights = concatenate(
503-
planar((N1, N3), spacing, [-offset1, 0, 0], [1, 0, 0]), # west
504-
planar((N2, N3), spacing, [0, offset2, 0], [0, -1, 0]), # north
505-
planar((N1, N3), spacing, [offset1, 0, 0], [-1, 0, 0]), # east
506-
planar((N2, N3), spacing, [0, -offset2, 0], [0, 1, 0]), # south
507-
planar((N2, N1), spacing, [0, 0, -offset3], [0, 0, 1]), # bottom
508-
planar((N2, N1), spacing, [0, 0, offset3], [0, 0, -1]), # top
508+
# west
509+
planar((N1, N3), d, center=[-offset1, 0, 0], orientation=[1, 0, 0]),
510+
# north
511+
planar((N2, N3), d, center=[0, offset2, 0], orientation=[0, -1, 0]),
512+
# east
513+
planar((N1, N3), d, center=[offset1, 0, 0], orientation=[-1, 0, 0]),
514+
# south
515+
planar((N2, N3), d, center=[0, -offset2, 0], orientation=[0, 1, 0]),
516+
# bottom
517+
planar((N2, N1), d, center=[0, 0, -offset3], orientation=[0, 0, 1]),
518+
# top
519+
planar((N2, N1), d, center=[0, 0, offset3], orientation=[0, 0, -1]),
509520
)
510521
positions, directions = _rotate_array(positions, directions,
511522
[1, 0, 0], orientation)
512523
positions += center
513524
return SecondarySourceDistribution(positions, directions, weights)
514525

515526

516-
def sphere_load(file, radius, center=[0, 0, 0]):
527+
def sphere_load(file, radius, *, center=[0, 0, 0]):
517528
"""Load spherical secondary source distribution from file.
518529
519530
ASCII Format (see MATLAB SFS Toolbox) with 4 numbers (3 for the cartesian
@@ -562,7 +573,7 @@ def sphere_load(file, radius, center=[0, 0, 0]):
562573
return SecondarySourceDistribution(positions, normals, weights)
563574

564575

565-
def load(file, center=[0, 0, 0], orientation=[1, 0, 0]):
576+
def load(file, *, center=[0, 0, 0], orientation=[1, 0, 0]):
566577
"""Load secondary source distribution from file.
567578
568579
Comma Separated Values (CSV) format with 7 values
@@ -615,7 +626,7 @@ def load(file, center=[0, 0, 0], orientation=[1, 0, 0]):
615626
return SecondarySourceDistribution(positions, normals, weights)
616627

617628

618-
def weights_midpoint(positions, closed):
629+
def weights_midpoint(positions, *, closed):
619630
"""Calculate loudspeaker weights for a simply connected array.
620631
621632
The weights are calculated according to the midpoint rule.

sfs/fd/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def secondary_source_point(omega, c):
6363
"""Create a point source for use in `sfs.fd.synthesize()`."""
6464

6565
def secondary_source(position, _, grid):
66-
return source.point(omega, position, grid, c)
66+
return source.point(omega, position, grid, c=c)
6767

6868
return secondary_source
6969

@@ -72,7 +72,7 @@ def secondary_source_line(omega, c):
7272
"""Create a line source for use in `sfs.fd.synthesize()`."""
7373

7474
def secondary_source(position, _, grid):
75-
return source.line(omega, position, grid, c)
75+
return source.line(omega, position, grid, c=c)
7676

7777
return secondary_source
7878

sfs/fd/esa.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
from . import secondary_source_line, secondary_source_point
1717

1818

19-
def plane_2d_edge(omega, x0, n=[0, 1, 0], alpha=3/2*np.pi, Nc=None,
20-
c=None):
19+
def plane_2d_edge(omega, x0, n=[0, 1, 0], *, alpha=3/2*np.pi, Nc=None, c=None):
2120
r"""Driving function for 2-dimensional plane wave with edge ESA.
2221
2322
Driving function for a virtual plane wave using the 2-dimensional ESA
@@ -87,8 +86,8 @@ def plane_2d_edge(omega, x0, n=[0, 1, 0], alpha=3/2*np.pi, Nc=None,
8786
return 4*np.pi/alpha * d, selection, secondary_source_line(omega, c)
8887

8988

90-
def plane_2d_edge_dipole_ssd(omega, x0, n=[0, 1, 0], alpha=3/2*np.pi, Nc=None,
91-
c=None):
89+
def plane_2d_edge_dipole_ssd(omega, x0, n=[0, 1, 0], *, alpha=3/2*np.pi,
90+
Nc=None, c=None):
9291
r"""Driving function for 2-dimensional plane wave with edge dipole ESA.
9392
9493
Driving function for a virtual plane wave using the 2-dimensional ESA
@@ -155,7 +154,7 @@ def plane_2d_edge_dipole_ssd(omega, x0, n=[0, 1, 0], alpha=3/2*np.pi, Nc=None,
155154
return 4*np.pi/alpha * d
156155

157156

158-
def line_2d_edge(omega, x0, xs, alpha=3/2*np.pi, Nc=None, c=None):
157+
def line_2d_edge(omega, x0, xs, *, alpha=3/2*np.pi, Nc=None, c=None):
159158
r"""Driving function for 2-dimensional line source with edge ESA.
160159
161160
Driving function for a virtual line source using the 2-dimensional ESA
@@ -229,7 +228,8 @@ def line_2d_edge(omega, x0, xs, alpha=3/2*np.pi, Nc=None, c=None):
229228
return -1j*np.pi/alpha * d, selection, secondary_source_line(omega, c)
230229

231230

232-
def line_2d_edge_dipole_ssd(omega, x0, xs, alpha=3/2*np.pi, Nc=None, c=None):
231+
def line_2d_edge_dipole_ssd(omega, x0, xs, *, alpha=3/2*np.pi, Nc=None,
232+
c=None):
233233
r"""Driving function for 2-dimensional line source with edge dipole ESA.
234234
235235
Driving function for a virtual line source using the 2-dimensional ESA
@@ -300,8 +300,8 @@ def line_2d_edge_dipole_ssd(omega, x0, xs, alpha=3/2*np.pi, Nc=None, c=None):
300300
return -1j*np.pi/alpha * d
301301

302302

303-
def point_25d_edge(omega, x0, xs, xref=[2, -2, 0], alpha=3/2*np.pi,
304-
Nc=None, c=None):
303+
def point_25d_edge(omega, x0, xs, *, xref=[2, -2, 0], alpha=3/2*np.pi,
304+
Nc=None, c=None):
305305
r"""Driving function for 2.5-dimensional point source with edge ESA.
306306
307307
Driving function for a virtual point source using the 2.5-dimensional

sfs/fd/nfchoa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def plot(d, selection, secondary_source):
3535
from . import secondary_source_point
3636

3737

38-
def plane_2d(omega, x0, r0, n=[0, 1, 0], max_order=None, c=None):
38+
def plane_2d(omega, x0, r0, n=[0, 1, 0], *, max_order=None, c=None):
3939
r"""Driving function for 2-dimensional NFC-HOA for a virtual plane wave.
4040
4141
Parameters
@@ -101,7 +101,7 @@ def plane_2d(omega, x0, r0, n=[0, 1, 0], max_order=None, c=None):
101101
return -2j / (np.pi*r0) * d, selection, secondary_source_point(omega, c)
102102

103103

104-
def point_25d(omega, x0, r0, xs, max_order=None, c=None):
104+
def point_25d(omega, x0, r0, xs, *, max_order=None, c=None):
105105
r"""Driving function for 2.5-dimensional NFC-HOA for a virtual point source.
106106
107107
Parameters
@@ -169,7 +169,7 @@ def point_25d(omega, x0, r0, xs, max_order=None, c=None):
169169
return d / (2 * np.pi * r0), selection, secondary_source_point(omega, c)
170170

171171

172-
def plane_25d(omega, x0, r0, n=[0, 1, 0], max_order=None, c=None):
172+
def plane_25d(omega, x0, r0, n=[0, 1, 0], *, max_order=None, c=None):
173173
r"""Driving function for 2.5-dimensional NFC-HOA for a virtual plane wave.
174174
175175
Parameters

sfs/fd/sdm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def plot(d, selection, secondary_source):
3434
from . import secondary_source_line, secondary_source_point
3535

3636

37-
def line_2d(omega, x0, n0, xs, c=None):
37+
def line_2d(omega, x0, n0, xs, *, c=None):
3838
r"""Driving function for 2-dimensional SDM for a virtual line source.
3939
4040
Parameters
@@ -87,7 +87,7 @@ def line_2d(omega, x0, n0, xs, c=None):
8787
return d, selection, secondary_source_line(omega, c)
8888

8989

90-
def plane_2d(omega, x0, n0, n=[0, 1, 0], c=None):
90+
def plane_2d(omega, x0, n0, n=[0, 1, 0], *, c=None):
9191
r"""Driving function for 2-dimensional SDM for a virtual plane wave.
9292
9393
Parameters
@@ -142,7 +142,7 @@ def plane_2d(omega, x0, n0, n=[0, 1, 0], c=None):
142142
return d, selection, secondary_source_line(omega, c)
143143

144144

145-
def plane_25d(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
145+
def plane_25d(omega, x0, n0, n=[0, 1, 0], *, xref=[0, 0, 0], c=None):
146146
r"""Driving function for 2.5-dimensional SDM for a virtual plane wave.
147147
148148
Parameters
@@ -182,7 +182,7 @@ def plane_25d(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
182182
:context: close-figs
183183
184184
d, selection, secondary_source = sfs.fd.sdm.plane_25d(
185-
omega, array.x, array.n, npw, [0, -1, 0])
185+
omega, array.x, array.n, npw, xref=[0, -1, 0])
186186
plot(d, selection, secondary_source)
187187
188188
"""
@@ -197,7 +197,7 @@ def plane_25d(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
197197
return d, selection, secondary_source_point(omega, c)
198198

199199

200-
def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None):
200+
def point_25d(omega, x0, n0, xs, *, xref=[0, 0, 0], c=None):
201201
r"""Driving function for 2.5-dimensional SDM for a virtual point source.
202202
203203
Parameters
@@ -237,7 +237,7 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None):
237237
:context: close-figs
238238
239239
d, selection, secondary_source = sfs.fd.sdm.point_25d(
240-
omega, array.x, array.n, xs, [0, -1, 0])
240+
omega, array.x, array.n, xs, xref=[0, -1, 0])
241241
plot(d, selection, secondary_source)
242242
243243
"""

0 commit comments

Comments
 (0)