129129# =============================================================================
130130
131131
132- def create_mock_tax_benefit_system (household_variables : list [str ] | None = None ) -> Mock :
132+ def create_mock_tax_benefit_system (
133+ household_variables : list [str ] | None = None ,
134+ ) -> Mock :
133135 """Create a mock tax benefit system with variable entity information.
134136
135137 Args:
@@ -152,12 +154,21 @@ def create_mock_tax_benefit_system(household_variables: list[str] | None = None)
152154 mock_tbs .variables [var_name ] = mock_var
153155
154156 # Add standard entity ID variables
155- for entity_id in ["person_id" , "household_id" , "tax_unit_id" , "spm_unit_id" , "family_id" , "marital_unit_id" ]:
157+ for entity_id in [
158+ "person_id" ,
159+ "household_id" ,
160+ "tax_unit_id" ,
161+ "spm_unit_id" ,
162+ "family_id" ,
163+ "marital_unit_id" ,
164+ ]:
156165 mock_var = Mock ()
157166 mock_var .entity = Mock ()
158167 # Entity IDs belong to their respective entities
159168 entity_name = entity_id .replace ("_id" , "" )
160- mock_var .entity .key = entity_name if entity_name != "person" else "person"
169+ mock_var .entity .key = (
170+ entity_name if entity_name != "person" else "person"
171+ )
161172 mock_tbs .variables [entity_id ] = mock_var
162173
163174 return mock_tbs
@@ -218,7 +229,12 @@ def mock_calculate(variable_name, map_to=None, period=None):
218229 result .values = np .array (person_household_ids )
219230 else :
220231 result .values = np .array (household_ids )
221- elif variable_name in ["tax_unit_id" , "spm_unit_id" , "family_id" , "marital_unit_id" ]:
232+ elif variable_name in [
233+ "tax_unit_id" ,
234+ "spm_unit_id" ,
235+ "family_id" ,
236+ "marital_unit_id" ,
237+ ]:
222238 # For simplicity, use household_id as proxy for other entity IDs
223239 if map_to == "person" :
224240 result .values = np .array (person_household_ids )
@@ -231,11 +247,13 @@ def mock_calculate(variable_name, map_to=None, period=None):
231247 mock_sim .calculate = mock_calculate
232248
233249 # Mock to_input_dataframe to return person-level DataFrame
234- df = pd .DataFrame ({
235- "person_id__2024" : person_ids ,
236- "household_id__2024" : person_household_ids ,
237- "place_fips__2024" : person_place_fips ,
238- })
250+ df = pd .DataFrame (
251+ {
252+ "person_id__2024" : person_ids ,
253+ "household_id__2024" : person_household_ids ,
254+ "place_fips__2024" : person_place_fips ,
255+ }
256+ )
239257 mock_sim .to_input_dataframe .return_value = df
240258
241259 return mock_sim
@@ -287,7 +305,12 @@ def mock_calculate(variable_name, map_to=None, period=None):
287305 result .values = np .array (person_household_ids )
288306 else :
289307 result .values = np .array (household_ids )
290- elif variable_name in ["tax_unit_id" , "spm_unit_id" , "family_id" , "marital_unit_id" ]:
308+ elif variable_name in [
309+ "tax_unit_id" ,
310+ "spm_unit_id" ,
311+ "family_id" ,
312+ "marital_unit_id" ,
313+ ]:
291314 if map_to == "person" :
292315 result .values = np .array (person_household_ids )
293316 else :
@@ -298,11 +321,13 @@ def mock_calculate(variable_name, map_to=None, period=None):
298321
299322 mock_sim .calculate = mock_calculate
300323
301- df = pd .DataFrame ({
302- "person_id__2024" : person_ids ,
303- "household_id__2024" : person_household_ids ,
304- "place_fips__2024" : person_place_fips ,
305- })
324+ df = pd .DataFrame (
325+ {
326+ "person_id__2024" : person_ids ,
327+ "household_id__2024" : person_household_ids ,
328+ "place_fips__2024" : person_place_fips ,
329+ }
330+ )
306331 mock_sim .to_input_dataframe .return_value = df
307332
308333 return mock_sim
0 commit comments