|
1 | 1 | from datetime import datetime
|
| 2 | +from distutils.version import LooseVersion |
2 | 3 | from itertools import product
|
3 | 4 |
|
4 | 5 | import numpy as np
|
@@ -865,5 +866,22 @@ def test_combine_by_coords_raises_for_differing_calendars():
|
865 | 866 | da_1 = DataArray([0], dims=["time"], coords=[time_1], name="a").to_dataset()
|
866 | 867 | da_2 = DataArray([1], dims=["time"], coords=[time_2], name="a").to_dataset()
|
867 | 868 |
|
868 |
| - with raises_regex(TypeError, r"cannot compare .* \(different calendars\)"): |
| 869 | + if LooseVersion(cftime.__version__) >= LooseVersion("1.5"): |
| 870 | + error_msg = "Cannot combine along dimension 'time' with mixed types." |
| 871 | + else: |
| 872 | + error_msg = r"cannot compare .* \(different calendars\)" |
| 873 | + |
| 874 | + with raises_regex(TypeError, error_msg): |
| 875 | + combine_by_coords([da_1, da_2]) |
| 876 | + |
| 877 | + |
| 878 | +def test_combine_by_coords_raises_for_differing_types(): |
| 879 | + |
| 880 | + # str and byte cannot be compared |
| 881 | + da_1 = DataArray([0], dims=["time"], coords=[["a"]], name="a").to_dataset() |
| 882 | + da_2 = DataArray([1], dims=["time"], coords=[[b"b"]], name="a").to_dataset() |
| 883 | + |
| 884 | + with raises_regex( |
| 885 | + TypeError, "Cannot combine along dimension 'time' with mixed types." |
| 886 | + ): |
869 | 887 | combine_by_coords([da_1, da_2])
|
0 commit comments