Conversation
|
I love this ❤ it adds some lecture overhead at first but having explicit contracts will definitely ease refactoring, bug correction, debugging... I would at a minimum create types mapping each important class. It's a layer of indirection maybe but I think it would make types more "drop-in" and ease code comprehension for most newcomers. |
|
I think we should move forward with this, any help needed? |
|
|
||
|
|
||
| #TODO change with a more specific type | ||
| ArrayLike = Any |
There was a problem hiding this comment.
This will be shipped out of the box in Numpy 1.20/21
| self.variable = variable | ||
| self.simulation = population.simulation | ||
| self._memory_storage = InMemoryStorage(is_eternal = (self.variable.definition_period == ETERNITY)) | ||
| def __init__(self, variable:'Variable', population:'Population'): |
There was a problem hiding this comment.
Flake won't like the lack of spaces.
Also you can forward-reference them no?
| def __init__(self, variable:'Variable', population:'Population'): | ||
| self.population:'Population' = population | ||
| self.variable:'Variable' = variable | ||
| # TODO change once decided if simulation is needed or not |
There was a problem hiding this comment.
I think this requires a bit more of examination. I'll take a look.
| self.variable:'Variable' = variable | ||
| # TODO change once decided if simulation is needed or not | ||
| if population.simulation is None: | ||
| raise Exception('You need a simulation attached to the population') |
There was a problem hiding this comment.
Error messages in OpenFisca are meant to help the users discover not just what is wrong, but how can they solve their problems or reach for help. Could you develop this further?
Technical changes