MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_nonunit_stride_from_python

Function test_nonunit_stride_from_python

tests/test_eigen_matrix.py:152–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150
151
152def test_nonunit_stride_from_python():
153 counting_mat = np.arange(9.0, dtype=np.float32).reshape((3, 3))
154 second_row = counting_mat[1, :]
155 second_col = counting_mat[:, 1]
156 np.testing.assert_array_equal(m.double_row(second_row), 2.0 * second_row)
157 np.testing.assert_array_equal(m.double_col(second_row), 2.0 * second_row)
158 np.testing.assert_array_equal(m.double_complex(second_row), 2.0 * second_row)
159 np.testing.assert_array_equal(m.double_row(second_col), 2.0 * second_col)
160 np.testing.assert_array_equal(m.double_col(second_col), 2.0 * second_col)
161 np.testing.assert_array_equal(m.double_complex(second_col), 2.0 * second_col)
162
163 counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
164 slices = [counting_3d[0, :, :], counting_3d[:, 0, :], counting_3d[:, :, 0]]
165 for ref_mat in slices:
166 np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
167 np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
168
169 # Mutator:
170 m.double_threer(second_row)
171 m.double_threec(second_col)
172 np.testing.assert_array_equal(counting_mat, [[0.0, 2, 2], [6, 16, 10], [6, 14, 8]])
173
174
175def test_negative_stride_from_python(msg):

Callers

nothing calls this directly

Calls 1

reshapeMethod · 0.80

Tested by

no test coverage detected