(m)
| 135 | |
| 136 | @pytest.mark.parametrize("m", submodules) |
| 137 | def test_bad_python_to_cpp_casts(m): |
| 138 | with pytest.raises( |
| 139 | TypeError, match=r"^round_trip_tensor\(\): incompatible function arguments" |
| 140 | ): |
| 141 | m.round_trip_tensor(np.zeros((2, 3))) |
| 142 | |
| 143 | with pytest.raises(TypeError, match=r"^Cannot cast array data from dtype"): |
| 144 | m.round_trip_tensor(np.zeros(dtype=np.str_, shape=(2, 3, 1))) |
| 145 | |
| 146 | with pytest.raises( |
| 147 | TypeError, |
| 148 | match=r"^round_trip_tensor_noconvert\(\): incompatible function arguments", |
| 149 | ): |
| 150 | m.round_trip_tensor_noconvert(tensor_ref) |
| 151 | |
| 152 | assert_equal_tensor_ref( |
| 153 | m.round_trip_tensor_noconvert(tensor_ref.astype(np.float64)) |
| 154 | ) |
| 155 | |
| 156 | bad_options = "C" if m.needed_options == "F" else "F" |
| 157 | # Shape, dtype and the order need to be correct for a TensorMap cast |
| 158 | with pytest.raises( |
| 159 | TypeError, match=r"^round_trip_view_tensor\(\): incompatible function arguments" |
| 160 | ): |
| 161 | m.round_trip_view_tensor( |
| 162 | np.zeros((3, 5, 2), dtype=np.float64, order=bad_options) |
| 163 | ) |
| 164 | |
| 165 | with pytest.raises( |
| 166 | TypeError, match=r"^round_trip_view_tensor\(\): incompatible function arguments" |
| 167 | ): |
| 168 | m.round_trip_view_tensor( |
| 169 | np.zeros((3, 5, 2), dtype=np.float32, order=m.needed_options) |
| 170 | ) |
| 171 | |
| 172 | with pytest.raises( |
| 173 | TypeError, match=r"^round_trip_view_tensor\(\): incompatible function arguments" |
| 174 | ): |
| 175 | m.round_trip_view_tensor( |
| 176 | np.zeros((3, 5), dtype=np.float64, order=m.needed_options) |
| 177 | ) |
| 178 | |
| 179 | temp = np.zeros((3, 5, 2), dtype=np.float64, order=m.needed_options) |
| 180 | with pytest.raises( |
| 181 | TypeError, match=r"^round_trip_view_tensor\(\): incompatible function arguments" |
| 182 | ): |
| 183 | m.round_trip_view_tensor( |
| 184 | temp[:, ::-1, :], |
| 185 | ) |
| 186 | |
| 187 | temp = np.zeros((3, 5, 2), dtype=np.float64, order=m.needed_options) |
| 188 | temp.setflags(write=False) |
| 189 | with pytest.raises( |
| 190 | TypeError, match=r"^round_trip_view_tensor\(\): incompatible function arguments" |
| 191 | ): |
| 192 | m.round_trip_view_tensor(temp) |
| 193 | |
| 194 |
nothing calls this directly
no test coverage detected