partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
DataArray.to_masked_array
Convert this array into a numpy.ma.MaskedArray Parameters ---------- copy : bool If True (default) make a copy of the array in the result. If False, a MaskedArray view of DataArray.values is returned. Returns ------- result : MaskedArray ...
xarray/core/dataarray.py
def to_masked_array(self, copy=True): """Convert this array into a numpy.ma.MaskedArray Parameters ---------- copy : bool If True (default) make a copy of the array in the result. If False, a MaskedArray view of DataArray.values is returned. Returns ...
def to_masked_array(self, copy=True): """Convert this array into a numpy.ma.MaskedArray Parameters ---------- copy : bool If True (default) make a copy of the array in the result. If False, a MaskedArray view of DataArray.values is returned. Returns ...
[ "Convert", "this", "array", "into", "a", "numpy", ".", "ma", ".", "MaskedArray" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1707-L1722
[ "def", "to_masked_array", "(", "self", ",", "copy", "=", "True", ")", ":", "isnull", "=", "pd", ".", "isnull", "(", "self", ".", "values", ")", "return", "np", ".", "ma", ".", "MaskedArray", "(", "data", "=", "self", ".", "values", ",", "mask", "="...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.to_netcdf
Write DataArray contents to a netCDF file. Parameters ---------- path : str or Path, optional Path to which to save this dataset. If no path is provided, this function returns the resulting netCDF file as a bytes object; in this case, we need to use scipy.io....
xarray/core/dataarray.py
def to_netcdf(self, *args, **kwargs): """Write DataArray contents to a netCDF file. Parameters ---------- path : str or Path, optional Path to which to save this dataset. If no path is provided, this function returns the resulting netCDF file as a bytes object; i...
def to_netcdf(self, *args, **kwargs): """Write DataArray contents to a netCDF file. Parameters ---------- path : str or Path, optional Path to which to save this dataset. If no path is provided, this function returns the resulting netCDF file as a bytes object; i...
[ "Write", "DataArray", "contents", "to", "a", "netCDF", "file", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1724-L1795
[ "def", "to_netcdf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "backends", ".", "api", "import", "DATAARRAY_NAME", ",", "DATAARRAY_VARIABLE", "if", "self", ".", "name", "is", "None", ":", "# If no name is set then u...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.to_dict
Convert this xarray.DataArray into a dictionary following xarray naming conventions. Converts all variables and attributes to native Python objects. Useful for coverting to json. To avoid datetime incompatibility use decode_times=False kwarg in xarrray.open_dataset. Parameters ...
xarray/core/dataarray.py
def to_dict(self, data=True): """ Convert this xarray.DataArray into a dictionary following xarray naming conventions. Converts all variables and attributes to native Python objects. Useful for coverting to json. To avoid datetime incompatibility use decode_times=False k...
def to_dict(self, data=True): """ Convert this xarray.DataArray into a dictionary following xarray naming conventions. Converts all variables and attributes to native Python objects. Useful for coverting to json. To avoid datetime incompatibility use decode_times=False k...
[ "Convert", "this", "xarray", ".", "DataArray", "into", "a", "dictionary", "following", "xarray", "naming", "conventions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1797-L1820
[ "def", "to_dict", "(", "self", ",", "data", "=", "True", ")", ":", "d", "=", "self", ".", "variable", ".", "to_dict", "(", "data", "=", "data", ")", "d", ".", "update", "(", "{", "'coords'", ":", "{", "}", ",", "'name'", ":", "self", ".", "name...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.from_dict
Convert a dictionary into an xarray.DataArray Input dict can take several forms:: d = {'dims': ('t'), 'data': x} d = {'coords': {'t': {'dims': 't', 'data': t, 'attrs': {'units':'s'}}}, 'attrs': {'title': 'air temperature'}, ...
xarray/core/dataarray.py
def from_dict(cls, d): """ Convert a dictionary into an xarray.DataArray Input dict can take several forms:: d = {'dims': ('t'), 'data': x} d = {'coords': {'t': {'dims': 't', 'data': t, 'attrs': {'units':'s'}}}, 'attrs...
def from_dict(cls, d): """ Convert a dictionary into an xarray.DataArray Input dict can take several forms:: d = {'dims': ('t'), 'data': x} d = {'coords': {'t': {'dims': 't', 'data': t, 'attrs': {'units':'s'}}}, 'attrs...
[ "Convert", "a", "dictionary", "into", "an", "xarray", ".", "DataArray" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1823-L1872
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "coords", "=", "None", "if", "'coords'", "in", "d", ":", "try", ":", "coords", "=", "OrderedDict", "(", "[", "(", "k", ",", "(", "v", "[", "'dims'", "]", ",", "v", "[", "'data'", "]", ",", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.from_series
Convert a pandas.Series into an xarray.DataArray. If the series's index is a MultiIndex, it will be expanded into a tensor product of one-dimensional coordinates (filling in missing values with NaN). Thus this operation should be the inverse of the `to_series` method.
xarray/core/dataarray.py
def from_series(cls, series): """Convert a pandas.Series into an xarray.DataArray. If the series's index is a MultiIndex, it will be expanded into a tensor product of one-dimensional coordinates (filling in missing values with NaN). Thus this operation should be the inverse of the ...
def from_series(cls, series): """Convert a pandas.Series into an xarray.DataArray. If the series's index is a MultiIndex, it will be expanded into a tensor product of one-dimensional coordinates (filling in missing values with NaN). Thus this operation should be the inverse of the ...
[ "Convert", "a", "pandas", ".", "Series", "into", "an", "xarray", ".", "DataArray", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1875-L1887
[ "def", "from_series", "(", "cls", ",", "series", ")", ":", "# TODO: add a 'name' parameter", "name", "=", "series", ".", "name", "df", "=", "pd", ".", "DataFrame", "(", "{", "name", ":", "series", "}", ")", "ds", "=", "Dataset", ".", "from_dataframe", "(...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray._all_compat
Helper function for equals and identical
xarray/core/dataarray.py
def _all_compat(self, other, compat_str): """Helper function for equals and identical""" def compat(x, y): return getattr(x.variable, compat_str)(y.variable) return (utils.dict_equiv(self.coords, other.coords, compat=compat) and compat(self, other))
def _all_compat(self, other, compat_str): """Helper function for equals and identical""" def compat(x, y): return getattr(x.variable, compat_str)(y.variable) return (utils.dict_equiv(self.coords, other.coords, compat=compat) and compat(self, other))
[ "Helper", "function", "for", "equals", "and", "identical" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1915-L1922
[ "def", "_all_compat", "(", "self", ",", "other", ",", "compat_str", ")", ":", "def", "compat", "(", "x", ",", "y", ")", ":", "return", "getattr", "(", "x", ".", "variable", ",", "compat_str", ")", "(", "y", ".", "variable", ")", "return", "(", "uti...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.identical
Like equals, but also checks the array name and attributes, and attributes on all coordinates. See Also -------- DataArray.broadcast_equals DataArray.equal
xarray/core/dataarray.py
def identical(self, other): """Like equals, but also checks the array name and attributes, and attributes on all coordinates. See Also -------- DataArray.broadcast_equals DataArray.equal """ try: return (self.name == other.name and ...
def identical(self, other): """Like equals, but also checks the array name and attributes, and attributes on all coordinates. See Also -------- DataArray.broadcast_equals DataArray.equal """ try: return (self.name == other.name and ...
[ "Like", "equals", "but", "also", "checks", "the", "array", "name", "and", "attributes", "and", "attributes", "on", "all", "coordinates", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1959-L1972
[ "def", "identical", "(", "self", ",", "other", ")", ":", "try", ":", "return", "(", "self", ".", "name", "==", "other", ".", "name", "and", "self", ".", "_all_compat", "(", "other", ",", "'identical'", ")", ")", "except", "(", "TypeError", ",", "Attr...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray._title_for_slice
If the dataarray has 1 dimensional coordinates or comes from a slice we can show that info in the title Parameters ---------- truncate : integer maximum number of characters for title Returns ------- title : string Can be used for plot ti...
xarray/core/dataarray.py
def _title_for_slice(self, truncate=50): """ If the dataarray has 1 dimensional coordinates or comes from a slice we can show that info in the title Parameters ---------- truncate : integer maximum number of characters for title Returns -----...
def _title_for_slice(self, truncate=50): """ If the dataarray has 1 dimensional coordinates or comes from a slice we can show that info in the title Parameters ---------- truncate : integer maximum number of characters for title Returns -----...
[ "If", "the", "dataarray", "has", "1", "dimensional", "coordinates", "or", "comes", "from", "a", "slice", "we", "can", "show", "that", "info", "in", "the", "title" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2061-L2087
[ "def", "_title_for_slice", "(", "self", ",", "truncate", "=", "50", ")", ":", "one_dims", "=", "[", "]", "for", "dim", ",", "coord", "in", "self", ".", "coords", ".", "items", "(", ")", ":", "if", "coord", ".", "size", "==", "1", ":", "one_dims", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.diff
Calculate the n-th order discrete difference along given axis. Parameters ---------- dim : str, optional Dimension over which to calculate the finite difference. n : int, optional The number of times values are differenced. label : str, optional ...
xarray/core/dataarray.py
def diff(self, dim, n=1, label='upper'): """Calculate the n-th order discrete difference along given axis. Parameters ---------- dim : str, optional Dimension over which to calculate the finite difference. n : int, optional The number of times values are ...
def diff(self, dim, n=1, label='upper'): """Calculate the n-th order discrete difference along given axis. Parameters ---------- dim : str, optional Dimension over which to calculate the finite difference. n : int, optional The number of times values are ...
[ "Calculate", "the", "n", "-", "th", "order", "discrete", "difference", "along", "given", "axis", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2089-L2128
[ "def", "diff", "(", "self", ",", "dim", ",", "n", "=", "1", ",", "label", "=", "'upper'", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "diff", "(", "n", "=", "n", ",", "dim", "=", "dim", ",", "label", "=", "label", ")"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.shift
Shift this array by an offset along one or more dimensions. Only the data is moved; coordinates stay in place. Values shifted from beyond array bounds are replaced by NaN. This is consistent with the behavior of ``shift`` in pandas. Parameters ---------- shifts : Mappin...
xarray/core/dataarray.py
def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs): """Shift this array by an offset along one or more dimensions. Only the data is moved; coordinates stay in place. Values shifted from beyond array bounds are replaced by NaN. This is consistent with the behavior of ``s...
def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs): """Shift this array by an offset along one or more dimensions. Only the data is moved; coordinates stay in place. Values shifted from beyond array bounds are replaced by NaN. This is consistent with the behavior of ``s...
[ "Shift", "this", "array", "by", "an", "offset", "along", "one", "or", "more", "dimensions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2130-L2171
[ "def", "shift", "(", "self", ",", "shifts", "=", "None", ",", "fill_value", "=", "dtypes", ".", "NA", ",", "*", "*", "shifts_kwargs", ")", ":", "variable", "=", "self", ".", "variable", ".", "shift", "(", "shifts", "=", "shifts", ",", "fill_value", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.roll
Roll this array by an offset along one or more dimensions. Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with :py:func:`numpy.roll`. Parameters ---------- roll_coords : bool Indicates...
xarray/core/dataarray.py
def roll(self, shifts=None, roll_coords=None, **shifts_kwargs): """Roll this array by an offset along one or more dimensions. Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with :py:func:`numpy.roll`. Par...
def roll(self, shifts=None, roll_coords=None, **shifts_kwargs): """Roll this array by an offset along one or more dimensions. Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with :py:func:`numpy.roll`. Par...
[ "Roll", "this", "array", "by", "an", "offset", "along", "one", "or", "more", "dimensions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2173-L2212
[ "def", "roll", "(", "self", ",", "shifts", "=", "None", ",", "roll_coords", "=", "None", ",", "*", "*", "shifts_kwargs", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "roll", "(", "shifts", "=", "shifts", ",", "roll_coords", "=...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.dot
Perform dot product of two DataArrays along their shared dims. Equivalent to taking taking tensordot over all shared dims. Parameters ---------- other : DataArray The other array with which the dot product is performed. dims: list of strings, optional Al...
xarray/core/dataarray.py
def dot(self, other, dims=None): """Perform dot product of two DataArrays along their shared dims. Equivalent to taking taking tensordot over all shared dims. Parameters ---------- other : DataArray The other array with which the dot product is performed. di...
def dot(self, other, dims=None): """Perform dot product of two DataArrays along their shared dims. Equivalent to taking taking tensordot over all shared dims. Parameters ---------- other : DataArray The other array with which the dot product is performed. di...
[ "Perform", "dot", "product", "of", "two", "DataArrays", "along", "their", "shared", "dims", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2222-L2268
[ "def", "dot", "(", "self", ",", "other", ",", "dims", "=", "None", ")", ":", "if", "isinstance", "(", "other", ",", "Dataset", ")", ":", "raise", "NotImplementedError", "(", "'dot products are not yet supported '", "'with Dataset objects.'", ")", "if", "not", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.sortby
Sort object by labels or values (along an axis). Sorts the dataarray, either along specified dimensions, or according to values of 1-D dataarrays that share dimension with calling object. If the input variables are dataarrays, then the dataarrays are aligned (via left-join) to ...
xarray/core/dataarray.py
def sortby(self, variables, ascending=True): """ Sort object by labels or values (along an axis). Sorts the dataarray, either along specified dimensions, or according to values of 1-D dataarrays that share dimension with calling object. If the input variables are dataar...
def sortby(self, variables, ascending=True): """ Sort object by labels or values (along an axis). Sorts the dataarray, either along specified dimensions, or according to values of 1-D dataarrays that share dimension with calling object. If the input variables are dataar...
[ "Sort", "object", "by", "labels", "or", "values", "(", "along", "an", "axis", ")", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2270-L2321
[ "def", "sortby", "(", "self", ",", "variables", ",", "ascending", "=", "True", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "sortby", "(", "variables", ",", "ascending", "=", "ascending", ")", "return", "self", ".", "_from_temp_da...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.quantile
Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) Quantile to compute, which must be between 0 and 1 inclusive. dim : str ...
xarray/core/dataarray.py
def quantile(self, q, dim=None, interpolation='linear', keep_attrs=None): """Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) ...
def quantile(self, q, dim=None, interpolation='linear', keep_attrs=None): """Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) ...
[ "Compute", "the", "qth", "quantile", "of", "the", "data", "along", "the", "specified", "dimension", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2323-L2367
[ "def", "quantile", "(", "self", ",", "q", ",", "dim", "=", "None", ",", "interpolation", "=", "'linear'", ",", "keep_attrs", "=", "None", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "quantile", "(", "q", ",", "dim", "=", "d...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.rank
Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If pct, computes percentage ranks. NaNs in the input array are returned as NaNs. The `bottl...
xarray/core/dataarray.py
def rank(self, dim, pct=False, keep_attrs=None): """Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If pct, computes percentage ranks. NaNs ...
def rank(self, dim, pct=False, keep_attrs=None): """Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If pct, computes percentage ranks. NaNs ...
[ "Ranks", "the", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2369-L2407
[ "def", "rank", "(", "self", ",", "dim", ",", "pct", "=", "False", ",", "keep_attrs", "=", "None", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "rank", "(", "dim", ",", "pct", "=", "pct", ",", "keep_attrs", "=", "keep_attrs",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.differentiate
Differentiate the array with the second order accurate central differences. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ---------- coord: str The coordinate to be used to comp...
xarray/core/dataarray.py
def differentiate(self, coord, edge_order=1, datetime_unit=None): """ Differentiate the array with the second order accurate central differences. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ...
def differentiate(self, coord, edge_order=1, datetime_unit=None): """ Differentiate the array with the second order accurate central differences. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ...
[ "Differentiate", "the", "array", "with", "the", "second", "order", "accurate", "central", "differences", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2409-L2462
[ "def", "differentiate", "(", "self", ",", "coord", ",", "edge_order", "=", "1", ",", "datetime_unit", "=", "None", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "differentiate", "(", "coord", ",", "edge_order", ",", "datetime_unit", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArray.integrate
integrate the array with the trapezoidal rule. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ---------- dim: str, or a sequence of str Coordinate(s) used for the integration. da...
xarray/core/dataarray.py
def integrate(self, dim, datetime_unit=None): """ integrate the array with the trapezoidal rule. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ---------- dim: str, or a sequence of str ...
def integrate(self, dim, datetime_unit=None): """ integrate the array with the trapezoidal rule. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ---------- dim: str, or a sequence of str ...
[ "integrate", "the", "array", "with", "the", "trapezoidal", "rule", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2464-L2509
[ "def", "integrate", "(", "self", ",", "dim", ",", "datetime_unit", "=", "None", ")", ":", "ds", "=", "self", ".", "_to_temp_dataset", "(", ")", ".", "integrate", "(", "dim", ",", "datetime_unit", ")", "return", "self", ".", "_from_temp_dataset", "(", "ds...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayRolling.construct
Convert this rolling object to xr.DataArray, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: integer, optional Size of stride for the rolling window. fill_val...
xarray/core/rolling.py
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): """ Convert this rolling object to xr.DataArray, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: ...
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): """ Convert this rolling object to xr.DataArray, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: ...
[ "Convert", "this", "rolling", "object", "to", "xr", ".", "DataArray", "where", "the", "window", "dimension", "is", "stacked", "as", "a", "new", "dimension" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L150-L195
[ "def", "construct", "(", "self", ",", "window_dim", ",", "stride", "=", "1", ",", "fill_value", "=", "dtypes", ".", "NA", ")", ":", "from", ".", "dataarray", "import", "DataArray", "window", "=", "self", ".", "obj", ".", "variable", ".", "rolling_window"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayRolling.reduce
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, **kwargs)` to return the result of collapsing an np.ndarray over an the rolling dimensio...
xarray/core/rolling.py
def reduce(self, func, **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, **kwargs)` to return the result of collapsing an ...
def reduce(self, func, **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, **kwargs)` to return the result of collapsing an ...
[ "Reduce", "the", "items", "in", "this", "group", "by", "applying", "func", "along", "some", "dimension", "(", "s", ")", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L197-L221
[ "def", "reduce", "(", "self", ",", "func", ",", "*", "*", "kwargs", ")", ":", "rolling_dim", "=", "utils", ".", "get_temp_dimname", "(", "self", ".", "obj", ".", "dims", ",", "'_rolling_dim'", ")", "windows", "=", "self", ".", "construct", "(", "rollin...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayRolling._counts
Number of non-nan entries in each rolling window.
xarray/core/rolling.py
def _counts(self): """ Number of non-nan entries in each rolling window. """ rolling_dim = utils.get_temp_dimname(self.obj.dims, '_rolling_dim') # We use False as the fill_value instead of np.nan, since boolean # array is faster to be reduced than object array. # The use of skip...
def _counts(self): """ Number of non-nan entries in each rolling window. """ rolling_dim = utils.get_temp_dimname(self.obj.dims, '_rolling_dim') # We use False as the fill_value instead of np.nan, since boolean # array is faster to be reduced than object array. # The use of skip...
[ "Number", "of", "non", "-", "nan", "entries", "in", "each", "rolling", "window", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L223-L235
[ "def", "_counts", "(", "self", ")", ":", "rolling_dim", "=", "utils", ".", "get_temp_dimname", "(", "self", ".", "obj", ".", "dims", ",", "'_rolling_dim'", ")", "# We use False as the fill_value instead of np.nan, since boolean", "# array is faster to be reduced than object...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayRolling._reduce_method
Methods to return a wrapped function for any function `func` for numpy methods.
xarray/core/rolling.py
def _reduce_method(cls, func): """ Methods to return a wrapped function for any function `func` for numpy methods. """ def wrapped_func(self, **kwargs): return self.reduce(func, **kwargs) return wrapped_func
def _reduce_method(cls, func): """ Methods to return a wrapped function for any function `func` for numpy methods. """ def wrapped_func(self, **kwargs): return self.reduce(func, **kwargs) return wrapped_func
[ "Methods", "to", "return", "a", "wrapped", "function", "for", "any", "function", "func", "for", "numpy", "methods", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L238-L246
[ "def", "_reduce_method", "(", "cls", ",", "func", ")", ":", "def", "wrapped_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "reduce", "(", "func", ",", "*", "*", "kwargs", ")", "return", "wrapped_func" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayRolling._bottleneck_reduce
Methods to return a wrapped function for any function `func` for bottoleneck method, except for `median`.
xarray/core/rolling.py
def _bottleneck_reduce(cls, func): """ Methods to return a wrapped function for any function `func` for bottoleneck method, except for `median`. """ def wrapped_func(self, **kwargs): from .dataarray import DataArray # bottleneck doesn't allow min_count t...
def _bottleneck_reduce(cls, func): """ Methods to return a wrapped function for any function `func` for bottoleneck method, except for `median`. """ def wrapped_func(self, **kwargs): from .dataarray import DataArray # bottleneck doesn't allow min_count t...
[ "Methods", "to", "return", "a", "wrapped", "function", "for", "any", "function", "func", "for", "bottoleneck", "method", "except", "for", "median", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L249-L301
[ "def", "_bottleneck_reduce", "(", "cls", ",", "func", ")", ":", "def", "wrapped_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", ".", "dataarray", "import", "DataArray", "# bottleneck doesn't allow min_count to be 0, although it should", "# work the same...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DatasetRolling.reduce
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, **kwargs)` to return the result of collapsing an np.ndarray over an the rolling dimensio...
xarray/core/rolling.py
def reduce(self, func, **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, **kwargs)` to return the result of collapsing an ...
def reduce(self, func, **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, **kwargs)` to return the result of collapsing an ...
[ "Reduce", "the", "items", "in", "this", "group", "by", "applying", "func", "along", "some", "dimension", "(", "s", ")", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L350-L375
[ "def", "reduce", "(", "self", ",", "func", ",", "*", "*", "kwargs", ")", ":", "from", ".", "dataset", "import", "Dataset", "reduced", "=", "OrderedDict", "(", ")", "for", "key", ",", "da", "in", "self", ".", "obj", ".", "data_vars", ".", "items", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DatasetRolling._reduce_method
Return a wrapped function for injecting numpy and bottoleneck methods. see ops.inject_datasetrolling_methods
xarray/core/rolling.py
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy and bottoleneck methods. see ops.inject_datasetrolling_methods """ def wrapped_func(self, **kwargs): from .dataset import Dataset reduced = OrderedDict() for key,...
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy and bottoleneck methods. see ops.inject_datasetrolling_methods """ def wrapped_func(self, **kwargs): from .dataset import Dataset reduced = OrderedDict() for key,...
[ "Return", "a", "wrapped", "function", "for", "injecting", "numpy", "and", "bottoleneck", "methods", ".", "see", "ops", ".", "inject_datasetrolling_methods" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L388-L404
[ "def", "_reduce_method", "(", "cls", ",", "func", ")", ":", "def", "wrapped_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", ".", "dataset", "import", "Dataset", "reduced", "=", "OrderedDict", "(", ")", "for", "key", ",", "da", "in", "s...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DatasetRolling.construct
Convert this rolling object to xr.Dataset, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: integer, optional size of stride for the rolling window. fill_value...
xarray/core/rolling.py
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): """ Convert this rolling object to xr.Dataset, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: in...
def construct(self, window_dim, stride=1, fill_value=dtypes.NA): """ Convert this rolling object to xr.Dataset, where the window dimension is stacked as a new dimension Parameters ---------- window_dim: str New name of the window dimension. stride: in...
[ "Convert", "this", "rolling", "object", "to", "xr", ".", "Dataset", "where", "the", "window", "dimension", "is", "stacked", "as", "a", "new", "dimension" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L406-L435
[ "def", "construct", "(", "self", ",", "window_dim", ",", "stride", "=", "1", ",", "fill_value", "=", "dtypes", ".", "NA", ")", ":", "from", ".", "dataset", "import", "Dataset", "dataset", "=", "OrderedDict", "(", ")", "for", "key", ",", "da", "in", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DataArrayCoarsen._reduce_method
Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods
xarray/core/rolling.py
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods """ def wrapped_func(self, **kwargs): from .dataarray import DataArray reduced = self.obj.variable.coarsen( self.windo...
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods """ def wrapped_func(self, **kwargs): from .dataarray import DataArray reduced = self.obj.variable.coarsen( self.windo...
[ "Return", "a", "wrapped", "function", "for", "injecting", "numpy", "methods", ".", "see", "ops", ".", "inject_coarsen_methods" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L498-L521
[ "def", "_reduce_method", "(", "cls", ",", "func", ")", ":", "def", "wrapped_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", ".", "dataarray", "import", "DataArray", "reduced", "=", "self", ".", "obj", ".", "variable", ".", "coarsen", "("...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
DatasetCoarsen._reduce_method
Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods
xarray/core/rolling.py
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods """ def wrapped_func(self, **kwargs): from .dataset import Dataset reduced = OrderedDict() for key, da in self.obj.data_va...
def _reduce_method(cls, func): """ Return a wrapped function for injecting numpy methods. see ops.inject_coarsen_methods """ def wrapped_func(self, **kwargs): from .dataset import Dataset reduced = OrderedDict() for key, da in self.obj.data_va...
[ "Return", "a", "wrapped", "function", "for", "injecting", "numpy", "methods", ".", "see", "ops", ".", "inject_coarsen_methods" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L526-L549
[ "def", "_reduce_method", "(", "cls", ",", "func", ")", ":", "def", "wrapped_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", ".", "dataset", "import", "Dataset", "reduced", "=", "OrderedDict", "(", ")", "for", "key", ",", "da", "in", "s...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
ensure_fixed_length_bytes
Ensure that a variable with vlen bytes is converted to fixed width.
xarray/coding/strings.py
def ensure_fixed_length_bytes(var): """Ensure that a variable with vlen bytes is converted to fixed width.""" dims, data, attrs, encoding = unpack_for_encoding(var) if check_vlen_dtype(data.dtype) == bytes: # TODO: figure out how to handle this with dask data = np.asarray(data, dtype=np.stri...
def ensure_fixed_length_bytes(var): """Ensure that a variable with vlen bytes is converted to fixed width.""" dims, data, attrs, encoding = unpack_for_encoding(var) if check_vlen_dtype(data.dtype) == bytes: # TODO: figure out how to handle this with dask data = np.asarray(data, dtype=np.stri...
[ "Ensure", "that", "a", "variable", "with", "vlen", "bytes", "is", "converted", "to", "fixed", "width", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L88-L94
[ "def", "ensure_fixed_length_bytes", "(", "var", ")", ":", "dims", ",", "data", ",", "attrs", ",", "encoding", "=", "unpack_for_encoding", "(", "var", ")", "if", "check_vlen_dtype", "(", "data", ".", "dtype", ")", "==", "bytes", ":", "# TODO: figure out how to ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
bytes_to_char
Convert numpy/dask arrays from fixed width bytes to characters.
xarray/coding/strings.py
def bytes_to_char(arr): """Convert numpy/dask arrays from fixed width bytes to characters.""" if arr.dtype.kind != 'S': raise ValueError('argument must have a fixed-width bytes dtype') if isinstance(arr, dask_array_type): import dask.array as da return da.map_blocks(_numpy_bytes_to_...
def bytes_to_char(arr): """Convert numpy/dask arrays from fixed width bytes to characters.""" if arr.dtype.kind != 'S': raise ValueError('argument must have a fixed-width bytes dtype') if isinstance(arr, dask_array_type): import dask.array as da return da.map_blocks(_numpy_bytes_to_...
[ "Convert", "numpy", "/", "dask", "arrays", "from", "fixed", "width", "bytes", "to", "characters", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L123-L135
[ "def", "bytes_to_char", "(", "arr", ")", ":", "if", "arr", ".", "dtype", ".", "kind", "!=", "'S'", ":", "raise", "ValueError", "(", "'argument must have a fixed-width bytes dtype'", ")", "if", "isinstance", "(", "arr", ",", "dask_array_type", ")", ":", "import...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_numpy_bytes_to_char
Like netCDF4.stringtochar, but faster and more flexible.
xarray/coding/strings.py
def _numpy_bytes_to_char(arr): """Like netCDF4.stringtochar, but faster and more flexible. """ # ensure the array is contiguous arr = np.array(arr, copy=False, order='C', dtype=np.string_) return arr.reshape(arr.shape + (1,)).view('S1')
def _numpy_bytes_to_char(arr): """Like netCDF4.stringtochar, but faster and more flexible. """ # ensure the array is contiguous arr = np.array(arr, copy=False, order='C', dtype=np.string_) return arr.reshape(arr.shape + (1,)).view('S1')
[ "Like", "netCDF4", ".", "stringtochar", "but", "faster", "and", "more", "flexible", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L138-L143
[ "def", "_numpy_bytes_to_char", "(", "arr", ")", ":", "# ensure the array is contiguous", "arr", "=", "np", ".", "array", "(", "arr", ",", "copy", "=", "False", ",", "order", "=", "'C'", ",", "dtype", "=", "np", ".", "string_", ")", "return", "arr", ".", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
char_to_bytes
Convert numpy/dask arrays from characters to fixed width bytes.
xarray/coding/strings.py
def char_to_bytes(arr): """Convert numpy/dask arrays from characters to fixed width bytes.""" if arr.dtype != 'S1': raise ValueError("argument must have dtype='S1'") if not arr.ndim: # no dimension to concatenate along return arr size = arr.shape[-1] if not size: #...
def char_to_bytes(arr): """Convert numpy/dask arrays from characters to fixed width bytes.""" if arr.dtype != 'S1': raise ValueError("argument must have dtype='S1'") if not arr.ndim: # no dimension to concatenate along return arr size = arr.shape[-1] if not size: #...
[ "Convert", "numpy", "/", "dask", "arrays", "from", "characters", "to", "fixed", "width", "bytes", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L146-L175
[ "def", "char_to_bytes", "(", "arr", ")", ":", "if", "arr", ".", "dtype", "!=", "'S1'", ":", "raise", "ValueError", "(", "\"argument must have dtype='S1'\"", ")", "if", "not", "arr", ".", "ndim", ":", "# no dimension to concatenate along", "return", "arr", "size"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_numpy_char_to_bytes
Like netCDF4.chartostring, but faster and more flexible.
xarray/coding/strings.py
def _numpy_char_to_bytes(arr): """Like netCDF4.chartostring, but faster and more flexible. """ # based on: http://stackoverflow.com/a/10984878/809705 arr = np.array(arr, copy=False, order='C') dtype = 'S' + str(arr.shape[-1]) return arr.view(dtype).reshape(arr.shape[:-1])
def _numpy_char_to_bytes(arr): """Like netCDF4.chartostring, but faster and more flexible. """ # based on: http://stackoverflow.com/a/10984878/809705 arr = np.array(arr, copy=False, order='C') dtype = 'S' + str(arr.shape[-1]) return arr.view(dtype).reshape(arr.shape[:-1])
[ "Like", "netCDF4", ".", "chartostring", "but", "faster", "and", "more", "flexible", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L178-L184
[ "def", "_numpy_char_to_bytes", "(", "arr", ")", ":", "# based on: http://stackoverflow.com/a/10984878/809705", "arr", "=", "np", ".", "array", "(", "arr", ",", "copy", "=", "False", ",", "order", "=", "'C'", ")", "dtype", "=", "'S'", "+", "str", "(", "arr", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
safe_cast_to_index
Given an array, safely cast it to a pandas.Index. If it is already a pandas.Index, return it unchanged. Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64, this function will not attempt to do automatic type conversion but will always return an index with dtype=object.
xarray/core/utils.py
def safe_cast_to_index(array: Any) -> pd.Index: """Given an array, safely cast it to a pandas.Index. If it is already a pandas.Index, return it unchanged. Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64, this function will not attempt to do automatic type conversion but will ...
def safe_cast_to_index(array: Any) -> pd.Index: """Given an array, safely cast it to a pandas.Index. If it is already a pandas.Index, return it unchanged. Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64, this function will not attempt to do automatic type conversion but will ...
[ "Given", "an", "array", "safely", "cast", "it", "to", "a", "pandas", ".", "Index", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L74-L92
[ "def", "safe_cast_to_index", "(", "array", ":", "Any", ")", "->", "pd", ".", "Index", ":", "if", "isinstance", "(", "array", ",", "pd", ".", "Index", ")", ":", "index", "=", "array", "elif", "hasattr", "(", "array", ",", "'to_index'", ")", ":", "inde...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
multiindex_from_product_levels
Creating a MultiIndex from a product without refactorizing levels. Keeping levels the same gives back the original labels when we unstack. Parameters ---------- levels : sequence of pd.Index Values for each MultiIndex level. names : optional sequence of objects Names for each level...
xarray/core/utils.py
def multiindex_from_product_levels(levels: Sequence[pd.Index], names: Optional[Sequence[str]] = None ) -> pd.MultiIndex: """Creating a MultiIndex from a product without refactorizing levels. Keeping levels the same gives back the original la...
def multiindex_from_product_levels(levels: Sequence[pd.Index], names: Optional[Sequence[str]] = None ) -> pd.MultiIndex: """Creating a MultiIndex from a product without refactorizing levels. Keeping levels the same gives back the original la...
[ "Creating", "a", "MultiIndex", "from", "a", "product", "without", "refactorizing", "levels", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L95-L119
[ "def", "multiindex_from_product_levels", "(", "levels", ":", "Sequence", "[", "pd", ".", "Index", "]", ",", "names", ":", "Optional", "[", "Sequence", "[", "str", "]", "]", "=", "None", ")", "->", "pd", ".", "MultiIndex", ":", "if", "any", "(", "not", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
maybe_wrap_array
Wrap a transformed array with __array_wrap__ is it can be done safely. This lets us treat arbitrary functions that take and return ndarray objects like ufuncs, as long as they return an array with the same shape.
xarray/core/utils.py
def maybe_wrap_array(original, new_array): """Wrap a transformed array with __array_wrap__ is it can be done safely. This lets us treat arbitrary functions that take and return ndarray objects like ufuncs, as long as they return an array with the same shape. """ # in case func lost array's metadata...
def maybe_wrap_array(original, new_array): """Wrap a transformed array with __array_wrap__ is it can be done safely. This lets us treat arbitrary functions that take and return ndarray objects like ufuncs, as long as they return an array with the same shape. """ # in case func lost array's metadata...
[ "Wrap", "a", "transformed", "array", "with", "__array_wrap__", "is", "it", "can", "be", "done", "safely", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L122-L132
[ "def", "maybe_wrap_array", "(", "original", ",", "new_array", ")", ":", "# in case func lost array's metadata", "if", "isinstance", "(", "new_array", ",", "np", ".", "ndarray", ")", "and", "new_array", ".", "shape", "==", "original", ".", "shape", ":", "return",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
equivalent
Compare two objects for equivalence (identity or equality), using array_equiv if either object is an ndarray
xarray/core/utils.py
def equivalent(first: T, second: T) -> bool: """Compare two objects for equivalence (identity or equality), using array_equiv if either object is an ndarray """ # TODO: refactor to avoid circular import from . import duck_array_ops if isinstance(first, np.ndarray) or isinstance(second, np.ndarra...
def equivalent(first: T, second: T) -> bool: """Compare two objects for equivalence (identity or equality), using array_equiv if either object is an ndarray """ # TODO: refactor to avoid circular import from . import duck_array_ops if isinstance(first, np.ndarray) or isinstance(second, np.ndarra...
[ "Compare", "two", "objects", "for", "equivalence", "(", "identity", "or", "equality", ")", "using", "array_equiv", "if", "either", "object", "is", "an", "ndarray" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L135-L146
[ "def", "equivalent", "(", "first", ":", "T", ",", "second", ":", "T", ")", "->", "bool", ":", "# TODO: refactor to avoid circular import", "from", ".", "import", "duck_array_ops", "if", "isinstance", "(", "first", ",", "np", ".", "ndarray", ")", "or", "isins...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
peek_at
Returns the first value from iterable, as well as a new iterator with the same content as the original iterable
xarray/core/utils.py
def peek_at(iterable: Iterable[T]) -> Tuple[T, Iterator[T]]: """Returns the first value from iterable, as well as a new iterator with the same content as the original iterable """ gen = iter(iterable) peek = next(gen) return peek, itertools.chain([peek], gen)
def peek_at(iterable: Iterable[T]) -> Tuple[T, Iterator[T]]: """Returns the first value from iterable, as well as a new iterator with the same content as the original iterable """ gen = iter(iterable) peek = next(gen) return peek, itertools.chain([peek], gen)
[ "Returns", "the", "first", "value", "from", "iterable", "as", "well", "as", "a", "new", "iterator", "with", "the", "same", "content", "as", "the", "original", "iterable" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L149-L155
[ "def", "peek_at", "(", "iterable", ":", "Iterable", "[", "T", "]", ")", "->", "Tuple", "[", "T", ",", "Iterator", "[", "T", "]", "]", ":", "gen", "=", "iter", "(", "iterable", ")", "peek", "=", "next", "(", "gen", ")", "return", "peek", ",", "i...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
update_safety_check
Check the safety of updating one dictionary with another. Raises ValueError if dictionaries have non-compatible values for any key, where compatibility is determined by identity (they are the same item) or the `compat` function. Parameters ---------- first_dict, second_dict : dict-like ...
xarray/core/utils.py
def update_safety_check(first_dict: MutableMapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent) -> None: """Check the safety of updating one dictionary with another. Raises ValueError if dictionaries have non-compatible values f...
def update_safety_check(first_dict: MutableMapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent) -> None: """Check the safety of updating one dictionary with another. Raises ValueError if dictionaries have non-compatible values f...
[ "Check", "the", "safety", "of", "updating", "one", "dictionary", "with", "another", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L158-L179
[ "def", "update_safety_check", "(", "first_dict", ":", "MutableMapping", "[", "K", ",", "V", "]", ",", "second_dict", ":", "Mapping", "[", "K", ",", "V", "]", ",", "compat", ":", "Callable", "[", "[", "V", ",", "V", "]", ",", "bool", "]", "=", "equi...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
remove_incompatible_items
Remove incompatible items from the first dictionary in-place. Items are retained if their keys are found in both dictionaries and the values are compatible. Parameters ---------- first_dict, second_dict : dict-like Mappings to merge. compat : function, optional Binary operator ...
xarray/core/utils.py
def remove_incompatible_items(first_dict: MutableMapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent ) -> None: """Remove incompatible items from the first dictionary in-place. Items are...
def remove_incompatible_items(first_dict: MutableMapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent ) -> None: """Remove incompatible items from the first dictionary in-place. Items are...
[ "Remove", "incompatible", "items", "from", "the", "first", "dictionary", "in", "-", "place", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L182-L201
[ "def", "remove_incompatible_items", "(", "first_dict", ":", "MutableMapping", "[", "K", ",", "V", "]", ",", "second_dict", ":", "Mapping", "[", "K", ",", "V", "]", ",", "compat", ":", "Callable", "[", "[", "V", ",", "V", "]", ",", "bool", "]", "=", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
is_scalar
Whether to treat a value as a scalar. Any non-iterable, string, or 0-D array
xarray/core/utils.py
def is_scalar(value: Any) -> bool: """Whether to treat a value as a scalar. Any non-iterable, string, or 0-D array """ return ( getattr(value, 'ndim', None) == 0 or isinstance(value, (str, bytes)) or not isinstance(value, (Iterable, ) + dask_array_type))
def is_scalar(value: Any) -> bool: """Whether to treat a value as a scalar. Any non-iterable, string, or 0-D array """ return ( getattr(value, 'ndim', None) == 0 or isinstance(value, (str, bytes)) or not isinstance(value, (Iterable, ) + dask_array_type))
[ "Whether", "to", "treat", "a", "value", "as", "a", "scalar", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L230-L238
[ "def", "is_scalar", "(", "value", ":", "Any", ")", "->", "bool", ":", "return", "(", "getattr", "(", "value", ",", "'ndim'", ",", "None", ")", "==", "0", "or", "isinstance", "(", "value", ",", "(", "str", ",", "bytes", ")", ")", "or", "not", "isi...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
to_0d_object_array
Given a value, wrap it in a 0-D numpy.ndarray with dtype=object.
xarray/core/utils.py
def to_0d_object_array(value: Any) -> np.ndarray: """Given a value, wrap it in a 0-D numpy.ndarray with dtype=object. """ result = np.empty((), dtype=object) result[()] = value return result
def to_0d_object_array(value: Any) -> np.ndarray: """Given a value, wrap it in a 0-D numpy.ndarray with dtype=object. """ result = np.empty((), dtype=object) result[()] = value return result
[ "Given", "a", "value", "wrap", "it", "in", "a", "0", "-", "D", "numpy", ".", "ndarray", "with", "dtype", "=", "object", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L250-L255
[ "def", "to_0d_object_array", "(", "value", ":", "Any", ")", "->", "np", ".", "ndarray", ":", "result", "=", "np", ".", "empty", "(", "(", ")", ",", "dtype", "=", "object", ")", "result", "[", "(", ")", "]", "=", "value", "return", "result" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
to_0d_array
Given a value, wrap it in a 0-D numpy.ndarray.
xarray/core/utils.py
def to_0d_array(value: Any) -> np.ndarray: """Given a value, wrap it in a 0-D numpy.ndarray. """ if np.isscalar(value) or (isinstance(value, np.ndarray) and value.ndim == 0): return np.array(value) else: return to_0d_object_array(value)
def to_0d_array(value: Any) -> np.ndarray: """Given a value, wrap it in a 0-D numpy.ndarray. """ if np.isscalar(value) or (isinstance(value, np.ndarray) and value.ndim == 0): return np.array(value) else: return to_0d_object_array(value)
[ "Given", "a", "value", "wrap", "it", "in", "a", "0", "-", "D", "numpy", ".", "ndarray", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L258-L265
[ "def", "to_0d_array", "(", "value", ":", "Any", ")", "->", "np", ".", "ndarray", ":", "if", "np", ".", "isscalar", "(", "value", ")", "or", "(", "isinstance", "(", "value", ",", "np", ".", "ndarray", ")", "and", "value", ".", "ndim", "==", "0", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
dict_equiv
Test equivalence of two dict-like objects. If any of the values are numpy arrays, compare them correctly. Parameters ---------- first, second : dict-like Dictionaries to compare for equality compat : function, optional Binary operator to determine if two values are compatible. By de...
xarray/core/utils.py
def dict_equiv(first: Mapping[K, V], second: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent) -> bool: """Test equivalence of two dict-like objects. If any of the values are numpy arrays, compare them correctly. Parameters ---------- first, second : dict-like Dicti...
def dict_equiv(first: Mapping[K, V], second: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent) -> bool: """Test equivalence of two dict-like objects. If any of the values are numpy arrays, compare them correctly. Parameters ---------- first, second : dict-like Dicti...
[ "Test", "equivalence", "of", "two", "dict", "-", "like", "objects", ".", "If", "any", "of", "the", "values", "are", "numpy", "arrays", "compare", "them", "correctly", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L268-L292
[ "def", "dict_equiv", "(", "first", ":", "Mapping", "[", "K", ",", "V", "]", ",", "second", ":", "Mapping", "[", "K", ",", "V", "]", ",", "compat", ":", "Callable", "[", "[", "V", ",", "V", "]", ",", "bool", "]", "=", "equivalent", ")", "->", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
ordered_dict_intersection
Return the intersection of two dictionaries as a new OrderedDict. Items are retained if their keys are found in both dictionaries and the values are compatible. Parameters ---------- first_dict, second_dict : dict-like Mappings to merge. compat : function, optional Binary opera...
xarray/core/utils.py
def ordered_dict_intersection(first_dict: Mapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent ) -> MutableMapping[K, V]: """Return the intersection of two dictionaries as a new OrderedDict. ...
def ordered_dict_intersection(first_dict: Mapping[K, V], second_dict: Mapping[K, V], compat: Callable[[V, V], bool] = equivalent ) -> MutableMapping[K, V]: """Return the intersection of two dictionaries as a new OrderedDict. ...
[ "Return", "the", "intersection", "of", "two", "dictionaries", "as", "a", "new", "OrderedDict", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L295-L319
[ "def", "ordered_dict_intersection", "(", "first_dict", ":", "Mapping", "[", "K", ",", "V", "]", ",", "second_dict", ":", "Mapping", "[", "K", ",", "V", "]", ",", "compat", ":", "Callable", "[", "[", "V", ",", "V", "]", ",", "bool", "]", "=", "equiv...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
is_uniform_spaced
Return True if values of an array are uniformly spaced and sorted. >>> is_uniform_spaced(range(5)) True >>> is_uniform_spaced([-4, 0, 100]) False kwargs are additional arguments to ``np.isclose``
xarray/core/utils.py
def is_uniform_spaced(arr, **kwargs) -> bool: """Return True if values of an array are uniformly spaced and sorted. >>> is_uniform_spaced(range(5)) True >>> is_uniform_spaced([-4, 0, 100]) False kwargs are additional arguments to ``np.isclose`` """ arr = np.array(arr, dtype=float) ...
def is_uniform_spaced(arr, **kwargs) -> bool: """Return True if values of an array are uniformly spaced and sorted. >>> is_uniform_spaced(range(5)) True >>> is_uniform_spaced([-4, 0, 100]) False kwargs are additional arguments to ``np.isclose`` """ arr = np.array(arr, dtype=float) ...
[ "Return", "True", "if", "values", "of", "an", "array", "are", "uniformly", "spaced", "and", "sorted", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L509-L521
[ "def", "is_uniform_spaced", "(", "arr", ",", "*", "*", "kwargs", ")", "->", "bool", ":", "arr", "=", "np", ".", "array", "(", "arr", ",", "dtype", "=", "float", ")", "diffs", "=", "np", ".", "diff", "(", "arr", ")", "return", "bool", "(", "np", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
decode_numpy_dict_values
Convert attribute values from numpy objects to native Python objects, for use in to_dict
xarray/core/utils.py
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]: """Convert attribute values from numpy objects to native Python objects, for use in to_dict """ attrs = dict(attrs) for k, v in attrs.items(): if isinstance(v, np.ndarray): attrs[k] = v.tolist() elif isinst...
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]: """Convert attribute values from numpy objects to native Python objects, for use in to_dict """ attrs = dict(attrs) for k, v in attrs.items(): if isinstance(v, np.ndarray): attrs[k] = v.tolist() elif isinst...
[ "Convert", "attribute", "values", "from", "numpy", "objects", "to", "native", "Python", "objects", "for", "use", "in", "to_dict" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L538-L548
[ "def", "decode_numpy_dict_values", "(", "attrs", ":", "Mapping", "[", "K", ",", "V", "]", ")", "->", "Dict", "[", "K", ",", "V", "]", ":", "attrs", "=", "dict", "(", "attrs", ")", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", ":"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
ensure_us_time_resolution
Convert val out of numpy time, for use in to_dict. Needed because of numpy bug GH#7619
xarray/core/utils.py
def ensure_us_time_resolution(val): """Convert val out of numpy time, for use in to_dict. Needed because of numpy bug GH#7619""" if np.issubdtype(val.dtype, np.datetime64): val = val.astype('datetime64[us]') elif np.issubdtype(val.dtype, np.timedelta64): val = val.astype('timedelta64[us]...
def ensure_us_time_resolution(val): """Convert val out of numpy time, for use in to_dict. Needed because of numpy bug GH#7619""" if np.issubdtype(val.dtype, np.datetime64): val = val.astype('datetime64[us]') elif np.issubdtype(val.dtype, np.timedelta64): val = val.astype('timedelta64[us]...
[ "Convert", "val", "out", "of", "numpy", "time", "for", "use", "in", "to_dict", ".", "Needed", "because", "of", "numpy", "bug", "GH#7619" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L551-L558
[ "def", "ensure_us_time_resolution", "(", "val", ")", ":", "if", "np", ".", "issubdtype", "(", "val", ".", "dtype", ",", "np", ".", "datetime64", ")", ":", "val", "=", "val", ".", "astype", "(", "'datetime64[us]'", ")", "elif", "np", ".", "issubdtype", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
get_temp_dimname
Get an new dimension name based on new_dim, that is not used in dims. If the same name exists, we add an underscore(s) in the head. Example1: dims: ['a', 'b', 'c'] new_dim: ['_rolling'] -> ['_rolling'] Example2: dims: ['a', 'b', 'c', '_rolling'] new_dim: ['_rolling']...
xarray/core/utils.py
def get_temp_dimname(dims: Container[Hashable], new_dim: Hashable) -> Hashable: """ Get an new dimension name based on new_dim, that is not used in dims. If the same name exists, we add an underscore(s) in the head. Example1: dims: ['a', 'b', 'c'] new_dim: ['_rolling'] -> ['_rolling...
def get_temp_dimname(dims: Container[Hashable], new_dim: Hashable) -> Hashable: """ Get an new dimension name based on new_dim, that is not used in dims. If the same name exists, we add an underscore(s) in the head. Example1: dims: ['a', 'b', 'c'] new_dim: ['_rolling'] -> ['_rolling...
[ "Get", "an", "new", "dimension", "name", "based", "on", "new_dim", "that", "is", "not", "used", "in", "dims", ".", "If", "the", "same", "name", "exists", "we", "add", "an", "underscore", "(", "s", ")", "in", "the", "head", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L597-L612
[ "def", "get_temp_dimname", "(", "dims", ":", "Container", "[", "Hashable", "]", ",", "new_dim", ":", "Hashable", ")", "->", "Hashable", ":", "while", "new_dim", "in", "dims", ":", "new_dim", "=", "'_'", "+", "str", "(", "new_dim", ")", "return", "new_dim...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_infer_dtype
Given an object array with no missing values, infer its dtype from its first element
xarray/conventions.py
def _infer_dtype(array, name=None): """Given an object array with no missing values, infer its dtype from its first element """ if array.dtype.kind != 'O': raise TypeError('infer_type must be called on a dtype=object array') if array.size == 0: return np.dtype(float) element = ...
def _infer_dtype(array, name=None): """Given an object array with no missing values, infer its dtype from its first element """ if array.dtype.kind != 'O': raise TypeError('infer_type must be called on a dtype=object array') if array.size == 0: return np.dtype(float) element = ...
[ "Given", "an", "object", "array", "with", "no", "missing", "values", "infer", "its", "dtype", "from", "its", "first", "element" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L115-L135
[ "def", "_infer_dtype", "(", "array", ",", "name", "=", "None", ")", ":", "if", "array", ".", "dtype", ".", "kind", "!=", "'O'", ":", "raise", "TypeError", "(", "'infer_type must be called on a dtype=object array'", ")", "if", "array", ".", "size", "==", "0",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_copy_with_dtype
Create a copy of an array with the given dtype. We use this instead of np.array() to ensure that custom object dtypes end up on the resulting array.
xarray/conventions.py
def _copy_with_dtype(data, dtype): """Create a copy of an array with the given dtype. We use this instead of np.array() to ensure that custom object dtypes end up on the resulting array. """ result = np.empty(data.shape, dtype) result[...] = data return result
def _copy_with_dtype(data, dtype): """Create a copy of an array with the given dtype. We use this instead of np.array() to ensure that custom object dtypes end up on the resulting array. """ result = np.empty(data.shape, dtype) result[...] = data return result
[ "Create", "a", "copy", "of", "an", "array", "with", "the", "given", "dtype", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L149-L157
[ "def", "_copy_with_dtype", "(", "data", ",", "dtype", ")", ":", "result", "=", "np", ".", "empty", "(", "data", ".", "shape", ",", "dtype", ")", "result", "[", "...", "]", "=", "data", "return", "result" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
encode_cf_variable
Converts an Variable into an Variable which follows some of the CF conventions: - Nans are masked using _FillValue (or the deprecated missing_value) - Rescaling via: scale_factor and add_offset - datetimes are converted to the CF 'units since time' format - dtype encodings are enfor...
xarray/conventions.py
def encode_cf_variable(var, needs_copy=True, name=None): """ Converts an Variable into an Variable which follows some of the CF conventions: - Nans are masked using _FillValue (or the deprecated missing_value) - Rescaling via: scale_factor and add_offset - datetimes are converted to...
def encode_cf_variable(var, needs_copy=True, name=None): """ Converts an Variable into an Variable which follows some of the CF conventions: - Nans are masked using _FillValue (or the deprecated missing_value) - Rescaling via: scale_factor and add_offset - datetimes are converted to...
[ "Converts", "an", "Variable", "into", "an", "Variable", "which", "follows", "some", "of", "the", "CF", "conventions", ":" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L204-L238
[ "def", "encode_cf_variable", "(", "var", ",", "needs_copy", "=", "True", ",", "name", "=", "None", ")", ":", "ensure_not_multiindex", "(", "var", ",", "name", "=", "name", ")", "for", "coder", "in", "[", "times", ".", "CFDatetimeCoder", "(", ")", ",", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
decode_cf_variable
Decodes a variable which may hold CF encoded information. This includes variables that have been masked and scaled, which hold CF style time variables (this is almost always the case if the dataset has been serialized) and which have strings encoded as character arrays. Parameters ---------- ...
xarray/conventions.py
def decode_cf_variable(name, var, concat_characters=True, mask_and_scale=True, decode_times=True, decode_endianness=True, stack_char_dim=True, use_cftime=None): """ Decodes a variable which may hold CF encoded information. This includes variables that have been...
def decode_cf_variable(name, var, concat_characters=True, mask_and_scale=True, decode_times=True, decode_endianness=True, stack_char_dim=True, use_cftime=None): """ Decodes a variable which may hold CF encoded information. This includes variables that have been...
[ "Decodes", "a", "variable", "which", "may", "hold", "CF", "encoded", "information", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L241-L326
[ "def", "decode_cf_variable", "(", "name", ",", "var", ",", "concat_characters", "=", "True", ",", "mask_and_scale", "=", "True", ",", "decode_times", "=", "True", ",", "decode_endianness", "=", "True", ",", "stack_char_dim", "=", "True", ",", "use_cftime", "="...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_update_bounds_attributes
Adds time attributes to time bounds variables. Variables handling time bounds ("Cell boundaries" in the CF conventions) do not necessarily carry the necessary attributes to be decoded. This copies the attributes from the time variable to the associated boundaries. See Also: http://cfconventio...
xarray/conventions.py
def _update_bounds_attributes(variables): """Adds time attributes to time bounds variables. Variables handling time bounds ("Cell boundaries" in the CF conventions) do not necessarily carry the necessary attributes to be decoded. This copies the attributes from the time variable to the associated b...
def _update_bounds_attributes(variables): """Adds time attributes to time bounds variables. Variables handling time bounds ("Cell boundaries" in the CF conventions) do not necessarily carry the necessary attributes to be decoded. This copies the attributes from the time variable to the associated b...
[ "Adds", "time", "attributes", "to", "time", "bounds", "variables", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L329-L354
[ "def", "_update_bounds_attributes", "(", "variables", ")", ":", "# For all time variables with bounds", "for", "v", "in", "variables", ".", "values", "(", ")", ":", "attrs", "=", "v", ".", "attrs", "has_date_units", "=", "'units'", "in", "attrs", "and", "'since'...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
decode_cf_variables
Decode several CF encoded variables. See: decode_cf_variable
xarray/conventions.py
def decode_cf_variables(variables, attributes, concat_characters=True, mask_and_scale=True, decode_times=True, decode_coords=True, drop_variables=None, use_cftime=None): """ Decode several CF encoded variables. See: decode_cf_variable ...
def decode_cf_variables(variables, attributes, concat_characters=True, mask_and_scale=True, decode_times=True, decode_coords=True, drop_variables=None, use_cftime=None): """ Decode several CF encoded variables. See: decode_cf_variable ...
[ "Decode", "several", "CF", "encoded", "variables", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L357-L416
[ "def", "decode_cf_variables", "(", "variables", ",", "attributes", ",", "concat_characters", "=", "True", ",", "mask_and_scale", "=", "True", ",", "decode_times", "=", "True", ",", "decode_coords", "=", "True", ",", "drop_variables", "=", "None", ",", "use_cftim...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
decode_cf
Decode the given Dataset or Datastore according to CF conventions into a new Dataset. Parameters ---------- obj : Dataset or DataStore Object to decode. concat_characters : bool, optional Should character arrays be concatenated to strings, for example: ['h', 'e', 'l', 'l', '...
xarray/conventions.py
def decode_cf(obj, concat_characters=True, mask_and_scale=True, decode_times=True, decode_coords=True, drop_variables=None, use_cftime=None): """Decode the given Dataset or Datastore according to CF conventions into a new Dataset. Parameters ---------- obj : Dataset or D...
def decode_cf(obj, concat_characters=True, mask_and_scale=True, decode_times=True, decode_coords=True, drop_variables=None, use_cftime=None): """Decode the given Dataset or Datastore according to CF conventions into a new Dataset. Parameters ---------- obj : Dataset or D...
[ "Decode", "the", "given", "Dataset", "or", "Datastore", "according", "to", "CF", "conventions", "into", "a", "new", "Dataset", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L419-L485
[ "def", "decode_cf", "(", "obj", ",", "concat_characters", "=", "True", ",", "mask_and_scale", "=", "True", ",", "decode_times", "=", "True", ",", "decode_coords", "=", "True", ",", "drop_variables", "=", "None", ",", "use_cftime", "=", "None", ")", ":", "f...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
cf_decoder
Decode a set of CF encoded variables and attributes. See Also, decode_cf_variable Parameters ---------- variables : dict A dictionary mapping from variable name to xarray.Variable attributes : dict A dictionary mapping from attribute name to value concat_characters : bool ...
xarray/conventions.py
def cf_decoder(variables, attributes, concat_characters=True, mask_and_scale=True, decode_times=True): """ Decode a set of CF encoded variables and attributes. See Also, decode_cf_variable Parameters ---------- variables : dict A dictionary mapping from va...
def cf_decoder(variables, attributes, concat_characters=True, mask_and_scale=True, decode_times=True): """ Decode a set of CF encoded variables and attributes. See Also, decode_cf_variable Parameters ---------- variables : dict A dictionary mapping from va...
[ "Decode", "a", "set", "of", "CF", "encoded", "variables", "and", "attributes", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L488-L520
[ "def", "cf_decoder", "(", "variables", ",", "attributes", ",", "concat_characters", "=", "True", ",", "mask_and_scale", "=", "True", ",", "decode_times", "=", "True", ")", ":", "variables", ",", "attributes", ",", "_", "=", "decode_cf_variables", "(", "variabl...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
encode_dataset_coordinates
Encode coordinates on the given dataset object into variable specific and global attributes. When possible, this is done according to CF conventions. Parameters ---------- dataset : Dataset Object to encode. Returns ------- variables : dict attrs : dict
xarray/conventions.py
def encode_dataset_coordinates(dataset): """Encode coordinates on the given dataset object into variable specific and global attributes. When possible, this is done according to CF conventions. Parameters ---------- dataset : Dataset Object to encode. Returns ------- varia...
def encode_dataset_coordinates(dataset): """Encode coordinates on the given dataset object into variable specific and global attributes. When possible, this is done according to CF conventions. Parameters ---------- dataset : Dataset Object to encode. Returns ------- varia...
[ "Encode", "coordinates", "on", "the", "given", "dataset", "object", "into", "variable", "specific", "and", "global", "attributes", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L574-L592
[ "def", "encode_dataset_coordinates", "(", "dataset", ")", ":", "non_dim_coord_names", "=", "set", "(", "dataset", ".", "coords", ")", "-", "set", "(", "dataset", ".", "dims", ")", "return", "_encode_coordinates", "(", "dataset", ".", "_variables", ",", "datase...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
cf_encoder
A function which takes a dicts of variables and attributes and encodes them to conform to CF conventions as much as possible. This includes masking, scaling, character array handling, and CF-time encoding. Decode a set of CF encoded variables and attributes. See Also, decode_cf_variable Para...
xarray/conventions.py
def cf_encoder(variables, attributes): """ A function which takes a dicts of variables and attributes and encodes them to conform to CF conventions as much as possible. This includes masking, scaling, character array handling, and CF-time encoding. Decode a set of CF encoded variables and attr...
def cf_encoder(variables, attributes): """ A function which takes a dicts of variables and attributes and encodes them to conform to CF conventions as much as possible. This includes masking, scaling, character array handling, and CF-time encoding. Decode a set of CF encoded variables and attr...
[ "A", "function", "which", "takes", "a", "dicts", "of", "variables", "and", "attributes", "and", "encodes", "them", "to", "conform", "to", "CF", "conventions", "as", "much", "as", "possible", ".", "This", "includes", "masking", "scaling", "character", "array", ...
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L595-L624
[ "def", "cf_encoder", "(", "variables", ",", "attributes", ")", ":", "new_vars", "=", "OrderedDict", "(", "(", "k", ",", "encode_cf_variable", "(", "v", ",", "name", "=", "k", ")", ")", "for", "k", ",", "v", "in", "variables", ".", "items", "(", ")", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
coerce_nc3_dtype
Coerce an array to a data type that can be stored in a netCDF-3 file This function performs the following dtype conversions: int64 -> int32 bool -> int8 Data is checked for equality, or equivalence (non-NaN values) with `np.allclose` with the default keyword arguments.
xarray/backends/netcdf3.py
def coerce_nc3_dtype(arr): """Coerce an array to a data type that can be stored in a netCDF-3 file This function performs the following dtype conversions: int64 -> int32 bool -> int8 Data is checked for equality, or equivalence (non-NaN values) with `np.allclose` with the default keywo...
def coerce_nc3_dtype(arr): """Coerce an array to a data type that can be stored in a netCDF-3 file This function performs the following dtype conversions: int64 -> int32 bool -> int8 Data is checked for equality, or equivalence (non-NaN values) with `np.allclose` with the default keywo...
[ "Coerce", "an", "array", "to", "a", "data", "type", "that", "can", "be", "stored", "in", "a", "netCDF", "-", "3", "file" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/netcdf3.py#L26-L45
[ "def", "coerce_nc3_dtype", "(", "arr", ")", ":", "dtype", "=", "str", "(", "arr", ".", "dtype", ")", "if", "dtype", "in", "_nc3_dtype_coercions", ":", "new_dtype", "=", "_nc3_dtype_coercions", "[", "dtype", "]", "# TODO: raise a warning whenever casting the data-typ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
is_valid_nc3_name
Test whether an object can be validly converted to a netCDF-3 dimension, variable or attribute name Earlier versions of the netCDF C-library reference implementation enforced a more restricted set of characters in creating new names, but permitted reading names containing arbitrary bytes. This spec...
xarray/backends/netcdf3.py
def is_valid_nc3_name(s): """Test whether an object can be validly converted to a netCDF-3 dimension, variable or attribute name Earlier versions of the netCDF C-library reference implementation enforced a more restricted set of characters in creating new names, but permitted reading names containi...
def is_valid_nc3_name(s): """Test whether an object can be validly converted to a netCDF-3 dimension, variable or attribute name Earlier versions of the netCDF C-library reference implementation enforced a more restricted set of characters in creating new names, but permitted reading names containi...
[ "Test", "whether", "an", "object", "can", "be", "validly", "converted", "to", "a", "netCDF", "-", "3", "dimension", "variable", "or", "attribute", "name" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/netcdf3.py#L83-L111
[ "def", "is_valid_nc3_name", "(", "s", ")", ":", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "return", "False", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", "num_bytes",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
as_variable
Convert an object into a Variable. Parameters ---------- obj : object Object to convert into a Variable. - If the object is already a Variable, return a shallow copy. - Otherwise, if the object has 'dims' and 'data' attributes, convert it into a new Variable. - If...
xarray/core/variable.py
def as_variable(obj, name=None) -> 'Union[Variable, IndexVariable]': """Convert an object into a Variable. Parameters ---------- obj : object Object to convert into a Variable. - If the object is already a Variable, return a shallow copy. - Otherwise, if the object has 'dims' a...
def as_variable(obj, name=None) -> 'Union[Variable, IndexVariable]': """Convert an object into a Variable. Parameters ---------- obj : object Object to convert into a Variable. - If the object is already a Variable, return a shallow copy. - Otherwise, if the object has 'dims' a...
[ "Convert", "an", "object", "into", "a", "Variable", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L46-L119
[ "def", "as_variable", "(", "obj", ",", "name", "=", "None", ")", "->", "'Union[Variable, IndexVariable]'", ":", "from", ".", "dataarray", "import", "DataArray", "# TODO: consider extending this method to automatically handle Iris and", "if", "isinstance", "(", "obj", ",",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_possibly_convert_objects
Convert arrays of datetime.datetime and datetime.timedelta objects into datetime64 and timedelta64, according to the pandas convention.
xarray/core/variable.py
def _possibly_convert_objects(values): """Convert arrays of datetime.datetime and datetime.timedelta objects into datetime64 and timedelta64, according to the pandas convention. """ return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
def _possibly_convert_objects(values): """Convert arrays of datetime.datetime and datetime.timedelta objects into datetime64 and timedelta64, according to the pandas convention. """ return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
[ "Convert", "arrays", "of", "datetime", ".", "datetime", "and", "datetime", ".", "timedelta", "objects", "into", "datetime64", "and", "timedelta64", "according", "to", "the", "pandas", "convention", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L135-L139
[ "def", "_possibly_convert_objects", "(", "values", ")", ":", "return", "np", ".", "asarray", "(", "pd", ".", "Series", "(", "values", ".", "ravel", "(", ")", ")", ")", ".", "reshape", "(", "values", ".", "shape", ")" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
as_compatible_data
Prepare and wrap data to put in a Variable. - If data does not have the necessary attributes, convert it to ndarray. - If data has dtype=datetime64, ensure that it has ns precision. If it's a pandas.Timestamp, convert it to datetime64. - If data is already a pandas or xarray object (other than an Ind...
xarray/core/variable.py
def as_compatible_data(data, fastpath=False): """Prepare and wrap data to put in a Variable. - If data does not have the necessary attributes, convert it to ndarray. - If data has dtype=datetime64, ensure that it has ns precision. If it's a pandas.Timestamp, convert it to datetime64. - If data is...
def as_compatible_data(data, fastpath=False): """Prepare and wrap data to put in a Variable. - If data does not have the necessary attributes, convert it to ndarray. - If data has dtype=datetime64, ensure that it has ns precision. If it's a pandas.Timestamp, convert it to datetime64. - If data is...
[ "Prepare", "and", "wrap", "data", "to", "put", "in", "a", "Variable", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L142-L196
[ "def", "as_compatible_data", "(", "data", ",", "fastpath", "=", "False", ")", ":", "if", "fastpath", "and", "getattr", "(", "data", ",", "'ndim'", ",", "0", ")", ">", "0", ":", "# can't use fastpath (yet) for scalars", "return", "_maybe_wrap_data", "(", "data"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_as_array_or_item
Return the given values as a numpy array, or as an individual item if it's a 0d datetime64 or timedelta64 array. Importantly, this function does not copy data if it is already an ndarray - otherwise, it will not be possible to update Variable values in place. This function mostly exists because 0-dime...
xarray/core/variable.py
def _as_array_or_item(data): """Return the given values as a numpy array, or as an individual item if it's a 0d datetime64 or timedelta64 array. Importantly, this function does not copy data if it is already an ndarray - otherwise, it will not be possible to update Variable values in place. This f...
def _as_array_or_item(data): """Return the given values as a numpy array, or as an individual item if it's a 0d datetime64 or timedelta64 array. Importantly, this function does not copy data if it is already an ndarray - otherwise, it will not be possible to update Variable values in place. This f...
[ "Return", "the", "given", "values", "as", "a", "numpy", "array", "or", "as", "an", "individual", "item", "if", "it", "s", "a", "0d", "datetime64", "or", "timedelta64", "array", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L199-L219
[ "def", "_as_array_or_item", "(", "data", ")", ":", "data", "=", "np", ".", "asarray", "(", "data", ")", "if", "data", ".", "ndim", "==", "0", ":", "if", "data", ".", "dtype", ".", "kind", "==", "'M'", ":", "data", "=", "np", ".", "datetime64", "(...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
_broadcast_compat_variables
Create broadcast compatible variables, with the same dimensions. Unlike the result of broadcast_variables(), some variables may have dimensions of size 1 instead of the the size of the broadcast dimension.
xarray/core/variable.py
def _broadcast_compat_variables(*variables): """Create broadcast compatible variables, with the same dimensions. Unlike the result of broadcast_variables(), some variables may have dimensions of size 1 instead of the the size of the broadcast dimension. """ dims = tuple(_unified_dims(variables)) ...
def _broadcast_compat_variables(*variables): """Create broadcast compatible variables, with the same dimensions. Unlike the result of broadcast_variables(), some variables may have dimensions of size 1 instead of the the size of the broadcast dimension. """ dims = tuple(_unified_dims(variables)) ...
[ "Create", "broadcast", "compatible", "variables", "with", "the", "same", "dimensions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L2016-L2024
[ "def", "_broadcast_compat_variables", "(", "*", "variables", ")", ":", "dims", "=", "tuple", "(", "_unified_dims", "(", "variables", ")", ")", "return", "tuple", "(", "var", ".", "set_dims", "(", "dims", ")", "if", "var", ".", "dims", "!=", "dims", "else...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
broadcast_variables
Given any number of variables, return variables with matching dimensions and broadcast data. The data on the returned variables will be a view of the data on the corresponding original arrays, but dimensions will be reordered and inserted so that both broadcast arrays have the same dimensions. The new ...
xarray/core/variable.py
def broadcast_variables(*variables): """Given any number of variables, return variables with matching dimensions and broadcast data. The data on the returned variables will be a view of the data on the corresponding original arrays, but dimensions will be reordered and inserted so that both broadca...
def broadcast_variables(*variables): """Given any number of variables, return variables with matching dimensions and broadcast data. The data on the returned variables will be a view of the data on the corresponding original arrays, but dimensions will be reordered and inserted so that both broadca...
[ "Given", "any", "number", "of", "variables", "return", "variables", "with", "matching", "dimensions", "and", "broadcast", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L2027-L2040
[ "def", "broadcast_variables", "(", "*", "variables", ")", ":", "dims_map", "=", "_unified_dims", "(", "variables", ")", "dims_tuple", "=", "tuple", "(", "dims_map", ")", "return", "tuple", "(", "var", ".", "set_dims", "(", "dims_map", ")", "if", "var", "."...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
concat
Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have matching dimensions and shape except for along the stacked dimension. dim : str or DataArray, optional ...
xarray/core/variable.py
def concat(variables, dim='concat_dim', positions=None, shortcut=False): """Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have matching dimensions and shape except for a...
def concat(variables, dim='concat_dim', positions=None, shortcut=False): """Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have matching dimensions and shape except for a...
[ "Concatenate", "variables", "along", "a", "new", "or", "existing", "dimension", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L2059-L2093
[ "def", "concat", "(", "variables", ",", "dim", "=", "'concat_dim'", ",", "positions", "=", "None", ",", "shortcut", "=", "False", ")", ":", "variables", "=", "list", "(", "variables", ")", "if", "all", "(", "isinstance", "(", "v", ",", "IndexVariable", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
assert_unique_multiindex_level_names
Check for uniqueness of MultiIndex level names in all given variables. Not public API. Used for checking consistency of DataArray and Dataset objects.
xarray/core/variable.py
def assert_unique_multiindex_level_names(variables): """Check for uniqueness of MultiIndex level names in all given variables. Not public API. Used for checking consistency of DataArray and Dataset objects. """ level_names = defaultdict(list) all_level_names = set() for var_name, var in...
def assert_unique_multiindex_level_names(variables): """Check for uniqueness of MultiIndex level names in all given variables. Not public API. Used for checking consistency of DataArray and Dataset objects. """ level_names = defaultdict(list) all_level_names = set() for var_name, var in...
[ "Check", "for", "uniqueness", "of", "MultiIndex", "level", "names", "in", "all", "given", "variables", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L2096-L2128
[ "def", "assert_unique_multiindex_level_names", "(", "variables", ")", ":", "level_names", "=", "defaultdict", "(", "list", ")", "all_level_names", "=", "set", "(", ")", "for", "var_name", ",", "var", "in", "variables", ".", "items", "(", ")", ":", "if", "isi...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.load
Manually trigger loading of this variable's data from disk or a remote source into memory and return this variable. Normally, it should not be necessary to call this method in user code, because all xarray functions should either work on deferred data or load data automatically. ...
xarray/core/variable.py
def load(self, **kwargs): """Manually trigger loading of this variable's data from disk or a remote source into memory and return this variable. Normally, it should not be necessary to call this method in user code, because all xarray functions should either work on deferred data or ...
def load(self, **kwargs): """Manually trigger loading of this variable's data from disk or a remote source into memory and return this variable. Normally, it should not be necessary to call this method in user code, because all xarray functions should either work on deferred data or ...
[ "Manually", "trigger", "loading", "of", "this", "variable", "s", "data", "from", "disk", "or", "a", "remote", "source", "into", "memory", "and", "return", "this", "variable", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L307-L328
[ "def", "load", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "self", ".", "_data", ",", "dask_array_type", ")", ":", "self", ".", "_data", "=", "as_compatible_data", "(", "self", ".", "_data", ".", "compute", "(", "*", "*",...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.to_base_variable
Return this variable as a base xarray.Variable
xarray/core/variable.py
def to_base_variable(self): """Return this variable as a base xarray.Variable""" return Variable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
def to_base_variable(self): """Return this variable as a base xarray.Variable""" return Variable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
[ "Return", "this", "variable", "as", "a", "base", "xarray", ".", "Variable" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L398-L401
[ "def", "to_base_variable", "(", "self", ")", ":", "return", "Variable", "(", "self", ".", "dims", ",", "self", ".", "_data", ",", "self", ".", "_attrs", ",", "encoding", "=", "self", ".", "_encoding", ",", "fastpath", "=", "True", ")" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.to_index_variable
Return this variable as an xarray.IndexVariable
xarray/core/variable.py
def to_index_variable(self): """Return this variable as an xarray.IndexVariable""" return IndexVariable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
def to_index_variable(self): """Return this variable as an xarray.IndexVariable""" return IndexVariable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
[ "Return", "this", "variable", "as", "an", "xarray", ".", "IndexVariable" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L405-L408
[ "def", "to_index_variable", "(", "self", ")", ":", "return", "IndexVariable", "(", "self", ".", "dims", ",", "self", ".", "_data", ",", "self", ".", "_attrs", ",", "encoding", "=", "self", ".", "_encoding", ",", "fastpath", "=", "True", ")" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.to_dict
Dictionary representation of variable.
xarray/core/variable.py
def to_dict(self, data=True): """Dictionary representation of variable.""" item = {'dims': self.dims, 'attrs': decode_numpy_dict_values(self.attrs)} if data: item['data'] = ensure_us_time_resolution(self.values).tolist() else: item.update({'dtype':...
def to_dict(self, data=True): """Dictionary representation of variable.""" item = {'dims': self.dims, 'attrs': decode_numpy_dict_values(self.attrs)} if data: item['data'] = ensure_us_time_resolution(self.values).tolist() else: item.update({'dtype':...
[ "Dictionary", "representation", "of", "variable", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L416-L424
[ "def", "to_dict", "(", "self", ",", "data", "=", "True", ")", ":", "item", "=", "{", "'dims'", ":", "self", ".", "dims", ",", "'attrs'", ":", "decode_numpy_dict_values", "(", "self", ".", "attrs", ")", "}", "if", "data", ":", "item", "[", "'data'", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._broadcast_indexes
Prepare an indexing key for an indexing operation. Parameters ----------- key: int, slice, array, dict or tuple of integer, slices and arrays Any valid input for indexing. Returns ------- dims: tuple Dimension of the resultant variable. i...
xarray/core/variable.py
def _broadcast_indexes(self, key): """Prepare an indexing key for an indexing operation. Parameters ----------- key: int, slice, array, dict or tuple of integer, slices and arrays Any valid input for indexing. Returns ------- dims: tuple ...
def _broadcast_indexes(self, key): """Prepare an indexing key for an indexing operation. Parameters ----------- key: int, slice, array, dict or tuple of integer, slices and arrays Any valid input for indexing. Returns ------- dims: tuple ...
[ "Prepare", "an", "indexing", "key", "for", "an", "indexing", "operation", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L452-L508
[ "def", "_broadcast_indexes", "(", "self", ",", "key", ")", ":", "key", "=", "self", ".", "_item_key_to_tuple", "(", "key", ")", "# key is a tuple", "# key is a tuple of full size", "key", "=", "indexing", ".", "expanded_indexer", "(", "key", ",", "self", ".", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._validate_indexers
Make sanity checks
xarray/core/variable.py
def _validate_indexers(self, key): """ Make sanity checks """ for dim, k in zip(self.dims, key): if isinstance(k, BASIC_INDEXING_TYPES): pass else: if not isinstance(k, Variable): k = np.asarray(k) if k.ndim ...
def _validate_indexers(self, key): """ Make sanity checks """ for dim, k in zip(self.dims, key): if isinstance(k, BASIC_INDEXING_TYPES): pass else: if not isinstance(k, Variable): k = np.asarray(k) if k.ndim ...
[ "Make", "sanity", "checks" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L515-L541
[ "def", "_validate_indexers", "(", "self", ",", "key", ")", ":", "for", "dim", ",", "k", "in", "zip", "(", "self", ".", "dims", ",", "key", ")", ":", "if", "isinstance", "(", "k", ",", "BASIC_INDEXING_TYPES", ")", ":", "pass", "else", ":", "if", "no...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._nonzero
Equivalent numpy's nonzero but returns a tuple of Varibles.
xarray/core/variable.py
def _nonzero(self): """ Equivalent numpy's nonzero but returns a tuple of Varibles. """ # TODO we should replace dask's native nonzero # after https://github.com/dask/dask/issues/1076 is implemented. nonzeros = np.nonzero(self.data) return tuple(Variable((dim), nz) for nz, dim ...
def _nonzero(self): """ Equivalent numpy's nonzero but returns a tuple of Varibles. """ # TODO we should replace dask's native nonzero # after https://github.com/dask/dask/issues/1076 is implemented. nonzeros = np.nonzero(self.data) return tuple(Variable((dim), nz) for nz, dim ...
[ "Equivalent", "numpy", "s", "nonzero", "but", "returns", "a", "tuple", "of", "Varibles", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L560-L566
[ "def", "_nonzero", "(", "self", ")", ":", "# TODO we should replace dask's native nonzero", "# after https://github.com/dask/dask/issues/1076 is implemented.", "nonzeros", "=", "np", ".", "nonzero", "(", "self", ".", "data", ")", "return", "tuple", "(", "Variable", "(", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._finalize_indexing_result
Used by IndexVariable to return IndexVariable objects when possible.
xarray/core/variable.py
def _finalize_indexing_result(self, dims, data): """Used by IndexVariable to return IndexVariable objects when possible. """ return type(self)(dims, data, self._attrs, self._encoding, fastpath=True)
def _finalize_indexing_result(self, dims, data): """Used by IndexVariable to return IndexVariable objects when possible. """ return type(self)(dims, data, self._attrs, self._encoding, fastpath=True)
[ "Used", "by", "IndexVariable", "to", "return", "IndexVariable", "objects", "when", "possible", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L641-L645
[ "def", "_finalize_indexing_result", "(", "self", ",", "dims", ",", "data", ")", ":", "return", "type", "(", "self", ")", "(", "dims", ",", "data", ",", "self", ".", "_attrs", ",", "self", ".", "_encoding", ",", "fastpath", "=", "True", ")" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._getitem_with_mask
Index this Variable with -1 remapped to fill_value.
xarray/core/variable.py
def _getitem_with_mask(self, key, fill_value=dtypes.NA): """Index this Variable with -1 remapped to fill_value.""" # TODO(shoyer): expose this method in public API somewhere (isel?) and # use it for reindex. # TODO(shoyer): add a sanity check that all other integers are # non-neg...
def _getitem_with_mask(self, key, fill_value=dtypes.NA): """Index this Variable with -1 remapped to fill_value.""" # TODO(shoyer): expose this method in public API somewhere (isel?) and # use it for reindex. # TODO(shoyer): add a sanity check that all other integers are # non-neg...
[ "Index", "this", "Variable", "with", "-", "1", "remapped", "to", "fill_value", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L647-L683
[ "def", "_getitem_with_mask", "(", "self", ",", "key", ",", "fill_value", "=", "dtypes", ".", "NA", ")", ":", "# TODO(shoyer): expose this method in public API somewhere (isel?) and", "# use it for reindex.", "# TODO(shoyer): add a sanity check that all other integers are", "# non-n...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.copy
Returns a copy of this object. If `deep=True`, the data array is loaded into memory and copied onto the new object. Dimensions, attributes and encodings are always copied. Use `data` to create a new object with the same structure as original but entirely new data. Parameters ...
xarray/core/variable.py
def copy(self, deep=True, data=None): """Returns a copy of this object. If `deep=True`, the data array is loaded into memory and copied onto the new object. Dimensions, attributes and encodings are always copied. Use `data` to create a new object with the same structure as orig...
def copy(self, deep=True, data=None): """Returns a copy of this object. If `deep=True`, the data array is loaded into memory and copied onto the new object. Dimensions, attributes and encodings are always copied. Use `data` to create a new object with the same structure as orig...
[ "Returns", "a", "copy", "of", "this", "object", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L743-L823
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ",", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "data", "=", "self", ".", "_data", "if", "isinstance", "(", "data", ",", "indexing", ".", "MemoryCachedArray", ")", ":", "# d...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.chunk
Coerce this array's data into a dask arrays with the given chunks. If this variable is a non-dask array, it will be converted to dask array. If it's a dask array, it will be rechunked to the given chunk sizes. If neither chunks is not provided for one or more dimensions, chunk ...
xarray/core/variable.py
def chunk(self, chunks=None, name=None, lock=False): """Coerce this array's data into a dask arrays with the given chunks. If this variable is a non-dask array, it will be converted to dask array. If it's a dask array, it will be rechunked to the given chunk sizes. If neither c...
def chunk(self, chunks=None, name=None, lock=False): """Coerce this array's data into a dask arrays with the given chunks. If this variable is a non-dask array, it will be converted to dask array. If it's a dask array, it will be rechunked to the given chunk sizes. If neither c...
[ "Coerce", "this", "array", "s", "data", "into", "a", "dask", "arrays", "with", "the", "given", "chunks", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L846-L898
[ "def", "chunk", "(", "self", ",", "chunks", "=", "None", ",", "name", "=", "None", ",", "lock", "=", "False", ")", ":", "import", "dask", ".", "array", "as", "da", "if", "utils", ".", "is_dict_like", "(", "chunks", ")", ":", "chunks", "=", "dict", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.isel
Return a new array indexed along the specified dimension(s). Parameters ---------- **indexers : {dim: indexer, ...} Keyword arguments with names matching dimensions and values given by integers, slice objects or arrays. Returns ------- obj : Arra...
xarray/core/variable.py
def isel(self, indexers=None, drop=False, **indexers_kwargs): """Return a new array indexed along the specified dimension(s). Parameters ---------- **indexers : {dim: indexer, ...} Keyword arguments with names matching dimensions and values given by integers, sli...
def isel(self, indexers=None, drop=False, **indexers_kwargs): """Return a new array indexed along the specified dimension(s). Parameters ---------- **indexers : {dim: indexer, ...} Keyword arguments with names matching dimensions and values given by integers, sli...
[ "Return", "a", "new", "array", "indexed", "along", "the", "specified", "dimension", "(", "s", ")", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L900-L927
[ "def", "isel", "(", "self", ",", "indexers", "=", "None", ",", "drop", "=", "False", ",", "*", "*", "indexers_kwargs", ")", ":", "indexers", "=", "either_dict_or_kwargs", "(", "indexers", ",", "indexers_kwargs", ",", "'isel'", ")", "invalid", "=", "[", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.squeeze
Return a new object with squeezed data. Parameters ---------- dim : None or str or tuple of str, optional Selects a subset of the length one dimensions. If a dimension is selected with length greater than one, an error is raised. If None, all length one dimen...
xarray/core/variable.py
def squeeze(self, dim=None): """Return a new object with squeezed data. Parameters ---------- dim : None or str or tuple of str, optional Selects a subset of the length one dimensions. If a dimension is selected with length greater than one, an error is raised. I...
def squeeze(self, dim=None): """Return a new object with squeezed data. Parameters ---------- dim : None or str or tuple of str, optional Selects a subset of the length one dimensions. If a dimension is selected with length greater than one, an error is raised. I...
[ "Return", "a", "new", "object", "with", "squeezed", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L929-L950
[ "def", "squeeze", "(", "self", ",", "dim", "=", "None", ")", ":", "dims", "=", "common", ".", "get_squeeze_dims", "(", "self", ",", "dim", ")", "return", "self", ".", "isel", "(", "{", "d", ":", "0", "for", "d", "in", "dims", "}", ")" ]
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.shift
Return a new Variable with shifted data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to shift along each of the given dimensions. Positive offsets shift to the right; negative offsets shift to the left. fill_value: ...
xarray/core/variable.py
def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs): """ Return a new Variable with shifted data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to shift along each of the given dimensions. Positive offsets...
def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs): """ Return a new Variable with shifted data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to shift along each of the given dimensions. Positive offsets...
[ "Return", "a", "new", "Variable", "with", "shifted", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L996-L1021
[ "def", "shift", "(", "self", ",", "shifts", "=", "None", ",", "fill_value", "=", "dtypes", ".", "NA", ",", "*", "*", "shifts_kwargs", ")", ":", "shifts", "=", "either_dict_or_kwargs", "(", "shifts", ",", "shifts_kwargs", ",", "'shift'", ")", "result", "=...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.pad_with_fill_value
Return a new Variable with paddings. Parameters ---------- pad_width: Mapping of the form {dim: (before, after)} Number of values padded to the edges of each dimension. **pad_widths_kwargs: Keyword argument for pad_widths
xarray/core/variable.py
def pad_with_fill_value(self, pad_widths=None, fill_value=dtypes.NA, **pad_widths_kwargs): """ Return a new Variable with paddings. Parameters ---------- pad_width: Mapping of the form {dim: (before, after)} Number of values padded to the ...
def pad_with_fill_value(self, pad_widths=None, fill_value=dtypes.NA, **pad_widths_kwargs): """ Return a new Variable with paddings. Parameters ---------- pad_width: Mapping of the form {dim: (before, after)} Number of values padded to the ...
[ "Return", "a", "new", "Variable", "with", "paddings", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1023-L1074
[ "def", "pad_with_fill_value", "(", "self", ",", "pad_widths", "=", "None", ",", "fill_value", "=", "dtypes", ".", "NA", ",", "*", "*", "pad_widths_kwargs", ")", ":", "pad_widths", "=", "either_dict_or_kwargs", "(", "pad_widths", ",", "pad_widths_kwargs", ",", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.roll
Return a new Variable with rolld data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to roll along each of the given dimensions. Positive offsets roll to the right; negative offsets roll to the left. **shifts_kwargs: ...
xarray/core/variable.py
def roll(self, shifts=None, **shifts_kwargs): """ Return a new Variable with rolld data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to roll along each of the given dimensions. Positive offsets roll to the right; negati...
def roll(self, shifts=None, **shifts_kwargs): """ Return a new Variable with rolld data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to roll along each of the given dimensions. Positive offsets roll to the right; negati...
[ "Return", "a", "new", "Variable", "with", "rolld", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1098-L1122
[ "def", "roll", "(", "self", ",", "shifts", "=", "None", ",", "*", "*", "shifts_kwargs", ")", ":", "shifts", "=", "either_dict_or_kwargs", "(", "shifts", ",", "shifts_kwargs", ",", "'roll'", ")", "result", "=", "self", "for", "dim", ",", "count", "in", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.transpose
Return a new Variable object with transposed dimensions. Parameters ---------- *dims : str, optional By default, reverse the dimensions. Otherwise, reorder the dimensions to this order. Returns ------- transposed : Variable The return...
xarray/core/variable.py
def transpose(self, *dims) -> 'Variable': """Return a new Variable object with transposed dimensions. Parameters ---------- *dims : str, optional By default, reverse the dimensions. Otherwise, reorder the dimensions to this order. Returns -------...
def transpose(self, *dims) -> 'Variable': """Return a new Variable object with transposed dimensions. Parameters ---------- *dims : str, optional By default, reverse the dimensions. Otherwise, reorder the dimensions to this order. Returns -------...
[ "Return", "a", "new", "Variable", "object", "with", "transposed", "dimensions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1124-L1156
[ "def", "transpose", "(", "self", ",", "*", "dims", ")", "->", "'Variable'", ":", "if", "len", "(", "dims", ")", "==", "0", ":", "dims", "=", "self", ".", "dims", "[", ":", ":", "-", "1", "]", "axes", "=", "self", ".", "get_axis_num", "(", "dims...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.set_dims
Return a new variable with given set of dimensions. This method might be used to attach new dimension(s) to variable. When possible, this operation does not copy this variable's data. Parameters ---------- dims : str or sequence of str or dict Dimensions to include ...
xarray/core/variable.py
def set_dims(self, dims, shape=None): """Return a new variable with given set of dimensions. This method might be used to attach new dimension(s) to variable. When possible, this operation does not copy this variable's data. Parameters ---------- dims : str or sequence ...
def set_dims(self, dims, shape=None): """Return a new variable with given set of dimensions. This method might be used to attach new dimension(s) to variable. When possible, this operation does not copy this variable's data. Parameters ---------- dims : str or sequence ...
[ "Return", "a", "new", "variable", "with", "given", "set", "of", "dimensions", ".", "This", "method", "might", "be", "used", "to", "attach", "new", "dimension", "(", "s", ")", "to", "variable", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1169-L1215
[ "def", "set_dims", "(", "self", ",", "dims", ",", "shape", "=", "None", ")", ":", "if", "isinstance", "(", "dims", ",", "str", ")", ":", "dims", "=", "[", "dims", "]", "if", "shape", "is", "None", "and", "utils", ".", "is_dict_like", "(", "dims", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.stack
Stack any number of existing dimensions into a single new dimension. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ---------- dimensions : Mapping of form new_name=(dim1, dim2, ...) ...
xarray/core/variable.py
def stack(self, dimensions=None, **dimensions_kwargs): """ Stack any number of existing dimensions into a single new dimension. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ------...
def stack(self, dimensions=None, **dimensions_kwargs): """ Stack any number of existing dimensions into a single new dimension. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ------...
[ "Stack", "any", "number", "of", "existing", "dimensions", "into", "a", "single", "new", "dimension", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1240-L1270
[ "def", "stack", "(", "self", ",", "dimensions", "=", "None", ",", "*", "*", "dimensions_kwargs", ")", ":", "dimensions", "=", "either_dict_or_kwargs", "(", "dimensions", ",", "dimensions_kwargs", ",", "'stack'", ")", "result", "=", "self", "for", "new_dim", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.unstack
Unstack an existing dimension into multiple new dimensions. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ---------- dimensions : mapping of the form old_dim={dim1: size1, ...} ...
xarray/core/variable.py
def unstack(self, dimensions=None, **dimensions_kwargs): """ Unstack an existing dimension into multiple new dimensions. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ---------- ...
def unstack(self, dimensions=None, **dimensions_kwargs): """ Unstack an existing dimension into multiple new dimensions. New dimensions will be added at the end, and the order of the data along each new dimension will be in contiguous (C) order. Parameters ---------- ...
[ "Unstack", "an", "existing", "dimension", "into", "multiple", "new", "dimensions", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1298-L1328
[ "def", "unstack", "(", "self", ",", "dimensions", "=", "None", ",", "*", "*", "dimensions_kwargs", ")", ":", "dimensions", "=", "either_dict_or_kwargs", "(", "dimensions", ",", "dimensions_kwargs", ",", "'unstack'", ")", "result", "=", "self", "for", "old_dim"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.reduce
Reduce this array 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 reducing an np.ndarray over an integer valued axis. dim...
xarray/core/variable.py
def reduce(self, func, dim=None, axis=None, keep_attrs=None, allow_lazy=False, **kwargs): """Reduce this array by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=...
def reduce(self, func, dim=None, axis=None, keep_attrs=None, allow_lazy=False, **kwargs): """Reduce this array by applying `func` along some dimension(s). Parameters ---------- func : function Function which can be called in the form `func(x, axis=...
[ "Reduce", "this", "array", "by", "applying", "func", "along", "some", "dimension", "(", "s", ")", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1336-L1391
[ "def", "reduce", "(", "self", ",", "func", ",", "dim", "=", "None", ",", "axis", "=", "None", ",", "keep_attrs", "=", "None", ",", "allow_lazy", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "dim", "is", "common", ".", "ALL_DIMS", ":", "...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.concat
Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have matching dimensions and shape except for along the stacked dimension. dim : str or...
xarray/core/variable.py
def concat(cls, variables, dim='concat_dim', positions=None, shortcut=False): """Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have ...
def concat(cls, variables, dim='concat_dim', positions=None, shortcut=False): """Concatenate variables along a new or existing dimension. Parameters ---------- variables : iterable of Array Arrays to stack together. Each variable is expected to have ...
[ "Concatenate", "variables", "along", "a", "new", "or", "existing", "dimension", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1394-L1458
[ "def", "concat", "(", "cls", ",", "variables", ",", "dim", "=", "'concat_dim'", ",", "positions", "=", "None", ",", "shortcut", "=", "False", ")", ":", "if", "not", "isinstance", "(", "dim", ",", "str", ")", ":", "dim", ",", "=", "dim", ".", "dims"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.equals
True if two Variables have the same dimensions and values; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations. This method is necessary because `v1 == v2` for Variables does element-wise comparisons (like numpy.ndar...
xarray/core/variable.py
def equals(self, other, equiv=duck_array_ops.array_equiv): """True if two Variables have the same dimensions and values; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations. This method is necessary because `v1 == v2...
def equals(self, other, equiv=duck_array_ops.array_equiv): """True if two Variables have the same dimensions and values; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations. This method is necessary because `v1 == v2...
[ "True", "if", "two", "Variables", "have", "the", "same", "dimensions", "and", "values", ";", "otherwise", "False", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1460-L1476
[ "def", "equals", "(", "self", ",", "other", ",", "equiv", "=", "duck_array_ops", ".", "array_equiv", ")", ":", "other", "=", "getattr", "(", "other", ",", "'variable'", ",", "other", ")", "try", ":", "return", "(", "self", ".", "dims", "==", "other", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.broadcast_equals
True if two Variables have the values after being broadcast against each other; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations.
xarray/core/variable.py
def broadcast_equals(self, other, equiv=duck_array_ops.array_equiv): """True if two Variables have the values after being broadcast against each other; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations. """ ...
def broadcast_equals(self, other, equiv=duck_array_ops.array_equiv): """True if two Variables have the values after being broadcast against each other; otherwise False. Variables can still be equal (like pandas objects) if they have NaN values in the same locations. """ ...
[ "True", "if", "two", "Variables", "have", "the", "values", "after", "being", "broadcast", "against", "each", "other", ";", "otherwise", "False", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1478-L1489
[ "def", "broadcast_equals", "(", "self", ",", "other", ",", "equiv", "=", "duck_array_ops", ".", "array_equiv", ")", ":", "try", ":", "self", ",", "other", "=", "broadcast_variables", "(", "self", ",", "other", ")", "except", "(", "ValueError", ",", "Attrib...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.identical
Like equals, but also checks attributes.
xarray/core/variable.py
def identical(self, other): """Like equals, but also checks attributes. """ try: return (utils.dict_equiv(self.attrs, other.attrs) and self.equals(other)) except (TypeError, AttributeError): return False
def identical(self, other): """Like equals, but also checks attributes. """ try: return (utils.dict_equiv(self.attrs, other.attrs) and self.equals(other)) except (TypeError, AttributeError): return False
[ "Like", "equals", "but", "also", "checks", "attributes", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1491-L1498
[ "def", "identical", "(", "self", ",", "other", ")", ":", "try", ":", "return", "(", "utils", ".", "dict_equiv", "(", "self", ".", "attrs", ",", "other", ".", "attrs", ")", "and", "self", ".", "equals", "(", "other", ")", ")", "except", "(", "TypeEr...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.quantile
Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) Quantile to compute, which must be between 0 and 1 inclusive. ...
xarray/core/variable.py
def quantile(self, q, dim=None, interpolation='linear'): """Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) Quantile to ...
def quantile(self, q, dim=None, interpolation='linear'): """Compute the qth quantile of the data along the specified dimension. Returns the qth quantiles(s) of the array elements. Parameters ---------- q : float in range of [0,1] (or sequence of floats) Quantile to ...
[ "Compute", "the", "qth", "quantile", "of", "the", "data", "along", "the", "specified", "dimension", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1510-L1573
[ "def", "quantile", "(", "self", ",", "q", ",", "dim", "=", "None", ",", "interpolation", "=", "'linear'", ")", ":", "if", "isinstance", "(", "self", ".", "data", ",", "dask_array_type", ")", ":", "raise", "TypeError", "(", "\"quantile does not work for array...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.rank
Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If `pct`, computes percentage ranks. NaNs in the input array are returned as NaNs. The `bot...
xarray/core/variable.py
def rank(self, dim, pct=False): """Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If `pct`, computes percentage ranks. NaNs in the input ar...
def rank(self, dim, pct=False): """Ranks the data. Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1, not 0. If `pct`, computes percentage ranks. NaNs in the input ar...
[ "Ranks", "the", "data", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1575-L1614
[ "def", "rank", "(", "self", ",", "dim", ",", "pct", "=", "False", ")", ":", "import", "bottleneck", "as", "bn", "if", "isinstance", "(", "self", ".", "data", ",", "dask_array_type", ")", ":", "raise", "TypeError", "(", "\"rank does not work for arrays stored...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.rolling_window
Make a rolling_window along dim and add a new_dim to the last place. Parameters ---------- dim: str Dimension over which to compute rolling_window window: int Window size of the rolling window_dim: str New name of the window dimension. ...
xarray/core/variable.py
def rolling_window(self, dim, window, window_dim, center=False, fill_value=dtypes.NA): """ Make a rolling_window along dim and add a new_dim to the last place. Parameters ---------- dim: str Dimension over which to compute rolling_window ...
def rolling_window(self, dim, window, window_dim, center=False, fill_value=dtypes.NA): """ Make a rolling_window along dim and add a new_dim to the last place. Parameters ---------- dim: str Dimension over which to compute rolling_window ...
[ "Make", "a", "rolling_window", "along", "dim", "and", "add", "a", "new_dim", "to", "the", "last", "place", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1616-L1665
[ "def", "rolling_window", "(", "self", ",", "dim", ",", "window", ",", "window_dim", ",", "center", "=", "False", ",", "fill_value", "=", "dtypes", ".", "NA", ")", ":", "if", "fill_value", "is", "dtypes", ".", "NA", ":", "# np.nan is passed", "dtype", ","...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable.coarsen
Apply
xarray/core/variable.py
def coarsen(self, windows, func, boundary='exact', side='left'): """ Apply """ windows = {k: v for k, v in windows.items() if k in self.dims} if not windows: return self.copy() reshaped, axes = self._coarsen_reshape(windows, boundary, side) if isinsta...
def coarsen(self, windows, func, boundary='exact', side='left'): """ Apply """ windows = {k: v for k, v in windows.items() if k in self.dims} if not windows: return self.copy() reshaped, axes = self._coarsen_reshape(windows, boundary, side) if isinsta...
[ "Apply" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1667-L1681
[ "def", "coarsen", "(", "self", ",", "windows", ",", "func", ",", "boundary", "=", "'exact'", ",", "side", "=", "'left'", ")", ":", "windows", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "windows", ".", "items", "(", ")", "if", "k", "in...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._coarsen_reshape
Construct a reshaped-array for corsen
xarray/core/variable.py
def _coarsen_reshape(self, windows, boundary, side): """ Construct a reshaped-array for corsen """ if not utils.is_dict_like(boundary): boundary = {d: boundary for d in windows.keys()} if not utils.is_dict_like(side): side = {d: side for d in windows.keys...
def _coarsen_reshape(self, windows, boundary, side): """ Construct a reshaped-array for corsen """ if not utils.is_dict_like(boundary): boundary = {d: boundary for d in windows.keys()} if not utils.is_dict_like(side): side = {d: side for d in windows.keys...
[ "Construct", "a", "reshaped", "-", "array", "for", "corsen" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1683-L1744
[ "def", "_coarsen_reshape", "(", "self", ",", "windows", ",", "boundary", ",", "side", ")", ":", "if", "not", "utils", ".", "is_dict_like", "(", "boundary", ")", ":", "boundary", "=", "{", "d", ":", "boundary", "for", "d", "in", "windows", ".", "keys", ...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
Variable._to_numeric
A (private) method to convert datetime array to numeric dtype See duck_array_ops.datetime_to_numeric
xarray/core/variable.py
def _to_numeric(self, offset=None, datetime_unit=None, dtype=float): """ A (private) method to convert datetime array to numeric dtype See duck_array_ops.datetime_to_numeric """ numeric_array = duck_array_ops.datetime_to_numeric( self.data, offset, datetime_unit, dtype) ...
def _to_numeric(self, offset=None, datetime_unit=None, dtype=float): """ A (private) method to convert datetime array to numeric dtype See duck_array_ops.datetime_to_numeric """ numeric_array = duck_array_ops.datetime_to_numeric( self.data, offset, datetime_unit, dtype) ...
[ "A", "(", "private", ")", "method", "to", "convert", "datetime", "array", "to", "numeric", "dtype", "See", "duck_array_ops", ".", "datetime_to_numeric" ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1797-L1803
[ "def", "_to_numeric", "(", "self", ",", "offset", "=", "None", ",", "datetime_unit", "=", "None", ",", "dtype", "=", "float", ")", ":", "numeric_array", "=", "duck_array_ops", ".", "datetime_to_numeric", "(", "self", ".", "data", ",", "offset", ",", "datet...
6d93a95d05bdbfc33fff24064f67d29dd891ab58
train
IndexVariable.concat
Specialized version of Variable.concat for IndexVariable objects. This exists because we want to avoid converting Index objects to NumPy arrays, if possible.
xarray/core/variable.py
def concat(cls, variables, dim='concat_dim', positions=None, shortcut=False): """Specialized version of Variable.concat for IndexVariable objects. This exists because we want to avoid converting Index objects to NumPy arrays, if possible. """ if not isinstance(dim...
def concat(cls, variables, dim='concat_dim', positions=None, shortcut=False): """Specialized version of Variable.concat for IndexVariable objects. This exists because we want to avoid converting Index objects to NumPy arrays, if possible. """ if not isinstance(dim...
[ "Specialized", "version", "of", "Variable", ".", "concat", "for", "IndexVariable", "objects", "." ]
pydata/xarray
python
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/variable.py#L1858-L1894
[ "def", "concat", "(", "cls", ",", "variables", ",", "dim", "=", "'concat_dim'", ",", "positions", "=", "None", ",", "shortcut", "=", "False", ")", ":", "if", "not", "isinstance", "(", "dim", ",", "str", ")", ":", "dim", ",", "=", "dim", ".", "dims"...
6d93a95d05bdbfc33fff24064f67d29dd891ab58