当前位置:网站首页>Numpy (data type)
Numpy (data type)
2022-06-30 09:26:00 【Orangejuicer】
Common data types
Python There are relatively few native data types , bool、int、float、str etc. . This is convenient in applications that do not need to care about all the ways data is represented in a computer . However , For scientific computing , More control is often required . To distinguish numpy At the end of the names of these types “_”.
The following table lists the common numpy Basic types .

Create data types
numpy The numerical type of is actually dtype Instance of object .
class dtype(object):
def __init__(self, obj, align=False, copy=False):
pass
Each built-in type has a unique character code that defines it , as follows :
【 example 】
import numpy as np
a = np.dtype('b1')
print(a.type) # <class 'numpy.bool_'>
print(a.itemsize) # 1
a = np.dtype('i1')
print(a.type) # <class 'numpy.int8'>
print(a.itemsize) # 1
a = np.dtype('i2')
print(a.type) # <class 'numpy.int16'>
print(a.itemsize) # 2
a = np.dtype('i4')
print(a.type) # <class 'numpy.int32'>
print(a.itemsize) # 4
a = np.dtype('i8')
print(a.type) # <class 'numpy.int64'>
print(a.itemsize) # 8
a = np.dtype('u1')
print(a.type) # <class 'numpy.uint8'>
print(a.itemsize) # 1
a = np.dtype('u2')
print(a.type) # <class 'numpy.uint16'>
print(a.itemsize) # 2
a = np.dtype('u4')
print(a.type) # <class 'numpy.uint32'>
print(a.itemsize) # 4
a = np.dtype('u8')
print(a.type) # <class 'numpy.uint64'>
print(a.itemsize) # 8
a = np.dtype('f2')
print(a.type) # <class 'numpy.float16'>
print(a.itemsize) # 2
a = np.dtype('f4')
print(a.type) # <class 'numpy.float32'>
print(a.itemsize) # 4
a = np.dtype('f8')
print(a.type) # <class 'numpy.float64'>
print(a.itemsize) # 8
a = np.dtype('S')
print(a.type) # <class 'numpy.bytes_'>
print(a.itemsize) # 0
a = np.dtype('S3')
print(a.type) # <class 'numpy.bytes_'>
print(a.itemsize) # 3
a = np.dtype('U3')
print(a.type) # <class 'numpy.str_'>
print(a.itemsize) # 12
Data type information
Python The floating-point number of is usually 64 Bit floating point , Almost equal to np.float64.
NumPy and Python The behavior of integer types differs significantly in terms of integer overflow , And NumPy Different ,Python Of int It's flexible . It means Python Integers can be extended to accommodate any integer without overflowing .
- Machine limits for integer types .
class iinfo(object):
def __init__(self, int_type):
pass
def min(self):
pass
def max(self):
pass
【 example 】
import numpy as np
ii16 = np.iinfo(np.int16)
print(ii16.min) # -32768
print(ii16.max) # 32767
ii32 = np.iinfo(np.int32)
print(ii32.min) # -2147483648
print(ii32.max) # 2147483647
- Machine limits for floating point types .
class finfo(object):
def _init(self, dtype):
【 example 】
import numpy as np
ff16 = np.finfo(np.float16)
print(ff16.bits) # 16
print(ff16.min) # -65500.0
print(ff16.max) # 65500.0
print(ff16.eps) # 0.000977
ff32 = np.finfo(np.float32)
print(ff32.bits) # 32
print(ff32.min) # -3.4028235e+38
print(ff32.max) # 3.4028235e+38
print(ff32.eps) # 1.1920929e-07
边栏推荐
- Use of Baidu face recognition API
- Express get request
- Using appbarlayout to realize secondary ceiling function
- 桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
- Understanding of MVVM and MVC
- Tclistener server and tcpclient client
- Challenge transform() 2D
- Esp32 things (VIII): music playing function of function development
- C accesses mongodb and performs CRUD operations
- Esp32 (7): I2S and I2C drivers for function development
猜你喜欢

Concatapter tutorial

Handwriting sorter component

Pit encountered by fastjason

Opencv learning notes -day3 (mat object and creation related operations mat:: clone(), mat:: copyto(), mat:: zeros(), mat:: ones(), scalar()...)

Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)

Rew acoustic test (II): offline test

Evaluation standard for audio signal quality of intelligent speakers

Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)

Solution to pychart's failure in importing torch package

Rew acoustic test (VI): signal and measurement
随机推荐
Set, map and modularity
float
5. Messager framework and imessager interface
Duplicate entry '2' for key 'primary appears in JPA‘
Mmdet line by line code interpretation of positive and negative sample sampler
2020-11-02
What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
Deep Learning with Pytorch- neural network
Differences between the notify(), notifyall(), notifydatasetchanged(), notifydatasetinvalidated() methods in the adapter
Rew acoustic test (III): generate test signal
Express - static resource request
Couldn't load this key (openssh ssh-2 private key (old PEM format))
The elegant combination of walle and Jianbao
Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
Challenge transform() 2D
Niuke rearrangement rule taking method
Raspberry pie 4B no screen installation system and networking using VNC wireless projection function
Anchorgenerator for mmdet line by line interpretation
桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
Experience of an acmer