numpy.ix_() function | Python (original) (raw)
Last Updated : 22 Apr, 2020
numpy.ix_()
function construct an open mesh from multiple sequences. This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all N dimensions.
Syntax : numpy.ix_(args)
Parameters :
args : [1-D sequences] Each sequence should be of integer or boolean type.
Return : [tuple of ndarrays] N arrays with N dimensions each, with N the number of input sequences. Together these arrays form an open mesh.
Code #1 :
import
numpy as geek
gfg
=
geek.ix_([
0
,
1
], [
2
,
4
])
print
(gfg)
Output :
(array([[0], [1]]), array([[2, 4]]))
Code #2 :
import
numpy as geek
arr
=
geek.arange(
10
).reshape(
2
,
5
)
print
(
"Initial array : \n"
, arr)
ixgrid
=
geek.ix_([
0
,
1
], [
2
,
4
])
print
(
"New array : \n"
, arr[ixgrid])
Output :
Initial array : [[0 1 2 3 4] [5 6 7 8 9]] New array : [[2 4] [7 9]]
Similar Reads
- numpy.i0() function | Python numpy.i0() function is the modified Bessel function of the first kind, order 0. it's usually denoted by I0. Syntax : numpy.i0(x) Parameters : x : [array_like, dtype float or complex] Argument of the Bessel function. Return : [ndarray, shape = x.shape, dtype = x.dtype] The modified Bessel function ev 1 min read
- numpy.imag() function - Python numpy.imag() function return the imaginary part of the complex argument. Syntax : numpy.imag(arr) Parameters : arr : [array_like] Input array. Return : [ndarray or scalar] The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elem 1 min read
- numpy.iinfo() function – Python numpy.iinfo() function shows machine limits for integer types. Syntax : numpy.iinfo(dtype) Parameters : dtype : [integer type, dtype, or instance] The kind of integer data type to get information about. Return : Machine limits for integer types. Code #1 : # Python program explaining # numpy.iinfo() 1 min read
- numpy.matrix.A() function - Python numpy.matrix.A() function return self as an ndarray object. Syntax : numpy.matrix.A() Parameters : None Return : [ndarray] Return self as an ndarray. Code #1 : # Python program explaining # numpy.matrix.A() function # importing numpy as geek import numpy as geek mat = geek.matrix(geek.arange(9).resh 1 min read
- numpy.interp() function - Python numpy.interp() function returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x. Syntax : numpy.interp(x, xp, fp, left = None, right = None, period = None) Parameters : x : [array_like] The x-coordinates at which to evaluate the 2 min read
- numpy.pad() function in Python numpy.pad() function is used to pad the Numpy arrays. Sometimes there is a need to perform padding in Numpy arrays, then numPy.pad() function is used. The function returns the padded array of rank equal to the given array and the shape will increase according to pad_width. Syntax: numpy.pad(array, p 2 min read
- numpy.info() function in Python In Numpy we can get all the information about the function, class, or module like what will the parameter and what will be the type of the return value with the help of numpy.info() function. This function returns the help information for a function, class, or module. Syntax: numpy.info(numpy.info(o 1 min read
- numpy.who function - Python numpy.who() function print the NumPy arrays in the given dictionary. Syntax : numpy.who(vardict = None) Parameters : vardict : [dict, optional] A dictionary possibly containing ndarrays. Return : Returns ‘None’. If there is no dictionary passed in or vardict is None then returns NumPy arrays in the 1 min read
- id() function in Python In Python, id() function is a built-in function that returns the unique identifier of an object. The identifier is an integer, which represents the memory address of the object. The id() function is commonly used to check if two variables or objects refer to the same memory location. Python id() Fun 3 min read
- numpy.real() function - Python numpy.real() function return the real part of the complex argument. Syntax : numpy.real(arr) Parameters : arr : [array_like] Input array. Return : [ndarray or scalar] The real component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the 1 min read