(self)
| 2019 | assert_raises(ValueError, lambda: a.transpose(0, 1, 2)) |
| 2020 | |
| 2021 | def test_sort(self): |
| 2022 | # test ordering for floats and complex containing nans. It is only |
| 2023 | # necessary to check the less-than comparison, so sorts that |
| 2024 | # only follow the insertion sort path are sufficient. We only |
| 2025 | # test doubles and complex doubles as the logic is the same. |
| 2026 | |
| 2027 | # check doubles |
| 2028 | msg = "Test real sort order with nans" |
| 2029 | a = np.array([np.nan, 1, 0]) |
| 2030 | b = np.sort(a) |
| 2031 | assert_equal(b, a[::-1], msg) |
| 2032 | # check complex |
| 2033 | msg = "Test complex sort order with nans" |
| 2034 | a = np.zeros(9, dtype=np.complex128) |
| 2035 | a.real += [np.nan, np.nan, np.nan, 1, 0, 1, 1, 0, 0] |
| 2036 | a.imag += [np.nan, 1, 0, np.nan, np.nan, 1, 0, 1, 0] |
| 2037 | b = np.sort(a) |
| 2038 | assert_equal(b, a[::-1], msg) |
| 2039 | |
| 2040 | # all c scalar sorts use the same code with different types |
| 2041 | # so it suffices to run a quick check with one type. The number |
nothing calls this directly
no test coverage detected