@@ -67,9 +67,9 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
6767
6868 You may use two alternate syntaxes::
6969
70- >>> import array_api_extra as xpx
71- >>> xpx.at(x, idx).set(value) # or add(value), etc.
72- >>> xpx.at(x)[idx].set(value)
70+ import array_api_extra as xpx
71+ xpx.at(x, idx).set(value) # or add(value), etc.
72+ xpx.at(x)[idx].set(value)
7373
7474 copy : bool, optional
7575 None (default)
@@ -94,8 +94,8 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
9494 (a) When you omit the ``copy`` parameter, you should never reuse the parameter
9595 array later on; ideally, you should reassign it immediately::
9696
97- >>> import array_api_extra as xpx
98- >>> x = xpx.at(x, 0).set(2)
97+ import array_api_extra as xpx
98+ x = xpx.at(x, 0).set(2)
9999
100100 The above best practice pattern ensures that the behaviour won't change depending
101101 on whether ``x`` is writeable or not, as the original ``x`` object is dereferenced
@@ -105,9 +105,9 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
105105 On the reverse, the anti-pattern below must be avoided, as it will result in
106106 different behaviour on read-only versus writeable arrays::
107107
108- >>> x = xp.asarray([0, 0, 0])
109- >>> y = xpx.at(x, 0).set(2)
110- >>> z = xpx.at(x, 1).set(3)
108+ x = xp.asarray([0, 0, 0])
109+ y = xpx.at(x, 0).set(2)
110+ z = xpx.at(x, 1).set(3)
111111
112112 In the above example, both calls to ``xpx.at`` update ``x`` in place *if possible*.
113113 This causes the behaviour to diverge depending on whether ``x`` is writeable or not:
@@ -120,22 +120,22 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
120120 The correct pattern to use if you want diverging outputs from the same input is
121121 to enforce copies::
122122
123- >>> x = xp.asarray([0, 0, 0])
124- >>> y = xpx.at(x, 0).set(2, copy=True) # Never updates x
125- >>> z = xpx.at(x, 1).set(3) # May or may not update x in place
126- >>> del x # avoid accidental reuse of x as we don't know its state anymore
123+ x = xp.asarray([0, 0, 0])
124+ y = xpx.at(x, 0).set(2, copy=True) # Never updates x
125+ z = xpx.at(x, 1).set(3) # May or may not update x in place
126+ del x # avoid accidental reuse of x as we don't know its state anymore
127127
128128 (b) The array API standard does not support integer array indices.
129129 The behaviour of update methods when the index is an array of integers is
130130 undefined and will vary between backends; this is particularly true when the
131131 index contains multiple occurrences of the same index, e.g.::
132132
133- >>> import numpy as np
134- >>> import jax.numpy as jnp
135- >>> import array_api_extra as xpx
136- >>> xpx.at(np.asarray([123]), np.asarray([0, 0])).add(1)
133+ import numpy as np
134+ import jax.numpy as jnp
135+ import array_api_extra as xpx
136+ xpx.at(np.asarray([123]), np.asarray([0, 0])).add(1)
137137 array([124])
138- >>> xpx.at(jnp.asarray([123]), jnp.asarray([0, 0])).add(1)
138+ xpx.at(jnp.asarray([123]), jnp.asarray([0, 0])).add(1)
139139 Array([125], dtype=int32)
140140
141141 See Also
@@ -155,38 +155,38 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
155155
156156 This pattern::
157157
158- >>> mask = m(x)
159- >>> x[mask] = f(x[mask])
158+ mask = m(x)
159+ x[mask] = f(x[mask])
160160
161161 Can't be replaced by `at`, as it won't work on Dask and JAX inside jax.jit::
162162
163- >>> mask = m(x)
164- >>> x = xpx.at(x, mask).set(f(x[mask]) # Crash on Dask and jax.jit
163+ mask = m(x)
164+ x = xpx.at(x, mask).set(f(x[mask]) ) # Crash on Dask and jax.jit
165165
166166 You should instead use::
167167
168- >>> x = xp.where(m(x), f(x), x)
168+ x = xp.where(m(x), f(x), x)
169169
170170 Examples
171171 --------
172172 Given either of these equivalent expressions::
173173
174- >>> import array_api_extra as xpx
175- >>> x = xpx.at(x)[1].add(2)
176- >>> x = xpx.at(x, 1).add(2)
174+ import array_api_extra as xpx
175+ x = xpx.at(x)[1].add(2)
176+ x = xpx.at(x, 1).add(2)
177177
178178 If x is a JAX array, they are the same as::
179179
180- >>> x = x.at[1].add(2)
180+ x = x.at[1].add(2)
181181
182182 If x is a read-only NumPy array, they are the same as::
183183
184- >>> x = x.copy()
185- >>> x[1] += 2
184+ x = x.copy()
185+ x[1] += 2
186186
187187 For other known backends, they are the same as::
188188
189- >>> x[1] += 2
189+ x[1] += 2
190190 """
191191
192192 _x : Array
0 commit comments