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
77
78
79
80
81
82
"""``numpy.exceptions`` — exception and warning classes used by numpy.
This is the user-facing slice of numpy 2.x's ``numpy.exceptions`` module:
the exception/warning *types* that downstream code catches or raises. The
runtime numpy operations in rumpy raise the standard Python exceptions
(``ValueError``, ``TypeError`` …) for the same error conditions, but
these names exist so that ``isinstance(...)`` checks and ``except``
clauses written against numpy's public types still compile and run.
"""
"""An axis is out of bounds or is duplicated."""
=
=
=
= f
= f
"""Casting a complex value to a real type discards the imaginary part."""
"""Issued by ``polyfit`` when a polynomial fit is poorly conditioned."""
"""An operation exceeded an internal complexity budget."""
"""A deprecation that users (not just downstream libraries) should see."""
"""No common dtype exists for the requested promotion."""
"""A whole numpy submodule is being deprecated."""
"""Linear-algebra-specific error (singular matrix, non-convergence, …).
Real numpy puts this in ``numpy.linalg``; we keep the canonical class
here so it's reachable from both ``numpy.exceptions.LinAlgError`` and
``numpy.linalg.LinAlgError`` (the latter via the post-import patch
below).
"""
# Side-effect: real numpy exposes ``LinAlgError`` as ``numpy.linalg.LinAlgError``
# too. rustpython's `#[pymodule]` macro doesn't accept nested pyattrs, so we
# materialise the class up here and pin it onto ``numpy.linalg`` at import
# time. The try/except guards against the (rare) case where ``numpy.linalg``
# isn't reachable yet.
# numpy.exceptions runs during numpy module construction (the lazy pyattrs
# get materialised eagerly while ``extend_module`` runs), so at this point
# ``numpy.linalg`` isn't on the module yet — we can't patch it from here.
# Embedders who want ``numpy.linalg.LinAlgError`` callable after import can
# do ``numpy.linalg.LinAlgError = numpy.exceptions.LinAlgError`` explicitly.
=