@@ -575,8 +575,29 @@ def test_createcolordata_remask():
575
575
data = ColorMapStyleDef .create_colordata (da , rgb , 0.0 , np .array ([True , True , True , True , True , True ]))
576
576
assert (np .isfinite (data ["red" ][0 :3 :1 ])).all ()
577
577
assert (np .isnan (data ["red" ][4 :5 :1 ])).all ()
578
-
579
-
580
-
581
-
582
578
579
+ def test_scale_ramp ():
580
+ from datacube_ows .styles .ramp import scale_unscaled_ramp
581
+
582
+ input = [
583
+ {"value" : 0.0 , "color" : "red" , "alpha" : 0.5 },
584
+ {"value" : 0.5 , "color" : "green" },
585
+ {"value" : 1.0 , "color" : "blue" },
586
+ ]
587
+ output = scale_unscaled_ramp (- 100.0 , 100.0 , input )
588
+ assert output [0 ]["color" ] == "red"
589
+ assert output [0 ]["alpha" ] == 0.5
590
+ assert output [0 ]["value" ] == - 100.0
591
+ assert output [1 ]["color" ] == "green"
592
+ assert output [1 ]["alpha" ] == 1.0
593
+ assert output [1 ]["value" ] == 0.0
594
+ assert output [2 ]["color" ] == "blue"
595
+ assert output [2 ]["alpha" ] == 1.0
596
+ assert output [2 ]["value" ] == 100.0
597
+
598
+ def test_bad_mpl_ramp ():
599
+ from datacube_ows .styles .ramp import read_mpl_ramp
600
+
601
+ with pytest .raises (ConfigException ) as e :
602
+ ramp = read_mpl_ramp ("definitely_not_a_real_matplotlib_ramp_name" )
603
+ assert "Invalid Matplotlib name: " in str (e .value )
0 commit comments