def wind(direction: Number, speed: Number, gust: Number, vardir: [Number] = None, unit: str = 'kt') -> str: """ Format wind details into a spoken word string """ unit = SPOKEN_UNITS.get(unit, unit) val = translate.wind(direction, speed, gust, vardir, unit, cardinals=False, spoken=True) return 'Winds ' + (val or 'unknown')
def test_wind(self): """ Tests that wind values are translating into a single string """ for *wind, vardir, translation in ( ('', '', '', None, ''), ('360', '12', '20', ['340', '020'], 'N-360 (variable 340 to 020) at 12kt gusting to 20kt'), ('000', '00', '', None, 'Calm'), ('VRB', '5', '12', None, 'Variable at 5kt gusting to 12kt'), ('270', '10', '', ['240', '300'], 'W-270 (variable 240 to 300) at 10kt'), ): wind = [core.make_number(i) for i in wind] if vardir: vardir = [core.make_number(i) for i in vardir] self.assertEqual(translate.wind(*wind, vardir), translation)
def wind( direction: Number, speed: Number, gust: Number, vardir: [Number] = None, unit: str = "kt", ) -> str: """ Format wind details into a spoken word string """ unit = SPOKEN_UNITS.get(unit, unit) val = translate.wind( direction, speed, gust, vardir, unit, cardinals=False, spoken=True ) return "Winds " + (val or "unknown")
def wind(wdir: str, wspd: str, wgst: str, wvar: [str] = None, unit: str = 'kt') -> str: """ Format wind details into a spoken word string """ if unit in SPOKEN_UNITS: unit = SPOKEN_UNITS[unit] if wdir not in ('000', 'VRB'): wdir = numbers(wdir) wvar = wvar if not wvar is None else [] for i, val in enumerate(wvar): wvar[i] = numbers(val) return 'Winds ' + translate.wind(wdir, remove_leading_zeros(wspd), remove_leading_zeros(wgst), wvar, unit, cardinals=False)
def test_wind(self): """ Tests that wind values are translating into a single string """ for *wind, vardir, translation in ( ("", "", "", None, ""), ( "360", "12", "20", ["340", "020"], "N-360 (variable 340 to 020) at 12kt gusting to 20kt", ), ("000", "00", "", None, "Calm"), ("VRB", "5", "12", None, "Variable at 5kt gusting to 12kt"), ("270", "10", "", ["240", "300"], "W-270 (variable 240 to 300) at 10kt"), ): wind = [_core.make_number(i) for i in wind] if vardir: vardir = [_core.make_number(i) for i in vardir] self.assertEqual(translate.wind(*wind, vardir), translation)