Skip to content

Commit be1ee6c

Browse files
committed
Update signatures from the latest version of the array API spec
1 parent 96f40fe commit be1ee6c

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

numpy/_array_api/_array_object.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __abs__(self: array, /) -> array:
150150
return self.__class__._new(res)
151151

152152
@np.errstate(all='ignore')
153-
def __add__(self: array, other: array, /) -> array:
153+
def __add__(self: array, other: Union[int, float, array], /) -> array:
154154
"""
155155
Performs the operation __add__.
156156
"""
@@ -160,7 +160,7 @@ def __add__(self: array, other: array, /) -> array:
160160
res = self._array.__add__(other._array)
161161
return self.__class__._new(res)
162162

163-
def __and__(self: array, other: array, /) -> array:
163+
def __and__(self: array, other: Union[int, bool, array], /) -> array:
164164
"""
165165
Performs the operation __and__.
166166
"""
@@ -201,7 +201,7 @@ def __dlpack_device__(self: array, /) -> Tuple[IntEnum, int]:
201201
res = self._array.__dlpack_device__()
202202
return self.__class__._new(res)
203203

204-
def __eq__(self: array, other: array, /) -> array:
204+
def __eq__(self: array, other: Union[int, float, bool, array], /) -> array:
205205
"""
206206
Performs the operation __eq__.
207207
"""
@@ -222,7 +222,7 @@ def __float__(self: array, /) -> float:
222222
return res
223223

224224
@np.errstate(all='ignore')
225-
def __floordiv__(self: array, other: array, /) -> array:
225+
def __floordiv__(self: array, other: Union[int, float, array], /) -> array:
226226
"""
227227
Performs the operation __floordiv__.
228228
"""
@@ -232,7 +232,7 @@ def __floordiv__(self: array, other: array, /) -> array:
232232
res = self._array.__floordiv__(other._array)
233233
return self.__class__._new(res)
234234

235-
def __ge__(self: array, other: array, /) -> array:
235+
def __ge__(self: array, other: Union[int, float, array], /) -> array:
236236
"""
237237
Performs the operation __ge__.
238238
"""
@@ -359,7 +359,7 @@ def __getitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, s
359359
res = self._array.__getitem__(key)
360360
return self.__class__._new(res)
361361

362-
def __gt__(self: array, other: array, /) -> array:
362+
def __gt__(self: array, other: Union[int, float, array], /) -> array:
363363
"""
364364
Performs the operation __gt__.
365365
"""
@@ -386,7 +386,7 @@ def __invert__(self: array, /) -> array:
386386
res = self._array.__invert__()
387387
return self.__class__._new(res)
388388

389-
def __le__(self: array, other: array, /) -> array:
389+
def __le__(self: array, other: Union[int, float, array], /) -> array:
390390
"""
391391
Performs the operation __le__.
392392
"""
@@ -403,7 +403,7 @@ def __len__(self, /):
403403
res = self._array.__len__()
404404
return self.__class__._new(res)
405405

406-
def __lshift__(self: array, other: array, /) -> array:
406+
def __lshift__(self: array, other: Union[int, array], /) -> array:
407407
"""
408408
Performs the operation __lshift__.
409409
"""
@@ -416,7 +416,7 @@ def __lshift__(self: array, other: array, /) -> array:
416416
res = self._array.__lshift__(other._array).astype(self.dtype)
417417
return self.__class__._new(res)
418418

419-
def __lt__(self: array, other: array, /) -> array:
419+
def __lt__(self: array, other: Union[int, float, array], /) -> array:
420420
"""
421421
Performs the operation __lt__.
422422
"""
@@ -438,7 +438,7 @@ def __matmul__(self: array, other: array, /) -> array:
438438
return self.__class__._new(res)
439439

440440
@np.errstate(all='ignore')
441-
def __mod__(self: array, other: array, /) -> array:
441+
def __mod__(self: array, other: Union[int, float, array], /) -> array:
442442
"""
443443
Performs the operation __mod__.
444444
"""
@@ -449,7 +449,7 @@ def __mod__(self: array, other: array, /) -> array:
449449
return self.__class__._new(res)
450450

451451
@np.errstate(all='ignore')
452-
def __mul__(self: array, other: array, /) -> array:
452+
def __mul__(self: array, other: Union[int, float, array], /) -> array:
453453
"""
454454
Performs the operation __mul__.
455455
"""
@@ -459,7 +459,7 @@ def __mul__(self: array, other: array, /) -> array:
459459
res = self._array.__mul__(other._array)
460460
return self.__class__._new(res)
461461

462-
def __ne__(self: array, other: array, /) -> array:
462+
def __ne__(self: array, other: Union[int, float, bool, array], /) -> array:
463463
"""
464464
Performs the operation __ne__.
465465
"""
@@ -476,7 +476,7 @@ def __neg__(self: array, /) -> array:
476476
res = self._array.__neg__()
477477
return self.__class__._new(res)
478478

479-
def __or__(self: array, other: array, /) -> array:
479+
def __or__(self: array, other: Union[int, bool, array], /) -> array:
480480
"""
481481
Performs the operation __or__.
482482
"""
@@ -494,7 +494,7 @@ def __pos__(self: array, /) -> array:
494494
return self.__class__._new(res)
495495

496496
@np.errstate(all='ignore')
497-
def __pow__(self: array, other: array, /) -> array:
497+
def __pow__(self: array, other: Union[int, float, array], /) -> array:
498498
"""
499499
Performs the operation __pow__.
500500
"""
@@ -506,7 +506,7 @@ def __pow__(self: array, other: array, /) -> array:
506506
# arrays, so we use pow() here instead.
507507
return pow(self, other)
508508

509-
def __rshift__(self: array, other: array, /) -> array:
509+
def __rshift__(self: array, other: Union[int, array], /) -> array:
510510
"""
511511
Performs the operation __rshift__.
512512
"""
@@ -530,7 +530,7 @@ def __setitem__(self, key, value, /):
530530
return self.__class__._new(res)
531531

532532
@np.errstate(all='ignore')
533-
def __sub__(self: array, other: array, /) -> array:
533+
def __sub__(self: array, other: Union[int, float, array], /) -> array:
534534
"""
535535
Performs the operation __sub__.
536536
"""
@@ -541,7 +541,7 @@ def __sub__(self: array, other: array, /) -> array:
541541
return self.__class__._new(res)
542542

543543
@np.errstate(all='ignore')
544-
def __truediv__(self: array, other: array, /) -> array:
544+
def __truediv__(self: array, other: Union[int, float, array], /) -> array:
545545
"""
546546
Performs the operation __truediv__.
547547
"""
@@ -551,7 +551,7 @@ def __truediv__(self: array, other: array, /) -> array:
551551
res = self._array.__truediv__(other._array)
552552
return self.__class__._new(res)
553553

554-
def __xor__(self: array, other: array, /) -> array:
554+
def __xor__(self: array, other: Union[int, bool, array], /) -> array:
555555
"""
556556
Performs the operation __xor__.
557557
"""
@@ -562,7 +562,7 @@ def __xor__(self: array, other: array, /) -> array:
562562
return self.__class__._new(res)
563563

564564
@np.errstate(all='ignore')
565-
def __iadd__(self: array, other: array, /) -> array:
565+
def __iadd__(self: array, other: Union[int, float, array], /) -> array:
566566
"""
567567
Performs the operation __iadd__.
568568
"""
@@ -574,7 +574,7 @@ def __iadd__(self: array, other: array, /) -> array:
574574
return self.__class__._new(res)
575575

576576
@np.errstate(all='ignore')
577-
def __radd__(self: array, other: array, /) -> array:
577+
def __radd__(self: array, other: Union[int, float, array], /) -> array:
578578
"""
579579
Performs the operation __radd__.
580580
"""
@@ -584,7 +584,7 @@ def __radd__(self: array, other: array, /) -> array:
584584
res = self._array.__radd__(other._array)
585585
return self.__class__._new(res)
586586

587-
def __iand__(self: array, other: array, /) -> array:
587+
def __iand__(self: array, other: Union[int, bool, array], /) -> array:
588588
"""
589589
Performs the operation __iand__.
590590
"""
@@ -593,7 +593,7 @@ def __iand__(self: array, other: array, /) -> array:
593593
res = self._array.__iand__(other._array)
594594
return self.__class__._new(res)
595595

596-
def __rand__(self: array, other: array, /) -> array:
596+
def __rand__(self: array, other: Union[int, bool, array], /) -> array:
597597
"""
598598
Performs the operation __rand__.
599599
"""
@@ -604,7 +604,7 @@ def __rand__(self: array, other: array, /) -> array:
604604
return self.__class__._new(res)
605605

606606
@np.errstate(all='ignore')
607-
def __ifloordiv__(self: array, other: array, /) -> array:
607+
def __ifloordiv__(self: array, other: Union[int, float, array], /) -> array:
608608
"""
609609
Performs the operation __ifloordiv__.
610610
"""
@@ -614,7 +614,7 @@ def __ifloordiv__(self: array, other: array, /) -> array:
614614
return self.__class__._new(res)
615615

616616
@np.errstate(all='ignore')
617-
def __rfloordiv__(self: array, other: array, /) -> array:
617+
def __rfloordiv__(self: array, other: Union[int, float, array], /) -> array:
618618
"""
619619
Performs the operation __rfloordiv__.
620620
"""
@@ -624,7 +624,7 @@ def __rfloordiv__(self: array, other: array, /) -> array:
624624
res = self._array.__rfloordiv__(other._array)
625625
return self.__class__._new(res)
626626

627-
def __ilshift__(self: array, other: array, /) -> array:
627+
def __ilshift__(self: array, other: Union[int, array], /) -> array:
628628
"""
629629
Performs the operation __ilshift__.
630630
"""
@@ -633,7 +633,7 @@ def __ilshift__(self: array, other: array, /) -> array:
633633
res = self._array.__ilshift__(other._array)
634634
return self.__class__._new(res)
635635

636-
def __rlshift__(self: array, other: array, /) -> array:
636+
def __rlshift__(self: array, other: Union[int, array], /) -> array:
637637
"""
638638
Performs the operation __rlshift__.
639639
"""
@@ -669,7 +669,7 @@ def __rmatmul__(self: array, other: array, /) -> array:
669669
return self.__class__._new(res)
670670

671671
@np.errstate(all='ignore')
672-
def __imod__(self: array, other: array, /) -> array:
672+
def __imod__(self: array, other: Union[int, float, array], /) -> array:
673673
"""
674674
Performs the operation __imod__.
675675
"""
@@ -679,7 +679,7 @@ def __imod__(self: array, other: array, /) -> array:
679679
return self.__class__._new(res)
680680

681681
@np.errstate(all='ignore')
682-
def __rmod__(self: array, other: array, /) -> array:
682+
def __rmod__(self: array, other: Union[int, float, array], /) -> array:
683683
"""
684684
Performs the operation __rmod__.
685685
"""
@@ -690,7 +690,7 @@ def __rmod__(self: array, other: array, /) -> array:
690690
return self.__class__._new(res)
691691

692692
@np.errstate(all='ignore')
693-
def __imul__(self: array, other: array, /) -> array:
693+
def __imul__(self: array, other: Union[int, float, array], /) -> array:
694694
"""
695695
Performs the operation __imul__.
696696
"""
@@ -700,7 +700,7 @@ def __imul__(self: array, other: array, /) -> array:
700700
return self.__class__._new(res)
701701

702702
@np.errstate(all='ignore')
703-
def __rmul__(self: array, other: array, /) -> array:
703+
def __rmul__(self: array, other: Union[int, float, array], /) -> array:
704704
"""
705705
Performs the operation __rmul__.
706706
"""
@@ -710,7 +710,7 @@ def __rmul__(self: array, other: array, /) -> array:
710710
res = self._array.__rmul__(other._array)
711711
return self.__class__._new(res)
712712

713-
def __ior__(self: array, other: array, /) -> array:
713+
def __ior__(self: array, other: Union[int, bool, array], /) -> array:
714714
"""
715715
Performs the operation __ior__.
716716
"""
@@ -719,7 +719,7 @@ def __ior__(self: array, other: array, /) -> array:
719719
res = self._array.__ior__(other._array)
720720
return self.__class__._new(res)
721721

722-
def __ror__(self: array, other: array, /) -> array:
722+
def __ror__(self: array, other: Union[int, bool, array], /) -> array:
723723
"""
724724
Performs the operation __ror__.
725725
"""
@@ -730,7 +730,7 @@ def __ror__(self: array, other: array, /) -> array:
730730
return self.__class__._new(res)
731731

732732
@np.errstate(all='ignore')
733-
def __ipow__(self: array, other: array, /) -> array:
733+
def __ipow__(self: array, other: Union[int, float, array], /) -> array:
734734
"""
735735
Performs the operation __ipow__.
736736
"""
@@ -740,7 +740,7 @@ def __ipow__(self: array, other: array, /) -> array:
740740
return self.__class__._new(res)
741741

742742
@np.errstate(all='ignore')
743-
def __rpow__(self: array, other: array, /) -> array:
743+
def __rpow__(self: array, other: Union[int, float, array], /) -> array:
744744
"""
745745
Performs the operation __rpow__.
746746
"""
@@ -752,7 +752,7 @@ def __rpow__(self: array, other: array, /) -> array:
752752
# for 0-d arrays, so we use pow() here instead.
753753
return pow(other, self)
754754

755-
def __irshift__(self: array, other: array, /) -> array:
755+
def __irshift__(self: array, other: Union[int, array], /) -> array:
756756
"""
757757
Performs the operation __irshift__.
758758
"""
@@ -761,7 +761,7 @@ def __irshift__(self: array, other: array, /) -> array:
761761
res = self._array.__irshift__(other._array)
762762
return self.__class__._new(res)
763763

764-
def __rrshift__(self: array, other: array, /) -> array:
764+
def __rrshift__(self: array, other: Union[int, array], /) -> array:
765765
"""
766766
Performs the operation __rrshift__.
767767
"""
@@ -775,7 +775,7 @@ def __rrshift__(self: array, other: array, /) -> array:
775775
return self.__class__._new(res)
776776

777777
@np.errstate(all='ignore')
778-
def __isub__(self: array, other: array, /) -> array:
778+
def __isub__(self: array, other: Union[int, float, array], /) -> array:
779779
"""
780780
Performs the operation __isub__.
781781
"""
@@ -785,7 +785,7 @@ def __isub__(self: array, other: array, /) -> array:
785785
return self.__class__._new(res)
786786

787787
@np.errstate(all='ignore')
788-
def __rsub__(self: array, other: array, /) -> array:
788+
def __rsub__(self: array, other: Union[int, float, array], /) -> array:
789789
"""
790790
Performs the operation __rsub__.
791791
"""
@@ -796,7 +796,7 @@ def __rsub__(self: array, other: array, /) -> array:
796796
return self.__class__._new(res)
797797

798798
@np.errstate(all='ignore')
799-
def __itruediv__(self: array, other: array, /) -> array:
799+
def __itruediv__(self: array, other: Union[int, float, array], /) -> array:
800800
"""
801801
Performs the operation __itruediv__.
802802
"""
@@ -806,7 +806,7 @@ def __itruediv__(self: array, other: array, /) -> array:
806806
return self.__class__._new(res)
807807

808808
@np.errstate(all='ignore')
809-
def __rtruediv__(self: array, other: array, /) -> array:
809+
def __rtruediv__(self: array, other: Union[int, float, array], /) -> array:
810810
"""
811811
Performs the operation __rtruediv__.
812812
"""
@@ -816,7 +816,7 @@ def __rtruediv__(self: array, other: array, /) -> array:
816816
res = self._array.__rtruediv__(other._array)
817817
return self.__class__._new(res)
818818

819-
def __ixor__(self: array, other: array, /) -> array:
819+
def __ixor__(self: array, other: Union[int, bool, array], /) -> array:
820820
"""
821821
Performs the operation __ixor__.
822822
"""
@@ -825,7 +825,7 @@ def __ixor__(self: array, other: array, /) -> array:
825825
res = self._array.__ixor__(other._array)
826826
return self.__class__._new(res)
827827

828-
def __rxor__(self: array, other: array, /) -> array:
828+
def __rxor__(self: array, other: Union[int, bool, array], /) -> array:
829829
"""
830830
Performs the operation __rxor__.
831831
"""

numpy/_array_api/_manipulation_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def roll(x: array, /, shift: Union[int, Tuple[int, ...]], *, axis: Optional[Unio
5050
"""
5151
return ndarray._new(np.roll(x._array, shift, axis=axis))
5252

53-
def squeeze(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array:
53+
def squeeze(x: array, /, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> array:
5454
"""
5555
Array API compatible wrapper for :py:func:`np.squeeze <numpy.squeeze>`.
5656

0 commit comments

Comments
 (0)