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

Function test_partially_fixed

tests/test_eigen_matrix.py:49–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48
49def 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
87def test_mutator_descriptors():

Callers

nothing calls this directly

Calls 3

fFunction · 0.85
strClass · 0.85
arrayMethod · 0.80

Tested by

no test coverage detected