MCPcopy Create free account
hub / github.com/dask/dask / test_operators

Function test_operators

dask/array/tests/test_array_core.py:1208–1229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1206
1207
1208def test_operators():
1209 x = np.arange(10)
1210 y = np.arange(10).reshape((10, 1))
1211 a = from_array(x, chunks=(5,))
1212 b = from_array(y, chunks=(5, 1))
1213
1214 c = a + 1
1215 assert_eq(c, x + 1)
1216
1217 c = a + b
1218 assert_eq(c, x + x.reshape((10, 1)))
1219
1220 expr = (3 / a * b) ** 2 > 5
1221 with warnings.catch_warnings():
1222 warnings.simplefilter("ignore", RuntimeWarning) # divide by zero
1223 assert_eq(expr, (3 / x * y) ** 2 > 5)
1224
1225 c = da.exp(a)
1226 assert_eq(c, np.exp(x))
1227
1228 assert_eq(abs(-a), a)
1229 assert_eq(a, +x)
1230
1231
1232def test_binary_operator_delegation(mocker):

Callers

nothing calls this directly

Calls 4

from_arrayFunction · 0.90
assert_eqFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45

Tested by

no test coverage detected