Skip to content

Commit

Permalink
fix: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SlowMo24 committed Nov 16, 2023
1 parent fc9fc91 commit aa00c27
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
72 changes: 36 additions & 36 deletions ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

class _OhsomeBaseClient:
def __init__(
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
):
"""
Initialize _OhsomeInfoClient object
Expand Down Expand Up @@ -86,12 +86,12 @@ class _OhsomeInfoClient(_OhsomeBaseClient):
"""Client for metadata of ohsome API"""

def __init__(
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
):
"""
Initialize _OhsomeInfoClient object
Expand Down Expand Up @@ -161,7 +161,7 @@ def _query_metadata(self):
except requests.exceptions.ConnectionError:
raise OhsomeException(
message="Connection Error: Query could not be sent. Make sure there are no network "
f"problems and that the ohsome API URL {self._url} is valid.",
f"problems and that the ohsome API URL {self._url} is valid.",
url=self._url,
params=self._parameters,
)
Expand All @@ -180,12 +180,12 @@ class _OhsomePostClient(_OhsomeBaseClient):
"""Client for sending requests to ohsome API"""

def __init__(
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
self,
base_api_url=None,
log=DEFAULT_LOG,
log_dir=DEFAULT_LOG_DIR,
cache=None,
user_agent=None,
):
"""
Initialize _OhsomePostClient object
Expand All @@ -203,22 +203,22 @@ def __init__(
self._url = None

def post(
self,
bboxes=None,
bcircles=None,
bpolys=None,
time=None,
filter=None,
filter2=None,
format=None,
showMetadata=None,
timeout=None,
groupByKey=None,
groupByKeys=None,
groupByValues=None,
properties=None,
clipGeometry=None,
endpoint=None,
self,
bboxes=None,
bcircles=None,
bpolys=None,
time=None,
filter=None,
filter2=None,
format=None,
showMetadata=None,
timeout=None,
groupByKey=None,
groupByKeys=None,
groupByValues=None,
properties=None,
clipGeometry=None,
endpoint=None,
):
"""
Sends request to ohsome API
Expand Down Expand Up @@ -308,7 +308,7 @@ def _handle_request(self) -> OhsomeResponse:
except requests.exceptions.ConnectionError as e:
ohsome_exception = OhsomeException(
message="Connection Error: Query could not be sent. Make sure there are no network "
f"problems and that the ohsome API URL {self._url} is valid.",
f"problems and that the ohsome API URL {self._url} is valid.",
url=self._url,
params=self._parameters,
response=e.response,
Expand Down
4 changes: 2 additions & 2 deletions ohsome/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def convert_arrays(params: dict) -> dict:
for i in params.keys():
if isinstance(params[i], np.ndarray):
assert (
params[i].ndim == 1
params[i].ndim == 1
), f"Only one dimensional arrays are supported for parameter {i}"
params[i] = list(params[i])

Expand Down Expand Up @@ -65,7 +65,7 @@ def format_boundary(params: dict) -> dict:
else:
raise OhsomeException(
message="No valid boundary parameter is given. Specify one of the parameters 'bboxes', 'bpolys' or "
"'bcircles'.",
"'bcircles'.",
error_code=440,
params=params,
)
Expand Down
2 changes: 1 addition & 1 deletion ohsome/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _as_geodataframe(self, multi_index=True):
if multi_index:
features = features.set_index(["@osmId", "@snapshotTimestamp"])
elif (
"timestamp" in features.columns and "groupByBoundaryId" in features.columns
"timestamp" in features.columns and "groupByBoundaryId" in features.columns
):
features["timestamp"] = pd.to_datetime(
features["timestamp"], format="%Y-%m-%dT%H:%M:%SZ"
Expand Down
16 changes: 8 additions & 8 deletions ohsome/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def test_timeout_error(base_client):
bboxes=bboxes, time=time, filter=fltr, timeout=timeout
)
assert (
"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser "
"time period." in e_info.value.message
"The given query is too large in respect to the given timeout. Please use a smaller region and/or coarser "
"time period." in e_info.value.message
)


Expand Down Expand Up @@ -158,12 +158,12 @@ def test_exception_connection_reset(base_client):
"""

with patch(
"requests.Response.raise_for_status",
MagicMock(
side_effect=RequestException(
"This request was failed on purpose without response!"
)
),
"requests.Response.raise_for_status",
MagicMock(
side_effect=RequestException(
"This request was failed on purpose without response!"
)
),
), patch("ohsome.OhsomeException.log_response", MagicMock()) as mock_func:
bpolys = gpd.read_file(f"{script_path}/data/polygons.geojson")
time = "2018-01-01"
Expand Down
10 changes: 5 additions & 5 deletions ohsome/test/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def test_convert_arrays_multi_dim():
"""Test error raising on multi dim array."""
method_input = {"bbox": np.ndarray(shape=(2, 2))}
with pytest.raises(
AssertionError,
match="Only one dimensional arrays are supported for parameter bbox",
AssertionError,
match="Only one dimensional arrays are supported for parameter bbox",
):
convert_arrays(method_input)

Expand Down Expand Up @@ -184,9 +184,9 @@ def test_format_time():
def test_format_time_error_format_not_supported():
"""Test weather a time with wrong type (e.g. a dict) raises an error."""
with pytest.raises(
ValueError,
match="The given time format <class 'dict'> is not supported. Feel free to open an "
"issue in the ohsome-py repository for a feature request.",
ValueError,
match="The given time format <class 'dict'> is not supported. Feel free to open an "
"issue in the ohsome-py repository for a feature request.",
):
format_time({})

Expand Down

0 comments on commit aa00c27

Please sign in to comment.