MCPcopy Create free account
hub / github.com/numpy/numpy / test_same_as_ufunc

Function test_same_as_ufunc

numpy/lib/tests/test_stride_tricks.py:182–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180
181
182def test_same_as_ufunc():
183 # Check that the data layout is the same as if a ufunc did the operation.
184
185 data = [
186 [[(1,), (3,)], (3,)],
187 [[(1, 3), (3, 3)], (3, 3)],
188 [[(3, 1), (3, 3)], (3, 3)],
189 [[(1, 3), (3, 1)], (3, 3)],
190 [[(1, 1), (3, 3)], (3, 3)],
191 [[(1, 1), (1, 3)], (1, 3)],
192 [[(1, 1), (3, 1)], (3, 1)],
193 [[(1, 0), (0, 0)], (0, 0)],
194 [[(0, 1), (0, 0)], (0, 0)],
195 [[(1, 0), (0, 1)], (0, 0)],
196 [[(1, 1), (0, 0)], (0, 0)],
197 [[(1, 1), (1, 0)], (1, 0)],
198 [[(1, 1), (0, 1)], (0, 1)],
199 [[(), (3,)], (3,)],
200 [[(3,), (3, 3)], (3, 3)],
201 [[(3,), (3, 1)], (3, 3)],
202 [[(1,), (3, 3)], (3, 3)],
203 [[(), (3, 3)], (3, 3)],
204 [[(1, 1), (3,)], (1, 3)],
205 [[(1,), (3, 1)], (3, 1)],
206 [[(1,), (1, 3)], (1, 3)],
207 [[(), (1, 3)], (1, 3)],
208 [[(), (3, 1)], (3, 1)],
209 [[(), (0,)], (0,)],
210 [[(0,), (0, 0)], (0, 0)],
211 [[(0,), (0, 1)], (0, 0)],
212 [[(1,), (0, 0)], (0, 0)],
213 [[(), (0, 0)], (0, 0)],
214 [[(1, 1), (0,)], (1, 0)],
215 [[(1,), (0, 1)], (0, 1)],
216 [[(1,), (1, 0)], (1, 0)],
217 [[(), (1, 0)], (1, 0)],
218 [[(), (0, 1)], (0, 1)],
219 ]
220 for input_shapes, expected_shape in data:
221 assert_same_as_ufunc(input_shapes[0], input_shapes[1],
222 "Shapes: %s %s" % (input_shapes[0], input_shapes[1]))
223 # Reverse the input shapes since broadcasting should be symmetric.
224 assert_same_as_ufunc(input_shapes[1], input_shapes[0])
225 # Try them transposed, too.
226 assert_same_as_ufunc(input_shapes[0], input_shapes[1], True)
227 # ... and flipped for non-rank-0 inputs in order to test negative
228 # strides.
229 if () not in input_shapes:
230 assert_same_as_ufunc(input_shapes[0], input_shapes[1], False, True)
231 assert_same_as_ufunc(input_shapes[0], input_shapes[1], True, True)
232
233
234def test_broadcast_to_succeeds():

Callers

nothing calls this directly

Calls 1

assert_same_as_ufuncFunction · 0.85

Tested by

no test coverage detected