def test_matrix_property_set_not_RO(self) -> None: """ Test that we can set the numpy matrix via property. """ e = MatrixDataElement((1, 2, 3, 4), readonly=False) e.matrix = (5, 6, 7, 8) assert isinstance(e._matrix, np.ndarray) np.testing.assert_allclose(e._matrix, (5, 6, 7, 8))
def test_matrix_property_set_RO_exception(self) -> None: """ Test that setting to the matrix property results in a ReadOnlyError when the `readonly` attribute is set. """ e = MatrixDataElement((1, 2, 3, 4), readonly=True) with pytest.raises(ReadOnlyError): e.matrix = (5, 6, 7, 8) np.testing.assert_allclose(e._matrix, (1, 2, 3, 4))