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 | exact_cftime_datetime_difference | Exact computation of b - a
Assumes:
a = a_0 + a_m
b = b_0 + b_m
Here a_0, and b_0 represent the input dates rounded
down to the nearest second, and a_m, and b_m represent
the remaining microseconds associated with date a and
date b.
We can then express the value of b - a as:
... | xarray/core/resample_cftime.py | def exact_cftime_datetime_difference(a, b):
"""Exact computation of b - a
Assumes:
a = a_0 + a_m
b = b_0 + b_m
Here a_0, and b_0 represent the input dates rounded
down to the nearest second, and a_m, and b_m represent
the remaining microseconds associated with date a and
date ... | def exact_cftime_datetime_difference(a, b):
"""Exact computation of b - a
Assumes:
a = a_0 + a_m
b = b_0 + b_m
Here a_0, and b_0 represent the input dates rounded
down to the nearest second, and a_m, and b_m represent
the remaining microseconds associated with date a and
date ... | [
"Exact",
"computation",
"of",
"b",
"-",
"a"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/resample_cftime.py#L326-L363 | [
"def",
"exact_cftime_datetime_difference",
"(",
"a",
",",
"b",
")",
":",
"seconds",
"=",
"b",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
"-",
"a",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
"seconds",
"=",
"int",
"(",
"round",
"(",
"s... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | CFTimeGrouper.first_items | Meant to reproduce the results of the following
grouper = pandas.Grouper(...)
first_items = pd.Series(np.arange(len(index)),
index).groupby(grouper).first()
with index being a CFTimeIndex instead of a DatetimeIndex. | xarray/core/resample_cftime.py | def first_items(self, index):
"""Meant to reproduce the results of the following
grouper = pandas.Grouper(...)
first_items = pd.Series(np.arange(len(index)),
index).groupby(grouper).first()
with index being a CFTimeIndex instead of a DatetimeIndex.
... | def first_items(self, index):
"""Meant to reproduce the results of the following
grouper = pandas.Grouper(...)
first_items = pd.Series(np.arange(len(index)),
index).groupby(grouper).first()
with index being a CFTimeIndex instead of a DatetimeIndex.
... | [
"Meant",
"to",
"reproduce",
"the",
"results",
"of",
"the",
"following"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/resample_cftime.py#L71-L101 | [
"def",
"first_items",
"(",
"self",
",",
"index",
")",
":",
"datetime_bins",
",",
"labels",
"=",
"_get_time_bins",
"(",
"index",
",",
"self",
".",
"freq",
",",
"self",
".",
"closed",
",",
"self",
".",
"label",
",",
"self",
".",
"base",
")",
"if",
"sel... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | align | align(*objects, join='inner', copy=True, indexes=None,
exclude=frozenset())
Given any number of Dataset and/or DataArray objects, returns new
objects with aligned indexes and dimension sizes.
Array from the aligned objects are suitable as input to mathematical
operators, because along eac... | xarray/core/alignment.py | def align(*objects, **kwargs):
"""align(*objects, join='inner', copy=True, indexes=None,
exclude=frozenset())
Given any number of Dataset and/or DataArray objects, returns new
objects with aligned indexes and dimension sizes.
Array from the aligned objects are suitable as input to mathema... | def align(*objects, **kwargs):
"""align(*objects, join='inner', copy=True, indexes=None,
exclude=frozenset())
Given any number of Dataset and/or DataArray objects, returns new
objects with aligned indexes and dimension sizes.
Array from the aligned objects are suitable as input to mathema... | [
"align",
"(",
"*",
"objects",
"join",
"=",
"inner",
"copy",
"=",
"True",
"indexes",
"=",
"None",
"exclude",
"=",
"frozenset",
"()",
")"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/alignment.py#L37-L169 | [
"def",
"align",
"(",
"*",
"objects",
",",
"*",
"*",
"kwargs",
")",
":",
"join",
"=",
"kwargs",
".",
"pop",
"(",
"'join'",
",",
"'inner'",
")",
"copy",
"=",
"kwargs",
".",
"pop",
"(",
"'copy'",
",",
"True",
")",
"indexes",
"=",
"kwargs",
".",
"pop... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | deep_align | Align objects for merging, recursing into dictionary values.
This function is not public API. | xarray/core/alignment.py | def deep_align(objects, join='inner', copy=True, indexes=None,
exclude=frozenset(), raise_on_invalid=True):
"""Align objects for merging, recursing into dictionary values.
This function is not public API.
"""
from .dataarray import DataArray
from .dataset import Dataset
if index... | def deep_align(objects, join='inner', copy=True, indexes=None,
exclude=frozenset(), raise_on_invalid=True):
"""Align objects for merging, recursing into dictionary values.
This function is not public API.
"""
from .dataarray import DataArray
from .dataset import Dataset
if index... | [
"Align",
"objects",
"for",
"merging",
"recursing",
"into",
"dictionary",
"values",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/alignment.py#L172-L228 | [
"def",
"deep_align",
"(",
"objects",
",",
"join",
"=",
"'inner'",
",",
"copy",
"=",
"True",
",",
"indexes",
"=",
"None",
",",
"exclude",
"=",
"frozenset",
"(",
")",
",",
"raise_on_invalid",
"=",
"True",
")",
":",
"from",
".",
"dataarray",
"import",
"Da... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | reindex_like_indexers | Extract indexers to align target with other.
Not public API.
Parameters
----------
target : Dataset or DataArray
Object to be aligned.
other : Dataset or DataArray
Object to be aligned with.
Returns
-------
Dict[Any, pandas.Index] providing indexes for reindex keyword ... | xarray/core/alignment.py | def reindex_like_indexers(target, other):
"""Extract indexers to align target with other.
Not public API.
Parameters
----------
target : Dataset or DataArray
Object to be aligned.
other : Dataset or DataArray
Object to be aligned with.
Returns
-------
Dict[Any, pan... | def reindex_like_indexers(target, other):
"""Extract indexers to align target with other.
Not public API.
Parameters
----------
target : Dataset or DataArray
Object to be aligned.
other : Dataset or DataArray
Object to be aligned with.
Returns
-------
Dict[Any, pan... | [
"Extract",
"indexers",
"to",
"align",
"target",
"with",
"other",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/alignment.py#L231-L262 | [
"def",
"reindex_like_indexers",
"(",
"target",
",",
"other",
")",
":",
"indexers",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"other",
".",
"indexes",
".",
"items",
"(",
")",
"if",
"k",
"in",
"target",
".",
"dims",
"}",
"for",
"dim",
"i... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | reindex_variables | Conform a dictionary of aligned variables onto a new set of variables,
filling in missing values with NaN.
Not public API.
Parameters
----------
variables : dict-like
Dictionary of xarray.Variable objects.
sizes : dict-like
Dictionary from dimension names to integer sizes.
... | xarray/core/alignment.py | def reindex_variables(
variables: Mapping[Any, Variable],
sizes: Mapping[Any, int],
indexes: Mapping[Any, pd.Index],
indexers: Mapping,
method: Optional[str] = None,
tolerance: Any = None,
copy: bool = True,
) -> 'Tuple[OrderedDict[Any, Variable], OrderedDict[Any, pd.Index]]':
"""Conform... | def reindex_variables(
variables: Mapping[Any, Variable],
sizes: Mapping[Any, int],
indexes: Mapping[Any, pd.Index],
indexers: Mapping,
method: Optional[str] = None,
tolerance: Any = None,
copy: bool = True,
) -> 'Tuple[OrderedDict[Any, Variable], OrderedDict[Any, pd.Index]]':
"""Conform... | [
"Conform",
"a",
"dictionary",
"of",
"aligned",
"variables",
"onto",
"a",
"new",
"set",
"of",
"variables",
"filling",
"in",
"missing",
"values",
"with",
"NaN",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/alignment.py#L265-L394 | [
"def",
"reindex_variables",
"(",
"variables",
":",
"Mapping",
"[",
"Any",
",",
"Variable",
"]",
",",
"sizes",
":",
"Mapping",
"[",
"Any",
",",
"int",
"]",
",",
"indexes",
":",
"Mapping",
"[",
"Any",
",",
"pd",
".",
"Index",
"]",
",",
"indexers",
":",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | broadcast | Explicitly broadcast any number of DataArray or Dataset objects against
one another.
xarray objects automatically broadcast against each other in arithmetic
operations, so this function should not be necessary for normal use.
If no change is needed, the input data is returned to the output without
... | xarray/core/alignment.py | def broadcast(*args, **kwargs):
"""Explicitly broadcast any number of DataArray or Dataset objects against
one another.
xarray objects automatically broadcast against each other in arithmetic
operations, so this function should not be necessary for normal use.
If no change is needed, the input dat... | def broadcast(*args, **kwargs):
"""Explicitly broadcast any number of DataArray or Dataset objects against
one another.
xarray objects automatically broadcast against each other in arithmetic
operations, so this function should not be necessary for normal use.
If no change is needed, the input dat... | [
"Explicitly",
"broadcast",
"any",
"number",
"of",
"DataArray",
"or",
"Dataset",
"objects",
"against",
"one",
"another",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/alignment.py#L397-L524 | [
"def",
"broadcast",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
"import",
"Dataset",
"exclude",
"=",
"kwargs",
".",
"pop",
"(",
"'exclude'",
",",
"None",
")",
"if",
"excl... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | assert_coordinate_consistent | Maeke sure the dimension coordinate of obj is
consistent with coords.
obj: DataArray or Dataset
coords: Dict-like of variables | xarray/core/coordinates.py | def assert_coordinate_consistent(obj, coords):
""" Maeke sure the dimension coordinate of obj is
consistent with coords.
obj: DataArray or Dataset
coords: Dict-like of variables
"""
for k in obj.dims:
# make sure there are no conflict in dimension coordinates
if k in coords and ... | def assert_coordinate_consistent(obj, coords):
""" Maeke sure the dimension coordinate of obj is
consistent with coords.
obj: DataArray or Dataset
coords: Dict-like of variables
"""
for k in obj.dims:
# make sure there are no conflict in dimension coordinates
if k in coords and ... | [
"Maeke",
"sure",
"the",
"dimension",
"coordinate",
"of",
"obj",
"is",
"consistent",
"with",
"coords",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L279-L293 | [
"def",
"assert_coordinate_consistent",
"(",
"obj",
",",
"coords",
")",
":",
"for",
"k",
"in",
"obj",
".",
"dims",
":",
"# make sure there are no conflict in dimension coordinates",
"if",
"k",
"in",
"coords",
"and",
"k",
"in",
"obj",
".",
"coords",
":",
"if",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | remap_label_indexers | Remap **indexers from obj.coords.
If indexer is an instance of DataArray and it has coordinate, then this
coordinate will be attached to pos_indexers.
Returns
-------
pos_indexers: Same type of indexers.
np.ndarray or Variable or DataArra
new_indexes: mapping of new dimensional-coordina... | xarray/core/coordinates.py | def remap_label_indexers(obj, indexers=None, method=None, tolerance=None,
**indexers_kwargs):
"""
Remap **indexers from obj.coords.
If indexer is an instance of DataArray and it has coordinate, then this
coordinate will be attached to pos_indexers.
Returns
-------
p... | def remap_label_indexers(obj, indexers=None, method=None, tolerance=None,
**indexers_kwargs):
"""
Remap **indexers from obj.coords.
If indexer is an instance of DataArray and it has coordinate, then this
coordinate will be attached to pos_indexers.
Returns
-------
p... | [
"Remap",
"**",
"indexers",
"from",
"obj",
".",
"coords",
".",
"If",
"indexer",
"is",
"an",
"instance",
"of",
"DataArray",
"and",
"it",
"has",
"coordinate",
"then",
"this",
"coordinate",
"will",
"be",
"attached",
"to",
"pos_indexers",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L296-L330 | [
"def",
"remap_label_indexers",
"(",
"obj",
",",
"indexers",
"=",
"None",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"*",
"*",
"indexers_kwargs",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"indexers",
"=",
"either_dict_or_... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractCoordinates.to_index | Convert all index coordinates into a :py:class:`pandas.Index`.
Parameters
----------
ordered_dims : sequence, optional
Possibly reordered version of this object's dimensions indicating
the order in which dimensions should appear on the result.
Returns
--... | xarray/core/coordinates.py | def to_index(self, ordered_dims=None):
"""Convert all index coordinates into a :py:class:`pandas.Index`.
Parameters
----------
ordered_dims : sequence, optional
Possibly reordered version of this object's dimensions indicating
the order in which dimensions should... | def to_index(self, ordered_dims=None):
"""Convert all index coordinates into a :py:class:`pandas.Index`.
Parameters
----------
ordered_dims : sequence, optional
Possibly reordered version of this object's dimensions indicating
the order in which dimensions should... | [
"Convert",
"all",
"index",
"coordinates",
"into",
"a",
":",
"py",
":",
"class",
":",
"pandas",
".",
"Index",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L55-L85 | [
"def",
"to_index",
"(",
"self",
",",
"ordered_dims",
"=",
"None",
")",
":",
"if",
"ordered_dims",
"is",
"None",
":",
"ordered_dims",
"=",
"self",
".",
"dims",
"elif",
"set",
"(",
"ordered_dims",
")",
"!=",
"set",
"(",
"self",
".",
"dims",
")",
":",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractCoordinates._merge_raw | For use with binary arithmetic. | xarray/core/coordinates.py | def _merge_raw(self, other):
"""For use with binary arithmetic."""
if other is None:
variables = OrderedDict(self.variables)
else:
# don't align because we already called xarray.align
variables = expand_and_merge_variables(
[self.variables, oth... | def _merge_raw(self, other):
"""For use with binary arithmetic."""
if other is None:
variables = OrderedDict(self.variables)
else:
# don't align because we already called xarray.align
variables = expand_and_merge_variables(
[self.variables, oth... | [
"For",
"use",
"with",
"binary",
"arithmetic",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L93-L101 | [
"def",
"_merge_raw",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"None",
":",
"variables",
"=",
"OrderedDict",
"(",
"self",
".",
"variables",
")",
"else",
":",
"# don't align because we already called xarray.align",
"variables",
"=",
"expand_and_merg... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractCoordinates._merge_inplace | For use with in-place binary arithmetic. | xarray/core/coordinates.py | def _merge_inplace(self, other):
"""For use with in-place binary arithmetic."""
if other is None:
yield
else:
# don't include indexes in priority_vars, because we didn't align
# first
priority_vars = OrderedDict(
kv for kv in self.v... | def _merge_inplace(self, other):
"""For use with in-place binary arithmetic."""
if other is None:
yield
else:
# don't include indexes in priority_vars, because we didn't align
# first
priority_vars = OrderedDict(
kv for kv in self.v... | [
"For",
"use",
"with",
"in",
"-",
"place",
"binary",
"arithmetic",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L104-L116 | [
"def",
"_merge_inplace",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"None",
":",
"yield",
"else",
":",
"# don't include indexes in priority_vars, because we didn't align",
"# first",
"priority_vars",
"=",
"OrderedDict",
"(",
"kv",
"for",
"kv",
"in",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractCoordinates.merge | Merge two sets of coordinates to create a new Dataset
The method implements the logic used for joining coordinates in the
result of a binary operation performed on xarray objects:
- If two index coordinates conflict (are not equal), an exception is
raised. You must align your data be... | xarray/core/coordinates.py | def merge(self, other):
"""Merge two sets of coordinates to create a new Dataset
The method implements the logic used for joining coordinates in the
result of a binary operation performed on xarray objects:
- If two index coordinates conflict (are not equal), an exception is
... | def merge(self, other):
"""Merge two sets of coordinates to create a new Dataset
The method implements the logic used for joining coordinates in the
result of a binary operation performed on xarray objects:
- If two index coordinates conflict (are not equal), an exception is
... | [
"Merge",
"two",
"sets",
"of",
"coordinates",
"to",
"create",
"a",
"new",
"Dataset"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L118-L147 | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"if",
"other",
"is",
"None",
":",
"return",
"self",
".",
"to_dataset",
"(",
")",
"else",
":",
"other_vars",
"=",
"getattr",
"(",
"other",
",",
"'variables... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DatasetCoordinates._ipython_key_completions_ | Provide method for the key-autocompletions in IPython. | xarray/core/coordinates.py | def _ipython_key_completions_(self):
"""Provide method for the key-autocompletions in IPython. """
return [key for key in self._data._ipython_key_completions_()
if key not in self._data.data_vars] | def _ipython_key_completions_(self):
"""Provide method for the key-autocompletions in IPython. """
return [key for key in self._data._ipython_key_completions_()
if key not in self._data.data_vars] | [
"Provide",
"method",
"for",
"the",
"key",
"-",
"autocompletions",
"in",
"IPython",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/coordinates.py#L205-L208 | [
"def",
"_ipython_key_completions_",
"(",
"self",
")",
":",
"return",
"[",
"key",
"for",
"key",
"in",
"self",
".",
"_data",
".",
"_ipython_key_completions_",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_data",
".",
"data_vars",
"]"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | dask_rolling_wrapper | wrapper to apply bottleneck moving window funcs on dask arrays | xarray/core/dask_array_ops.py | def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1):
'''wrapper to apply bottleneck moving window funcs on dask arrays'''
dtype, fill_value = dtypes.maybe_promote(a.dtype)
a = a.astype(dtype)
# inputs for overlap
if axis < 0:
axis = a.ndim + axis
depth = {d: 0 for d... | def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1):
'''wrapper to apply bottleneck moving window funcs on dask arrays'''
dtype, fill_value = dtypes.maybe_promote(a.dtype)
a = a.astype(dtype)
# inputs for overlap
if axis < 0:
axis = a.ndim + axis
depth = {d: 0 for d... | [
"wrapper",
"to",
"apply",
"bottleneck",
"moving",
"window",
"funcs",
"on",
"dask",
"arrays"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dask_array_ops.py#L21-L38 | [
"def",
"dask_rolling_wrapper",
"(",
"moving_func",
",",
"a",
",",
"window",
",",
"min_count",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"dtype",
",",
"fill_value",
"=",
"dtypes",
".",
"maybe_promote",
"(",
"a",
".",
"dtype",
")",
"a",
"=",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | rolling_window | Dask's equivalence to np.utils.rolling_window | xarray/core/dask_array_ops.py | def rolling_window(a, axis, window, center, fill_value):
""" Dask's equivalence to np.utils.rolling_window """
orig_shape = a.shape
if axis < 0:
axis = a.ndim + axis
depth = {d: 0 for d in range(a.ndim)}
depth[axis] = int(window / 2)
# For evenly sized window, we need to crop the first p... | def rolling_window(a, axis, window, center, fill_value):
""" Dask's equivalence to np.utils.rolling_window """
orig_shape = a.shape
if axis < 0:
axis = a.ndim + axis
depth = {d: 0 for d in range(a.ndim)}
depth[axis] = int(window / 2)
# For evenly sized window, we need to crop the first p... | [
"Dask",
"s",
"equivalence",
"to",
"np",
".",
"utils",
".",
"rolling_window"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dask_array_ops.py#L41-L104 | [
"def",
"rolling_window",
"(",
"a",
",",
"axis",
",",
"window",
",",
"center",
",",
"fill_value",
")",
":",
"orig_shape",
"=",
"a",
".",
"shape",
"if",
"axis",
"<",
"0",
":",
"axis",
"=",
"a",
".",
"ndim",
"+",
"axis",
"depth",
"=",
"{",
"d",
":",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _determine_zarr_chunks | Given encoding chunks (possibly None) and variable chunks (possibly None) | xarray/backends/zarr.py | def _determine_zarr_chunks(enc_chunks, var_chunks, ndim):
"""
Given encoding chunks (possibly None) and variable chunks (possibly None)
"""
# zarr chunk spec:
# chunks : int or tuple of ints, optional
# Chunk shape. If not provided, will be guessed from shape and dtype.
# if there are no... | def _determine_zarr_chunks(enc_chunks, var_chunks, ndim):
"""
Given encoding chunks (possibly None) and variable chunks (possibly None)
"""
# zarr chunk spec:
# chunks : int or tuple of ints, optional
# Chunk shape. If not provided, will be guessed from shape and dtype.
# if there are no... | [
"Given",
"encoding",
"chunks",
"(",
"possibly",
"None",
")",
"and",
"variable",
"chunks",
"(",
"possibly",
"None",
")"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/zarr.py#L59-L147 | [
"def",
"_determine_zarr_chunks",
"(",
"enc_chunks",
",",
"var_chunks",
",",
"ndim",
")",
":",
"# zarr chunk spec:",
"# chunks : int or tuple of ints, optional",
"# Chunk shape. If not provided, will be guessed from shape and dtype.",
"# if there are no chunks in encoding and the variable... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | encode_zarr_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/backends/zarr.py | def encode_zarr_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 ... | def encode_zarr_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 ... | [
"Converts",
"an",
"Variable",
"into",
"an",
"Variable",
"which",
"follows",
"some",
"of",
"the",
"CF",
"conventions",
":"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/zarr.py#L189-L219 | [
"def",
"encode_zarr_variable",
"(",
"var",
",",
"needs_copy",
"=",
"True",
",",
"name",
"=",
"None",
")",
":",
"var",
"=",
"conventions",
".",
"encode_cf_variable",
"(",
"var",
",",
"name",
"=",
"name",
")",
"# zarr allows unicode, but not variable-length strings,... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_zarr | Load and decode a dataset from a Zarr store.
.. note:: Experimental
The Zarr backend is new and experimental. Please report any
unexpected behavior via github issues.
The `store` object should be a valid store for a Zarr group. `store`
variables must contain dimension metadata ... | xarray/backends/zarr.py | def open_zarr(store, group=None, synchronizer=None, chunks='auto',
decode_cf=True, mask_and_scale=True, decode_times=True,
concat_characters=True, decode_coords=True,
drop_variables=None, consolidated=False,
overwrite_encoded_chunks=False, **kwargs):
"""Load a... | def open_zarr(store, group=None, synchronizer=None, chunks='auto',
decode_cf=True, mask_and_scale=True, decode_times=True,
concat_characters=True, decode_coords=True,
drop_variables=None, consolidated=False,
overwrite_encoded_chunks=False, **kwargs):
"""Load a... | [
"Load",
"and",
"decode",
"a",
"dataset",
"from",
"a",
"Zarr",
"store",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/zarr.py#L356-L533 | [
"def",
"open_zarr",
"(",
"store",
",",
"group",
"=",
"None",
",",
"synchronizer",
"=",
"None",
",",
"chunks",
"=",
"'auto'",
",",
"decode_cf",
"=",
"True",
",",
"mask_and_scale",
"=",
"True",
",",
"decode_times",
"=",
"True",
",",
"concat_characters",
"=",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | broadcast_dimension_size | Extract dimension sizes from a dictionary of variables.
Raises ValueError if any dimensions have different sizes. | xarray/core/merge.py | def broadcast_dimension_size(
variables: List[Variable],
) -> 'OrderedDict[Any, int]':
"""Extract dimension sizes from a dictionary of variables.
Raises ValueError if any dimensions have different sizes.
"""
dims = OrderedDict() # type: OrderedDict[Any, int]
for var in variables:
for d... | def broadcast_dimension_size(
variables: List[Variable],
) -> 'OrderedDict[Any, int]':
"""Extract dimension sizes from a dictionary of variables.
Raises ValueError if any dimensions have different sizes.
"""
dims = OrderedDict() # type: OrderedDict[Any, int]
for var in variables:
for d... | [
"Extract",
"dimension",
"sizes",
"from",
"a",
"dictionary",
"of",
"variables",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L26-L39 | [
"def",
"broadcast_dimension_size",
"(",
"variables",
":",
"List",
"[",
"Variable",
"]",
",",
")",
"->",
"'OrderedDict[Any, int]'",
":",
"dims",
"=",
"OrderedDict",
"(",
")",
"# type: OrderedDict[Any, int]",
"for",
"var",
"in",
"variables",
":",
"for",
"dim",
","... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | unique_variable | Return the unique variable from a list of variables or raise MergeError.
Parameters
----------
name : hashable
Name for this variable.
variables : list of xarray.Variable
List of Variable objects, all of which go by the same name in different
inputs.
compat : {'identical', '... | xarray/core/merge.py | def unique_variable(name, variables, compat='broadcast_equals'):
# type: (Any, List[Variable], str) -> Variable
"""Return the unique variable from a list of variables or raise MergeError.
Parameters
----------
name : hashable
Name for this variable.
variables : list of xarray.Variable
... | def unique_variable(name, variables, compat='broadcast_equals'):
# type: (Any, List[Variable], str) -> Variable
"""Return the unique variable from a list of variables or raise MergeError.
Parameters
----------
name : hashable
Name for this variable.
variables : list of xarray.Variable
... | [
"Return",
"the",
"unique",
"variable",
"from",
"a",
"list",
"of",
"variables",
"or",
"raise",
"MergeError",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L49-L96 | [
"def",
"unique_variable",
"(",
"name",
",",
"variables",
",",
"compat",
"=",
"'broadcast_equals'",
")",
":",
"# type: (Any, List[Variable], str) -> Variable",
"# noqa",
"out",
"=",
"variables",
"[",
"0",
"]",
"if",
"len",
"(",
"variables",
")",
">",
"1",
":",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge_variables | Merge dicts of variables, while resolving conflicts appropriately.
Parameters
----------
lists_of_variables_dicts : list of mappings with Variable values
List of mappings for which each value is a xarray.Variable object.
priority_vars : mapping with Variable or None values, optional
If ... | xarray/core/merge.py | def merge_variables(
list_of_variables_dicts, # type: List[Mapping[Any, Variable]]
priority_vars=None, # type: Optional[Mapping[Any, Variable]]
compat='minimal', # type: str
):
# type: (...) -> OrderedDict[Any, Variable]
"""Merge dicts of variables, while resolving conflic... | def merge_variables(
list_of_variables_dicts, # type: List[Mapping[Any, Variable]]
priority_vars=None, # type: Optional[Mapping[Any, Variable]]
compat='minimal', # type: str
):
# type: (...) -> OrderedDict[Any, Variable]
"""Merge dicts of variables, while resolving conflic... | [
"Merge",
"dicts",
"of",
"variables",
"while",
"resolving",
"conflicts",
"appropriately",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L117-L177 | [
"def",
"merge_variables",
"(",
"list_of_variables_dicts",
",",
"# type: List[Mapping[Any, Variable]]",
"priority_vars",
"=",
"None",
",",
"# type: Optional[Mapping[Any, Variable]]",
"compat",
"=",
"'minimal'",
",",
"# type: str",
")",
":",
"# type: (...) -> OrderedDict[Any, Varia... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | expand_variable_dicts | Given a list of dicts with xarray object values, expand the values.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Each value for the mappings must be of the following types:
- an xarray.Variable
- a tuple `(dims, data[, attrs[, encoding]])` that can ... | xarray/core/merge.py | def expand_variable_dicts(
list_of_variable_dicts: 'List[Union[Dataset, OrderedDict]]',
) -> 'List[Mapping[Any, Variable]]':
"""Given a list of dicts with xarray object values, expand the values.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Each value for t... | def expand_variable_dicts(
list_of_variable_dicts: 'List[Union[Dataset, OrderedDict]]',
) -> 'List[Mapping[Any, Variable]]':
"""Given a list of dicts with xarray object values, expand the values.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Each value for t... | [
"Given",
"a",
"list",
"of",
"dicts",
"with",
"xarray",
"object",
"values",
"expand",
"the",
"values",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L180-L227 | [
"def",
"expand_variable_dicts",
"(",
"list_of_variable_dicts",
":",
"'List[Union[Dataset, OrderedDict]]'",
",",
")",
"->",
"'List[Mapping[Any, Variable]]'",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
"import",
"Dataset",
"var_dicts",
"="... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | determine_coords | Given a list of dicts with xarray object values, identify coordinates.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Of the same form as the arguments to expand_variable_dicts.
Returns
-------
coord_names : set of variable names
noncoord_names : set... | xarray/core/merge.py | def determine_coords(list_of_variable_dicts):
# type: (List[Dict]) -> Tuple[Set, Set]
"""Given a list of dicts with xarray object values, identify coordinates.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Of the same form as the arguments to expand_variable... | def determine_coords(list_of_variable_dicts):
# type: (List[Dict]) -> Tuple[Set, Set]
"""Given a list of dicts with xarray object values, identify coordinates.
Parameters
----------
list_of_variable_dicts : list of dict or Dataset objects
Of the same form as the arguments to expand_variable... | [
"Given",
"a",
"list",
"of",
"dicts",
"with",
"xarray",
"object",
"values",
"identify",
"coordinates",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L230-L264 | [
"def",
"determine_coords",
"(",
"list_of_variable_dicts",
")",
":",
"# type: (List[Dict]) -> Tuple[Set, Set]",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
"import",
"Dataset",
"coord_names",
"=",
"set",
"(",
")",
"# type: set",
"noncoord_nam... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | coerce_pandas_values | Convert pandas values found in a list of labeled objects.
Parameters
----------
objects : list of Dataset or mappings
The mappings may contain any sort of objects coercible to
xarray.Variables as keys, including pandas objects.
Returns
-------
List of Dataset or OrderedDict obj... | xarray/core/merge.py | def coerce_pandas_values(objects):
"""Convert pandas values found in a list of labeled objects.
Parameters
----------
objects : list of Dataset or mappings
The mappings may contain any sort of objects coercible to
xarray.Variables as keys, including pandas objects.
Returns
----... | def coerce_pandas_values(objects):
"""Convert pandas values found in a list of labeled objects.
Parameters
----------
objects : list of Dataset or mappings
The mappings may contain any sort of objects coercible to
xarray.Variables as keys, including pandas objects.
Returns
----... | [
"Convert",
"pandas",
"values",
"found",
"in",
"a",
"list",
"of",
"labeled",
"objects",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L267-L297 | [
"def",
"coerce_pandas_values",
"(",
"objects",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"from",
".",
"dataarray",
"import",
"DataArray",
"out",
"=",
"[",
"]",
"for",
"obj",
"in",
"objects",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Dataset",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge_coords_for_inplace_math | Merge coordinate variables without worrying about alignment.
This function is used for merging variables in coordinates.py. | xarray/core/merge.py | def merge_coords_for_inplace_math(objs, priority_vars=None):
"""Merge coordinate variables without worrying about alignment.
This function is used for merging variables in coordinates.py.
"""
expanded = expand_variable_dicts(objs)
variables = merge_variables(expanded, priority_vars)
assert_uniq... | def merge_coords_for_inplace_math(objs, priority_vars=None):
"""Merge coordinate variables without worrying about alignment.
This function is used for merging variables in coordinates.py.
"""
expanded = expand_variable_dicts(objs)
variables = merge_variables(expanded, priority_vars)
assert_uniq... | [
"Merge",
"coordinate",
"variables",
"without",
"worrying",
"about",
"alignment",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L300-L308 | [
"def",
"merge_coords_for_inplace_math",
"(",
"objs",
",",
"priority_vars",
"=",
"None",
")",
":",
"expanded",
"=",
"expand_variable_dicts",
"(",
"objs",
")",
"variables",
"=",
"merge_variables",
"(",
"expanded",
",",
"priority_vars",
")",
"assert_unique_multiindex_lev... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _get_priority_vars | Extract the priority variable from a list of mappings.
We need this method because in some cases the priority argument itself
might have conflicting values (e.g., if it is a dict with two DataArray
values with conflicting coordinate values).
Parameters
----------
objects : list of dictionaries... | xarray/core/merge.py | def _get_priority_vars(objects, priority_arg, compat='equals'):
"""Extract the priority variable from a list of mappings.
We need this method because in some cases the priority argument itself
might have conflicting values (e.g., if it is a dict with two DataArray
values with conflicting coordinate val... | def _get_priority_vars(objects, priority_arg, compat='equals'):
"""Extract the priority variable from a list of mappings.
We need this method because in some cases the priority argument itself
might have conflicting values (e.g., if it is a dict with two DataArray
values with conflicting coordinate val... | [
"Extract",
"the",
"priority",
"variable",
"from",
"a",
"list",
"of",
"mappings",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L311-L337 | [
"def",
"_get_priority_vars",
"(",
"objects",
",",
"priority_arg",
",",
"compat",
"=",
"'equals'",
")",
":",
"# noqa",
"if",
"priority_arg",
"is",
"None",
":",
"priority_vars",
"=",
"{",
"}",
"else",
":",
"expanded",
"=",
"expand_variable_dicts",
"(",
"[",
"o... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | expand_and_merge_variables | Merge coordinate variables without worrying about alignment.
This function is used for merging variables in computation.py. | xarray/core/merge.py | def expand_and_merge_variables(objs, priority_arg=None):
"""Merge coordinate variables without worrying about alignment.
This function is used for merging variables in computation.py.
"""
expanded = expand_variable_dicts(objs)
priority_vars = _get_priority_vars(objs, priority_arg)
variables = m... | def expand_and_merge_variables(objs, priority_arg=None):
"""Merge coordinate variables without worrying about alignment.
This function is used for merging variables in computation.py.
"""
expanded = expand_variable_dicts(objs)
priority_vars = _get_priority_vars(objs, priority_arg)
variables = m... | [
"Merge",
"coordinate",
"variables",
"without",
"worrying",
"about",
"alignment",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L340-L348 | [
"def",
"expand_and_merge_variables",
"(",
"objs",
",",
"priority_arg",
"=",
"None",
")",
":",
"expanded",
"=",
"expand_variable_dicts",
"(",
"objs",
")",
"priority_vars",
"=",
"_get_priority_vars",
"(",
"objs",
",",
"priority_arg",
")",
"variables",
"=",
"merge_va... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge_coords | Merge coordinate variables.
See merge_core below for argument descriptions. This works similarly to
merge_core, except everything we don't worry about whether variables are
coordinates or not. | xarray/core/merge.py | def merge_coords(objs, compat='minimal', join='outer', priority_arg=None,
indexes=None):
"""Merge coordinate variables.
See merge_core below for argument descriptions. This works similarly to
merge_core, except everything we don't worry about whether variables are
coordinates or not.
... | def merge_coords(objs, compat='minimal', join='outer', priority_arg=None,
indexes=None):
"""Merge coordinate variables.
See merge_core below for argument descriptions. This works similarly to
merge_core, except everything we don't worry about whether variables are
coordinates or not.
... | [
"Merge",
"coordinate",
"variables",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L351-L367 | [
"def",
"merge_coords",
"(",
"objs",
",",
"compat",
"=",
"'minimal'",
",",
"join",
"=",
"'outer'",
",",
"priority_arg",
"=",
"None",
",",
"indexes",
"=",
"None",
")",
":",
"_assert_compat_valid",
"(",
"compat",
")",
"coerced",
"=",
"coerce_pandas_values",
"("... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge_data_and_coords | Used in Dataset.__init__. | xarray/core/merge.py | def merge_data_and_coords(data, coords, compat='broadcast_equals',
join='outer'):
"""Used in Dataset.__init__."""
objs = [data, coords]
explicit_coords = coords.keys()
indexes = dict(extract_indexes(coords))
return merge_core(objs, compat, join, explicit_coords=explicit_coo... | def merge_data_and_coords(data, coords, compat='broadcast_equals',
join='outer'):
"""Used in Dataset.__init__."""
objs = [data, coords]
explicit_coords = coords.keys()
indexes = dict(extract_indexes(coords))
return merge_core(objs, compat, join, explicit_coords=explicit_coo... | [
"Used",
"in",
"Dataset",
".",
"__init__",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L370-L377 | [
"def",
"merge_data_and_coords",
"(",
"data",
",",
"coords",
",",
"compat",
"=",
"'broadcast_equals'",
",",
"join",
"=",
"'outer'",
")",
":",
"objs",
"=",
"[",
"data",
",",
"coords",
"]",
"explicit_coords",
"=",
"coords",
".",
"keys",
"(",
")",
"indexes",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | extract_indexes | Yields the name & index of valid indexes from a mapping of coords | xarray/core/merge.py | def extract_indexes(coords):
"""Yields the name & index of valid indexes from a mapping of coords"""
for name, variable in coords.items():
variable = as_variable(variable, name=name)
if variable.dims == (name,):
yield name, variable.to_index() | def extract_indexes(coords):
"""Yields the name & index of valid indexes from a mapping of coords"""
for name, variable in coords.items():
variable = as_variable(variable, name=name)
if variable.dims == (name,):
yield name, variable.to_index() | [
"Yields",
"the",
"name",
"&",
"index",
"of",
"valid",
"indexes",
"from",
"a",
"mapping",
"of",
"coords"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L380-L385 | [
"def",
"extract_indexes",
"(",
"coords",
")",
":",
"for",
"name",
",",
"variable",
"in",
"coords",
".",
"items",
"(",
")",
":",
"variable",
"=",
"as_variable",
"(",
"variable",
",",
"name",
"=",
"name",
")",
"if",
"variable",
".",
"dims",
"==",
"(",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | assert_valid_explicit_coords | Validate explicit coordinate names/dims.
Raise a MergeError if an explicit coord shares a name with a dimension
but is comprised of arbitrary dimensions. | xarray/core/merge.py | def assert_valid_explicit_coords(variables, dims, explicit_coords):
"""Validate explicit coordinate names/dims.
Raise a MergeError if an explicit coord shares a name with a dimension
but is comprised of arbitrary dimensions.
"""
for coord_name in explicit_coords:
if coord_name in dims and v... | def assert_valid_explicit_coords(variables, dims, explicit_coords):
"""Validate explicit coordinate names/dims.
Raise a MergeError if an explicit coord shares a name with a dimension
but is comprised of arbitrary dimensions.
"""
for coord_name in explicit_coords:
if coord_name in dims and v... | [
"Validate",
"explicit",
"coordinate",
"names",
"/",
"dims",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L388-L399 | [
"def",
"assert_valid_explicit_coords",
"(",
"variables",
",",
"dims",
",",
"explicit_coords",
")",
":",
"for",
"coord_name",
"in",
"explicit_coords",
":",
"if",
"coord_name",
"in",
"dims",
"and",
"variables",
"[",
"coord_name",
"]",
".",
"dims",
"!=",
"(",
"co... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge_core | Core logic for merging labeled objects.
This is not public API.
Parameters
----------
objs : list of mappings
All values must be convertable to labeled arrays.
compat : {'identical', 'equals', 'broadcast_equals', 'no_conflicts'}, optional
Compatibility checks to use when merging va... | xarray/core/merge.py | def merge_core(objs,
compat='broadcast_equals',
join='outer',
priority_arg=None,
explicit_coords=None,
indexes=None):
"""Core logic for merging labeled objects.
This is not public API.
Parameters
----------
objs : list of m... | def merge_core(objs,
compat='broadcast_equals',
join='outer',
priority_arg=None,
explicit_coords=None,
indexes=None):
"""Core logic for merging labeled objects.
This is not public API.
Parameters
----------
objs : list of m... | [
"Core",
"logic",
"for",
"merging",
"labeled",
"objects",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L402-L470 | [
"def",
"merge_core",
"(",
"objs",
",",
"compat",
"=",
"'broadcast_equals'",
",",
"join",
"=",
"'outer'",
",",
"priority_arg",
"=",
"None",
",",
"explicit_coords",
"=",
"None",
",",
"indexes",
"=",
"None",
")",
":",
"# noqa",
"from",
".",
"dataset",
"import... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | merge | Merge any number of xarray objects into a single Dataset as variables.
Parameters
----------
objects : Iterable[Union[xarray.Dataset, xarray.DataArray, dict]]
Merge together all variables from these objects. If any of them are
DataArray objects, they must have a name.
compat : {'identic... | xarray/core/merge.py | def merge(objects, compat='no_conflicts', join='outer'):
"""Merge any number of xarray objects into a single Dataset as variables.
Parameters
----------
objects : Iterable[Union[xarray.Dataset, xarray.DataArray, dict]]
Merge together all variables from these objects. If any of them are
... | def merge(objects, compat='no_conflicts', join='outer'):
"""Merge any number of xarray objects into a single Dataset as variables.
Parameters
----------
objects : Iterable[Union[xarray.Dataset, xarray.DataArray, dict]]
Merge together all variables from these objects. If any of them are
... | [
"Merge",
"any",
"number",
"of",
"xarray",
"objects",
"into",
"a",
"single",
"Dataset",
"as",
"variables",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L473-L537 | [
"def",
"merge",
"(",
"objects",
",",
"compat",
"=",
"'no_conflicts'",
",",
"join",
"=",
"'outer'",
")",
":",
"# noqa",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
"import",
"Dataset",
"dict_like_objects",
"=",
"[",
"obj",
".",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | dataset_merge_method | Guts of the Dataset.merge method. | xarray/core/merge.py | def dataset_merge_method(dataset, other, overwrite_vars, compat, join):
"""Guts of the Dataset.merge method."""
# we are locked into supporting overwrite_vars for the Dataset.merge
# method due for backwards compatibility
# TODO: consider deprecating it?
if isinstance(overwrite_vars, str):
... | def dataset_merge_method(dataset, other, overwrite_vars, compat, join):
"""Guts of the Dataset.merge method."""
# we are locked into supporting overwrite_vars for the Dataset.merge
# method due for backwards compatibility
# TODO: consider deprecating it?
if isinstance(overwrite_vars, str):
... | [
"Guts",
"of",
"the",
"Dataset",
".",
"merge",
"method",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L540-L568 | [
"def",
"dataset_merge_method",
"(",
"dataset",
",",
"other",
",",
"overwrite_vars",
",",
"compat",
",",
"join",
")",
":",
"# we are locked into supporting overwrite_vars for the Dataset.merge",
"# method due for backwards compatibility",
"# TODO: consider deprecating it?",
"if",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | dataset_update_method | Guts of the Dataset.update method.
This drops a duplicated coordinates from `other` if `other` is not an
`xarray.Dataset`, e.g., if it's a dict with DataArray values (GH2068,
GH2180). | xarray/core/merge.py | def dataset_update_method(dataset, other):
"""Guts of the Dataset.update method.
This drops a duplicated coordinates from `other` if `other` is not an
`xarray.Dataset`, e.g., if it's a dict with DataArray values (GH2068,
GH2180).
"""
from .dataset import Dataset
from .dataarray import DataA... | def dataset_update_method(dataset, other):
"""Guts of the Dataset.update method.
This drops a duplicated coordinates from `other` if `other` is not an
`xarray.Dataset`, e.g., if it's a dict with DataArray values (GH2068,
GH2180).
"""
from .dataset import Dataset
from .dataarray import DataA... | [
"Guts",
"of",
"the",
"Dataset",
".",
"update",
"method",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/merge.py#L571-L592 | [
"def",
"dataset_update_method",
"(",
"dataset",
",",
"other",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"from",
".",
"dataarray",
"import",
"DataArray",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Dataset",
")",
":",
"other",
"=",
"OrderedDic... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _replace_nan | replace nan in a by val, and returns the replaced array and the nan
position | xarray/core/nanops.py | def _replace_nan(a, val):
"""
replace nan in a by val, and returns the replaced array and the nan
position
"""
mask = isnull(a)
return where_method(val, mask, a), mask | def _replace_nan(a, val):
"""
replace nan in a by val, and returns the replaced array and the nan
position
"""
mask = isnull(a)
return where_method(val, mask, a), mask | [
"replace",
"nan",
"in",
"a",
"by",
"val",
"and",
"returns",
"the",
"replaced",
"array",
"and",
"the",
"nan",
"position"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L14-L20 | [
"def",
"_replace_nan",
"(",
"a",
",",
"val",
")",
":",
"mask",
"=",
"isnull",
"(",
"a",
")",
"return",
"where_method",
"(",
"val",
",",
"mask",
",",
"a",
")",
",",
"mask"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _maybe_null_out | xarray version of pandas.core.nanops._maybe_null_out | xarray/core/nanops.py | def _maybe_null_out(result, axis, mask, min_count=1):
"""
xarray version of pandas.core.nanops._maybe_null_out
"""
if hasattr(axis, '__len__'): # if tuple or list
raise ValueError('min_count is not available for reduction '
'with more than one dimensions.')
if axis... | def _maybe_null_out(result, axis, mask, min_count=1):
"""
xarray version of pandas.core.nanops._maybe_null_out
"""
if hasattr(axis, '__len__'): # if tuple or list
raise ValueError('min_count is not available for reduction '
'with more than one dimensions.')
if axis... | [
"xarray",
"version",
"of",
"pandas",
".",
"core",
".",
"nanops",
".",
"_maybe_null_out"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L23-L43 | [
"def",
"_maybe_null_out",
"(",
"result",
",",
"axis",
",",
"mask",
",",
"min_count",
"=",
"1",
")",
":",
"if",
"hasattr",
"(",
"axis",
",",
"'__len__'",
")",
":",
"# if tuple or list",
"raise",
"ValueError",
"(",
"'min_count is not available for reduction '",
"'... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _nan_argminmax_object | In house nanargmin, nanargmax for object arrays. Always return integer
type | xarray/core/nanops.py | def _nan_argminmax_object(func, fill_value, value, axis=None, **kwargs):
""" In house nanargmin, nanargmax for object arrays. Always return integer
type
"""
valid_count = count(value, axis=axis)
value = fillna(value, fill_value)
data = _dask_or_eager_func(func)(value, axis=axis, **kwargs)
#... | def _nan_argminmax_object(func, fill_value, value, axis=None, **kwargs):
""" In house nanargmin, nanargmax for object arrays. Always return integer
type
"""
valid_count = count(value, axis=axis)
value = fillna(value, fill_value)
data = _dask_or_eager_func(func)(value, axis=axis, **kwargs)
#... | [
"In",
"house",
"nanargmin",
"nanargmax",
"for",
"object",
"arrays",
".",
"Always",
"return",
"integer",
"type"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L46-L58 | [
"def",
"_nan_argminmax_object",
"(",
"func",
",",
"fill_value",
",",
"value",
",",
"axis",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"valid_count",
"=",
"count",
"(",
"value",
",",
"axis",
"=",
"axis",
")",
"value",
"=",
"fillna",
"(",
"value",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _nan_minmax_object | In house nanmin and nanmax for object array | xarray/core/nanops.py | def _nan_minmax_object(func, fill_value, value, axis=None, **kwargs):
""" In house nanmin and nanmax for object array """
valid_count = count(value, axis=axis)
filled_value = fillna(value, fill_value)
data = getattr(np, func)(filled_value, axis=axis, **kwargs)
if not hasattr(data, 'dtype'): # scala... | def _nan_minmax_object(func, fill_value, value, axis=None, **kwargs):
""" In house nanmin and nanmax for object array """
valid_count = count(value, axis=axis)
filled_value = fillna(value, fill_value)
data = getattr(np, func)(filled_value, axis=axis, **kwargs)
if not hasattr(data, 'dtype'): # scala... | [
"In",
"house",
"nanmin",
"and",
"nanmax",
"for",
"object",
"array"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L61-L69 | [
"def",
"_nan_minmax_object",
"(",
"func",
",",
"fill_value",
",",
"value",
",",
"axis",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"valid_count",
"=",
"count",
"(",
"value",
",",
"axis",
"=",
"axis",
")",
"filled_value",
"=",
"fillna",
"(",
"value... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _nanmean_ddof_object | In house nanmean. ddof argument will be used in _nanvar method | xarray/core/nanops.py | def _nanmean_ddof_object(ddof, value, axis=None, **kwargs):
""" In house nanmean. ddof argument will be used in _nanvar method """
from .duck_array_ops import (count, fillna, _dask_or_eager_func,
where_method)
valid_count = count(value, axis=axis)
value = fillna(value, ... | def _nanmean_ddof_object(ddof, value, axis=None, **kwargs):
""" In house nanmean. ddof argument will be used in _nanvar method """
from .duck_array_ops import (count, fillna, _dask_or_eager_func,
where_method)
valid_count = count(value, axis=axis)
value = fillna(value, ... | [
"In",
"house",
"nanmean",
".",
"ddof",
"argument",
"will",
"be",
"used",
"in",
"_nanvar",
"method"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/nanops.py#L134-L149 | [
"def",
"_nanmean_ddof_object",
"(",
"ddof",
",",
"value",
",",
"axis",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"duck_array_ops",
"import",
"(",
"count",
",",
"fillna",
",",
"_dask_or_eager_func",
",",
"where_method",
")",
"valid_count",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _disable_auto_decode_variable | Disable automatic decoding on a netCDF4.Variable.
We handle these types of decoding ourselves. | xarray/backends/netCDF4_.py | def _disable_auto_decode_variable(var):
"""Disable automatic decoding on a netCDF4.Variable.
We handle these types of decoding ourselves.
"""
var.set_auto_maskandscale(False)
# only added in netCDF4-python v1.2.8
with suppress(AttributeError):
var.set_auto_chartostring(False) | def _disable_auto_decode_variable(var):
"""Disable automatic decoding on a netCDF4.Variable.
We handle these types of decoding ourselves.
"""
var.set_auto_maskandscale(False)
# only added in netCDF4-python v1.2.8
with suppress(AttributeError):
var.set_auto_chartostring(False) | [
"Disable",
"automatic",
"decoding",
"on",
"a",
"netCDF4",
".",
"Variable",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/netCDF4_.py#L254-L263 | [
"def",
"_disable_auto_decode_variable",
"(",
"var",
")",
":",
"var",
".",
"set_auto_maskandscale",
"(",
"False",
")",
"# only added in netCDF4-python v1.2.8",
"with",
"suppress",
"(",
"AttributeError",
")",
":",
"var",
".",
"set_auto_chartostring",
"(",
"False",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | maybe_promote | Simpler equivalent of pandas.core.common._maybe_promote
Parameters
----------
dtype : np.dtype
Returns
-------
dtype : Promoted dtype that can hold missing values.
fill_value : Valid missing value for the promoted dtype. | xarray/core/dtypes.py | def maybe_promote(dtype):
"""Simpler equivalent of pandas.core.common._maybe_promote
Parameters
----------
dtype : np.dtype
Returns
-------
dtype : Promoted dtype that can hold missing values.
fill_value : Valid missing value for the promoted dtype.
"""
# N.B. these casting rul... | def maybe_promote(dtype):
"""Simpler equivalent of pandas.core.common._maybe_promote
Parameters
----------
dtype : np.dtype
Returns
-------
dtype : Promoted dtype that can hold missing values.
fill_value : Valid missing value for the promoted dtype.
"""
# N.B. these casting rul... | [
"Simpler",
"equivalent",
"of",
"pandas",
".",
"core",
".",
"common",
".",
"_maybe_promote"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L45-L78 | [
"def",
"maybe_promote",
"(",
"dtype",
")",
":",
"# N.B. these casting rules should match pandas",
"if",
"np",
".",
"issubdtype",
"(",
"dtype",
",",
"np",
".",
"floating",
")",
":",
"fill_value",
"=",
"np",
".",
"nan",
"elif",
"np",
".",
"issubdtype",
"(",
"d... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_pos_infinity | Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype. | xarray/core/dtypes.py | def get_pos_infinity(dtype):
"""Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype.
"""
if issubclass(dtype.type, (np.floating, np.integer)):
return ... | def get_pos_infinity(dtype):
"""Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype.
"""
if issubclass(dtype.type, (np.floating, np.integer)):
return ... | [
"Return",
"an",
"appropriate",
"positive",
"infinity",
"for",
"this",
"dtype",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L99-L116 | [
"def",
"get_pos_infinity",
"(",
"dtype",
")",
":",
"if",
"issubclass",
"(",
"dtype",
".",
"type",
",",
"(",
"np",
".",
"floating",
",",
"np",
".",
"integer",
")",
")",
":",
"return",
"np",
".",
"inf",
"if",
"issubclass",
"(",
"dtype",
".",
"type",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_neg_infinity | Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype. | xarray/core/dtypes.py | def get_neg_infinity(dtype):
"""Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype.
"""
if issubclass(dtype.type, (np.floating, np.integer)):
return ... | def get_neg_infinity(dtype):
"""Return an appropriate positive infinity for this dtype.
Parameters
----------
dtype : np.dtype
Returns
-------
fill_value : positive infinity value corresponding to this dtype.
"""
if issubclass(dtype.type, (np.floating, np.integer)):
return ... | [
"Return",
"an",
"appropriate",
"positive",
"infinity",
"for",
"this",
"dtype",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L119-L136 | [
"def",
"get_neg_infinity",
"(",
"dtype",
")",
":",
"if",
"issubclass",
"(",
"dtype",
".",
"type",
",",
"(",
"np",
".",
"floating",
",",
"np",
".",
"integer",
")",
")",
":",
"return",
"-",
"np",
".",
"inf",
"if",
"issubclass",
"(",
"dtype",
".",
"ty... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | is_datetime_like | Check if a dtype is a subclass of the numpy datetime types | xarray/core/dtypes.py | def is_datetime_like(dtype):
"""Check if a dtype is a subclass of the numpy datetime types
"""
return (np.issubdtype(dtype, np.datetime64) or
np.issubdtype(dtype, np.timedelta64)) | def is_datetime_like(dtype):
"""Check if a dtype is a subclass of the numpy datetime types
"""
return (np.issubdtype(dtype, np.datetime64) or
np.issubdtype(dtype, np.timedelta64)) | [
"Check",
"if",
"a",
"dtype",
"is",
"a",
"subclass",
"of",
"the",
"numpy",
"datetime",
"types"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L139-L143 | [
"def",
"is_datetime_like",
"(",
"dtype",
")",
":",
"return",
"(",
"np",
".",
"issubdtype",
"(",
"dtype",
",",
"np",
".",
"datetime64",
")",
"or",
"np",
".",
"issubdtype",
"(",
"dtype",
",",
"np",
".",
"timedelta64",
")",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | result_type | Like np.result_type, but with type promotion rules matching pandas.
Examples of changed behavior:
number + string -> object (not string)
bytes + unicode -> object (not unicode)
Parameters
----------
*arrays_and_dtypes : list of arrays and dtypes
The dtype is extracted from both numpy a... | xarray/core/dtypes.py | def result_type(*arrays_and_dtypes):
"""Like np.result_type, but with type promotion rules matching pandas.
Examples of changed behavior:
number + string -> object (not string)
bytes + unicode -> object (not unicode)
Parameters
----------
*arrays_and_dtypes : list of arrays and dtypes
... | def result_type(*arrays_and_dtypes):
"""Like np.result_type, but with type promotion rules matching pandas.
Examples of changed behavior:
number + string -> object (not string)
bytes + unicode -> object (not unicode)
Parameters
----------
*arrays_and_dtypes : list of arrays and dtypes
... | [
"Like",
"np",
".",
"result_type",
"but",
"with",
"type",
"promotion",
"rules",
"matching",
"pandas",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dtypes.py#L146-L169 | [
"def",
"result_type",
"(",
"*",
"arrays_and_dtypes",
")",
":",
"types",
"=",
"{",
"np",
".",
"result_type",
"(",
"t",
")",
".",
"type",
"for",
"t",
"in",
"arrays_and_dtypes",
"}",
"for",
"left",
",",
"right",
"in",
"PROMOTE_TO_OBJECT",
":",
"if",
"(",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _parse_envi | Parse ENVI metadata into Python data structures.
See the link for information on the ENVI header file format:
http://www.harrisgeospatial.com/docs/enviheaderfiles.html
Parameters
----------
meta : dict
Dictionary of keys and str values to parse, as returned by the rasterio
tags(ns=... | xarray/backends/rasterio_.py | def _parse_envi(meta):
"""Parse ENVI metadata into Python data structures.
See the link for information on the ENVI header file format:
http://www.harrisgeospatial.com/docs/enviheaderfiles.html
Parameters
----------
meta : dict
Dictionary of keys and str values to parse, as returned by... | def _parse_envi(meta):
"""Parse ENVI metadata into Python data structures.
See the link for information on the ENVI header file format:
http://www.harrisgeospatial.com/docs/enviheaderfiles.html
Parameters
----------
meta : dict
Dictionary of keys and str values to parse, as returned by... | [
"Parse",
"ENVI",
"metadata",
"into",
"Python",
"data",
"structures",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L133-L161 | [
"def",
"_parse_envi",
"(",
"meta",
")",
":",
"def",
"parsevec",
"(",
"s",
")",
":",
"return",
"np",
".",
"fromstring",
"(",
"s",
".",
"strip",
"(",
"'{}'",
")",
",",
"dtype",
"=",
"'float'",
",",
"sep",
"=",
"','",
")",
"def",
"default",
"(",
"s"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_rasterio | Open a file with rasterio (experimental).
This should work with any file that rasterio can open (most often:
geoTIFF). The x and y coordinates are generated automatically from the
file's geoinformation, shifted to the center of each pixel (see
`"PixelIsArea" Raster Space
<http://web.archive.org/web... | xarray/backends/rasterio_.py | def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None,
lock=None):
"""Open a file with rasterio (experimental).
This should work with any file that rasterio can open (most often:
geoTIFF). The x and y coordinates are generated automatically from the
file's geoinf... | def open_rasterio(filename, parse_coordinates=None, chunks=None, cache=None,
lock=None):
"""Open a file with rasterio (experimental).
This should work with any file that rasterio can open (most often:
geoTIFF). The x and y coordinates are generated automatically from the
file's geoinf... | [
"Open",
"a",
"file",
"with",
"rasterio",
"(",
"experimental",
")",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L164-L347 | [
"def",
"open_rasterio",
"(",
"filename",
",",
"parse_coordinates",
"=",
"None",
",",
"chunks",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"lock",
"=",
"None",
")",
":",
"import",
"rasterio",
"from",
"rasterio",
".",
"vrt",
"import",
"WarpedVRT",
"vrt_par... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | RasterioArrayWrapper._get_indexer | Get indexer for rasterio array.
Parameter
---------
key: tuple of int
Returns
-------
band_key: an indexer for the 1st dimension
window: two tuples. Each consists of (start, stop).
squeeze_axis: axes to be squeezed
np_ind: indexer for loaded nump... | xarray/backends/rasterio_.py | def _get_indexer(self, key):
""" Get indexer for rasterio array.
Parameter
---------
key: tuple of int
Returns
-------
band_key: an indexer for the 1st dimension
window: two tuples. Each consists of (start, stop).
squeeze_axis: axes to be squeeze... | def _get_indexer(self, key):
""" Get indexer for rasterio array.
Parameter
---------
key: tuple of int
Returns
-------
band_key: an indexer for the 1st dimension
window: two tuples. Each consists of (start, stop).
squeeze_axis: axes to be squeeze... | [
"Get",
"indexer",
"for",
"rasterio",
"array",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/rasterio_.py#L51-L106 | [
"def",
"_get_indexer",
"(",
"self",
",",
"key",
")",
":",
"assert",
"len",
"(",
"key",
")",
"==",
"3",
",",
"'rasterio datasets should always be 3D'",
"# bands cannot be windowed but they can be listed",
"band_key",
"=",
"key",
"[",
"0",
"]",
"np_inds",
"=",
"[",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | unique_value_groups | Group an array by its unique values.
Parameters
----------
ar : array-like
Input array. This will be flattened if it is not already 1-D.
sort : boolean, optional
Whether or not to sort unique values.
Returns
-------
values : np.ndarray
Sorted, unique values as retur... | xarray/core/groupby.py | def unique_value_groups(ar, sort=True):
"""Group an array by its unique values.
Parameters
----------
ar : array-like
Input array. This will be flattened if it is not already 1-D.
sort : boolean, optional
Whether or not to sort unique values.
Returns
-------
values : np... | def unique_value_groups(ar, sort=True):
"""Group an array by its unique values.
Parameters
----------
ar : array-like
Input array. This will be flattened if it is not already 1-D.
sort : boolean, optional
Whether or not to sort unique values.
Returns
-------
values : np... | [
"Group",
"an",
"array",
"by",
"its",
"unique",
"values",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L18-L42 | [
"def",
"unique_value_groups",
"(",
"ar",
",",
"sort",
"=",
"True",
")",
":",
"inverse",
",",
"values",
"=",
"pd",
".",
"factorize",
"(",
"ar",
",",
"sort",
"=",
"sort",
")",
"groups",
"=",
"[",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"len",
"("... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _consolidate_slices | Consolidate adjacent slices in a list of slices. | xarray/core/groupby.py | def _consolidate_slices(slices):
"""Consolidate adjacent slices in a list of slices.
"""
result = []
last_slice = slice(None)
for slice_ in slices:
if not isinstance(slice_, slice):
raise ValueError('list element is not a slice: %r' % slice_)
if (result and last_slice.sto... | def _consolidate_slices(slices):
"""Consolidate adjacent slices in a list of slices.
"""
result = []
last_slice = slice(None)
for slice_ in slices:
if not isinstance(slice_, slice):
raise ValueError('list element is not a slice: %r' % slice_)
if (result and last_slice.sto... | [
"Consolidate",
"adjacent",
"slices",
"in",
"a",
"list",
"of",
"slices",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L72-L88 | [
"def",
"_consolidate_slices",
"(",
"slices",
")",
":",
"result",
"=",
"[",
"]",
"last_slice",
"=",
"slice",
"(",
"None",
")",
"for",
"slice_",
"in",
"slices",
":",
"if",
"not",
"isinstance",
"(",
"slice_",
",",
"slice",
")",
":",
"raise",
"ValueError",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _inverse_permutation_indices | Like inverse_permutation, but also handles slices.
Parameters
----------
positions : list of np.ndarray or slice objects.
If slice objects, all are assumed to be slices.
Returns
-------
np.ndarray of indices or None, if no permutation is necessary. | xarray/core/groupby.py | def _inverse_permutation_indices(positions):
"""Like inverse_permutation, but also handles slices.
Parameters
----------
positions : list of np.ndarray or slice objects.
If slice objects, all are assumed to be slices.
Returns
-------
np.ndarray of indices or None, if no permutation... | def _inverse_permutation_indices(positions):
"""Like inverse_permutation, but also handles slices.
Parameters
----------
positions : list of np.ndarray or slice objects.
If slice objects, all are assumed to be slices.
Returns
-------
np.ndarray of indices or None, if no permutation... | [
"Like",
"inverse_permutation",
"but",
"also",
"handles",
"slices",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L91-L113 | [
"def",
"_inverse_permutation_indices",
"(",
"positions",
")",
":",
"if",
"not",
"positions",
":",
"return",
"None",
"if",
"isinstance",
"(",
"positions",
"[",
"0",
"]",
",",
"slice",
")",
":",
"positions",
"=",
"_consolidate_slices",
"(",
"positions",
")",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _apply_loffset | (copied from pandas)
if loffset is set, offset the result index
This is NOT an idempotent routine, it will be applied
exactly once to the result.
Parameters
----------
result : Series or DataFrame
the result of resample | xarray/core/groupby.py | def _apply_loffset(grouper, result):
"""
(copied from pandas)
if loffset is set, offset the result index
This is NOT an idempotent routine, it will be applied
exactly once to the result.
Parameters
----------
result : Series or DataFrame
the result of resample
"""
need... | def _apply_loffset(grouper, result):
"""
(copied from pandas)
if loffset is set, offset the result index
This is NOT an idempotent routine, it will be applied
exactly once to the result.
Parameters
----------
result : Series or DataFrame
the result of resample
"""
need... | [
"(",
"copied",
"from",
"pandas",
")",
"if",
"loffset",
"is",
"set",
"offset",
"the",
"result",
"index"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L156-L179 | [
"def",
"_apply_loffset",
"(",
"grouper",
",",
"result",
")",
":",
"needs_offset",
"=",
"(",
"isinstance",
"(",
"grouper",
".",
"loffset",
",",
"(",
"pd",
".",
"DateOffset",
",",
"datetime",
".",
"timedelta",
")",
")",
"and",
"isinstance",
"(",
"result",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | GroupBy._iter_grouped | Iterate over each element in this group | xarray/core/groupby.py | def _iter_grouped(self):
"""Iterate over each element in this group"""
for indices in self._group_indices:
yield self._obj.isel(**{self._group_dim: indices}) | def _iter_grouped(self):
"""Iterate over each element in this group"""
for indices in self._group_indices:
yield self._obj.isel(**{self._group_dim: indices}) | [
"Iterate",
"over",
"each",
"element",
"in",
"this",
"group"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L322-L325 | [
"def",
"_iter_grouped",
"(",
"self",
")",
":",
"for",
"indices",
"in",
"self",
".",
"_group_indices",
":",
"yield",
"self",
".",
"_obj",
".",
"isel",
"(",
"*",
"*",
"{",
"self",
".",
"_group_dim",
":",
"indices",
"}",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | GroupBy._maybe_restore_empty_groups | Our index contained empty groups (e.g., from a resampling). If we
reduced on that dimension, we want to restore the full index. | xarray/core/groupby.py | def _maybe_restore_empty_groups(self, combined):
"""Our index contained empty groups (e.g., from a resampling). If we
reduced on that dimension, we want to restore the full index.
"""
if (self._full_index is not None and
self._group.name in combined.dims):
ind... | def _maybe_restore_empty_groups(self, combined):
"""Our index contained empty groups (e.g., from a resampling). If we
reduced on that dimension, we want to restore the full index.
"""
if (self._full_index is not None and
self._group.name in combined.dims):
ind... | [
"Our",
"index",
"contained",
"empty",
"groups",
"(",
"e",
".",
"g",
".",
"from",
"a",
"resampling",
")",
".",
"If",
"we",
"reduced",
"on",
"that",
"dimension",
"we",
"want",
"to",
"restore",
"the",
"full",
"index",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L372-L380 | [
"def",
"_maybe_restore_empty_groups",
"(",
"self",
",",
"combined",
")",
":",
"if",
"(",
"self",
".",
"_full_index",
"is",
"not",
"None",
"and",
"self",
".",
"_group",
".",
"name",
"in",
"combined",
".",
"dims",
")",
":",
"indexers",
"=",
"{",
"self",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | GroupBy._maybe_unstack | This gets called if we are applying on an array with a
multidimensional group. | xarray/core/groupby.py | def _maybe_unstack(self, obj):
"""This gets called if we are applying on an array with a
multidimensional group."""
if self._stacked_dim is not None and self._stacked_dim in obj.dims:
obj = obj.unstack(self._stacked_dim)
for dim in self._inserted_dims:
if ... | def _maybe_unstack(self, obj):
"""This gets called if we are applying on an array with a
multidimensional group."""
if self._stacked_dim is not None and self._stacked_dim in obj.dims:
obj = obj.unstack(self._stacked_dim)
for dim in self._inserted_dims:
if ... | [
"This",
"gets",
"called",
"if",
"we",
"are",
"applying",
"on",
"an",
"array",
"with",
"a",
"multidimensional",
"group",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L382-L390 | [
"def",
"_maybe_unstack",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"_stacked_dim",
"is",
"not",
"None",
"and",
"self",
".",
"_stacked_dim",
"in",
"obj",
".",
"dims",
":",
"obj",
"=",
"obj",
".",
"unstack",
"(",
"self",
".",
"_stacked_dim",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | GroupBy.first | Return the first element of each group along the group dimension | xarray/core/groupby.py | def first(self, skipna=None, keep_attrs=None):
"""Return the first element of each group along the group dimension
"""
return self._first_or_last(duck_array_ops.first, skipna, keep_attrs) | def first(self, skipna=None, keep_attrs=None):
"""Return the first element of each group along the group dimension
"""
return self._first_or_last(duck_array_ops.first, skipna, keep_attrs) | [
"Return",
"the",
"first",
"element",
"of",
"each",
"group",
"along",
"the",
"group",
"dimension"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L448-L451 | [
"def",
"first",
"(",
"self",
",",
"skipna",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_first_or_last",
"(",
"duck_array_ops",
".",
"first",
",",
"skipna",
",",
"keep_attrs",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | GroupBy.last | Return the last element of each group along the group dimension | xarray/core/groupby.py | def last(self, skipna=None, keep_attrs=None):
"""Return the last element of each group along the group dimension
"""
return self._first_or_last(duck_array_ops.last, skipna, keep_attrs) | def last(self, skipna=None, keep_attrs=None):
"""Return the last element of each group along the group dimension
"""
return self._first_or_last(duck_array_ops.last, skipna, keep_attrs) | [
"Return",
"the",
"last",
"element",
"of",
"each",
"group",
"along",
"the",
"group",
"dimension"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L453-L456 | [
"def",
"last",
"(",
"self",
",",
"skipna",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_first_or_last",
"(",
"duck_array_ops",
".",
"last",
",",
"skipna",
",",
"keep_attrs",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataArrayGroupBy._iter_grouped_shortcut | Fast version of `_iter_grouped` that yields Variables without
metadata | xarray/core/groupby.py | def _iter_grouped_shortcut(self):
"""Fast version of `_iter_grouped` that yields Variables without
metadata
"""
var = self._obj.variable
for indices in self._group_indices:
yield var[{self._group_dim: indices}] | def _iter_grouped_shortcut(self):
"""Fast version of `_iter_grouped` that yields Variables without
metadata
"""
var = self._obj.variable
for indices in self._group_indices:
yield var[{self._group_dim: indices}] | [
"Fast",
"version",
"of",
"_iter_grouped",
"that",
"yields",
"Variables",
"without",
"metadata"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L482-L488 | [
"def",
"_iter_grouped_shortcut",
"(",
"self",
")",
":",
"var",
"=",
"self",
".",
"_obj",
".",
"variable",
"for",
"indices",
"in",
"self",
".",
"_group_indices",
":",
"yield",
"var",
"[",
"{",
"self",
".",
"_group_dim",
":",
"indices",
"}",
"]"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataArrayGroupBy.apply | Apply a function over each array in the group and concatenate them
together into a new array.
`func` is called like `func(ar, *args, **kwargs)` for each array `ar`
in this group.
Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how
to stack together the array. ... | xarray/core/groupby.py | def apply(self, func, shortcut=False, args=(), **kwargs):
"""Apply a function over each array in the group and concatenate them
together into a new array.
`func` is called like `func(ar, *args, **kwargs)` for each array `ar`
in this group.
Apply uses heuristics (like `pandas.Gr... | def apply(self, func, shortcut=False, args=(), **kwargs):
"""Apply a function over each array in the group and concatenate them
together into a new array.
`func` is called like `func(ar, *args, **kwargs)` for each array `ar`
in this group.
Apply uses heuristics (like `pandas.Gr... | [
"Apply",
"a",
"function",
"over",
"each",
"array",
"in",
"the",
"group",
"and",
"concatenate",
"them",
"together",
"into",
"a",
"new",
"array",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L513-L558 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"shortcut",
"=",
"False",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"shortcut",
":",
"grouped",
"=",
"self",
".",
"_iter_grouped_shortcut",
"(",
")",
"else",
":",
"grouped",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataArrayGroupBy._combine | Recombine the applied objects like the original. | xarray/core/groupby.py | def _combine(self, applied, shortcut=False):
"""Recombine the applied objects like the original."""
applied_example, applied = peek_at(applied)
coord, dim, positions = self._infer_concat_args(applied_example)
if shortcut:
combined = self._concat_shortcut(applied, dim, positio... | def _combine(self, applied, shortcut=False):
"""Recombine the applied objects like the original."""
applied_example, applied = peek_at(applied)
coord, dim, positions = self._infer_concat_args(applied_example)
if shortcut:
combined = self._concat_shortcut(applied, dim, positio... | [
"Recombine",
"the",
"applied",
"objects",
"like",
"the",
"original",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L560-L580 | [
"def",
"_combine",
"(",
"self",
",",
"applied",
",",
"shortcut",
"=",
"False",
")",
":",
"applied_example",
",",
"applied",
"=",
"peek_at",
"(",
"applied",
")",
"coord",
",",
"dim",
",",
"positions",
"=",
"self",
".",
"_infer_concat_args",
"(",
"applied_ex... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataArrayGroupBy.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, axis=axis, **kwargs)` to return the result of collapsing
an np.ndarray over an integer v... | xarray/core/groupby.py | def reduce(self, func, dim=None, axis=None,
keep_attrs=None, shortcut=True, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
... | def reduce(self, func, dim=None, axis=None,
keep_attrs=None, shortcut=True, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
... | [
"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/groupby.py#L582-L629 | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"dim",
"=",
"None",
",",
"axis",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
",",
"shortcut",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dim",
"==",
"DEFAULT_DIMS",
":",
"dim",
"=",
"AL... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DatasetGroupBy.apply | Apply a function over each Dataset in the group and concatenate them
together into a new Dataset.
`func` is called like `func(ds, *args, **kwargs)` for each dataset `ds`
in this group.
Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how
to stack together the d... | xarray/core/groupby.py | def apply(self, func, args=(), **kwargs):
"""Apply a function over each Dataset in the group and concatenate them
together into a new Dataset.
`func` is called like `func(ds, *args, **kwargs)` for each dataset `ds`
in this group.
Apply uses heuristics (like `pandas.GroupBy.appl... | def apply(self, func, args=(), **kwargs):
"""Apply a function over each Dataset in the group and concatenate them
together into a new Dataset.
`func` is called like `func(ds, *args, **kwargs)` for each dataset `ds`
in this group.
Apply uses heuristics (like `pandas.GroupBy.appl... | [
"Apply",
"a",
"function",
"over",
"each",
"Dataset",
"in",
"the",
"group",
"and",
"concatenate",
"them",
"together",
"into",
"a",
"new",
"Dataset",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L655-L686 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"args",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"pop",
"(",
"'shortcut'",
",",
"None",
")",
"# ignore shortcut if set (for now)",
"applied",
"=",
"(",
"func",
"(",
"ds",
",",
"*"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DatasetGroupBy._combine | Recombine the applied objects like the original. | xarray/core/groupby.py | def _combine(self, applied):
"""Recombine the applied objects like the original."""
applied_example, applied = peek_at(applied)
coord, dim, positions = self._infer_concat_args(applied_example)
combined = concat(applied, dim)
combined = _maybe_reorder(combined, dim, positions)
... | def _combine(self, applied):
"""Recombine the applied objects like the original."""
applied_example, applied = peek_at(applied)
coord, dim, positions = self._infer_concat_args(applied_example)
combined = concat(applied, dim)
combined = _maybe_reorder(combined, dim, positions)
... | [
"Recombine",
"the",
"applied",
"objects",
"like",
"the",
"original",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L688-L698 | [
"def",
"_combine",
"(",
"self",
",",
"applied",
")",
":",
"applied_example",
",",
"applied",
"=",
"peek_at",
"(",
"applied",
")",
"coord",
",",
"dim",
",",
"positions",
"=",
"self",
".",
"_infer_concat_args",
"(",
"applied_example",
")",
"combined",
"=",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DatasetGroupBy.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, axis=axis, **kwargs)` to return the result of collapsing
an np.ndarray over an integer v... | xarray/core/groupby.py | def reduce(self, func, dim=None, keep_attrs=None, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, axis=axis, **kwargs)` to ret... | def reduce(self, func, dim=None, keep_attrs=None, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, axis=axis, **kwargs)` to ret... | [
"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/groupby.py#L700-L747 | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"dim",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dim",
"==",
"DEFAULT_DIMS",
":",
"dim",
"=",
"ALL_DIMS",
"# TODO change this to dim = self._group_dim after",
"# the... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _filter_attrs | Return attrs that are not in ignored_attrs | xarray/convert.py | def _filter_attrs(attrs, ignored_attrs):
""" Return attrs that are not in ignored_attrs
"""
return dict((k, v) for k, v in attrs.items() if k not in ignored_attrs) | def _filter_attrs(attrs, ignored_attrs):
""" Return attrs that are not in ignored_attrs
"""
return dict((k, v) for k, v in attrs.items() if k not in ignored_attrs) | [
"Return",
"attrs",
"that",
"are",
"not",
"in",
"ignored_attrs"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L30-L33 | [
"def",
"_filter_attrs",
"(",
"attrs",
",",
"ignored_attrs",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
"if",
"k",
"not",
"in",
"ignored_attrs",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | from_cdms2 | Convert a cdms2 variable into an DataArray | xarray/convert.py | def from_cdms2(variable):
"""Convert a cdms2 variable into an DataArray
"""
values = np.asarray(variable)
name = variable.id
dims = variable.getAxisIds()
coords = {}
for axis in variable.getAxisList():
coords[axis.id] = DataArray(
np.asarray(axis), dims=[axis.id],
... | def from_cdms2(variable):
"""Convert a cdms2 variable into an DataArray
"""
values = np.asarray(variable)
name = variable.id
dims = variable.getAxisIds()
coords = {}
for axis in variable.getAxisList():
coords[axis.id] = DataArray(
np.asarray(axis), dims=[axis.id],
... | [
"Convert",
"a",
"cdms2",
"variable",
"into",
"an",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L36-L59 | [
"def",
"from_cdms2",
"(",
"variable",
")",
":",
"values",
"=",
"np",
".",
"asarray",
"(",
"variable",
")",
"name",
"=",
"variable",
".",
"id",
"dims",
"=",
"variable",
".",
"getAxisIds",
"(",
")",
"coords",
"=",
"{",
"}",
"for",
"axis",
"in",
"variab... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | to_cdms2 | Convert a DataArray into a cdms2 variable | xarray/convert.py | def to_cdms2(dataarray, copy=True):
"""Convert a DataArray into a cdms2 variable
"""
# we don't want cdms2 to be a hard dependency
import cdms2
def set_cdms2_attrs(var, attrs):
for k, v in attrs.items():
setattr(var, k, v)
# 1D axes
axes = []
for dim in dataarray.di... | def to_cdms2(dataarray, copy=True):
"""Convert a DataArray into a cdms2 variable
"""
# we don't want cdms2 to be a hard dependency
import cdms2
def set_cdms2_attrs(var, attrs):
for k, v in attrs.items():
setattr(var, k, v)
# 1D axes
axes = []
for dim in dataarray.di... | [
"Convert",
"a",
"DataArray",
"into",
"a",
"cdms2",
"variable"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L62-L116 | [
"def",
"to_cdms2",
"(",
"dataarray",
",",
"copy",
"=",
"True",
")",
":",
"# we don't want cdms2 to be a hard dependency",
"import",
"cdms2",
"def",
"set_cdms2_attrs",
"(",
"var",
",",
"attrs",
")",
":",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _pick_attrs | Return attrs with keys in keys list | xarray/convert.py | def _pick_attrs(attrs, keys):
""" Return attrs with keys in keys list
"""
return dict((k, v) for k, v in attrs.items() if k in keys) | def _pick_attrs(attrs, keys):
""" Return attrs with keys in keys list
"""
return dict((k, v) for k, v in attrs.items() if k in keys) | [
"Return",
"attrs",
"with",
"keys",
"in",
"keys",
"list"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L119-L122 | [
"def",
"_pick_attrs",
"(",
"attrs",
",",
"keys",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
"if",
"k",
"in",
"keys",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _get_iris_args | Converts the xarray attrs into args that can be passed into Iris | xarray/convert.py | def _get_iris_args(attrs):
""" Converts the xarray attrs into args that can be passed into Iris
"""
# iris.unit is deprecated in Iris v1.9
import cf_units
args = {'attributes': _filter_attrs(attrs, iris_forbidden_keys)}
args.update(_pick_attrs(attrs, ('standard_name', 'long_name',)))
unit_ar... | def _get_iris_args(attrs):
""" Converts the xarray attrs into args that can be passed into Iris
"""
# iris.unit is deprecated in Iris v1.9
import cf_units
args = {'attributes': _filter_attrs(attrs, iris_forbidden_keys)}
args.update(_pick_attrs(attrs, ('standard_name', 'long_name',)))
unit_ar... | [
"Converts",
"the",
"xarray",
"attrs",
"into",
"args",
"that",
"can",
"be",
"passed",
"into",
"Iris"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L125-L135 | [
"def",
"_get_iris_args",
"(",
"attrs",
")",
":",
"# iris.unit is deprecated in Iris v1.9",
"import",
"cf_units",
"args",
"=",
"{",
"'attributes'",
":",
"_filter_attrs",
"(",
"attrs",
",",
"iris_forbidden_keys",
")",
"}",
"args",
".",
"update",
"(",
"_pick_attrs",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | to_iris | Convert a DataArray into a Iris Cube | xarray/convert.py | def to_iris(dataarray):
""" Convert a DataArray into a Iris Cube
"""
# Iris not a hard dependency
import iris
from iris.fileformats.netcdf import parse_cell_methods
dim_coords = []
aux_coords = []
for coord_name in dataarray.coords:
coord = encode(dataarray.coords[coord_name])
... | def to_iris(dataarray):
""" Convert a DataArray into a Iris Cube
"""
# Iris not a hard dependency
import iris
from iris.fileformats.netcdf import parse_cell_methods
dim_coords = []
aux_coords = []
for coord_name in dataarray.coords:
coord = encode(dataarray.coords[coord_name])
... | [
"Convert",
"a",
"DataArray",
"into",
"a",
"Iris",
"Cube"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L139-L178 | [
"def",
"to_iris",
"(",
"dataarray",
")",
":",
"# Iris not a hard dependency",
"import",
"iris",
"from",
"iris",
".",
"fileformats",
".",
"netcdf",
"import",
"parse_cell_methods",
"dim_coords",
"=",
"[",
"]",
"aux_coords",
"=",
"[",
"]",
"for",
"coord_name",
"in"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _iris_obj_to_attrs | Return a dictionary of attrs when given a Iris object | xarray/convert.py | def _iris_obj_to_attrs(obj):
""" Return a dictionary of attrs when given a Iris object
"""
attrs = {'standard_name': obj.standard_name,
'long_name': obj.long_name}
if obj.units.calendar:
attrs['calendar'] = obj.units.calendar
if obj.units.origin != '1' and not obj.units.is_unkno... | def _iris_obj_to_attrs(obj):
""" Return a dictionary of attrs when given a Iris object
"""
attrs = {'standard_name': obj.standard_name,
'long_name': obj.long_name}
if obj.units.calendar:
attrs['calendar'] = obj.units.calendar
if obj.units.origin != '1' and not obj.units.is_unkno... | [
"Return",
"a",
"dictionary",
"of",
"attrs",
"when",
"given",
"a",
"Iris",
"object"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L181-L191 | [
"def",
"_iris_obj_to_attrs",
"(",
"obj",
")",
":",
"attrs",
"=",
"{",
"'standard_name'",
":",
"obj",
".",
"standard_name",
",",
"'long_name'",
":",
"obj",
".",
"long_name",
"}",
"if",
"obj",
".",
"units",
".",
"calendar",
":",
"attrs",
"[",
"'calendar'",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _iris_cell_methods_to_str | Converts a Iris cell methods into a string | xarray/convert.py | def _iris_cell_methods_to_str(cell_methods_obj):
""" Converts a Iris cell methods into a string
"""
cell_methods = []
for cell_method in cell_methods_obj:
names = ''.join(['{}: '.format(n) for n in cell_method.coord_names])
intervals = ' '.join(['interval: {}'.format(interval)
... | def _iris_cell_methods_to_str(cell_methods_obj):
""" Converts a Iris cell methods into a string
"""
cell_methods = []
for cell_method in cell_methods_obj:
names = ''.join(['{}: '.format(n) for n in cell_method.coord_names])
intervals = ' '.join(['interval: {}'.format(interval)
... | [
"Converts",
"a",
"Iris",
"cell",
"methods",
"into",
"a",
"string"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L194-L208 | [
"def",
"_iris_cell_methods_to_str",
"(",
"cell_methods_obj",
")",
":",
"cell_methods",
"=",
"[",
"]",
"for",
"cell_method",
"in",
"cell_methods_obj",
":",
"names",
"=",
"''",
".",
"join",
"(",
"[",
"'{}: '",
".",
"format",
"(",
"n",
")",
"for",
"n",
"in",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _name | Mimicks `iris_obj.name()` but with different name resolution order.
Similar to iris_obj.name() method, but using iris_obj.var_name first to
enable roundtripping. | xarray/convert.py | def _name(iris_obj, default='unknown'):
""" Mimicks `iris_obj.name()` but with different name resolution order.
Similar to iris_obj.name() method, but using iris_obj.var_name first to
enable roundtripping.
"""
return (iris_obj.var_name or iris_obj.standard_name or
iris_obj.long_name or ... | def _name(iris_obj, default='unknown'):
""" Mimicks `iris_obj.name()` but with different name resolution order.
Similar to iris_obj.name() method, but using iris_obj.var_name first to
enable roundtripping.
"""
return (iris_obj.var_name or iris_obj.standard_name or
iris_obj.long_name or ... | [
"Mimicks",
"iris_obj",
".",
"name",
"()",
"but",
"with",
"different",
"name",
"resolution",
"order",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L211-L218 | [
"def",
"_name",
"(",
"iris_obj",
",",
"default",
"=",
"'unknown'",
")",
":",
"return",
"(",
"iris_obj",
".",
"var_name",
"or",
"iris_obj",
".",
"standard_name",
"or",
"iris_obj",
".",
"long_name",
"or",
"default",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | from_iris | Convert a Iris cube into an DataArray | xarray/convert.py | def from_iris(cube):
""" Convert a Iris cube into an DataArray
"""
import iris.exceptions
from xarray.core.pycompat import dask_array_type
name = _name(cube)
if name == 'unknown':
name = None
dims = []
for i in range(cube.ndim):
try:
dim_coord = cube.coord(di... | def from_iris(cube):
""" Convert a Iris cube into an DataArray
"""
import iris.exceptions
from xarray.core.pycompat import dask_array_type
name = _name(cube)
if name == 'unknown':
name = None
dims = []
for i in range(cube.ndim):
try:
dim_coord = cube.coord(di... | [
"Convert",
"a",
"Iris",
"cube",
"into",
"an",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/convert.py#L221-L272 | [
"def",
"from_iris",
"(",
"cube",
")",
":",
"import",
"iris",
".",
"exceptions",
"from",
"xarray",
".",
"core",
".",
"pycompat",
"import",
"dask_array_type",
"name",
"=",
"_name",
"(",
"cube",
")",
"if",
"name",
"==",
"'unknown'",
":",
"name",
"=",
"None"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | decode_cf_datetime | Given an array of numeric dates in netCDF format, convert it into a
numpy array of date time objects.
For standard (Gregorian) calendars, this function uses vectorized
operations, which makes it much faster than cftime.num2date. In such a
case, the returned array will be of type np.datetime64.
Not... | xarray/coding/times.py | def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):
"""Given an array of numeric dates in netCDF format, convert it into a
numpy array of date time objects.
For standard (Gregorian) calendars, this function uses vectorized
operations, which makes it much faster than cftime.num2dat... | def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):
"""Given an array of numeric dates in netCDF format, convert it into a
numpy array of date time objects.
For standard (Gregorian) calendars, this function uses vectorized
operations, which makes it much faster than cftime.num2dat... | [
"Given",
"an",
"array",
"of",
"numeric",
"dates",
"in",
"netCDF",
"format",
"convert",
"it",
"into",
"a",
"numpy",
"array",
"of",
"date",
"time",
"objects",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L153-L198 | [
"def",
"decode_cf_datetime",
"(",
"num_dates",
",",
"units",
",",
"calendar",
"=",
"None",
",",
"use_cftime",
"=",
"None",
")",
":",
"num_dates",
"=",
"np",
".",
"asarray",
"(",
"num_dates",
")",
"flat_num_dates",
"=",
"num_dates",
".",
"ravel",
"(",
")",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | decode_cf_timedelta | Given an array of numeric timedeltas in netCDF format, convert it into a
numpy timedelta64[ns] array. | xarray/coding/times.py | def decode_cf_timedelta(num_timedeltas, units):
"""Given an array of numeric timedeltas in netCDF format, convert it into a
numpy timedelta64[ns] array.
"""
num_timedeltas = np.asarray(num_timedeltas)
units = _netcdf_to_numpy_timeunit(units)
shape = num_timedeltas.shape
num_timedeltas = num... | def decode_cf_timedelta(num_timedeltas, units):
"""Given an array of numeric timedeltas in netCDF format, convert it into a
numpy timedelta64[ns] array.
"""
num_timedeltas = np.asarray(num_timedeltas)
units = _netcdf_to_numpy_timeunit(units)
shape = num_timedeltas.shape
num_timedeltas = num... | [
"Given",
"an",
"array",
"of",
"numeric",
"timedeltas",
"in",
"netCDF",
"format",
"convert",
"it",
"into",
"a",
"numpy",
"timedelta64",
"[",
"ns",
"]",
"array",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L201-L215 | [
"def",
"decode_cf_timedelta",
"(",
"num_timedeltas",
",",
"units",
")",
":",
"num_timedeltas",
"=",
"np",
".",
"asarray",
"(",
"num_timedeltas",
")",
"units",
"=",
"_netcdf_to_numpy_timeunit",
"(",
"units",
")",
"shape",
"=",
"num_timedeltas",
".",
"shape",
"num... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | infer_calendar_name | Given an array of datetimes, infer the CF calendar name | xarray/coding/times.py | def infer_calendar_name(dates):
"""Given an array of datetimes, infer the CF calendar name"""
if np.asarray(dates).dtype == 'datetime64[ns]':
return 'proleptic_gregorian'
else:
return np.asarray(dates).ravel()[0].calendar | def infer_calendar_name(dates):
"""Given an array of datetimes, infer the CF calendar name"""
if np.asarray(dates).dtype == 'datetime64[ns]':
return 'proleptic_gregorian'
else:
return np.asarray(dates).ravel()[0].calendar | [
"Given",
"an",
"array",
"of",
"datetimes",
"infer",
"the",
"CF",
"calendar",
"name"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L228-L233 | [
"def",
"infer_calendar_name",
"(",
"dates",
")",
":",
"if",
"np",
".",
"asarray",
"(",
"dates",
")",
".",
"dtype",
"==",
"'datetime64[ns]'",
":",
"return",
"'proleptic_gregorian'",
"else",
":",
"return",
"np",
".",
"asarray",
"(",
"dates",
")",
".",
"ravel... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | infer_datetime_units | Given an array of datetimes, returns a CF compatible time-unit string of
the form "{time_unit} since {date[0]}", where `time_unit` is 'days',
'hours', 'minutes' or 'seconds' (the first one that can evenly divide all
unique time deltas in `dates`) | xarray/coding/times.py | def infer_datetime_units(dates):
"""Given an array of datetimes, returns a CF compatible time-unit string of
the form "{time_unit} since {date[0]}", where `time_unit` is 'days',
'hours', 'minutes' or 'seconds' (the first one that can evenly divide all
unique time deltas in `dates`)
"""
dates = n... | def infer_datetime_units(dates):
"""Given an array of datetimes, returns a CF compatible time-unit string of
the form "{time_unit} since {date[0]}", where `time_unit` is 'days',
'hours', 'minutes' or 'seconds' (the first one that can evenly divide all
unique time deltas in `dates`)
"""
dates = n... | [
"Given",
"an",
"array",
"of",
"datetimes",
"returns",
"a",
"CF",
"compatible",
"time",
"-",
"unit",
"string",
"of",
"the",
"form",
"{",
"time_unit",
"}",
"since",
"{",
"date",
"[",
"0",
"]",
"}",
"where",
"time_unit",
"is",
"days",
"hours",
"minutes",
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L236-L257 | [
"def",
"infer_datetime_units",
"(",
"dates",
")",
":",
"dates",
"=",
"np",
".",
"asarray",
"(",
"dates",
")",
".",
"ravel",
"(",
")",
"if",
"np",
".",
"asarray",
"(",
"dates",
")",
".",
"dtype",
"==",
"'datetime64[ns]'",
":",
"dates",
"=",
"pd",
".",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | format_cftime_datetime | Converts a cftime.datetime object to a string with the format:
YYYY-MM-DD HH:MM:SS.UUUUUU | xarray/coding/times.py | def format_cftime_datetime(date):
"""Converts a cftime.datetime object to a string with the format:
YYYY-MM-DD HH:MM:SS.UUUUUU
"""
return '{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'.format(
date.year, date.month, date.day, date.hour, date.minute, date.second,
date.microsecond) | def format_cftime_datetime(date):
"""Converts a cftime.datetime object to a string with the format:
YYYY-MM-DD HH:MM:SS.UUUUUU
"""
return '{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'.format(
date.year, date.month, date.day, date.hour, date.minute, date.second,
date.microsecond) | [
"Converts",
"a",
"cftime",
".",
"datetime",
"object",
"to",
"a",
"string",
"with",
"the",
"format",
":",
"YYYY",
"-",
"MM",
"-",
"DD",
"HH",
":",
"MM",
":",
"SS",
".",
"UUUUUU"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L260-L266 | [
"def",
"format_cftime_datetime",
"(",
"date",
")",
":",
"return",
"'{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}.{:06d}'",
".",
"format",
"(",
"date",
".",
"year",
",",
"date",
".",
"month",
",",
"date",
".",
"day",
",",
"date",
".",
"hour",
",",
"date",
".",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | infer_timedelta_units | Given an array of timedeltas, returns a CF compatible time-unit from
{'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly
divide all unique time deltas in `deltas`) | xarray/coding/times.py | def infer_timedelta_units(deltas):
"""Given an array of timedeltas, returns a CF compatible time-unit from
{'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly
divide all unique time deltas in `deltas`)
"""
deltas = pd.to_timedelta(np.asarray(deltas).ravel(), box=False)
unique_t... | def infer_timedelta_units(deltas):
"""Given an array of timedeltas, returns a CF compatible time-unit from
{'days', 'hours', 'minutes' 'seconds'} (the first one that can evenly
divide all unique time deltas in `deltas`)
"""
deltas = pd.to_timedelta(np.asarray(deltas).ravel(), box=False)
unique_t... | [
"Given",
"an",
"array",
"of",
"timedeltas",
"returns",
"a",
"CF",
"compatible",
"time",
"-",
"unit",
"from",
"{",
"days",
"hours",
"minutes",
"seconds",
"}",
"(",
"the",
"first",
"one",
"that",
"can",
"evenly",
"divide",
"all",
"unique",
"time",
"deltas",
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L269-L277 | [
"def",
"infer_timedelta_units",
"(",
"deltas",
")",
":",
"deltas",
"=",
"pd",
".",
"to_timedelta",
"(",
"np",
".",
"asarray",
"(",
"deltas",
")",
".",
"ravel",
"(",
")",
",",
"box",
"=",
"False",
")",
"unique_timedeltas",
"=",
"np",
".",
"unique",
"(",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | cftime_to_nptime | Given an array of cftime.datetime objects, return an array of
numpy.datetime64 objects of the same size | xarray/coding/times.py | def cftime_to_nptime(times):
"""Given an array of cftime.datetime objects, return an array of
numpy.datetime64 objects of the same size"""
times = np.asarray(times)
new = np.empty(times.shape, dtype='M8[ns]')
for i, t in np.ndenumerate(times):
try:
# Use pandas.Timestamp in place... | def cftime_to_nptime(times):
"""Given an array of cftime.datetime objects, return an array of
numpy.datetime64 objects of the same size"""
times = np.asarray(times)
new = np.empty(times.shape, dtype='M8[ns]')
for i, t in np.ndenumerate(times):
try:
# Use pandas.Timestamp in place... | [
"Given",
"an",
"array",
"of",
"cftime",
".",
"datetime",
"objects",
"return",
"an",
"array",
"of",
"numpy",
".",
"datetime64",
"objects",
"of",
"the",
"same",
"size"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L280-L297 | [
"def",
"cftime_to_nptime",
"(",
"times",
")",
":",
"times",
"=",
"np",
".",
"asarray",
"(",
"times",
")",
"new",
"=",
"np",
".",
"empty",
"(",
"times",
".",
"shape",
",",
"dtype",
"=",
"'M8[ns]'",
")",
"for",
"i",
",",
"t",
"in",
"np",
".",
"nden... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _encode_datetime_with_cftime | Fallback method for encoding dates using cftime.
This method is more flexible than xarray's parsing using datetime64[ns]
arrays but also slower because it loops over each element. | xarray/coding/times.py | def _encode_datetime_with_cftime(dates, units, calendar):
"""Fallback method for encoding dates using cftime.
This method is more flexible than xarray's parsing using datetime64[ns]
arrays but also slower because it loops over each element.
"""
cftime = _import_cftime()
if np.issubdtype(dates.... | def _encode_datetime_with_cftime(dates, units, calendar):
"""Fallback method for encoding dates using cftime.
This method is more flexible than xarray's parsing using datetime64[ns]
arrays but also slower because it loops over each element.
"""
cftime = _import_cftime()
if np.issubdtype(dates.... | [
"Fallback",
"method",
"for",
"encoding",
"dates",
"using",
"cftime",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L310-L325 | [
"def",
"_encode_datetime_with_cftime",
"(",
"dates",
",",
"units",
",",
"calendar",
")",
":",
"cftime",
"=",
"_import_cftime",
"(",
")",
"if",
"np",
".",
"issubdtype",
"(",
"dates",
".",
"dtype",
",",
"np",
".",
"datetime64",
")",
":",
"# numpy's broken date... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | encode_cf_datetime | Given an array of datetime objects, returns the tuple `(num, units,
calendar)` suitable for a CF compliant time variable.
Unlike `date2num`, this function can handle datetime64 arrays.
See also
--------
cftime.date2num | xarray/coding/times.py | def encode_cf_datetime(dates, units=None, calendar=None):
"""Given an array of datetime objects, returns the tuple `(num, units,
calendar)` suitable for a CF compliant time variable.
Unlike `date2num`, this function can handle datetime64 arrays.
See also
--------
cftime.date2num
"""
da... | def encode_cf_datetime(dates, units=None, calendar=None):
"""Given an array of datetime objects, returns the tuple `(num, units,
calendar)` suitable for a CF compliant time variable.
Unlike `date2num`, this function can handle datetime64 arrays.
See also
--------
cftime.date2num
"""
da... | [
"Given",
"an",
"array",
"of",
"datetime",
"objects",
"returns",
"the",
"tuple",
"(",
"num",
"units",
"calendar",
")",
"suitable",
"for",
"a",
"CF",
"compliant",
"time",
"variable",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/times.py#L335-L381 | [
"def",
"encode_cf_datetime",
"(",
"dates",
",",
"units",
"=",
"None",
",",
"calendar",
"=",
"None",
")",
":",
"dates",
"=",
"np",
".",
"asarray",
"(",
"dates",
")",
"if",
"units",
"is",
"None",
":",
"units",
"=",
"infer_datetime_units",
"(",
"dates",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _validate_dataset_names | DataArray.name and Dataset keys must be a string or None | xarray/backends/api.py | def _validate_dataset_names(dataset):
"""DataArray.name and Dataset keys must be a string or None"""
def check_name(name):
if isinstance(name, str):
if not name:
raise ValueError('Invalid name for DataArray or Dataset key: '
'string must be le... | def _validate_dataset_names(dataset):
"""DataArray.name and Dataset keys must be a string or None"""
def check_name(name):
if isinstance(name, str):
if not name:
raise ValueError('Invalid name for DataArray or Dataset key: '
'string must be le... | [
"DataArray",
".",
"name",
"and",
"Dataset",
"keys",
"must",
"be",
"a",
"string",
"or",
"None"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L125-L138 | [
"def",
"_validate_dataset_names",
"(",
"dataset",
")",
":",
"def",
"check_name",
"(",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"'Invalid name for DataArray or Dataset key: '",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _validate_attrs | `attrs` must have a string key and a value which is either: a number,
a string, an ndarray or a list/tuple of numbers/strings. | xarray/backends/api.py | def _validate_attrs(dataset):
"""`attrs` must have a string key and a value which is either: a number,
a string, an ndarray or a list/tuple of numbers/strings.
"""
def check_attr(name, value):
if isinstance(name, str):
if not name:
raise ValueError('Invalid name for a... | def _validate_attrs(dataset):
"""`attrs` must have a string key and a value which is either: a number,
a string, an ndarray or a list/tuple of numbers/strings.
"""
def check_attr(name, value):
if isinstance(name, str):
if not name:
raise ValueError('Invalid name for a... | [
"attrs",
"must",
"have",
"a",
"string",
"key",
"and",
"a",
"value",
"which",
"is",
"either",
":",
"a",
"number",
"a",
"string",
"an",
"ndarray",
"or",
"a",
"list",
"/",
"tuple",
"of",
"numbers",
"/",
"strings",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L141-L169 | [
"def",
"_validate_attrs",
"(",
"dataset",
")",
":",
"def",
"check_attr",
"(",
"name",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"'Invalid name for attr: string must be... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_dataset | Load and decode a dataset from a file or file-like object.
Parameters
----------
filename_or_obj : str, Path, file or xarray.backends.*DataStore
Strings and Path objects are interpreted as a path to a netCDF file
or an OpenDAP URL and opened with python-netCDF4, unless the filename
... | xarray/backends/api.py | def open_dataset(filename_or_obj, group=None, decode_cf=True,
mask_and_scale=None, decode_times=True, autoclose=None,
concat_characters=True, decode_coords=True, engine=None,
chunks=None, lock=None, cache=None, drop_variables=None,
backend_kwargs=None,... | def open_dataset(filename_or_obj, group=None, decode_cf=True,
mask_and_scale=None, decode_times=True, autoclose=None,
concat_characters=True, decode_coords=True, engine=None,
chunks=None, lock=None, cache=None, drop_variables=None,
backend_kwargs=None,... | [
"Load",
"and",
"decode",
"a",
"dataset",
"from",
"a",
"file",
"or",
"file",
"-",
"like",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L188-L401 | [
"def",
"open_dataset",
"(",
"filename_or_obj",
",",
"group",
"=",
"None",
",",
"decode_cf",
"=",
"True",
",",
"mask_and_scale",
"=",
"None",
",",
"decode_times",
"=",
"True",
",",
"autoclose",
"=",
"None",
",",
"concat_characters",
"=",
"True",
",",
"decode_... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_dataarray | Open an DataArray from a netCDF file containing a single data variable.
This is designed to read netCDF files with only one data variable. If
multiple variables are present then a ValueError is raised.
Parameters
----------
filename_or_obj : str, Path, file or xarray.backends.*DataStore
St... | xarray/backends/api.py | def open_dataarray(filename_or_obj, group=None, decode_cf=True,
mask_and_scale=None, decode_times=True, autoclose=None,
concat_characters=True, decode_coords=True, engine=None,
chunks=None, lock=None, cache=None, drop_variables=None,
backend_kw... | def open_dataarray(filename_or_obj, group=None, decode_cf=True,
mask_and_scale=None, decode_times=True, autoclose=None,
concat_characters=True, decode_coords=True, engine=None,
chunks=None, lock=None, cache=None, drop_variables=None,
backend_kw... | [
"Open",
"an",
"DataArray",
"from",
"a",
"netCDF",
"file",
"containing",
"a",
"single",
"data",
"variable",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L404-L529 | [
"def",
"open_dataarray",
"(",
"filename_or_obj",
",",
"group",
"=",
"None",
",",
"decode_cf",
"=",
"True",
",",
"mask_and_scale",
"=",
"None",
",",
"decode_times",
"=",
"True",
",",
"autoclose",
"=",
"None",
",",
"concat_characters",
"=",
"True",
",",
"decod... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_mfdataset | Open multiple files as a single dataset.
Requires dask to be installed. See documentation for details on dask [1].
Attributes from the first dataset file are used for the combined dataset.
Parameters
----------
paths : str or sequence
Either a string glob in the form "path/to/my/files/*.nc... | xarray/backends/api.py | def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT,
compat='no_conflicts', preprocess=None, engine=None,
lock=None, data_vars='all', coords='different',
autoclose=None, parallel=False, **kwargs):
"""Open multiple files as a single dataset.
... | def open_mfdataset(paths, chunks=None, concat_dim=_CONCAT_DIM_DEFAULT,
compat='no_conflicts', preprocess=None, engine=None,
lock=None, data_vars='all', coords='different',
autoclose=None, parallel=False, **kwargs):
"""Open multiple files as a single dataset.
... | [
"Open",
"multiple",
"files",
"as",
"a",
"single",
"dataset",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L541-L727 | [
"def",
"open_mfdataset",
"(",
"paths",
",",
"chunks",
"=",
"None",
",",
"concat_dim",
"=",
"_CONCAT_DIM_DEFAULT",
",",
"compat",
"=",
"'no_conflicts'",
",",
"preprocess",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"lock",
"=",
"None",
",",
"data_vars",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | to_netcdf | This function creates an appropriate datastore for writing a dataset to
disk as a netCDF file
See `Dataset.to_netcdf` for full API docs.
The ``multifile`` argument is only for the private use of save_mfdataset. | xarray/backends/api.py | def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None,
engine=None, encoding=None, unlimited_dims=None, compute=True,
multifile=False):
"""This function creates an appropriate datastore for writing a dataset to
disk as a netCDF file
See `Dataset.to_netcdf` ... | def to_netcdf(dataset, path_or_file=None, mode='w', format=None, group=None,
engine=None, encoding=None, unlimited_dims=None, compute=True,
multifile=False):
"""This function creates an appropriate datastore for writing a dataset to
disk as a netCDF file
See `Dataset.to_netcdf` ... | [
"This",
"function",
"creates",
"an",
"appropriate",
"datastore",
"for",
"writing",
"a",
"dataset",
"to",
"disk",
"as",
"a",
"netCDF",
"file"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L735-L826 | [
"def",
"to_netcdf",
"(",
"dataset",
",",
"path_or_file",
"=",
"None",
",",
"mode",
"=",
"'w'",
",",
"format",
"=",
"None",
",",
"group",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"unlimited_dims",
"=",
"None",
",",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | dump_to_store | Store dataset contents to a backends.*DataStore object. | xarray/backends/api.py | def dump_to_store(dataset, store, writer=None, encoder=None,
encoding=None, unlimited_dims=None):
"""Store dataset contents to a backends.*DataStore object."""
if writer is None:
writer = ArrayWriter()
if encoding is None:
encoding = {}
variables, attrs = conventions.... | def dump_to_store(dataset, store, writer=None, encoder=None,
encoding=None, unlimited_dims=None):
"""Store dataset contents to a backends.*DataStore object."""
if writer is None:
writer = ArrayWriter()
if encoding is None:
encoding = {}
variables, attrs = conventions.... | [
"Store",
"dataset",
"contents",
"to",
"a",
"backends",
".",
"*",
"DataStore",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L829-L851 | [
"def",
"dump_to_store",
"(",
"dataset",
",",
"store",
",",
"writer",
"=",
"None",
",",
"encoder",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"unlimited_dims",
"=",
"None",
")",
":",
"if",
"writer",
"is",
"None",
":",
"writer",
"=",
"ArrayWriter",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | save_mfdataset | Write multiple datasets to disk as netCDF files simultaneously.
This function is intended for use with datasets consisting of dask.array
objects, in which case it can write the multiple datasets to disk
simultaneously using a shared thread pool.
When not using dask, it is no different than calling ``t... | xarray/backends/api.py | def save_mfdataset(datasets, paths, mode='w', format=None, groups=None,
engine=None, compute=True):
"""Write multiple datasets to disk as netCDF files simultaneously.
This function is intended for use with datasets consisting of dask.array
objects, in which case it can write the multiple... | def save_mfdataset(datasets, paths, mode='w', format=None, groups=None,
engine=None, compute=True):
"""Write multiple datasets to disk as netCDF files simultaneously.
This function is intended for use with datasets consisting of dask.array
objects, in which case it can write the multiple... | [
"Write",
"multiple",
"datasets",
"to",
"disk",
"as",
"netCDF",
"files",
"simultaneously",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L854-L950 | [
"def",
"save_mfdataset",
"(",
"datasets",
",",
"paths",
",",
"mode",
"=",
"'w'",
",",
"format",
"=",
"None",
",",
"groups",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"compute",
"=",
"True",
")",
":",
"if",
"mode",
"==",
"'w'",
"and",
"len",
"("... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | to_zarr | This function creates an appropriate datastore for writing a dataset to
a zarr ztore
See `Dataset.to_zarr` for full API docs. | xarray/backends/api.py | def to_zarr(dataset, store=None, mode='w-', synchronizer=None, group=None,
encoding=None, compute=True, consolidated=False):
"""This function creates an appropriate datastore for writing a dataset to
a zarr ztore
See `Dataset.to_zarr` for full API docs.
"""
if isinstance(store, Path):
... | def to_zarr(dataset, store=None, mode='w-', synchronizer=None, group=None,
encoding=None, compute=True, consolidated=False):
"""This function creates an appropriate datastore for writing a dataset to
a zarr ztore
See `Dataset.to_zarr` for full API docs.
"""
if isinstance(store, Path):
... | [
"This",
"function",
"creates",
"an",
"appropriate",
"datastore",
"for",
"writing",
"a",
"dataset",
"to",
"a",
"zarr",
"ztore"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/api.py#L953-L985 | [
"def",
"to_zarr",
"(",
"dataset",
",",
"store",
"=",
"None",
",",
"mode",
"=",
"'w-'",
",",
"synchronizer",
"=",
"None",
",",
"group",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"compute",
"=",
"True",
",",
"consolidated",
"=",
"False",
")",
":"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | remove_unused_levels | create a new MultiIndex from the current that removing
unused levels, meaning that they are not expressed in the labels
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
be .equals() to the original.
.. versionadded:: 0.20.0
Retur... | xarray/core/pdcompat.py | def remove_unused_levels(self):
"""
create a new MultiIndex from the current that removing
unused levels, meaning that they are not expressed in the labels
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
be .equals() to the orig... | def remove_unused_levels(self):
"""
create a new MultiIndex from the current that removing
unused levels, meaning that they are not expressed in the labels
The resulting MultiIndex will have the same outward
appearance, meaning the same .values and ordering. It will also
be .equals() to the orig... | [
"create",
"a",
"new",
"MultiIndex",
"from",
"the",
"current",
"that",
"removing",
"unused",
"levels",
"meaning",
"that",
"they",
"are",
"not",
"expressed",
"in",
"the",
"labels",
"The",
"resulting",
"MultiIndex",
"will",
"have",
"the",
"same",
"outward",
"appe... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/pdcompat.py#L45-L118 | [
"def",
"remove_unused_levels",
"(",
"self",
")",
":",
"import",
"pandas",
".",
"core",
".",
"algorithms",
"as",
"algos",
"new_levels",
"=",
"[",
"]",
"new_labels",
"=",
"[",
"]",
"changed",
"=",
"False",
"for",
"lev",
",",
"lab",
"in",
"zip",
"(",
"sel... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | robust_getitem | Robustly index an array, using retry logic with exponential backoff if any
of the errors ``catch`` are raised. The initial_delay is measured in ms.
With the default settings, the maximum delay will be in the range of 32-64
seconds. | xarray/backends/common.py | def robust_getitem(array, key, catch=Exception, max_retries=6,
initial_delay=500):
"""
Robustly index an array, using retry logic with exponential backoff if any
of the errors ``catch`` are raised. The initial_delay is measured in ms.
With the default settings, the maximum delay will... | def robust_getitem(array, key, catch=Exception, max_retries=6,
initial_delay=500):
"""
Robustly index an array, using retry logic with exponential backoff if any
of the errors ``catch`` are raised. The initial_delay is measured in ms.
With the default settings, the maximum delay will... | [
"Robustly",
"index",
"an",
"array",
"using",
"retry",
"logic",
"with",
"exponential",
"backoff",
"if",
"any",
"of",
"the",
"errors",
"catch",
"are",
"raised",
".",
"The",
"initial_delay",
"is",
"measured",
"in",
"ms",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L43-L65 | [
"def",
"robust_getitem",
"(",
"array",
",",
"key",
",",
"catch",
"=",
"Exception",
",",
"max_retries",
"=",
"6",
",",
"initial_delay",
"=",
"500",
")",
":",
"assert",
"max_retries",
">=",
"0",
"for",
"n",
"in",
"range",
"(",
"max_retries",
"+",
"1",
")... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractDataStore.load | This loads the variables and attributes simultaneously.
A centralized loading function makes it easier to create
data stores that do automatic encoding/decoding.
For example::
class SuffixAppendingDataStore(AbstractDataStore):
def load(self):
va... | xarray/backends/common.py | def load(self):
"""
This loads the variables and attributes simultaneously.
A centralized loading function makes it easier to create
data stores that do automatic encoding/decoding.
For example::
class SuffixAppendingDataStore(AbstractDataStore):
de... | def load(self):
"""
This loads the variables and attributes simultaneously.
A centralized loading function makes it easier to create
data stores that do automatic encoding/decoding.
For example::
class SuffixAppendingDataStore(AbstractDataStore):
de... | [
"This",
"loads",
"the",
"variables",
"and",
"attributes",
"simultaneously",
".",
"A",
"centralized",
"loading",
"function",
"makes",
"it",
"easier",
"to",
"create",
"data",
"stores",
"that",
"do",
"automatic",
"encoding",
"/",
"decoding",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L98-L122 | [
"def",
"load",
"(",
"self",
")",
":",
"variables",
"=",
"FrozenOrderedDict",
"(",
"(",
"_decode_variable_name",
"(",
"k",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"get_variables",
"(",
")",
".",
"items",
"(",
")",
")",
"attributes... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractWritableDataStore.encode | Encode the variables and attributes in this store
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
attributes : dict-like
Dictionary of key/value (attribute name / attribute) pairs
Returns
--... | xarray/backends/common.py | def encode(self, variables, attributes):
"""
Encode the variables and attributes in this store
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
attributes : dict-like
Dictionary of key/value (... | def encode(self, variables, attributes):
"""
Encode the variables and attributes in this store
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
attributes : dict-like
Dictionary of key/value (... | [
"Encode",
"the",
"variables",
"and",
"attributes",
"in",
"this",
"store"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L186-L207 | [
"def",
"encode",
"(",
"self",
",",
"variables",
",",
"attributes",
")",
":",
"variables",
"=",
"OrderedDict",
"(",
"[",
"(",
"k",
",",
"self",
".",
"encode_variable",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"variables",
".",
"items",
"(",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractWritableDataStore.store | Top level method for putting data on this store, this method:
- encodes variables/attributes
- sets dimensions
- sets variables
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
attributes : ... | xarray/backends/common.py | def store(self, variables, attributes, check_encoding_set=frozenset(),
writer=None, unlimited_dims=None):
"""
Top level method for putting data on this store, this method:
- encodes variables/attributes
- sets dimensions
- sets variables
Parameters
... | def store(self, variables, attributes, check_encoding_set=frozenset(),
writer=None, unlimited_dims=None):
"""
Top level method for putting data on this store, this method:
- encodes variables/attributes
- sets dimensions
- sets variables
Parameters
... | [
"Top",
"level",
"method",
"for",
"putting",
"data",
"on",
"this",
"store",
"this",
"method",
":",
"-",
"encodes",
"variables",
"/",
"attributes",
"-",
"sets",
"dimensions",
"-",
"sets",
"variables"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L235-L265 | [
"def",
"store",
"(",
"self",
",",
"variables",
",",
"attributes",
",",
"check_encoding_set",
"=",
"frozenset",
"(",
")",
",",
"writer",
"=",
"None",
",",
"unlimited_dims",
"=",
"None",
")",
":",
"if",
"writer",
"is",
"None",
":",
"writer",
"=",
"ArrayWri... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractWritableDataStore.set_attributes | This provides a centralized method to set the dataset attributes on the
data store.
Parameters
----------
attributes : dict-like
Dictionary of key/value (attribute name / attribute) pairs | xarray/backends/common.py | def set_attributes(self, attributes):
"""
This provides a centralized method to set the dataset attributes on the
data store.
Parameters
----------
attributes : dict-like
Dictionary of key/value (attribute name / attribute) pairs
"""
for k, v ... | def set_attributes(self, attributes):
"""
This provides a centralized method to set the dataset attributes on the
data store.
Parameters
----------
attributes : dict-like
Dictionary of key/value (attribute name / attribute) pairs
"""
for k, v ... | [
"This",
"provides",
"a",
"centralized",
"method",
"to",
"set",
"the",
"dataset",
"attributes",
"on",
"the",
"data",
"store",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L267-L278 | [
"def",
"set_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"for",
"k",
",",
"v",
"in",
"attributes",
".",
"items",
"(",
")",
":",
"self",
".",
"set_attribute",
"(",
"k",
",",
"v",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.