|
66 | 66 | "isfinite",
|
67 | 67 | "isinf",
|
68 | 68 | "isnan",
|
| 69 | + "isneginf", |
69 | 70 | "less",
|
70 | 71 | "less_equal",
|
71 | 72 | "logical_and",
|
@@ -710,6 +711,70 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
|
710 | 711 | )
|
711 | 712 |
|
712 | 713 |
|
| 714 | +def isneginf(x, out=None): |
| 715 | + """ |
| 716 | + Test element-wise for negative infinity, return result as bool array. |
| 717 | +
|
| 718 | + For full documentation refer to :obj:`numpy.isneginf`. |
| 719 | +
|
| 720 | + Parameters |
| 721 | + ---------- |
| 722 | + x : {dpnp.ndarray, usm_ndarray} |
| 723 | + Input array. |
| 724 | + out : {None, dpnp.ndarray, usm_ndarray}, optional |
| 725 | + A location into which the result is stored. If provided, it must have a |
| 726 | + shape that the input broadcasts to and a boolean data type. |
| 727 | + If not provided or None, a freshly-allocated boolean array is returned |
| 728 | +
|
| 729 | + Returns |
| 730 | + ------- |
| 731 | + out : dpnp.ndarray |
| 732 | + Boolean array of same shape as ``x``. |
| 733 | +
|
| 734 | + See Also |
| 735 | + -------- |
| 736 | + :obj:`dpnp.isinf` : Test element-wise for positive or negative infinity. |
| 737 | + :obj:`dpnp.isposinf` : Test element-wise for positive infinity, |
| 738 | + return result as bool array. |
| 739 | + :obj:`dpnp.isnan` : Test element-wise for NaN and |
| 740 | + return result as a boolean array. |
| 741 | + :obj:`dpnp.isfinite` : Test element-wise for finiteness. |
| 742 | +
|
| 743 | + Examples |
| 744 | + -------- |
| 745 | + >>> import dpnp as np |
| 746 | + >>> x = np.array(np.inf) |
| 747 | + >>> np.isneginf(-x) |
| 748 | + array(True) |
| 749 | + >>> np.isneginf(x) |
| 750 | + array(False) |
| 751 | +
|
| 752 | + >>> x = np.array([-np.inf, 0., np.inf]) |
| 753 | + >>> np.isneginf(x) |
| 754 | + array([ True, False, False]) |
| 755 | +
|
| 756 | + >>> x = np.array([-np.inf, 0., np.inf]) |
| 757 | + >>> y = np.zeros(x.shape, dtype='bool') |
| 758 | + >>> np.isneginf(x, y) |
| 759 | + array([ True, False, False]) |
| 760 | + >>> y |
| 761 | + array([ True, False, False]) |
| 762 | +
|
| 763 | + """ |
| 764 | + |
| 765 | + is_inf = dpnp.isinf(x) |
| 766 | + try: |
| 767 | + signbit = dpnp.signbit(x) |
| 768 | + except ValueError as e: |
| 769 | + dtype = x.dtype |
| 770 | + raise TypeError( |
| 771 | + f"This operation is not supported for {dtype} values " |
| 772 | + "because it would be ambiguous." |
| 773 | + ) from e |
| 774 | + |
| 775 | + return dpnp.logical_and(is_inf, signbit, out) |
| 776 | + |
| 777 | + |
713 | 778 | _LESS_DOCSTRING = """
|
714 | 779 | Computes the less-than test results for each element `x1_i` of
|
715 | 780 | the input array `x1` with the respective element `x2_i` of the input array `x2`.
|
|
0 commit comments