NumPy-源码解析-四十三-

46 阅读1小时+

NumPy 源码解析(四十三)

.\numpy\numpy\typing\tests\data\pass\ndarray_shape_manipulation.py

import numpy as np  # 导入 NumPy 库,用于科学计算

nd1 = np.array([[1, 2], [3, 4]])

# reshape方法示例
nd1.reshape(4)  # 将数组重塑为一维数组,形状为 (4,)
nd1.reshape(2, 2)  # 将数组重塑为 2x2 的二维数组
nd1.reshape((2, 2))  # 同样将数组重塑为 2x2 的二维数组

nd1.reshape((2, 2), order="C")  # 使用C顺序按行填充重塑数组
nd1.reshape(4, order="C")  # 使用C顺序按行填充重塑数组

# resize方法示例
nd1.resize()  # 将数组就地重塑为新形状
nd1.resize(4)  # 将数组就地重塑为形状为 (4,) 的新数组
nd1.resize(2, 2)  # 将数组就地重塑为 2x2 的新数组
nd1.resize((2, 2))  # 同样将数组就地重塑为 2x2 的新数组

nd1.resize((2, 2), refcheck=True)  # 将数组就地重塑为 2x2 的新数组,检查引用是否有效
nd1.resize(4, refcheck=True)  # 将数组就地重塑为形状为 (4,) 的新数组,检查引用是否有效

nd2 = np.array([[1, 2], [3, 4]])

# transpose方法示例
nd2.transpose()  # 返回转置的数组
nd2.transpose(1, 0)  # 返回轴的转置,等同于 nd2.T
nd2.transpose((1, 0))  # 同样返回轴的转置

# swapaxes方法示例
nd2.swapaxes(0, 1)  # 交换数组的两个轴

# flatten方法示例
nd2.flatten()  # 返回数组的一维副本,按行顺序
nd2.flatten("C")  # 同样返回按行顺序的一维副本

# ravel方法示例
nd2.ravel()  # 返回数组的扁平化视图,默认按行顺序
nd2.ravel("C")  # 同样返回按行顺序的扁平化视图

# squeeze方法示例
nd2.squeeze()  # 删除数组的单维度条目

nd3 = np.array([[1, 2]])
nd3.squeeze(0)  # 删除指定轴上的单维度条目,这里删除第0轴上的单维度

nd4 = np.array([[[1, 2]]])
nd4.squeeze((0, 1))  # 删除指定轴上的单维度条目,这里删除第0轴和第1轴上的单维度

.\numpy\numpy\typing\tests\data\pass\numeric.py

"""
Tests for :mod:`numpy._core.numeric`.

Does not include tests which fall under ``array_constructors``.
"""

# 导入 NumPy 库和类型定义模块
import numpy as np
import numpy.typing as npt

# 创建一个继承自 NDArray 的子类,元素类型为 np.float64
class SubClass(npt.NDArray[np.float64]):
    ...

# 创建一个 np.int64 类型的整数变量 i8,赋值为 1
i8 = np.int64(1)

# 使用 np.arange 创建一个长度为 27 的数组,并通过 reshape 转换为 3x3x3 的三维数组 A
A = np.arange(27).reshape(3, 3, 3)

# 将数组 A 转换为嵌套列表 B
B: list[list[list[int]]] = A.tolist()

# 创建一个形状为 (27, 27) 的空数组,并将其视图转换为 SubClass 类型 C
C = np.empty((27, 27)).view(SubClass)

# 计算 i8 中非零元素的数量
np.count_nonzero(i8)

# 计算数组 A 中非零元素的数量
np.count_nonzero(A)

# 计算嵌套列表 B 中非零元素的数量
np.count_nonzero(B)

# 计算数组 A 中非零元素的数量,并保持维度信息
np.count_nonzero(A, keepdims=True)

# 计算数组 A 沿着第 0 轴(行)的非零元素数量
np.count_nonzero(A, axis=0)

# 检查 i8 是否使用 Fortran 风格存储
np.isfortran(i8)

# 检查数组 A 是否使用 Fortran 风格存储
np.isfortran(A)

# 返回 i8 中非零元素的索引数组
np.argwhere(i8)

# 返回数组 A 中非零元素的索引数组
np.argwhere(A)

# 返回 i8 中扁平化后非零元素的索引数组
np.flatnonzero(i8)

# 返回数组 A 中扁平化后非零元素的索引数组
np.flatnonzero(A)

# 计算 B[0][0] 和 A 扁平化后的相关性,模式为 "valid"
np.correlate(B[0][0], A.ravel(), mode="valid")

# 计算数组 A 自身扁平化后的相关性,模式为 "same"
np.correlate(A.ravel(), A.ravel(), mode="same")

# 计算 B[0][0] 和 A 扁平化后的卷积,模式为 "valid"
np.convolve(B[0][0], A.ravel(), mode="valid")

# 计算数组 A 自身扁平化后的卷积,模式为 "same"
np.convolve(A.ravel(), A.ravel(), mode="same")

# 计算 i8 和数组 A 的外积
np.outer(i8, A)

# 计算嵌套列表 B 和数组 A 的外积
np.outer(B, A)

# 计算数组 A 自身的外积
np.outer(A, A)

# 计算数组 A 自身的外积,并将结果写入 C
np.outer(A, A, out=C)

# 计算 B 和数组 A 的张量积
np.tensordot(B, A)

# 计算数组 A 自身的张量积
np.tensordot(A, A)

# 计算数组 A 自身的张量积,轴为 (0, 1)
np.tensordot(A, A, axes=(0, 1))

# 检查 i8 是否为标量
np.isscalar(i8)

# 检查数组 A 是否为标量
np.isscalar(A)

# 检查嵌套列表 B 是否为标量
np.isscalar(B)

# 将数组 A 沿第 0 轴(行)滚动 1 个位置
np.roll(A, 1)

# 将数组 A 沿第 0 和第 1 轴滚动分别 1 和 2 个位置
np.roll(A, (1, 2))

# 将嵌套列表 B 沿第 0 轴滚动 1 个位置
np.roll(B, 1)

# 将数组 A 的第 0 轴(行)移动到第 1 轴(列)
np.rollaxis(A, 0, 1)

# 将数组 A 的第 0 轴(行)移动到第 1 轴(列),同时将第 1 轴(列)移动到第 2 轴(深度)
np.moveaxis(A, (0, 1), (1, 2))

# 计算嵌套列表 B 和数组 A 的叉乘
np.cross(B, A)

# 计算数组 A 自身的叉乘
np.cross(A, A)

# 返回一个形状为 [0, 1, 2] 的索引数组
np.indices([0, 1, 2])

# 返回一个形状为 [0, 1, 2] 的稀疏索引数组
np.indices([0, 1, 2], sparse=False)

# 返回一个形状为 [0, 1, 2] 的稀疏索引数组
np.indices([0, 1, 2], sparse=True)

# 返回整数 1 的二进制表示
np.binary_repr(1)

# 返回整数 1 的基数为 2 的表示
np.base_repr(1)

# 检查 i8 和数组 A 是否所有元素在容差范围内相等
np.allclose(i8, A)

# 检查嵌套列表 B 和数组 A 是否所有元素在容差范围内相等
np.allclose(B, A)

# 检查数组 A 自身所有元素在容差范围内是否相等
np.allclose(A, A)

# 检查 i8 和数组 A 是否所有元素在容差范围内近似相等
np.isclose(i8, A)

# 检查嵌套列表 B 和数组 A 是否所有元素在容差范围内近似相等
np.isclose(B, A)

# 检查数组 A 自身所有元素在容差范围内是否近似相等
np.isclose(A, A)

# 检查 i8 和数组 A 是否在形状和元素上完全相等
np.array_equal(i8, A)

# 检查嵌套列表 B 和数组 A 是否在形状和元素上完全相等
np.array_equal(B, A)

# 检查数组 A 自身是否在形状和元素上完全相等
np.array_equal(A, A)

# 检查 i8 和数组 A 是否在形状和元素上等效
np.array_equiv(i8, A)

# 检查嵌套列表 B 和数组 A 是否在形状和元素上等效
np.array_equiv(B, A)

# 检查数组 A 自身是否在形状和元素上等效
np.array_equiv(A, A)

.\numpy\numpy\typing\tests\data\pass\numerictypes.py

# 导入 NumPy 库,命名为 np
import numpy as np

# 检查 np.float64 是否为 np.int64 或 np.float64 类型
np.isdtype(np.float64, (np.int64, np.float64))

# 检查 np.int64 是否为有符号整数类型
np.isdtype(np.int64, "signed integer")

# 检查 "S1" 是否为 np.bytes_ 类型的子类型
np.issubdtype("S1", np.bytes_)

# 检查 np.float64 是否为 np.float32 类型的子类型
np.issubdtype(np.float64, np.float32)

# np.ScalarType 是所有标量类型的父类

# np.ScalarType[0] 是 NumPy 中的标量类型列表的第一个元素
# np.ScalarType[3] 是 NumPy 中的标量类型列表的第四个元素
# np.ScalarType[8] 是 NumPy 中的标量类型列表的第九个元素
# np.ScalarType[10] 是 NumPy 中的标量类型列表的第十一个元素

# np.typecodes["Character"] 返回 NumPy 中字符类型的代码
# np.typecodes["Complex"] 返回 NumPy 中复数类型的代码
# np.typecodes["All"] 返回 NumPy 中所有已定义类型的代码

.\numpy\numpy\typing\tests\data\pass\random.py

from __future__ import annotations  # 导入未来的类型注释功能

from typing import Any  # 导入 Any 类型,表示可以是任意类型
import numpy as np  # 导入 NumPy 库,用于科学计算

SEED_NONE = None  # 定义空种子
SEED_INT = 4579435749574957634658964293569  # 定义整数种子
SEED_ARR: np.ndarray[Any, np.dtype[np.int64]] = np.array([1, 2, 3, 4], dtype=np.int64)  # 定义 NumPy 整数数组种子
SEED_ARRLIKE: list[int] = [1, 2, 3, 4]  # 定义整数列表种子
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)  # 创建 SeedSequence 类型的种子序列对象
SEED_MT19937: np.random.MT19937 = np.random.MT19937(0)  # 创建 MT19937 类型的随机数生成器对象
SEED_PCG64: np.random.PCG64 = np.random.PCG64(0)  # 创建 PCG64 类型的随机数生成器对象
SEED_PHILOX: np.random.Philox = np.random.Philox(0)  # 创建 Philox 类型的随机数生成器对象
SEED_SFC64: np.random.SFC64 = np.random.SFC64(0)  # 创建 SFC64 类型的随机数生成器对象

# 创建默认的随机数生成器对象,没有指定种子
np.random.default_rng()
# 使用 SEED_NONE 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_NONE)
# 使用 SEED_INT 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_INT)
# 使用 SEED_ARR 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_ARR)
# 使用 SEED_ARRLIKE 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_ARRLIKE)
# 使用 SEED_SEED_SEQ 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_SEED_SEQ)
# 使用 SEED_MT19937 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_MT19937)
# 使用 SEED_PCG64 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_PCG64)
# 使用 SEED_PHILOX 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_PHILOX)
# 使用 SEED_SFC64 作为种子创建默认的随机数生成器对象
np.random.default_rng(SEED_SFC64)

# 使用 SEED_NONE 创建 SeedSequence 对象
np.random.SeedSequence(SEED_NONE)
# 使用 SEED_INT 创建 SeedSequence 对象
np.random.SeedSequence(SEED_INT)
# 使用 SEED_ARR 创建 SeedSequence 对象
np.random.SeedSequence(SEED_ARR)
# 使用 SEED_ARRLIKE 创建 SeedSequence 对象
np.random.SeedSequence(SEED_ARRLIKE)

# 使用 SEED_NONE 创建 MT19937 随机数生成器对象
np.random.MT19937(SEED_NONE)
# 使用 SEED_INT 创建 MT19937 随机数生成器对象
np.random.MT19937(SEED_INT)
# 使用 SEED_ARR 创建 MT19937 随机数生成器对象
np.random.MT19937(SEED_ARR)
# 使用 SEED_ARRLIKE 创建 MT19937 随机数生成器对象
np.random.MT19937(SEED_ARRLIKE)
# 使用 SEED_SEED_SEQ 创建 MT19937 随机数生成器对象
np.random.MT19937(SEED_SEED_SEQ)

# 使用 SEED_NONE 创建 PCG64 随机数生成器对象
np.random.PCG64(SEED_NONE)
# 使用 SEED_INT 创建 PCG64 随机数生成器对象
np.random.PCG64(SEED_INT)
# 使用 SEED_ARR 创建 PCG64 随机数生成器对象
np.random.PCG64(SEED_ARR)
# 使用 SEED_ARRLIKE 创建 PCG64 随机数生成器对象
np.random.PCG64(SEED_ARRLIKE)
# 使用 SEED_SEED_SEQ 创建 PCG64 随机数生成器对象
np.random.PCG64(SEED_SEED_SEQ)

# 使用 SEED_NONE 创建 Philox 随机数生成器对象
np.random.Philox(SEED_NONE)
# 使用 SEED_INT 创建 Philox 随机数生成器对象
np.random.Philox(SEED_INT)
# 使用 SEED_ARR 创建 Philox 随机数生成器对象
np.random.Philox(SEED_ARR)
# 使用 SEED_ARRLIKE 创建 Philox 随机数生成器对象
np.random.Philox(SEED_ARRLIKE)
# 使用 SEED_SEED_SEQ 创建 Philox 随机数生成器对象
np.random.Philox(SEED_SEED_SEQ)

# 使用 SEED_NONE 创建 SFC64 随机数生成器对象
np.random.SFC64(SEED_NONE)
# 使用 SEED_INT 创建 SFC64 随机数生成器对象
np.random.SFC64(SEED_INT)
# 使用 SEED_ARR 创建 SFC64 随机数生成器对象
np.random.SFC64(SEED_ARR)
# 使用 SEED_ARRLIKE 创建 SFC64 随机数生成器对象
np.random.SFC64(SEED_ARRLIKE)
# 使用 SEED_SEED_SEQ 创建 SFC64 随机数生成器对象
np.random.SFC64(SEED_SEED_SEQ)

# 创建 SeedSequence 类型的种子序列对象
seed_seq: np.random.bit_generator.SeedSequence = np.random.SeedSequence(SEED_NONE)
# 使用 spawn 方法生成新的种子序列对象
seed_seq.spawn(10)
# 使用 generate_state 方法生成状态数组,指定数据类型为 "u4"
seed_seq.generate_state(3, "u4")
# 使用 generate_state 方法生成状态数组,指定数据类型为 "uint32"
seed_seq.generate_state(3, "uint32")
# 使用 generate_state 方法生成状态数组,指定数据类型为 "u8"
seed_seq.generate_state(3, "u8")
# 使用 generate_state 方法生成状态数组,指定数据类型为 "uint64"
seed_seq.generate_state(3, "uint64")
# 使用 generate_state 方法生成状态数组,指定数据类型为 np.uint32
seed_seq.generate_state(3, np.uint32)
# 使用 generate_state 方法生成状态数组,指定数据类型为 np.uint64
seed_seq.generate_state(3, np.uint64)

# 创建默认的随机数生成器对象
def_gen: np.random.Generator = np.random.default_rng()

# 创建包含单个浮点数 0.1 的 NumPy 浮点数数组
D_arr_0p1: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.1])
# 创建包含单个浮点数 0.5 的 NumPy 浮点数数组
D_arr_0p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.5])
# 创建包含单个浮点数 0.9 的 NumPy 浮点数数组
D_arr_0p9: np.ndarray[Any, np.dtype[np.float64]] = np.array([0.9])
# 创建包含单个浮点数 1.5 的 NumPy 浮点数数组
D_arr_1p5: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.5])
# 创建包含单个整数 10 的 NumPy 整数数组
I_arr_10: np.ndarray[Any, np.dtype[np.int_]] = np.array([10], dtype=np.int_)
# 创建包含单个整数 20 的 NumPy 整数数组
I_arr_20: np.ndarray[Any, np.dtype[np.int_]] = np.array([20], dtype=np.int_)
# 创建包含单个浮点数 0.1 的浮点数列表
D_arr_like_0p1: list[float] = [0.1]
# 创建包含单个浮点数 0.5 的浮点数列表
D_arr_like_0p5: list[float] = [0.5]
# 创建包含单个浮点数 0.9 的浮点数列表
D_arr_like_0p9: list[float] = [0.9]
# 创建包含单个浮点数 1.5 的浮点数列表
D_arr_like_1p5: list[float] = [1.5]
# 创建包含单个整数 10 的整数列表
I_arr_like_10: list[int] = [10]
# 创建包含单个整数 20 的整数列表
I_arr
# 生成一个形状为标准正态分布的随机数,数据类型为np.float32
def_gen.standard_normal(dtype=np.float32)

# 生成一个形状为标
# 生成符合标准 t 分布的随机变量
def_gen.standard_t(D_arr_like_0p5)
# 生成指定大小符合标准 t 分布的随机变量
def_gen.standard_t(D_arr_like_0p5, size=1)

# 生成符合泊松分布的随机变量
def_gen.poisson(0.5)
# 生成一个符合泊松分布的随机变量,大小为 None
def_gen.poisson(0.5, size=None)
# 生成指定大小符合泊松分布的随机变量
def_gen.poisson(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合泊松分布的随机变量
def_gen.poisson(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合泊松分布的随机变量
def_gen.poisson(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合泊松分布的随机变量
def_gen.poisson(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合泊松分布的随机变量
def_gen.poisson(D_arr_like_0p5, size=1)

# 生成符合幂分布的随机变量
def_gen.power(0.5)
# 生成一个符合幂分布的随机变量,大小为 None
def_gen.power(0.5, size=None)
# 生成指定大小符合幂分布的随机变量
def_gen.power(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合幂分布的随机变量
def_gen.power(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合幂分布的随机变量
def_gen.power(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合幂分布的随机变量
def_gen.power(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合幂分布的随机变量
def_gen.power(D_arr_like_0p5, size=1)

# 生成符合帕累托分布的随机变量
def_gen.pareto(0.5)
# 生成一个符合帕累托分布的随机变量,大小为 None
def_gen.pareto(0.5, size=None)
# 生成指定大小符合帕累托分布的随机变量
def_gen.pareto(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合帕累托分布的随机变量
def_gen.pareto(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合帕累托分布的随机变量
def_gen.pareto(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合帕累托分布的随机变量
def_gen.pareto(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合帕累托分布的随机变量
def_gen.pareto(D_arr_like_0p5, size=1)

# 生成符合卡方分布的随机变量
def_gen.chisquare(0.5)
# 生成一个符合卡方分布的随机变量,大小为 None
def_gen.chisquare(0.5, size=None)
# 生成指定大小符合卡方分布的随机变量
def_gen.chisquare(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合卡方分布的随机变量
def_gen.chisquare(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合卡方分布的随机变量
def_gen.chisquare(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合卡方分布的随机变量
def_gen.chisquare(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合卡方分布的随机变量
def_gen.chisquare(D_arr_like_0p5, size=1)

# 生成符合指数分布的随机变量
def_gen.exponential(0.5)
# 生成一个符合指数分布的随机变量,大小为 None
def_gen.exponential(0.5, size=None)
# 生成指定大小符合指数分布的随机变量
def_gen.exponential(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合指数分布的随机变量
def_gen.exponential(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合指数分布的随机变量
def_gen.exponential(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合指数分布的随机变量
def_gen.exponential(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合指数分布的随机变量
def_gen.exponential(D_arr_like_0p5, size=1)

# 生成符合几何分布的随机变量
def_gen.geometric(0.5)
# 生成一个符合几何分布的随机变量,大小为 None
def_gen.geometric(0.5, size=None)
# 生成指定大小符合几何分布的随机变量
def_gen.geometric(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合几何分布的随机变量
def_gen.geometric(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合几何分布的随机变量
def_gen.geometric(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合几何分布的随机变量
def_gen.geometric(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合几何分布的随机变量
def_gen.geometric(D_arr_like_0p5, size=1)

# 生成符合对数系列分布的随机变量
def_gen.logseries(0.5)
# 生成一个符合对数系列分布的随机变量,大小为 None
def_gen.logseries(0.5, size=None)
# 生成指定大小符合对数系列分布的随机变量
def_gen.logseries(0.5, size=1)
# 根据数组 D_arr_0p5 生成符合对数系列分布的随机变量
def_gen.logseries(D_arr_0p5)
# 根据数组 D_arr_0p5 生成指定大小符合对数系列分布的随机变量
def_gen.logseries(D_arr_0p5, size=1)
# 根据类似于 D_arr_0p5 的数组生成符合对数系列分布的随机变量
def_gen.logseries(D_arr_like_0p5)
# 根据类似于 D_arr_0p5 的数组生成指定大小符合对数系列分布的随机变量
def_gen.logseries(D_arr_like_0p5, size=1)

# 生成符合瑞利分布的随机变量
def_gen.rayleigh(0.5)
# 生成一个符合瑞利分布的随机变量,大小为 None
def_gen.rayleigh(0.5
# 生成服从 von Mises 分布的随机数
def_gen.vonmises(D_arr_like_0p5, D_arr_like_0p5)

# 生成服从 von Mises 分布的随机数,可以指定生成的随机数个数
def_gen.vonmises(D_arr_0p5, D_arr_0p5, size=1)

# 生成服从 von Mises 分布的随机数,可以指定生成的随机数个数,输入参数为类似数组的结构
def_gen.vonmises(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成 Wald 分布的随机数
def_gen.wald(0.5, 0.5)

# 生成 Wald 分布的随机数,可以指定生成的随机数个数
def_gen.wald(0.5, 0.5, size=None)

# 生成 Wald 分布的随机数,生成一个随机数
def_gen.wald(0.5, 0.5, size=1)

# 生成 Wald 分布的随机数,其中一个参数为类似数组的结构
def_gen.wald(D_arr_0p5, 0.5)

# 生成 Wald 分布的随机数,其中一个参数为类似数组的结构
def_gen.wald(0.5, D_arr_0p5)

# 生成 Wald 分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.wald(D_arr_0p5, 0.5, size=1)

# 生成 Wald 分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.wald(0.5, D_arr_0p5, size=1)

# 生成 Wald 分布的随机数,其中一个参数为类似数组的结构
def_gen.wald(D_arr_like_0p5, 0.5)

# 生成 Wald 分布的随机数,其中一个参数为类似数组的结构
def_gen.wald(0.5, D_arr_like_0p5)

# 生成 Wald 分布的随机数,两个参数均为类似数组的结构
def_gen.wald(D_arr_0p5, D_arr_0p5)

# 生成 Wald 分布的随机数,两个参数均为类似数组的结构
def_gen.wald(D_arr_like_0p5, D_arr_like_0p5)

# 生成 Wald 分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.wald(D_arr_0p5, D_arr_0p5, size=1)

# 生成 Wald 分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.wald(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成服从均匀分布的随机数
def_gen.uniform(0.5, 0.5)

# 生成服从均匀分布的随机数,可以指定生成的随机数个数
def_gen.uniform(0.5, 0.5, size=None)

# 生成服从均匀分布的随机数,生成一个随机数
def_gen.uniform(0.5, 0.5, size=1)

# 生成服从均匀分布的随机数,其中一个参数为类似数组的结构
def_gen.uniform(D_arr_0p5, 0.5)

# 生成服从均匀分布的随机数,其中一个参数为类似数组的结构
def_gen.uniform(0.5, D_arr_0p5)

# 生成服从均匀分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.uniform(D_arr_0p5, 0.5, size=1)

# 生成服从均匀分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.uniform(0.5, D_arr_0p5, size=1)

# 生成服从均匀分布的随机数,其中一个参数为类似数组的结构
def_gen.uniform(D_arr_like_0p5, 0.5)

# 生成服从均匀分布的随机数,其中一个参数为类似数组的结构
def_gen.uniform(0.5, D_arr_like_0p5)

# 生成服从均匀分布的随机数,两个参数均为类似数组的结构
def_gen.uniform(D_arr_0p5, D_arr_0p5)

# 生成服从均匀分布的随机数,两个参数均为类似数组的结构
def_gen.uniform(D_arr_like_0p5, D_arr_like_0p5)

# 生成服从均匀分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.uniform(D_arr_0p5, D_arr_0p5, size=1)

# 生成服从均匀分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.uniform(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成 Beta 分布的随机数
def_gen.beta(0.5, 0.5)

# 生成 Beta 分布的随机数,可以指定生成的随机数个数
def_gen.beta(0.5, 0.5, size=None)

# 生成 Beta 分布的随机数,生成一个随机数
def_gen.beta(0.5, 0.5, size=1)

# 生成 Beta 分布的随机数,其中一个参数为类似数组的结构
def_gen.beta(D_arr_0p5, 0.5)

# 生成 Beta 分布的随机数,其中一个参数为类似数组的结构
def_gen.beta(0.5, D_arr_0p5)

# 生成 Beta 分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.beta(D_arr_0p5, 0.5, size=1)

# 生成 Beta 分布的随机数,可以指定生成的随机数个数,其中一个参数为类似数组的结构
def_gen.beta(0.5, D_arr_0p5, size=1)

# 生成 Beta 分布的随机数,其中一个参数为类似数组的结构
def_gen.beta(D_arr_like_0p5, 0.5)

# 生成 Beta 分布的随机数,其中一个参数为类似数组的结构
def_gen.beta(0.5, D_arr_like_0p5)

# 生成 Beta 分布的随机数,两个参数均为类似数组的结构
def_gen.beta(D_arr_0p5, D_arr_0p5)

# 生成 Beta 分布的随机数,两个参数均为类似数组的结构
def_gen.beta(D_arr_like_0p5, D_arr_like_0p5)

# 生成 Beta 分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.beta(D_arr_0p5, D_arr_0p5, size=1)

# 生成 Beta 分布的随机数,可以指定生成的随机数个数,两个参数均为类似数组的结构
def_gen.beta(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成 F 分布的随机数
def_gen.f(0.5, 0.5)

# 生成 F 分布的随机数,可以指定生成的随机数个数
def_gen.f(0.5, 0.5, size=None)

# 生成 F 分布的随机数,生成一个随
# 使用 laplace 分布生成一个随机数,参数为 loc=0.5, scale=0.5
def_gen.laplace(0.5, 0.5)

# 使用 laplace 分布生成一个随机数数组,参数为 loc=0.5, scale=0.5,size 可选
def_gen.laplace(0.5, 0.5, size=None)

# 使用 laplace 分布生成一个单一随机数,参数为 loc=0.5, scale=0.5
def_gen.laplace(0.5, 0.5, size=1)

# 使用 laplace 分布生成一个随机数数组,第一个参数是数组 D_arr_0p5,loc=0.5, scale=0.5
def_gen.laplace(D_arr_0p5, 0.5)

# 使用 laplace 分布生成一个随机数数组,loc=0.5, scale=0.5,第一个参数是数组 D_arr_0p5,size=1
def_gen.laplace(0.5, D_arr_0p5, size=1)

# 使用 laplace 分布生成一个单一随机数,第一个参数是数组 D_arr_0p5,loc=0.5, scale=0.5
def_gen.laplace(D_arr_0p5, 0.5, size=1)

# 使用 laplace 分布生成一个随机数数组,第一个参数是数组 D_arr_like_0p5,loc=0.5, scale=0.5
def_gen.laplace(0.5, D_arr_like_0p5)

# 使用 laplace 分布生成一个单一随机数,两个参数都是数组 D_arr_0p5
def_gen.laplace(D_arr_0p5, D_arr_0p5)

# 使用 laplace 分布生成一个随机数数组,两个参数都是数组 D_arr_like_0p5,size=1
def_gen.laplace(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 使用 logistic 分布生成一个随机数,参数为 loc=0.5, scale=0.5
def_gen.logistic(0.5, 0.5)

# 使用 logistic 分布生成一个随机数数组,参数为 loc=0.5, scale=0.5,size 可选
def_gen.logistic(0.5, 0.5, size=None)

# 使用 logistic 分布生成一个单一随机数,参数为 loc=0.5, scale=0.5
def_gen.logistic(0.5, 0.5, size=1)

# 使用 logistic 分布生成一个随机数数组,第一个参数是数组 D_arr_0p5,loc=0.5, scale=0.5
def_gen.logistic(D_arr_0p5, 0.5)

# 使用 logistic 分布生成一个随机数数组,loc=0.5, scale=0.5,第一个参数是数组 D_arr_0p5,size=1
def_gen.logistic(0.5, D_arr_0p5, size=1)

# 使用 logistic 分布生成一个单一随机数,第一个参数是数组 D_arr_0p5,loc=0.5, scale=0.5
def_gen.logistic(D_arr_0p5, 0.5, size=1)

# 使用 logistic 分布生成一个随机数数组,第一个参数是数组 D_arr_like_0p5,loc=0.5, scale=0.5
def_gen.logistic(0.5, D_arr_like_0p5)

# 使用 logistic 分布生成一个单一随机数,两个参数都是数组 D_arr_0p5
def_gen.logistic(D_arr_0p5, D_arr_0p5)

# 使用 logistic 分布生成一个随机数数组,两个参数都是数组 D_arr_like_0p5,size=1
def_gen.logistic(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 使用 lognormal 分布生成一个随机数,参数为 mean=0.5, sigma=0.5
def_gen.lognormal(0.5, 0.5)

# 使用 lognormal 分布生成一个随机数数组,参数为 mean=0.5, sigma=0.5,size 可选
def_gen.lognormal(0.5, 0.5, size=None)

# 使用 lognormal 分布生成一个单一随机数,参数为 mean=0.5, sigma=0.5
def_gen.lognormal(0.5, 0.5, size=1)

# 使用 lognormal 分布生成一个随机数数组,第一个参数是数组 D_arr_0p5,mean=0.5, sigma=0.5
def_gen.lognormal(D_arr_0p5, 0.5)

# 使用 lognormal 分布生成一个随机数数组,mean=0.5, sigma=0.5,第一个参数是数组 D_arr_0p5,size=1
def_gen.lognormal(0.5, D_arr_0p5, size=1)

# 使用 lognormal 分布生成一个单一随机数,第一个参数是数组 D_arr_0p5,mean=0.5, sigma=0.5
def_gen.lognormal(D_arr_0p5, 0.5, size=1)

# 使用 lognormal 分布生成一个随机数数组,第一个参数是数组 D_arr_like_0p5,mean=0.5, sigma=0.5
def_gen.lognormal(0.5, D_arr_like_0p5)

# 使用 lognormal 分布生成一个单一随机数,两个参数都是数组 D_arr_0p5
def_gen.lognormal(D_arr_0p5, D_arr_0p5)

# 使用 lognormal 分布生成一个随机数数组,两个参数都是数组 D_arr_like_0p5,size=1
def_gen.lognormal(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 使用 noncentral_chisquare 分布生成一个随机数,参数为 df=0.5, nonc=0.5
def_gen.noncentral_chisquare(0.5, 0.5)

# 使用 noncentral_chisquare 分布生成一个随机数数组,参数为 df=0.5, nonc=0.5,size 可选
def_gen.noncentral_chisquare(0.5, 0.5, size=None)

# 使用 noncentral_chisquare 分布生成一个单一随机数,参数为 df=0.5, nonc=0.5
def_gen.noncentral_chisquare(0.5, 0.5, size=1)

# 使用 noncentral_chisquare 分布生成一个随机数数组,第一个参数是数组 D_arr_0p5,df=0.5, nonc=0.5
def_gen.noncentral_chisquare(D_arr_0p5, 0.5)

# 使用 noncentral_chisquare 分布生成一个随机数数组,df=0.5, nonc=0.5,第一个参数是数组 D_arr_0p5,size=1
def_gen.noncentral_chisquare(0.5, D_arr_0p5, size=1)

# 使用 noncentral_chisquare 分布生成一个单一随机数,第一个参数是数组 D_arr_0p5,df=0.5, nonc=0.5
def_gen.noncentral_chisquare(D_arr_0p5, 0.5, size=1)

# 使用 noncentral_chisquare 分布生成一个随机数数组,第一个参数是数组 D_arr_like_0p5,df=0.5, nonc=0.5
def_gen.noncentral_chisquare(0.5, D_arr_like_0p5)

# 使用 noncentral_chisquare 分布生成一个单一随机数,两个参数都是数组 D_arr_0p5
def_gen.noncentral_chisquare(D_arr_0p5, D_arr_0p5)

# 使用 noncentral_chisquare 分布生成一个随机数数组,两个参数都是数组 D_arr_like_0p5,size=1
def_gen.noncentral_chisquare(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 使用 normal 分布生成一个随机数,参数为 loc=0.5, scale=0.5
def_gen.normal(0.5, 0.5)

# 使用 normal 分布生成一个随机数数组,参数为 loc=0.5, scale=0.5,size 可选
def_gen.normal(0.5, 0.5, size=None)

# 使用 normal 分布生成一个单一随机
# 生成一个从 0.1 到 0.9 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(0.1, D_arr_0p5, 0.9, size=1)

# 生成一个从 D_arr_like_0p1 到 0.5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(D_arr_like_0p1, 0.5, D_arr_0p9)

# 生成一个从 0.5 到 D_arr_like_0p5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(0.5, D_arr_like_0p5, 0.9)

# 生成一个从 D_arr_0p1 到 D_arr_0p5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(D_arr_0p1, D_arr_0p5, 0.9)

# 生成一个从 D_arr_like_0p1 到 D_arr_like_0p5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(D_arr_like_0p1, D_arr_like_0p5, 0.9)

# 生成一个从 D_arr_0p1 到 D_arr_0p5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(D_arr_0p1, D_arr_0p5, D_arr_0p9, size=1)

# 生成一个从 D_arr_like_0p1 到 D_arr_like_0p5 之间的三角分布的随机数,返回一个包含一个元素的数组
def_gen.triangular(D_arr_like_0p1, D_arr_like_0p5, D_arr_like_0p9, size=1)

# 生成一个自由度为 0.5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(0.1, 0.5, 0.9)

# 生成一个自由度为 0.5 的非中心 F 分布的随机数,返回一个数组,其大小为 None
def_gen.noncentral_f(0.1, 0.5, 0.9, size=None)

# 生成一个自由度为 0.5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(0.1, 0.5, 0.9, size=1)

# 生成一个自由度为 D_arr_0p1 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_0p1, 0.5, 0.9)

# 生成一个自由度为 0.5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(0.1, D_arr_0p5, 0.9)

# 生成一个自由度为 D_arr_0p1 和 D_arr_like_0p9 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_0p1, 0.5, D_arr_like_0p9, size=1)

# 生成一个自由度为 0.5 和 D_arr_0p5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(0.1, D_arr_0p5, 0.9, size=1)

# 生成一个自由度为 D_arr_like_0p1 和 D_arr_0p9 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_like_0p1, 0.5, D_arr_0p9)

# 生成一个自由度为 0.5 和 D_arr_like_0p5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(0.5, D_arr_like_0p5, 0.9)

# 生成一个自由度为 D_arr_0p1 和 D_arr_0p5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_0p1, D_arr_0p5, 0.9)

# 生成一个自由度为 D_arr_like_0p1 和 D_arr_like_0p5 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_like_0p1, D_arr_like_0p5, 0.9)

# 生成一个自由度为 D_arr_0p1 和 D_arr_0p5 和 D_arr_0p9 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_0p1, D_arr_0p5, D_arr_0p9, size=1)

# 生成一个自由度为 D_arr_like_0p1 和 D_arr_like_0p5 和 D_arr_like_0p9 的非中心 F 分布的随机数,返回一个包含一个元素的数组
def_gen.noncentral_f(D_arr_like_0p1, D_arr_like_0p5, D_arr_like_0p9, size=1)

# 生成一个参数为 10 和 0.5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(10, 0.5)

# 生成一个参数为 10 和 0.5 的二项分布的随机数,返回一个数组,其大小为 None
def_gen.binomial(10, 0.5, size=None)

# 生成一个参数为 10 和 0.5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(10, 0.5, size=1)

# 生成一个参数为 I_arr_10 和 0.5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_10, 0.5)

# 生成一个参数为 10 和 D_arr_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(10, D_arr_0p5)

# 生成一个参数为 I_arr_10 和 0.5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_10, 0.5, size=1)

# 生成一个参数为 10 和 D_arr_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(10, D_arr_0p5, size=1)

# 生成一个参数为 I_arr_like_10 和 0.5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_like_10, 0.5)

# 生成一个参数为 10 和 D_arr_like_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(10, D_arr_like_0p5)

# 生成一个参数为 I_arr_10 和 D_arr_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_10, D_arr_0p5)

# 生成一个参数为 I_arr_like_10 和 D_arr_like_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_like_10, D_arr_like_0p5)

# 生成一个参数为 I_arr_10 和 D_arr_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_10, D_arr_0p5, size=1)

# 生成一个参数为 I_arr_like_10 和 D_arr_like_0p5 的二项分布的随机数,返回一个包含一个元素的数组
def_gen.binomial(I_arr_like_10, D_arr_like_0p5, size
# 定义一个随机数生成器,生成整数范围在 [0, 100) 内的随机数
def_gen.integers(0, [100])

# 定义一个布尔类型的 numpy 数组,包含一个元素 0
I_bool_low: np.ndarray[Any, np.dtype[np.bool]] = np.array([0], dtype=np.bool)
# 定义一个与上述 numpy 数组相似的 Python 列表,包含一个整数 0
I_bool_low_like: list[int] = [0]
# 定义一个布尔类型的 numpy 数组,包含一个元素 1
I_bool_high_open: np.ndarray[Any, np.dtype[np.bool]] = np.array([1], dtype=np.bool)
# 定义一个布尔类型的 numpy 数组,包含一个元素 1
I_bool_high_closed: np.ndarray[Any, np.dtype[np.bool]] = np.array([1], dtype=np.bool)

# 生成一个布尔类型的随机数
def_gen.integers(2, dtype=bool)
# 生成一个布尔类型的随机数,取值范围 [0, 2)
def_gen.integers(0, 2, dtype=bool)
# 生成一个布尔类型的随机数,取值范围 [0, 1]
def_gen.integers(1, dtype=bool, endpoint=True)
# 生成一个布尔类型的随机数,取值范围 [0, 1]
def_gen.integers(0, 1, dtype=bool, endpoint=True)
# 生成一个布尔类型的随机数,取值范围 [0, 1]
def_gen.integers(I_bool_low_like, 1, dtype=bool, endpoint=True)
# 生成一个布尔类型的随机数,取值范围 [0, 1)
def_gen.integers(I_bool_high_open, dtype=bool)
# 生成一个布尔类型的随机数,取值范围 [0, 1)
def_gen.integers(I_bool_low, I_bool_high_open, dtype=bool)
# 生成一个布尔类型的随机数,取值范围 [0, 1)
def_gen.integers(0, I_bool_high_open, dtype=bool)
# 生成一个布尔类型的随机数,取值范围 [0, 2]
def_gen.integers(I_bool_high_closed, dtype=bool, endpoint=True)
# 生成一个布尔类型的随机数,取值范围 [0, 2]
def_gen.integers(I_bool_low, I_bool_high_closed, dtype=bool, endpoint=True)
# 生成一个布尔类型的随机数,取值范围 [0, 2]
def_gen.integers(0, I_bool_high_closed, dtype=bool, endpoint=True)

# 定义一个无符号 8 位整数的 numpy 数组,包含一个元素 0
I_u1_low: np.ndarray[Any, np.dtype[np.uint8]] = np.array([0], dtype=np.uint8)
# 定义一个与上述 numpy 数组相似的 Python 列表,包含一个整数 0
I_u1_low_like: list[int] = [0]
# 定义一个无符号 8 位整数的 numpy 数组,包含一个元素 255
I_u1_high_open: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)
# 定义一个无符号 8 位整数的 numpy 数组,包含一个元素 255
I_u1_high_closed: np.ndarray[Any, np.dtype[np.uint8]] = np.array([255], dtype=np.uint8)

# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(256, dtype="u1")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(0, 256, dtype="u1")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(255, dtype="u1", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(0, 255, dtype="u1", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(I_u1_low_like, 255, dtype="u1", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(I_u1_high_open, dtype="u1")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(I_u1_low, I_u1_high_open, dtype="u1")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(0, I_u1_high_open, dtype="u1")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(I_u1_high_closed, dtype="u1", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(I_u1_low, I_u1_high_closed, dtype="u1", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(0, I_u1_high_closed, dtype="u1", endpoint=True)

# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(256, dtype="uint8")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(0, 256, dtype="uint8")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(255, dtype="uint8", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(0, 255, dtype="uint8", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255]
def_gen.integers(I_u1_low_like, 255, dtype="uint8", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(I_u1_high_open, dtype="uint8")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(I_u1_low, I_u1_high_open, dtype="uint8")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 255)
def_gen.integers(0, I_u1_high_open, dtype="uint8")
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(I_u1_high_closed, dtype="uint8", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(I_u1_low, I_u1_high_closed, dtype="uint8", endpoint=True)
# 生成一个无符号 8 位整数的随机数,取值范围 [0, 256)
def_gen.integers(0, I_u1_high_closed, dtype="uint8", endpoint=True)
# 生成一个指定范围内的 uint8 类型的随机整数,包括上限值
def_gen.integers(0, I_u1_high_closed, dtype="uint8", endpoint=True)

# 生成一个范围在 0 到 255 之间的 uint8 类型的随机整数
def_gen.integers(256, dtype=np.uint8)

# 生成一个范围在 0 到 255 之间的 uint8 类型的随机整数,包括上限值 255
def_gen.integers(0, 256, dtype=np.uint8)

# 生成一个范围在 0 到 255 之间的 uint8 类型的随机整数,包括上限值 255
def_gen.integers(255, dtype=np.uint8, endpoint=True)

# 生成一个范围在 0 到 255 之间的 uint8 类型的随机整数,包括上限值 255
def_gen.integers(0, 255, dtype=np.uint8, endpoint=True)

# 生成一个范围在 I_u1_low_like 到 255 之间的 uint8 类型的随机整数,包括上限值 255
def_gen.integers(I_u1_low_like, 255, dtype=np.uint8, endpoint=True)

# 生成一个范围在 I_u1_high_open 到 255 之间的 uint8 类型的随机整数
def_gen.integers(I_u1_high_open, dtype=np.uint8)

# 生成一个范围在 I_u1_low 到 I_u1_high_open 之间的 uint8 类型的随机整数
def_gen.integers(I_u1_low, I_u1_high_open, dtype=np.uint8)

# 生成一个范围在 0 到 I_u1_high_open 之间的 uint8 类型的随机整数
def_gen.integers(0, I_u1_high_open, dtype=np.uint8)

# 生成一个范围在 I_u1_high_closed 到 255 之间的 uint8 类型的随机整数,包括上限值 I_u1_high_closed
def_gen.integers(I_u1_high_closed, dtype=np.uint8, endpoint=True)

# 生成一个范围在 I_u1_low 到 I_u1_high_closed 之间的 uint8 类型的随机整数,包括上限值 I_u1_high_closed
def_gen.integers(I_u1_low, I_u1_high_closed, dtype=np.uint8, endpoint=True)

# 生成一个范围在 0 到 I_u1_high_closed 之间的 uint8 类型的随机整数,包括上限值 I_u1_high_closed
def_gen.integers(0, I_u1_high_closed, dtype=np.uint8, endpoint=True)

# 创建一个 uint16 类型的数组,包含一个元素 0
I_u2_low: np.ndarray[Any, np.dtype[np.uint16]] = np.array([0], dtype=np.uint16)

# 创建一个包含一个元素 0 的整数列表
I_u2_low_like: list[int] = [0]

# 创建一个 uint16 类型的数组,包含一个元素 65535
I_u2_high_open: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)

# 创建一个 uint16 类型的数组,包含一个元素 65535
I_u2_high_closed: np.ndarray[Any, np.dtype[np.uint16]] = np.array([65535], dtype=np.uint16)

# 生成一个范围在 0 到 65536 之间的 u2 类型的随机整数
def_gen.integers(65536, dtype="u2")

# 生成一个范围在 0 到 65536 之间的 u2 类型的随机整数
def_gen.integers(0, 65536, dtype="u2")

# 生成一个范围在 0 到 65535 之间的 u2 类型的随机整数,包括上限值 65535
def_gen.integers(65535, dtype="u2", endpoint=True)

# 生成一个范围在 0 到 65535 之间的 u2 类型的随机整数,包括上限值 65535
def_gen.integers(0, 65535, dtype="u2", endpoint=True)

# 生成一个范围在 I_u2_low_like 到 65535 之间的 u2 类型的随机整数,包括上限值 65535
def_gen.integers(I_u2_low_like, 65535, dtype="u2", endpoint=True)

# 生成一个范围在 I_u2_high_open 到 65535 之间的 u2 类型的随机整数
def_gen.integers(I_u2_high_open, dtype="u2")

# 生成一个范围在 I_u2_low 到 I_u2_high_open 之间的 u2 类型的随机整数
def_gen.integers(I_u2_low, I_u2_high_open, dtype="u2")

# 生成一个范围在 0 到 I_u2_high_open 之间的 u2 类型的随机整数
def_gen.integers(0, I_u2_high_open, dtype="u2")

# 生成一个范围在 I_u2_high_closed 到 65535 之间的 u2 类型的随机整数,包括上限值 I_u2_high_closed
def_gen.integers(I_u2_high_closed, dtype="u2", endpoint=True)

# 生成一个范围在 I_u2_low 到 I_u2_high_closed 之间的 u2 类型的随机整数,包括上限值 I_u2_high_closed
def_gen.integers(I_u2_low, I_u2_high_closed, dtype="u2", endpoint=True)

# 生成一个范围在 0 到 I_u2_high_closed 之间的 u2 类型的随机整数,包括上限值 I_u2_high_closed
def_gen.integers(0, I_u2_high_closed, dtype="u2", endpoint=True)

# 生成一个范围在 0 到 65536 之间的 uint16 类型的随机整数
def_gen.integers(65536, dtype="uint16")

# 生成一个范围在 0 到 65536 之间的 uint16 类型的随机整数
def_gen.integers(0, 65536, dtype="uint16")

# 生成一个范围在 0 到 65535 之间的 uint16 类型的随机整数,包括上限值 65535
def_gen.integers(65535, dtype="uint16", endpoint=True)

# 生成一个范围在 0 到 65535 之间的 uint16 类型的随机整数,包括上限值 65535
def_gen.integers(0, 65535, dtype="uint16", endpoint=True)

# 生成一个范围在 I_u2_low_like 到 65535 之间的 uint16 类型的随机整数,包括上限值 65535
def_gen.integers(I_u2_low_like, 65535, dtype="uint16", endpoint=True)

# 生成一个范围在 I_u2_high_open 到 65535 之间的 uint16 类型的随机整数
def_gen.integers(I_u2_high_open, dtype="uint16")

# 生成一个范围在 I_u2_low 到 I_u2_high_open 之间的 uint16 类型的随机整数
def_gen.integers(I_u2_low, I_u2_high_open, dtype="uint16")

# 生成一个范围在 0 到 I_u2_high_open 之间的 uint16 类型的随机整数
def_gen.integers(0, I_u2_high_open, dtype="uint16")

# 生成一个范围在 I_u2_high_closed 到 65535 之间的 uint16 类型的随机整数,包括上限值 I_u2_high_closed
def_gen.integers(I_u2_high_closed, dtype="uint16", endpoint=True)

# 生成一个范围在 I_u2_low 到 I_u2_high_closed 之间的 uint16 类型的随机整数,包括上限值 I_u2_high_closed
def_gen.integers(I_u2_low, I_u2_high_closed, dtype="uint16", endpoint=True)

# 生成一个范围在 0
# 定义一个包含单个元素 4294967295 的 uint32 类型的 numpy 数组
I_u4_high_open: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)
# 定义一个包含单个元素 4294967295 的 uint32 类型的 numpy 数组
I_u4_high_closed: np.ndarray[Any, np.dtype[np.uint32]] = np.array([4294967295], dtype=np.uint32)

# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967296),不包含 4294967296
def_gen.integers(4294967296, dtype="u4")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967296),不包含 4294967296
def_gen.integers(0, 4294967296, dtype="u4")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(4294967295, dtype="u4", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(0, 4294967295, dtype="u4", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low_like, 4294967295],包含 4294967295
def_gen.integers(I_u4_low_like, 4294967295, dtype="u4", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(I_u4_high_open, dtype="u4")
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(I_u4_low, I_u4_high_open, dtype="u4")
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(0, I_u4_high_open, dtype="u4")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(I_u4_high_closed, dtype="u4", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low, 4294967295],包含 4294967295
def_gen.integers(I_u4_low, I_u4_high_closed, dtype="u4", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(0, I_u4_high_closed, dtype="u4", endpoint=True)

# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967296),不包含 4294967296
def_gen.integers(4294967296, dtype="uint32")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967296),不包含 4294967296
def_gen.integers(0, 4294967296, dtype="uint32")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(4294967295, dtype="uint32", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(0, 4294967295, dtype="uint32", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low_like, 4294967295],包含 4294967295
def_gen.integers(I_u4_low_like, 4294967295, dtype="uint32", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(I_u4_high_open, dtype="uint32")
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(I_u4_low, I_u4_high_open, dtype="uint32")
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u4_high_open),不包含 I_u4_high_open
def_gen.integers(0, I_u4_high_open, dtype="uint32")
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(I_u4_high_closed, dtype="uint32", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [I_u4_low, 4294967295],包含 4294967295
def_gen.integers(I_u4_low, I_u4_high_closed, dtype="uint32", endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, 4294967295],包含 4294967295
def_gen.integers(0, I_u4_high_closed, dtype="uint32", endpoint=True)

# 生成一个 uint32 类型的随机整数,范围为 [0, 18446744073709551616),不包含 18446744073709551616
def_gen.integers(18446744073709551616, dtype=np.uint64)
# 生成一个 uint32 类型的随机整数,范围为 [0, 18446744073709551616),不包含 18446744073709551616
def_gen.integers(0, 18446744073709551616, dtype=np.uint64)
# 生成一个 uint32 类型的随机整数,范围为 [0, 18446744073709551615],包含 18446744073709551615
def_gen.integers(18446744073709551615, dtype=np.uint64, endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, 18446744073709551615],包含 18446744073709551615
def_gen.integers(0, 18446744073709551615, dtype=np.uint64, endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [I_u8_low_like, 18446744073709551615],包含 18446744073709551615
def_gen.integers(I_u8_low_like, 18446744073709551615, dtype=np.uint64, endpoint=True)
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u8_high_open),不包含 I_u8_high_open
def_gen.integers(I_u8_high_open, dtype=np.uint64)
# 生成一个 uint32 类型的随机整数,范围为 [I_u8_low, I_u8_high_open),不包含 I_u8_high_open
def_gen.integers(I_u8_low, I_u8_high_open, dtype=np.uint64)
# 生成一个 uint32 类型的随机整数,范围为 [0, I_u8_high_open),不包含 I_u8_high_open
def_gen.integers(0, I_u8_high_open, dtype=np.uint64)
# 生成一个随机整数,范围是从 I_u8_high_closed 到最大无符号 8 位整数,包含上界
def_gen.integers(I_u8_high_closed, dtype="u8", endpoint=True)

# 生成一个随机整数,范围是从 I_u8_low 到 I_u8_high_closed,包含上界,数据类型为无符号 8 位整数
def_gen.integers(I_u8_low, I_u8_high_closed, dtype="u8", endpoint=True)

# 生成一个随机整数,范围是从 0 到 I_u8_high_closed,包含上界,数据类型为无符号 8 位整数
def_gen.integers(0, I_u8_high_closed, dtype="u8", endpoint=True)

# 生成一个随机整数,大于等于 18446744073709551616,数据类型为无符号 64 位整数
def_gen.integers(18446744073709551616, dtype="uint64")

# 生成一个随机整数,范围是从 0 到 18446744073709551616,数据类型为无符号 64 位整数
def_gen.integers(0, 18446744073709551616, dtype="uint64")

# 生成一个随机整数,范围是从 0 到 18446744073709551615,包含上界,数据类型为无符号 64 位整数
def_gen.integers(18446744073709551615, dtype="uint64", endpoint=True)

# 生成一个随机整数,范围是从 0 到 18446744073709551615,包含上界,数据类型为无符号 64 位整数
def_gen.integers(0, 18446744073709551615, dtype="uint64", endpoint=True)

# 生成一个随机整数,范围是从 I_u8_low_like 到 18446744073709551615,包含上界,数据类型为无符号 64 位整数
def_gen.integers(I_u8_low_like, 18446744073709551615, dtype="uint64", endpoint=True)

# 生成一个随机整数,大于等于 I_u8_high_open,数据类型为无符号 64 位整数
def_gen.integers(I_u8_high_open, dtype="uint64")

# 生成一个随机整数,范围是从 I_u8_low 到 I_u8_high_open,数据类型为无符号 64 位整数
def_gen.integers(I_u8_low, I_u8_high_open, dtype="uint64")

# 生成一个随机整数,范围是从 0 到 I_u8_high_open,数据类型为无符号 64 位整数
def_gen.integers(0, I_u8_high_open, dtype="uint64")

# 生成一个随机整数,小于等于 I_u8_high_closed,数据类型为无符号 64 位整数
def_gen.integers(I_u8_high_closed, dtype="uint64", endpoint=True)

# 生成一个随机整数,范围是从 I_u8_low 到 I_u8_high_closed,包含上界,数据类型为无符号 64 位整数
def_gen.integers(I_u8_low, I_u8_high_closed, dtype="uint64", endpoint=True)

# 生成一个随机整数,范围是从 0 到 I_u8_high_closed,包含上界,数据类型为无符号 64 位整数
def_gen.integers(0, I_u8_high_closed, dtype="uint64", endpoint=True)

# 生成一个随机整数,大于等于 18446744073709551616,数据类型为 numpy 的无符号 64 位整数
def_gen.integers(18446744073709551616, dtype=np.uint64)

# 生成一个随机整数,范围是从 0 到 18446744073709551616,数据类型为 numpy 的无符号 64 位整数
def_gen.integers(0, 18446744073709551616, dtype=np.uint64)

# 生成一个随机整数,范围是从 0 到 18446744073709551615,包含上界,数据类型为 numpy 的无符号 64 位整数
def_gen.integers(18446744073709551615, dtype=np.uint64, endpoint=True)

# 生成一个随机整数,范围是从 0 到 18446744073709551615,包含上界,数据类型为 numpy 的无符号 64 位整数
def_gen.integers(0, 18446744073709551615, dtype=np.uint64, endpoint=True)

# 生成一个随机整数,范围是从 I_i1_low_like 到 127,包含上界,数据类型为 8 位整数
def_gen.integers(I_i1_low_like, 127, dtype="i1", endpoint=True)

# 生成一个随机整数,大于等于 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(I_i1_high_open, dtype="i1")

# 生成一个随机整数,范围是从 I_i1_low 到 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(I_i1_low, I_i1_high_open, dtype="i1")

# 生成一个随机整数,小于等于 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(-128, I_i1_high_open, dtype="i1")

# 生成一个随机整数,大于等于 I_i1_high_closed,数据类型为 8 位整数
def_gen.integers(I_i1_high_closed, dtype="i1", endpoint=True)

# 生成一个随机整数,范围是从 I_i1_low 到 I_i1_high_closed,包含上界,数据类型为 8 位整数
def_gen.integers(I_i1_low, I_i1_high_closed, dtype="i1", endpoint=True)

# 生成一个随机整数,范围是从 0 到 I_i1_high_closed,包含上界,数据类型为 8 位整数
def_gen.integers(-128, I_i1_high_closed, dtype="i1", endpoint=True)

# 生成一个随机整数,范围是从 0 到 127,包含上界,数据类型为 8 位整数
def_gen.integers(127, dtype="i1", endpoint=True)

# 生成一个随机整数,范围是从 -128 到 127,包含上界,数据类型为 8 位整数
def_gen.integers(-128, 127, dtype="i1", endpoint=True)

# 生成一个随机整数,范围是从 I_i1_low_like 到 127,包含上界,数据类型为 8 位整数
def_gen.integers(I_i1_low_like, 127, dtype="int8", endpoint=True)

# 生成一个随机整数,大于等于 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(I_i1_high_open, dtype="int8")

# 生成一个随机整数,范围是从 I_i1_low 到 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(I_i1_low, I_i1_high_open, dtype="int8")

# 生成一个随机整数,小于等于 I_i1_high_open,数据类型为 8 位整数
def_gen.integers(-128, I_i1_high_open, dtype="int8")

# 生成一个随机整数,大于等于 I_i1_high_closed,数据类型为 8 位整数
def_gen.integers(I_i1_high_closed, dtype="int8", endpoint=True)
    
# 生成一个随机整数,范围是从 I_i1_low 到 I_i1_high_closed,包含上界,数据类型为 8 位整数
def_gen.integers(I_i1_low, I_i1_high_closed, dtype="int8", endpoint=True)

# 生成一个随机整数,范围是从 -128 到 I_i1_high_closed,包含上界,数据类型为 8 位整数
def_gen.integers(-128, I_i1_high_closed, dtype="int8", endpoint=True)

# 创建一个 numpy 的 8 位整数类型的数组,包
# 使用 numpy.random.default_rng() 创建一个新的生成器对象
def_gen.integers(I_i1_low, I_i1_high_closed, dtype="int8", endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 -128 到 I_i1_high_closed
def_gen.integers(-128, I_i1_high_closed, dtype="int8", endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 128 到 +127
def_gen.integers(128, dtype=np.int8)

# 使用 np.int8 类型生成一个随机整数,范围从 -128 到 +127
def_gen.integers(-128, 128, dtype=np.int8)

# 使用 np.int8 类型生成一个随机整数,范围从 0 到 +127
def_gen.integers(127, dtype=np.int8, endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 -128 到 +127
def_gen.integers(-128, 127, dtype=np.int8, endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 I_i1_low_like 到 +127
def_gen.integers(I_i1_low_like, 127, dtype=np.int8, endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 I_i1_high_open 到 +127
def_gen.integers(I_i1_high_open, dtype=np.int8)

# 使用 np.int8 类型生成一个随机整数,范围从 I_i1_low 到 I_i1_high_open
def_gen.integers(I_i1_low, I_i1_high_open, dtype=np.int8)

# 使用 np.int8 类型生成一个随机整数,范围从 -128 到 I_i1_high_open
def_gen.integers(-128, I_i1_high_open, dtype=np.int8)

# 使用 np.int8 类型生成一个随机整数,范围从 I_i1_high_closed 到 +127
def_gen.integers(I_i1_high_closed, dtype=np.int8, endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 I_i1_low 到 I_i1_high_closed
def_gen.integers(I_i1_low, I_i1_high_closed, dtype=np.int8, endpoint=True)

# 使用 np.int8 类型生成一个随机整数,范围从 -128 到 I_i1_high_closed
def_gen.integers(-128, I_i1_high_closed, dtype=np.int8, endpoint=True)

# 创建一个包含单个元素 -32768 的 np.int16 类型的数组
I_i2_low: np.ndarray[Any, np.dtype[np.int16]] = np.array([-32768], dtype=np.int16)

# 创建一个包含单个元素 -32768 的 list[int] 类型列表
I_i2_low_like: list[int] = [-32768]

# 创建一个包含单个元素 32767 的 np.int16 类型的数组
I_i2_high_open: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)

# 创建一个包含单个元素 32767 的 np.int16 类型的数组
I_i2_high_closed: np.ndarray[Any, np.dtype[np.int16]] = np.array([32767], dtype=np.int16)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 32768 到 +32767
def_gen.integers(32768, dtype="i2")

# 使用 dtype="i2" 类型生成一个随机整数,范围从 -32768 到 32768
def_gen.integers(-32768, 32768, dtype="i2")

# 使用 dtype="i2" 类型生成一个随机整数,范围从 32767 到 +32767
def_gen.integers(32767, dtype="i2", endpoint=True)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 -32768 到 32767
def_gen.integers(-32768, 32767, dtype="i2", endpoint=True)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 I_i2_low_like 到 32767
def_gen.integers(I_i2_low_like, 32767, dtype="i2", endpoint=True)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 I_i2_high_open 到 +32767
def_gen.integers(I_i2_high_open, dtype="i2")

# 使用 dtype="i2" 类型生成一个随机整数,范围从 I_i2_low 到 I_i2_high_open
def_gen.integers(I_i2_low, I_i2_high_open, dtype="i2")

# 使用 dtype="i2" 类型生成一个随机整数,范围从 -32768 到 I_i2_high_open
def_gen.integers(-32768, I_i2_high_open, dtype="i2")

# 使用 dtype="i2" 类型生成一个随机整数,范围从 I_i2_high_closed 到 +32767
def_gen.integers(I_i2_high_closed, dtype="i2", endpoint=True)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 I_i2_low 到 I_i2_high_closed
def_gen.integers(I_i2_low, I_i2_high_closed, dtype="i2", endpoint=True)

# 使用 dtype="i2" 类型生成一个随机整数,范围从 -32768 到 I_i2_high_closed
def_gen.integers(-32768, I_i2_high_closed, dtype="i2", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 32768 到 +32767
def_gen.integers(32768, dtype="int16")

# 使用 dtype="int16" 类型生成一个随机整数,范围从 -32768 到 32768
def_gen.integers(-32768, 32768, dtype="int16")

# 使用 dtype="int16" 类型生成一个随机整数,范围从 32767 到 +32767
def_gen.integers(32767, dtype="int16", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 -32768 到 32767
def_gen.integers(-32768, 32767, dtype="int16", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 I_i2_low_like 到 32767
def_gen.integers(I_i2_low_like, 32767, dtype="int16", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 I_i2_high_open 到 +32767
def_gen.integers(I_i2_high_open, dtype="int16")

# 使用 dtype="int16" 类型生成一个随机整数,范围从 I_i2_low 到 I_i2_high_open
def_gen.integers(I_i2_low, I_i2_high_open, dtype="int16")

# 使用 dtype="int16" 类型生成一个随机整数,范围从 -32768 到 I_i2_high_open
def_gen.integers(-32768, I_i2_high_open, dtype="int16")

# 使用 dtype="int16" 类型生成一个随机整数,范围从 I_i2_high_closed 到 +32767
def_gen.integers(I_i2_high_closed, dtype="int16", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 I_i2_low 到 I_i2_high_closed
def_gen.integers(I_i2_low, I_i2_high_closed, dtype="int16", endpoint=True)

# 使用 dtype="int16" 类型生成一个随机整数,范围从 -32768 到 I_i2_high_closed
def_gen.integers(-32768, I_i2_high_closed, dtype="int16", endpoint=True)

# 使用 dtype=np.int16 类型生成一个随机整数,范围从 32768 到 +32767
def_gen.integers(32768, dtype=np.int16)

# 使用 dtype=np.int16 类型生成一个随机整数,范围从 -32768 到 32768
def_gen.integers(-32768, 32768, dtype=np.int16)

# 使用 dtype=np.int16 类型生成一个随机整数,范围从 32767 到 +32767
def_gen.integers(32767, dtype=np.int16,
# 创建一个包含单个值 -2147483648 的 int32 类型的 NumPy 数组
I_i4_low: np.ndarray[Any, np.dtype[np.int32]] = np.array([-2147483648], dtype=np.int32)
# 创建一个包含单个值 -2147483648 的 int32 类型的列表
I_i4_low_like: list[int] = [-2147483648]
# 创建一个包含单个值 2147483647 的 int32 类型的 NumPy 数组
I_i4_high_open: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)
# 创建一个包含单个值 2147483647 的 int32 类型的 NumPy 数组
I_i4_high_closed: np.ndarray[Any, np.dtype[np.int32]] = np.array([2147483647], dtype=np.int32)

# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,默认情况下是开区间
def_gen.integers(2147483648, dtype="i4")
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,指定了范围
def_gen.integers(-2147483648, 2147483648, dtype="i4")
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,端点包含在内
def_gen.integers(2147483647, dtype="i4", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,指定了范围且端点包含在内
def_gen.integers(-2147483648, 2147483647, dtype="i4", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,起始值为列表中的值
def_gen.integers(I_i4_low_like, 2147483647, dtype="i4", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,默认情况下是开区间,起始值为数组中的值
def_gen.integers(I_i4_high_open, dtype="i4")
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,起始值和结束值分别为数组中的值
def_gen.integers(I_i4_low, I_i4_high_open, dtype="i4")
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,起始值为 -2147483648,结束值为数组中的值
def_gen.integers(-2147483648, I_i4_high_open, dtype="i4")
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,端点包含在内,结束值为数组中的值
def_gen.integers(I_i4_high_closed, dtype="i4", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,指定了范围且端点包含在内,起始值和结束值分别为数组中的值
def_gen.integers(I_i4_low, I_i4_high_closed, dtype="i4", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int32 类型的随机整数,起始值为 -2147483648,结束值为数组中的值,端点包含在内
def_gen.integers(-2147483648, I_i4_high_closed, dtype="i4", endpoint=True)

# 创建一个包含单个值 -9223372036854775808 的 int64 类型的 NumPy 数组
I_i8_low: np.ndarray[Any, np.dtype[np.int64]] = np.array([-9223372036854775808], dtype=np.int64)
# 创建一个包含单个值 -9223372036854775808 的 int64 类型的列表
I_i8_low_like: list[int] = [-9223372036854775808]
# 创建一个包含单个值 9223372036854775807 的 int64 类型的 NumPy 数组
I_i8_high_open: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)
# 创建一个包含单个值 9223372036854775807 的 int64 类型的 NumPy 数组
I_i8_high_closed: np.ndarray[Any, np.dtype[np.int64]] = np.array([9223372036854775807], dtype=np.int64)

# 使用 def_gen.integers 函数生成一个 int64 类型的随机整数,默认情况下是开区间
def_gen.integers(9223372036854775808, dtype="i8")
# 使用 def_gen.integers 函数生成一个 int64 类型的随机整数,指定了范围
def_gen.integers(-9223372036854775808, 9223372036854775808, dtype="i8")
# 使用 def_gen.integers 函数生成一个 int64 类型的随机整数,端点包含在内
def_gen.integers(9223372036854775807, dtype="i8", endpoint=True)
# 使用 def_gen.integers 函数生成一个 int64 类型的随机整数,指定了范围且端点包含在内
def_gen.integers(-9223372036854775808, 9223372036854775807, dtype="i8", endpoint=True)
# 生成一个从 I_i8_low_like 到 9223372036854775807 的整数,数据类型为 'i8',包括端点
def_gen.integers(I_i8_low_like, 9223372036854775807, dtype="i8", endpoint=True)

# 生成一个从 I_i8_high_open 开始的整数,数据类型为 'i8'
def_gen.integers(I_i8_high_open, dtype="i8")

# 生成一个从 I_i8_low 到 I_i8_high_open 的整数,数据类型为 'i8'
def_gen.integers(I_i8_low, I_i8_high_open, dtype="i8")

# 生成一个从 -9223372036854775808 到 I_i8_high_open 的整数,数据类型为 'i8'
def_gen.integers(-9223372036854775808, I_i8_high_open, dtype="i8")

# 生成一个从 I_i8_high_closed 开始的整数,数据类型为 'i8',不包括端点
def_gen.integers(I_i8_high_closed, dtype="i8", endpoint=True)

# 生成一个从 I_i8_low 到 I_i8_high_closed 的整数,数据类型为 'i8',包括端点
def_gen.integers(I_i8_low, I_i8_high_closed, dtype="i8", endpoint=True)

# 生成一个从 -9223372036854775808 到 I_i8_high_closed 的整数,数据类型为 'i8',包括端点
def_gen.integers(-9223372036854775808, I_i8_high_closed, dtype="i8", endpoint=True)

# 生成一个大于 9223372036854775808 的整数,数据类型为 'int64'
def_gen.integers(9223372036854775808, dtype="int64")

# 生成一个从 -9223372036854775808 到 9223372036854775808 的整数,数据类型为 'int64'
def_gen.integers(-9223372036854775808, 9223372036854775808, dtype="int64")

# 生成一个从 9223372036854775807 开始的整数,数据类型为 'int64',包括端点
def_gen.integers(9223372036854775807, dtype="int64", endpoint=True)

# 生成一个从 -9223372036854775808 到 9223372036854775807 的整数,数据类型为 'int64',包括端点
def_gen.integers(-9223372036854775808, 9223372036854775807, dtype="int64", endpoint=True)

# 生成一个从 I_i8_low_like 到 9223372036854775807 的整数,数据类型为 'int64',包括端点
def_gen.integers(I_i8_low_like, 9223372036854775807, dtype="int64", endpoint=True)

# 生成一个从 I_i8_high_open 开始的整数,数据类型为 'int64'
def_gen.integers(I_i8_high_open, dtype="int64")

# 生成一个从 I_i8_low 到 I_i8_high_open 的整数,数据类型为 'int64'
def_gen.integers(I_i8_low, I_i8_high_open, dtype="int64")

# 生成一个从 -9223372036854775808 到 I_i8_high_open 的整数,数据类型为 'int64'
def_gen.integers(-9223372036854775808, I_i8_high_open, dtype="int64")

# 生成一个从 I_i8_high_closed 开始的整数,数据类型为 'int64',不包括端点
def_gen.integers(I_i8_high_closed, dtype="int64", endpoint=True)

# 生成一个从 I_i8_low 到 I_i8_high_closed 的整数,数据类型为 'int64',包括端点
def_gen.integers(I_i8_low, I_i8_high_closed, dtype="int64", endpoint=True)

# 生成一个从 -9223372036854775808 到 I_i8_high_closed 的整数,数据类型为 'int64',包括端点
def_gen.integers(-9223372036854775808, I_i8_high_closed, dtype="int64", endpoint=True)

# 获取默认的随机数生成器的位生成器
def_gen.bit_generator

# 生成一个长度为 2 的随机字节数组
def_gen.bytes(2)

# 从 0 到 4 中随机选择一个整数
def_gen.choice(5)

# 从 0 到 4 中随机选择 3 个整数,允许重复选择
def_gen.choice(5, 3)

# 从 0 到 4 中随机选择 3 个整数,允许重复选择
def_gen.choice(5, 3, replace=True)

# 从 0 到 4 中随机选择 3 个整数,每个选择的概率相等
def_gen.choice(5, 3, p=[1 / 5] * 5)

# 从 0 到 4 中随机选择 3 个整数,每个选择的概率相等,且不允许重复选择
def_gen.choice(5, 3, p=[1 / 5] * 5, replace=False)

# 从给定的列表中随机选择一个元素
def_gen.choice(["pooh", "rabbit", "piglet", "Christopher"])

# 从给定的列表中随机选择 3 个元素
def_gen.choice(["pooh", "rabbit", "piglet", "Christopher"], 3)

# 从给定的列表中随机选择 3 个元素,每个选择的概率相等
def_gen.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, p=[1 / 4] * 4)

# 从给定的列表中随机选择 3 个元素,允许重复选择
def_gen.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, replace=True)

# 从给定的列表中随机选择 3 个元素,不允许重复选择,且每个选择的概率由给定的 numpy 数组决定
def_gen.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, replace=False, p=np.array([1 / 8, 1 / 8, 1 / 2, 1 / 4]))

# 生成一个二维 Dirichlet 分布样本,参数为 [0.5, 0.5]
def_gen.dirichlet([0.5, 0.5])

# 生成一个二维 Dirichlet 分布样本,参数为 np.array([0.5, 0.5])
def_gen.dirichlet(np.array([0.5, 0.5]))

# 生成三个二维 Dirichlet 分布样本,参数为 np.array([0.5, 0.5])
def_gen.dirichlet(np.array([0.5, 0.5]), size=3)

# 生成一个多项式分布样本,参数为总共 20 次试验,每个结果的概率为 [1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0]
def_gen.multinomial(20, [1 / 6.0] * 6)

# 生成一个多项式分布样本,参数为总共 20 次试验,每个结果的概率为 np.array([0.5, 0.5])
def_gen.multinomial(20, np.array([0.5, 0.5]))

# 生成两个多项式分布样本,每个样本为总共 20 次试验,每个结果的概率为 [1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0]
def_gen.multinomial(20, [1 / 6.0] * 6, size=2)

# 生成一个二维多项式分布样本,参数为分别有两个试验组,每个组中有 [10] 和 [20] 次试验,每个结果的概率为 [1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0]
def_gen.multinomial([[10], [20]], [1 / 6.0] * 6, size=(2,
# 从 np.random 模块中导入 RandomState 类别名为 random_st
random_st: np.random.RandomState = np.random.RandomState()

# 生成一个指定形状的多项式分布样本
def_gen.multinomial(np.array([[10], [20]]), np.array([0.5, 0.5]), size=(2, 2))

# 使用多元超几何分布生成样本,传入列表参数
def_gen.multivariate_hypergeometric([3, 5, 7], 2)
def_gen.multivariate_hypergeometric(np.array([3, 5, 7]), 2)
def_gen.multivariate_hypergeometric(np.array([3, 5, 7]), 2, size=4)
def_gen.multivariate_hypergeometric(np.array([3, 5, 7]), 2, size=(4, 7))
def_gen.multivariate_hypergeometric([3, 5, 7], 2, method="count")
def_gen.multivariate_hypergeometric(np.array([3, 5, 7]), 2, method="marginals")

# 使用多元正态分布生成样本,传入均值和协方差矩阵
def_gen.multivariate_normal([0.0], [[1.0]])
def_gen.multivariate_normal([0.0], np.array([[1.0]]))
def_gen.multivariate_normal(np.array([0.0]), [[1.0]])
def_gen.multivariate_normal([0.0], np.array([[1.0]]))

# 生成一个序列的随机排列
def_gen.permutation(10)
def_gen.permutation([1, 2, 3, 4])
def_gen.permutation(np.array([1, 2, 3, 4]))
def_gen.permutation(D_2D, axis=1)
def_gen.permuted(D_2D)
def_gen.permuted(D_2D_like)
def_gen.permuted(D_2D, axis=1)
def_gen.permuted(D_2D, out=D_2D)
def_gen.permuted(D_2D_like, out=D_2D)
def_gen.permuted(D_2D_like, out=D_2D)
def_gen.permuted(D_2D, axis=1, out=D_2D)

# 对数组或列表进行就地随机排列
def_gen.shuffle(np.arange(10))
def_gen.shuffle([1, 2, 3, 4, 5])
def_gen.shuffle(D_2D, axis=1)

# 返回 RandomState 对象的字符串表示形式
def_gen.__str__()
def_gen.__repr__()
def_gen.__setstate__(dict(def_gen.bit_generator.state))

# 以下是 RandomState 对象的各种随机分布方法的使用示例

# 标准正态分布
random_st.standard_normal()
random_st.standard_normal(size=None)
random_st.standard_normal(size=1)

# 均匀分布
random_st.random()
random_st.random(size=None)
random_st.random(size=1)

# 标准柯西分布
random_st.standard_cauchy()
random_st.standard_cauchy(size=None)
random_st.standard_cauchy(size=1)

# 标准指数分布
random_st.standard_exponential()
random_st.standard_exponential(size=None)
random_st.standard_exponential(size=1)

# Zipf 分布
random_st.zipf(1.5)
random_st.zipf(1.5, size=None)
random_st.zipf(1.5, size=1)
random_st.zipf(D_arr_1p5)
random_st.zipf(D_arr_1p5, size=1)
random_st.zipf(D_arr_like_1p5)
random_st.zipf(D_arr_like_1p5, size=1)

# Weibull 分布
random_st.weibull(0.5)
random_st.weibull(0.5, size=None)
random_st.weibull(0.5, size=1)
random_st.weibull(D_arr_0p5)
random_st.weibull(D_arr_0p5, size=1)
random_st.weibull(D_arr_like_0p5)
random_st.weibull(D_arr_like_0p5, size=1)

# t 分布
random_st.standard_t(0.5)
random_st.standard_t(0.5, size=None)
random_st.standard_t(0.5, size=1)
random_st.standard_t(D_arr_0p5)
random_st.standard_t(D_arr_0p5, size=1)
random_st.standard_t(D_arr_like_0p5)
random_st.standard_t(D_arr_like_0p5, size=1)

# 泊松分布
random_st.poisson(0.5)
random_st.poisson(0.5, size=None)
random_st.poisson(0.5, size=1)
random_st.poisson(D_arr_0p5)
random_st.poisson(D_arr_0p5, size=1)
random_st.poisson(D_arr_like_0p5)
random_st.poisson(D_arr_like_0p5, size=1)

# 功率分布
random_st.power(0.5)
random_st.power(0.5, size=None)
random_st.power(0.5, size=1)
random_st.power(D_arr_0p5)
random_st.power(D_arr_0p5, size=1)
random_st.power(D_arr_like_0p5)
random_st.power(D_arr_like_0p5, size=1)

# 帕累托分布
random_st.pareto(0.5)
random_st.pareto(0.5, size=None)
random_st.pareto(0.5, size=1)
random_st.pareto(D_arr_0p5)
random_st.pareto(D_arr_0p5, size=1)
# 生成服从帕累托分布的随机数
random_st.pareto(D_arr_like_0p5)

# 生成一个服从帕累托分布的随机数,返回一个大小为1的数组
random_st.pareto(D_arr_like_0p5, size=1)

# 生成服从卡方分布的随机数,自由度为0.5
random_st.chisquare(0.5)

# 生成一个服从卡方分布的随机数,自由度为0.5,默认返回单个数值
random_st.chisquare(0.5, size=None)

# 生成一个服从卡方分布的随机数,自由度为0.5,返回一个大小为1的数组
random_st.chisquare(0.5, size=1)

# 生成服从卡方分布的随机数,自由度为D_arr_0p5
random_st.chisquare(D_arr_0p5)

# 生成一个服从卡方分布的随机数,自由度为D_arr_0p5,返回一个大小为1的数组
random_st.chisquare(D_arr_0p5, size=1)

# 生成服从卡方分布的随机数,自由度为D_arr_like_0p5
random_st.chisquare(D_arr_like_0p5)

# 生成一个服从卡方分布的随机数,自由度为D_arr_like_0p5,返回一个大小为1的数组
random_st.chisquare(D_arr_like_0p5, size=1)

# 生成服从指数分布的随机数,比例参数为0.5
random_st.exponential(0.5)

# 生成一个服从指数分布的随机数,比例参数为0.5,默认返回单个数值
random_st.exponential(0.5, size=None)

# 生成一个服从指数分布的随机数,比例参数为0.5,返回一个大小为1的数组
random_st.exponential(0.5, size=1)

# 生成服从指数分布的随机数,比例参数为D_arr_0p5
random_st.exponential(D_arr_0p5)

# 生成一个服从指数分布的随机数,比例参数为D_arr_0p5,返回一个大小为1的数组
random_st.exponential(D_arr_0p5, size=1)

# 生成服从指数分布的随机数,比例参数为D_arr_like_0p5
random_st.exponential(D_arr_like_0p5)

# 生成一个服从指数分布的随机数,比例参数为D_arr_like_0p5,返回一个大小为1的数组
random_st.exponential(D_arr_like_0p5, size=1)

# 生成服从几何分布的随机数,成功概率为0.5
random_st.geometric(0.5)

# 生成一个服从几何分布的随机数,成功概率为0.5,默认返回单个数值
random_st.geometric(0.5, size=None)

# 生成一个服从几何分布的随机数,成功概率为0.5,返回一个大小为1的数组
random_st.geometric(0.5, size=1)

# 生成服从几何分布的随机数,成功概率为D_arr_0p5
random_st.geometric(D_arr_0p5)

# 生成一个服从几何分布的随机数,成功概率为D_arr_0p5,返回一个大小为1的数组
random_st.geometric(D_arr_0p5, size=1)

# 生成服从几何分布的随机数,成功概率为D_arr_like_0p5
random_st.geometric(D_arr_like_0p5)

# 生成一个服从几何分布的随机数,成功概率为D_arr_like_0p5,返回一个大小为1的数组
random_st.geometric(D_arr_like_0p5, size=1)

# 生成服从对数系列分布的随机数,成功概率为0.5
random_st.logseries(0.5)

# 生成一个服从对数系列分布的随机数,成功概率为0.5,默认返回单个数值
random_st.logseries(0.5, size=None)

# 生成一个服从对数系列分布的随机数,成功概率为0.5,返回一个大小为1的数组
random_st.logseries(0.5, size=1)

# 生成服从对数系列分布的随机数,成功概率为D_arr_0p5
random_st.logseries(D_arr_0p5)

# 生成一个服从对数系列分布的随机数,成功概率为D_arr_0p5,返回一个大小为1的数组
random_st.logseries(D_arr_0p5, size=1)

# 生成服从对数系列分布的随机数,成功概率为D_arr_like_0p5
random_st.logseries(D_arr_like_0p5)

# 生成一个服从对数系列分布的随机数,成功概率为D_arr_like_0p5,返回一个大小为1的数组
random_st.logseries(D_arr_like_0p5, size=1)

# 生成服从瑞利分布的随机数,比例参数为0.5
random_st.rayleigh(0.5)

# 生成一个服从瑞利分布的随机数,比例参数为0.5,默认返回单个数值
random_st.rayleigh(0.5, size=None)

# 生成一个服从瑞利分布的随机数,比例参数为0.5,返回一个大小为1的数组
random_st.rayleigh(0.5, size=1)

# 生成服从瑞利分布的随机数,比例参数为D_arr_0p5
random_st.rayleigh(D_arr_0p5)

# 生成一个服从瑞利分布的随机数,比例参数为D_arr_0p5,返回一个大小为1的数组
random_st.rayleigh(D_arr_0p5, size=1)

# 生成服从瑞利分布的随机数,比例参数为D_arr_like_0p5
random_st.rayleigh(D_arr_like_0p5)

# 生成一个服从瑞利分布的随机数,比例参数为D_arr_like_0p5,返回一个大小为1的数组
random_st.rayleigh(D_arr_like_0p5, size=1)

# 生成服从标准伽马分布的随机数,形状参数为0.5
random_st.standard_gamma(0.5)

# 生成一个服从标准伽马分布的随机数,形状参数为0.5,默认返回单个数值
random_st.standard_gamma(0.5, size=None)

# 生成一个服从标准伽马分布的随机数,形状参数为0.5,返回一个大小为1的数组
random_st.standard_gamma(0.5, size=1)

# 生成服从标准伽马分布的随机数,形状参数为D_arr_0p5
random_st.standard_gamma(D_arr_0p5)

# 生成一个服从标准伽马分布的随机数,形状参数为D_arr_0p5,返回一个大小为1的数组
random_st.standard_gamma(D_arr_0p5, size=1)

# 生成服从标准伽马分布的随机数,形状参数为D_arr_like_0p5
random_st.standard_gamma(D_arr_like_0p5)

# 生成一个服从标准伽马分布的随机数,形状参数为D_arr_like_0p5,返回一个大小为1的数组
random_st.standard_gamma(D_arr_like_0p5, size=1)

# 生成服从冯·米塞斯分布的随机数,形状参数为0.5,位置参数为0.5
random_st.vonmises(0.5, 0.5)

# 生成一个服从冯·米塞斯分布的随机数
# 生成一个在区间 [0.5, D_arr_like_0p5] 内均匀分布的随机数
random_st.uniform(0.5, D_arr_like_0p5)

# 生成一个在区间 [D_arr_0p5, D_arr_0p5] 内均匀分布的随机数
random_st.uniform(D_arr_0p5, D_arr_0p5)

# 生成一个在区间 [D_arr_like_0p5, D_arr_like_0p5] 内均匀分布的随机数
random_st.uniform(D_arr_like_0p5, D_arr_like_0p5)

# 生成一个在区间 [D_arr_0p5, D_arr_0p5] 内均匀分布的大小为1的随机数数组
random_st.uniform(D_arr_0p5, D_arr_0p5, size=1)

# 生成一个在区间 [D_arr_like_0p5, D_arr_like_0p5] 内均匀分布的大小为1的随机数数组
random_st.uniform(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成一个 Beta 分布的随机数,参数为 (0.5, 0.5)
random_st.beta(0.5, 0.5)

# 生成一个 Beta 分布的随机数,参数为 (0.5, 0.5),大小为 None
random_st.beta(0.5, 0.5, size=None)

# 生成一个 Beta 分布的大小为1的随机数数组,参数为 (0.5, 0.5)
random_st.beta(0.5, 0.5, size=1)

# 生成一个 Beta 分布的随机数,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.beta(D_arr_0p5, 0.5)

# 生成一个 Beta 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.beta(0.5, D_arr_0p5)

# 生成一个 Beta 分布的大小为1的随机数数组,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.beta(D_arr_0p5, 0.5, size=1)

# 生成一个 Beta 分布的大小为1的随机数数组,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.beta(0.5, D_arr_0p5, size=1)

# 生成一个 Beta 分布的随机数,其中一个参数为 D_arr_like_0p5,另一个为 0.5
random_st.beta(D_arr_like_0p5, 0.5)

# 生成一个 Beta 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_like_0p5
random_st.beta(0.5, D_arr_like_0p5)

# 生成一个 Beta 分布的随机数,两个参数均为 D_arr_0p5
random_st.beta(D_arr_0p5, D_arr_0p5)

# 生成一个 Beta 分布的随机数,两个参数均为 D_arr_like_0p5
random_st.beta(D_arr_like_0p5, D_arr_like_0p5)

# 生成一个 Beta 分布的大小为1的随机数数组,两个参数均为 D_arr_0p5
random_st.beta(D_arr_0p5, D_arr_0p5, size=1)

# 生成一个 Beta 分布的大小为1的随机数数组,两个参数均为 D_arr_like_0p5
random_st.beta(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成一个 F 分布的随机数,参数为 (0.5, 0.5)
random_st.f(0.5, 0.5)

# 生成一个 F 分布的随机数,参数为 (0.5, 0.5),大小为 None
random_st.f(0.5, 0.5, size=None)

# 生成一个 F 分布的大小为1的随机数数组,参数为 (0.5, 0.5)
random_st.f(0.5, 0.5, size=1)

# 生成一个 F 分布的随机数,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.f(D_arr_0p5, 0.5)

# 生成一个 F 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.f(0.5, D_arr_0p5)

# 生成一个 F 分布的大小为1的随机数数组,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.f(D_arr_0p5, 0.5, size=1)

# 生成一个 F 分布的大小为1的随机数数组,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.f(0.5, D_arr_0p5, size=1)

# 生成一个 F 分布的随机数,其中一个参数为 D_arr_like_0p5,另一个为 0.5
random_st.f(D_arr_like_0p5, 0.5)

# 生成一个 F 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_like_0p5
random_st.f(0.5, D_arr_like_0p5)

# 生成一个 F 分布的随机数,两个参数均为 D_arr_0p5
random_st.f(D_arr_0p5, D_arr_0p5)

# 生成一个 F 分布的随机数,两个参数均为 D_arr_like_0p5
random_st.f(D_arr_like_0p5, D_arr_like_0p5)

# 生成一个 F 分布的大小为1的随机数数组,两个参数均为 D_arr_0p5
random_st.f(D_arr_0p5, D_arr_0p5, size=1)

# 生成一个 F 分布的大小为1的随机数数组,两个参数均为 D_arr_like_0p5
random_st.f(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 生成一个 Gamma 分布的随机数,参数为 (0.5, 0.5)
random_st.gamma(0.5, 0.5)

# 生成一个 Gamma 分布的随机数,参数为 (0.5, 0.5),大小为 None
random_st.gamma(0.5, 0.5, size=None)

# 生成一个 Gamma 分布的大小为1的随机数数组,参数为 (0.5, 0.5)
random_st.gamma(0.5, 0.5, size=1)

# 生成一个 Gamma 分布的随机数,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.gamma(D_arr_0p5, 0.5)

# 生成一个 Gamma 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.gamma(0.5, D_arr_0p5)

# 生成一个 Gamma 分布的大小为1的随机数数组,其中一个参数为 D_arr_0p5,另一个为 0.5
random_st.gamma(D_arr_0p5, 0.5, size=1)

# 生成一个 Gamma 分布的大小为1的随机数数组,其中一个参数为 0.5,另一个为 D_arr_0p5
random_st.gamma(0.5, D_arr_0p5, size=1)

# 生成一个 Gamma 分布的随机数,其中一个参数为 D_arr_like_0p5,另一个为 0.5
random_st.gamma(D_arr_like_0p5, 0.5)

# 生成一个 Gamma 分布的随机数,其中一个参数为 0.5,另一个为 D_arr_like_0p5
random_st.gamma(0.5, D_arr_like_0p5)

# 生成一个 Gamma 分布的随机数,两个参数均为 D_arr_0p5
random_st.gamma(D_arr_0p5, D_arr_0p5)

#
# 从 scipy.stats 模块中调用 logistic 分布函数,生成指定形状参数的随机数
random_st.logistic(D_arr_like_0p5, 0.5)

# 从 scipy.stats 模块中调用 logistic 分布函数,生成指定位置参数的随机数
random_st.logistic(0.5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 logistic 分布函数,生成两个参数相同的随机数
random_st.logistic(D_arr_0p5, D_arr_0p5)

# 从 scipy.stats 模块中调用 logistic 分布函数,生成两个参数相同的随机数
random_st.logistic(D_arr_like_0p5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 logistic 分布函数,生成指定形状参数的单个随机数
random_st.logistic(D_arr_0p5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 logistic 分布函数,生成指定形状参数的单个随机数
random_st.logistic(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成指定位置和形状参数的随机数
random_st.lognormal(0.5, 0.5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成指定位置和形状参数的随机数
random_st.lognormal(0.5, 0.5, size=None)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成指定位置和形状参数的单个随机数
random_st.lognormal(0.5, 0.5, size=1)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为数组的随机数
random_st.lognormal(D_arr_0p5, 0.5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为数组的随机数
random_st.lognormal(0.5, D_arr_0p5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为数组的单个随机数
random_st.lognormal(D_arr_0p5, 0.5, size=1)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为数组的单个随机数
random_st.lognormal(0.5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为类似数组的随机数
random_st.lognormal(D_arr_like_0p5, 0.5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成一个参数为类似数组的随机数
random_st.lognormal(0.5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成两个参数相同的随机数
random_st.lognormal(D_arr_0p5, D_arr_0p5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成两个参数相同的随机数
random_st.lognormal(D_arr_like_0p5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成两个参数相同的单个随机数
random_st.lognormal(D_arr_0p5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 lognormal 分布函数,生成两个参数相同的单个随机数
random_st.lognormal(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成指定自由度和非中心参数的随机数
random_st.noncentral_chisquare(0.5, 0.5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成指定自由度和非中心参数的随机数
random_st.noncentral_chisquare(0.5, 0.5, size=None)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成指定自由度和非中心参数的单个随机数
random_st.noncentral_chisquare(0.5, 0.5, size=1)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为数组的随机数
random_st.noncentral_chisquare(D_arr_0p5, 0.5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为数组的随机数
random_st.noncentral_chisquare(0.5, D_arr_0p5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为数组的单个随机数
random_st.noncentral_chisquare(D_arr_0p5, 0.5, size=1)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为数组的单个随机数
random_st.noncentral_chisquare(0.5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为类似数组的随机数
random_st.noncentral_chisquare(D_arr_like_0p5, 0.5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成一个参数为类似数组的随机数
random_st.noncentral_chisquare(0.5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成两个参数相同的随机数
random_st.noncentral_chisquare(D_arr_0p5, D_arr_0p5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成两个参数相同的随机数
random_st.noncentral_chisquare(D_arr_like_0p5, D_arr_like_0p5)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成两个参数相同的单个随机数
random_st.noncentral_chisquare(D_arr_0p5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 noncentral_chisquare 分布函数,生成两个参数相同的单个随机数
random_st.noncentral_chisquare(D_arr_like_0p5, D_arr_like_0p5, size=1)

# 从 scipy.stats 模块中调用 normal 分布函数,生成指定位置和形状参数的随机数
random_st.normal(0.5, 0.5)

# 从 scipy.stats 模块中调用 normal 分布函数,生成指定位置和形状参数的随机数
random_st.normal(0.5, 0.5, size=None)

# 从 scipy.stats 模块中调用 normal 分布函数,生成指定位置和形状参数的单个随机数
random_st.normal(0.5, 0.5, size=1)

# 从 scipy.stats 模块中调用 normal 分布函数,生成一个参数为数组的随机数
random_st.normal(D_arr_0p5, 0.5)

# 从 scipy.stats 模块中调用 normal 分布函数,生成一个参数为数组的随机数
random_st.normal(0.5, D_arr_0p5)

# 从 scipy.stats 模块中调用 normal 分布函数,生成一个参数为数组的单个随机数
random_st.normal(D_arr_0p5, 0.5, size=1)

# 从 scipy.stats 模块中调用 normal 分布函数,生成一个参数为数组的单个随机数
random_st.normal(0.5, D_arr_0p5, size=1)

# 从 scipy.stats 模块中调用 normal 分布函数,生成一个参数为类似数组的随机数
random_st.normal(D_arr_like_0
# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_0p1, 0.5, D_arr_like_0p9,生成一个随机数
random_st.noncentral_f(D_arr_0p1, 0.5, D_arr_like_0p9, size=1)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 0.1, D_arr_0p5, 0.9,生成一个随机数
random_st.noncentral_f(0.1, D_arr_0p5, 0.9, size=1)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_like_0p1, 0.5, D_arr_0p9
random_st.noncentral_f(D_arr_like_0p1, 0.5, D_arr_0p9)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 0.5, D_arr_like_0p5, 0.9
random_st.noncentral_f(0.5, D_arr_like_0p5, 0.9)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_0p1, D_arr_0p5, 0.9
random_st.noncentral_f(D_arr_0p1, D_arr_0p5, 0.9)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_like_0p1, D_arr_like_0p5, 0.9
random_st.noncentral_f(D_arr_like_0p1, D_arr_like_0p5, 0.9)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_0p1, D_arr_0p5, D_arr_0p9,生成一个随机数
random_st.noncentral_f(D_arr_0p1, D_arr_0p5, D_arr_0p9, size=1)

# 使用 Scipy 中的 random_st 对象生成非中心 F 分布的随机变量,参数分别为 D_arr_like_0p1, D_arr_like_0p5, D_arr_like_0p9,生成一个随机数
random_st.noncentral_f(D_arr_like_0p1, D_arr_like_0p5, D_arr_like_0p9, size=1)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, 0.5,返回一个随机数
random_st.binomial(10, 0.5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, 0.5,返回一个指定大小的数组
random_st.binomial(10, 0.5, size=None)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, 0.5,返回一个大小为 1 的数组
random_st.binomial(10, 0.5, size=1)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_10, 0.5
random_st.binomial(I_arr_10, 0.5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, D_arr_0p5
random_st.binomial(10, D_arr_0p5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_10, 0.5,返回一个大小为 1 的数组
random_st.binomial(I_arr_10, 0.5, size=1)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, D_arr_0p5,返回一个大小为 1 的数组
random_st.binomial(10, D_arr_0p5, size=1)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_like_10, 0.5
random_st.binomial(I_arr_like_10, 0.5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 10, D_arr_like_0p5
random_st.binomial(10, D_arr_like_0p5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_10, D_arr_0p5
random_st.binomial(I_arr_10, D_arr_0p5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_like_10, D_arr_like_0p5
random_st.binomial(I_arr_like_10, D_arr_like_0p5)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_10, D_arr_0p5,返回一个大小为 1 的数组
random_st.binomial(I_arr_10, D_arr_0p5, size=1)

# 使用 Scipy 中的 random_st 对象生成二项分布的随机变量,参数分别为 I_arr_like_10, D_arr_like_0p5,返回一个大小为 1 的数组
random_st.binomial(I_arr_like_10, D_arr_like_0p5, size=1)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, 0.5
random_st.negative_binomial(10, 0.5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, 0.5,返回一个指定大小的数组
random_st.negative_binomial(10, 0.5, size=None)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, 0.5,返回一个大小为 1 的数组
random_st.negative_binomial(10, 0.5, size=1)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 I_arr_10, 0.5
random_st.negative_binomial(I_arr_10, 0.5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, D_arr_0p5
random_st.negative_binomial(10, D_arr_0p5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 I_arr_10, 0.5,返回一个大小为 1 的数组
random_st.negative_binomial(I_arr_10, 0.5, size=1)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, D_arr_0p5,返回一个大小为 1 的数组
random_st.negative_binomial(10, D_arr_0p5, size=1)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 I_arr_like_10, 0.5
random_st.negative_binomial(I_arr_like_10, 0.5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 10, D_arr_like_0p5
random_st.negative_binomial(10, D_arr_like_0p5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 I_arr_10, D_arr_0p5
random_st.negative_binomial(I_arr_10, D_arr_0p5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的随机变量,参数分别为 I_arr_like_10, D_arr_like_0p5
random_st.negative_binomial(I_arr_like_10, D_arr_like_0p5)

# 使用 Scipy 中的 random_st 对象生成负二项分布的
# 生成一个随机整数,范围是[I_u1_high_open, inf),数据类型是'u1'
random_st.randint(I_u1_high_open, dtype="u1")

# 生成一个随机整数,范围是[I_u1_low, I_u1_high_open),数据类型是'u1'
random_st.randint(I_u1_low, I_u1_high_open, dtype="u1")

# 生成一个随机整数,范围是[0, I_u1_high_open),数据类型是'u1'
random_st.randint(0, I_u1_high_open, dtype="u1")

# 生成一个随机整数,范围是[0, 256),数据类型是'uint8'
random_st.randint(256, dtype="uint8")

# 生成一个随机整数,范围是[0, 256),数据类型是'uint8'
random_st.randint(0, 256, dtype="uint8")

# 生成一个随机整数,范围是[I_u1_high_open, inf),数据类型是'uint8'
random_st.randint(I_u1_high_open, dtype="uint8")

# 生成一个随机整数,范围是[I_u1_low, I_u1_high_open),数据类型是'uint8'
random_st.randint(I_u1_low, I_u1_high_open, dtype="uint8")

# 生成一个随机整数,范围是[0, I_u1_high_open),数据类型是'uint8'
random_st.randint(0, I_u1_high_open, dtype="uint8")

# 生成一个随机整数,范围是[0, 256),数据类型是'uint8'
random_st.randint(256, dtype=np.uint8)

# 生成一个随机整数,范围是[0, 256),数据类型是'uint8'
random_st.randint(0, 256, dtype=np.uint8)

# 生成一个随机整数,范围是[I_u1_high_open, inf),数据类型是'uint8'
random_st.randint(I_u1_high_open, dtype=np.uint8)

# 生成一个随机整数,范围是[I_u1_low, I_u1_high_open),数据类型是'uint8'
random_st.randint(I_u1_low, I_u1_high_open, dtype=np.uint8)

# 生成一个随机整数,范围是[0, I_u1_high_open),数据类型是'uint8'
random_st.randint(0, I_u1_high_open, dtype=np.uint8)

# 生成一个随机整数,范围是[0, 65536),数据类型是'u2'
random_st.randint(65536, dtype="u2")

# 生成一个随机整数,范围是[0, 65536),数据类型是'u2'
random_st.randint(0, 65536, dtype="u2")

# 生成一个随机整数,范围是[I_u2_high_open, inf),数据类型是'u2'
random_st.randint(I_u2_high_open, dtype="u2")

# 生成一个随机整数,范围是[I_u2_low, I_u2_high_open),数据类型是'u2'
random_st.randint(I_u2_low, I_u2_high_open, dtype="u2")

# 生成一个随机整数,范围是[0, I_u2_high_open),数据类型是'u2'
random_st.randint(0, I_u2_high_open, dtype="u2")

# 生成一个随机整数,范围是[0, 65536),数据类型是'uint16'
random_st.randint(65536, dtype="uint16")

# 生成一个随机整数,范围是[0, 65536),数据类型是'uint16'
random_st.randint(0, 65536, dtype="uint16")

# 生成一个随机整数,范围是[I_u2_high_open, inf),数据类型是'uint16'
random_st.randint(I_u2_high_open, dtype="uint16")

# 生成一个随机整数,范围是[I_u2_low, I_u2_high_open),数据类型是'uint16'
random_st.randint(I_u2_low, I_u2_high_open, dtype="uint16")

# 生成一个随机整数,范围是[0, I_u2_high_open),数据类型是'uint16'
random_st.randint(0, I_u2_high_open, dtype="uint16")

# 生成一个随机整数,范围是[0, 65536),数据类型是'uint16'
random_st.randint(65536, dtype=np.uint16)

# 生成一个随机整数,范围是[0, 65536),数据类型是'uint16'
random_st.randint(0, 65536, dtype=np.uint16)

# 生成一个随机整数,范围是[I_u2_high_open, inf),数据类型是'uint16'
random_st.randint(I_u2_high_open, dtype=np.uint16)

# 生成一个随机整数,范围是[I_u2_low, I_u2_high_open),数据类型是'uint16'
random_st.randint(I_u2_low, I_u2_high_open, dtype=np.uint16)

# 生成一个随机整数,范围是[0, I_u2_high_open),数据类型是'uint16'
random_st.randint(0, I_u2_high_open, dtype=np.uint16)

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'u4'
random_st.randint(4294967296, dtype="u4")

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'u4'
random_st.randint(0, 4294967296, dtype="u4")

# 生成一个随机整数,范围是[I_u4_high_open, inf),数据类型是'u4'
random_st.randint(I_u4_high_open, dtype="u4")

# 生成一个随机整数,范围是[I_u4_low, I_u4_high_open),数据类型是'u4'
random_st.randint(I_u4_low, I_u4_high_open, dtype="u4")

# 生成一个随机整数,范围是[0, I_u4_high_open),数据类型是'u4'
random_st.randint(0, I_u4_high_open, dtype="u4")

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'uint32'
random_st.randint(4294967296, dtype="uint32")

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'uint32'
random_st.randint(0, 4294967296, dtype="uint32")

# 生成一个随机整数,范围是[I_u4_high_open, inf),数据类型是'uint32'
random_st.randint(I_u4_high_open, dtype="uint32")

# 生成一个随机整数,范围是[I_u4_low, I_u4_high_open),数据类型是'uint32'
random_st.randint(I_u4_low, I_u4_high_open, dtype="uint32")

# 生成一个随机整数,范围是[0, I_u4_high_open),数据类型是'uint32'
random_st.randint(0, I_u4_high_open, dtype="uint32")

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'uint32'
random_st.randint(4294967296, dtype=np.uint32)

# 生成一个随机整数,范围是[0, 4294967296),数据类型是'uint32'
random_st.randint(0, 4294967296, dtype=np.uint32)

# 生成一个随机整数,范围是[I_u4_high_open, inf),数据类型是'uint32'
random_st.randint(I_u4_high_open, dtype=np.uint32)

# 生成一个随机整数,范围是[I_u4_low, I_u4_high_open),数据类型是'uint32'
random_st.randint(I_u4_low, I_u4_high_open, dtype=np.uint32)

# 生成一个随机整数,范围是[0, I_u4_high_open),数据类型是'uint32'
random_st.randint(0, I_u4_high_open, dtype=np.uint32)

# 生成一个随机整数,范围是[0, 18446744073709551616),数据类型是'u8'
random_st.randint(18446744073709551616, dtype="u8")

# 生成一个随机整数,范围是
# 生成一个随机的8位有符号整数(int8)在范围[-128, 127]之间
random_st.randint(-128, 128, dtype="i1")

# 生成一个随机的8位有符号整数(int8),范围从0到I_i1_high_open-1
random_st.randint(I_i1_high_open, dtype="i1")

# 生成一个随机的8位有符号整数(int8),范围从I_i1_low到I_i1_high_open-1
random_st.randint(I_i1_low, I_i1_high_open, dtype="i1")

# 生成一个随机的8位有符号整数(int8),范围从-128到I_i1_high_open-1
random_st.randint(-128, I_i1_high_open, dtype="i1")

# 生成一个随机的8位有符号整数(int8),范围从0到127
random_st.randint(128, dtype="int8")

# 生成一个随机的8位有符号整数(int8),范围从-128到127
random_st.randint(-128, 128, dtype="int8")

# 生成一个随机的8位有符号整数(int8),范围从0到I_i1_high_open-1
random_st.randint(I_i1_high_open, dtype="int8")

# 生成一个随机的8位有符号整数(int8),范围从I_i1_low到I_i1_high_open-1
random_st.randint(I_i1_low, I_i1_high_open, dtype="int8")

# 生成一个随机的8位有符号整数(int8),范围从-128到I_i1_high_open-1
random_st.randint(-128, I_i1_high_open, dtype="int8")

# 生成一个随机的16位有符号整数(int16),范围从-32768到32767
random_st.randint(32768, dtype="i2")

# 生成一个随机的16位有符号整数(int16),范围从-32768到32767
random_st.randint(-32768, 32768, dtype="i2")

# 生成一个随机的16位有符号整数(int16),范围从0到I_i2_high_open-1
random_st.randint(I_i2_high_open, dtype="i2")

# 生成一个随机的16位有符号整数(int16),范围从I_i2_low到I_i2_high_open-1
random_st.randint(I_i2_low, I_i2_high_open, dtype="i2")

# 生成一个随机的16位有符号整数(int16),范围从-32768到I_i2_high_open-1
random_st.randint(-32768, I_i2_high_open, dtype="i2")

# 生成一个随机的16位有符号整数(int16),范围从0到32767
random_st.randint(32768, dtype="int16")

# 生成一个随机的16位有符号整数(int16),范围从-32768到32767
random_st.randint(-32768, 32768, dtype="int16")

# 生成一个随机的16位有符号整数(int16),范围从0到I_i2_high_open-1
random_st.randint(I_i2_high_open, dtype="int16")

# 生成一个随机的16位有符号整数(int16),范围从I_i2_low到I_i2_high_open-1
random_st.randint(I_i2_low, I_i2_high_open, dtype="int16")

# 生成一个随机的16位有符号整数(int16),范围从-32768到I_i2_high_open-1
random_st.randint(-32768, I_i2_high_open, dtype="int16")

# 生成一个随机的16位有符号整数(int16),范围从0到32767
random_st.randint(32768, dtype=np.int16)

# 生成一个随机的16位有符号整数(int16),范围从-32768到32767
random_st.randint(-32768, 32768, dtype=np.int16)

# 生成一个随机的16位有符号整数(int16),范围从0到I_i2_high_open-1
random_st.randint(I_i2_high_open, dtype=np.int16)

# 生成一个随机的16位有符号整数(int16),范围从I_i2_low到I_i2_high_open-1
random_st.randint(I_i2_low, I_i2_high_open, dtype=np.int16)

# 生成一个随机的16位有符号整数(int16),范围从-32768到I_i2_high_open-1
random_st.randint(-32768, I_i2_high_open, dtype=np.int16)

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到2147483647
random_st.randint(2147483648, dtype="i4")

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到2147483647
random_st.randint(-2147483648, 2147483648, dtype="i4")

# 生成一个随机的32位有符号整数(int32),范围从0到I_i4_high_open-1
random_st.randint(I_i4_high_open, dtype="i4")

# 生成一个随机的32位有符号整数(int32),范围从I_i4_low到I_i4_high_open-1
random_st.randint(I_i4_low, I_i4_high_open, dtype="i4")

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到I_i4_high_open-1
random_st.randint(-2147483648, I_i4_high_open, dtype="i4")

# 生成一个随机的32位有符号整数(int32),范围从0到2147483647
random_st.randint(2147483648, dtype="int32")

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到2147483647
random_st.randint(-2147483648, 2147483648, dtype="int32")

# 生成一个随机的32位有符号整数(int32),范围从0到I_i4_high_open-1
random_st.randint(I_i4_high_open, dtype="int32")

# 生成一个随机的32位有符号整数(int32),范围从I_i4_low到I_i4_high_open-1
random_st.randint(I_i4_low, I_i4_high_open, dtype="int32")

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到I_i4_high_open-1
random_st.randint(-2147483648, I_i4_high_open, dtype="int32")

# 生成一个随机的32位有符号整数(int32),范围从0到2147483647
random_st.randint(2147483648, dtype=np.int32)

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到2147483647
random_st.randint(-2147483648, 2147483648, dtype=np.int32)

# 生成一个随机的32位有符号整数(int32),范围从0到I_i4_high_open-1
random_st.randint(I_i4_high_open, dtype=np.int32)

# 生成一个随机的32位有符号整数(int32),范围从I_i4_low到I_i4_high_open-1
random_st.randint(I_i4_low, I_i4_high_open, dtype=np.int32)

# 生成一个随机的32位有符号整数(int32),范围从-2147483648到I_i4_high_open-1
random_st.randint(-2147483648, I_i4_high_open, dtype=np.int32)

# 生成一个随机的64位有符号整数(int64),范围从-9223372036854775808到9223372036854775807
random_st.randint(9223372036854775808, dtype="i8")

# 生成一个随机的64位有符号整数
# 生成一个 64 位整数,范围在 I_i8_high_open 之间
random_st.randint(I_i8_high_open, dtype=np.int64)

# 生成一个 64 位整数,范围在 I_i8_low 到 I_i8_high_open 之间
random_st.randint(I_i8_low, I_i8_high_open, dtype=np.int64)

# 生成一个 64 位整数,范围在 -9223372036854775808 到 I_i8_high_open 之间
random_st.randint(-9223372036854775808, I_i8_high_open, dtype=np.int64)

# 设置背景为 np.random.BitGenerator 类型的变量,值为 random_st._bit_generator
bg: np.random.BitGenerator = random_st._bit_generator

# 生成一个包含 2 个字节的随机字节串
random_st.bytes(2)

# 从 0 到 4 中随机选择一个整数
random_st.choice(5)

# 从 0 到 4 中随机选择 3 个整数,可以重复选择
random_st.choice(5, 3)

# 从 0 到 4 中随机选择 3 个整数,允许重复选择,按给定的概率分布 p 选择
random_st.choice(5, 3, replace=True, p=[1 / 5] * 5)

# 从 0 到 4 中随机选择 3 个整数,不允许重复选择,按给定的概率分布 p 选择
random_st.choice(5, 3, replace=False, p=[1 / 5] * 5)

# 从列表 ["pooh", "rabbit", "piglet", "Christopher"] 中随机选择一个元素
random_st.choice(["pooh", "rabbit", "piglet", "Christopher"])

# 从列表 ["pooh", "rabbit", "piglet", "Christopher"] 中随机选择 3 个元素
random_st.choice(["pooh", "rabbit", "piglet", "Christopher"], 3)

# 从列表 ["pooh", "rabbit", "piglet", "Christopher"] 中随机选择 3 个元素,按给定的概率分布 p 选择
random_st.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, p=[1 / 4] * 4)

# 从列表 ["pooh", "rabbit", "piglet", "Christopher"] 中随机选择 3 个元素,允许重复选择
random_st.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, replace=True)

# 从列表 ["pooh", "rabbit", "piglet", "Christopher"] 中随机选择 3 个元素,不允许重复选择,按给定的概率分布 p 选择
random_st.choice(["pooh", "rabbit", "piglet", "Christopher"], 3, replace=False, p=np.array([1 / 8, 1 / 8, 1 / 2, 1 / 4]))

# 生成一个二维 Dirichlet 分布样本,参数为 [0.5, 0.5]
random_st.dirichlet([0.5, 0.5])

# 生成一个二维 Dirichlet 分布样本,参数为 np.array([0.5, 0.5])
random_st.dirichlet(np.array([0.5, 0.5]))

# 生成三个二维 Dirichlet 分布样本,参数为 np.array([0.5, 0.5])
random_st.dirichlet(np.array([0.5, 0.5]), size=3)

# 生成一个多项式分布样本,总样本数为 20,每个类别的概率为 [1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0, 1/6.0]
random_st.multinomial(20, [1 / 6.0] * 6)

# 生成一个多项式分布样本,总样本数为 20,每个类别的概率为 np.array([0.5, 0.5])
random_st.multinomial(20, np.array([0.5, 0.5]))

# 生成两个多项式分布样本,每个样本总数为 20,每个类别的概率为 [1/6.0] * 6
random_st.multinomial(20, [1 / 6.0] * 6, size=2)

# 生成一个多变量正态分布样本,均值为 [0.0],协方差矩阵为 [[1.0]]
random_st.multivariate_normal([0.0], [[1.0]])

# 生成一个多变量正态分布样本,均值为 [0.0],协方差矩阵为 np.array([[1.0]])
random_st.multivariate_normal([0.0], np.array([[1.0]]))

# 生成一个多变量正态分布样本,均值为 np.array([0.0]),协方差矩阵为 [[1.0]]
random_st.multivariate_normal(np.array([0.0]), [[1.0]])

# 生成一个多变量正态分布样本,均值为 [0.0],协方差矩阵为 np.array([[1.0]])
random_st.multivariate_normal([0.0], np.array([[1.0]]))

# 对整数序列进行随机排列
random_st.permutation(10)

# 对列表 [1, 2, 3, 4] 进行随机排列
random_st.permutation([1, 2, 3, 4])

# 对数组 np.array([1, 2, 3, 4]) 进行随机排列
random_st.permutation(np.array([1, 2, 3, 4]))

# 对二维数组 D_2D 进行随机排列
random_st.permutation(D_2D)

# 随机打乱数组 np.arange(10)
random_st.shuffle(np.arange(10))

# 随机打乱列表 [1, 2, 3, 4, 5]
random_st.shuffle([1, 2, 3, 4, 5])

# 随机打乱二维数组 D_2D
random_st.shuffle(D_2D)

# 创建一个新的 RandomState 实例,使用 SEED_PCG64 作为种子
np.random.RandomState(SEED_PCG64)

# 创建一个新的 RandomState 实例,使用 0 作为种子
np.random.RandomState(0)

# 创建一个新的 RandomState 实例,使用 [0, 1, 2] 作为种子
np.random.RandomState([0, 1, 2])

# 返回 random_st 的字符串表示形式
random_st.__str__()

# 返回 random_st 的详细表示形式
random_st.__repr__()

# 获取 random_st 的状态信息,并存储在 random_st_state 中
random_st_state = random_st.__getstate__()

# 恢复 random_st 的状态信息,使用之前存储的 random_st_state
random_st.__setstate__(random_st_state)

# 使用默认种子初始化随机数生成器
random_st.seed()

# 使用指定种子(1)初始化随机数生成器
random_st.seed(1)

# 使用指定种子([0, 1])初始化随机数生成器
random_st.seed([0, 1])

# 获取 random_st 的当前状态信息,并存储在 random_st_get_state 中
random_st_get_state = random_st.get_state()

# 获取 random_st 的当前状态信息(兼容模式),并存储在 random_st_get_state_legacy 中
random_st_get_state_legacy = random_st.get_state(legacy=True)

# 设置 random_st 的状态信息,使用之前存储的状态 random_st_get_state
random_st.set_state(random_st_get_state)

# 生成一个 [0, 1) 范围内的随机浮点数
random_st.rand()

# 生成一个包含一个 [0, 1) 范围内随机浮点数的数组
random_st.rand(1)

# 生成一个包含一个 [0, 1) 范围内随机浮点数的 1x2 数组
random_st.rand(1, 2)

# 生成一个标准正态分布的随机数
random_st.randn()

# 生成一个包含一个标准正态分布

.\numpy\numpy\typing\tests\data\pass\scalars.py

import sys  # 导入系统模块sys,用于访问系统相关功能
import datetime as dt  # 导入datetime模块并命名为dt,用于处理日期和时间

import pytest  # 导入pytest模块,用于编写和运行测试用例
import numpy as np  # 导入numpy库并命名为np,用于数值计算

b = np.bool()  # 创建一个布尔型对象b
b_ = np.bool_()  # 创建一个布尔型对象b_
u8 = np.uint64()  # 创建一个64位无符号整数对象u8
i8 = np.int64()  # 创建一个64位有符号整数对象i8
f8 = np.float64()  # 创建一个64位浮点数对象f8
c16 = np.complex128()  # 创建一个128位复数对象c16
U = np.str_()  # 创建一个空字符串对象U
S = np.bytes_()  # 创建一个空字节串对象S

# Construction

class D:
    def __index__(self) -> int:
        return 0

class C:
    def __complex__(self) -> complex:
        return 3j

class B:
    def __int__(self) -> int:
        return 4

class A:
    def __float__(self) -> float:
        return 4.0

np.complex64(3j)  # 创建一个32位复数对象,使用Python复数值3j
np.complex64(A())  # 创建一个32位复数对象,使用A类返回的浮点数值
np.complex64(C())  # 创建一个32位复数对象,使用C类返回的复数值
np.complex128(3j)  # 创建一个64位复数对象,使用Python复数值3j
np.complex128(C())  # 创建一个64位复数对象,使用C类返回的复数值
np.complex128(None)  # 创建一个64位复数对象,使用Python None

np.complex64("1.2")  # 尝试使用字符串创建32位复数对象,会抛出错误
np.complex128(b"2j")  # 尝试使用字节串创建64位复数对象,会抛出错误

np.int8(4)  # 创建一个8位有符号整数对象,使用整数4
np.int16(3.4)  # 创建一个16位有符号整数对象,尝试使用浮点数3.4,将会截断为整数3
np.int32(4)  # 创建一个32位有符号整数对象,使用整数4
np.int64(-1)  # 创建一个64位有符号整数对象,使用整数-1
np.uint8(B())  # 创建一个8位无符号整数对象,使用B类返回的整数值
np.uint32()  # 创建一个32位无符号整数对象,未提供值,默认为0
np.int32("1")  # 尝试使用字符串创建32位有符号整数对象,会抛出错误
np.int64(b"2")  # 尝试使用字节串创建64位有符号整数对象,会抛出错误

np.float16(A())  # 创建一个16位浮点数对象,使用A类返回的浮点数值
np.float32(16)  # 创建一个32位浮点数对象,使用整数16
np.float64(3.0)  # 创建一个64位浮点数对象,使用浮点数3.0
np.float64(None)  # 创建一个64位浮点数对象,使用Python None
np.float32("1")  # 尝试使用字符串创建32位浮点数对象,会抛出错误
np.float16(b"2.5")  # 尝试使用字节串创建16位浮点数对象,会抛出错误

np.uint64(D())  # 创建一个64位无符号整数对象,使用D类返回的整数值
np.float32(D())  # 创建一个32位浮点数对象,使用D类返回的浮点数值
np.complex64(D())  # 创建一个32位复数对象,使用D类返回的复数值

np.bytes_(b"hello")  # 创建一个字节串对象,使用字节串b"hello"
np.bytes_("hello", 'utf-8')  # 创建一个字节串对象,使用字符串"hello",指定编码为utf-8
np.bytes_("hello", encoding='utf-8')  # 创建一个字节串对象,使用字符串"hello",指定编码为utf-8
np.str_("hello")  # 创建一个字符串对象,使用字符串"hello"
np.str_(b"hello", 'utf-8')  # 创建一个字符串对象,使用字节串b"hello",指定编码为utf-8
np.str_(b"hello", encoding='utf-8')  # 创建一个字符串对象,使用字节串b"hello",指定编码为utf-8

# Array-ish semantics

np.int8().real  # 访问一个8位整数对象的实部属性
np.int16().imag  # 访问一个16位整数对象的虚部属性
np.int32().data  # 访问一个32位整数对象的数据属性
np.int64().flags  # 访问一个64位整数对象的标志属性

np.uint8().itemsize * 2  # 计算一个8位无符号整数对象的字节大小乘以2
np.uint16().ndim + 1  # 访问一个16位无符号整数对象的维度属性,并加1
np.uint32().strides  # 访问一个32位无符号整数对象的步幅属性
np.uint64().shape  # 访问一个64位无符号整数对象的形状属性

# Time structures

np.datetime64()  # 创建一个datetime64对象,未提供参数,默认为'1970-01-01'
np.datetime64(0, "D")  # 创建一个datetime64对象,使用0和时间单位"D"表示天
np.datetime64(0, b"D")  # 创建一个datetime64对象,使用0和时间单位b"D"表示天
np.datetime64(0, ('ms', 3))  # 创建一个datetime64对象,使用0和时间单位('ms', 3)表示毫秒
np.datetime64("2019")  # 创建一个datetime64对象,使用字符串"2019"
np.datetime64(b"2019")  # 创建一个datetime64对象,使用字节串b"2019"
np.datetime64("2019", "D")  # 创建一个datetime64对象,使用字符串"2019"和时间单位"D"表示天
np.datetime64(np.datetime64())  # 创建一个datetime64对象,使用当前的datetime64对象
np.datetime64(dt.datetime(2000, 5, 3))  # 创建一个datetime64对象,使用datetime.datetime对象表示的日期时间
np.datetime64(dt.date(2000, 5, 3))  # 创建一个datetime64对象,使用datetime.date对象表示的日期
np.datetime64(None)  # 创建一个datetime64对象,使用Python None
np.datetime64(None, "D")  # 创建一个datetime64对象,使用Python None和时间单位"D"表示天

np.timedelta64()  # 创建一个timedelta64对象,未提供参数,默认为0
np.timedelta64(0)  # 创建一个timedelta64对象,使用整数0
np.timedelta64(0, "D")  # 创建一个timedelta64对象,使用0和时间单位"D"表示天
np.timedelta64(0, ('ms', 3))  # 创建一个timedelta64对象,使用0和时间单位('ms', 3)表示毫秒
np.timedelta64(0, b"D")  # 创建一个timedelta64对象,使用0和时间单位b"D"表示天
np.timedelta64("3")  # 创建一个timedelta64对象,使用字符串"3"
np.timedelta64(b"5")  # 创建一个timedelta64对象,使用字节串b"5"
np.timedelta64(np.timedelta64(2))  # 创建一个timedelta64对象,使用当前的timedelta64对象
np.timedelta64(dt.timedelta(2))  # 创建一个timedelta64对象,使用datetime.timedelta对象表示的时间差
np.timedelta64(None)  # 创建一个timedelta64对象,使用Python None
np.timedelta64(None, "D")  # 创建一个timedelta64对象,使用Python None和时间单位"D"表示天

np.void(1)  # 创建一个void对象,使用整数1
np.void(np.int64(1))  # 创建一个void对象,使用np.int64对象表示的整数1
np.
# 获取数组的单个元素
u8.item()
f8.item()
c16.item()
U.item()
S.item()

# 将数组转换为列表
b.tolist()
i8.tolist()
u8.tolist()
f8.tolist()
c16.tolist()
U.tolist()
S.tolist()

# 将数组展开为一维数组
b.ravel()
i8.ravel()
u8.ravel()
f8.ravel()
c16.ravel()
U.ravel()
S.ravel()

# 将数组展开为一维数组
b.flatten()
i8.flatten()
u8.flatten()
f8.flatten()
c16.flatten()
U.flatten()
S.flatten()

# 将数组重新整形为指定形状
b.reshape(1)
i8.reshape(1)
u8.reshape(1)
f8.reshape(1)
c16.reshape(1)
U.reshape(1)
S.reshape(1)

.\numpy\numpy\typing\tests\data\pass\simple.py

"""Simple expression that should pass with mypy."""
import operator  # 导入 operator 模块

import numpy as np  # 导入 numpy 库
import numpy.typing as npt  # 导入 numpy.typing 模块,用于类型注解
from collections.abc import Iterable  # 从 collections.abc 模块导入 Iterable 类型

# Basic checks
array = np.array([1, 2])  # 创建一个 NumPy 数组 `array`,包含元素 [1, 2]

def ndarray_func(x: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
    return x  # 函数接收一个 np.float64 类型的 NumPy 数组,并返回相同类型的数组

ndarray_func(np.array([1, 2], dtype=np.float64))  # 调用函数 `ndarray_func`,传入一个 np.float64 类型的数组
array == 1  # 检查数组 `array` 中的每个元素是否等于 1,返回布尔值数组
array.dtype == float  # 检查数组 `array` 的数据类型是否为 float,返回布尔值

# Dtype construction
np.dtype(float)  # 创建一个描述 float 类型的 NumPy dtype 对象
np.dtype(np.float64)  # 创建一个描述 np.float64 类型的 NumPy dtype 对象
np.dtype(None)  # 创建一个未指定类型的 NumPy dtype 对象
np.dtype("float64")  # 创建一个描述 float64 类型的 NumPy dtype 对象
np.dtype(np.dtype(float))  # 使用已有的 float 类型的 dtype 创建一个新的 NumPy dtype 对象
np.dtype(("U", 10))  # 创建一个长度为 10 的 Unicode 字符串数组的 dtype 对象
np.dtype((np.int32, (2, 2)))  # 创建一个 2x2 的 int32 类型的结构化 dtype 对象

# Define the arguments on the previous line to prevent bidirectional
# type inference in mypy from broadening the types.
two_tuples_dtype = [("R", "u1"), ("G", "u1"), ("B", "u1")]
np.dtype(two_tuples_dtype)  # 创建一个包含三个字段的结构化 dtype 对象

three_tuples_dtype = [("R", "u1", 2)]
np.dtype(three_tuples_dtype)  # 创建一个包含一个字段和其形状的结构化 dtype 对象

mixed_tuples_dtype = [("R", "u1"), ("G", np.str_, 1)]
np.dtype(mixed_tuples_dtype)  # 创建一个包含一个字符字段和一个字符串字段的结构化 dtype 对象

shape_tuple_dtype = [("R", "u1", (2, 2))]
np.dtype(shape_tuple_dtype)  # 创建一个包含一个形状为 (2, 2) 的字符字段的结构化 dtype 对象

shape_like_dtype = [("R", "u1", (2, 2)), ("G", np.str_, 1)]
np.dtype(shape_like_dtype)  # 创建一个包含两个字段的结构化 dtype 对象,其中一个是形状为 (2, 2) 的字符字段

object_dtype = [("field1", object)]
np.dtype(object_dtype)  # 创建一个包含一个 object 类型字段的结构化 dtype 对象

np.dtype((np.int32, (np.int8, 4)))  # 创建一个嵌套的 dtype 对象,包含 int32 和 int8 组成的元组

# Dtype comparison
np.dtype(float) == float  # 检查 np.dtype(float) 是否等于 float,返回布尔值
np.dtype(float) != np.float64  # 检查 np.dtype(float) 是否不等于 np.float64,返回布尔值
np.dtype(float) < None  # 检查 np.dtype(float) 是否小于 None,返回布尔值
np.dtype(float) <= "float64"  # 检查 np.dtype(float) 是否小于等于 "float64",返回布尔值
np.dtype(float) > np.dtype(float)  # 检查 np.dtype(float) 是否大于 np.dtype(float),返回布尔值
np.dtype(float) >= np.dtype(("U", 10))  # 检查 np.dtype(float) 是否大于等于包含长度为 10 的 Unicode 字符串数组的 dtype 对象

# Iteration and indexing
def iterable_func(x: Iterable[object]) -> Iterable[object]:
    return x  # 函数接收一个可迭代对象,返回相同的可迭代对象

iterable_func(array)  # 调用函数 `iterable_func`,传入数组 `array`
[element for element in array]  # 列表推导式,生成数组 `array` 的所有元素组成的列表
iter(array)  # 返回一个迭代器,迭代数组 `array` 中的元素
zip(array, array)  # 创建一个迭代器,同时迭代两个数组 `array` 中的元素
array[1]  # 获取数组 `array` 中索引为 1 的元素
array[:]  # 获取数组 `array` 的所有元素(切片)
array[...]  # 获取数组 `array` 的所有元素(完整切片)
array[:] = 0  # 将数组 `array` 的所有元素设置为 0

array_2d = np.ones((3, 3))  # 创建一个全为 1 的 3x3 的二维数组 `array_2d`
array_2d[:2, :2]  # 获取二维数组 `array_2d` 的左上角 2x2 子数组
array_2d[..., 0]  # 获取二维数组 `array_2d` 的第一列元素
array_2d[:2, :2] = 0  # 将二维数组 `array_2d` 的左上角 2x2 子数组的元素设置为 0

# Other special methods
len(array)  # 返回数组 `array` 的长度
str(array)  # 返回数组 `array` 的字符串表示
array_scalar = np.array(1)  # 创建一个标量值为 1 的数组 `array_scalar`
int(array_scalar)  # 将数组 `array_scalar` 转换为整数
float(array_scalar)  # 将数组 `array_scalar` 转换为浮点数
bytes(array_scalar)  # 返回数组 `array_scalar` 的字节表示
operator.index(array_scalar)  # 返回数组 `array_scalar` 的索引

# comparisons
array < 1  # 比较数组 `array` 中的每个元素是否小于 1,返回布尔值数组
array <= 1  # 比较数组 `array` 中的每个元素是否小于等于 1,返回布尔值数组
array == 1  # 比较数组 `array` 中的每个元素是否等于 1,返回布尔值数组
array != 1  # 比较数组 `array` 中的每个元素是否不等于 1,返回布尔值数组
array > 1  # 比较数组 `array` 中的每个元素是否大于 1,返回布尔值数组
array >= 1  # 比较数组 `array` 中的每个元素是否大于等于 1,返回布尔值数组
1 < array  # 比较数组 `array` 中的每个元素是否大于 1,返回布尔值数组
1 <= array  # 比较数组 `array` 中的每个元素是否大于等于 1,返回布尔值数组
1 == array  # 比较数组 `array` 中的每个元素是否等于 1,返回布尔值数组
1 != array  # 比较数组 `array` 中的每个元素是否不等于 1,返回布尔值数组
1 > array  # 比较数组 `array` 中的每个元素是否小于 1,返回布尔值数组
1 >= array  # 比较数组 `array` 中的每个元素是否小于等于 1,返回布尔值数组

# binary arithmetic
array + 1  # 将数组 `array` 中的每个元素加上 1
1 + array  # 将数组 `array` 中的每个元素加上 1
array += 1  # 将数组 `array` 中的每个元素加上 1

array - 1  # 将数组 `array` 中的每个元素减去 1
1 - array  # 将 1 减去数组 `array` 中的每个元素
array -= 1  # 将

.\numpy\numpy\typing\tests\data\pass\simple_py3.py

import numpy as np  # 导入NumPy库,通常用于数值计算

array = np.array([1, 2])  # 创建一个NumPy数组,包含元素1和2

# 使用 @ 符号进行数组的矩阵乘法运算(在Python 2中不支持此操作)
array @ array

.\numpy\numpy\typing\tests\data\pass\ufunclike.py

from __future__ import annotations
from typing import Any, Optional
import numpy as np

class Object:
    # 定义 ceil 魔术方法,返回对象自身
    def __ceil__(self) -> Object:
        return self

    # 定义 floor 魔术方法,返回对象自身
    def __floor__(self) -> Object:
        return self

    # 定义 >= 比较魔术方法,始终返回 True
    def __ge__(self, value: object) -> bool:
        return True

    # 定义数组转换魔术方法,将对象转换为包含自身的 numpy 数组
    def __array__(self, dtype: Optional[np.typing.DTypeLike] = None,
                  copy: Optional[bool] = None) -> np.ndarray[Any, np.dtype[np.object_]]:
        ret = np.empty((), dtype=object)
        ret[()] = self
        return ret

# 创建不同类型的数组样本
AR_LIKE_b = [True, True, False]
AR_LIKE_u = [np.uint32(1), np.uint32(2), np.uint32(3)]
AR_LIKE_i = [1, 2, 3]
AR_LIKE_f = [1.0, 2.0, 3.0]
AR_LIKE_O = [Object(), Object(), Object()]

# 创建指定类型的空字符串数组
AR_U: np.ndarray[Any, np.dtype[np.str_]] = np.zeros(3, dtype="U5")

# 使用 np.fix 函数处理各种类型的数组样本
np.fix(AR_LIKE_b)  # 四舍五入为最接近的整数
np.fix(AR_LIKE_u)  # 四舍五入为最接近的整数
np.fix(AR_LIKE_i)  # 四舍五入为最接近的整数
np.fix(AR_LIKE_f)  # 四舍五入为最接近的整数
np.fix(AR_LIKE_O)  # 四舍五入为最接近的整数
np.fix(AR_LIKE_f, out=AR_U)  # 将结果存储到指定的字符串数组中

# 使用 np.isposinf 函数检查数组中元素是否为正无穷
np.isposinf(AR_LIKE_b)
np.isposinf(AR_LIKE_u)
np.isposinf(AR_LIKE_i)
np.isposinf(AR_LIKE_f)
np.isposinf(AR_LIKE_f, out=AR_U)

# 使用 np.isneginf 函数检查数组中元素是否为负无穷
np.isneginf(AR_LIKE_b)
np.isneginf(AR_LIKE_u)
np.isneginf(AR_LIKE_i)
np.isneginf(AR_LIKE_f)
np.isneginf(AR_LIKE_f, out=AR_U)

.\numpy\numpy\typing\tests\data\pass\ufuncs.py

# 导入 numpy 库,约定使用 np 作为别名
import numpy as np

# 调用 np.sin 函数计算给定参数 1 的正弦值
np.sin(1)

# 调用 np.sin 函数计算给定数组 [1, 2, 3] 中每个元素的正弦值,返回一个数组
np.sin([1, 2, 3])

# 使用 np.sin 函数计算给定参数 1 的正弦值,并将结果存储到预先分配的 np.empty(1) 的数组中
np.sin(1, out=np.empty(1))

# 使用 np.matmul 函数计算两个 2x2x2 的全一数组的矩阵乘积,
# 指定轴的组合为 [(0, 1), (0, 1), (0, 1)]
np.matmul(np.ones((2, 2, 2)), np.ones((2, 2, 2)), axes=[(0, 1), (0, 1), (0, 1)])

# 调用 np.sin 函数,指定 signature 参数为 "D->D"
np.sin(1, signature="D->D")

# 注意: `np.generic` 的子类不能保证支持加法操作;
# 当我们可以推断出 `np.sin(...)` 的确切返回类型时,可以重新启用这行代码。
#
# np.sin(1) + np.sin(1)

# 访问 np.sin 函数返回类型的第一个元素的类型信息
np.sin.types[0]

# 访问 np.sin 函数的名称
np.sin.__name__

# 访问 np.sin 函数的文档字符串
np.sin.__doc__

# 对 np.array([1]) 应用 np.abs 函数,返回其绝对值的数组
np.abs(np.array([1]))

.\numpy\numpy\typing\tests\data\pass\ufunc_config.py

"""Typing tests for `numpy._core._ufunc_config`."""

import numpy as np  # 导入 numpy 库


def func1(a: str, b: int) -> None:
    return None  # 函数 func1 接受一个字符串和一个整数参数,无返回值


def func2(a: str, b: int, c: float = 1.0) -> None:
    return None  # 函数 func2 接受一个字符串和两个整数参数(其中一个有默认值),无返回值


def func3(a: str, b: int) -> int:
    return 0  # 函数 func3 接受一个字符串和一个整数参数,返回整数


class Write1:
    def write(self, a: str) -> None:
        return None  # 类 Write1 的方法 write 接受一个字符串参数,无返回值


class Write2:
    def write(self, a: str, b: int = 1) -> None:
        return None  # 类 Write2 的方法 write 接受一个字符串和一个整数参数(其中一个有默认值),无返回值


class Write3:
    def write(self, a: str) -> int:
        return 0  # 类 Write3 的方法 write 接受一个字符串参数,返回整数


_err_default = np.geterr()  # 获取当前 numpy 的错误处理设置
_bufsize_default = np.getbufsize()  # 获取当前 numpy 的缓冲区大小设置
_errcall_default = np.geterrcall()  # 获取当前 numpy 的错误回调设置

try:
    np.seterr(all=None)  # 设置所有错误为默认值
    np.seterr(divide="ignore")  # 设置除法相关错误为忽略
    np.seterr(over="warn")  # 设置溢出错误为警告
    np.seterr(under="call")  # 设置下溢错误为调用回调函数
    np.seterr(invalid="raise")  # 设置无效操作错误为抛出异常
    np.geterr()  # 获取当前 numpy 的错误处理设置

    np.setbufsize(4096)  # 设置 numpy 的缓冲区大小为 4096
    np.getbufsize()  # 获取当前 numpy 的缓冲区大小设置

    np.seterrcall(func1)  # 设置 numpy 的错误回调函数为 func1
    np.seterrcall(func2)  # 设置 numpy 的错误回调函数为 func2
    np.seterrcall(func3)  # 设置 numpy 的错误回调函数为 func3
    np.seterrcall(Write1())  # 设置 numpy 的错误回调函数为 Write1 类的实例
    np.seterrcall(Write2())  # 设置 numpy 的错误回调函数为 Write2 类的实例
    np.seterrcall(Write3())  # 设置 numpy 的错误回调函数为 Write3 类的实例
    np.geterrcall()  # 获取当前 numpy 的错误回调设置

    with np.errstate(call=func1, all="call"):  # 在上下文中设置错误状态,call 错误使用 func1 处理,所有错误都调用错误回调
        pass

    with np.errstate(call=Write1(), divide="log", over="log"):  # 在上下文中设置错误状态,call 错误使用 Write1 类的实例处理,divide 和 over 错误使用对数处理
        pass

finally:
    np.seterr(**_err_default)  # 恢复 numpy 的错误处理设置为默认值
    np.setbufsize(_bufsize_default)  # 恢复 numpy 的缓冲区大小设置为默认值
    np.seterrcall(_errcall_default)  # 恢复 numpy 的错误回调设置为默认值

.\numpy\numpy\typing\tests\data\pass\warnings_and_errors.py

import numpy.exceptions as ex
创建了一个别名 ex,用于引用 numpy.exceptions 模块

ex.AxisError("test")
创建一个 AxisError 的异常对象,参数为字符串 "test",用于标识异常

ex.AxisError(1, ndim=2)
创建一个 AxisError 的异常对象,其中第一个参数为整数 1,ndim 参数为 2,指定异常的维度信息

ex.AxisError(1, ndim=2, msg_prefix="error")
创建一个 AxisError 的异常对象,除了指定异常的维度信息外,还传入了 msg_prefix 参数,用于定制异常消息前缀

ex.AxisError(1, ndim=2, msg_prefix=None)
创建一个 AxisError 的异常对象,参数与上例相同,但是 msg_prefix 参数被设置为 None,可能会影响异常消息的生成

.\numpy\numpy\typing\tests\data\reveal\arithmetic.pyi

import sys
from typing import Any  # 导入 Any 类型,表示可以接受任何类型的参数

import numpy as np  # 导入 NumPy 库,并命名为 np
import numpy.typing as npt  # 导入 NumPy 的类型注解模块
from numpy._typing import _32Bit, _64Bit, _128Bit  # 导入 NumPy 中的特定位数类型

if sys.version_info >= (3, 11):
    from typing import assert_type  # 根据 Python 版本导入不同的 assert_type 函数
else:
    from typing_extensions import assert_type  # 使用 typing_extensions 模块中的 assert_type 函数

# 无法直接导入 `np.float128`,因为它不在所有平台上都可用
f16: np.floating[_128Bit]  # 声明一个名为 f16 的浮点数类型变量,具体类型为 np.floating[_128Bit]

c16 = np.complex128()  # 创建一个复数类型为 np.complex128 的变量 c16
f8 = np.float64()  # 创建一个浮点数类型为 np.float64 的变量 f8
i8 = np.int64()  # 创建一个整数类型为 np.int64 的变量 i8
u8 = np.uint64()  # 创建一个无符号整数类型为 np.uint64 的变量 u8

c8 = np.complex64()  # 创建一个复数类型为 np.complex64 的变量 c8
f4 = np.float32()  # 创建一个浮点数类型为 np.float32 的变量 f4
i4 = np.int32()  # 创建一个整数类型为 np.int32 的变量 i4
u4 = np.uint32()  # 创建一个无符号整数类型为 np.uint32 的变量 u4

dt = np.datetime64(0, "D")  # 创建一个日期时间类型为 np.datetime64 的变量 dt,初始化为 0 天
td = np.timedelta64(0, "D")  # 创建一个时间间隔类型为 np.timedelta64 的变量 td,初始化为 0 天

b_ = np.bool()  # 创建一个布尔类型为 np.bool 的变量 b_

b = bool()  # 创建一个 Python 内置的布尔类型变量 b
c = complex()  # 创建一个 Python 内置的复数类型变量 c
f = float()  # 创建一个 Python 内置的浮点数类型变量 f
i = int()  # 创建一个 Python 内置的整数类型变量 i

AR_b: npt.NDArray[np.bool]  # 声明一个 NumPy 数组类型变量 AR_b,元素类型为 np.bool
AR_u: npt.NDArray[np.uint32]  # 声明一个 NumPy 数组类型变量 AR_u,元素类型为 np.uint32
AR_i: npt.NDArray[np.int64]  # 声明一个 NumPy 数组类型变量 AR_i,元素类型为 np.int64
AR_f: npt.NDArray[np.float64]  # 声明一个 NumPy 数组类型变量 AR_f,元素类型为 np.float64
AR_c: npt.NDArray[np.complex128]  # 声明一个 NumPy 数组类型变量 AR_c,元素类型为 np.complex128
AR_m: npt.NDArray[np.timedelta64]  # 声明一个 NumPy 数组类型变量 AR_m,元素类型为 np.timedelta64
AR_M: npt.NDArray[np.datetime64]  # 声明一个 NumPy 数组类型变量 AR_M,元素类型为 np.datetime64
AR_O: npt.NDArray[np.object_]  # 声明一个 NumPy 数组类型变量 AR_O,元素类型为 np.object_
AR_number: npt.NDArray[np.number[Any]]  # 声明一个 NumPy 数组类型变量 AR_number,元素类型为 np.number[Any]

AR_LIKE_b: list[bool]  # 声明一个 Python 列表类型变量 AR_LIKE_b,元素类型为 bool
AR_LIKE_u: list[np.uint32]  # 声明一个 Python 列表类型变量 AR_LIKE_u,元素类型为 np.uint32
AR_LIKE_i: list[int]  # 声明一个 Python 列表类型变量 AR_LIKE_i,元素类型为 int
AR_LIKE_f: list[float]  # 声明一个 Python 列表类型变量 AR_LIKE_f,元素类型为 float
AR_LIKE_c: list[complex]  # 声明一个 Python 列表类型变量 AR_LIKE_c,元素类型为 complex
AR_LIKE_m: list[np.timedelta64]  # 声明一个 Python 列表类型变量 AR_LIKE_m,元素类型为 np.timedelta64
AR_LIKE_M: list[np.datetime64]  # 声明一个 Python 列表类型变量 AR_LIKE_M,元素类型为 np.datetime64
AR_LIKE_O: list[np.object_]  # 声明一个 Python 列表类型变量 AR_LIKE_O,元素类型为 np.object_

# 数组相减

assert_type(AR_number - AR_number, npt.NDArray[np.number[Any]])  # 断言 AR_number 和 AR_number 相减后的类型为 npt.NDArray[np.number[Any]]

assert_type(AR_b - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])  # 断言 AR_b 和 AR_LIKE_u 相减后的类型为 npt.NDArray[np.unsignedinteger[Any]]
assert_type(AR_b - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])  # 断言 AR_b 和 AR_LIKE_i 相减后的类型为 npt.NDArray[np.signedinteger[Any]]
assert_type(AR_b - AR_LIKE_f, npt.NDArray[np.floating[Any]])  # 断言 AR_b 和 AR_LIKE_f 相减后的类型为 npt.NDArray[np.floating[Any]]
assert_type(AR_b - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])  # 断言 AR_b 和 AR_LIKE_c 相减后的类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(AR_b - AR_LIKE_m, npt.NDArray[np.timedelta64])  # 断言 AR_b 和 AR_LIKE_m 相减后的类型为 npt.NDArray[np.timedelta64]
assert_type(AR_b - AR_LIKE_O, Any)  # 断言 AR_b 和 AR_LIKE_O 相减后的类型为 Any

assert_type(AR_LIKE_u - AR_b, npt.NDArray[np.unsignedinteger[Any]])  # 断言 AR_LIKE_u 和 AR_b 相减后的类型为 npt.NDArray[np.unsignedinteger[Any]]
assert_type(AR_LIKE_i - AR_b, npt.NDArray[np.signedinteger[Any]])  # 断言 AR_LIKE_i 和 AR_b 相减后的类型为 npt.NDArray[np.signedinteger[Any]]
assert_type(AR_LIKE_f - AR_b, npt.NDArray[np.floating[Any]])  # 断言 AR_LIKE_f 和 AR_b 相减后的类型为 npt.NDArray[np.floating[Any]]
assert_type(AR_LIKE_c - AR_b, npt.NDArray[np.complexfloating[Any, Any]])  # 断言 AR_LIKE_c 和 AR_b 相减后的类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(AR_LIKE_m - AR_b, npt.NDArray[np.timedelta64])  # 断言 AR_LIKE_m 和 AR_b 相减后的类型为 npt.NDArray[np.timedelta64]
assert_type(AR_LIKE_M - AR_b, npt.NDArray[np.datetime64])  # 断言 AR_LIKE_M 和 AR_b 相减后的类型为 npt.NDArray[np.datetime64]
assert_type(AR_LIKE_O - AR_b, Any)  # 断言 AR_LIKE_O 和 AR_b 相减后的类型为 Any

assert_type(AR_u - AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])  # 断言 AR_u 和 AR_LIKE_b 相减后的类型为 npt.NDArray[np.unsignedinteger[Any]]
assert_type(AR_u - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])  # 断言 AR_u 和 AR_LIKE_u 相减后的类型为 npt.NDArray[np.unsignedinteger[Any]]
assert_type(AR_u - AR_LIKE_i, npt.NDArray[np.signed
# 确保 AR_i 与 AR_LIKE_u 的元素类型为带符号整数的 NumPy 数组
assert_type(AR_i - AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])

# 确保 AR_i 与 AR_LIKE_i 的元素类型为带符号整数的 NumPy 数组
assert_type(AR_i - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])

# 确保 AR_i 与 AR_LIKE_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_i - AR_LIKE_f, npt.NDArray[np.floating[Any]])

# 确保 AR_i 与 AR_LIKE_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_i - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_i 与 AR_LIKE_m 的元素类型为时间间隔的 NumPy 数组
assert_type(AR_i - AR_LIKE_m, npt.NDArray[np.timedelta64])

# 确保 AR_i 与 AR_LIKE_O 的元素类型为任意类型
assert_type(AR_i - AR_LIKE_O, Any)

# 确保 AR_LIKE_b 与 AR_i 的元素类型为带符号整数的 NumPy 数组
assert_type(AR_LIKE_b - AR_i, npt.NDArray[np.signedinteger[Any]])

# 确保 AR_LIKE_u 与 AR_i 的元素类型为带符号整数的 NumPy 数组
assert_type(AR_LIKE_u - AR_i, npt.NDArray[np.signedinteger[Any]])

# 确保 AR_LIKE_i 与 AR_i 的元素类型为带符号整数的 NumPy 数组
assert_type(AR_LIKE_i - AR_i, npt.NDArray[np.signedinteger[Any]])

# 确保 AR_LIKE_f 与 AR_i 的元素类型为浮点数的 NumPy 数组
assert_type(AR_LIKE_f - AR_i, npt.NDArray[np.floating[Any]])

# 确保 AR_LIKE_c 与 AR_i 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_c - AR_i, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_m 与 AR_i 的元素类型为时间间隔的 NumPy 数组
assert_type(AR_LIKE_m - AR_i, npt.NDArray[np.timedelta64])

# 确保 AR_LIKE_M 与 AR_i 的元素类型为日期时间的 NumPy 数组
assert_type(AR_LIKE_M - AR_i, npt.NDArray[np.datetime64])

# 确保 AR_LIKE_O 与 AR_i 的元素类型为任意类型
assert_type(AR_LIKE_O - AR_i, Any)

# 确保 AR_f 与 AR_LIKE_b 的元素类型为浮点数的 NumPy 数组
assert_type(AR_f - AR_LIKE_b, npt.NDArray[np.floating[Any]])

# 确保 AR_f 与 AR_LIKE_u 的元素类型为浮点数的 NumPy 数组
assert_type(AR_f - AR_LIKE_u, npt.NDArray[np.floating[Any]])

# 确保 AR_f 与 AR_LIKE_i 的元素类型为浮点数的 NumPy 数组
assert_type(AR_f - AR_LIKE_i, npt.NDArray[np.floating[Any]])

# 确保 AR_f 与 AR_LIKE_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_f - AR_LIKE_f, npt.NDArray[np.floating[Any]])

# 确保 AR_f 与 AR_LIKE_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_f - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_f 与 AR_LIKE_O 的元素类型为任意类型
assert_type(AR_f - AR_LIKE_O, Any)

# 确保 AR_LIKE_b 与 AR_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_LIKE_b - AR_f, npt.NDArray[np.floating[Any]])

# 确保 AR_LIKE_u 与 AR_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_LIKE_u - AR_f, npt.NDArray[np.floating[Any]])

# 确保 AR_LIKE_i 与 AR_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_LIKE_i - AR_f, npt.NDArray[np.floating[Any]])

# 确保 AR_LIKE_f 与 AR_f 的元素类型为浮点数的 NumPy 数组
assert_type(AR_LIKE_f - AR_f, npt.NDArray[np.floating[Any]])

# 确保 AR_LIKE_c 与 AR_f 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_c - AR_f, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_O 与 AR_f 的元素类型为任意类型
assert_type(AR_LIKE_O - AR_f, Any)

# 确保 AR_c 与 AR_LIKE_b 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_c - AR_LIKE_b, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_c 与 AR_LIKE_u 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_c - AR_LIKE_u, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_c 与 AR_LIKE_i 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_c - AR_LIKE_i, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_c 与 AR_LIKE_f 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_c - AR_LIKE_f, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_c 与 AR_LIKE_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_c - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_c 与 AR_LIKE_O 的元素类型为任意类型
assert_type(AR_c - AR_LIKE_O, Any)

# 确保 AR_LIKE_b 与 AR_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_b - AR_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_u 与 AR_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_u - AR_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_i 与 AR_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_i - AR_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_f 与 AR_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_f - AR_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_c 与 AR_c 的元素类型为复数浮点数的 NumPy 数组
assert_type(AR_LIKE_c - AR_c, npt.NDArray[np.complexfloating[Any, Any]])

# 确保 AR_LIKE_O 与 AR_c 的元素类型为任意类型
assert_type(AR_LIKE_O - AR_c, Any)

# 确保 AR_m 与 AR_LIKE_b 的元素类型为时间间隔的 NumPy 数组
assert_type(AR_m - AR_LIKE_b, npt.NDArray[np.timedelta64])

# 确保 AR_m 与 AR_LIKE_u 的元素类型为时间间隔的 NumPy 数组
assert_type(AR_m - AR_LIKE_u, npt.NDArray[np.timedelta64])

# 确保 AR_m 与 AR_LIKE_i 的元素类型为时间间隔的 NumPy 数组
assert_type(AR_m - AR_LIKE_i, npt.NDArray[np.timedelta64])

# 确保 AR_m 与 AR_LIKE_m 的元素类型为时间间隔的 NumPy 数组
assert
# 确保 AR_M 减去 AR_LIKE_b 后的结果为 np.datetime64 类型
assert_type(AR_M - AR_LIKE_b, npt.NDArray[np.datetime64])
# 确保 AR_M 减去 AR_LIKE_u 后的结果为 np.datetime64 类型
assert_type(AR_M - AR_LIKE_u, npt.NDArray[np.datetime64])
# 确保 AR_M 减去 AR_LIKE_i 后的结果为 np.datetime64 类型
assert_type(AR_M - AR_LIKE_i, npt.NDArray[np.datetime64])
# 确保 AR_M 减去 AR_LIKE_m 后的结果为 np.datetime64 类型
assert_type(AR_M - AR_LIKE_m, npt.NDArray[np.datetime64])
# 确保 AR_M 减去 AR_LIKE_M 后的结果为 np.timedelta64 类型
assert_type(AR_M - AR_LIKE_M, npt.NDArray[np.timedelta64])
# 确保 AR_M 减去 AR_LIKE_O 后的结果为任何类型
assert_type(AR_M - AR_LIKE_O, Any)

# 确保 AR_LIKE_M 减去 AR_M 后的结果为 np.timedelta64 类型
assert_type(AR_LIKE_M - AR_M, npt.NDArray[np.timedelta64])
# 确保 AR_LIKE_O 减去 AR_M 后的结果为任何类型
assert_type(AR_LIKE_O - AR_M, Any)

# 确保 AR_O 减去 AR_LIKE_b 后的结果为任何类型
assert_type(AR_O - AR_LIKE_b, Any)
# 确保 AR_O 减去 AR_LIKE_u 后的结果为任何类型
assert_type(AR_O - AR_LIKE_u, Any)
# 确保 AR_O 减去 AR_LIKE_i 后的结果为任何类型
assert_type(AR_O - AR_LIKE_i, Any)
# 确保 AR_O 减去 AR_LIKE_f 后的结果为任何类型
assert_type(AR_O - AR_LIKE_f, Any)
# 确保 AR_O 减去 AR_LIKE_c 后的结果为任何类型
assert_type(AR_O - AR_LIKE_c, Any)
# 确保 AR_O 减去 AR_LIKE_m 后的结果为任何类型
assert_type(AR_O - AR_LIKE_m, Any)
# 确保 AR_O 减去 AR_LIKE_M 后的结果为任何类型
assert_type(AR_O - AR_LIKE_M, Any)
# 确保 AR_O 减去 AR_LIKE_O 后的结果为任何类型
assert_type(AR_O - AR_LIKE_O, Any)

# 确保 AR_LIKE_b 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_b - AR_O, Any)
# 确保 AR_LIKE_u 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_u - AR_O, Any)
# 确保 AR_LIKE_i 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_i - AR_O, Any)
# 确保 AR_LIKE_f 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_f - AR_O, Any)
# 确保 AR_LIKE_c 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_c - AR_O, Any)
# 确保 AR_LIKE_m 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_m - AR_O, Any)
# 确保 AR_LIKE_M 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_M - AR_O, Any)
# 确保 AR_LIKE_O 减去 AR_O 后的结果为任何类型
assert_type(AR_LIKE_O - AR_O, Any)

# 数组的整数除法操作

# 确保 AR_b 除以 AR_LIKE_b 后的结果为 np.int8 类型
assert_type(AR_b // AR_LIKE_b, npt.NDArray[np.int8])
# 确保 AR_b 除以 AR_LIKE_u 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_b // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_b 除以 AR_LIKE_i 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_b // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_b 除以 AR_LIKE_f 后的结果为 np.floating[Any] 类型的数组
assert_type(AR_b // AR_LIKE_f, npt.NDArray[np.floating[Any]])
# 确保 AR_b 除以 AR_LIKE_O 后的结果为任何类型
assert_type(AR_b // AR_LIKE_O, Any)

# 确保 AR_LIKE_b 除以 AR_b 后的结果为 np.int8 类型的数组
assert_type(AR_LIKE_b // AR_b, npt.NDArray[np.int8])
# 确保 AR_LIKE_u 除以 AR_b 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_LIKE_u // AR_b, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_LIKE_i 除以 AR_b 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_LIKE_i // AR_b, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_LIKE_f 除以 AR_b 后的结果为 np.floating[Any] 类型的数组
assert_type(AR_LIKE_f // AR_b, npt.NDArray[np.floating[Any]])
# 确保 AR_LIKE_O 除以 AR_b 后的结果为任何类型
assert_type(AR_LIKE_O // AR_b, Any)

# 确保 AR_u 除以 AR_LIKE_b 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_u // AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_u 除以 AR_LIKE_u 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_u // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_u 除以 AR_LIKE_i 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_u // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_u 除以 AR_LIKE_f 后的结果为 np.floating[Any] 类型的数组
assert_type(AR_u // AR_LIKE_f, npt.NDArray[np.floating[Any]])
# 确保 AR_u 除以 AR_LIKE_O 后的结果为任何类型
assert_type(AR_u // AR_LIKE_O, Any)

# 确保 AR_LIKE_b 除以 AR_u 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_LIKE_b // AR_u, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_LIKE_u 除以 AR_u 后的结果为 np.unsignedinteger[Any] 类型的数组
assert_type(AR_LIKE_u // AR_u, npt.NDArray[np.unsignedinteger[Any]])
# 确保 AR_LIKE_i 除以 AR_u 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_LIKE_i // AR_u, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_LIKE_f 除以 AR_u 后的结果为 np.floating[Any] 类型的数组
assert_type(AR_LIKE_f // AR_u, npt.NDArray[np.floating[Any]])
# 确保 AR_LIKE_m 除以 AR_u 后的结果为 np.timedelta64 类型的数组
assert_type(AR_LIKE_m // AR_u, npt.NDArray[np.timedelta64])
# 确保 AR_LIKE_O 除以 AR_u 后的结果为任何类型
assert_type(AR_LIKE_O // AR_u, Any)

# 确保 AR_i 除以 AR_LIKE_b 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_i // AR_LIKE_b, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_i 除以 AR_LIKE_u 后的结果为 np.signedinteger[Any] 类型的数组
assert_type(AR_i // AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])
# 确保 AR_i 除以
# 断言表达式,验证 AR_f 与 AR_LIKE_u 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_f // AR_LIKE_u, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_f 与 AR_LIKE_i 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_f // AR_LIKE_i, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_f 与 AR_LIKE_f 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_f // AR_LIKE_f, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_f 与 AR_LIKE_O 之间的整除操作结果类型为任意类型
assert_type(AR_f // AR_LIKE_O, Any)

# 断言表达式,验证 AR_LIKE_b 与 AR_f 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_LIKE_b // AR_f, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_LIKE_u 与 AR_f 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_LIKE_u // AR_f, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_LIKE_i 与 AR_f 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_LIKE_i // AR_f, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_LIKE_f 与 AR_f 之间的整除操作结果类型为 numpy 中的浮点数数组
assert_type(AR_LIKE_f // AR_f, npt.NDArray[np.floating[Any]])
# 断言表达式,验证 AR_LIKE_m 与 AR_f 之间的整除操作结果类型为 numpy 中的时间间隔数组
assert_type(AR_LIKE_m // AR_f, npt.NDArray[np.timedelta64])
# 断言表达式,验证 AR_LIKE_O 与 AR_f 之间的整除操作结果类型为任意类型
assert_type(AR_LIKE_O // AR_f, Any)

# 断言表达式,验证 AR_m 与 AR_LIKE_u 之间的整除操作结果类型为 numpy 中的时间间隔数组
assert_type(AR_m // AR_LIKE_u, npt.NDArray[np.timedelta64])
# 断言表达式,验证 AR_m 与 AR_LIKE_i 之间的整除操作结果类型为 numpy 中的时间间隔数组
assert_type(AR_m // AR_LIKE_i, npt.NDArray[np.timedelta64])
# 断言表达式,验证 AR_m 与 AR_LIKE_f 之间的整除操作结果类型为 numpy 中的时间间隔数组
assert_type(AR_m // AR_LIKE_f, npt.NDArray[np.timedelta64])
# 断言表达式,验证 AR_m 与 AR_LIKE_m 之间的整除操作结果类型为 numpy 中的整数数组
assert_type(AR_m // AR_LIKE_m, npt.NDArray[np.int64])
# 断言表达式,验证 AR_m 与 AR_LIKE_O 之间的整除操作结果类型为任意类型
assert_type(AR_m // AR_LIKE_O, Any)

# 断言表达式,验证 AR_LIKE_m 与 AR_m 之间的整除操作结果类型为 numpy 中的整数数组
assert_type(AR_LIKE_m // AR_m, npt.NDArray[np.int64])
# 断言表达式,验证 AR_LIKE_O 与 AR_m 之间的整除操作结果类型为任意类型
assert_type(AR_LIKE_O // AR_m, Any)

# 断言表达式,验证 AR_O 与 AR_LIKE_b 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_b, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_u 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_u, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_i 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_i, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_f 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_f, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_m 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_m, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_M 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_M, Any)
# 断言表达式,验证 AR_O 与 AR_LIKE_O 之间的整除操作结果类型为任意类型
assert_type(AR_O // AR_LIKE_O, Any)

# 断言表达式,验证 f16 取负操作的结果类型为 numpy 中的浮点数,精度为 128 位
assert_type(-f16, np.floating[_128Bit])
# 断言表达式,验证 c16 取负操作的结果类型为 numpy 中的复数,精度为 complex128
assert_type(-c16, np.complex128)
# 断言表达式,验证 c8 取负操作的结果类型为 numpy 中的复数,精度为 complex64
assert_type(-c8, np.complex64)
# 断言表达式,验证 f8 取负操作的结果类型为 numpy 中的浮点数,精度为 float64
assert_type(-f8, np.float64)
# 断言表达式,验证 f4 取负操作的结果类型为 numpy 中的浮点数,精度为 float32
assert_type(-f4, np.float32)
# 断言表达式,验证 i8 取负操作的结果类型为 numpy 中的整数,精度为 int64
assert_type(-i8, np.int64)
# 断言表达式,验证 i4 取负操作的结果类型为 numpy 中的整数,精度为 int32
assert_type(-i4, np.int32)
# 断言表达式,验证 u8 取负操作的结果类型为 numpy 中的无符号整数,精度为 uint64
assert_type(-u8, np.uint64)
# 断言表达式,验证 u4 取负操作的结果类型为 numpy 中的无符号整数,精度为 uint32
assert_type(-u4, np.uint32)
# 断言表达式,验证 td 取负操作的结果类型为 numpy 中的时间间隔,精度由 td 决定
assert_type(-td, np.timedelta64)
# 断言表达式,验证 AR_f 取负操作的结果类型为 numpy 中的浮点数数组,精度为 float64
assert_type(-AR_f, npt.NDArray[np.float64])

# 断言表达式,验证 f16 取正操作的结果类型为 numpy 中的浮点数,精度为 128 位
assert_type(+f16, np.floating[_128Bit])
# 断言表达式,验证 c16 取正操作的结果类型为 numpy 中的复数,精度为 complex128
assert_type(+c16, np.complex128)
# 断言表达式,验证 c8 取正操作的结果类型为 numpy 中的复数,精度为 complex64
assert_type(+c8, np.complex64)
# 断言表达式,验证 f8 取正操作的结果类型为 numpy 中的浮点数,精度为 float64
assert_type(+f8, np.float64)
# 断言表达式,验证 f4 取正操作的结果类型为 numpy 中的浮点数,精度为 float32
assert_type(+f4, np.float32)
# 断言表达式,验证 i8 取正操作的结果类型为 numpy 中的整数,精度为 int64
assert_type(+i8, np.int64)
# 断言表达式,验证 i4 取正操作的结果类型为 numpy 中的整数,精度为 int32
assert_type(+i4, np.int32)
# 断言表达式,验证 u8 取正操作的结果类型为 numpy
# Assert that the result of subtracting two timedelta64 objects is of type np.timedelta64
assert_type(td - td, np.timedelta64)
# Assert that the result of subtracting a timedelta64 object from an integer is of type np.timedelta64
assert_type(td - i, np.timedelta64)
# Assert that the result of subtracting a timedelta64 object from an int32 is of type np.timedelta64
assert_type(td - i4, np.timedelta64)
# Assert that the result of subtracting a timedelta64 object from an int64 is of type np.timedelta64
assert_type(td - i8, np.timedelta64)
# Assert that the result of dividing a timedelta64 object by a float is of type np.timedelta64
assert_type(td / f, np.timedelta64)
# Assert that the result of dividing a timedelta64 object by a float32 is of type np.timedelta64
assert_type(td / f4, np.timedelta64)
# Assert that the result of dividing a timedelta64 object by a float64 is of type np.timedelta64
assert_type(td / f8, np.timedelta64)
# Assert that the result of dividing a timedelta64 object by another timedelta64 object is of type np.float64
assert_type(td / td, np.float64)
# Assert that the result of floor dividing a timedelta64 object by another timedelta64 object is of type np.int64
assert_type(td // td, np.int64)

# Boolean operations

# Assert that the result of dividing a boolean object by a boolean object is of type np.float64
assert_type(b_ / b, np.float64)
# Assert that the result of dividing a boolean object by another boolean object is of type np.float64
assert_type(b_ / b_, np.float64)
# Assert that the result of dividing a boolean object by an integer is of type np.float64
assert_type(b_ / i, np.float64)
# Assert that the result of dividing a boolean object by an int64 is of type np.float64
assert_type(b_ / i8, np.float64)
# Assert that the result of dividing a boolean object by an int32 is of type np.float64
assert_type(b_ / i4, np.float64)
# Assert that the result of dividing a boolean object by an uint64 is of type np.float64
assert_type(b_ / u8, np.float64)
# Assert that the result of dividing a boolean object by an uint32 is of type np.float64
assert_type(b_ / u4, np.float64)
# Assert that the result of dividing a boolean object by a float is of type np.float64
assert_type(b_ / f, np.float64)
# Assert that the result of dividing a boolean object by a float128 is of type np.floating[_128Bit]
assert_type(b_ / f16, np.floating[_128Bit])
# Assert that the result of dividing a boolean object by a float64 is of type np.float64
assert_type(b_ / f8, np.float64)
# Assert that the result of dividing a boolean object by a float32 is of type np.float32
assert_type(b_ / f4, np.float32)
# Assert that the result of dividing a boolean object by a complex128 object is of type np.complex128
assert_type(b_ / c, np.complex128)
# Assert that the result of dividing a boolean object by a complex256 object is of type np.complex128
assert_type(b_ / c16, np.complex128)
# Assert that the result of dividing a boolean object by a complex128 object is of type np.complex64
assert_type(b_ / c8, np.complex64)

# Assert that the result of dividing an integer by a boolean object is of type np.float64
assert_type(b / b_, np.float64)
# Assert that the result of dividing a boolean object by another boolean object is of type np.float64
assert_type(b_ / b_, np.float64)
# Assert that the result of dividing an integer by a boolean object is of type np.float64
assert_type(i / b_, np.float64)
# Assert that the result of dividing an int64 by a boolean object is of type np.float64
assert_type(i8 / b_, np.float64)
# Assert that the result of dividing an int32 by a boolean object is of type np.float64
assert_type(i4 / b_, np.float64)
# Assert that the result of dividing an uint64 by a boolean object is of type np.float64
assert_type(u8 / b_, np.float64)
# Assert that the result of dividing an uint32 by a boolean object is of type np.float64
assert_type(u4 / b_, np.float64)
# Assert that the result of dividing a float by a boolean object is of type np.float64
assert_type(f / b_, np.float64)
# Assert that the result of dividing a float128 by a boolean object is of type np.floating[_128Bit]
assert_type(f16 / b_, np.floating[_128Bit])
# Assert that the result of dividing a float64 by a boolean object is of type np.float64
assert_type(f8 / b_, np.float64)
# Assert that the result of dividing a float32 by a boolean object is of type np.float32
assert_type(f4 / b_, np.float32)
# Assert that the result of dividing a complex128 by a boolean object is of type np.complex128
assert_type(c / b_, np.complex128)
# Assert that the result of dividing a complex256 by a boolean object is of type np.complex128
assert_type(c16 / b_, np.complex128)
# Assert that the result of dividing a complex128 by a boolean object is of type np.complex64
assert_type(c8 / b_, np.complex64)

# Complex operations

# Assert that the result of adding a complex256 object to a float128 object is of type np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit]
assert_type(c16 + f16, np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit])
# Assert that the result of adding two complex128 objects is of type np.complex128
assert_type(c16 + c16, np.complex128)
# Assert that the result of adding a complex128 object to a float64 object is of type np.complex128
assert_type(c16 + f8, np.complex128)
# Assert that the result of adding a complex128 object to an int64 object is of type np.complex128
assert_type(c16 + i8, np.complex128)
# Assert that the result of adding two complex64 objects is of type np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c16 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
# Assert that the result of adding a complex64 object to a float32 object is of type np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c16 + f4, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
# Assert that the result of adding a complex64 object to an int32 object is of type np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c16 + i4, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
# Assert that the result of adding a complex128 object to a boolean object is of type np.complex128
assert_type(c16 + b_, np.complex128)
# Assert that the result of adding a complex128 object to a boolean object is of type np.complex128
assert_type(c16 + b, np.complex128)
# Assert that the result of adding a complex128 object to a complex64 object is of type np.complex128
assert_type(c16 + c, np.complex128)
# Assert that the result of adding a complex128 object to a float object is of type np.complex128
assert_type(c16 + f, np.complex128)
# Assert that the result of adding a complex128 object to an array of float objects is of type npt.NDArray[np.complexfloating[Any, Any]]

# Assert that the result of adding a float128 object to a complex256 object is of type np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit]
assert_type(f16 + c16, np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit])
# Assert that the result of adding two complex128 objects is of type np.complex128
assert_type(c16 + c16, np.complex128)
# Assert that the result of adding a float64 object to a complex128 object is of type np.complex128
assert_type(f8 + c16, np.complex128)
# Assert that the result of adding an int64 object to a complex128 object is of type np.complex128
assert_type(i8 + c16, np.complex128)
# Assert that the result of adding a complex64 object to a complex128 object is of type np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c8 + c16, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
# Assert that the result of adding a float32 object to a complex128 object is of type np.complexfloating[_
# 断言两个复数相加后的类型为 np.complex64
assert_type(c8 + b_, np.complex64)

# 断言两个复数相加后的类型为 np.complex64
assert_type(c8 + b, np.complex64)

# 断言一个复数与复数浮点数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c8 + c, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个复数与复数浮点数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c8 + f, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个复数与任意复数数组相加后的类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(c8 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])

# 断言一个浮点数与复数相加后的类型为 np.complexfloating[_32Bit | _128Bit, _32Bit | _128Bit]
assert_type(f16 + c8, np.complexfloating[_32Bit | _128Bit, _32Bit | _128Bit])

# 断言两个复数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c16 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个浮点数与复数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(f8 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个整数与复数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(i8 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言两个复数相加后的类型为 np.complex64
assert_type(c8 + c8, np.complex64)

# 断言一个单精度浮点数与复数相加后的类型为 np.complex64
assert_type(f4 + c8, np.complex64)

# 断言一个整数与复数相加后的类型为 np.complex64
assert_type(i4 + c8, np.complex64)

# 断言一个布尔值与复数相加后的类型为 np.complex64
assert_type(b_ + c8, np.complex64)

# 断言一个布尔值与复数相加后的类型为 np.complex64
assert_type(b + c8, np.complex64)

# 断言一个复数与复数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(c + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个浮点数与复数相加后的类型为 np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit]
assert_type(f + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])

# 断言一个任意复数数组与复数相加后的类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(AR_f + c8, npt.NDArray[np.complexfloating[Any, Any]])

# 断言两个双精度浮点数相加后的类型为 np.floating[_64Bit | _128Bit]
assert_type(f8 + f16, np.floating[_64Bit | _128Bit])

# 断言两个双精度浮点数相加后的类型为 np.float64
assert_type(f8 + f8, np.float64)

# 断言一个双精度浮点数与整数相加后的类型为 np.float64
assert_type(f8 + i8, np.float64)

# 断言一个双精度浮点数与单精度浮点数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(f8 + f4, np.floating[_32Bit | _64Bit])

# 断言一个双精度浮点数与整数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(f8 + i4, np.floating[_32Bit | _64Bit])

# 断言一个双精度浮点数与布尔值相加后的类型为 np.float64
assert_type(f8 + b_, np.float64)

# 断言一个双精度浮点数与布尔值相加后的类型为 np.float64
assert_type(f8 + b, np.float64)

# 断言一个双精度浮点数与复数相加后的类型为 np.complex128
assert_type(f8 + c, np.complex128)

# 断言一个双精度浮点数与浮点数相加后的类型为 np.float64
assert_type(f8 + f, np.float64)

# 断言一个双精度浮点数与任意浮点数数组相加后的类型为 npt.NDArray[np.floating[Any]]
assert_type(f8 + AR_f, npt.NDArray[np.floating[Any]])

# 断言一个双精度浮点数与双精度浮点数相加后的类型为 np.floating[_64Bit | _128Bit]
assert_type(f16 + f8, np.floating[_64Bit | _128Bit])

# 断言一个双精度浮点数与整数相加后的类型为 np.float64
assert_type(i8 + f8, np.float64)

# 断言一个单精度浮点数与双精度浮点数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(f4 + f8, np.floating[_32Bit | _64Bit])

# 断言一个单精度浮点数与整数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(i4 + f8, np.floating[_32Bit | _64Bit])

# 断言一个布尔值与双精度浮点数相加后的类型为 np.float64
assert_type(b_ + f8, np.float64)

# 断言一个布尔值与双精度浮点数相加后的类型为 np.float64
assert_type(b + f8, np.float64)

# 断言一个复数与双精度浮点数相加后的类型为 np.complex128
assert_type(c + f8, np.complex128)

# 断言一个浮点数与双精度浮点数相加后的类型为 np.float64
assert_type(f + f8, np.float64)

# 断言一个任意浮点数数组与双精度浮点数相加后的类型为 npt.NDArray[np.floating[Any]]
assert_type(AR_f + f8, npt.NDArray[np.floating[Any]])

# 断言一个单精度浮点数与单精度浮点数相加后的类型为 np.floating[_32Bit | _128Bit]
assert_type(f4 + f16, np.floating[_32Bit | _128Bit])

# 断言一个单精度浮点数与双精度浮点数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(f4 + f8, np.floating[_32Bit | _64Bit])

# 断言一个单精度浮点数与整数相加后的类型为 np.floating[_32Bit | _64Bit]
assert_type(f4 + i8, np.floating[_32Bit | _64Bit])

# 断言两个单精度浮点数相加后的类型为 np.float32
assert_type(f4 + f4, np.float32)

# 断言一个单精度浮点数与整数相加后的类型为 np.float32
assert_type(f4 + i4, np.float32)

# 断言一个单精度浮点数与布尔值相加后的类型为 np.float32
assert_type(f4 + b_, np.float32)

#
# 检查 i8 与 f 的相加结果的数据类型是否为 np.float64
assert_type(i8 + f, np.float64)

# 检查 i8 与 AR_f 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(i8 + AR_f, npt.NDArray[np.floating[Any]])

# 检查 u8 与 u8 的相加结果的数据类型是否为 np.uint64
assert_type(u8 + u8, np.uint64)

# 检查 u8 与 i4 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(u8 + i4, Any)

# 检查 u8 与 u4 的相加结果的数据类型是否为 np.unsignedinteger[_32Bit | _64Bit]
assert_type(u8 + u4, np.unsignedinteger[_32Bit | _64Bit])

# 检查 u8 与 b_ 的相加结果的数据类型是否为 np.uint64
assert_type(u8 + b_, np.uint64)

# 检查 u8 与 b 的相加结果的数据类型是否为 np.uint64
assert_type(u8 + b, np.uint64)

# 检查 u8 与 c 的相加结果的数据类型是否为 np.complex128
assert_type(u8 + c, np.complex128)

# 检查 u8 与 f 的相加结果的数据类型是否为 np.float64
assert_type(u8 + f, np.float64)

# 检查 u8 与 AR_f 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(u8 + AR_f, npt.NDArray[np.floating[Any]])

# 检查 i8 与 i8 的相加结果的数据类型是否为 np.int64
assert_type(i8 + i8, np.int64)

# 检查 u8 与 i8 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(u8 + i8, Any)

# 检查 i4 与 i8 的相加结果的数据类型是否为 np.signedinteger[_32Bit | _64Bit]
assert_type(i4 + i8, np.signedinteger[_32Bit | _64Bit])

# 检查 u4 与 i8 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(u4 + i8, Any)

# 检查 b_ 与 i8 的相加结果的数据类型是否为 np.int64
assert_type(b_ + i8, np.int64)

# 检查 b 与 i8 的相加结果的数据类型是否为 np.int64
assert_type(b + i8, np.int64)

# 检查 c 与 i8 的相加结果的数据类型是否为 np.complex128
assert_type(c + i8, np.complex128)

# 检查 f 与 i8 的相加结果的数据类型是否为 np.float64
assert_type(f + i8, np.float64)

# 检查 AR_f 与 i8 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(AR_f + i8, npt.NDArray[np.floating[Any]])

# 检查 u8 与 u8 的相加结果的数据类型是否为 np.uint64
assert_type(u8 + u8, np.uint64)

# 检查 i4 与 u8 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(i4 + u8, Any)

# 检查 u4 与 u8 的相加结果的数据类型是否为 np.unsignedinteger[_32Bit | _64Bit]
assert_type(u4 + u8, np.unsignedinteger[_32Bit | _64Bit])

# 检查 b_ 与 u8 的相加结果的数据类型是否为 np.uint64
assert_type(b_ + u8, np.uint64)

# 检查 b 与 u8 的相加结果的数据类型是否为 np.uint64
assert_type(b + u8, np.uint64)

# 检查 c 与 u8 的相加结果的数据类型是否为 np.complex128
assert_type(c + u8, np.complex128)

# 检查 f 与 u8 的相加结果的数据类型是否为 np.float64
assert_type(f + u8, np.float64)

# 检查 AR_f 与 u8 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(AR_f + u8, npt.NDArray[np.floating[Any]])

# 检查 i4 与 i8 的相加结果的数据类型是否为 np.signedinteger[_32Bit | _64Bit]
assert_type(i4 + i8, np.signedinteger[_32Bit | _64Bit])

# 检查 i4 与 i4 的相加结果的数据类型是否为 np.int32
assert_type(i4 + i4, np.int32)

# 检查 i4 与 b_ 的相加结果的数据类型是否为 np.int32
assert_type(i4 + b_, np.int32)

# 检查 i4 与 b 的相加结果的数据类型是否为 np.int32
assert_type(i4 + b, np.int32)

# 检查 i4 与 AR_f 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(i4 + AR_f, npt.NDArray[np.floating[Any]])

# 检查 u4 与 i8 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(u4 + i8, Any)

# 检查 u4 与 i4 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(u4 + i4, Any)

# 检查 u4 与 u8 的相加结果的数据类型是否为 np.unsignedinteger[_32Bit | _64Bit]
assert_type(u4 + u8, np.unsignedinteger[_32Bit | _64Bit])

# 检查 u4 与 u4 的相加结果的数据类型是否为 np.uint32
assert_type(u4 + u4, np.uint32)

# 检查 u4 与 b_ 的相加结果的数据类型是否为 np.uint32
assert_type(u4 + b_, np.uint32)

# 检查 u4 与 b 的相加结果的数据类型是否为 np.uint32
assert_type(u4 + b, np.uint32)

# 检查 u4 与 AR_f 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(u4 + AR_f, npt.NDArray[np.floating[Any]])

# 检查 i8 与 i4 的相加结果的数据类型是否为 np.signedinteger[_32Bit | _64Bit]
assert_type(i8 + i4, np.signedinteger[_32Bit | _64Bit])

# 检查 i4 与 i4 的相加结果的数据类型是否为 np.int32
assert_type(i4 + i4, np.int32)

# 检查 b_ 与 i4 的相加结果的数据类型是否为 np.int32
assert_type(b_ + i4, np.int32)

# 检查 b 与 i4 的相加结果的数据类型是否为 np.int32
assert_type(b + i4, np.int32)

# 检查 AR_f 与 i4 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(AR_f + i4, npt.NDArray[np.floating[Any]])

# 检查 i8 与 u4 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(i8 + u4, Any)

# 检查 i4 与 u4 的相加结果的数据类型是否为 Any(即没有特定限制)
assert_type(i4 + u4, Any)

# 检查 u8 与 u4 的相加结果的数据类型是否为 np.unsignedinteger[_32Bit | _64Bit]
assert_type(u8 + u4, np.unsignedinteger[_32Bit | _64Bit])

# 检查 u4 与 u4 的相加结果的数据类型是否为 np.uint32
assert_type(u4 + u4, np.uint32)

# 检查 b_ 与 u4 的相加结果的数据类型是否为 np.uint32
assert_type(b_ + u4, np.uint32)

# 检查 b 与 u4 的相加结果的数据类型是否为 np.uint32
assert_type(b + u4, np.uint32)

# 检查 AR_f 与 u4 的相加结果的数据类型是否为 npt.NDArray[np.floating[Any]]
assert_type(AR_f + u4, npt.NDArray[np.f

.\numpy\numpy\typing\tests\data\reveal\arraypad.pyi

# 导入系统模块sys
import sys
# 从collections.abc模块中导入Mapping类
from collections.abc import Mapping
# 从typing模块中导入Any和SupportsIndex类型
from typing import Any, SupportsIndex

# 导入numpy库,并将其重命名为np
import numpy as np
# 导入numpy.typing模块中的npt类型
import numpy.typing as npt

# 如果Python版本大于等于3.11,则从typing模块中导入assert_type函数
if sys.version_info >= (3, 11):
    from typing import assert_type
# 否则,从typing_extensions模块中导入assert_type函数
else:
    from typing_extensions import assert_type

# 定义一个函数mode_func,参数类型为npt.NDArray[np.number[Any]]、tuple[int, int]、SupportsIndex和Mapping[str, Any],返回类型为None
def mode_func(
    ar: npt.NDArray[np.number[Any]],
    width: tuple[int, int],
    iaxis: SupportsIndex,
    kwargs: Mapping[str, Any],
) -> None: ...

# 定义变量AR_i8,类型为npt.NDArray[np.int64]
AR_i8: npt.NDArray[np.int64]
# 定义变量AR_f8,类型为npt.NDArray[np.float64]
AR_f8: npt.NDArray[np.float64]
# 定义变量AR_LIKE,类型为list[int]
AR_LIKE: list[int]

# 使用assert_type函数验证np.pad函数的返回类型为npt.NDArray[np.int64]
assert_type(np.pad(AR_i8, (2, 3), "constant"), npt.NDArray[np.int64])
# 使用assert_type函数验证np.pad函数的返回类型为npt.NDArray[Any]
assert_type(np.pad(AR_LIKE, (2, 3), "constant"), npt.NDArray[Any])

# 使用assert_type函数验证np.pad函数的返回类型为npt.NDArray[np.float64]
assert_type(np.pad(AR_f8, (2, 3), mode_func), npt.NDArray[np.float64])
# 使用assert_type函数验证np.pad函数的返回类型为npt.NDArray[np.float64],并传递额外的关键字参数a=1和b=2
assert_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2), npt.NDArray[np.float64])

.\numpy\numpy\typing\tests\data\reveal\arrayprint.pyi

import sys
import contextlib
from collections.abc import Callable
from typing import Any

import numpy as np
import numpy.typing as npt
from numpy._core.arrayprint import _FormatOptions

# 如果 Python 版本大于等于 3.11,则使用标准库 typing 中的 assert_type
if sys.version_info >= (3, 11):
    from typing import assert_type
# 否则,使用 typing_extensions 中的 assert_type
else:
    from typing_extensions import assert_type

# 定义一个 numpy 的多维数组 AR,元素类型为 np.int64
AR: npt.NDArray[np.int64]
# 定义两个可调用对象,接受 np.floating 和 np.integer 类型的参数,返回字符串
func_float: Callable[[np.floating[Any]], str]
func_int: Callable[[np.integer[Any]], str]

# 使用 assert_type 确保 np.get_printoptions() 返回的类型是 _FormatOptions
assert_type(np.get_printoptions(), _FormatOptions)

# 使用 assert_type 确保 np.array2string(AR, formatter={'float_kind': func_float, 'int_kind': func_int}) 返回的类型是 str
assert_type(
    np.array2string(AR, formatter={'float_kind': func_float, 'int_kind': func_int}),
    str,
)

# 使用 assert_type 确保 np.format_float_scientific(1.0) 返回的类型是 str
assert_type(np.format_float_scientific(1.0), str)

# 使用 assert_type 确保 np.format_float_positional(1) 返回的类型是 str
assert_type(np.format_float_positional(1), str)

# 使用 assert_type 确保 np.array_repr(AR) 返回的类型是 str
assert_type(np.array_repr(AR), str)

# 使用 assert_type 确保 np.array_str(AR) 返回的类型是 str
assert_type(np.array_str(AR), str)

# 使用 assert_type 确保 np.printoptions() 返回的类型是 contextlib._GeneratorContextManager[_FormatOptions]
assert_type(np.printoptions(), contextlib._GeneratorContextManager[_FormatOptions])

# 进入 np.printoptions() 上下文管理器,使用 with 语句
with np.printoptions() as dct:
    # 使用 assert_type 确保上下文管理器 dct 的类型是 _FormatOptions
    assert_type(dct, _FormatOptions)

.\numpy\numpy\typing\tests\data\reveal\arraysetops.pyi

import sys
from typing import Any  # 导入 Any 类型

import numpy as np  # 导入 NumPy 库
import numpy.typing as npt  # 导入 NumPy 类型标注模块
from numpy.lib._arraysetops_impl import (  # 导入 NumPy 库中的数组操作函数
    UniqueAllResult, UniqueCountsResult, UniqueInverseResult
)

if sys.version_info >= (3, 11):
    from typing import assert_type  # 根据 Python 版本导入不同的类型断言函数
else:
    from typing_extensions import assert_type  # 引入类型断言函数的扩展模块

AR_b: npt.NDArray[np.bool]  # 定义布尔类型的 NumPy 数组标注
AR_i8: npt.NDArray[np.int64]  # 定义 int64 类型的 NumPy 数组标注
AR_f8: npt.NDArray[np.float64]  # 定义 float64 类型的 NumPy 数组标注
AR_M: npt.NDArray[np.datetime64]  # 定义 datetime64 类型的 NumPy 数组标注
AR_O: npt.NDArray[np.object_]  # 定义 object 类型的 NumPy 数组标注

AR_LIKE_f8: list[float]  # 定义元素类型为 float 的列表

assert_type(np.ediff1d(AR_b), npt.NDArray[np.int8])  # 断言 ediff1d 函数返回类型为 int8 的 NumPy 数组
assert_type(np.ediff1d(AR_i8, to_end=[1, 2, 3]), npt.NDArray[np.int64])  # 断言 ediff1d 函数返回类型为 int64 的 NumPy 数组
assert_type(np.ediff1d(AR_M), npt.NDArray[np.timedelta64])  # 断言 ediff1d 函数返回类型为 timedelta64 的 NumPy 数组
assert_type(np.ediff1d(AR_O), npt.NDArray[np.object_])  # 断言 ediff1d 函数返回类型为 object 的 NumPy 数组
assert_type(np.ediff1d(AR_LIKE_f8, to_begin=[1, 1.5]), npt.NDArray[Any])  # 断言 ediff1d 函数返回类型为 Any 的 NumPy 数组

assert_type(np.intersect1d(AR_i8, AR_i8), npt.NDArray[np.int64])  # 断言 intersect1d 函数返回类型为 int64 的 NumPy 数组
assert_type(np.intersect1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])  # 断言 intersect1d 函数返回类型为 datetime64 的 NumPy 数组
assert_type(np.intersect1d(AR_f8, AR_i8), npt.NDArray[Any])  # 断言 intersect1d 函数返回类型为 Any 的 NumPy 数组
assert_type(np.intersect1d(AR_f8, AR_f8, return_indices=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])  # 断言 intersect1d 函数返回元组,包含三个 NumPy 数组类型

assert_type(np.setxor1d(AR_i8, AR_i8), npt.NDArray[np.int64])  # 断言 setxor1d 函数返回类型为 int64 的 NumPy 数组
assert_type(np.setxor1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])  # 断言 setxor1d 函数返回类型为 datetime64 的 NumPy 数组
assert_type(np.setxor1d(AR_f8, AR_i8), npt.NDArray[Any])  # 断言 setxor1d 函数返回类型为 Any 的 NumPy 数组

assert_type(np.isin(AR_i8, AR_i8), npt.NDArray[np.bool])  # 断言 isin 函数返回类型为 bool 的 NumPy 数组
assert_type(np.isin(AR_M, AR_M, assume_unique=True), npt.NDArray[np.bool])  # 断言 isin 函数返回类型为 bool 的 NumPy 数组
assert_type(np.isin(AR_f8, AR_i8), npt.NDArray[np.bool])  # 断言 isin 函数返回类型为 bool 的 NumPy 数组
assert_type(np.isin(AR_f8, AR_LIKE_f8, invert=True), npt.NDArray[np.bool])  # 断言 isin 函数返回类型为 bool 的 NumPy 数组

assert_type(np.union1d(AR_i8, AR_i8), npt.NDArray[np.int64])  # 断言 union1d 函数返回类型为 int64 的 NumPy 数组
assert_type(np.union1d(AR_M, AR_M), npt.NDArray[np.datetime64])  # 断言 union1d 函数返回类型为 datetime64 的 NumPy 数组
assert_type(np.union1d(AR_f8, AR_i8), npt.NDArray[Any])  # 断言 union1d 函数返回类型为 Any 的 NumPy 数组

assert_type(np.setdiff1d(AR_i8, AR_i8), npt.NDArray[np.int64])  # 断言 setdiff1d 函数返回类型为 int64 的 NumPy 数组
assert_type(np.setdiff1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])  # 断言 setdiff1d 函数返回类型为 datetime64 的 NumPy 数组
assert_type(np.setdiff1d(AR_f8, AR_i8), npt.NDArray[Any])  # 断言 setdiff1d 函数返回类型为 Any 的 NumPy 数组

assert_type(np.unique(AR_f8), npt.NDArray[np.float64])  # 断言 unique 函数返回类型为 float64 的 NumPy 数组
assert_type(np.unique(AR_LIKE_f8, axis=0), npt.NDArray[Any])  # 断言 unique 函数返回类型为 Any 的 NumPy 数组
assert_type(np.unique(AR_f8, return_index=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_LIKE_f8, return_index=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_f8, return_inverse=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_LIKE_f8, return_inverse=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_f8, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_LIKE_f8, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含两个 NumPy 数组类型
assert_type(np.unique(AR_f8, return_index=True, return_inverse=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])  # 断言 unique 函数返回元组,包含三个 NumPy 数组类型
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_f8, return_index=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_f8, return_inverse=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_LIKE_f8, return_inverse=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_f8, return_index=True, return_inverse=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp], npt.NDArray[np.intp]])
# 断言调用 np.unique 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp], npt.NDArray[np.intp]])

# 断言调用 np.unique_all 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_all(AR_f8), UniqueAllResult[np.float64])
# 断言调用 np.unique_all 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_all(AR_LIKE_f8), UniqueAllResult[Any])
# 断言调用 np.unique_counts 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_counts(AR_f8), UniqueCountsResult[np.float64])
# 断言调用 np.unique_counts 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_counts(AR_LIKE_f8), UniqueCountsResult[Any])
# 断言调用 np.unique_inverse 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_inverse(AR_f8), UniqueInverseResult[np.float64])
# 断言调用 np.unique_inverse 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_inverse(AR_LIKE_f8), UniqueInverseResult[Any])
# 断言调用 np.unique_values 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_values(AR_f8), npt.NDArray[np.float64])
# 断言调用 np.unique_values 函数,并验证返回结果的类型符合指定的类型
assert_type(np.unique_values(AR_LIKE_f8), npt.NDArray[Any])

.\numpy\numpy\typing\tests\data\reveal\arrayterator.pyi

import sys
from typing import Any  # 导入 Any 类型用于泛型
from collections.abc import Generator  # 导入 Generator 类型用于定义生成器对象

import numpy as np  # 导入 NumPy 库并用 np 别名表示
import numpy.typing as npt  # 导入 NumPy 的类型提示模块

if sys.version_info >= (3, 11):
    from typing import assert_type  # 根据 Python 版本导入 assert_type 函数
else:
    from typing_extensions import assert_type  # 使用 typing_extensions 模块导入 assert_type 函数

AR_i8: npt.NDArray[np.int64]  # 声明 AR_i8 变量为 NumPy 的 int64 类型数组
ar_iter = np.lib.Arrayterator(AR_i8)  # 使用 AR_i8 创建一个数组迭代器对象

assert_type(ar_iter.var, npt.NDArray[np.int64])  # 断言 ar_iter.var 的类型为 int64 类型的 NumPy 数组
assert_type(ar_iter.buf_size, None | int)  # 断言 ar_iter.buf_size 的类型可以是 None 或者 int
assert_type(ar_iter.start, list[int])  # 断言 ar_iter.start 的类型为 int 类型的列表
assert_type(ar_iter.stop, list[int])  # 断言 ar_iter.stop 的类型为 int 类型的列表
assert_type(ar_iter.step, list[int])  # 断言 ar_iter.step 的类型为 int 类型的列表
assert_type(ar_iter.shape, tuple[int, ...])  # 断言 ar_iter.shape 的类型为不定长的 int 类型元组
assert_type(ar_iter.flat, Generator[np.int64, None, None])  # 断言 ar_iter.flat 的类型为生成器,生成 int64 类型的数据

assert_type(ar_iter.__array__(), npt.NDArray[np.int64])  # 断言 ar_iter.__array__() 方法返回的类型为 int64 类型的 NumPy 数组

for i in ar_iter:  # 迭代 ar_iter 中的元素
    assert_type(i, npt.NDArray[np.int64])  # 断言每个迭代出的 i 的类型为 int64 类型的 NumPy 数组

assert_type(ar_iter[0], np.lib.Arrayterator[Any, np.dtype[np.int64]])  # 断言 ar_iter[0] 的类型为 Arrayterator 对象
assert_type(ar_iter[...], np.lib.Arrayterator[Any, np.dtype[np.int64]])  # 断言 ar_iter[...] 的类型为 Arrayterator 对象
assert_type(ar_iter[:], np.lib.Arrayterator[Any, np.dtype[np.int64]])  # 断言 ar_iter[:] 的类型为 Arrayterator 对象
assert_type(ar_iter[0, 0, 0], np.lib.Arrayterator[Any, np.dtype[np.int64]])  # 断言 ar_iter[0, 0, 0] 的类型为 Arrayterator 对象
assert_type(ar_iter[..., 0, :], np.lib.Arrayterator[Any, np.dtype[np.int64]])  # 断言 ar_iter[..., 0, :] 的类型为 Arrayterator 对象

.\numpy\numpy\typing\tests\data\reveal\array_api_info.pyi

# 导入系统相关的模块
import sys
# 导入 List 类型的泛型支持
from typing import List

# 导入 numpy 库,并重命名为 np
import numpy as np

# 根据 Python 版本导入对应的 assert_type 函数
if sys.version_info >= (3, 11):
    from typing import assert_type
else:
    from typing_extensions import assert_type

# 获取 numpy 库中的 __array_namespace_info__ 函数返回的对象
array_namespace_info = np.__array_namespace_info__()

# 使用 assert_type 函数确认 array_namespace_info.__module__ 是字符串类型
assert_type(array_namespace_info.__module__, str)
# 使用 assert_type 函数确认 array_namespace_info.capabilities() 返回的类型
assert_type(array_namespace_info.capabilities(), np._array_api_info.Capabilities)
# 使用 assert_type 函数确认 array_namespace_info.default_device() 返回的默认设备是字符串类型
assert_type(array_namespace_info.default_device(), str)
# 使用 assert_type 函数确认 array_namespace_info.default_dtypes() 返回的默认数据类型集合类型
assert_type(array_namespace_info.default_dtypes(), np._array_api_info.DefaultDataTypes)
# 使用 assert_type 函数确认 array_namespace_info.dtypes() 返回的数据类型集合类型
assert_type(array_namespace_info.dtypes(), np._array_api_info.DataTypes)
# 使用 assert_type 函数确认 array_namespace_info.devices() 返回的设备列表类型
assert_type(array_namespace_info.devices(), List[str])

.\numpy\numpy\typing\tests\data\reveal\array_constructors.pyi

import sys
from typing import Any, TypeVar
from pathlib import Path
from collections import deque

import numpy as np
import numpy.typing as npt

# 导入 assert_type 函数,根据 Python 版本不同选择不同的来源
if sys.version_info >= (3, 11):
    from typing import assert_type
else:
    from typing_extensions import assert_type

# 定义泛型类型变量 _SCT,继承自 np.generic 类型,是协变的
_SCT = TypeVar("_SCT", bound=np.generic, covariant=True)

# 定义一个子类 SubClass,继承自 npt.NDArray[_SCT] 类型
class SubClass(npt.NDArray[_SCT]): ...

# 定义一个变量 i8,类型为 np.int64
i8: np.int64

# 定义变量 A,类型为 npt.NDArray[np.float64]
A: npt.NDArray[np.float64]

# 定义变量 B,类型为 SubClass[np.float64]
B: SubClass[np.float64]

# 定义变量 C,类型为 list[int]
C: list[int]

# 定义函数 func,接受两个整数参数 i 和 j,以及任意关键字参数,返回类型为 SubClass[np.float64]
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...

# 对 np.empty_like(A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.empty_like(A), npt.NDArray[np.float64])

# 对 np.empty_like(B) 的返回类型进行断言,应为 SubClass[np.float64]
assert_type(np.empty_like(B), SubClass[np.float64])

# 对 np.empty_like([1, 1.0]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.empty_like([1, 1.0]), npt.NDArray[Any])

# 对 np.empty_like(A, dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.empty_like(A, dtype=np.int64), npt.NDArray[np.int64])

# 对 np.empty_like(A, dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.empty_like(A, dtype='c16'), npt.NDArray[Any])

# 对 np.array(A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.array(A), npt.NDArray[np.float64])

# 对 np.array(B) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.array(B), npt.NDArray[np.float64])

# 对 np.array(B, subok=True) 的返回类型进行断言,应为 SubClass[np.float64]
assert_type(np.array(B, subok=True), SubClass[np.float64])

# 对 np.array([1, 1.0]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.array([1, 1.0]), npt.NDArray[Any])

# 对 np.array(deque([1, 2, 3])) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.array(deque([1, 2, 3])), npt.NDArray[Any])

# 对 np.array(A, dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.array(A, dtype=np.int64), npt.NDArray[np.int64])

# 对 np.array(A, dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.array(A, dtype='c16'), npt.NDArray[Any])

# 对 np.array(A, like=A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.array(A, like=A), npt.NDArray[np.float64])

# 对 np.zeros([1, 5, 6]) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.zeros([1, 5, 6]), npt.NDArray[np.float64])

# 对 np.zeros([1, 5, 6], dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.zeros([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])

# 对 np.zeros([1, 5, 6], dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.zeros([1, 5, 6], dtype='c16'), npt.NDArray[Any])

# 对 np.empty([1, 5, 6]) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.empty([1, 5, 6]), npt.NDArray[np.float64])

# 对 np.empty([1, 5, 6], dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.empty([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])

# 对 np.empty([1, 5, 6], dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.empty([1, 5, 6], dtype='c16'), npt.NDArray[Any])

# 对 np.concatenate(A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.concatenate(A), npt.NDArray[np.float64])

# 对 np.concatenate([A, A]) 的返回类型进行断言,类型不确定,断言为 Any
assert_type(np.concatenate([A, A]), Any)

# 对 np.concatenate([[1], A]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.concatenate([[1], A]), npt.NDArray[Any])

# 对 np.concatenate([[1], [1]]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.concatenate([[1], [1]]), npt.NDArray[Any])

# 对 np.concatenate((A, A)) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.concatenate((A, A)), npt.NDArray[np.float64])

# 对 np.concatenate(([1], [1])) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.concatenate(([1], [1])), npt.NDArray[Any])

# 对 np.concatenate([1, 1.0]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.concatenate([1, 1.0]), npt.NDArray[Any])

# 对 np.concatenate(A, dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.concatenate(A, dtype=np.int64), npt.NDArray[np.int64])

# 对 np.concatenate(A, dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.concatenate(A, dtype='c16'), npt.NDArray[Any])

# 对 np.concatenate([1, 1.0], out=A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.concatenate([1, 1.0], out=A), npt.NDArray[np.float64])

# 对 np.asarray(A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.asarray(A), npt.NDArray[np.float64])

# 对 np.asarray(B) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.asarray(B), npt.NDArray[np.float64])

# 对 np.asarray([1, 1.0]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.asarray([1, 1.0]), npt.NDArray[Any])

# 对 np.asarray(A, dtype=np.int64) 的返回类型进行断言,应为 npt.NDArray[np.int64]
assert_type(np.asarray(A, dtype=np.int64), npt.NDArray[np.int64])

# 对 np.asarray(A, dtype='c16') 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.asarray(A, dtype='c16'), npt.NDArray[Any])

# 对 np.asanyarray(A) 的返回类型进行断言,应为 npt.NDArray[np.float64]
assert_type(np.asanyarray(A), npt.NDArray[np.float64])

# 对 np.asanyarray(B) 的返回类型进行断言,应为 SubClass[np.float64]
assert_type(np.asanyarray(B), SubClass[np.float64])

# 对 np.asanyarray([1, 1.0]) 的返回类型进行断言,应为 npt.NDArray[Any]
assert_type(np.asanyarray([1,
# 使用 np.ascontiguousarray 函数将数组 A 转换为连续的内存布局,并指定数据类型为 np.int64,然后进行类型断言
assert_type(np.ascontiguousarray(A, dtype=np.int64), npt.NDArray[np.int64])

# 使用 np.ascontiguousarray 函数将数组 A 转换为连续的内存布局,并指定数据类型为 'c16'(复数类型),然后进行类型断言
assert_type(np.ascontiguousarray(A, dtype='c16'), npt.NDArray[Any])

# 使用 np.asfortranarray 函数将数组 A 转换为 Fortran 风格的内存布局,并进行类型断言
assert_type(np.asfortranarray(A), npt.NDArray[np.float64])

# 使用 np.asfortranarray 函数将数组 B 转换为 Fortran 风格的内存布局,并进行类型断言
assert_type(np.asfortranarray(B), npt.NDArray[np.float64])

# 使用 np.asfortranarray 函数将列表 [1, 1.0] 转换为 Fortran 风格的内存布局,并进行类型断言
assert_type(np.asfortranarray([1, 1.0]), npt.NDArray[Any])

# 使用 np.asfortranarray 函数将数组 A 转换为 Fortran 风格的内存布局,并指定数据类型为 np.int64,然后进行类型断言
assert_type(np.asfortranarray(A, dtype=np.int64), npt.NDArray[np.int64])

# 使用 np.asfortranarray 函数将数组 A 转换为 Fortran 风格的内存布局,并指定数据类型为 'c16'(复数类型),然后进行类型断言
assert_type(np.asfortranarray(A, dtype='c16'), npt.NDArray[Any])

# 使用 np.fromstring 函数从字符串 "1 1 1" 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromstring("1 1 1", sep=" "), npt.NDArray[np.float64])

# 使用 np.fromstring 函数从字节串 b"1 1 1" 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromstring(b"1 1 1", sep=" "), npt.NDArray[np.float64])

# 使用 np.fromstring 函数从字符串 "1 1 1" 中按照空格分隔解析出 np.int64 类型的数组,并进行类型断言
assert_type(np.fromstring("1 1 1", dtype=np.int64, sep=" "), npt.NDArray[np.int64])

# 使用 np.fromstring 函数从字节串 b"1 1 1" 中按照空格分隔解析出 np.int64 类型的数组,并进行类型断言
assert_type(np.fromstring(b"1 1 1", dtype=np.int64, sep=" "), npt.NDArray[np.int64])

# 使用 np.fromstring 函数从字符串 "1 1 1" 中按照空格分隔解析出 dtype 为 'c16'(复数类型)的数组,并进行类型断言
assert_type(np.fromstring("1 1 1", dtype="c16", sep=" "), npt.NDArray[Any])

# 使用 np.fromstring 函数从字节串 b"1 1 1" 中按照空格分隔解析出 dtype 为 'c16'(复数类型)的数组,并进行类型断言
assert_type(np.fromstring(b"1 1 1", dtype="c16", sep=" "), npt.NDArray[Any])

# 使用 np.fromfile 函数从文件 "test.txt" 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromfile("test.txt", sep=" "), npt.NDArray[np.float64])

# 使用 np.fromfile 函数从文件 "test.txt" 中按照空格分隔解析出 dtype 为 np.int64 的数组,并进行类型断言
assert_type(np.fromfile("test.txt", dtype=np.int64, sep=" "), npt.NDArray[np.int64])

# 使用 np.fromfile 函数从文件 "test.txt" 中按照空格分隔解析出 dtype 为 'c16'(复数类型)的数组,并进行类型断言
assert_type(np.fromfile("test.txt", dtype="c16", sep=" "), npt.NDArray[Any])

# 使用 np.fromfile 函数从文件对象 f 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
with open("test.txt") as f:
    assert_type(np.fromfile(f, sep=" "), npt.NDArray[np.float64])

# 使用 np.fromfile 函数从字节串 b"test.txt" 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromfile(b"test.txt", sep=" "), npt.NDArray[np.float64])

# 使用 np.fromfile 函数从路径对象 Path("test.txt") 中按照空格分隔解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromfile(Path("test.txt"), sep=" "), npt.NDArray[np.float64])

# 使用 np.fromiter 函数从字符串 "12345" 中迭代解析出 np.float64 类型的数组,并进行类型断言
assert_type(np.fromiter("12345", np.float64), npt.NDArray[np.float64])

# 使用 np.fromiter 函数从字符串 "12345" 中迭代解析出 float 类型的数组,并进行类型断言
assert_type(np.fromiter("12345", float), npt.NDArray[Any])

# 使用 np.frombuffer 函数从数组 A 的缓冲区创建 np.float64 类型的数组,并进行类型断言
assert_type(np.frombuffer(A), npt.NDArray[np.float64])

# 使用 np.frombuffer 函数从数组 A 的缓冲区创建 dtype 为 np.int64 的数组,并进行类型断言
assert_type(np.frombuffer(A, dtype=np.int64), npt.NDArray[np.int64])

# 使用 np.frombuffer 函数从数组 A 的缓冲区创建 dtype 为 'c16'(复数类型)的数组,并进行类型断言
assert_type(np.frombuffer(A, dtype="c16"), npt.NDArray[Any])

# 使用 np.arange 函数生成一个从 False 到 True 的整数序列,并进行类型断言
assert_type(np.arange(False, True), npt.NDArray[np.signedinteger[Any]])

# 使用 np.arange 函数生成一个从 0 到 9 的整数序列,并进行类型断言
assert_type(np.arange(10), npt.NDArray[np.signedinteger[Any]])

# 使用 np.arange 函数生成一个从 0 到 10,步长为 2 的整数序列,并进行类型断言
assert_type(np.arange(0, 10, step=2), npt.NDArray[np.signedinteger[Any]])

# 使用 np.arange 函数生成一个从 0.0 到 9.0 的浮点数序列,并进行类型断言
assert_type(np.arange(10.0), npt.NDArray[np.floating[Any]])

# 使用 np.arange 函数生成一个从 0 到 9.0 的浮点数序列,并进行类型断言
assert_type(np.arange(start=0, stop=10.0), npt.NDArray[np.floating[Any]])

# 使用 np.arange 函数生成一个从 np.timedelta64(0) 开始到 np.timedelta64(10) 结束的时间序列,并进行类型断言
assert_type(np.arange(np.timedelta64(0)), npt.NDArray[np.timedelta64])

# 使用 np.arange 函数生成一个从 0 到 np.timedelta64(10) 的时间序列,并进行类型断言
assert_type(np.arange(0, np.timedelta64(10)), npt.NDArray[np.timedelta64])

# 使用 np.arange 函数生成一个从 np.datetime64("0") 到 np.datetime64("10") 的日期时间序列,并进行类型断言
assert_type(np.arange(np.datetime64("0"), np.datetime64("10")), npt.NDArray[np.datetime64])

# 使用 np.arange 函数生成一个从 0 到 9 的浮点数序列,并指定数据类型为 np.float64,并进行类型断言
assert_type(np.arange(10, dtype=np.float64), npt.NDArray[np.float64])

# 使用 np.arange 函数生成一个从 0 到 10,步长为 2 的整数序列,并指定数据类型为 np.int16,并进行类型断言
assert_type(np.arange(0, 10, step=2, dtype=np.int16), n
# 确保数组 B 满足指定的要求,返回类型为 npt.NDArray[Any]
assert_type(np.require(B, requirements={"F", "E"}), npt.NDArray[Any])

# 确保数组 B 满足指定的要求,返回类型为 SubClass[np.float64]
assert_type(np.require(B, requirements=["C", "OWNDATA"]), SubClass[np.float64])

# 确保数组 B 满足指定的要求,返回类型为 SubClass[np.float64]
assert_type(np.require(B, requirements="W"), SubClass[np.float64])

# 确保数组 B 满足指定的要求,返回类型为 SubClass[np.float64]
assert_type(np.require(B, requirements="A"), SubClass[np.float64])

# 确保数组 C 满足默认要求,返回类型为 npt.NDArray[Any]
assert_type(np.require(C), npt.NDArray[Any])

# 生成一个包含从 0 到 10 的均匀间隔的数组,返回类型为 npt.NDArray[np.floating[Any]]
assert_type(np.linspace(0, 10), npt.NDArray[np.floating[Any]])

# 生成一个包含从 0 到 10j(虚数单位)的均匀间隔的数组,返回类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(np.linspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])

# 生成一个包含从 0 到 10 的均匀间隔的数组,元素类型为 np.int64,返回类型为 npt.NDArray[np.int64]
assert_type(np.linspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])

# 生成一个包含从 0 到 10 的均匀间隔的数组,元素类型为 int(默认为 float),返回类型为 npt.NDArray[Any]
assert_type(np.linspace(0, 10, dtype=int), npt.NDArray[Any])

# 生成一个包含从 0 到 10 的均匀间隔的数组,并返回结果和步长的元组,结果类型为 npt.NDArray[np.floating[Any]],步长类型为 np.floating[Any]
assert_type(np.linspace(0, 10, retstep=True), tuple[npt.NDArray[np.floating[Any]], np.floating[Any]])

# 生成一个包含从 0j(虚数单位)到 10 的均匀间隔的数组,并返回结果和步长的元组,结果类型为 npt.NDArray[np.complexfloating[Any, Any]],步长类型为 np.complexfloating[Any, Any]
assert_type(np.linspace(0j, 10, retstep=True), tuple[npt.NDArray[np.complexfloating[Any, Any]], np.complexfloating[Any, Any]])

# 生成一个包含从 0 到 10 的均匀间隔的数组,并返回结果和步长的元组,结果类型为 npt.NDArray[np.int64],步长类型为 np.int64
assert_type(np.linspace(0, 10, retstep=True, dtype=np.int64), tuple[npt.NDArray[np.int64], np.int64])

# 生成一个包含从 0j(虚数单位)到 10 的均匀间隔的数组,并返回结果和步长的元组,结果类型为 npt.NDArray[Any],步长类型为 Any(默认为 complex)
assert_type(np.linspace(0j, 10, retstep=True, dtype=int), tuple[npt.NDArray[Any], Any])

# 生成一个包含从 0 到 10 的对数间隔的数组,返回类型为 npt.NDArray[np.floating[Any]]
assert_type(np.logspace(0, 10), npt.NDArray[np.floating[Any]])

# 生成一个包含从 0 到 10j(虚数单位)的对数间隔的数组,返回类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(np.logspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])

# 生成一个包含从 0 到 10 的对数间隔的数组,元素类型为 np.int64,返回类型为 npt.NDArray[np.int64]
assert_type(np.logspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])

# 生成一个包含从 0 到 10 的对数间隔的数组,元素类型为 int(默认为 float),返回类型为 npt.NDArray[Any]
assert_type(np.logspace(0, 10, dtype=int), npt.NDArray[Any])

# 生成一个包含从 0 到 10 的几何间隔的数组,返回类型为 npt.NDArray[np.floating[Any]]
assert_type(np.geomspace(0, 10), npt.NDArray[np.floating[Any]])

# 生成一个包含从 0 到 10j(虚数单位)的几何间隔的数组,返回类型为 npt.NDArray[np.complexfloating[Any, Any]]
assert_type(np.geomspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])

# 生成一个包含从 0 到 10 的几何间隔的数组,元素类型为 np.int64,返回类型为 npt.NDArray[np.int64]
assert_type(np.geomspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])

# 生成一个包含从 0 到 10 的几何间隔的数组,元素类型为 int(默认为 float),返回类型为 npt.NDArray[Any]
assert_type(np.geomspace(0, 10, dtype=int), npt.NDArray[Any])

# 返回与数组 A 结构相同且元素全为 0 的数组,返回类型为 npt.NDArray[np.float64]
assert_type(np.zeros_like(A), npt.NDArray[np.float64])

# 返回与数组 C 结构相同且元素全为 0 的数组,返回类型为 npt.NDArray[Any]
assert_type(np.zeros_like(C), npt.NDArray[Any])

# 返回与数组 A 结构相同且元素全为 0.0 的数组,返回类型为 npt.NDArray[Any]
assert_type(np.zeros_like(A, dtype=float), npt.NDArray[Any])

# 返回与数组 B 结构相同且元素全为 0 的数组,返回类型为 SubClass[np.float64]
assert_type(np.zeros_like(B), SubClass[np.float64])

# 返回与数组 B 结构相同且元素全为 0 的数组,元素类型为 np.int64,返回类型为 npt.NDArray[np.int64]
assert_type(np.zeros_like(B, dtype=np.int64), npt.NDArray[np.int64])

# 返回与数组 A 结构相同且元素全为 1 的数组,返回类型为 npt.NDArray[np.float64]
assert_type(np.ones_like(A), npt.NDArray[np.float64])

# 返回与数组 C 结构相同且元素全为 1 的数组,返回类型为 npt.NDArray[Any]
assert_type(np.ones_like(C), npt.NDArray[Any])

# 返回与数组 A 结构相同且元素全为 1.0 的数组,返回类型为 npt.NDArray[Any]
assert_type(np.ones_like(A, dtype=float), npt.NDArray[Any])

# 返回与数组 B 结构相同且元素全为 1 的数组,返回类型为 SubClass[np.float64]
assert_type(np.ones_like(B), SubClass[np.float64])

# 返回与数组 B 结构相同且元素全为 1 的数组,元素类型为 np.int64,返回类型为 npt.NDArray[np.int64]
assert_type(np.ones_like(B, dtype=np.int64), npt.NDArray[np.int64])

# 返回与数组 A 结构相同且元素全为 i8 的数组,元素类型为 np.float64,返回类型为 npt.NDArray[np.float64]
assert_type(np.full_like(A, i8), npt.NDArray[np.float64])

# 返回与数组 C 结构相同且元素全为 i8 的数组,返回类型为 npt.NDArray[Any]
assert_type(np.full_like(C, i8), npt.NDArray[Any])

# 返回与数组 A 结构相同且元素全为 i8 的数组,元素类型为 int,返回类型为 npt.NDArray[Any]
assert_type(np.full_like(A, i8, dtype=int), npt.NDArray[Any])

# 返回与数组 B 结构相同且元素全为 i8
# 检查 np.indices 函数返回值类型是否符合指定的 tuple 类型标注
assert_type(np.indices([1, 2, 3], sparse=True), tuple[npt.NDArray[np.int_], ...])

# 检查 np.fromfunction 函数返回值类型是否为 SubClass[np.float64]
assert_type(np.fromfunction(func, (3, 5)), SubClass[np.float64])

# 检查 np.identity 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.identity(10), npt.NDArray[np.float64])
# 检查带有 dtype 参数的 np.identity 函数返回值类型是否为 npt.NDArray[np.int64]
assert_type(np.identity(10, dtype=np.int64), npt.NDArray[np.int64])
# 检查带有 dtype 参数为 int 的 np.identity 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.identity(10, dtype=int), npt.NDArray[Any])

# 检查 np.atleast_1d 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.atleast_1d(A), npt.NDArray[np.float64])
# 检查 np.atleast_1d 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.atleast_1d(C), npt.NDArray[Any])
# 检查 np.atleast_1d 函数返回值类型是否为 tuple[npt.NDArray[Any], ...]
assert_type(np.atleast_1d(A, A), tuple[npt.NDArray[Any], ...])
# 检查 np.atleast_1d 函数返回值类型是否为 tuple[npt.NDArray[Any], ...]
assert_type(np.atleast_1d(A, C), tuple[npt.NDArray[Any], ...])
# 检查 np.atleast_1d 函数返回值类型是否为 tuple[npt.NDArray[Any], ...]
assert_type(np.atleast_1d(C, C), tuple[npt.NDArray[Any], ...])

# 检查 np.atleast_2d 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.atleast_2d(A), npt.NDArray[np.float64])
# 检查 np.atleast_2d 函数返回值类型是否为 tuple[npt.NDArray[Any], ...]
assert_type(np.atleast_2d(A, A), tuple[npt.NDArray[Any], ...])

# 检查 np.atleast_3d 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.atleast_3d(A), npt.NDArray[np.float64])
# 检查 np.atleast_3d 函数返回值类型是否为 tuple[npt.NDArray[Any], ...]
assert_type(np.atleast_3d(A, A), tuple[npt.NDArray[Any], ...])

# 检查 np.vstack 函数返回值类型是否为 np.ndarray[Any, Any]
assert_type(np.vstack([A, A]), np.ndarray[Any, Any])
# 检查 np.vstack 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.vstack([A, A], dtype=np.float64), npt.NDArray[np.float64])
# 检查 np.vstack 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.vstack([A, C]), npt.NDArray[Any])
# 检查 np.vstack 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.vstack([C, C]), npt.NDArray[Any])

# 检查 np.hstack 函数返回值类型是否为 np.ndarray[Any, Any]
assert_type(np.hstack([A, A]), np.ndarray[Any, Any])
# 检查 np.hstack 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.hstack([A, A], dtype=np.float64), npt.NDArray[np.float64])

# 检查 np.stack 函数返回值类型是否为 Any
assert_type(np.stack([A, A]), Any)
# 检查 np.stack 函数返回值类型是否为 npt.NDArray[np.float64]
assert_type(np.stack([A, A], dtype=np.float64), npt.NDArray[np.float64])
# 检查 np.stack 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.stack([A, C]), npt.NDArray[Any])
# 检查 np.stack 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.stack([C, C]), npt.NDArray[Any])
# 检查 np.stack 函数返回值类型是否为 Any
assert_type(np.stack([A, A], axis=0), Any)
# 检查 np.stack 函数返回值类型是否为 SubClass[np.float64]
assert_type(np.stack([A, A], out=B), SubClass[np.float64])

# 检查 np.block 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.block([[A, A], [A, A]]), npt.NDArray[Any])
# 检查 np.block 函数返回值类型是否为 npt.NDArray[Any]
assert_type(np.block(C), npt.NDArray[Any])

# 检查如果 Python 版本大于等于 3.12,则导入 Buffer 类型
if sys.version_info >= (3, 12):
    from collections.abc import Buffer

    # 定义函数 create_array,接受 npt.ArrayLike 类型参数,返回 npt.NDArray[Any]
    def create_array(obj: npt.ArrayLike) -> npt.NDArray[Any]: ...

    # 定义变量 buffer 类型为 Buffer
    buffer: Buffer
    # 检查 create_array 函数返回值类型是否为 npt.NDArray[Any]
    assert_type(create_array(buffer), npt.NDArray[Any])

.\numpy\numpy\typing\tests\data\reveal\bitwise_ops.pyi

import sys
from typing import Any  # 导入 Any 类型

import numpy as np  # 导入 NumPy 库
import numpy.typing as npt  # 导入 NumPy 的类型注解模块
from numpy._typing import _64Bit, _32Bit  # 导入 64 位和 32 位整数类型注解

if sys.version_info >= (3, 11):
    from typing import assert_type  # 如果 Python 版本大于等于 3.11,则使用标准库中的 assert_type
else:
    from typing_extensions import assert_type  # 否则,从 typing_extensions 中导入 assert_type

i8 = np.int64(1)  # 创建一个 NumPy 的 64 位有符号整数对象
u8 = np.uint64(1)  # 创建一个 NumPy 的 64 位无符号整数对象

i4 = np.int32(1)  # 创建一个 NumPy 的 32 位有符号整数对象
u4 = np.uint32(1)  # 创建一个 NumPy 的 32 位无符号整数对象

b_ = np.bool(1)  # 创建一个 NumPy 的布尔类型对象

b = bool(1)  # 创建一个 Python 内置的布尔类型对象
i = int(1)  # 创建一个 Python 内置的整数对象

AR = np.array([0, 1, 2], dtype=np.int32)  # 创建一个 NumPy 的整数数组对象,数据类型为 32 位有符号整数
AR.setflags(write=False)  # 设置数组为只读模式,禁止写入操作

# 下面是一系列的类型断言,用来验证不同操作的返回类型

assert_type(i8 << i8, np.int64)  # 断言 i8 左移 i8 的结果为 64 位有符号整数类型
assert_type(i8 >> i8, np.int64)  # 断言 i8 右移 i8 的结果为 64 位有符号整数类型
assert_type(i8 | i8, np.int64)  # 断言 i8 按位或 i8 的结果为 64 位有符号整数类型
assert_type(i8 ^ i8, np.int64)  # 断言 i8 按位异或 i8 的结果为 64 位有符号整数类型
assert_type(i8 & i8, np.int64)  # 断言 i8 按位与 i8 的结果为 64 位有符号整数类型

assert_type(i8 << AR, npt.NDArray[np.signedinteger[Any]])  # 断言 i8 左移 AR 数组的结果为特定类型的 NumPy 数组
assert_type(i8 >> AR, npt.NDArray[np.signedinteger[Any]])  # 断言 i8 右移 AR 数组的结果为特定类型的 NumPy 数组
assert_type(i8 | AR, npt.NDArray[np.signedinteger[Any]])  # 断言 i8 按位或 AR 数组的结果为特定类型的 NumPy 数组
assert_type(i8 ^ AR, npt.NDArray[np.signedinteger[Any]])  # 断言 i8 按位异或 AR 数组的结果为特定类型的 NumPy 数组
assert_type(i8 & AR, npt.NDArray[np.signedinteger[Any]])  # 断言 i8 按位与 AR 数组的结果为特定类型的 NumPy 数组

assert_type(i4 << i4, np.int32)  # 断言 i4 左移 i4 的结果为 32 位有符号整数类型
assert_type(i4 >> i4, np.int32)  # 断言 i4 右移 i4 的结果为 32 位有符号整数类型
assert_type(i4 | i4, np.int32)  # 断言 i4 按位或 i4 的结果为 32 位有符号整数类型
assert_type(i4 ^ i4, np.int32)  # 断言 i4 按位异或 i4 的结果为 32 位有符号整数类型
assert_type(i4 & i4, np.int32)  # 断言 i4 按位与 i4 的结果为 32 位有符号整数类型

assert_type(i8 << i4, np.signedinteger[_32Bit | _64Bit])  # 断言 i8 左移 i4 的结果为特定类型的 NumPy 数组
assert_type(i8 >> i4, np.signedinteger[_32Bit | _64Bit])  # 断言 i8 右移 i4 的结果为特定类型的 NumPy 数组
assert_type(i8 | i4, np.signedinteger[_32Bit | _64Bit])  # 断言 i8 按位或 i4 的结果为特定类型的 NumPy 数组
assert_type(i8 ^ i4, np.signedinteger[_32Bit | _64Bit])  # 断言 i8 按位异或 i4 的结果为特定类型的 NumPy 数组
assert_type(i8 & i4, np.signedinteger[_32Bit | _64Bit])  # 断言 i8 按位与 i4 的结果为特定类型的 NumPy 数组

assert_type(i8 << b_, np.int64)  # 断言 i8 左移 b_ 的结果为 64 位有符号整数类型
assert_type(i8 >> b_, np.int64)  # 断言 i8 右移 b_ 的结果为 64 位有符号整数类型
assert_type(i8 | b_, np.int64)  # 断言 i8 按位或 b_ 的结果为 64 位有符号整数类型
assert_type(i8 ^ b_, np.int64)  # 断言 i8 按位异或 b_ 的结果为 64 位有符号整数类型
assert_type(i8 & b_, np.int64)  # 断言 i8 按位与 b_ 的结果为 64 位有符号整数类型

assert_type(i8 << b, np.int64)  # 断言 i8 左移 b 的结果为 64 位有符号整数类型
assert_type(i8 >> b, np.int64)  # 断言 i8 右移 b 的结果为 64 位有符号整数类型
assert_type(i8 | b, np.int64)  # 断言 i8 按位或 b 的结果为 64 位有符号整数类型
assert_type(i8 ^ b, np.int64)  # 断言 i8 按位异或 b 的结果为 64 位有符号整数类型
assert_type(i8 & b, np.int64)  # 断言 i8 按位与 b 的结果为 64 位有符号整数类型

assert_type(u8 << u8, np.uint64)  # 断言 u8 左移 u8 的结果为 64 位无符号整数类型
assert_type(u8 >> u8, np.uint64)  # 断言 u8 右移 u8 的结果为 64 位无符号整数类型
assert_type(u8 | u8, np.uint64)  # 断言 u8 按位或 u8 的结果为 64 位无符号整数类型
assert_type(u8 ^ u8, np.uint64)  # 断言 u8 按位异或 u8 的结果为 64 位无符号整数类型
assert_type(u8 & u8, np.uint64)  # 断言 u8 按位与 u8 的结果为 64 位无符号整数类型

assert_type(u8 << AR, npt.NDArray[np.signedinteger[Any]])  # 断言 u8 左移 AR 数组的结果为特定类型的 NumPy 数组
assert_type(u8 >> AR, npt.NDArray[np.signedinteger[Any]])  # 断言 u8 右移 AR 数组的结果为特定类型的 NumPy 数组
assert_type(u8 | AR, npt.NDArray[np.signedinteger[Any]])  # 断言 u8 按位或 AR 数组的结果为特定类型的 NumPy 数组
assert_type(u8 ^ AR, npt.NDArray[np.signedinteger[Any]])  # 断言 u8 按位异或 AR 数组的结果为特定类型的 NumPy 数组
assert_type(u8 & AR, npt.NDArray[np.signedinteger[Any]])  # 断言 u8 按位与 AR 数组的结果为特定类型的 NumPy 数
# 对比两者进行左移位运算,断言结果类型为 np.int8
assert_type(b_ << b_, np.int8)
# 对比两者进行右移位运算,断言结果类型为 np.int8
assert_type(b_ >> b_, np.int8)
# 对比两者进行按位或运算,断言结果类型为 np.bool
assert_type(b_ | b_, np.bool)
# 对比两者进行按位异或运算,断言结果类型为 np.bool
assert_type(b_ ^ b_, np.bool)
# 对比两者进行按位与运算,断言结果类型为 np.bool
assert_type(b_ & b_, np.bool)

# 对比一个变量与数组元素进行左移位运算,断言结果类型为指定数组的有符号整数类型
assert_type(b_ << AR, npt.NDArray[np.signedinteger[Any]])
# 对比一个变量与数组元素进行右移位运算,断言结果类型为指定数组的有符号整数类型
assert_type(b_ >> AR, npt.NDArray[np.signedinteger[Any]])
# 对比一个变量与数组元素进行按位或运算,断言结果类型为指定数组的有符号整数类型
assert_type(b_ | AR, npt.NDArray[np.signedinteger[Any]])
# 对比一个变量与数组元素进行按位异或运算,断言结果类型为指定数组的有符号整数类型
assert_type(b_ ^ AR, npt.NDArray[np.signedinteger[Any]])
# 对比一个变量与数组元素进行按位与运算,断言结果类型为指定数组的有符号整数类型
assert_type(b_ & AR, npt.NDArray[np.signedinteger[Any]])

# 对比两者进行左移位运算,断言结果类型为 np.int8
assert_type(b_ << b, np.int8)
# 对比两者进行右移位运算,断言结果类型为 np.int8
assert_type(b_ >> b, np.int8)
# 对比两者进行按位或运算,断言结果类型为 np.bool
assert_type(b_ | b, np.bool)
# 对比两者进行按位异或运算,断言结果类型为 np.bool
assert_type(b_ ^ b, np.bool)
# 对比两者进行按位与运算,断言结果类型为 np.bool
assert_type(b_ & b, np.bool)

# 对比一个变量与整数进行左移位运算,断言结果类型为 np.int_
assert_type(b_ << i, np.int_)
# 对比一个变量与整数进行右移位运算,断言结果类型为 np.int_
assert_type(b_ >> i, np.int_)
# 对比一个变量与整数进行按位或运算,断言结果类型为 np.int_
assert_type(b_ | i, np.int_)
# 对比一个变量与整数进行按位异或运算,断言结果类型为 np.int_
assert_type(b_ ^ i, np.int_)
# 对比一个变量与整数进行按位与运算,断言结果类型为 np.int_
assert_type(b_ & i, np.int_)

# 对比取反运算,断言结果类型为 np.int64
assert_type(~i8, np.int64)
# 对比取反运算,断言结果类型为 np.int32
assert_type(~i4, np.int32)
# 对比取反运算,断言结果类型为 np.uint64
assert_type(~u8, np.uint64)
# 对比取反运算,断言结果类型为 np.uint32
assert_type(~u4, np.uint32)
# 对比取反运算,断言结果类型为 np.bool
assert_type(~b_, np.bool)
# 对比取反运算,断言结果类型为指定数组的有符号整数类型
assert_type(~AR, npt.NDArray[np.int32])

.\numpy\numpy\typing\tests\data\reveal\char.pyi

import sys
from typing import Any

import numpy as np
import numpy.typing as npt

# 如果 Python 版本大于等于 3.11,使用标准库 typing 中的 assert_type 函数
if sys.version_info >= (3, 11):
    from typing import assert_type
# 否则,使用 typing_extensions 中的 assert_type 函数
else:
    from typing_extensions import assert_type

# 定义一个字符串类型的 NumPy 数组
AR_U: npt.NDArray[np.str_]
# 定义一个字节字符串类型的 NumPy 数组
AR_S: npt.NDArray[np.bytes_]

# 使用 assert_type 函数确保 np.char.equal 返回的结果是一个布尔型 NumPy 数组
assert_type(np.char.equal(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.equal(AR_S, AR_S), npt.NDArray[np.bool])

assert_type(np.char.not_equal(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.not_equal(AR_S, AR_S), npt.NDArray[np.bool])

assert_type(np.char.greater_equal(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.greater_equal(AR_S, AR_S), npt.NDArray[np.bool])

assert_type(np.char.less_equal(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.less_equal(AR_S, AR_S), npt.NDArray[np.bool])

assert_type(np.char.greater(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.greater(AR_S, AR_S), npt.NDArray[np.bool])

assert_type(np.char.less(AR_U, AR_U), npt.NDArray[np.bool])
assert_type(np.char.less(AR_S, AR_S), npt.NDArray[np.bool])

# 对字符串数组进行乘法操作,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.multiply(AR_U, 5), npt.NDArray[np.str_])
assert_type(np.char.multiply(AR_S, [5, 4, 3]), npt.NDArray[np.bytes_])

# 使用字符串格式化操作,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.mod(AR_U, "test"), npt.NDArray[np.str_])
assert_type(np.char.mod(AR_S, "test"), npt.NDArray[np.bytes_])

# 将字符串数组的每个元素首字母大写,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.capitalize(AR_U), npt.NDArray[np.str_])
assert_type(np.char.capitalize(AR_S), npt.NDArray[np.bytes_])

# 将字符串数组的每个元素居中对齐,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.center(AR_U, 5), npt.NDArray[np.str_])
assert_type(np.char.center(AR_S, [2, 3, 4], b"a"), npt.NDArray[np.bytes_])

# 将字符串数组编码为字节字符串类型的 NumPy 数组
assert_type(np.char.encode(AR_U), npt.NDArray[np.bytes_])
# 将字节字符串数组解码为字符串类型的 NumPy 数组
assert_type(np.char.decode(AR_S), npt.NDArray[np.str_])

# 将字符串数组中的制表符扩展为空格,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.expandtabs(AR_U), npt.NDArray[np.str_])
assert_type(np.char.expandtabs(AR_S, tabsize=4), npt.NDArray[np.bytes_])

# 使用指定的分隔符连接字符串数组的每个元素,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.join(AR_U, "_"), npt.NDArray[np.str_])
assert_type(np.char.join(AR_S, [b"_", b""]), npt.NDArray[np.bytes_])

# 将字符串数组的每个元素左对齐或右对齐到指定的宽度,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.ljust(AR_U, 5), npt.NDArray[np.str_])
assert_type(np.char.ljust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
assert_type(np.char.rjust(AR_U, 5), npt.NDArray[np.str_])
assert_type(np.char.rjust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])

# 移除字符串数组每个元素的开头或结尾的空白字符或指定字符,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.lstrip(AR_U), npt.NDArray[np.str_])
assert_type(np.char.lstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])
assert_type(np.char.rstrip(AR_U), npt.NDArray[np.str_])
assert_type(np.char.rstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])
assert_type(np.char.strip(AR_U), npt.NDArray[np.str_])
assert_type(np.char.strip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])

# 使用指定的分隔符分割字符串数组的每个元素,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.partition(AR_U, "\n"), npt.NDArray[np.str_])
assert_type(np.char.partition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
assert_type(np.char.rpartition(AR_U, "\n"), npt.NDArray[np.str_])
assert_type(np.char.rpartition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])

# 使用指定的字符串替换字符串数组中的指定子字符串,确保返回的结果是字符串类型的 NumPy 数组
assert_type(np.char.replace(AR_U, "_", "-"), npt.NDArray[np.str_])
# 使用 np.char.replace 函数替换 AR_S 数组中的特定字节序列,将 b"_" 替换为 b"a",b"" 替换为 b"b"
assert_type(np.char.replace(AR_S, [b"_", b""], [b"a", b"b"]), npt.NDArray[np.bytes_])

# 使用 np.char.split 函数将 AR_U 数组按照 "_" 分割,并返回分割后的对象数组
assert_type(np.char.split(AR_U, "_"), npt.NDArray[np.object_])

# 使用 np.char.split 函数将 AR_S 数组按照 maxsplit 指定的分割次数进行分割,并返回对象数组
assert_type(np.char.split(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])

# 使用 np.char.rsplit 函数将 AR_U 数组按照 "_" 分割,并返回从右侧开始的对象数组
assert_type(np.char.rsplit(AR_U, "_"), npt.NDArray[np.object_])

# 使用 np.char.rsplit 函数将 AR_S 数组按照 maxsplit 指定的分割次数从右侧开始分割,并返回对象数组
assert_type(np.char.rsplit(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])

# 使用 np.char.splitlines 函数按照行分割 AR_U 数组,并返回对象数组
assert_type(np.char.splitlines(AR_U), npt.NDArray[np.object_])

# 使用 np.char.splitlines 函数按照行分割 AR_S 数组,根据 keepends 参数保留行尾符号,并返回对象数组
assert_type(np.char.splitlines(AR_S, keepends=[True, True, False]), npt.NDArray[np.object_])

# 使用 np.char.swapcase 函数将 AR_U 数组中的字母大小写互换,并返回字符串数组
assert_type(np.char.swapcase(AR_U), npt.NDArray[np.str_])

# 使用 np.char.swapcase 函数将 AR_S 数组中的字母大小写互换,并返回字节字符串数组
assert_type(np.char.swapcase(AR_S), npt.NDArray[np.bytes_])

# 使用 np.char.title 函数将 AR_U 数组中的每个单词的首字母大写,并返回字符串数组
assert_type(np.char.title(AR_U), npt.NDArray[np.str_])

# 使用 np.char.title 函数将 AR_S 数组中的每个单词的首字母大写,并返回字节字符串数组
assert_type(np.char.title(AR_S), npt.NDArray[np.bytes_])

# 使用 np.char.upper 函数将 AR_U 数组中的字母转换为大写,并返回字符串数组
assert_type(np.char.upper(AR_U), npt.NDArray[np.str_])

# 使用 np.char.upper 函数将 AR_S 数组中的字母转换为大写,并返回字节字符串数组
assert_type(np.char.upper(AR_S), npt.NDArray[np.bytes_])

# 使用 np.char.zfill 函数将 AR_U 数组中的字符串填充为指定长度,并返回字符串数组
assert_type(np.char.zfill(AR_U, 5), npt.NDArray[np.str_])

# 使用 np.char.zfill 函数将 AR_S 数组中的字节字符串填充为指定长度,并返回字节字符串数组
assert_type(np.char.zfill(AR_S, [2, 3, 4]), npt.NDArray[np.bytes_])

# 使用 np.char.count 函数计算 AR_U 数组中字符 "a" 出现的次数,并返回整数数组
assert_type(np.char.count(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 np.char.count 函数计算 AR_S 数组中特定字节序列出现的次数,并返回整数数组
assert_type(np.char.count(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 np.char.endswith 函数检查 AR_U 数组中是否以指定字符结尾,并返回布尔数组
assert_type(np.char.endswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool])

# 使用 np.char.endswith 函数检查 AR_S 数组中是否以指定字节序列结尾,并返回布尔数组
assert_type(np.char.endswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])

# 使用 np.char.startswith 函数检查 AR_U 数组中是否以指定字符开头,并返回布尔数组
assert_type(np.char.startswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool])

# 使用 np.char.startswith 函数检查 AR_S 数组中是否以指定字节序列开头,并返回布尔数组
assert_type(np.char.startswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])

# 使用 np.char.find 函数在 AR_U 数组中查找指定字符并返回其位置,未找到返回 -1,并返回整数数组
assert_type(np.char.find(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 np.char.find 函数在 AR_S 数组中查找指定字节序列并返回其位置,未找到返回 -1,并返回整数数组
assert_type(np.char.find(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 np.char.rfind 函数在 AR_U 数组中从右侧开始查找指定字符并返回其位置,未找到返回 -1,并返回整数数组
assert_type(np.char.rfind(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 np.char.rfind 函数在 AR_S 数组中从右侧开始查找指定字节序列并返回其位置,未找到返回 -1,并返回整数数组
assert_type(np.char.rfind(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 np.char.index 函数在 AR_U 数组中查找指定字符并返回其位置,未找到会引发 ValueError,并返回整数数组
assert_type(np.char.index(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 np.char.index 函数在 AR_S 数组中查找指定字节序列并返回其位置,未找到会引发 ValueError,并返回整数数组
assert_type(np.char.index(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 np.char.rindex 函数在 AR_U 数组中从右侧开始查找指定字符并返回其位置,未找到会引发 ValueError,并返回整数数组
assert_type(np.char.rindex(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 np.char.rindex 函数在 AR_S 数组中从右侧开始查找指定字节序列并返回其位置,未找到会引发 ValueError,并返回整数数组
assert_type(np.char.rindex(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 np.char.isalpha 函数检查 AR_U 数组中的每个字符串是否都是字母,并返回布尔数组
assert_type(np.char.isalpha(AR_U), npt.NDArray[np.bool])

# 使用 np.char.isalpha 函数检查 AR_S 数组中的每个字节序列是否都是字母,并返回布尔数组
assert_type(np.char.isalpha(AR_S), npt.NDArray[np.bool])

# 使用 np.char.isalnum 函数检查 AR_U 数组中的每个字符串是否都是字母或数字,并返回布尔数组
assert_type(np.char.isalnum(AR_U), npt.NDArray[np.bool])

# 使用 np.char.isalnum 函数检查 AR_S 数组中的每个字节序列是否都是字母或数字,并返回布尔数组
assert_type(np.char.isalnum(AR_S), npt.NDArray[np.bool])

# 使用 np.char.isdecimal 函数检查 AR_U 数组中的每个字符串是否都是十进制数字,并返回布尔数组
assert_type(np.char.isdecimal(AR_U), npt.NDArray[np.bool])

# 使用 np.char.isdigit 函数检查 AR_U 数组中的每个字符串是否都
# 确保 AR_U 中的每个字符都是大写,并返回一个布尔类型的 NumPy 数组
assert_type(np.char.isupper(AR_U), npt.NDArray[np.bool])
# 确保 AR_S 中的每个字符都是大写,并返回一个布尔类型的 NumPy 数组
assert_type(np.char.isupper(AR_S), npt.NDArray[np.bool])

# 计算 AR_U 中每个字符串的长度,并返回一个整数类型的 NumPy 数组
assert_type(np.char.str_len(AR_U), npt.NDArray[np.int_])
# 计算 AR_S 中每个字符串的长度,并返回一个整数类型的 NumPy 数组
assert_type(np.char.str_len(AR_S), npt.NDArray[np.int_])

# 将 AR_U 转换为字符类型的 NumPy 数组
assert_type(np.char.array(AR_U), np.char.chararray[Any, np.dtype[np.str_]])
# 将 AR_S 转换为字节类型的 NumPy 数组,按照内存布局 "K" 排列
assert_type(np.char.array(AR_S, order="K"), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将字符串 "bob" 转换为字符类型的 NumPy 数组,复制原始数据
assert_type(np.char.array("bob", copy=True), np.char.chararray[Any, np.dtype[np.str_]])
# 将字节串 b"bob" 转换为字符类型的 NumPy 数组,每个元素占据 5 字节
assert_type(np.char.array(b"bob", itemsize=5), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将整数 1 转换为字节类型的 NumPy 数组,unicode=False 表示不启用 Unicode 编码
assert_type(np.char.array(1, unicode=False), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将整数 1 转换为字符类型的 NumPy 数组,unicode=True 表示启用 Unicode 编码
assert_type(np.char.array(1, unicode=True), np.char.chararray[Any, np.dtype[np.str_]])

# 将 AR_U 转换为字符类型的 NumPy 数组,并返回一个新的数组对象
assert_type(np.char.asarray(AR_U), np.char.chararray[Any, np.dtype[np.str_]])
# 将 AR_S 转换为字节类型的 NumPy 数组,按照内存布局 "K" 排列,并返回一个新的数组对象
assert_type(np.char.asarray(AR_S, order="K"), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将字符串 "bob" 转换为字符类型的 NumPy 数组,并返回一个新的数组对象
assert_type(np.char.asarray("bob"), np.char.chararray[Any, np.dtype[np.str_]])
# 将字节串 b"bob" 转换为字符类型的 NumPy 数组,每个元素占据 5 字节,并返回一个新的数组对象
assert_type(np.char.asarray(b"bob", itemsize=5), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将整数 1 转换为字节类型的 NumPy 数组,unicode=False 表示不启用 Unicode 编码,并返回一个新的数组对象
assert_type(np.char.asarray(1, unicode=False), np.char.chararray[Any, np.dtype[np.bytes_]])
# 将整数 1 转换为字符类型的 NumPy 数组,unicode=True 表示启用 Unicode 编码,并返回一个新的数组对象
assert_type(np.char.asarray(1, unicode=True), np.char.chararray[Any, np.dtype[np.str_]])

.\numpy\numpy\typing\tests\data\reveal\chararray.pyi

# 导入sys模块,用于访问系统相关功能
import sys
# 导入Any类型用于灵活类型声明
from typing import Any

# 导入NumPy库,并引入NumPy类型注解
import numpy as np
import numpy.typing as npt

# 根据Python版本选择合适的assert_type函数导入
if sys.version_info >= (3, 11):
    from typing import assert_type
else:
    from typing_extensions import assert_type

# 声明AR_U和AR_S为chararray类型的NumPy数组,可以包含任意类型的数据
AR_U: np.char.chararray[Any, np.dtype[np.str_]]
AR_S: np.char.chararray[Any, np.dtype[np.bytes_]]

# 使用assert_type函数验证AR_U和AR_S的比较运算结果为布尔类型的NumPy数组
assert_type(AR_U == AR_U, npt.NDArray[np.bool])
assert_type(AR_S == AR_S, npt.NDArray[np.bool])

assert_type(AR_U != AR_U, npt.NDArray[np.bool])
assert_type(AR_S != AR_S, npt.NDArray[np.bool])

assert_type(AR_U >= AR_U, npt.NDArray[np.bool])
assert_type(AR_S >= AR_S, npt.NDArray[np.bool])

assert_type(AR_U <= AR_U, npt.NDArray[np.bool])
assert_type(AR_S <= AR_S, npt.NDArray[np.bool])

assert_type(AR_U > AR_U, npt.NDArray[np.bool])
assert_type(AR_S > AR_S, npt.NDArray[np.bool])

assert_type(AR_U < AR_U, npt.NDArray[np.bool])
assert_type(AR_S < AR_S, npt.NDArray[np.bool])

# 使用assert_type函数验证AR_U和AR_S的数学运算结果为chararray类型的NumPy数组
assert_type(AR_U * 5, np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S * [5], np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U % "test", np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S % b"test", np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用assert_type函数验证AR_U和AR_S的字符串操作结果为chararray类型的NumPy数组
assert_type(AR_U.capitalize(), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.capitalize(), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.center(5), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.center([2, 3, 4], b"a"), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.encode(), np.char.chararray[Any, np.dtype[np.bytes_]])
assert_type(AR_S.decode(), np.char.chararray[Any, np.dtype[np.str_]])

assert_type(AR_U.expandtabs(), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.expandtabs(tabsize=4), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.join("_"), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.join([b"_", b""]), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.ljust(5), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.ljust([4, 3, 1], fillchar=[b"a", b"b", b"c"]), np.char.chararray[Any, np.dtype[np.bytes_]])
assert_type(AR_U.rjust(5), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.rjust([4, 3, 1], fillchar=[b"a", b"b", b"c"]), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.lstrip(), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.lstrip(chars=b"_"), np.char.chararray[Any, np.dtype[np.bytes_]])
assert_type(AR_U.rstrip(), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.rstrip(chars=b"_"), np.char.chararray[Any, np.dtype[np.bytes_]])
assert_type(AR_U.strip(), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.strip(chars=b"_"), np.char.chararray[Any, np.dtype[np.bytes_]])

assert_type(AR_U.partition("\n"), np.char.chararray[Any, np.dtype[np.str_]])
assert_type(AR_S.partition([b"a", b"b", b"c"]), np.char.chararray[Any, np.dtype[np.bytes_]])
assert_type(AR_U.rpartition("\n"), np.char.chararray[Any, np.dtype[np.str_]])
# 使用 assert_type 函数验证 AR_S.rpartition([b"a", b"b", b"c"]) 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.rpartition([b"a", b"b", b"c"]), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.replace("_", "-") 返回的类型是否为 np.char.chararray[Any, np.dtype[np.str_]]
assert_type(AR_U.replace("_", "-"), np.char.chararray[Any, np.dtype[np.str_]])

# 使用 assert_type 函数验证 AR_S.replace([b"_", b""], [b"a", b"b"]) 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.replace([b"_", b""], [b"a", b"b"]), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.split("_") 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_U.split("_"), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_S.split(maxsplit=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_S.split(maxsplit=[1, 2, 3]), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_U.rsplit("_") 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_U.rsplit("_"), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_S.rsplit(maxsplit=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_S.rsplit(maxsplit=[1, 2, 3]), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_U.splitlines() 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_U.splitlines(), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_S.splitlines(keepends=[True, True, False]) 返回的类型是否为 npt.NDArray[np.object_]
assert_type(AR_S.splitlines(keepends=[True, True, False]), npt.NDArray[np.object_])

# 使用 assert_type 函数验证 AR_U.swapcase() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.str_]]
assert_type(AR_U.swapcase(), np.char.chararray[Any, np.dtype[np.str_]])

# 使用 assert_type 函数验证 AR_S.swapcase() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.swapcase(), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.title() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.str_]]
assert_type(AR_U.title(), np.char.chararray[Any, np.dtype[np.str_]])

# 使用 assert_type 函数验证 AR_S.title() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.title(), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.upper() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.str_]]
assert_type(AR_U.upper(), np.char.chararray[Any, np.dtype[np.str_]])

# 使用 assert_type 函数验证 AR_S.upper() 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.upper(), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.zfill(5) 返回的类型是否为 np.char.chararray[Any, np.dtype[np.str_]]
assert_type(AR_U.zfill(5), np.char.chararray[Any, np.dtype[np.str_]])

# 使用 assert_type 函数验证 AR_S.zfill([2, 3, 4]) 返回的类型是否为 np.char.chararray[Any, np.dtype[np.bytes_]]
assert_type(AR_S.zfill([2, 3, 4]), np.char.chararray[Any, np.dtype[np.bytes_]])

# 使用 assert_type 函数验证 AR_U.count("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_U.count("a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_S.count([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_S.count([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_U.endswith("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_U.endswith("a", start=[1, 2, 3]), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_S.endswith([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_S.endswith([b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_U.startswith("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_U.startswith("a", start=[1, 2, 3]), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_S.startswith([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_S.startswith([b"a", b"b", b"c"], end=9), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_U.find("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_U.find("a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_S.find([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_S.find([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_U.rfind("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_U.rfind("a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_S.rfind([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_S.rfind([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_U.index("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_U.index("a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_S.index([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_S.index([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_U.rindex("a", start=[1, 2, 3]) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_U.rindex("a", start=[1, 2, 3]), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_S.rindex([b"a", b"b", b"c"], end=9) 返回的类型是否为 npt.NDArray[np.int_]
assert_type(AR_S.rindex([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])

# 使用 assert_type 函数验证 AR_U.isalpha() 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_U.isalpha(), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_S.isalpha() 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_S.isalpha(), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_U.isalnum() 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_U.isalnum(), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_S.isalnum() 返回的类型是否为 npt.NDArray[np.bool]
assert_type(AR_S.isalnum(), npt.NDArray[np.bool])

# 使用 assert_type 函数验证 AR_U.isdecimal() 返回的类型是否为 npt.NDArray[np.bool]
assert
# 断言检查 AR_U 是否每个元素的首字母大写,返回布尔数组
assert_type(AR_U.istitle(), npt.NDArray[np.bool])

# 断言检查 AR_S 是否每个元素的首字母大写,返回布尔数组
assert_type(AR_S.istitle(), npt.NDArray[np.bool])

# 断言检查 AR_U 是否每个元素都是大写字母,返回布尔数组
assert_type(AR_U.isupper(), npt.NDArray[np.bool])

# 断言检查 AR_S 是否每个元素都是大写字母,返回布尔数组
assert_type(AR_S.isupper(), npt.NDArray[np.bool])

# 调用 __array_finalize__ 方法并断言其返回值类型为 None
assert_type(AR_U.__array_finalize__(object()), None)

# 调用 __array_finalize__ 方法并断言其返回值类型为 None
assert_type(AR_S.__array_finalize__(object()), None)