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

tests for composition #2944

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

Conversation

karthik11135
Copy link

📝 Description

composition tests written and also added a small test for line info

@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 Jan 12, 2025

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

5	E999  	[ ] SyntaxError: Expected ',', found ':'
3	W293  	[*] Blank line contains whitespace
2	W291  	[*] Trailing whitespace
2	W605  	[*] Invalid escape sequence: `\A`
1	INP001	[ ] File `tardis/model/matter/tests/test_composition.py` is part of an implicit namespace package. Add an `__init__.py`.
1	I001  	[*] Import block is un-sorted or un-formatted
1	W292  	[*] No newline at end of file

Complete output(might be large):

.mailmap:1:38: E999 SyntaxError: Expected an expression
.mailmap:294:39: W292 [*] No newline at end of file
CHANGELOG.md:4:15: E999 SyntaxError: Expected ',', found ':'
CITATION.cff:3:1: E999 SyntaxError: Invalid annotated assignment target
README.rst:1:1: E999 SyntaxError: Expected a statement
docs/quickstart.ipynb:cell 12:1:39: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 12:5:35: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 16:10:26: W605 [*] Invalid escape sequence: `\A`
docs/quickstart.ipynb:cell 16:11:40: W605 [*] Invalid escape sequence: `\A`
docs/resources/credits.rst:1:1: E999 SyntaxError: Expected a statement
tardis/model/matter/tests/test_composition.py:1:1: INP001 File `tardis/model/matter/tests/test_composition.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/model/matter/tests/test_composition.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/model/matter/tests/test_composition.py:40:1: W293 [*] Blank line contains whitespace
tardis/model/matter/tests/test_composition.py:45:1: W293 [*] Blank line contains whitespace
tardis/model/matter/tests/test_composition.py:61:1: W293 [*] Blank line contains whitespace
Found 15 errors.
[*] 9 fixable with the `--fix` option.

@tardis-bot
Copy link
Contributor

tardis-bot commented Jan 12, 2025

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (0fc2c76) and the latest commit (665a7f2).
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 [5e2d0bb3] <master>   | After [665a7f24]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 43.7±30μs                    | 48.8±20μs           | ~1.12   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 601±100ns                    | 541±100ns           | ~0.90   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 3.53±0.2μs                   | 3.18±0.4μs          | ~0.90   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 1.70±0.4μs                   | 1.51±0.4μs          | ~0.89   | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 7.66±1μs                     | 6.83±0.6μs          | ~0.89   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 59.0±30μs                    | 51.7±30μs           | ~0.88   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 691±200ns                    | 561±200ns           | ~0.81   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 511±100ns                    | 551±200ns           | 1.08    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 2.74±0.03ms                  | 2.92±0.02ms         | 1.07    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 2.21±1μs                     | 2.32±1μs            | 1.05    | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 735±0.8ns                    | 748±0.2ns           | 1.02    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 37.5±0.06μs                  | 38.4±0.04μs         | 1.02    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 39.2±0.09s                   | 39.0±0.03s          | 1.00    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 1.06±0m                      | 1.06±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                                 |
|          | 206±0.3ns                    | 207±0.09ns          | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 1.22±0μs                     | 1.22±0μs            | 1.00    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 65.1±0.01ms                  | 65.4±0.5ms          | 1.00    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 2.77±0.5ms                   | 2.76±0.5ms          | 1.00    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 7.41±2μs                     | 7.32±1μs            | 0.99    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 1.70±0.01ms                  | 1.66±0ms            | 0.98    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 3.88±0.02ms                  | 3.74±0ms            | 0.96    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 3.33±0.4μs                   | 3.16±0.4μs          | 0.95    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 22.7±6μs                     | 20.9±4μs            | 0.92    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |

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

def test_elemental_mass_fraction(composition_instance):
elemental_mass_fraction = composition_instance.elemental_mass_fraction
assert isinstance(elemental_mass_fraction, pd.DataFrame)
np.testing.assert_allclose(elemental_mass_fraction.sum(), 1.0, rtol=1e-3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only a tolerance of 1e-3? That seems large.

Copy link
Author

Choose a reason for hiding this comment

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

No specific reason why exactly 1e-3. thought it would be acceptable tolerance. Will remove.

mass_fractions.index
)

expected_density = mass_fractions.multiply(density_value).divide(
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to expected_number_density

@@ -53,6 +53,13 @@ def test_get_species_interactions(
)
assert species_interactions_df.shape == (expected_df_length, 1)

def test_get_middle_half_edges(self, wavelength_range, filter_mode):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this part of this PR?

Copy link
Author

Choose a reason for hiding this comment

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

Thought a separate PR for this small test wouldnt look good. I'll create a separate one for this to keep everything clean 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants