def test_Axis_data_change_not_broadcastable(base, new): try: np.broadcast_to(new, base.shape) assume(False) # not valid hypothesis test except ValueError: pass axis = Axis(base) with pytest.raises(ValueError): axis.data = new
def test_Axis_data_change_broadcastable(base, new): try: expected = np.broadcast_to(new, base.shape) except ValueError: assume(False) # compensating the dimension consumption if base.shape and len(base) == 1: axis = Axis(base[np.newaxis]) else: axis = Axis(base) np.testing.assert_array_equal(axis, base) axis.data = new np.testing.assert_array_equal(axis, expected)