Closed valentineap closed 2 years ago
We could consider making this a defaultdict
to make it easy to assign default values to 'optional' fields...
Yeah, I like the idea of . (And the exception name above 🤣)defaultdict
This separates metadata from other problem-related fields 👍
Edit: defaultdict
isn't as handy as I thought. The inbuilt data structure can't handle default values for different keys.
At present we have embedded all the problem metadata into class variables:
I wonder if we should change to have a class variable,
metadata
, which holds a dictionary containing the metadata:The motivation would be two-fold: first, it makes it much easier to write functions that parse metadata, since they just need to operate on dictionaries; second, it becomes easier for us (or users) to define new metadata fields in future. We can still enforce required fields, e.g.
but metadata-using-functions don't necessarily need to know about all metadata fields by name.
Thoughts?