Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix None dataframe bug #95

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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