Skip to content

Commit 31deac2

Browse files
committed
Small speed improvement in color mapping.
svn path=/trunk/matplotlib/; revision=5045
1 parent 59cdb2b commit 31deac2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/colors.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,11 @@ def __call__(self, X, alpha=1.0, bytes=False):
446446
lut = (self._lut * 255).astype(npy.uint8)
447447
else:
448448
lut = self._lut
449-
rgba = lut.take(xa, axis=0) # twice as fast as lut[xa]
449+
rgba = npy.empty(shape=xa.shape+(4,), dtype=lut.dtype)
450+
lut.take(xa, axis=0, mode='clip', out=rgba)
451+
# twice as fast as lut[xa];
452+
# using the clip or wrap mode and providing an
453+
# output array speeds it up a little more.
450454
if vtype == 'scalar':
451455
rgba = tuple(rgba[0,:])
452456
return rgba

0 commit comments

Comments
 (0)