From 5c0e65272ee59fa4970b6f7e8ca02c278d44cc9b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 28 Nov 2019 11:16:22 +0100 Subject: [PATCH] Slightly clarify the implementation of safe_masked_invalid. --- lib/matplotlib/cbook/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 44dd0f44aa99..5045e893b8f3 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -746,12 +746,9 @@ def safezip(*args): def safe_masked_invalid(x, copy=False): x = np.array(x, subok=True, copy=copy) if not x.dtype.isnative: - # Note that the argument to `byteswap` is 'inplace', - # thus if we have already made a copy, do the byteswap in - # place, else make a copy with the byte order swapped. - # Be explicit that we are swapping the byte order of the dtype - x = x.byteswap(copy).newbyteorder('S') - + # If we have already made a copy, do the byteswap in place, else make a + # copy with the byte order swapped. + x = x.byteswap(inplace=copy).newbyteorder('N') # Swap to native order. try: xm = np.ma.masked_invalid(x, copy=False) xm.shrink_mask()