Skip to content

Commit

Permalink
Fix memory_usage() for ListSeries (#11355)
Browse files Browse the repository at this point in the history
This PR fixes the `memory_usage()` call for `ListSeries`. This is a bugfix. https://www.github.com/rapidsai/cuspatial/pull/585 depends on this. Perhaps it can get into `branch-22.08`?

Fixes #11346.

Authors:
  - H. Thomson Comer (https://github.com/thomcom)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #11355
  • Loading branch information
thomcom authored Jul 26, 2022
1 parent c07557c commit e7e5f45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/cudf/cudf/core/column/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def memory_usage(self):
child0_size = (
current_base_child.size + 1 - current_offset
) * current_base_child.base_children[0].dtype.itemsize
current_offset = current_base_child.base_children[0][
current_offset
]
current_offset = current_base_child.base_children[
0
].element_indexing(current_offset)
n += child0_size
current_base_child = current_base_child.base_children[1]

Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,10 @@ def test_list_astype():
s2 = s.list.astype("string")
assert s2.dtype == cudf.ListDtype(cudf.ListDtype("string"))
assert_eq(s.list.leaves.astype("string"), s2.list.leaves)


def test_memory_usage():
s1 = cudf.Series([[1, 2], [3, 4]])
assert s1.memory_usage() == 44
s2 = cudf.Series([[[[1, 2]]], [[[3, 4]]]])
assert s2.memory_usage() == 68

0 comments on commit e7e5f45

Please sign in to comment.