【发布时间】:2020-02-04 01:35:58
【问题描述】:
我想为 NumPy 测试生成一个策略,输出如下:
array([[-2, -2],
[-3, -3],
[5, 5],
[-1, -1]], dtype=int16)
我尝试的是:
import numpy as np
from hypothesis.strategies import integers
from hypothesis.extra.numpy import arrays
arrays(np.int16, (4,2), elements=integers(-10, 10)).example()
不幸的是,我无法使元组中的值相同,因此上面的查询返回:
array([[ 5, 5],
[-7, 5],
[ 5, 5],
[ 5, 5]], dtype=int16)
【问题讨论】: