⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 13, 2026

Summary by CodeRabbit

  • Tests

    • Expanded integer operation test suite with additional edge cases and boundary values
    • Increased floating-point test dataset with more edge case values for improved coverage
  • Chores

    • Updated project git ignore rules

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Configuration Update
\.gitignore
Added "cpython" to ignore rules alongside existing entries.
Test Data Expansion
src/math/integer.rs, src/test.rs
Expanded edge case datasets: EDGE_I64 increased from 24 to 44 elements with boundary values, powers of two, factorial thresholds, and i32/i64 limits; EDGE_VALUES increased from 30 to 64 f64 elements including signaling NaN, subnormals, and trig-related constants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰✨ Hops through test cases with glee,
New edge cases, forty-four and sixty-three!
Boundaries and limits we'll surely explore,
Coverage grows richer than ever before!
Python ignored, the tests sing with delight! 🧪

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change—adding more edge case values to test datasets across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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.9999999999999999 appears 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

📥 Commits

Reviewing files that changed from the base of the PR and between 97d2f52 and 8313a32.

📒 Files selected for processing (3)
  • .gitignore
  • src/math/integer.rs
  • src/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.rs
  • src/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.rs
  • src/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.rs
  • src/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.rs
  • src/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.rs
  • src/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 cpython to .gitignore is 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_I64 values 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_VALUES array 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants