File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 123
123
from matplotlib .rcsetup import (defaultParams ,
124
124
validate_backend )
125
125
126
+ from collections import Hashable
127
+ import numbers
126
128
import numpy
127
129
from matplotlib .externals .six .moves .urllib .request import urlopen
128
130
from matplotlib .externals .six .moves import reload_module as reload
@@ -1517,15 +1519,11 @@ def test(verbosity=1):
1517
1519
1518
1520
1519
1521
def _replacer (data , key ):
1520
- # if key isn't a string don't bother
1521
- if not isinstance (key , six .string_types ):
1522
- return key
1523
- # try to use __getitem__
1524
- try :
1525
- return data [key ]
1526
- # key does not exist, silently fall back to key
1527
- except KeyError :
1522
+ # don't bother if key is a number or array, or not a possible hash key
1523
+ if isinstance (key , (numbers .Number , numpy .ndarray )) or not isinstance (key , Hashable ):
1528
1524
return key
1525
+ # try to use __getitem__, otherwise fall back to key
1526
+ return data .get (key , key )
1529
1527
1530
1528
1531
1529
def unpack_labeled_data (wl_args = None , wl_kwargs = None , label_pos = None ):
You can’t perform that action at this time.
0 commit comments