Exemple #1
0
# print(d is c,e.base is c)
#花式索引
#一维索引
# print(c[1,2])
# print(c[[2,3],[1,2]])#行索引和列索引
# rows = np.array([[0,0],[3,3]])#0轴的0行和3行分别由两个元素
# cols = np.array([[0,3],[0,3]])#这4个元素分别是0,2列的
# print(c[rows,cols])
a = np.arange(12).reshape(3, 4)
b1 = np.array([False, True, True])
b2 = np.array([True, False, True, False])
# print(a[b1,b2])
aa = np.array([2, 3, 4, 5])
bb = np.array([8, 5, 4])
cc = np.array([5, 4, 6, 8, 3])
# ax,bx,cx = np.ix_(aa,bb,cc)
# print(np.shape(ax))
# print(np.shape(bx))
# print(np.shape(cx))
aa.itemset(3, 100)  #在指定位置插入值
# print(bb.tostring())#转化为字节字符串
# print(bb.tolist())
cc.fill(0)  #方法:无返回值
bb.flat = 1  #数组的迭代器,可索引
cf = c.flatten()  #将多维数组展开
zl = np.zeros_like(c)
np.argmax(c, axis=0)
com = np.arange(12).reshape(((3, 4)))
g1 = np.generic()
print(g1)
Exemple #2
0
    def __float__(self):
        return 1.0


np.int8(A())  # E: incompatible type
np.int16(A())  # E: incompatible type
np.int32(A())  # E: incompatible type
np.int64(A())  # E: incompatible type
np.uint8(A())  # E: incompatible type
np.uint16(A())  # E: incompatible type
np.uint32(A())  # E: incompatible type
np.uint64(A())  # E: incompatible type

np.void("test")  # E: incompatible type

np.generic(1)  # E: Cannot instantiate abstract class
np.number(1)  # E: Cannot instantiate abstract class
np.integer(1)  # E: Cannot instantiate abstract class
np.inexact(1)  # E: Cannot instantiate abstract class
np.character("test")  # E: Cannot instantiate abstract class
np.flexible(b"test")  # E: Cannot instantiate abstract class

np.float64(value=0.0)  # E: Unexpected keyword argument
np.int64(value=0)  # E: Unexpected keyword argument
np.uint64(value=0)  # E: Unexpected keyword argument
np.complex128(value=0.0j)  # E: Unexpected keyword argument
np.str_(value='bob')  # E: No overload variant
np.bytes_(value=b'test')  # E: No overload variant
np.void(value=b'test')  # E: Unexpected keyword argument
np.bool_(value=True)  # E: Unexpected keyword argument
np.datetime64(value="2019")  # E: No overload variant