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

Function test_masked_array

dask/array/tests/test_masked.py:327–354  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

325
326
327def test_masked_array():
328 x = np.random.default_rng().random((10, 10)).astype("f4")
329 dx = da.from_array(x, chunks=(3, 4))
330 f1 = da.from_array(np.array(1), chunks=())
331
332 fill_values = [(None, None), (0.5, 0.5), (1, f1)]
333 for data, (df, f) in product([x, dx], fill_values):
334 assert_eq(
335 da.ma.masked_array(data, fill_value=df), np.ma.masked_array(x, fill_value=f)
336 )
337 assert_eq(
338 da.ma.masked_array(data, mask=data > 0.4, fill_value=df),
339 np.ma.masked_array(x, mask=x > 0.4, fill_value=f),
340 )
341 assert_eq(
342 da.ma.masked_array(data, mask=data > 0.4, fill_value=df),
343 np.ma.masked_array(x, mask=x > 0.4, fill_value=f),
344 )
345 assert_eq(
346 da.ma.masked_array(data, fill_value=df, dtype="f8"),
347 np.ma.masked_array(x, fill_value=f, dtype="f8"),
348 )
349
350 with pytest.raises(ValueError):
351 da.ma.masked_array(dx, fill_value=dx)
352
353 with pytest.raises(np.ma.MaskError):
354 da.ma.masked_array(dx, mask=dx[:3, :3])
355
356
357def test_set_fill_value():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
astypeMethod · 0.45
randomMethod · 0.45

Tested by

no test coverage detected