Skip to content

Commit 83a0c30

Browse files
committed
Add citation to wsint, remove empty line, add 'the' in docstrings
1 parent f737a13 commit 83a0c30

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/diffpy/utils/resampler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def wsinterp(x, xp, fp, left=None, right=None):
2424
Reconstruct a continuous signal from discrete data points by utilizing sinc functions
2525
as interpolation kernels. This function interpolates the values of fp (array),
2626
which are defined over xp (array), at new points x (array or float).
27+
The implementation is based on E. T. Whittaker's 1915 paper (https://doi.org/10.1017/S0370164600017806).
2728
2829
Parameters
2930
----------
@@ -32,7 +33,7 @@ def wsinterp(x, xp, fp, left=None, right=None):
3233
xp: ndarray
3334
The array of known x values.
3435
fp: ndarray
35-
The array of y values associated xp.
36+
The array of y values associated with xp.
3637
left: float
3738
If given, set fp for x < xp[0] to left. Otherwise, if left is None (default) or not given,
3839
set fp for x < xp[0] to fp evaluated at xp[-1].
@@ -43,7 +44,7 @@ def wsinterp(x, xp, fp, left=None, right=None):
4344
Returns
4445
-------
4546
ndarray or float
46-
Interpolated values at points x. Returns a single float if x is a scalar,
47+
The interpolated values at points x. Returns a single float if x is a scalar,
4748
otherwise returns a numpy.ndarray.
4849
"""
4950
scalar = np.isscalar(x)

tests/test_resample.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@ def test_wsinterp():
1818
x = np.array([i * ssr for i in range(-n - 1, n + 2, 1)])
1919
assert len(xp) == 11 and len(x) == 13
2020

21-
# Generating fp values across 10 trial runs
21+
# Generating a new set of fp values across 10 trial runs
2222
trials = 10
2323

2424
for _ in range(trials):
2525
# Create random function values (fp) at the points defined in xp above
2626
fp = np.array([random.random() * ssr for _ in range(-n, n + 1, 1)])
27-
28-
# Interpolate the values at new x points
2927
fp_at_x = wsinterp(x, xp, fp)
3028

3129
# Check that the known points are unchanged by interpolation
3230
assert np.allclose(fp_at_x[1:-1], fp)
3331
for i in range(len(x)):
3432
assert fp_at_x[i] == pytest.approx(wsinterp(x[i], xp, fp))
35-
36-
37-
if __name__ == "__main__":
38-
test_wsinterp()

0 commit comments

Comments
 (0)