Skip to content

Commit b958f0f

Browse files
Update dpnp.fix by reusing trunc and align docs with NumPy
1 parent 290ab65 commit b958f0f

1 file changed

Lines changed: 43 additions & 53 deletions

File tree

dpnp/dpnp_iface_mathematical.py

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
DPNPBinaryFunc,
6767
DPNPBinaryFuncOutKw,
6868
DPNPBinaryTwoOutputsFunc,
69-
DPNPFix,
7069
DPNPImag,
7170
DPNPReal,
7271
DPNPRound,
@@ -1813,66 +1812,57 @@ def ediff1d(ary, to_end=None, to_begin=None):
18131812
)
18141813

18151814

1816-
_FIX_DOCSTRING = """
1817-
Round to nearest integer towards zero.
1818-
1819-
Round an array of floats element-wise to nearest integer towards zero.
1820-
The rounded values have the same data-type as the input.
1821-
1822-
For full documentation refer to :obj:`numpy.fix`.
1815+
def fix(x, out=None):
1816+
"""
1817+
Round to nearest integer towards zero.
18231818
1824-
Parameters
1825-
----------
1826-
x : {dpnp.ndarray, usm_ndarray}
1827-
Input array, expected to have a boolean or real-valued data type.
1828-
out : {None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional
1829-
Output array to populate.
1830-
Array must have the correct shape and the expected data type.
1831-
A tuple (possible only as a keyword argument) must have length equal to the
1832-
number of outputs.
1819+
Round an array of floats element-wise to nearest integer towards zero.
1820+
The rounded values have the same data-type as the input.
18331821
1834-
Default: ``None``.
1835-
order : {None, "C", "F", "A", "K"}, optional
1836-
Memory layout of the newly output array, if parameter `out` is ``None``.
1822+
For full documentation refer to :obj:`numpy.fix`.
18371823
1838-
Default: ``"K"``.
1824+
Parameters
1825+
----------
1826+
x : {dpnp.ndarray, usm_ndarray}
1827+
Input array, expected to have a boolean or real-valued data type.
1828+
out : {None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional
1829+
Output array to populate.
1830+
Array must have the correct shape and the expected data type.
1831+
A tuple (possible only as a keyword argument) must have length equal to
1832+
the number of outputs.
18391833
1840-
Returns
1841-
-------
1842-
out : dpnp.ndarray
1843-
An array with the same dimensions and data-type as the input.
1844-
If `out` is ``None`` then a new array is returned
1845-
with the rounded values.
1846-
Otherwise the result is stored there and the return value `out` is
1847-
a reference to that array.
1834+
Default: ``None``.
18481835
1849-
See Also
1850-
--------
1851-
:obj:`dpnp.round` : Round to given number of decimals.
1852-
:obj:`dpnp.rint` : Round elements of the array to the nearest integer.
1853-
:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise.
1854-
:obj:`dpnp.floor` : Return the floor of the input, element-wise.
1855-
:obj:`dpnp.ceil` : Return the ceiling of the input, element-wise.
1836+
Returns
1837+
-------
1838+
out : dpnp.ndarray
1839+
An array with the same dimensions and data-type as the input.
1840+
If `out` is ``None`` then a new array is returned
1841+
with the rounded values.
1842+
Otherwise the result is stored there and the return value `out` is
1843+
a reference to that array.
18561844
1857-
Examples
1858-
--------
1859-
>>> import dpnp as np
1860-
>>> np.fix(np.array(3.14))
1861-
array(3.)
1862-
>>> np.fix(np.array(3))
1863-
array(3.)
1864-
>>> a = np.array([2.1, 2.9, -2.1, -2.9])
1865-
>>> np.fix(a)
1866-
array([ 2., 2., -2., -2.])
1845+
See Also
1846+
--------
1847+
:obj:`dpnp.round` : Round to given number of decimals.
1848+
:obj:`dpnp.rint` : Round elements of the array to the nearest integer.
1849+
:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise.
1850+
:obj:`dpnp.floor` : Return the floor of the input, element-wise.
1851+
:obj:`dpnp.ceil` : Return the ceiling of the input, element-wise.
18671852
1868-
"""
1853+
Examples
1854+
--------
1855+
>>> import dpnp as np
1856+
>>> np.fix(np.array(3.14))
1857+
array(3.)
1858+
>>> np.fix(np.array(3))
1859+
array(3.)
1860+
>>> a = np.array([2.1, 2.9, -2.1, -2.9])
1861+
>>> np.fix(a)
1862+
array([ 2., 2., -2., -2.])
1863+
"""
18691864

1870-
fix = DPNPFix(
1871-
"fix",
1872-
ufi._fix_result_type,
1873-
ufi._fix,
1874-
_FIX_DOCSTRING,
1875-
)
1865+
return trunc(x, out=out)
18761866

18771867

18781868
_FLOAT_POWER_DOCSTRING = """

0 commit comments

Comments
 (0)