File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Original file line number Diff line number Diff line change @@ -319,6 +319,31 @@ was accidental. The old behavior can be retained with
319
319
``structured_to_unstructured(arr[['a']]).squeeze(axis=-1) `` or far more simply,
320
320
``arr['a'] ``.
321
321
322
+ ``clip `` now uses a ufunc under the hood
323
+ ----------------------------------------
324
+ This means that registering clip functions for custom dtypes in C via
325
+ `descr->f->fastclip ` is deprecated - they should use the ufunc registration
326
+ mechanism instead, attaching to the ``np.core.umath.clip `` ufunc.
327
+
328
+ It also means that ``clip `` accepts ``where `` and ``casting `` arguments,
329
+ and can be override with ``__array_ufunc__ ``.
330
+
331
+ A consequence of this change is that some behaviors of the old ``clip `` have
332
+ been deprecated:
333
+
334
+ * Passing ``nan `` to mean "do not clip" as one or both bounds. This didn't work
335
+ in all cases anyway, and can be better handled by passing infinities of the
336
+ appropriate sign.
337
+ * Using "unsafe" casting by default when an ``out `` argument is passed. Using
338
+ ``casting="unsafe" `` explicitly will silence this warning.
339
+
340
+ Additionally, there are some corner cases with behavior changes:
341
+
342
+ * Padding ``max < min `` has changed to be more consistent across dtypes, but
343
+ should not be relied upon.
344
+ * Scalar ``min `` and ``max `` take part in promotion rules like they do in all
345
+ other ufuncs.
346
+
322
347
``__array_interface__ `` offset now works as documented
323
348
------------------------------------------------------
324
349
The interface may use an ``offset `` value that was mistakenly ignored.
Original file line number Diff line number Diff line change 2771
2771
2772
2772
add_newdoc ('numpy.core.multiarray' , 'ndarray' , ('clip' ,
2773
2773
"""
2774
- a.clip(min=None, max=None, out=None)
2774
+ a.clip(min=None, max=None, out=None, **kwargs )
2775
2775
2776
2776
Return an array whose values are limited to ``[min, max]``.
2777
2777
One of max or min must be given.
You can’t perform that action at this time.
0 commit comments