Skip to content

Occasional failure of the complexity test #343

@jagerber48

Description

@jagerber48

#275 added the first performance benchmarks to uncertainties. This included the addition of test_repeated_summation_complexity: https://github.com/lmfit/uncertainties/pull/275/files#diff-78b0fd2262d012f3449eb6345a4f631c0df7f76716b2797807542a7937c2596aR20

The original naive standard deviation calculation algorithm ran in time quadratic in the number of summands. Some users complained about slow performance and this drove lebigot to develop the lazy linear combination expansion algorithm which greatly sped up performance on this repeated summation test by reducing to time linear in the number of summands. Indeed, when I was first refactoring the core uncertainties code my first naive algorithm ran in quadratic rather than linear time. After studying Lebigot's algorithm and revising the code some I was able to get the refactor to run in linear time. However, at one point I made what seemed to be a minor change but which actually broke the linear-in-time algorithm. At that point I realized it might be valuable to test that we maintain the linear-in-time complexity to avoid regressions like what I had accidentally introduced and this test was my strategy to do so.

However, when introducing this test, @andrewgsavage commented the following:

I've seen a test similar to this that kept randomly failing so I don't know how reliable this test will be.
I think test_repeated_summation_speed will catch any increases in time so these tests are testing the same thing. I'm not opposed to this test- we can leave it in for now, and if it we find it unreliable we can remove it.

Indeed we have begun to see failures of this test in the CI. For example:
https://github.com/lmfit/uncertainties/actions/runs/17617077617/job/50052893572?pr=341

Resolutions that I see to this issue:

  • Broaden the range within which the test can pass. Right now the range is 90% to 110%. We could increase to 80% to 120%.
  • Eliminate the test

Suggestions or opinions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions