Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and kmuehlbauer committed Jan 5, 2023
1 parent 2f61796 commit 3da2ded
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def test_concat_str_dtype(self, dtype, dim) -> None:
def test_concat_fill_missing_variables(self, dim, coord):
# create var names list with one missing value
def get_var_names(var_cnt=10, list_cnt=10):
orig = [f'd{i:02d}' for i in range(var_cnt)]
orig = [f"d{i:02d}" for i in range(var_cnt)]
var_names = []
for i in range(0, list_cnt):
l1 = orig.copy()
Expand All @@ -603,15 +603,19 @@ def create_ds(var_names, dim=False, coord=False, drop_idx=False):
dsi = dsi.isel(time=0)
out_ds.append(dsi)
return out_ds

var_names = get_var_names()

import random

random.seed(42)
drop_idx = [random.randrange(len(vlist)) for vlist in var_names]
expected = concat(create_ds(var_names, dim=dim, coord=coord), dim="time", data_vars="all")
expected = concat(
create_ds(var_names, dim=dim, coord=coord), dim="time", data_vars="all"
)
for i, idx in enumerate(drop_idx):
if dim:
expected[var_names[0][idx]][i * 2: i * 2 + 2] = np.nan
expected[var_names[0][idx]][i * 2 : i * 2 + 2] = np.nan
else:
expected[var_names[0][idx]][i] = np.nan

Expand Down

0 comments on commit 3da2ded

Please sign in to comment.