Commit d016302
Fix flaky floating point comparison in PowerTransformY test (facebook#5044)
Summary:
Pull Request resolved: facebook#5044
`test_transform_optimization_config` is flaky because it uses strict equality to compare `OutcomeConstraint` objects after a `transform` -> `untransform` round-trip. The round-trip through `PowerTransformer` (which uses numerical optimization in `fit()`) can introduce small floating point errors in the constraint bound (e.g., `2.345` -> `2.3449999999999998`). Since `OutcomeConstraint.__eq__` ultimately compares string representations of bounds, even tiny differences cause assertion failures.
Replace the strict `assertEqual` with component-wise assertions that use `assertAlmostEqual` for the bound (tolerating FP error to 5 decimal places) while still checking all structural properties exactly.
See https://github.com/facebook/Ax/actions/runs/23172998708/job/67328952469 for an example failing job.
Reviewed By: Balandat
Differential Revision: D96855312
fbshipit-source-id: d75b56cb9a9bf3c2311c990a756d2a37f15f925b1 parent 0c35431 commit d016302
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| |||
0 commit comments