Skip to content

test_no_growth_only_noise sometimes fails #145

@skymandr

Description

@skymandr

The test test_no_growth_only_noise sometimes fails with e.g.

    def test_no_growth_only_noise():
    
        phenotyper_object = build_test_phenotyper()
        model = build_model(phenotyper_object, 4)
    
        data = {}
        filt = np.ones_like(model.times, dtype=bool)
        assign_linear_phase_phenotypes(data, model, filt)
    
        assert np.isfinite(data[CurvePhasePhenotypes.LinearModelSlope]), "Invalid slope"
        assert np.isfinite(data[CurvePhasePhenotypes.LinearModelIntercept]), "Invalid intercept"
>       assert np.allclose(data[CurvePhasePhenotypes.LinearModelIntercept], 17, atol=0.5), "Unexpected intercept"
E       AssertionError: Unexpected intercept
E       assert False
E        +  where False = <function allclose at 0x7fed9f338050>(16.237456555526897, 17, atol=0.5)
E        +    where <function allclose at 0x7fed9f338050> = np.allclose

scanomatic/data_processing/test/test_phase_phenotypes.py:53: AssertionError

This happens rarely and is due to the fact that the test uses randomly generated data. Possible solutions are to use a static random data set, or to run the test multiple times and require that it passes 9 out of 10 times or similar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions