Пример #1
0
 def test_rank_2d_e(self) -> None:
     a1 = np.array([10, 3, -4, 9, 3, -12, 18, 3, 0, 17]).reshape(5, 2)
     self.assertEqual(
         rank_2d(a1, axis=0, method='dense', start=1).tolist(),
         [[4, 2], [1, 3], [3, 1], [5, 2], [2, 4]])
     self.assertEqual(
         rank_2d(a1, axis=1, method='dense', start=1).tolist(),
         [[2, 1], [1, 2], [2, 1], [2, 1], [1, 2]])
Пример #2
0
 def test_rank_2d_b(self) -> None:
     a1 = np.array([10, 3, -4, 9, 3, -12, 18, 3, 0, 17]).reshape(5, 2)
     self.assertEqual(
         rank_2d(a1, axis=0, method='mean', start=1).tolist(),
         [[4.0, 2.5], [1.0, 4.0], [3.0, 1.0], [5.0, 2.5], [2.0, 5.0]])
     self.assertEqual(
         rank_2d(a1, axis=1, method='mean', start=1).tolist(),
         [[2.0, 1.0], [1.0, 2.0], [2.0, 1.0], [2.0, 1.0], [1.0, 2.0]])
Пример #3
0
 def test_rank_2d_min(self, value: np.ndarray) -> None:
     # cannot compare values with NaN as scipy uses quicksort
     if np.isnan(value).any():
         return
     for axis in (0, 1):
         a1 = rankdata(value, method='min', axis=axis)
         a2 = rank_2d(value, method='min', start=1, axis=axis)
         self.assertEqual(a1.tolist(), a2.tolist())
Пример #4
0
 def test_rank_2d_ordinal(self, value: np.ndarray) -> None:
     for axis in (0, 1):
         a1 = rankdata(value, method='ordinal', axis=axis)
         a2 = rank_2d(value, method='ordinal', start=1, axis=axis)
         self.assertEqual(a1.tolist(), a2.tolist())