| 47 | |
| 48 | |
| 49 | def test_partially_fixed(): |
| 50 | ref2 = np.array([[0.0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]) |
| 51 | np.testing.assert_array_equal(m.partial_copy_four_rm_r(ref2), ref2) |
| 52 | np.testing.assert_array_equal(m.partial_copy_four_rm_c(ref2), ref2) |
| 53 | np.testing.assert_array_equal(m.partial_copy_four_rm_r(ref2[:, 1]), ref2[:, [1]]) |
| 54 | np.testing.assert_array_equal(m.partial_copy_four_rm_c(ref2[0, :]), ref2[[0], :]) |
| 55 | np.testing.assert_array_equal( |
| 56 | m.partial_copy_four_rm_r(ref2[:, (0, 2)]), ref2[:, (0, 2)] |
| 57 | ) |
| 58 | np.testing.assert_array_equal( |
| 59 | m.partial_copy_four_rm_c(ref2[(3, 1, 2), :]), ref2[(3, 1, 2), :] |
| 60 | ) |
| 61 | |
| 62 | np.testing.assert_array_equal(m.partial_copy_four_cm_r(ref2), ref2) |
| 63 | np.testing.assert_array_equal(m.partial_copy_four_cm_c(ref2), ref2) |
| 64 | np.testing.assert_array_equal(m.partial_copy_four_cm_r(ref2[:, 1]), ref2[:, [1]]) |
| 65 | np.testing.assert_array_equal(m.partial_copy_four_cm_c(ref2[0, :]), ref2[[0], :]) |
| 66 | np.testing.assert_array_equal( |
| 67 | m.partial_copy_four_cm_r(ref2[:, (0, 2)]), ref2[:, (0, 2)] |
| 68 | ) |
| 69 | np.testing.assert_array_equal( |
| 70 | m.partial_copy_four_cm_c(ref2[(3, 1, 2), :]), ref2[(3, 1, 2), :] |
| 71 | ) |
| 72 | |
| 73 | # TypeError should be raise for a shape mismatch |
| 74 | functions = [ |
| 75 | m.partial_copy_four_rm_r, |
| 76 | m.partial_copy_four_rm_c, |
| 77 | m.partial_copy_four_cm_r, |
| 78 | m.partial_copy_four_cm_c, |
| 79 | ] |
| 80 | matrix_with_wrong_shape = [[1, 2], [3, 4]] |
| 81 | for f in functions: |
| 82 | with pytest.raises(TypeError) as excinfo: |
| 83 | f(matrix_with_wrong_shape) |
| 84 | assert "incompatible function arguments" in str(excinfo.value) |
| 85 | |
| 86 | |
| 87 | def test_mutator_descriptors(): |