Skip to content

Commit

Permalink
Fix: from_numpy references ListArray64 (#1404)
Browse files Browse the repository at this point in the history
* Test: add test for #1403

* Fix: correct typo `ListArray64`
  • Loading branch information
agoose77 authored Apr 8, 2022
1 parent e718a8d commit edfce38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/awkward/_v2/operations/convert/ak_from_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def recurse(array, mask):
itemsize = asbytes.dtype.itemsize
starts = numpy.arange(0, len(asbytes) * itemsize, itemsize, dtype=np.int64)
stops = starts + numpy.char.str_len(asbytes)
data = ak._v2.contents.ListArray64(
data = ak._v2.contents.ListArray(
ak._v2.index.Index64(starts),
ak._v2.index.Index64(stops),
ak._v2.contents.NumpyArray(
Expand All @@ -88,7 +88,7 @@ def recurse(array, mask):
itemsize = asbytes.dtype.itemsize
starts = numpy.arange(0, len(asbytes) * itemsize, itemsize, dtype=np.int64)
stops = starts + numpy.char.str_len(asbytes)
data = ak._v2.contents.ListArray64(
data = ak._v2.contents.ListArray(
ak._v2.index.Index64(starts),
ak._v2.index.Index64(stops),
ak._v2.contents.NumpyArray(
Expand Down
17 changes: 17 additions & 0 deletions tests/v2/test_1403-from_numpy-strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

import pytest # noqa: F401
import awkward as ak # noqa: F401
import numpy as np


def test_unicode():
data = np.array(["this", "that"])
array = ak._v2.from_numpy(data)
assert array.to_list() == ["this", "that"]


def test_bytes():
data = np.array([b"this", b"that"], dtype="S")
array = ak._v2.from_numpy(data)
assert array.to_list() == [b"this", b"that"]

0 comments on commit edfce38

Please sign in to comment.