-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the tracker utility functions
- Loading branch information
1 parent
c18503a
commit 8f81e54
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
) |