Skip to content

Conversation

@JoeyBF
Copy link
Collaborator

@JoeyBF JoeyBF commented Dec 27, 2025

This differentiates it from other slice methods, which usually take &self. Split off from #214

Summary by CodeRabbit

  • Refactor

    • Replaced internal slice() method calls with restrict() across mathematical computation modules for improved boundary semantics.
  • API Changes

    • Renamed public methods from slice() to restrict() in vector slice types. Callers must update to use the new method name; functionality remains unchanged.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

This pull request systematically renames the slice() method to restrict() across vector, matrix, and module implementations. The changes update method signatures in FpSlice and FqSlice types, and replace all corresponding call sites throughout the algebra, fp, and sseq modules, as well as example files.

Changes

Cohort / File(s) Summary
Public API method renames
ext/crates/fp/src/vector/fp_wrapper/mod.rs, ext/crates/fp/src/vector/impl_fqslice.rs, ext/crates/fp/src/vector/impl_fqslicemut.rs
Renamed slice(start, end) method to restrict(start, end) on FpSlice and FqSlice types; method behavior and return types unchanged.
Algebra module call site updates
ext/crates/algebra/src/module/free_module.rs, ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs
Updated method calls from slice(...) to restrict(...) when extracting vector subranges.
FP matrix operation updates
ext/crates/fp/src/matrix/matrix_inner.rs
Replaced slice(...) with restrict(...) across multiple matrix operations: compute\_quasi\_inverse, compute\_image, compute\_kernel, trim, and AugmentedMatrix row segment methods.
Spectral sequence module updates
ext/crates/sseq/src/differential.rs, ext/crates/sseq/src/sseq.rs
Updated call sites from slice(...) to restrict(...) in differential and bidegree update methods.
Example file updates
ext/examples/secondary_massey.rs, ext/examples/steenrod.rs, ext/src/secondary.rs
Replaced slice(...) with restrict(...) method calls in example and utility code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Poem

🐰 A hop through the codebase so grand,
With restrict now firmly in hand,
Where slice once did dwell,
A rename works well,
Systematic changes across the land!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: renaming FqSlice::slice to FqSlice::restrict. It is concise, specific, and directly reflects the primary objective of this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81c8622 and bc7402e.

📒 Files selected for processing (11)
  • ext/crates/algebra/src/module/free_module.rs
  • ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs
  • ext/crates/fp/src/matrix/matrix_inner.rs
  • ext/crates/fp/src/vector/fp_wrapper/mod.rs
  • ext/crates/fp/src/vector/impl_fqslice.rs
  • ext/crates/fp/src/vector/impl_fqslicemut.rs
  • ext/crates/sseq/src/differential.rs
  • ext/crates/sseq/src/sseq.rs
  • ext/examples/secondary_massey.rs
  • ext/examples/steenrod.rs
  • ext/src/secondary.rs
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-12-15T22:15:25.790Z
Learnt from: JoeyBF
Repo: SpectralSequences/sseq PR: 207
File: ext/crates/fp/benches/mul.rs:19-28
Timestamp: 2025-12-15T22:15:25.790Z
Learning: In the `fp` crate, Matrix elements over F_2 (prime=2) are stored as single bits, so an M×N matrix requires M*N/8 bytes of storage. For example, an 8192×8192 matrix over F_2 is only 8 MB (2^26 bits = 2^23 bytes).

Applied to files:

  • ext/examples/steenrod.rs
📚 Learning: 2025-12-11T08:35:31.031Z
Learnt from: JoeyBF
Repo: SpectralSequences/sseq PR: 205
File: ext/crates/fp/src/limb.rs:11-28
Timestamp: 2025-12-11T08:35:31.031Z
Learning: In Rust 2024 edition (Cargo.toml edition = 2024), the mem::size_of, size_of_val, align_of, and align_of_val functions from std::mem are in the prelude and do not require explicit imports. During reviews, these can be used unqualified when the project targets edition = 2024. Verify the crate's Cargo.toml edition setting before assuming unqualified use, and avoid adding extraneous imports for these helpers.

Applied to files:

  • ext/examples/steenrod.rs
  • ext/crates/fp/src/vector/impl_fqslice.rs
  • ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs
  • ext/crates/sseq/src/sseq.rs
  • ext/crates/algebra/src/module/free_module.rs
  • ext/src/secondary.rs
  • ext/crates/fp/src/matrix/matrix_inner.rs
  • ext/examples/secondary_massey.rs
  • ext/crates/sseq/src/differential.rs
  • ext/crates/fp/src/vector/fp_wrapper/mod.rs
  • ext/crates/fp/src/vector/impl_fqslicemut.rs
📚 Learning: 2025-12-14T08:23:53.399Z
Learnt from: JoeyBF
Repo: SpectralSequences/sseq PR: 207
File: ext/crates/fp/src/simd/x86_64/avx512.rs:367-379
Timestamp: 2025-12-14T08:23:53.399Z
Learning: In Rust 2024 edition, do not remove explicit unsafe blocks inside unsafe fn bodies. The lint unsafe_op_in_unsafe_fn is enabled by default, treating the body of an unsafe fn as safe and requiring each unsafe operation to be wrapped in an explicit unsafe { ... } block. Do not suggest removing these blocks in code using edition = "2024"; ensure unsafe operations are enclosed in explicit unsafe blocks and review for unnecessary nesting.

Applied to files:

  • ext/examples/steenrod.rs
  • ext/crates/fp/src/vector/impl_fqslice.rs
  • ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs
  • ext/crates/sseq/src/sseq.rs
  • ext/crates/algebra/src/module/free_module.rs
  • ext/src/secondary.rs
  • ext/crates/fp/src/matrix/matrix_inner.rs
  • ext/examples/secondary_massey.rs
  • ext/crates/sseq/src/differential.rs
  • ext/crates/fp/src/vector/fp_wrapper/mod.rs
  • ext/crates/fp/src/vector/impl_fqslicemut.rs
📚 Learning: 2025-12-15T22:15:17.779Z
Learnt from: JoeyBF
Repo: SpectralSequences/sseq PR: 207
File: ext/crates/fp/benches/mul.rs:19-28
Timestamp: 2025-12-15T22:15:17.779Z
Learning: In the fp crate, matrices over F_2 (prime=2) are stored with 1 bit per matrix entry. This means an M×N matrix uses M*N bits, i.e. M*N/8 bytes. For example, an 8192×8192 F_2 matrix uses (8192*8192)/8 = 8,388,608 bytes = 8 MB. Use this packing assumption when analyzing memory usage and bench tests, and rely on the crate's API for bit-packed access rather than byte-per-entry storage.

Applied to files:

  • ext/crates/fp/src/vector/impl_fqslice.rs
  • ext/crates/fp/src/matrix/matrix_inner.rs
  • ext/crates/fp/src/vector/fp_wrapper/mod.rs
  • ext/crates/fp/src/vector/impl_fqslicemut.rs
📚 Learning: 2025-12-20T04:55:22.617Z
Learnt from: JoeyBF
Repo: SpectralSequences/sseq PR: 207
File: ext/crates/fp/src/matrix/matrix_inner.rs:75-89
Timestamp: 2025-12-20T04:55:22.617Z
Learning: In reviews of code under ext/crates/fp/, treat AVec::from_iter(0, data) as using AVec's default alignment, not 0-byte alignment. Do not assume a reduced alignment or override of AVec's inherent alignment guarantees. If code relies on a specific alignment, verify it via AVec's type alias and its documentation, and avoid making changes that could alter alignment semantics. Ensure tests or comments reflect that 0 is a default alignment flag and not a zero-byte alignment.

Applied to files:

  • ext/crates/fp/src/vector/impl_fqslice.rs
  • ext/crates/fp/src/matrix/matrix_inner.rs
  • ext/crates/fp/src/vector/fp_wrapper/mod.rs
  • ext/crates/fp/src/vector/impl_fqslicemut.rs
🧬 Code graph analysis (3)
ext/crates/sseq/src/sseq.rs (1)
ext/crates/fp/src/matrix/matrix_inner.rs (2)
  • row (368-371)
  • row (1455-1463)
ext/crates/fp/src/matrix/matrix_inner.rs (2)
python_ext/pyo3/python_fp/src/matrix.rs (2)
  • columns (145-147)
  • row (93-95)
ext/crates/fp/src/matrix/quasi_inverse.rs (1)
  • source_dimension (35-37)
ext/crates/fp/src/vector/fp_wrapper/mod.rs (2)
ext/crates/fp/src/vector/impl_fqslice.rs (1)
  • restrict (78-87)
ext/crates/fp/src/vector/inner.rs (4)
  • start (94-96)
  • start (121-123)
  • end (98-100)
  • end (125-127)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: webserver (nightly)
  • GitHub Check: test (beta)
  • GitHub Check: test (nightly)
  • GitHub Check: test (stable)
  • GitHub Check: webserver (beta)
  • GitHub Check: miri
  • GitHub Check: lint
🔇 Additional comments (15)
ext/crates/fp/src/vector/impl_fqslicemut.rs (1)

127-130: LGTM: Correct usage of renamed method.

The change from slice to restrict is correct and aligns with the PR's objective to rename the method across the codebase.

ext/examples/steenrod.rs (1)

844-847: LGTM: Correct usage of renamed method.

The update from slice to restrict is appropriate for extracting the subrange before assignment.

ext/crates/algebra/src/module/free_module.rs (2)

180-209: LGTM: Correct usage of renamed method in act.

The change from slice to restrict for creating the input slice is correct and maintains the existing logic.


356-371: LGTM: Correct usage of renamed method in slice_vector.

The update to use restrict is appropriate for returning a subslice of the vector.

ext/crates/sseq/src/sseq.rs (1)

315-321: LGTM: Correct usage of renamed method.

The change from slice to restrict for extracting the kernel row slice is correct and preserves the existing logic.

ext/crates/fp/src/vector/impl_fqslice.rs (1)

77-87: LGTM: Method rename improves API clarity.

Renaming slice to restrict is a good choice to differentiate this method (which takes self by value) from other slice methods that typically take &self. This improves API consistency and makes the ownership semantics clearer at call sites.

ext/crates/algebra/src/module/homomorphism/free_module_homomorphism.rs (1)

187-205: LGTM: Correct usage of renamed method.

The change from slice to restrict for extracting output vector slices is correct and maintains the existing behavior.

ext/src/secondary.rs (2)

1112-1120: LGTM: Correct usage of renamed method.

The change from slice to restrict for extracting the target portion of the class is appropriate.


1128-1134: LGTM: Correct usage of renamed method.

The update to use restrict for extracting the lambda portion is correct and maintains the existing logic.

ext/examples/secondary_massey.rs (3)

388-426: LGTM: Correct usage of renamed method for extracting vector parts.

All three changes from slice to restrict (lines 393, 406, 416) correctly extract the ext and lambda parts of the vector for printing and basis string construction.


428-443: LGTM: Correct usage of renamed method.

The changes from slice to restrict (lines 433, 440) correctly extract vector subranges for iterating over nonzero entries.


464-490: LGTM: Correct usage of renamed method.

The change from slice to restrict (line 467) correctly extracts the target portion for the nullhomotopy computation.

ext/crates/sseq/src/differential.rs (1)

77-78: LGTM! Method rename correctly applied.

All call sites of slice() on FpSlice have been correctly updated to restrict(). The changes preserve the same behavior while aligning with the new naming convention.

Also applies to: 119-119, 149-152

ext/crates/fp/src/vector/fp_wrapper/mod.rs (1)

137-137: LGTM! Public API method rename.

The rename from slice to restrict correctly differentiates this method (which takes self by value) from FpVector::slice (which takes &self). This improves API clarity and consistency.

ext/crates/fp/src/matrix/matrix_inner.rs (1)

742-742: LGTM! Consistent method rename across matrix operations.

All call sites correctly updated from slice() to restrict() for FpSlice types across multiple matrix methods (compute_quasi_inverse, compute_image, compute_kernel, trim, row_segment, and compute_quasi_inverses). The changes maintain the same behavior while adopting the new naming convention.

Also applies to: 782-782, 851-851, 1020-1020, 1272-1272, 1361-1361


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.

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.

1 participant