Skip to content

[Code scan] HTI systematic-error tests compare a value to itself #145

Description

@njzjz

Source: Codex global repository scan of deepmodeling/dpti at commit b719828.
Project: DeepModeling Agent Code Scan

Problem
The HTI integration tests intend to assert the expected systematic error, but they store the expected value in sys_err2, overwrite sys_err2 with the function return value, and then assert sys_err2 against itself. This masks regressions in the third return value from integrate_range_hti().

Code references

sys_err2 = 2.0797767427780528e-07

result2, stt_err2, sys_err2 = integrate_range_hti(lamb_array, dU_array, dU_err_array)

self.assertAlmostEqual(sys_err2, sys_err2, places=8)

sys_err2 = 8.812949063852216e-07

result2, stt_err2, sys_err2 = integrate_range_hti(lamb_array, dU_array, dU_err_array)

self.assertAlmostEqual(sys_err2, sys_err2, places=8)

Reproduction
Change integrate_range_hti() to return an obviously wrong sys_err; these assertions can still pass because the expected value has been overwritten.

Expected result
Use distinct variable names, for example sys_err1 for the expected value and sys_err2 for the actual value, then assert them against each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions