Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Nov 11, 2021
1 parent b961a40 commit c36d9d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/awkward/_v2/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,9 @@ def validityerror(self, path="layout"):
return paramcheck
return self._validityerror(path)

def nbytes(self):
return self._nbytes_part()

def purelist_parameter(self, key):
return self.Form.purelist_parameter(self, key)

Expand Down
2 changes: 2 additions & 0 deletions src/awkward/_v2/contents/numpyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ def _validityerror(self, path):
)
return ""


def _rpad(self, target, axis, depth, clip):
if len(self.shape) == 0:
raise ValueError("cannot rpad a scalar")
Expand All @@ -1003,6 +1004,7 @@ def _rpad(self, target, axis, depth, clip):
else:
return self.rpad_axis0(target, clip=True)


def _to_arrow(self, pyarrow, mask_node, validbytes, length, options):
if self._data.ndim != 1:
return self.toRegularArray()._to_arrow(
Expand Down
20 changes: 20 additions & 0 deletions tests/v2/test_0927-numpy-array-nbytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

from __future__ import absolute_import

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

from awkward._v2.tmp_for_testing import v1_to_v2, v1_to_v2_index

pytestmark = pytest.mark.skipif(
ak._util.py27, reason="No Python 2.7 support in Awkward 2.x"
)

def test():
np_data = np.random.random(size=(4, 100 * 1024 * 1024 // 8 // 4))
array = ak.from_numpy(np_data, regulararray=False)
array = v1_to_v2(array.layout)

assert np_data.nbytes == array.nbytes()

0 comments on commit c36d9d6

Please sign in to comment.