ExplainaBoard
ExplainaBoard copied to clipboard
Replacing structured types with datatype
Several functions use NumPy's structured arrays. I thought it is better to replace them to dataclasses for several reasons:
- It is basically not informative to users to know what members are contained in the array since the array does not provide static type information (i.e., users can't comprehend the behavior by seeing the function signatures). Unfortunately we couldn't expect that structured arrays are supported by a mypy-friendly manner in the near future: https://github.com/numpy/numpy/issues/7370#issuecomment-908308757
- Manipulating structured arrays with heterogeneous data is usually much expensive than manipulating usual objects. Enforcing memory alignment can mitigate this problem, but it requires to constrain the length of string fields, which may be not suitable for the current implementation.
RFC: @neubig @pfliu-nlp
Sorry I realize I didn't comment on this yet, but I agree with this general direction and I think we're moving in this direction already!