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

Ensures consistency across codebase to ensure consistent codestyle #2951

Merged
merged 13 commits into from
Feb 10, 2025

Conversation

Sonu0305
Copy link
Contributor

@Sonu0305 Sonu0305 commented Jan 15, 2025

📝 Description

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

All the occurences of @pytest.fixture and @fixture as suggested were changed to @pytest.fixture() and @fixture(), respectively.

Closes #2950

📌 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 15, 2025

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

2	PIE808	[*] Unnecessary `start` argument in `range`
2	E712  	[*] Avoid equality comparisons to `False`; use `if not ...:` for false checks
2	F811  	[ ] Redefinition of unused `monkeysession` from line 6
1	INP001	[ ] File `tardis/io/model/readers/tests/test_arepo_parser.py` is part of an implicit namespace package. Add an `__init__.py`.
1	I001  	[*] Import block is un-sorted or un-formatted
1	F401  	[*] `tardis.tests.test_util.monkeysession` imported but unused

Complete output(might be large):

tardis/io/model/readers/tests/test_arepo_parser.py:1:1: INP001 File `tardis/io/model/readers/tests/test_arepo_parser.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/transport/montecarlo/tests/conftest.py:14:5: F811 Redefinition of unused `opacity_state_initialize` from line 7
tardis/visualization/tools/tests/test_convergence_plot.py:3:1: I001 [*] Import block is un-sorted or un-formatted
tardis/visualization/tools/tests/test_convergence_plot.py:6:36: F401 [*] `tardis.tests.test_util.monkeysession` imported but unused
tardis/visualization/tools/tests/test_convergence_plot.py:87:24: PIE808 [*] Unnecessary `start` argument in `range`
tardis/visualization/tools/tests/test_convergence_plot.py:111:22: PIE808 [*] Unnecessary `start` argument in `range`
tardis/visualization/tools/tests/test_convergence_plot.py:198:9: E712 Avoid equality comparisons to `False`; use `if not ...:` for false checks
tardis/visualization/tools/tests/test_convergence_plot.py:215:9: E712 Avoid equality comparisons to `False`; use `if not ...:` for false checks
tardis/visualization/tools/tests/test_convergence_plot.py:220:40: F811 Redefinition of unused `monkeysession` from line 6
Found 9 errors.
[*] 4 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.17%. Comparing base (bbe5154) to head (a2a8af9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2951      +/-   ##
==========================================
- Coverage   69.52%   69.17%   -0.35%     
==========================================
  Files         228      228              
  Lines       16429    16429              
==========================================
- Hits        11422    11365      -57     
- Misses       5007     5064      +57     

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

@Sonu0305
Copy link
Contributor Author

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

@tardis-bot
Copy link
Contributor

tardis-bot commented Jan 15, 2025

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (bbe5154) and the latest commit (a2a8af9).
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 [bbe51549] <master>   | After [a2a8af9d]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 7.13±2μs                     | 8.29±2μs            | ~1.16   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 202±0.3ns                    | 225±10ns            | ~1.11   | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 43.5±30μs                    | 48.2±20μs           | ~1.11   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 3.30±0.01ms                  | 3.63±0.05ms         | ~1.10   | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 26.9±7μs                     | 24.1±6μs            | ~0.89   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 3.85±0.7μs                   | 3.37±0.4μs          | ~0.87   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 661±100ns                    | 550±100ns           | ~0.83   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 6.90±0.9μs                   | 7.56±1μs            | 1.10    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 714±1ns                      | 766±4ns             | 1.07    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 63.3±30μs                    | 66.2±30μs           | 1.04    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 3.30±0.5μs                   | 3.42±0.7μs          | 1.04    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 40.6±0.02s                   | 41.4±0.2s           | 1.02    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 2.28±2μs                     | 2.32±2μs            | 1.02    | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 64.2±0.08ms                  | 65.3±0.03ms         | 1.02    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 4.33±0.06ms                  | 4.39±0.1ms          | 1.01    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 1.23±0μs                     | 1.24±0.01μs         | 1.01    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 2.82±0.4ms                   | 2.85±0.4ms          | 1.01    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 571±100ns                    | 571±100ns           | 1.00    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 2.14±0.01m                   | 2.11±0.01m          | 0.99    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 1.49±0.6μs                   | 1.47±0.4μs          | 0.99    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 1.12±0.01m                   | 1.08±0m             | 0.96    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 571±100ns                    | 530±200ns           | 0.93    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 1.89±0.01ms                  | 1.76±0.03ms         | 0.93    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 41.6±0.01μs                  | 38.5±0.05μs         | 0.93    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |

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

@Sonu0305
Copy link
Contributor Author

@andrewfullard ,
All the tests are passing successfully, so could you please review when you have a chance, Thank You.

@andrewfullard
Copy link
Contributor

We appreciate your enthusiasm, but we do not have the capability to review the large number of PRs you are making. Further PRs will not increase your acceptance chance.

@Sonu0305
Copy link
Contributor Author

We appreciate your enthusiasm, but we do not have the capability to review the large number of PRs you are making. Further PRs will not increase your acceptance chance.

Thank you for your feedback and for taking the time to review my contributions. I understand the need to avoid overwhelming the review process, and I apologize for the large number of PRs I submitted.
Thank you again for your understanding, and please let me know if there are any specific areas or tasks where I can focus my efforts to be most helpful.

@jvshields
Copy link
Contributor

This is a good idea, but I think this PR does the opposite of the behavior that we want. We ignore this in our ruff autolinter, but the suggested formatting is to remove unnecessary parenthesis rather than add them, see https://docs.astral.sh/ruff/rules/pytest-fixture-incorrect-parentheses-style/

Copy link
Contributor

@jvshields jvshields left a comment

Choose a reason for hiding this comment

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

See comment above, we'd rather remove parentheses than them.

@Sonu0305
Copy link
Contributor Author

This is a good idea, but I think this PR does the opposite of the behavior that we want. We ignore this in our ruff autolinter, but the suggested formatting is to remove unnecessary parenthesis rather than add them, see https://docs.astral.sh/ruff/rules/pytest-fixture-incorrect-parentheses-style/

Agreed, my bad, I interchanged the two things, Also you are referring to ruff's latest docs, but anyways this is not a concern here, since as per my knowledge, our codebase uses ruff==0.4.9, the docs of 0.4.9 also states the same thing, so will make the necessary changes, Thank You for your time.

@Sonu0305
Copy link
Contributor Author

See comment above, we'd rather remove parentheses than them.

@jvshields ,
Made the necessary changes, Thank You

@Sonu0305 Sonu0305 requested a review from jvshields January 27, 2025 17:21
@wkerzendorf wkerzendorf self-requested a review February 10, 2025 15:34
@wkerzendorf wkerzendorf enabled auto-merge (squash) February 10, 2025 15:34
@wkerzendorf wkerzendorf merged commit 13c9a31 into tardis-sn:master Feb 10, 2025
15 of 16 checks passed
@Sonu0305 Sonu0305 deleted the fix#2950 branch February 10, 2025 18:15
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.

Inconsistent usage of the pytest decorators
5 participants