Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaHutter committed Oct 25, 2024
1 parent 9b5a4bb commit 7875291
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def aggregate_temporal(
labels_nans = labels_nans[~mask]

intervals_flat = np.unique(intervals_flat)
data[t] = data[t].values.astype("float")
data[t] = np.datetime64(data[t].values).astype("float")
grouped_data = data.groupby_bins(t, bins=intervals_flat)
positional_parameters = {"data": 0}
groups = grouped_data.reduce(
reducer, keep_attrs=True, positional_parameters=positional_parameters
)
groups[t + "_bins"] = labels_nans
data_agg_temp = groups.sel({t + "_bins": labels})
data_agg_temp = data_agg_temp.rename(t + "_bins", t)
data_agg_temp = data_agg_temp.rename({t + "_bins": t})

return data_agg_temp

Expand Down
3 changes: 2 additions & 1 deletion tests/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
@pytest.mark.parametrize("size", [(6, 5, 100, 4)])
@pytest.mark.parametrize("dtype", [np.float64])
@pytest.mark.parametrize(
"temporal_extent,intervals,expected",
"temporal_extent,intervals,labels, expected",
[
(
["2018-01-01", "2019-01-01"],
[
["2018-01-01T12:00:00", "2018-06-01T12:00:00"],
["2018-07-01T12:00:00", "2018-12-01T12:00:00"],
],
["half-1", "half-2"],
2,
)
],
Expand Down

0 comments on commit 7875291

Please sign in to comment.