Skip to content

Commit

Permalink
clean up model deletions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattea committed Feb 10, 2021
1 parent 4cf97a0 commit e0fa2ab
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_interventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,8 @@ def test_lateral_flow_interventions_has_tests(self, test_params):
model.write_individual_file()
model.write_transmissions()

del( model )

# read CSV's
df_indiv = pd.read_csv( constant.TEST_INDIVIDUAL_FILE, comment="#", sep=",", skipinitialspace=True )
np.testing.assert_equal( sum( df_indiv[ "lateral_flow_status" ] == 0 ) > 0, True, "No negative Lateral Flow tests found." )
Expand All @@ -2351,6 +2353,8 @@ def test_lateral_flow_interventions_no_tests(self, test_params):
model.write_individual_file()
model.write_transmissions()

del( model )

# read CSV's
df_indiv = pd.read_csv( constant.TEST_INDIVIDUAL_FILE, comment="#", sep=",", skipinitialspace=True )
np.testing.assert_equal( sum( df_indiv[ "lateral_flow_status" ] >= 0 ), 0, "Unexpected Lateral Flow tests found." )
Expand Down Expand Up @@ -2387,7 +2391,7 @@ def test_lateral_flow_interventions_vs_quarantine(self, test_params, quarantine_
df_test = pd.merge( df_indiv, df_quar, on = "ID", how = "left" )
all_test.append( df_test )

del model
del( model )

df_test = pd.concat( all_test )

Expand Down Expand Up @@ -2477,6 +2481,7 @@ def test_lateral_flow_test_sensitivity(self, test_params):
p_val = binom.cdf( true_pos[ sens_peak_idx ], ( false_neg[ sens_peak_idx ] + true_pos[ sens_peak_idx ] ), sens_exp )
np.testing.assert_equal( p_val > lower_CI, True, f"Too few true positives in sensitive period given the test sensitivity s={sens_exp}: tn={true_neg}, fp={false_pos}, p={p_val}" )
np.testing.assert_equal( p_val < upper_CI, True, f"Too many true positives in sensitive period the test sensitivity s={sens_exp}: tn={true_neg}, fp={false_pos}, p={p_val}" )

del( model )

def test_recursive_testing_indirect_release(self, test_params ):
Expand All @@ -2497,6 +2502,8 @@ def test_recursive_testing_indirect_release(self, test_params ):

# write files
model.write_trace_tokens()

del( model )

df_trace = pd.read_csv( constant.TEST_TRACE_FILE, comment="#", sep=",", skipinitialspace=True )
df_trace = df_trace[ df_trace[ "index_time" ] == symp_time ]
Expand Down Expand Up @@ -2541,6 +2548,8 @@ def test_manual_trace_params(self, test_params, time_steps_test ):
all_pos = all_pos.append(df_inter[ df_inter[ "manual_traceable" ] == 1 ] )
model.write_trace_tokens()

del( model )

np.testing.assert_equal( len( all_pos ) > 0, True, "expected manual traces do not exist" )

def test_recursive_testing(self, test_params ):
Expand Down

0 comments on commit e0fa2ab

Please sign in to comment.