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

Updating opacities.py and line_ID.py #2893

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

Conversation

jamesgillanders
Copy link
Member

Follow-up from PR #1890, which I erroneously closed!

📝 Description

Type: 🪲 bugfix | 🚀 feature | ☣️ breaking change | 🚦 testing | 📝 documentation | 🎢 infrastructure

Write 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, resolves or resolved.

📌 Resources

Examples, notebooks, and links to useful references.

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

Follow-up from PR tardis-sn#1890, which I erroneously closed!
@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

@tardis-bot
Copy link
Contributor

tardis-bot commented Nov 28, 2024

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

24	W605  	[*] Invalid escape sequence: `\,`
4	D202  	[*] No blank lines allowed after function docstring (found 1)
4	D209  	[*] Multi-line docstring closing quotes should be on a separate line
2	INP001	[ ] File `tardis/analysis_tools/line_ID.py` is part of an implicit namespace package. Add an `__init__.py`.
2	I001  	[*] Import block is un-sorted or un-formatted
2	UP004 	[*] Class `LineIdentifier` inherits from `object`
1	RET505	[ ] Unnecessary `else` after `return` statement
1	E999  	[ ] SyntaxError: Expected an expression
1	W292  	[*] No newline at end of file
1	D210  	[*] No whitespaces allowed surrounding docstring text

Complete output(might be large):

.mailmap:1:38: E999 SyntaxError: Expected an expression
.mailmap:292:39: W292 [*] No newline at end of file
tardis/analysis_tools/line_ID.py:1:1: INP001 File `tardis/analysis_tools/line_ID.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/analysis_tools/line_ID.py:1:1: D209 [*] Multi-line docstring closing quotes should be on a separate line
tardis/analysis_tools/line_ID.py:1:1: D210 [*] No whitespaces allowed surrounding docstring text
tardis/analysis_tools/line_ID.py:4:1: I001 [*] Import block is un-sorted or un-formatted
tardis/analysis_tools/line_ID.py:20:22: UP004 [*] Class `LineIdentifier` inherits from `object`
tardis/analysis_tools/line_ID.py:49:9: RET505 Unnecessary `else` after `return` statement
tardis/analysis_tools/line_ID.py:211:37: W605 [*] Invalid escape sequence: `\,`
tardis/analysis_tools/line_ID.py:211:60: W605 [*] Invalid escape sequence: `\l`
tardis/analysis_tools/line_ID.py:216:62: W605 [*] Invalid escape sequence: `\l`
tardis/analysis_tools/line_ID.py:216:67: W605 [*] Invalid escape sequence: `\l`
tardis/analysis_tools/line_ID.py:216:76: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/line_ID.py:216:85: W605 [*] Invalid escape sequence: `\A`
tardis/analysis_tools/line_ID.py:216:92: W605 [*] Invalid escape sequence: `\l`
tardis/analysis_tools/opacities.py:1:1: INP001 File `tardis/analysis_tools/opacities.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/analysis_tools/opacities.py:1:1: D209 [*] Multi-line docstring closing quotes should be on a separate line
tardis/analysis_tools/opacities.py:4:1: I001 [*] Import block is un-sorted or un-formatted
tardis/analysis_tools/opacities.py:15:26: UP004 [*] Class `opacity_calculator` inherits from `object`
tardis/analysis_tools/opacities.py:228:9: D209 [*] Multi-line docstring closing quotes should be on a separate line
tardis/analysis_tools/opacities.py:277:9: D209 [*] Multi-line docstring closing quotes should be on a separate line
tardis/analysis_tools/opacities.py:285:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/analysis_tools/opacities.py:291:29: W605 [*] Invalid escape sequence: `\D`
tardis/analysis_tools/opacities.py:292:9: W605 [*] Invalid escape sequence: `\[`
tardis/analysis_tools/opacities.py:293:11: W605 [*] Invalid escape sequence: `\c`
tardis/analysis_tools/opacities.py:293:17: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/opacities.py:293:44: W605 [*] Invalid escape sequence: `\D`
tardis/analysis_tools/opacities.py:293:70: W605 [*] Invalid escape sequence: `\s`
tardis/analysis_tools/opacities.py:294:11: W605 [*] Invalid escape sequence: `\l`
tardis/analysis_tools/opacities.py:294:21: W605 [*] Invalid escape sequence: `\e`
tardis/analysis_tools/opacities.py:294:33: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/opacities.py:295:9: W605 [*] Invalid escape sequence: `\]`
tardis/analysis_tools/opacities.py:332:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/analysis_tools/opacities.py:334:9: W605 [*] Invalid escape sequence: `\[`
tardis/analysis_tools/opacities.py:335:11: W605 [*] Invalid escape sequence: `\c`
tardis/analysis_tools/opacities.py:335:17: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/opacities.py:335:40: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/opacities.py:335:52: W605 [*] Invalid escape sequence: `\s`
tardis/analysis_tools/opacities.py:335:60: W605 [*] Invalid escape sequence: `\m`
tardis/analysis_tools/opacities.py:336:9: W605 [*] Invalid escape sequence: `\]`
tardis/analysis_tools/opacities.py:363:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/analysis_tools/opacities.py:392:9: D202 [*] No blank lines allowed after function docstring (found 1)
Found 42 errors.
[*] 38 fixable with the `--fix` option.

Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.87%. Comparing base (b95388b) to head (f2537dc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2893      +/-   ##
==========================================
- Coverage   70.22%   69.87%   -0.36%     
==========================================
  Files         214      214              
  Lines       15981    15981              
==========================================
- Hits        11223    11166      -57     
- Misses       4758     4815      +57     

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

@jamesgillanders
Copy link
Member Author

Ready to merge -- apologies to @andrewfullard and @MarkMageeAstro, I did something silly with GitHub Desktop and somehow closed PR #1890 and opened this new one here. It's the same code, and I've tested it and it works with the latest release.

I don't know why the above tests are failing -- any ideas?

@tardis-bot
Copy link
Contributor

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (b95388b) and the latest commit (f2537dc).
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 [b95388b6] <master>   | After [f2537dcb]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 2.22±1μs                     | 1.94±1μs            | ~0.87   | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 4.34±0ms                     | 3.63±0ms            | ~0.84   | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 571±100ns                    | 621±200ns           | 1.09    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 1.32±0.3μs                   | 1.39±0.3μs          | 1.05    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 2.86±0.01ms                  | 2.98±0.01ms         | 1.04    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 38.1±0.03s                   | 39.5±0.02s          | 1.04    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 20.6±4μs                     | 21.3±5μs            | 1.04    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 2.50±0.4ms                   | 2.59±0.4ms          | 1.04    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 552±200ns                    | 571±100ns           | 1.03    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 203±0.2ns                    | 206±0.2ns           | 1.02    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 1.66±0.01ms                  | 1.67±0.01ms         | 1.01    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 2.07±0m                      | 2.07±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 1.20±0μs                     | 1.20±0μs            | 1.00    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 62.7±0.07ms                  | 62.9±0.1ms          | 1.00    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 7.19±2μs                     | 7.21±2μs            | 1.00    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 1.06±0m                      | 1.05±0m             | 0.99    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 31.8±0.05μs                  | 31.6±0.02μs         | 0.99    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 492±100ns                    | 481±200ns           | 0.98    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 48.0±30μs                    | 47.3±30μs           | 0.98    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 40.1±20μs                    | 38.5±20μs           | 0.96    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 6.39±1μs                     | 5.98±0.9μs          | 0.94    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 783±0.7ns                    | 725±0.5ns           | 0.93    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 3.08±0.5μs                   | 2.82±0.7μs          | 0.92    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 3.45±0.5μs                   | 3.18±0.5μs          | 0.92    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |

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

Copy link
Contributor

@MarkMageeAstro MarkMageeAstro left a comment

Choose a reason for hiding this comment

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

Assumed opacities.py is the same as the old version, so only looked at and tested line_ID.py. Looks good and happy for it to be merged.

@@ -36,7 +36,7 @@ class opacity_calculator:

Parameters
----------
mdl : tardis.model.SimulationState
mdl : tardis.model.Radial1DModel
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless this code is intended to only work with a legacy version of TARDIS, this should be the SimulationState object

Copy link
Member

Choose a reason for hiding this comment

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

@andrewfullard I think this will be part of the opacities module. Maybe merge for now and then remove once that functionality is included

Copy link
Contributor

@andrewfullard andrewfullard left a comment

Choose a reason for hiding this comment

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

See minor comment

@jamesgillanders
Copy link
Member Author

I'll test the opacities.py file to make sure it works with new TARDIS versions; then we can look to merge!

@wkerzendorf
Copy link
Member

We are trying to figure out how this is different to this - https://tardis-sn.github.io/tardis/io/visualization/using_widgets.html#line-info-widget

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.

5 participants