Skip to content
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
2 changes: 1 addition & 1 deletion arkouda/numpy/pdarraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def array(
try:
from arkouda.numpy.dtypes import dtype as ak_dtype

if dtype is not None and ak_dtype(dtype) != "bigint":
if dtype is not None and ak_dtype(dtype) not in (bigint, "bigint"):
# if the user specified dtype, use that dtype
a = np.array(a, dtype=dtype)
elif (
Expand Down
8 changes: 3 additions & 5 deletions arkouda/pandas/extension/_arkouda_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
ArkoudaInt64Dtype,
ArkoudaUint8Dtype,
ArkoudaUint64Dtype,
_ArkoudaBaseDtype,
)


Expand Down Expand Up @@ -114,6 +113,8 @@ def __init__(
def _from_sequence(cls, scalars, dtype=None, copy=False):
from arkouda.numpy.pdarraycreation import array as ak_array

from ._dtypes import ArkoudaBigintDtype

# normalize dtype input
if (
dtype is not None
Expand All @@ -122,13 +123,10 @@ def _from_sequence(cls, scalars, dtype=None, copy=False):
or str(dtype) in {"bigint", "ak.bigint"}
)
or dtype is ArkoudaBigintDtype
or isinstance(dtype, ArkoudaBigintDtype)
):
dtype = "bigint"

# If pandas passes our own EA dtype, ignore it and infer from data
if isinstance(dtype, _ArkoudaBaseDtype):
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