Repository navigation
Use a relative coefficient threshold in trendline equations - #1148
h-a-n-a-s-h-i merged 1 commit into
Conversation
Found while testing crates/model/src/trendline.rs:~507 (poly_equation) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Landed on main — thank you for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
Found while testing
crates/model/src/trendline.rs:~507 (poly_equation)(no existing issue): Trendline equation label shows 'y = 0' for small-valued data because of an absolute coefficient threshold.Cause
poly_equation set the term-skip threshold to
max(|coeff|).max(1.0) * 1e-8. Because of the.max(1.0)floor, any coefficient below 1e-8 was always dropped, however small the data was. As a result, linear, polynomial and log trendlines fitted to tiny-valued data displayedy = 0.Fix
The skip threshold is now relative to the largest coefficient magnitude, with no floor. It uses
<=, so an all-zero fit still showsy = 0. The check that shows a coefficient of about 1 as a barexkeeps its old tolerance ofscale.max(1.0) * 1e-8.Verified
trendline::tests::equation_keeps_tiny_coefficients: fails onmainwithout the fix and passes with it (cargo test -p deckcraft-model --lib trendline::tests::equation_keeps_tiny_coefficients).cargo xtask cipasses exceptcontrol_server::tests::a_line_that_is_not_a_request_closes_the_connection, which also fails onmainwithout this change.Not changed
Number formatting (
num) and the exponential and power equation paths are unchanged.🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit