MCPcopy
hub / github.com/pydata/xarray / _maybe_wrap_data

Function _maybe_wrap_data

xarray/core/variable.py:192–208  ·  view source on GitHub ↗

Put pandas.Index and numpy.ndarray arguments in adapter objects to ensure they can be indexed properly. NumpyArrayAdapter, PandasIndexingAdapter and LazilyIndexedArray should all pass through unmodified.

(data)

Source from the content-addressed store, hash-verified

190
191
192def _maybe_wrap_data(data):
193 """
194 Put pandas.Index and numpy.ndarray arguments in adapter objects to ensure
195 they can be indexed properly.
196
197 NumpyArrayAdapter, PandasIndexingAdapter and LazilyIndexedArray should
198 all pass through unmodified.
199 """
200 if isinstance(data, pd.Index):
201 return PandasIndexingAdapter(data)
202 if isinstance(data, UNSUPPORTED_EXTENSION_ARRAY_TYPES):
203 return data.to_numpy()
204 if isinstance(
205 data, pd.api.extensions.ExtensionArray
206 ) and is_allowed_extension_array(data):
207 return PandasExtensionArray(data)
208 return data
209
210
211def _possibly_convert_objects(values):

Callers 2

convert_non_numpy_typeFunction · 0.85
as_compatible_dataFunction · 0.85

Calls 4

to_numpyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…