pymc-testing

Mock PyMC model sampling and provide pytest fixtures for testing.

76|10|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/pymc-labs/python-analytics-skills --skill pymc-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pymc-testing
Source: https://github.com/pymc-labs/python-analytics-skills/tree/main/skills/pymc-testing
Command: npx skills add https://github.com/pymc-labs/python-analytics-skills --skill pymc-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymc, pytest, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of efficiently testing PyMC models by providing optimized mocking and fixture utilities, allowing users to quickly verify model structure and functionality without the need for full MCMC sampling.

Core Features & Use Cases

  • Mock Sampling: Accelerates model testing by replacing MCMC sampling with prior predictive sampling, reducing inference time.
  • Test Fixtures: Provides pytest fixtures for convenient setup and teardown of model testing environments.
  • Use Case: When developing Bayesian models, use this Skill to quickly write tests for model specification and downstream code, ensuring that your model behaves as expected without the need for extensive computational resources.

Quick Start

Execute the following command to test a PyMC model using the mock sampling feature:

from pymc.testing import mock_sample
pm.sample = mock_sample
# Your model code here

Frequently Asked Questions about pymc-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test PyMC models without running slow MCMC sampling?

To test PyMC models without slow MCMC sampling, you can replace the sampling function with prior predictive mock sampling. This validates model structure and downstream code quickly without extensive computational resources.

What is the best way to speed up pytest workflows for Bayesian modeling?

The best way to speed up pytest workflows for Bayesian modeling is using specialized fixtures that handle setup and teardown. This streamlines testing environments by replacing full inference with faster mock sampling.

Do I need pytest to validate PyMC model structure?

Yes, you need pytest to validate PyMC model structure using this testing approach. The provided mock sampling utilities and fixtures are specifically designed to execute within the pytest framework.

Can I use prior predictive sampling to verify downstream code?

Yes, you can use prior predictive mock sampling to verify downstream code. By replacing standard MCMC sampling, it generates the necessary model outputs to ensure your downstream logic behaves as expected.

How does mock sampling reduce inference time in PyMC?

Mock sampling reduces inference time in PyMC by replacing computationally expensive MCMC sampling with prior predictive sampling. This allows quick verification of model specification and functionality without waiting for full chains to converge.

What are the limitations of using mocks for Bayesian model testing?

Using mocks for Bayesian model testing validates structure and downstream code but does not verify actual posterior distributions. It should be used to simplify workflows, not to replace full MCMC inference for final statistical validation.