第五节.特别的方法
标准库函数:
ndarray.__copy__() |
在数组上调用ifcopy.copyis。 |
|---|---|
ndarray.__deepcopy__((memo, ...) |
在数组上调用ifcopy.deepcopy。 |
ndarray.__reduce__() |
For pickling. |
ndarray.__setstate__(state, /) |
For unpickling. |
基本的定制方法:
ndarray.__new__((S, ...) |
|
|---|---|
ndarray.__array__(...) |
如果dtype不是给定的,则返回一个新的自引用;如果dtype与数组的当前dtype不同,则返回提供的数据类型的新数组。 |
ndarray.__array_wrap__(...) |
容器定制化
ndarray.__len__() <==> len(x) |
|
|---|---|
ndarray.__getitem__ |
x.__getitem__(y) <==> x[y] |
ndarray.__setitem__ |
x.__setitem__(i, y) <==> x[i]=y |
ndarray.__contains__ |
x.__contains__(y) <==> y in x |
转换; Complex,int,long,float,oct和hex操作。 它们只能工作在有一个元素的数组上,并返回相应的标量。
ndarray.__int__() <==> int(x) |
|
|---|---|
ndarray.__long__() <==> long(x) |
|
ndarray.__float__() <==> float(x) |
|
ndarray.__oct__() <==> oct(x) |
|
ndarray.__hex__() <==> hex(x) |
字符串表现形式:
ndarray.__str__() <==> str(x) |
|
|---|---|
ndarray.__repr__() <==> repr(x) |