Skip to content

TYP: numpy.unique stub missing a keyword only parameter #29583

@hunterhogan

Description

@hunterhogan

Describe the issue:

Note sorted is a keyword-only parameter

def unique(ar, return_index=False, return_inverse=False,
return_counts=False, axis=None, *, equal_nan=True,
sorted=True):

If "numpy/lib/_arraysetops_impl.pyi" is the corresponding stub file

Then it seems that sorted is missing from all of the overload definitions. The first overload, for example, is:

@overload # known scalar-type, FFF
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False] = False,
return_inverse: L[False] = False,
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> NDArray[_ScalarT]: ...

View all overload definitions

@overload # known scalar-type, FFF
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False] = False,
return_inverse: L[False] = False,
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> NDArray[_ScalarT]: ...
@overload # unknown scalar-type, FFF
def unique(
ar: ArrayLike,
return_index: L[False] = False,
return_inverse: L[False] = False,
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> _AnyArray: ...
@overload # known scalar-type, TFF
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[True],
return_inverse: L[False] = False,
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray]: ...
@overload # unknown scalar-type, TFF
def unique(
ar: ArrayLike,
return_index: L[True],
return_inverse: L[False] = False,
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray]: ...
@overload # known scalar-type, FTF (positional)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False],
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray]: ...
@overload # known scalar-type, FTF (keyword)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False] = False,
*,
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray]: ...
@overload # unknown scalar-type, FTF (positional)
def unique(
ar: ArrayLike,
return_index: L[False],
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray]: ...
@overload # unknown scalar-type, FTF (keyword)
def unique(
ar: ArrayLike,
return_index: L[False] = False,
*,
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray]: ...
@overload # known scalar-type, FFT (positional)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False],
return_inverse: L[False],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray]: ...
@overload # known scalar-type, FFT (keyword)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False] = False,
return_inverse: L[False] = False,
*,
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray]: ...
@overload # unknown scalar-type, FFT (positional)
def unique(
ar: ArrayLike,
return_index: L[False],
return_inverse: L[False],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray]: ...
@overload # unknown scalar-type, FFT (keyword)
def unique(
ar: ArrayLike,
return_index: L[False] = False,
return_inverse: L[False] = False,
*,
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray]: ...
@overload # known scalar-type, TTF
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[True],
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray]: ...
@overload # unknown scalar-type, TTF
def unique(
ar: ArrayLike,
return_index: L[True],
return_inverse: L[True],
return_counts: L[False] = False,
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray]: ...
@overload # known scalar-type, TFT (positional)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[True],
return_inverse: L[False],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray]: ...
@overload # known scalar-type, TFT (keyword)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[True],
return_inverse: L[False] = False,
*,
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray]: ...
@overload # unknown scalar-type, TFT (positional)
def unique(
ar: ArrayLike,
return_index: L[True],
return_inverse: L[False],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray]: ...
@overload # unknown scalar-type, TFT (keyword)
def unique(
ar: ArrayLike,
return_index: L[True],
return_inverse: L[False] = False,
*,
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray]: ...
@overload # known scalar-type, FTT (positional)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False],
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray]: ...
@overload # known scalar-type, FTT (keyword)
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[False] = False,
*,
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray]: ...
@overload # unknown scalar-type, FTT (positional)
def unique(
ar: ArrayLike,
return_index: L[False],
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray]: ...
@overload # unknown scalar-type, FTT (keyword)
def unique(
ar: ArrayLike,
return_index: L[False] = False,
*,
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray]: ...
@overload # known scalar-type, TTT
def unique(
ar: _ArrayLike[_ScalarT],
return_index: L[True],
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[NDArray[_ScalarT], _IntArray, _IntArray, _IntArray]: ...
@overload # unknown scalar-type, TTT
def unique(
ar: ArrayLike,
return_index: L[True],
return_inverse: L[True],
return_counts: L[True],
axis: SupportsIndex | None = None,
*,
equal_nan: bool = True,
) -> tuple[_AnyArray, _IntArray, _IntArray, _IntArray]: ...

First "Issue" and probably the last

If y'all make a script to collect most of the required data you want in specific fields, then maybe I'll contribute again. But this experience was not worth the trouble.

Reproduce the code example:

from pathlib import Path
import numpy
import pickle

indexDistinctCrossings: int = 0
indexCurveLocations: int = 1

listArrayCurveLocationsAnalyzed: list[numpy.ndarray[tuple[int, int], numpy.dtype[numpy.uint64]]] = pickle.loads(Path("listArrayCurveLocationsAnalyzed.pkl").read_bytes())

for arrayCurveLocationsAnalyzed in listArrayCurveLocationsAnalyzed:
    abcd = numpy.unique(arrayCurveLocationsAnalyzed, return_index=False, return_inverse=True, return_counts=False, axis=indexCurveLocations, sorted=False)

Error message:

No overloads for "unique" match the provided arguments
  Argument types: (ndarray[tuple[int, int], dtype[uint64]], Literal[False], Literal[True], Literal[False], Literal[1], Literal[False])


From Pylance

Python and NumPy Versions:

2.3.2
3.14.0rc2 (main, Aug 17 2025, 21:35:08) [Clang 20.1.8 ] 64 bit (AMD64) with MSC v.1944 CRT]

Type-checker version and settings:

Version: 1.104.0-insider (user setup)
Commit: 09401e712d4ffa5e497787978fe90c1557a0092b
Date: 2025-08-18T05:03:13.234Z
Electron: 37.2.3
ElectronBuildId: 12035395
Chromium: 138.0.7204.100
Node.js: 22.17.0
V8: 13.8.500258-electron.0
OS: Windows_NT x64 10.0.26100

Identifier
ms-python.vscode-pylance
Version
2025.7.102
Last Updated
2025-08-13, 20:10:16

Additional typing packages.

(.vtail) C:\apps\mapFolding>pip list
Package            Version Editable project location
------------------ ------- -------------------------
astToolkit         0.7.1
autoflake          2.3.1
charset-normalizer 3.4.3
hunterMakesPy      0.2.4
mapFolding         0.15.3  C:\apps\mapFolding
more-itertools     10.7.0
numpy              2.3.2
pip                25.2
platformdirs       4.3.8
pyflakes           3.4.0
typing_extensions  4.14.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions