Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sparse/numba_backend/_coo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,11 +1070,11 @@ def reshape(self, shape, order="C"):
if order not in {"C", None}:
raise NotImplementedError("The `order` parameter is not supported")

if self.shape == shape:
return self
if any(d == -1 for d in shape):
extra = int(self.size / np.prod([d for d in shape if d != -1]))
shape = tuple([d if d != -1 else extra for d in shape])
if self.shape == shape:
return self

if self.size != reduce(operator.mul, shape, 1):
raise ValueError(f"cannot reshape array of size {self.size} into shape {shape}")
Expand Down
Loading