OpenSourceEconomics / skillmodels

MIT License
11 stars 5 forks source link

Make attributes immutable where possible #34

Closed janosg closed 3 years ago

janosg commented 5 years ago

Current Situation

When I wrote skillmodels, I did not see the benefit of immutability. Therefore many attributes of SkillModel, which are generated in ModelSpecProcessor are lists and dictionaries, even though we never change them later.

Desired Situation

Replace lists by tuples, unless we use them in numba functions that in the most recent numba version need them to be numpy arrays (see #33). Replace dictionaries by namedtuples.

Implementation

Do this as early as possible, i.e. in ModelSpecProcessor

Anecdote

When converting skillmodels to use estimagic I lost one day on debugging. The problem was that I had accidentally appended something to a list of measurements. So this is an easy but important change!

janosg commented 3 years ago

Solved.