Skip to main content

RuleSet

Struct RuleSet 

Source
pub struct RuleSet { /* private fields */ }
Expand description

A chosen subset of the run tests.

Each test reports exactly one ViolationType, so a rule is named by what it would report rather than by a parallel enum that would have to be kept in step with this one.

Three sets have names – shewhart (the 3-sigma test alone, the default), western_electric and nelson – and RuleSet::named looks them up by the names a wire request uses; any other combination is built from the tests a process actually warrants. A rule that a process is known to trigger for a benign reason – a deliberately drifting tool, a bimodal fixture – otherwise has to be filtered out downstream, after it has already been counted as an out-of-control signal.

§Examples

use u_analytics::spc::{RuleSet, RunRule, ChartPoint, ControlLimits, ViolationType};

// Only the 3-sigma test, and nothing else.
let rules = RuleSet::from_iter([ViolationType::BeyondLimits]);

let limits = ControlLimits { ucl: 28.0, cl: 25.0, lcl: 22.0 };
let points: Vec<ChartPoint> = (0..12)
    .map(|i| ChartPoint { value: 26.0, index: i, violations: vec![] })
    .collect();

// Twelve points above the centre line would trip Nelson rule 2, but that
// test is not in this set.
assert!(rules.check(&points, &limits).is_empty());
assert!(RuleSet::nelson().check(&points, &limits).len() > 0);

Implementations§

Source§

impl RuleSet

Source

pub const NAMES: [&'static str; 3]

The names RuleSet::named takes, in the order a refusal lists them.

Source

pub fn shewhart() -> Self

The 3-sigma test alone – Shewhart’s criterion, and the default.

In routine monitoring each added test raises the false alarm rate of an in-control process (ISO 7870-2:2023, 8.2.7), so the supplementary tests are chosen, not assumed.

Source

pub fn nelson() -> Self

Nelson’s eight tests (1984).

Source

pub fn western_electric() -> Self

The four Western Electric tests (1956): Nelson rules 1, 5 and 6, and eight points in a row on one side of the centre line.

Source

pub fn named(name: &str) -> Option<Self>

The set a name in RuleSet::NAMES stands for.

Source

pub fn none() -> Self

The empty set: no run test is applied.

Useful as a base to add to, and as the honest way to say “limits only”.

Source

pub fn contains(&self, rule: ViolationType) -> bool

Whether this set applies the test that reports rule.

Source

pub fn with(self, rule: ViolationType) -> Self

This set with rule added.

Source

pub fn without(self, rule: ViolationType) -> Self

This set with rule removed.

Source

pub fn iter(&self) -> impl Iterator<Item = ViolationType> + '_

The tests in this set, in the order of ViolationType::ALL.

Source

pub fn len(&self) -> usize

How many tests this set applies.

Source

pub fn is_empty(&self) -> bool

Whether no test is applied.

Trait Implementations§

Source§

impl Clone for RuleSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RuleSet

Source§

impl Debug for RuleSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RuleSet

Source§

fn default() -> Self

RuleSet::shewhart – the 3-sigma test alone.

Source§

impl Eq for RuleSet

Source§

impl FromIterator<ViolationType> for RuleSet

Source§

fn from_iter<I: IntoIterator<Item = ViolationType>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for RuleSet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RunRule for RuleSet

Source§

fn check( &self, points: &[ChartPoint], limits: &ControlLimits, ) -> Vec<(usize, ViolationType)>

Check points against this rule set and return violations per point index. Read more
Source§

impl StructuralPartialEq for RuleSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.