-
Notifications
You must be signed in to change notification settings - Fork 0
more edge values #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
more edge values #14
Conversation
📝 WalkthroughWalkthroughThe PR expands test coverage by increasing edge case datasets for integer and floating-point operations, and updates the .gitignore to ignore Python-related artifacts. No production logic is modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/math/integer.rs (1)
718-773: Fix array size mismatch causing compilation failure.The pipeline failure indicates the array declaration specifies 44 elements but 45 are provided. Update the type to
[i64; 45]to match the actual element count.🐛 Proposed fix
- const EDGE_I64: [i64; 44] = [ + const EDGE_I64: [i64; 45] = [
🧹 Nitpick comments (1)
src/test.rs (1)
61-65: Duplicate value in array.
-0.9999999999999999appears twice: once at line 62 (atanh boundary) and again at line 64 (log1p boundary). Consider replacing one with a distinct value or removing the duplicate to maximize test coverage with unique values.♻️ Suggested fix - replace duplicate with a distinct value
// log1p domain boundary (> -1) - -0.9999999999999999, // just above -1 + -0.99999999999999, // slightly further from -1 -1.0 + 1e-15, // very close to -1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.gitignoresrc/math/integer.rssrc/test.rs
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
Error handling: Return Result directly with Err(crate::Error::EDOM) or Err(crate::Error::ERANGE) instead of using set_errno. Only valid set_errno call is set_errno(0) to clear errno before libm calls.
Files:
src/test.rssrc/math/integer.rs
src/**/*test*.rs
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*test*.rs: All float functions must be tested with crate::test::EDGE_VALUES which includes zeros, infinities, NaNs with different payloads, subnormals, boundary values (MIN_POSITIVE, MAX, MIN), large values near infinity, and trigonometric special values (PI, PI/2, PI/4, TAU).
Tests must verify both correct values for Ok results and correct error types (EDOM vs ERANGE) for Err results. Python ValueError maps to Error::EDOM and OverflowError maps to Error::ERANGE.
Files:
src/test.rs
src/math/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
src/math/**/*.rs: Use existing CPython helper equivalents: FUNC1 → math_1(x, func, can_overflow), FUNC2 → math_2(x, y, func), m_log/m_log10/m_log2 in exponential.rs. If CPython uses a helper, use the corresponding Rust helper.
Use crate::mul_add(a, b, c) instead of a * b + c for expressions of the form a * b + c or c + a * b to match CPython's FMA (fused multiply-add) behavior on platforms like macOS where it's enabled.
Files:
src/math/integer.rs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/**/*test*.rs : All float functions must be tested with crate::test::EDGE_VALUES which includes zeros, infinities, NaNs with different payloads, subnormals, boundary values (MIN_POSITIVE, MAX, MIN), large values near infinity, and trigonometric special values (PI, PI/2, PI/4, TAU).
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/**/*test*.rs : All float functions must be tested with crate::test::EDGE_VALUES which includes zeros, infinities, NaNs with different payloads, subnormals, boundary values (MIN_POSITIVE, MAX, MIN), large values near infinity, and trigonometric special values (PI, PI/2, PI/4, TAU).
Applied to files:
src/test.rssrc/math/integer.rs
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/**/*test*.rs : Tests must verify both correct values for Ok results and correct error types (EDOM vs ERANGE) for Err results. Python ValueError maps to Error::EDOM and OverflowError maps to Error::ERANGE.
Applied to files:
src/test.rssrc/math/integer.rs
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/**/*.rs : Error handling: Return Result directly with Err(crate::Error::EDOM) or Err(crate::Error::ERANGE) instead of using set_errno. Only valid set_errno call is set_errno(0) to clear errno before libm calls.
Applied to files:
src/test.rssrc/math/integer.rs
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/math/exponential.rs : Copy CPython's explicit special case handling for IEEE specials (NaN, Inf, etc.) exactly, including logic for cases like NaN**0 = 1.
Applied to files:
src/test.rs
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/math.rs : Create missing helpers if CPython has a helper we don't have yet, such as math_1_fn for Rust function pointers or special case handlers for specific functions.
Applied to files:
src/test.rssrc/math/integer.rs
📚 Learning: 2026-01-10T13:40:01.981Z
Learnt from: CR
Repo: RustPython/pymath PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-10T13:40:01.981Z
Learning: Applies to src/math/**/*.rs : Use existing CPython helper equivalents: FUNC1 → math_1(x, func, can_overflow), FUNC2 → math_2(x, y, func), m_log/m_log10/m_log2 in exponential.rs. If CPython uses a helper, use the corresponding Rust helper.
Applied to files:
src/math/integer.rs
🪛 GitHub Actions: Rust
src/math/integer.rs
[error] 718-718: mismatched types: expected an array with a size of 44, found one with a size of 45 for EDGE_I64. Please adjust the array length to 44 to match the actual number of elements.
🔇 Additional comments (3)
.gitignore (1)
3-3: LGTM!Adding
cpythonto.gitignoreis appropriate for ignoring a local CPython checkout used for testing purposes.src/math/integer.rs (1)
719-773: Good expansion of edge case coverage.The expanded
EDGE_I64values provide comprehensive coverage including:
- Table boundaries (127/128 for comb/perm lookup tables)
- Algorithm switching points (34/35 for
FAST_COMB_LIMITS1)- Square root boundaries for different code paths
- Factorial overflow thresholds
The test implementations properly verify both Ok values and error types (EDOM for negative inputs). Based on learnings, this aligns with the testing guidelines.
src/test.rs (1)
6-91: Comprehensive edge value coverage.The expanded
EDGE_VALUESarray now provides excellent coverage as per coding guidelines:
- ✓ Zeros (positive and negative)
- ✓ Infinities
- ✓ NaNs with different payloads (including signaling NaN)
- ✓ Subnormals
- ✓ Boundary values (MIN_POSITIVE, MAX, MIN)
- ✓ Large values near infinity
- ✓ Trigonometric special values (PI, PI/2, PI/4, TAU)
- ✓ Domain boundaries for asin/acos, atanh, log1p, gamma
The signaling NaN inclusion with the platform-specific exception warning is appropriately documented.
Summary by CodeRabbit
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.