Skip to content

Commit 37be891

Browse files
committed
add docstring for Variable.load_async
1 parent 8bce3bb commit 37be891

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

xarray/core/variable.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ def _replace(
976976
encoding = copy.copy(self._encoding)
977977
return type(self)(dims, data, attrs, encoding, fastpath=True)
978978

979-
def load(self, **kwargs):
979+
def load(self, **kwargs) -> Self:
980980
"""Manually trigger loading of this variable's data from disk or a
981981
remote source into memory and return this variable.
982982
@@ -991,16 +991,34 @@ def load(self, **kwargs):
991991
992992
See Also
993993
--------
994+
Variable.compute
995+
Variable.load_async
994996
dask.array.compute
995997
"""
996998
self._data = to_duck_array(self._data, **kwargs)
997999
return self
9981000

999-
async def load_async(self, **kwargs):
1001+
async def load_async(self, **kwargs) -> Self:
1002+
"""Manually trigger and await asynchronous loading of this variable's data from disk or a
1003+
remote source into memory and return this variable.
1004+
1005+
Only works when opening data lazily from IO storage backends which support lazy asynchronous loading.
1006+
Otherwise will raise a NotImplementedError.
1007+
1008+
Parameters
1009+
----------
1010+
**kwargs : dict
1011+
Additional keyword arguments passed on to ``dask.array.compute``.
1012+
1013+
See Also
1014+
--------
1015+
Variable.load
1016+
dask.array.compute
1017+
"""
10001018
self._data = await async_to_duck_array(self._data, **kwargs)
10011019
return self
10021020

1003-
def compute(self, **kwargs):
1021+
def compute(self, **kwargs) -> Self:
10041022
"""Manually trigger loading of this variable's data from disk or a
10051023
remote source into memory and return a new variable. The original is
10061024
left unaltered.
@@ -1017,6 +1035,7 @@ def compute(self, **kwargs):
10171035
See Also
10181036
--------
10191037
dask.array.compute
1038+
Variable.load
10201039
"""
10211040
new = self.copy(deep=False)
10221041
return new.load(**kwargs)

0 commit comments

Comments
 (0)