MCPcopy Index your code
hub / github.com/numpy/numpy / test_simple

Method test_simple

numpy/_core/tests/test_item_selection.py:106–120  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

104class 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"])

Callers

nothing calls this directly

Calls 4

assert_array_equalFunction · 0.90
lowerMethod · 0.80
astypeMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected