Commit 07430e1
authored
Disallow standard calendar datetime64 encoding prior to reform (pydata#10352)
In pydata#9618 we allowed encoding `np.datetime64` values prior to 1582-10-15 using a `"standard"` or `"gregorian"` calendar through cftime. While technically possible, this implicitly introduces a calendar change, and means the values can no longer be round tripped as `np.datetime64`—xarray will choose `cftime.DatetimeGregorian` instances when decoding instead. I am not sure how often this will come up and the behavior may not be the user's intent.
This PR switches to raising a `ValueError` in this circumstance, and recommends encoding with a `"proleptic_gregorian"` calendar instead (the calendar that xarray automatically chooses for `np.datetime64` values if provided no user input).1 parent e18336f commit 07430e1
File tree
3 files changed
+36
-32
lines changed- doc
- xarray
- coding
- tests
3 files changed
+36
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1065 | 1065 | | |
1066 | 1066 | | |
1067 | 1067 | | |
| 1068 | + | |
1068 | 1069 | | |
1069 | 1070 | | |
1070 | 1071 | | |
| |||
1073 | 1074 | | |
1074 | 1075 | | |
1075 | 1076 | | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
| 1077 | + | |
1086 | 1078 | | |
1087 | 1079 | | |
1088 | 1080 | | |
| |||
1166 | 1158 | | |
1167 | 1159 | | |
1168 | 1160 | | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1169 | 1171 | | |
1170 | 1172 | | |
1171 | 1173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
243 | | - | |
244 | 242 | | |
245 | 243 | | |
246 | 244 | | |
| |||
379 | 377 | | |
380 | 378 | | |
381 | 379 | | |
382 | | - | |
383 | | - | |
384 | 380 | | |
385 | 381 | | |
386 | 382 | | |
| |||
1163 | 1159 | | |
1164 | 1160 | | |
1165 | 1161 | | |
1166 | | - | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
1167 | 1175 | | |
1168 | 1176 | | |
1169 | | - | |
1170 | | - | |
1171 | 1177 | | |
1172 | | - | |
| 1178 | + | |
1173 | 1179 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
| 1180 | + | |
| 1181 | + | |
1187 | 1182 | | |
1188 | 1183 | | |
1189 | 1184 | | |
| |||
0 commit comments