Skip to content

Commit

Permalink
Merge branch 'release-1.7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Milind220 committed Apr 23, 2022
2 parents 41d9926 + f21eea1 commit 1347d1b
Show file tree
Hide file tree
Showing 13 changed files with 22,017 additions and 257 deletions.
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: 'Create a report to help Ozone improve. Treat this template more as a guide
to filling a good issue, rather than a rulebook '
title: "[BUG]"
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment**
- OS: [e.g. MacOS]
- Python version [e.g. 3.9.12]
- Ozone Version [e.g. 1.7.1]
- Execution Environment [e.g. Jupyter Notebook]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ozon3
version = 1.7.2
version = 1.7.3
author = Milind Sharma
author_email = [email protected]
description = A package to get air quality data using the WAQI API
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
description="A package to get air quality data using the WAQI API",
license="GPLv3+",
url="https://github.com/Milind220/Ozone",
version="1.7.2",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.2.tar.gz",
version="1.7.3",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.3.tar.gz",
packages=setuptools.find_packages(),
install_requires=[
"numpy; python_version>='3'",
Expand Down
21 changes: 16 additions & 5 deletions src/ozone/ozone.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def _extract_forecast_data(self, data_obj: Any) -> pandas.DataFrame:
df.index = pandas.to_datetime(df.index)
return df

def _check_and_get_data_obj(self, r: requests.Response, **check_debug_info) -> dict:
def _check_and_get_data_obj(
self, r: requests.Response, **check_debug_info
) -> Union[dict, List[dict]]:
"""Get data object from API response and throw error if any is encouuntered
Args:
Expand All @@ -239,8 +241,8 @@ def _check_and_get_data_obj(self, r: requests.Response, **check_debug_info) -> d
city names to show it instead of just generic exception message.
Returns:
dict: The data object i.e. the `data` part of the API response,
in dictionary format (already JSON-ified).
Union[dict, List[dict]]: The data object i.e. the `data` part of the
API response, in dictionary or list format (already JSON-ified).
"""
self._check_status_code(r)
Expand All @@ -249,8 +251,11 @@ def _check_and_get_data_obj(self, r: requests.Response, **check_debug_info) -> d
status = response.get("status")
data = response.get("data")

if status == "ok" and isinstance(data, dict):
return data
if status == "ok":
if isinstance(data, dict) or isinstance(data, list):
# Only return data if status is ok and data is either dict or list.
# Otherwise it gets to exception raisers below.
return data

if isinstance(data, str):
if "Unknown station" in data:
Expand Down Expand Up @@ -657,6 +662,12 @@ def get_historical_data(
"you can use get_city_station_options method first to "
"identify the correct city ID."
)
else:
if city is not None:
warnings.warn(
"Both arguments city and city_id were supplied. "
"Only city_id will be used. city argument will be ignored."
)

df = get_data_from_id(city_id)
return self._format_output(data_format, df)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ interactions:
Content-Type:
- application/json; charset=UTF-8
Date:
- Fri, 22 Apr 2022 01:27:05 GMT
- Fri, 22 Apr 2022 17:39:52 GMT
Server:
- nginx
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
X-Gen-Time:
- "33.192\xC2\xB5s"
- "24.849\xC2\xB5s"
X-Powered-By:
- rxstreamer-waqi/1.3
content-length:
Expand Down
2,467 changes: 2,432 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_bad_data_format.yaml

Large diffs are not rendered by default.

2,467 changes: 2,432 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_column_expected_contents.yaml

Large diffs are not rendered by default.

2,467 changes: 2,432 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_column_types.yaml

Large diffs are not rendered by default.

2,467 changes: 2,432 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_excluded_params.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7,403 changes: 7,368 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_output_formats.yaml

Large diffs are not rendered by default.

2,467 changes: 2,432 additions & 35 deletions tests/cassettes/test_get_range_coordinates_air/test_return_value_and_format.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/test_get_range_coordinates_air.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def test_column_expected_contents():
# Sanity check: make sure lat-lon are within range
assert (result["latitude"] > LOWER_BOUND[0]).all()
assert (result["latitude"] < UPPER_BOUND[0]).all()
assert (result["longitude"] < LOWER_BOUND[1]).all()
assert (result["longitude"] > UPPER_BOUND[1]).all()
assert (result["longitude"] > LOWER_BOUND[1]).all()
assert (result["longitude"] < UPPER_BOUND[1]).all()

# Range of coordinates: no city was given, hence city must all be nan
assert numpy.isnan(result["city"]).all()
Expand Down

0 comments on commit 1347d1b

Please sign in to comment.