Skip to content

Help needed with error after including indexed parameters in the baseline #2902

@hdublois

Description

@hdublois

I'm trying to model some CTC provisions relative to TCJA permanence (relying on the ext.json changes), and I'm getting an error when trying to index the ACTC values in my baseline.

Specifically, it's these lines of code in my baseline that are problematic:

"ACTC_c": {"2026": 1776.67},
"ACTC_c-indexed": {"2026": True},
"ACTC_c": {"2032": 2000.00},
"ACTC_c-indexed": {"2032": False},

The error I'm receiving is:

TypeError: '<' not supported between instances of 'int' and 'str'

When I remove the specifications to index the ACTC, the error goes away.

Any suggestions on how to solve this? Any help would be greatly appreciated!

(Also, as this is my first Github post, please let me know if I'm not posting this in the correct format).

Here is the full specification for the baseline and reform:

_baseline = {}

tcja_baseline = {

"II_rt1": {"2026": 0.10},
"II_brk1": {"2026": [12250.0, 24500.0, 12250.0, 17500.0, 24500.0]},
"PT_rt1": {"2026": 0.10},
"PT_brk1": {"2026": [12250.0, 24500.0, 12250.0, 17500.0, 24500.0]},
"II_rt2": {"2026": 0.12},
"II_brk2": {"2026": [49750.0, 99500.0, 49750.0, 66600.0, 99500.0]},
"PT_rt2": {"2026": 0.12},
"PT_brk2": {"2026": [49750.0, 99500.0, 49750.0, 66600.0, 99500.0]},
"II_rt3": {"2026": 0.22},
"II_brk3": {"2026": [106100.0, 212200.0, 106100.0, 106100.0, 212200.0]},
"PT_rt3": {"2026": 0.22},
"PT_brk3": {"2026": [106100.0, 212200.0, 106100.0, 106100.0, 212200.0]},
"II_rt4": {"2026": 0.24},
"II_brk4": {"2026": [202550.0, 405050.0, 202550.0, 202550.0, 405050.0]},
"PT_rt4": {"2026": 0.24},
"PT_brk4": {"2026": [202550.0, 405050.0, 202550.0, 202550.0, 405050.0]},
"II_rt5": {"2026": 0.32},
"II_brk5": {"2026": [257200.0, 514400.0, 257200.0, 257200.0, 514400.0]},
"PT_rt5": {"2026": 0.32},
"PT_brk5": {"2026": [257200.0, 514400.0, 257200.0, 257200.0, 514400.0]},
"II_rt6": {"2026": 0.35},
"II_brk6": {"2026": [642950.0, 771550.0, 385760.0, 642950.0, 771550.0]},
"PT_rt6": {"2026": 0.35},
"PT_brk6": {"2026": [642950.0, 771550.0, 385760.0, 642950.0, 771550.0]},
"II_rt7": {"2026": 0.37},
"II_brk7": {"2026": [9e+99, 9e+99, 9e+99, 9e+99, 9e+99]},
"PT_rt7": {"2026": 0.37},
"PT_brk7": {"2026": [9e+99, 9e+99, 9e+99, 9e+99, 9e+99]},
"CTC_c": {"2026": 2000.00},
"ACTC_c": {"2026": 1776.67},
"ACTC_c-indexed": {"2026": True},
"ACTC_c": {"2032": 2000.00},
"ACTC_c-indexed": {"2032": False},
"ODC_c": {"2026": 500.00},
"CTC_ps": {"2026": [200000.0, 400000.0, 200000.0, 200000.0, 400000.0]},
"ACTC_Income_thd": {"2026": 2500.00},
"AMT_em": {"2026": [90400.0, 140700.0, 70300.0, 90400.0, 140700.0]},
"AMT_em_ps": {"2026": [642950.0, 1285950.0, 642950.0, 642950.0, 1285950.0]},
"AMT_em_pe": {"2026": 940953.35},
"STD": {"2026": [15450.0, 30850.0, 15450.0, 23150.0, 30850.0]},
"ID_AllTaxes_c": {"2026": [10000.0, 10000.0, 5000.0, 10000.0, 10000.0]},
"ID_Charity_crt_cash": {"2026": 0.60},
"ID_Casualty_hc": {"2026": 1.00},
"ID_Miscellaneous_hc": {"2026": 1.00},
"ID_ps": {"2026": [9e+99, 9e+99, 9e+99, 9e+99, 9e+99]},
"ID_prt": {"2026": 0.00},
"ID_crt": {"2026": 1.00},
"II_em": {"2026": 0.00},
"II_em_ps": {"2026": [9e+99, 9e+99, 9e+99, 9e+99, 9e+99]},
"PT_qbid_rt": {"2026": 0.20},
"PT_qbid_taxinc_thd": {"2026": [202550.0, 405050.0, 202550.0, 405050.0, 202550.0]},
"PT_qbid_taxinc_gap": {"2026": [50000.0, 100000.0, 50000.0, 50000.0, 100000.0]},
"PT_qbid_w2_wages_rt": {"2026": 0.50},
"PT_qbid_alt_w2_wages_rt": {"2026": 0.25},
"PT_qbid_alt_property_rt": {"2026": 0.025},
"ALD_BusinessLosses_c": {"2029": [342904.94, 685809.88, 342904.94, 342904.94, 685809.88]}

}

allreforms = {

"CTC_c": {"2025": 2500.00,
          "2026": 2500.00,
          "2027": 2500.00,
          "2028": 2500.00,
          "2029": 2000.00},
"CTC_c-indexed": {"2029": True},
"ACTC_c": {"2026": 1776.67},
"ACTC_c-indexed": {"2026": True}    

}_

And here is the full error:


TypeError Traceback (most recent call last)
Cell In[32], line 1
----> 1 run_calc(
2 # Define Year Range
3 yr_range = range(2025, 2035), #
4 # Create Reform Lists
5 refs_policy = [tcja_baseline, reform1, reform2], # reform
6 refs_base = [baseline, tcja_baseline, reform1, reform2], # baseline
7 # Set Records
8 rec = recs_tmd,
9 # Create Index Labels
10 df = pd.DataFrame(index=["TCJA", "CTC Changes", "ACTC Changes"])
11 )

Cell In[28], line 11, in run_calc(yr_range, refs_policy, refs_base, rec, df)
9 calc_base = Calculator(pol_base, rec)
10 calc_base.advance_to_year(year)
---> 11 pol_ref.implement_reform(ref_policy)
12 calc_ref=Calculator(pol_ref, rec)
13 calc_ref.advance_to_year(year)

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/taxcalc/policy.py:150, in Policy.implement_reform(self, reform, print_warnings, raise_errors)
145 """
146 Implement reform using Tax-Calculator syled reforms/adjustments. Users
147 may also use the adjust method with ParamTools styled reforms.
148 """
149 # need to do conversion:
--> 150 return self._update(reform, print_warnings, raise_errors)

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/taxcalc/parameters.py:679, in Parameters._update(self, revision, print_warnings, raise_errors)
671 msg = (
672 f"{param} must be a year:value dictionary "
673 f"if you are not using the new adjust method."
674 )
675 raise pt.ValidationError(
676 {"errors": {"schema": msg}},
677 None
678 )
--> 679 return self.adjust(
680 new_params,
681 print_warnings=print_warnings,
682 raise_errors=raise_errors
683 )

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/taxcalc/parameters.py:183, in Parameters.adjust(self, params_or_path, print_warnings, raise_errors, **kwargs)
174 try:
175 # Wrap all updates in adjust_with_indexing in a transaction and
176 # defer related-parameter validation until all intermediate updates
177 # are complete.
178 with self.transaction(
179 defer_validation=True,
180 raise_errors=True,
181 ignore_warnings=kwargs["ignore_warnings"],
182 ):
--> 183 return self.adjust_with_indexing(
184 params_or_path, raise_errors=True, **kwargs
185 )
186 except pt.ValidationError as ve:
187 if self.errors and raise_errors:

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/taxcalc/parameters.py:425, in Parameters.adjust_with_indexing(self, params_or_path, **kwargs)
423 if base_param in params:
424 min_index_change_year = min(indexed_changes.keys())
--> 425 vos = self.sel[params[base_param]]["year"].lt(
426 min_index_change_year, strict=False
427 )
429 if list(vos):
430 min_adj_year = min(vos, key=lambda vo: vo["year"])[
431 "year"
432 ]

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/paramtools/values.py:84, in ValueBase.lt(self, value, strict)
83 def lt(self, value, strict=True):
---> 84 return self.cmp_attr.lt(strict, **{self.label: value})

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/paramtools/values.py:361, in Values.lt(self, strict, **labels)
350 def lt(self, strict=True, **labels):
351 """
352 Returns values that have label values less than the label value:
353
(...) 358
359 """
--> 361 return self._cmp("lt", strict, **labels)

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/paramtools/values.py:282, in Values._cmp(self, op, strict, **labels)
279 elif skl is None and not strict:
280 return QueryResult(self, list(self.index))
--> 282 skl_result = getattr(self.skls[label], op)(value)
283 if not strict:
284 match_index = skl_result.index if skl_result else []

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/paramtools/sorted_key_list.py:84, in SortedKeyList.lt(self, value)
81 def lt(self, value):
82 key = self.keyfunc(value)
83 irange = list(
---> 84 self.sorted_key_list_2.irange_key(
85 max_key=key, inclusive=(True, False)
86 )
87 )
88 if irange:
89 return SortedKeyListResult(irange)

File ~/anaconda3/envs/fga-taxcalc-dev/lib/python3.12/site-packages/sortedcontainers/sortedlist.py:2223, in SortedKeyList.irange_key(self, min_key, max_key, inclusive, reverse)
2221 max_idx = bisect_right(_keys[max_pos], max_key)
2222 else:
-> 2223 max_pos = bisect_left(_maxes, max_key)
2225 if max_pos == len(_maxes):
2226 max_pos -= 1

TypeError: '<' not supported between instances of 'int' and 'str'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions