1j[ f d Z ddlmZ ddlmZ ddlmZ ddlmZm Z e ed G d d Z
G d
de
Z G d d
e Z G d de Z
G d de
Z G d de Z G d de Z G d de Z G d de ZddlmZ ddlmZmZmZmZmZmZmZmZmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZR ddlSmTZTmUZU dd lVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZf dd!lgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z| erdd"l}m~Z~mZmZmZmZ d#S eZ~eZeZeZeZd#S )$z(Private counterpart of ``numpy.typing``. )annotations )ufunc)
set_module)
TYPE_CHECKINGfinalznumpy.typingc $ e Zd ZdZd fdZ xZS )NBitBasea
A type representing `numpy.number` precision during static type checking.
Used exclusively for the purpose static type checking, `NBitBase`
represents the base of a hierarchical set of subclasses.
Each subsequent subclass is herein used for representing a lower level
of precision, *e.g.* ``64Bit > 32Bit > 16Bit``.
.. versionadded:: 1.20
Examples
--------
Below is a typical usage example: `NBitBase` is herein used for annotating
a function that takes a float and integer of arbitrary precision
as arguments and returns a new float of whichever precision is largest
(*e.g.* ``np.float16 + np.int64 -> np.float64``).
.. code-block:: python
>>> from __future__ import annotations
>>> from typing import TypeVar, TYPE_CHECKING
>>> import numpy as np
>>> import numpy.typing as npt
>>> T1 = TypeVar("T1", bound=npt.NBitBase)
>>> T2 = TypeVar("T2", bound=npt.NBitBase)
>>> def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[T1 | T2]:
... return a + b
>>> a = np.float16()
>>> b = np.int64()
>>> out = add(a, b)
>>> if TYPE_CHECKING:
... reveal_locals()
... # note: Revealed local types are:
... # note: a: numpy.floating[numpy.typing._16Bit*]
... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
... # note: out: numpy.floating[numpy.typing._64Bit*]
returnNonec h d}| j |vrt d t d S )N> _8Bit_16Bit_32Bit_64Bit_80Bit_96Bit_128Bit_256Bitr
z*cannot inherit from final class "NBitBase")__name__ TypeErrorsuper__init_subclass__)cls
allowed_names __class__s M/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/_typing/__init__.pyr zNBitBase.__init_subclass__8 sN
<},,HIII
!!##### )r r )r
__module____qualname____doc__r
__classcell__)r s @r r
r
sH ) )V$ $ $ $ $ $ $ $ $ $r r
c e Zd ZdS )r Nr r r r r r r C Dr r c e Zd ZdS )r Nr$ r% r r r r F r&