(self, variable: Variable, name: T_Name = None)
| 1405 | return variable |
| 1406 | |
| 1407 | def decode(self, variable: Variable, name: T_Name = None) -> Variable: |
| 1408 | units = variable.attrs.get("units", None) |
| 1409 | if isinstance(units, str) and "since" in units: |
| 1410 | dims, data, attrs, encoding = unpack_for_decoding(variable) |
| 1411 | |
| 1412 | units = pop_to(attrs, encoding, "units") |
| 1413 | calendar = pop_to(attrs, encoding, "calendar") |
| 1414 | dtype = _decode_cf_datetime_dtype( |
| 1415 | data, units, calendar, self.use_cftime, self.time_unit |
| 1416 | ) |
| 1417 | transform = partial( |
| 1418 | decode_cf_datetime, |
| 1419 | units=units, |
| 1420 | calendar=calendar, |
| 1421 | use_cftime=self.use_cftime, |
| 1422 | time_unit=self.time_unit, |
| 1423 | ) |
| 1424 | data = lazy_elemwise_func(data, transform, dtype) |
| 1425 | |
| 1426 | return Variable(dims, data, attrs, encoding, fastpath=True) |
| 1427 | else: |
| 1428 | return variable |
| 1429 | |
| 1430 | |
| 1431 | def has_timedelta64_encoding_dtype(attrs_or_encoding: dict) -> bool: |
no test coverage detected