I'm getting a TypeError: unbound method set.union() needs an argument when running the test.
There is no set.union() in my function and I wonder if it's caused by the set.union() in the sets_test_data.py?
I've copied over the function as well as the relevant lists and sets from the sets_test_data.py and sets_categories_data.py to my local jupyter and used the loop of the test script to see if I can debug the error locally, but I'm not getting any errors here, the function works as expected.
My function is as follows:
def singleton_ingredients(dishes, intersection):
"""Determine which `dishes` have a singleton ingredient (an ingredient that only appears once across dishes).
:param dishes: list - of ingredient sets.
:param intersection: constant - can be one of `<CATEGORY>_INTERSECTIONS` constants imported from `sets_categories_data.py`.
:return: set - containing singleton ingredients.
Each dish is represented by a `set` of its ingredients.
Each `<CATEGORY>_INTERSECTIONS` is an `intersection` of all dishes in the category. `<CATEGORY>` can be any one of:
(VEGAN, VEGETARIAN, PALEO, KETO, or OMNIVORE).
The function should return a `set` of ingredients that only appear in a single dish.
"""
full_list = [ingredient for dish in dishes for ingredient in dish if ingredient not in intersection]
unique_ingredients = {item for item in set(full_list) if full_list.count(item) == 1}
return unique_ingredients
I've included the test error as screenshot.
I hope someone can help, thanks in advance!