Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is numpy method int0?

I've seen np.int0 used for converting bounding box floating point values to int in OpenCV problems.

What exactly is np.int0?

I've seen np.uint8, np.int32, etc. I can't seem to find np.int0 in any online documentation. What kind of int does this cast arguments to?

like image 723
A. Hendry Avatar asked Jan 19 '18 22:01

A. Hendry


People also ask

What does * do in NumPy?

NumPy performs operations element-by-element, so multiplying 2D arrays with * is not a matrix multiplication – it's an element-by-element multiplication.

What are NumPy data type?

NumPy dtypeA data type object implements the fixed size of memory corresponding to an array. We can create a dtype object by using the following syntax. The constructor accepts the following object. Object: It represents the object which is to be converted to the data type.

What is uint8 in NumPy?

NumPy data types uint8 In Python uint8 datatype indicates unsigned integer and it consists of 8 bits with positive range values from 0 to 255. This datatype store information about the type byte order and bit-width with 'C'unsigned character.

What is NumPy Jupyter?

A numpy array is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers. The number of dimensions is the rank of the array; the shape of an array is a tuple of integers giving the size of the array along each dimension.


3 Answers

int0 is an alias for intp; this, in turn, is

Integer used for indexing (same as C ssize_t; normally either int32 or int64)

-- Numpy docs: basic types

like image 136
Amadan Avatar answered Oct 28 '22 21:10

Amadan


It's a mere alias to int64, try this from either Python 2 or Python 3:

>>> import numpy
>>> numpy.int0 is numpy.int64
True
like image 8
Right leg Avatar answered Oct 28 '22 20:10

Right leg


Here is some more information:

# get complete list of datatype names
>>> np.sctypeDict.keys()

# returns the default integer type (here `int64`)
>>> np.sctypeDict['int0']
<class 'numpy.int64'>

# verify
>>> arr = np.int0([1, 2, 3])
>>> arr.nbytes
24
like image 1
kmario23 Avatar answered Oct 28 '22 22:10

kmario23