|
65 | 65 | DPNPAngle, |
66 | 66 | DPNPBinaryFunc, |
67 | 67 | DPNPBinaryFuncOutKw, |
| 68 | + DPNPBinaryTwoOutputsFunc, |
68 | 69 | DPNPFix, |
69 | 70 | DPNPImag, |
70 | 71 | DPNPReal, |
@@ -1564,6 +1565,100 @@ def diff(a, n=1, axis=-1, prepend=None, append=None): |
1564 | 1565 | ) |
1565 | 1566 |
|
1566 | 1567 |
|
| 1568 | +_DIVMOD_DOCSTRING = r""" |
| 1569 | +Calculates the quotient and the remainder for each element :math:`x1_i` of the |
| 1570 | +input array `x1` with the respective element :math:`x2_i` of the input array |
| 1571 | +`x2`. |
| 1572 | +
|
| 1573 | +For full documentation refer to :obj:`numpy.divmod`. |
| 1574 | +
|
| 1575 | +Parameters |
| 1576 | +---------- |
| 1577 | +x1 : {dpnp.ndarray, usm_ndarray} |
| 1578 | + Dividend input array, expected to have a real-valued floating-point data |
| 1579 | + type. |
| 1580 | +x2 : {dpnp.ndarray, usm_ndarray} |
| 1581 | + Divisor input array, expected to have a real-valued floating-point data |
| 1582 | + type. |
| 1583 | +out1 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 1584 | + Output array for the quotient to populate. Array must have the same shape |
| 1585 | + as `x` and the expected data type. |
| 1586 | +
|
| 1587 | + Default: ``None``. |
| 1588 | +out2 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 1589 | + Output array for the remainder to populate. Array must have the same shape |
| 1590 | + as `x` and the expected data type. |
| 1591 | +
|
| 1592 | + Default: ``None``. |
| 1593 | +out : tuple of None, dpnp.ndarray, or usm_ndarray, optional |
| 1594 | + A location into which the result is stored. If provided, it must be a tuple |
| 1595 | + and have length equal to the number of outputs. Each provided array must |
| 1596 | + have the same shape as `x` and the expected data type. |
| 1597 | + It is prohibited to pass output arrays through `out` keyword when either |
| 1598 | + `out1` or `out2` is passed. |
| 1599 | +
|
| 1600 | + Default: ``(None, None)``. |
| 1601 | +order : {None, "C", "F", "A", "K"}, optional |
| 1602 | + Memory layout of the newly output array, if parameter `out` is ``None``. |
| 1603 | +
|
| 1604 | + Default: ``"K"``. |
| 1605 | +
|
| 1606 | +Returns |
| 1607 | +------- |
| 1608 | +quotient : dpnp.ndarray |
| 1609 | + Element-wise quotient resulting from floor division. |
| 1610 | +remainder : dpnp.ndarray |
| 1611 | + Element-wise remainder from floor division. |
| 1612 | +
|
| 1613 | +Limitations |
| 1614 | +----------- |
| 1615 | +Parameters `where`, `dtype` and `subok` are supported with their default values. |
| 1616 | +Keyword argument `kwargs` is currently unsupported. |
| 1617 | +Otherwise ``NotImplementedError`` exception will be raised. |
| 1618 | +
|
| 1619 | +Notes |
| 1620 | +----- |
| 1621 | +At least one of `x1` or `x2` must be an array. |
| 1622 | +
|
| 1623 | +If ``x1.shape != x2.shape``, they must be broadcastable to a common shape |
| 1624 | +(which becomes the shape of the output). |
| 1625 | +
|
| 1626 | +Equivalent to :math:`(x1 // x2, x1 \% x2)`, but faster because it avoids |
| 1627 | +redundant work. It is used to implement the Python built-in function ``divmod`` |
| 1628 | +on :class:`dpnp.ndarray`. |
| 1629 | +
|
| 1630 | +Complex dtypes are not supported, they will raise a ``TypeError``. |
| 1631 | +
|
| 1632 | +See Also |
| 1633 | +-------- |
| 1634 | +:obj:`dpnp.floor_divide` : Equivalent to Python's :math:`//` operator. |
| 1635 | +:obj:`dpnp.remainder` : Equivalent to Python's :math:`\%` operator. |
| 1636 | +:obj:`dpnp.modf` : Equivalent to ``divmod(x, 1)`` for positive `x` with the |
| 1637 | + return values switched. |
| 1638 | +
|
| 1639 | +Examples |
| 1640 | +-------- |
| 1641 | +>>> import dpnp as np |
| 1642 | +>>> np.divmod(np.arange(5), 3) |
| 1643 | +(array([0, 0, 0, 1, 1]), array([0, 1, 2, 0, 1])) |
| 1644 | +
|
| 1645 | +The Python built-in function ``divmod`` function can be used as a shorthand for |
| 1646 | +``np.divmod`` on :class:`dpnp.ndarray`. |
| 1647 | +
|
| 1648 | +>>> x = np.arange(5) |
| 1649 | +>>> divmod(x, 3) |
| 1650 | +(array([0, 0, 0, 1, 1]), array([0, 1, 2, 0, 1])) |
| 1651 | +
|
| 1652 | +""" |
| 1653 | + |
| 1654 | +divmod = DPNPBinaryTwoOutputsFunc( |
| 1655 | + "divmod", |
| 1656 | + ufi._divmod_result_type, |
| 1657 | + ufi._divmod, |
| 1658 | + _DIVMOD_DOCSTRING, |
| 1659 | +) |
| 1660 | + |
| 1661 | + |
1567 | 1662 | def ediff1d(ary, to_end=None, to_begin=None): |
1568 | 1663 | """ |
1569 | 1664 | The differences between consecutive elements of an array. |
@@ -1999,6 +2094,7 @@ def ediff1d(ary, to_end=None, to_begin=None): |
1999 | 2094 | See Also |
2000 | 2095 | -------- |
2001 | 2096 | :obj:`dpnp.remainder` : Remainder complementary to floor_divide. |
| 2097 | +:obj:`dpnp.divmod` : Simultaneous floor division and remainder. |
2002 | 2098 | :obj:`dpnp.divide` : Standard division. |
2003 | 2099 | :obj:`dpnp.floor` : Round a number to the nearest integer toward minus infinity. |
2004 | 2100 | :obj:`dpnp.ceil` : Round a number to the nearest integer toward infinity. |
@@ -2379,7 +2475,7 @@ def ediff1d(ary, to_end=None, to_begin=None): |
2379 | 2475 | """ |
2380 | 2476 |
|
2381 | 2477 | frexp = DPNPUnaryTwoOutputsFunc( |
2382 | | - "_frexp", |
| 2478 | + "frexp", |
2383 | 2479 | ufi._frexp_result_type, |
2384 | 2480 | ufi._frexp, |
2385 | 2481 | _FREXP_DOCSTRING, |
@@ -3141,7 +3237,7 @@ def interp(x, xp, fp, left=None, right=None, period=None): |
3141 | 3237 | """ |
3142 | 3238 |
|
3143 | 3239 | ldexp = DPNPBinaryFunc( |
3144 | | - "_ldexp", |
| 3240 | + "ldexp", |
3145 | 3241 | ufi._ldexp_result_type, |
3146 | 3242 | ufi._ldexp, |
3147 | 3243 | _LDEXP_DOCSTRING, |
@@ -3421,7 +3517,7 @@ def interp(x, xp, fp, left=None, right=None, period=None): |
3421 | 3517 | """ |
3422 | 3518 |
|
3423 | 3519 | modf = DPNPUnaryTwoOutputsFunc( |
3424 | | - "_modf", |
| 3520 | + "modf", |
3425 | 3521 | ufi._modf_result_type, |
3426 | 3522 | ufi._modf, |
3427 | 3523 | _MODF_DOCSTRING, |
@@ -4278,6 +4374,7 @@ def real_if_close(a, tol=100): |
4278 | 4374 | See Also |
4279 | 4375 | -------- |
4280 | 4376 | :obj:`dpnp.fmod` : Calculate the element-wise remainder of division. |
| 4377 | +:obj:`dpnp.divmod` : Simultaneous floor division and remainder. |
4281 | 4378 | :obj:`dpnp.divide` : Standard division. |
4282 | 4379 | :obj:`dpnp.floor` : Round a number to the nearest integer toward minus infinity. |
4283 | 4380 | :obj:`dpnp.floor_divide` : Compute the largest integer smaller or equal to the |
|
0 commit comments