Summary
The TestResidualPlots tests in tests/test_plotting.py are not actually testing the residual plotting functionality because the fixture produces results where has_residuals is False.
Details
The tests have conditional guards like:
def test_plot_residuals_available (self , result_with_residuals ):
if result_with_residuals .has_residuals :
plotter = Plotter (result_with_residuals )
fig = plotter .plot_residuals ()
assert isinstance (fig , ControlChartFigure )
But the result_with_residuals fixture returns a result where has_residuals is False:
@pytest .fixture
def result_with_residuals (self ):
np .random .seed (42 )
df = pd .DataFrame ({
'value' : np .random .normal (100 , 5 , 100 ),
'subgroup' : np .repeat (range (20 ), 5 ),
'time' : range (100 )
})
pdf = ProcessDataFrame (df )
study = pdf .formulate (response = pdf .columns .value , factors = [pdf .columns .subgroup ])
return study .analyze () # has_residuals is False!
This means the tests pass by doing nothing - plot_residuals() is never called.
Affected tests
test_plot_residuals_available
test_plot_residuals_histogram
test_plot_residuals_qq
test_plot_residuals_sequence
Suggested fix
Fix the fixture to produce results that actually have residuals
Consider eliminating scipy entirely from plot_residuals() to keep the package lightweight. The current scipy usage is minimal:
norm.pdf() for histogram overlay - trivial to replace:
(1 / (std * math .sqrt (2 * math .pi ))) * math .exp (- 0.5 * ((x - mean ) / std ) ** 2 )
norm.ppf() for Q-Q plot quantiles - can use well-known approximations (e.g., Abramowitz & Stegun or Beasley-Springer-Moro algorithm)
This would match the approach taken in PR fix: Resolve ruff linting errors and remove scipy dependency #47 where scipy.special.loggamma was replaced with math.lgamma in spc_constants.py.
🤖 Generated with Claude Code
Summary
The
TestResidualPlotstests intests/test_plotting.pyare not actually testing the residual plotting functionality because the fixture produces results wherehas_residualsisFalse.Details
The tests have conditional guards like:
But the
result_with_residualsfixture returns a result wherehas_residualsisFalse:This means the tests pass by doing nothing -
plot_residuals()is never called.Affected tests
test_plot_residuals_availabletest_plot_residuals_histogramtest_plot_residuals_qqtest_plot_residuals_sequenceSuggested fix
Fix the fixture to produce results that actually have residuals
Consider eliminating scipy entirely from
plot_residuals()to keep the package lightweight. The current scipy usage is minimal:norm.pdf()for histogram overlay - trivial to replace:norm.ppf()for Q-Q plot quantiles - can use well-known approximations (e.g., Abramowitz & Stegun or Beasley-Springer-Moro algorithm)This would match the approach taken in PR fix: Resolve ruff linting errors and remove scipy dependency #47 where
scipy.special.loggammawas replaced withmath.lgammainspc_constants.py.🤖 Generated with Claude Code