Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several minor build issues #782

Merged
merged 5 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ concurrency:
# Precompute the ref if the workflow was triggered by a workflow dispatch rather than copying this logic repeatedly
env:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || null }}
use_lkg: ${{ (github.event_name == 'workflow_dispatch' && inputs.use_lkg) || github.event_name == 'pull_request' }}
# we want to use the LKG if that is explicitly requested, or if we're in a PR, but not a nightly run
# the final `|| ''` is because env vars are always converted to strings and the string 'false' is truthy (!!)
# (see https://github.com/orgs/community/discussions/25645)
use_lkg: ${{ (github.event_name == 'workflow_dispatch' && inputs.use_lkg) || github.event_name == 'pull_request' || ''}}

jobs:
eval:
Expand Down Expand Up @@ -291,6 +294,7 @@ jobs:
repository: testpypi
# don't have access to env context here for some reason
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || null }}
# can't use env context here so need to duplicate expression, but these are true boolean values so don't need extra string logic
use_lkg: ${{ (github.event_name == 'workflow_dispatch' && inputs.use_lkg) || github.event_name == 'pull_request' }}

docs:
Expand All @@ -303,6 +307,7 @@ jobs:
environment: test
# don't have access to env context here for some reason
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || null }}
# can't use env context here so need to duplicate expression, but these are true boolean values so don't need extra string logic
use_lkg: ${{ (github.event_name == 'workflow_dispatch' && inputs.use_lkg) || github.event_name == 'pull_request' }}

verify:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
python-version: 3.8 # because of our supported TensorFlow versions, must build on 3.6-3.8
- run: python -m pip install --upgrade pip && pip install --upgrade setuptools
name: Ensure latest pip and setuptools
- run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' }}
- run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' || '' }}
name: Install econml[all]
- run: sudo apt-get -yq install graphviz
name: Install graphviz
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- run: pip install cibuildwheel && python -m cibuildwheel --output-dir dist
name: Build wheels
env:
CIBW_BUILD: cp3{7,8,9,10}-*
CIBW_BUILD: cp3*
CIBW_SKIP: "*musl* *win32 *i686"
- uses: actions/upload-artifact@v3
name: Upload wheels as artifact
Expand All @@ -91,7 +91,7 @@ jobs:
python-version: 3.8 # because of our supported TensorFlow versions, must build on 3.6-3.8
- run: python -m pip install --upgrade pip && pip install --upgrade setuptools
name: Ensure latest pip and setuptools
- run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' }}
- run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' || '' }}
name: Install econml[all]
- run: python setup.py sdist
name: Build sdist
Expand Down
4 changes: 2 additions & 2 deletions econml/_cate_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from .inference import BootstrapInference
from .utilities import (tensordot, ndim, reshape, shape, parse_final_model_params, get_feature_names_or_default,
inverse_onehot, Summary, get_input_columns, check_input_arrays, jacify_featurizer)
from .inference import StatsModelsInference, StatsModelsInferenceDiscrete, LinearModelFinalInference,\
LinearModelFinalInferenceDiscrete, NormalInferenceResults, GenericSingleTreatmentModelFinalInference,\
from .inference import StatsModelsInference, StatsModelsInferenceDiscrete, LinearModelFinalInference, \
LinearModelFinalInferenceDiscrete, NormalInferenceResults, GenericSingleTreatmentModelFinalInference, \
GenericModelFinalInferenceDiscrete
from ._shap import _shap_explain_cme, _shap_explain_joint_linear_model_cate
from .dowhy import DoWhyWrapper
Expand Down
4 changes: 2 additions & 2 deletions econml/dowhy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class DoWhyWrapper:

def __init__(self, cate_estimator):
from pkg_resources import parse_version
if parse_version(dowhy.__version__) >= parse_version('0.9'):
warnings.warn("econml has not been tested with dowhy versions >= 0.9")
if parse_version(dowhy.__version__) >= parse_version('0.11'):
warnings.warn("econml has not been tested with dowhy versions >= 0.11")
self._cate_estimator = cate_estimator

def _get_params(self):
Expand Down
6 changes: 3 additions & 3 deletions econml/inference/_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,11 +1067,11 @@ def conf_int(self, alpha=0.05):
if self.stderr is None:
raise AttributeError("Only point estimates are available!")
if np.isscalar(self.point_estimate):
return _safe_norm_ppf(alpha / 2, loc=self.point_estimate, scale=self.stderr),\
return _safe_norm_ppf(alpha / 2, loc=self.point_estimate, scale=self.stderr), \
_safe_norm_ppf(1 - alpha / 2, loc=self.point_estimate, scale=self.stderr)
else:
return np.array([_safe_norm_ppf(alpha / 2, loc=p, scale=err)
for p, err in zip(self.point_estimate, self.stderr)]),\
for p, err in zip(self.point_estimate, self.stderr)]), \
np.array([_safe_norm_ppf(1 - alpha / 2, loc=p, scale=err)
for p, err in zip(self.point_estimate, self.stderr)])

Expand Down Expand Up @@ -1403,7 +1403,7 @@ def conf_int_mean(self, *, alpha=None):
_safe_norm_ppf(1 - alpha / 2, loc=mean_point, scale=stderr_mean))
else:
return np.array([_safe_norm_ppf(alpha / 2, loc=p, scale=err)
for p, err in zip(mean_point, stderr_mean)]),\
for p, err in zip(mean_point, stderr_mean)]), \
np.array([_safe_norm_ppf(1 - alpha / 2, loc=p, scale=err)
for p, err in zip(mean_point, stderr_mean)])

Expand Down
12 changes: 6 additions & 6 deletions econml/orf/_ortho_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,12 @@ def _pw_effect_inputs(self, X_single, stderr=False):
slice_weights_one, slice_weights_two = self._get_weights(X_single, tree_slice=slice_it)
slice_weights_list.append((slice_weights_one[mask_w1], slice_weights_two[mask_w2]))
W_none = self.W_one is None
return np.concatenate((self.Y_one[mask_w1], self.Y_two[mask_w2])),\
np.concatenate((self.T_one[mask_w1], self.T_two[mask_w2])),\
np.concatenate((self.X_one[mask_w1], self.X_two[mask_w2])),\
return np.concatenate((self.Y_one[mask_w1], self.Y_two[mask_w2])), \
np.concatenate((self.T_one[mask_w1], self.T_two[mask_w2])), \
np.concatenate((self.X_one[mask_w1], self.X_two[mask_w2])), \
np.concatenate((self.W_one[mask_w1], self.W_two[mask_w2])
) if not W_none else None,\
w_nonzero,\
) if not W_none else None, \
w_nonzero, \
split_inds, slice_weights_list

def _get_inference_options(self):
Expand Down Expand Up @@ -1255,7 +1255,7 @@ def const_marginal_effect_interval(self, X=None, *, alpha=0.05):
param_upper = [param + np.apply_along_axis(lambda s: norm.ppf(upper, scale=s), 0, np.sqrt(np.diag(cov_mat)))
for (param, cov_mat) in params_and_cov]
param_lower, param_upper = np.asarray(param_lower), np.asarray(param_upper)
return param_lower.reshape((-1,) + self._estimator._d_y + self._estimator._d_t),\
return param_lower.reshape((-1,) + self._estimator._d_y + self._estimator._d_t), \
param_upper.reshape((-1,) + self._estimator._d_y + self._estimator._d_t)

def const_marginal_effect_inference(self, X=None):
Expand Down
10 changes: 5 additions & 5 deletions econml/sklearn_extensions/linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ def coef__interval(self, alpha=0.05):
The lower and upper bounds of the confidence interval of the coefficients
"""
return np.array([_safe_norm_ppf(alpha / 2, loc=p, scale=err)
for p, err in zip(self.coef_, self.coef_stderr_)]),\
for p, err in zip(self.coef_, self.coef_stderr_)]), \
np.array([_safe_norm_ppf(1 - alpha / 2, loc=p, scale=err)
for p, err in zip(self.coef_, self.coef_stderr_)])

Expand All @@ -1677,15 +1677,15 @@ def intercept__interval(self, alpha=0.05):
The lower and upper bounds of the confidence interval of the intercept(s)
"""
if not self.fit_intercept:
return (0 if self._n_out == 0 else np.zeros(self._n_out)),\
return (0 if self._n_out == 0 else np.zeros(self._n_out)), \
(0 if self._n_out == 0 else np.zeros(self._n_out))

if self._n_out == 0:
return _safe_norm_ppf(alpha / 2, loc=self.intercept_, scale=self.intercept_stderr_),\
return _safe_norm_ppf(alpha / 2, loc=self.intercept_, scale=self.intercept_stderr_), \
_safe_norm_ppf(1 - alpha / 2, loc=self.intercept_, scale=self.intercept_stderr_)
else:
return np.array([_safe_norm_ppf(alpha / 2, loc=p, scale=err)
for p, err in zip(self.intercept_, self.intercept_stderr_)]),\
for p, err in zip(self.intercept_, self.intercept_stderr_)]), \
np.array([_safe_norm_ppf(1 - alpha / 2, loc=p, scale=err)
for p, err in zip(self.intercept_, self.intercept_stderr_)])

Expand All @@ -1707,7 +1707,7 @@ def predict_interval(self, X, alpha=0.05):
The lower and upper bounds of the confidence intervals of the predicted mean outcomes
"""
return np.array([_safe_norm_ppf(alpha / 2, loc=p, scale=err)
for p, err in zip(self.predict(X), self.prediction_stderr(X))]),\
for p, err in zip(self.predict(X), self.prediction_stderr(X))]), \
np.array([_safe_norm_ppf(1 - alpha / 2, loc=p, scale=err)
for p, err in zip(self.predict(X), self.prediction_stderr(X))])

Expand Down
Loading