Skip to content

Commit 2fcf523

Browse files
committed
update y_col setter
1 parent 1c48f0e commit 2fcf523

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

doubleml/data/base_data.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)