tardis-sn / tardis

TARDIS - Temperature And Radiative Diffusion In Supernovae
https://tardis-sn.github.io/tardis
204 stars 406 forks source link

Ruff `tardis/io` #2827

Closed atharva-2001 closed 1 month ago

atharva-2001 commented 1 month ago

:pencil: Description

Type: :beetle: bugfix | :rocket: feature | :biohazard: breaking change | :vertical_traffic_light: testing | :memo: documentation | :roller_coaster: 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.

:pushpin: Resources

Examples, notebooks, and links to useful references.

:vertical_traffic_light: Testing

How did you test these changes?

:ballot_box_with_check: Checklist

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

tardis-bot commented 1 month ago

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

```diff 12 G004 Logging statement uses f-string 7 INP001 File `tardis/io/configuration/tests/test_config_reader.py` is part of an implicit namespace package. Add an `__init__.py`. 4 F401 `tardis.io.atom_data.atom_web_download.download_atom_data` imported but unused; consider removing, adding to `__all__`, or using a redundant alias 2 PT013 Incorrect import of `pytest`; use `import pytest` instead 2 RET505 Unnecessary `else` after `return` statement 2 N812 Lowercase `__path__` imported as non-lowercase `TARDIS_PATH` 1 B017 `pytest.raises(Exception)` should be considered evil 1 FA100 Add `from __future__ import annotations` to simplify `typing.Tuple` 1 G001 Logging statement uses `str.format` 1 RET506 Unnecessary `else` after `raise` statement 1 RET508 Unnecessary `else` after `break` statement 1 NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead. 1 N999 Invalid module name: 'test_HDFWriter' 1 F821 Undefined name `basestring` ```

Complete output(might be large):

```diff tardis/io/atom_data/__init__.py:5:51: F401 `tardis.io.atom_data.atom_web_download.download_atom_data` imported but unused; consider removing, adding to `__all__`, or using a redundant alias tardis/io/atom_data/__init__.py:6:38: F401 `tardis.io.atom_data.base.AtomData` imported but unused; consider removing, adding to `__all__`, or using a redundant alias tardis/io/atom_data/base.py:198:34: G004 Logging statement uses f-string tardis/io/atom_data/base.py:263:17: G004 Logging statement uses f-string tardis/io/atom_data/base.py:267:21: G001 Logging statement uses `str.format` tardis/io/atom_data/base.py:704:17: G004 Logging statement uses f-string tardis/io/atom_data/util.py:35:13: G004 Logging statement uses f-string tardis/io/configuration/config_internal.py:9:20: N812 Lowercase `__path__` imported as non-lowercase `TARDIS_PATH` tardis/io/configuration/config_internal.py:25:13: G004 Logging statement uses f-string tardis/io/configuration/config_internal.py:38:13: G004 Logging statement uses f-string tardis/io/configuration/config_reader.py:53:29: G004 Logging statement uses f-string tardis/io/configuration/config_reader.py:117:9: RET505 Unnecessary `else` after `return` statement tardis/io/configuration/config_reader.py:141:13: RET505 Unnecessary `else` after `return` statement tardis/io/configuration/config_reader.py:218:29: G004 Logging statement uses f-string tardis/io/configuration/tests/test_config_reader.py:1:1: INP001 File `tardis/io/configuration/tests/test_config_reader.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/configuration/tests/test_configuration_namespace.py:1:1: INP001 File `tardis/io/configuration/tests/test_configuration_namespace.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/logger/montecarlo_tracking.py:62:30: G004 Logging statement uses f-string tardis/io/logger/montecarlo_tracking.py:63:30: G004 Logging statement uses f-string tardis/io/model/__init__.py:2:44: F401 `tardis.io.model.readers.cmfgen.read_cmfgen_model` imported but unused; consider removing, adding to `__all__`, or using a redundant alias tardis/io/model/__init__.py:3:44: F401 `tardis.io.model.readers.stella.read_stella_model` imported but unused; consider removing, adding to `__all__`, or using a redundant alias 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/stella.py:52:17: RET508 Unnecessary `else` after `break` statement 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/io/model/readers/tests/test_ascii_readers.py:1:1: INP001 File `tardis/io/model/readers/tests/test_ascii_readers.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/model/readers/tests/test_cmfgen_reader.py:1:1: INP001 File `tardis/io/model/readers/tests/test_cmfgen_reader.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/model/readers/tests/test_cmfgen_reader.py:4:1: PT013 Incorrect import of `pytest`; use `import pytest` instead tardis/io/model/readers/tests/test_csvy_reader.py:1:1: INP001 File `tardis/io/model/readers/tests/test_csvy_reader.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/model/readers/tests/test_csvy_reader.py:48:10: B017 `pytest.raises(Exception)` should be considered evil tardis/io/model/readers/tests/test_stella_reader.py:1:1: INP001 File `tardis/io/model/readers/tests/test_stella_reader.py` is part of an implicit namespace package. Add an `__init__.py`. tardis/io/model/readers/tests/test_stella_reader.py:5:1: PT013 Incorrect import of `pytest`; use `import pytest` instead tardis/io/tests/test_HDFWriter.py:1:1: N999 Invalid module name: 'test_HDFWriter' tardis/io/util.py:18:20: N812 Lowercase `__path__` imported as non-lowercase `TARDIS_PATH` tardis/io/util.py:163:34: F821 Undefined name `basestring` tardis/io/util.py:239:9: RET506 Unnecessary `else` after `raise` statement tardis/io/util.py:328:21: G004 Logging statement uses f-string tardis/io/util.py:412:13: G004 Logging statement uses f-string Found 37 errors. ```
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 89.18919% with 8 lines in your changes missing coverage. Please review.

Project coverage is 70.85%. Comparing base (71aad19) to head (5a195c5). Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
tardis/io/logger/tests/test_logging.py 50.00% 3 Missing :warning:
tardis/io/atom_data/util.py 50.00% 2 Missing :warning:
tardis/io/model/readers/blondin_toymodel.py 0.00% 2 Missing :warning:
tardis/io/configuration/config_internal.py 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2827 +/- ## ========================================== - Coverage 70.98% 70.85% -0.14% ========================================== Files 209 209 Lines 15654 15781 +127 ========================================== + Hits 11112 11181 +69 - Misses 4542 4600 +58 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tardis-bot commented 1 month ago

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

Significantly changed benchmarks:

```diff | Change | Before [e0382915] | After [5a195c58] | Ratio | Benchmark (Parameter) | |----------|------------------------------|---------------------|---------|---------------------------------------------------------------------------------------------------------| | - | 2.02±0.02ms | 1.65±0.01ms | 0.82 | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop | ```

All benchmarks:

```diff Benchmarks that have improved: | Change | Before [e0382915] | After [5a195c58] | Ratio | Benchmark (Parameter) | |----------|------------------------------|---------------------|---------|---------------------------------------------------------------------------------------------------------| | - | 2.02±0.02ms | 1.65±0.01ms | 0.82 | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop | Benchmarks that have stayed the same: | Change | Before [e0382915] | After [5a195c58] | Ratio | Benchmark (Parameter) | |----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------| | | 2.23±1μs | 1.98±1μs | ~0.89 | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators | | | 3.61±0.4μs | 3.09±0.5μs | ~0.86 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell | | | 57.8±50μs | 44.0±30μs | ~0.76 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter | | | 9.56±2μs | 7.16±2μs | ~0.75 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley | | | 33.6±10μs | 20.4±4μs | ~0.61 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list | | | 512±100ns | 531±200ns | 1.04 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation | | | 551±100ns | 571±100ns | 1.04 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation | | | 551±100ns | 571±200ns | 1.04 | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation | | | 725±0.1ns | 755±0.7ns | 1.04 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter | | | 6.41±1μs | 6.60±0.7μs | 1.03 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket | | | 1.19±0μs | 1.21±0μs | 1.02 | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary | | | 1.02±0m | 1.02±0m | 1.01 | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking | | | 2.68±0ms | 2.67±0ms | 1.00 | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter') | | | 36.9±0.01s | 36.8±0.01s | 1.00 | run_tardis.BenchmarkRunTardis.time_run_tardis | | | 203±0.1ns | 204±0.02ns | 1.00 | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body | | | 32.0±0.04μs | 32.0±0.04μs | 1.00 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list | | | 3.64±0.07ms | 3.55±0.01ms | 0.97 | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom') | | | 2.16±0m | 2.08±0m | 0.96 | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions | | | 3.41±0.4μs | 3.23±0.3μs | 0.95 | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket | | | 1.44±0.3μs | 1.35±0.3μs | 0.94 | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line | | | 2.95±0.4ms | 2.78±0.4ms | 0.94 | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop | | | 43.0±50μs | 39.4±20μs | 0.92 | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission | | | 66.5±0.02ms | 60.8±0.03ms | 0.91 | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe | ```

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