@@ -628,15 +628,16 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
628
628
>>> xpx.at(x)[idx].set(value)
629
629
630
630
copy : bool, optional
631
- True (default)
631
+ None (default)
632
+ The array parameter *may* be modified in place if it is
633
+ possible and beneficial for performance.
634
+ You should not reuse it after calling this function.
635
+ True
632
636
Ensure that the inputs are not modified.
633
637
False
634
638
Ensure that the update operation writes back to the input.
635
639
Raise ``ValueError`` if a copy cannot be avoided.
636
- None
637
- The array parameter *may* be modified in place if it is
638
- possible and beneficial for performance.
639
- You should not reuse it after calling this function.
640
+
640
641
xp : array_namespace, optional
641
642
The standard-compatible namespace for `x`. Default: infer.
642
643
@@ -646,18 +647,18 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
646
647
647
648
Warnings
648
649
--------
649
- (a) When you use ``copy=None`` , you should always immediately overwrite
650
+ (a) When you omit the ``copy`` parameter , you should always immediately overwrite
650
651
the parameter array::
651
652
652
653
>>> import array_api_extra as xpx
653
- >>> x = xpx.at(x, 0).set(2, copy=None )
654
+ >>> x = xpx.at(x, 0).set(2)
654
655
655
656
The anti-pattern below must be avoided, as it will result in different
656
657
behaviour on read-only versus writeable arrays::
657
658
658
659
>>> x = xp.asarray([0, 0, 0])
659
- >>> y = xpx.at(x, 0).set(2, copy=None )
660
- >>> z = xpx.at(x, 1).set(3, copy=None )
660
+ >>> y = xpx.at(x, 0).set(2)
661
+ >>> z = xpx.at(x, 1).set(3)
661
662
662
663
In the above example, ``x == [0, 0, 0]``, ``y == [2, 0, 0]`` and z == ``[0, 3, 0]``
663
664
when ``x`` is read-only, whereas ``x == y == z == [2, 3, 0]`` when ``x`` is
@@ -691,8 +692,8 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
691
692
Given either of these equivalent expressions::
692
693
693
694
>>> import array_api_extra as xpx
694
- >>> x = xpx.at(x)[1].add(2, copy=None )
695
- >>> x = xpx.at(x, 1).add(2, copy=None )
695
+ >>> x = xpx.at(x)[1].add(2)
696
+ >>> x = xpx.at(x, 1).add(2)
696
697
697
698
If x is a JAX array, they are the same as::
698
699
@@ -735,8 +736,8 @@ def _update_common(
735
736
at_op : str ,
736
737
y : Array ,
737
738
/ ,
738
- copy : bool | None = True ,
739
- xp : ModuleType | None = None ,
739
+ copy : bool | None ,
740
+ xp : ModuleType | None ,
740
741
) -> tuple [Array , None ] | tuple [None , Array ]: # numpydoc ignore=PR01
741
742
"""
742
743
Perform common prepocessing to all update operations.
@@ -800,7 +801,7 @@ def set(
800
801
self ,
801
802
y : Array ,
802
803
/ ,
803
- copy : bool | None = True ,
804
+ copy : bool | None = None ,
804
805
xp : ModuleType | None = None ,
805
806
) -> Array : # numpydoc ignore=PR01,RT01
806
807
"""Apply ``x[idx] = y`` and return the update array."""
@@ -819,8 +820,8 @@ def _iop(
819
820
elwise_op : Callable [[Array , Array ], Array ],
820
821
y : Array ,
821
822
/ ,
822
- copy : bool | None = True ,
823
- xp : ModuleType | None = None ,
823
+ copy : bool | None ,
824
+ xp : ModuleType | None ,
824
825
) -> Array : # numpydoc ignore=PR01,RT01
825
826
"""
826
827
``x[idx] += y`` or equivalent in-place operation on a subset of x.
@@ -843,7 +844,7 @@ def add(
843
844
self ,
844
845
y : Array ,
845
846
/ ,
846
- copy : bool | None = True ,
847
+ copy : bool | None = None ,
847
848
xp : ModuleType | None = None ,
848
849
) -> Array : # numpydoc ignore=PR01,RT01
849
850
"""Apply ``x[idx] += y`` and return the updated array."""
@@ -853,7 +854,7 @@ def subtract(
853
854
self ,
854
855
y : Array ,
855
856
/ ,
856
- copy : bool | None = True ,
857
+ copy : bool | None = None ,
857
858
xp : ModuleType | None = None ,
858
859
) -> Array : # numpydoc ignore=PR01,RT01
859
860
"""Apply ``x[idx] -= y`` and return the updated array."""
@@ -863,7 +864,7 @@ def multiply(
863
864
self ,
864
865
y : Array ,
865
866
/ ,
866
- copy : bool | None = True ,
867
+ copy : bool | None = None ,
867
868
xp : ModuleType | None = None ,
868
869
) -> Array : # numpydoc ignore=PR01,RT01
869
870
"""Apply ``x[idx] *= y`` and return the updated array."""
@@ -873,7 +874,7 @@ def divide(
873
874
self ,
874
875
y : Array ,
875
876
/ ,
876
- copy : bool | None = True ,
877
+ copy : bool | None = None ,
877
878
xp : ModuleType | None = None ,
878
879
) -> Array : # numpydoc ignore=PR01,RT01
879
880
"""Apply ``x[idx] /= y`` and return the updated array."""
@@ -883,7 +884,7 @@ def power(
883
884
self ,
884
885
y : Array ,
885
886
/ ,
886
- copy : bool | None = True ,
887
+ copy : bool | None = None ,
887
888
xp : ModuleType | None = None ,
888
889
) -> Array : # numpydoc ignore=PR01,RT01
889
890
"""Apply ``x[idx] **= y`` and return the updated array."""
@@ -893,7 +894,7 @@ def min(
893
894
self ,
894
895
y : Array ,
895
896
/ ,
896
- copy : bool | None = True ,
897
+ copy : bool | None = None ,
897
898
xp : ModuleType | None = None ,
898
899
) -> Array : # numpydoc ignore=PR01,RT01
899
900
"""Apply ``x[idx] = minimum(x[idx], y)`` and return the updated array."""
@@ -906,7 +907,7 @@ def max(
906
907
self ,
907
908
y : Array ,
908
909
/ ,
909
- copy : bool | None = True ,
910
+ copy : bool | None = None ,
910
911
xp : ModuleType | None = None ,
911
912
) -> Array : # numpydoc ignore=PR01,RT01
912
913
"""Apply ``x[idx] = maximum(x[idx], y)`` and return the updated array."""
0 commit comments