Skip to content

Commit

Permalink
Merge pull request #95 from ocefpaf/fix_none_dataframe_bug
Browse files Browse the repository at this point in the history
Fix None dataframe bug
  • Loading branch information
ocefpaf authored Mar 12, 2024
2 parents cf62043 + 4397814 commit 69a5ba9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gliderpy/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)

OptionalBool = bool | None
OptionalDF = pd.DataFrame | None
OptionalDict = dict | None
OptionalList = list[str] | tuple[str] | None
OptionalStr = str | None
Expand Down Expand Up @@ -80,7 +81,7 @@ def __init__(
)
self.fetcher.variables = server_vars[server]
self.fetcher.dataset_id: OptionalStr = None
self.datasets: OptionalBool = None
self.datasets: OptionalDF = None

def to_pandas(self: "GliderDataFetcher") -> pd.DataFrame:
"""Return data from the server as a pandas dataframe.
Expand All @@ -97,10 +98,7 @@ def to_pandas(self: "GliderDataFetcher") -> pd.DataFrame:
self.fetcher.dataset_id = None
return glider_df
else:
msg = (
f"Must provide a {self.fetcher.dataset_id} or "
"`query` terms to download data."
)
msg = "Must provide a dataset_id or query terms to download data."
raise ValueError(msg)

# Standardize variable names for the single dataset_id.
Expand Down Expand Up @@ -145,7 +143,7 @@ def query( # noqa: PLR0913
"longitude>=": min_lon,
"longitude<=": max_lon,
}
if not self.datasets:
if self.datasets is None:
url = self.fetcher.get_search_url(
search_for="glider",
response="csv",
Expand Down

0 comments on commit 69a5ba9

Please sign in to comment.