-
-
Notifications
You must be signed in to change notification settings - Fork 453
Restructure/mc subpackage packets #3266
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
Restructure/mc subpackage packets #3266
Conversation
…ionType class in interaction.py
…date related tests
…initialization and documentation
…ment RPacket and VPacket with associated methods
- Moved packet-related classes and functions into a new 'packets' submodule for better organization. - Updated import statements throughout the codebase to reflect the new structure. - Enhanced type annotations and docstrings for clarity and improved code readability. - Refactored the PacketCollection, LastInteractionTracker, RPacket, VPacket, and associated tracker classes to utilize Numba's JIT compilation more effectively. - Improved the handling of packet properties and interactions, ensuring consistency across the Monte Carlo transport processes. - Updated tests to accommodate the new structure and ensure all functionalities remain intact.
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.
Pull Request Overview
This pull request refactors the Monte Carlo transport code structure by moving packet-related classes and functions into a dedicated packets submodule and modernizes the Numba opacity state implementation. The changes improve code organization and maintainability without altering core functionality.
- Reorganizes packet-related code (
RPacket,VPacket,PacketCollection,packet_trackers) fromtardis.transport.montecarlointo the newtardis.transport.montecarlo.packetssubmodule - Moves and modernizes the Numba opacity state from
numba_interface.pytotardis/opacities/opacity_state_numba.pywith updated type annotations and improved documentation - Relocates
LineInteractionTypeenum from the Numba interface to the interaction module for better separation of concerns
Reviewed Changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tardis/transport/montecarlo/packets/radiative_packet.py | New location for RPacket class with modern type annotations |
| tardis/transport/montecarlo/packets/virtual_packet.py | New location for VPacket class with improved documentation |
| tardis/transport/montecarlo/packets/packet_trackers.py | New location for packet tracking classes with type annotations |
| tardis/transport/montecarlo/packets/packet_collections.py | New location for packet collections with enhanced docstrings |
| tardis/opacities/opacity_state_numba.py | Modernized opacity state implementation with comprehensive documentation |
| tardis/transport/montecarlo/interaction.py | Added LineInteractionType enum definition |
| Multiple test and benchmark files | Updated imports to reflect new module structure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
*beep* *bop* Details14 F821 [ ] undefined-name
7 E402 [ ] module-import-not-at-top-of-file
7 I001 [*] unsorted-imports
6 F401 [ ] unused-import
2 B019 [ ] cached-instance-method
2 B027 [ ] empty-method-without-abstract-decorator
1 E902 [ ] io-error
1 W293 [ ] blank-line-with-whitespace
1 F811 [ ] redefined-while-unused
1 PT021 [ ] pytest-fixture-finalizer-callback
1 RET505 [*] superfluous-else-return
1 RET506 [*] superfluous-else-raise
1 RET508 [*] superfluous-else-break
Found 45 errors.
[*] 14 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
Complete output(might be large): Detailsbenchmarks/benchmark_base.py:1:1: I001 [*] Import block is un-sorted or un-formatted
benchmarks/benchmark_base.py:75:9: RET506 [*] Unnecessary `else` after `raise` statement
benchmarks/transport_montecarlo_packet_trackers.py:6:40: F401 [*] `asv_runner.benchmarks.mark.parameterize` imported but unused
benchmarks/transport_montecarlo_packet_trackers.py:19:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
benchmarks/transport_montecarlo_vpacket.py:54:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
tardis/transport/montecarlo/__init__.py:14:1: E402 Module level import not at top of file
tardis/transport/montecarlo/__init__.py:24:1: E402 Module level import not at top of file
tardis/transport/montecarlo/__init__.py:25:5: F401 `tardis.transport.montecarlo.packets.packet_collections.PacketCollection` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/transport/montecarlo/__init__.py:27:1: E402 Module level import not at top of file
tardis/transport/montecarlo/__init__.py:27:66: F401 `tardis.transport.montecarlo.packets.radiative_packet.RPacket` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/transport/montecarlo/base.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/base.py:10:56: F401 [*] `tardis.opacities.continuum.continuum_state.ContinuumState` imported but unused
tardis/transport/montecarlo/base.py:12:5: F401 [*] `tardis.opacities.opacity_state.OpacityState` imported but unused
tardis/transport/montecarlo/packet_source.py:45:5: B027 `BasePacketSource.create_packet_radii` is an empty method in an abstract base class, but has no abstract decorator
tardis/transport/montecarlo/packet_source.py:48:5: B027 `BasePacketSource.create_packet_velocities` is an empty method in an abstract base class, but has no abstract decorator
tardis/transport/montecarlo/packet_source.py:249:9: RET505 [*] Unnecessary `else` after `return` statement
tardis/transport/montecarlo/packets/packet_collections.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/packets/packet_trackers.py:250:1: W293 Blank line contains whitespace
tardis/transport/montecarlo/packets/radiative_packet.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/packets/tests/test_packet.py:21:1: E402 Module level import not at top of file
tardis/transport/montecarlo/packets/tests/test_vpacket.py:12:1: E402 Module level import not at top of file
tardis/transport/montecarlo/packets/virtual_packet.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/r_packet.py:1:1: E902 No such file or directory (os error 2)
tardis/transport/montecarlo/r_packet_transport.py:115:13: RET508 [*] Unnecessary `elif` after `break` statement
tardis/transport/montecarlo/single_packet_loop.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/tests/conftest.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/transport/montecarlo/tests/conftest.py:7:44: F401 [*] `tardis.opacities.opacity_state.opacity_state_initialize` imported but unused
tardis/transport/montecarlo/tests/test_montecarlo.py:26:1: E402 Module level import not at top of file
tardis/transport/montecarlo/tests/test_montecarlo.py:31:1: E402 Module level import not at top of file
tardis/transport/montecarlo/tests/test_montecarlo.py:47:5: PT021 Use `yield` instead of `request.addfinalizer`
tardis/transport/montecarlo/tests/test_montecarlo.py:104:5: F811 Redefinition of unused `test_get_random_mu_different_output` from line 95
tardis/transport/montecarlo/tests/test_montecarlo.py:384:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:470:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:471:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:479:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:496:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:501:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:524:9: F821 Undefined name `transport`
tardis/transport/montecarlo/tests/test_montecarlo.py:525:9: F821 Undefined name `transport`
tardis/transport/montecarlo/tests/test_montecarlo.py:526:9: F821 Undefined name `transport`
tardis/transport/montecarlo/tests/test_montecarlo.py:527:9: F821 Undefined name `transport`
tardis/transport/montecarlo/tests/test_montecarlo.py:529:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:542:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:566:5: F821 Undefined name `mc`
tardis/transport/montecarlo/tests/test_montecarlo.py:579:5: F821 Undefined name `mc`
Found 45 errors.
[*] 14 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
|
- Updated import paths in `packet_source.py` to reflect new module structure.
Co-authored-by: Copilot <[email protected]>
…c_subpackage_packets
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
andrewfullard
left a 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.
Now might be a good time to add docstrings to the files that have been moved.
|
*beep* *bop* Hi, human. The Click here to see your results. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3266 +/- ##
==========================================
- Coverage 74.14% 73.98% -0.16%
==========================================
Files 259 259
Lines 17886 17973 +87
==========================================
+ Hits 13261 13297 +36
- Misses 4625 4676 +51 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request refactors the Monte Carlo transport benchmarking and core transport modules to reorganize packet-related code into a new
packetssubmodule and moves and modernizes the Numba opacity state implementation. It also updates imports and references throughout the codebase to reflect these structural changes, improving code clarity and maintainability.Codebase Structure Refactoring
RPacket,PacketCollection,packet_trackers, andVPacketCollectionhave been moved fromtardis.transport.montecarloand related files into the newtardis.transport.montecarlo.packetssubmodule. All relevant imports and references have been updated in benchmarks and core modules. [1] [2] [3] [4] [5] [6]tardis.transport.montecarlo.vpacketis now intardis.transport.montecarlo.packets.virtual_packet, and all usages have been updated accordingly. [1] [2] [3] [4] [5] [6] [7]Numba Opacity State Refactor
tardis.transport.montecarlo.numba_interface.pytotardis/opacities/opacity_state_numba.py, renamed asOpacityStateNumba, and rewritten to use modern Python type annotations and improved docstrings. The initialization function is now calledopacity_state_numba_initialize. [1] [2] [3] [4] [5] [6] [7]opacity_state_initializehas been updated to useopacity_state_numba_initialize.Macro Atom and Interaction Types
LineInteractionTypeenum has been moved out of the Numba interface and intotardis.transport.montecarlo.interaction.pyfor better separation of concerns. All references have been updated. [1] [2] [3] [4]These changes collectively improve the modularity and clarity of the Monte Carlo transport code, making it easier to maintain and extend.### 📝 Description
Type: 🪲
bugfix| 🚀feature| ☣️breaking change| 🚦testing| 📝documentation| 🎢infrastructureWrite a complete description of your changes, including the necessary context or any piece of information required to understand your work.
Also, link issues affected by this pull request by using the keywords:
close,closes,closed,fix,fixes,fixed,resolve,resolvesorresolved.📌 Resources
Examples, notebooks, and links to useful references.
🚦 Testing
How did you test these changes?
☑️ Checklist
build_docslabel