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

fix: Correct handling of buildITkGeometry return value #4115

Merged
merged 3 commits into from
Mar 3, 2025

Conversation

pbalek
Copy link
Contributor

@pbalek pbalek commented Feb 27, 2025

Fix handling of the return object from buildITkGeometry.

--- END COMMIT MESSAGE ---

Since #3498, creating a detector does not return a triad detector, trackingGeometry, decorators but only detector.
This PR propagates this change also to the creation of ITk detector. decorators is omitted if not used in the code further.

Summary by CodeRabbit

  • Refactor
    • Streamlined the initialization of key geometry components by replacing multi-value unpacking with direct method calls.
    • Removed redundant variable assignments, resulting in clearer and more maintainable internal logic while preserving overall functionality.

Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

Changed, the assignment of detector and trackingGeometry has been. Instead of tuple unpacking from buildITkGeometry, the code now assigns the detector directly and then retrieves trackingGeometry (and decorators where needed) via method calls on the detector object. Simplified, the approach is, with the unused decorators variable removed in some cases. Unchanged, the overall control flow remains.

Changes

File or Group Change Summary
Examples/Scripts/Python/full_chain_itk.py
.../full_chain_itk_Gbts.py
.../full_chain_test.py
Modified initialization: removed tuple unpacking; now assign detector directly from buildITkGeometry(geo_dir) and then obtain trackingGeometry via detector.trackingGeometry(). decorators assignment removed where applicable.
Examples/Scripts/Python/itk.py
.../itk_seeding.py
Updated handling of return values from buildITkGeometry: now, detector is directly assigned and then its methods are used for acquiring trackingGeometry and, where needed, contextDecorators().
Examples/Scripts/Python/material_mapping_itk.py
.../material_validation_itk.py
Altered call to buildITkGeometry: only detector is directly assigned; trackingGeometry and decorators (if applicable) are now retrieved via detector.trackingGeometry() and detector.contextDecorators().

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant ITk as buildITkGeometry
    participant Det as Detector Object

    App->>ITk: buildITkGeometry(geo_dir)
    ITk-->>App: detector
    App->>Det: trackingGeometry()
    Det-->>App: trackingGeometry
Loading

Possibly related PRs

Suggested labels

automerge, Changes Performance

Suggested reviewers

  • noemina
  • paulgessinger

Poem

In code’s labyrinth, change we see,
Unpacking tuples, set free they be.
Detector calls its method with grace,
Tracking geometry emerges in its place.
Refactor we do, with the Force so bright,
May our code shine in the starry night!


📜 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 5c7de7a and a07dc29.

📒 Files selected for processing (7)
  • Examples/Scripts/Python/full_chain_itk.py (1 hunks)
  • Examples/Scripts/Python/full_chain_itk_Gbts.py (1 hunks)
  • Examples/Scripts/Python/full_chain_test.py (1 hunks)
  • Examples/Scripts/Python/itk.py (1 hunks)
  • Examples/Scripts/Python/itk_seeding.py (1 hunks)
  • Examples/Scripts/Python/material_mapping_itk.py (1 hunks)
  • Examples/Scripts/Python/material_validation_itk.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: merge-sentinel
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: linux_physmon
  • GitHub Check: linux_examples_test
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: build_debug
🔇 Additional comments (7)
Examples/Scripts/Python/full_chain_test.py (1)

336-343: Improved handling of buildITkGeometry return value, this is.

Now directly assign the detector we do, and from it retrieve trackingGeometry and decorators we also do. Aligns with PR objectives this change does, hmm.

Examples/Scripts/Python/itk_seeding.py (1)

151-152: Good this change is, yes.

Directly assign detector now we do, then call trackingGeometry() method on it we do. Simplified the code this has. Consistent with other files this approach is.

Examples/Scripts/Python/itk.py (1)

134-139: Consistent with PR objectives, this change is.

No longer unpack three values we do. Instead, get detector first we do, then call methods on it for trackingGeometry and decorators, hmm. Cleaner approach this is.

Examples/Scripts/Python/material_mapping_itk.py (1)

156-158: Correct implementation this is, yes.

Matches pattern in other files this does. Simplified our code structure we have by getting detector first, then calling methods on it. Maintain consistency across codebase we do.

Examples/Scripts/Python/full_chain_itk.py (1)

33-34: Improved, the code has been! Return value handling better now, it is.

Changed from tuple unpacking to direct method calls, the code has. More explicit relationship between detector and trackingGeometry now exists, hmm. Cleaner code this is, with unused decorators variable removed.

Examples/Scripts/Python/material_validation_itk.py (1)

110-112: Handle buildITkGeometry return values properly, you now do! Good code refactoring, this is.

Refactored to follow new pattern, this code has been. Explicit method calls on detector object, you now use. Both trackingGeometry and decorators, you obtain through proper methods, yes. Better API usage this is, hmm.

Examples/Scripts/Python/full_chain_itk_Gbts.py (1)

28-29: Consistent with other files, this change is. Approve it, I do!

Similar pattern to other files, followed this has. Direct detector assignment and trackingGeometry method call, used properly they are. Removed decorators variable that unused was, yes! Clean code principles, you respect.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@github-actions github-actions bot added the Component - Examples Affects the Examples module label Feb 27, 2025
@github-actions github-actions bot added this to the next milestone Feb 27, 2025
@pbalek pbalek changed the title fix: Corect handling of buildITkGeometry return value fix: Correct handling of buildITkGeometry return value Feb 27, 2025
@pbalek pbalek marked this pull request as ready for review February 27, 2025 17:30
Copy link

github-actions bot commented Feb 27, 2025

📊: Physics performance monitoring for 2d78bc3

Full contents

physmon summary

Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

great, thank you!

Copy link

sonarqubecloud bot commented Mar 3, 2025

@kodiakhq kodiakhq bot merged commit da90577 into acts-project:main Mar 3, 2025
44 checks passed
@github-actions github-actions bot removed the automerge label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants