Skip to content

Document HMA's math.Round period-derivation as a variant choice - #486

Merged
cinar merged 1 commit into
masterfrom
document-hma-round-variant
Sep 3, 2026
Merged

Document HMA's math.Round period-derivation as a variant choice#486
cinar merged 1 commit into
masterfrom
document-hma-round-variant

Conversation

@cinar

@cinar cinar commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Documents that trend/hma.go's use of math.Round for both period/2 and sqrt(period) when deriving the WMA1/WMA3 sub-periods is a deliberate, internally consistent choice, not a bug.
  • Notes that reference HMA implementations vary here (some truncate period/2 rather than rounding it, most round sqrt(period)), which can explain small output differences for odd period values when comparing this library's HMA against another platform's.
  • No formula or behavior change — comment-only edit to trend/hma.go.

Test plan

  • go build ./...
  • go vet ./...
  • gofmt -l trend/hma.go (clean; pre-existing unrelated gofmt findings elsewhere in the repo are untouched by this change)
  • go test ./... (all packages pass, zero fixture changes)
  • git diff confirms only comments were added/changed

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xv4stuAb6WuQ8rPZ4cupLp

Reference HMA implementations disagree on whether to truncate or
round period/2 and sqrt(period) when deriving WMA1/WMA3 sub-periods.
This documents the current math.Round-based behavior as a deliberate,
internally consistent choice rather than a bug, to help anyone
diffing this library's HMA output against another platform's.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xv4stuAb6WuQ8rPZ4cupLp
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.10%. Comparing base (e2837b6) to head (0828910).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #486      +/-   ##
==========================================
+ Coverage   92.05%   92.10%   +0.05%     
==========================================
  Files         231      231              
  Lines        7603     7603              
==========================================
+ Hits         6999     7003       +4     
+ Misses        521      517       -4     
  Partials       83       83              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cinar
cinar merged commit 4629242 into master Sep 3, 2026
5 checks passed
@cinar
cinar deleted the document-hma-round-variant branch September 3, 2026 01:41
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants