|
31 | 31 |
|
32 | 32 | import numpy as np |
33 | 33 |
|
34 | | -from pygeoapi.provider.base import ProviderNoDataError, ProviderQueryError, ProviderInvalidQueryError |
| 34 | +from pygeoapi.provider.base import (ProviderNoDataError, ProviderQueryError, |
| 35 | + ProviderInvalidQueryError) |
35 | 36 | from pygeoapi.provider.base_edr import BaseEDRProvider |
36 | 37 | from pygeoapi.provider.xarray_ import ( |
37 | 38 | _to_datetime_string, |
@@ -122,13 +123,18 @@ def position(self, **kwargs): |
122 | 123 | if isinstance(dims, dict): |
123 | 124 | for coord, level in dims.items(): |
124 | 125 | if coord in self._dims: |
125 | | - if self._dims[coord]['type'](level) in self._dims[coord]['values']: |
| 126 | + if self._dims[coord]['type'](level) in self._dims[coord]['values']: # noqa |
126 | 127 | if self._dims[coord]['type'] == str: |
127 | | - string_query[coord] = self._dims[coord]['type'](level) |
| 128 | + string_query[coord] = self._dims[coord]['type'](level) # noqa |
128 | 129 | else: |
129 | | - query_params[coord] = self._dims[coord]['type'](level) |
| 130 | + query_params[coord] = self._dims[coord]['type'](level) # noqa |
130 | 131 | else: |
131 | | - raise ProviderInvalidQueryError(user_msg=f"""Invalid Value '{level}' for Dimension Parameter '{coord}'. Valid Values are '{self._dims[coord]['values']}'""") |
| 132 | + raise ProviderInvalidQueryError( |
| 133 | + user_msg=( |
| 134 | + f"Invalid Value '{level}' for Dimension Parameter '{coord}'. " # noqa |
| 135 | + f"Valid Values are '{self._dims[coord]['values']}'" # noqa |
| 136 | + ) |
| 137 | + ) |
132 | 138 |
|
133 | 139 | data = data.sel(string_query) |
134 | 140 | else: |
@@ -241,18 +247,22 @@ def cube(self, **kwargs): |
241 | 247 | if isinstance(dims, dict): |
242 | 248 | for coord, level in dims.items(): |
243 | 249 | if coord in self._dims: |
244 | | - if self._dims[coord]['type'](level) in self._dims[coord]['values']: |
| 250 | + if self._dims[coord]['type'](level) in self._dims[coord]['values']: # noqa |
245 | 251 | if self._dims[coord]['type'] == str: |
246 | | - string_query[coord] = self._dims[coord]['type'](level) |
| 252 | + string_query[coord] = self._dims[coord]['type'](level) # noqa |
247 | 253 | else: |
248 | | - query_params[coord] = self._dims[coord]['type'](level) |
| 254 | + query_params[coord] = self._dims[coord]['type'](level) # noqa |
249 | 255 | else: |
250 | 256 | raise ProviderInvalidQueryError( |
251 | | - user_msg=f"""Invalid Value '{level}' for Dimension Parameter '{coord}'. Valid Values are '{self._dims[coord]['values']}'""") |
| 257 | + user_msg=( |
| 258 | + f"Invalid Value '{level}' for Dimension Parameter '{coord}'. " # noqa |
| 259 | + f"Valid Values are '{self._dims[coord]['values']}'" # noqa |
| 260 | + ) |
| 261 | + ) |
252 | 262 |
|
253 | 263 | data = data.sel(string_query) |
254 | 264 | else: |
255 | | - raise ProviderInvalidQueryError(user_msg=f"""Invalid Dimension Parameter '{coord}'""") |
| 265 | + raise ProviderInvalidQueryError(user_msg=f"""Invalid Dimension Parameter '{coord}'""") # noqa |
256 | 266 |
|
257 | 267 | data = data.sel(query_params) |
258 | 268 | data = _convert_float32_to_float64(data) |
|
0 commit comments