MCPcopy Index your code
hub / github.com/pydata/xarray / _asarray_tuplesafe

Function _asarray_tuplesafe

xarray/core/indexes.py:593–608  ·  view source on GitHub ↗

Convert values into a numpy array of at most 1-dimension, while preserving tuples. Adapted from pandas.core.common._asarray_tuplesafe

(values)

Source from the content-addressed store, hash-verified

591
592
593def _asarray_tuplesafe(values):
594 """
595 Convert values into a numpy array of at most 1-dimension, while preserving
596 tuples.
597
598 Adapted from pandas.core.common._asarray_tuplesafe
599 """
600 if isinstance(values, tuple):
601 result = utils.to_0d_object_array(values)
602 else:
603 result = np.asarray(values)
604 if result.ndim == 2:
605 result = np.empty(len(values), dtype=object)
606 result[:] = values
607
608 return result
609
610
611def _is_nested_tuple(possible_tuple):

Callers 2

test_asarray_tuplesafeFunction · 0.90
normalize_labelFunction · 0.85

Calls 1

emptyMethod · 0.80

Tested by 1

test_asarray_tuplesafeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…