Skip to content

Commit

Permalink
FIX: do not mutate Series input to Normalize()
Browse files Browse the repository at this point in the history
This forces a copy in all cases.  For input sequences which are base
python (list, tuple, deque, ...) this will cause a second un-needed copy
of all of the data, but will force the required copy in the case where
the the input values is enough ndarray-like for `ma.asarray` to re-use
memory.

closes #5427
  • Loading branch information
tacaswell committed Dec 22, 2015
1 parent 5ccc604 commit b25c50b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/matplotlib/colors.py
Expand Up @@ -904,8 +904,11 @@ def process_value(value):
is_scalar = False
result = ma.asarray(value)
if result.dtype.kind == 'f':
if isinstance(value, np.ndarray):
result = result.copy()
# this is overkill for lists of floats, but required
# to support pd.Series as input until we can reliable
# determine if result and value share memory in all cases
# (list, tuple, deque, ndarray, Series, ...)
result = result.copy()
elif result.dtype.itemsize > 2:
result = result.astype(np.float)
else:
Expand Down

0 comments on commit b25c50b

Please sign in to comment.