diff --git a/pixi.toml b/pixi.toml index 90fd51a975a..8e232fea069 100644 --- a/pixi.toml +++ b/pixi.toml @@ -180,7 +180,7 @@ generate-aggregations-ci = { cmd = 'test -z "$(git status --porcelain)" && echo kerchunk = "*" ipykernel = "*" ipywidgets = "*" # silence nbsphinx warning -iris = "*" +iris = "!=3.16.0" # avoid ncdata failing. See https://github.com/SciTools/ncdata/issues/255 ipython = "*" jupyter_client = "*" jupyter_sphinx = "*" diff --git a/xarray/core/accessor_str.py b/xarray/core/accessor_str.py index 0699fbdd5b1..db92c14d4fe 100644 --- a/xarray/core/accessor_str.py +++ b/xarray/core/accessor_str.py @@ -147,49 +147,49 @@ class StringAccessor(Generic[T_DataArray]): Similar to pandas, fields can be accessed through the `.str` attribute for applicable DataArrays. - >>> da = xr.DataArray(["some", "text", "in", "an", "array"]) - >>> da.str.len() - Size: 40B - array([4, 4, 2, 2, 5]) - Dimensions without coordinates: dim_0 + >>> da = xr.DataArray(["some", "text", "in", "an", "array"]) + >>> da.str.len() + Size: 40B + array([4, 4, 2, 2, 5]) + Dimensions without coordinates: dim_0 It also implements ``+``, ``*``, and ``%``, which operate as elementwise versions of the corresponding ``str`` methods. These will automatically broadcast for array-like inputs. - >>> da1 = xr.DataArray(["first", "second", "third"], dims=["X"]) - >>> da2 = xr.DataArray([1, 2, 3], dims=["Y"]) - >>> da1.str + da2 - Size: 252B - array([['first1', 'first2', 'first3'], - ['second1', 'second2', 'second3'], - ['third1', 'third2', 'third3']], dtype='>> da1 = xr.DataArray(["a", "b", "c", "d"], dims=["X"]) - >>> reps = xr.DataArray([3, 4], dims=["Y"]) - >>> da1.str * reps - Size: 128B - array([['aaa', 'aaaa'], - ['bbb', 'bbbb'], - ['ccc', 'cccc'], - ['ddd', 'dddd']], dtype='>> da1 = xr.DataArray(["%s_%s", "%s-%s", "%s|%s"], dims=["X"]) - >>> da2 = xr.DataArray([1, 2], dims=["Y"]) - >>> da3 = xr.DataArray([0.1, 0.2], dims=["Z"]) - >>> da1.str % (da2, da3) - Size: 240B - array([[['1_0.1', '1_0.2'], - ['2_0.1', '2_0.2']], - - [['1-0.1', '1-0.2'], - ['2-0.1', '2-0.2']], - - [['1|0.1', '1|0.2'], - ['2|0.1', '2|0.2']]], dtype='>> da1 = xr.DataArray(["first", "second", "third"], dims=["X"]) + >>> da2 = xr.DataArray([1, 2, 3], dims=["Y"]) + >>> da1.str + da2 + Size: 252B + array([['first1', 'first2', 'first3'], + ['second1', 'second2', 'second3'], + ['third1', 'third2', 'third3']], dtype='>> da1 = xr.DataArray(["a", "b", "c", "d"], dims=["X"]) + >>> reps = xr.DataArray([3, 4], dims=["Y"]) + >>> da1.str * reps + Size: 128B + array([['aaa', 'aaaa'], + ['bbb', 'bbbb'], + ['ccc', 'cccc'], + ['ddd', 'dddd']], dtype='>> da1 = xr.DataArray(["%s_%s", "%s-%s", "%s|%s"], dims=["X"]) + >>> da2 = xr.DataArray([1, 2], dims=["Y"]) + >>> da3 = xr.DataArray([0.1, 0.2], dims=["Z"]) + >>> da1.str % (da2, da3) + Size: 240B + array([[['1_0.1', '1_0.2'], + ['2_0.1', '2_0.2']], + + [['1-0.1', '1-0.2'], + ['2-0.1', '2-0.2']], + + [['1|0.1', '1|0.2'], + ['2|0.1', '2|0.2']]], dtype='