xr.merge drops the variable encoding (as well as the attributes), hence this information is often lost when using open_datasets. This information is particularly useful for time variables as the units ensure that the data is written correctly to a netCDF file. When units are not found for a time variable they are encoded in "nanoseconds since XXX", which is not compatible with some software (e.g. netcdf4.num2date).
The code change preserves the "important" pieces of encoding, that one can consider consistent for all fields, and a test is included to ensure that it works (without the code change the test fails)
xr.merge drops the variable encoding (as well as the attributes), hence this information is often lost when using open_datasets. This information is particularly useful for time variables as the units ensure that the data is written correctly to a netCDF file. When units are not found for a time variable they are encoded in "nanoseconds since XXX", which is not compatible with some software (e.g. netcdf4.num2date).
The code change preserves the "important" pieces of encoding, that one can consider consistent for all fields, and a test is included to ensure that it works (without the code change the test fails)