From c1a3013d625210e52f1424972691cd9b1b6ad44c Mon Sep 17 00:00:00 2001 From: Doug Branton Date: Tue, 16 Jul 2024 15:11:11 -0700 Subject: [PATCH] add reproducibility test --- tests/nested_pandas/nestedframe/test_nestedframe.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/nested_pandas/nestedframe/test_nestedframe.py b/tests/nested_pandas/nestedframe/test_nestedframe.py index 6dc52b2..019f5f9 100644 --- a/tests/nested_pandas/nestedframe/test_nestedframe.py +++ b/tests/nested_pandas/nestedframe/test_nestedframe.py @@ -169,6 +169,17 @@ def test_from_flat(index): assert len(out_nf) == 5 +def test_recover_from_flat(): + """test that going to_flat and then from_flat recovers the same df""" + nf = generate_data(5, 10, seed=1) + + flat = nf["nested"].nest.to_flat() + + nf2 = NestedFrame.from_flat(nf[["a", "b"]].join(flat), base_columns=["a", "b"], name="nested") + + assert nf2.equals(nf) + + def test_query(): """Test that NestedFrame.query handles nested queries correctly"""