From 337fd60da83eefc388055e24254be56ec666adeb Mon Sep 17 00:00:00 2001 From: Florian Nachtigall Date: Fri, 23 Jun 2023 16:13:41 +0200 Subject: [PATCH 1/2] Suppress scalar warning if treatment is 0 If multiple treatments are specified, a warning is given if a scalar is provided as treatment value. Previously, since this check currently included the base treatment T0, for which the default is 0, a warning was emitted even if the base treatment was not specified. Now, to avoid misleading warnings for the base treatment, suppress the warning if T is 0. --- econml/_cate_estimator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/econml/_cate_estimator.py b/econml/_cate_estimator.py index 3c453b291..67040117b 100644 --- a/econml/_cate_estimator.py +++ b/econml/_cate_estimator.py @@ -852,7 +852,7 @@ def _expand_treatments(self, X=None, *Ts, transform=True): n_rows = 1 if X is None else shape(X)[0] outTs = [] for T in Ts: - if (ndim(T) == 0) and self._d_t_in and self._d_t_in[0] > 1: + if (ndim(T) == 0) and self._d_t_in and self._d_t_in[0] > 1 and T != 0: warn("A scalar was specified but there are multiple treatments; " "the same value will be used for each treatment. Consider specifying" "all treatments, or using the const_marginal_effect method.") From 61b9bdc7bad046fe5363d1f7728e8f05a96df7e2 Mon Sep 17 00:00:00 2001 From: Florian Nachtigall Date: Fri, 23 Jun 2023 16:17:09 +0200 Subject: [PATCH 2/2] Remove dead code --- econml/_cate_estimator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/econml/_cate_estimator.py b/econml/_cate_estimator.py index 67040117b..c1f9e26d8 100644 --- a/econml/_cate_estimator.py +++ b/econml/_cate_estimator.py @@ -599,7 +599,6 @@ def effect(self, X=None, *, T0, T1): # of rows of T was not taken into account if X is None: eff = np.repeat(eff, shape(T0)[0], axis=0) - m = shape(eff)[0] dT = T1 - T0 einsum_str = 'myt,mt->my' if ndim(dT) == 1: