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

Fix flaky memory usage test by guaranteeing array size. #10114

Merged
Merged
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
14 changes: 10 additions & 4 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5474,20 +5474,26 @@ def test_memory_usage_list():
@pytest.mark.parametrize("rows", [10, 100])
def test_memory_usage_multi(rows):
deep = True
# We need to sample without replacement to guarantee that the size of the
# levels are always the same.
df = pd.DataFrame(
{
"A": np.arange(rows, dtype="int32"),
"B": np.random.choice(np.arange(3, dtype="int64"), rows),
"C": np.random.choice(np.arange(3, dtype="float64"), rows),
"B": np.random.choice(
np.arange(rows, dtype="int64"), rows, replace=False
),
"C": np.random.choice(
np.arange(rows, dtype="float64"), rows, replace=False
),
}
).set_index(["B", "C"])
gdf = cudf.from_pandas(df)
# Assume MultiIndex memory footprint is just that
# of the underlying columns, levels, and codes
expect = rows * 16 # Source Columns
expect += rows * 16 # Codes
expect += 3 * 8 # Level 0
expect += 3 * 8 # Level 1
expect += rows * 8 # Level 0
expect += rows * 8 # Level 1

assert expect == gdf.index.memory_usage(deep=deep)

Expand Down