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

Function test_meta_from_array

dask/array/tests/test_array_utils.py:34–55  ·  view source on GitHub ↗
(asarray)

Source from the content-addressed store, hash-verified

32
33@pytest.mark.parametrize("asarray", asarrays)
34def test_meta_from_array(asarray):
35 x = np.array(1)
36 assert meta_from_array(x, ndim=1).shape == (0,)
37
38 x = np.ones((1, 2, 3), dtype="float32")
39 x = asarray(x)
40
41 assert meta_from_array(x).shape == (0, 0, 0)
42 assert meta_from_array(x).dtype == "float32"
43 assert type(meta_from_array(x)) is type(x)
44
45 assert meta_from_array(x, ndim=2).shape == (0, 0)
46 assert meta_from_array(x, ndim=4).shape == (0, 0, 0, 0)
47 assert meta_from_array(x, dtype="float64").dtype == "float64"
48 assert meta_from_array(x, dtype=float).dtype == "float64"
49
50 x = da.ones((1,))
51 assert isinstance(meta_from_array(x), np.ndarray)
52
53 assert meta_from_array(123) == 123
54 assert meta_from_array("foo") == "foo"
55 assert meta_from_array(np.dtype("float32")) == np.dtype("float32")
56
57
58@pytest.mark.parametrize("meta", ["", "str", "", "str", b"", b"str"])

Callers

nothing calls this directly

Calls 4

meta_from_arrayFunction · 0.90
asarrayFunction · 0.50
onesMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected