@@ -1811,3 +1811,44 @@ def test_LinearSegmentedColormap_from_list_value_color_tuple():
18111811 cmap ([value for value , _ in value_color_tuples ]),
18121812 to_rgba_array ([color for _ , color in value_color_tuples ]),
18131813 )
1814+
1815+
1816+ def test_multi_norm ():
1817+ # tests for mcolors.MultiNorm
1818+
1819+ # test wrong input
1820+ with pytest .raises (ValueError ,
1821+ match = "A MultiNorm must be assigned multiple norms" ):
1822+ mcolors .MultiNorm ("bad_norm_name" )
1823+ with pytest .raises (ValueError ,
1824+ match = "Invalid norm str name" ):
1825+ mcolors .MultiNorm (["bad_norm_name" ])
1826+
1827+ # test get vmin, vmax
1828+ norm = mpl .colors .MultiNorm (['linear' , 'log' ])
1829+ norm .vmin = 1
1830+ norm .vmax = 2
1831+ assert norm .vmin [0 ] == 1
1832+ assert norm .vmin [1 ] == 1
1833+ assert norm .vmax [0 ] == 2
1834+ assert norm .vmax [1 ] == 2
1835+
1836+ # test call with clip
1837+ assert_array_equal (norm ([3 , 3 ], clip = False ), [2.0 , 1.584962500721156 ])
1838+ assert_array_equal (norm ([3 , 3 ], clip = True ), [1.0 , 1.0 ])
1839+ assert_array_equal (norm ([3 , 3 ], clip = [True , False ]), [1.0 , 1.584962500721156 ])
1840+ norm .clip = False
1841+ assert_array_equal (norm ([3 , 3 ]), [2.0 , 1.584962500721156 ])
1842+ norm .clip = True
1843+ assert_array_equal (norm ([3 , 3 ]), [1.0 , 1.0 ])
1844+ norm .clip = [True , False ]
1845+ assert_array_equal (norm ([3 , 3 ]), [1.0 , 1.584962500721156 ])
1846+ norm .clip = True
1847+
1848+ # test inverse
1849+ assert_array_almost_equal (norm .inverse ([0.5 , 0.5849625007211562 ]), [1.5 , 1.5 ])
1850+
1851+ # test autoscale
1852+ norm .autoscale ([[0 , 1 , 2 , 3 ], [0.1 , 1 , 2 , 3 ]])
1853+ assert_array_equal (norm .vmin , [0 , 0.1 ])
1854+ assert_array_equal (norm .vmax , [3 , 3 ])
0 commit comments