mindspore.numpy.ogrid

mindspore.numpy.ogrid()

ogrid is an NdGrid instance with sparse=True.

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.

Note

Not supported in graph mode. Unlike Numpy, if the step length is a complex number with a real component, the step length is handled as equivalent to int(abs(step)).

Raises

TypeError – If slicing indices are not integers.

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore.numpy import ogrid
>>> output = ogrid[0:5,0:5]
>>> print(output)
[Tensor(shape=[5, 1], dtype=Int32, value=
[[0],
[1],
[2],
[3],
[4]]), Tensor(shape=[1, 5], dtype=Int32, value=
[[0, 1, 2, 3, 4]])]
>>> output = ogrid[-1:1:5j]
>>> print(output)
[-1.  -0.5  0.   0.5  1. ]