Check if an array inside a Variable contains cftime.datetime objects
(array: Any)
| 2076 | |
| 2077 | |
| 2078 | def _contains_cftime_datetimes(array: Any) -> bool: |
| 2079 | """Check if an array inside a Variable contains cftime.datetime objects""" |
| 2080 | if cftime is None: |
| 2081 | return False |
| 2082 | |
| 2083 | if array.dtype == np.dtype("O") and array.size > 0: |
| 2084 | first_idx = (0,) * array.ndim |
| 2085 | if isinstance(array, ExplicitlyIndexed): |
| 2086 | first_idx = BasicIndexer(first_idx) |
| 2087 | sample = array[first_idx] |
| 2088 | return isinstance(np.asarray(sample).item(), cftime.datetime) |
| 2089 | |
| 2090 | return False |
| 2091 | |
| 2092 | |
| 2093 | def contains_cftime_datetimes(var: T_Variable) -> bool: |
searching dependent graphs…