Skip to content

Commit

Permalink
Closes 3943 issue with reshape (#3947)
Browse files Browse the repository at this point in the history
* Ready for testing

* Addresses flake8 error

---------

Co-authored-by: drculhane <[email protected]>
Co-authored-by: ajpotts <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2025
1 parent a77be87 commit fcdd559
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit fcdd559

Please sign in to comment.