From ada34cc87d24d5031370de7ba2b107913a7c7e48 Mon Sep 17 00:00:00 2001 From: chenglu Date: Thu, 21 Nov 2024 10:24:12 +0800 Subject: [PATCH] fix dowhy_ not existance issue --- econml/dowhy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/econml/dowhy.py b/econml/dowhy.py index ac5fda772..73cc33795 100644 --- a/econml/dowhy.py +++ b/econml/dowhy.py @@ -231,9 +231,13 @@ def __getattr__(self, attr): # don't proxy special methods if attr.startswith('__'): raise AttributeError(attr) - elif attr in ['_cate_estimator', 'dowhy_', - 'identified_estimand_', 'estimate_']: - return super().__getattr__(attr) + elif attr == "dowhy_": + if "dowhy_" not in dir(self): + raise RuntimeError("Please call DoWhyWrapper.fit first before any other operations") + else: + return self.dowhy_ + elif attr in ['_cate_estimator', 'identified_estimand_', 'estimate_']: + return getattr(self, attr) elif attr.startswith('dowhy__'): return getattr(self.dowhy_, attr[len('dowhy__'):]) elif hasattr(self.estimate_._estimator_object, attr):