From 051cd235eff2fd9f2c85e3a887e2e27b32b2144d Mon Sep 17 00:00:00 2001 From: Christian Lamprecht Date: Wed, 17 Aug 2022 14:25:43 -0400 Subject: [PATCH] Meteostat 1.6.5 (#109) * Meteostat 1.6.5 * Ignore consider-using-set-comprehension --- .pylintrc | 3 ++- meteostat/__init__.py | 2 +- meteostat/interface/hourly.py | 18 ++++++++++++------ meteostat/utilities/mutations.py | 9 +++++++-- setup.py | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.pylintrc b/.pylintrc index 344d861..b520d24 100644 --- a/.pylintrc +++ b/.pylintrc @@ -9,7 +9,8 @@ disable=print-statement, import-outside-toplevel, duplicate-code, import-error, - nan-comparison + nan-comparison, + consider-using-set-comprehension [BASIC] diff --git a/meteostat/__init__.py b/meteostat/__init__.py index 57e4ccb..5130865 100644 --- a/meteostat/__init__.py +++ b/meteostat/__init__.py @@ -12,7 +12,7 @@ """ __appname__ = "meteostat" -__version__ = "1.6.4" +__version__ = "1.6.5" from .interface.base import Base from .interface.timeseries import TimeSeries diff --git a/meteostat/interface/hourly.py b/meteostat/interface/hourly.py index 1aab232..d5ba952 100644 --- a/meteostat/interface/hourly.py +++ b/meteostat/interface/hourly.py @@ -104,8 +104,11 @@ def _set_time( Set & adapt the period's time zone """ - if timezone: + # Don't use chunks if full dataset is requested + if start == None: + self.chunked = False + if timezone: # Save timezone self._timezone = timezone @@ -121,11 +124,14 @@ def _set_time( end = timezone.localize(end, is_dst=None).astimezone(pytz.utc) if self.chunked: - - self._annual_steps = [ - (start + timedelta(days=365 * i)).year - for i in range(end.year - start.year + 2) - ] + self._annual_steps = list( + set( + [ + (start + timedelta(days=365 * i)).year + for i in range(end.year - start.year + 2) + ] + ) + ) self._start = start self._end = end diff --git a/meteostat/utilities/mutations.py b/meteostat/utilities/mutations.py index acef1ec..c279d1a 100644 --- a/meteostat/utilities/mutations.py +++ b/meteostat/utilities/mutations.py @@ -9,6 +9,7 @@ """ from datetime import datetime +from typing import Union import numpy as np import pandas as pd @@ -21,7 +22,11 @@ def localize(df: pd.DataFrame, timezone: str) -> pd.DataFrame: return df.tz_localize("UTC", level="time").tz_convert(timezone, level="time") -def filter_time(df: pd.DataFrame, start: datetime, end: datetime) -> pd.DataFrame: +def filter_time( + df: pd.DataFrame, + start: Union[datetime, None] = None, + end: Union[datetime, None] = None, +) -> pd.DataFrame: """ Filter time series data based on start and end date """ @@ -30,7 +35,7 @@ def filter_time(df: pd.DataFrame, start: datetime, end: datetime) -> pd.DataFram time = df.index.get_level_values("time") # Filter & return - return df.loc[(time >= start) & (time <= end)] + return df.loc[(time >= start) & (time <= end)] if start and end else df def adjust_temp(df: pd.DataFrame, alt: int): diff --git a/setup.py b/setup.py index 289af3b..3364561 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ # Setup setup( name="meteostat", - version="1.6.4", + version="1.6.5", author="Meteostat", author_email="info@meteostat.net", description="Access and analyze historical weather and climate data with Python.",