8000 expanded CenteredNorm testing · matplotlib/matplotlib@101d08d · GitHub
[go: up one dir, main page]

Skip to content

Commit 101d08d

Browse files
committed
expanded CenteredNorm testing
1 parent 5c0dadb commit 101d08d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,19 @@ def test_CenteredNorm():
395395
norm.vcenter = 2
396396
assert_array_almost_equal(x, 4 * norm(x))
397397

398+
# Check that manual change of vcenter adjusts halfrange accordingly.
399+
norm = mcolors.CenteredNorm()
400+
assert norm.vcenter == 0
401+
# add data
402+
norm(np.linspace(-1.0, 0.0, 10))
403+
assert norm.vmax == 1.0
404+
assert norm.halfrange == 1.0
405+
# set vcenter to 1, which should double halfrange
406+
norm.vcenter = 1
407+
assert norm.vmin == -1.0
408+
assert norm.vmax == 3.0
409+
assert norm.halfrange == 2.0
410+
398411

399412
@pytest.mark.parametrize("vmin,vmax", [[-1, 2], [3, 1]])
400413
def test_lognorm_invalid(vmin, vmax):

0 commit comments

Comments
 (0)
0