diff options
author | scimax <max.kellermeier@hotmail.de> | 2020-08-21 23:08:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 23:08:14 +0200 |
commit | 8755c7f102363bee2572a08a5d9f83671af7957d (patch) | |
tree | 273dd114e15119679875d92fc1c8a6d12257c7ad /numpy/lib/function_base.py | |
parent | 00dcda244bc1eb58cb3b4f30c7b18a71a8569194 (diff) | |
download | numpy-8755c7f102363bee2572a08a5d9f83671af7957d.tar.gz |
Code cleanup
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 2a942a13a..4f0377efe 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1552,13 +1552,12 @@ def unwrap(p, discont=None, axis=-1, *, period=2*pi): slice1 = tuple(slice1) dtype = np.result_type(dd, period) if _nx.issubdtype(dtype, _nx.integer): - interval_low = -(period // 2) - interval_high = -interval_low - boundary_ambiguous = (period % 2 == 0) + interval_high, rem = divmod(period, 2) + boundary_ambiguous = rem == 0 else: - interval_low = -period / 2 - interval_high = -interval_low + interval_high = period / 2 boundary_ambiguous = True + interval_low = -interval_high ddmod = mod(dd - interval_low, period) + interval_low if boundary_ambiguous: # for `mask = (abs(dd) == period/2)`, the above line made `ddmod[mask] == -period/2`. |