- Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
🐛 Bug
This is a serious bug. If ExampleFactory is instantiated with fields in the dict format, calling from_list will throw an error.
This line in ExampleFactory.from_list is the problem (self.fields is a dict so the loop is iterating over the field names):
for value, field in filter(lambda el: el[1] is not None, zip(data, self.fields)):And this is my workaround (not tested!!!):
fields = self.fields.values() if isinstance(self.fields, dict) else self.fields for value, field in filter(lambda el: el[1] is not None, zip(data, fields)):The ExampleFactory tests don't cover this case.
EDIT:
The same thing happens if the fields are passed as a list and ExampleFactory.from_dict is called.
Steps to Reproduce
Example source:
>>> from podium import Field >>> from podium.datasets import ExampleFactory >>> >>> fields = {'f': Field('f')} >>> ExampleFactory(fields).from_list(['some data']) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "c:\users\mario\desktop\takelab\podium\podium\datasets\example_factory.py", line 146, in from_list set_example_attributes(example, field, value) File "c:\users\mario\desktop\takelab\podium\podium\datasets\example_factory.py", line 357, in set_example_attributes set_example_attributes_for_single_field(example, field, val) File "c:\users\mario\desktop\takelab\podium\podium\datasets\example_factory.py", line 349, in set_example_attributes_for_single_field for name, data in field.preprocess(val): AttributeError: 'str' object has no attribute 'preprocess'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working