Skip to content

Commit 6750ea7

Browse files
authored
Supress warning SMC initialization (#5827)
1 parent 6027be1 commit 6750ea7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pymc/smc/smc.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import abc
15+
import sys
16+
import warnings
1517

1618
from abc import ABC
1719
from typing import Dict, cast
@@ -175,12 +177,18 @@ def __init__(
175177

176178
def initialize_population(self) -> Dict[str, np.ndarray]:
177179
"""Create an initial population from the prior distribution"""
178-
result = sample_prior_predictive(
179-
self.draws,
180-
var_names=[v.name for v in self.model.unobserved_value_vars],
181-
model=self.model,
182-
return_inferencedata=False,
183-
)
180+
sys.stdout.write(" ") # see issue #5828
181+
with warnings.catch_warnings():
182+
warnings.filterwarnings(
183+
"ignore", category=UserWarning, message="The effect of Potentials"
184+
)
185+
186+
result = sample_prior_predictive(
187+
self.draws,
188+
var_names=[v.name for v in self.model.unobserved_value_vars],
189+
model=self.model,
190+
return_inferencedata=False,
191+
)
184192
return cast(Dict[str, np.ndarray], result)
185193

186194
def _initialize_kernel(self):

0 commit comments

Comments
 (0)