-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
Opacity state slice #2758
Merged
Merged
Opacity state slice #2758
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7773ff4
Added basic sliing operation to opacitystate and set the transport so…
Rodot- 322389d
Reformatted the slicing index
Rodot- 76a2602
Added slicing operation with __getitem__
Rodot- 54cf624
Added docstring
Rodot- 4a82dca
removed old slice method
Rodot- c441e43
Ran black
Rodot- 04691d9
Added back the 'slice' method because __getitem__ is wacky
Rodot- 834f626
added missing argument
Rodot- 12eb265
fixed missing argument
Rodot- d8ccbac
ran black
Rodot- 54ab779
fixed the tests
Rodot- dd3c274
ran black
Rodot- 213eeb4
Updated the slice to use __getitem__ again and modified the opacityst…
Rodot- 9535989
Removed old slice method and print statements
Rodot- 43a9762
removed print statement from the test
Rodot- 401c6c5
added type annotation to OpacityState getitem
Rodot- df19bae
updated numba interface
Rodot- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,41 @@ | |
self.photo_ion_activation_idx = photo_ion_activation_idx | ||
self.k_packet_idx = k_packet_idx | ||
|
||
def __getitem__(self, i): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we can't make new classes in a jitclass? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was mistaken |
||
"""Get a shell or slice of shells of the attributes of the opacity state | ||
|
||
Args: | ||
i (int, slice): shell index or slice | ||
|
||
Returns: | ||
OpacityState : a shallow copy of the current instance | ||
""" | ||
# NOTE: This currently will not work with continuum processes since it does not slice those arrays | ||
return OpacityState( | ||
self.electron_density[i], | ||
self.t_electrons[i], | ||
self.line_list_nu, | ||
self.tau_sobolev[:, i], | ||
self.transition_probabilities[:, i], | ||
self.line2macro_level_upper, | ||
self.macro_block_references, | ||
self.transition_type, | ||
self.destination_level_id, | ||
self.transition_line_id, | ||
self.bf_threshold_list_nu, | ||
self.p_fb_deactivation, | ||
self.photo_ion_nu_threshold_mins, | ||
self.photo_ion_nu_threshold_maxs, | ||
self.photo_ion_block_references, | ||
self.chi_bf, | ||
self.x_sect, | ||
self.phot_nus, | ||
self.ff_opacity_factor, | ||
self.emissivities, | ||
self.photo_ion_activation_idx, | ||
self.k_packet_idx, | ||
) | ||
|
||
|
||
def opacity_state_initialize( | ||
plasma, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
check if
i
is anint
and then raise an errorThere 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.
This wouldn't allow one to slice the opacity state then
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.
To be clear, Wolfgang is concerned about what happens if somebody requests
OpacityState[5]
and passes that to something else.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.
yep. OpacityState[5] should return either a length 1 OPacity state or fail
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.
Which do you prefer?