(self, dtype)
| 91 | class TestPutMask: |
| 92 | @pytest.mark.parametrize("dtype", list(np.typecodes["All"]) + ["i,O"]) |
| 93 | def test_simple(self, dtype): |
| 94 | if dtype.lower() == "m": |
| 95 | dtype += "8[ns]" |
| 96 | |
| 97 | # putmask is weird and doesn't care about value length (even shorter) |
| 98 | vals = np.arange(1001).astype(dtype=dtype) |
| 99 | |
| 100 | mask = np.random.randint(2, size=1000).astype(bool) |
| 101 | # Use vals.dtype in case of flexible dtype (i.e. string) |
| 102 | arr = np.zeros(1000, dtype=vals.dtype) |
| 103 | zeros = arr.copy() |
| 104 | |
| 105 | np.putmask(arr, mask, vals) |
| 106 | assert_array_equal(arr[mask], vals[:len(mask)][mask]) |
| 107 | assert_array_equal(arr[~mask], zeros[~mask]) |
| 108 | |
| 109 | @pytest.mark.parametrize("dtype", list(np.typecodes["All"])[1:] + ["i,O"]) |
| 110 | @pytest.mark.parametrize("mode", ["raise", "wrap", "clip"]) |
nothing calls this directly
no test coverage detected