# Replacements for nanobind's stub generator (python/make_stub.py), for the
# declarations of meshsearch._core that it cannot derive from the module.

# The aliases the signatures of the binding use (python/meshsearch_python.cpp),
# so that they stay readable in help() and in the reference. They exist in
# the stub alone, and a type checker reads through them: the types are those
# their definitions spell out.
#
# A number and the array form of the same argument must not share a type, or
# a type checker could not tell the single form of a query from its batch.
# So a real number is a Python or numpy number and not anything with
# __float__, which an array has, and an integer is a Python or numpy integer
# and not anything with __index__. An array argument is a sequence of such
# numbers or a numpy array; numpy.typing.ArrayLike would also take a single
# number.
^meshsearch\.__prefix__$:
    \from collections.abc import Sequence
    \from typing import TypeAlias
    \import numpy
    \import numpy.typing
    # A real number: a Python float or int, or a numpy floating or integer number.
    _Real: TypeAlias = float | numpy.floating | numpy.integer

    # An integer, for an index or a count: a Python int or a numpy integer.
    _Int: TypeAlias = int | numpy.integer

    # Real numbers for a batch of queries: a sequence of them, or a numpy
    # array of a floating or integer dtype.
    _RealArray: TypeAlias = Sequence[_Real] | numpy.typing.NDArray[numpy.floating | numpy.integer]

    # Integers for a batch of indices: a sequence of them, or a numpy array of
    # an integer dtype.
    _IntArray: TypeAlias = Sequence[_Int] | numpy.typing.NDArray[numpy.integer]

    # One coordinate of every point, for the constructor: as _RealArray, and
    # a numpy array of bools as well.
    _Column: TypeAlias = Sequence[_Real] | numpy.typing.NDArray[numpy.floating | numpy.integer | numpy.bool_]

    # The points as rows (x, y, z), for the constructor: a sequence of triples
    # of real numbers, or a numpy array of shape (N, 3) of a floating, integer
    # or bool dtype.
    _Rows: TypeAlias = Sequence[Sequence[_Real]] | numpy.typing.NDArray[numpy.floating | numpy.integer | numpy.bool_]

    # The box: three pairs (lo, hi) of real numbers, as nested sequences or
    # as a numpy array of shape (3, 2).
    _Limits: TypeAlias = Sequence[Sequence[_Real]] | numpy.typing.NDArray[numpy.floating | numpy.integer]

    # One bool for all three axes, or three bools, as a sequence or a numpy
    # array.
    _Periodic: TypeAlias = bool | numpy.bool_ | Sequence[bool | numpy.bool_] | numpy.typing.NDArray[numpy.bool_]

# Created with collections.namedtuple, which carries no field types.
^meshsearch\.Batch$:
    \from typing import NamedTuple
    \import numpy
    \import numpy.typing
    class Batch(NamedTuple):
        \doc
        indices: numpy.typing.NDArray[numpy.uint32]
        """uint32 array: the indices found by every query, concatenated."""
        offsets: numpy.typing.NDArray[numpy.int64]
        """int64 array of n_query + 1 entries, starting at 0 and ending at len(indices)."""

# Its second base is the built-in the class shares its name with.
^meshsearch\.IndexError$:
    \import builtins
    class IndexError(Error, builtins.IndexError):
        \doc

# The generator leaves module attributes with double underscores out.
^meshsearch\.__suffix__$:
    __version__: str
