@@ -227,44 +227,44 @@ def test_process_value_array(self):
227
227
assert_array_equal (res , np .array ([5. , 10. ]))
228
228
229
229
230
- class BaseOffsetNorm (BaseNormMixin ):
231
- normclass = mcolors .OffsetNorm
230
+ class BasePiecewiseLinearNorm (BaseNormMixin ):
231
+ normclass = mcolors .PiecewiseLinearNorm
232
232
test_inverse = False
233
233
234
- class test_OffsetNorm_Even ( BaseOffsetNorm ):
234
+ class test_PiecewiseLinearNorm_Even ( BasePiecewiseLinearNorm ):
235
235
def setup (self ):
236
236
self .norm = self .normclass (vmin = - 1 , vcenter = 0 , vmax = 4 )
237
237
self .vals = np .array ([- 1.0 , - 0.5 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 ])
238
238
self .expected = np .array ([0.0 , 0.25 , 0.5 , 0.625 , 0.75 , 0.875 , 1.0 ])
239
239
240
240
241
- class test_OffsetNorm_Odd ( BaseOffsetNorm ):
241
+ class test_PiecewiseLinearNorm_Odd ( BasePiecewiseLinearNorm ):
242
242
def setup (self ):
243
- self .normclass = mcolors .OffsetNorm
243
+ self .normclass = mcolors .PiecewiseLinearNorm
244
244
self .norm = self .normclass (vmin = - 2 , vcenter = 0 , vmax = 5 )
245
245
self .vals = np .array ([- 2.0 , - 1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 ])
246
246
self .expected = np .array ([0.0 , 0.25 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1.0 ])
247
247
248
248
249
- class test_OffsetNorm_AllNegative ( BaseOffsetNorm ):
249
+ class test_PiecewiseLinearNorm_AllNegative ( BasePiecewiseLinearNorm ):
250
250
def setup (self ):
251
- self .normclass = mcolors .OffsetNorm
251
+ self .normclass = mcolors .PiecewiseLinearNorm
252
252
self .norm = self .normclass (vmin = - 10 , vcenter = - 8 , vmax = - 2 )
253
253
self .vals = np .array ([- 10. , - 9. , - 8. , - 6. , - 4. , - 2. ])
254
254
self .expected = np .array ([0.0 , 0.25 , 0.5 , 0.666667 , 0.833333 , 1.0 ])
255
255
256
256
257
- class test_OffsetNorm_AllPositive ( BaseOffsetNorm ):
257
+ class test_PiecewiseLinearNorm_AllPositive ( BasePiecewiseLinearNorm ):
258
258
def setup (self ):
259
- self .normclass = mcolors .OffsetNorm
259
+ self .normclass = mcolors .PiecewiseLinearNorm
260
260
self .norm = self .normclass (vmin = 0 , vcenter = 3 , vmax = 9 )
261
261
self .vals = np .array ([0. , 1.5 , 3. , 4.5 , 6.0 , 7.5 , 9. ])
262
262
self .expected = np .array ([0.0 , 0.25 , 0.5 , 0.625 , 0.75 , 0.875 , 1.0 ])
263
263
264
264
265
- class test_OffsetNorm_NoVs ( BaseOffsetNorm ):
265
+ class test_PiecewiseLinearNorm_NoVs ( BasePiecewiseLinearNorm ):
266
266
def setup (self ):
267
- self .normclass = mcolors .OffsetNorm
267
+ self .normclass = mcolors .PiecewiseLinearNorm
268
268
self .norm = self .normclass (vmin = None , vcenter = None , vmax = None )
269
269
self .vals = np .array ([- 2.0 , - 1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 ])
270
270
self .expected = np .array ([0. , 0.16666667 , 0.33333333 ,
@@ -289,26 +289,26 @@ def test_vmax(self):
289
289
assert_equal (self .norm .vmax , self .expected_vmax )
290
290
291
291
292
- class test_OffsetNorm_VminEqualsVcenter ( BaseOffsetNorm ):
292
+ class test_PiecewiseLinearNorm_VminEqualsVcenter ( BasePiecewiseLinearNorm ):
293
293
def setup (self ):
294
- self .normclass = mcolors .OffsetNorm
294
+ self .normclass = mcolors .PiecewiseLinearNorm
295
295
self .norm = self .normclass (vmin = - 2 , vcenter = - 2 , vmax = 2 )
296
296
self .vals = np .array ([- 2.0 , - 1.0 , 0.0 , 1.0 , 2.0 ])
297
297
self .expected = np .array ([0.5 , 0.625 , 0.75 , 0.875 , 1.0 ])
298
298
299
299
300
- class test_OffsetNorm_VmaxEqualsVcenter ( BaseOffsetNorm ):
300
+ class test_PiecewiseLinearNorm_VmaxEqualsVcenter ( BasePiecewiseLinearNorm ):
301
301
def setup (self ):
302
- self .normclass = mcolors .OffsetNorm
302
+ self .normclass = mcolors .PiecewiseLinearNorm
303
303
self .norm = self .normclass (vmin = - 2 , vcenter = 2 , vmax = 2 )
304
304
self .vals = np .array ([- 2.0 , - 1.0 , 0.0 , 1.0 , 2.0 ])
305
305
self .expected = np .array ([0.0 , 0.125 , 0.25 , 0.375 , 0.5 ])
306
306
307
307
308
- class test_OffsetNorm_VsAllEqual ( BaseOffsetNorm ):
308
+ class test_PiecewiseLinearNorm_VsAllEqual ( BasePiecewiseLinearNorm ):
309
309
def setup (self ):
310
310
self .v = 10
311
- self .normclass = mcolors .OffsetNorm
311
+ self .normclass = mcolors .PiecewiseLinearNorm
312
312
self .norm = self .normclass (vmin = self .v , vcenter = self .v , vmax = self .v )
313
313
self .vals = np .array ([- 2.0 , - 1.0 , 0.0 , 1.0 , 2.0 ])
314
314
self .expected = np .array ([0.0 , 0.0 , 0.0 , 0.0 , 0.0 ])
@@ -321,28 +321,28 @@ def test_inverse(self):
321
321
)
322
322
323
323
324
- class test_OffsetNorm_Errors (object ):
324
+ class test_PiecewiseLinearNorm_Errors (object ):
325
325
def setup (self ):
326
326
self .vals = np .arange (50 )
327
327
328
328
@raises (ValueError )
329
329
def test_VminGTVcenter (self ):
330
- norm = mcolors .OffsetNorm (vmin = 10 , vcenter = 0 , vmax = 20 )
330
+ norm = mcolors .PiecewiseLinearNorm (vmin = 10 , vcenter = 0 , vmax = 20 )
331
331
norm (self .vals )
332
332
333
333
@raises (ValueError )
334
334
def test_VminGTVmax (self ):
335
- norm = mcolors .OffsetNorm (vmin = 10 , vcenter = 0 , vmax = 5 )
335
+ norm = mcolors .PiecewiseLinearNorm (vmin = 10 , vcenter = 0 , vmax = 5 )
336
336
norm (self .vals )
337
337
338
338
@raises (ValueError )
339
339
def test_VcenterGTVmax (self ):
340
- norm = mcolors .OffsetNorm (vmin = 10 , vcenter = 25 , vmax = 20 )
340
+ norm = mcolors .PiecewiseLinearNorm (vmin = 10 , vcenter = 25 , vmax = 20 )
341
341
norm (self .vals )
342
342
343
343
@raises (ValueError )
344
344
def test_premature_scaling (self ):
345
- norm = mcolors .OffsetNorm ()
345
+ norm = mcolors .PiecewiseLinearNorm ()
346
346
norm .inverse (np .array ([0.1 , 0.5 , 0.9 ]))
347
347
348
348
@@ -355,7 +355,7 @@ def test_offset_norm_img():
355
355
356
356
fig , (ax1 , ax2 ) = plt .subplots (ncols = 2 )
357
357
cmap = plt .cm .coolwarm
358
- norm = mcolors .OffsetNorm (vmin = - 2 , vcenter = 0 , vmax = 7 )
358
+ norm = mcolors .PiecewiseLinearNorm (vmin = - 2 , vcenter = 0 , vmax = 7 )
359
359
360
360
img1 = ax1 .imshow (Z , cmap = cmap , norm = None )
361
361
cbar1 = fig .colorbar (img1 , ax = ax1 )
0 commit comments