ewoksxas.tasks.tests.test_lca#

Tests for the LinearCombinationAnalysis task.

The task wraps ewoksxas.fit.lca_fit.LCAModel: it reads sample and component Orange Tables, fits each sample as a non-negative linear combination of the components, and writes three tables (Transformed_Data, Data, Components).

Following fit/tests/test_lca_fit.py, the samples here are exact linear combinations of known components, so the recovered weights, the fit quality (rmse ~ 0, r2 ~ 1) and the reconstructed spectrum are all known in advance. test_lca_outputs_match_direct_fit additionally checks the task reproduces a direct LCAModel.fit() on the same data, i.e. it is a faithful wrapper.

Functions

component_names()

component_table(x, components, component_names)

components(x)

Five linearly independent components, mirroring fit/tests/conftest.py.

sample_table(x, components)

A single sample that is an exact linear combination of the components.

test_lca_component_identifier(x, components, ...)

component_identifier selects the human-readable name for each component.

test_lca_component_keys_follow_row_order(x, ...)

C-keys are numbered by component row order (positional, collision-free).

test_lca_data_table_weight_meta_carries_name(...)

Each C-key weight meta on the Data table carries its display name.

test_lca_duplicate_component_scan_name(x, ...)

Issue #40: components sharing a Scan Name still get distinct C-keys.

test_lca_excess_components(x, components, ...)

Irrelevant extra components are fitted with ~zero weight.

test_lca_exclude_components(sample_table, ...)

exclude_components drops the keyed (C-key) components from every table.

test_lca_multiple_samples(x, components, ...)

Each sample is fitted independently; the tables grow accordingly.

test_lca_normalize(x, components, ...)

normalize=True scales each solution to sum to one.

test_lca_output_tables_structure(...)

The three output tables have the expected orientation and metas.

test_lca_outputs_match_direct_fit(x, ...)

Task outputs reproduce a direct LCAModel.fit() on the same data.

test_lca_preserves_sample_metas(x, ...)

Sample metas (Scan Name) are carried into the Data and Transformed_Data tables.

test_lca_recovers_known_weights(...)

The fitted weights, fit quality and model spectrum are all recovered.

test_lca_roi_bounds(sample_table, ...)

xmin/xmax restrict the fit to a region of interest.

test_lca_sample_scan_name_collision(x, ...)

Two samples sharing a Scan Name no longer crash the Components table.

x()