repository stringclasses 11
values | repo_id stringlengths 1 3 | target_module_path stringlengths 16 72 | prompt stringlengths 298 21.7k | relavent_test_path stringlengths 50 99 | full_function stringlengths 336 33.8k | function_name stringlengths 2 51 | content_class stringclasses 3
values | external_dependencies stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|
sphinx | 18 | sphinx/domains/javascript.py | def before_content(self) -> None:
"""Handle object nesting before content
:py:class:`JSObject` represents JavaScript language constructs. For
constructs that are nestable, this method will build up a stack of the
nesting hierarchy so that it can be later de-nested correctly, in
... | /usr/src/app/target_test_cases/failed_tests_before_content.txt | def before_content(self) -> None:
"""Handle object nesting before content
:py:class:`JSObject` represents JavaScript language constructs. For
constructs that are nestable, this method will build up a stack of the
nesting hierarchy so that it can be later de-nested correctly, in
... | before_content | file-level | non_external |
sphinx | 19 | tests/test_builders/xpath_util.py | def check_xpath(
etree: ElementTree,
filename: str | os.PathLike[str],
xpath: str,
check: str | re.Pattern[str] | Callable[[Sequence[Element]], None] | None,
be_found: bool = True,
*,
min_count: int = 1,
) -> None:
"""Check that one or more nodes satisfy a predicate.
:param etree: T... | /usr/src/app/target_test_cases/failed_tests_check_xpath.txt | def check_xpath(
etree: ElementTree,
filename: str | os.PathLike[str],
xpath: str,
check: str | re.Pattern[str] | Callable[[Sequence[Element]], None] | None,
be_found: bool = True,
*,
min_count: int = 1,
) -> None:
"""Check that one or more nodes satisfy a predicate.
:param etree: T... | check_xpath | file-level | external |
sphinx | 20 | sphinx/util/fileutil.py | def copy_asset(source: str | os.PathLike[str], destination: str | os.PathLike[str],
excluded: PathMatcher = lambda path: False,
context: dict[str, Any] | None = None, renderer: BaseRenderer | None = None,
onerror: Callable[[str, Exception], None] | None = None,
... | /usr/src/app/target_test_cases/failed_tests_copy_asset.txt | def copy_asset(source: str | os.PathLike[str], destination: str | os.PathLike[str],
excluded: PathMatcher = lambda path: False,
context: dict[str, Any] | None = None, renderer: BaseRenderer | None = None,
onerror: Callable[[str, Exception], None] | None = None,
... | copy_asset | repository-level | external |
sphinx | 21 | sphinx/ext/githubpages.py | def create_nojekyll_and_cname(app: Sphinx, env: BuildEnvironment) -> None:
"""Manage the ``.nojekyll`` and ``CNAME`` files for GitHub Pages.
For HTML-format builders (e.g. 'html', 'dirhtml') we unconditionally create
the ``.nojekyll`` file to signal that GitHub Pages should not run Jekyll
processing.
... | /usr/src/app/target_test_cases/failed_tests_githubpages.create_nojekyll_and_cname.txt | def create_nojekyll_and_cname(app: Sphinx, env: BuildEnvironment) -> None:
"""Manage the ``.nojekyll`` and ``CNAME`` files for GitHub Pages.
For HTML-format builders (e.g. 'html', 'dirhtml') we unconditionally create
the ``.nojekyll`` file to signal that GitHub Pages should not run Jekyll
processing.
... | create_nojekyll_and_cname | repository-level | external |
sphinx | 22 | sphinx/ext/doctest.py | def is_allowed_version(spec: str, version: str) -> bool:
"""Check `spec` satisfies `version` or not.
This obeys PEP-440 specifiers:
https://peps.python.org/pep-0440/#version-specifiers
Some examples:
>>> is_allowed_version('<=3.5', '3.3')
True
>>> is_allowed_version('<=3.2', '... | /usr/src/app/target_test_cases/failed_tests_is_allowed_version.txt | def is_allowed_version(spec: str, version: str) -> bool:
"""Check `spec` satisfies `version` or not.
This obeys PEP-440 specifiers:
https://peps.python.org/pep-0440/#version-specifiers
Some examples:
>>> is_allowed_version('<=3.5', '3.3')
True
>>> is_allowed_version('<=3.2', '... | doctest.is_allowed_version | self-contained | external |
sphinx | 23 | sphinx/util/docutils.py | def parse_inline(
self, text: str, *, lineno: int = -1,
) -> tuple[list[Node], list[system_message]]:
"""Parse *text* as inline elements.
:param text:
The text to parse, which should be a single line or paragraph.
This cannot contain any structural elements (head... | /usr/src/app/target_test_cases/failed_tests_parse_inline.txt | def parse_inline(
self, text: str, *, lineno: int = -1,
) -> tuple[list[Node], list[system_message]]:
"""Parse *text* as inline elements.
:param text:
The text to parse, which should be a single line or paragraph.
This cannot contain any structural elements (head... | docutils.SphinxDirective.parse_inline | file-level | non_external |
sphinx | 24 | sphinx/ext/autodoc/__init__.py | def filter_members(self, members: list[ObjectMember], want_all: bool,
) -> list[tuple[str, Any, bool]]:
"""Filter the given member list.
Members are skipped if
- they are private (except if given explicitly or the private-members
option is set)
- th... | /usr/src/app/target_test_cases/failed_tests_filter_members.txt | def filter_members(self, members: list[ObjectMember], want_all: bool,
) -> list[tuple[str, Any, bool]]:
"""Filter the given member list.
Members are skipped if
- they are private (except if given explicitly or the private-members
option is set)
- th... | filter_members | repository-level | external |
sphinx | 25 | sphinx/util/parsing.py | def nested_parse_to_nodes(
state: RSTState,
text: str | StringList,
*,
source: str = '<generated text>',
offset: int = 0,
allow_section_headings: bool = True,
keep_title_context: bool = False,
) -> list[Node]: # Element | nodes.Text
"""Parse *text* into nodes.
:param state:
... | /usr/src/app/target_test_cases/failed_tests_parsing.nested_parse_to_nodes.txt | def nested_parse_to_nodes(
state: RSTState,
text: str | StringList,
*,
source: str = '<generated text>',
offset: int = 0,
allow_section_headings: bool = True,
keep_title_context: bool = False,
) -> list[Node]: # Element | nodes.Text
"""Parse *text* into nodes.
:param state:
... | nested_parse_to_nodes | file-level | non_external |
sphinx | 26 | sphinx/domains/std/__init__.py | def note_hyperlink_target(self, name: str, docname: str, node_id: str,
title: str = '') -> None:
"""Add a hyperlink target for cross reference.
.. warning::
This is only for internal use. Please don't use this from your extension.
``document.not... | /usr/src/app/target_test_cases/failed_tests_note_hyperlink_target.txt | def note_hyperlink_target(self, name: str, docname: str, node_id: str,
title: str = '') -> None:
"""Add a hyperlink target for cross reference.
.. warning::
This is only for internal use. Please don't use this from your extension.
``document.not... | note_hyperlink_target | repository-level | non_external |
sphinx | 27 | sphinx/util/docutils.py | def parse_content_to_nodes(self, allow_section_headings: bool = False) -> list[Node]:
"""Parse the directive's content into nodes.
:param allow_section_headings:
Are titles (sections) allowed in the directive's content?
Note that this option bypasses Docutils' usual checks o... | /usr/src/app/target_test_cases/failed_tests_parse_content_to_nodes.txt | def parse_content_to_nodes(self, allow_section_headings: bool = False) -> list[Node]:
"""Parse the directive's content into nodes.
:param allow_section_headings:
Are titles (sections) allowed in the directive's content?
Note that this option bypasses Docutils' usual checks o... | parse_content_to_nodes | repository-level | non_external |
sphinx | 28 | sphinx/util/docutils.py | def parse_text_to_nodes(
self, text: str = '', /, *, offset: int = -1, allow_section_headings: bool = False,
) -> list[Node]:
"""Parse *text* into nodes.
:param text:
Text, in string form. ``StringList`` is also accepted.
:param allow_section_headings:
Ar... | /usr/src/app/target_test_cases/failed_tests_parse_text_to_nodes.txt | def parse_text_to_nodes(
self, text: str = '', /, *, offset: int = -1, allow_section_headings: bool = False,
) -> list[Node]:
"""Parse *text* into nodes.
:param text:
Text, in string form. ``StringList`` is also accepted.
:param allow_section_headings:
Ar... | parse_text_to_nodes | repository-level | non_external |
sphinx | 29 | sphinx/transforms/i18n.py | def publish_msgstr(app: Sphinx, source: str, source_path: str, source_line: int,
config: Config, settings: Any) -> nodes.Element:
"""Publish msgstr (single line) into docutils document
:param sphinx.application.Sphinx app: sphinx application
:param str source: source text
:param str ... | /usr/src/app/target_test_cases/failed_tests_publish_msgstr.txt | def publish_msgstr(app: Sphinx, source: str, source_path: str, source_line: int,
config: Config, settings: Any) -> nodes.Element:
"""Publish msgstr (single line) into docutils document
:param sphinx.application.Sphinx app: sphinx application
:param str source: source text
:param str ... | publish_msgstr | repository-level | external |
sphinx | 30 | sphinx/ext/imgmath.py | def render_math(
self: HTML5Translator,
math: str,
) -> tuple[str | None, int | None]:
"""Render the LaTeX math expression *math* using latex and dvipng or
dvisvgm.
Return the image absolute filename and the "depth",
that is, the distance of image bottom and baseline in pixels, if the
optio... | /usr/src/app/target_test_cases/failed_tests_render_math.txt | def render_math(
self: HTML5Translator,
math: str,
) -> tuple[str | None, int | None]:
"""Render the LaTeX math expression *math* using latex and dvipng or
dvisvgm.
Return the image absolute filename and the "depth",
that is, the distance of image bottom and baseline in pixels, if the
optio... | render_math | repository-level | external |
sphinx | 31 | sphinx/util/typing.py | def stringify_annotation(
annotation: Any,
/,
mode: _StringifyMode = 'fully-qualified-except-typing',
) -> str:
"""Stringify type annotation object.
:param annotation: The annotation to stringified.
:param mode: Specify a method how annotations will be stringified.
'fully-qual... | /usr/src/app/target_test_cases/failed_tests_stringify_annotation.txt | def stringify_annotation(
annotation: Any,
/,
mode: _StringifyMode = 'fully-qualified-except-typing',
) -> str:
"""Stringify type annotation object.
:param annotation: The annotation to stringified.
:param mode: Specify a method how annotations will be stringified.
'fully-qual... | stringify_annotation | repository-level | external |
sphinx | 32 | sphinx/util/logging.py | def warning( # type: ignore[override]
self,
msg: object,
*args: object,
type: None | str = None,
subtype: None | str = None,
location: None | str | tuple[str | None, int | None] | Node = None,
nonl: bool = True,
color: str | None = None,
once:... | /usr/src/app/target_test_cases/failed_tests_warning.txt | def warning( # type: ignore[override]
self,
msg: object,
*args: object,
type: None | str = None,
subtype: None | str = None,
location: None | str | tuple[str | None, int | None] | Node = None,
nonl: bool = True,
color: str | None = None,
once:... | warning | self-contained | external |
xarray | 0 | xarray/backends/file_manager.py | def acquire(self, needs_lock=True):
"""Acquire 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... | /usr/src/app/target_test_cases/failed_tests_CachingFileManager.acquire.txt | def acquire(self, needs_lock=True):
"""Acquire 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... | CachingFileManager.acquire | file-level | non_external |
xarray | 1 | xarray/core/coordinates.py | def assign(self, coords: Mapping | None = None, **coords_kwargs: Any) -> Self:
"""Assign new coordinates (and indexes) to a Coordinates object, returning
a new object with all the original coordinates in addition to the new ones.
Parameters
----------
coords : mapping of dim... | /usr/src/app/target_test_cases/failed_tests_Coordinates.assign.txt | def assign(self, coords: Mapping | None = None, **coords_kwargs: Any) -> Self:
"""Assign new coordinates (and indexes) to a Coordinates object, returning
a new object with all the original coordinates in addition to the new ones.
Parameters
----------
coords : mapping of dim... | Coordinates.assign | repository-level | external |
xarray | 2 | xarray/core/datatree.py | def to_dataset(self, inherited: bool = True) -> Dataset:
"""
Return the data in this node as a new xarray.Dataset object.
Parameters
----------
inherited : bool, optional
If False, only include coordinates and indexes defined at the level
of this Data... | /usr/src/app/target_test_cases/failed_tests_DataTree.to_dataset.txt | def to_dataset(self, inherited: bool = True) -> Dataset:
"""
Return the data in this node as a new xarray.Dataset object.
Parameters
----------
inherited : bool, optional
If False, only include coordinates and indexes defined at the level
of this Data... | DataTree.to_dataset | repository-level | non_external |
xarray | 3 | xarray/core/treenode.py | def _set_item(
self: Tree,
path: str | NodePath,
item: Tree | T_DataArray,
new_nodes_along_path: bool = False,
allow_overwrite: bool = True,
) -> None:
"""
Set a new item in the tree, overwriting anything already present at that path.
The given va... | /usr/src/app/target_test_cases/failed_tests_TreeNode._set_item.txt | def _set_item(
self: Tree,
path: str | NodePath,
item: Tree | T_DataArray,
new_nodes_along_path: bool = False,
allow_overwrite: bool = True,
) -> None:
"""
Set a new item in the tree, overwriting anything already present at that path.
The given va... | TreeNode._set_item | repository-level | non_external |
xarray | 4 | xarray/backends/file_manager.py | def __init__(
self,
opener,
*args,
mode=_DEFAULT_MODE,
kwargs=None,
lock=None,
cache=None,
manager_id: Hashable | None = None,
ref_counts=None,
):
"""Initialize a CachingFileManager.
The cache, manager_id and ref_counts arg... | /usr/src/app/target_test_cases/failed_tests___init__.txt | def __init__(
self,
opener,
*args,
mode=_DEFAULT_MODE,
kwargs=None,
lock=None,
cache=None,
manager_id: Hashable | None = None,
ref_counts=None,
):
"""Initialize a CachingFileManager.
The cache, manager_id and ref_counts arg... | __init__ | file-level | external |
xarray | 5 | xarray/core/resample_cftime.py | def _adjust_dates_anchored(
first: CFTimeDatetime,
last: CFTimeDatetime,
freq: Tick,
closed: SideOptions = "right",
origin: str | CFTimeDatetime = "start_day",
offset: datetime.timedelta | None = None,
):
"""First and last offsets should be calculated from the start day to fix
an error c... | /usr/src/app/target_test_cases/failed_tests__adjust_dates_anchored.txt | def _adjust_dates_anchored(
first: CFTimeDatetime,
last: CFTimeDatetime,
freq: Tick,
closed: SideOptions = "right",
origin: str | CFTimeDatetime = "start_day",
offset: datetime.timedelta | None = None,
):
"""First and last offsets should be calculated from the start day to fix
an error c... | _adjust_dates_anchored | repository-level | external |
xarray | 6 | xarray/core/combine.py | def _combine_nd(
combined_ids,
concat_dims,
data_vars="all",
coords="different",
compat: CompatOptions = "no_conflicts",
fill_value=dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: CombineAttrsOptions = "drop",
):
"""
Combines an N-dimensional structure of datasets into one... | /usr/src/app/target_test_cases/failed_tests__combine_nd.txt | def _combine_nd(
combined_ids,
concat_dims,
data_vars="all",
coords="different",
compat: CompatOptions = "no_conflicts",
fill_value=dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: CombineAttrsOptions = "drop",
):
"""
Combines an N-dimensional structure of datasets into one... | _combine_nd | repository-level | non_external |
xarray | 7 | xarray/core/indexing.py | def _decompose_outer_indexer(
indexer: BasicIndexer | OuterIndexer,
shape: _Shape,
indexing_support: IndexingSupport,
) -> tuple[ExplicitIndexer, ExplicitIndexer]:
"""
Decompose outer indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the ... | /usr/src/app/target_test_cases/failed_tests__decompose_outer_indexer.txt | def _decompose_outer_indexer(
indexer: BasicIndexer | OuterIndexer,
shape: _Shape,
indexing_support: IndexingSupport,
) -> tuple[ExplicitIndexer, ExplicitIndexer]:
"""
Decompose outer indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the ... | _decompose_outer_indexer | repository-level | external |
xarray | 8 | xarray/core/indexing.py | def _decompose_vectorized_indexer(
indexer: VectorizedIndexer,
shape: _Shape,
indexing_support: IndexingSupport,
) -> tuple[ExplicitIndexer, ExplicitIndexer]:
"""
Decompose vectorized indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the ... | /usr/src/app/target_test_cases/failed_tests__decompose_vectorized_indexer.txt | def _decompose_vectorized_indexer(
indexer: VectorizedIndexer,
shape: _Shape,
indexing_support: IndexingSupport,
) -> tuple[ExplicitIndexer, ExplicitIndexer]:
"""
Decompose vectorized indexer to the successive two indexers, where the
first indexer will be used to index backend arrays, while the ... | _decompose_vectorized_indexer | repository-level | external |
xarray | 9 | 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,
_is_facetgrid=False,
):
"""
Use some heuristics to set good defaults for colorbar and range.
Parameters
------... | /usr/src/app/target_test_cases/failed_tests__determine_cmap_params.txt | def _determine_cmap_params(
plot_data,
vmin=None,
vmax=None,
cmap=None,
center=None,
robust=False,
extend=None,
levels=None,
filled=True,
norm=None,
_is_facetgrid=False,
):
"""
Use some heuristics to set good defaults for colorbar and range.
Parameters
------... | _determine_cmap_params | repository-level | external |
xarray | 10 | xarray/core/resample_cftime.py | def _get_range_edges(
first: CFTimeDatetime,
last: CFTimeDatetime,
freq: BaseCFTimeOffset,
closed: SideOptions = "left",
origin: str | CFTimeDatetime = "start_day",
offset: datetime.timedelta | None = None,
):
"""Get the correct starting and ending datetimes for the resampled
CFTimeIndex... | /usr/src/app/target_test_cases/failed_tests__get_range_edges.txt | def _get_range_edges(
first: CFTimeDatetime,
last: CFTimeDatetime,
freq: BaseCFTimeOffset,
closed: SideOptions = "left",
origin: str | CFTimeDatetime = "start_day",
offset: datetime.timedelta | None = None,
):
"""Get the correct starting and ending datetimes for the resampled
CFTimeIndex... | _get_range_edges | repository-level | external |
xarray | 11 | xarray/core/resample_cftime.py | def _get_time_bins(
index: CFTimeIndex,
freq: BaseCFTimeOffset,
closed: SideOptions,
label: SideOptions,
origin: str | CFTimeDatetime,
offset: datetime.timedelta | None,
):
"""Obtain the bins and their respective labels for resampling operations.
Parameters
----------
index : CF... | /usr/src/app/target_test_cases/failed_tests__get_time_bins.txt | def _get_time_bins(
index: CFTimeIndex,
freq: BaseCFTimeOffset,
closed: SideOptions,
label: SideOptions,
origin: str | CFTimeDatetime,
offset: datetime.timedelta | None,
):
"""Obtain the bins and their respective labels for resampling operations.
Parameters
----------
index : CF... | _get_time_bins | repository-level | external |
xarray | 12 | xarray/plot/utils.py | def _guess_coords_to_plot(
darray: DataArray,
coords_to_plot: MutableMapping[str, Hashable | None],
kwargs: dict,
default_guess: tuple[str, ...] = ("x",),
# TODO: Can this be normalized, plt.cbook.normalize_kwargs?
ignore_guess_kwargs: tuple[tuple[str, ...], ...] = ((),),
) -> MutableMapping[str... | /usr/src/app/target_test_cases/failed_tests__guess_coords_to_plot.txt | def _guess_coords_to_plot(
darray: DataArray,
coords_to_plot: MutableMapping[str, Hashable | None],
kwargs: dict,
default_guess: tuple[str, ...] = ("x",),
# TODO: Can this be normalized, plt.cbook.normalize_kwargs?
ignore_guess_kwargs: tuple[tuple[str, ...], ...] = ((),),
) -> MutableMapping[str... | _guess_coords_to_plot | repository-level | external |
xarray | 13 | xarray/coding/cftimeindex.py | def _parse_array_of_cftime_strings(strings, date_type):
"""Create a numpy array from an array of strings.
For use in generating dates from strings for use with interp. Assumes the
array is either 0-dimensional or 1-dimensional.
Parameters
----------
strings : array of strings
Strings ... | /usr/src/app/target_test_cases/failed_tests__parse_array_of_cftime_strings.txt | def _parse_array_of_cftime_strings(strings, date_type):
"""Create a numpy array from an array of strings.
For use in generating dates from strings for use with interp. Assumes the
array is either 0-dimensional or 1-dimensional.
Parameters
----------
strings : array of strings
Strings ... | _parse_array_of_cftime_strings | self-contained | external |
xarray | 14 | xarray/coding/cftimeindex.py | def _partial_date_slice(self, resolution, parsed):
"""Adapted from
pandas.tseries.index.DatetimeIndex._partial_date_slice
Note that when using a CFTimeIndex, if a partial-date selection
returns a single element, it will never be converted to a scalar
coordinate; this is in s... | /usr/src/app/target_test_cases/failed_tests__partial_date_slice.txt | def _partial_date_slice(self, resolution, parsed):
"""Adapted from
pandas.tseries.index.DatetimeIndex._partial_date_slice
Note that when using a CFTimeIndex, if a partial-date selection
returns a single element, it will never be converted to a scalar
coordinate; this is in s... | _partial_date_slice | file-level | external |
xarray | 15 | xarray/plot/dataarray_plot.py | def _prepare_plot1d_data(
darray: T_DataArray,
coords_to_plot: MutableMapping[str, Hashable],
plotfunc_name: str | None = None,
_is_facetgrid: bool = False,
) -> dict[str, T_DataArray]:
"""
Prepare data for usage with plt.scatter.
Parameters
----------
darray : T_DataArray
B... | /usr/src/app/target_test_cases/failed_tests__prepare_plot1d_data.txt | def _prepare_plot1d_data(
darray: T_DataArray,
coords_to_plot: MutableMapping[str, Hashable],
plotfunc_name: str | None = None,
_is_facetgrid: bool = False,
) -> dict[str, T_DataArray]:
"""
Prepare data for usage with plt.scatter.
Parameters
----------
darray : T_DataArray
B... | _prepare_plot1d_data | repository-level | external |
xarray | 16 | xarray/core/formatting_html.py | def _wrap_datatree_repr(r: str, end: bool = False) -> str:
"""
Wrap HTML representation with a tee to the left of it.
Enclosing HTML tag is a <div> with :code:`display: inline-grid` style.
Turns:
[ title ]
| details |
|_____________|
into (A):
|─ [ title ]
| |... | /usr/src/app/target_test_cases/failed_tests__wrap_datatree_repr.txt | def _wrap_datatree_repr(r: str, end: bool = False) -> str:
"""
Wrap HTML representation with a tee to the left of it.
Enclosing HTML tag is a <div> with :code:`display: inline-grid` style.
Turns:
[ title ]
| details |
|_____________|
into (A):
|─ [ title ]
| |... | _wrap_datatree_repr | self-contained | non_external |
xarray | 17 | xarray/core/_aggregations.py | def any(
self,
dim: Dims = None,
*,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``any`` along some dimension(s).
Parameters
----------
dim : str, Iterable of Hashable, "..." ... | /usr/src/app/target_test_cases/failed_tests_any.txt | def any(
self,
dim: Dims = None,
*,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``any`` along some dimension(s).
Parameters
----------
dim : str, Iterable of Hashable, "..." ... | any | repository-level | external |
xarray | 18 | xarray/core/computation.py | def apply_ufunc(
func: Callable,
*args: Any,
input_core_dims: Sequence[Sequence] | None = None,
output_core_dims: Sequence[Sequence] | None = ((),),
exclude_dims: Set = frozenset(),
vectorize: bool = False,
join: JoinOptions = "exact",
dataset_join: str = "exact",
dataset_fill_value:... | /usr/src/app/target_test_cases/failed_tests_apply_ufunc.txt | def apply_ufunc(
func: Callable,
*args: Any,
input_core_dims: Sequence[Sequence] | None = None,
output_core_dims: Sequence[Sequence] | None = ((),),
exclude_dims: Set = frozenset(),
vectorize: bool = False,
join: JoinOptions = "exact",
dataset_join: str = "exact",
dataset_fill_value:... | apply_ufunc | repository-level | external |
xarray | 19 | xarray/core/common.py | def assign_coords(
self,
coords: Mapping | None = None,
**coords_kwargs: Any,
) -> Self:
"""Assign new coordinates to this object.
Returns a new object with all the original data in addition to the new
coordinates.
Parameters
----------
c... | /usr/src/app/target_test_cases/failed_tests_assign_coords.txt | def assign_coords(
self,
coords: Mapping | None = None,
**coords_kwargs: Any,
) -> Self:
"""Assign new coordinates to this object.
Returns a new object with all the original data in addition to the new
coordinates.
Parameters
----------
c... | assign_coords | repository-level | external |
xarray | 20 | xarray/core/variable.py | def astype(
self,
dtype,
*,
order=None,
casting=None,
subok=None,
copy=None,
keep_attrs=True,
) -> Self:
"""
Copy of the Variable object, with data cast to a specified type.
Parameters
----------
dtype : str... | /usr/src/app/target_test_cases/failed_tests_astype.txt | def astype(
self,
dtype,
*,
order=None,
casting=None,
subok=None,
copy=None,
keep_attrs=True,
) -> Self:
"""
Copy of the Variable object, with data cast to a specified type.
Parameters
----------
dtype : str... | astype | repository-level | external |
xarray | 21 | xarray/core/computation.py | def build_output_coords_and_indexes(
args: Iterable[Any],
signature: _UFuncSignature,
exclude_dims: Set = frozenset(),
combine_attrs: CombineAttrsOptions = "override",
) -> tuple[list[dict[Any, Variable]], list[dict[Any, Index]]]:
"""Build output coordinates and indexes for an operation.
Parame... | /usr/src/app/target_test_cases/failed_tests_build_output_coords_and_indexes.txt | def build_output_coords_and_indexes(
args: Iterable[Any],
signature: _UFuncSignature,
exclude_dims: Set = frozenset(),
combine_attrs: CombineAttrsOptions = "override",
) -> tuple[list[dict[Any, Variable]], list[dict[Any, Index]]]:
"""Build output coordinates and indexes for an operation.
Parame... | build_output_coords_and_indexes | repository-level | external |
xarray | 22 | xarray/core/accessor_str.py | def cat(self, *others, sep: str | bytes | Any = "") -> T_DataArray:
"""
Concatenate strings elementwise in the DataArray with other strings.
The other strings can either be string scalars or other array-like.
Dimensions are automatically broadcast together.
An optional sepa... | /usr/src/app/target_test_cases/failed_tests_cat.txt | def cat(self, *others, sep: str | bytes | Any = "") -> T_DataArray:
"""
Concatenate strings elementwise in the DataArray with other strings.
The other strings can either be string scalars or other array-like.
Dimensions are automatically broadcast together.
An optional sepa... | cat | repository-level | external |
xarray | 23 | xarray/coding/cftime_offsets.py | def cftime_range(
start=None,
end=None,
periods=None,
freq=None,
normalize=False,
name=None,
closed: NoDefault | SideOptions = no_default,
inclusive: None | InclusiveOptions = None,
calendar="standard",
) -> CFTimeIndex:
"""Return a fixed frequency CFTimeIndex.
Parameters
... | /usr/src/app/target_test_cases/failed_tests_cftime_range.txt | def cftime_range(
start=None,
end=None,
periods=None,
freq=None,
normalize=False,
name=None,
closed: NoDefault | SideOptions = no_default,
inclusive: None | InclusiveOptions = None,
calendar="standard",
) -> CFTimeIndex:
"""Return a fixed frequency CFTimeIndex.
Parameters
... | cftime_range | repository-level | external |
xarray | 24 | xarray/core/datatree_mapping.py | def check_isomorphic(
a: DataTree,
b: DataTree,
require_names_equal: bool = False,
check_from_root: bool = True,
):
"""
Check that two trees have the same structure, raising an error if not.
Does not compare the actual data in the nodes.
By default this function only checks that subtre... | /usr/src/app/target_test_cases/failed_tests_check_isomorphic.txt | def check_isomorphic(
a: DataTree,
b: DataTree,
require_names_equal: bool = False,
check_from_root: bool = True,
):
"""
Check that two trees have the same structure, raising an error if not.
Does not compare the actual data in the nodes.
By default this function only checks that subtre... | check_isomorphic | repository-level | non_external |
xarray | 25 | xarray/core/combine.py | def combine_by_coords(
data_objects: Iterable[Dataset | DataArray] = [],
compat: CompatOptions = "no_conflicts",
data_vars: Literal["all", "minimal", "different"] | list[str] = "all",
coords: str = "different",
fill_value: object = dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: Combi... | /usr/src/app/target_test_cases/failed_tests_combine_by_coords.txt | def combine_by_coords(
data_objects: Iterable[Dataset | DataArray] = [],
compat: CompatOptions = "no_conflicts",
data_vars: Literal["all", "minimal", "different"] | list[str] = "all",
coords: str = "different",
fill_value: object = dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: Combi... | combine_by_coords | repository-level | external |
xarray | 26 | xarray/core/combine.py | def combine_nested(
datasets: DATASET_HYPERCUBE,
concat_dim: str | DataArray | None | Sequence[str | DataArray | pd.Index | None],
compat: str = "no_conflicts",
data_vars: str = "all",
coords: str = "different",
fill_value: object = dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: ... | /usr/src/app/target_test_cases/failed_tests_combine_nested.txt | def combine_nested(
datasets: DATASET_HYPERCUBE,
concat_dim: str | DataArray | None | Sequence[str | DataArray | pd.Index | None],
compat: str = "no_conflicts",
data_vars: str = "all",
coords: str = "different",
fill_value: object = dtypes.NA,
join: JoinOptions = "outer",
combine_attrs: ... | combine_nested | repository-level | external |
xarray | 27 | xarray/core/rolling.py | def construct(
self,
window_dim: Hashable | Mapping[Any, Hashable] | None = None,
stride: int | Mapping[Any, int] = 1,
fill_value: Any = dtypes.NA,
keep_attrs: bool | None = None,
**window_dim_kwargs: Hashable,
) -> DataArray:
"""
Convert this roll... | /usr/src/app/target_test_cases/failed_tests_construct.txt | def construct(
self,
window_dim: Hashable | Mapping[Any, Hashable] | None = None,
stride: int | Mapping[Any, int] = 1,
fill_value: Any = dtypes.NA,
keep_attrs: bool | None = None,
**window_dim_kwargs: Hashable,
) -> DataArray:
"""
Convert this roll... | construct | repository-level | external |
xarray | 28 | xarray/coding/calendar_ops.py | def convert_calendar(
obj,
calendar,
dim="time",
align_on=None,
missing=None,
use_cftime=None,
):
"""Transform a time-indexed Dataset or DataArray to one that uses another calendar.
This function only converts the individual timestamps; it does not modify any
data except in dropping... | /usr/src/app/target_test_cases/failed_tests_convert_calendar.txt | def convert_calendar(
obj,
calendar,
dim="time",
align_on=None,
missing=None,
use_cftime=None,
):
"""Transform a time-indexed Dataset or DataArray to one that uses another calendar.
This function only converts the individual timestamps; it does not modify any
data except in dropping... | convert_calendar | repository-level | external |
xarray | 29 | xarray/core/computation.py | def corr(
da_a: T_DataArray,
da_b: T_DataArray,
dim: Dims = None,
weights: T_DataArray | None = None,
) -> T_DataArray:
"""
Compute the Pearson correlation coefficient between
two DataArray objects along a shared dimension.
Parameters
----------
da_a : DataArray
Array to... | /usr/src/app/target_test_cases/failed_tests_corr.txt | def corr(
da_a: T_DataArray,
da_b: T_DataArray,
dim: Dims = None,
weights: T_DataArray | None = None,
) -> T_DataArray:
"""
Compute the Pearson correlation coefficient between
two DataArray objects along a shared dimension.
Parameters
----------
da_a : DataArray
Array to... | corr | repository-level | non_external |
xarray | 30 | xarray/core/_aggregations.py | def count(
self,
dim: Dims = None,
*,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``count`` along some dimension(s).
Parameters
----------
dim : str, Iterable of Hashable, ".... | /usr/src/app/target_test_cases/failed_tests_count.txt | def count(
self,
dim: Dims = None,
*,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``count`` along some dimension(s).
Parameters
----------
dim : str, Iterable of Hashable, ".... | count | repository-level | external |
xarray | 31 | xarray/core/computation.py | def cov(
da_a: T_DataArray,
da_b: T_DataArray,
dim: Dims = None,
ddof: int = 1,
weights: T_DataArray | None = None,
) -> T_DataArray:
"""
Compute covariance between two DataArray objects along a shared dimension.
Parameters
----------
da_a : DataArray
Array to compute.
... | /usr/src/app/target_test_cases/failed_tests_cov.txt | def cov(
da_a: T_DataArray,
da_b: T_DataArray,
dim: Dims = None,
ddof: int = 1,
weights: T_DataArray | None = None,
) -> T_DataArray:
"""
Compute covariance between two DataArray objects along a shared dimension.
Parameters
----------
da_a : DataArray
Array to compute.
... | cov | repository-level | non_external |
xarray | 32 | xarray/tests/conftest.py | def create_test_datatree():
"""
Create a test datatree with this structure:
<xarray.DataTree>
|-- set1
| |-- <xarray.Dataset>
| | Dimensions: ()
| | Data variables:
| | a int64 0
| | b int64 1
| |-- set1
| |-- set2
|-- set2
... | /usr/src/app/target_test_cases/failed_tests_create_test_datatree.txt | def create_test_datatree():
"""
Create a test datatree with this structure:
<xarray.DataTree>
|-- set1
| |-- <xarray.Dataset>
| | Dimensions: ()
| | Data variables:
| | a int64 0
| | b int64 1
| |-- set1
| |-- set2
|-- set2
... | create_test_datatree | repository-level | non_external |
xarray | 33 | xarray/core/computation.py | def cross(
a: DataArray | Variable, b: DataArray | Variable, *, dim: Hashable
) -> DataArray | Variable:
"""
Compute the cross product of two (arrays of) vectors.
The cross product of `a` and `b` in :math:`R^3` is a vector
perpendicular to both `a` and `b`. The vectors in `a` and `b` are
define... | /usr/src/app/target_test_cases/failed_tests_cross.txt | def cross(
a: DataArray | Variable, b: DataArray | Variable, *, dim: Hashable
) -> DataArray | Variable:
"""
Compute the cross product of two (arrays of) vectors.
The cross product of `a` and `b` in :math:`R^3` is a vector
perpendicular to both `a` and `b`. The vectors in `a` and `b` are
define... | cross | repository-level | external |
xarray | 34 | xarray/coding/cftime_offsets.py | def date_range_like(source, calendar, use_cftime=None):
"""Generate a datetime array with the same frequency, start and end as
another one, but in a different calendar.
Parameters
----------
source : DataArray, CFTimeIndex, or pd.DatetimeIndex
1D datetime array
calendar : str
Ne... | /usr/src/app/target_test_cases/failed_tests_date_range_like.txt | def date_range_like(source, calendar, use_cftime=None):
"""Generate a datetime array with the same frequency, start and end as
another one, but in a different calendar.
Parameters
----------
source : DataArray, CFTimeIndex, or pd.DatetimeIndex
1D datetime array
calendar : str
Ne... | date_range_like | repository-level | external |
xarray | 35 | xarray/conventions.py | def decode_cf(
obj: T_DatasetOrAbstractstore,
concat_characters: bool = True,
mask_and_scale: bool = True,
decode_times: bool = True,
decode_coords: bool | Literal["coordinates", "all"] = True,
drop_variables: T_DropVariables = None,
use_cftime: bool | None = None,
decode_timedelta: bool... | /usr/src/app/target_test_cases/failed_tests_decode_cf.txt | def decode_cf(
obj: T_DatasetOrAbstractstore,
concat_characters: bool = True,
mask_and_scale: bool = True,
decode_times: bool = True,
decode_coords: bool | Literal["coordinates", "all"] = True,
drop_variables: T_DropVariables = None,
use_cftime: bool | None = None,
decode_timedelta: bool... | decode_cf | repository-level | external |
xarray | 36 | xarray/coding/times.py | def decode_cf_datetime(
num_dates, units: str, calendar: str | None = None, use_cftime: bool | None = None
) -> np.ndarray:
"""Given an array of numeric dates in netCDF format, convert it into a
numpy array of date time objects.
For standard (Gregorian) calendars, this function uses vectorized
oper... | /usr/src/app/target_test_cases/failed_tests_decode_cf_datetime.txt | def decode_cf_datetime(
num_dates, units: str, calendar: str | None = None, use_cftime: bool | None = None
) -> np.ndarray:
"""Given an array of numeric dates in netCDF format, convert it into a
numpy array of date time objects.
For standard (Gregorian) calendars, this function uses vectorized
oper... | decode_cf_datetime | repository-level | external |
xarray | 37 | xarray/conventions.py | def decode_cf_variable(
name: Hashable,
var: Variable,
concat_characters: bool = True,
mask_and_scale: bool = True,
decode_times: bool = True,
decode_endianness: bool = True,
stack_char_dim: bool = True,
use_cftime: bool | None = None,
decode_timedelta: bool | None = None,
) -> Varia... | /usr/src/app/target_test_cases/failed_tests_decode_cf_variable.txt | def decode_cf_variable(
name: Hashable,
var: Variable,
concat_characters: bool = True,
mask_and_scale: bool = True,
decode_times: bool = True,
decode_endianness: bool = True,
stack_char_dim: bool = True,
use_cftime: bool | None = None,
decode_timedelta: bool | None = None,
) -> Varia... | decode_cf_variable | repository-level | external |
xarray | 38 | xarray/core/computation.py | def dot(
*arrays,
dim: Dims = None,
**kwargs: Any,
):
"""Generalized dot product for xarray objects. Like ``np.einsum``, but
provides a simpler interface based on array dimension names.
Parameters
----------
*arrays : DataArray or Variable
Arrays to compute.
dim : str, itera... | /usr/src/app/target_test_cases/failed_tests_dot.txt | def dot(
*arrays,
dim: Dims = None,
**kwargs: Any,
):
"""Generalized dot product for xarray objects. Like ``np.einsum``, but
provides a simpler interface based on array dimension names.
Parameters
----------
*arrays : DataArray or Variable
Arrays to compute.
dim : str, itera... | dot | repository-level | external |
xarray | 39 | xarray/conventions.py | def encode_cf_variable(
var: Variable, needs_copy: bool = True, name: T_Name = None
) -> Variable:
"""
Converts a Variable into a Variable which follows some
of the CF conventions:
- Nans are masked using _FillValue (or the deprecated missing_value)
- Rescaling via: scale_factor and add... | /usr/src/app/target_test_cases/failed_tests_encode_cf_variable.txt | def encode_cf_variable(
var: Variable, needs_copy: bool = True, name: T_Name = None
) -> Variable:
"""
Converts a Variable into a Variable which follows some
of the CF conventions:
- Nans are masked using _FillValue (or the deprecated missing_value)
- Rescaling via: scale_factor and add... | encode_cf_variable | repository-level | non_external |
xarray | 40 | xarray/conventions.py | def encode_dataset_coordinates(dataset: Dataset):
"""Encode coordinates on the given dataset object into variable specific
and global attributes.
When possible, this is done according to CF conventions.
Parameters
----------
dataset : Dataset
Object to encode.
Returns
-------
... | /usr/src/app/target_test_cases/failed_tests_encode_dataset_coordinates.txt | def encode_dataset_coordinates(dataset: Dataset):
"""Encode coordinates on the given dataset object into variable specific
and global attributes.
When possible, this is done according to CF conventions.
Parameters
----------
dataset : Dataset
Object to encode.
Returns
-------
... | encode_dataset_coordinates | repository-level | non_external |
xarray | 41 | xarray/namedarray/_array_api.py | def expand_dims(
x: NamedArray[Any, _DType],
/,
*,
dim: _Dim | Default = _default,
axis: _Axis = 0,
) -> NamedArray[Any, _DType]:
"""
Expands the shape of an array by inserting a new dimension of size one at the
position specified by dims.
Parameters
----------
x :
A... | /usr/src/app/target_test_cases/failed_tests_expand_dims.txt | def expand_dims(
x: NamedArray[Any, _DType],
/,
*,
dim: _Dim | Default = _default,
axis: _Axis = 0,
) -> NamedArray[Any, _DType]:
"""
Expands the shape of an array by inserting a new dimension of size one at the
position specified by dims.
Parameters
----------
x :
A... | expand_dims | repository-level | external |
xarray | 42 | xarray/core/accessor_str.py | def format(
self,
*args: Any,
**kwargs: Any,
) -> T_DataArray:
"""
Perform python string formatting on each element of the DataArray.
This is equivalent to calling `str.format` on every element of the
DataArray. The replacement values can either be a stri... | /usr/src/app/target_test_cases/failed_tests_format.txt | def format(
self,
*args: Any,
**kwargs: Any,
) -> T_DataArray:
"""
Perform python string formatting on each element of the DataArray.
This is equivalent to calling `str.format` on every element of the
DataArray. The replacement values can either be a stri... | format | repository-level | external |
xarray | 43 | xarray/core/missing.py | def get_clean_interp_index(
arr, dim: Hashable, use_coordinate: str | bool = True, strict: bool = True
):
"""Return index to use for x values in interpolation or curve fitting.
Parameters
----------
arr : DataArray
Array to interpolate or fit to a curve.
dim : str
Name of dimens... | /usr/src/app/target_test_cases/failed_tests_get_clean_interp_index.txt | def get_clean_interp_index(
arr, dim: Hashable, use_coordinate: str | bool = True, strict: bool = True
):
"""Return index to use for x values in interpolation or curve fitting.
Parameters
----------
arr : DataArray
Array to interpolate or fit to a curve.
dim : str
Name of dimens... | get_clean_interp_index | repository-level | external |
xarray | 44 | xarray/core/dataset.py | def head(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with the first `n` values of each array
for the specified dimension(s).
Parameters
----------
indexers : dict or int, defa... | /usr/src/app/target_test_cases/failed_tests_head.txt | def head(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with the first `n` values of each array
for the specified dimension(s).
Parameters
----------
indexers : dict or int, defa... | head | repository-level | external |
xarray | 45 | xarray/plot/dataarray_plot.py | def hist(
darray: DataArray,
*args: Any,
figsize: Iterable[float] | None = None,
size: float | None = None,
aspect: AspectOptions = None,
ax: Axes | None = None,
xincrease: bool | None = None,
yincrease: bool | None = None,
xscale: ScaleOptions = None,
yscale: ScaleOptions = None... | /usr/src/app/target_test_cases/failed_tests_hist.txt | def hist(
darray: DataArray,
*args: Any,
figsize: Iterable[float] | None = None,
size: float | None = None,
aspect: AspectOptions = None,
ax: Axes | None = None,
xincrease: bool | None = None,
yincrease: bool | None = None,
xscale: ScaleOptions = None,
yscale: ScaleOptions = None... | hist | repository-level | external |
xarray | 46 | xarray/core/dataset.py | def identical(self, other: Self) -> bool:
"""Like equals, but also checks all dataset attributes and the
attributes on all variables and coordinates.
Example
-------
>>> a = xr.Dataset(
... {"Width": ("X", [1, 2, 3])},
... coords={"X": [1, 2, 3]},
... | /usr/src/app/target_test_cases/failed_tests_identical.txt | def identical(self, other: Self) -> bool:
"""Like equals, but also checks all dataset attributes and the
attributes on all variables and coordinates.
Example
-------
>>> a = xr.Dataset(
... {"Width": ("X", [1, 2, 3])},
... coords={"X": [1, 2, 3]},
... | identical | repository-level | external |
xarray | 47 | xarray/coding/frequencies.py | def infer_freq(index):
"""
Infer the most likely frequency given the input index.
Parameters
----------
index : CFTimeIndex, DataArray, DatetimeIndex, TimedeltaIndex, Series
If not passed a CFTimeIndex, this simply calls `pandas.infer_freq`.
If passed a Series or a DataArray will us... | /usr/src/app/target_test_cases/failed_tests_infer_freq.txt | def infer_freq(index):
"""
Infer the most likely frequency given the input index.
Parameters
----------
index : CFTimeIndex, DataArray, DatetimeIndex, TimedeltaIndex, Series
If not passed a CFTimeIndex, this simply calls `pandas.infer_freq`.
If passed a Series or a DataArray will us... | infer_freq | repository-level | external |
xarray | 48 | xarray/coding/calendar_ops.py | def interp_calendar(source, target, dim="time"):
"""Interpolates a DataArray or Dataset indexed by a time coordinate to
another calendar based on decimal year measure.
Each timestamp in `source` and `target` are first converted to their decimal
year equivalent then `source` is interpolated on the targe... | /usr/src/app/target_test_cases/failed_tests_interp_calendar.txt | def interp_calendar(source, target, dim="time"):
"""Interpolates a DataArray or Dataset indexed by a time coordinate to
another calendar based on decimal year measure.
Each timestamp in `source` and `target` are first converted to their decimal
year equivalent then `source` is interpolated on the targe... | interp_calendar | repository-level | external |
xarray | 49 | xarray/core/missing.py | def interp_func(var, x, new_x, method: InterpOptions, kwargs):
"""
multi-dimensional interpolation for array-like. Interpolated axes should be
located in the last position.
Parameters
----------
var : np.ndarray or dask.array.Array
Array to be interpolated. The final dimension is interp... | /usr/src/app/target_test_cases/failed_tests_interp_func.txt | def interp_func(var, x, new_x, method: InterpOptions, kwargs):
"""
multi-dimensional interpolation for array-like. Interpolated axes should be
located in the last position.
Parameters
----------
var : np.ndarray or dask.array.Array
Array to be interpolated. The final dimension is interp... | interp_func | repository-level | external |
xarray | 50 | xarray/core/dataset.py | def isel(
self,
indexers: Mapping[Any, Any] | None = None,
drop: bool = False,
missing_dims: ErrorOptionsWithWarn = "raise",
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed along the specified
dimension(s).
This... | /usr/src/app/target_test_cases/failed_tests_isel.txt | def isel(
self,
indexers: Mapping[Any, Any] | None = None,
drop: bool = False,
missing_dims: ErrorOptionsWithWarn = "raise",
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed along the specified
dimension(s).
This... | isel | repository-level | external |
xarray | 51 | xarray/core/accessor_str.py | def join(
self,
dim: Hashable = None,
sep: str | bytes | Any = "",
) -> T_DataArray:
"""
Concatenate strings in a DataArray along a particular dimension.
An optional separator `sep` can also be specified. If `sep` is
array-like, it is broadcast against th... | /usr/src/app/target_test_cases/failed_tests_join.txt | def join(
self,
dim: Hashable = None,
sep: str | bytes | Any = "",
) -> T_DataArray:
"""
Concatenate strings in a DataArray along a particular dimension.
An optional separator `sep` can also be specified. If `sep` is
array-like, it is broadcast against th... | join | repository-level | external |
xarray | 52 | xarray/plot/utils.py | def legend_elements(
self, prop="colors", num="auto", fmt=None, func=lambda x: x, **kwargs
):
"""
Create legend handles and labels for a PathCollection.
Each legend handle is a `.Line2D` representing the Path that was drawn,
and each label is a string what each Path represents.
This is useful ... | /usr/src/app/target_test_cases/failed_tests_legend_elements.txt | def legend_elements(
self, prop="colors", num="auto", fmt=None, func=lambda x: x, **kwargs
):
"""
Create legend handles and labels for a PathCollection.
Each legend handle is a `.Line2D` representing the Path that was drawn,
and each label is a string what each Path represents.
This is useful ... | legend_elements | file-level | external |
xarray | 53 | xarray/core/datatree.py | def map( # type: ignore[override]
self,
func: Callable,
keep_attrs: bool | None = None,
args: Iterable[Any] = (),
**kwargs: Any,
) -> Dataset:
"""Apply a function to each data variable in this dataset
Parameters
----------
func : callable... | /usr/src/app/target_test_cases/failed_tests_map.txt | def map( # type: ignore[override]
self,
func: Callable,
keep_attrs: bool | None = None,
args: Iterable[Any] = (),
**kwargs: Any,
) -> Dataset:
"""Apply a function to each data variable in this dataset
Parameters
----------
func : callable... | map | repository-level | external |
xarray | 54 | xarray/core/parallel.py | def map_blocks(
func: Callable[..., T_Xarray],
obj: DataArray | Dataset,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] | None = None,
template: DataArray | Dataset | None = None,
) -> T_Xarray:
"""Apply a function to each block of a DataArray or Dataset.
.. warning::
This func... | /usr/src/app/target_test_cases/failed_tests_map_blocks.txt | def map_blocks(
func: Callable[..., T_Xarray],
obj: DataArray | Dataset,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] | None = None,
template: DataArray | Dataset | None = None,
) -> T_Xarray:
"""Apply a function to each block of a DataArray or Dataset.
.. warning::
This func... | map_blocks | repository-level | external |
xarray | 55 | xarray/core/datatree.py | def match(self, pattern: str) -> DataTree:
"""
Return nodes with paths matching pattern.
Uses unix glob-like syntax for pattern-matching.
Parameters
----------
pattern: str
A pattern to match each node path against.
Returns
-------
... | /usr/src/app/target_test_cases/failed_tests_match.txt | def match(self, pattern: str) -> DataTree:
"""
Return nodes with paths matching pattern.
Uses unix glob-like syntax for pattern-matching.
Parameters
----------
pattern: str
A pattern to match each node path against.
Returns
-------
... | match | repository-level | non_external |
xarray | 56 | xarray/core/_aggregations.py | def max(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``max`` along some dimension(s).
Parameters
----------
dim... | /usr/src/app/target_test_cases/failed_tests_max.txt | def max(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``max`` along some dimension(s).
Parameters
----------
dim... | max | repository-level | external |
xarray | 57 | xarray/core/_aggregations.py | def mean(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``mean`` along some dimension(s).
Parameters
----------
d... | /usr/src/app/target_test_cases/failed_tests_mean.txt | def mean(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``mean`` along some dimension(s).
Parameters
----------
d... | mean | repository-level | external |
xarray | 58 | xarray/core/merge.py | def merge(
objects: Iterable[DataArray | CoercibleMapping],
compat: CompatOptions = "no_conflicts",
join: JoinOptions = "outer",
fill_value: object = dtypes.NA,
combine_attrs: CombineAttrsOptions = "override",
) -> Dataset:
"""Merge any number of xarray objects into a single Dataset as variables... | /usr/src/app/target_test_cases/failed_tests_merge.txt | def merge(
objects: Iterable[DataArray | CoercibleMapping],
compat: CompatOptions = "no_conflicts",
join: JoinOptions = "outer",
fill_value: object = dtypes.NA,
combine_attrs: CombineAttrsOptions = "override",
) -> Dataset:
"""Merge any number of xarray objects into a single Dataset as variables... | merge | repository-level | external |
xarray | 59 | xarray/core/_aggregations.py | def min(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``min`` along some dimension(s).
Parameters
----------
dim... | /usr/src/app/target_test_cases/failed_tests_min.txt | def min(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``min`` along some dimension(s).
Parameters
----------
dim... | min | repository-level | external |
xarray | 60 | xarray/backends/api.py | def open_dataarray(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
*,
engine: T_Engine | None = None,
chunks: T_Chunks | None = None,
cache: bool | None = None,
decode_cf: bool | None = None,
mask_and_scale: bool | None = None,
decode_times: bool | None = N... | /usr/src/app/target_test_cases/failed_tests_open_dataarray.txt | def open_dataarray(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
*,
engine: T_Engine | None = None,
chunks: T_Chunks | None = None,
cache: bool | None = None,
decode_cf: bool | None = None,
mask_and_scale: bool | None = None,
decode_times: bool | None = N... | open_dataarray | repository-level | external |
xarray | 61 | xarray/backends/api.py | def open_dataset(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
*,
engine: T_Engine = None,
chunks: T_Chunks = None,
cache: bool | None = None,
decode_cf: bool | None = None,
mask_and_scale: bool | Mapping[str, bool] | None = None,
decode_times: bool | Map... | /usr/src/app/target_test_cases/failed_tests_open_dataset.txt | def open_dataset(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
*,
engine: T_Engine = None,
chunks: T_Chunks = None,
cache: bool | None = None,
decode_cf: bool | None = None,
mask_and_scale: bool | Mapping[str, bool] | None = None,
decode_times: bool | Map... | open_dataset | repository-level | external |
xarray | 62 | xarray/backends/api.py | def open_datatree(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
engine: T_Engine = None,
**kwargs,
) -> DataTree:
"""
Open and decode a DataTree from a file or file-like object, creating one tree node for each group in the file.
Parameters
----------
fil... | /usr/src/app/target_test_cases/failed_tests_open_datatree.txt | def open_datatree(
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore,
engine: T_Engine = None,
**kwargs,
) -> DataTree:
"""
Open and decode a DataTree from a file or file-like object, creating one tree node for each group in the file.
Parameters
----------
fil... | open_datatree | repository-level | external |
xarray | 63 | xarray/backends/api.py | def open_mfdataset(
paths: str | NestedSequence[str | os.PathLike],
chunks: T_Chunks | None = None,
concat_dim: (
str
| DataArray
| Index
| Sequence[str]
| Sequence[DataArray]
| Sequence[Index]
| None
) = None,
compat: CompatOptions = "no_confl... | /usr/src/app/target_test_cases/failed_tests_open_mfdataset.txt | def open_mfdataset(
paths: str | NestedSequence[str | os.PathLike],
chunks: T_Chunks | None = None,
concat_dim: (
str
| DataArray
| Index
| Sequence[str]
| Sequence[DataArray]
| Sequence[Index]
| None
) = None,
compat: CompatOptions = "no_confl... | open_mfdataset | repository-level | external |
xarray | 64 | xarray/backends/zarr.py | def open_zarr(
store,
group=None,
synchronizer=None,
chunks="auto",
decode_cf=True,
mask_and_scale=True,
decode_times=True,
concat_characters=True,
decode_coords=True,
drop_variables=None,
consolidated=None,
overwrite_encoded_chunks=False,
chunk_store=None,
storag... | /usr/src/app/target_test_cases/failed_tests_open_zarr.txt | def open_zarr(
store,
group=None,
synchronizer=None,
chunks="auto",
decode_cf=True,
mask_and_scale=True,
decode_times=True,
concat_characters=True,
decode_coords=True,
drop_variables=None,
consolidated=None,
overwrite_encoded_chunks=False,
chunk_store=None,
storag... | open_zarr | repository-level | external |
xarray | 65 | xarray/plot/dataarray_plot.py | def plot(
darray: DataArray,
*,
row: Hashable | None = None,
col: Hashable | None = None,
col_wrap: int | None = None,
ax: Axes | None = None,
hue: Hashable | None = None,
subplot_kws: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
"""
Default plot of DataArray using ... | /usr/src/app/target_test_cases/failed_tests_plot.txt | def plot(
darray: DataArray,
*,
row: Hashable | None = None,
col: Hashable | None = None,
col_wrap: int | None = None,
ax: Axes | None = None,
hue: Hashable | None = None,
subplot_kws: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
"""
Default plot of DataArray using ... | plot | repository-level | external |
xarray | 66 | xarray/core/_aggregations.py | def prod(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
min_count: int | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``prod`` along some dimension(s).
P... | /usr/src/app/target_test_cases/failed_tests_prod.txt | def prod(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
min_count: int | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``prod`` along some dimension(s).
P... | prod | repository-level | external |
xarray | 67 | xarray/core/groupby.py | def quantile(
self,
q: ArrayLike,
dim: Dims = None,
*,
method: QuantileMethods = "linear",
keep_attrs: bool | None = None,
skipna: bool | None = None,
interpolation: QuantileMethods | None = None,
) -> T_Xarray:
"""Compute the qth quantile ... | /usr/src/app/target_test_cases/failed_tests_quantile.txt | def quantile(
self,
q: ArrayLike,
dim: Dims = None,
*,
method: QuantileMethods = "linear",
keep_attrs: bool | None = None,
skipna: bool | None = None,
interpolation: QuantileMethods | None = None,
) -> T_Xarray:
"""Compute the qth quantile ... | quantile | repository-level | external |
xarray | 68 | xarray/core/rolling.py | def reduce(
self, func: Callable, keep_attrs: bool | None = None, **kwargs: Any
) -> DataArray:
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : callable
Function which can be called in the for... | /usr/src/app/target_test_cases/failed_tests_reduce.txt | def reduce(
self, func: Callable, keep_attrs: bool | None = None, **kwargs: Any
) -> DataArray:
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : callable
Function which can be called in the for... | reduce | repository-level | external |
xarray | 69 | xarray/core/dataset.py | def reindex_like(
self,
other: T_Xarray,
method: ReindexMethodOptions = None,
tolerance: float | Iterable[float] | str | None = None,
copy: bool = True,
fill_value: Any = xrdtypes.NA,
) -> Self:
"""
Conform this object onto the indexes of another o... | /usr/src/app/target_test_cases/failed_tests_reindex_like.txt | def reindex_like(
self,
other: T_Xarray,
method: ReindexMethodOptions = None,
tolerance: float | Iterable[float] | str | None = None,
copy: bool = True,
fill_value: Any = xrdtypes.NA,
) -> Self:
"""
Conform this object onto the indexes of another o... | reindex_like | repository-level | external |
xarray | 70 | xarray/core/dataset.py | def reset_coords(
self,
names: Dims = None,
drop: bool = False,
) -> Self:
"""Given names of coordinates, reset them to become variables
Parameters
----------
names : str, Iterable of Hashable or None, optional
Name(s) of non-index coordinates... | /usr/src/app/target_test_cases/failed_tests_reset_coords.txt | def reset_coords(
self,
names: Dims = None,
drop: bool = False,
) -> Self:
"""Given names of coordinates, reset them to become variables
Parameters
----------
names : str, Iterable of Hashable or None, optional
Name(s) of non-index coordinates... | reset_coords | repository-level | external |
xarray | 71 | xarray/backends/api.py | def save_mfdataset(
datasets,
paths,
mode="w",
format=None,
groups=None,
engine=None,
compute=True,
**kwargs,
):
"""Write multiple datasets to disk as netCDF files simultaneously.
This function is intended for use with datasets consisting of dask.array
objects, in which case... | /usr/src/app/target_test_cases/failed_tests_save_mfdataset.txt | def save_mfdataset(
datasets,
paths,
mode="w",
format=None,
groups=None,
engine=None,
compute=True,
**kwargs,
):
"""Write multiple datasets to disk as netCDF files simultaneously.
This function is intended for use with datasets consisting of dask.array
objects, in which case... | save_mfdataset | file-level | non_external |
xarray | 72 | xarray/core/dataset.py | def sel(
self,
indexers: Mapping[Any, Any] | None = None,
method: str | None = None,
tolerance: int | float | Iterable[int | float] | None = None,
drop: bool = False,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed by ti... | /usr/src/app/target_test_cases/failed_tests_sel.txt | def sel(
self,
indexers: Mapping[Any, Any] | None = None,
method: str | None = None,
tolerance: int | float | Iterable[int | float] | None = None,
drop: bool = False,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed by ti... | sel | repository-level | external |
xarray | 73 | xarray/core/dataset.py | def set_coords(self, names: Hashable | Iterable[Hashable]) -> Self:
"""Given names of one or more variables, set them as coordinates
Parameters
----------
names : hashable or iterable of hashable
Name(s) of variables in this dataset to convert into coordinates.
... | /usr/src/app/target_test_cases/failed_tests_set_coords.txt | def set_coords(self, names: Hashable | Iterable[Hashable]) -> Self:
"""Given names of one or more variables, set them as coordinates
Parameters
----------
names : hashable or iterable of hashable
Name(s) of variables in this dataset to convert into coordinates.
... | set_coords | file-level | external |
xarray | 74 | xarray/coding/cftimeindex.py | def shift( # type: ignore[override] # freq is typed Any, we are more precise
self,
periods: int | float,
freq: str | timedelta | BaseCFTimeOffset | None = None,
) -> Self:
"""Shift the CFTimeIndex a multiple of the given frequency.
See the documentation for :py:func:`~... | /usr/src/app/target_test_cases/failed_tests_shift.txt | def shift( # type: ignore[override] # freq is typed Any, we are more precise
self,
periods: int | float,
freq: str | timedelta | BaseCFTimeOffset | None = None,
) -> Self:
"""Shift the CFTimeIndex a multiple of the given frequency.
See the documentation for :py:func:`~... | shift | repository-level | external |
xarray | 75 | xarray/core/_aggregations.py | def sum(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
min_count: int | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``sum`` along some dimension(s).
Par... | /usr/src/app/target_test_cases/failed_tests_sum.txt | def sum(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
min_count: int | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Self:
"""
Reduce this Dataset's data by applying ``sum`` along some dimension(s).
Par... | sum | repository-level | external |
xarray | 76 | xarray/core/dataset.py | def tail(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with the last `n` values of each array
for the specified dimension(s).
Parameters
----------
indexers : dict or int, defau... | /usr/src/app/target_test_cases/failed_tests_tail.txt | def tail(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with the last `n` values of each array
for the specified dimension(s).
Parameters
----------
indexers : dict or int, defau... | tail | repository-level | external |
xarray | 77 | xarray/core/dataset.py | def thin(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed along every `n`-th
value for the specified dimension(s)
Parameters
----------
indexers : dict or i... | /usr/src/app/target_test_cases/failed_tests_thin.txt | def thin(
self,
indexers: Mapping[Any, int] | int | None = None,
**indexers_kwargs: Any,
) -> Self:
"""Returns a new dataset with each array indexed along every `n`-th
value for the specified dimension(s)
Parameters
----------
indexers : dict or i... | thin | repository-level | external |
xarray | 78 | xarray/core/duck_array_ops.py | def timedelta_to_numeric(value, datetime_unit="ns", dtype=float):
"""Convert a timedelta-like object to numerical values.
Parameters
----------
value : datetime.timedelta, numpy.timedelta64, pandas.Timedelta, str
Time delta representation.
datetime_unit : {Y, M, W, D, h, m, s, ms, us, ns, p... | /usr/src/app/target_test_cases/failed_tests_timedelta_to_numeric.txt | def timedelta_to_numeric(value, datetime_unit="ns", dtype=float):
"""Convert a timedelta-like object to numerical values.
Parameters
----------
value : datetime.timedelta, numpy.timedelta64, pandas.Timedelta, str
Time delta representation.
datetime_unit : {Y, M, W, D, h, m, s, ms, us, ns, p... | timedelta_to_numeric | file-level | external |
xarray | 79 | xarray/coding/cftimeindex.py | def to_datetimeindex(self, unsafe=False):
"""If possible, convert this index to a pandas.DatetimeIndex.
Parameters
----------
unsafe : bool
Flag to turn off warning when converting from a CFTimeIndex with
a non-standard calendar to a DatetimeIndex (default ``... | /usr/src/app/target_test_cases/failed_tests_to_datetimeindex.txt | def to_datetimeindex(self, unsafe=False):
"""If possible, convert this index to a pandas.DatetimeIndex.
Parameters
----------
unsafe : bool
Flag to turn off warning when converting from a CFTimeIndex with
a non-standard calendar to a DatetimeIndex (default ``... | to_datetimeindex | repository-level | external |
xarray | 80 | xarray/plot/utils.py | def values(self) -> DataArray | None:
"""
Return a normalized number array for the unique levels.
Examples
--------
>>> a = xr.DataArray(["b", "a", "a", "b", "c"])
>>> _Normalize(a).values
<xarray.DataArray (dim_0: 5)> Size: 40B
array([3, 1, 1, 3, 5])... | /usr/src/app/target_test_cases/failed_tests_values.txt | def values(self) -> DataArray | None:
"""
Return a normalized number array for the unique levels.
Examples
--------
>>> a = xr.DataArray(["b", "a", "a", "b", "c"])
>>> _Normalize(a).values
<xarray.DataArray (dim_0: 5)> Size: 40B
array([3, 1, 1, 3, 5])... | values | repository-level | non_external |
xarray | 81 | xarray/testing/strategies.py | def variables(
draw: st.DrawFn,
*,
array_strategy_fn: ArrayStrategyFn | None = None,
dims: st.SearchStrategy[Sequence[Hashable] | Mapping[Hashable, int]] | None = None,
dtype: st.SearchStrategy[np.dtype] | None = None,
attrs: st.SearchStrategy[Mapping] = ATTRS,
) -> xr.Variable:
"""
Gene... | /usr/src/app/target_test_cases/failed_tests_variables.txt | def variables(
draw: st.DrawFn,
*,
array_strategy_fn: ArrayStrategyFn | None = None,
dims: st.SearchStrategy[Sequence[Hashable] | Mapping[Hashable, int]] | None = None,
dtype: st.SearchStrategy[np.dtype] | None = None,
attrs: st.SearchStrategy[Mapping] = ATTRS,
) -> xr.Variable:
"""
Gene... | variables | repository-level | external |
xarray | 82 | xarray/core/computation.py | def where(cond, x, y, keep_attrs=None):
"""Return elements from `x` or `y` depending on `cond`.
Performs xarray-like broadcasting across input arguments.
All dimension coordinates on `x` and `y` must be aligned with each
other and with `cond`.
Parameters
----------
cond : scalar, array, ... | /usr/src/app/target_test_cases/failed_tests_where.txt | def where(cond, x, y, keep_attrs=None):
"""Return elements from `x` or `y` depending on `cond`.
Performs xarray-like broadcasting across input arguments.
All dimension coordinates on `x` and `y` must be aligned with each
other and with `cond`.
Parameters
----------
cond : scalar, array, ... | where | repository-level | non_external |
datasets | 0 | src/datasets/features/audio.py | def decode_example(
self, value: dict, token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None
) -> dict:
"""Decode example audio file into audio data.
Args:
value (`dict`):
A dictionary with keys:
- `path`: String with relative... | /usr/src/app/target_test_cases/failed_tests_Audio.decode_example.txt | def decode_example(
self, value: dict, token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None
) -> dict:
"""Decode example audio file into audio data.
Args:
value (`dict`):
A dictionary with keys:
- `path`: String with relative... | Audio.decode_example | repository-level | external |
datasets | 1 | src/datasets/features/features.py | def cast_storage(self, storage: Union[pa.StringArray, pa.IntegerArray]) -> pa.Int64Array:
"""Cast an Arrow array to the `ClassLabel` arrow storage type.
The Arrow types that can be converted to the `ClassLabel` pyarrow storage type are:
- `pa.string()`
- `pa.int()`
Args:
... | /usr/src/app/target_test_cases/failed_tests_ClassLabel.cast_storage.txt | def cast_storage(self, storage: Union[pa.StringArray, pa.IntegerArray]) -> pa.Int64Array:
"""Cast an Arrow array to the `ClassLabel` arrow storage type.
The Arrow types that can be converted to the `ClassLabel` pyarrow storage type are:
- `pa.string()`
- `pa.int()`
Args:
... | ClassLabel.cast_storage | repository-level | external |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.