Skip to content

Add fast pytest for skpro FunctionalCPD in FunctionalBN refactor#61

Merged
daehyun99 merged 1 commit intowipfrom
codex/add-pytest-test-code-for-cpd-model
Mar 31, 2026
Merged

Add fast pytest for skpro FunctionalCPD in FunctionalBN refactor#61
daehyun99 merged 1 commit intowipfrom
codex/add-pytest-test-code-for-cpd-model

Conversation

@daehyun99
Copy link
Copy Markdown
Owner

Motivation

  • Provide CI coverage for the skpro integration path in FunctionalCPD without running expensive Bayesian training.
  • Ensure FunctionalBayesianNetwork correctly invokes the external-model adapter for tag='skpro' and passes the expected input shapes.

Description

  • Added pytest import and a new test test_fit_with_bayesian_linear_regressor_uses_fast_mocked_fit to pgmpy/tests/test_models/test_FunctionalBayesianNetwork_Refactor.py that exercises the skpro CPD path with a small synthetic dataset.
  • The test uses pytest.importorskip for skpro and pymc_marketing and monkeypatch to replace BayesianLinearRegressor.fit with a fast mock that records X/y shapes and column names.
  • The test constructs a FunctionalBN with mixed CPD tags (tabular, skpro, linear), calls model.fit(data), and asserts the adapter supplied a constant-design matrix (['_const_']) of shape (n_samples, 1) and the expected y shape.

Testing

  • Ran pytest -q pgmpy/tests/test_models/test_FunctionalBayesianNetwork_Refactor.py which completed with 2 passed, 1 skipped.
  • Attempted pre-commit run --all-files but it failed in the environment with pre-commit: command not found.

Codex Task

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test case, test_fit_with_bayesian_linear_regressor_uses_fast_mocked_fit, to verify the integration of FunctionalBayesianNetwork with skpro's BayesianLinearRegressor using a mocked fit method. The review feedback recommends using monkeypatch.setitem when modifying the _tags attribute of BayesianLinearRegressor to prevent side effects from persisting across other tests.

@daehyun99 daehyun99 merged commit 87bceef into wip Mar 31, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant