Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add tests/test_colors.py with test for issue #1005

  • Loading branch information...
commit 988b328c47c93991e210e26b3fad31f23870be51 1 parent a99651e
@efiring authored
Showing with 27 additions and 0 deletions.
  1. +1 −0  lib/matplotlib/__init__.py
  2. +26 −0 lib/matplotlib/tests/test_colors.py
View
1  lib/matplotlib/__init__.py
@@ -1008,6 +1008,7 @@ def tk_window_focus():
'matplotlib.tests.test_basic',
'matplotlib.tests.test_cbook',
'matplotlib.tests.test_colorbar',
+ 'matplotlib.tests.test_colors',
'matplotlib.tests.test_dates',
'matplotlib.tests.test_delaunay',
'matplotlib.tests.test_figure',
View
26 lib/matplotlib/tests/test_colors.py
@@ -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.array(a, dtype=dt)
+ aforeign = anative.byteswap().newbyteorder()
+ print(anative.dtype.isnative, aforeign.dtype.isnative)
+ assert_array_equal(cmap(anative), cmap(aforeign))
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.