Skip to content
Open
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
2 changes: 1 addition & 1 deletion arkouda/numpy/pdarraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def array(
# If a is not already a numpy.ndarray, convert it
if not isinstance(a, np.ndarray):
try:
if dtype is not None and dtype != bigint:
if dtype is not None and dtype not in (bigint, "bigint"):
# if the user specified dtype, use that dtype
a = np.array(a, dtype=dtype)
elif (
Expand Down
7 changes: 6 additions & 1 deletion arkouda/pandas/extension/_arkouda_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ def __init__(
def _from_sequence(cls, scalars, dtype=None, copy=False):
from arkouda.numpy.pdarraycreation import array as ak_array

from ._dtypes import ArkoudaBigintDtype

# If pandas passes our own EA dtype, ignore it and infer from data
if isinstance(dtype, _ArkoudaBaseDtype):
dtype = dtype.numpy_dtype
if isinstance(dtype, ArkoudaBigintDtype) or getattr(dtype, "name", None) == "bigint":
dtype = "bigint"
else:
dtype = dtype.numpy_dtype

if dtype is not None and hasattr(dtype, "numpy_dtype"):
dtype = dtype.numpy_dtype
Expand Down
10 changes: 10 additions & 0 deletions tests/pandas/extension/arkouda_array_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,16 @@ def test_copy_default_behaves_like_deep_true(self, ea):
# Values preserved
np.testing.assert_array_equal(default_copy.to_numpy(), ea.to_numpy())

def test_pd_array_construct_from_ak_bigint_pdarray_explicit_dtype_does_not_cast_to_object(self):
# Regression: used to try cast<bigint,object,1> and fail on server
a = ak.array(np.array([0, -1, 2]), dtype="bigint")

b = pd.array(a, dtype="ak.bigint")

# Should be Arkouda-backed and preserve values
assert str(b.dtype) in ("ak_bigint", "ak.bigint", "bigint") # tolerate aliasing
np.testing.assert_array_equal(np.asarray(b), np.array([0, -1, 2], dtype=object))


class TestArkoudaArrayAsType:
def test_arkouda_array_astype_object_returns_numpy_object_array(self):
Expand Down