NumPy array creation: ogrid() function
nd_grid instance which returns an open multi-dimensional “meshgrid”.
An instance of numpy.lib.index_tricks.nd_grid which returns an open (i.e. not fleshed out) mesh-grid when indexed, so that only one dimension of each returned array is greater than 1. The dimension and number of the output arrays are equal to the number of indexing dimensions. If the step length is not a complex number, then the stop is not inclusive.
However, if the step length is a complex number (e.g. 5j), then the integer part of its magnitude is interpreted as specifying the number of points to create between the start and stop values, where the stop value is inclusive.
numpy.ogrid = <numpy.lib.index_tricks.nd_grid object>
mesh-grid 'ndarrays' with only one dimension :math:'neq 1'.
Example-1: NumPy.ogrid() function
>>> import numpy as np >>> from numpy import ogrid >>> ogrid[-1:1:4j] array([-1. , -0.33333333, 0.33333333, 1. ])
Example-2: NumPy.ogrid() function
>>> import numpy as np >>> from numpy import ogrid >>> ogrid[0:4,0:4] [array([, , , ]), array([[0, 1, 2, 3]])]
Python - NumPy Code Editor:
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework