numpy的 - 阵VS asarray [英] Numpy - array vs asarray
问题描述
之间有什么numpy的的<一的区别href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html#numpy.array\"><$c$c>array()$c$c>和<一个href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.asarray.html#numpy.asarray\"><$c$c>asarray()$c$c>功能?当你应该使用一个,而不是其他?他们似乎为所有我能想到的输入相同的输出。
What is the difference between Numpy's array()
and asarray()
functions? When should you use one rather than the other? They seem to generate identical output for all the inputs I can think of.
推荐答案
的<一个href=\"https://github.com/numpy/numpy/blob/bcbed877f42ed6e9b01b2125134db4b6395f1d9d/numpy/core/numeric.py#L413-481\"相对=nofollow>定义 asarray
是:
def asarray(a, dtype=None, order=None):
return array(a, dtype, copy=False, order=order)
因此,它是像阵列
,除了它具有较少的选项,复制=假
。 阵列
的副本= TRUE
默认情况下。
So it is like array
, except it has fewer options, and copy = False
. array
has copy = True
by default.
我认为主要的区别是,阵列
(默认)可以使对象的副本,而 asarray
不会,除非必要的。
I think the main difference is that array
(by default) will make a copy of the object, while asarray
will not unless necessary.
这篇关于numpy的 - 阵VS asarray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!