This block:
|
# Use cftime for converting reference times that are not using a |
|
# gregorian calendar as it handles these and udunits does not. |
|
if self.is_time_reference() and self.calendar != CALENDAR_STANDARD: |
|
result_datetimes = cftime.num2date( |
|
result, self.cftime_unit, self.calendar |
|
) |
|
result = cftime.date2num( |
|
result_datetimes, other.cftime_unit, other.calendar |
|
) |
|
convert_type = isinstance(value, np.ndarray) and np.issubdtype( |
|
value.dtype, np.floating |
|
) |
|
if convert_type: |
|
result = result.astype(value.dtype) |
... will never be entered because it is hidden behind this check:
|
if self.is_convertible(other): |
|
else: |
|
result = self.calendar == other.calendar and _ud.are_convertible( |
|
self.ut_unit, other.ut_unit |
|
) |
|
return result |
This may be inconsequential given these docs, but in either case this block should presumably be removed?
|
.. note:: |
|
|
|
Conversion between unit calendars is not permitted unless the |
|
calendars are aliases, see :attr:`cf_units.CALENDAR_ALIASES`. |
|
|
|
>>> from cf_units import Unit |
|
>>> a = Unit('days since 1850-1-1', calendar='gregorian') |
|
>>> b = Unit('days since 1851-1-1', calendar='standard') |
|
>>> a.convert(365.75, b) |
|
0.75 |
This block:
cf-units/cf_units/__init__.py
Lines 1731 to 1744 in 23bd604
... will never be entered because it is hidden behind this check:
cf-units/cf_units/__init__.py
Line 1726 in 23bd604
cf-units/cf_units/__init__.py
Lines 998 to 1002 in 23bd604
This may be inconsequential given these docs, but in either case this block should presumably be removed?
cf-units/cf_units/__init__.py
Lines 1709 to 1718 in 23bd604