Python and numpy scalars are automatically converted to ndarray
(type_)
| 2936 | |
| 2937 | @pytest.mark.parametrize("type_", [t for t in np.ScalarType if t is not memoryview]) |
| 2938 | def test_from_array_scalar(type_): |
| 2939 | """Python and numpy scalars are automatically converted to ndarray""" |
| 2940 | if type_ is np.datetime64: |
| 2941 | x = np.datetime64("2000-01-01") |
| 2942 | elif type_ is np.timedelta64: |
| 2943 | x = np.timedelta64(1, "s") |
| 2944 | else: |
| 2945 | x = type_(1) |
| 2946 | |
| 2947 | dx = da.from_array(x, chunks=-1) |
| 2948 | assert_eq(np.array(x), dx) |
| 2949 | assert isinstance( |
| 2950 | dx.dask[dx.name,], |
| 2951 | np.ndarray, |
| 2952 | ) |
| 2953 | |
| 2954 | |
| 2955 | @pytest.mark.parametrize("asarray,cls", [(True, np.ndarray), (False, np.matrix)]) |
nothing calls this directly
no test coverage detected