numpy.require

numpy.require(a, dtype=None, requirements=None)

Return an ndarray of the provided type that satisfies requirements.

This function is useful to be sure that an array with the correct flags is returned for passing to compiled code (perhaps through ctypes).

Parameters:

a : array_like

The object to be converted to a type-and-requirement satisfying array

dtype : data-type

The required data-type (None is the default data-type – float64)

requirements : list of strings

The requirements list can be any of the following

  • ‘ENSUREARRAY’ (‘E’) - ensure that a base-class ndarray
  • ‘F_CONTIGUOUS’ (‘F’) - ensure a Fortran-contiguous array
  • ‘C_CONTIGUOUS’ (‘C’) - ensure a C-contiguous array
  • ‘ALIGNED’ (‘A’) - ensure a data-type aligned array
  • ‘WRITEABLE’ (‘W’) - ensure a writeable array
  • ‘OWNDATA’ (‘O’) - ensure an array that owns its own data

Notes

The returned array will be guaranteed to have the listed requirements by making a copy if needed.

Previous topic

numpy.asscalar

Next topic

numpy.append

This Page

Quick search