From c17b331c3b8ad231e1b5d6158f9bcf62aa68ef10 Mon Sep 17 00:00:00 2001 From: Amanda Potts Date: Tue, 10 Sep 2024 19:57:51 -0400 Subject: [PATCH] #3757: ak.array gives unexpected results on a transposed numpy multi-dimensional array. --- arkouda/pdarraycreation.py | 2 ++ tests/pdarray_creation_test.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/arkouda/pdarraycreation.py b/arkouda/pdarraycreation.py index 81e063f867..42f656cb40 100644 --- a/arkouda/pdarraycreation.py +++ b/arkouda/pdarraycreation.py @@ -291,6 +291,8 @@ def array( raise RuntimeError( "Array exceeds allowed transfer size. Increase ak.client.maxTransferBytes to allow" ) + # Make a copy to avoid + a = a.copy() # Pack binary array data into a bytes object with a command header # including the dtype and size. If the server has a different byteorder # than our numpy array we need to swap to match since the server expects diff --git a/tests/pdarray_creation_test.py b/tests/pdarray_creation_test.py index fb574d86f0..016e0765d5 100644 --- a/tests/pdarray_creation_test.py +++ b/tests/pdarray_creation_test.py @@ -104,6 +104,19 @@ def test_array_creation_misc(self): with pytest.raises(TypeError): ak.array(list(list(0))) + @pytest.mark.skip_if_max_rank_less_than(2) + def test_array_creation_transpose_bug_reproducer(self): + + import numpy as np + + rows = 5 + cols = 5 + nda = np.random.randint(1, 10, (rows, cols)) + + from arkouda.testing import assert_arkouda_array_equal + + assert_arkouda_array_equal(ak.transpose(ak.array(nda)), ak.array(np.transpose(nda))) + def test_infer_shape_from_size(self): from arkouda.util import _infer_shape_from_size