Commit 12246465 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Check also for numpy integers and floats in get_norm and to_scalar_mappable...

Check also for numpy integers and floats in get_norm and to_scalar_mappable methods of ThematicStyleIndividual, and in is_color_style method of ThematicStyle.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@7290 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent aa45dccc
...@@ -94,7 +94,7 @@ class ThematicStyle(object): ...@@ -94,7 +94,7 @@ class ThematicStyle(object):
## ThematicStyleColormap ## ThematicStyleColormap
return True return True
else: else:
if isinstance(style, (int, float)): if isinstance(style, (int, float, np.integer, np.floating)):
return False return False
else: else:
cc = matplotlib.colors.ColorConverter() cc = matplotlib.colors.ColorConverter()
...@@ -283,7 +283,7 @@ class ThematicStyleIndividual(ThematicStyle): ...@@ -283,7 +283,7 @@ class ThematicStyleIndividual(ThematicStyle):
""" """
## The norm is constructed in such a way that, if classes are numbers, ## The norm is constructed in such a way that, if classes are numbers,
## they will be placed below the corresponding color in the colorbar ## they will be placed below the corresponding color in the colorbar
if isinstance(self.values[0], (int, float)): if isinstance(self.values[0], (int, float, np.integer, np.floating)):
values = np.array(self.values) values = np.array(self.values)
else: else:
values = np.arange(len(self.values)) values = np.arange(len(self.values))
...@@ -309,7 +309,7 @@ class ThematicStyleIndividual(ThematicStyle): ...@@ -309,7 +309,7 @@ class ThematicStyleIndividual(ThematicStyle):
cmap = self.to_colormap() cmap = self.to_colormap()
sm = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap) sm = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap)
if values is None: if values is None:
if isinstance(self.values[0], (int, float)): if isinstance(self.values[0], (int, float, np.integer, np.floating)):
sm.set_array(self.values) sm.set_array(self.values)
else: else:
sm.set_array(np.arange(len(self.values))) sm.set_array(np.arange(len(self.values)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment