Massachusetts income tax#

Massachusetts has a mostly flat income tax of five percent, with personal exemptions based on filing status and number of dependents. It also has other exemptions, deductions, and credits, including a partial federal Earned Income Tax Credit match.

Examples#

Full income tax#

from policyengine_us import IndividualSim
import pandas as pd
import plotly.express as px

LIGHT_GRAY = "#F5F5F5"
GRAY = "#BDBDBD"
BLUE = "#5091cc"
LIGHT_BLUE = "lightblue"
DARK_BLUE = "darkblue"

COLOR_MAP = {"0": GRAY, "1": LIGHT_BLUE, "2": BLUE, "3": DARK_BLUE}


def make_tax(adults, children):
    sim = IndividualSim(year=2022)
    sim.add_person(name="head", age=25, rent=12_000)
    members = ["head"]
    if adults == 2:
        sim.add_person(name="spouse")
        members += ["spouse"]
    for i in range(children):
        child = "child{}".format(i)
        sim.add_person(name=child, age=6)
        members += [child]
    sim.add_tax_unit(name="tax_unit", members=members)
    sim.add_spm_unit(name="spm_unit", members=members)
    sim.add_household(name="household", members=members, state_code="MA")
    sim.vary("employment_income", max=100_000, step=100)
    return pd.DataFrame(
        dict(
            employment_income=sim.calc("employment_income")[0],
            state_income_tax=sim.calc("state_income_tax")[0].round(),
            ma_eitc=sim.calc("ma_eitc")[0].round(),
            ma_limited_income_tax_credit=sim.calc(
                "ma_limited_income_tax_credit"
            )[0].round(),
            mtr=sim.deriv(
                "state_income_tax", "employment_income", wrt_target="head"
            ),
            adults=adults,
            children=str(children),
        )
    )


# Make a table of state taxes for different numbers of adults and children.
l = []
for adults in range(1, 3):
    for children in range(0, 4):
        l.append(make_tax(adults, children))

df = pd.concat(l)

LABELS = dict(
    employment_income="Employment income",
    state_income_tax="Massachusetts income tax",
    mtr="State marginal tax rate",
    adults="Adults",
    children="Children",
    state_eitc="Massachusetts EITC",
    ma_limited_income_tax_credit="Massachusetts Limited Income Credit",
)

fig = px.line(
    df,
    "employment_income",
    "state_income_tax",
    color="children",
    animation_frame="adults",
    labels=LABELS,
    title="Massachusetts state income tax",
    color_discrete_map=COLOR_MAP,
)
fig.update_layout(
    xaxis_tickformat="$,",
    yaxis_tickformat="$,",
    plot_bgcolor="white",
    xaxis_gridcolor=LIGHT_GRAY,
    yaxis_gridcolor=LIGHT_GRAY,
)
fig.show()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/individual_sim.py:261, in IndividualSim.calc(self, var, period, target, index, map_to, reform)
    260 try:
--> 261     result = self.simulation.calculate(var, period)
    262 except:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/tax/income/state_income_tax.py:34, in state_income_tax.formula(tax_unit, period, parameters)
     33 else:
---> 34     return add(tax_unit, period, state_income_tax.adds)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:704, in Simulation._run_formula(self, variable, population, period)
    703     for subtracted_variable in subtracts_list:
--> 704         values = values - self.calculate(
    705             subtracted_variable, period, map_to=variable.entity.key
    706         )
    707 return values

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_senior_circuit_breaker.py:32, in ma_senior_circuit_breaker.formula(tax_unit, period, parameters)
     31 # Comparison to income for maximum credit determination.
---> 32 income = tax_unit("ma_scb_total_income", period)
     33 income_threshold = income * scb.amount.min_real_estate_tax

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_scb_total_income.py:20, in ma_scb_total_income.formula(tax_unit, period, parameters)
     17 scb = parameters(
     18     period
     19 ).gov.states.ma.tax.income.credits.senior_circuit_breaker
---> 20 disallowed_deductions = add(
     21     tax_unit, period, scb.income.disallowed_deductions
     22 )
     24 # Re-add some exemptions

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:195, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    191 variable_population = entity.simulation.populations[
    192     variable_entity.key
    193 ]
    194 person_shares = variable_population.project(
--> 195     variable_population(variable, period)
    196 ) / variable_population.project(variable_population.nb_persons())
    197 values = entity.sum(person_shares)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap.py:18, in snap.formula(spm_unit, period, parameters)
     17 else:
---> 18     added_components = add(spm_unit, period, snap.adds)
     19     return added_components

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap_normal_allotment.py:16, in snap_normal_allotment.formula(spm_unit, period, parameters)
     13 def formula(spm_unit, period, parameters):
     14     # Federal SNAP rules are defined in U.S.C Title 7, Chapter 51, which
     15     # also defines state powers to modify the rules.
---> 16     eligible = spm_unit("is_snap_eligible", period)
     17     expected_contribution = spm_unit("snap_expected_contribution", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/is_snap_eligible.py:16, in is_snap_eligible.formula(spm_unit, period, parameters)
     15 def formula(spm_unit, period, parameters):
---> 16     net = spm_unit("meets_snap_net_income_test", period)
     17     gross = spm_unit("meets_snap_gross_income_test", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_net_income_test.py:19, in meets_snap_net_income_test.formula(spm_unit, period, parameters)
     16 net_income_limit_fpg = parameters(
     17     period
     18 ).gov.usda.snap.income.limit.net
---> 19 net_income_fpg = spm_unit("snap_net_income_fpg_ratio", period)
     20 return net_income_fpg <= net_income_limit_fpg

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income_fpg_ratio.py:15, in snap_net_income_fpg_ratio.formula(spm_unit, period)
     14 def formula(spm_unit, period):
---> 15     income = spm_unit("snap_net_income", period)
     16     fpg = spm_unit("spm_unit_fpg", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income.py:14, in snap_net_income.formula(spm_unit, period)
     13 def formula(spm_unit, period):
---> 14     gross_income = spm_unit("snap_gross_income", period)
     15     deductions = spm_unit("snap_deductions", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi.py:16, in ssi.formula(person, period, parameters)
     15     return 0
---> 16 return max_(0, person("uncapped_ssi", period))

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/uncapped_ssi.py:13, in uncapped_ssi.formula(person, period, parameters)
     12 def formula(person, period, parameters):
---> 13     amount = person("ssi_amount_if_eligible", period)
     14     meets_resource_test = person("meets_ssi_resource_test", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_amount_if_eligible.py:16, in ssi_amount_if_eligible.formula(person, period, parameters)
     13 ssi = parameters(period).gov.ssa.ssi.amount
     14 return (
     15     where(
---> 16         person("ssi_claim_is_joint", period),
     17         ssi.couple,
     18         ssi.individual,
     19     )
     20     * MONTHS_IN_YEAR
     21 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_claim_is_joint.py:12, in ssi_claim_is_joint.formula(person, period, parameters)
     11 eligible = person("is_ssi_aged_blind_disabled", period)
---> 12 both_eligible = person.marital_unit.sum(eligible) == 2
     13 income_is_deemed = (
     14     person("ssi_income_deemed_from_ineligible_spouse", period) > 0
     15 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:28, in Projector.__getattr__.<locals>.projector_function(*args, **kwargs)
     27 result = reference_attr(*args, **kwargs)
---> 28 return self.transform_and_bubble_up(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:37, in Projector.transform_and_bubble_up(self, result)
     36 def transform_and_bubble_up(self, result):
---> 37     transformed_result = self.transform(result)
     38     if self.parent is None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/entity_to_person_projector.py:19, in EntityToPersonProjector.transform(self, result)
     18 def transform(self, result: ArrayLike) -> ArrayLike:
---> 19     return self.reference_entity.project(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/group_population.py:335, in GroupPopulation.project(self, array, role)
    334 def project(self, array: ArrayLike, role: Role = None) -> ArrayLike:
--> 335     self.check_array_compatible_with_entity(array)
    336     self.entity.check_role_validity(role)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:60, in Population.check_array_compatible_with_entity(self, array)
     59 if not self.count == array.size:
---> 60     raise ValueError(
     61         "Input {} is not a valid value for the entity {} (size = {} != {} = count)".format(
     62             array, self.entity.key, array.size, self.count
     63         )
     64     )

ValueError: Input [0. 0. 0. ... 0. 0. 0.] is not a valid value for the entity marital_unit (size = 4003 != 4004 = count)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/individual_sim.py:264, in IndividualSim.calc(self, var, period, target, index, map_to, reform)
    263 try:
--> 264     result = self.sim.calculate_add(var, period)
    265 except:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:597, in Simulation.calculate_add(self, variable_name, period, decode_enums)
    591     raise ValueError(
    592         "Unable to sum constant variable '{}' over period {}: only variables defined daily, monthly, or yearly can be summed over time.".format(
    593             variable.name, period
    594         )
    595     )
--> 597 return sum(
    598     self.calculate(variable_name, sub_period)
    599     for sub_period in period.get_subperiods(variable.definition_period)
    600 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:598, in <genexpr>(.0)
    591     raise ValueError(
    592         "Unable to sum constant variable '{}' over period {}: only variables defined daily, monthly, or yearly can be summed over time.".format(
    593             variable.name, period
    594         )
    595     )
    597 return sum(
--> 598     self.calculate(variable_name, sub_period)
    599     for sub_period in period.get_subperiods(variable.definition_period)
    600 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/tax/income/state_income_tax.py:34, in state_income_tax.formula(tax_unit, period, parameters)
     33 else:
---> 34     return add(tax_unit, period, state_income_tax.adds)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:704, in Simulation._run_formula(self, variable, population, period)
    703     for subtracted_variable in subtracts_list:
--> 704         values = values - self.calculate(
    705             subtracted_variable, period, map_to=variable.entity.key
    706         )
    707 return values

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_senior_circuit_breaker.py:32, in ma_senior_circuit_breaker.formula(tax_unit, period, parameters)
     31 # Comparison to income for maximum credit determination.
---> 32 income = tax_unit("ma_scb_total_income", period)
     33 income_threshold = income * scb.amount.min_real_estate_tax

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_scb_total_income.py:20, in ma_scb_total_income.formula(tax_unit, period, parameters)
     17 scb = parameters(
     18     period
     19 ).gov.states.ma.tax.income.credits.senior_circuit_breaker
---> 20 disallowed_deductions = add(
     21     tax_unit, period, scb.income.disallowed_deductions
     22 )
     24 # Re-add some exemptions

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:195, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    191 variable_population = entity.simulation.populations[
    192     variable_entity.key
    193 ]
    194 person_shares = variable_population.project(
--> 195     variable_population(variable, period)
    196 ) / variable_population.project(variable_population.nb_persons())
    197 values = entity.sum(person_shares)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap.py:18, in snap.formula(spm_unit, period, parameters)
     17 else:
---> 18     added_components = add(spm_unit, period, snap.adds)
     19     return added_components

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    211 """Sums a list of variables.
    212 
    213 Args:
   (...)
    223     ArrayLike: The result of the operation.
    224 """
--> 225 return for_each_variable(
    226     entity, period, variables, agg_func="add", options=options
    227 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap_normal_allotment.py:16, in snap_normal_allotment.formula(spm_unit, period, parameters)
     13 def formula(spm_unit, period, parameters):
     14     # Federal SNAP rules are defined in U.S.C Title 7, Chapter 51, which
     15     # also defines state powers to modify the rules.
---> 16     eligible = spm_unit("is_snap_eligible", period)
     17     expected_contribution = spm_unit("snap_expected_contribution", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/is_snap_eligible.py:16, in is_snap_eligible.formula(spm_unit, period, parameters)
     15 def formula(spm_unit, period, parameters):
---> 16     net = spm_unit("meets_snap_net_income_test", period)
     17     gross = spm_unit("meets_snap_gross_income_test", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_net_income_test.py:19, in meets_snap_net_income_test.formula(spm_unit, period, parameters)
     16 net_income_limit_fpg = parameters(
     17     period
     18 ).gov.usda.snap.income.limit.net
---> 19 net_income_fpg = spm_unit("snap_net_income_fpg_ratio", period)
     20 return net_income_fpg <= net_income_limit_fpg

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income_fpg_ratio.py:15, in snap_net_income_fpg_ratio.formula(spm_unit, period)
     14 def formula(spm_unit, period):
---> 15     income = spm_unit("snap_net_income", period)
     16     fpg = spm_unit("spm_unit_fpg", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income.py:14, in snap_net_income.formula(spm_unit, period)
     13 def formula(spm_unit, period):
---> 14     gross_income = spm_unit("snap_gross_income", period)
     15     deductions = spm_unit("snap_deductions", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi.py:16, in ssi.formula(person, period, parameters)
     15     return 0
---> 16 return max_(0, person("uncapped_ssi", period))

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/uncapped_ssi.py:13, in uncapped_ssi.formula(person, period, parameters)
     12 def formula(person, period, parameters):
---> 13     amount = person("ssi_amount_if_eligible", period)
     14     meets_resource_test = person("meets_ssi_resource_test", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_amount_if_eligible.py:16, in ssi_amount_if_eligible.formula(person, period, parameters)
     13 ssi = parameters(period).gov.ssa.ssi.amount
     14 return (
     15     where(
---> 16         person("ssi_claim_is_joint", period),
     17         ssi.couple,
     18         ssi.individual,
     19     )
     20     * MONTHS_IN_YEAR
     21 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    480 self._check_for_cycle(variable.name, period)
--> 481 array = self._run_formula(variable, population, period)
    483 # If no result, use the default value and cache it

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_claim_is_joint.py:12, in ssi_claim_is_joint.formula(person, period, parameters)
     11 eligible = person("is_ssi_aged_blind_disabled", period)
---> 12 both_eligible = person.marital_unit.sum(eligible) == 2
     13 income_is_deemed = (
     14     person("ssi_income_deemed_from_ineligible_spouse", period) > 0
     15 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:28, in Projector.__getattr__.<locals>.projector_function(*args, **kwargs)
     27 result = reference_attr(*args, **kwargs)
---> 28 return self.transform_and_bubble_up(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:37, in Projector.transform_and_bubble_up(self, result)
     36 def transform_and_bubble_up(self, result):
---> 37     transformed_result = self.transform(result)
     38     if self.parent is None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/entity_to_person_projector.py:19, in EntityToPersonProjector.transform(self, result)
     18 def transform(self, result: ArrayLike) -> ArrayLike:
---> 19     return self.reference_entity.project(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/group_population.py:335, in GroupPopulation.project(self, array, role)
    334 def project(self, array: ArrayLike, role: Role = None) -> ArrayLike:
--> 335     self.check_array_compatible_with_entity(array)
    336     self.entity.check_role_validity(role)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:60, in Population.check_array_compatible_with_entity(self, array)
     59 if not self.count == array.size:
---> 60     raise ValueError(
     61         "Input {} is not a valid value for the entity {} (size = {} != {} = count)".format(
     62             array, self.entity.key, array.size, self.count
     63         )
     64     )

ValueError: Input [0. 0. 0. ... 0. 0. 0.] is not a valid value for the entity marital_unit (size = 4003 != 4004 = count)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Cell In[1], line 50
     48 for adults in range(1, 3):
     49     for children in range(0, 4):
---> 50         l.append(make_tax(adults, children))
     52 df = pd.concat(l)
     54 LABELS = dict(
     55     employment_income="Employment income",
     56     state_income_tax="Massachusetts income tax",
   (...)
     61     ma_limited_income_tax_credit="Massachusetts Limited Income Credit",
     62 )

Cell In[1], line 32, in make_tax(adults, children)
     27 sim.add_household(name="household", members=members, state_code="MA")
     28 sim.vary("employment_income", max=100_000, step=100)
     29 return pd.DataFrame(
     30     dict(
     31         employment_income=sim.calc("employment_income")[0],
---> 32         state_income_tax=sim.calc("state_income_tax")[0].round(),
     33         ma_eitc=sim.calc("ma_eitc")[0].round(),
     34         ma_limited_income_tax_credit=sim.calc(
     35             "ma_limited_income_tax_credit"
     36         )[0].round(),
     37         mtr=sim.deriv(
     38             "state_income_tax", "employment_income", wrt_target="head"
     39         ),
     40         adults=adults,
     41         children=str(children),
     42     )
     43 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/individual_sim.py:266, in IndividualSim.calc(self, var, period, target, index, map_to, reform)
    264         result = self.sim.calculate_add(var, period)
    265     except:
--> 266         result = self.simulation.calculate_divide(var, period)
    267 if (
    268     target is not None
    269     and target not in self.situation_data[entity.plural]
    270 ):
    271     map_to = self.get_entity(target).key

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:634, in Simulation.calculate_divide(self, variable_name, period, decode_enums)
    630     return (
    631         self.calculate(variable_name, period=computation_period) / 12.0
    632     )
    633 elif period.unit == periods.YEAR:
--> 634     return self.calculate(variable_name, period)
    636 raise ValueError(
    637     "Unable to divide the value of '{}' to match period {}.".format(
    638         variable_name, period
    639     )
    640 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/tax/income/state_income_tax.py:34, in state_income_tax.formula(tax_unit, period, parameters)
     28     return where(
     29         total_tax_unit_heads > 0,
     30         spm_unit_state_tax / total_tax_unit_heads,
     31         0,
     32     )
     33 else:
---> 34     return add(tax_unit, period, state_income_tax.adds)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    205 def add(
    206     entity: Population,
    207     period: Period,
    208     variables: List[str],
    209     options: List[str] = None,
    210 ):
    211     """Sums a list of variables.
    212 
    213     Args:
   (...)
    223         ArrayLike: The result of the operation.
    224     """
--> 225     return for_each_variable(
    226         entity, period, variables, agg_func="add", options=options
    227     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    179 variable_entity = entity.entity.get_variable(variable).entity
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:
    183     values = group_agg_func(
    184         entity.members(variable, period, options=options)
    185     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:704, in Simulation._run_formula(self, variable, population, period)
    702             values = 0
    703         for subtracted_variable in subtracts_list:
--> 704             values = values - self.calculate(
    705                 subtracted_variable, period, map_to=variable.entity.key
    706             )
    707     return values
    709 if self.trace and not isinstance(
    710     self.tax_benefit_system.parameters, TracingParameterNodeAtInstant
    711 ):
    712     # Soft-recast

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    682     values = 0
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:
    688     if isinstance(variable.subtracts, str):

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_senior_circuit_breaker.py:32, in ma_senior_circuit_breaker.formula(tax_unit, period, parameters)
     29 real_estate_tax_or_equiv = real_estate_tax + equivalent_rent
     31 # Comparison to income for maximum credit determination.
---> 32 income = tax_unit("ma_scb_total_income", period)
     33 income_threshold = income * scb.amount.min_real_estate_tax
     34 ret_over_threshold = max_(
     35     0, real_estate_tax_or_equiv - income_threshold
     36 )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/states/ma/tax/income/credits/senior_circuit_breaker/ma_scb_total_income.py:20, in ma_scb_total_income.formula(tax_unit, period, parameters)
     14 ma_gross_income = tax_unit(
     15     "ma_gross_income", period
     16 )  # The law specifies to start at AGI and re-add deducted capital losses. We instead start from gross income, on an equivalent path.
     17 scb = parameters(
     18     period
     19 ).gov.states.ma.tax.income.credits.senior_circuit_breaker
---> 20 disallowed_deductions = add(
     21     tax_unit, period, scb.income.disallowed_deductions
     22 )
     24 # Re-add some exemptions
     25 person = tax_unit.members

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    205 def add(
    206     entity: Population,
    207     period: Period,
    208     variables: List[str],
    209     options: List[str] = None,
    210 ):
    211     """Sums a list of variables.
    212 
    213     Args:
   (...)
    223         ArrayLike: The result of the operation.
    224     """
--> 225     return for_each_variable(
    226         entity, period, variables, agg_func="add", options=options
    227     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:195, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    190 else:  # Group-to-group aggregation
    191     variable_population = entity.simulation.populations[
    192         variable_entity.key
    193     ]
    194     person_shares = variable_population.project(
--> 195         variable_population(variable, period)
    196     ) / variable_population.project(variable_population.nb_persons())
    197     values = entity.sum(person_shares)
    198 if result is None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap.py:18, in snap.formula(spm_unit, period, parameters)
     16     return 0
     17 else:
---> 18     added_components = add(spm_unit, period, snap.adds)
     19     return added_components

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:225, in add(entity, period, variables, options)
    205 def add(
    206     entity: Population,
    207     period: Period,
    208     variables: List[str],
    209     options: List[str] = None,
    210 ):
    211     """Sums a list of variables.
    212 
    213     Args:
   (...)
    223         ArrayLike: The result of the operation.
    224     """
--> 225     return for_each_variable(
    226         entity, period, variables, agg_func="add", options=options
    227     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/commons/formulas.py:181, in for_each_variable(entity, period, variables, agg_func, group_agg_func, options)
    179 variable_entity = entity.entity.get_variable(variable).entity
    180 if variable_entity.key == entity.entity.key:
--> 181     values = entity(variable, period, options=options)
    182 elif variable_entity.is_person:
    183     values = group_agg_func(
    184         entity.members(variable, period, options=options)
    185     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/snap_normal_allotment.py:16, in snap_normal_allotment.formula(spm_unit, period, parameters)
     13 def formula(spm_unit, period, parameters):
     14     # Federal SNAP rules are defined in U.S.C Title 7, Chapter 51, which
     15     # also defines state powers to modify the rules.
---> 16     eligible = spm_unit("is_snap_eligible", period)
     17     expected_contribution = spm_unit("snap_expected_contribution", period)
     18     max_allotment = spm_unit("snap_max_allotment", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/is_snap_eligible.py:16, in is_snap_eligible.formula(spm_unit, period, parameters)
     15 def formula(spm_unit, period, parameters):
---> 16     net = spm_unit("meets_snap_net_income_test", period)
     17     gross = spm_unit("meets_snap_gross_income_test", period)
     18     asset = spm_unit("meets_snap_asset_test", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/eligibility/meets_snap_net_income_test.py:19, in meets_snap_net_income_test.formula(spm_unit, period, parameters)
     15 def formula(spm_unit, period, parameters):
     16     net_income_limit_fpg = parameters(
     17         period
     18     ).gov.usda.snap.income.limit.net
---> 19     net_income_fpg = spm_unit("snap_net_income_fpg_ratio", period)
     20     return net_income_fpg <= net_income_limit_fpg

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    716 parameters_at = self.tax_benefit_system.parameters
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:
    721     array = formula(population, period, parameters_at)

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income_fpg_ratio.py:15, in snap_net_income_fpg_ratio.formula(spm_unit, period)
     14 def formula(spm_unit, period):
---> 15     income = spm_unit("snap_net_income", period)
     16     fpg = spm_unit("spm_unit_fpg", period)
     17     return income / fpg

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:719, in Simulation._run_formula(self, variable, population, period)
    716 parameters_at = self.tax_benefit_system.parameters
    718 if formula.__code__.co_argcount == 2:
--> 719     array = formula(population, period)
    720 else:
    721     array = formula(population, period, parameters_at)

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/usda/snap/income/snap_net_income.py:14, in snap_net_income.formula(spm_unit, period)
     13 def formula(spm_unit, period):
---> 14     gross_income = spm_unit("snap_gross_income", period)
     15     deductions = spm_unit("snap_deductions", period)
     16     return max_(0, gross_income - deductions)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    682     values = 0
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:
    688     if isinstance(variable.subtracts, str):

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:684, in Simulation._run_formula(self, variable, population, period)
    682     values = 0
    683     for added_variable in adds_list:
--> 684         values = values + self.calculate(
    685             added_variable, period, map_to=variable.entity.key
    686         )
    687 if variable.subtracts is not None:
    688     if isinstance(variable.subtracts, str):

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi.py:16, in ssi.formula(person, period, parameters)
     14 if parameters(period).gov.ssa.ssi.abolish_ssi:
     15     return 0
---> 16 return max_(0, person("uncapped_ssi", period))

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/uncapped_ssi.py:13, in uncapped_ssi.formula(person, period, parameters)
     12 def formula(person, period, parameters):
---> 13     amount = person("ssi_amount_if_eligible", period)
     14     meets_resource_test = person("meets_ssi_resource_test", period)
     15     eligible = person("is_ssi_eligible_individual", period)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_amount_if_eligible.py:16, in ssi_amount_if_eligible.formula(person, period, parameters)
     12 def formula(person, period, parameters):
     13     ssi = parameters(period).gov.ssa.ssi.amount
     14     return (
     15         where(
---> 16             person("ssi_claim_is_joint", period),
     17             ssi.couple,
     18             ssi.individual,
     19         )
     20         * MONTHS_IN_YEAR
     21     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:134, in Population.__call__(self, variable_name, period, options)
    130     return self.simulation.calculate_divide(
    131         variable_name, period, **calculate_kwargs
    132     )
    133 else:
--> 134     return self.simulation.calculate(
    135         variable_name, period, **calculate_kwargs
    136     )

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:320, in Simulation.calculate(self, variable_name, period, map_to, decode_enums)
    315 self.tracer.record_calculation_start(
    316     variable_name, period, self.branch_name
    317 )
    319 try:
--> 320     result = self._calculate(variable_name, period)
    321     if isinstance(result, EnumArray) and decode_enums:
    322         result = result.decode_to_str()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:481, in Simulation._calculate(self, variable_name, period)
    479 try:
    480     self._check_for_cycle(variable.name, period)
--> 481     array = self._run_formula(variable, population, period)
    483     # If no result, use the default value and cache it
    484     if array is None:
    485         # Check if the variable has a previously defined value

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py:721, in Simulation._run_formula(self, variable, population, period)
    719     array = formula(population, period)
    720 else:
--> 721     array = formula(population, period, parameters_at)
    723 return array

File ~/work/policyengine-us/policyengine-us/policyengine_us/variables/gov/ssa/ssi/ssi_claim_is_joint.py:12, in ssi_claim_is_joint.formula(person, period, parameters)
     10 def formula(person, period, parameters):
     11     eligible = person("is_ssi_aged_blind_disabled", period)
---> 12     both_eligible = person.marital_unit.sum(eligible) == 2
     13     income_is_deemed = (
     14         person("ssi_income_deemed_from_ineligible_spouse", period) > 0
     15     )
     16     return both_eligible | income_is_deemed

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:28, in Projector.__getattr__.<locals>.projector_function(*args, **kwargs)
     26 def projector_function(*args, **kwargs):
     27     result = reference_attr(*args, **kwargs)
---> 28     return self.transform_and_bubble_up(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/projector.py:37, in Projector.transform_and_bubble_up(self, result)
     36 def transform_and_bubble_up(self, result):
---> 37     transformed_result = self.transform(result)
     38     if self.parent is None:
     39         return transformed_result

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/projectors/entity_to_person_projector.py:19, in EntityToPersonProjector.transform(self, result)
     18 def transform(self, result: ArrayLike) -> ArrayLike:
---> 19     return self.reference_entity.project(result)

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/group_population.py:335, in GroupPopulation.project(self, array, role)
    334 def project(self, array: ArrayLike, role: Role = None) -> ArrayLike:
--> 335     self.check_array_compatible_with_entity(array)
    336     self.entity.check_role_validity(role)
    337     if role is None:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/policyengine_core/populations/population.py:60, in Population.check_array_compatible_with_entity(self, array)
     58 def check_array_compatible_with_entity(self, array: numpy.ndarray) -> None:
     59     if not self.count == array.size:
---> 60         raise ValueError(
     61             "Input {} is not a valid value for the entity {} (size = {} != {} = count)".format(
     62                 array, self.entity.key, array.size, self.count
     63             )
     64         )

ValueError: Input [0. 0. 0. ... 0. 0. 0.] is not a valid value for the entity marital_unit (size = 4003 != 4004 = count)

Core marginal tax rates span from zero to five percent, but when including the EITC, they range from -13.5% to 12.3%, depending on income and household structure.

fig = px.line(
    df,
    "employment_income",
    "mtr",
    color="children",
    animation_frame="adults",
    labels=LABELS,
    title="Massachusetts state income tax marginal tax rate",
    color_discrete_map=COLOR_MAP,
)
fig.update_layout(
    xaxis_tickformat="$,",
    yaxis_tickformat=".1%",
    plot_bgcolor="white",
    xaxis_gridcolor=LIGHT_GRAY,
    yaxis_gridcolor=LIGHT_GRAY,
)
fig.show()

Massachusetts EITC#

Massachusetts matches 30 percent of a filer’s federal Earned Income Tax Credit.

def set_bounds(fig, x, y, buffer=1.1):
    fig.update_layout(
        xaxis_range=[0, x[y != 0].max() * buffer],
        yaxis_range=[0, y.max() * buffer],
    )


fig = px.line(
    df,
    "employment_income",
    "ma_eitc",
    color="children",
    animation_frame="adults",
    labels=LABELS,
    title="Massachusetts EITC",
    color_discrete_map=COLOR_MAP,
)
fig.update_layout(
    xaxis_tickformat="$,",
    yaxis_tickformat="$,",
    plot_bgcolor="white",
    xaxis_gridcolor=LIGHT_GRAY,
    yaxis_gridcolor=LIGHT_GRAY,
)
set_bounds(fig, df.employment_income, df.ma_eitc)
fig.show()

Massachusetts Limited Income Credit#

See Schedule NTS-L-NR/PY No Tax Status and Limited Income Credit.

fig = px.line(
    df,
    "employment_income",
    "ma_limited_income_tax_credit",
    color="children",
    animation_frame="adults",
    labels=LABELS,
    title="Massachusetts Limited Income Credit",
    color_discrete_map=COLOR_MAP,
)
fig.update_layout(
    xaxis_tickformat="$,",
    yaxis_tickformat="$,",
    yaxis_range=[0, df.ma_limited_income_tax_credit.max()],
    plot_bgcolor="white",
    xaxis_gridcolor=LIGHT_GRAY,
    yaxis_gridcolor=LIGHT_GRAY,
)
set_bounds(fig, df.employment_income, df.ma_limited_income_tax_credit)
fig.show()