@@ -5610,6 +5610,37 @@ def test_check_national_vif_has_correct_vif_value(self):
56105610 national_artifact .vif_da .values , expected_national_vif
56115611 )
56125612
5613+ def test_check_vif_with_constant_variable (self ):
5614+ meridian = model .Meridian (self .national_input_data_media_and_rf )
5615+ engine = eda_engine .EDAEngine (meridian )
5616+ shape = (_N_TIMES_VIF ,)
5617+ v1 = _RNG .random (shape )
5618+ v2 = np .ones (shape )
5619+ v3 = _RNG .random (shape )
5620+ data_np = np .stack ([v1 , v2 , v3 ], axis = - 1 )
5621+ data = (
5622+ _create_data_array_with_var_dim (data_np , "VIF" , "var" )
5623+ .rename ({"var_dim" : eda_engine ._STACK_VAR_COORD_NAME })
5624+ .assign_coords (
5625+ {eda_engine ._STACK_VAR_COORD_NAME : ["var_1" , "var_2" , "var_3" ]}
5626+ )
5627+ )
5628+ self ._mock_eda_engine_property (
5629+ "_stacked_national_treatment_control_scaled_da" , data
5630+ )
5631+
5632+ outcome = engine .check_national_vif ()
5633+
5634+ self .assertIsInstance (outcome , eda_outcome .EDAOutcome )
5635+ self .assertEqual (
5636+ outcome .check_type , eda_outcome .EDACheckType .MULTICOLLINEARITY
5637+ )
5638+ self .assertLen (outcome .analysis_artifacts , 1 )
5639+
5640+ national_artifact = outcome .analysis_artifacts [0 ]
5641+ self .assertIsInstance (national_artifact , eda_outcome .VIFArtifact )
5642+ self .assertEqual (national_artifact .vif_da .sel (var = "var_2" ), 0 )
5643+
56135644 @parameterized .named_parameters (
56145645 dict (
56155646 testcase_name = "national_model" ,
@@ -6312,7 +6343,7 @@ def test_run_all_critical_checks_with_exception(self):
63126343 outcomes [1 ].findings [0 ].severity , eda_outcome .EDASeverity .ERROR
63136344 )
63146345 self .assertIn (
6315- "An error occurred during check check_vif: Test Error" ,
6346+ "An error occurred during running check_vif: ValueError(' Test Error') " ,
63166347 outcomes [1 ].findings [0 ].explanation ,
63176348 )
63186349
@@ -6325,7 +6356,8 @@ def test_run_all_critical_checks_with_exception(self):
63256356 outcomes [2 ].findings [0 ].severity , eda_outcome .EDASeverity .ERROR
63266357 )
63276358 self .assertIn (
6328- "An error occurred during check check_pairwise_corr: Another Error" ,
6359+ "An error occurred during running check_pairwise_corr:"
6360+ " TypeError('Another Error')" ,
63296361 outcomes [2 ].findings [0 ].explanation ,
63306362 )
63316363
0 commit comments