| 150 | |
| 151 | |
| 152 | def 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 | |
| 175 | def test_negative_stride_from_python(msg): |