(asarray)
| 31 | |
| 32 | @pytest.mark.parametrize("asarray", asarrays) |
| 33 | def 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"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…