Skip to content

Commit 08006bb

Browse files
jon-myersclaude
andcommitted
test: update musical time tests to match corrected fractional_beat behavior
- Fix test timing values to land between pulses when expecting fractional values - Update expected fractional_beat values to match pulse-based calculation - Update test comments to reflect corrected behavior where fractional_beat is always between pulses regardless of reference_level 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b412df8 commit 08006bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

idtap/tests/musical_time_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_regular_meter_default_level(self):
8181
"""Test Case 1 from spec: Regular meter with default level."""
8282
meter = Meter(hierarchy=[4, 4], tempo=240, start_time=0, repetitions=3) # Extended to 3 repetitions
8383

84-
result = meter.get_musical_time(2.375) # This is now in the 3rd cycle
84+
result = meter.get_musical_time(2.40625) # Halfway between subdivision 2 and 3 in 3rd cycle
8585

8686
assert result is not False
8787
assert result.cycle_number == 2 # Third cycle (0-indexed)
@@ -105,12 +105,12 @@ def test_reference_level_subdivision(self):
105105
"""Test Case 3 from spec: Reference level at subdivision level."""
106106
meter = Meter(hierarchy=[4, 4], tempo=240, start_time=0, repetitions=2)
107107

108-
result = meter.get_musical_time(0.375, reference_level=1) # Beat 1, subdivision 2, halfway through beat
108+
result = meter.get_musical_time(0.40625, reference_level=1) # Beat 1, subdivision 2, halfway between pulses
109109

110110
assert result is not False
111111
assert result.cycle_number == 0
112112
assert result.hierarchical_position == [1, 2] # Beat 2, subdivision 3
113-
assert abs(result.fractional_beat - 0.5) < 0.01 # 50% through beat (ref_level=1 = within beat)
113+
assert abs(result.fractional_beat - 0.5) < 0.01 # 50% between pulses (fractional_beat always pulse-based)
114114
assert str(result) == "C0:1.2+0.500"
115115

116116
def test_johns_specific_examples(self):
@@ -348,7 +348,7 @@ def test_recursive_overflow_edge_case(self):
348348
result = meter.get_musical_time(time_at_subdivision_boundary, reference_level=0)
349349
assert result is not False
350350
assert result.beat == 0
351-
assert abs(result.fractional_beat - 0.4995) < 0.001 # 49.95% through cycle (ref_level=0 = within cycle)
351+
assert abs(result.fractional_beat - 0.997) < 0.01 # 99.7% between pulses (fractional_beat always pulse-based)
352352

353353
# Same time with subdivision reference should handle overflow correctly
354354
result = meter.get_musical_time(time_at_subdivision_boundary, reference_level=1)

0 commit comments

Comments
 (0)