File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -527,15 +527,27 @@ def y_col(self):
527527 @y_col .setter
528528 def y_col (self , value ):
529529 reset_value = hasattr (self , "_y_col" )
530+
531+ # Basic checks
530532 if not isinstance (value , str ):
531533 raise TypeError (
532534 f"The outcome variable y_col must be of str type. { str (value )} of type { str (type (value ))} was passed."
533535 )
534536 if value not in self .all_variables :
535537 raise ValueError (f"Invalid outcome variable y_col. { value } is no data column." )
536- self ._y_col = value
538+
539+ if reset_value :
540+ previous_value = self ._y_col
541+ self ._y_col = value
542+ try :
543+ self ._check_disjoint_sets ()
544+ except ValueError as e :
545+ self ._y_col = previous_value
546+ raise e
547+ else :
548+ self ._y_col = value
549+
537550 if reset_value :
538- self ._check_disjoint_sets ()
539551 self ._set_y_z ()
540552
541553 @property
You can’t perform that action at this time.
0 commit comments