Skip to main content

CITest

Trait CITest 

Source
pub trait CITest: Send + Sync {
    // Required methods
    fn test_impl(
        &self,
        data: &Dataset,
        x: usize,
        y: usize,
        z: &[usize],
    ) -> Result<CIResult, CIError>;
    fn meta(&self) -> TestMeta;

    // Provided methods
    fn validate(&self, _data: &Dataset) -> Result<(), CIError> { ... }
    fn test(
        &self,
        data: &Dataset,
        x: usize,
        y: usize,
        z: &[usize],
    ) -> Result<CIResult, CIError> { ... }
    fn is_independent(
        &self,
        data: &Dataset,
        x: usize,
        y: usize,
        z: &[usize],
        alpha: f64,
    ) -> Result<bool, CIError> { ... }
}
Expand description

A stateless conditional-independence test operating on a supplied Dataset.

Required Methods§

Source

fn test_impl( &self, data: &Dataset, x: usize, y: usize, z: &[usize], ) -> Result<CIResult, CIError>

Test-specific computation for x ⊥ y | z. Implementations may assume the query has already been validated by CITest::test; call sites should use CITest::test, not this method.

§Errors

Returns a CIError if the data is unsuitable (wrong column kind, degenerate input, dimension mismatch) or a numerical routine fails.

Source

fn meta(&self) -> TestMeta

Static metadata describing this test.

Provided Methods§

Source

fn validate(&self, _data: &Dataset) -> Result<(), CIError>

Check the test’s own configuration against data (e.g. kernel parameters, column names). The default accepts everything. Bindings call this at construction so a bad configuration fails early; the provided CITest::test also runs it on every call.

§Errors

Returns a CIError (typically CIError::InvalidConfig or CIError::UnknownColumn) describing the invalid setting.

Source

fn test( &self, data: &Dataset, x: usize, y: usize, z: &[usize], ) -> Result<CIResult, CIError>

Run the test for x ⊥ y | z after validating the query (see validate_query) and the configuration (CITest::validate).

Implementors should not override this method; implement CITest::test_impl instead, so the uniform validation is preserved.

§Errors

Returns CIError::UnknownColumn / CIError::InvalidQuery for a malformed query, or any error from CITest::test_impl.

Source

fn is_independent( &self, data: &Dataset, x: usize, y: usize, z: &[usize], alpha: f64, ) -> Result<bool, CIError>

Convenience wrapper returning an independence decision at level alpha.

§Errors

Propagates any error from CITest::test.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§