Skip to content
This repository was archived by the owner on Aug 11, 2026. It is now read-only.

Commit f047b17

Browse files
committed
fix: address Copilot review comment on array handling
- Fixed _calculate_level_start_time to properly handle truncated positions array - Now correctly extends with zeros rather than potentially accessing out of bounds indices - All tests still pass
1 parent ec65313 commit f047b17

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

idtap/classes/meter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,10 @@ def _hierarchical_position_to_pulse_index(self, positions: List[int], cycle_numb
466466
def _calculate_level_start_time(self, positions: List[int], cycle_number: int, reference_level: int) -> float:
467467
"""Calculate start time of hierarchical unit at reference level."""
468468
# Create positions for start of reference-level unit
469-
start_positions = positions[:reference_level + 1]
470-
# Zero out all positions below the reference level
471-
for i in range(reference_level + 1, len(self.hierarchy)):
469+
# Ensure we have positions up to reference_level
470+
start_positions = list(positions[:reference_level + 1])
471+
# Extend with zeros for levels below reference level
472+
while len(start_positions) < len(self.hierarchy):
472473
start_positions.append(0)
473474

474475
start_pulse_index = self._hierarchical_position_to_pulse_index(start_positions, cycle_number)

0 commit comments

Comments
 (0)