def calculate_number_of_available_data(self): """ | Calculate number of available data :return: {"temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign, "snowDepth": snowDepth} """ temp = Climate.number(self.tempMins) > 0 and Climate.number( self.tempMaxs) > 0 tempDist = Climate.number2(self.generate_temp_distribution()) > 0 rhDist = Climate.number2(self.generate_rh_distribution()) > 0 prec = Climate.number( self.collect_daily_precipitation()) > 0 and Climate.sum( self.collect_daily_precipitation()) > 0 windDist = Climate.number2(self.generate_wind_distribution(), True) > 0 sign = Climate.sum([ self.monthObjs[0].significants.get(i) for i in self.monthObjs[0].significants ]) > 0 snowDepth = Climate.number( self.collect_snow_depth()) > 0 and Climate.sum( self.collect_snow_depth()) > 0 return { "temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign, "snowDepth": snowDepth, }
def calculate_number_of_available_data(self): """ | Calculate number of available data for every months :return: {"temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign } """ temp = Climate.number( self.collect_monthly_data('tempMin')) > 0 and Climate.number( self.collect_monthly_data('tempMinAvg')) > 0 tempDist = Climate.number2(self.generate_temperature_distribution(), strict=True) > 0 rhDist = Climate.number2(self.generate_rh_distribution(), strict=True) > 0 prec = Climate.number( self.collect_monthly_data('precipitation')) > 0 and Climate.sum( self.collect_monthly_data('precipitation')) > 0 windDist = Climate.number2(self.generate_wind_distribution(), strict=True) > 0 sign = False for m in self.monthObjs: if Climate.sum([ self.monthObjs[0].significants.get(i) for i in self.monthObjs[0].significants ]) > 0: sign = True break return { "temp": temp, "tempDist": tempDist, "rhDist": rhDist, "prec": prec, "windDist": windDist, "sign": sign }
def test_num2_with_none_strict(self): self.assertEqual( Climate.number2([[0, 1, None], [2, None]], strict=True), 2)
def test_num2_not_none_strict(self): self.assertEqual( Climate.number2([[-5, 10, 0], [1, 3, 4]], strict=True), 5)
def test_num2_empty2_strict(self): self.assertEqual(Climate.number2([[], []], strict=True), 0)
def test_num2_only_none_strict(self): self.assertEqual(Climate.number2([[None], [None]], strict=True), 0)
def test_num2_not_none(self): self.assertEqual(Climate.number2([[-5, 10, 0], [1, 3, 4]]), 6)
def test_num2_with_none(self): self.assertEqual(Climate.number2([[0, 1, None], [2, None]]), 3)
def test_num2_only_none(self): self.assertEqual(Climate.number2([[None], [None]]), 0)
def test_num2_empty2(self): self.assertEqual(Climate.number2([[], []]), 0)
def test_num2_empty(self): self.assertEqual(Climate.number2([]), 0)