Skip to content

BUG: ascontiguousarray and asfortranarray make 0d scalars into 1d arrays #5300

@tbekolay

Description

@tbekolay

Not sure if this is intended behavior or a bug, but I had been under the assumption that the result of np.ascontiguousarray would be the same shape as the input. This is true except in the case of scalars.

>>> scalar = np.float64(3.0)
>>> np.asarray(scalar).shape  # asarray doesn't change shape
()
>>> np.ascontiguousarray(scalar).shape  # ascontiguousarray does
(1,)

If this is what should be expected, it would be helpful to document this in its docstring.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions