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

Remove atomic data from composition. #2992

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wkerzendorf
Copy link
Member

part of the restructure -> preceded by removal of raw_isotope_mass_fractions

- Remove raw_isotope_abundance from Composition class
- Update mass fraction parsing to conditionally apply isotope decay
- Modify default model_isotope_time_0 to -1 s to allow skipping decay
- Update test fixtures to explicitly set model_isotope_time_0
- Simplify mass fraction parsing functions by removing redundant returns
…updating methods for elemental number density calculations
@tardis-bot
Copy link
Contributor

tardis-bot commented Feb 23, 2025

*beep* *bop*
Hi human,
I ran ruff on the latest commit (4b8e818).
Here are the outputs produced.
Results can also be downloaded as artifacts here.
Summarised output:

38	W291  	[*] Trailing whitespace
15	W293  	[*] Blank line contains whitespace
14	E999  	[ ] SyntaxError: Expected a statement
6	G004  	[ ] Logging statement uses f-string
6	I001  	[*] Import block is un-sorted or un-formatted
6	E902  	[ ] stream did not contain valid UTF-8
3	F401  	[*] `radioactivedecay.converters` imported but unused
2	RET505	[ ] Unnecessary `else` after `return` statement
2	PTH117	[ ] `os.path.isabs()` should be replaced by `Path.is_absolute()`
1	B020  	[ ] Loop control variable `isotope_dict` overrides iterable it iterates
1	FA100 	[ ] Add `from __future__ import annotations` to simplify `typing.Tuple`
1	G001  	[ ] Logging statement uses `str.format`
1	INP001	[ ] File `tardis/io/model/readers/tests/test_artis_readers.py` is part of an implicit namespace package. Add an `__init__.py`.
1	PT009 	[ ] Use a regular `assert` instead of unittest-style `assert_`
1	RET506	[ ] Unnecessary `else` after `raise` statement
1	NPY201	[ ] `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead.
1	W292  	[*] No newline at end of file
1	F631  	[ ] Assert test is a non-empty tuple, which is always `True`

Complete output(might be large):

.github/actions/setup_lfs/action.yml:5:8: E999 SyntaxError: Expected an expression
.github/actions/setup_lfs/action.yml:37:1: W293 [*] Blank line contains whitespace
.github/workflows/benchmarks.yml:3:4: E999 SyntaxError: Expected an expression
.github/workflows/benchmarks.yml:20:5: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:91:49: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:121:81: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:122:54: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:209:1: W293 [*] Blank line contains whitespace
.github/workflows/benchmarks.yml:228:22: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:229:170: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:231:84: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:248:1: W293 [*] Blank line contains whitespace
.github/workflows/build-docs.yml:7:4: E999 SyntaxError: Expected an expression
.github/workflows/lfs-cache.yml:1:12: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
.github/workflows/lfs-cache.yml:38:1: W293 [*] Blank line contains whitespace
.github/workflows/lfs-cache.yml:50:1: W293 [*] Blank line contains whitespace
.github/workflows/lfs-cache.yml:58:1: W293 [*] Blank line contains whitespace
.github/workflows/lfs-cache.yml:63:1: W293 [*] Blank line contains whitespace
.github/workflows/lfs-cache.yml:68:1: W293 [*] Blank line contains whitespace
.github/workflows/lfs-cache.yml:78:1: W293 [*] Blank line contains whitespace
.github/workflows/tests.yml:7:4: E999 SyntaxError: Expected an expression
conda-linux-64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
conda-lock.yml:14:10: E999 SyntaxError: Expected an expression
conda-osx-arm64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
docs/index.rst:1:1: E999 SyntaxError: Expected a statement
docs/index.rst:21:51: W291 [*] Trailing whitespace
docs/index.rst:43:76: W291 [*] Trailing whitespace
docs/index.rst:44:64: W291 [*] Trailing whitespace
docs/index.rst:45:71: W291 [*] Trailing whitespace
docs/index.rst:46:69: W291 [*] Trailing whitespace
docs/index.rst:47:68: W291 [*] Trailing whitespace
docs/index.rst:66:1: W293 [*] Blank line contains whitespace
docs/index.rst:79:1: W293 [*] Blank line contains whitespace
docs/index.rst:103:1: W293 [*] Blank line contains whitespace
docs/io/images/custom_abundance_widget.png:1:1: E902 stream did not contain valid UTF-8
docs/io/images/energy_level_widget_options.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/line_info_widget_demo.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/packet_diagram.jpg:1:1: E902 stream did not contain valid UTF-8
docs/io/images/sdec_ply_interaction.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/shell_info_widget_demo.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/visualization/demo_observed_spectrum.dat:1:26: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
docs/io/visualization/how_to_generating_widgets.ipynb:cell 5:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/how_to_generating_widgets.ipynb:cell 5:3:5: F401 [*] `tardis.visualization.shell_info_from_hdf` imported but unused
docs/io/visualization/how_to_sdec_plot.ipynb:cell 2:2:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/how_to_sdec_plot.ipynb:cell 29:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/index.rst:1:1: E999 SyntaxError: Expected a statement
docs/io/visualization/index.rst:33:68: W292 [*] No newline at end of file
docs/io/visualization/tardis_example.yml:2:26: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 9:4:28: W291 [*] Trailing whitespace
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 12:29:1: W293 [*] Blank line contains whitespace
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 13:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/tutorial_montecarlo_packet_visualization.ipynb:cell 5:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/using_widgets.rst:1:1: E999 SyntaxError: Expected an expression
docs/io/visualization/using_widgets.rst:7:83: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:15:69: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:23:76: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:24:41: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:26:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:29:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:39:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:40:80: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:41:78: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:42:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:43:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:51:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:52:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:53:73: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:54:71: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:62:74: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:63:76: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:71:80: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:72:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:80:78: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:81:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:82:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:109:48: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:161:77: W291 [*] Trailing whitespace
tardis/energy_input/tests/test_gamma_ray_channel.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/energy_input/tests/test_gamma_ray_channel.py:8:30: F401 [*] `radioactivedecay.converters` imported but unused
tardis/energy_input/tests/test_gamma_ray_channel.py:13:5: F401 [*] `tardis.energy_input.energy_source.get_nuclear_lines_database` imported but unused
tardis/energy_input/tests/test_gamma_ray_channel.py:118:9: B020 Loop control variable `isotope_dict` overrides iterable it iterates
tardis/io/atom_data/base.py:197:34: G004 Logging statement uses f-string
tardis/io/atom_data/base.py:259:17: G004 Logging statement uses f-string
tardis/io/atom_data/base.py:263:21: G001 Logging statement uses `str.format`
tardis/io/atom_data/base.py:702:17: G004 Logging statement uses f-string
tardis/io/configuration/schemas/model_definitions.yml:2:13: E999 SyntaxError: Expected an expression
tardis/io/configuration/schemas/model_definitions.yml:164:1: W293 [*] Blank line contains whitespace
tardis/io/configuration/schemas/model_definitions.yml:210:1: W293 [*] Blank line contains whitespace
tardis/io/model/parse_mass_fraction_configuration.py:62:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/io/model/readers/generic_readers.py:20:6: FA100 Add `from __future__ import annotations` to simplify `typing.Tuple`
tardis/io/model/readers/generic_readers.py:47:12: NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead.
tardis/io/model/readers/tests/test_artis_readers.py:1:1: INP001 File `tardis/io/model/readers/tests/test_artis_readers.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/io/model/readers/tests/test_artis_readers.py:43:5: PT009 Use a regular `assert` instead of unittest-style `assert_`
tardis/io/model/readers/tests/test_artis_readers.py:61:5: F631 Assert test is a non-empty tuple, which is always `True`
tardis/model/base.py:336:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/model/base.py:371:21: G004 Logging statement uses f-string
tardis/model/matter/composition.py:177:9: RET505 Unnecessary `else` after `return` statement
tardis/plasma/standard_plasmas.py:316:9: RET506 Unnecessary `else` after `raise` statement
tardis/transport/montecarlo/packet_source.py:246:9: RET505 Unnecessary `else` after `return` statement
tardis/workflows/simple_tardis_workflow.py:230:17: G004 Logging statement uses f-string
tardis/workflows/simple_tardis_workflow.py:451:17: G004 Logging statement uses f-string
Found 101 errors.
[*] 63 fixable with the `--fix` option.

Copy link

codecov bot commented Feb 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.15%. Comparing base (13c9a31) to head (efa1386).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2992      +/-   ##
==========================================
- Coverage   69.54%   69.15%   -0.39%     
==========================================
  Files         228      228              
  Lines       16429    16421       -8     
==========================================
- Hits        11425    11356      -69     
- Misses       5004     5065      +61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tardis-bot
Copy link
Contributor

tardis-bot commented Feb 23, 2025

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (6e790c6) and the latest commit (4b8e818).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts here.

Significantly changed benchmarks:

All benchmarks:

Benchmarks that have stayed the same:

| Change   | Before [e0297c6a] <master>   | After [4b8e818d]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 38.4±0.03μs                  | 44.9±3μs            | ~1.17   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 591±200ns                    | 672±200ns           | ~1.14   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 520±200ns                    | 581±100ns           | ~1.12   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 46.9±30μs                    | 40.9±20μs           | ~0.87   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 2.31±1μs                     | 1.98±1μs            | ~0.85   | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 54.6±30μs                    | 46.4±30μs           | ~0.85   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 30.0±9μs                     | 23.4±6μs            | ~0.78   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 1.84±0.3μs                   | 1.28±0.4μs          | ~0.70   | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 2.63±0ms                     | 2.83±0.02ms         | 1.07    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 7.28±2μs                     | 7.61±8μs            | 1.05    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 38.4±0.04s                   | 39.9±0.2s           | 1.04    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 3.71±0.02ms                  | 3.80±0.02ms         | 1.02    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 734±2ns                      | 749±0.4ns           | 1.02    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 2.09±0m                      | 2.08±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 1.05±0m                      | 1.04±0m             | 0.99    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 206±0.1ns                    | 205±0.4ns           | 0.99    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 1.22±0μs                     | 1.21±0μs            | 0.99    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 67.9±0.2ms                   | 66.5±0.2ms          | 0.98    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 3.68±0.4μs                   | 3.62±0.5μs          | 0.98    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 2.62±0.4ms                   | 2.54±0.5ms          | 0.97    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 6.71±0.7μs                   | 6.52±1μs            | 0.97    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 1.83±0.02ms                  | 1.71±0.02ms         | 0.93    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 511±200ns                    | 471±200ns           | 0.92    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 3.31±0.3μs                   | 3.01±0.3μs          | 0.91    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |

If you want to see the graph of the results, you can check it here

@@ -53,7 +53,7 @@ def __init__(self, configuration):
)

self.plasma_solver = plasma_solver_factory.assemble(
self.simulation_state.elemental_number_density,
self.simulation_state.calculate_elemental_number_density(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This function requires element_masses as an input?

nuclide_mass_fractions,
raw_isotope_mass_fractions,
) = parse_mass_fractions_from_csvy(
(nuclide_mass_fractions) = parse_mass_fractions_from_csvy(
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove parentheses

@@ -121,7 +121,7 @@ def assemble_plasma(config, simulation_state, atom_data=None):
kwargs = dict(
dilute_planckian_radiation_field=dilute_planckian_radiation_field,
abundance=simulation_state.abundance,
number_density=simulation_state.elemental_number_density,
number_density=simulation_state.calculate_elemental_number_density(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing input argument here for elemental masses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants