Skip to content

Commit 7800242

Browse files
committed
fixing
1 parent dac3431 commit 7800242

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

db_dtypes/json.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ def _from_sequence(cls, scalars, *, dtype=None, copy=False):
120120
@classmethod
121121
def _concat_same_type(cls, to_concat) -> JSONArray:
122122
"""Concatenate multiple JSONArray."""
123-
chunks = [array for ea in to_concat for array in ea._pa_array.iterchunks()]
123+
chunks = [
124+
pa_array_chunks
125+
for item in to_concat
126+
for pa_array_chunks in item._pa_array.iterchunks()
127+
]
124128
arr = pa.chunked_array(chunks, type=pa.string())
125129
return cls(arr)
126130

@@ -166,13 +170,10 @@ def __getitem__(self, item):
166170
return type(self)(pa.chunked_array([], type=pa.string()))
167171
elif item.dtype.kind in "iu":
168172
return self.take(item)
169-
elif item.dtype.kind == "b":
170-
return type(self)(self._pa_array.filter(item))
171173
else:
172-
raise IndexError(
173-
"Only integers, slices and integer or "
174-
+ "boolean arrays are valid indices."
175-
)
174+
# `check_array_indexer` should verify that the assertion hold true.
175+
assert item.dtype.kind == "b"
176+
return type(self)(self._pa_array.filter(item))
176177
elif isinstance(item, tuple):
177178
item = indexers.unpack_tuple_and_ellipses(item)
178179

tests/unit/test_json.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ def test_getitems_w_unboxed_dict():
7272
data[0]["unknown"]
7373

7474

75-
def test_getitems_w_invalid_numpy_array():
76-
data = db_dtypes.JSONArray._from_sequence(JSON_DATA.values())
77-
idx = np.array(["str"])
78-
with pytest.raises(IndexError):
79-
data[idx]
80-
81-
8275
def test_getitems_when_iter_with_null():
8376
data = db_dtypes.JSONArray._from_sequence([JSON_DATA["null"]])
8477
s = pd.Series(data)

0 commit comments

Comments
 (0)