diff options
author | Max Kellermeier <max.kellermeier@hotmail.de> | 2020-08-20 11:59:52 +0200 |
---|---|---|
committer | Max Kellermeier <max.kellermeier@hotmail.de> | 2020-08-20 11:59:52 +0200 |
commit | 11ae4340173c644768368755bba93ced112b4505 (patch) | |
tree | 4fad48ef6e6ed0647d8020b62b6085854cd89186 /numpy/lib/function_base.py | |
parent | de7aa73c56d8128e3fa5cca1e99ff352fffdf0c5 (diff) | |
download | numpy-11ae4340173c644768368755bba93ced112b4505.tar.gz |
Renamed new argument for unwraping. Extended release note
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3115f7a80..ceea92849 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1482,32 +1482,32 @@ def angle(z, deg=False): return a -def _unwrap_dispatcher(p, discont=None, axis=None, *, interval_size=None): +def _unwrap_dispatcher(p, discont=None, axis=None, *, period=None): return (p,) @array_function_dispatch(_unwrap_dispatcher) -def unwrap(p, discont=None, axis=-1, *, interval_size=2*pi): +def unwrap(p, discont=None, axis=-1, *, period=2*pi): """ Unwrap by changing deltas between values to complement. - For the default case where `interval_size= 2*pi`, `discont=pi`, + For the default case where `period= 2*pi`, `discont=pi`, It unwraps radian phase `p` by changing absolute jumps greater than `discont` to their 2*pi complement along the given axis. Jumps equal to `discont` are not changed. In general it unwrapps a signal `p` by changing absolute jumps - greater than `discont` to their `interval_size` complementary values. + greater than `discont` to their `period` complementary values. Parameters ---------- p : array_like Input array. discont : float, optional - Maximum discontinuity between values, default is ``interval_size/2``. + Maximum discontinuity between values, default is ``period/2``. axis : int, optional Axis along which unwrap will operate, default is the last axis. - interval_size: float, optional + period: float, optional Size of the range over which the input wraps. By default, it is ``2 pi``. Returns @@ -1519,7 +1519,7 @@ def unwrap(p, discont=None, axis=-1, *, interval_size=2*pi): rad2deg, deg2rad Notes ----- - If the discontinuity in `p` is smaller than ``interval_size/2``, + If the discontinuity in `p` is smaller than ``period/2``, but larger than `discont`, no unwrapping is done because taking the complement would only make the discontinuity larger. Examples @@ -1530,14 +1530,14 @@ def unwrap(p, discont=None, axis=-1, *, interval_size=2*pi): array([ 0. , 0.78539816, 1.57079633, 5.49778714, 6.28318531]) # may vary >>> np.unwrap(phase) array([ 0. , 0.78539816, 1.57079633, -0.78539816, 0. ]) # may vary - >>> unwrap([0, 1, 2, -1, 0], interval_size=4) + >>> unwrap([0, 1, 2, -1, 0], period=4) array([0., 1., 2., 3., 4.]) - >>> unwrap([ 1, 2, 3, 4, 5, 6, 1, 2, 3], interval_size=6) + >>> unwrap([ 1, 2, 3, 4, 5, 6, 1, 2, 3], period=6) array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) - >>> unwrap([2, 3, 4, 5, 2, 3, 4, 5], interval_size=4) + >>> unwrap([2, 3, 4, 5, 2, 3, 4, 5], period=4) array([2., 3., 4., 5., 6., 7., 8., 9.]) >>> phase_deg = np.mod(np.linspace(0,720,19), 360) - 180 - >>> unwrap(phase_deg, interval_size=360) + >>> unwrap(phase_deg, period=360) array([-180., -140., -100., -60., -20., 20., 60., 100., 140., 180., 220., 260., 300., 340., 380., 420., 460., 500., 540.]) @@ -1546,14 +1546,14 @@ def unwrap(p, discont=None, axis=-1, *, interval_size=2*pi): nd = p.ndim dd = diff(p, axis=axis) if discont is None: - discont = interval_size/2 + discont = period/2 slice1 = [slice(None, None)]*nd # full slices slice1[axis] = slice(1, None) slice1 = tuple(slice1) - ddmod = mod(dd + interval_size/2, interval_size) - interval_size/2 - # the above line made `ddmod[abs(dd) == interval_size/2] == -interval_size/2`. - # correct these such that `ddmod[abs(dd) == interval_size/2] == sign(dd)*interval_size/2`. - _nx.copyto(ddmod, interval_size/2, where=(ddmod == -interval_size/2) & (dd > 0)) + ddmod = mod(dd + period/2, period) - period/2 + # for `mask = (abs(dd) == period/2)`, the above line made `ddmod[mask] == -period/2`. + # correct these such that `ddmod[mask] == sign(dd[mask])*period/2`. + _nx.copyto(ddmod, period/2, where=(ddmod == -period/2) & (dd > 0)) ph_correct = ddmod - dd _nx.copyto(ph_correct, 0, where=abs(dd) < discont) up = array(p, copy=True, dtype='d') |