1e0e89516bd9780b632b0a8ea5bcd371d72c9fba,upsetplot/tests/test_data.py,,test_from_contents,#,117
Before Change
def test_from_contents(typ=set, id_column="id"):
contents = {"cat1": {"aa", "bb", "cc"},
"cat2": {"cc", "dd"},
"cat3": {"ee"},
}
empty_data = pd.DataFrame(index=["aa", "bb", "cc", "dd", "ee"])
baseline = from_contents(OrderedDict(contents), data=empty_data,
id_column=id_column)
// data=None
out = from_contents(OrderedDict(contents), id_column=id_column)
assert_frame_equal(out.sort_values(id_column), baseline)
// unordered contents dict
out = from_contents({"cat3": contents["cat3"],
"cat2": contents["cat2"],
"cat1": contents["cat1"]},
data=empty_data, id_column=id_column)
assert_frame_equal(out.reorder_levels(["cat1", "cat2", "cat3"]),
baseline)
// empty category
out = from_contents({"cat1": contents["cat1"],
"cat2": contents["cat2"],
"cat3": contents["cat3"],
"cat4": []},
After Change
def test_from_contents(typ=set, id_column="id"):
contents = OrderedDict([("cat1", {"aa", "bb", "cc"}),
("cat2", {"cc", "dd"}),
("cat3", {"ee"})])
empty_data = pd.DataFrame(index=["aa", "bb", "cc", "dd", "ee"])
baseline = from_contents(contents, data=empty_data,
id_column=id_column)
// data=None
out = from_contents(contents, id_column=id_column)
assert_frame_equal(out.sort_values(id_column), baseline)
// unordered contents dict
out = from_contents({"cat3": contents["cat3"],
"cat2": contents["cat2"],
"cat1": contents["cat1"]},
data=empty_data, id_column=id_column)
assert_frame_equal(out.reorder_levels(["cat1", "cat2", "cat3"]),
baseline)
// empty category
out = from_contents({"cat1": contents["cat1"],
"cat2": contents["cat2"],
"cat3": contents["cat3"],
"cat4": []},

In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances
Project Name: jnothman/UpSetPlot
Commit Name: 1e0e89516bd9780b632b0a8ea5bcd371d72c9fba
Time: 2019-05-30
Author: joel.nothman@gmail.com
File Name: upsetplot/tests/test_data.py
Class Name:
Method Name: test_from_contents