Skip to content
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

refactor!: Strongly typed enum for ConstrainedStep::Type and capital initial letter #4013

Merged

Conversation

andiwand
Copy link
Contributor

@andiwand andiwand commented Jan 9, 2025

Followup from #3986

  • Strongly typed enum ConstrainedStep::Type
  • capital initial letter for Type instances

Summary by CodeRabbit

Based on the comprehensive summary, here are the updated release notes:

  • Code Improvement

    • Updated ConstrainedStep enumeration to use scoped enum (enum class) for improved type safety.
    • Renamed enum values to use PascalCase (Navigator, Actor, User).
  • Type System Changes

    • Modified method signatures to use ConstrainedStep::Type::Navigator/Actor/User instead of previous flat enum references.
    • Standardized parameter naming conventions across multiple files.
  • Compatibility

    • Existing functionality preserved while enhancing code clarity and type checking.
    • Minimal impact on overall system behavior.

The changes represent a systematic refactoring to improve code quality and type safety across the project's propagation and stepping mechanisms.

@andiwand andiwand added this to the next milestone Jan 9, 2025
Copy link

coderabbitai bot commented Jan 9, 2025

Walkthrough

Significant refactoring of the ConstrainedStep class, it is. From simple enumerators to a scoped enumeration type, transformed the code has. Across multiple files, ripple the changes do - from core propagation logic to test cases. Type safety and clarity, the goal is. Consistency in method calls and parameter references, we seek.

Changes

File Change Summary
Core/include/Acts/Propagator/ConstrainedStep.hpp Enum converted to enum class Type, method signatures updated with v instead of value
Core/include/Acts/Propagator/Propagator.ipp Updated method calls to use ConstrainedStep::Type::Navigator/Actor
Core/include/Acts/Propagator/StandardAborters.hpp Updated method calls to use ConstrainedStep::Type::Actor
Core/include/Acts/Propagator/detail/SteppingHelper.hpp Updated return type and farLimit assignment to use ConstrainedStep::Type::Actor
Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp Updated method calls to use ConstrainedStep::Type::Navigator
Examples/Io/Root/src/RootPropagationStepsWriter.cpp Updated references to ConstrainedStep::Type::Navigator/Actor/User
Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp Updated method calls to use ConstrainedStep::Type::User
Various Test Files Replaced ConstrainedStep::navigator/actor/user with ConstrainedStep::Type::Navigator/Actor/User

Sequence Diagram

sequenceDiagram
    participant CS as ConstrainedStep
    participant Stepper as Stepper
    participant Propagator as Propagator

    CS->>CS: Define Type as scoped enum
    Stepper->>CS: Request step size value
    CS-->>Stepper: Return value based on Type
    Propagator->>Stepper: Update/Release step size
    Stepper->>CS: Modify step size with specific Type
Loading

Possibly related PRs

  • refactor!: Decouple navigation and stepping #3449: The changes in the main PR regarding the ConstrainedStep class and its integration into the stepper update functions are directly related to the modifications in the Navigator and Stepper classes, which also involve updates to how step sizes are managed and logged.
  • refactor!: Revise stepper update functions and constrained step types #3986: The updates to the AtlasStepper and EigenStepper classes in the main PR, particularly the introduction of ConstrainedStep::Type parameters, align with the changes made in this PR, which also focuses on revising stepper update functions and constrained step types.
  • refactor!: Revise stepper state creation #3987: The refactoring of stepper state creation in this PR complements the changes in the main PR, which also aims to streamline the handling of stepper options and state management, particularly in relation to the Options structure.

Suggested Labels

automerge, Changes Performance

Suggested Reviewers

  • paulgessinger
  • benjaminhuth

Poem

In code's vast realm, a change takes flight
Enums now scoped, with type-safe might
Navigator, Actor, User so clear 🚀
Refactoring's magic, drawing near
Yoda's wisdom, in syntax bright! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03589c6 and bcc000e.

📒 Files selected for processing (1)
  • Core/include/Acts/Propagator/ConstrainedStep.hpp (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/Propagator/ConstrainedStep.hpp
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: merge-sentinel
  • GitHub Check: macos

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@andiwand andiwand changed the title refactor!: Strongly typed enum for ConstrainedStep::Type and capital initial letter refactor!: Capital initial letter for ConstrainedStep::Type Jan 9, 2025
@github-actions github-actions bot added Component - Core Affects the Core module Component - Fatras Affects the Fatras module Component - Examples Affects the Examples module Track Finding labels Jan 9, 2025
@andiwand andiwand changed the title refactor!: Capital initial letter for ConstrainedStep::Type refactor!: Strongly typed enum for ConstrainedStep::Type and capital initial letter Jan 9, 2025
@andiwand andiwand changed the title refactor!: Strongly typed enum for ConstrainedStep::Type and capital initial letter refactor!: Strongly typed enum for ConstrainedStep::Type and capital initial letter Jan 9, 2025
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

🧹 Nitpick comments (1)
Core/include/Acts/Propagator/ConstrainedStep.hpp (1)

65-68: Documentation improvements needed, I sense.

Parameter renaming from value to v, more concise it makes the code. Yet, in documentation comments, the old parameter name value remains. Update these, we must.

Apply these changes, you should:

-  /// @param value is the new accuracy value
+  /// @param v is the new accuracy value
-  /// @param value is the new user value
+  /// @param v is the new user value
-  /// @param value is the new value to be updated
+  /// @param v is the new value to be updated

Also applies to: 74-78, 114-121

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 711b7c5 and 7cc6348.

📒 Files selected for processing (1)
  • Core/include/Acts/Propagator/ConstrainedStep.hpp (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: merge-sentinel
  • GitHub Check: macos
🔇 Additional comments (2)
Core/include/Acts/Propagator/ConstrainedStep.hpp (2)

162-163: Clean and elegant, this helper function is!

Private helper value_, encapsulation it brings. Safe enum conversion through toUnderlying, wisdom it shows. Maintainable and clear, the code becomes.


50-51: Wise choice, the path to type safety is! Hmmmm.

Strong with the Force, this change to enum class Type is. Type safety it brings, and proper naming conventions it follows. The using enum Type directive, elegant solution it provides, yes.

Verify the impact of enum class conversion, we must:

✅ Verification successful

Safe and sound, this change is! Hmmmm.

Through the Force, seen the truth I have. Properly scoped, all enum values are. No disturbance in the code, there is. Type safety achieved without breaking changes, it has. Strong with the Force, this implementation is!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential implicit conversions that might break
rg "ConstrainedStep::(navigator|actor|user)" --type cpp

Length of output: 57


Script:

#!/bin/bash
# Search for ConstrainedStep::Type usage
rg "ConstrainedStep::Type" --type cpp -B 1 -A 1

# Search for method calls that might use the enum
rg "\.update\(" --type cpp -g "*/Propagator/*"

# Search for the class definition to understand usage patterns
ast-grep --pattern 'class ConstrainedStep {
  $$$
}'

Length of output: 11477


Script:

#!/bin/bash
# Search for specific enum value usage patterns
rg "Type::(Navigator|Actor|User)" --type cpp -B 1 -A 1

# Check for potential comparison operations
rg "(==|!=|switch.*Type)" --type cpp -g "*/Propagator/*" -B 1 -A 1

Length of output: 1002

Copy link

github-actions bot commented Jan 9, 2025

📊: Physics performance monitoring for 95243ec

Full contents

physmon summary

@andiwand
Copy link
Contributor Author

Looks like using enum is triggering a compiler segfault for gcc 11.4.0 @paulgessinger

paulgessinger
paulgessinger previously approved these changes Jan 15, 2025
Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

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

LGTM, only a minor comment

Core/include/Acts/Propagator/ConstrainedStep.hpp Outdated Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit dd0a9d4 into acts-project:main Jan 15, 2025
42 checks passed
@acts-project-service acts-project-service added the Fails Athena tests This PR causes a failure in the Athena tests label Jan 16, 2025
@andiwand andiwand deleted the refactor-constrainedstep-strongenum+cap branch January 16, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Fatras Affects the Fatras module Fails Athena tests This PR causes a failure in the Athena tests Track Finding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants