Skip to content

anonymous_namespace{binding_builder.hh}

Return Name Description
constexpr const char * reshape_doc static constexpr

static constexpr

constexpr const char * reshape_doc = R"a(Reshape an array if possible.
For contiguous arrays, reshaping can be a copy-free transformation. It requires
that the final shape contain the same number of elements as in the inital shape.
For NON-contiguous arrays, reshaping, in general, is not possible without a copy.
As such, an explicit flag is passed as an extra parameter to indicate whether the
reshape should occur by means of a copy operation. If False, an exception is raised.
For contiguous arrays, the copy flag is ignored.
Args:
shape (Sequence[int]): The target shape to reshape the array into.
copy (bool): Whether reshaping should use a copy. Applies only for non-contiguous
arrays, and is ignored for contiguous arrays. Default: False.
Returns:
reshaped (View | Owner): The reshaped array if a transformation can be done.
For contiguous arrays, the reshaped array is a new view. For non-contiguous
arrays, the reshaped array is a new owning copy of the data.
Raises:
RuntimeException: Raised if the input and output shapes have different numbers of
elements, or if attempting to reshape a non-contiguous array without the copy
parameter set to True.
)a"

Defined in src/lib/pyncarray/binding_builder.hh:56