Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/md-local-unknown-county.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed crashes in the Maryland local tax variables md_applicable_local_tax_rate and md_flat_rate_county_tax for Maryland households whose county is unknown, by falling back to the same default county used elsewhere.
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@
county_str: FREDERICK_COUNTY_MD
output:
md_applicable_local_tax_rate: 0.0296

- name: Allegany County uses its flat rate (2025)
period: 2025
absolute_error_margin: 0.0001
input:
state_code_str: MD
county_str: ALLEGANY_COUNTY_MD
output:
md_applicable_local_tax_rate: 0.0303

- name: Unknown county in an MD household falls back to Allegany County (issue #8975)
period: 2025
absolute_error_margin: 0.0001
input:
state_code_str: MD
county_str: UNKNOWN
output:
# gov.local.md.flat_rate has no UNKNOWN key; the formula falls back to
# ALLEGANY_COUNTY_MD. Before the fix this raised ParameterNotFoundError.
md_applicable_local_tax_rate: 0.0303
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- name: Allegany County MD flat rate county tax baseline (2025)
period: 2025
absolute_error_margin: 0.01
input:
state_code_str: MD
county_str: ALLEGANY_COUNTY_MD
md_taxable_income: 30_000
output:
# 3.03% Allegany rate * 30,000 = 909
md_flat_rate_county_tax: 909

- name: Unknown county in an MD household falls back to Allegany County (issue #8975)
period: 2025
absolute_error_margin: 0.01
input:
state_code_str: MD
county_str: UNKNOWN
md_taxable_income: 30_000
output:
# gov.local.md.flat_rate has no UNKNOWN key; the formula falls back to
# ALLEGANY_COUNTY_MD, so this must equal the Allegany baseline above.
# Before the fix this raised ParameterNotFoundError instead of computing.
md_flat_rate_county_tax: 909
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def formula(tax_unit, period, parameters):
# Guard against non-MD counties in microsimulation:
# defined_for masks results but doesn't prevent formula execution.
in_md = tax_unit.household("state_code_str", period) == "MD"
safe_county = where(in_md, county, "ALLEGANY_COUNTY_MD")
# Fall back to a default MD county when the county is unknown/unmapped
# (County.UNKNOWN is the default), since gov.local.md.flat_rate has no
# UNKNOWN key and would otherwise raise ParameterNotFoundError. The
# non-MD path already falls back to the same default county.
safe_county = where(in_md & (county != "UNKNOWN"), county, "ALLEGANY_COUNTY_MD")

p = parameters(period).gov.local.md
flat_rate = p.flat_rate[safe_county]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def formula(tax_unit, period, parameters):
# Guard against non-MD counties in microsimulation
# defined_for masks results but doesn't prevent formula execution
in_md = tax_unit.household("state_code_str", period) == "MD"
safe_county = where(in_md, county, "ALLEGANY_COUNTY_MD")
# Fall back to a default MD county when the county is unknown/unmapped
# (County.UNKNOWN is the default), since gov.local.md.flat_rate has no
# UNKNOWN key and would otherwise raise ParameterNotFoundError. The
# non-MD path already falls back to the same default county.
safe_county = where(in_md & (county != "UNKNOWN"), county, "ALLEGANY_COUNTY_MD")

p = parameters(period).gov.local.md.flat_rate
flat_rate = p[safe_county]
Expand Down
Loading