1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Bare-minimum ``numpy.typing`` for rumpy.
Exports the three names a typical ``from numpy.typing import ...`` line
expects. These are runtime placeholders aimed at making static-typing
imports succeed — rumpy itself doesn't enforce the hints.
The ``_ndarray`` name is injected into the module globals by rumpy's
Rust side before this source is executed, so ``NDArray[T]`` resolves to
the real ndarray class.
Exports:
NDArray[T] — generic alias resolving to ``numpy.ndarray``
ArrayLike — anything coercible to an array
DTypeLike — anything that can specify a dtype
The implementation deliberately avoids ``import typing`` so it works in
rustpython builds that don't ship the Python stdlib.
"""
"""Stand-in for ``typing.Union`` — ``_Union[A, B, …]`` returns a sentinel
object carrying the member types. Pure-runtime placeholder; nothing
inspects the contents."""
=
# Return a fresh instance so each alias compares as a distinct object.
=
=
return
=
return f
# DTypeLike — anything numpy accepts as a `dtype=` argument:
# * one of the scalar types (``np.float64``, ``np.int32``, …),
# * a dtype string ("float64", "int32", "f8", "<i4", …).
=
# ArrayLike — anything coercible to an ndarray by ``np.array(...)``:
# * an existing ndarray (``_ndarray``),
# * a (nested) sequence of numbers / bools,
# * a Python scalar (int / float / bool / complex).
=
# NDArray[T] — generic alias for "ndarray of element type T". rumpy doesn't
# carry element-type info on the static type, so ``NDArray[float]`` is just
# ``numpy.ndarray`` at runtime — the parameter is purely documentary.
"""``NDArray[T]`` ≡ ``numpy.ndarray`` (T unenforced)."""
return
"""Stand-in for numpy's static-typing generic ``NBitBase``.
Real numpy uses this as a base for parametrized integer/float bit-width
aliases (``np.intp`` etc.). rumpy doesn't enforce those constraints at
runtime; the class exists so ``from numpy.typing import NBitBase`` works.
"""
pass
=