From 56c34e6717d50255f1819d3bdf7f8f99e83fd6b7 Mon Sep 17 00:00:00 2001 From: "Benjamin T. Vincent" Date: Mon, 27 Oct 2025 12:17:38 +0000 Subject: [PATCH 1/4] fix environment issue --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index a838de19..09850e05 100644 --- a/environment.yml +++ b/environment.yml @@ -16,3 +16,4 @@ dependencies: - statsmodels - xarray>=v2022.11.0 - pymc-extras>=0.3.0 + - python>=3.11 From ac95a60b3cc10b9e29c266d276a768a5dfece1e8 Mon Sep 17 00:00:00 2001 From: "Benjamin T. Vincent" Date: Mon, 27 Oct 2025 12:27:06 +0000 Subject: [PATCH 2/4] update makefile to avoid local dev errors --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d109ae39..4fdfbf7c 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,10 @@ check_lint: interrogate . doctest: - pytest --doctest-modules --ignore=causalpy/tests/ causalpy/ --config-file=causalpy/tests/conftest.py + python -m pytest --doctest-modules --ignore=causalpy/tests/ causalpy/ --config-file=causalpy/tests/conftest.py test: - pytest + python -m pytest uml: pyreverse -o png causalpy --output-directory docs/source/_static --ignore tests From d28164e21e5329c37389ede069f4c8a838742d3c Mon Sep 17 00:00:00 2001 From: "Benjamin T. Vincent" Date: Mon, 27 Oct 2025 12:28:25 +0000 Subject: [PATCH 3/4] hide arviz style change in BaseExperiment.plot --- causalpy/__init__.py | 3 --- causalpy/experiments/base.py | 17 +++++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/causalpy/__init__.py b/causalpy/__init__.py index 66031185..5587fb3e 100644 --- a/causalpy/__init__.py +++ b/causalpy/__init__.py @@ -11,7 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import arviz as az import causalpy.pymc_models as pymc_models import causalpy.skl_models as skl_models @@ -28,8 +27,6 @@ from .experiments.regression_kink import RegressionKink from .experiments.synthetic_control import SyntheticControl -az.style.use("arviz-darkgrid") - __all__ = [ "__version__", "DifferenceInDifferences", diff --git a/causalpy/experiments/base.py b/causalpy/experiments/base.py index abc284c7..e8bb83dc 100644 --- a/causalpy/experiments/base.py +++ b/causalpy/experiments/base.py @@ -63,12 +63,17 @@ def plot(self, *args, **kwargs) -> tuple: Internally, this function dispatches to either `_bayesian_plot` or `_ols_plot` depending on the model type. """ - if isinstance(self.model, PyMCModel): - return self._bayesian_plot(*args, **kwargs) - elif isinstance(self.model, RegressorMixin): - return self._ols_plot(*args, **kwargs) - else: - raise ValueError("Unsupported model type") + import arviz as az + import matplotlib.pyplot as plt + + # Apply arviz-darkgrid style only during plotting, then revert + with plt.style.context(az.style.library["arviz-darkgrid"]): + if isinstance(self.model, PyMCModel): + return self._bayesian_plot(*args, **kwargs) + elif isinstance(self.model, RegressorMixin): + return self._ols_plot(*args, **kwargs) + else: + raise ValueError("Unsupported model type") @abstractmethod def _bayesian_plot(self, *args, **kwargs): From edcb861f6d08c48512abb05244526d1860a43a0a Mon Sep 17 00:00:00 2001 From: "Benjamin T. Vincent" Date: Mon, 27 Oct 2025 15:52:03 +0000 Subject: [PATCH 4/4] move imports to top --- causalpy/experiments/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/causalpy/experiments/base.py b/causalpy/experiments/base.py index e8bb83dc..f24cc69a 100644 --- a/causalpy/experiments/base.py +++ b/causalpy/experiments/base.py @@ -17,6 +17,8 @@ from abc import abstractmethod +import arviz as az +import matplotlib.pyplot as plt import pandas as pd from sklearn.base import RegressorMixin @@ -63,9 +65,6 @@ def plot(self, *args, **kwargs) -> tuple: Internally, this function dispatches to either `_bayesian_plot` or `_ols_plot` depending on the model type. """ - import arviz as az - import matplotlib.pyplot as plt - # Apply arviz-darkgrid style only during plotting, then revert with plt.style.context(az.style.library["arviz-darkgrid"]): if isinstance(self.model, PyMCModel):