Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes 3943 issue with reshape #3947

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions arkouda/pdarrayclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1817,13 +1817,17 @@ def reshape(self, *shape):
"""
# allows the elements of the shape parameter to be passed in as separate arguments
# For example, a.reshape(10, 11) is equivalent to a.reshape((10, 11))
# the lenshape variable addresses an error that occurred when a single integer was
# passed
if len(shape) == 1:
shape = shape[0]
elif not isinstance(shape, pdarray):
lenshape = 1
if (not isinstance(shape, int)) and (not isinstance(shape, pdarray)):
shape = [i for i in shape]
lenshape = len(shape)
return create_pdarray(
generic_msg(
cmd=f"reshape<{self.dtype},{self.ndim},{len(shape)}>",
cmd=f"reshape<{self.dtype},{self.ndim},{lenshape}>",
args={
"name": self.name,
"shape": shape,
Expand Down
2 changes: 2 additions & 0 deletions tests/pdarrayclass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_reshape(self, dtype):
r = a.reshape((2, 2))
assert r.shape == (2, 2)
assert isinstance(r, ak.pdarray)
b = r.reshape(4)
assert ak.all(a==b)

@pytest.mark.skip_if_max_rank_less_than(3)
def test_reshape_and_flatten_bug_reproducer(self):
Expand Down
Loading