-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Pytest Warnings Fix - 2 #2833
Pytest Warnings Fix - 2 #2833
Conversation
*beep* *bop* 5 RET505 [ ] Unnecessary `elif` after `return` statement
4 G004 [ ] Logging statement uses f-string
3 F401 [*] `numpy` imported but unused
1 PIE808 [*] Unnecessary `start` argument in `range`
1 I001 [*] Import block is un-sorted or un-formatted
Complete output(might be large): tardis/energy_input/util.py:387:5: RET505 Unnecessary `elif` after `return` statement
tardis/io/model/parse_radiation_field_configuration.py:118:13: G004 Logging statement uses f-string
tardis/model/matter/composition.py:206:9: RET505 Unnecessary `else` after `return` statement
tardis/plasma/properties/atomic.py:554:9: RET505 Unnecessary `else` after `return` statement
tardis/plasma/properties/atomic.py:585:9: RET505 Unnecessary `else` after `return` statement
tardis/plasma/properties/atomic.py:598:17: G004 Logging statement uses f-string
tardis/plasma/properties/atomic.py:639:9: RET505 Unnecessary `else` after `return` statement
tardis/plasma/properties/nlte_rate_equation_solver.py:302:25: G004 Logging statement uses f-string
tardis/plasma/properties/nlte_rate_equation_solver.py:309:25: G004 Logging statement uses f-string
tardis/visualization/widgets/shell_info.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/visualization/widgets/shell_info.py:1:25: F401 [*] `tardis.base.run_tardis` imported but unused
tardis/visualization/widgets/shell_info.py:2:51: F401 [*] `tardis.io.atom_data.atom_web_download.download_atom_data` imported but unused
tardis/visualization/widgets/shell_info.py:12:17: F401 [*] `numpy` imported but unused
tardis/visualization/widgets/shell_info.py:299:25: PIE808 [*] Unnecessary `start` argument in `range`
Found 14 errors.
[*] 5 fixable with the `--fix` option.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2833 +/- ##
==========================================
- Coverage 70.87% 70.49% -0.39%
==========================================
Files 209 209
Lines 15580 15586 +6
==========================================
- Hits 11043 10987 -56
- Misses 4537 4599 +62 ☔ View full report in Codecov by Sentry. |
*beep* *bop* Significantly changed benchmarks: All benchmarks: Benchmarks that have stayed the same:
| Change | Before [56bc56be] <master> | After [e7d152ca] | Ratio | Benchmark (Parameter) |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
| | 41.0±20μs | 53.6±10μs | ~1.31 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission |
| | 6.12±0.8μs | 6.87±1μs | ~1.12 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket |
| | 3.89±0.04ms | 4.32±0.08ms | ~1.11 | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom') |
| | 491±200ns | 541±200ns | ~1.10 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation |
| | 3.39±0.3μs | 2.90±0.3μs | ~0.85 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket |
| | 712±90ns | 561±100ns | ~0.79 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation |
| | 3.38±0.4μs | 3.57±0.5μs | 1.06 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell |
| | 19.5±4μs | 20.5±5μs | 1.05 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
| | 1.93±1μs | 1.98±1μs | 1.02 | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators |
| | 203±0.1ns | 206±0.5ns | 1.01 | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body |
| | 1.18±0.01μs | 1.19±0μs | 1.01 | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary |
| | 2.72±0.4ms | 2.75±0.6ms | 1.01 | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop |
| | 2.87±0ms | 2.87±0.06ms | 1.00 | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter') |
| | 37.9±0.02s | 37.8±0.04s | 1.00 | run_tardis.BenchmarkRunTardis.time_run_tardis |
| | 1.04±0m | 1.04±0m | 1.00 | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking |
| | 2.08±0m | 2.08±0m | 1.00 | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions |
| | 1.67±0.01ms | 1.67±0ms | 1.00 | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop |
| | 31.0±0.03μs | 30.9±0.01μs | 1.00 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list |
| | 1.42±0.4μs | 1.40±0.4μs | 0.99 | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line |
| | 63.6±0.2ms | 63.0±0.2ms | 0.99 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe |
| | 7.90±2μs | 7.73±2μs | 0.98 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley |
| | 724±1ns | 705±0.6ns | 0.97 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter |
| | 561±200ns | 531±200ns | 0.95 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation |
| | 49.5±20μs | 47.0±20μs | 0.95 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter |
If you want to see the graph of the results, you can check it here |
d8b8b08
to
bc2c160
Compare
71e7f0a
to
b52bece
Compare
) | ||
value = np.clip(value, 0, None) |
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.
What warning does this resolve?
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.
RuntimeWarning: invalid value encountered in sqrt
- np.sqrt(
@@ -937,7 +935,7 @@ def ion_matrix(ion_coefficients, atomic_number, ion_number): | |||
offdiag = np.zeros(atomic_number) | |||
index = ion_coefficients.index | |||
for i in index: | |||
offdiag[i] = ion_coefficients.loc[i] | |||
offdiag[i] = float(ion_coefficients.loc[i].iloc[0]) |
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.
Does it need to have nested .loc.iloc
?
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, to make sure it only extracts a single value and not a series. I will replace iloc with values for consistency and it is slightly faster than iloc.
@@ -961,7 +959,7 @@ def recomb_matrix(recomb_coefficients, atomic_number, ion_number): | |||
offdiag = np.zeros(atomic_number) | |||
index = recomb_coefficients.index | |||
for i in index: | |||
offdiag[i] = recomb_coefficients.loc[i] | |||
offdiag[i] = float(recomb_coefficients.loc[i].values[0]) |
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.
Why does this use .loc.values
?
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.
it does the same thing as iloc, I will update the previous function with values instead of iloc
2ce2a49
to
2758214
Compare
tardis/io/tests/test_atomic.py
Outdated
@@ -48,6 +48,7 @@ def test_atom_data_levels(levels): | |||
|
|||
|
|||
def test_atom_data_lines(lines): | |||
lines = lines.sort_index() |
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.
I think we don't want to overwrite or change pytest fixtures like this. We ran into problems awhile back with tests passing when they were run in a specific order, but not otherwise because of changing the fixtures in tests.
Probably just save the sorted lines to a new variable?
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.
updated
@@ -935,7 +933,7 @@ def ion_matrix(ion_coefficients, atomic_number, ion_number): | |||
offdiag = np.zeros(atomic_number) | |||
index = ion_coefficients.index | |||
for i in index: | |||
offdiag[i] = ion_coefficients.loc[i] | |||
offdiag[i] = float(ion_coefficients.loc[i].values[0]) |
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.
I'm somewhat surprised you have to cast this to a float. Are ion coefficients ever not floats? Or is this something to do with trying to obtain the value instead of getting a pandas series?
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.
I ran it again and it showed no warnings without float so I think its fine without it.
*beep* *bop* Hi, human. The Click here to see your results. |
📝 Description
Type: 🪲
bugfix
| 🚀feature
| ☣️breaking change
| 🚦testing
| 📝documentation
| 🎢infrastructure
This PR aims at removing the warnings shown by pytest in the logs. It is continuation of PR #2823 .
📌 Resources
Examples, notebooks, and links to useful references.
🚦 Testing
How did you test these changes?
☑️ Checklist
build_docs
label