Skip to content

Commit

Permalink
Apply black 19.10 in conda default
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Dec 22, 2021
1 parent d282a4b commit a0d9763
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
8 changes: 2 additions & 6 deletions cfgrib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,7 @@ def __getitem__(self, item):


def build_geography_coordinates(
first: abc.Field,
encode_cf: T.Sequence[str],
errors: str,
log: logging.Logger = LOG,
first: abc.Field, encode_cf: T.Sequence[str], errors: str, log: logging.Logger = LOG,
) -> T.Tuple[T.Tuple[str, ...], T.Tuple[int, ...], T.Dict[str, Variable]]:
geo_coord_vars = {} # type: T.Dict[str, Variable]
grid_type = first["gridType"]
Expand Down Expand Up @@ -561,8 +558,7 @@ def build_variable_components(
if "time" in coord_vars and "step" in coord_vars:
# add the 'valid_time' secondary coordinate
time_dims, time_data = cfmessage.build_valid_time(
coord_vars["time"].data,
coord_vars["step"].data,
coord_vars["time"].data, coord_vars["step"].data,
)
attrs = COORD_ATTRS["valid_time"]
coord_vars["valid_time"] = Variable(dimensions=time_dims, data=time_data, attributes=attrs)
Expand Down
20 changes: 4 additions & 16 deletions cfgrib/xarray_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ def __init__(
opener = dataset.open_fieldset
self.ds = opener(filename, **backend_kwargs)

def open_store_variable(
self,
var: dataset.Variable,
) -> xr.Variable:
def open_store_variable(self, var: dataset.Variable,) -> xr.Variable:
if isinstance(var.data, np.ndarray):
data = var.data
else:
Expand Down Expand Up @@ -70,10 +67,7 @@ def get_encoding(self) -> T.Dict[str, T.Set[str]]:


class CfGribBackend(BackendEntrypoint):
def guess_can_open(
self,
store_spec: str,
) -> bool:
def guess_can_open(self, store_spec: str,) -> bool:
try:
_, ext = os.path.splitext(store_spec)
except TypeError:
Expand Down Expand Up @@ -145,17 +139,11 @@ def __init__(
self.dtype = array.dtype
self.array = array

def __getitem__(
self,
key: xr.core.indexing.ExplicitIndexer,
) -> np.ndarray:
def __getitem__(self, key: xr.core.indexing.ExplicitIndexer,) -> np.ndarray:
return xr.core.indexing.explicit_indexing_adapter(
key, self.shape, xr.core.indexing.IndexingSupport.BASIC, self._getitem
)

def _getitem(
self,
key: T.Tuple[T.Any, ...],
) -> np.ndarray:
def _getitem(self, key: T.Tuple[T.Any, ...],) -> np.ndarray:
with self.datastore.lock:
return self.array[key]
6 changes: 1 addition & 5 deletions tests/test_50_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ def test_canonical_dataset_to_grib(grib_name: str, tmpdir: py.path.local) -> Non


@pytest.mark.parametrize(
"grib_name,ndims",
[
("era5-levels-members", 1),
("era5-single-level-scalar-time", 0),
],
"grib_name,ndims", [("era5-levels-members", 1), ("era5-single-level-scalar-time", 0),],
)
def test_open_dataset_extra_coords(grib_name: str, ndims: T.Any) -> None:
grib_path = os.path.join(SAMPLE_DATA_FOLDER, grib_name + ".grib")
Expand Down

0 comments on commit a0d9763

Please sign in to comment.