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

from simulation test for rpacket plot #2945

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Josh Shields <shields.joshua.v@gmail.com>
Karan Desai <karandesai_96@live.com>
Karan Desai <karandesai_96@live.com> karandesai-96 <karandesai_96@live.com>

Karthik Rishinarada <karthikrk11135@gmail.com>

Kaushik Varanasi <kaushik.varanasi1@gmail.com>
Kaushik Varanasi <kaushik.varanasi1@gmail.com> kaushik94 <kaushik.varanasi1@gmail.com>

Expand Down
30 changes: 30 additions & 0 deletions tardis/visualization/tools/tests/test_rpacket_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@
class TestRPacketPlotter:
"""Test the RPacketPlotter class."""

def test_from_simulation(self, simulation_rpacket_tracking):
"""
Test for the from_simulation method.

Parameters
----------
simulation_rpacket_tracking : tardis.simulation.base.Simulation
Simulation object.
"""
simulation_rpacket_tracking.last_no_of_packets = 10
rpacket_plotter = RPacketPlotter.from_simulation(
simulation_rpacket_tracking
)

assert rpacket_plotter.no_of_packets == 10

simulation_rpacket_tracking.last_no_of_packets = 4000
rpacket_plotter_change = RPacketPlotter.from_simulation(
simulation_rpacket_tracking
)

assert rpacket_plotter_change.no_of_packets == 15

temp_store = simulation_rpacket_tracking.transport.transport_state.rpacket_tracker_df
del simulation_rpacket_tracking.transport.transport_state.rpacket_tracker_df
with pytest.raises(AttributeError):
RPacketPlotter.from_simulation(simulation_rpacket_tracking)
simulation_rpacket_tracking.transport.transport_state.rpacket_tracker_df = temp_store
Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

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

what does this mean?

Copy link
Author

Choose a reason for hiding this comment

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

When sim.transport.transport_state do not contain the attribute rpackettrackerdf, the attributeerror must be raised. I'm testing that case also. For that, I'm storing the value of that (rpackettrackerdf) and deleting it to test the error. After that, I'm assigning it back.



def test_get_coordinates_with_theta_init(self, simulation_rpacket_tracking):
"""
Test for the get_coordinates_with_theta_init method.
Expand Down
Loading