harvard-hbs / team-formation

A tool to form teams from a larger group based on clustering and diversity constraints
MIT License
1 stars 0 forks source link

Check for missing values for an attribute #5

Closed bbenson-hbs closed 7 months ago

bbenson-hbs commented 7 months ago

There is a hard-to-debug error in categories_to_bool_vars when there are missing NaN values for an attribute value:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bwb/.pyenv/versions/itf/lib/python3.11/site-packages/team_formation/team_assignment.py", line 188, in __init__
    bool_vars = categories_to_bool_vars(attr_name, self.participants[attr_name])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bwb/.pyenv/versions/itf/lib/python3.11/site-packages/team_formation/team_assignment.py", line 610, in categories_to_bool_vars
    unique_cats = sorted(set(cat_values))
                  ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'float' and 'str'

There should be a check for missing values with a descriptive error.

bbenson-hbs commented 7 months ago

Fixed in https://github.com/harvard-hbs/team-formation/commit/7d14f7b2c8e7d7ece43dd2a1fe680f4ee9d4af53