|
62 | 62 | import dpnp |
63 | 63 | import dpnp.backend.extensions.ufunc._ufunc_impl as ufi |
64 | 64 |
|
65 | | -from .dpnp_algo import dpnp_modf |
66 | 65 | from .dpnp_algo.dpnp_elementwise_common import ( |
67 | 66 | DPNPI0, |
68 | 67 | DPNPAngle, |
|
82 | 81 | resolve_weak_types_2nd_arg_int, |
83 | 82 | ) |
84 | 83 | from .dpnp_array import dpnp_array |
85 | | -from .dpnp_utils import call_origin, get_usm_allocations |
| 84 | +from .dpnp_utils import get_usm_allocations |
86 | 85 | from .dpnp_utils.dpnp_utils_linearalgebra import dpnp_cross |
87 | 86 | from .dpnp_utils.dpnp_utils_reduction import dpnp_wrap_reduction_call |
88 | 87 |
|
@@ -2366,7 +2365,6 @@ def ediff1d(ary, to_end=None, to_begin=None): |
2366 | 2365 | as `x` and the expected data type. |
2367 | 2366 |
|
2368 | 2367 | Default: ``None``. |
2369 | | -
|
2370 | 2368 | out : tuple of None, dpnp.ndarray, or usm_ndarray, optional |
2371 | 2369 | A location into which the result is stored. If provided, it must be a tuple |
2372 | 2370 | and have length equal to the number of outputs. Each provided array must |
@@ -3352,42 +3350,80 @@ def interp(x, xp, fp, left=None, right=None, period=None): |
3352 | 3350 | ) |
3353 | 3351 |
|
3354 | 3352 |
|
3355 | | -def modf(x1, **kwargs): |
3356 | | - """ |
3357 | | - Return the fractional and integral parts of an array, element-wise. |
| 3353 | +_MODF_DOCSTRING = """ |
| 3354 | +Decompose each element :math:`x_i` of the input array `x` into the fractional |
| 3355 | +and the integral parts. |
3358 | 3356 |
|
3359 | | - For full documentation refer to :obj:`numpy.modf`. |
| 3357 | +The fractional and integral parts are negative if the given :math:`x_i` is |
| 3358 | +negative. |
3360 | 3359 |
|
3361 | | - Limitations |
3362 | | - ----------- |
3363 | | - Parameter `x` is supported as :obj:`dpnp.ndarray`. |
3364 | | - Keyword argument `kwargs` is currently unsupported. |
3365 | | - Otherwise the function will be executed sequentially on CPU. |
3366 | | - Input array data types are limited by supported DPNP :ref:`Data types`. |
| 3360 | +Parameters |
| 3361 | +---------- |
| 3362 | +x : {dpnp.ndarray, usm_ndarray} |
| 3363 | + Array of numbers to be decomposed, expected to have a real-valued |
| 3364 | + floating-point data type. |
| 3365 | +out1 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 3366 | + Output array for the fractional parts to populate. Array must have the same |
| 3367 | + shape as `x` and the expected data type. |
3367 | 3368 |
|
3368 | | - Examples |
3369 | | - -------- |
3370 | | - >>> import dpnp as np |
3371 | | - >>> a = np.array([1, 2]) |
3372 | | - >>> result = np.modf(a) |
3373 | | - >>> [[x for x in y] for y in result ] |
3374 | | - [[1.0, 2.0], [0.0, 0.0]] |
| 3369 | + Default: ``None``. |
| 3370 | +out2 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 3371 | + Output array for the integral parts to populate. Array must have the same |
| 3372 | + shape as `x` and the expected data type. |
3375 | 3373 |
|
3376 | | - """ |
| 3374 | + Default: ``None``. |
| 3375 | +out : tuple of None, dpnp.ndarray, or usm_ndarray, optional |
| 3376 | + A location into which the result is stored. If provided, it must be a tuple |
| 3377 | + and have length equal to the number of outputs. Each provided array must |
| 3378 | + have the same shape as `x` and the expected data type. |
| 3379 | + It is prohibited to pass output arrays through `out` keyword when either |
| 3380 | + `out1` or `out2` is passed. |
3377 | 3381 |
|
3378 | | - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) |
3379 | | - if x1_desc: |
3380 | | - if dpnp.is_cuda_backend(x1_desc.get_array()): # pragma: no cover |
3381 | | - raise NotImplementedError( |
3382 | | - "Running on CUDA is currently not supported" |
3383 | | - ) |
| 3382 | + Default: ``(None, None)``. |
| 3383 | +order : {None, "C", "F", "A", "K"}, optional |
| 3384 | + Memory layout of the newly output array, if parameter `out` is ``None``. |
3384 | 3385 |
|
3385 | | - if kwargs: |
3386 | | - pass |
3387 | | - else: |
3388 | | - return dpnp_modf(x1_desc) |
| 3386 | + Default: ``"K"``. |
| 3387 | +
|
| 3388 | +Returns |
| 3389 | +------- |
| 3390 | +y1 : dpnp.ndarray |
| 3391 | + Fractional part of `x`. |
| 3392 | +y2 : dpnp.ndarray |
| 3393 | + Integral part of `x`. |
| 3394 | +
|
| 3395 | +Limitations |
| 3396 | +----------- |
| 3397 | +Parameters `where`, `dtype` and `subok` are supported with their default values. |
| 3398 | +Keyword argument `kwargs` is currently unsupported. |
| 3399 | +Otherwise ``NotImplementedError`` exception will be raised. |
3389 | 3400 |
|
3390 | | - return call_origin(numpy.modf, x1, **kwargs) |
| 3401 | +See Also |
| 3402 | +-------- |
| 3403 | +:obj:`dpnp.divmod` : ``divmod(x, 1)`` is an equivalent to ``modf(x)`` with the |
| 3404 | + return values switched, except it always has a positive remainder. |
| 3405 | +
|
| 3406 | +Notes |
| 3407 | +----- |
| 3408 | +For integer input the return values are floats. |
| 3409 | +
|
| 3410 | +Examples |
| 3411 | +-------- |
| 3412 | +>>> import dpnp as np |
| 3413 | +>>> x = np.array([0, 3.5]) |
| 3414 | +>>> np.modf(x) |
| 3415 | +(array([0. , 0.5]), array([0., 3.])) |
| 3416 | +>>> np.modf(np.array(-0.5)) |
| 3417 | +(array(-0.5), array(-0.)) |
| 3418 | +
|
| 3419 | +""" |
| 3420 | + |
| 3421 | +modf = DPNPUnaryTwoOutputsFunc( |
| 3422 | + "_modf", |
| 3423 | + ufi._modf_result_type, |
| 3424 | + ufi._modf, |
| 3425 | + _MODF_DOCSTRING, |
| 3426 | +) |
3391 | 3427 |
|
3392 | 3428 |
|
3393 | 3429 | _MULTIPLY_DOCSTRING = """ |
|
0 commit comments