nums.numpy.api.creation module

nums.numpy.api.creation.arange(start=None, stop=None, step=1, dtype=None)[source]

Return evenly spaced values within a given interval.

This docstring was copied from numpy.arange.

Some inconsistencies with the NumS version may exist.

Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments the function is equivalent to the Python built-in range function, but returns an BlockArray rather than a list.

When using a non-integer step, such as 0.1, the results will often not be consistent. It is better to use nums.linspace for these cases.

Parameters
  • start (number, optional) – Start of interval. The interval includes this value. The default start value is 0.

  • stop (number) – End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.

  • step (number, optional) – Spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.

  • dtype (dtype) – The type of the output array. If dtype is not given, infer the data type from the other input arguments.

Returns

arange – Array of evenly spaced values.

For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.

Return type

BlockArray

See also

linspace

Evenly spaced numbers with careful handling of endpoints.

Notes

Only step size of 1 is currently supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.arange(3).get()  
array([0, 1, 2])
>>> nps.arange(3.0).get()  
array([ 0.,  1.,  2.])
>>> nps.arange(3,7).get()  
array([3, 4, 5, 6])
nums.numpy.api.creation.array(object, dtype=None, copy=True, order='K', ndmin=0, subok=False)[source]

Creates a BlockArray.

This docstring was copied from numpy.array.

Some inconsistencies with the NumS version may exist.

Parameters
  • object (array_like) – An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence.

  • dtype (data-type, optional) – The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence.

  • copy (bool, optional) – If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).

  • order ({'K'}, optional) –

    Specify the memory layout of the array. If object is not an array, the newly created array will be in C order (row major) unless ‘F’ is specified, in which case it will be in Fortran order (column major). If object is an array the following holds.

    order

    no copy

    copy=True

    ’K’

    unchanged

    F & C order preserved, otherwise most similar order

    ’A’

    unchanged

    F order if input is F and not C, otherwise C order

    ’C’

    C order

    C order

    ’F’

    F order

    F order

    When copy=False and a copy is made for other reasons, the result is the same as if copy=True, with some exceptions for A, see the Notes section. The default order is ‘K’.

  • subok (bool, optional) – If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

  • ndmin (int, optional) – Specifies the minimum number of dimensions that the resulting array should have. Ones will be pre-pended to the shape as needed to meet this requirement.

Returns

out – An array object satisfying the specified requirements.

Return type

BlockArray

See also

empty_like

Return an empty array with shape and type of input.

ones_like

Return an array of ones with shape and type of input.

zeros_like

Return an array of zeros with shape and type of input.

full_like

Return a new array with shape of input filled with value.

empty

Return a new uninitialized array.

ones

Return a new array setting values to one.

zeros

Return a new array setting values to zero.

full

Return a new array of given shape filled with value.

Notes

Only order=’K’ is supported.

Only ndmin=0 is currently supported.

subok must be False

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.array([1, 2, 3]).get()  
array([1, 2, 3])

Upcasting:

>>> nps.array([1, 2, 3.0]).get()  
array([ 1.,  2.,  3.])

More than one dimension:

>>> nps.array([[1, 2], [3, 4]]).get()  
array([[1, 2],
       [3, 4]])

Type provided:

>>> nps.array([1, 2, 3], dtype=complex).get()  
array([ 1.+0.j,  2.+0.j,  3.+0.j])
nums.numpy.api.creation.copy(a, order='K', subok=False)[source]

Return an array copy of the given object.

This docstring was copied from numpy.copy.

Some inconsistencies with the NumS version may exist.

Parameters
  • a (BlockArray) – Input data.

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and BlockArray.copy() are very similar, but have different default values for their order= arguments.)

  • subok (bool, optional) – If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (defaults to False).

Returns

arr – Array interpretation of a.

Return type

BlockArray

See also

copy

Preferred method for creating an array copy

Notes

This is equivalent to:

>>> nps.array(a, copy=True).get()  

Only default args supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

Create an array x, with a reference y and a copy z:

>>> x = nps.array([1, 2, 3])  
>>> y = x  
>>> z = nps.copy(x)  

Note that, when we modify x, y changes, but not z:

>>> x[0] = 10  
>>> (x[0] == y[0]).get()  
array(True)
>>> (x[0] == z[0]).get()  
False
nums.numpy.api.creation.diag(v, k=0)[source]

Extract a diagonal or construct a diagonal array.

This docstring was copied from numpy.diag.

Some inconsistencies with the NumS version may exist.

See the more detailed documentation for numpy.diagonal if you use this function to extract a diagonal and wish to write to the resulting array; whether it returns a copy or a view depends on what version of numpy you are using.

Parameters
  • v (BlockArray) – If v is a 2-D array, return a copy of its k-th diagonal. If v is a 1-D array, return a 2-D array with v on the k-th diagonal.

  • k (int, optional) – Diagonal in question. The default is 0. Use k>0 for diagonals above the main diagonal, and k<0 for diagonals below the main diagonal.

Returns

out – The extracted diagonal or constructed diagonal array.

Return type

BlockArray

See also

diagonal

Return specified diagonals.

trace

Sum along diagonals.

triu

Upper triangle of an array.

Notes

offset != 0 is currently not supported.

out is currently not supported.

axis1 != 0 or axis2 != 1 is currently not supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(9).reshape((3,3))  
>>> x.get()  
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
>>> nps.diag(x).get()  
array([0, 4, 8])
>>> nps.diag(nps.diag(x)).get()  
array([[0, 0, 0],
       [0, 4, 0],
       [0, 0, 8]])
nums.numpy.api.creation.empty(shape, dtype=<class 'float'>)[source]

Return a new array of given shape and type, without initializing entries.

This docstring was copied from numpy.empty.

Some inconsistencies with the NumS version may exist.

Parameters
  • shape (int or tuple of int) – Shape of the empty array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – Desired output data-type for the array, e.g, int. Default is float.

Returns

out – Array of uninitialized (arbitrary) data of the given shape and dtype.

Return type

BlockArray

See also

empty_like

Return an empty array with shape and type of input.

ones

Return a new array setting values to one.

zeros

Return a new array setting values to zero.

full

Return a new array of given shape filled with value.

Notes

empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster. On the other hand, it requires the user to manually set all the values in the array, and should be used with caution.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.empty([2, 2]).get()  
array([[ -9.74499359e+001,   6.69583040e-309],
       [  2.13182611e-314,   3.06959433e-309]])         #uninitialized
>>> nps.empty([2, 2], dtype=int).get()  
array([[-1073741821, -1067949133],
       [  496041986,    19249760]])                     #uninitialized
nums.numpy.api.creation.empty_like(prototype, dtype=None, order='K', shape=None)[source]

Return a new array with the same shape and type as a given array.

This docstring was copied from numpy.empty_like.

Some inconsistencies with the NumS version may exist.

Parameters
  • prototype (BlockArray) – The shape and data-type of prototype define these same attributes of the returned array.

  • dtype (data-type, optional) – Overrides the data type of the result.

  • order ({'C', 'F', 'A', or 'K'}, optional) – Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if prototype is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of prototype as closely as possible.

  • shape (int or sequence of ints, optional.) – Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

Returns

out – Array of uninitialized (arbitrary) data with the same shape and type as prototype.

Return type

BlockArray

See also

ones_like

Return an array of ones with shape and type of input.

zeros_like

Return an array of zeros with shape and type of input.

full_like

Return a new array with shape of input filled with value.

empty

Return a new uninitialized array.

Notes

This function does not initialize the returned array; to do that use zeros_like or ones_like instead. It may be marginally faster than the functions that do set the array values.

Only order=’K’ is supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> a = ([1,2,3], [4,5,6])                         # a is array-like  
>>> nps.empty_like(a, shape=(2, 3), dtype=float).get()  
array([[-1073741821, -1073741821,           3],    # uninitialized
       [          0,           0, -1073741821]])
>>> a = nps.array([[1., 2., 3.],[4.,5.,6.]]).get()  
>>> nps.empty_like(a, shape=(2, 3), dtype=float).get()  
array([[ -2.00000715e+000,   1.48219694e-323,  -2.00000572e+000], # uninitialized
       [  4.38791518e-305,  -2.00000715e+000,   4.17269252e-309]])
nums.numpy.api.creation.eye(N, M=None, k=0, dtype=<class 'float'>)[source]

Return a 2-D array with ones on the diagonal and zeros elsewhere.

This docstring was copied from numpy.eye.

Some inconsistencies with the NumS version may exist.

Parameters
  • N (int) – Number of rows in the output.

  • M (int, optional) – Number of columns in the output. If None, defaults to N.

  • k (int, optional) – Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.

  • dtype (data-type, optional) – Data-type of the returned array.

Returns

I – An array where all elements are equal to zero, except for the k-th diagonal, whose values are equal to one.

Return type

BlockArray of shape (N,M)

See also

identity

(almost) equivalent function

diag

diagonal 2-D array from a 1-D array specified by the user.

Notes

Only k==0 is currently supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.eye(2, dtype=int).get()  
array([[1, 0],
       [0, 1]])
>>> nps.eye(3, k=1).get()  
array([[0.,  1.,  0.],
       [0.,  0.,  1.],
       [0.,  0.,  0.]])
nums.numpy.api.creation.identity(n, dtype=<class 'float'>)[source]

Return the identity array.

This docstring was copied from numpy.identity.

Some inconsistencies with the NumS version may exist.

The identity array is a square array with ones on the main diagonal.

Parameters
  • n (int) – Number of rows (and columns) in n x n output.

  • dtype (data-type, optional) – Data-type of the output. Defaults to float.

Returns

outn x n array with its main diagonal set to one, and all other elements 0.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.identity(3).get()  
array([[1.,  0.,  0.],
       [0.,  1.,  0.],
       [0.,  0.,  1.]])
nums.numpy.api.creation.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)[source]

Return evenly spaced numbers over a specified interval.

This docstring was copied from numpy.linspace.

Some inconsistencies with the NumS version may exist.

Returns num evenly spaced samples, calculated over the interval [start, stop].

The endpoint of the interval can optionally be excluded.

Parameters
  • start (BlockArray) – The starting value of the sequence.

  • stop (BlockArray) – The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

  • num (int, optional) – Number of samples to generate. Default is 50. Must be non-negative.

  • endpoint (bool, optional) – If True, stop is the last sample. Otherwise, it is not included. Default is True.

  • retstep (bool, optional) – If True, return (samples, step), where step is the spacing between samples.

  • dtype (dtype, optional) – The type of the output array. If dtype is not given, infer the data type from the other input arguments.

  • axis (int, optional) – The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

Returns

  • samples (BlockArray) – There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).

  • step (float, optional) – Only returned if retstep is True

    Size of spacing between samples.

See also

arange

Similar to linspace, but uses a step size (instead of the number of samples).

geomspace

Similar to linspace, but with numbers spaced evenly on a log scale (a geometric progression).

logspace

Similar to geomspace, but with the end points specified as logarithms.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.linspace(2.0, 3.0, num=5).get()  
array([2.  , 2.25, 2.5 , 2.75, 3.  ])
nums.numpy.api.creation.loadtxt(fname, dtype=<class 'float'>, comments='# ', delimiter=' ', converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0, encoding='bytes', max_rows=None)[source]

Load data from a text file.

This docstring was copied from numpy.loadtxt.

Some inconsistencies with the NumS version may exist.

Each row in the text file must have the same number of values.

Parameters
  • fname (file, str, or pathlib.Path) – File, filename, or generator to read. If the filename extension is .gz or .bz2, the file is first decompressed. Note that generators should return byte strings.

  • dtype (data-type, optional) – Data-type of the resulting array; default: float. If this is a structured data-type, the resulting array will be 1-dimensional, and each row will be interpreted as an element of the array. In this case, the number of columns used must match the number of fields in the data-type.

  • comments (str or sequence of str, optional) – The characters or list of characters used to indicate the start of a comment. None implies no comments. For backwards compatibility, byte strings will be decoded as ‘latin1’. The default is ‘#’.

  • delimiter (str, optional) – The string used to separate values. For backwards compatibility, byte strings will be decoded as ‘latin1’. The default is whitespace.

  • converters (dict, optional) – A dictionary mapping column number to a function that will parse the column string into the desired value. E.g., if column 0 is a date string: converters = {0: datestr2num}. Converters can also be used to provide a default value for missing data (but see also genfromtxt): converters = {3: lambda s: float(s.strip() or 0)}. Default: None.

  • skiprows (int, optional) – Skip the first skiprows lines, including comments; default: 0.

  • usecols (int or sequence, optional) –

    Which columns to read, with 0 being the first. For example, usecols = (1,4,5) will extract the 2nd, 5th and 6th columns. The default, None, results in all columns being read.

    When a single column has to be read it is possible to use an integer instead of a tuple. E.g usecols = 3 reads the fourth column the same way as usecols = (3,) would.

  • unpack (bool, optional) – If True, the returned array is transposed, so that arguments may be unpacked using x, y, z = loadtxt(...). When used with a structured data-type, arrays are returned for each field. Default is False.

  • ndmin (int, optional) – The returned array will have at least ndmin dimensions. Otherwise mono-dimensional axes will be squeezed. Legal values: 0 (default), 1 or 2.

  • encoding (str, optional) – Encoding used to decode the inputfile. Does not apply to input streams. The special value ‘bytes’ enables backward compatibility workarounds that ensures you receive byte arrays as results if possible and passes ‘latin1’ encoded strings to converters. Override this value to receive unicode arrays and pass strings as input to converters. If set to None the system default is used. The default value is ‘bytes’.

  • max_rows (int, optional) – Read max_rows lines of content after skiprows lines. The default is to read all the lines.

Returns

out – Data read from the text file.

Return type

BlockArray

Notes

This function aims to be a fast reader for simply formatted files. The genfromtxt function provides more sophisticated handling of, e.g., lines with missing values.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> from io import StringIO  
>>> c = StringIO("0 1\n2 3")  
>>> nps.loadtxt(c).get()  
array([[0., 1.],
       [2., 3.]])
>>> c = StringIO("1,0,2\n3,0,4")  
>>> x, y = nps.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True)  
>>> x.get()  
array([1., 3.])
>>> y.get()  
array([2., 4.])
nums.numpy.api.creation.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0)[source]

Return numbers spaced evenly on a log scale.

This docstring was copied from numpy.logspace.

Some inconsistencies with the NumS version may exist.

In linear space, the sequence starts at base ** start (base to the power of start) and ends with base ** stop (see endpoint below).

Parameters
  • start (BlockArray) – base ** start is the starting value of the sequence.

  • stop (BlockArray) – base ** stop is the final value of the sequence, unless endpoint is False. In that case, num + 1 values are spaced over the interval in log-space, of which all but the last (a sequence of length num) are returned.

  • num (integer, optional) – Number of samples to generate. Default is 50.

  • endpoint (boolean, optional) – If true, stop is the last sample. Otherwise, it is not included. Default is True.

  • base (float, optional) – The base of the log space. The step size between the elements in ln(samples) / ln(base) (or log_base(samples)) is uniform. Default is 10.0.

  • dtype (dtype) – The type of the output array. If dtype is not given, infer the data type from the other input arguments.

  • axis (int, optional) –

    The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

    New in version 1.16.0.

Returns

samplesnum samples, equally spaced on a log scale.

Return type

BlockArray

See also

arange

Similar to linspace, with the step size specified instead of the number of samples. Note that, when used with a float endpoint, the endpoint may or may not be included.

linspace

Similar to logspace, but with the samples uniformly distributed in linear space, instead of log space.

Notes

Logspace is equivalent to the code

>>> y = nps.linspace(start, stop, num=num, endpoint=endpoint)  
... 
>>> power(base, y).astype(dtype)  
... 

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.logspace(2.0, 3.0, num=4).get()  
array([ 100.        ,  215.443469  ,  464.15888336, 1000.        ])
>>> nps.logspace(2.0, 3.0, num=4, base=2.0).get()  
array([4.        ,  5.0396842 ,  6.34960421,  8.        ])
nums.numpy.api.creation.ones(shape, dtype=<class 'float'>)[source]

Return a new array of given shape and type, filled with ones.

This docstring was copied from numpy.ones.

Some inconsistencies with the NumS version may exist.

Parameters
  • shape (int or sequence of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – The desired data-type for the array, e.g., int. Default is float.

Returns

out – Array of ones with the given shape and dtype.

Return type

BlockArray

See also

ones_like

Return an array of ones with shape and type of input.

empty

Return a new uninitialized array.

zeros

Return a new array setting values to zero.

full

Return a new array of given shape filled with value.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.ones(5).get()  
array([1., 1., 1., 1., 1.])
>>> nps.ones((5,), dtype=int).get()  
array([1, 1, 1, 1, 1])
>>> nps.ones((2, 1)).get()  
array([[1.],
       [1.]])
>>> s = (2,2)  
>>> nps.ones(s).get()  
array([[1.,  1.],
       [1.,  1.]])
nums.numpy.api.creation.ones_like(prototype, dtype=None, order='K', shape=None)[source]

Return an array of ones with the same shape and type as a given array.

This docstring was copied from numpy.ones_like.

Some inconsistencies with the NumS version may exist.

Parameters
  • prototype (array_like) – The shape and data-type of a define these same attributes of the returned array.

  • dtype (data-type, optional) – Overrides the data type of the result.

  • order ({'C', 'F', 'A', or 'K'}, optional) – Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

  • shape (int or sequence of ints, optional.) – Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

Returns

out – Array of ones with the same shape and type as a.

Return type

BlockArray

See also

empty_like

Return an empty array with shape and type of input.

zeros_like

Return an array of zeros with shape and type of input.

full_like

Return a new array with shape of input filled with value.

ones

Return a new array setting values to one.

Notes

Only order=’K’ is supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(6)  
>>> x = x.reshape((2, 3))  
>>> x.get()  
array([[0, 1, 2],
       [3, 4, 5]])
>>> nps.ones_like(x).get()  
array([[1, 1, 1],
       [1, 1, 1]])
>>> y = nps.arange(3, dtype=float)  
>>> y.get()  
array([0., 1., 2.])
>>> nps.ones_like(y).get()  
array([1.,  1.,  1.])
nums.numpy.api.creation.zeros(shape, dtype=<class 'float'>)[source]

Return a new array of given shape and type, without initializing entries.

This docstring was copied from numpy.zeros.

Some inconsistencies with the NumS version may exist.

Return a new array of given shape and type, filled with zeros.

Parameters
  • shape (int or tuple of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – The desired data-type for the array, e.g., int. Default is float.

Returns

out – Array of zeros with the given shape and dtype.

Return type

BlockArray

See also

zeros_like

Return an array of zeros with shape and type of input.

empty

Return a new uninitialized array.

ones

Return a new array setting values to one.

full

Return a new array of given shape filled with value.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.zeros(5).get()  
array([ 0.,  0.,  0.,  0.,  0.])
>>> nps.zeros((5,), dtype=int).get()  
array([0, 0, 0, 0, 0])
>>> nps.zeros((2, 1)).get()  
array([[ 0.],
       [ 0.]])
>>> s = (2,2)  
>>> nps.zeros(s).get()  
array([[ 0.,  0.],
       [ 0.,  0.]])
nums.numpy.api.creation.zeros_like(prototype, dtype=None, order='K', shape=None)[source]

Return an array of zeros with the same shape and type as a given array.

This docstring was copied from numpy.zeros_like.

Some inconsistencies with the NumS version may exist.

Parameters
  • prototype (array_like) – The shape and data-type of prototype define these same attributes of the returned array.

  • dtype (data-type, optional) – Overrides the data type of the result.

  • order ({'C', 'F', 'A', or 'K'}, optional) – Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

  • shape (int or sequence of ints, optional.) – Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

Returns

out – Array of zeros with the same shape and type as prototype.

Return type

BlockArray

See also

empty_like

Return an empty array with shape and type of input.

ones_like

Return an array of ones with shape and type of input.

full_like

Return a new array with shape of input filled with value.

zeros

Return a new array setting values to zero.

Notes

Only order=’K’ is supported.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(6)  
>>> x = x.reshape((2, 3))  
>>> x.get()  
array([[0, 1, 2],
       [3, 4, 5]])
>>> nps.zeros_like(x).get()  
array([[0, 0, 0],
       [0, 0, 0]])
>>> y = nps.arange(3, dtype=float)  
>>> y.get()  
array([0., 1., 2.])
>>> nps.zeros_like(y).get()  
array([0.,  0.,  0.])