(self)
| 2828 | assert actual2.dtype == np.dtype("datetime64[s]") |
| 2829 | |
| 2830 | def test_full_like(self) -> None: |
| 2831 | # For more thorough tests, see test_variable.py |
| 2832 | orig = Variable( |
| 2833 | dims=("x", "y"), data=[[1.5, 2.0], [3.1, 4.3]], attrs={"foo": "bar"} |
| 2834 | ) |
| 2835 | |
| 2836 | expect = orig.copy(deep=True) |
| 2837 | # see https://github.com/python/mypy/issues/3004 for why we need to ignore type |
| 2838 | expect.values = [[2.0, 2.0], [2.0, 2.0]] # type: ignore[assignment,unused-ignore] |
| 2839 | assert_identical(expect, full_like(orig, 2)) |
| 2840 | |
| 2841 | # override dtype |
| 2842 | expect.values = [[True, True], [True, True]] # type: ignore[assignment,unused-ignore] |
| 2843 | assert expect.dtype == bool |
| 2844 | assert_identical(expect, full_like(orig, True, dtype=bool)) |
| 2845 | |
| 2846 | # raise error on non-scalar fill_value |
| 2847 | with pytest.raises(ValueError, match=r"must be scalar"): |
| 2848 | full_like(orig, [1.0, 2.0]) |
| 2849 | |
| 2850 | with pytest.raises(ValueError, match="'dtype' cannot be dict-like"): |
| 2851 | full_like(orig, True, dtype={"x": bool}) |
| 2852 | |
| 2853 | @requires_dask |
| 2854 | def test_full_like_dask(self) -> None: |
nothing calls this directly
no test coverage detected