Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Internal Changes
- Remove ``setup.py`` file (:pull:`11261`).
By `Nick Hodgskin <https://github.com/VeckoTheGecko>`_.

- Add :func:`typing.overload` decorators to :py:meth:`DataArray.argmin` and :py:meth:`DataArray.argmax`
to narrow return type based on ``dim`` parameter (:issue:`10893` :pull:`11233`).
By `Amartya Anand <https://github.com/SurfyPenguin>`_.

.. _whats-new.2026.02.0:

v2026.02.0 (Feb 13, 2026)
Expand Down
41 changes: 41 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import warnings
from collections.abc import (
Callable,
Collection,
Hashable,
Iterable,
Mapping,
Expand Down Expand Up @@ -6187,6 +6188,26 @@ def idxmax(
keep_attrs=keep_attrs,
)

@overload
def argmin( # type: ignore[overload-overlap]
self,
dim: str,
*,
axis: int | None = None,
keep_attrs: bool | None = None,
skipna: bool | None = None,
) -> Self: ...

@overload
def argmin(
self,
dim: Collection[Hashable] | EllipsisType | None = None,
*,
axis: int | None = None,
keep_attrs: bool | None = None,
skipna: bool | None = None,
) -> dict[Hashable, Self]: ...

def argmin(
self,
dim: Dims = None,
Expand Down Expand Up @@ -6288,6 +6309,26 @@ def argmin(
else:
return self._replace_maybe_drop_dims(result)

@overload
def argmax( # type: ignore[overload-overlap]
self,
dim: str,
*,
axis: int | None = None,
keep_attrs: bool | None = None,
skipna: bool | None = None,
) -> Self: ...

@overload
def argmax(
self,
dim: Collection[Hashable] | EllipsisType | None = None,
*,
axis: int | None = None,
keep_attrs: bool | None = None,
skipna: bool | None = None,
) -> dict[Hashable, Self]: ...

def argmax(
self,
dim: Dims = None,
Expand Down
Loading