Skip to content

Commit 9fd1bbf

Browse files
committed
MAINT: Remove atol and rtol from trim_zeros
It's easy to emulate this behavior by assigning zeros appropriately beforehand.
1 parent 571348e commit 9fd1bbf

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

numpy/lib/function_base.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,28 +1557,12 @@ def sort_complex(a):
15571557
return b
15581558

15591559

1560-
def _trim_zeros(
1561-
filt,
1562-
trim=None,
1563-
axis=None,
1564-
*,
1565-
atol=None,
1566-
rtol=None,
1567-
return_lengths=None
1568-
):
1560+
def _trim_zeros(filt, trim=None, axis=None, *, return_lengths=None):
15691561
return (filt,)
15701562

15711563

15721564
@array_function_dispatch(_trim_zeros)
1573-
def trim_zeros(
1574-
filt,
1575-
trim='fb',
1576-
axis=-1,
1577-
*,
1578-
atol=0,
1579-
rtol=0,
1580-
return_lengths=False
1581-
):
1565+
def trim_zeros(filt, trim='fb', axis=-1, *, return_lengths=False):
15821566
"""Remove values along a dimension which are zero along all other.
15831567
15841568
Parameters
@@ -1590,10 +1574,6 @@ def trim_zeros(
15901574
back. By default, zeros are trimmed from the front and back.
15911575
axis : int or sequence, optional
15921576
The axis or a sequence of axes to trim. If None all axes are trimmed.
1593-
atol : float, optional
1594-
Absolute tolerance with which a value is considered for trimming.
1595-
rtol : float, optional
1596-
Relative tolerance with which a value is considered for trimming.
15971577
return_lengths : bool, optional
15981578
Additionally return the number of trimmed samples in each dimension at
15991579
the front and back.
@@ -1629,12 +1609,7 @@ def trim_zeros(
16291609
trim = trim.lower()
16301610

16311611
absolutes = np.abs(filt)
1632-
if atol > 0:
1633-
absolutes[absolutes <= atol] = 0
1634-
if rtol > 0:
1635-
absolutes[absolutes <= rtol * absolutes.max()] = 0
16361612
nonzero = np.nonzero(absolutes)
1637-
16381613
lengths = np.zeros((absolutes.ndim, 2), dtype=np.intp)
16391614

16401615
if axis is None:

0 commit comments

Comments
 (0)