@@ -848,7 +848,11 @@ def add(
848848 xp : ModuleType | None = None ,
849849 ) -> Array : # numpydoc ignore=PR01,RT01
850850 """Apply ``x[idx] += y`` and return the updated array."""
851- return self ._iop ("add" , operator .add , y , copy = copy , xp = xp )
851+
852+ # Note for this and all other methods based on _iop:
853+ # operator.iadd and operator.add subtly differ in behaviour, as
854+ # only iadd will trigger exceptions when y has an incompatible dtype.
855+ return self ._iop ("add" , operator .iadd , y , copy = copy , xp = xp )
852856
853857 def subtract (
854858 self ,
@@ -858,7 +862,7 @@ def subtract(
858862 xp : ModuleType | None = None ,
859863 ) -> Array : # numpydoc ignore=PR01,RT01
860864 """Apply ``x[idx] -= y`` and return the updated array."""
861- return self ._iop ("subtract" , operator .sub , y , copy = copy , xp = xp )
865+ return self ._iop ("subtract" , operator .isub , y , copy = copy , xp = xp )
862866
863867 def multiply (
864868 self ,
@@ -868,7 +872,7 @@ def multiply(
868872 xp : ModuleType | None = None ,
869873 ) -> Array : # numpydoc ignore=PR01,RT01
870874 """Apply ``x[idx] *= y`` and return the updated array."""
871- return self ._iop ("multiply" , operator .mul , y , copy = copy , xp = xp )
875+ return self ._iop ("multiply" , operator .imul , y , copy = copy , xp = xp )
872876
873877 def divide (
874878 self ,
@@ -878,7 +882,7 @@ def divide(
878882 xp : ModuleType | None = None ,
879883 ) -> Array : # numpydoc ignore=PR01,RT01
880884 """Apply ``x[idx] /= y`` and return the updated array."""
881- return self ._iop ("divide" , operator .truediv , y , copy = copy , xp = xp )
885+ return self ._iop ("divide" , operator .itruediv , y , copy = copy , xp = xp )
882886
883887 def power (
884888 self ,
@@ -888,7 +892,7 @@ def power(
888892 xp : ModuleType | None = None ,
889893 ) -> Array : # numpydoc ignore=PR01,RT01
890894 """Apply ``x[idx] **= y`` and return the updated array."""
891- return self ._iop ("power" , operator .pow , y , copy = copy , xp = xp )
895+ return self ._iop ("power" , operator .ipow , y , copy = copy , xp = xp )
892896
893897 def min (
894898 self ,
0 commit comments