Skip to content

Commit

Permalink
Merge pull request #27597 from meeseeksmachine/auto-backport-of-pr-27…
Browse files Browse the repository at this point in the history
…595-on-v3.8.x

Backport PR #27595 on branch v3.8.x (Fix is_sorted_and_has_non_nan for byteswapped inputs.)
  • Loading branch information
QuLogic committed Jan 4, 2024
2 parents 6eca804 + 88d3600 commit 86e5a45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def test_is_sorted_and_has_non_nan():
assert _path.is_sorted_and_has_non_nan(np.array([1, 2, 3]))
assert _path.is_sorted_and_has_non_nan(np.array([1, np.nan, 3]))
assert not _path.is_sorted_and_has_non_nan([3, 5] + [np.nan] * 100 + [0, 2])
# [2, 256] byteswapped:
assert not _path.is_sorted_and_has_non_nan(np.array([33554432, 65536], ">i4"))
n = 2 * mlines.Line2D._subslice_optim_min_size
plt.plot([np.nan] * n, range(n))

Expand Down
4 changes: 2 additions & 2 deletions src/_path_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ static PyObject *Py_is_sorted_and_has_non_nan(PyObject *self, PyObject *obj)
{
bool result;

PyArrayObject *array = (PyArrayObject *)PyArray_FromAny(
obj, NULL, 1, 1, 0, NULL);
PyArrayObject *array = (PyArrayObject *)PyArray_CheckFromAny(
obj, NULL, 1, 1, NPY_ARRAY_NOTSWAPPED, NULL);

if (array == NULL) {
return NULL;
Expand Down

0 comments on commit 86e5a45

Please sign in to comment.