Skip to content

Commit e40db42

Browse files
Set compat='no_conflicts' explicitly (#1802)
Fixes #1796 # Description Explicitly set compat='no_conflicts' to quell a noisy warning thrown repeatedly, as we call xr.merge a lot. This is the current default of xarray. We can later reconsider if this should be "override" in some cases. This would increase performance, at the risk of providing unexpected results when incorrect data is provided. We'd have to profile this on a heavy case (e.g. our user acceptance test) to see if it increases performance. # Checklist <!--- Before requesting review, please go through this checklist: --> - [x] Links to correct issue - [ ] Update changelog, if changes affect users - [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737`` - [ ] Unit tests were added - [ ] **If feature added**: Added/extended example - [ ] **If feature added**: Added feature to API documentation - [ ] **If pixi.lock was changed**: Ran `pixi run generate-sbom` and committed changes
1 parent 54940d4 commit e40db42

6 files changed

Lines changed: 19 additions & 11 deletions

File tree

imod/formats/prj/prj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def _create_dataarray(
621621
dav = _create_dataarray_from_values(values_valid, headers_values, dim=dim)
622622
dap.name = "tmp"
623623
dav.name = "tmp"
624-
da = xr.merge((dap, dav), join="outer")["tmp"]
624+
da = xr.merge((dap, dav), join="outer", compat="no_conflicts")["tmp"]
625625
elif paths_valid:
626626
# Only paths provided
627627
da = _create_dataarray_from_paths(paths_valid, headers_paths, dim=dim)

imod/mf6/gwfgwf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def __init__(
5454

5555
auxiliary_variables = [var for var in [angldegx, cdist] if var is not None]
5656
if auxiliary_variables:
57-
self.dataset["auxiliary_data"] = xr.merge(auxiliary_variables).to_array(
58-
name="auxiliary_data"
59-
)
57+
self.dataset["auxiliary_data"] = xr.merge(
58+
auxiliary_variables, compat="no_conflicts"
59+
).to_array(name="auxiliary_data")
6060
expand_transient_auxiliary_variables(self)
6161

6262
def set_options(

imod/mf6/gwtgwt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ def __init__(
5858

5959
auxiliary_variables = [var for var in [angldegx, cdist] if var is not None]
6060
if auxiliary_variables:
61-
self.dataset["auxiliary_data"] = xr.merge(auxiliary_variables).to_array(
62-
name="auxiliary_data"
63-
)
61+
self.dataset["auxiliary_data"] = xr.merge(
62+
auxiliary_variables, compat="no_conflicts"
63+
).to_array(name="auxiliary_data")
6464
expand_transient_auxiliary_variables(self)
6565

6666
def set_options(

imod/mf6/hfb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,10 @@ def line_data(self) -> GeoDataFrameType:
522522
def line_data(self, value: GeoDataFrameType) -> None:
523523
variables_for_gdf = self._get_variable_names_for_gdf()
524524
self.dataset = self.dataset.merge(
525-
value.to_xarray(), overwrite_vars=variables_for_gdf, join="right"
525+
value.to_xarray(),
526+
overwrite_vars=variables_for_gdf,
527+
join="right",
528+
compat="no_conflicts",
526529
)
527530

528531
def _render(self, directory, pkgname, globaltimes, binary):

imod/typing/grid.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def merge(
186186
objects: Sequence[GridDataArray | GridDataset], *args, **kwargs
187187
) -> GridDataset:
188188
return _type_dispatch_functions_on_grid_sequence(
189-
objects, xu.merge, xr.merge, *args, **kwargs
189+
objects, xu.merge, xr.merge, *args, compat="no_conflicts", **kwargs
190190
)
191191

192192

@@ -263,7 +263,12 @@ def merge_with_dictionary(
263263
**kwargs,
264264
):
265265
return _type_dispatch_functions_on_dict(
266-
variables_to_merge, merge_unstructured_dataset, xr.merge, *args, **kwargs
266+
variables_to_merge,
267+
merge_unstructured_dataset,
268+
xr.merge,
269+
*args,
270+
compat="no_conflicts",
271+
**kwargs,
267272
)
268273

269274

imod/typing/structured.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def merge_partitions(
245245
merged_ls = []
246246
for key in unique_keys:
247247
merged_ls.append(_merge_partitions([da[key] for da in das]).rename(key))
248-
return xr.merge(merged_ls)
248+
return xr.merge(merged_ls, compat="no_conflicts")
249249
elif isinstance(first_item, xr.DataArray):
250250
# Store name to rename after concatenation
251251
name = first_item.name

0 commit comments

Comments
 (0)