File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -579,6 +579,16 @@ def _get_label(inputs):
579579 if not isinstance (inputs ,dict ):
580580 raise TypeError ("_get_label input must be dictionary." )
581581
582+ # handle units specially.
583+ units = {"m" ,"km" ,
584+ "deg" ,"rad" ,
585+ "sec" ,"s" ,"hr" ,"min" ,
586+ "mps" ,
587+ }
588+ unit_replacements = {
589+ "mps" : "m/s" ,
590+ }
591+
582592 label = ""
583593 for key , value in inputs .items ():
584594
@@ -593,8 +603,14 @@ def _get_label(inputs):
593603 except ValueError :
594604 pass
595605
596- value = value .upper ()
597- value = value .replace ("_" ," " )
606+ value = value .split ("_" )
607+ if value [- 1 ] in units :
608+ # make units lowercase and bracketed.
609+ if value [- 1 ] in unit_replacements :
610+ value [- 1 ] = unit_replacements [value [- 1 ]]
611+ value = " " .join (value [:- 1 ]).upper () + " [" + value [- 1 ] + "]"
612+ else :
613+ value = " " .join (value ).upper ()
598614
599615 if key == "gnss_id" : # use GNSS specific capitalization
600616 constellation_map = {"GALILEO" : "Galileo" ,
Original file line number Diff line number Diff line change @@ -415,6 +415,10 @@ def test_get_label():
415415 assert viz ._get_label ({"gnss_id" : "galileo" ,
416416 "signal_type" : "b1i" }) == "Galileo B1i"
417417
418+ assert viz ._get_label ({"row" : "x_rx_m" }) == "X RX [m]"
419+ assert viz ._get_label ({"row" : "lat_rx_deg" }) == "LAT RX [deg]"
420+ assert viz ._get_label ({"row" : "vx_sv_mps" }) == "VX SV [m/s]"
421+
418422 with pytest .raises (TypeError ) as excinfo :
419423 viz ._get_label (["should" ,"fail" ])
420424 assert "dictionary" in str (excinfo .value )
You can’t perform that action at this time.
0 commit comments