You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a lot of redundancy in each reform checking if it's active or not. We can make this a function for them all to call, either here or in policyengine-core.
Here's one way:
# File: policyengine_us/reforms/utils.pyfrompolicyengine_core.periodsimportperiodasperiod_defcreate_reform_if_active(parameters, period, parameter_path, reform_function, bypass: bool=False):
""" Check if a reform's parameter is truthy in any of the next five years and create the reform if so. Args: parameters: The parameters object from the reform function. period: The current period. parameter_path: A string representing the path to the relevant parameter. reform_function: A function that creates and returns the reform. bypass: If True, always return the reform regardless of the parameter value. Returns: Reform or None: The reform if the parameter is truthy or bypassed, None otherwise. """ifbypass:
returnreform_function()
current_period=period_(period)
for_inrange(5):
ifparameters(current_period).get_descendants(parameter_path):
returnreform_function()
current_period=current_period.offset(1, "year")
returnNone# Example usage:# def create_my_reform():# # Reform creation logic here# return Reform()## my_reform = create_reform_if_active(parameters, period, "gov.some.parameter", create_my_reform)
There's a lot of redundancy in each reform checking if it's active or not. We can make this a function for them all to call, either here or in policyengine-core.
Here's one way:
For example, Wyden-Smith would look like:
and DC CTC would look like:
@nikhilwoodruff should this go in core?
@PavelMakarchuk fyi given the new reform modeling hire.
The text was updated successfully, but these errors were encountered: