# Copyright (c) 2026 Umber # # Licensed under the Apache License, Version 2.0; see LICENSE. from __future__ import annotations import pytest np = pytest.importorskip("numpy") def test_shewhart_individuals_limits() -> None: from fiwicontrol.spc import ShewhartControlChart x = np.array([1.0, 1.1, 0.9, 1.05, 0.95, 1.02]) chart = ShewhartControlChart(k=3.0).fit_individuals(x) lo, c, hi = chart.limits() assert lo < c < hi assert not chart.is_out_of_control(c) assert chart.is_out_of_control(c + 10 * (hi - lo)) def test_hotelling_t2_ucl() -> None: pytest.importorskip("scipy") from fiwicontrol.spc import HotellingT2 rng = np.random.default_rng(0) m, p = 40, 3 base = rng.standard_normal((m, p)) ht = HotellingT2().fit(base) ucl = ht.ucl(alpha=0.05) in_control = np.mean(base, axis=0) assert ht.t2(in_control) < ucl