FAIL: matplotlib.tests.test_transforms.test_pre_transform_plotting.test on Python 3.x #1120

Merged
merged 1 commit into from Sep 5, 2012
@@ -4,7 +4,7 @@
"""
-from __future__ import print_function
+from __future__ import print_function, division
import numpy as np
_binary_data = {
@@ -1625,7 +1625,7 @@ def gfunc32(x):
}
# This bipolar color map was generated from CoolWarmFloat33.csv of
-# "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland.
+# "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland.
# <http://www.cs.unm.edu/~kmorel/documents/ColorMaps/>
_coolwarm_data = {
'red': [
@@ -4,7 +4,7 @@
and a mixin class for adding color mapping functionality.
"""
-from __future__ import print_function
+from __future__ import print_function, division
import os
@@ -158,7 +158,7 @@ def get_transforms(self):
def get_offset_transform(self):
t = self._transOffset
- if (not isinstance(t, transforms.Transform)
+ if (not isinstance(t, transforms.Transform)
and hasattr(t, '_as_mpl_transform')):
t = t._as_mpl_transform(self.axes)
return t
@@ -48,7 +48,7 @@
Finally, legal html names for colors, like 'red', 'burlywood' and
'chartreuse' are supported.
"""
-from __future__ import print_function
+from __future__ import print_function, division
import re
import numpy as np
from numpy import ma
@@ -219,7 +219,7 @@ def is_color_like(c):
def rgb2hex(rgb):
'Given an rgb or rgba sequence of 0-1 floats, return the hex string'
- return '#%02x%02x%02x' % tuple([round(val*255) for val in rgb[:3]])
+ return '#%02x%02x%02x' % tuple([np.round(val*255) for val in rgb[:3]])
@efiring
efiring Sep 4, 2012 Member

Micro-optimization: the part on the right is a bit quicker and perhaps more readable as
tuple(np.round(np.asarray(rgb[:3]) * 255)).

Or tuple((np.asarray(rgb[:3]) * 255).round()), which is slightly more efficient. Not that efficiency matters at this microsecond level.

@WeatherGod
WeatherGod Sep 4, 2012 Member

watch out when doing asarray(). We support masked arrays, so it really should be asanyarray(). Although, admittedly, in this context, it probably makes no difference.

@efiring
efiring Sep 4, 2012 Member

Agreed, but I don't think either version would work sensibly with rgb as a masked array. And the docstring says "floats", with no mention of masked array support.

hexColorPattern = re.compile("\A#[a-fA-F0-9]{6}\Z")
@@ -15,7 +15,7 @@
"""
-from __future__ import print_function
+from __future__ import print_function, division
import numpy as np
from numpy import ma
import matplotlib.collections as collections
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.