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 | AbstractWritableDataStore.set_variables | This provides a centralized method to set the variables on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
check_encoding_set : list-like
List of variables that should be checked for ... | xarray/backends/common.py | def set_variables(self, variables, check_encoding_set, writer,
unlimited_dims=None):
"""
This provides a centralized method to set the variables on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (vari... | def set_variables(self, variables, check_encoding_set, writer,
unlimited_dims=None):
"""
This provides a centralized method to set the variables on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (vari... | [
"This",
"provides",
"a",
"centralized",
"method",
"to",
"set",
"the",
"variables",
"on",
"the",
"data",
"store",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L280-L305 | [
"def",
"set_variables",
"(",
"self",
",",
"variables",
",",
"check_encoding_set",
",",
"writer",
",",
"unlimited_dims",
"=",
"None",
")",
":",
"for",
"vn",
",",
"v",
"in",
"variables",
".",
"items",
"(",
")",
":",
"name",
"=",
"_encode_variable_name",
"(",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractWritableDataStore.set_dimensions | This provides a centralized method to set the dimensions on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
unlimited_dims : list-like
List of dimension names that should be treated a... | xarray/backends/common.py | def set_dimensions(self, variables, unlimited_dims=None):
"""
This provides a centralized method to set the dimensions on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
unlimited... | def set_dimensions(self, variables, unlimited_dims=None):
"""
This provides a centralized method to set the dimensions on the data
store.
Parameters
----------
variables : dict-like
Dictionary of key/value (variable name / xr.Variable) pairs
unlimited... | [
"This",
"provides",
"a",
"centralized",
"method",
"to",
"set",
"the",
"dimensions",
"on",
"the",
"data",
"store",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/common.py#L307-L338 | [
"def",
"set_dimensions",
"(",
"self",
",",
"variables",
",",
"unlimited_dims",
"=",
"None",
")",
":",
"if",
"unlimited_dims",
"is",
"None",
":",
"unlimited_dims",
"=",
"set",
"(",
")",
"existing_dims",
"=",
"self",
".",
"get_dimensions",
"(",
")",
"dims",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _season_from_months | Compute season (DJF, MAM, JJA, SON) from month ordinal | xarray/core/accessors.py | def _season_from_months(months):
"""Compute season (DJF, MAM, JJA, SON) from month ordinal
"""
# TODO: Move "season" accessor upstream into pandas
seasons = np.array(['DJF', 'MAM', 'JJA', 'SON'])
months = np.asarray(months)
return seasons[(months // 3) % 4] | def _season_from_months(months):
"""Compute season (DJF, MAM, JJA, SON) from month ordinal
"""
# TODO: Move "season" accessor upstream into pandas
seasons = np.array(['DJF', 'MAM', 'JJA', 'SON'])
months = np.asarray(months)
return seasons[(months // 3) % 4] | [
"Compute",
"season",
"(",
"DJF",
"MAM",
"JJA",
"SON",
")",
"from",
"month",
"ordinal"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L8-L14 | [
"def",
"_season_from_months",
"(",
"months",
")",
":",
"# TODO: Move \"season\" accessor upstream into pandas",
"seasons",
"=",
"np",
".",
"array",
"(",
"[",
"'DJF'",
",",
"'MAM'",
",",
"'JJA'",
",",
"'SON'",
"]",
")",
"months",
"=",
"np",
".",
"asarray",
"(",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _access_through_cftimeindex | Coerce an array of datetime-like values to a CFTimeIndex
and access requested datetime component | xarray/core/accessors.py | def _access_through_cftimeindex(values, name):
"""Coerce an array of datetime-like values to a CFTimeIndex
and access requested datetime component
"""
from ..coding.cftimeindex import CFTimeIndex
values_as_cftimeindex = CFTimeIndex(values.ravel())
if name == 'season':
months = values_as_... | def _access_through_cftimeindex(values, name):
"""Coerce an array of datetime-like values to a CFTimeIndex
and access requested datetime component
"""
from ..coding.cftimeindex import CFTimeIndex
values_as_cftimeindex = CFTimeIndex(values.ravel())
if name == 'season':
months = values_as_... | [
"Coerce",
"an",
"array",
"of",
"datetime",
"-",
"like",
"values",
"to",
"a",
"CFTimeIndex",
"and",
"access",
"requested",
"datetime",
"component"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L17-L28 | [
"def",
"_access_through_cftimeindex",
"(",
"values",
",",
"name",
")",
":",
"from",
".",
".",
"coding",
".",
"cftimeindex",
"import",
"CFTimeIndex",
"values_as_cftimeindex",
"=",
"CFTimeIndex",
"(",
"values",
".",
"ravel",
"(",
")",
")",
"if",
"name",
"==",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _access_through_series | Coerce an array of datetime-like values to a pandas Series and
access requested datetime component | xarray/core/accessors.py | def _access_through_series(values, name):
"""Coerce an array of datetime-like values to a pandas Series and
access requested datetime component
"""
values_as_series = pd.Series(values.ravel())
if name == "season":
months = values_as_series.dt.month.values
field_values = _season_from_... | def _access_through_series(values, name):
"""Coerce an array of datetime-like values to a pandas Series and
access requested datetime component
"""
values_as_series = pd.Series(values.ravel())
if name == "season":
months = values_as_series.dt.month.values
field_values = _season_from_... | [
"Coerce",
"an",
"array",
"of",
"datetime",
"-",
"like",
"values",
"to",
"a",
"pandas",
"Series",
"and",
"access",
"requested",
"datetime",
"component"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L31-L41 | [
"def",
"_access_through_series",
"(",
"values",
",",
"name",
")",
":",
"values_as_series",
"=",
"pd",
".",
"Series",
"(",
"values",
".",
"ravel",
"(",
")",
")",
"if",
"name",
"==",
"\"season\"",
":",
"months",
"=",
"values_as_series",
".",
"dt",
".",
"mo... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _get_date_field | Indirectly access pandas' libts.get_date_field by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str
Name of datetime field to access
dtype : dtype-li... | xarray/core/accessors.py | def _get_date_field(values, name, dtype):
"""Indirectly access pandas' libts.get_date_field by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str
Name... | def _get_date_field(values, name, dtype):
"""Indirectly access pandas' libts.get_date_field by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str
Name... | [
"Indirectly",
"access",
"pandas",
"libts",
".",
"get_date_field",
"by",
"wrapping",
"data",
"as",
"a",
"Series",
"and",
"calling",
"through",
".",
"dt",
"attribute",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L44-L73 | [
"def",
"_get_date_field",
"(",
"values",
",",
"name",
",",
"dtype",
")",
":",
"if",
"is_np_datetime_like",
"(",
"values",
".",
"dtype",
")",
":",
"access_method",
"=",
"_access_through_series",
"else",
":",
"access_method",
"=",
"_access_through_cftimeindex",
"if"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _round_series | Coerce an array of datetime-like values to a pandas Series and
apply requested rounding | xarray/core/accessors.py | def _round_series(values, name, freq):
"""Coerce an array of datetime-like values to a pandas Series and
apply requested rounding
"""
values_as_series = pd.Series(values.ravel())
method = getattr(values_as_series.dt, name)
field_values = method(freq=freq).values
return field_values.reshape(... | def _round_series(values, name, freq):
"""Coerce an array of datetime-like values to a pandas Series and
apply requested rounding
"""
values_as_series = pd.Series(values.ravel())
method = getattr(values_as_series.dt, name)
field_values = method(freq=freq).values
return field_values.reshape(... | [
"Coerce",
"an",
"array",
"of",
"datetime",
"-",
"like",
"values",
"to",
"a",
"pandas",
"Series",
"and",
"apply",
"requested",
"rounding"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L76-L84 | [
"def",
"_round_series",
"(",
"values",
",",
"name",
",",
"freq",
")",
":",
"values_as_series",
"=",
"pd",
".",
"Series",
"(",
"values",
".",
"ravel",
"(",
")",
")",
"method",
"=",
"getattr",
"(",
"values_as_series",
".",
"dt",
",",
"name",
")",
"field_... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _round_field | Indirectly access pandas rounding functions by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str (ceil, floor, round)
Name of rounding function
freq ... | xarray/core/accessors.py | def _round_field(values, name, freq):
"""Indirectly access pandas rounding functions by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str (ceil, floor, round... | def _round_field(values, name, freq):
"""Indirectly access pandas rounding functions by wrapping data
as a Series and calling through `.dt` attribute.
Parameters
----------
values : np.ndarray or dask.array-like
Array-like container of datetime-like values
name : str (ceil, floor, round... | [
"Indirectly",
"access",
"pandas",
"rounding",
"functions",
"by",
"wrapping",
"data",
"as",
"a",
"Series",
"and",
"calling",
"through",
".",
"dt",
"attribute",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L87-L110 | [
"def",
"_round_field",
"(",
"values",
",",
"name",
",",
"freq",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"dask_array_type",
")",
":",
"from",
"dask",
".",
"array",
"import",
"map_blocks",
"return",
"map_blocks",
"(",
"_round_series",
",",
"values",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | fillna | Fill missing values in this object with data from the other object.
Follows normal broadcasting and alignment rules.
Parameters
----------
join : {'outer', 'inner', 'left', 'right'}, optional
Method for joining the indexes of the passed objects along each
dimension
- 'outer': us... | xarray/core/ops.py | def fillna(data, other, join="left", dataset_join="left"):
"""Fill missing values in this object with data from the other object.
Follows normal broadcasting and alignment rules.
Parameters
----------
join : {'outer', 'inner', 'left', 'right'}, optional
Method for joining the indexes of the... | def fillna(data, other, join="left", dataset_join="left"):
"""Fill missing values in this object with data from the other object.
Follows normal broadcasting and alignment rules.
Parameters
----------
join : {'outer', 'inner', 'left', 'right'}, optional
Method for joining the indexes of the... | [
"Fill",
"missing",
"values",
"in",
"this",
"object",
"with",
"data",
"from",
"the",
"other",
"object",
".",
"Follows",
"normal",
"broadcasting",
"and",
"alignment",
"rules",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/ops.py#L135-L165 | [
"def",
"fillna",
"(",
"data",
",",
"other",
",",
"join",
"=",
"\"left\"",
",",
"dataset_join",
"=",
"\"left\"",
")",
":",
"from",
".",
"computation",
"import",
"apply_ufunc",
"return",
"apply_ufunc",
"(",
"duck_array_ops",
".",
"fillna",
",",
"data",
",",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | where_method | Return elements from `self` or `other` depending on `cond`.
Parameters
----------
cond : DataArray or Dataset with boolean dtype
Locations at which to preserve this objects values.
other : scalar, DataArray or Dataset, optional
Value to use for locations in this object where ``cond`` is... | xarray/core/ops.py | def where_method(self, cond, other=dtypes.NA):
"""Return elements from `self` or `other` depending on `cond`.
Parameters
----------
cond : DataArray or Dataset with boolean dtype
Locations at which to preserve this objects values.
other : scalar, DataArray or Dataset, optional
Value... | def where_method(self, cond, other=dtypes.NA):
"""Return elements from `self` or `other` depending on `cond`.
Parameters
----------
cond : DataArray or Dataset with boolean dtype
Locations at which to preserve this objects values.
other : scalar, DataArray or Dataset, optional
Value... | [
"Return",
"elements",
"from",
"self",
"or",
"other",
"depending",
"on",
"cond",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/ops.py#L168-L191 | [
"def",
"where_method",
"(",
"self",
",",
"cond",
",",
"other",
"=",
"dtypes",
".",
"NA",
")",
":",
"from",
".",
"computation",
"import",
"apply_ufunc",
"# alignment for three arguments is complicated, so don't support it yet",
"join",
"=",
"'inner'",
"if",
"other",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | open_dataset | Load a dataset from the online repository (requires internet).
If a local copy is found then always use that to avoid network traffic.
Parameters
----------
name : str
Name of the netcdf file containing the dataset
ie. 'air_temperature'
cache_dir : string, optional
The dire... | xarray/tutorial.py | def open_dataset(name, cache=True, cache_dir=_default_cache_dir,
github_url='https://github.com/pydata/xarray-data',
branch='master', **kws):
"""
Load a dataset from the online repository (requires internet).
If a local copy is found then always use that to avoid network t... | def open_dataset(name, cache=True, cache_dir=_default_cache_dir,
github_url='https://github.com/pydata/xarray-data',
branch='master', **kws):
"""
Load a dataset from the online repository (requires internet).
If a local copy is found then always use that to avoid network t... | [
"Load",
"a",
"dataset",
"from",
"the",
"online",
"repository",
"(",
"requires",
"internet",
")",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/tutorial.py#L26-L89 | [
"def",
"open_dataset",
"(",
"name",
",",
"cache",
"=",
"True",
",",
"cache_dir",
"=",
"_default_cache_dir",
",",
"github_url",
"=",
"'https://github.com/pydata/xarray-data'",
",",
"branch",
"=",
"'master'",
",",
"*",
"*",
"kws",
")",
":",
"longdir",
"=",
"_os"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | load_dataset | `load_dataset` will be removed a future version of xarray. The current
behavior of this function can be achived by using
`tutorial.open_dataset(...).load()`.
See Also
--------
open_dataset | xarray/tutorial.py | def load_dataset(*args, **kwargs):
"""
`load_dataset` will be removed a future version of xarray. The current
behavior of this function can be achived by using
`tutorial.open_dataset(...).load()`.
See Also
--------
open_dataset
"""
warnings.warn(
"load_dataset` will be remov... | def load_dataset(*args, **kwargs):
"""
`load_dataset` will be removed a future version of xarray. The current
behavior of this function can be achived by using
`tutorial.open_dataset(...).load()`.
See Also
--------
open_dataset
"""
warnings.warn(
"load_dataset` will be remov... | [
"load_dataset",
"will",
"be",
"removed",
"a",
"future",
"version",
"of",
"xarray",
".",
"The",
"current",
"behavior",
"of",
"this",
"function",
"can",
"be",
"achived",
"by",
"using",
"tutorial",
".",
"open_dataset",
"(",
"...",
")",
".",
"load",
"()",
"."
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/tutorial.py#L92-L107 | [
"def",
"load_dataset",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"load_dataset` will be removed in a future version of xarray. The \"",
"\"current behavior of this function can be achived by using \"",
"\"`tutorial.open_dataset(...).load()... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | CachingFileManager._make_key | Make a key for caching files in the LRU cache. | xarray/backends/file_manager.py | def _make_key(self):
"""Make a key for caching files in the LRU cache."""
value = (self._opener,
self._args,
'a' if self._mode == 'w' else self._mode,
tuple(sorted(self._kwargs.items())))
return _HashedSequence(value) | def _make_key(self):
"""Make a key for caching files in the LRU cache."""
value = (self._opener,
self._args,
'a' if self._mode == 'w' else self._mode,
tuple(sorted(self._kwargs.items())))
return _HashedSequence(value) | [
"Make",
"a",
"key",
"for",
"caching",
"files",
"in",
"the",
"LRU",
"cache",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L134-L140 | [
"def",
"_make_key",
"(",
"self",
")",
":",
"value",
"=",
"(",
"self",
".",
"_opener",
",",
"self",
".",
"_args",
",",
"'a'",
"if",
"self",
".",
"_mode",
"==",
"'w'",
"else",
"self",
".",
"_mode",
",",
"tuple",
"(",
"sorted",
"(",
"self",
".",
"_k... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | CachingFileManager.acquire | Acquiring a file object from the manager.
A new file is only opened if it has expired from the
least-recently-used cache.
This method uses a lock, which ensures that it is thread-safe. You can
safely acquire a file in multiple threads at the same time, as long as
the underlying... | xarray/backends/file_manager.py | def acquire(self, needs_lock=True):
"""Acquiring a file object from the manager.
A new file is only opened if it has expired from the
least-recently-used cache.
This method uses a lock, which ensures that it is thread-safe. You can
safely acquire a file in multiple threads at t... | def acquire(self, needs_lock=True):
"""Acquiring a file object from the manager.
A new file is only opened if it has expired from the
least-recently-used cache.
This method uses a lock, which ensures that it is thread-safe. You can
safely acquire a file in multiple threads at t... | [
"Acquiring",
"a",
"file",
"object",
"from",
"the",
"manager",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L151-L178 | [
"def",
"acquire",
"(",
"self",
",",
"needs_lock",
"=",
"True",
")",
":",
"with",
"self",
".",
"_optional_lock",
"(",
"needs_lock",
")",
":",
"try",
":",
"file",
"=",
"self",
".",
"_cache",
"[",
"self",
".",
"_key",
"]",
"except",
"KeyError",
":",
"kw... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | CachingFileManager.close | Explicitly close any associated file object (if necessary). | xarray/backends/file_manager.py | def close(self, needs_lock=True):
"""Explicitly close any associated file object (if necessary)."""
# TODO: remove needs_lock if/when we have a reentrant lock in
# dask.distributed: https://github.com/dask/dask/issues/3832
with self._optional_lock(needs_lock):
default = None
... | def close(self, needs_lock=True):
"""Explicitly close any associated file object (if necessary)."""
# TODO: remove needs_lock if/when we have a reentrant lock in
# dask.distributed: https://github.com/dask/dask/issues/3832
with self._optional_lock(needs_lock):
default = None
... | [
"Explicitly",
"close",
"any",
"associated",
"file",
"object",
"(",
"if",
"necessary",
")",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/file_manager.py#L180-L188 | [
"def",
"close",
"(",
"self",
",",
"needs_lock",
"=",
"True",
")",
":",
"# TODO: remove needs_lock if/when we have a reentrant lock in",
"# dask.distributed: https://github.com/dask/dask/issues/3832",
"with",
"self",
".",
"_optional_lock",
"(",
"needs_lock",
")",
":",
"default... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | LRUCache._enforce_size_limit | Shrink the cache if necessary, evicting the oldest items. | xarray/backends/lru_cache.py | def _enforce_size_limit(self, capacity):
"""Shrink the cache if necessary, evicting the oldest items."""
while len(self._cache) > capacity:
key, value = self._cache.popitem(last=False)
if self._on_evict is not None:
self._on_evict(key, value) | def _enforce_size_limit(self, capacity):
"""Shrink the cache if necessary, evicting the oldest items."""
while len(self._cache) > capacity:
key, value = self._cache.popitem(last=False)
if self._on_evict is not None:
self._on_evict(key, value) | [
"Shrink",
"the",
"cache",
"if",
"necessary",
"evicting",
"the",
"oldest",
"items",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/lru_cache.py#L46-L51 | [
"def",
"_enforce_size_limit",
"(",
"self",
",",
"capacity",
")",
":",
"while",
"len",
"(",
"self",
".",
"_cache",
")",
">",
"capacity",
":",
"key",
",",
"value",
"=",
"self",
".",
"_cache",
".",
"popitem",
"(",
"last",
"=",
"False",
")",
"if",
"self"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | LRUCache.maxsize | Resize the cache, evicting the oldest items if necessary. | xarray/backends/lru_cache.py | def maxsize(self, size):
"""Resize the cache, evicting the oldest items if necessary."""
if size < 0:
raise ValueError('maxsize must be non-negative')
with self._lock:
self._enforce_size_limit(size)
self._maxsize = size | def maxsize(self, size):
"""Resize the cache, evicting the oldest items if necessary."""
if size < 0:
raise ValueError('maxsize must be non-negative')
with self._lock:
self._enforce_size_limit(size)
self._maxsize = size | [
"Resize",
"the",
"cache",
"evicting",
"the",
"oldest",
"items",
"if",
"necessary",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/lru_cache.py#L84-L90 | [
"def",
"maxsize",
"(",
"self",
",",
"size",
")",
":",
"if",
"size",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'maxsize must be non-negative'",
")",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_enforce_size_limit",
"(",
"size",
")",
"self",
".",
"_... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_sys_info | Returns system information as a dict | xarray/util/print_versions.py | def get_sys_info():
"Returns system information as a dict"
blob = []
# get full commit hash
commit = None
if os.path.isdir(".git") and os.path.isdir("xarray"):
try:
pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "),
stdout=subpr... | def get_sys_info():
"Returns system information as a dict"
blob = []
# get full commit hash
commit = None
if os.path.isdir(".git") and os.path.isdir("xarray"):
try:
pipe = subprocess.Popen('git log --format="%H" -n 1'.split(" "),
stdout=subpr... | [
"Returns",
"system",
"information",
"as",
"a",
"dict"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/util/print_versions.py#L16-L62 | [
"def",
"get_sys_info",
"(",
")",
":",
"blob",
"=",
"[",
"]",
"# get full commit hash",
"commit",
"=",
"None",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"\".git\"",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"\"xarray\"",
")",
":",
"try",
":"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | expanded_indexer | Given a key for indexing an ndarray, return an equivalent key which is a
tuple with length equal to the number of dimensions.
The expansion is done by replacing all `Ellipsis` items with the right
number of full slices and then padding the key with full slices so that it
reaches the appropriate dimensi... | xarray/core/indexing.py | def expanded_indexer(key, ndim):
"""Given a key for indexing an ndarray, return an equivalent key which is a
tuple with length equal to the number of dimensions.
The expansion is done by replacing all `Ellipsis` items with the right
number of full slices and then padding the key with full slices so tha... | def expanded_indexer(key, ndim):
"""Given a key for indexing an ndarray, return an equivalent key which is a
tuple with length equal to the number of dimensions.
The expansion is done by replacing all `Ellipsis` items with the right
number of full slices and then padding the key with full slices so tha... | [
"Given",
"a",
"key",
"for",
"indexing",
"an",
"ndarray",
"return",
"an",
"equivalent",
"key",
"which",
"is",
"a",
"tuple",
"with",
"length",
"equal",
"to",
"the",
"number",
"of",
"dimensions",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L16-L43 | [
"def",
"expanded_indexer",
"(",
"key",
",",
"ndim",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"tuple",
")",
":",
"# numpy treats non-tuple keys equivalent to tuples of length 1",
"key",
"=",
"(",
"key",
",",
")",
"new_key",
"=",
"[",
"]",
"# handli... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _asarray_tuplesafe | Convert values into a numpy array of at most 1-dimension, while preserving
tuples.
Adapted from pandas.core.common._asarray_tuplesafe | xarray/core/indexing.py | def _asarray_tuplesafe(values):
"""
Convert values into a numpy array of at most 1-dimension, while preserving
tuples.
Adapted from pandas.core.common._asarray_tuplesafe
"""
if isinstance(values, tuple):
result = utils.to_0d_object_array(values)
else:
result = np.asarray(val... | def _asarray_tuplesafe(values):
"""
Convert values into a numpy array of at most 1-dimension, while preserving
tuples.
Adapted from pandas.core.common._asarray_tuplesafe
"""
if isinstance(values, tuple):
result = utils.to_0d_object_array(values)
else:
result = np.asarray(val... | [
"Convert",
"values",
"into",
"a",
"numpy",
"array",
"of",
"at",
"most",
"1",
"-",
"dimension",
"while",
"preserving",
"tuples",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L71-L86 | [
"def",
"_asarray_tuplesafe",
"(",
"values",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"tuple",
")",
":",
"result",
"=",
"utils",
".",
"to_0d_object_array",
"(",
"values",
")",
"else",
":",
"result",
"=",
"np",
".",
"asarray",
"(",
"values",
")",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_indexer_nd | Call pd.Index.get_indexer(labels). | xarray/core/indexing.py | def get_indexer_nd(index, labels, method=None, tolerance=None):
""" Call pd.Index.get_indexer(labels). """
kwargs = _index_method_kwargs(method, tolerance)
flat_labels = np.ravel(labels)
flat_indexer = index.get_indexer(flat_labels, **kwargs)
indexer = flat_indexer.reshape(labels.shape)
return ... | def get_indexer_nd(index, labels, method=None, tolerance=None):
""" Call pd.Index.get_indexer(labels). """
kwargs = _index_method_kwargs(method, tolerance)
flat_labels = np.ravel(labels)
flat_indexer = index.get_indexer(flat_labels, **kwargs)
indexer = flat_indexer.reshape(labels.shape)
return ... | [
"Call",
"pd",
".",
"Index",
".",
"get_indexer",
"(",
"labels",
")",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L111-L118 | [
"def",
"get_indexer_nd",
"(",
"index",
",",
"labels",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
")",
":",
"kwargs",
"=",
"_index_method_kwargs",
"(",
"method",
",",
"tolerance",
")",
"flat_labels",
"=",
"np",
".",
"ravel",
"(",
"labels",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | convert_label_indexer | Given a pandas.Index and labels (e.g., from __getitem__) for one
dimension, return an indexer suitable for indexing an ndarray along that
dimension. If `index` is a pandas.MultiIndex and depending on `label`,
return a new pandas.Index or pandas.MultiIndex (otherwise return None). | xarray/core/indexing.py | def convert_label_indexer(index, label, index_name='', method=None,
tolerance=None):
"""Given a pandas.Index and labels (e.g., from __getitem__) for one
dimension, return an indexer suitable for indexing an ndarray along that
dimension. If `index` is a pandas.MultiIndex and dependi... | def convert_label_indexer(index, label, index_name='', method=None,
tolerance=None):
"""Given a pandas.Index and labels (e.g., from __getitem__) for one
dimension, return an indexer suitable for indexing an ndarray along that
dimension. If `index` is a pandas.MultiIndex and dependi... | [
"Given",
"a",
"pandas",
".",
"Index",
"and",
"labels",
"(",
"e",
".",
"g",
".",
"from",
"__getitem__",
")",
"for",
"one",
"dimension",
"return",
"an",
"indexer",
"suitable",
"for",
"indexing",
"an",
"ndarray",
"along",
"that",
"dimension",
".",
"If",
"in... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L121-L192 | [
"def",
"convert_label_indexer",
"(",
"index",
",",
"label",
",",
"index_name",
"=",
"''",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
")",
":",
"new_index",
"=",
"None",
"if",
"isinstance",
"(",
"label",
",",
"slice",
")",
":",
"if",
"me... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_dim_indexers | Given a xarray data object and label based indexers, return a mapping
of label indexers with only dimension names as keys.
It groups multiple level indexers given on a multi-index dimension
into a single, dictionary indexer for that dimension (Raise a ValueError
if it is not possible). | xarray/core/indexing.py | def get_dim_indexers(data_obj, indexers):
"""Given a xarray data object and label based indexers, return a mapping
of label indexers with only dimension names as keys.
It groups multiple level indexers given on a multi-index dimension
into a single, dictionary indexer for that dimension (Raise a ValueE... | def get_dim_indexers(data_obj, indexers):
"""Given a xarray data object and label based indexers, return a mapping
of label indexers with only dimension names as keys.
It groups multiple level indexers given on a multi-index dimension
into a single, dictionary indexer for that dimension (Raise a ValueE... | [
"Given",
"a",
"xarray",
"data",
"object",
"and",
"label",
"based",
"indexers",
"return",
"a",
"mapping",
"of",
"label",
"indexers",
"with",
"only",
"dimension",
"names",
"as",
"keys",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L195-L225 | [
"def",
"get_dim_indexers",
"(",
"data_obj",
",",
"indexers",
")",
":",
"invalid",
"=",
"[",
"k",
"for",
"k",
"in",
"indexers",
"if",
"k",
"not",
"in",
"data_obj",
".",
"dims",
"and",
"k",
"not",
"in",
"data_obj",
".",
"_level_coords",
"]",
"if",
"inval... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | remap_label_indexers | Given an xarray data object and label based indexers, return a mapping
of equivalent location based indexers. Also return a mapping of updated
pandas index objects (in case of multi-index level drop). | xarray/core/indexing.py | def remap_label_indexers(data_obj, indexers, method=None, tolerance=None):
"""Given an xarray data object and label based indexers, return a mapping
of equivalent location based indexers. Also return a mapping of updated
pandas index objects (in case of multi-index level drop).
"""
if method is not ... | def remap_label_indexers(data_obj, indexers, method=None, tolerance=None):
"""Given an xarray data object and label based indexers, return a mapping
of equivalent location based indexers. Also return a mapping of updated
pandas index objects (in case of multi-index level drop).
"""
if method is not ... | [
"Given",
"an",
"xarray",
"data",
"object",
"and",
"label",
"based",
"indexers",
"return",
"a",
"mapping",
"of",
"equivalent",
"location",
"based",
"indexers",
".",
"Also",
"return",
"a",
"mapping",
"of",
"updated",
"pandas",
"index",
"objects",
"(",
"in",
"c... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L228-L257 | [
"def",
"remap_label_indexers",
"(",
"data_obj",
",",
"indexers",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
")",
":",
"if",
"method",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"method",
",",
"str",
")",
":",
"raise",
"TypeErro... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | slice_slice | Given a slice and the size of the dimension to which it will be applied,
index it with another slice to return a new slice equivalent to applying
the slices sequentially | xarray/core/indexing.py | def slice_slice(old_slice, applied_slice, size):
"""Given a slice and the size of the dimension to which it will be applied,
index it with another slice to return a new slice equivalent to applying
the slices sequentially
"""
step = (old_slice.step or 1) * (applied_slice.step or 1)
# For now, u... | def slice_slice(old_slice, applied_slice, size):
"""Given a slice and the size of the dimension to which it will be applied,
index it with another slice to return a new slice equivalent to applying
the slices sequentially
"""
step = (old_slice.step or 1) * (applied_slice.step or 1)
# For now, u... | [
"Given",
"a",
"slice",
"and",
"the",
"size",
"of",
"the",
"dimension",
"to",
"which",
"it",
"will",
"be",
"applied",
"index",
"it",
"with",
"another",
"slice",
"to",
"return",
"a",
"new",
"slice",
"equivalent",
"to",
"applying",
"the",
"slices",
"sequentia... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L260-L279 | [
"def",
"slice_slice",
"(",
"old_slice",
",",
"applied_slice",
",",
"size",
")",
":",
"step",
"=",
"(",
"old_slice",
".",
"step",
"or",
"1",
")",
"*",
"(",
"applied_slice",
".",
"step",
"or",
"1",
")",
"# For now, use the hack of turning old_slice into an ndarray... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | as_indexable | This function always returns a ExplicitlyIndexed subclass,
so that the vectorized indexing is always possible with the returned
object. | xarray/core/indexing.py | def as_indexable(array):
"""
This function always returns a ExplicitlyIndexed subclass,
so that the vectorized indexing is always possible with the returned
object.
"""
if isinstance(array, ExplicitlyIndexed):
return array
if isinstance(array, np.ndarray):
return NumpyIndexin... | def as_indexable(array):
"""
This function always returns a ExplicitlyIndexed subclass,
so that the vectorized indexing is always possible with the returned
object.
"""
if isinstance(array, ExplicitlyIndexed):
return array
if isinstance(array, np.ndarray):
return NumpyIndexin... | [
"This",
"function",
"always",
"returns",
"a",
"ExplicitlyIndexed",
"subclass",
"so",
"that",
"the",
"vectorized",
"indexing",
"is",
"always",
"possible",
"with",
"the",
"returned",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L639-L653 | [
"def",
"as_indexable",
"(",
"array",
")",
":",
"if",
"isinstance",
"(",
"array",
",",
"ExplicitlyIndexed",
")",
":",
"return",
"array",
"if",
"isinstance",
"(",
"array",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"NumpyIndexingAdapter",
"(",
"array",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _outer_to_vectorized_indexer | Convert an OuterIndexer into an vectorized indexer.
Parameters
----------
key : Outer/Basic Indexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
VectorizedIndexer
Tuple suitable for use to index a NumPy array with ... | xarray/core/indexing.py | def _outer_to_vectorized_indexer(key, shape):
"""Convert an OuterIndexer into an vectorized indexer.
Parameters
----------
key : Outer/Basic Indexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
VectorizedIndexer
... | def _outer_to_vectorized_indexer(key, shape):
"""Convert an OuterIndexer into an vectorized indexer.
Parameters
----------
key : Outer/Basic Indexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
VectorizedIndexer
... | [
"Convert",
"an",
"OuterIndexer",
"into",
"an",
"vectorized",
"indexer",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L656-L689 | [
"def",
"_outer_to_vectorized_indexer",
"(",
"key",
",",
"shape",
")",
":",
"key",
"=",
"key",
".",
"tuple",
"n_dim",
"=",
"len",
"(",
"[",
"k",
"for",
"k",
"in",
"key",
"if",
"not",
"isinstance",
"(",
"k",
",",
"integer_types",
")",
"]",
")",
"i_dim"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _outer_to_numpy_indexer | Convert an OuterIndexer into an indexer for NumPy.
Parameters
----------
key : Basic/OuterIndexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
tuple
Tuple suitable for use to index a NumPy array. | xarray/core/indexing.py | def _outer_to_numpy_indexer(key, shape):
"""Convert an OuterIndexer into an indexer for NumPy.
Parameters
----------
key : Basic/OuterIndexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
tuple
Tuple suitable fo... | def _outer_to_numpy_indexer(key, shape):
"""Convert an OuterIndexer into an indexer for NumPy.
Parameters
----------
key : Basic/OuterIndexer
An indexer to convert.
shape : tuple
Shape of the array subject to the indexing.
Returns
-------
tuple
Tuple suitable fo... | [
"Convert",
"an",
"OuterIndexer",
"into",
"an",
"indexer",
"for",
"NumPy",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L692-L713 | [
"def",
"_outer_to_numpy_indexer",
"(",
"key",
",",
"shape",
")",
":",
"if",
"len",
"(",
"[",
"k",
"for",
"k",
"in",
"key",
".",
"tuple",
"if",
"not",
"isinstance",
"(",
"k",
",",
"slice",
")",
"]",
")",
"<=",
"1",
":",
"# If there is only one vector an... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _combine_indexers | Combine two indexers.
Parameters
----------
old_key: ExplicitIndexer
The first indexer for the original array
shape: tuple of ints
Shape of the original array to be indexed by old_key
new_key:
The second indexer for indexing original[old_key] | xarray/core/indexing.py | def _combine_indexers(old_key, shape, new_key):
""" Combine two indexers.
Parameters
----------
old_key: ExplicitIndexer
The first indexer for the original array
shape: tuple of ints
Shape of the original array to be indexed by old_key
new_key:
The second indexer for ind... | def _combine_indexers(old_key, shape, new_key):
""" Combine two indexers.
Parameters
----------
old_key: ExplicitIndexer
The first indexer for the original array
shape: tuple of ints
Shape of the original array to be indexed by old_key
new_key:
The second indexer for ind... | [
"Combine",
"two",
"indexers",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L716-L740 | [
"def",
"_combine_indexers",
"(",
"old_key",
",",
"shape",
",",
"new_key",
")",
":",
"if",
"not",
"isinstance",
"(",
"old_key",
",",
"VectorizedIndexer",
")",
":",
"old_key",
"=",
"_outer_to_vectorized_indexer",
"(",
"old_key",
",",
"shape",
")",
"if",
"len",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | explicit_indexing_adapter | Support explicit indexing by delegating to a raw indexing method.
Outer and/or vectorized indexers are supported by indexing a second time
with a NumPy array.
Parameters
----------
key : ExplicitIndexer
Explicit indexing object.
shape : Tuple[int, ...]
Shape of the indexed arra... | xarray/core/indexing.py | def explicit_indexing_adapter(
key, shape, indexing_support, raw_indexing_method):
"""Support explicit indexing by delegating to a raw indexing method.
Outer and/or vectorized indexers are supported by indexing a second time
with a NumPy array.
Parameters
----------
key : ExplicitIndex... | def explicit_indexing_adapter(
key, shape, indexing_support, raw_indexing_method):
"""Support explicit indexing by delegating to a raw indexing method.
Outer and/or vectorized indexers are supported by indexing a second time
with a NumPy array.
Parameters
----------
key : ExplicitIndex... | [
"Support",
"explicit",
"indexing",
"by",
"delegating",
"to",
"a",
"raw",
"indexing",
"method",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L754-L782 | [
"def",
"explicit_indexing_adapter",
"(",
"key",
",",
"shape",
",",
"indexing_support",
",",
"raw_indexing_method",
")",
":",
"raw_key",
",",
"numpy_indices",
"=",
"decompose_indexer",
"(",
"key",
",",
"shape",
",",
"indexing_support",
")",
"result",
"=",
"raw_inde... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _decompose_slice | convert a slice to successive two slices. The first slice always has
a positive step. | xarray/core/indexing.py | def _decompose_slice(key, size):
""" convert a slice to successive two slices. The first slice always has
a positive step.
"""
start, stop, step = key.indices(size)
if step > 0:
# If key already has a positive step, use it as is in the backend
return key, slice(None)
else:
... | def _decompose_slice(key, size):
""" convert a slice to successive two slices. The first slice always has
a positive step.
"""
start, stop, step = key.indices(size)
if step > 0:
# If key already has a positive step, use it as is in the backend
return key, slice(None)
else:
... | [
"convert",
"a",
"slice",
"to",
"successive",
"two",
"slices",
".",
"The",
"first",
"slice",
"always",
"has",
"a",
"positive",
"step",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L793-L806 | [
"def",
"_decompose_slice",
"(",
"key",
",",
"size",
")",
":",
"start",
",",
"stop",
",",
"step",
"=",
"key",
".",
"indices",
"(",
"size",
")",
"if",
"step",
">",
"0",
":",
"# If key already has a positive step, use it as is in the backend",
"return",
"key",
",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _decompose_vectorized_indexer | Decompose vectorized indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index loaded on-memory np.ndarray.
Parameters
----------
indexer: VectorizedIndexer
indexing_support: one of IndexerSupport entries
Ret... | xarray/core/indexing.py | def _decompose_vectorized_indexer(indexer, shape, indexing_support):
"""
Decompose vectorized indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index loaded on-memory np.ndarray.
Parameters
----------
indexe... | def _decompose_vectorized_indexer(indexer, shape, indexing_support):
"""
Decompose vectorized indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index loaded on-memory np.ndarray.
Parameters
----------
indexe... | [
"Decompose",
"vectorized",
"indexer",
"to",
"the",
"successive",
"two",
"indexers",
"where",
"the",
"first",
"indexer",
"will",
"be",
"used",
"to",
"index",
"backend",
"arrays",
"while",
"the",
"second",
"one",
"is",
"used",
"to",
"index",
"loaded",
"on",
"-... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L809-L877 | [
"def",
"_decompose_vectorized_indexer",
"(",
"indexer",
",",
"shape",
",",
"indexing_support",
")",
":",
"assert",
"isinstance",
"(",
"indexer",
",",
"VectorizedIndexer",
")",
"if",
"indexing_support",
"is",
"IndexingSupport",
".",
"VECTORIZED",
":",
"return",
"inde... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _decompose_outer_indexer | Decompose outer indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index the loaded on-memory np.ndarray.
Parameters
----------
indexer: VectorizedIndexer
indexing_support: One of the entries of IndexingSupport
... | xarray/core/indexing.py | def _decompose_outer_indexer(indexer, shape, indexing_support):
"""
Decompose outer indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index the loaded on-memory np.ndarray.
Parameters
----------
indexer: Vec... | def _decompose_outer_indexer(indexer, shape, indexing_support):
"""
Decompose outer indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the second one
is used to index the loaded on-memory np.ndarray.
Parameters
----------
indexer: Vec... | [
"Decompose",
"outer",
"indexer",
"to",
"the",
"successive",
"two",
"indexers",
"where",
"the",
"first",
"indexer",
"will",
"be",
"used",
"to",
"index",
"backend",
"arrays",
"while",
"the",
"second",
"one",
"is",
"used",
"to",
"index",
"the",
"loaded",
"on",
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L880-L994 | [
"def",
"_decompose_outer_indexer",
"(",
"indexer",
",",
"shape",
",",
"indexing_support",
")",
":",
"if",
"indexing_support",
"==",
"IndexingSupport",
".",
"VECTORIZED",
":",
"return",
"indexer",
",",
"BasicIndexer",
"(",
"(",
")",
")",
"assert",
"isinstance",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _arrayize_vectorized_indexer | Return an identical vindex but slices are replaced by arrays | xarray/core/indexing.py | def _arrayize_vectorized_indexer(indexer, shape):
""" Return an identical vindex but slices are replaced by arrays """
slices = [v for v in indexer.tuple if isinstance(v, slice)]
if len(slices) == 0:
return indexer
arrays = [v for v in indexer.tuple if isinstance(v, np.ndarray)]
n_dim = arr... | def _arrayize_vectorized_indexer(indexer, shape):
""" Return an identical vindex but slices are replaced by arrays """
slices = [v for v in indexer.tuple if isinstance(v, slice)]
if len(slices) == 0:
return indexer
arrays = [v for v in indexer.tuple if isinstance(v, np.ndarray)]
n_dim = arr... | [
"Return",
"an",
"identical",
"vindex",
"but",
"slices",
"are",
"replaced",
"by",
"arrays"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L997-L1015 | [
"def",
"_arrayize_vectorized_indexer",
"(",
"indexer",
",",
"shape",
")",
":",
"slices",
"=",
"[",
"v",
"for",
"v",
"in",
"indexer",
".",
"tuple",
"if",
"isinstance",
"(",
"v",
",",
"slice",
")",
"]",
"if",
"len",
"(",
"slices",
")",
"==",
"0",
":",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _dask_array_with_chunks_hint | Create a dask array using the chunks hint for dimensions of size > 1. | xarray/core/indexing.py | def _dask_array_with_chunks_hint(array, chunks):
"""Create a dask array using the chunks hint for dimensions of size > 1."""
import dask.array as da
if len(chunks) < array.ndim:
raise ValueError('not enough chunks in hint')
new_chunks = []
for chunk, size in zip(chunks, array.shape):
... | def _dask_array_with_chunks_hint(array, chunks):
"""Create a dask array using the chunks hint for dimensions of size > 1."""
import dask.array as da
if len(chunks) < array.ndim:
raise ValueError('not enough chunks in hint')
new_chunks = []
for chunk, size in zip(chunks, array.shape):
... | [
"Create",
"a",
"dask",
"array",
"using",
"the",
"chunks",
"hint",
"for",
"dimensions",
"of",
"size",
">",
"1",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1018-L1026 | [
"def",
"_dask_array_with_chunks_hint",
"(",
"array",
",",
"chunks",
")",
":",
"import",
"dask",
".",
"array",
"as",
"da",
"if",
"len",
"(",
"chunks",
")",
"<",
"array",
".",
"ndim",
":",
"raise",
"ValueError",
"(",
"'not enough chunks in hint'",
")",
"new_ch... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | create_mask | Create a mask for indexing with a fill-value.
Parameters
----------
indexer : ExplicitIndexer
Indexer with -1 in integer or ndarray value to indicate locations in
the result that should be masked.
shape : tuple
Shape of the array being indexed.
chunks_hint : tuple, optional
... | xarray/core/indexing.py | def create_mask(indexer, shape, chunks_hint=None):
"""Create a mask for indexing with a fill-value.
Parameters
----------
indexer : ExplicitIndexer
Indexer with -1 in integer or ndarray value to indicate locations in
the result that should be masked.
shape : tuple
Shape of t... | def create_mask(indexer, shape, chunks_hint=None):
"""Create a mask for indexing with a fill-value.
Parameters
----------
indexer : ExplicitIndexer
Indexer with -1 in integer or ndarray value to indicate locations in
the result that should be masked.
shape : tuple
Shape of t... | [
"Create",
"a",
"mask",
"for",
"indexing",
"with",
"a",
"fill",
"-",
"value",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1042-L1085 | [
"def",
"create_mask",
"(",
"indexer",
",",
"shape",
",",
"chunks_hint",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"OuterIndexer",
")",
":",
"key",
"=",
"_outer_to_vectorized_indexer",
"(",
"indexer",
",",
"shape",
")",
".",
"tuple",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _posify_mask_subindexer | Convert masked indices in a flat array to the nearest unmasked index.
Parameters
----------
index : np.ndarray
One dimensional ndarray with dtype=int.
Returns
-------
np.ndarray
One dimensional ndarray with all values equal to -1 replaced by an
adjacent non-masked eleme... | xarray/core/indexing.py | def _posify_mask_subindexer(index):
"""Convert masked indices in a flat array to the nearest unmasked index.
Parameters
----------
index : np.ndarray
One dimensional ndarray with dtype=int.
Returns
-------
np.ndarray
One dimensional ndarray with all values equal to -1 repla... | def _posify_mask_subindexer(index):
"""Convert masked indices in a flat array to the nearest unmasked index.
Parameters
----------
index : np.ndarray
One dimensional ndarray with dtype=int.
Returns
-------
np.ndarray
One dimensional ndarray with all values equal to -1 repla... | [
"Convert",
"masked",
"indices",
"in",
"a",
"flat",
"array",
"to",
"the",
"nearest",
"unmasked",
"index",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1088-L1111 | [
"def",
"_posify_mask_subindexer",
"(",
"index",
")",
":",
"masked",
"=",
"index",
"==",
"-",
"1",
"unmasked_locs",
"=",
"np",
".",
"flatnonzero",
"(",
"~",
"masked",
")",
"if",
"not",
"unmasked_locs",
".",
"size",
":",
"# indexing unmasked_locs is invalid",
"r... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | posify_mask_indexer | Convert masked values (-1) in an indexer to nearest unmasked values.
This routine is useful for dask, where it can be much faster to index
adjacent points than arbitrary points from the end of an array.
Parameters
----------
indexer : ExplicitIndexer
Input indexer.
Returns
-------... | xarray/core/indexing.py | def posify_mask_indexer(indexer):
"""Convert masked values (-1) in an indexer to nearest unmasked values.
This routine is useful for dask, where it can be much faster to index
adjacent points than arbitrary points from the end of an array.
Parameters
----------
indexer : ExplicitIndexer
... | def posify_mask_indexer(indexer):
"""Convert masked values (-1) in an indexer to nearest unmasked values.
This routine is useful for dask, where it can be much faster to index
adjacent points than arbitrary points from the end of an array.
Parameters
----------
indexer : ExplicitIndexer
... | [
"Convert",
"masked",
"values",
"(",
"-",
"1",
")",
"in",
"an",
"indexer",
"to",
"nearest",
"unmasked",
"values",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/indexing.py#L1114-L1134 | [
"def",
"posify_mask_indexer",
"(",
"indexer",
")",
":",
"key",
"=",
"tuple",
"(",
"_posify_mask_subindexer",
"(",
"k",
".",
"ravel",
"(",
")",
")",
".",
"reshape",
"(",
"k",
".",
"shape",
")",
"if",
"isinstance",
"(",
"k",
",",
"np",
".",
"ndarray",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | import_seaborn | import seaborn and handle deprecation of apionly module | xarray/plot/utils.py | def import_seaborn():
'''import seaborn and handle deprecation of apionly module'''
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
try:
import seaborn.apionly as sns
if (w and issubclass(w[-1].category, UserWarning) and
... | def import_seaborn():
'''import seaborn and handle deprecation of apionly module'''
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
try:
import seaborn.apionly as sns
if (w and issubclass(w[-1].category, UserWarning) and
... | [
"import",
"seaborn",
"and",
"handle",
"deprecation",
"of",
"apionly",
"module"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L27-L40 | [
"def",
"import_seaborn",
"(",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",
"True",
")",
"as",
"w",
":",
"warnings",
".",
"simplefilter",
"(",
"\"always\"",
")",
"try",
":",
"import",
"seaborn",
".",
"apionly",
"as",
"sns",
"if... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _build_discrete_cmap | Build a discrete colormap and normalization of the data. | xarray/plot/utils.py | def _build_discrete_cmap(cmap, levels, extend, filled):
"""
Build a discrete colormap and normalization of the data.
"""
import matplotlib as mpl
if not filled:
# non-filled contour plots
extend = 'max'
if extend == 'both':
ext_n = 2
elif extend in ['min', 'max']:
... | def _build_discrete_cmap(cmap, levels, extend, filled):
"""
Build a discrete colormap and normalization of the data.
"""
import matplotlib as mpl
if not filled:
# non-filled contour plots
extend = 'max'
if extend == 'both':
ext_n = 2
elif extend in ['min', 'max']:
... | [
"Build",
"a",
"discrete",
"colormap",
"and",
"normalization",
"of",
"the",
"data",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L81-L106 | [
"def",
"_build_discrete_cmap",
"(",
"cmap",
",",
"levels",
",",
"extend",
",",
"filled",
")",
":",
"import",
"matplotlib",
"as",
"mpl",
"if",
"not",
"filled",
":",
"# non-filled contour plots",
"extend",
"=",
"'max'",
"if",
"extend",
"==",
"'both'",
":",
"ex... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _determine_cmap_params | Use some heuristics to set good defaults for colorbar and range.
Parameters
==========
plot_data: Numpy array
Doesn't handle xarray objects
Returns
=======
cmap_params : dict
Use depends on the type of the plotting function | xarray/plot/utils.py | def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
center=None, robust=False, extend=None,
levels=None, filled=True, norm=None):
"""
Use some heuristics to set good defaults for colorbar and range.
Parameters
==========
plot_... | def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
center=None, robust=False, extend=None,
levels=None, filled=True, norm=None):
"""
Use some heuristics to set good defaults for colorbar and range.
Parameters
==========
plot_... | [
"Use",
"some",
"heuristics",
"to",
"set",
"good",
"defaults",
"for",
"colorbar",
"and",
"range",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L143-L273 | [
"def",
"_determine_cmap_params",
"(",
"plot_data",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"center",
"=",
"None",
",",
"robust",
"=",
"False",
",",
"extend",
"=",
"None",
",",
"levels",
"=",
"None",
",",
"fi... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _infer_xy_labels_3d | Determine x and y labels for showing RGB images.
Attempts to infer which dimension is RGB/RGBA by size and order of dims. | xarray/plot/utils.py | def _infer_xy_labels_3d(darray, x, y, rgb):
"""
Determine x and y labels for showing RGB images.
Attempts to infer which dimension is RGB/RGBA by size and order of dims.
"""
assert rgb is None or rgb != x
assert rgb is None or rgb != y
# Start by detecting and reporting invalid combination... | def _infer_xy_labels_3d(darray, x, y, rgb):
"""
Determine x and y labels for showing RGB images.
Attempts to infer which dimension is RGB/RGBA by size and order of dims.
"""
assert rgb is None or rgb != x
assert rgb is None or rgb != y
# Start by detecting and reporting invalid combination... | [
"Determine",
"x",
"and",
"y",
"labels",
"for",
"showing",
"RGB",
"images",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L276-L323 | [
"def",
"_infer_xy_labels_3d",
"(",
"darray",
",",
"x",
",",
"y",
",",
"rgb",
")",
":",
"assert",
"rgb",
"is",
"None",
"or",
"rgb",
"!=",
"x",
"assert",
"rgb",
"is",
"None",
"or",
"rgb",
"!=",
"y",
"# Start by detecting and reporting invalid combinations of arg... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _infer_xy_labels | Determine x and y labels. For use in _plot2d
darray must be a 2 dimensional data array, or 3d for imshow only. | xarray/plot/utils.py | def _infer_xy_labels(darray, x, y, imshow=False, rgb=None):
"""
Determine x and y labels. For use in _plot2d
darray must be a 2 dimensional data array, or 3d for imshow only.
"""
assert x is None or x != y
if imshow and darray.ndim == 3:
return _infer_xy_labels_3d(darray, x, y, rgb)
... | def _infer_xy_labels(darray, x, y, imshow=False, rgb=None):
"""
Determine x and y labels. For use in _plot2d
darray must be a 2 dimensional data array, or 3d for imshow only.
"""
assert x is None or x != y
if imshow and darray.ndim == 3:
return _infer_xy_labels_3d(darray, x, y, rgb)
... | [
"Determine",
"x",
"and",
"y",
"labels",
".",
"For",
"use",
"in",
"_plot2d"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L326-L350 | [
"def",
"_infer_xy_labels",
"(",
"darray",
",",
"x",
",",
"y",
",",
"imshow",
"=",
"False",
",",
"rgb",
"=",
"None",
")",
":",
"assert",
"x",
"is",
"None",
"or",
"x",
"!=",
"y",
"if",
"imshow",
"and",
"darray",
".",
"ndim",
"==",
"3",
":",
"return... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | label_from_attrs | Makes informative labels if variable metadata (attrs) follows
CF conventions. | xarray/plot/utils.py | def label_from_attrs(da, extra=''):
''' Makes informative labels if variable metadata (attrs) follows
CF conventions. '''
if da.attrs.get('long_name'):
name = da.attrs['long_name']
elif da.attrs.get('standard_name'):
name = da.attrs['standard_name']
elif da.name is not None:
... | def label_from_attrs(da, extra=''):
''' Makes informative labels if variable metadata (attrs) follows
CF conventions. '''
if da.attrs.get('long_name'):
name = da.attrs['long_name']
elif da.attrs.get('standard_name'):
name = da.attrs['standard_name']
elif da.name is not None:
... | [
"Makes",
"informative",
"labels",
"if",
"variable",
"metadata",
"(",
"attrs",
")",
"follows",
"CF",
"conventions",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L382-L400 | [
"def",
"label_from_attrs",
"(",
"da",
",",
"extra",
"=",
"''",
")",
":",
"if",
"da",
".",
"attrs",
".",
"get",
"(",
"'long_name'",
")",
":",
"name",
"=",
"da",
".",
"attrs",
"[",
"'long_name'",
"]",
"elif",
"da",
".",
"attrs",
".",
"get",
"(",
"'... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _interval_to_bound_points | Helper function which returns an array
with the Intervals' boundaries. | xarray/plot/utils.py | def _interval_to_bound_points(array):
"""
Helper function which returns an array
with the Intervals' boundaries.
"""
array_boundaries = np.array([x.left for x in array])
array_boundaries = np.concatenate(
(array_boundaries, np.array([array[-1].right])))
return array_boundaries | def _interval_to_bound_points(array):
"""
Helper function which returns an array
with the Intervals' boundaries.
"""
array_boundaries = np.array([x.left for x in array])
array_boundaries = np.concatenate(
(array_boundaries, np.array([array[-1].right])))
return array_boundaries | [
"Helper",
"function",
"which",
"returns",
"an",
"array",
"with",
"the",
"Intervals",
"boundaries",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L412-L422 | [
"def",
"_interval_to_bound_points",
"(",
"array",
")",
":",
"array_boundaries",
"=",
"np",
".",
"array",
"(",
"[",
"x",
".",
"left",
"for",
"x",
"in",
"array",
"]",
")",
"array_boundaries",
"=",
"np",
".",
"concatenate",
"(",
"(",
"array_boundaries",
",",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _interval_to_double_bound_points | Helper function to deal with a xarray consisting of pd.Intervals. Each
interval is replaced with both boundaries. I.e. the length of xarray
doubles. yarray is modified so it matches the new shape of xarray. | xarray/plot/utils.py | def _interval_to_double_bound_points(xarray, yarray):
"""
Helper function to deal with a xarray consisting of pd.Intervals. Each
interval is replaced with both boundaries. I.e. the length of xarray
doubles. yarray is modified so it matches the new shape of xarray.
"""
xarray1 = np.array([x.left... | def _interval_to_double_bound_points(xarray, yarray):
"""
Helper function to deal with a xarray consisting of pd.Intervals. Each
interval is replaced with both boundaries. I.e. the length of xarray
doubles. yarray is modified so it matches the new shape of xarray.
"""
xarray1 = np.array([x.left... | [
"Helper",
"function",
"to",
"deal",
"with",
"a",
"xarray",
"consisting",
"of",
"pd",
".",
"Intervals",
".",
"Each",
"interval",
"is",
"replaced",
"with",
"both",
"boundaries",
".",
"I",
".",
"e",
".",
"the",
"length",
"of",
"xarray",
"doubles",
".",
"yar... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L425-L438 | [
"def",
"_interval_to_double_bound_points",
"(",
"xarray",
",",
"yarray",
")",
":",
"xarray1",
"=",
"np",
".",
"array",
"(",
"[",
"x",
".",
"left",
"for",
"x",
"in",
"xarray",
"]",
")",
"xarray2",
"=",
"np",
".",
"array",
"(",
"[",
"x",
".",
"right",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _resolve_intervals_2dplot | Helper function to replace the values of a coordinate array containing
pd.Interval with their mid-points or - for pcolormesh - boundaries which
increases length by 1. | xarray/plot/utils.py | def _resolve_intervals_2dplot(val, func_name):
"""
Helper function to replace the values of a coordinate array containing
pd.Interval with their mid-points or - for pcolormesh - boundaries which
increases length by 1.
"""
label_extra = ''
if _valid_other_type(val, [pd.Interval]):
if ... | def _resolve_intervals_2dplot(val, func_name):
"""
Helper function to replace the values of a coordinate array containing
pd.Interval with their mid-points or - for pcolormesh - boundaries which
increases length by 1.
"""
label_extra = ''
if _valid_other_type(val, [pd.Interval]):
if ... | [
"Helper",
"function",
"to",
"replace",
"the",
"values",
"of",
"a",
"coordinate",
"array",
"containing",
"pd",
".",
"Interval",
"with",
"their",
"mid",
"-",
"points",
"or",
"-",
"for",
"pcolormesh",
"-",
"boundaries",
"which",
"increases",
"length",
"by",
"1"... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L441-L455 | [
"def",
"_resolve_intervals_2dplot",
"(",
"val",
",",
"func_name",
")",
":",
"label_extra",
"=",
"''",
"if",
"_valid_other_type",
"(",
"val",
",",
"[",
"pd",
".",
"Interval",
"]",
")",
":",
"if",
"func_name",
"==",
"'pcolormesh'",
":",
"val",
"=",
"_interva... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _valid_other_type | Do all elements of x have a type from types? | xarray/plot/utils.py | def _valid_other_type(x, types):
"""
Do all elements of x have a type from types?
"""
return all(any(isinstance(el, t) for t in types) for el in np.ravel(x)) | def _valid_other_type(x, types):
"""
Do all elements of x have a type from types?
"""
return all(any(isinstance(el, t) for t in types) for el in np.ravel(x)) | [
"Do",
"all",
"elements",
"of",
"x",
"have",
"a",
"type",
"from",
"types?"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L458-L462 | [
"def",
"_valid_other_type",
"(",
"x",
",",
"types",
")",
":",
"return",
"all",
"(",
"any",
"(",
"isinstance",
"(",
"el",
",",
"t",
")",
"for",
"t",
"in",
"types",
")",
"for",
"el",
"in",
"np",
".",
"ravel",
"(",
"x",
")",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _valid_numpy_subdtype | Is any dtype from numpy_types superior to the dtype of x? | xarray/plot/utils.py | def _valid_numpy_subdtype(x, numpy_types):
"""
Is any dtype from numpy_types superior to the dtype of x?
"""
# If any of the types given in numpy_types is understood as numpy.generic,
# all possible x will be considered valid. This is probably unwanted.
for t in numpy_types:
assert not ... | def _valid_numpy_subdtype(x, numpy_types):
"""
Is any dtype from numpy_types superior to the dtype of x?
"""
# If any of the types given in numpy_types is understood as numpy.generic,
# all possible x will be considered valid. This is probably unwanted.
for t in numpy_types:
assert not ... | [
"Is",
"any",
"dtype",
"from",
"numpy_types",
"superior",
"to",
"the",
"dtype",
"of",
"x?"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L465-L474 | [
"def",
"_valid_numpy_subdtype",
"(",
"x",
",",
"numpy_types",
")",
":",
"# If any of the types given in numpy_types is understood as numpy.generic,",
"# all possible x will be considered valid. This is probably unwanted.",
"for",
"t",
"in",
"numpy_types",
":",
"assert",
"not",
"np... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _ensure_plottable | Raise exception if there is anything in args that can't be plotted on an
axis by matplotlib. | xarray/plot/utils.py | def _ensure_plottable(*args):
"""
Raise exception if there is anything in args that can't be plotted on an
axis by matplotlib.
"""
numpy_types = [np.floating, np.integer, np.timedelta64, np.datetime64]
other_types = [datetime]
try:
import cftime
cftime_datetime = [cftime.date... | def _ensure_plottable(*args):
"""
Raise exception if there is anything in args that can't be plotted on an
axis by matplotlib.
"""
numpy_types = [np.floating, np.integer, np.timedelta64, np.datetime64]
other_types = [datetime]
try:
import cftime
cftime_datetime = [cftime.date... | [
"Raise",
"exception",
"if",
"there",
"is",
"anything",
"in",
"args",
"that",
"can",
"t",
"be",
"plotted",
"on",
"an",
"axis",
"by",
"matplotlib",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L477-L503 | [
"def",
"_ensure_plottable",
"(",
"*",
"args",
")",
":",
"numpy_types",
"=",
"[",
"np",
".",
"floating",
",",
"np",
".",
"integer",
",",
"np",
".",
"timedelta64",
",",
"np",
".",
"datetime64",
"]",
"other_types",
"=",
"[",
"datetime",
"]",
"try",
":",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _update_axes | Update axes with provided parameters | xarray/plot/utils.py | def _update_axes(ax, xincrease, yincrease,
xscale=None, yscale=None,
xticks=None, yticks=None,
xlim=None, ylim=None):
"""
Update axes with provided parameters
"""
if xincrease is None:
pass
elif xincrease and ax.xaxis_inverted():
ax.... | def _update_axes(ax, xincrease, yincrease,
xscale=None, yscale=None,
xticks=None, yticks=None,
xlim=None, ylim=None):
"""
Update axes with provided parameters
"""
if xincrease is None:
pass
elif xincrease and ax.xaxis_inverted():
ax.... | [
"Update",
"axes",
"with",
"provided",
"parameters"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L562-L601 | [
"def",
"_update_axes",
"(",
"ax",
",",
"xincrease",
",",
"yincrease",
",",
"xscale",
"=",
"None",
",",
"yscale",
"=",
"None",
",",
"xticks",
"=",
"None",
",",
"yticks",
"=",
"None",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
")",
":",
"if"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _is_monotonic | >>> _is_monotonic(np.array([0, 1, 2]))
True
>>> _is_monotonic(np.array([2, 1, 0]))
True
>>> _is_monotonic(np.array([0, 2, 1]))
False | xarray/plot/utils.py | def _is_monotonic(coord, axis=0):
"""
>>> _is_monotonic(np.array([0, 1, 2]))
True
>>> _is_monotonic(np.array([2, 1, 0]))
True
>>> _is_monotonic(np.array([0, 2, 1]))
False
"""
if coord.shape[axis] < 3:
return True
else:
n = coord.shape[axis]
delta_pos = (co... | def _is_monotonic(coord, axis=0):
"""
>>> _is_monotonic(np.array([0, 1, 2]))
True
>>> _is_monotonic(np.array([2, 1, 0]))
True
>>> _is_monotonic(np.array([0, 2, 1]))
False
"""
if coord.shape[axis] < 3:
return True
else:
n = coord.shape[axis]
delta_pos = (co... | [
">>>",
"_is_monotonic",
"(",
"np",
".",
"array",
"(",
"[",
"0",
"1",
"2",
"]",
"))",
"True",
">>>",
"_is_monotonic",
"(",
"np",
".",
"array",
"(",
"[",
"2",
"1",
"0",
"]",
"))",
"True",
">>>",
"_is_monotonic",
"(",
"np",
".",
"array",
"(",
"[",
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L604-L621 | [
"def",
"_is_monotonic",
"(",
"coord",
",",
"axis",
"=",
"0",
")",
":",
"if",
"coord",
".",
"shape",
"[",
"axis",
"]",
"<",
"3",
":",
"return",
"True",
"else",
":",
"n",
"=",
"coord",
".",
"shape",
"[",
"axis",
"]",
"delta_pos",
"=",
"(",
"coord",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _infer_interval_breaks | >>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
>>> _infer_interval_breaks([[0, 1], [3, 4]], axis=1)
array([[-0.5, 0.5, 1.5],
[ 2.5, 3.5, 4.5]]) | xarray/plot/utils.py | def _infer_interval_breaks(coord, axis=0, check_monotonic=False):
"""
>>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
>>> _infer_interval_breaks([[0, 1], [3, 4]], axis=1)
array([[-0.5, 0.5, 1.5],
[ 2.5, 3.5, 4.5]])
"""
coord = np.asarray(co... | def _infer_interval_breaks(coord, axis=0, check_monotonic=False):
"""
>>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
>>> _infer_interval_breaks([[0, 1], [3, 4]], axis=1)
array([[-0.5, 0.5, 1.5],
[ 2.5, 3.5, 4.5]])
"""
coord = np.asarray(co... | [
">>>",
"_infer_interval_breaks",
"(",
"np",
".",
"arange",
"(",
"5",
"))",
"array",
"(",
"[",
"-",
"0",
".",
"5",
"0",
".",
"5",
"1",
".",
"5",
"2",
".",
"5",
"3",
".",
"5",
"4",
".",
"5",
"]",
")",
">>>",
"_infer_interval_breaks",
"(",
"[[",
... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L624-L649 | [
"def",
"_infer_interval_breaks",
"(",
"coord",
",",
"axis",
"=",
"0",
",",
"check_monotonic",
"=",
"False",
")",
":",
"coord",
"=",
"np",
".",
"asarray",
"(",
"coord",
")",
"if",
"check_monotonic",
"and",
"not",
"_is_monotonic",
"(",
"coord",
",",
"axis",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _process_cmap_cbar_kwargs | Parameters
==========
func : plotting function
kwargs : dict,
Dictionary with arguments that need to be parsed
data : ndarray,
Data values
Returns
=======
cmap_params
cbar_kwargs | xarray/plot/utils.py | def _process_cmap_cbar_kwargs(func, kwargs, data):
"""
Parameters
==========
func : plotting function
kwargs : dict,
Dictionary with arguments that need to be parsed
data : ndarray,
Data values
Returns
=======
cmap_params
cbar_kwargs
"""
cmap = kwargs.p... | def _process_cmap_cbar_kwargs(func, kwargs, data):
"""
Parameters
==========
func : plotting function
kwargs : dict,
Dictionary with arguments that need to be parsed
data : ndarray,
Data values
Returns
=======
cmap_params
cbar_kwargs
"""
cmap = kwargs.p... | [
"Parameters",
"==========",
"func",
":",
"plotting",
"function",
"kwargs",
":",
"dict",
"Dictionary",
"with",
"arguments",
"that",
"need",
"to",
"be",
"parsed",
"data",
":",
"ndarray",
"Data",
"values"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L652-L704 | [
"def",
"_process_cmap_cbar_kwargs",
"(",
"func",
",",
"kwargs",
",",
"data",
")",
":",
"cmap",
"=",
"kwargs",
".",
"pop",
"(",
"'cmap'",
",",
"None",
")",
"colors",
"=",
"kwargs",
".",
"pop",
"(",
"'colors'",
",",
"None",
")",
"cbar_kwargs",
"=",
"kwar... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | plot | Default plot of DataArray using matplotlib.pyplot.
Calls xarray plotting function based on the dimensions of
darray.squeeze()
=============== ===========================
Dimensions Plotting function
--------------- ---------------------------
1 :py:func:`xarray.plot.line`
... | xarray/plot/plot.py | def plot(darray, row=None, col=None, col_wrap=None, ax=None, hue=None,
rtol=0.01, subplot_kws=None, **kwargs):
"""
Default plot of DataArray using matplotlib.pyplot.
Calls xarray plotting function based on the dimensions of
darray.squeeze()
=============== ===========================
... | def plot(darray, row=None, col=None, col_wrap=None, ax=None, hue=None,
rtol=0.01, subplot_kws=None, **kwargs):
"""
Default plot of DataArray using matplotlib.pyplot.
Calls xarray plotting function based on the dimensions of
darray.squeeze()
=============== ===========================
... | [
"Default",
"plot",
"of",
"DataArray",
"using",
"matplotlib",
".",
"pyplot",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L99-L172 | [
"def",
"plot",
"(",
"darray",
",",
"row",
"=",
"None",
",",
"col",
"=",
"None",
",",
"col_wrap",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"hue",
"=",
"None",
",",
"rtol",
"=",
"0.01",
",",
"subplot_kws",
"=",
"None",
",",
"*",
"*",
"kwargs",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | line | Line plot of DataArray index against values
Wraps :func:`matplotlib:matplotlib.pyplot.plot`
Parameters
----------
darray : DataArray
Must be 1 dimensional
figsize : tuple, optional
A tuple (width, height) of the figure in inches.
Mutually exclusive with ``size`` and ``ax``.... | xarray/plot/plot.py | def line(darray, *args, **kwargs):
"""
Line plot of DataArray index against values
Wraps :func:`matplotlib:matplotlib.pyplot.plot`
Parameters
----------
darray : DataArray
Must be 1 dimensional
figsize : tuple, optional
A tuple (width, height) of the figure in inches.
... | def line(darray, *args, **kwargs):
"""
Line plot of DataArray index against values
Wraps :func:`matplotlib:matplotlib.pyplot.plot`
Parameters
----------
darray : DataArray
Must be 1 dimensional
figsize : tuple, optional
A tuple (width, height) of the figure in inches.
... | [
"Line",
"plot",
"of",
"DataArray",
"index",
"against",
"values"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L177-L315 | [
"def",
"line",
"(",
"darray",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Handle facetgrids first",
"row",
"=",
"kwargs",
".",
"pop",
"(",
"'row'",
",",
"None",
")",
"col",
"=",
"kwargs",
".",
"pop",
"(",
"'col'",
",",
"None",
")",
"if"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | step | Step plot of DataArray index against values
Similar to :func:`matplotlib:matplotlib.pyplot.step`
Parameters
----------
where : {'pre', 'post', 'mid'}, optional, default 'pre'
Define where the steps should be placed:
- 'pre': The y value is continued constantly to the left from
... | xarray/plot/plot.py | def step(darray, *args, **kwargs):
"""
Step plot of DataArray index against values
Similar to :func:`matplotlib:matplotlib.pyplot.step`
Parameters
----------
where : {'pre', 'post', 'mid'}, optional, default 'pre'
Define where the steps should be placed:
- 'pre': The y value is... | def step(darray, *args, **kwargs):
"""
Step plot of DataArray index against values
Similar to :func:`matplotlib:matplotlib.pyplot.step`
Parameters
----------
where : {'pre', 'post', 'mid'}, optional, default 'pre'
Define where the steps should be placed:
- 'pre': The y value is... | [
"Step",
"plot",
"of",
"DataArray",
"index",
"against",
"values"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L318-L355 | [
"def",
"step",
"(",
"darray",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"'ls'",
"in",
"kwargs",
".",
"keys",
"(",
")",
")",
"and",
"(",
"'linestyle'",
"not",
"in",
"kwargs",
".",
"keys",
"(",
")",
")",
":",
"kwargs",
"[",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | hist | Histogram of DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.hist`
Plots N dimensional arrays by first flattening the array.
Parameters
----------
darray : DataArray
Can be any dimension
figsize : tuple, optional
A tuple (width, height) of the figure in inches.
Mut... | xarray/plot/plot.py | def hist(darray, figsize=None, size=None, aspect=None, ax=None, **kwargs):
"""
Histogram of DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.hist`
Plots N dimensional arrays by first flattening the array.
Parameters
----------
darray : DataArray
Can be any dimension
figsize... | def hist(darray, figsize=None, size=None, aspect=None, ax=None, **kwargs):
"""
Histogram of DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.hist`
Plots N dimensional arrays by first flattening the array.
Parameters
----------
darray : DataArray
Can be any dimension
figsize... | [
"Histogram",
"of",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L358-L408 | [
"def",
"hist",
"(",
"darray",
",",
"figsize",
"=",
"None",
",",
"size",
"=",
"None",
",",
"aspect",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ax",
"=",
"get_axis",
"(",
"figsize",
",",
"size",
",",
"aspect",
",",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _plot2d | Decorator for common 2d plotting logic
Also adds the 2d plot method to class _PlotMethods | xarray/plot/plot.py | def _plot2d(plotfunc):
"""
Decorator for common 2d plotting logic
Also adds the 2d plot method to class _PlotMethods
"""
commondoc = """
Parameters
----------
darray : DataArray
Must be 2 dimensional, unless creating faceted plots
x : string, optional
Coordinate for ... | def _plot2d(plotfunc):
"""
Decorator for common 2d plotting logic
Also adds the 2d plot method to class _PlotMethods
"""
commondoc = """
Parameters
----------
darray : DataArray
Must be 2 dimensional, unless creating faceted plots
x : string, optional
Coordinate for ... | [
"Decorator",
"for",
"common",
"2d",
"plotting",
"logic"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L438-L722 | [
"def",
"_plot2d",
"(",
"plotfunc",
")",
":",
"commondoc",
"=",
"\"\"\"\n Parameters\n ----------\n darray : DataArray\n Must be 2 dimensional, unless creating faceted plots\n x : string, optional\n Coordinate for x axis. If None use darray.dims[1]\n y : string, optional\... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | imshow | Image plot of 2d DataArray using matplotlib.pyplot
Wraps :func:`matplotlib:matplotlib.pyplot.imshow`
While other plot methods require the DataArray to be strictly
two-dimensional, ``imshow`` also accepts a 3D array where some
dimension can be interpreted as RGB or RGBA color channels and
allows th... | xarray/plot/plot.py | def imshow(x, y, z, ax, **kwargs):
"""
Image plot of 2d DataArray using matplotlib.pyplot
Wraps :func:`matplotlib:matplotlib.pyplot.imshow`
While other plot methods require the DataArray to be strictly
two-dimensional, ``imshow`` also accepts a 3D array where some
dimension can be interpreted ... | def imshow(x, y, z, ax, **kwargs):
"""
Image plot of 2d DataArray using matplotlib.pyplot
Wraps :func:`matplotlib:matplotlib.pyplot.imshow`
While other plot methods require the DataArray to be strictly
two-dimensional, ``imshow`` also accepts a 3D array where some
dimension can be interpreted ... | [
"Image",
"plot",
"of",
"2d",
"DataArray",
"using",
"matplotlib",
".",
"pyplot"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L726-L797 | [
"def",
"imshow",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"x",
".",
"ndim",
"!=",
"1",
"or",
"y",
".",
"ndim",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'imshow requires 1D coordinates, try using '",
"'pcol... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | contour | Contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contour` | xarray/plot/plot.py | def contour(x, y, z, ax, **kwargs):
"""
Contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contour`
"""
primitive = ax.contour(x, y, z, **kwargs)
return primitive | def contour(x, y, z, ax, **kwargs):
"""
Contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contour`
"""
primitive = ax.contour(x, y, z, **kwargs)
return primitive | [
"Contour",
"plot",
"of",
"2d",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L801-L808 | [
"def",
"contour",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
",",
"*",
"*",
"kwargs",
")",
":",
"primitive",
"=",
"ax",
".",
"contour",
"(",
"x",
",",
"y",
",",
"z",
",",
"*",
"*",
"kwargs",
")",
"return",
"primitive"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | contourf | Filled contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contourf` | xarray/plot/plot.py | def contourf(x, y, z, ax, **kwargs):
"""
Filled contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contourf`
"""
primitive = ax.contourf(x, y, z, **kwargs)
return primitive | def contourf(x, y, z, ax, **kwargs):
"""
Filled contour plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.contourf`
"""
primitive = ax.contourf(x, y, z, **kwargs)
return primitive | [
"Filled",
"contour",
"plot",
"of",
"2d",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L812-L819 | [
"def",
"contourf",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
",",
"*",
"*",
"kwargs",
")",
":",
"primitive",
"=",
"ax",
".",
"contourf",
"(",
"x",
",",
"y",
",",
"z",
",",
"*",
"*",
"kwargs",
")",
"return",
"primitive"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | pcolormesh | Pseudocolor plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.pcolormesh` | xarray/plot/plot.py | def pcolormesh(x, y, z, ax, infer_intervals=None, **kwargs):
"""
Pseudocolor plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.pcolormesh`
"""
# decide on a default for infer_intervals (GH781)
x = np.asarray(x)
if infer_intervals is None:
if hasattr(ax, 'projection'):
... | def pcolormesh(x, y, z, ax, infer_intervals=None, **kwargs):
"""
Pseudocolor plot of 2d DataArray
Wraps :func:`matplotlib:matplotlib.pyplot.pcolormesh`
"""
# decide on a default for infer_intervals (GH781)
x = np.asarray(x)
if infer_intervals is None:
if hasattr(ax, 'projection'):
... | [
"Pseudocolor",
"plot",
"of",
"2d",
"DataArray"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/plot.py#L823-L869 | [
"def",
"pcolormesh",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
",",
"infer_intervals",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# decide on a default for infer_intervals (GH781)",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"if",
"infer_intervals... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _get_scheduler | Determine the dask scheduler that is being used.
None is returned if no dask scheduler is active.
See also
--------
dask.base.get_scheduler | xarray/backends/locks.py | def _get_scheduler(get=None, collection=None):
"""Determine the dask scheduler that is being used.
None is returned if no dask scheduler is active.
See also
--------
dask.base.get_scheduler
"""
try:
# dask 0.18.1 and later
from dask.base import get_scheduler
actual_... | def _get_scheduler(get=None, collection=None):
"""Determine the dask scheduler that is being used.
None is returned if no dask scheduler is active.
See also
--------
dask.base.get_scheduler
"""
try:
# dask 0.18.1 and later
from dask.base import get_scheduler
actual_... | [
"Determine",
"the",
"dask",
"scheduler",
"that",
"is",
"being",
"used",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/locks.py#L65-L97 | [
"def",
"_get_scheduler",
"(",
"get",
"=",
"None",
",",
"collection",
"=",
"None",
")",
":",
"try",
":",
"# dask 0.18.1 and later",
"from",
"dask",
".",
"base",
"import",
"get_scheduler",
"actual_get",
"=",
"get_scheduler",
"(",
"get",
",",
"collection",
")",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | acquire | Acquire a lock, possibly in a non-blocking fashion.
Includes backwards compatibility hacks for old versions of Python, dask
and dask-distributed. | xarray/backends/locks.py | def acquire(lock, blocking=True):
"""Acquire a lock, possibly in a non-blocking fashion.
Includes backwards compatibility hacks for old versions of Python, dask
and dask-distributed.
"""
if blocking:
# no arguments needed
return lock.acquire()
elif DistributedLock is not None an... | def acquire(lock, blocking=True):
"""Acquire a lock, possibly in a non-blocking fashion.
Includes backwards compatibility hacks for old versions of Python, dask
and dask-distributed.
"""
if blocking:
# no arguments needed
return lock.acquire()
elif DistributedLock is not None an... | [
"Acquire",
"a",
"lock",
"possibly",
"in",
"a",
"non",
"-",
"blocking",
"fashion",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/locks.py#L117-L135 | [
"def",
"acquire",
"(",
"lock",
",",
"blocking",
"=",
"True",
")",
":",
"if",
"blocking",
":",
"# no arguments needed",
"return",
"lock",
".",
"acquire",
"(",
")",
"elif",
"DistributedLock",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"lock",
",",
"Distr... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | combine_locks | Combine a sequence of locks into a single lock. | xarray/backends/locks.py | def combine_locks(locks):
"""Combine a sequence of locks into a single lock."""
all_locks = []
for lock in locks:
if isinstance(lock, CombinedLock):
all_locks.extend(lock.locks)
elif lock is not None:
all_locks.append(lock)
num_locks = len(all_locks)
if num_l... | def combine_locks(locks):
"""Combine a sequence of locks into a single lock."""
all_locks = []
for lock in locks:
if isinstance(lock, CombinedLock):
all_locks.extend(lock.locks)
elif lock is not None:
all_locks.append(lock)
num_locks = len(all_locks)
if num_l... | [
"Combine",
"a",
"sequence",
"of",
"locks",
"into",
"a",
"single",
"lock",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/backends/locks.py#L189-L204 | [
"def",
"combine_locks",
"(",
"locks",
")",
":",
"all_locks",
"=",
"[",
"]",
"for",
"lock",
"in",
"locks",
":",
"if",
"isinstance",
"(",
"lock",
",",
"CombinedLock",
")",
":",
"all_locks",
".",
"extend",
"(",
"lock",
".",
"locks",
")",
"elif",
"lock",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | get_squeeze_dims | Get a list of dimensions to squeeze out. | xarray/core/common.py | def get_squeeze_dims(xarray_obj,
dim: Union[Hashable, Iterable[Hashable], None] = None,
axis: Union[int, Iterable[int], None] = None
) -> List[Hashable]:
"""Get a list of dimensions to squeeze out.
"""
if dim is not None and axis is not None:
... | def get_squeeze_dims(xarray_obj,
dim: Union[Hashable, Iterable[Hashable], None] = None,
axis: Union[int, Iterable[int], None] = None
) -> List[Hashable]:
"""Get a list of dimensions to squeeze out.
"""
if dim is not None and axis is not None:
... | [
"Get",
"a",
"list",
"of",
"dimensions",
"to",
"squeeze",
"out",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L217-L246 | [
"def",
"get_squeeze_dims",
"(",
"xarray_obj",
",",
"dim",
":",
"Union",
"[",
"Hashable",
",",
"Iterable",
"[",
"Hashable",
"]",
",",
"None",
"]",
"=",
"None",
",",
"axis",
":",
"Union",
"[",
"int",
",",
"Iterable",
"[",
"int",
"]",
",",
"None",
"]",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | full_like | Return a new object with the same shape and type as a given object.
Parameters
----------
other : DataArray, Dataset, or Variable
The reference object in input
fill_value : scalar
Value to fill the new object with before returning it.
dtype : dtype, optional
dtype of the new... | xarray/core/common.py | def full_like(other, fill_value, dtype: Union[str, np.dtype, None] = None):
"""Return a new object with the same shape and type as a given object.
Parameters
----------
other : DataArray, Dataset, or Variable
The reference object in input
fill_value : scalar
Value to fill the new ob... | def full_like(other, fill_value, dtype: Union[str, np.dtype, None] = None):
"""Return a new object with the same shape and type as a given object.
Parameters
----------
other : DataArray, Dataset, or Variable
The reference object in input
fill_value : scalar
Value to fill the new ob... | [
"Return",
"a",
"new",
"object",
"with",
"the",
"same",
"shape",
"and",
"type",
"as",
"a",
"given",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L942-L979 | [
"def",
"full_like",
"(",
"other",
",",
"fill_value",
",",
"dtype",
":",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
",",
"None",
"]",
"=",
"None",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
"import",
"Dataset",... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _full_like_variable | Inner function of full_like, where other must be a variable | xarray/core/common.py | def _full_like_variable(other, fill_value,
dtype: Union[str, np.dtype, None] = None):
"""Inner function of full_like, where other must be a variable
"""
from .variable import Variable
if isinstance(other.data, dask_array_type):
import dask.array
if dtype is None:... | def _full_like_variable(other, fill_value,
dtype: Union[str, np.dtype, None] = None):
"""Inner function of full_like, where other must be a variable
"""
from .variable import Variable
if isinstance(other.data, dask_array_type):
import dask.array
if dtype is None:... | [
"Inner",
"function",
"of",
"full_like",
"where",
"other",
"must",
"be",
"a",
"variable"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L982-L997 | [
"def",
"_full_like_variable",
"(",
"other",
",",
"fill_value",
",",
"dtype",
":",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
",",
"None",
"]",
"=",
"None",
")",
":",
"from",
".",
"variable",
"import",
"Variable",
"if",
"isinstance",
"(",
"other",
".... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | zeros_like | Shorthand for full_like(other, 0, dtype) | xarray/core/common.py | def zeros_like(other, dtype: Union[str, np.dtype, None] = None):
"""Shorthand for full_like(other, 0, dtype)
"""
return full_like(other, 0, dtype) | def zeros_like(other, dtype: Union[str, np.dtype, None] = None):
"""Shorthand for full_like(other, 0, dtype)
"""
return full_like(other, 0, dtype) | [
"Shorthand",
"for",
"full_like",
"(",
"other",
"0",
"dtype",
")"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L1000-L1003 | [
"def",
"zeros_like",
"(",
"other",
",",
"dtype",
":",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
",",
"None",
"]",
"=",
"None",
")",
":",
"return",
"full_like",
"(",
"other",
",",
"0",
",",
"dtype",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | ones_like | Shorthand for full_like(other, 1, dtype) | xarray/core/common.py | def ones_like(other, dtype: Union[str, np.dtype, None] = None):
"""Shorthand for full_like(other, 1, dtype)
"""
return full_like(other, 1, dtype) | def ones_like(other, dtype: Union[str, np.dtype, None] = None):
"""Shorthand for full_like(other, 1, dtype)
"""
return full_like(other, 1, dtype) | [
"Shorthand",
"for",
"full_like",
"(",
"other",
"1",
"dtype",
")"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L1006-L1009 | [
"def",
"ones_like",
"(",
"other",
",",
"dtype",
":",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
",",
"None",
"]",
"=",
"None",
")",
":",
"return",
"full_like",
"(",
"other",
",",
"1",
",",
"dtype",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | is_np_datetime_like | Check if a dtype is a subclass of the numpy datetime types | xarray/core/common.py | def is_np_datetime_like(dtype: Union[str, np.dtype]) -> bool:
"""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_np_datetime_like(dtype: Union[str, np.dtype]) -> bool:
"""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/common.py#L1012-L1016 | [
"def",
"is_np_datetime_like",
"(",
"dtype",
":",
"Union",
"[",
"str",
",",
"np",
".",
"dtype",
"]",
")",
"->",
"bool",
":",
"return",
"(",
"np",
".",
"issubdtype",
"(",
"dtype",
",",
"np",
".",
"datetime64",
")",
"or",
"np",
".",
"issubdtype",
"(",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | _contains_cftime_datetimes | Check if an array contains cftime.datetime objects | xarray/core/common.py | def _contains_cftime_datetimes(array) -> bool:
"""Check if an array contains cftime.datetime objects
"""
try:
from cftime import datetime as cftime_datetime
except ImportError:
return False
else:
if array.dtype == np.dtype('O') and array.size > 0:
sample = array.r... | def _contains_cftime_datetimes(array) -> bool:
"""Check if an array contains cftime.datetime objects
"""
try:
from cftime import datetime as cftime_datetime
except ImportError:
return False
else:
if array.dtype == np.dtype('O') and array.size > 0:
sample = array.r... | [
"Check",
"if",
"an",
"array",
"contains",
"cftime",
".",
"datetime",
"objects"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L1019-L1035 | [
"def",
"_contains_cftime_datetimes",
"(",
"array",
")",
"->",
"bool",
":",
"try",
":",
"from",
"cftime",
"import",
"datetime",
"as",
"cftime_datetime",
"except",
"ImportError",
":",
"return",
"False",
"else",
":",
"if",
"array",
".",
"dtype",
"==",
"np",
"."... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractArray.get_axis_num | Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the give... | xarray/core/common.py | def get_axis_num(self, dim: Union[Hashable, Iterable[Hashable]]
) -> Union[int, Tuple[int, ...]]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to look... | def get_axis_num(self, dim: Union[Hashable, Iterable[Hashable]]
) -> Union[int, Tuple[int, ...]]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to look... | [
"Return",
"axis",
"number",
"(",
"s",
")",
"corresponding",
"to",
"dimension",
"(",
"s",
")",
"in",
"this",
"array",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L117-L134 | [
"def",
"get_axis_num",
"(",
"self",
",",
"dim",
":",
"Union",
"[",
"Hashable",
",",
"Iterable",
"[",
"Hashable",
"]",
"]",
")",
"->",
"Union",
"[",
"int",
",",
"Tuple",
"[",
"int",
",",
"...",
"]",
"]",
":",
"if",
"isinstance",
"(",
"dim",
",",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AbstractArray.sizes | Ordered mapping from dimension names to lengths.
Immutable.
See also
--------
Dataset.sizes | xarray/core/common.py | def sizes(self: Any) -> Mapping[Hashable, int]:
"""Ordered mapping from dimension names to lengths.
Immutable.
See also
--------
Dataset.sizes
"""
return Frozen(OrderedDict(zip(self.dims, self.shape))) | def sizes(self: Any) -> Mapping[Hashable, int]:
"""Ordered mapping from dimension names to lengths.
Immutable.
See also
--------
Dataset.sizes
"""
return Frozen(OrderedDict(zip(self.dims, self.shape))) | [
"Ordered",
"mapping",
"from",
"dimension",
"names",
"to",
"lengths",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L144-L153 | [
"def",
"sizes",
"(",
"self",
":",
"Any",
")",
"->",
"Mapping",
"[",
"Hashable",
",",
"int",
"]",
":",
"return",
"Frozen",
"(",
"OrderedDict",
"(",
"zip",
"(",
"self",
".",
"dims",
",",
"self",
".",
"shape",
")",
")",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | AttrAccessMixin._ipython_key_completions_ | Provide method for the key-autocompletions in IPython.
See http://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion
For the details. | xarray/core/common.py | def _ipython_key_completions_(self) -> List[str]:
"""Provide method for the key-autocompletions in IPython.
See http://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion
For the details.
""" # noqa
item_lists = [item
for sublist in self... | def _ipython_key_completions_(self) -> List[str]:
"""Provide method for the key-autocompletions in IPython.
See http://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion
For the details.
""" # noqa
item_lists = [item
for sublist in self... | [
"Provide",
"method",
"for",
"the",
"key",
"-",
"autocompletions",
"in",
"IPython",
".",
"See",
"http",
":",
"//",
"ipython",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"stable",
"/",
"config",
"/",
"integrating",
".",
"html#tab",
"-",
"completion",
"... | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L205-L214 | [
"def",
"_ipython_key_completions_",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"# noqa",
"item_lists",
"=",
"[",
"item",
"for",
"sublist",
"in",
"self",
".",
"_item_sources",
"for",
"item",
"in",
"sublist",
"if",
"isinstance",
"(",
"item",
",",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.squeeze | Return a new object with squeezed data.
Parameters
----------
dim : None or Hashable or iterable of Hashable, optional
Selects a subset of the length one dimensions. If a dimension is
selected with length greater than one, an error is raised. If
None, all len... | xarray/core/common.py | def squeeze(self, dim: Union[Hashable, Iterable[Hashable], None] = None,
drop: bool = False,
axis: Union[int, Iterable[int], None] = None):
"""Return a new object with squeezed data.
Parameters
----------
dim : None or Hashable or iterable of Hashable, op... | def squeeze(self, dim: Union[Hashable, Iterable[Hashable], None] = None,
drop: bool = False,
axis: Union[int, Iterable[int], None] = None):
"""Return a new object with squeezed data.
Parameters
----------
dim : None or Hashable or iterable of Hashable, op... | [
"Return",
"a",
"new",
"object",
"with",
"squeezed",
"data",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L252-L280 | [
"def",
"squeeze",
"(",
"self",
",",
"dim",
":",
"Union",
"[",
"Hashable",
",",
"Iterable",
"[",
"Hashable",
"]",
",",
"None",
"]",
"=",
"None",
",",
"drop",
":",
"bool",
"=",
"False",
",",
"axis",
":",
"Union",
"[",
"int",
",",
"Iterable",
"[",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.get_index | Get an index for a dimension, with fall-back to a default RangeIndex | xarray/core/common.py | def get_index(self, key: Hashable) -> pd.Index:
"""Get an index for a dimension, with fall-back to a default RangeIndex
"""
if key not in self.dims:
raise KeyError(key)
try:
return self.indexes[key]
except KeyError:
# need to ensure dtype=int6... | def get_index(self, key: Hashable) -> pd.Index:
"""Get an index for a dimension, with fall-back to a default RangeIndex
"""
if key not in self.dims:
raise KeyError(key)
try:
return self.indexes[key]
except KeyError:
# need to ensure dtype=int6... | [
"Get",
"an",
"index",
"for",
"a",
"dimension",
"with",
"fall",
"-",
"back",
"to",
"a",
"default",
"RangeIndex"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L282-L292 | [
"def",
"get_index",
"(",
"self",
",",
"key",
":",
"Hashable",
")",
"->",
"pd",
".",
"Index",
":",
"if",
"key",
"not",
"in",
"self",
".",
"dims",
":",
"raise",
"KeyError",
"(",
"key",
")",
"try",
":",
"return",
"self",
".",
"indexes",
"[",
"key",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.assign_coords | Assign new coordinates to this object.
Returns a new object with all the original data in addition to the new
coordinates.
Parameters
----------
kwargs : keyword, value pairs
keywords are the variables names. If the values are callable, they
are computed... | xarray/core/common.py | def assign_coords(self, **kwargs):
"""Assign new coordinates to this object.
Returns a new object with all the original data in addition to the new
coordinates.
Parameters
----------
kwargs : keyword, value pairs
keywords are the variables names. If the valu... | def assign_coords(self, **kwargs):
"""Assign new coordinates to this object.
Returns a new object with all the original data in addition to the new
coordinates.
Parameters
----------
kwargs : keyword, value pairs
keywords are the variables names. If the valu... | [
"Assign",
"new",
"coordinates",
"to",
"this",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L304-L359 | [
"def",
"assign_coords",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"copy",
"(",
"deep",
"=",
"False",
")",
"results",
"=",
"self",
".",
"_calc_assign_results",
"(",
"kwargs",
")",
"data",
".",
"coords",
".",
"update",
"... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.assign_attrs | Assign new attrs to this object.
Returns a new object equivalent to self.attrs.update(*args, **kwargs).
Parameters
----------
args : positional arguments passed into ``attrs.update``.
kwargs : keyword arguments passed into ``attrs.update``.
Returns
-------
... | xarray/core/common.py | def assign_attrs(self, *args, **kwargs):
"""Assign new attrs to this object.
Returns a new object equivalent to self.attrs.update(*args, **kwargs).
Parameters
----------
args : positional arguments passed into ``attrs.update``.
kwargs : keyword arguments passed into ``a... | def assign_attrs(self, *args, **kwargs):
"""Assign new attrs to this object.
Returns a new object equivalent to self.attrs.update(*args, **kwargs).
Parameters
----------
args : positional arguments passed into ``attrs.update``.
kwargs : keyword arguments passed into ``a... | [
"Assign",
"new",
"attrs",
"to",
"this",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L361-L382 | [
"def",
"assign_attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"out",
"=",
"self",
".",
"copy",
"(",
"deep",
"=",
"False",
")",
"out",
".",
"attrs",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"retur... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.pipe | Apply func(self, *args, **kwargs)
This method replicates the pandas method of the same name.
Parameters
----------
func : function
function to apply to this xarray object (Dataset/DataArray).
``args``, and ``kwargs`` are passed into ``func``.
Alterna... | xarray/core/common.py | def pipe(self, func: Union[Callable[..., T], Tuple[Callable[..., T], str]],
*args, **kwargs) -> T:
"""
Apply func(self, *args, **kwargs)
This method replicates the pandas method of the same name.
Parameters
----------
func : function
function to... | def pipe(self, func: Union[Callable[..., T], Tuple[Callable[..., T], str]],
*args, **kwargs) -> T:
"""
Apply func(self, *args, **kwargs)
This method replicates the pandas method of the same name.
Parameters
----------
func : function
function to... | [
"Apply",
"func",
"(",
"self",
"*",
"args",
"**",
"kwargs",
")"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L384-L442 | [
"def",
"pipe",
"(",
"self",
",",
"func",
":",
"Union",
"[",
"Callable",
"[",
"...",
",",
"T",
"]",
",",
"Tuple",
"[",
"Callable",
"[",
"...",
",",
"T",
"]",
",",
"str",
"]",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"T",
":... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.groupby | Returns a GroupBy object for performing grouped operations.
Parameters
----------
group : str, DataArray or IndexVariable
Array whose unique values should be used to group this array. If a
string, must be the name of a variable contained in this dataset.
squeeze ... | xarray/core/common.py | def groupby(self, group, squeeze: bool = True):
"""Returns a GroupBy object for performing grouped operations.
Parameters
----------
group : str, DataArray or IndexVariable
Array whose unique values should be used to group this array. If a
string, must be the nam... | def groupby(self, group, squeeze: bool = True):
"""Returns a GroupBy object for performing grouped operations.
Parameters
----------
group : str, DataArray or IndexVariable
Array whose unique values should be used to group this array. If a
string, must be the nam... | [
"Returns",
"a",
"GroupBy",
"object",
"for",
"performing",
"grouped",
"operations",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L444-L488 | [
"def",
"groupby",
"(",
"self",
",",
"group",
",",
"squeeze",
":",
"bool",
"=",
"True",
")",
":",
"# noqa",
"return",
"self",
".",
"_groupby_cls",
"(",
"self",
",",
"group",
",",
"squeeze",
"=",
"squeeze",
")"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.groupby_bins | Returns a GroupBy object for performing grouped operations.
Rather than using all unique values of `group`, the values are discretized
first by applying `pandas.cut` [1]_ to `group`.
Parameters
----------
group : str, DataArray or IndexVariable
Array whose binned va... | xarray/core/common.py | def groupby_bins(self, group, bins, right: bool = True, labels=None,
precision: int = 3, include_lowest: bool = False,
squeeze: bool = True):
"""Returns a GroupBy object for performing grouped operations.
Rather than using all unique values of `group`, the valu... | def groupby_bins(self, group, bins, right: bool = True, labels=None,
precision: int = 3, include_lowest: bool = False,
squeeze: bool = True):
"""Returns a GroupBy object for performing grouped operations.
Rather than using all unique values of `group`, the valu... | [
"Returns",
"a",
"GroupBy",
"object",
"for",
"performing",
"grouped",
"operations",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L490-L541 | [
"def",
"groupby_bins",
"(",
"self",
",",
"group",
",",
"bins",
",",
"right",
":",
"bool",
"=",
"True",
",",
"labels",
"=",
"None",
",",
"precision",
":",
"int",
"=",
"3",
",",
"include_lowest",
":",
"bool",
"=",
"False",
",",
"squeeze",
":",
"bool",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.rolling | Rolling window object.
Parameters
----------
dim: dict, optional
Mapping from the dimension name to create the rolling iterator
along (e.g. `time`) to its moving window size.
min_periods : int, default None
Minimum number of observations in window req... | xarray/core/common.py | def rolling(self, dim: Optional[Mapping[Hashable, int]] = None,
min_periods: Optional[int] = None, center: bool = False,
**dim_kwargs: int):
"""
Rolling window object.
Parameters
----------
dim: dict, optional
Mapping from the dimensio... | def rolling(self, dim: Optional[Mapping[Hashable, int]] = None,
min_periods: Optional[int] = None, center: bool = False,
**dim_kwargs: int):
"""
Rolling window object.
Parameters
----------
dim: dict, optional
Mapping from the dimensio... | [
"Rolling",
"window",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L543-L603 | [
"def",
"rolling",
"(",
"self",
",",
"dim",
":",
"Optional",
"[",
"Mapping",
"[",
"Hashable",
",",
"int",
"]",
"]",
"=",
"None",
",",
"min_periods",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"center",
":",
"bool",
"=",
"False",
",",
"*",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.coarsen | Coarsen object.
Parameters
----------
dim: dict, optional
Mapping from the dimension name to the window size.
dim : str
Name of the dimension to create the rolling iterator
along (e.g., `time`).
window : int
Siz... | xarray/core/common.py | def coarsen(self, dim: Optional[Mapping[Hashable, int]] = None,
boundary: str = 'exact',
side: Union[str, Mapping[Hashable, str]] = 'left',
coord_func: str = 'mean',
**dim_kwargs: int):
"""
Coarsen object.
Parameters
------... | def coarsen(self, dim: Optional[Mapping[Hashable, int]] = None,
boundary: str = 'exact',
side: Union[str, Mapping[Hashable, str]] = 'left',
coord_func: str = 'mean',
**dim_kwargs: int):
"""
Coarsen object.
Parameters
------... | [
"Coarsen",
"object",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L605-L666 | [
"def",
"coarsen",
"(",
"self",
",",
"dim",
":",
"Optional",
"[",
"Mapping",
"[",
"Hashable",
",",
"int",
"]",
"]",
"=",
"None",
",",
"boundary",
":",
"str",
"=",
"'exact'",
",",
"side",
":",
"Union",
"[",
"str",
",",
"Mapping",
"[",
"Hashable",
","... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.resample | Returns a Resample object for performing resampling operations.
Handles both downsampling and upsampling. If any intervals contain no
values from the original object, they will be given the value ``NaN``.
Parameters
----------
indexer : {dim: freq}, optional
Mapping... | xarray/core/common.py | def resample(self, indexer: Optional[Mapping[Hashable, str]] = None,
skipna=None, closed: Optional[str] = None,
label: Optional[str] = None,
base: int = 0, keep_attrs: Optional[bool] = None,
loffset=None,
**indexer_kwargs: str):
... | def resample(self, indexer: Optional[Mapping[Hashable, str]] = None,
skipna=None, closed: Optional[str] = None,
label: Optional[str] = None,
base: int = 0, keep_attrs: Optional[bool] = None,
loffset=None,
**indexer_kwargs: str):
... | [
"Returns",
"a",
"Resample",
"object",
"for",
"performing",
"resampling",
"operations",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L668-L791 | [
"def",
"resample",
"(",
"self",
",",
"indexer",
":",
"Optional",
"[",
"Mapping",
"[",
"Hashable",
",",
"str",
"]",
"]",
"=",
"None",
",",
"skipna",
"=",
"None",
",",
"closed",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"label",
":",
"Optio... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.where | Filter elements from this object according to a condition.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic.
Parameters
----------
cond : DataArray or Dataset with boolean dtype
Locations at which to preserve ... | xarray/core/common.py | def where(self, cond, other=dtypes.NA, drop: bool = False):
"""Filter elements from this object according to a condition.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic.
Parameters
----------
cond : DataArray or... | def where(self, cond, other=dtypes.NA, drop: bool = False):
"""Filter elements from this object according to a condition.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic.
Parameters
----------
cond : DataArray or... | [
"Filter",
"elements",
"from",
"this",
"object",
"according",
"to",
"a",
"condition",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L793-L877 | [
"def",
"where",
"(",
"self",
",",
"cond",
",",
"other",
"=",
"dtypes",
".",
"NA",
",",
"drop",
":",
"bool",
"=",
"False",
")",
":",
"from",
".",
"alignment",
"import",
"align",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"dataset",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.close | Close any files linked to this object | xarray/core/common.py | def close(self: Any) -> None:
"""Close any files linked to this object
"""
if self._file_obj is not None:
self._file_obj.close()
self._file_obj = None | def close(self: Any) -> None:
"""Close any files linked to this object
"""
if self._file_obj is not None:
self._file_obj.close()
self._file_obj = None | [
"Close",
"any",
"files",
"linked",
"to",
"this",
"object"
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L879-L884 | [
"def",
"close",
"(",
"self",
":",
"Any",
")",
"->",
"None",
":",
"if",
"self",
".",
"_file_obj",
"is",
"not",
"None",
":",
"self",
".",
"_file_obj",
".",
"close",
"(",
")",
"self",
".",
"_file_obj",
"=",
"None"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | DataWithCoords.isin | Tests each value in the array for whether it is in test elements.
Parameters
----------
test_elements : array_like
The values against which to test each value of `element`.
This argument is flattened if an array or array_like.
See numpy notes for behavior wit... | xarray/core/common.py | def isin(self, test_elements):
"""Tests each value in the array for whether it is in test elements.
Parameters
----------
test_elements : array_like
The values against which to test each value of `element`.
This argument is flattened if an array or array_like.
... | def isin(self, test_elements):
"""Tests each value in the array for whether it is in test elements.
Parameters
----------
test_elements : array_like
The values against which to test each value of `element`.
This argument is flattened if an array or array_like.
... | [
"Tests",
"each",
"value",
"in",
"the",
"array",
"for",
"whether",
"it",
"is",
"in",
"test",
"elements",
"."
] | pydata/xarray | python | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/common.py#L886-L933 | [
"def",
"isin",
"(",
"self",
",",
"test_elements",
")",
":",
"from",
".",
"computation",
"import",
"apply_ufunc",
"from",
".",
"dataset",
"import",
"Dataset",
"from",
".",
"dataarray",
"import",
"DataArray",
"from",
".",
"variable",
"import",
"Variable",
"if",
... | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 |
train | compare_version | Compare docker versions
>>> v1 = '1.9'
>>> v2 = '1.10'
>>> compare_version(v1, v2)
1
>>> compare_version(v2, v1)
-1
>>> compare_version(v2, v2)
0 | docker/utils/utils.py | def compare_version(v1, v2):
"""Compare docker versions
>>> v1 = '1.9'
>>> v2 = '1.10'
>>> compare_version(v1, v2)
1
>>> compare_version(v2, v1)
-1
>>> compare_version(v2, v2)
0
"""
s1 = StrictVersion(v1)
s2 = StrictVersion(v2)
if s1 == s2:
return 0
elif ... | def compare_version(v1, v2):
"""Compare docker versions
>>> v1 = '1.9'
>>> v2 = '1.10'
>>> compare_version(v1, v2)
1
>>> compare_version(v2, v1)
-1
>>> compare_version(v2, v2)
0
"""
s1 = StrictVersion(v1)
s2 = StrictVersion(v2)
if s1 == s2:
return 0
elif ... | [
"Compare",
"docker",
"versions"
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/utils/utils.py#L54-L73 | [
"def",
"compare_version",
"(",
"v1",
",",
"v2",
")",
":",
"s1",
"=",
"StrictVersion",
"(",
"v1",
")",
"s2",
"=",
"StrictVersion",
"(",
"v2",
")",
"if",
"s1",
"==",
"s2",
":",
"return",
"0",
"elif",
"s1",
">",
"s2",
":",
"return",
"-",
"1",
"else"... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | datetime_to_timestamp | Convert a UTC datetime to a Unix timestamp | docker/utils/utils.py | def datetime_to_timestamp(dt):
"""Convert a UTC datetime to a Unix timestamp"""
delta = dt - datetime.utcfromtimestamp(0)
return delta.seconds + delta.days * 24 * 3600 | def datetime_to_timestamp(dt):
"""Convert a UTC datetime to a Unix timestamp"""
delta = dt - datetime.utcfromtimestamp(0)
return delta.seconds + delta.days * 24 * 3600 | [
"Convert",
"a",
"UTC",
"datetime",
"to",
"a",
"Unix",
"timestamp"
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/utils/utils.py#L394-L397 | [
"def",
"datetime_to_timestamp",
"(",
"dt",
")",
":",
"delta",
"=",
"dt",
"-",
"datetime",
".",
"utcfromtimestamp",
"(",
"0",
")",
"return",
"delta",
".",
"seconds",
"+",
"delta",
".",
"days",
"*",
"24",
"*",
"3600"
] | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | parse_env_file | Reads a line-separated environment file.
The format of each line should be "key=value". | docker/utils/utils.py | def parse_env_file(env_file):
"""
Reads a line-separated environment file.
The format of each line should be "key=value".
"""
environment = {}
with open(env_file, 'r') as f:
for line in f:
if line[0] == '#':
continue
line = line.strip()
... | def parse_env_file(env_file):
"""
Reads a line-separated environment file.
The format of each line should be "key=value".
"""
environment = {}
with open(env_file, 'r') as f:
for line in f:
if line[0] == '#':
continue
line = line.strip()
... | [
"Reads",
"a",
"line",
"-",
"separated",
"environment",
"file",
".",
"The",
"format",
"of",
"each",
"line",
"should",
"be",
"key",
"=",
"value",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/utils/utils.py#L448-L474 | [
"def",
"parse_env_file",
"(",
"env_file",
")",
":",
"environment",
"=",
"{",
"}",
"with",
"open",
"(",
"env_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
"[",
"0",
"]",
"==",
"'#'",
":",
"continue",
"line",
... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.configure_plugin | Configure a plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
options (dict): A key-value mapping of options
Returns:
``True`` if successful | docker/api/plugin.py | def configure_plugin(self, name, options):
"""
Configure a plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
options (dict): A key-value mapping of options
... | def configure_plugin(self, name, options):
"""
Configure a plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
options (dict): A key-value mapping of options
... | [
"Configure",
"a",
"plugin",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L9-L27 | [
"def",
"configure_plugin",
"(",
"self",
",",
"name",
",",
"options",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/{0}/set'",
",",
"name",
")",
"data",
"=",
"options",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
"=",
... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.create_plugin | Create a new plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
plugin_data_dir (string): Path to the plugin data directory.
Plugin data directory must contain the ``con... | docker/api/plugin.py | def create_plugin(self, name, plugin_data_dir, gzip=False):
"""
Create a new plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
plugin_data_dir (string): Path to the plu... | def create_plugin(self, name, plugin_data_dir, gzip=False):
"""
Create a new plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
plugin_data_dir (string): Path to the plu... | [
"Create",
"a",
"new",
"plugin",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L30-L53 | [
"def",
"create_plugin",
"(",
"self",
",",
"name",
",",
"plugin_data_dir",
",",
"gzip",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/create'",
")",
"with",
"utils",
".",
"create_archive",
"(",
"root",
"=",
"plugin_data_dir",
",",... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.disable_plugin | Disable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
``True`` if successful | docker/api/plugin.py | def disable_plugin(self, name):
"""
Disable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
``True`` if successful
"""
... | def disable_plugin(self, name):
"""
Disable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
``True`` if successful
"""
... | [
"Disable",
"an",
"installed",
"plugin",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L56-L70 | [
"def",
"disable_plugin",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/{0}/disable'",
",",
"name",
")",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
")",
"self",
".",
"_raise_for_status",
"(",
"res",
")",
"return... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.enable_plugin | Enable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
timeout (int): Operation timeout (in seconds). Default: 0
Returns:
``True`` if successful | docker/api/plugin.py | def enable_plugin(self, name, timeout=0):
"""
Enable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
timeout (int): Operation timeout (in seconds). Defau... | def enable_plugin(self, name, timeout=0):
"""
Enable an installed plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
timeout (int): Operation timeout (in seconds). Defau... | [
"Enable",
"an",
"installed",
"plugin",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L73-L89 | [
"def",
"enable_plugin",
"(",
"self",
",",
"name",
",",
"timeout",
"=",
"0",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/{0}/enable'",
",",
"name",
")",
"params",
"=",
"{",
"'timeout'",
":",
"timeout",
"}",
"res",
"=",
"self",
".",
"_po... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.inspect_plugin | Retrieve plugin metadata.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
A dict containing plugin info | docker/api/plugin.py | def inspect_plugin(self, name):
"""
Retrieve plugin metadata.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
A dict containing plugin info
"""
... | def inspect_plugin(self, name):
"""
Retrieve plugin metadata.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
Returns:
A dict containing plugin info
"""
... | [
"Retrieve",
"plugin",
"metadata",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L92-L104 | [
"def",
"inspect_plugin",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/{0}/json'",
",",
"name",
")",
"return",
"self",
".",
"_result",
"(",
"self",
".",
"_get",
"(",
"url",
")",
",",
"True",
")"
] | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.plugins | Retrieve a list of installed plugins.
Returns:
A list of dicts, one per plugin | docker/api/plugin.py | def plugins(self):
"""
Retrieve a list of installed plugins.
Returns:
A list of dicts, one per plugin
"""
url = self._url('/plugins')
return self._result(self._get(url), True) | def plugins(self):
"""
Retrieve a list of installed plugins.
Returns:
A list of dicts, one per plugin
"""
url = self._url('/plugins')
return self._result(self._get(url), True) | [
"Retrieve",
"a",
"list",
"of",
"installed",
"plugins",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L145-L153 | [
"def",
"plugins",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins'",
")",
"return",
"self",
".",
"_result",
"(",
"self",
".",
"_get",
"(",
"url",
")",
",",
"True",
")"
] | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.plugin_privileges | Retrieve list of privileges to be granted to a plugin.
Args:
name (string): Name of the remote plugin to examine. The
``:latest`` tag is optional, and is the default if omitted.
Returns:
A list of dictionaries representing the plugin's
... | docker/api/plugin.py | def plugin_privileges(self, name):
"""
Retrieve list of privileges to be granted to a plugin.
Args:
name (string): Name of the remote plugin to examine. The
``:latest`` tag is optional, and is the default if omitted.
Returns:
... | def plugin_privileges(self, name):
"""
Retrieve list of privileges to be granted to a plugin.
Args:
name (string): Name of the remote plugin to examine. The
``:latest`` tag is optional, and is the default if omitted.
Returns:
... | [
"Retrieve",
"list",
"of",
"privileges",
"to",
"be",
"granted",
"to",
"a",
"plugin",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L156-L182 | [
"def",
"plugin_privileges",
"(",
"self",
",",
"name",
")",
":",
"params",
"=",
"{",
"'remote'",
":",
"name",
",",
"}",
"headers",
"=",
"{",
"}",
"registry",
",",
"repo_name",
"=",
"auth",
".",
"resolve_repository_name",
"(",
"name",
")",
"header",
"=",
... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
train | PluginApiMixin.push_plugin | Push a plugin to the registry.
Args:
name (string): Name of the plugin to upload. The ``:latest``
tag is optional, and is the default if omitted.
Returns:
``True`` if successful | docker/api/plugin.py | def push_plugin(self, name):
"""
Push a plugin to the registry.
Args:
name (string): Name of the plugin to upload. The ``:latest``
tag is optional, and is the default if omitted.
Returns:
``True`` if successful
"""... | def push_plugin(self, name):
"""
Push a plugin to the registry.
Args:
name (string): Name of the plugin to upload. The ``:latest``
tag is optional, and is the default if omitted.
Returns:
``True`` if successful
"""... | [
"Push",
"a",
"plugin",
"to",
"the",
"registry",
"."
] | docker/docker-py | python | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/plugin.py#L186-L206 | [
"def",
"push_plugin",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'/plugins/{0}/pull'",
",",
"name",
")",
"headers",
"=",
"{",
"}",
"registry",
",",
"repo_name",
"=",
"auth",
".",
"resolve_repository_name",
"(",
"name",
")"... | 613d6aad83acc9931ff2ecfd6a6c7bd8061dc125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.