日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python numpy ones.like()(返回形状与类型与给定数组相同的数组)

發布時間:2025/3/20 python 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python numpy ones.like()(返回形状与类型与给定数组相同的数组) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
def ones_like(a, dtype=None, order='K', subok=True):"""Return an array of ones with the same shape and type as a given array.返回形狀與類型與給定數組相同的數組。Parameters----------a : array_likeThe shape and data-type of `a` define these same attributes ofthe returned array.a的形狀和數據類型定義了返回數組的這些相同屬性。dtype : data-type, optionalOverrides the data type of the result.覆蓋結果的數據類型。.. versionadded:: 1.6.0order : {'C', 'F', 'A', or 'K'}, optionalOverrides the memory layout of the result. 'C' means C-order,'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,'C' otherwise. 'K' means match the layout of `a` as closelyas possible.覆蓋結果的內存布局。 “ C”表示C階,“ F”表示F階,如果“ a”是Fortran連續的,則“ A”表示“ F”,否則為“ C”。 “ K”表示盡可能匹配“ a”的布局。.. versionadded:: 1.6.0subok : bool, optional.If True, then the newly created array will use the sub-classtype of 'a', otherwise it will be a base-class array. Defaultsto True.如果為True,則新創建的數組將使用'a'的子類類型,否則它將是基類數組。 默認為True。Returns-------out : ndarrayArray of ones with the same shape and type as `a`.與a形狀和類型相同的數組。See Also--------empty_like : Return an empty array with shape and type of input.zeros_like : Return an array of zeros with shape and type of input.full_like : Return a new array with shape of input filled with value.ones : Return a new array setting values to one.Examples-------->>> x = np.arange(6)>>> x = x.reshape((2, 3))>>> xarray([[0, 1, 2],[3, 4, 5]])>>> np.ones_like(x)array([[1, 1, 1],[1, 1, 1]])>>> y = np.arange(3, dtype=float)>>> yarray([ 0., 1., 2.])>>> np.ones_like(y)array([ 1., 1., 1.])"""res = empty_like(a, dtype=dtype, order=order, subok=subok)multiarray.copyto(res, 1, casting='unsafe')return res

總結

以上是生活随笔為你收集整理的python numpy ones.like()(返回形状与类型与给定数组相同的数组)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。