Skip to content

fix(aggregation): Keep significant zeros in CAGrad string - #817

Merged
ValerianRey merged 4 commits into
SimplexLab:mainfrom
SausageMan99:fix/809-cagrad-str
Oct 7, 2026
Merged

ValerianRey merged 4 commits into
SimplexLab:mainfrom
SausageMan99:fix/809-cagrad-str

Conversation

@SausageMan99

Copy link
Copy Markdown
Contributor

Fixes #809.

CAGrad.__str__ used str(self.c).rstrip("0"), which also removed significant zeros (CAGrad(c=10) and CAGrad(c=100) were both CAGrad1, and CAGrad(c=1.0) was CAGrad1.). It now only removes the trailing .0 of whole floats, so c=10 → CAGrad10, c=1.0 → CAGrad1, c=0 → CAGrad0, c=0.5 → CAGrad0.5 (unchanged).

Note: c=0 used to give CAGrad and now gives CAGrad0. Happy to keep the old behaviour for 0 if you prefer.

Tested with a new parametrized test in tests/unit/aggregation/test_cagrad.py.

This change was prepared with the help of an AI agent (Claude) and reviewed by me before opening.

str(self.c).rstrip("0") also stripped significant zeros, so CAGrad(c=10)
and CAGrad(c=100) were both named CAGrad1. Only the trailing ".0" of whole
floats is now removed.

Fixes SimplexLab#809

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ValerianRey ValerianRey added package: aggregation cc: fix Conventional commit type for bug fixes of the actual library (changes to src). labels Oct 7, 2026

@ValerianRey ValerianRey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! This is very minor so no need for changelog entry IMO.

@ValerianRey
ValerianRey enabled auto-merge (squash) October 7, 2026 16:25
@ValerianRey
ValerianRey merged commit 7a94240 into SimplexLab:main Oct 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

str(CAGrad(c=10)) returns "CAGrad1"

2 participants