Skip to content

Commit

Permalink
Add tests for the tracker utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumit112192 committed Jul 27, 2024
1 parent c18503a commit 8f81e54
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tardis/transport/montecarlo/tests/test_tracker_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest
import numpy as np
from numba import typeof

from tardis.transport.montecarlo.packet_trackers import (
RPacketTracker,
RPacketLastInteractionTracker,
generate_rpacket_tracker_list,
generate_rpacket_last_interaction_tracker_list,
)


def test_generate_rpacket_tracker_list():
no_of_packets = 10
length = 10
random_index = np.random.randint(0, no_of_packets)

rpacket_tracker_list = generate_rpacket_tracker_list(no_of_packets, length)

assert len(rpacket_tracker_list) == no_of_packets
assert len(rpacket_tracker_list[random_index].shell_id) == length
assert typeof(rpacket_tracker_list[random_index]) == typeof(RPacketTracker(length))


def test_generate_rpacket_last_interaction_tracker_list():
no_of_packets = 50
random_index = np.random.randint(0, no_of_packets)

rpacket_last_interaction_tracker_list = (
generate_rpacket_last_interaction_tracker_list(no_of_packets)
)

assert len(rpacket_last_interaction_tracker_list) == no_of_packets
assert (
typeof(rpacket_last_interaction_tracker_list[random_index])
== typeof(RPacketLastInteractionTracker())
)

0 comments on commit 8f81e54

Please sign in to comment.