From 4cd998db0ad1eab9ff1af9936503177846af5704 Mon Sep 17 00:00:00 2001 From: Virgile Andreani Date: Fri, 18 Oct 2024 16:07:39 +0200 Subject: [PATCH] Fix typos in docs and code --- DATATREE_MIGRATION_GUIDE.md | 2 +- doc/user-guide/data-structures.rst | 6 +++--- doc/user-guide/hierarchical-data.rst | 4 ++-- xarray/core/dataarray.py | 2 +- xarray/core/indexes.py | 2 +- xarray/tests/test_dataarray.py | 2 +- xarray/tests/test_dataset.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DATATREE_MIGRATION_GUIDE.md b/DATATREE_MIGRATION_GUIDE.md index a13dd52f0f7..b60f0e49e06 100644 --- a/DATATREE_MIGRATION_GUIDE.md +++ b/DATATREE_MIGRATION_GUIDE.md @@ -41,7 +41,7 @@ A number of other API changes have been made, which should only require minor mo - The method `DataTree.to_dataset()` still exists but now has different options for controlling which variables are present on the resulting `Dataset`, e.g. `inherit=True/False`. - `DataTree.copy()` also has a new `inherit` keyword argument for controlling whether or not coordinates defined on parents are copied (only relevant when copying a non-root node). - The `DataTree.parent` property is now read-only. To assign a ancestral relationships directly you must instead use the `.children` property on the parent node, which remains settable. -- Similarly the `parent` kwarg has been removed from the `DataTree.__init__` constuctor. +- Similarly the `parent` kwarg has been removed from the `DataTree.__init__` constructor. - DataTree objects passed to the `children` kwarg in `DataTree.__init__` are now shallow-copied. - `DataTree.as_array` has been replaced by `DataTree.to_dataarray`. - A number of methods which were not well tested have been (temporarily) disabled. In general we have tried to only keep things that are known to work, with the plan to increase API surface incrementally after release. diff --git a/doc/user-guide/data-structures.rst b/doc/user-guide/data-structures.rst index ae73f2c09c7..71f7ae5b8aa 100644 --- a/doc/user-guide/data-structures.rst +++ b/doc/user-guide/data-structures.rst @@ -608,7 +608,7 @@ We have created a tree with three nodes in it: Consistency checks are enforced. For instance, if we try to create a ``cycle``, -where the root node is also a child of a decendent, the constructor will raise +where the root node is also a child of a descendent, the constructor will raise an (:py:class:`~xarray.InvalidTreeError`): .. ipython:: python @@ -710,8 +710,8 @@ inherited dimensions, but DataTree's inheritance is slightly stricter yet easier to reason about. The constraint that this puts on a DataTree is that dimensions and indices that -are inherited must be aligned with any direct decendent node's existing -dimension or index. This allows decendents to use dimensions defined in +are inherited must be aligned with any direct descendent node's existing +dimension or index. This allows descendents to use dimensions defined in ancestor nodes, without duplicating that information. But as a consequence, if a dimension-name is defined in on a node and that same dimension-name exists in one of its ancestors, they must align (have the same index and diff --git a/doc/user-guide/hierarchical-data.rst b/doc/user-guide/hierarchical-data.rst index 6992bf37f95..aa4ecf1002a 100644 --- a/doc/user-guide/hierarchical-data.rst +++ b/doc/user-guide/hierarchical-data.rst @@ -177,7 +177,7 @@ Let's use a different example of a tree to discuss more complex relationships be "/Bony Skeleton/Four Limbs/Amniotic Egg/Two Fenestrae/Dinosaurs" ] -We have used the :py:meth:`~xarray.DataTree.from_dict` constructor method as a prefered way to quickly create a whole tree, +We have used the :py:meth:`~xarray.DataTree.from_dict` constructor method as a preferred way to quickly create a whole tree, and :ref:`filesystem paths` (to be explained shortly) to select two nodes of interest. .. ipython:: python @@ -658,7 +658,7 @@ Data Alignment ~~~~~~~~~~~~~~ The data in different datatree nodes are not totally independent. In particular dimensions (and indexes) in child nodes must be exactly aligned with those in their parent nodes. -Exact aligment means that shared dimensions must be the same length, and indexes along those dimensions must be equal. +Exact alignment means that shared dimensions must be the same length, and indexes along those dimensions must be equal. .. note:: If you were a previous user of the prototype `xarray-contrib/datatree `_ package, this is different from what you're used to! diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 3735bf1099c..9f6c2395e86 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -1105,7 +1105,7 @@ def reset_coords( return self._replace(coords=dataset._variables) if self.name is None: raise ValueError( - "cannot reset_coords with drop=False on an unnamed DataArrray" + "cannot reset_coords with drop=False on an unnamed DataArray" ) dataset[self.name] = self.variable return dataset diff --git a/xarray/core/indexes.py b/xarray/core/indexes.py index 4a735959298..c1682cdbaff 100644 --- a/xarray/core/indexes.py +++ b/xarray/core/indexes.py @@ -1623,7 +1623,7 @@ def group_by_index( return index_coords def to_pandas_indexes(self) -> Indexes[pd.Index]: - """Returns an immutable proxy for Dataset or DataArrary pandas indexes. + """Returns an immutable proxy for Dataset or DataArray pandas indexes. Raises an error if this proxy contains indexes that cannot be coerced to pandas.Index objects. diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 78db39c194e..b70f06a5b5c 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3797,7 +3797,7 @@ def test_to_dataset_retains_keys(self) -> None: array = DataArray([1, 2, 3], coords=[("x", dates)], attrs={"a": 1}) - # convert to dateset and back again + # convert to dataset and back again result = array.to_dataset("x").to_dataarray(dim="x") assert_equal(array, result) diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index c89cfa85622..6db17208e16 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -3206,7 +3206,7 @@ def test_rename_multiindex(self) -> None: with pytest.raises(ValueError, match=r"'b' conflicts"): original.rename({"a": "b"}) - def test_rename_perserve_attrs_encoding(self) -> None: + def test_rename_preserve_attrs_encoding(self) -> None: # test propagate attrs/encoding to new variable(s) created from Index object original = Dataset(coords={"x": ("x", [0, 1, 2])}) expected = Dataset(coords={"y": ("y", [0, 1, 2])})