@@ -360,25 +360,41 @@ def test_BoundaryNorm():
360360
361361
362362def test_CenteredNorm ():
363+ np .random .seed (0 )
364+
363365 # Assert equivalence to symmetrical Normalize.
364366 x = np .random .normal (size = 100 )
365367 x_maxabs = np .max (np .abs (x ))
366368 norm_ref = mcolors .Normalize (vmin = - x_maxabs , vmax = x_maxabs )
367369 norm = mcolors .CenteredNorm ()
368370 assert_array_almost_equal (norm_ref (x ), norm (x ))
371+
369372 # Check that vcenter is in the center of vmin and vmax
370373 # when vcenter is set.
371374 vcenter = int (np .random .normal (scale = 50 ))
372375 norm = mcolors .CenteredNorm (vcenter = vcenter )
373376 norm .autoscale_None ([1 , 2 ])
374377 assert norm .vmax + norm .vmin == 2 * vcenter
378+
375379 # Check that halfrange input works correctly.
376380 x = np .random .normal (size = 10 )
377381 norm = mcolors .CenteredNorm (vcenter = 0.5 , halfrange = 0.5 )
378382 assert_array_almost_equal (x , norm (x ))
379383 norm = mcolors .CenteredNorm (vcenter = 1 , halfrange = 1 )
380384 assert_array_almost_equal (x , 2 * norm (x ))
381385
386+ # Check that halfrange input works correctly and use setters.
387+ norm = mcolors .CenteredNorm ()
388+ norm .vcenter = 2
389+ norm .halfrange = 2
390+ assert_array_almost_equal (x , 4 * norm (x ))
391+
392+ # Check that prior to adding data, setting halfrange first has same effect.
393+ norm = mcolors .CenteredNorm ()
394+ norm .halfrange = 2
395+ norm .vcenter = 2
396+ assert_array_almost_equal (x , 4 * norm (x ))
397+
382398
383399@pytest .mark .parametrize ("vmin,vmax" , [[- 1 , 2 ], [3 , 1 ]])
384400def test_lognorm_invalid (vmin , vmax ):
0 commit comments