Skip to content

Commit

Permalink
adjusting conditional for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
coltleese17 committed Jul 23, 2024
1 parent d72aef2 commit 4002161
Showing 1 changed file with 20 additions and 2 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

0 comments on commit 4002161

Please sign in to comment.