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

Method values

xarray/plot/utils.py:1503–1547  ·  view source on GitHub ↗

Return a normalized number array for the unique levels. Examples -------- >>> a = xr.DataArray(["b", "a", "a", "b", "c"]) >>> _Normalize(a).values Size: 40B array([3, 1, 1, 3, 5]) Dimensions without coord

(self)

Source from the content-addressed store, hash-verified

1501
1502 @property
1503 def values(self) -> DataArray | None:
1504 """
1505 Return a normalized number array for the unique levels.
1506
1507 Examples
1508 --------
1509 >>> a = xr.DataArray(["b", "a", "a", "b", "c"])
1510 >>> _Normalize(a).values
1511 <xarray.DataArray (dim_0: 5)> Size: 40B
1512 array([3, 1, 1, 3, 5])
1513 Dimensions without coordinates: dim_0
1514
1515 >>> _Normalize(a, width=(18, 36, 72)).values
1516 <xarray.DataArray (dim_0: 5)> Size: 40B
1517 array([45., 18., 18., 45., 72.])
1518 Dimensions without coordinates: dim_0
1519
1520 >>> a = xr.DataArray([0.5, 0, 0, 0.5, 2, 3])
1521 >>> _Normalize(a).values
1522 <xarray.DataArray (dim_0: 6)> Size: 48B
1523 array([0.5, 0. , 0. , 0.5, 2. , 3. ])
1524 Dimensions without coordinates: dim_0
1525
1526 >>> _Normalize(a, width=(18, 36, 72)).values
1527 <xarray.DataArray (dim_0: 6)> Size: 48B
1528 array([27., 18., 18., 27., 54., 72.])
1529 Dimensions without coordinates: dim_0
1530
1531 >>> _Normalize(a * 0, width=(18, 36, 72)).values
1532 <xarray.DataArray (dim_0: 6)> Size: 48B
1533 array([36., 36., 36., 36., 36., 36.])
1534 Dimensions without coordinates: dim_0
1535
1536 """
1537 if self.data is None:
1538 return None
1539
1540 val: DataArray
1541 if self.data_is_numeric:
1542 val = self.data
1543 else:
1544 arr = self._indexes_centered(self._data_unique_inverse)
1545 val = self.data.copy(data=arr.reshape(self.data.shape))
1546
1547 return self._calc_widths(val)
1548
1549 @property
1550 def _values_unique(self) -> np.ndarray | None:

Callers 15

create_transform_daFunction · 0.45
create_pandas_daFunction · 0.45
test_vectorized_indexingFunction · 0.45
decode_cf_variablesFunction · 0.45
cf_encoderFunction · 0.45
find_independent_seasonsFunction · 0.45
_prepare_plot1d_dataFunction · 0.45
_guess_coords_to_plotFunction · 0.45
get_chunked_array_typeFunction · 0.45
_calc_concat_overFunction · 0.45
_check_shape_tile_idsFunction · 0.45

Calls 3

_indexes_centeredMethod · 0.95
_calc_widthsMethod · 0.95
copyMethod · 0.45

Tested by 15

create_transform_daFunction · 0.36
create_pandas_daFunction · 0.36
test_vectorized_indexingFunction · 0.36
test_propertiesMethod · 0.36
test_chunkMethod · 0.36
test_drop_encodingMethod · 0.36