repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
pydata/xarray
xarray/core/nanops.py
_nan_minmax_object
def _nan_minmax_object(func, fill_value, value, axis=None, **kwargs): """ In house nanmin and nanmax for object array """ valid_count = count(value, axis=axis) filled_value = fillna(value, fill_value) data = getattr(np, func)(filled_value, axis=axis, **kwargs) if not hasattr(data, 'dtype'): # scala...
python
def _nan_minmax_object(func, fill_value, value, axis=None, **kwargs): """ In house nanmin and nanmax for object array """ valid_count = count(value, axis=axis) filled_value = fillna(value, fill_value) data = getattr(np, func)(filled_value, axis=axis, **kwargs) if not hasattr(data, 'dtype'): # scala...
[ "def", "_nan_minmax_object", "(", "func", ",", "fill_value", ",", "value", ",", "axis", "=", "None", ",", "*", "*", "kwargs", ")", ":", "valid_count", "=", "count", "(", "value", ",", "axis", "=", "axis", ")", "filled_value", "=", "fillna", "(", "value...
In house nanmin and nanmax for object array
[ "In", "house", "nanmin", "and", "nanmax", "for", "object", "array" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L61-L69
train
In house nanmin and nanmax for object array
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/nanops.py
_nanmean_ddof_object
def _nanmean_ddof_object(ddof, value, axis=None, **kwargs): """ In house nanmean. ddof argument will be used in _nanvar method """ from .duck_array_ops import (count, fillna, _dask_or_eager_func, where_method) valid_count = count(value, axis=axis) value = fillna(value, ...
python
def _nanmean_ddof_object(ddof, value, axis=None, **kwargs): """ In house nanmean. ddof argument will be used in _nanvar method """ from .duck_array_ops import (count, fillna, _dask_or_eager_func, where_method) valid_count = count(value, axis=axis) value = fillna(value, ...
[ "def", "_nanmean_ddof_object", "(", "ddof", ",", "value", ",", "axis", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", ".", "duck_array_ops", "import", "(", "count", ",", "fillna", ",", "_dask_or_eager_func", ",", "where_method", ")", "valid_count", ...
In house nanmean. ddof argument will be used in _nanvar method
[ "In", "house", "nanmean", ".", "ddof", "argument", "will", "be", "used", "in", "_nanvar", "method" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L134-L149
train
In house nanmean. ddof argument will be used in _nanvar method
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/netCDF4_.py
_disable_auto_decode_variable
def _disable_auto_decode_variable(var): """Disable automatic decoding on a netCDF4.Variable. We handle these types of decoding ourselves. """ var.set_auto_maskandscale(False) # only added in netCDF4-python v1.2.8 with suppress(AttributeError): var.set_auto_chartostring(False)
python
def _disable_auto_decode_variable(var): """Disable automatic decoding on a netCDF4.Variable. We handle these types of decoding ourselves. """ var.set_auto_maskandscale(False) # only added in netCDF4-python v1.2.8 with suppress(AttributeError): var.set_auto_chartostring(False)
[ "def", "_disable_auto_decode_variable", "(", "var", ")", ":", "var", ".", "set_auto_maskandscale", "(", "False", ")", "# only added in netCDF4-python v1.2.8", "with", "suppress", "(", "AttributeError", ")", ":", "var", ".", "set_auto_chartostring", "(", "False", ")" ]
Disable automatic decoding on a netCDF4.Variable. We handle these types of decoding ourselves.
[ "Disable", "automatic", "decoding", "on", "a", "netCDF4", ".", "Variable", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/netCDF4_.py#L254-L263
train
Disable automatic decoding on a netCDF4. Variable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/dtypes.py
maybe_promote
def maybe_promote(dtype): """Simpler equivalent of pandas.core.common._maybe_promote Parameters ---------- dtype : np.dtype Returns ------- dtype : Promoted dtype that can hold missing values. fill_value : Valid missing value for the promoted dtype. """ # N.B. these casting rul...
python
def maybe_promote(dtype): """Simpler equivalent of pandas.core.common._maybe_promote Parameters ---------- dtype : np.dtype Returns ------- dtype : Promoted dtype that can hold missing values. fill_value : Valid missing value for the promoted dtype. """ # N.B. these casting rul...
[ "def", "maybe_promote", "(", "dtype", ")", ":", "# N.B. these casting rules should match pandas", "if", "np", ".", "issubdtype", "(", "dtype", ",", "np", ".", "floating", ")", ":", "fill_value", "=", "np", ".", "nan", "elif", "np", ".", "issubdtype", "(", "d...
Simpler equivalent of pandas.core.common._maybe_promote Parameters ---------- dtype : np.dtype Returns ------- dtype : Promoted dtype that can hold missing values. fill_value : Valid missing value for the promoted dtype.
[ "Simpler", "equivalent", "of", "pandas", ".", "core", ".", "common", ".", "_maybe_promote" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L45-L78
train
Simplpler equivalent of pandas. core. common. _maybe_promote .
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/dtypes.py
get_pos_infinity
def get_pos_infinity(dtype): """Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype. """ if issubclass(dtype.type, (np.floating, np.integer)): return ...
python
def get_pos_infinity(dtype): """Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype. """ if issubclass(dtype.type, (np.floating, np.integer)): return ...
[ "def", "get_pos_infinity", "(", "dtype", ")", ":", "if", "issubclass", "(", "dtype", ".", "type", ",", "(", "np", ".", "floating", ",", "np", ".", "integer", ")", ")", ":", "return", "np", ".", "inf", "if", "issubclass", "(", "dtype", ".", "type", ...
Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype.
[ "Return", "an", "appropriate", "positive", "infinity", "for", "this", "dtype", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L99-L116
train
Return an appropriate positive infinity value for this dtype.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/dtypes.py
get_neg_infinity
def get_neg_infinity(dtype): """Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype. """ if issubclass(dtype.type, (np.floating, np.integer)): return ...
python
def get_neg_infinity(dtype): """Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype. """ if issubclass(dtype.type, (np.floating, np.integer)): return ...
[ "def", "get_neg_infinity", "(", "dtype", ")", ":", "if", "issubclass", "(", "dtype", ".", "type", ",", "(", "np", ".", "floating", ",", "np", ".", "integer", ")", ")", ":", "return", "-", "np", ".", "inf", "if", "issubclass", "(", "dtype", ".", "ty...
Return an appropriate positive infinity for this dtype. Parameters ---------- dtype : np.dtype Returns ------- fill_value : positive infinity value corresponding to this dtype.
[ "Return", "an", "appropriate", "positive", "infinity", "for", "this", "dtype", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L119-L136
train
Return an appropriate positive infinity value for this dtype.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/dtypes.py
is_datetime_like
def is_datetime_like(dtype): """Check if a dtype is a subclass of the numpy datetime types """ return (np.issubdtype(dtype, np.datetime64) or np.issubdtype(dtype, np.timedelta64))
python
def is_datetime_like(dtype): """Check if a dtype is a subclass of the numpy datetime types """ return (np.issubdtype(dtype, np.datetime64) or np.issubdtype(dtype, np.timedelta64))
[ "def", "is_datetime_like", "(", "dtype", ")", ":", "return", "(", "np", ".", "issubdtype", "(", "dtype", ",", "np", ".", "datetime64", ")", "or", "np", ".", "issubdtype", "(", "dtype", ",", "np", ".", "timedelta64", ")", ")" ]
Check if a dtype is a subclass of the numpy datetime types
[ "Check", "if", "a", "dtype", "is", "a", "subclass", "of", "the", "numpy", "datetime", "types" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L139-L143
train
Check if a dtype is a subclass of the numpy datetime types
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/dtypes.py
result_type
def result_type(*arrays_and_dtypes): """Like np.result_type, but with type promotion rules matching pandas. Examples of changed behavior: number + string -> object (not string) bytes + unicode -> object (not unicode) Parameters ---------- *arrays_and_dtypes : list of arrays and dtypes ...
python
def result_type(*arrays_and_dtypes): """Like np.result_type, but with type promotion rules matching pandas. Examples of changed behavior: number + string -> object (not string) bytes + unicode -> object (not unicode) Parameters ---------- *arrays_and_dtypes : list of arrays and dtypes ...
[ "def", "result_type", "(", "*", "arrays_and_dtypes", ")", ":", "types", "=", "{", "np", ".", "result_type", "(", "t", ")", ".", "type", "for", "t", "in", "arrays_and_dtypes", "}", "for", "left", ",", "right", "in", "PROMOTE_TO_OBJECT", ":", "if", "(", ...
Like np.result_type, but with type promotion rules matching pandas. Examples of changed behavior: number + string -> object (not string) bytes + unicode -> object (not unicode) Parameters ---------- *arrays_and_dtypes : list of arrays and dtypes The dtype is extracted from both numpy a...
[ "Like", "np", ".", "result_type", "but", "with", "type", "promotion", "rules", "matching", "pandas", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L146-L169
train
Like np. result_type but with type promotion rules matching pandas.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/rasterio_.py
_parse_envi
def _parse_envi(meta): """Parse ENVI metadata into Python data structures. See the link for information on the ENVI header file format: http://www.harrisgeospatial.com/docs/enviheaderfiles.html Parameters ---------- meta : dict Dictionary of keys and str values to parse, as returned by...
python
def _parse_envi(meta): """Parse ENVI metadata into Python data structures. See the link for information on the ENVI header file format: http://www.harrisgeospatial.com/docs/enviheaderfiles.html Parameters ---------- meta : dict Dictionary of keys and str values to parse, as returned by...
[ "def", "_parse_envi", "(", "meta", ")", ":", "def", "parsevec", "(", "s", ")", ":", "return", "np", ".", "fromstring", "(", "s", ".", "strip", "(", "'{}'", ")", ",", "dtype", "=", "'float'", ",", "sep", "=", "','", ")", "def", "default", "(", "s"...
Parse ENVI metadata into Python data structures. See the link for information on the ENVI header file format: http://www.harrisgeospatial.com/docs/enviheaderfiles.html Parameters ---------- meta : dict Dictionary of keys and str values to parse, as returned by the rasterio tags(ns=...
[ "Parse", "ENVI", "metadata", "into", "Python", "data", "structures", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L133-L161
train
Parse the ENVI metadata into a dictionary of dicts.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/rasterio_.py
open_rasterio
def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, lock=None): """Open a file with rasterio (experimental). This should work with any file that rasterio can open (most often: geoTIFF). The x and y coordinates are generated automatically from the file's geoinf...
python
def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None, lock=None): """Open a file with rasterio (experimental). This should work with any file that rasterio can open (most often: geoTIFF). The x and y coordinates are generated automatically from the file's geoinf...
[ "def", "open_rasterio", "(", "filename", ",", "parse_coordinates", "=", "None", ",", "chunks", "=", "None", ",", "cache", "=", "None", ",", "lock", "=", "None", ")", ":", "import", "rasterio", "from", "rasterio", ".", "vrt", "import", "WarpedVRT", "vrt_par...
Open a file with rasterio (experimental). This should work with any file that rasterio can open (most often: geoTIFF). The x and y coordinates are generated automatically from the file's geoinformation, shifted to the center of each pixel (see `"PixelIsArea" Raster Space <http://web.archive.org/web...
[ "Open", "a", "file", "with", "rasterio", "(", "experimental", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L164-L347
train
Open a file with rasterio.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/rasterio_.py
RasterioArrayWrapper._get_indexer
def _get_indexer(self, key): """ Get indexer for rasterio array. Parameter --------- key: tuple of int Returns ------- band_key: an indexer for the 1st dimension window: two tuples. Each consists of (start, stop). squeeze_axis: axes to be squeeze...
python
def _get_indexer(self, key): """ Get indexer for rasterio array. Parameter --------- key: tuple of int Returns ------- band_key: an indexer for the 1st dimension window: two tuples. Each consists of (start, stop). squeeze_axis: axes to be squeeze...
[ "def", "_get_indexer", "(", "self", ",", "key", ")", ":", "assert", "len", "(", "key", ")", "==", "3", ",", "'rasterio datasets should always be 3D'", "# bands cannot be windowed but they can be listed", "band_key", "=", "key", "[", "0", "]", "np_inds", "=", "[", ...
Get indexer for rasterio array. Parameter --------- key: tuple of int Returns ------- band_key: an indexer for the 1st dimension window: two tuples. Each consists of (start, stop). squeeze_axis: axes to be squeezed np_ind: indexer for loaded nump...
[ "Get", "indexer", "for", "rasterio", "array", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L51-L106
train
Get indexer for rasterio array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
unique_value_groups
def unique_value_groups(ar, sort=True): """Group an array by its unique values. Parameters ---------- ar : array-like Input array. This will be flattened if it is not already 1-D. sort : boolean, optional Whether or not to sort unique values. Returns ------- values : np...
python
def unique_value_groups(ar, sort=True): """Group an array by its unique values. Parameters ---------- ar : array-like Input array. This will be flattened if it is not already 1-D. sort : boolean, optional Whether or not to sort unique values. Returns ------- values : np...
[ "def", "unique_value_groups", "(", "ar", ",", "sort", "=", "True", ")", ":", "inverse", ",", "values", "=", "pd", ".", "factorize", "(", "ar", ",", "sort", "=", "sort", ")", "groups", "=", "[", "[", "]", "for", "_", "in", "range", "(", "len", "("...
Group an array by its unique values. Parameters ---------- ar : array-like Input array. This will be flattened if it is not already 1-D. sort : boolean, optional Whether or not to sort unique values. Returns ------- values : np.ndarray Sorted, unique values as retur...
[ "Group", "an", "array", "by", "its", "unique", "values", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L18-L42
train
Group an array by its unique values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
_consolidate_slices
def _consolidate_slices(slices): """Consolidate adjacent slices in a list of slices. """ result = [] last_slice = slice(None) for slice_ in slices: if not isinstance(slice_, slice): raise ValueError('list element is not a slice: %r' % slice_) if (result and last_slice.sto...
python
def _consolidate_slices(slices): """Consolidate adjacent slices in a list of slices. """ result = [] last_slice = slice(None) for slice_ in slices: if not isinstance(slice_, slice): raise ValueError('list element is not a slice: %r' % slice_) if (result and last_slice.sto...
[ "def", "_consolidate_slices", "(", "slices", ")", ":", "result", "=", "[", "]", "last_slice", "=", "slice", "(", "None", ")", "for", "slice_", "in", "slices", ":", "if", "not", "isinstance", "(", "slice_", ",", "slice", ")", ":", "raise", "ValueError", ...
Consolidate adjacent slices in a list of slices.
[ "Consolidate", "adjacent", "slices", "in", "a", "list", "of", "slices", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L72-L88
train
Consolidate adjacent slices in a list of slices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
_inverse_permutation_indices
def _inverse_permutation_indices(positions): """Like inverse_permutation, but also handles slices. Parameters ---------- positions : list of np.ndarray or slice objects. If slice objects, all are assumed to be slices. Returns ------- np.ndarray of indices or None, if no permutation...
python
def _inverse_permutation_indices(positions): """Like inverse_permutation, but also handles slices. Parameters ---------- positions : list of np.ndarray or slice objects. If slice objects, all are assumed to be slices. Returns ------- np.ndarray of indices or None, if no permutation...
[ "def", "_inverse_permutation_indices", "(", "positions", ")", ":", "if", "not", "positions", ":", "return", "None", "if", "isinstance", "(", "positions", "[", "0", "]", ",", "slice", ")", ":", "positions", "=", "_consolidate_slices", "(", "positions", ")", "...
Like inverse_permutation, but also handles slices. Parameters ---------- positions : list of np.ndarray or slice objects. If slice objects, all are assumed to be slices. Returns ------- np.ndarray of indices or None, if no permutation is necessary.
[ "Like", "inverse_permutation", "but", "also", "handles", "slices", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L91-L113
train
Like inverse_permutation but also handles slices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
_apply_loffset
def _apply_loffset(grouper, result): """ (copied from pandas) if loffset is set, offset the result index This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ need...
python
def _apply_loffset(grouper, result): """ (copied from pandas) if loffset is set, offset the result index This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample """ need...
[ "def", "_apply_loffset", "(", "grouper", ",", "result", ")", ":", "needs_offset", "=", "(", "isinstance", "(", "grouper", ".", "loffset", ",", "(", "pd", ".", "DateOffset", ",", "datetime", ".", "timedelta", ")", ")", "and", "isinstance", "(", "result", ...
(copied from pandas) if loffset is set, offset the result index This is NOT an idempotent routine, it will be applied exactly once to the result. Parameters ---------- result : Series or DataFrame the result of resample
[ "(", "copied", "from", "pandas", ")", "if", "loffset", "is", "set", "offset", "the", "result", "index" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L156-L179
train
Applies the loffset to the result DataFrame.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
GroupBy._iter_grouped
def _iter_grouped(self): """Iterate over each element in this group""" for indices in self._group_indices: yield self._obj.isel(**{self._group_dim: indices})
python
def _iter_grouped(self): """Iterate over each element in this group""" for indices in self._group_indices: yield self._obj.isel(**{self._group_dim: indices})
[ "def", "_iter_grouped", "(", "self", ")", ":", "for", "indices", "in", "self", ".", "_group_indices", ":", "yield", "self", ".", "_obj", ".", "isel", "(", "*", "*", "{", "self", ".", "_group_dim", ":", "indices", "}", ")" ]
Iterate over each element in this group
[ "Iterate", "over", "each", "element", "in", "this", "group" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L322-L325
train
Iterate over each element in this group
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
GroupBy._maybe_restore_empty_groups
def _maybe_restore_empty_groups(self, combined): """Our index contained empty groups (e.g., from a resampling). If we reduced on that dimension, we want to restore the full index. """ if (self._full_index is not None and self._group.name in combined.dims): ind...
python
def _maybe_restore_empty_groups(self, combined): """Our index contained empty groups (e.g., from a resampling). If we reduced on that dimension, we want to restore the full index. """ if (self._full_index is not None and self._group.name in combined.dims): ind...
[ "def", "_maybe_restore_empty_groups", "(", "self", ",", "combined", ")", ":", "if", "(", "self", ".", "_full_index", "is", "not", "None", "and", "self", ".", "_group", ".", "name", "in", "combined", ".", "dims", ")", ":", "indexers", "=", "{", "self", ...
Our index contained empty groups (e.g., from a resampling). If we reduced on that dimension, we want to restore the full index.
[ "Our", "index", "contained", "empty", "groups", "(", "e", ".", "g", ".", "from", "a", "resampling", ")", ".", "If", "we", "reduced", "on", "that", "dimension", "we", "want", "to", "restore", "the", "full", "index", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L372-L380
train
Restore empty groups if needed.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
GroupBy._maybe_unstack
def _maybe_unstack(self, obj): """This gets called if we are applying on an array with a multidimensional group.""" if self._stacked_dim is not None and self._stacked_dim in obj.dims: obj = obj.unstack(self._stacked_dim) for dim in self._inserted_dims: if ...
python
def _maybe_unstack(self, obj): """This gets called if we are applying on an array with a multidimensional group.""" if self._stacked_dim is not None and self._stacked_dim in obj.dims: obj = obj.unstack(self._stacked_dim) for dim in self._inserted_dims: if ...
[ "def", "_maybe_unstack", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "_stacked_dim", "is", "not", "None", "and", "self", ".", "_stacked_dim", "in", "obj", ".", "dims", ":", "obj", "=", "obj", ".", "unstack", "(", "self", ".", "_stacked_dim", ...
This gets called if we are applying on an array with a multidimensional group.
[ "This", "gets", "called", "if", "we", "are", "applying", "on", "an", "array", "with", "a", "multidimensional", "group", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L382-L390
train
Unstacks the array with the specified dimension if there is one.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
GroupBy.first
def first(self, skipna=None, keep_attrs=None): """Return the first element of each group along the group dimension """ return self._first_or_last(duck_array_ops.first, skipna, keep_attrs)
python
def first(self, skipna=None, keep_attrs=None): """Return the first element of each group along the group dimension """ return self._first_or_last(duck_array_ops.first, skipna, keep_attrs)
[ "def", "first", "(", "self", ",", "skipna", "=", "None", ",", "keep_attrs", "=", "None", ")", ":", "return", "self", ".", "_first_or_last", "(", "duck_array_ops", ".", "first", ",", "skipna", ",", "keep_attrs", ")" ]
Return the first element of each group along the group dimension
[ "Return", "the", "first", "element", "of", "each", "group", "along", "the", "group", "dimension" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L448-L451
train
Return the first element of each group along the group dimension
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
GroupBy.last
def last(self, skipna=None, keep_attrs=None): """Return the last element of each group along the group dimension """ return self._first_or_last(duck_array_ops.last, skipna, keep_attrs)
python
def last(self, skipna=None, keep_attrs=None): """Return the last element of each group along the group dimension """ return self._first_or_last(duck_array_ops.last, skipna, keep_attrs)
[ "def", "last", "(", "self", ",", "skipna", "=", "None", ",", "keep_attrs", "=", "None", ")", ":", "return", "self", ".", "_first_or_last", "(", "duck_array_ops", ".", "last", ",", "skipna", ",", "keep_attrs", ")" ]
Return the last element of each group along the group dimension
[ "Return", "the", "last", "element", "of", "each", "group", "along", "the", "group", "dimension" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L453-L456
train
Return the last element of each group along the group dimension
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DataArrayGroupBy._iter_grouped_shortcut
def _iter_grouped_shortcut(self): """Fast version of `_iter_grouped` that yields Variables without metadata """ var = self._obj.variable for indices in self._group_indices: yield var[{self._group_dim: indices}]
python
def _iter_grouped_shortcut(self): """Fast version of `_iter_grouped` that yields Variables without metadata """ var = self._obj.variable for indices in self._group_indices: yield var[{self._group_dim: indices}]
[ "def", "_iter_grouped_shortcut", "(", "self", ")", ":", "var", "=", "self", ".", "_obj", ".", "variable", "for", "indices", "in", "self", ".", "_group_indices", ":", "yield", "var", "[", "{", "self", ".", "_group_dim", ":", "indices", "}", "]" ]
Fast version of `_iter_grouped` that yields Variables without metadata
[ "Fast", "version", "of", "_iter_grouped", "that", "yields", "Variables", "without", "metadata" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L482-L488
train
Fast version of _iter_grouped that yields Variables without metadata
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DataArrayGroupBy.apply
def apply(self, func, shortcut=False, args=(), **kwargs): """Apply a function over each array in the group and concatenate them together into a new array. `func` is called like `func(ar, *args, **kwargs)` for each array `ar` in this group. Apply uses heuristics (like `pandas.Gr...
python
def apply(self, func, shortcut=False, args=(), **kwargs): """Apply a function over each array in the group and concatenate them together into a new array. `func` is called like `func(ar, *args, **kwargs)` for each array `ar` in this group. Apply uses heuristics (like `pandas.Gr...
[ "def", "apply", "(", "self", ",", "func", ",", "shortcut", "=", "False", ",", "args", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "if", "shortcut", ":", "grouped", "=", "self", ".", "_iter_grouped_shortcut", "(", ")", "else", ":", "grouped", ...
Apply a function over each array in the group and concatenate them together into a new array. `func` is called like `func(ar, *args, **kwargs)` for each array `ar` in this group. Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how to stack together the array. ...
[ "Apply", "a", "function", "over", "each", "array", "in", "the", "group", "and", "concatenate", "them", "together", "into", "a", "new", "array", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L513-L558
train
Apply a function over each array in the group and concatenate them together into a new array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DataArrayGroupBy._combine
def _combine(self, applied, shortcut=False): """Recombine the applied objects like the original.""" applied_example, applied = peek_at(applied) coord, dim, positions = self._infer_concat_args(applied_example) if shortcut: combined = self._concat_shortcut(applied, dim, positio...
python
def _combine(self, applied, shortcut=False): """Recombine the applied objects like the original.""" applied_example, applied = peek_at(applied) coord, dim, positions = self._infer_concat_args(applied_example) if shortcut: combined = self._concat_shortcut(applied, dim, positio...
[ "def", "_combine", "(", "self", ",", "applied", ",", "shortcut", "=", "False", ")", ":", "applied_example", ",", "applied", "=", "peek_at", "(", "applied", ")", "coord", ",", "dim", ",", "positions", "=", "self", ".", "_infer_concat_args", "(", "applied_ex...
Recombine the applied objects like the original.
[ "Recombine", "the", "applied", "objects", "like", "the", "original", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L560-L580
train
Recombine the applied objects like the original.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DataArrayGroupBy.reduce
def reduce(self, func, dim=None, axis=None, keep_attrs=None, shortcut=True, **kwargs): """Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form ...
python
def reduce(self, func, dim=None, axis=None, keep_attrs=None, shortcut=True, **kwargs): """Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form ...
[ "def", "reduce", "(", "self", ",", "func", ",", "dim", "=", "None", ",", "axis", "=", "None", ",", "keep_attrs", "=", "None", ",", "shortcut", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "dim", "==", "DEFAULT_DIMS", ":", "dim", "=", "AL...
Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=axis, **kwargs)` to return the result of collapsing an np.ndarray over an integer v...
[ "Reduce", "the", "items", "in", "this", "group", "by", "applying", "func", "along", "some", "dimension", "(", "s", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L582-L629
train
Reduce the items in this group by applying func along some dimension and axis.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DatasetGroupBy.apply
def apply(self, func, args=(), **kwargs): """Apply a function over each Dataset in the group and concatenate them together into a new Dataset. `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds` in this group. Apply uses heuristics (like `pandas.GroupBy.appl...
python
def apply(self, func, args=(), **kwargs): """Apply a function over each Dataset in the group and concatenate them together into a new Dataset. `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds` in this group. Apply uses heuristics (like `pandas.GroupBy.appl...
[ "def", "apply", "(", "self", ",", "func", ",", "args", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "pop", "(", "'shortcut'", ",", "None", ")", "# ignore shortcut if set (for now)", "applied", "=", "(", "func", "(", "ds", ",", "*"...
Apply a function over each Dataset in the group and concatenate them together into a new Dataset. `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds` in this group. Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how to stack together the d...
[ "Apply", "a", "function", "over", "each", "Dataset", "in", "the", "group", "and", "concatenate", "them", "together", "into", "a", "new", "Dataset", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L655-L686
train
Apply a function over each Dataset in the group and concatenate them together into a new Dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DatasetGroupBy._combine
def _combine(self, applied): """Recombine the applied objects like the original.""" applied_example, applied = peek_at(applied) coord, dim, positions = self._infer_concat_args(applied_example) combined = concat(applied, dim) combined = _maybe_reorder(combined, dim, positions) ...
python
def _combine(self, applied): """Recombine the applied objects like the original.""" applied_example, applied = peek_at(applied) coord, dim, positions = self._infer_concat_args(applied_example) combined = concat(applied, dim) combined = _maybe_reorder(combined, dim, positions) ...
[ "def", "_combine", "(", "self", ",", "applied", ")", ":", "applied_example", ",", "applied", "=", "peek_at", "(", "applied", ")", "coord", ",", "dim", ",", "positions", "=", "self", ".", "_infer_concat_args", "(", "applied_example", ")", "combined", "=", "...
Recombine the applied objects like the original.
[ "Recombine", "the", "applied", "objects", "like", "the", "original", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L688-L698
train
Recombine the applied objects like the original.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/groupby.py
DatasetGroupBy.reduce
def reduce(self, func, dim=None, keep_attrs=None, **kwargs): """Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=axis, **kwargs)` to ret...
python
def reduce(self, func, dim=None, keep_attrs=None, **kwargs): """Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=axis, **kwargs)` to ret...
[ "def", "reduce", "(", "self", ",", "func", ",", "dim", "=", "None", ",", "keep_attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "dim", "==", "DEFAULT_DIMS", ":", "dim", "=", "ALL_DIMS", "# TODO change this to dim = self._group_dim after", "# the...
Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=axis, **kwargs)` to return the result of collapsing an np.ndarray over an integer v...
[ "Reduce", "the", "items", "in", "this", "group", "by", "applying", "func", "along", "some", "dimension", "(", "s", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L700-L747
train
Reduce the items in this group by applying func along some dimension.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_filter_attrs
def _filter_attrs(attrs, ignored_attrs): """ Return attrs that are not in ignored_attrs """ return dict((k, v) for k, v in attrs.items() if k not in ignored_attrs)
python
def _filter_attrs(attrs, ignored_attrs): """ Return attrs that are not in ignored_attrs """ return dict((k, v) for k, v in attrs.items() if k not in ignored_attrs)
[ "def", "_filter_attrs", "(", "attrs", ",", "ignored_attrs", ")", ":", "return", "dict", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", "if", "k", "not", "in", "ignored_attrs", ")" ]
Return attrs that are not in ignored_attrs
[ "Return", "attrs", "that", "are", "not", "in", "ignored_attrs" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L30-L33
train
Return attrs that are not in ignored_attrs
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
from_cdms2
def from_cdms2(variable): """Convert a cdms2 variable into an DataArray """ values = np.asarray(variable) name = variable.id dims = variable.getAxisIds() coords = {} for axis in variable.getAxisList(): coords[axis.id] = DataArray( np.asarray(axis), dims=[axis.id], ...
python
def from_cdms2(variable): """Convert a cdms2 variable into an DataArray """ values = np.asarray(variable) name = variable.id dims = variable.getAxisIds() coords = {} for axis in variable.getAxisList(): coords[axis.id] = DataArray( np.asarray(axis), dims=[axis.id], ...
[ "def", "from_cdms2", "(", "variable", ")", ":", "values", "=", "np", ".", "asarray", "(", "variable", ")", "name", "=", "variable", ".", "id", "dims", "=", "variable", ".", "getAxisIds", "(", ")", "coords", "=", "{", "}", "for", "axis", "in", "variab...
Convert a cdms2 variable into an DataArray
[ "Convert", "a", "cdms2", "variable", "into", "an", "DataArray" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L36-L59
train
Convert a cdms2 variable into a DataArray
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
to_cdms2
def to_cdms2(dataarray, copy=True): """Convert a DataArray into a cdms2 variable """ # we don't want cdms2 to be a hard dependency import cdms2 def set_cdms2_attrs(var, attrs): for k, v in attrs.items(): setattr(var, k, v) # 1D axes axes = [] for dim in dataarray.di...
python
def to_cdms2(dataarray, copy=True): """Convert a DataArray into a cdms2 variable """ # we don't want cdms2 to be a hard dependency import cdms2 def set_cdms2_attrs(var, attrs): for k, v in attrs.items(): setattr(var, k, v) # 1D axes axes = [] for dim in dataarray.di...
[ "def", "to_cdms2", "(", "dataarray", ",", "copy", "=", "True", ")", ":", "# we don't want cdms2 to be a hard dependency", "import", "cdms2", "def", "set_cdms2_attrs", "(", "var", ",", "attrs", ")", ":", "for", "k", ",", "v", "in", "attrs", ".", "items", "(",...
Convert a DataArray into a cdms2 variable
[ "Convert", "a", "DataArray", "into", "a", "cdms2", "variable" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L62-L116
train
Convert a DataArray into a cdms2 variable and its axes and grids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_pick_attrs
def _pick_attrs(attrs, keys): """ Return attrs with keys in keys list """ return dict((k, v) for k, v in attrs.items() if k in keys)
python
def _pick_attrs(attrs, keys): """ Return attrs with keys in keys list """ return dict((k, v) for k, v in attrs.items() if k in keys)
[ "def", "_pick_attrs", "(", "attrs", ",", "keys", ")", ":", "return", "dict", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", "if", "k", "in", "keys", ")" ]
Return attrs with keys in keys list
[ "Return", "attrs", "with", "keys", "in", "keys", "list" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L119-L122
train
Return attrs with keys in keys list
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_get_iris_args
def _get_iris_args(attrs): """ Converts the xarray attrs into args that can be passed into Iris """ # iris.unit is deprecated in Iris v1.9 import cf_units args = {'attributes': _filter_attrs(attrs, iris_forbidden_keys)} args.update(_pick_attrs(attrs, ('standard_name', 'long_name',))) unit_ar...
python
def _get_iris_args(attrs): """ Converts the xarray attrs into args that can be passed into Iris """ # iris.unit is deprecated in Iris v1.9 import cf_units args = {'attributes': _filter_attrs(attrs, iris_forbidden_keys)} args.update(_pick_attrs(attrs, ('standard_name', 'long_name',))) unit_ar...
[ "def", "_get_iris_args", "(", "attrs", ")", ":", "# iris.unit is deprecated in Iris v1.9", "import", "cf_units", "args", "=", "{", "'attributes'", ":", "_filter_attrs", "(", "attrs", ",", "iris_forbidden_keys", ")", "}", "args", ".", "update", "(", "_pick_attrs", ...
Converts the xarray attrs into args that can be passed into Iris
[ "Converts", "the", "xarray", "attrs", "into", "args", "that", "can", "be", "passed", "into", "Iris" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L125-L135
train
Converts the xarray attrs into args that can be passed into Iris
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
to_iris
def to_iris(dataarray): """ Convert a DataArray into a Iris Cube """ # Iris not a hard dependency import iris from iris.fileformats.netcdf import parse_cell_methods dim_coords = [] aux_coords = [] for coord_name in dataarray.coords: coord = encode(dataarray.coords[coord_name]) ...
python
def to_iris(dataarray): """ Convert a DataArray into a Iris Cube """ # Iris not a hard dependency import iris from iris.fileformats.netcdf import parse_cell_methods dim_coords = [] aux_coords = [] for coord_name in dataarray.coords: coord = encode(dataarray.coords[coord_name]) ...
[ "def", "to_iris", "(", "dataarray", ")", ":", "# Iris not a hard dependency", "import", "iris", "from", "iris", ".", "fileformats", ".", "netcdf", "import", "parse_cell_methods", "dim_coords", "=", "[", "]", "aux_coords", "=", "[", "]", "for", "coord_name", "in"...
Convert a DataArray into a Iris Cube
[ "Convert", "a", "DataArray", "into", "a", "Iris", "Cube" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L139-L178
train
Convert a DataArray into a Iris Cube
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_iris_obj_to_attrs
def _iris_obj_to_attrs(obj): """ Return a dictionary of attrs when given a Iris object """ attrs = {'standard_name': obj.standard_name, 'long_name': obj.long_name} if obj.units.calendar: attrs['calendar'] = obj.units.calendar if obj.units.origin != '1' and not obj.units.is_unkno...
python
def _iris_obj_to_attrs(obj): """ Return a dictionary of attrs when given a Iris object """ attrs = {'standard_name': obj.standard_name, 'long_name': obj.long_name} if obj.units.calendar: attrs['calendar'] = obj.units.calendar if obj.units.origin != '1' and not obj.units.is_unkno...
[ "def", "_iris_obj_to_attrs", "(", "obj", ")", ":", "attrs", "=", "{", "'standard_name'", ":", "obj", ".", "standard_name", ",", "'long_name'", ":", "obj", ".", "long_name", "}", "if", "obj", ".", "units", ".", "calendar", ":", "attrs", "[", "'calendar'", ...
Return a dictionary of attrs when given a Iris object
[ "Return", "a", "dictionary", "of", "attrs", "when", "given", "a", "Iris", "object" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L181-L191
train
Return a dictionary of attrs when given a Iris object
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_iris_cell_methods_to_str
def _iris_cell_methods_to_str(cell_methods_obj): """ Converts a Iris cell methods into a string """ cell_methods = [] for cell_method in cell_methods_obj: names = ''.join(['{}: '.format(n) for n in cell_method.coord_names]) intervals = ' '.join(['interval: {}'.format(interval) ...
python
def _iris_cell_methods_to_str(cell_methods_obj): """ Converts a Iris cell methods into a string """ cell_methods = [] for cell_method in cell_methods_obj: names = ''.join(['{}: '.format(n) for n in cell_method.coord_names]) intervals = ' '.join(['interval: {}'.format(interval) ...
[ "def", "_iris_cell_methods_to_str", "(", "cell_methods_obj", ")", ":", "cell_methods", "=", "[", "]", "for", "cell_method", "in", "cell_methods_obj", ":", "names", "=", "''", ".", "join", "(", "[", "'{}: '", ".", "format", "(", "n", ")", "for", "n", "in", ...
Converts a Iris cell methods into a string
[ "Converts", "a", "Iris", "cell", "methods", "into", "a", "string" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L194-L208
train
Converts a Iris cell methods into a string
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
_name
def _name(iris_obj, default='unknown'): """ Mimicks `iris_obj.name()` but with different name resolution order. Similar to iris_obj.name() method, but using iris_obj.var_name first to enable roundtripping. """ return (iris_obj.var_name or iris_obj.standard_name or iris_obj.long_name or ...
python
def _name(iris_obj, default='unknown'): """ Mimicks `iris_obj.name()` but with different name resolution order. Similar to iris_obj.name() method, but using iris_obj.var_name first to enable roundtripping. """ return (iris_obj.var_name or iris_obj.standard_name or iris_obj.long_name or ...
[ "def", "_name", "(", "iris_obj", ",", "default", "=", "'unknown'", ")", ":", "return", "(", "iris_obj", ".", "var_name", "or", "iris_obj", ".", "standard_name", "or", "iris_obj", ".", "long_name", "or", "default", ")" ]
Mimicks `iris_obj.name()` but with different name resolution order. Similar to iris_obj.name() method, but using iris_obj.var_name first to enable roundtripping.
[ "Mimicks", "iris_obj", ".", "name", "()", "but", "with", "different", "name", "resolution", "order", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L211-L218
train
Mimicks name method but with different name resolution order.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/convert.py
from_iris
def from_iris(cube): """ Convert a Iris cube into an DataArray """ import iris.exceptions from xarray.core.pycompat import dask_array_type name = _name(cube) if name == 'unknown': name = None dims = [] for i in range(cube.ndim): try: dim_coord = cube.coord(di...
python
def from_iris(cube): """ Convert a Iris cube into an DataArray """ import iris.exceptions from xarray.core.pycompat import dask_array_type name = _name(cube) if name == 'unknown': name = None dims = [] for i in range(cube.ndim): try: dim_coord = cube.coord(di...
[ "def", "from_iris", "(", "cube", ")", ":", "import", "iris", ".", "exceptions", "from", "xarray", ".", "core", ".", "pycompat", "import", "dask_array_type", "name", "=", "_name", "(", "cube", ")", "if", "name", "==", "'unknown'", ":", "name", "=", "None"...
Convert a Iris cube into an DataArray
[ "Convert", "a", "Iris", "cube", "into", "an", "DataArray" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L221-L272
train
Convert a Iris cube into a DataArray .
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
decode_cf_datetime
def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None): """Given an array of numeric dates in netCDF format, convert it into a numpy array of date time objects. For standard (Gregorian) calendars, this function uses vectorized operations, which makes it much faster than cftime.num2dat...
python
def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None): """Given an array of numeric dates in netCDF format, convert it into a numpy array of date time objects. For standard (Gregorian) calendars, this function uses vectorized operations, which makes it much faster than cftime.num2dat...
[ "def", "decode_cf_datetime", "(", "num_dates", ",", "units", ",", "calendar", "=", "None", ",", "use_cftime", "=", "None", ")", ":", "num_dates", "=", "np", ".", "asarray", "(", "num_dates", ")", "flat_num_dates", "=", "num_dates", ".", "ravel", "(", ")", ...
Given an array of numeric dates in netCDF format, convert it into a numpy array of date time objects. For standard (Gregorian) calendars, this function uses vectorized operations, which makes it much faster than cftime.num2date. In such a case, the returned array will be of type np.datetime64. Not...
[ "Given", "an", "array", "of", "numeric", "dates", "in", "netCDF", "format", "convert", "it", "into", "a", "numpy", "array", "of", "date", "time", "objects", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L153-L198
train
Given an array of numeric dates in netCDF format convert it into numpy array of date time objects.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
decode_cf_timedelta
def decode_cf_timedelta(num_timedeltas, units): """Given an array of numeric timedeltas in netCDF format, convert it into a numpy timedelta64[ns] array. """ num_timedeltas = np.asarray(num_timedeltas) units = _netcdf_to_numpy_timeunit(units) shape = num_timedeltas.shape num_timedeltas = num...
python
def decode_cf_timedelta(num_timedeltas, units): """Given an array of numeric timedeltas in netCDF format, convert it into a numpy timedelta64[ns] array. """ num_timedeltas = np.asarray(num_timedeltas) units = _netcdf_to_numpy_timeunit(units) shape = num_timedeltas.shape num_timedeltas = num...
[ "def", "decode_cf_timedelta", "(", "num_timedeltas", ",", "units", ")", ":", "num_timedeltas", "=", "np", ".", "asarray", "(", "num_timedeltas", ")", "units", "=", "_netcdf_to_numpy_timeunit", "(", "units", ")", "shape", "=", "num_timedeltas", ".", "shape", "num...
Given an array of numeric timedeltas in netCDF format, convert it into a numpy timedelta64[ns] array.
[ "Given", "an", "array", "of", "numeric", "timedeltas", "in", "netCDF", "format", "convert", "it", "into", "a", "numpy", "timedelta64", "[", "ns", "]", "array", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L201-L215
train
Given an array of numeric timedeltas in netCDF format convert it into a numpy timedelta64 [ ns ] array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
infer_calendar_name
def infer_calendar_name(dates): """Given an array of datetimes, infer the CF calendar name""" if np.asarray(dates).dtype == 'datetime64[ns]': return 'proleptic_gregorian' else: return np.asarray(dates).ravel()[0].calendar
python
def infer_calendar_name(dates): """Given an array of datetimes, infer the CF calendar name""" if np.asarray(dates).dtype == 'datetime64[ns]': return 'proleptic_gregorian' else: return np.asarray(dates).ravel()[0].calendar
[ "def", "infer_calendar_name", "(", "dates", ")", ":", "if", "np", ".", "asarray", "(", "dates", ")", ".", "dtype", "==", "'datetime64[ns]'", ":", "return", "'proleptic_gregorian'", "else", ":", "return", "np", ".", "asarray", "(", "dates", ")", ".", "ravel...
Given an array of datetimes, infer the CF calendar name
[ "Given", "an", "array", "of", "datetimes", "infer", "the", "CF", "calendar", "name" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L228-L233
train
Given an array of datetimes infer the CF calendar name
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
infer_datetime_units
def infer_datetime_units(dates): """Given an array of datetimes, returns a CF compatible time-unit string of the form "{time_unit} since {date[0]}", where `time_unit` is 'days', 'hours', 'minutes' or 'seconds' (the first one that can evenly divide all unique time deltas in `dates`) """ dates = n...
python
def infer_datetime_units(dates): """Given an array of datetimes, returns a CF compatible time-unit string of the form "{time_unit} since {date[0]}", where `time_unit` is 'days', 'hours', 'minutes' or 'seconds' (the first one that can evenly divide all unique time deltas in `dates`) """ dates = n...
[ "def", "infer_datetime_units", "(", "dates", ")", ":", "dates", "=", "np", ".", "asarray", "(", "dates", ")", ".", "ravel", "(", ")", "if", "np", ".", "asarray", "(", "dates", ")", ".", "dtype", "==", "'datetime64[ns]'", ":", "dates", "=", "pd", ".",...
Given an array of datetimes, returns a CF compatible time-unit string of the form "{time_unit} since {date[0]}", where `time_unit` is 'days', 'hours', 'minutes' or 'seconds' (the first one that can evenly divide all unique time deltas in `dates`)
[ "Given", "an", "array", "of", "datetimes", "returns", "a", "CF", "compatible", "time", "-", "unit", "string", "of", "the", "form", "{", "time_unit", "}", "since", "{", "date", "[", "0", "]", "}", "where", "time_unit", "is", "days", "hours", "minutes", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L236-L257
train
Given an array of datetimes returns a CF compatible time - unit string of the form days hours minutes or seconds
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
format_cftime_datetime
def format_cftime_datetime(date): """Converts a cftime.datetime object to a string with the format: YYYY-MM-DD HH:MM:SS.UUUUUU """ return '{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'.format( date.year, date.month, date.day, date.hour, date.minute, date.second, date.microsecond)
python
def format_cftime_datetime(date): """Converts a cftime.datetime object to a string with the format: YYYY-MM-DD HH:MM:SS.UUUUUU """ return '{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'.format( date.year, date.month, date.day, date.hour, date.minute, date.second, date.microsecond)
[ "def", "format_cftime_datetime", "(", "date", ")", ":", "return", "'{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'", ".", "format", "(", "date", ".", "year", ",", "date", ".", "month", ",", "date", ".", "day", ",", "date", ".", "hour", ",", "date", ".", "...
Converts a cftime.datetime object to a string with the format: YYYY-MM-DD HH:MM:SS.UUUUUU
[ "Converts", "a", "cftime", ".", "datetime", "object", "to", "a", "string", "with", "the", "format", ":", "YYYY", "-", "MM", "-", "DD", "HH", ":", "MM", ":", "SS", ".", "UUUUUU" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L260-L266
train
Converts a cftime. datetime object to a string with the format YYYY - MM - DD. UUUUUU YYYY - MM - DD. UUUUUUU YYYY - MM - DD. UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
infer_timedelta_units
def infer_timedelta_units(deltas): """Given an array of timedeltas, returns a CF compatible time-unit from {'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly divide all unique time deltas in `deltas`) """ deltas = pd.to_timedelta(np.asarray(deltas).ravel(), box=False) unique_t...
python
def infer_timedelta_units(deltas): """Given an array of timedeltas, returns a CF compatible time-unit from {'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly divide all unique time deltas in `deltas`) """ deltas = pd.to_timedelta(np.asarray(deltas).ravel(), box=False) unique_t...
[ "def", "infer_timedelta_units", "(", "deltas", ")", ":", "deltas", "=", "pd", ".", "to_timedelta", "(", "np", ".", "asarray", "(", "deltas", ")", ".", "ravel", "(", ")", ",", "box", "=", "False", ")", "unique_timedeltas", "=", "np", ".", "unique", "(",...
Given an array of timedeltas, returns a CF compatible time-unit from {'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly divide all unique time deltas in `deltas`)
[ "Given", "an", "array", "of", "timedeltas", "returns", "a", "CF", "compatible", "time", "-", "unit", "from", "{", "days", "hours", "minutes", "seconds", "}", "(", "the", "first", "one", "that", "can", "evenly", "divide", "all", "unique", "time", "deltas", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L269-L277
train
Given an array of timedeltas returns a CF compatible time - unit from that array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
cftime_to_nptime
def cftime_to_nptime(times): """Given an array of cftime.datetime objects, return an array of numpy.datetime64 objects of the same size""" times = np.asarray(times) new = np.empty(times.shape, dtype='M8[ns]') for i, t in np.ndenumerate(times): try: # Use pandas.Timestamp in place...
python
def cftime_to_nptime(times): """Given an array of cftime.datetime objects, return an array of numpy.datetime64 objects of the same size""" times = np.asarray(times) new = np.empty(times.shape, dtype='M8[ns]') for i, t in np.ndenumerate(times): try: # Use pandas.Timestamp in place...
[ "def", "cftime_to_nptime", "(", "times", ")", ":", "times", "=", "np", ".", "asarray", "(", "times", ")", "new", "=", "np", ".", "empty", "(", "times", ".", "shape", ",", "dtype", "=", "'M8[ns]'", ")", "for", "i", ",", "t", "in", "np", ".", "nden...
Given an array of cftime.datetime objects, return an array of numpy.datetime64 objects of the same size
[ "Given", "an", "array", "of", "cftime", ".", "datetime", "objects", "return", "an", "array", "of", "numpy", ".", "datetime64", "objects", "of", "the", "same", "size" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L280-L297
train
Given an array of cftime. datetime objects return an array of numpy. datetime64 objects of the same size
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
_encode_datetime_with_cftime
def _encode_datetime_with_cftime(dates, units, calendar): """Fallback method for encoding dates using cftime. This method is more flexible than xarray's parsing using datetime64[ns] arrays but also slower because it loops over each element. """ cftime = _import_cftime() if np.issubdtype(dates....
python
def _encode_datetime_with_cftime(dates, units, calendar): """Fallback method for encoding dates using cftime. This method is more flexible than xarray's parsing using datetime64[ns] arrays but also slower because it loops over each element. """ cftime = _import_cftime() if np.issubdtype(dates....
[ "def", "_encode_datetime_with_cftime", "(", "dates", ",", "units", ",", "calendar", ")", ":", "cftime", "=", "_import_cftime", "(", ")", "if", "np", ".", "issubdtype", "(", "dates", ".", "dtype", ",", "np", ".", "datetime64", ")", ":", "# numpy's broken date...
Fallback method for encoding dates using cftime. This method is more flexible than xarray's parsing using datetime64[ns] arrays but also slower because it loops over each element.
[ "Fallback", "method", "for", "encoding", "dates", "using", "cftime", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L310-L325
train
Fallback method for encoding dates using cftime.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/coding/times.py
encode_cf_datetime
def encode_cf_datetime(dates, units=None, calendar=None): """Given an array of datetime objects, returns the tuple `(num, units, calendar)` suitable for a CF compliant time variable. Unlike `date2num`, this function can handle datetime64 arrays. See also -------- cftime.date2num """ da...
python
def encode_cf_datetime(dates, units=None, calendar=None): """Given an array of datetime objects, returns the tuple `(num, units, calendar)` suitable for a CF compliant time variable. Unlike `date2num`, this function can handle datetime64 arrays. See also -------- cftime.date2num """ da...
[ "def", "encode_cf_datetime", "(", "dates", ",", "units", "=", "None", ",", "calendar", "=", "None", ")", ":", "dates", "=", "np", ".", "asarray", "(", "dates", ")", "if", "units", "is", "None", ":", "units", "=", "infer_datetime_units", "(", "dates", "...
Given an array of datetime objects, returns the tuple `(num, units, calendar)` suitable for a CF compliant time variable. Unlike `date2num`, this function can handle datetime64 arrays. See also -------- cftime.date2num
[ "Given", "an", "array", "of", "datetime", "objects", "returns", "the", "tuple", "(", "num", "units", "calendar", ")", "suitable", "for", "a", "CF", "compliant", "time", "variable", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L335-L381
train
Given an array of datetime objects returns the tuple num units and calendar suitable for a CF compliant time variable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
_validate_dataset_names
def _validate_dataset_names(dataset): """DataArray.name and Dataset keys must be a string or None""" def check_name(name): if isinstance(name, str): if not name: raise ValueError('Invalid name for DataArray or Dataset key: ' 'string must be le...
python
def _validate_dataset_names(dataset): """DataArray.name and Dataset keys must be a string or None""" def check_name(name): if isinstance(name, str): if not name: raise ValueError('Invalid name for DataArray or Dataset key: ' 'string must be le...
[ "def", "_validate_dataset_names", "(", "dataset", ")", ":", "def", "check_name", "(", "name", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "if", "not", "name", ":", "raise", "ValueError", "(", "'Invalid name for DataArray or Dataset key: '", ...
DataArray.name and Dataset keys must be a string or None
[ "DataArray", ".", "name", "and", "Dataset", "keys", "must", "be", "a", "string", "or", "None" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L125-L138
train
Validate the names of the DataArray and Dataset keys.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
_validate_attrs
def _validate_attrs(dataset): """`attrs` must have a string key and a value which is either: a number, a string, an ndarray or a list/tuple of numbers/strings. """ def check_attr(name, value): if isinstance(name, str): if not name: raise ValueError('Invalid name for a...
python
def _validate_attrs(dataset): """`attrs` must have a string key and a value which is either: a number, a string, an ndarray or a list/tuple of numbers/strings. """ def check_attr(name, value): if isinstance(name, str): if not name: raise ValueError('Invalid name for a...
[ "def", "_validate_attrs", "(", "dataset", ")", ":", "def", "check_attr", "(", "name", ",", "value", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "if", "not", "name", ":", "raise", "ValueError", "(", "'Invalid name for attr: string must be...
`attrs` must have a string key and a value which is either: a number, a string, an ndarray or a list/tuple of numbers/strings.
[ "attrs", "must", "have", "a", "string", "key", "and", "a", "value", "which", "is", "either", ":", "a", "number", "a", "string", "an", "ndarray", "or", "a", "list", "/", "tuple", "of", "numbers", "/", "strings", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L141-L169
train
Validate the attrs of the dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
open_dataset
def open_dataset(filename_or_obj, group=None, decode_cf=True, mask_and_scale=None, decode_times=True, autoclose=None, concat_characters=True, decode_coords=True, engine=None, chunks=None, lock=None, cache=None, drop_variables=None, backend_kwargs=None,...
python
def open_dataset(filename_or_obj, group=None, decode_cf=True, mask_and_scale=None, decode_times=True, autoclose=None, concat_characters=True, decode_coords=True, engine=None, chunks=None, lock=None, cache=None, drop_variables=None, backend_kwargs=None,...
[ "def", "open_dataset", "(", "filename_or_obj", ",", "group", "=", "None", ",", "decode_cf", "=", "True", ",", "mask_and_scale", "=", "None", ",", "decode_times", "=", "True", ",", "autoclose", "=", "None", ",", "concat_characters", "=", "True", ",", "decode_...
Load and decode a dataset from a file or file-like object. Parameters ---------- filename_or_obj : str, Path, file or xarray.backends.*DataStore Strings and Path objects are interpreted as a path to a netCDF file or an OpenDAP URL and opened with python-netCDF4, unless the filename ...
[ "Load", "and", "decode", "a", "dataset", "from", "a", "file", "or", "file", "-", "like", "object", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L188-L401
train
Load and decode a dataset from a file or file - like object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
open_dataarray
def open_dataarray(filename_or_obj, group=None, decode_cf=True, mask_and_scale=None, decode_times=True, autoclose=None, concat_characters=True, decode_coords=True, engine=None, chunks=None, lock=None, cache=None, drop_variables=None, backend_kw...
python
def open_dataarray(filename_or_obj, group=None, decode_cf=True, mask_and_scale=None, decode_times=True, autoclose=None, concat_characters=True, decode_coords=True, engine=None, chunks=None, lock=None, cache=None, drop_variables=None, backend_kw...
[ "def", "open_dataarray", "(", "filename_or_obj", ",", "group", "=", "None", ",", "decode_cf", "=", "True", ",", "mask_and_scale", "=", "None", ",", "decode_times", "=", "True", ",", "autoclose", "=", "None", ",", "concat_characters", "=", "True", ",", "decod...
Open an DataArray from a netCDF file containing a single data variable. This is designed to read netCDF files with only one data variable. If multiple variables are present then a ValueError is raised. Parameters ---------- filename_or_obj : str, Path, file or xarray.backends.*DataStore St...
[ "Open", "an", "DataArray", "from", "a", "netCDF", "file", "containing", "a", "single", "data", "variable", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L404-L529
train
Open an array from a netCDF file containing a single data variable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
open_mfdataset
def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT, compat='no_conflicts', preprocess=None, engine=None, lock=None, data_vars='all', coords='different', autoclose=None, parallel=False, **kwargs): """Open multiple files as a single dataset. ...
python
def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT, compat='no_conflicts', preprocess=None, engine=None, lock=None, data_vars='all', coords='different', autoclose=None, parallel=False, **kwargs): """Open multiple files as a single dataset. ...
[ "def", "open_mfdataset", "(", "paths", ",", "chunks", "=", "None", ",", "concat_dim", "=", "_CONCAT_DIM_DEFAULT", ",", "compat", "=", "'no_conflicts'", ",", "preprocess", "=", "None", ",", "engine", "=", "None", ",", "lock", "=", "None", ",", "data_vars", ...
Open multiple files as a single dataset. Requires dask to be installed. See documentation for details on dask [1]. Attributes from the first dataset file are used for the combined dataset. Parameters ---------- paths : str or sequence Either a string glob in the form "path/to/my/files/*.nc...
[ "Open", "multiple", "files", "as", "a", "single", "dataset", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L541-L727
train
Open multiple files as a single dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
to_netcdf
def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None, engine=None, encoding=None, unlimited_dims=None, compute=True, multifile=False): """This function creates an appropriate datastore for writing a dataset to disk as a netCDF file See `Dataset.to_netcdf` ...
python
def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None, engine=None, encoding=None, unlimited_dims=None, compute=True, multifile=False): """This function creates an appropriate datastore for writing a dataset to disk as a netCDF file See `Dataset.to_netcdf` ...
[ "def", "to_netcdf", "(", "dataset", ",", "path_or_file", "=", "None", ",", "mode", "=", "'w'", ",", "format", "=", "None", ",", "group", "=", "None", ",", "engine", "=", "None", ",", "encoding", "=", "None", ",", "unlimited_dims", "=", "None", ",", "...
This function creates an appropriate datastore for writing a dataset to disk as a netCDF file See `Dataset.to_netcdf` for full API docs. The ``multifile`` argument is only for the private use of save_mfdataset.
[ "This", "function", "creates", "an", "appropriate", "datastore", "for", "writing", "a", "dataset", "to", "disk", "as", "a", "netCDF", "file" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L735-L826
train
This function creates an appropriate datastore for writing a dataset to a netCDF file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
dump_to_store
def dump_to_store(dataset, store, writer=None, encoder=None, encoding=None, unlimited_dims=None): """Store dataset contents to a backends.*DataStore object.""" if writer is None: writer = ArrayWriter() if encoding is None: encoding = {} variables, attrs = conventions....
python
def dump_to_store(dataset, store, writer=None, encoder=None, encoding=None, unlimited_dims=None): """Store dataset contents to a backends.*DataStore object.""" if writer is None: writer = ArrayWriter() if encoding is None: encoding = {} variables, attrs = conventions....
[ "def", "dump_to_store", "(", "dataset", ",", "store", ",", "writer", "=", "None", ",", "encoder", "=", "None", ",", "encoding", "=", "None", ",", "unlimited_dims", "=", "None", ")", ":", "if", "writer", "is", "None", ":", "writer", "=", "ArrayWriter", ...
Store dataset contents to a backends.*DataStore object.
[ "Store", "dataset", "contents", "to", "a", "backends", ".", "*", "DataStore", "object", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L829-L851
train
Store dataset contents to a backends. DataStore object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
save_mfdataset
def save_mfdataset(datasets, paths, mode='w', format=None, groups=None, engine=None, compute=True): """Write multiple datasets to disk as netCDF files simultaneously. This function is intended for use with datasets consisting of dask.array objects, in which case it can write the multiple...
python
def save_mfdataset(datasets, paths, mode='w', format=None, groups=None, engine=None, compute=True): """Write multiple datasets to disk as netCDF files simultaneously. This function is intended for use with datasets consisting of dask.array objects, in which case it can write the multiple...
[ "def", "save_mfdataset", "(", "datasets", ",", "paths", ",", "mode", "=", "'w'", ",", "format", "=", "None", ",", "groups", "=", "None", ",", "engine", "=", "None", ",", "compute", "=", "True", ")", ":", "if", "mode", "==", "'w'", "and", "len", "("...
Write multiple datasets to disk as netCDF files simultaneously. This function is intended for use with datasets consisting of dask.array objects, in which case it can write the multiple datasets to disk simultaneously using a shared thread pool. When not using dask, it is no different than calling ``t...
[ "Write", "multiple", "datasets", "to", "disk", "as", "netCDF", "files", "simultaneously", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L854-L950
train
Save multiple datasets to disk as netCDF files simultaneously.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/api.py
to_zarr
def to_zarr(dataset, store=None, mode='w-', synchronizer=None, group=None, encoding=None, compute=True, consolidated=False): """This function creates an appropriate datastore for writing a dataset to a zarr ztore See `Dataset.to_zarr` for full API docs. """ if isinstance(store, Path): ...
python
def to_zarr(dataset, store=None, mode='w-', synchronizer=None, group=None, encoding=None, compute=True, consolidated=False): """This function creates an appropriate datastore for writing a dataset to a zarr ztore See `Dataset.to_zarr` for full API docs. """ if isinstance(store, Path): ...
[ "def", "to_zarr", "(", "dataset", ",", "store", "=", "None", ",", "mode", "=", "'w-'", ",", "synchronizer", "=", "None", ",", "group", "=", "None", ",", "encoding", "=", "None", ",", "compute", "=", "True", ",", "consolidated", "=", "False", ")", ":"...
This function creates an appropriate datastore for writing a dataset to a zarr ztore See `Dataset.to_zarr` for full API docs.
[ "This", "function", "creates", "an", "appropriate", "datastore", "for", "writing", "a", "dataset", "to", "a", "zarr", "ztore" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L953-L985
train
This function creates an appropriate datastore for writing a dataset to a zarr ztore \'' + store + '\'.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/pdcompat.py
remove_unused_levels
def remove_unused_levels(self): """ create a new MultiIndex from the current that removing unused levels, meaning that they are not expressed in the labels The resulting MultiIndex will have the same outward appearance, meaning the same .values and ordering. It will also be .equals() to the orig...
python
def remove_unused_levels(self): """ create a new MultiIndex from the current that removing unused levels, meaning that they are not expressed in the labels The resulting MultiIndex will have the same outward appearance, meaning the same .values and ordering. It will also be .equals() to the orig...
[ "def", "remove_unused_levels", "(", "self", ")", ":", "import", "pandas", ".", "core", ".", "algorithms", "as", "algos", "new_levels", "=", "[", "]", "new_labels", "=", "[", "]", "changed", "=", "False", "for", "lev", ",", "lab", "in", "zip", "(", "sel...
create a new MultiIndex from the current that removing unused levels, meaning that they are not expressed in the labels The resulting MultiIndex will have the same outward appearance, meaning the same .values and ordering. It will also be .equals() to the original. .. versionadded:: 0.20.0 Retur...
[ "create", "a", "new", "MultiIndex", "from", "the", "current", "that", "removing", "unused", "levels", "meaning", "that", "they", "are", "not", "expressed", "in", "the", "labels", "The", "resulting", "MultiIndex", "will", "have", "the", "same", "outward", "appe...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/pdcompat.py#L45-L118
train
Returns a new MultiIndex that contains all the unused levels in the current MultiIndex.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
robust_getitem
def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500): """ Robustly index an array, using retry logic with exponential backoff if any of the errors ``catch`` are raised. The initial_delay is measured in ms. With the default settings, the maximum delay will...
python
def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500): """ Robustly index an array, using retry logic with exponential backoff if any of the errors ``catch`` are raised. The initial_delay is measured in ms. With the default settings, the maximum delay will...
[ "def", "robust_getitem", "(", "array", ",", "key", ",", "catch", "=", "Exception", ",", "max_retries", "=", "6", ",", "initial_delay", "=", "500", ")", ":", "assert", "max_retries", ">=", "0", "for", "n", "in", "range", "(", "max_retries", "+", "1", ")...
Robustly index an array, using retry logic with exponential backoff if any of the errors ``catch`` are raised. The initial_delay is measured in ms. With the default settings, the maximum delay will be in the range of 32-64 seconds.
[ "Robustly", "index", "an", "array", "using", "retry", "logic", "with", "exponential", "backoff", "if", "any", "of", "the", "errors", "catch", "are", "raised", ".", "The", "initial_delay", "is", "measured", "in", "ms", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L43-L65
train
Robustly index an array using exponential backoff.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractDataStore.load
def load(self): """ This loads the variables and attributes simultaneously. A centralized loading function makes it easier to create data stores that do automatic encoding/decoding. For example:: class SuffixAppendingDataStore(AbstractDataStore): de...
python
def load(self): """ This loads the variables and attributes simultaneously. A centralized loading function makes it easier to create data stores that do automatic encoding/decoding. For example:: class SuffixAppendingDataStore(AbstractDataStore): de...
[ "def", "load", "(", "self", ")", ":", "variables", "=", "FrozenOrderedDict", "(", "(", "_decode_variable_name", "(", "k", ")", ",", "v", ")", "for", "k", ",", "v", "in", "self", ".", "get_variables", "(", ")", ".", "items", "(", ")", ")", "attributes...
This loads the variables and attributes simultaneously. A centralized loading function makes it easier to create data stores that do automatic encoding/decoding. For example:: class SuffixAppendingDataStore(AbstractDataStore): def load(self): va...
[ "This", "loads", "the", "variables", "and", "attributes", "simultaneously", ".", "A", "centralized", "loading", "function", "makes", "it", "easier", "to", "create", "data", "stores", "that", "do", "automatic", "encoding", "/", "decoding", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L98-L122
train
This loads the variables and attributes simultaneously. This function is a centralized loading function makes it easier to create a new SuffixAppendingDataStore class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractWritableDataStore.encode
def encode(self, variables, attributes): """ Encode the variables and attributes in this store Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs attributes : dict-like Dictionary of key/value (...
python
def encode(self, variables, attributes): """ Encode the variables and attributes in this store Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs attributes : dict-like Dictionary of key/value (...
[ "def", "encode", "(", "self", ",", "variables", ",", "attributes", ")", ":", "variables", "=", "OrderedDict", "(", "[", "(", "k", ",", "self", ".", "encode_variable", "(", "v", ")", ")", "for", "k", ",", "v", "in", "variables", ".", "items", "(", "...
Encode the variables and attributes in this store Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs attributes : dict-like Dictionary of key/value (attribute name / attribute) pairs Returns --...
[ "Encode", "the", "variables", "and", "attributes", "in", "this", "store" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L186-L207
train
Encodes the variables and attributes in this store
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractWritableDataStore.store
def store(self, variables, attributes, check_encoding_set=frozenset(), writer=None, unlimited_dims=None): """ Top level method for putting data on this store, this method: - encodes variables/attributes - sets dimensions - sets variables Parameters ...
python
def store(self, variables, attributes, check_encoding_set=frozenset(), writer=None, unlimited_dims=None): """ Top level method for putting data on this store, this method: - encodes variables/attributes - sets dimensions - sets variables Parameters ...
[ "def", "store", "(", "self", ",", "variables", ",", "attributes", ",", "check_encoding_set", "=", "frozenset", "(", ")", ",", "writer", "=", "None", ",", "unlimited_dims", "=", "None", ")", ":", "if", "writer", "is", "None", ":", "writer", "=", "ArrayWri...
Top level method for putting data on this store, this method: - encodes variables/attributes - sets dimensions - sets variables Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs attributes : ...
[ "Top", "level", "method", "for", "putting", "data", "on", "this", "store", "this", "method", ":", "-", "encodes", "variables", "/", "attributes", "-", "sets", "dimensions", "-", "sets", "variables" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L235-L265
train
This method stores the data in the internal store.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractWritableDataStore.set_attributes
def set_attributes(self, attributes): """ This provides a centralized method to set the dataset attributes on the data store. Parameters ---------- attributes : dict-like Dictionary of key/value (attribute name / attribute) pairs """ for k, v ...
python
def set_attributes(self, attributes): """ This provides a centralized method to set the dataset attributes on the data store. Parameters ---------- attributes : dict-like Dictionary of key/value (attribute name / attribute) pairs """ for k, v ...
[ "def", "set_attributes", "(", "self", ",", "attributes", ")", ":", "for", "k", ",", "v", "in", "attributes", ".", "items", "(", ")", ":", "self", ".", "set_attribute", "(", "k", ",", "v", ")" ]
This provides a centralized method to set the dataset attributes on the data store. Parameters ---------- attributes : dict-like Dictionary of key/value (attribute name / attribute) pairs
[ "This", "provides", "a", "centralized", "method", "to", "set", "the", "dataset", "attributes", "on", "the", "data", "store", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L267-L278
train
This method sets the attributes on the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractWritableDataStore.set_variables
def set_variables(self, variables, check_encoding_set, writer, unlimited_dims=None): """ This provides a centralized method to set the variables on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (vari...
python
def set_variables(self, variables, check_encoding_set, writer, unlimited_dims=None): """ This provides a centralized method to set the variables on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (vari...
[ "def", "set_variables", "(", "self", ",", "variables", ",", "check_encoding_set", ",", "writer", ",", "unlimited_dims", "=", "None", ")", ":", "for", "vn", ",", "v", "in", "variables", ".", "items", "(", ")", ":", "name", "=", "_encode_variable_name", "(",...
This provides a centralized method to set the variables on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs check_encoding_set : list-like List of variables that should be checked for ...
[ "This", "provides", "a", "centralized", "method", "to", "set", "the", "variables", "on", "the", "data", "store", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L280-L305
train
This method sets the variables on the data store.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/common.py
AbstractWritableDataStore.set_dimensions
def set_dimensions(self, variables, unlimited_dims=None): """ This provides a centralized method to set the dimensions on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs unlimited...
python
def set_dimensions(self, variables, unlimited_dims=None): """ This provides a centralized method to set the dimensions on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs unlimited...
[ "def", "set_dimensions", "(", "self", ",", "variables", ",", "unlimited_dims", "=", "None", ")", ":", "if", "unlimited_dims", "is", "None", ":", "unlimited_dims", "=", "set", "(", ")", "existing_dims", "=", "self", ".", "get_dimensions", "(", ")", "dims", ...
This provides a centralized method to set the dimensions on the data store. Parameters ---------- variables : dict-like Dictionary of key/value (variable name / xr.Variable) pairs unlimited_dims : list-like List of dimension names that should be treated a...
[ "This", "provides", "a", "centralized", "method", "to", "set", "the", "dimensions", "on", "the", "data", "store", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L307-L338
train
This method sets the dimensions of the data store.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_season_from_months
def _season_from_months(months): """Compute season (DJF, MAM, JJA, SON) from month ordinal """ # TODO: Move "season" accessor upstream into pandas seasons = np.array(['DJF', 'MAM', 'JJA', 'SON']) months = np.asarray(months) return seasons[(months // 3) % 4]
python
def _season_from_months(months): """Compute season (DJF, MAM, JJA, SON) from month ordinal """ # TODO: Move "season" accessor upstream into pandas seasons = np.array(['DJF', 'MAM', 'JJA', 'SON']) months = np.asarray(months) return seasons[(months // 3) % 4]
[ "def", "_season_from_months", "(", "months", ")", ":", "# TODO: Move \"season\" accessor upstream into pandas", "seasons", "=", "np", ".", "array", "(", "[", "'DJF'", ",", "'MAM'", ",", "'JJA'", ",", "'SON'", "]", ")", "months", "=", "np", ".", "asarray", "(",...
Compute season (DJF, MAM, JJA, SON) from month ordinal
[ "Compute", "season", "(", "DJF", "MAM", "JJA", "SON", ")", "from", "month", "ordinal" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L8-L14
train
Compute season from month ordinal
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_access_through_cftimeindex
def _access_through_cftimeindex(values, name): """Coerce an array of datetime-like values to a CFTimeIndex and access requested datetime component """ from ..coding.cftimeindex import CFTimeIndex values_as_cftimeindex = CFTimeIndex(values.ravel()) if name == 'season': months = values_as_...
python
def _access_through_cftimeindex(values, name): """Coerce an array of datetime-like values to a CFTimeIndex and access requested datetime component """ from ..coding.cftimeindex import CFTimeIndex values_as_cftimeindex = CFTimeIndex(values.ravel()) if name == 'season': months = values_as_...
[ "def", "_access_through_cftimeindex", "(", "values", ",", "name", ")", ":", "from", ".", ".", "coding", ".", "cftimeindex", "import", "CFTimeIndex", "values_as_cftimeindex", "=", "CFTimeIndex", "(", "values", ".", "ravel", "(", ")", ")", "if", "name", "==", ...
Coerce an array of datetime-like values to a CFTimeIndex and access requested datetime component
[ "Coerce", "an", "array", "of", "datetime", "-", "like", "values", "to", "a", "CFTimeIndex", "and", "access", "requested", "datetime", "component" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L17-L28
train
Coerce an array of datetime - like values to a CFTimeIndex and access requested datetime component
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_access_through_series
def _access_through_series(values, name): """Coerce an array of datetime-like values to a pandas Series and access requested datetime component """ values_as_series = pd.Series(values.ravel()) if name == "season": months = values_as_series.dt.month.values field_values = _season_from_...
python
def _access_through_series(values, name): """Coerce an array of datetime-like values to a pandas Series and access requested datetime component """ values_as_series = pd.Series(values.ravel()) if name == "season": months = values_as_series.dt.month.values field_values = _season_from_...
[ "def", "_access_through_series", "(", "values", ",", "name", ")", ":", "values_as_series", "=", "pd", ".", "Series", "(", "values", ".", "ravel", "(", ")", ")", "if", "name", "==", "\"season\"", ":", "months", "=", "values_as_series", ".", "dt", ".", "mo...
Coerce an array of datetime-like values to a pandas Series and access requested datetime component
[ "Coerce", "an", "array", "of", "datetime", "-", "like", "values", "to", "a", "pandas", "Series", "and", "access", "requested", "datetime", "component" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L31-L41
train
Coerce an array of datetime - like values to a pandas Series and access requested datetime component
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_get_date_field
def _get_date_field(values, name, dtype): """Indirectly access pandas' libts.get_date_field by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str Name...
python
def _get_date_field(values, name, dtype): """Indirectly access pandas' libts.get_date_field by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str Name...
[ "def", "_get_date_field", "(", "values", ",", "name", ",", "dtype", ")", ":", "if", "is_np_datetime_like", "(", "values", ".", "dtype", ")", ":", "access_method", "=", "_access_through_series", "else", ":", "access_method", "=", "_access_through_cftimeindex", "if"...
Indirectly access pandas' libts.get_date_field by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str Name of datetime field to access dtype : dtype-li...
[ "Indirectly", "access", "pandas", "libts", ".", "get_date_field", "by", "wrapping", "data", "as", "a", "Series", "and", "calling", "through", ".", "dt", "attribute", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L44-L73
train
Indirectly access pandas libts. get_date_field by wrapping data as a Series and calling through. dt attribute.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_round_series
def _round_series(values, name, freq): """Coerce an array of datetime-like values to a pandas Series and apply requested rounding """ values_as_series = pd.Series(values.ravel()) method = getattr(values_as_series.dt, name) field_values = method(freq=freq).values return field_values.reshape(...
python
def _round_series(values, name, freq): """Coerce an array of datetime-like values to a pandas Series and apply requested rounding """ values_as_series = pd.Series(values.ravel()) method = getattr(values_as_series.dt, name) field_values = method(freq=freq).values return field_values.reshape(...
[ "def", "_round_series", "(", "values", ",", "name", ",", "freq", ")", ":", "values_as_series", "=", "pd", ".", "Series", "(", "values", ".", "ravel", "(", ")", ")", "method", "=", "getattr", "(", "values_as_series", ".", "dt", ",", "name", ")", "field_...
Coerce an array of datetime-like values to a pandas Series and apply requested rounding
[ "Coerce", "an", "array", "of", "datetime", "-", "like", "values", "to", "a", "pandas", "Series", "and", "apply", "requested", "rounding" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L76-L84
train
Coerce an array of datetime - like values to a pandas Series and apply requested rounding
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/accessors.py
_round_field
def _round_field(values, name, freq): """Indirectly access pandas rounding functions by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str (ceil, floor, round...
python
def _round_field(values, name, freq): """Indirectly access pandas rounding functions by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str (ceil, floor, round...
[ "def", "_round_field", "(", "values", ",", "name", ",", "freq", ")", ":", "if", "isinstance", "(", "values", ",", "dask_array_type", ")", ":", "from", "dask", ".", "array", "import", "map_blocks", "return", "map_blocks", "(", "_round_series", ",", "values", ...
Indirectly access pandas rounding functions by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str (ceil, floor, round) Name of rounding function freq ...
[ "Indirectly", "access", "pandas", "rounding", "functions", "by", "wrapping", "data", "as", "a", "Series", "and", "calling", "through", ".", "dt", "attribute", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L87-L110
train
Indirectly access pandas rounding functions by wrapping data as a Series and calling through. dt attribute.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/ops.py
fillna
def fillna(data, other, join="left", dataset_join="left"): """Fill missing values in this object with data from the other object. Follows normal broadcasting and alignment rules. Parameters ---------- join : {'outer', 'inner', 'left', 'right'}, optional Method for joining the indexes of the...
python
def fillna(data, other, join="left", dataset_join="left"): """Fill missing values in this object with data from the other object. Follows normal broadcasting and alignment rules. Parameters ---------- join : {'outer', 'inner', 'left', 'right'}, optional Method for joining the indexes of the...
[ "def", "fillna", "(", "data", ",", "other", ",", "join", "=", "\"left\"", ",", "dataset_join", "=", "\"left\"", ")", ":", "from", ".", "computation", "import", "apply_ufunc", "return", "apply_ufunc", "(", "duck_array_ops", ".", "fillna", ",", "data", ",", ...
Fill missing values in this object with data from the other object. Follows normal broadcasting and alignment rules. Parameters ---------- join : {'outer', 'inner', 'left', 'right'}, optional Method for joining the indexes of the passed objects along each dimension - 'outer': us...
[ "Fill", "missing", "values", "in", "this", "object", "with", "data", "from", "the", "other", "object", ".", "Follows", "normal", "broadcasting", "and", "alignment", "rules", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/ops.py#L135-L165
train
Fill missing values in this object with data from other object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/ops.py
where_method
def where_method(self, cond, other=dtypes.NA): """Return elements from `self` or `other` depending on `cond`. Parameters ---------- cond : DataArray or Dataset with boolean dtype Locations at which to preserve this objects values. other : scalar, DataArray or Dataset, optional Value...
python
def where_method(self, cond, other=dtypes.NA): """Return elements from `self` or `other` depending on `cond`. Parameters ---------- cond : DataArray or Dataset with boolean dtype Locations at which to preserve this objects values. other : scalar, DataArray or Dataset, optional Value...
[ "def", "where_method", "(", "self", ",", "cond", ",", "other", "=", "dtypes", ".", "NA", ")", ":", "from", ".", "computation", "import", "apply_ufunc", "# alignment for three arguments is complicated, so don't support it yet", "join", "=", "'inner'", "if", "other", ...
Return elements from `self` or `other` depending on `cond`. Parameters ---------- cond : DataArray or Dataset with boolean dtype Locations at which to preserve this objects values. other : scalar, DataArray or Dataset, optional Value to use for locations in this object where ``cond`` is...
[ "Return", "elements", "from", "self", "or", "other", "depending", "on", "cond", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/ops.py#L168-L191
train
Return elements from self or other depending on cond.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/tutorial.py
open_dataset
def open_dataset(name, cache=True, cache_dir=_default_cache_dir, github_url='https://github.com/pydata/xarray-data', branch='master', **kws): """ Load a dataset from the online repository (requires internet). If a local copy is found then always use that to avoid network t...
python
def open_dataset(name, cache=True, cache_dir=_default_cache_dir, github_url='https://github.com/pydata/xarray-data', branch='master', **kws): """ Load a dataset from the online repository (requires internet). If a local copy is found then always use that to avoid network t...
[ "def", "open_dataset", "(", "name", ",", "cache", "=", "True", ",", "cache_dir", "=", "_default_cache_dir", ",", "github_url", "=", "'https://github.com/pydata/xarray-data'", ",", "branch", "=", "'master'", ",", "*", "*", "kws", ")", ":", "longdir", "=", "_os"...
Load a dataset from the online repository (requires internet). If a local copy is found then always use that to avoid network traffic. Parameters ---------- name : str Name of the netcdf file containing the dataset ie. 'air_temperature' cache_dir : string, optional The dire...
[ "Load", "a", "dataset", "from", "the", "online", "repository", "(", "requires", "internet", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/tutorial.py#L26-L89
train
Open a netcdf dataset from the online repository.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/tutorial.py
load_dataset
def load_dataset(*args, **kwargs): """ `load_dataset` will be removed a future version of xarray. The current behavior of this function can be achived by using `tutorial.open_dataset(...).load()`. See Also -------- open_dataset """ warnings.warn( "load_dataset` will be remov...
python
def load_dataset(*args, **kwargs): """ `load_dataset` will be removed a future version of xarray. The current behavior of this function can be achived by using `tutorial.open_dataset(...).load()`. See Also -------- open_dataset """ warnings.warn( "load_dataset` will be remov...
[ "def", "load_dataset", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"load_dataset` will be removed in a future version of xarray. The \"", "\"current behavior of this function can be achived by using \"", "\"`tutorial.open_dataset(...).load()...
`load_dataset` will be removed a future version of xarray. The current behavior of this function can be achived by using `tutorial.open_dataset(...).load()`. See Also -------- open_dataset
[ "load_dataset", "will", "be", "removed", "a", "future", "version", "of", "xarray", ".", "The", "current", "behavior", "of", "this", "function", "can", "be", "achived", "by", "using", "tutorial", ".", "open_dataset", "(", "...", ")", ".", "load", "()", "." ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/tutorial.py#L92-L107
train
A function that opens a new xarray dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/file_manager.py
CachingFileManager._make_key
def _make_key(self): """Make a key for caching files in the LRU cache.""" value = (self._opener, self._args, 'a' if self._mode == 'w' else self._mode, tuple(sorted(self._kwargs.items()))) return _HashedSequence(value)
python
def _make_key(self): """Make a key for caching files in the LRU cache.""" value = (self._opener, self._args, 'a' if self._mode == 'w' else self._mode, tuple(sorted(self._kwargs.items()))) return _HashedSequence(value)
[ "def", "_make_key", "(", "self", ")", ":", "value", "=", "(", "self", ".", "_opener", ",", "self", ".", "_args", ",", "'a'", "if", "self", ".", "_mode", "==", "'w'", "else", "self", ".", "_mode", ",", "tuple", "(", "sorted", "(", "self", ".", "_k...
Make a key for caching files in the LRU cache.
[ "Make", "a", "key", "for", "caching", "files", "in", "the", "LRU", "cache", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L134-L140
train
Make a key for caching files in the LRU cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/file_manager.py
CachingFileManager.acquire
def acquire(self, needs_lock=True): """Acquiring a file object from the manager. A new file is only opened if it has expired from the least-recently-used cache. This method uses a lock, which ensures that it is thread-safe. You can safely acquire a file in multiple threads at t...
python
def acquire(self, needs_lock=True): """Acquiring a file object from the manager. A new file is only opened if it has expired from the least-recently-used cache. This method uses a lock, which ensures that it is thread-safe. You can safely acquire a file in multiple threads at t...
[ "def", "acquire", "(", "self", ",", "needs_lock", "=", "True", ")", ":", "with", "self", ".", "_optional_lock", "(", "needs_lock", ")", ":", "try", ":", "file", "=", "self", ".", "_cache", "[", "self", ".", "_key", "]", "except", "KeyError", ":", "kw...
Acquiring a file object from the manager. A new file is only opened if it has expired from the least-recently-used cache. This method uses a lock, which ensures that it is thread-safe. You can safely acquire a file in multiple threads at the same time, as long as the underlying...
[ "Acquiring", "a", "file", "object", "from", "the", "manager", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L151-L178
train
Acquiring a file object from the manager.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/file_manager.py
CachingFileManager.close
def close(self, needs_lock=True): """Explicitly close any associated file object (if necessary).""" # TODO: remove needs_lock if/when we have a reentrant lock in # dask.distributed: https://github.com/dask/dask/issues/3832 with self._optional_lock(needs_lock): default = None ...
python
def close(self, needs_lock=True): """Explicitly close any associated file object (if necessary).""" # TODO: remove needs_lock if/when we have a reentrant lock in # dask.distributed: https://github.com/dask/dask/issues/3832 with self._optional_lock(needs_lock): default = None ...
[ "def", "close", "(", "self", ",", "needs_lock", "=", "True", ")", ":", "# TODO: remove needs_lock if/when we have a reentrant lock in", "# dask.distributed: https://github.com/dask/dask/issues/3832", "with", "self", ".", "_optional_lock", "(", "needs_lock", ")", ":", "default...
Explicitly close any associated file object (if necessary).
[ "Explicitly", "close", "any", "associated", "file", "object", "(", "if", "necessary", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L180-L188
train
Explicitly close any associated file object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/lru_cache.py
LRUCache._enforce_size_limit
def _enforce_size_limit(self, capacity): """Shrink the cache if necessary, evicting the oldest items.""" while len(self._cache) > capacity: key, value = self._cache.popitem(last=False) if self._on_evict is not None: self._on_evict(key, value)
python
def _enforce_size_limit(self, capacity): """Shrink the cache if necessary, evicting the oldest items.""" while len(self._cache) > capacity: key, value = self._cache.popitem(last=False) if self._on_evict is not None: self._on_evict(key, value)
[ "def", "_enforce_size_limit", "(", "self", ",", "capacity", ")", ":", "while", "len", "(", "self", ".", "_cache", ")", ">", "capacity", ":", "key", ",", "value", "=", "self", ".", "_cache", ".", "popitem", "(", "last", "=", "False", ")", "if", "self"...
Shrink the cache if necessary, evicting the oldest items.
[ "Shrink", "the", "cache", "if", "necessary", "evicting", "the", "oldest", "items", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/lru_cache.py#L46-L51
train
Shrink the cache if necessary evicting the oldest items.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/backends/lru_cache.py
LRUCache.maxsize
def maxsize(self, size): """Resize the cache, evicting the oldest items if necessary.""" if size < 0: raise ValueError('maxsize must be non-negative') with self._lock: self._enforce_size_limit(size) self._maxsize = size
python
def maxsize(self, size): """Resize the cache, evicting the oldest items if necessary.""" if size < 0: raise ValueError('maxsize must be non-negative') with self._lock: self._enforce_size_limit(size) self._maxsize = size
[ "def", "maxsize", "(", "self", ",", "size", ")", ":", "if", "size", "<", "0", ":", "raise", "ValueError", "(", "'maxsize must be non-negative'", ")", "with", "self", ".", "_lock", ":", "self", ".", "_enforce_size_limit", "(", "size", ")", "self", ".", "_...
Resize the cache, evicting the oldest items if necessary.
[ "Resize", "the", "cache", "evicting", "the", "oldest", "items", "if", "necessary", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/lru_cache.py#L84-L90
train
Resize the cache evicting the oldest items if necessary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/util/print_versions.py
get_sys_info
def get_sys_info(): "Returns system information as a dict" blob = [] # get full commit hash commit = None if os.path.isdir(".git") and os.path.isdir("xarray"): try: pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "), stdout=subpr...
python
def get_sys_info(): "Returns system information as a dict" blob = [] # get full commit hash commit = None if os.path.isdir(".git") and os.path.isdir("xarray"): try: pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "), stdout=subpr...
[ "def", "get_sys_info", "(", ")", ":", "blob", "=", "[", "]", "# get full commit hash", "commit", "=", "None", "if", "os", ".", "path", ".", "isdir", "(", "\".git\"", ")", "and", "os", ".", "path", ".", "isdir", "(", "\"xarray\"", ")", ":", "try", ":"...
Returns system information as a dict
[ "Returns", "system", "information", "as", "a", "dict" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/util/print_versions.py#L16-L62
train
Returns system information as a dict
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
expanded_indexer
def expanded_indexer(key, ndim): """Given a key for indexing an ndarray, return an equivalent key which is a tuple with length equal to the number of dimensions. The expansion is done by replacing all `Ellipsis` items with the right number of full slices and then padding the key with full slices so tha...
python
def expanded_indexer(key, ndim): """Given a key for indexing an ndarray, return an equivalent key which is a tuple with length equal to the number of dimensions. The expansion is done by replacing all `Ellipsis` items with the right number of full slices and then padding the key with full slices so tha...
[ "def", "expanded_indexer", "(", "key", ",", "ndim", ")", ":", "if", "not", "isinstance", "(", "key", ",", "tuple", ")", ":", "# numpy treats non-tuple keys equivalent to tuples of length 1", "key", "=", "(", "key", ",", ")", "new_key", "=", "[", "]", "# handli...
Given a key for indexing an ndarray, return an equivalent key which is a tuple with length equal to the number of dimensions. The expansion is done by replacing all `Ellipsis` items with the right number of full slices and then padding the key with full slices so that it reaches the appropriate dimensi...
[ "Given", "a", "key", "for", "indexing", "an", "ndarray", "return", "an", "equivalent", "key", "which", "is", "a", "tuple", "with", "length", "equal", "to", "the", "number", "of", "dimensions", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L16-L43
train
Given a key for indexing an ndarray return an equivalent key which is a tuple with length equal to the number of dimensions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_asarray_tuplesafe
def _asarray_tuplesafe(values): """ Convert values into a numpy array of at most 1-dimension, while preserving tuples. Adapted from pandas.core.common._asarray_tuplesafe """ if isinstance(values, tuple): result = utils.to_0d_object_array(values) else: result = np.asarray(val...
python
def _asarray_tuplesafe(values): """ Convert values into a numpy array of at most 1-dimension, while preserving tuples. Adapted from pandas.core.common._asarray_tuplesafe """ if isinstance(values, tuple): result = utils.to_0d_object_array(values) else: result = np.asarray(val...
[ "def", "_asarray_tuplesafe", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "tuple", ")", ":", "result", "=", "utils", ".", "to_0d_object_array", "(", "values", ")", "else", ":", "result", "=", "np", ".", "asarray", "(", "values", ")", ...
Convert values into a numpy array of at most 1-dimension, while preserving tuples. Adapted from pandas.core.common._asarray_tuplesafe
[ "Convert", "values", "into", "a", "numpy", "array", "of", "at", "most", "1", "-", "dimension", "while", "preserving", "tuples", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L71-L86
train
Convert values into a numpy array of at most 1 - dimension while preserving tuples.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
get_indexer_nd
def get_indexer_nd(index, labels, method=None, tolerance=None): """ Call pd.Index.get_indexer(labels). """ kwargs = _index_method_kwargs(method, tolerance) flat_labels = np.ravel(labels) flat_indexer = index.get_indexer(flat_labels, **kwargs) indexer = flat_indexer.reshape(labels.shape) return ...
python
def get_indexer_nd(index, labels, method=None, tolerance=None): """ Call pd.Index.get_indexer(labels). """ kwargs = _index_method_kwargs(method, tolerance) flat_labels = np.ravel(labels) flat_indexer = index.get_indexer(flat_labels, **kwargs) indexer = flat_indexer.reshape(labels.shape) return ...
[ "def", "get_indexer_nd", "(", "index", ",", "labels", ",", "method", "=", "None", ",", "tolerance", "=", "None", ")", ":", "kwargs", "=", "_index_method_kwargs", "(", "method", ",", "tolerance", ")", "flat_labels", "=", "np", ".", "ravel", "(", "labels", ...
Call pd.Index.get_indexer(labels).
[ "Call", "pd", ".", "Index", ".", "get_indexer", "(", "labels", ")", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L111-L118
train
Get the indexer for the N - dimensional index.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
convert_label_indexer
def convert_label_indexer(index, label, index_name='', method=None, tolerance=None): """Given a pandas.Index and labels (e.g., from __getitem__) for one dimension, return an indexer suitable for indexing an ndarray along that dimension. If `index` is a pandas.MultiIndex and dependi...
python
def convert_label_indexer(index, label, index_name='', method=None, tolerance=None): """Given a pandas.Index and labels (e.g., from __getitem__) for one dimension, return an indexer suitable for indexing an ndarray along that dimension. If `index` is a pandas.MultiIndex and dependi...
[ "def", "convert_label_indexer", "(", "index", ",", "label", ",", "index_name", "=", "''", ",", "method", "=", "None", ",", "tolerance", "=", "None", ")", ":", "new_index", "=", "None", "if", "isinstance", "(", "label", ",", "slice", ")", ":", "if", "me...
Given a pandas.Index and labels (e.g., from __getitem__) for one dimension, return an indexer suitable for indexing an ndarray along that dimension. If `index` is a pandas.MultiIndex and depending on `label`, return a new pandas.Index or pandas.MultiIndex (otherwise return None).
[ "Given", "a", "pandas", ".", "Index", "and", "labels", "(", "e", ".", "g", ".", "from", "__getitem__", ")", "for", "one", "dimension", "return", "an", "indexer", "suitable", "for", "indexing", "an", "ndarray", "along", "that", "dimension", ".", "If", "in...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L121-L192
train
Converts a pandas. Index and labels to a pandas. MultiIndex.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
get_dim_indexers
def get_dim_indexers(data_obj, indexers): """Given a xarray data object and label based indexers, return a mapping of label indexers with only dimension names as keys. It groups multiple level indexers given on a multi-index dimension into a single, dictionary indexer for that dimension (Raise a ValueE...
python
def get_dim_indexers(data_obj, indexers): """Given a xarray data object and label based indexers, return a mapping of label indexers with only dimension names as keys. It groups multiple level indexers given on a multi-index dimension into a single, dictionary indexer for that dimension (Raise a ValueE...
[ "def", "get_dim_indexers", "(", "data_obj", ",", "indexers", ")", ":", "invalid", "=", "[", "k", "for", "k", "in", "indexers", "if", "k", "not", "in", "data_obj", ".", "dims", "and", "k", "not", "in", "data_obj", ".", "_level_coords", "]", "if", "inval...
Given a xarray data object and label based indexers, return a mapping of label indexers with only dimension names as keys. It groups multiple level indexers given on a multi-index dimension into a single, dictionary indexer for that dimension (Raise a ValueError if it is not possible).
[ "Given", "a", "xarray", "data", "object", "and", "label", "based", "indexers", "return", "a", "mapping", "of", "label", "indexers", "with", "only", "dimension", "names", "as", "keys", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L195-L225
train
Given a xarray data object and label based indexers return a mapping of label indexers with only dimension names as keys.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
remap_label_indexers
def remap_label_indexers(data_obj, indexers, method=None, tolerance=None): """Given an xarray data object and label based indexers, return a mapping of equivalent location based indexers. Also return a mapping of updated pandas index objects (in case of multi-index level drop). """ if method is not ...
python
def remap_label_indexers(data_obj, indexers, method=None, tolerance=None): """Given an xarray data object and label based indexers, return a mapping of equivalent location based indexers. Also return a mapping of updated pandas index objects (in case of multi-index level drop). """ if method is not ...
[ "def", "remap_label_indexers", "(", "data_obj", ",", "indexers", ",", "method", "=", "None", ",", "tolerance", "=", "None", ")", ":", "if", "method", "is", "not", "None", "and", "not", "isinstance", "(", "method", ",", "str", ")", ":", "raise", "TypeErro...
Given an xarray data object and label based indexers, return a mapping of equivalent location based indexers. Also return a mapping of updated pandas index objects (in case of multi-index level drop).
[ "Given", "an", "xarray", "data", "object", "and", "label", "based", "indexers", "return", "a", "mapping", "of", "equivalent", "location", "based", "indexers", ".", "Also", "return", "a", "mapping", "of", "updated", "pandas", "index", "objects", "(", "in", "c...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L228-L257
train
Given an xarray data object and label based indexers return a mapping of updated pandas index objects.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
slice_slice
def slice_slice(old_slice, applied_slice, size): """Given a slice and the size of the dimension to which it will be applied, index it with another slice to return a new slice equivalent to applying the slices sequentially """ step = (old_slice.step or 1) * (applied_slice.step or 1) # For now, u...
python
def slice_slice(old_slice, applied_slice, size): """Given a slice and the size of the dimension to which it will be applied, index it with another slice to return a new slice equivalent to applying the slices sequentially """ step = (old_slice.step or 1) * (applied_slice.step or 1) # For now, u...
[ "def", "slice_slice", "(", "old_slice", ",", "applied_slice", ",", "size", ")", ":", "step", "=", "(", "old_slice", ".", "step", "or", "1", ")", "*", "(", "applied_slice", ".", "step", "or", "1", ")", "# For now, use the hack of turning old_slice into an ndarray...
Given a slice and the size of the dimension to which it will be applied, index it with another slice to return a new slice equivalent to applying the slices sequentially
[ "Given", "a", "slice", "and", "the", "size", "of", "the", "dimension", "to", "which", "it", "will", "be", "applied", "index", "it", "with", "another", "slice", "to", "return", "a", "new", "slice", "equivalent", "to", "applying", "the", "slices", "sequentia...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L260-L279
train
Given a slice and the size of the dimension to which it will be applied return a new slice equivalent to applying the slices sequentially
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
as_indexable
def as_indexable(array): """ This function always returns a ExplicitlyIndexed subclass, so that the vectorized indexing is always possible with the returned object. """ if isinstance(array, ExplicitlyIndexed): return array if isinstance(array, np.ndarray): return NumpyIndexin...
python
def as_indexable(array): """ This function always returns a ExplicitlyIndexed subclass, so that the vectorized indexing is always possible with the returned object. """ if isinstance(array, ExplicitlyIndexed): return array if isinstance(array, np.ndarray): return NumpyIndexin...
[ "def", "as_indexable", "(", "array", ")", ":", "if", "isinstance", "(", "array", ",", "ExplicitlyIndexed", ")", ":", "return", "array", "if", "isinstance", "(", "array", ",", "np", ".", "ndarray", ")", ":", "return", "NumpyIndexingAdapter", "(", "array", "...
This function always returns a ExplicitlyIndexed subclass, so that the vectorized indexing is always possible with the returned object.
[ "This", "function", "always", "returns", "a", "ExplicitlyIndexed", "subclass", "so", "that", "the", "vectorized", "indexing", "is", "always", "possible", "with", "the", "returned", "object", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L639-L653
train
Returns a new object that can be indexed by the given array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_outer_to_vectorized_indexer
def _outer_to_vectorized_indexer(key, shape): """Convert an OuterIndexer into an vectorized indexer. Parameters ---------- key : Outer/Basic Indexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- VectorizedIndexer ...
python
def _outer_to_vectorized_indexer(key, shape): """Convert an OuterIndexer into an vectorized indexer. Parameters ---------- key : Outer/Basic Indexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- VectorizedIndexer ...
[ "def", "_outer_to_vectorized_indexer", "(", "key", ",", "shape", ")", ":", "key", "=", "key", ".", "tuple", "n_dim", "=", "len", "(", "[", "k", "for", "k", "in", "key", "if", "not", "isinstance", "(", "k", ",", "integer_types", ")", "]", ")", "i_dim"...
Convert an OuterIndexer into an vectorized indexer. Parameters ---------- key : Outer/Basic Indexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- VectorizedIndexer Tuple suitable for use to index a NumPy array with ...
[ "Convert", "an", "OuterIndexer", "into", "an", "vectorized", "indexer", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L656-L689
train
Convert an OuterIndexer into a VectorizedIndexer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_outer_to_numpy_indexer
def _outer_to_numpy_indexer(key, shape): """Convert an OuterIndexer into an indexer for NumPy. Parameters ---------- key : Basic/OuterIndexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- tuple Tuple suitable fo...
python
def _outer_to_numpy_indexer(key, shape): """Convert an OuterIndexer into an indexer for NumPy. Parameters ---------- key : Basic/OuterIndexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- tuple Tuple suitable fo...
[ "def", "_outer_to_numpy_indexer", "(", "key", ",", "shape", ")", ":", "if", "len", "(", "[", "k", "for", "k", "in", "key", ".", "tuple", "if", "not", "isinstance", "(", "k", ",", "slice", ")", "]", ")", "<=", "1", ":", "# If there is only one vector an...
Convert an OuterIndexer into an indexer for NumPy. Parameters ---------- key : Basic/OuterIndexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- tuple Tuple suitable for use to index a NumPy array.
[ "Convert", "an", "OuterIndexer", "into", "an", "indexer", "for", "NumPy", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L692-L713
train
Convert an OuterIndexer into a NumPy indexer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_combine_indexers
def _combine_indexers(old_key, shape, new_key): """ Combine two indexers. Parameters ---------- old_key: ExplicitIndexer The first indexer for the original array shape: tuple of ints Shape of the original array to be indexed by old_key new_key: The second indexer for ind...
python
def _combine_indexers(old_key, shape, new_key): """ Combine two indexers. Parameters ---------- old_key: ExplicitIndexer The first indexer for the original array shape: tuple of ints Shape of the original array to be indexed by old_key new_key: The second indexer for ind...
[ "def", "_combine_indexers", "(", "old_key", ",", "shape", ",", "new_key", ")", ":", "if", "not", "isinstance", "(", "old_key", ",", "VectorizedIndexer", ")", ":", "old_key", "=", "_outer_to_vectorized_indexer", "(", "old_key", ",", "shape", ")", "if", "len", ...
Combine two indexers. Parameters ---------- old_key: ExplicitIndexer The first indexer for the original array shape: tuple of ints Shape of the original array to be indexed by old_key new_key: The second indexer for indexing original[old_key]
[ "Combine", "two", "indexers", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L716-L740
train
Combine two indexers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
explicit_indexing_adapter
def explicit_indexing_adapter( key, shape, indexing_support, raw_indexing_method): """Support explicit indexing by delegating to a raw indexing method. Outer and/or vectorized indexers are supported by indexing a second time with a NumPy array. Parameters ---------- key : ExplicitIndex...
python
def explicit_indexing_adapter( key, shape, indexing_support, raw_indexing_method): """Support explicit indexing by delegating to a raw indexing method. Outer and/or vectorized indexers are supported by indexing a second time with a NumPy array. Parameters ---------- key : ExplicitIndex...
[ "def", "explicit_indexing_adapter", "(", "key", ",", "shape", ",", "indexing_support", ",", "raw_indexing_method", ")", ":", "raw_key", ",", "numpy_indices", "=", "decompose_indexer", "(", "key", ",", "shape", ",", "indexing_support", ")", "result", "=", "raw_inde...
Support explicit indexing by delegating to a raw indexing method. Outer and/or vectorized indexers are supported by indexing a second time with a NumPy array. Parameters ---------- key : ExplicitIndexer Explicit indexing object. shape : Tuple[int, ...] Shape of the indexed arra...
[ "Support", "explicit", "indexing", "by", "delegating", "to", "a", "raw", "indexing", "method", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L754-L782
train
Support explicit indexing by delegating to a raw indexing method.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_decompose_slice
def _decompose_slice(key, size): """ convert a slice to successive two slices. The first slice always has a positive step. """ start, stop, step = key.indices(size) if step > 0: # If key already has a positive step, use it as is in the backend return key, slice(None) else: ...
python
def _decompose_slice(key, size): """ convert a slice to successive two slices. The first slice always has a positive step. """ start, stop, step = key.indices(size) if step > 0: # If key already has a positive step, use it as is in the backend return key, slice(None) else: ...
[ "def", "_decompose_slice", "(", "key", ",", "size", ")", ":", "start", ",", "stop", ",", "step", "=", "key", ".", "indices", "(", "size", ")", "if", "step", ">", "0", ":", "# If key already has a positive step, use it as is in the backend", "return", "key", ",...
convert a slice to successive two slices. The first slice always has a positive step.
[ "convert", "a", "slice", "to", "successive", "two", "slices", ".", "The", "first", "slice", "always", "has", "a", "positive", "step", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L793-L806
train
decompose a slice to successive two slices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_decompose_vectorized_indexer
def _decompose_vectorized_indexer(indexer, shape, indexing_support): """ Decompose vectorized indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index loaded on-memory np.ndarray. Parameters ---------- indexe...
python
def _decompose_vectorized_indexer(indexer, shape, indexing_support): """ Decompose vectorized indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index loaded on-memory np.ndarray. Parameters ---------- indexe...
[ "def", "_decompose_vectorized_indexer", "(", "indexer", ",", "shape", ",", "indexing_support", ")", ":", "assert", "isinstance", "(", "indexer", ",", "VectorizedIndexer", ")", "if", "indexing_support", "is", "IndexingSupport", ".", "VECTORIZED", ":", "return", "inde...
Decompose vectorized indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index loaded on-memory np.ndarray. Parameters ---------- indexer: VectorizedIndexer indexing_support: one of IndexerSupport entries Ret...
[ "Decompose", "vectorized", "indexer", "to", "the", "successive", "two", "indexers", "where", "the", "first", "indexer", "will", "be", "used", "to", "index", "backend", "arrays", "while", "the", "second", "one", "is", "used", "to", "index", "loaded", "on", "-...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L809-L877
train
Decomposes vectorized indexer to the successive two indexers where the first one is used to index the backend arrays while the second one is used to index loaded on - memory np. ndarray.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_decompose_outer_indexer
def _decompose_outer_indexer(indexer, shape, indexing_support): """ Decompose outer indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index the loaded on-memory np.ndarray. Parameters ---------- indexer: Vec...
python
def _decompose_outer_indexer(indexer, shape, indexing_support): """ Decompose outer indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index the loaded on-memory np.ndarray. Parameters ---------- indexer: Vec...
[ "def", "_decompose_outer_indexer", "(", "indexer", ",", "shape", ",", "indexing_support", ")", ":", "if", "indexing_support", "==", "IndexingSupport", ".", "VECTORIZED", ":", "return", "indexer", ",", "BasicIndexer", "(", "(", ")", ")", "assert", "isinstance", "...
Decompose outer indexer to the successive two indexers, where the first indexer will be used to index backend arrays, while the second one is used to index the loaded on-memory np.ndarray. Parameters ---------- indexer: VectorizedIndexer indexing_support: One of the entries of IndexingSupport ...
[ "Decompose", "outer", "indexer", "to", "the", "successive", "two", "indexers", "where", "the", "first", "indexer", "will", "be", "used", "to", "index", "backend", "arrays", "while", "the", "second", "one", "is", "used", "to", "index", "the", "loaded", "on", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L880-L994
train
Decomposes an outer indexer to the successive two indexers where the first one is used to index backend arrays while the second one is used to index backend arrays while the second one is used to index backend arrays.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_arrayize_vectorized_indexer
def _arrayize_vectorized_indexer(indexer, shape): """ Return an identical vindex but slices are replaced by arrays """ slices = [v for v in indexer.tuple if isinstance(v, slice)] if len(slices) == 0: return indexer arrays = [v for v in indexer.tuple if isinstance(v, np.ndarray)] n_dim = arr...
python
def _arrayize_vectorized_indexer(indexer, shape): """ Return an identical vindex but slices are replaced by arrays """ slices = [v for v in indexer.tuple if isinstance(v, slice)] if len(slices) == 0: return indexer arrays = [v for v in indexer.tuple if isinstance(v, np.ndarray)] n_dim = arr...
[ "def", "_arrayize_vectorized_indexer", "(", "indexer", ",", "shape", ")", ":", "slices", "=", "[", "v", "for", "v", "in", "indexer", ".", "tuple", "if", "isinstance", "(", "v", ",", "slice", ")", "]", "if", "len", "(", "slices", ")", "==", "0", ":", ...
Return an identical vindex but slices are replaced by arrays
[ "Return", "an", "identical", "vindex", "but", "slices", "are", "replaced", "by", "arrays" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L997-L1015
train
Return an identical vindex but slices are replaced by arrays
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_dask_array_with_chunks_hint
def _dask_array_with_chunks_hint(array, chunks): """Create a dask array using the chunks hint for dimensions of size > 1.""" import dask.array as da if len(chunks) < array.ndim: raise ValueError('not enough chunks in hint') new_chunks = [] for chunk, size in zip(chunks, array.shape): ...
python
def _dask_array_with_chunks_hint(array, chunks): """Create a dask array using the chunks hint for dimensions of size > 1.""" import dask.array as da if len(chunks) < array.ndim: raise ValueError('not enough chunks in hint') new_chunks = [] for chunk, size in zip(chunks, array.shape): ...
[ "def", "_dask_array_with_chunks_hint", "(", "array", ",", "chunks", ")", ":", "import", "dask", ".", "array", "as", "da", "if", "len", "(", "chunks", ")", "<", "array", ".", "ndim", ":", "raise", "ValueError", "(", "'not enough chunks in hint'", ")", "new_ch...
Create a dask array using the chunks hint for dimensions of size > 1.
[ "Create", "a", "dask", "array", "using", "the", "chunks", "hint", "for", "dimensions", "of", "size", ">", "1", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1018-L1026
train
Create a dask array using the chunks hint for dimensions of size > 1.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
create_mask
def create_mask(indexer, shape, chunks_hint=None): """Create a mask for indexing with a fill-value. Parameters ---------- indexer : ExplicitIndexer Indexer with -1 in integer or ndarray value to indicate locations in the result that should be masked. shape : tuple Shape of t...
python
def create_mask(indexer, shape, chunks_hint=None): """Create a mask for indexing with a fill-value. Parameters ---------- indexer : ExplicitIndexer Indexer with -1 in integer or ndarray value to indicate locations in the result that should be masked. shape : tuple Shape of t...
[ "def", "create_mask", "(", "indexer", ",", "shape", ",", "chunks_hint", "=", "None", ")", ":", "if", "isinstance", "(", "indexer", ",", "OuterIndexer", ")", ":", "key", "=", "_outer_to_vectorized_indexer", "(", "indexer", ",", "shape", ")", ".", "tuple", "...
Create a mask for indexing with a fill-value. Parameters ---------- indexer : ExplicitIndexer Indexer with -1 in integer or ndarray value to indicate locations in the result that should be masked. shape : tuple Shape of the array being indexed. chunks_hint : tuple, optional ...
[ "Create", "a", "mask", "for", "indexing", "with", "a", "fill", "-", "value", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1042-L1085
train
Create a mask for indexing with a fill - value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
_posify_mask_subindexer
def _posify_mask_subindexer(index): """Convert masked indices in a flat array to the nearest unmasked index. Parameters ---------- index : np.ndarray One dimensional ndarray with dtype=int. Returns ------- np.ndarray One dimensional ndarray with all values equal to -1 repla...
python
def _posify_mask_subindexer(index): """Convert masked indices in a flat array to the nearest unmasked index. Parameters ---------- index : np.ndarray One dimensional ndarray with dtype=int. Returns ------- np.ndarray One dimensional ndarray with all values equal to -1 repla...
[ "def", "_posify_mask_subindexer", "(", "index", ")", ":", "masked", "=", "index", "==", "-", "1", "unmasked_locs", "=", "np", ".", "flatnonzero", "(", "~", "masked", ")", "if", "not", "unmasked_locs", ".", "size", ":", "# indexing unmasked_locs is invalid", "r...
Convert masked indices in a flat array to the nearest unmasked index. Parameters ---------- index : np.ndarray One dimensional ndarray with dtype=int. Returns ------- np.ndarray One dimensional ndarray with all values equal to -1 replaced by an adjacent non-masked eleme...
[ "Convert", "masked", "indices", "in", "a", "flat", "array", "to", "the", "nearest", "unmasked", "index", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1088-L1111
train
Convert masked indices in a flat array to nearest unmasked index.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/core/indexing.py
posify_mask_indexer
def posify_mask_indexer(indexer): """Convert masked values (-1) in an indexer to nearest unmasked values. This routine is useful for dask, where it can be much faster to index adjacent points than arbitrary points from the end of an array. Parameters ---------- indexer : ExplicitIndexer ...
python
def posify_mask_indexer(indexer): """Convert masked values (-1) in an indexer to nearest unmasked values. This routine is useful for dask, where it can be much faster to index adjacent points than arbitrary points from the end of an array. Parameters ---------- indexer : ExplicitIndexer ...
[ "def", "posify_mask_indexer", "(", "indexer", ")", ":", "key", "=", "tuple", "(", "_posify_mask_subindexer", "(", "k", ".", "ravel", "(", ")", ")", ".", "reshape", "(", "k", ".", "shape", ")", "if", "isinstance", "(", "k", ",", "np", ".", "ndarray", ...
Convert masked values (-1) in an indexer to nearest unmasked values. This routine is useful for dask, where it can be much faster to index adjacent points than arbitrary points from the end of an array. Parameters ---------- indexer : ExplicitIndexer Input indexer. Returns -------...
[ "Convert", "masked", "values", "(", "-", "1", ")", "in", "an", "indexer", "to", "nearest", "unmasked", "values", "." ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1114-L1134
train
Convert masked values in an indexer to nearest unmasked values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pydata/xarray
xarray/plot/utils.py
import_seaborn
def import_seaborn(): '''import seaborn and handle deprecation of apionly module''' with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") try: import seaborn.apionly as sns if (w and issubclass(w[-1].category, UserWarning) and ...
python
def import_seaborn(): '''import seaborn and handle deprecation of apionly module''' with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") try: import seaborn.apionly as sns if (w and issubclass(w[-1].category, UserWarning) and ...
[ "def", "import_seaborn", "(", ")", ":", "with", "warnings", ".", "catch_warnings", "(", "record", "=", "True", ")", "as", "w", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "try", ":", "import", "seaborn", ".", "apionly", "as", "sns", "if...
import seaborn and handle deprecation of apionly module
[ "import", "seaborn", "and", "handle", "deprecation", "of", "apionly", "module" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L27-L40
train
import seaborn and handle deprecation of apionly module
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...