Skip to content

Commit 33f46ee

Browse files
Update logic func docs adding broadcast info
1 parent 72a7c9b commit 33f46ee

File tree

1 file changed

+89
-83
lines changed

1 file changed

+89
-83
lines changed

dpnp/dpnp_iface_logic.py

Lines changed: 89 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,15 @@ def allclose(a, b, rtol=1.0e-5, atol=1.0e-8, equal_nan=False):
192192
193193
Parameters
194194
----------
195-
a : {dpnp.ndarray, usm_ndarray, scalar}
196-
First input array, expected to have numeric data type.
197-
Both inputs `a` and `b` can not be scalars at the same time.
198-
b : {dpnp.ndarray, usm_ndarray, scalar}
199-
Second input array, also expected to have numeric data type.
195+
a, b : {dpnp.ndarray, usm_ndarray, scalar}
196+
Input arrays, expected to have numeric data type.
200197
Both inputs `a` and `b` can not be scalars at the same time.
201198
rtol : {dpnp.ndarray, usm_ndarray, scalar}, optional
202-
The relative tolerance parameter. Default: ``1e-05``.
199+
The relative tolerance parameter.
200+
Default: ``1e-05``.
203201
atol : {dpnp.ndarray, usm_ndarray, scalar}, optional
204-
The absolute tolerance parameter. Default: ``1e-08``.
202+
The absolute tolerance parameter.
203+
Default: ``1e-08``.
205204
equal_nan : bool
206205
Whether to compare ``NaNs`` as equal. If ``True``, ``NaNs`` in `a` will
207206
be considered equal to ``NaNs`` in `b` in the output array.
@@ -213,14 +212,20 @@ def allclose(a, b, rtol=1.0e-5, atol=1.0e-8, equal_nan=False):
213212
A 0-dim array with ``True`` value if the two arrays are equal within
214213
the given tolerance; with ``False`` otherwise.
215214
216-
217215
See Also
218216
--------
219217
:obj:`dpnp.isclose` : Test whether two arrays are element-wise equal.
220218
:obj:`dpnp.all` : Test whether all elements evaluate to True.
221219
:obj:`dpnp.any` : Test whether any element evaluates to True.
222220
:obj:`dpnp.equal` : Return (x1 == x2) element-wise.
223221
222+
Notes
223+
-----
224+
The comparison of `a` and `b` uses standard broadcasting, which
225+
means that `a` and `b` need not have the same shape in order for
226+
``dpnp.allclose(a, b)`` to evaluate to ``True``.
227+
The same is true for :obj:`dpnp.equal` but not :obj:`dpnp.array_equal`.
228+
224229
Examples
225230
--------
226231
>>> import dpnp as np
@@ -348,11 +353,8 @@ def array_equal(a1, a2, equal_nan=False):
348353
349354
Parameters
350355
----------
351-
a1 : {dpnp.ndarray, usm_ndarray, scalar}
352-
First input array.
353-
Both inputs `x1` and `x2` can not be scalars at the same time.
354-
a2 : {dpnp.ndarray, usm_ndarray, scalar}
355-
Second input array.
356+
a1, a2 : {dpnp.ndarray, usm_ndarray, scalar}
357+
Input arrays.
356358
Both inputs `x1` and `x2` can not be scalars at the same time.
357359
equal_nan : bool, optional
358360
Whether to compare ``NaNs`` as equal. If the dtype of `a1` and `a2` is
@@ -473,11 +475,8 @@ def array_equiv(a1, a2):
473475
474476
Parameters
475477
----------
476-
a1 : {dpnp.ndarray, usm_ndarray, scalar}
477-
First input array.
478-
Both inputs `x1` and `x2` can not be scalars at the same time.
479-
a2 : {dpnp.ndarray, usm_ndarray, scalar}
480-
Second input array.
478+
a1, a2 : {dpnp.ndarray, usm_ndarray, scalar}
479+
Input arrays.
481480
Both inputs `x1` and `x2` can not be scalars at the same time.
482481
483482
Returns
@@ -532,15 +531,16 @@ def array_equiv(a1, a2):
532531
533532
Parameters
534533
----------
535-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
536-
First input array, expected to have numeric data type.
537-
Both inputs `x1` and `x2` can not be scalars at the same time.
538-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
539-
Second input array, also expected to have numeric data type.
534+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
535+
Input arrays, expected to have numeric data type.
540536
Both inputs `x1` and `x2` can not be scalars at the same time.
537+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
538+
(which becomes the shape of the output).
541539
out : {None, dpnp.ndarray, usm_ndarray}, optional
542540
Output array to populate.
543-
Array have the correct shape and the expected data type.
541+
Array must have a shape that the inputs broadcast to and
542+
the expected data type.
543+
Default: ``None``.
544544
order : {"C", "F", "A", "K"}, optional
545545
Memory layout of the newly output array, if parameter `out` is ``None``.
546546
Default: ``"K"``.
@@ -603,15 +603,15 @@ def array_equiv(a1, a2):
603603
604604
Parameters
605605
----------
606-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
607-
First input array, expected to have numeric data type.
608-
Both inputs `x1` and `x2` can not be scalars at the same time.
609-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
610-
Second input array, also expected to have numeric data type.
606+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
607+
Input arrays, expected to have numeric data type.
611608
Both inputs `x1` and `x2` can not be scalars at the same time.
609+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
610+
(which becomes the shape of the output).
612611
out : {None, dpnp.ndarray, usm_ndarray}, optional
613612
Output array to populate.
614-
Array must have the correct shape and the expected data type.
613+
Array must have a shape that the inputs broadcast to and
614+
the expected data type.
615615
Default: ``None``.
616616
order : {"C", "F", "A", "K"}, optional
617617
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -669,15 +669,15 @@ def array_equiv(a1, a2):
669669
670670
Parameters
671671
----------
672-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
673-
First input array, expected to have numeric data type.
674-
Both inputs `x1` and `x2` can not be scalars at the same time.
675-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
676-
Second input array, also expected to have numeric data type.
672+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
673+
Input arrays, expected to have numeric data type.
677674
Both inputs `x1` and `x2` can not be scalars at the same time.
675+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
676+
(which becomes the shape of the output).
678677
out : {None, dpnp.ndarray, usm_ndarray}, optional
679678
Output array to populate.
680-
Array must have the correct shape and the expected data type.
679+
Array must have a shape that the inputs broadcast to and
680+
the expected data type.
681681
Default: ``None``.
682682
order : {"C", "F", "A", "K"}, optional
683683
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -746,16 +746,15 @@ def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):
746746
747747
Parameters
748748
----------
749-
a : {dpnp.ndarray, usm_ndarray, scalar}
750-
First input array, expected to have numeric data type.
751-
Both inputs `a` and `b` can not be scalars at the same time.
752-
b : {dpnp.ndarray, usm_ndarray, scalar}
753-
Second input array, also expected to have numeric data type.
749+
a, b : {dpnp.ndarray, usm_ndarray, scalar}
750+
Input arrays to compare, expected to have numeric data type.
754751
Both inputs `a` and `b` can not be scalars at the same time.
755752
rtol : {dpnp.ndarray, usm_ndarray, scalar}, optional
756-
The relative tolerance parameter. Default: ``1e-05``.
753+
The relative tolerance parameter.
754+
Default: ``1e-05``.
757755
atol : {dpnp.ndarray, usm_ndarray, scalar}, optional
758-
The absolute tolerance parameter. Default: ``1e-08``.
756+
The absolute tolerance parameter.
757+
Default: ``1e-08``.
759758
equal_nan : bool
760759
Whether to compare ``NaNs`` as equal. If ``True``, ``NaNs`` in `a` will
761760
be considered equal to ``NaNs`` in `b` in the output array.
@@ -943,7 +942,8 @@ def iscomplexobj(x):
943942
Input array, expected to have numeric data type.
944943
out : {None, dpnp.ndarray, usm_ndarray}, optional
945944
Output array to populate.
946-
Array must have the correct shape and the expected data type.
945+
Array must have a shape that the input broadcast to and
946+
the expected data type.
947947
Default: ``None``.
948948
order : {"C", "F", "A", "K"}, optional
949949
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1073,7 +1073,8 @@ def isfortran(a):
10731073
Input array, expected to have numeric data type.
10741074
out : {None, dpnp.ndarray, usm_ndarray}, optional
10751075
Output array to populate.
1076-
Array must have the correct shape and the expected data type.
1076+
Array must have a shape that the input broadcast to and
1077+
the expected data type.
10771078
Default: ``None``.
10781079
order : {"C", "F", "A", "K"}, optional
10791080
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1127,7 +1128,8 @@ def isfortran(a):
11271128
Input array, expected to have numeric data type.
11281129
out : {None, dpnp.ndarray, usm_ndarray}, optional
11291130
Output array to populate.
1130-
Array must have the correct shape and the expected data type.
1131+
Array must have a shape that the input broadcast to and
1132+
the expected data type.
11311133
Default: ``None``.
11321134
order : {"C", "F", "A", "K"}, optional
11331135
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1440,15 +1442,15 @@ def isscalar(element):
14401442
14411443
Parameters
14421444
----------
1443-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1444-
First input array, expected to have numeric data type.
1445-
Both inputs `x1` and `x2` can not be scalars at the same time.
1446-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1447-
Second input array, also expected to have numeric data type.
1445+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1446+
Input arrays, expected to have numeric data type.
14481447
Both inputs `x1` and `x2` can not be scalars at the same time.
1448+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1449+
(which becomes the shape of the output).
14491450
out : {None, dpnp.ndarray, usm_ndarray}, optional
14501451
Output array to populate.
1451-
Array must have the correct shape and the expected data type.
1452+
Array must have a shape that the inputs broadcast to and
1453+
the expected data type.
14521454
Default: ``None``.
14531455
order : {"C", "F", "A", "K"}, optional
14541456
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1506,15 +1508,15 @@ def isscalar(element):
15061508
15071509
Parameters
15081510
----------
1509-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1510-
First input array, expected to have numeric data type.
1511-
Both inputs `x1` and `x2` can not be scalars at the same time.
1512-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1513-
Second input array, also expected to have numeric data type.
1511+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1512+
Input arrays, expected to have numeric data type.
15141513
Both inputs `x1` and `x2` can not be scalars at the same time.
1514+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1515+
(which becomes the shape of the output).
15151516
out : {None, dpnp.ndarray, usm_ndarray}, optional
15161517
Output array to populate.
1517-
Array must have the correct shape and the expected data type.
1518+
Array must have a shape that the inputs broadcast to and
1519+
the expected data type.
15181520
Default: ``None``.
15191521
order : {"C", "F", "A", "K"}, optional
15201522
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1572,15 +1574,15 @@ def isscalar(element):
15721574
15731575
Parameters
15741576
----------
1575-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1576-
First input array.
1577-
Both inputs `x1` and `x2` can not be scalars at the same time.
1578-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1579-
Second input array.
1577+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1578+
Input arrays, expected to have numeric data type.
15801579
Both inputs `x1` and `x2` can not be scalars at the same time.
1580+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1581+
(which becomes the shape of the output).
15811582
out : {None, dpnp.ndarray, usm_ndarray}, optional
15821583
Output array to populate.
1583-
Array must have the correct shape and the expected data type.
1584+
Array must have a shape that the inputs broadcast to and
1585+
the expected data type.
15841586
Default: ``None``.
15851587
order : {"C", "F", "A", "K"}, optional
15861588
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1590,6 +1592,7 @@ def isscalar(element):
15901592
-------
15911593
out : dpnp.ndarray
15921594
An array containing the element-wise logical AND results.
1595+
The shape is determined by broadcasting.
15931596
15941597
Limitations
15951598
-----------
@@ -1643,7 +1646,8 @@ def isscalar(element):
16431646
Input array.
16441647
out : {None, dpnp.ndarray, usm_ndarray}, optional
16451648
Output array to populate.
1646-
Array must have the correct shape and the expected data type.
1649+
Array must have a shape that the input broadcast to and
1650+
the expected data type.
16471651
Default: ``None``.
16481652
order : {"C", "F", "A", "K"}, optional
16491653
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1693,15 +1697,15 @@ def isscalar(element):
16931697
16941698
Parameters
16951699
----------
1696-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1697-
First input array.
1698-
Both inputs `x1` and `x2` can not be scalars at the same time.
1699-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1700-
Second input array.
1700+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1701+
Input arrays, expected to have numeric data type.
17011702
Both inputs `x1` and `x2` can not be scalars at the same time.
1703+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1704+
(which becomes the shape of the output).
17021705
out : {None, dpnp.ndarray, usm_ndarray}, optional
17031706
Output array to populate.
1704-
Array must have the correct shape and the expected data type.
1707+
Array must have a shape that the inputs broadcast to and
1708+
the expected data type.
17051709
Default: ``None``.
17061710
order : {"C", "F", "A", "K"}, optional
17071711
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1711,6 +1715,7 @@ def isscalar(element):
17111715
-------
17121716
out : dpnp.ndarray
17131717
An array containing the element-wise logical OR results.
1718+
The shape is determined by broadcasting.
17141719
17151720
Limitations
17161721
-----------
@@ -1761,15 +1766,15 @@ def isscalar(element):
17611766
17621767
Parameters
17631768
----------
1764-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1765-
First input array.
1766-
Both inputs `x1` and `x2` can not be scalars at the same time.
1767-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1768-
Second input array.
1769+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1770+
Input arrays, expected to have numeric data type.
17691771
Both inputs `x1` and `x2` can not be scalars at the same time.
1772+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1773+
(which becomes the shape of the output).
17701774
out : {None, dpnp.ndarray, usm_ndarray}, optional
17711775
Output array to populate.
1772-
Array must have the correct shape and the expected data type.
1776+
Array must have a shape that the inputs broadcast to and
1777+
the expected data type.
17731778
Default: ``None``.
17741779
order : {"C", "F", "A", "K"}, optional
17751780
Memory layout of the newly output array, if parameter `out` is ``None``.
@@ -1779,6 +1784,7 @@ def isscalar(element):
17791784
-------
17801785
out : dpnp.ndarray
17811786
An array containing the element-wise logical XOR results.
1787+
The shape is determined by broadcasting.
17821788
17831789
Limitations
17841790
-----------
@@ -1827,15 +1833,15 @@ def isscalar(element):
18271833
18281834
Parameters
18291835
----------
1830-
x1 : {dpnp.ndarray, usm_ndarray, scalar}
1831-
First input array, expected to have numeric data type.
1832-
Both inputs `x1` and `x2` can not be scalars at the same time.
1833-
x2 : {dpnp.ndarray, usm_ndarray, scalar}
1834-
Second input array, also expected to have numeric data type.
1836+
x1, x2 : {dpnp.ndarray, usm_ndarray, scalar}
1837+
Input arrays, expected to have numeric data type.
18351838
Both inputs `x1` and `x2` can not be scalars at the same time.
1839+
If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1840+
(which becomes the shape of the output).
18361841
out : {None, dpnp.ndarray, usm_ndarray}, optional
18371842
Output array to populate.
1838-
Array must have the correct shape and the expected data type.
1843+
Array must have a shape that the inputs broadcast to and
1844+
the expected data type.
18391845
Default: ``None``.
18401846
order : {"C", "F", "A", "K"}, optional
18411847
Memory layout of the newly output array, if parameter `out` is ``None``.

0 commit comments

Comments
 (0)