Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1095 from efiring/colormap_byteorder_bug
Colormap byteorder bug
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Tests for the colors module. | ||
""" | ||
|
||
from __future__ import print_function | ||
import numpy as np | ||
from numpy.testing.utils import assert_array_equal | ||
import matplotlib.colors as mcolors | ||
import matplotlib.cm as cm | ||
|
||
def test_colormap_endian(): | ||
""" | ||
Github issue #1005: a bug in putmask caused erroneous | ||
mapping of 1.0 when input from a non-native-byteorder | ||
array. | ||
""" | ||
cmap = cm.get_cmap("jet") | ||
# Test under, over, and invalid along with values 0 and 1. | ||
a = [-0.5, 0, 0.5, 1, 1.5, np.nan] | ||
for dt in ["f2", "f4", "f8"]: | ||
anative = np.ma.masked_invalid(np.array(a, dtype=dt)) | ||
aforeign = anative.byteswap().newbyteorder() | ||
#print(anative.dtype.isnative, aforeign.dtype.isnative) | ||
assert_array_equal(cmap(anative), cmap(aforeign)) | ||
|
||
|