Open MattiSG opened 6 years ago
I'm wondering if this should include deprecating formula helpers and replacing them with NumPy snippets? I see only 3 there, and they are not documented (https://github.com/openfisca/openfisca-doc/issues/4).
I am not so sure that pluralizing first argument will help a lot when the vector nature of the argument is made clearer and emphasized at the beginning of the training. Using singular for both the entity and the first parameter helps a lot. If not you end up asking yourself should I use a plural here or a singular, am I dealing with the entity or the vector etc. From my experience, when the vector thing is well understood, the question of the use of plural vs singular changes in nature.
Hi @MattiSG this is IMHO a good direction to move forward 😃. I've had experienced this issue myself.
Country Template: pluralise first argument name in all formulas, using the pluralised name of the entity. Doc: pluralise first argument name in all formulas, using the pluralised name of the entity. Doc: document the recommendation to use the pluralised name of the entity as the first formula parameter.
I've passed quite a lot of time of my performance improvement efforts trying to understand the nature of the receiving arguments. Given the lack of native type check in Python
(at least < 3.6), it can be a bit cumbersome.
I think naming should more or less reflect the duck-typing of the argument. Whether it is a list
, tuple
, set
or a numpy.ndarray
, I think argument name should be pluralised. Even if argument is an empty collection or if it has just one element.
(Note: it goes beyond the current RFC, but arguments, if not optional, should respect duck-typing, i.e. not passing None
where a list
is expected).
I am not so sure that pluralizing first argument will help a lot when the vector nature of the argument is made clearer and emphasized at the beginning of the training.
I see two other arguments for this:
It is easier IMHO to foster contribution if the fact that we're dealing with a vector is self-evident. We can only do a limited amount of training, for the rest we rely on the doc, the code and the tests.
It is way easier to refactor and to improve code when we know more or less the signature of functions and their returning type. If I can see I'm dealing with vectors, I'll adapt my refactoring approach immediately.
Core: always import numpy rather than import numpy as np to increase discoverability of that library.
Not sure about this one, as all code snippets I've seen so far in the internet use
import numpy as np
Closing as stale. This might well still be one of the core issues in OF, and some ideas are starting to emerge for addressing it from a different perspective (e.g. creating more affordances for directing computation based on conditions, which would eliminate the NumPy-idiomatic "logic multiply" operator in favor of something more salient and documented, as well as afford a large performance boost if initial trials prove a reliable indication).
I'm reopening this issue as I'd like to arrive to a consensus on this. I'll probably split it into several other issues to have more targeted discussions.
Current assumptions
Traditionally, vectorial computations have been hidden from newcomers, in the hope (https://github.com/openfisca/openfisca-core/issues/651#issuecomment-391152789) that users would not need to grasp the complexity up front, and that they could be confronted to it later.
How this is problematic
Experiments that prove it is the good direction
Concrete steps that would be taken
import numpy as np
to increase discoverability of that library.NumPy
in all texts.Estimated impact