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