def test_invalid_axis(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) with pytest.raises(InputError): sort2D(array, axis=3)
def test_invalid_order(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) with pytest.raises(ValueError): sort2D(array, order=(0, 3, 1))
def test_vector(self): vec = np.array([7, 8, 9]) with pytest.raises(ShapeError): sort2D(vec)
def test_diff_order(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) assert np.allclose( sort2D(array, order=(0, 2, 1)), np.array([[0, 5, 1], [0, 1, 8], [3, 13, 6], [7, 4, 9]]))
def test_first_row(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) assert np.allclose( sort2D(array, axis=0, order=0), np.array([[0, 1, 5], [7, 9, 4], [3, 6, 13], [0, 8, 1]]))
def test_first_col(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) assert np.allclose( sort2D(array, order=0), np.array([[0, 5, 1], [0, 1, 8], [3, 13, 6], [7, 4, 9]]))
def test_default(self): array = np.array([[0, 5, 1], [7, 4, 9], [3, 13, 6], [0, 1, 8]]) assert np.allclose( sort2D(array), np.array([[0, 1, 1], [0, 4, 6], [3, 5, 8], [7, 13, 9]]))