From 67f5aead414143318335c1da8b496102737dd330 Mon Sep 17 00:00:00 2001 From: Rob Zinkov Date: Fri, 11 Nov 2022 00:52:18 +0100 Subject: [PATCH 1/5] Remove arviz as a dependency --- setup.py | 2 +- src/beanmachine/ppl/inference/monte_carlo_samples.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 1f4f42b609..65f45c5009 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ REQUIRED_MINOR = 7 INSTALL_REQUIRES = [ - "arviz>=0.12.1", "astor>=0.7.1", "black==22.3.0", "botorch>=0.5.1", @@ -36,6 +35,7 @@ ] TEST_REQUIRES = ["pytest>=7.0.0", "pytest-cov"] TUTORIALS_REQUIRES = [ + "arviz>=0.12.1", "bokeh", "cma", "ipywidgets", diff --git a/src/beanmachine/ppl/inference/monte_carlo_samples.py b/src/beanmachine/ppl/inference/monte_carlo_samples.py index 8345bd6e79..080db28ab8 100644 --- a/src/beanmachine/ppl/inference/monte_carlo_samples.py +++ b/src/beanmachine/ppl/inference/monte_carlo_samples.py @@ -5,7 +5,6 @@ from typing import Any, Dict, Iterator, List, Mapping, NamedTuple, Optional, Union -import arviz as az import torch import xarray as xr from beanmachine.ppl.inference.utils import detach_samples, merge_dicts @@ -266,10 +265,11 @@ def add_groups(self, mcs: "MonteCarloSamples"): if n not in self.namespaces: self.namespaces[n] = mcs.namespaces[n] - def to_inference_data(self, include_adapt_steps: bool = False) -> az.InferenceData: + def to_inference_data(self, include_adapt_steps: bool = False): """ Return an az.InferenceData from MonteCarloSamples. """ + import arviz as az if "posterior" in self.namespaces: posterior = detach_samples(self.namespaces["posterior"].samples) From 79b7a39a288606d12114bd55703c338f2b4f6e5d Mon Sep 17 00:00:00 2001 From: Rob Zinkov Date: Fri, 11 Nov 2022 03:20:02 +0100 Subject: [PATCH 2/5] Test setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 65f45c5009..1f4f42b609 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ REQUIRED_MINOR = 7 INSTALL_REQUIRES = [ + "arviz>=0.12.1", "astor>=0.7.1", "black==22.3.0", "botorch>=0.5.1", @@ -35,7 +36,6 @@ ] TEST_REQUIRES = ["pytest>=7.0.0", "pytest-cov"] TUTORIALS_REQUIRES = [ - "arviz>=0.12.1", "bokeh", "cma", "ipywidgets", From e025e2c3a3bba868dcb930623dd7eba5ab300c4d Mon Sep 17 00:00:00 2001 From: Rob Zinkov Date: Fri, 11 Nov 2022 03:44:11 +0100 Subject: [PATCH 3/5] Another test --- src/beanmachine/ppl/inference/monte_carlo_samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beanmachine/ppl/inference/monte_carlo_samples.py b/src/beanmachine/ppl/inference/monte_carlo_samples.py index 080db28ab8..d68728e9b9 100644 --- a/src/beanmachine/ppl/inference/monte_carlo_samples.py +++ b/src/beanmachine/ppl/inference/monte_carlo_samples.py @@ -5,6 +5,7 @@ from typing import Any, Dict, Iterator, List, Mapping, NamedTuple, Optional, Union +import arviz as az import torch import xarray as xr from beanmachine.ppl.inference.utils import detach_samples, merge_dicts @@ -269,7 +270,6 @@ def to_inference_data(self, include_adapt_steps: bool = False): """ Return an az.InferenceData from MonteCarloSamples. """ - import arviz as az if "posterior" in self.namespaces: posterior = detach_samples(self.namespaces["posterior"].samples) From 51c7abbfffdb3bbfb61ffa6643ed0f0ab119e19f Mon Sep 17 00:00:00 2001 From: Rob Zinkov Date: Fri, 11 Nov 2022 04:40:25 +0100 Subject: [PATCH 4/5] Move deps --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1f4f42b609..df62492726 100644 --- a/setup.py +++ b/setup.py @@ -17,13 +17,11 @@ REQUIRED_MINOR = 7 INSTALL_REQUIRES = [ - "arviz>=0.12.1", "astor>=0.7.1", "black==22.3.0", "botorch>=0.5.1", "gpytorch>=1.3.0, <1.9.0", "graphviz>=0.17", - "netCDF4<=1.5.8; python_version<'3.8'", "numpy>=1.18.1", "pandas>=0.24.2", "plotly>=2.2.1", @@ -36,6 +34,7 @@ ] TEST_REQUIRES = ["pytest>=7.0.0", "pytest-cov"] TUTORIALS_REQUIRES = [ + "arviz>=0.12.1", "bokeh", "cma", "ipywidgets", @@ -44,6 +43,7 @@ "matplotlib", "mdformat", "mdformat-myst", + "netCDF4<=1.5.8; python_version<'3.8'", "scikit-learn>=1.0.0", "seaborn", "tabulate", From 28714c471d22a9e7d472bd529b812bd831468ea3 Mon Sep 17 00:00:00 2001 From: Rob Zinkov Date: Thu, 26 Jan 2023 19:52:34 +0100 Subject: [PATCH 5/5] Use _requires_dev_package --- src/beanmachine/ppl/inference/monte_carlo_samples.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/beanmachine/ppl/inference/monte_carlo_samples.py b/src/beanmachine/ppl/inference/monte_carlo_samples.py index d68728e9b9..3bb64ccc52 100644 --- a/src/beanmachine/ppl/inference/monte_carlo_samples.py +++ b/src/beanmachine/ppl/inference/monte_carlo_samples.py @@ -10,6 +10,7 @@ import xarray as xr from beanmachine.ppl.inference.utils import detach_samples, merge_dicts from beanmachine.ppl.model.rv_identifier import RVIdentifier +from beanmachine.ppl.diagnostics.tools.viz import _requires_dev_packages RVDict = Dict[RVIdentifier, torch.Tensor] @@ -266,10 +267,12 @@ def add_groups(self, mcs: "MonteCarloSamples"): if n not in self.namespaces: self.namespaces[n] = mcs.namespaces[n] + @_requires_dev_packages def to_inference_data(self, include_adapt_steps: bool = False): """ Return an az.InferenceData from MonteCarloSamples. """ + import arviz as az if "posterior" in self.namespaces: posterior = detach_samples(self.namespaces["posterior"].samples)