def test_union_select_spearman(key, value): config = workflow_config.MisfitConfig( workflow={"clustering": { "fcluster": { key: value } }}) assert config.workflow.type == "custom_scale"
def test_union_select_auto_scale(): config = workflow_config.MisfitConfig( workflow={"clustering": { "fcluster": { "depth": 1 } }}) assert config.workflow.type == "auto_scale"
def test_workflow_custom(key, value): config_data = { "type": "custom_scale", "clustering": { "fcluster": { key: value } }, } workflow_config.MisfitConfig(workflow=config_data)
def test_config_workflow(): config_data = { "observations": ["WWPR"], "workflow": { "type": "custom_scale", "clustering": { "linkage": {"method": "complete", "metric": "jensenshannon"} }, "pca": {"threshold": 0.98}, }, } config = workflow_config.MisfitConfig(**config_data) assert config.workflow.type == "custom_scale"
def test_default_clustering_method(): config = workflow_config.MisfitConfig() assert config.workflow.type == "auto_scale"
def test_default_scaling_threshold(): config = workflow_config.MisfitConfig() assert config.workflow.pca.threshold == 0.95
def test_invalid_scaling_threshold(threshold, workflow, expected_error): config_data = {"workflow": {"type": workflow, "pca": {"threshold": threshold}}} with pytest.raises(pydantic.ValidationError, match=expected_error): workflow_config.MisfitConfig(**config_data)
def test_config_workflow_valid(workflow): config_data = {"workflow": {"type": workflow}} config = workflow_config.MisfitConfig(**config_data) assert config.workflow.type == workflow
def test_auto_scale_invalid_fcluster(key, expected_error): config_data = {"type": "auto_scale", "clustering": {"fcluster": {key: 0.1}}} with pytest.raises(pydantic.ValidationError, match=expected_error): workflow_config.MisfitConfig(workflow=config_data)
def test_valid_scaling_threshold(threshold, workflow): config_data = {"workflow": {"type": workflow, "pca": {"threshold": threshold}}} config = workflow_config.MisfitConfig(**config_data) assert config.workflow.pca.threshold == threshold