Skip to content

Update docstrings for elementwise functions #2406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
88a9605
Add blank lines prior Default value and description of `include_initial`
antonwolfy Apr 2, 2025
bdf5599
Update docstring of `acos` function to use `math` where applicable.
antonwolfy Apr 2, 2025
790e50c
Replace nan with NaN
antonwolfy Apr 2, 2025
2157258
Use :math:`\pi` where applicable
antonwolfy Apr 2, 2025
1f0f9dd
Use :math:`\infty` where applicable
antonwolfy Apr 2, 2025
6396684
Update docstring of `acosh` function to use math where applicable.
antonwolfy Apr 2, 2025
beb9c1e
Update `See also` in `acos` and `acosh` functions
antonwolfy Apr 2, 2025
9abce32
Update docstring of `asin` and `asinh` function to use math where app…
antonwolfy Apr 2, 2025
4f39caa
Update branch cuts intervals in acos, acosh, asin, and asinh
antonwolfy Apr 2, 2025
bc879bf
Update docstring of `atan`, `atan2`, and `atanh` functions to use mat…
antonwolfy Apr 2, 2025
926c203
Remove unnecessary reruning of tests in testing MKL interfaces GH action
antonwolfy Apr 2, 2025
378d252
Update docstring of `cbrt` function
antonwolfy Apr 2, 2025
335d0f8
Update docstring of `cos` and `cosh` function to use math where appli…
antonwolfy Apr 2, 2025
ef8be1d
Replace `real floating-point` with `real-valued floating-point` per
antonwolfy Apr 2, 2025
870570a
Replace `real-valued` with `real-valued floating-point` per array API…
antonwolfy Apr 2, 2025
be87542
Update docstring of `cumlogsumexp` function
antonwolfy Apr 2, 2025
3e02fbf
Update docstring of `deg2rad`, `rad2deg`, `radians`, and `degrees` fu…
antonwolfy Apr 2, 2025
80b90c3
Update docstring of `exp`, `exp2`, and `expm1` functions to use math …
antonwolfy Apr 2, 2025
bac9deb
Update docstring of `hypot` function to use math where applicable
antonwolfy Apr 3, 2025
0e35d64
Update docstring of `log`, `log10`, `log1p`, and `log2` functions to …
antonwolfy Apr 3, 2025
75dd574
Update docstring of `logaddexp`, `logaddexp2` and `cumlogsumexp` func…
antonwolfy Apr 3, 2025
fc27d3a
Update docstring of `reciprocal`, `rsqrt` and `sqrt` functions to use…
antonwolfy Apr 3, 2025
f7e2d20
Update docstring of `reduce_hypot` function to use math where applicable
antonwolfy Apr 3, 2025
8c3bccb
Update docstring of `sin` and `sinh` functions to use math where appl…
antonwolfy Apr 3, 2025
89d93e6
Update `square`, `tan`, `tanh` and `unwrap` functions to use math whe…
antonwolfy Apr 3, 2025
6a41c48
Rephrase see also link on dpnp.power
antonwolfy Apr 4, 2025
8be126f
Update bitwise functions to add notes and to tune docstrings for inpu…
antonwolfy Apr 7, 2025
b5683ff
Update logic functions to add notes and to tune docstrings for input …
antonwolfy Apr 7, 2025
bb711a1
Update math functions to add notes and to tune docstrings for input a…
antonwolfy Apr 7, 2025
ae17868
Rephrase a case when an input array may have any dtype
antonwolfy Apr 9, 2025
5f34212
Apply review comments
antonwolfy Apr 10, 2025
d0f1b97
Merge branch 'master' into update-trigonometric-docstrings
antonwolfy Apr 10, 2025
0cb520b
Update atan2 docstring with proper use of :math:`\frac{x1}{x2}`
antonwolfy Apr 10, 2025
9dd7d43
Merge branch 'master' into update-trigonometric-docstrings
antonwolfy Apr 10, 2025
8c2afc9
Merge branch 'master' into update-trigonometric-docstrings
antonwolfy Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-mkl-interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
python -c "import dpnp; print(dpnp.__version__)"

- name: Run tests
if: env.rerun-tests-on-failure == 'true'
if: env.rerun-tests-on-failure != 'true'
run: |
python -m pytest -ra --pyargs dpnp.tests
env:
Expand Down
108 changes: 64 additions & 44 deletions dpnp/dpnp_iface_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,17 @@ def binary_repr(num, width=None):

_BITWISE_AND_DOCSTRING = """
Computes the bitwise AND of the underlying binary representation of each
element `x1_i` of the input array `x1` with the respective element `x2_i`
of the input array `x2`.
element :math:`x1_i` of the input array `x1` with the respective element
:math:`x2_i` of the input array `x2`.

For full documentation refer to :obj:`numpy.bitwise_and`.

Parameters
----------
x1 : {dpnp.ndarray, usm_ndarray, scalar}
First input array, expected to have integer or boolean data type.
Both inputs `x1` and `x2` can not be scalars at the same time.
First input array, expected to have an integer or boolean data type.
x2 : {dpnp.ndarray, usm_ndarray, scalar}
Second input array, also expected to have integer or boolean data
type. Both inputs `x1` and `x2` can not be scalars at the same time.
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).
Second input array, also expected to have an integer or boolean data type.
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -175,6 +171,13 @@ def binary_repr(num, width=None):
:obj:`dpnp.binary_repr` : Return the binary representation of the input number
as a string.

Notes
-----
At least one of `x1` or `x2` must be an array.

If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).

Examples
--------
>>> import dpnp as np
Expand Down Expand Up @@ -206,6 +209,7 @@ def binary_repr(num, width=None):
'1100'
>>> np.bitwise_and(np.array([14, 3]), 13)
array([12, 1])

"""

bitwise_and = DPNPBinaryFunc(
Expand All @@ -225,7 +229,7 @@ def binary_repr(num, width=None):
Parameters
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have integer or boolean data type.
Input array, expected to have an integer data type.
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -272,21 +276,17 @@ def binary_repr(num, width=None):

_BITWISE_OR_DOCSTRING = """
Computes the bitwise OR of the underlying binary representation of each
element `x1_i` of the input array `x1` with the respective element `x2_i`
of the input array `x2`.
element :math:`x1_i` of the input array `x1` with the respective element
:math:`x2_i` of the input array `x2`.

For full documentation refer to :obj:`numpy.bitwise_or`.

Parameters
----------
x1 : {dpnp.ndarray, usm_ndarray, scalar}
First input array, expected to have integer or boolean data type.
Both inputs `x1` and `x2` can not be scalars at the same time.
First input array, expected to have an integer or boolean data type.
x2 : {dpnp.ndarray, usm_ndarray, scalar}
Second input array, also expected to have integer or boolean data
type. Both inputs `x1` and `x2` can not be scalars at the same time.
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).
Second input array, also expected to have an integer or boolean data type.
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -317,6 +317,13 @@ def binary_repr(num, width=None):
:obj:`dpnp.binary_repr` : Return the binary representation of the input number
as a string.

Notes
-----
At least one of `x1` or `x2` must be an array.

If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).

Examples
--------
>>> import dpnp as np
Expand All @@ -339,6 +346,7 @@ def binary_repr(num, width=None):
array(29)
>>> np.binary_repr(29)
'11101'

"""

bitwise_or = DPNPBinaryFunc(
Expand All @@ -352,21 +360,17 @@ def binary_repr(num, width=None):

_BITWISE_XOR_DOCSTRING = """
Computes the bitwise XOR of the underlying binary representation of each
element `x1_i` of the input array `x1` with the respective element `x2_i`
of the input array `x2`.
element :math:`x1_i` of the input array `x1` with the respective element
:math:`x2_i` of the input array `x2`.

For full documentation refer to :obj:`numpy.bitwise_xor`.

Parameters
----------
x1 : {dpnp.ndarray, usm_ndarray, scalar}
First input array, expected to have integer or boolean data type.
Both inputs `x1` and `x2` can not be scalars at the same time.
First input array, expected to have an integer or boolean data type.
x2 : {dpnp.ndarray, usm_ndarray, scalar}
Second input array, also expected to have integer or boolean data
type. Both inputs `x1` and `x2` can not be scalars at the same time.
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).
Second input array, also expected to have an integer or boolean data type.
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -397,6 +401,13 @@ def binary_repr(num, width=None):
:obj:`dpnp.binary_repr` : Return the binary representation of the input number
as a string.

Notes
-----
At least one of `x1` or `x2` must be an array.

If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).

Examples
--------
>>> import dpnp as np
Expand All @@ -423,6 +434,7 @@ def binary_repr(num, width=None):
array(28)
>>> np.binary_repr(28)
'11100'

"""

bitwise_xor = DPNPBinaryFunc(
Expand All @@ -435,7 +447,7 @@ def binary_repr(num, width=None):


_INVERT_DOCSTRING = """
Inverts (flips) each bit for each element `x_i` of the input array `x`.
Inverts (flips) each bit for each element :math:`x_i` of the input array `x`.

Note that :obj:`dpnp.bitwise_invert` is an alias of :obj:`dpnp.invert`.

Expand All @@ -444,7 +456,7 @@ def binary_repr(num, width=None):
Parameters
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have integer or boolean data type.
Input array, expected to have an integer or boolean data type.
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -514,9 +526,9 @@ def binary_repr(num, width=None):
bitwise_invert = invert # bitwise_invert is an alias for invert

_LEFT_SHIFT_DOCSTRING = """
Shifts the bits of each element `x1_i` of the input array x1 to the left by
appending `x2_i` (i.e., the respective element in the input array `x2`) zeros to
the right of `x1_i`.
Shifts the bits of each element :math:`x1_i` of the input array `x1` to the
left by appending :math:`x2_i` (i.e., the respective element in the input array
`x2`) zeros to the right of :math:`x1_i`.

Note that :obj:`dpnp.bitwise_left_shift` is an alias of :obj:`dpnp.left_shift`.

Expand All @@ -525,14 +537,10 @@ def binary_repr(num, width=None):
Parameters
----------
x1 : {dpnp.ndarray, usm_ndarray, scalar}
First input array, expected to have integer data type.
Both inputs `x1` and `x2` can not be scalars at the same time.
First input array, expected to have an integer data type.
x2 : {dpnp.ndarray, usm_ndarray, scalar}
Second input array, also expected to have integer data type.
Second input array, also expected to have an integer data type.
Each element must be greater than or equal to ``0``.
Both inputs `x1` and `x2` can not be scalars at the same time.
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -560,6 +568,13 @@ def binary_repr(num, width=None):
:obj:`dpnp.binary_repr` : Return the binary representation of the input number
as a string.

Notes
-----
At least one of `x1` or `x2` must be an array.

If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).

Examples
--------
>>> import dpnp as np
Expand All @@ -580,6 +595,7 @@ def binary_repr(num, width=None):
array(20)
>>> np.binary_repr(20)
'10100'

"""

left_shift = DPNPBinaryFunc(
Expand All @@ -594,8 +610,8 @@ def binary_repr(num, width=None):


_RIGHT_SHIFT_DOCSTRING = """
Shifts the bits of each element `x1_i` of the input array `x1` to the right
according to the respective element `x2_i` of the input array `x2`.
Shifts the bits of each element :math:`x1_i` of the input array `x1` to the
right according to the respective element :math:`x2_i` of the input array `x2`.

Note that :obj:`dpnp.bitwise_right_shift` is an alias of :obj:`dpnp.right_shift`.

Expand All @@ -604,14 +620,10 @@ def binary_repr(num, width=None):
Parameters
----------
x1 : {dpnp.ndarray, usm_ndarray, scalar}
First input array, expected to have integer data type.
Both inputs `x1` and `x2` can not be scalars at the same time.
First input array, expected to have an integer data type.
x2 : {dpnp.ndarray, usm_ndarray, scalar}
Second input array, also expected to have integer data type.
Second input array, also expected to have an integer data type.
Each element must be greater than or equal to ``0``.
Both inputs `x1` and `x2` can not be scalars at the same time.
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
Expand Down Expand Up @@ -640,6 +652,13 @@ def binary_repr(num, width=None):
:obj:`dpnp.binary_repr` : Return the binary representation of the input number
as a string.

Notes
-----
At least one of `x1` or `x2` must be an array.

If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
(which becomes the shape of the output).

Examples
--------
>>> import dpnp as np
Expand All @@ -660,6 +679,7 @@ def binary_repr(num, width=None):
array(5)
>>> np.binary_repr(5)
'101'

"""

right_shift = DPNPBinaryFunc(
Expand Down
6 changes: 3 additions & 3 deletions dpnp/dpnp_iface_linearalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def inner(a, b):

See Also
--------
:obj:`dpnp.einsum` : Einstein summation convention..
:obj:`dpnp.einsum` : Einstein summation convention.
:obj:`dpnp.dot` : Generalized matrix product,
using second last dimension of `b`.
:obj:`dpnp.tensordot` : Sum products over arbitrary axes.
Expand Down Expand Up @@ -998,7 +998,7 @@ def matvec(

See Also
--------
:obj:`dpnp.vecdot` : Vector-vector product..
:obj:`dpnp.vecdot` : Vector-vector product.
:obj:`dpnp.vecmat` : Vector-matrix product.
:obj:`dpnp.matmul` : Matrix-matrix product.
:obj:`dpnp.einsum` : Einstein summation convention.
Expand Down Expand Up @@ -1502,7 +1502,7 @@ def vecmat(

See Also
--------
:obj:`dpnp.vecdot` : Vector-vector product..
:obj:`dpnp.vecdot` : Vector-vector product.
:obj:`dpnp.matvec` : Matrix-vector product.
:obj:`dpnp.matmul` : Matrix-matrix product.
:obj:`dpnp.einsum` : Einstein summation convention.
Expand Down
Loading
Loading