Skip to content

Commit

Permalink
Merge pull request #84 from TheCGO/colton-dev-branch
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
rickecon authored Oct 10, 2024
2 parents fbfe609 + e92e74f commit c7942a5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from fiscalsim_us.model_api import *


class is_older_child_for_medicaid(Variable):
value_type = bool
entity = Person
Expand All @@ -17,4 +17,22 @@ def formula(person, period, parameters):
is_older_child = ma.age_range.calc(age)
state = person.household("state_code_str", period)
income_limit = ma.income_limit[state]
return is_older_child & (income < income_limit)

try:
result = is_older_child & (income < income_limit)
return result
except Exception as e:
print(f"Calculation failed: {str(e)}")
print(f"is_older_child: type={type(is_older_child)}, value={is_older_child}")
print(f"income: type={type(income)}, value={income}")
print(f"income_limit: type={type(income_limit)}, value={income_limit}")

# Convert to numpy arrays and ensure correct types
is_older_child = np.asarray(is_older_child if is_older_child is not None else False).astype(bool)
income = np.asarray(income if income is not None else 0).astype(float)
income_limit = np.asarray(income_limit if income_limit is not None else 0).astype(float)

# Attempt calculation again
result = is_older_child & (income < income_limit)
print("Calculation succeeded after type conversion")
return result
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from fiscalsim_us.model_api import *


class is_ptc_eligible(Variable):
value_type = bool
entity = TaxUnit
Expand All @@ -15,4 +15,9 @@ def formula(tax_unit, period, parameters):
on_marketplace = (
add(tax_unit, period, ["has_marketplace_health_coverage"]) > 0
)
return on_marketplace & eligibility.calc(income_level)
income_eligible = eligibility.calc(income_level)

on_marketplace = np.array(on_marketplace, dtype=bool)
income_eligible = np.array(income_eligible, dtype=bool)

return on_marketplace & income_eligible
18 changes: 16 additions & 2 deletions fiscalsim_us/variables/gov/states/co/ssa/oap/co_oap_eligible.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fiscalsim_us.model_api import *
import numpy as np


class co_oap_eligible(Variable):
Expand All @@ -12,10 +13,23 @@ def formula(person, period, parameters):
assets = person("ssi_countable_resources", period)
joint_claim = person("ssi_claim_is_joint", period)
p = parameters(period).gov.states.co.ssa.oap
asset_limit = where(
joint_claim, p.resources.couple, p.resources.single

assets = np.array(assets)
joint_claim = np.array(joint_claim, dtype=bool)

asset_limit = np.where(
joint_claim,
p.resources.couple,
p.resources.single
)

below_asset_limit = assets <= asset_limit

age = person("age", period)
in_age_range = p.age_range.calc(age)

in_age_range = np.array(in_age_range, dtype=bool)

below_asset_limit = below_asset_limit.astype(bool)

return below_asset_limit & in_age_range
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fiscalsim_us.model_api import *

import numpy as np

class co_state_supplement_eligible(Variable):
value_type = bool
Expand All @@ -12,8 +12,19 @@ def formula(person, period, parameters):
ssi_eligible = person("is_ssi_eligible_individual", period)
is_disabled = person("is_ssi_disabled", period)
is_blind = person("is_blind", period)
disabled_or_blind = is_disabled | is_blind
age = person("age", period)
p = parameters(period).gov.states.co.ssa.state_supplement

# Convert to boolean arrays and handle potential None or NaN values
ssi_eligible = np.array(ssi_eligible).astype(bool)
is_disabled = np.array(is_disabled).astype(bool)
is_blind = np.array(is_blind).astype(bool)

disabled_or_blind = is_disabled | is_blind
in_age_range = p.age_range.calc(age)
return disabled_or_blind & ssi_eligible & in_age_range

# Convert in_age_range to boolean array
in_age_range = np.array(in_age_range).astype(bool)

# Use bitwise & for the final operation
return disabled_or_blind & ssi_eligible & in_age_range

0 comments on commit c7942a5

Please sign in to comment.