本文簡要介紹 python 語言中 numpy.common_type
的用法。
用法:
numpy.common_type(*arrays)
返回輸入數組共有的標量類型。
返回類型將始終是不精確(即浮點)標量類型,即使所有數組都是整數數組。如果輸入之一是整數數組,則返回的最小精度類型是 64 位浮點 dtype。
除了 int64 和 uint64 之外的所有輸入數組都可以安全地轉換為返回的 dtype 而不會丟失信息。
- array1, array2, …: ndarray
輸入數組。
- out: 數據類型代碼
數據類型代碼。
參數:
返回:
例子:
>>> np.common_type(np.arange(2, dtype=np.float32)) <class 'numpy.float32'> >>> np.common_type(np.arange(2, dtype=np.float32), np.arange(2)) <class 'numpy.float64'> >>> np.common_type(np.arange(4), np.array([45, 6.j]), np.array([45.0])) <class 'numpy.complex128'>
相關用法
- Python numpy compress用法及代碼示例
- Python numpy copy用法及代碼示例
- Python numpy copysign用法及代碼示例
- Python numpy count_nonzero用法及代碼示例
- Python numpy correlate用法及代碼示例
- Python numpy cosh用法及代碼示例
- Python numpy conjugate用法及代碼示例
- Python numpy concatenate用法及代碼示例
- Python numpy cos用法及代碼示例
- Python numpy cov用法及代碼示例
- Python numpy conj用法及代碼示例
- Python numpy corrcoef用法及代碼示例
- Python numpy convolve用法及代碼示例
- Python numpy column_stack用法及代碼示例
- Python numpy chararray.ndim用法及代碼示例
- Python numpy chebyshev.chebsub用法及代碼示例
- Python numpy chararray.nbytes用法及代碼示例
- Python numpy chebyshev.chebdiv用法及代碼示例
- Python numpy chararray.setflags用法及代碼示例
- Python numpy chararray.flat用法及代碼示例
- Python numpy can_cast用法及代碼示例
- Python numpy chararray.strides用法及代碼示例
- Python numpy chebyshev.cheb2poly用法及代碼示例
- Python numpy chararray.view用法及代碼示例
- Python numpy chebyshev.chebx用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.common_type。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。