From 2f22c1a1629a8956387d05c086d9cec8849718ae Mon Sep 17 00:00:00 2001 From: aloctavodia Date: Tue, 31 May 2022 10:54:52 -0300 Subject: [PATCH 1/4] supress warning SMC initialization --- pymc/smc/smc.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pymc/smc/smc.py b/pymc/smc/smc.py index a38f700f38..ab88dff487 100644 --- a/pymc/smc/smc.py +++ b/pymc/smc/smc.py @@ -15,6 +15,7 @@ from abc import ABC from typing import Dict, cast +import warnings import aesara.tensor as at import numpy as np @@ -175,12 +176,18 @@ def __init__( def initialize_population(self) -> Dict[str, np.ndarray]: """Create an initial population from the prior distribution""" - result = sample_prior_predictive( - self.draws, - var_names=[v.name for v in self.model.unobserved_value_vars], - model=self.model, - return_inferencedata=False, - ) + print() + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", category=UserWarning, message="The effect of Potentials" + ) + + result = sample_prior_predictive( + self.draws, + var_names=[v.name for v in self.model.unobserved_value_vars], + model=self.model, + return_inferencedata=False, + ) return cast(Dict[str, np.ndarray], result) def _initialize_kernel(self): From 7089c9c822b67b4778a5f483b4f2f2519637ce09 Mon Sep 17 00:00:00 2001 From: aloctavodia Date: Tue, 31 May 2022 11:48:30 -0300 Subject: [PATCH 2/4] use sys instead of print --- pymc/smc/smc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymc/smc/smc.py b/pymc/smc/smc.py index ab88dff487..511c5c6de9 100644 --- a/pymc/smc/smc.py +++ b/pymc/smc/smc.py @@ -14,6 +14,7 @@ import abc from abc import ABC +import sys from typing import Dict, cast import warnings @@ -176,7 +177,7 @@ def __init__( def initialize_population(self) -> Dict[str, np.ndarray]: """Create an initial population from the prior distribution""" - print() + sys.stdout.write(" ") with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=UserWarning, message="The effect of Potentials" From ff6e02143eaf9b1da7555cefcba75c1bd8f21a0c Mon Sep 17 00:00:00 2001 From: aloctavodia Date: Tue, 31 May 2022 12:03:44 -0300 Subject: [PATCH 3/4] isort --- pymc/smc/smc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymc/smc/smc.py b/pymc/smc/smc.py index 511c5c6de9..6007ad73f6 100644 --- a/pymc/smc/smc.py +++ b/pymc/smc/smc.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import abc +import sys +import warnings from abc import ABC -import sys from typing import Dict, cast -import warnings import aesara.tensor as at import numpy as np From a67b9b4c00e04df7bd5f52a8cb5a1e3d0b00fd11 Mon Sep 17 00:00:00 2001 From: aloctavodia Date: Tue, 31 May 2022 12:10:17 -0300 Subject: [PATCH 4/4] add comment --- pymc/smc/smc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/smc/smc.py b/pymc/smc/smc.py index 6007ad73f6..6cb37a8feb 100644 --- a/pymc/smc/smc.py +++ b/pymc/smc/smc.py @@ -177,7 +177,7 @@ def __init__( def initialize_population(self) -> Dict[str, np.ndarray]: """Create an initial population from the prior distribution""" - sys.stdout.write(" ") + sys.stdout.write(" ") # see issue #5828 with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=UserWarning, message="The effect of Potentials"