예제 #1
0
 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)
예제 #2
0
 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))
예제 #3
0
 def test_vector(self):
     vec = np.array([7, 8, 9])
     with pytest.raises(ShapeError):
         sort2D(vec)
예제 #4
0
 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]]))
예제 #5
0
 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]]))
예제 #6
0
 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]]))
예제 #7
0
 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]]))