@@ -122,6 +122,7 @@ def test_cmap_and_norm_from_levels_and_colors2():
122
122
clr = mcolors .colorConverter .to_rgba_array (colors )
123
123
bad = (0.1 , 0.1 , 0.1 , 0.1 )
124
124
no_color = (0.0 , 0.0 , 0.0 , 0.0 )
125
+ masked_value = 'masked value'
125
126
126
127
# Define the test values which are of interest.
127
128
# Note: levels are lev[i] <= v < lev[i+1]
@@ -131,38 +132,40 @@ def test_cmap_and_norm_from_levels_and_colors2():
131
132
2.25 : clr [2 ],
132
133
3 : clr [4 ],
133
134
3.5 : clr [4 ],
134
- np . ma . array ( 1 , mask = True ) : bad }),
135
+ masked_value : bad }),
135
136
136
137
('min' , - 1 , {- 2 : clr [0 ],
137
138
- 1 : clr [1 ],
138
139
2 : clr [2 ],
139
140
2.25 : clr [2 ],
140
141
3 : no_color ,
141
142
3.5 : no_color ,
142
- np . ma . array ( 1 , mask = True ) : bad }),
143
+ masked_value : bad }),
143
144
144
145
('max' , - 1 , {- 2 : no_color ,
145
146
- 1 : clr [0 ],
146
147
2 : clr [1 ],
147
148
2.25 : clr [1 ],
148
149
3 : clr [3 ],
149
150
3.5 : clr [3 ],
150
- np . ma . array ( 1 , mask = True ) : bad }),
151
+ masked_value : bad }),
151
152
152
153
('neither' , - 2 , {- 2 : no_color ,
153
154
- 1 : clr [0 ],
154
155
2 : clr [1 ],
155
156
2.25 : clr [1 ],
156
157
3 : no_color ,
157
158
3.5 : no_color ,
158
- np . ma . array ( 1 , mask = True ) : bad }),
159
+ masked_value : bad }),
159
160
]
160
161
161
162
for extend , i1 , cases in tests :
162
163
cmap , norm = mcolors .from_levels_and_colors (levels , colors [0 :i1 ],
163
164
extend = extend )
164
165
cmap .set_bad (bad )
165
166
for d_val , expected_color in sorted (cases .items ()):
167
+ if d_val == masked_value :
168
+ d_val = np .ma .array (1 , mask = True )
166
169
assert_array_equal (expected_color , cmap (norm ([d_val ]))[0 ],
167
170
'Wih extend={0!r} and data '
168
171
'value={1!r}' .format (extend , d_val ))
0 commit comments