Skip to content

Make shape of scalar slices NDArray objects to follow NumPy conventions #117

@FrancescAlted

Description

@FrancescAlted

This exposes the issue:

import numpy as np
import blosc2

shape = (5, 5)
slice_ = (slice(4, 6), slice(4, 6))

npa = np.arange(int(np.prod(shape)), dtype=np.int32).reshape(shape)
b2a = blosc2.asarray(npa)

# Get a slice with Numpy
npbuffer = npa[slice_]
print(f"numpy {npbuffer.shape=}")

# Get a slice with Blosc2
b2buffer = b2a[slice_]
print(f"blosc2 {b2buffer.shape=}")

The output is:

numpy npbuffer.shape=(1, 1)
blosc2 b2buffer.shape=()

Blosc2 should follow NumPy convention here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions