Skip to content

Resolve concat warnings in xarray #1251

@veenstrajelmer

Description

@veenstrajelmer

New defaults for xarrays concat/merge/combine were set in pydata/xarray#10062. This gives some warnings:

FAILED tests/test_xarray_helpers.py::test_merge_meteofiles - FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.
FAILED tests/test_xarray_helpers.py::test_merge_meteofiles_number_coordinate - FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly.

The new defaults can be tested by setting xr.set_options(use_new_combine_kwarg_defaults=True). This indeed silences the warnings above, and the testcase tests/test_interpolate_grid2bnd.py:test_open_prepare_dataset_slightly_different_latlons also still passes with new defaults. This is because we use join='exact' troughout the dfm_tools code, which is strict enough even with compat='override'.

Some options:

  1. setting the option in __init__.py breaks all older xarray versions, so that is not desireable
  2. setting compat explicitly in all xarray mergings is possible, but that is additional code only to suppress a warning
  3. we can temporarily suppress the warning via pyproject.toml, but that still gives a warning for users.

Option 2 seems most useful since the warning is only given by dfmt.merge_meteofiles() so it is not too much additional code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions