-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Variable and Column #590
Conversation
156b5f8
to
0149a63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I have a few question on the remaining Column references
```py | ||
class housing_occupancy_status(Variable): | ||
value_type = Enum | ||
possible_values = Enum([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more relevant to have the Enum be outside of the Variable ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know.
The goal of this part of the Changelog is to show OpenFisca reusers what has changed and what they need to do to adapt their code.
Moving the Enum
declaration out of the variable definition is not related to this PR. It is more a consequence of #589. In France, most (all?) enums are declared in the variable block. I'm not sure we should anticipate the outcome of another PR in this PR changelog, at the risk of making this PR syntactic changes less understandable.
CHANGELOG.md
Outdated
label = "Basic income provided to adults" | ||
``` | ||
|
||
- `default` is now a `Variable` attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default_value
@@ -22,67 +21,34 @@ def N_(message): | |||
|
|||
# Base Column | |||
|
|||
def make_column_from_variable(variable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why keep colums if they are deprecated ? Should there be a comment indicating that they are ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , a comment is indeed necessary.
@@ -31,7 +32,7 @@ def new_test_case_array(holder, array): | |||
exc.simulation_index = simulation_index | |||
raise | |||
holder = simulation.get_holder(node['code']) | |||
column = holder.column | |||
column = make_column_from_variable(holder.variable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why keep column
? Is the name still relevant ? If columns are deprecated, should we indicate it in the code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indicated it in columns.py
.
This part of the code is full of Byriani, not properly documented, and we're not sure about what it does exactly. From there, two strategies are possible when we want to publish a change that impact this code:
- We try to understand how this piece of code work. When we succeed, we adapt the code so that it can work with the a Variable instead of a Column.
- Advantage: cleaner once its one, if we don't pollute the new
Variable
class with stuff fromColumn
that we don't really want to keep. - Drawback: high risk of getting lost, and to spend more time migrating this module we don't even know than making the changes we want to do.
- Advantage: cleaner once its one, if we don't pollute the new
- We consider this piece of code as legacy that we are maintaining in a minimalistic way. We try to avoid modifying it. If it needs a column, we give it a column, hoping that one day it will be rebuilt or remove.
- Advantage: Our time investment is more focused. We are more likely to deliver in time.
- Drawback: Some legacy modules stay in the code
I chose strategy 2, as columns were needed in several part of the code I don't want to deal with.
@@ -65,6 +58,59 @@ class Formula(object): | |||
dated_formulas = None # A list of dictionaries containing a formula instance and a start instant | |||
dated_formulas_class = None # A list of dictionaries containing a formula class and a start instant | |||
|
|||
@staticmethod | |||
def build_formula_class(attributes, variable, baseline_variable = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a comment here be useful ? As to what this method does ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment 👌
CHANGELOG.md
Outdated
@@ -1,5 +1,176 @@ | |||
# Changelog | |||
|
|||
# 19.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V20
setup.py
Outdated
@@ -7,7 +7,7 @@ | |||
|
|||
setup( | |||
name = 'OpenFisca-Core', | |||
version = '18.1.0', | |||
version = '19.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V20
e716aee
to
55133df
Compare
Breaking changes
Change the way Variables are declared
column
attribute byvalue_type
value_type
are:int
float
bool
str
date
Enum
Before:
Now:
default
is now aVariable
attributeBefore:
Now:
Variables
whichvalue_type
isstr
,max_lentgh
is now an attributeBefore:
After:
Variables
whichvalue_type
isEnum
,possible_values
is now an attribute:Before:
After:
PeriodSizeIndependentIntCol
:Variable
attributeis_period_size_independent
Deprecate
Column
Column
are now considered deprecated. Preferably useVariable
instead.If you do need a column for retro-compatibility, you can use:
In
TaxBenefitSystem
:neutralize_column
(deprecated since9.1.0
, replaced byneutralize_variable
)column_by_name
tovariables
get_column
toget_variable
update_column
add_column
automatically_loaded_variable
(irrelevant since conversion columns have been removed)VariableNotFound
toerrors
moduleIn
Holder
:holder.column
toholder.variable
In
Column
:Column
should only be instantiated usingmake_column_from_variable
. Former constructors do not work anymore.column.start
, which wasNone
since14.0.0
column.formula_class
byvariable.formula
column.enum
byvariable.possible_values
column.default
byvariable.default_value
In
formulas
:get_neutralized_column
toget_neutralized_variable
new_filled_column
In
Variable
:to_column