Skip to content

Commit 0d282fa

Browse files
authored
fix #747 : renamed a_min and a_max arguments of LArray.clip method as minval and maxval respectively + made them optional
1 parent 42d240e commit 0d282fa

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

doc/source/changes/version_0_30.rst.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ Miscellaneous improvements
218218

219219
* updated the ``Working With Sessions`` section of the tutorial (closes :issue:`568`).
220220

221+
* renamed `a_min` and `a_max` arguments of :py:obj:`LArray.clip()` as `minval` and `maxval` respectively
222+
and made them optional (closes :issue:`747`).
223+
221224

222225
Fixes
223226
-----

larray/core/array.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,34 +6014,68 @@ def transpose(self, *args):
60146014
return LArray(self.data.transpose(axes_indices), self.axes[axes_indices])
60156015
T = property(transpose)
60166016

6017-
def clip(self, a_min, a_max, out=None):
6018-
"""Clip (limit) the values in an array.
6017+
def clip(self, minval=None, maxval=None, out=None):
6018+
r"""Clip (limit) the values in an array.
60196019
60206020
Given an interval, values outside the interval are clipped to the interval edges.
60216021
For example, if an interval of [0, 1] is specified, values smaller than 0 become 0,
60226022
and values larger than 1 become 1.
60236023
60246024
Parameters
60256025
----------
6026-
a_min : scalar or array-like
6027-
Minimum value.
6028-
a_max : scalar or array-like
6029-
Maximum value.
6026+
minval : scalar or array-like, optional
6027+
Minimum value. If None, clipping is not performed on lower interval edge.
6028+
Not more than one of `minval` and `maxval` may be None.
6029+
Defaults to None.
6030+
maxval : scalar or array-like, optional
6031+
Maximum value. If None, clipping is not performed on upper interval edge.
6032+
Not more than one of `minval` and `maxval` may be None.
6033+
Defaults to None.
60306034
out : LArray, optional
60316035
The results will be placed in this array.
60326036
60336037
Returns
60346038
-------
60356039
LArray
60366040
An array with the elements of the current array,
6037-
but where values < `a_min` are replaced with `a_min`, and those > `a_max` with `a_max`.
6041+
but where values < `minval` are replaced with `minval`, and those > `maxval` with `maxval`.
60386042
60396043
Notes
60406044
-----
6041-
If `a_min` and/or `a_max` are array_like, broadcast will occur between self, `a_min` and `a_max`.
6045+
If `minval` and/or `maxval` are array_like, broadcast will occur between self, `minval` and `maxval`.
6046+
6047+
Examples
6048+
--------
6049+
>>> arr = ndtest((3, 3)) - 3
6050+
>>> arr
6051+
a\b b0 b1 b2
6052+
a0 -3 -2 -1
6053+
a1 0 1 2
6054+
a2 3 4 5
6055+
>>> arr.clip(0, 2)
6056+
a\b b0 b1 b2
6057+
a0 0 0 0
6058+
a1 0 1 2
6059+
a2 2 2 2
6060+
6061+
Clipping on lower interval edge only
6062+
6063+
>>> arr.clip(0)
6064+
a\b b0 b1 b2
6065+
a0 0 0 0
6066+
a1 0 1 2
6067+
a2 3 4 5
6068+
6069+
Clipping on upper interval edge only
6070+
6071+
>>> arr.clip(maxval=2)
6072+
a\b b0 b1 b2
6073+
a0 -3 -2 -1
6074+
a1 0 1 2
6075+
a2 2 2 2
60426076
"""
60436077
from larray.core.npufuncs import clip
6044-
return clip(self, a_min, a_max, out)
6078+
return clip(self, minval, maxval, out)
60456079

60466080
@deprecate_kwarg('transpose', 'wide')
60476081
def to_csv(self, filepath, sep=',', na_rep='', wide=True, value_name='value', dropna=None,

0 commit comments

Comments
 (0)