MCPcopy Index your code
hub / github.com/dask/dask / test_meta_from_array

Function test_meta_from_array

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…