Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: return correct nbytes value for multidimensional NumPy arrays #928

Merged
merged 2 commits into from
Jun 15, 2021
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
4 changes: 2 additions & 2 deletions src/libawkward/array/NumpyArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,8 @@ namespace awkward {
void
NumpyArray::nbytes_part(std::map<size_t, int64_t>& largest) const {
int64_t len = 1;
if (!shape_.empty()) {
len = shape_[0];
for (auto size: shape_) {
len *= size;
}
size_t x = (size_t)ptr_.get();
auto it = largest.find(x);
Expand Down
13 changes: 13 additions & 0 deletions tests/test_0927-numpy-array-nbytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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


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