当前位置:网站首页>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
边栏推荐
- Detailed explanation of pipline of mmdetection
- Pytorch BERT
- Do you want the dialog box that pops up from the click?
- C accesses mongodb and performs CRUD operations
- Row column (vertical and horizontal table) conversion of SQL
- Small program learning path 1 - getting to know small programs
- float
- Find the number that appears only once in the array
- Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line
- 127.0.0.1, 0.0.0.0 and localhost
猜你喜欢

Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())

ES6 learning path (III) deconstruction assignment

Challenge transform() 2D

Pytorch BERT

Use Huawei performance management service to configure the sampling rate on demand

Deep understanding of continuation principle

Harmonyos actual combat - ten thousand words long article understanding service card development process

Couldn't load this key (openssh ssh-2 private key (old PEM format))

Installation, use and explanation of vulnerability scanning tool OpenVAS

ES6 learning path (II) let & const
随机推荐
[wechat applet] realize applet pull-down refresh and pull-up loading
Pytorch BERT
Opencv learning notes -day1 (image reading display imread, imshow, namedwindow)
Tclistener server and tcpclient client
Splice and slice functions of JS
Flutter theme (skin) changes
Opencv learning notes -day13 pixel value statistics calculation of maximum and minimum values, average values and standard deviations (use of minmaxloc() and meanstddev() functions)
Esp32 things (V): analysis of common API of esp32 of Swiss Army knife
Comparison of two ways for C to access SQL Server database (SqlDataReader vs SqlDataAdapter)
Talk about writing
Talking about kotlin process exception handling mechanism
Express file upload
Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
So the toolbar can still be used like this? The toolbar uses the most complete parsing. Netizen: finally, you don't have to always customize the title bar!
Treatment process record of Union Medical College Hospital (Dongdan hospital area)
Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)
Express の Hello World
Resnet50+fpn for mmdet line by line code interpretation
Advanced technology management -- how managers design and build echelons
Rew acoustic test (V): equipment required for test