(self, dtype)
| 104 | class TestPutMask: |
| 105 | @pytest.mark.parametrize("dtype", list(np.typecodes["All"]) + ["i,O"]) |
| 106 | def test_simple(self, dtype): |
| 107 | if dtype.lower() == "m": |
| 108 | dtype += "8[ns]" |
| 109 | |
| 110 | # putmask is weird and doesn't care about value length (even shorter) |
| 111 | vals = np.arange(1001).astype(dtype=dtype) |
| 112 | |
| 113 | mask = np.random.randint(2, size=1000).astype(bool) |
| 114 | # Use vals.dtype in case of flexible dtype (i.e. string) |
| 115 | arr = np.zeros(1000, dtype=vals.dtype) |
| 116 | zeros = arr.copy() |
| 117 | |
| 118 | np.putmask(arr, mask, vals) |
| 119 | assert_array_equal(arr[mask], vals[:len(mask)][mask]) |
| 120 | assert_array_equal(arr[~mask], zeros[~mask]) |
| 121 | |
| 122 | @pytest.mark.parametrize("dtype", list(np.typecodes["All"])[1:] + ["i,O"]) |
| 123 | @pytest.mark.parametrize("mode", ["raise", "wrap", "clip"]) |
nothing calls this directly
no test coverage detected