diff --git a/tests/test_utils.py b/tests/test_utils.py index 223667e9..80b7ebf7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2021,12 +2021,14 @@ def test_is_sorted(self): assert array_.is_sorted(np.array([0])) assert not array_.is_sorted(np.array([1, 0])) assert not array_.is_sorted(np.array([0, 1, 2, 4, 3])) + assert not array_.is_sorted(np.array([0.0, np.nan, 1.0])) # nb assert array_.is_sorted_nb(np.array([0, 1, 2, 3, 4])) assert array_.is_sorted_nb(np.array([0, 1])) assert array_.is_sorted_nb(np.array([0])) assert not array_.is_sorted_nb(np.array([1, 0])) assert not array_.is_sorted_nb(np.array([0, 1, 2, 4, 3])) + assert not array_.is_sorted_nb(np.array([0.0, np.nan, 1.0])) def test_insert_argsort_nb(self): a = np.random.uniform(size=1000) diff --git a/vectorbt/utils/array_.py b/vectorbt/utils/array_.py index 354034ba..01a3c847 100644 --- a/vectorbt/utils/array_.py +++ b/vectorbt/utils/array_.py @@ -18,7 +18,7 @@ def is_sorted(a: tp.Array1d) -> np.bool_: def is_sorted_nb(a: tp.Array1d) -> bool: """Numba-compiled version of `is_sorted`.""" for i in range(a.size - 1): - if a[i + 1] < a[i]: + if not a[i] <= a[i + 1]: return False return True