mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-06 17:49:07 -05:00
[PR #1608] [MERGED] fix(mlsysim): skip viz test when matplotlib is not installed #9219
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1608
Author: @Shashank-Tripathi-07
Created: 4/30/2026
Status: ✅ Merged
Merged: 4/30/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/mlsysim-viz-test-missing-skip📝 Commits (2)
b464692fix(mlsysim): skip viz test when matplotlib is not installed7125cb0Merge branch 'dev' into fix/mlsysim-viz-test-missing-skip📊 Changes
1 file changed (+2 additions, -0 deletions)
View changed files
📝
mlsysim/tests/test_evaluation_contract.py(+2 -0)📄 Description
Summary
test_scorecard_plot_accepts_scenario_evaluation_quantitiescalledplot_evaluation_scorecardunconditionally, butmatplotlibis an optional dependency undermlsysim[viz]-- not installed in the base dev environment. Runningpytestwithout the viz extra caused a hardImportErrorinstead of a graceful skip:Fix: Add
pytest.importorskip("matplotlib")at the start of the test, which is the standard pytest pattern for optional-dependency tests -- the test is skipped when matplotlib is absent and runs normally whenmlsysim[viz]is installed.Before / after
Test plan
uv run python -m pytest tests/with base deps -- confirm test is skipped, not faileduv run python -m pytest tests/ --extras viz(or with matplotlib installed) -- confirm test runs and passes🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.