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

Function test_count_nonzero_obj_axis

dask/array/tests/test_routines.py:2067–2082  ·  view source on GitHub ↗
(axis)

Source from the content-addressed store, hash-verified

2065
2066@pytest.mark.parametrize("axis", [None, 0, (1,), (0, 1)])
2067def test_count_nonzero_obj_axis(axis):
2068 x = np.random.default_rng().integers(10, size=(15, 16)).astype(object)
2069 d = da.from_array(x, chunks=(4, 5))
2070
2071 x_c = np.count_nonzero(x, axis)
2072 d_c = da.count_nonzero(d, axis)
2073
2074 if d_c.shape == tuple():
2075 assert x_c == d_c.compute()
2076 else:
2077 #######################################################
2078 # Workaround oddness with Windows and object arrays. #
2079 # #
2080 # xref: https://github.com/numpy/numpy/issues/9468 #
2081 #######################################################
2082 assert_eq(x_c.astype(np.intp), d_c)
2083
2084
2085def test_count_nonzero_str():

Callers

nothing calls this directly

Calls 4

assert_eqFunction · 0.90
astypeMethod · 0.45
integersMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected