Skip to content

Commit

Permalink
Merge pull request #36 from noman404/noman404/issue-fix32
Browse files Browse the repository at this point in the history
issue fix #32 - added rounded up number than array value in outputs
  • Loading branch information
noman404 authored Oct 23, 2024
2 parents 3104ea2 + d8fbb8a commit 4607866
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions output/policyengine_taxsim_output.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
taxsimid,year,state,mstat,page,sage,fiitax,siitax,fica
1,2021,3,1,40,0,[2775.],[1008.87],[3748.5]
1,2021,3,1,40,0,[2535.],[942.07],[3595.5]
1,2021,3,1,40,0,2775.0,1008.87,3748.5
1,2021,3,1,40,0,2535.0,942.07,3595.5
10 changes: 5 additions & 5 deletions policyengine_taxsim/core/output_mapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from policyengine_taxsim.core.utils import (
load_variable_mappings,
get_state_number,
get_state_number, to_roundedup_number,
)
from policyengine_us import Simulation

Expand Down Expand Up @@ -40,12 +40,12 @@ def export_single_household(policyengine_situation):
.get("your spouse", {})
.get("age", {})
.get(year, 0),
"fiitax": simulation.calculate("income_tax", period=year),
"siitax": simulation.calculate("state_income_tax", period=year),
"fica": simulation.calculate(
"fiitax": to_roundedup_number(simulation.calculate("income_tax", period=year)),
"siitax": to_roundedup_number(simulation.calculate("state_income_tax", period=year)),
"fica": to_roundedup_number(simulation.calculate(
"employee_social_security_tax", period=year
)
+ simulation.calculate("employee_medicare_tax", period=year),
+ simulation.calculate("employee_medicare_tax", period=year)),
}

# Add more variables as needed to match TAXSIM output
Expand Down
8 changes: 6 additions & 2 deletions policyengine_taxsim/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def load_variable_mappings():
"""Load variable mappings from YAML file."""
config_path = (
Path(__file__).parent.parent / "config" / "variable_mappings.yaml"
Path(__file__).parent.parent / "config" / "variable_mappings.yaml"
)
with open(config_path, "r") as f:
return yaml.safe_load(f)
Expand Down Expand Up @@ -84,7 +84,11 @@ def is_date(string):
try:
year = int(string)
return (
1900 <= year <= 2100
1900 <= year <= 2100
) # Assuming years between 1900 and 2100 are valid
except ValueError:
return False


def to_roundedup_number(pe_array):
return round(pe_array[0], 2)

0 comments on commit 4607866

Please sign in to comment.