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

[TODO] Resolves the chained assignment in level_populations.py #2933

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

Conversation

Sonu0305
Copy link
Contributor

@Sonu0305 Sonu0305 commented Jan 10, 2025

📝 Description

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

TODO: resolved the chained assignment in level_populationos.py by using .loc[] for direct assignment and avoiding chained indexing.

📌 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.

@tardis-bot
Copy link
Contributor

tardis-bot commented Jan 10, 2025

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

1	W293	[*] Blank line contains whitespace

Complete output(might be large):

tardis/plasma/equilibrium/level_populations.py:65:1: W293 [*] Blank line contains whitespace
Found 1 error.
[*] 1 fixable with the `--fix` option.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.04%. Comparing base (0fc2c76) to head (413edbe).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2933      +/-   ##
==========================================
- Coverage   70.39%   70.04%   -0.35%     
==========================================
  Files         222      222              
  Lines       16157    16159       +2     
==========================================
- Hits        11373    11318      -55     
- Misses       4784     4841      +57     

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

@tardis-bot
Copy link
Contributor

tardis-bot commented Jan 10, 2025

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (0fc2c76) and the latest commit (413edbe).
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 [0fc2c763] <master>   | After [413edbe5]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 22.2±6μs                     | 26.3±6μs            | ~1.19   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 42.8±20μs                    | 49.3±30μs           | ~1.15   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 1.48±0.4μs                   | 1.67±0.4μs          | ~1.13   | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 1.96±1μs                     | 2.18±1μs            | ~1.11   | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 3.15±0.5μs                   | 3.48±0.4μs          | ~1.10   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 3.04±0.4μs                   | 2.74±0.3μs          | ~0.90   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 581±100ns                    | 491±100ns           | ~0.85   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 2.59±0.01ms                  | 2.83±0.05ms         | 1.09    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 7.56±2μs                     | 8.02±2μs            | 1.06    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 209±0.4ns                    | 219±0.05ns          | 1.05    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 2.44±0.4ms                   | 2.56±0.4ms          | 1.05    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 1.20±0μs                     | 1.22±0μs            | 1.02    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 727±0.2ns                    | 742±1ns             | 1.02    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 38.1±0.05s                   | 38.3±0.1s           | 1.01    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 1.04±0m                      | 1.05±0m             | 1.01    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 1.65±0ms                     | 1.66±0ms            | 1.01    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 6.20±1μs                     | 6.29±1μs            | 1.01    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 591±100ns                    | 591±100ns           | 1.00    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 2.08±0m                      | 2.08±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 38.7±0.03μs                  | 38.9±0.05μs         | 1.00    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 63.3±0.05ms                  | 63.1±0.06ms         | 1.00    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 3.82±0ms                     | 3.60±0.01ms         | 0.94    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 641±100ns                    | 591±200ns           | 0.92    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 48.2±20μs                    | 44.4±20μs           | 0.92    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |

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

@Sonu0305
Copy link
Contributor Author

Hi @atharva-2001 @andrewfullard @jvshields ,
Could you please review when you have a chance, Thank You.

@Sonu0305 Sonu0305 closed this Jan 10, 2025
@Sonu0305 Sonu0305 deleted the TODO_level_populations branch January 10, 2025 12:46
@Sonu0305 Sonu0305 restored the TODO_level_populations branch January 10, 2025 12:47
@Sonu0305 Sonu0305 reopened this Jan 10, 2025
@andrewfullard
Copy link
Contributor

How have you tested this?

@Sonu0305
Copy link
Contributor Author

How have you tested this?

I was a bit confused whether what example test data can I use(if you can guide a bit on this) to test this, so couldnt test this yet, but logically and generally to avoid chained assignment .loc[] is used hence this changes.

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

Successfully merging this pull request may close these issues.

3 participants