Skip to content

Commit

Permalink
Expose drop_duplicate_grid_labels in the public API
Browse files Browse the repository at this point in the history
- [ ] Write a test that the combine func never returns duplicate match_attrs. Before this fix keys from drop_duplicate_grid_labels would have variable_id in there twice!
  • Loading branch information
jbusecke authored Jun 25, 2024
1 parent aff6659 commit f717173
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions xmip/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,10 @@ def _pick_grid_label(ds_list, preferred_grid_label):
return ds_list[0]


def _drop_duplicate_grid_labels(ddict, preferred_grid_label):
def drop_duplicate_grid_labels(ddict, preferred_grid_label):
"""Eliminate multiple grid labels for the same dataset, by dropping multiples
with a preference for `preferred_grid_label`"""
match_attrs = [ma for ma in EXACT_ATTRS if ma not in ["version", "grid_label"]] + [
"variable_id"
]
match_attrs = [ma for ma in EXACT_ATTRS if ma not in ["version", "grid_label"]]
return combine_datasets(
ddict,
_pick_grid_label,
Expand Down Expand Up @@ -521,7 +519,7 @@ def interpolate_grid_label(
merge_kwargs.setdefault("combine_attrs", "drop_conflicts")

# first drop the datasets that might have both the target and another grid_label present
ds_dict = _drop_duplicate_grid_labels(ds_dict, target_grid_label)
ds_dict = drop_duplicate_grid_labels(ds_dict, target_grid_label)

return combine_datasets(
ds_dict,
Expand Down

0 comments on commit f717173

Please sign in to comment.