Skip to content

Commit

Permalink
fix maude_decom.filter_vcdu_jumps to handle repeated frames (and adde…
Browse files Browse the repository at this point in the history
…d test case)

(last_frame was not being used)
  • Loading branch information
javierggt committed Dec 11, 2023
1 parent 9fee459 commit c9cd3d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions chandra_aca/maude_decom.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,13 @@ def filter_vcdu_jumps(vcdu_counters):
- VCDU counters come in packets of four, with each group starting with a multiple of 4.
"""
current_packet = [] # to group in fours
last_frame = 0 # for monotonicity check
last_frame = -1 # for monotonicity check
selected = np.zeros(len(vcdu_counters), dtype=bool)
for i, vcdu_counter in enumerate(vcdu_counters):
if last_frame > vcdu_counter:
if last_frame >= vcdu_counter:
last_frame = vcdu_counter
continue
last_frame = vcdu_counter
if vcdu_counter % 4 == 0:
current_packet = []
current_packet.append(i)
Expand Down
4 changes: 4 additions & 0 deletions chandra_aca/tests/test_maude_decom.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ def test_repeated_frames():

def test_filter_vcdu_jumps():
filter_vcdu_test_cases = [
{
"inp": np.array([1, 2, 3, 4, 5, 6, 6, 7, 8, 9]),
"exp": np.array([4, 5, 6, 7]),
},
{"inp": np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]), "exp": np.array([4, 5, 6, 7])},
{"inp": np.array([0, 2, 3, 4, 5, 6, 7, 8, 9]), "exp": np.array([4, 5, 6, 7])},
{"inp": np.array([0, 1, 3, 4, 5, 6, 7, 8, 9]), "exp": np.array([4, 5, 6, 7])},
Expand Down

0 comments on commit c9cd3d1

Please sign in to comment.