diff --git a/bpeng/bill/disaggregate.py b/bpeng/bill/disaggregate.py index 29b414b3cb72500e4e1b987ae86b13b700917725..b440941eb03e642fbeb88c559292452c71fe985c 100644 --- a/bpeng/bill/disaggregate.py +++ b/bpeng/bill/disaggregate.py @@ -273,8 +273,11 @@ class BillDisaggregation(): if (last_date - timedelta(365)).day != last_date.day: days_in_recent_year = 366 days_cumsum = np.array(output['Days In Bill']).cumsum() - periods_in_recent_year = \ - next(i for i, v in enumerate(days_cumsum) if v >= days_in_recent_year) + try: + periods_in_recent_year = \ + next(i for i, v in enumerate(days_cumsum) if v >= days_in_recent_year) + except StopIteration: + raise ArithmeticError('Days in bill less than one whole year.') bill_in_recent_year = output.iloc[:(periods_in_recent_year + 1)] values_in_recent_year = bill_in_recent_year.iloc[:, 2:].values values_in_recent_year[-1] *= \ diff --git a/bpeng/weather/weather.py b/bpeng/weather/weather.py index 6c9c3824987c708ca8fe12d28a9841434107478e..a7e09941b00f5a1bf346613afc3c267e239a32c0 100644 --- a/bpeng/weather/weather.py +++ b/bpeng/weather/weather.py @@ -392,5 +392,5 @@ class WeatherUnderground: dataframe_detail.columns = ['temperature', 'humidity', 'wind', 'rain'] dataframe_detail.index = self.day_list return dataframe_detail - except Exception as _: + except Exception: raise ValueError("Get detail weather first")