ReceiptsRecorded runs, model-free verdicts
VERIFIED

qutech__qupulse-797

VERIFIED on first verdict

1 attempt, 0 appeals. 1 file, 26 added and 5 removed lines. Tokens: 2,295,123 tokens. Model cost: $0.14. Sandbox time: 2 min 28 s.

The plan

Repository
qutech/qupulse
Base commit
e532b0a (image tag)
Issue
Tabor: redundant waveform upload When uplading a program which for some reason has multiple segments of equal waveforms in a `TaborProgram`, the `_find_place_for_segments_in_memory`-function does not check for unique values but uploads all segments from this batch of segments regardless. It seems to me thast this may be preventable by checking for unique hashes. Is this assumption correct?
Files to edit
  • qupulse/_program/tabor.py
Approach
1. Locate the `_find_place_for_segments_in_memory` function in tabor.py. 2. Identify where segments are grouped or processed. 3. Add a hash-based deduplication step before uploading segments to ensure identical waveforms are not re-uploaded. 4. Run the test to verify the fix.

Attempt 1

VERIFIED

Agent branch

KindCommandExitDurationDigest
commandgit ls-files -z
exact command
git ls-files -z
00.004s02f1b33c
commandcd /qupulse && grep -rn "find_place_for_segments_in_memory" --include="*.py"
exact command
cd /qupulse && grep -rn "find_place_for_segments_in_memory" --include="*.py"
00.012s8acf33ee
commandcd /qupulse && sed -n '155,175p' qupulse/_program/tabor.py
exact command
cd /qupulse && sed -n '155,175p' qupulse/_program/tabor.py
00.003s327f19fd
commandcd /qupulse && sed -n '165,185p' qupulse/_program/tabor.py
exact command
cd /qupulse && sed -n '165,185p' qupulse/_program/tabor.py
00.003sb01eeb23
commandcd /qupulse && grep -n "_calc_sampled_segments" qupulse/_program/tabor.py
exact command
cd /qupulse && grep -n "_calc_sampled_segments" qupulse/_program/tabor.py
00.004s5d7140ae
commandcd /qupulse && sed -n '466,495p' qupulse/_program/tabor.py
exact command
cd /qupulse && sed -n '466,495p' qupulse/_program/tabor.py
00.003s542ea647
commandcd /qupulse && python3 -c " with open('qupulse/_program/tabor.py', 'r') as f: lines = f.readlines() for i, line in enumerate(lines[465:495], start=466): print(f'{i}: {repr(line)}')"
exact command
cd /qupulse && python3 -c "
with open('qupulse/_program/tabor.py', 'r') as f:
    lines = f.readlines()
    for i, line in enumerate(lines[465:495], start=466):
        print(f'{i}: {repr(line)}')"
00.014s5b8f1185
commandcd /qupulse && python3 -c " with open('qupulse/_program/tabor.py', 'r') as f: content = f.read() # Find and replace the function old_func = ''' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]: \"\"\" Returns: (segments, segment_lengths) \"\"\" time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate) if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192): raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') segments = [] for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) assert (len(segment_a) == len(t)) assert (len(segment_b) == len(t)) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segments.append(segment) return segments, segment_lengths''' new_func = ''' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]: \"\"\" Returns: (segments, segment_lengths) \"\"\" time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate) if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192): raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times segments = [] segment_hashes = [] seen_hash_to_index = {} for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) assert (len(segment_a) == len(t)) assert (len(segment_b) == len(t)) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash if segment_hash not in seen_hash_to_index: seen_hash_to_index[segment_hash] = len(segments) segments.append(segment) segment_hashes.append(segment_hash) # If hash already seen, we skip adding the segment to avoid redundancy # Recalculate segment_lengths to only include unique segments in order of first appearance unique_segment_indices = [] for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash if segment_hash in seen_hash_to_index: unique_segment_indices.append(seen_hash_to_index[segment_hash]) else: # This case should not happen as we add all hashes above, but handle it just in case unique_segment_indices.append(len(segments)) seen_hash_to_index[segment_hash] = len(segments) segments.append(segment) segment_hashes.append(segment_hash) # Build new segment_lengths based on unique segments unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices], dtype=np.int64) return segments, unique_lengths''' if old_func in content: content = content.replace(old_func, new_func) with open('qupulse/_program/tabor.py', 'w') as f: f.write(content) print('Replacement successful') else: print('Old function not found') # Let's debug import re match = re.search(r'def _calc_sampled_segments.*?return segments, segment_lengths', content, re.DOTALL) if match: print('Found:', match.group()[:200]) else: print('No match found') "
exact command
cd /qupulse && python3 -c "
with open('qupulse/_program/tabor.py', 'r') as f:
    content = f.read()

# Find and replace the function
old_func = '''    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:
        \"\"\"
        Returns:
            (segments, segment_lengths)
        \"\"\"
        time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate)

        if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):
            raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16')

        segments = []
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            assert (len(segment_a) == len(t))
            assert (len(segment_b) == len(t))
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segments.append(segment)
        return segments, segment_lengths'''

new_func = '''    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:
        \"\"\"
        Returns:
            (segments, segment_lengths)
        \"\"\"
        time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate)

        if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):
            raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16')

        # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times
        segments = []
        segment_hashes = []
        seen_hash_to_index = {}
        
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            assert (len(segment_a) == len(t))
            assert (len(segment_b) == len(t))
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            if segment_hash not in seen_hash_to_index:
                seen_hash_to_index[segment_hash] = len(segments)
                segments.append(segment)
                segment_hashes.append(segment_hash)
            # If hash already seen, we skip adding the segment to avoid redundancy

        # Recalculate segment_lengths to only include unique segments in order of first appearance
        unique_segment_indices = []
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            if segment_hash in seen_hash_to_index:
                unique_segment_indices.append(seen_hash_to_index[segment_hash])
            else:
                # This case should not happen as we add all hashes above, but handle it just in case
                unique_segment_indices.append(len(segments))
                seen_hash_to_index[segment_hash] = len(segments)
                segments.append(segment)
                segment_hashes.append(segment_hash)

        # Build new segment_lengths based on unique segments
        unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices], dtype=np.int64)

        return segments, unique_lengths'''

if old_func in content:
    content = content.replace(old_func, new_func)
    with open('qupulse/_program/tabor.py', 'w') as f:
        f.write(content)
    print('Replacement successful')
else:
    print('Old function not found')
    # Let's debug
    import re
    match = re.search(r'def _calc_sampled_segments.*?return segments, segment_lengths', content, re.DOTALL)
    if match:
        print('Found:', match.group()[:200])
    else:
        print('No match found')
"
00.018s24f227fc
show all 39 steps
KindCommandExitDurationDigest
commandcd /qupulse && python3 << 'EOF' with open('qupulse/_program/tabor.py', 'r') as f: lines = f.readlines() # Find the line numbers for the function start_line = None end_line = None for i, line in enumerate(lines): if 'def _calc_sampled_segments' in line: start_line = i if start_line is not None and start_line < i and 'return segments, segment_lengths' in line: end_line = i break print(f"Function starts at line {start_line + 1}") print(f"Function ends at line {end_line + 1}") # Replace the function body new_lines = lines[:start_line] new_func = ''' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]: \"\"\" Returns: (segments, segment_lengths) \"\"\" time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate) if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192): raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times segments = [] segment_hashes = [] seen_hash_to_index = {} for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) assert (len(segment_a) == len(t)) assert (len(segment_b) == len(t)) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash if segment_hash not in seen_hash_to_index: seen_hash_to_index[segment_hash] = len(segments) segments.append(segment) segment_hashes.append(segment_hash) # If hash already seen, we skip adding the segment to avoid redundancy # Recalculate segment_lengths to only include unique segments in order of first appearance unique_segment_indices = [] for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash if segment_hash in seen_hash_to_index: unique_segment_indices.append(seen_hash_to_index[segment_hash]) else: # This case should not happen as we add all hashes above, but handle it just in case unique_segment_indices.append(len(segments)) seen_hash_to_index[segment_hash] = len(segments) segments.append(segment) segment_hashes.append(segment_hash) # Build new segment_lengths based on unique segments unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices], dtype=np.int64) return segments, unique_lengths''' new_lines.extend([new_func, '\n']) new_lines.extend(lines[end_line + 1:]) with open('qupulse/_program/tabor.py', 'w') as f: f.writelines(new_lines) print("Replacement done") EOF
exact command
cd /qupulse && python3 << 'EOF'
with open('qupulse/_program/tabor.py', 'r') as f:
    lines = f.readlines()

# Find the line numbers for the function
start_line = None
end_line = None
for i, line in enumerate(lines):
    if 'def _calc_sampled_segments' in line:
        start_line = i
    if start_line is not None and start_line < i and 'return segments, segment_lengths' in line:
        end_line = i
        break

print(f"Function starts at line {start_line + 1}")
print(f"Function ends at line {end_line + 1}")

# Replace the function body
new_lines = lines[:start_line]

new_func = '''    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:
        \"\"\"
        Returns:
            (segments, segment_lengths)
        \"\"\"
        time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate)

        if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):
            raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16')

        # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times
        segments = []
        segment_hashes = []
        seen_hash_to_index = {}
        
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            assert (len(segment_a) == len(t))
            assert (len(segment_b) == len(t))
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            if segment_hash not in seen_hash_to_index:
                seen_hash_to_index[segment_hash] = len(segments)
                segments.append(segment)
                segment_hashes.append(segment_hash)
            # If hash already seen, we skip adding the segment to avoid redundancy

        # Recalculate segment_lengths to only include unique segments in order of first appearance
        unique_segment_indices = []
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            if segment_hash in seen_hash_to_index:
                unique_segment_indices.append(seen_hash_to_index[segment_hash])
            else:
                # This case should not happen as we add all hashes above, but handle it just in case
                unique_segment_indices.append(len(segments))
                seen_hash_to_index[segment_hash] = len(segments)
                segments.append(segment)
                segment_hashes.append(segment_hash)

        # Build new segment_lengths based on unique segments
        unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices], dtype=np.int64)

        return segments, unique_lengths'''

new_lines.extend([new_func, '\n'])
new_lines.extend(lines[end_line + 1:])

with open('qupulse/_program/tabor.py', 'w') as f:
    f.writelines(new_lines)

print("Replacement done")
EOF
00.013s9ebbc724
commandcd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1
exact command
cd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1
11.257s1a59cfbd
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborSegment from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from qupulse.hardware.awgs.tabor import model_properties_dict instr_props = model_properties_dict['WX2184C'].copy() waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) from tests.pulses.sequencing_dummies import WaveformGenerator root_loop = __import__('tests._program.loop_tests').LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) prog = root_loop # Let's manually check the waveforms wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') print(f"wf1 duration: {wf1.duration}") print(f"wf2 duration: {wf2.duration}") print(f"wf3 duration: {wf3.duration}") # Check compare_key print(f"wf1.compare_key: {wf1.compare_key}") print(f"wf2.compare_key: {wf2.compare_key}") print(f"wf3.compare_key: {wf3.compare_key}") # Check if they have the same data when sampled t = np.array([0, 1]) # simple times sampled_a1 = wf1.unsafe_sample('A', t) sampled_a2 = wf2.unsafe_sample('A', t) sampled_a3 = wf3.unsafe_sample('A', t) print(f"wf1 sampled A: {sampled_a1}") print(f"wf2 sampled A: {sampled_a2}") print(f"wf3 sampled A: {sampled_a3}") print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}") print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}") # Check TaborSegment hashes seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None) seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None) print(f"seg1._hash: {seg1._hash}") print(f"seg2._hash: {seg2._hash}") print(f"seg3._hash: {seg3._hash}") print(f"seg1 == seg2: {seg1 == seg2}") print(f"seg1 == seg3: {seg1 == seg3}") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborSegment
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from qupulse.hardware.awgs.tabor import model_properties_dict

instr_props = model_properties_dict['WX2184C'].copy()

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

from tests.pulses.sequencing_dummies import WaveformGenerator

root_loop = __import__('tests._program.loop_tests').LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                                     waveform_data_generator=waveform_data_generator2,
                                                                     duration_generator=__import__('itertools').repeat(1)))

prog = root_loop

# Let's manually check the waveforms
wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

print(f"wf1 duration: {wf1.duration}")
print(f"wf2 duration: {wf2.duration}")
print(f"wf3 duration: {wf3.duration}")

# Check compare_key
print(f"wf1.compare_key: {wf1.compare_key}")
print(f"wf2.compare_key: {wf2.compare_key}")
print(f"wf3.compare_key: {wf3.compare_key}")

# Check if they have the same data when sampled
t = np.array([0, 1])  # simple times
sampled_a1 = wf1.unsafe_sample('A', t)
sampled_a2 = wf2.unsafe_sample('A', t)
sampled_a3 = wf3.unsafe_sample('A', t)

print(f"wf1 sampled A: {sampled_a1}")
print(f"wf2 sampled A: {sampled_a2}")
print(f"wf3 sampled A: {sampled_a3}")

print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}")
print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}")

# Check TaborSegment hashes
seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None)
seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None)

print(f"seg1._hash: {seg1._hash}")
print(f"seg2._hash: {seg2._hash}")
print(f"seg3._hash: {seg3._hash}")

print(f"seg1 == seg2: {seg1 == seg2}")
print(f"seg1 == seg3: {seg1 == seg3}")
EOF
10.731s58a28e67
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborSegment from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from tests.pulses.sequencing_dummies import WaveformGenerator from tests._program.loop_tests import LoopTests waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) # Let's manually check the waveforms wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') print(f"wf1 duration: {wf1.duration}") print(f"wf2 duration: {wf2.duration}") print(f"wf3 duration: {wf3.duration}") # Check compare_key print(f"wf1.compare_key: {wf1.compare_key}") print(f"wf2.compare_key: {wf2.compare_key}") print(f"wf3.compare_key: {wf3.compare_key}") # Check if they have the same data when sampled t = np.array([0, 1, 2, 3, 4, 5]) # simple times sampled_a1 = wf1.unsafe_sample('A', t) sampled_a2 = wf2.unsafe_sample('A', t) sampled_a3 = wf3.unsafe_sample('A', t) print(f"wf1 sampled A: {sampled_a1}") print(f"wf2 sampled A: {sampled_a2}") print(f"wf3 sampled A: {sampled_a3}") print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}") print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}") # Check TaborSegment hashes seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None) seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None) print(f"seg1._hash: {seg1._hash}") print(f"seg2._hash: {seg2._hash}") print(f"seg3._hash: {seg3._hash}") print(f"seg1 == seg2: {seg1 == seg2}") print(f"seg1 == seg3: {seg1 == seg3}") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborSegment
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from tests.pulses.sequencing_dummies import WaveformGenerator
from tests._program.loop_tests import LoopTests

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                     waveform_data_generator=waveform_data_generator2,
                                                     duration_generator=__import__('itertools').repeat(1)))

# Let's manually check the waveforms
wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

print(f"wf1 duration: {wf1.duration}")
print(f"wf2 duration: {wf2.duration}")
print(f"wf3 duration: {wf3.duration}")

# Check compare_key
print(f"wf1.compare_key: {wf1.compare_key}")
print(f"wf2.compare_key: {wf2.compare_key}")
print(f"wf3.compare_key: {wf3.compare_key}")

# Check if they have the same data when sampled
t = np.array([0, 1, 2, 3, 4, 5])  # simple times
sampled_a1 = wf1.unsafe_sample('A', t)
sampled_a2 = wf2.unsafe_sample('A', t)
sampled_a3 = wf3.unsafe_sample('A', t)

print(f"wf1 sampled A: {sampled_a1}")
print(f"wf2 sampled A: {sampled_a2}")
print(f"wf3 sampled A: {sampled_a3}")

print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}")
print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}")

# Check TaborSegment hashes
seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None)
seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None)

print(f"seg1._hash: {seg1._hash}")
print(f"seg2._hash: {seg2._hash}")
print(f"seg3._hash: {seg3._hash}")

print(f"seg1 == seg2: {seg1 == seg2}")
print(f"seg1 == seg3: {seg1 == seg3}")
EOF
10.772sa05dbbaf
commandcd /qupulse && grep -n "class WaveformGenerator" tests/_program/loop_tests.py
exact command
cd /qupulse && grep -n "class WaveformGenerator" tests/_program/loop_tests.py
00.003s190da7a4
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborSegment from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from tests._program.loop_tests import WaveformGenerator, LoopTests waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) # Let's manually check the waveforms wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') print(f"wf1 duration: {wf1.duration}") print(f"wf2 duration: {wf2.duration}") print(f"wf3 duration: {wf3.duration}") # Check compare_key print(f"wf1.compare_key: {wf1.compare_key}") print(f"wf2.compare_key: {wf2.compare_key}") print(f"wf3.compare_key: {wf3.compare_key}") # Check if they have the same data when sampled t = np.array([0, 1, 2, 3, 4, 5]) # simple times sampled_a1 = wf1.unsafe_sample('A', t) sampled_a2 = wf2.unsafe_sample('A', t) sampled_a3 = wf3.unsafe_sample('A', t) print(f"wf1 sampled A: {sampled_a1}") print(f"wf2 sampled A: {sampled_a2}") print(f"wf3 sampled A: {sampled_a3}") print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}") print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}") # Check TaborSegment hashes seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None) seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None) print(f"seg1._hash: {seg1._hash}") print(f"seg2._hash: {seg2._hash}") print(f"seg3._hash: {seg3._hash}") print(f"seg1 == seg2: {seg1 == seg2}") print(f"seg1 == seg3: {seg1 == seg3}") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborSegment
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from tests._program.loop_tests import WaveformGenerator, LoopTests

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                     waveform_data_generator=waveform_data_generator2,
                                                     duration_generator=__import__('itertools').repeat(1)))

# Let's manually check the waveforms
wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

print(f"wf1 duration: {wf1.duration}")
print(f"wf2 duration: {wf2.duration}")
print(f"wf3 duration: {wf3.duration}")

# Check compare_key
print(f"wf1.compare_key: {wf1.compare_key}")
print(f"wf2.compare_key: {wf2.compare_key}")
print(f"wf3.compare_key: {wf3.compare_key}")

# Check if they have the same data when sampled
t = np.array([0, 1, 2, 3, 4, 5])  # simple times
sampled_a1 = wf1.unsafe_sample('A', t)
sampled_a2 = wf2.unsafe_sample('A', t)
sampled_a3 = wf3.unsafe_sample('A', t)

print(f"wf1 sampled A: {sampled_a1}")
print(f"wf2 sampled A: {sampled_a2}")
print(f"wf3 sampled A: {sampled_a3}")

print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}")
print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}")

# Check TaborSegment hashes
seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None)
seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None)

print(f"seg1._hash: {seg1._hash}")
print(f"seg2._hash: {seg2._hash}")
print(f"seg3._hash: {seg3._hash}")

print(f"seg1 == seg2: {seg1 == seg2}")
print(f"seg1 == seg3: {seg1 == seg3}")
EOF
10.800s9d181876
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborSegment from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform from qupulse.hardware.util import voltage_to_uint16 # Let's manually check the waveforms wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') # Check if they have the same data when sampled t = np.array([0, 1, 2, 3, 4, 5]) # simple times sampled_a1 = wf1.unsafe_sample('A', t) sampled_a2 = wf2.unsafe_sample('A', t) sampled_a3 = wf3.unsafe_sample('A', t) print(f"wf1 sampled A: {sampled_a1}") print(f"wf2 sampled A: {sampled_a2}") print(f"wf3 sampled A: {sampled_a3}") print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}") print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}") # Convert to uint16 uint16_a1 = voltage_to_uint16(sampled_a1, 1., 0., 14) uint16_a2 = voltage_to_uint16(sampled_a2, 1., 0., 14) uint16_a3 = voltage_to_uint16(sampled_a3, 1., 0., 14) print(f"uint16_a1: {uint16_a1}") print(f"uint16_a2: {uint16_a2}") print(f"uint16_a3: {uint16_a3}") # Check TaborSegment hashes seg1 = TaborSegment.from_sampled(ch_a=uint16_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=uint16_a2, ch_b=None, marker_a=None, marker_b=None) seg3 = TaborSegment.from_sampled(ch_a=uint16_a3, ch_b=None, marker_a=None, marker_b=None) print(f"seg1._hash: {seg1._hash}") print(f"seg2._hash: {seg2._hash}") print(f"seg3._hash: {seg3._hash}") print(f"seg1 == seg2: {seg1 == seg2}") print(f"seg1 == seg3: {seg1 == seg3}") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborSegment
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform
from qupulse.hardware.util import voltage_to_uint16

# Let's manually check the waveforms
wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

# Check if they have the same data when sampled
t = np.array([0, 1, 2, 3, 4, 5])  # simple times
sampled_a1 = wf1.unsafe_sample('A', t)
sampled_a2 = wf2.unsafe_sample('A', t)
sampled_a3 = wf3.unsafe_sample('A', t)

print(f"wf1 sampled A: {sampled_a1}")
print(f"wf2 sampled A: {sampled_a2}")
print(f"wf3 sampled A: {sampled_a3}")

print(f"wf1 sampled A == wf2 sampled A: {np.array_equal(sampled_a1, sampled_a2)}")
print(f"wf1 sampled A == wf3 sampled A: {np.array_equal(sampled_a1, sampled_a3)}")

# Convert to uint16
uint16_a1 = voltage_to_uint16(sampled_a1, 1., 0., 14)
uint16_a2 = voltage_to_uint16(sampled_a2, 1., 0., 14)
uint16_a3 = voltage_to_uint16(sampled_a3, 1., 0., 14)

print(f"uint16_a1: {uint16_a1}")
print(f"uint16_a2: {uint16_a2}")
print(f"uint16_a3: {uint16_a3}")

# Check TaborSegment hashes
seg1 = TaborSegment.from_sampled(ch_a=uint16_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=uint16_a2, ch_b=None, marker_a=None, marker_b=None)
seg3 = TaborSegment.from_sampled(ch_a=uint16_a3, ch_b=None, marker_a=None, marker_b=None)

print(f"seg1._hash: {seg1._hash}")
print(f"seg2._hash: {seg2._hash}")
print(f"seg3._hash: {seg3._hash}")

print(f"seg1 == seg2: {seg1 == seg2}")
print(f"seg1 == seg3: {seg1 == seg3}")
EOF
10.691se61df8d1
commandcd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1 | head -50
exact command
cd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1 | head -50
01.076s2cee460e
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborProgram from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from tests._program.loop_tests import WaveformGenerator, LoopTests from tests.pulses.sequencing_dummies import ConstantWaveform instr_props = None # Will use default waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), amplitudes=(1., 1.), offsets=(0., 0.), voltage_transformations=(mock.Mock(wraps=lambda x: x), mock.Mock(wraps=lambda x: x)), sample_rate=TimeType.from_fraction(192, 1), mode=None) sampled, sampled_length = prog.get_sampled_segments() print(f"len(sampled): {len(sampled)}") print(f"sampled_length: {sampled_length}") print(f"sampled[0]._hash: {sampled[0]._hash}") if len(sampled) > 1: print(f"sampled[1]._hash: {sampled[1]._hash}") if len(sampled) > 2: print(f"sampled[2]._hash: {sampled[2]._hash}") # Check if any have the same hash for i in range(len(sampled)): for j in range(i+1, len(sampled)): if sampled[i]._hash == sampled[j]._hash: print(f"sampled[{i}]._hash == sampled[{j}]._hash") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborProgram
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from tests._program.loop_tests import WaveformGenerator, LoopTests
from tests.pulses.sequencing_dummies import ConstantWaveform

instr_props = None  # Will use default

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                     waveform_data_generator=waveform_data_generator2,
                                                     duration_generator=__import__('itertools').repeat(1)))

prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), 
                    amplitudes=(1., 1.),
                    offsets=(0., 0.),
                    voltage_transformations=(mock.Mock(wraps=lambda x: x),
                                           mock.Mock(wraps=lambda x: x)),
                    sample_rate=TimeType.from_fraction(192, 1),
                    mode=None)

sampled, sampled_length = prog.get_sampled_segments()

print(f"len(sampled): {len(sampled)}")
print(f"sampled_length: {sampled_length}")
print(f"sampled[0]._hash: {sampled[0]._hash}")
if len(sampled) > 1:
    print(f"sampled[1]._hash: {sampled[1]._hash}")
if len(sampled) > 2:
    print(f"sampled[2]._hash: {sampled[2]._hash}")

# Check if any have the same hash
for i in range(len(sampled)):
    for j in range(i+1, len(sampled)):
        if sampled[i]._hash == sampled[j]._hash:
            print(f"sampled[{i}]._hash == sampled[{j}]._hash")
EOF
10.772sf322b363
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborProgram from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from tests._program.loop_tests import WaveformGenerator, LoopTests from qupulse.program.waveforms import ConstantWaveform instr_props = None # Will use default waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), __import__('tests').pulses.sequencing_dummies.SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), amplitudes=(1., 1.), offsets=(0., 0.), voltage_transformations=(mock.Mock(wraps=lambda x: x), mock.Mock(wraps=lambda x: x)), sample_rate=TimeType.from_fraction(192, 1), mode=None) sampled, sampled_length = prog.get_sampled_segments() print(f"len(sampled): {len(sampled)}") print(f"sampled_length: {sampled_length}") print(f"sampled[0]._hash: {sampled[0]._hash}") if len(sampled) > 1: print(f"sampled[1]._hash: {sampled[1]._hash}") if len(sampled) > 2: print(f"sampled[2]._hash: {sampled[2]._hash}") # Check if any have the same hash for i in range(len(sampled)): for j in range(i+1, len(sampled)): if sampled[i]._hash == sampled[j]._hash: print(f"sampled[{i}]._hash == sampled[{j}]._hash") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborProgram
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from tests._program.loop_tests import WaveformGenerator, LoopTests
from qupulse.program.waveforms import ConstantWaveform

instr_props = None  # Will use default

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        __import__('tests').pulses.sequencing_dummies.SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                     waveform_data_generator=waveform_data_generator2,
                                                     duration_generator=__import__('itertools').repeat(1)))

prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), 
                    amplitudes=(1., 1.),
                    offsets=(0., 0.),
                    voltage_transformations=(mock.Mock(wraps=lambda x: x),
                                           mock.Mock(wraps=lambda x: x)),
                    sample_rate=TimeType.from_fraction(192, 1),
                    mode=None)

sampled, sampled_length = prog.get_sampled_segments()

print(f"len(sampled): {len(sampled)}")
print(f"sampled_length: {sampled_length}")
print(f"sampled[0]._hash: {sampled[0]._hash}")
if len(sampled) > 1:
    print(f"sampled[1]._hash: {sampled[1]._hash}")
if len(sampled) > 2:
    print(f"sampled[2]._hash: {sampled[2]._hash}")

# Check if any have the same hash
for i in range(len(sampled)):
    for j in range(i+1, len(sampled)):
        if sampled[i]._hash == sampled[j]._hash:
            print(f"sampled[{i}]._hash == sampled[{j}]._hash")
EOF
10.774s9ad7f3ac
commandcd /qupulse && grep -rn "class SubsetWaveform" --include="*.py"
exact command
cd /qupulse && grep -rn "class SubsetWaveform" --include="*.py"
00.012sfe292d53
commandcd /qupulse && python3 << 'EOF' import numpy as np from qupulse._program.tabor import TaborProgram from unittest import mock from qupulse.utils.types import TimeType, FrozenDict from qupulse.parameter_scope import DictScope from qupulse.expressions import ExpressionScalar from qupulse.program.loop import Loop from tests._program.loop_tests import WaveformGenerator, LoopTests from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform instr_props = None # Will use default waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192), np.concatenate((np.linspace(-0.5, 0.5, num=96), np.linspace(0.5, -0.5, num=96))), -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))]) waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'), SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ), ConstantWaveform(duration=1, amplitude=0.2, channel='A')]) root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2, waveform_data_generator=waveform_data_generator2, duration_generator=__import__('itertools').repeat(1))) prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), amplitudes=(1., 1.), offsets=(0., 0.), voltage_transformations=(mock.Mock(wraps=lambda x: x), mock.Mock(wraps=lambda x: x)), sample_rate=TimeType.from_fraction(192, 1), mode=None) sampled, sampled_length = prog.get_sampled_segments() print(f"len(sampled): {len(sampled)}") print(f"sampled_length: {sampled_length}") print(f"sampled[0]._hash: {sampled[0]._hash}") if len(sampled) > 1: print(f"sampled[1]._hash: {sampled[1]._hash}") if len(sampled) > 2: print(f"sampled[2]._hash: {sampled[2]._hash}") # Check if any have the same hash for i in range(len(sampled)): for j in range(i+1, len(sampled)): if sampled[i]._hash == sampled[j]._hash: print(f"sampled[{i}]._hash == sampled[{j}]._hash") EOF
exact command
cd /qupulse && python3 << 'EOF'
import numpy as np
from qupulse._program.tabor import TaborProgram
from unittest import mock
from qupulse.utils.types import TimeType, FrozenDict
from qupulse.parameter_scope import DictScope
from qupulse.expressions import ExpressionScalar
from qupulse.program.loop import Loop
from tests._program.loop_tests import WaveformGenerator, LoopTests
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform

instr_props = None  # Will use default

waveform_data_generator = __import__('itertools').cycle([np.linspace(-0.5, 0.5, num=192),
                                                        np.concatenate((np.linspace(-0.5, 0.5, num=96),
                                                                        np.linspace(0.5, -0.5, num=96))),
                                                        -0.5*np.cos(np.linspace(0, 2*np.pi, num=192))])

waveform_data_generator2 = __import__('itertools').cycle([ConstantWaveform(duration=2, amplitude=0.1, channel='A'),
                                                        SubsetWaveform(
                                                            ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
                                                            {'A'}
                                                        ),
                                                        ConstantWaveform(duration=1, amplitude=0.2, channel='A')])

root_loop = LoopTests.get_test_loop(WaveformGenerator(num_channels=2,
                                                     waveform_data_generator=waveform_data_generator2,
                                                     duration_generator=__import__('itertools').repeat(1)))

prog = TaborProgram(root_loop, instr_props, ('A', None), (None, None), 
                    amplitudes=(1., 1.),
                    offsets=(0., 0.),
                    voltage_transformations=(mock.Mock(wraps=lambda x: x),
                                           mock.Mock(wraps=lambda x: x)),
                    sample_rate=TimeType.from_fraction(192, 1),
                    mode=None)

sampled, sampled_length = prog.get_sampled_segments()

print(f"len(sampled): {len(sampled)}")
print(f"sampled_length: {sampled_length}")
print(f"sampled[0]._hash: {sampled[0]._hash}")
if len(sampled) > 1:
    print(f"sampled[1]._hash: {sampled[1]._hash}")
if len(sampled) > 2:
    print(f"sampled[2]._hash: {sampled[2]._hash}")

# Check if any have the same hash
for i in range(len(sampled)):
    for j in range(i+1, len(sampled)):
        if sampled[i]._hash == sampled[j]._hash:
            print(f"sampled[{i}]._hash == sampled[{j}]._hash")
EOF
10.773s7de421e5
commandcd /qupulse && python3 -c " import sys sys.path.insert(0, '.') from tests._program.tabor_tests import TaborProgramTests import unittest # Create test instance test = TaborProgramTests('test_calc_sampled_segments_deduplication') # Setup test.setUp() # Run the test method try: test.test_calc_sampled_segments_deduplication() print('Test passed!') except AssertionError as e: print(f'Test failed: {e}') except Exception as e: print(f'Error: {e}') " 2>&1
exact command
cd /qupulse && python3 -c "
import sys
sys.path.insert(0, '.')
from tests._program.tabor_tests import TaborProgramTests
import unittest

# Create test instance
test = TaborProgramTests('test_calc_sampled_segments_deduplication')

# Setup
test.setUp()

# Run the test method
try:
    test.test_calc_sampled_segments_deduplication()
    print('Test passed!')
except AssertionError as e:
    print(f'Test failed: {e}')
except Exception as e:
    print(f'Error: {e}')
" 2>&1
00.840s53c7589a
commandcd /qupulse && sed -n '466,530p' qupulse/_program/tabor.py
exact command
cd /qupulse && sed -n '466,530p' qupulse/_program/tabor.py
00.003sde5eb35e
commandcd /qupulse && python3 << 'EOF' # Let me trace through what's happening import numpy as np from unittest import mock from qupulse.utils.types import TimeType from qupulse.program.loop import Loop from tests._program.loop_tests import WaveformGenerator, LoopTests from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform from qupulse.hardware.util import voltage_to_uint16 # Simulate what the test does wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') loop = Loop(children=[ Loop(waveform=wf1), Loop(waveform=wf2), Loop(waveform=wf3), ]) # Now let's check what _calc_sampled_segments does internally from qupulse.utils.types import TimeType from unittest import mock instr_props_dict = {'chan_per_part': 2} # Minimal # Create a minimal program from qupulse.program.loop import Loop prog_loop = Loop(children=[ Loop(waveform=ConstantWaveform(duration=2, amplitude=0.1, channel='A')), Loop(waveform=SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} )), Loop(waveform=ConstantWaveform(duration=1, amplitude=0.2, channel='A')), ], repetition_count=1) # Now let's manually call get_sampled_segments from qupulse.hardware.awgs.tabor import model_properties_dict instr_props = model_properties_dict['WX2184C'].copy() prog = TaborProgram(prog_loop, instr_props, ('A', None), (None, None), amplitudes=(1., 1.), offsets=(0., 0.), voltage_transformations=(mock.Mock(wraps=lambda x: x), mock.Mock(wraps=lambda x: x)), sample_rate=TimeType.from_fraction(192, 1), mode=None) sampled, sampled_length = prog.get_sampled_segments() print(f"len(sampled): {len(sampled)}") print(f"sampled_length: {sampled_length}") for i, s in enumerate(sampled): print(f"sampled[{i}]._hash: {s._hash}, num_points: {s.num_points}") EOF
exact command
cd /qupulse && python3 << 'EOF'
# Let me trace through what's happening
import numpy as np
from unittest import mock
from qupulse.utils.types import TimeType
from qupulse.program.loop import Loop
from tests._program.loop_tests import WaveformGenerator, LoopTests
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform
from qupulse.hardware.util import voltage_to_uint16

# Simulate what the test does
wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

loop = Loop(children=[
    Loop(waveform=wf1),
    Loop(waveform=wf2),
    Loop(waveform=wf3),
])

# Now let's check what _calc_sampled_segments does internally
from qupulse.utils.types import TimeType
from unittest import mock

instr_props_dict = {'chan_per_part': 2}  # Minimal

# Create a minimal program
from qupulse.program.loop import Loop
prog_loop = Loop(children=[
    Loop(waveform=ConstantWaveform(duration=2, amplitude=0.1, channel='A')),
    Loop(waveform=SubsetWaveform(
        ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
        {'A'}
    )),
    Loop(waveform=ConstantWaveform(duration=1, amplitude=0.2, channel='A')),
], repetition_count=1)

# Now let's manually call get_sampled_segments
from qupulse.hardware.awgs.tabor import model_properties_dict
instr_props = model_properties_dict['WX2184C'].copy()

prog = TaborProgram(prog_loop, instr_props, ('A', None), (None, None), 
                    amplitudes=(1., 1.),
                    offsets=(0., 0.),
                    voltage_transformations=(mock.Mock(wraps=lambda x: x),
                                           mock.Mock(wraps=lambda x: x)),
                    sample_rate=TimeType.from_fraction(192, 1),
                    mode=None)

sampled, sampled_length = prog.get_sampled_segments()

print(f"len(sampled): {len(sampled)}")
print(f"sampled_length: {sampled_length}")
for i, s in enumerate(sampled):
    print(f"sampled[{i}]._hash: {s._hash}, num_points: {s.num_points}")
EOF
10.815sa18214fc
commandcd /qupulse && python3 -c " import sys sys.path.insert(0, '.') from tests._program.tabor_tests import TaborProgramTests import unittest # Create test instance test = TaborProgramTests('test_calc_sampled_segments_deduplication') # Add some debug import qupulse._program.tabor as tabor_module original_calc = tabor_module.TaborProgram._calc_sampled_segments def debug_calc(self): result = original_calc(self) segments, lengths = result print(f'DEBUG: _calc_sampled_segments returned {len(segments)} segments') for i, s in enumerate(segments): print(f' segment[{i}]._hash={s._hash}, num_points={s.num_points}') print(f'DEBUG: lengths={lengths}') return result tabor_module.TaborProgram._calc_sampled_segments = debug_calc # Setup test.setUp() # Run the test method try: test.test_calc_sampled_segments_deduplication() print('Test passed!') except AssertionError as e: print(f'Test failed: {e}') except Exception as e: print(f'Error: {e}') " 2>&1
exact command
cd /qupulse && python3 -c "
import sys
sys.path.insert(0, '.')
from tests._program.tabor_tests import TaborProgramTests
import unittest

# Create test instance
test = TaborProgramTests('test_calc_sampled_segments_deduplication')

# Add some debug
import qupulse._program.tabor as tabor_module

original_calc = tabor_module.TaborProgram._calc_sampled_segments

def debug_calc(self):
    result = original_calc(self)
    segments, lengths = result
    print(f'DEBUG: _calc_sampled_segments returned {len(segments)} segments')
    for i, s in enumerate(segments):
        print(f'  segment[{i}]._hash={s._hash}, num_points={s.num_points}')
    print(f'DEBUG: lengths={lengths}')
    return result

tabor_module.TaborProgram._calc_sampled_segments = debug_calc

# Setup
test.setUp()

# Run the test method
try:
    test.test_calc_sampled_segments_deduplication()
    print('Test passed!')
except AssertionError as e:
    print(f'Test failed: {e}')
except Exception as e:
    print(f'Error: {e}')
" 2>&1
00.851seacb2bf7
commandcd /qupulse && python3 -c " import sys sys.path.insert(0, '.') from tests._program.tabor_tests import TaborProgramTests import unittest from unittest import mock from qupulse.utils.types import TimeType # Create test instance test = TaborProgramTests('test_calc_sampled_segments_deduplication') test.setUp() # Access the program directly loop = test.root_loop.children # This might not be right # Let me just check what the test creates print('Testing wf1 and wf2 directly...') from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A') # Check compare_key print(f'wf1.compare_key: {wf1.compare_key}') print(f'wf2.compare_key: {wf2.compare_key}') print(f'wf3.compare_key: {wf3.compare_key}') # Sample them t = [0, 1, 2, 3, 4, 5] # 6 points for duration 2 with sample rate 192/1 -> 192 samples from qupulse.hardware.util import voltage_to_uint16 sampled_a1 = voltage_to_uint16(wf1.unsafe_sample('A', t), 1., 0., 14) sampled_a2 = voltage_to_uint16(wf2.unsafe_sample('A', t), 1., 0., 14) sampled_a3 = voltage_to_uint16(wf3.unsafe_sample('A', 6), 1., 0., 14) # duration 1 print(f'sampled_a1: {sampled_a1}') print(f'sampled_a2: {sampled_a2}') print(f'sampled_a3: {sampled_a3}') print(f'sampled_a1 == sampled_a2: {np.array_equal(sampled_a1, sampled_a2)}') print(f'sampled_a1 == sampled_a3: {np.array_equal(sampled_a1, sampled_a3)}') # Now create TaborSegments from qupulse._program.tabor import TaborSegment seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None) seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None) print(f'seg1._hash: {seg1._hash}') print(f'seg2._hash: {seg2._hash}') print(f'seg3._hash: {seg3._hash}') print(f'seg1 == seg2: {seg1 == seg2}') print(f'seg1 == seg3: {seg1 == seg3}') " 2>&1
exact command
cd /qupulse && python3 -c "
import sys
sys.path.insert(0, '.')
from tests._program.tabor_tests import TaborProgramTests
import unittest
from unittest import mock
from qupulse.utils.types import TimeType

# Create test instance
test = TaborProgramTests('test_calc_sampled_segments_deduplication')
test.setUp()

# Access the program directly
loop = test.root_loop.children  # This might not be right

# Let me just check what the test creates
print('Testing wf1 and wf2 directly...')
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform

wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)
wf3 = ConstantWaveform(duration=1, amplitude=0.2, channel='A')

# Check compare_key
print(f'wf1.compare_key: {wf1.compare_key}')
print(f'wf2.compare_key: {wf2.compare_key}')
print(f'wf3.compare_key: {wf3.compare_key}')

# Sample them
t = [0, 1, 2, 3, 4, 5]  # 6 points for duration 2 with sample rate 192/1 -> 192 samples
from qupulse.hardware.util import voltage_to_uint16
sampled_a1 = voltage_to_uint16(wf1.unsafe_sample('A', t), 1., 0., 14)
sampled_a2 = voltage_to_uint16(wf2.unsafe_sample('A', t), 1., 0., 14)
sampled_a3 = voltage_to_uint16(wf3.unsafe_sample('A', 6), 1., 0., 14)  # duration 1

print(f'sampled_a1: {sampled_a1}')
print(f'sampled_a2: {sampled_a2}')
print(f'sampled_a3: {sampled_a3}')
print(f'sampled_a1 == sampled_a2: {np.array_equal(sampled_a1, sampled_a2)}')
print(f'sampled_a1 == sampled_a3: {np.array_equal(sampled_a1, sampled_a3)}')

# Now create TaborSegments
from qupulse._program.tabor import TaborSegment
seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None)
seg3 = TaborSegment.from_sampled(ch_a=sampled_a3, ch_b=None, marker_a=None, marker_b=None)

print(f'seg1._hash: {seg1._hash}')
print(f'seg2._hash: {seg2._hash}')
print(f'seg3._hash: {seg3._hash}')
print(f'seg1 == seg2: {seg1 == seg2}')
print(f'seg1 == seg3: {seg1 == seg3}')
" 2>&1
10.817s5f1a31e8
commandcd /qupulse && python3 -c " import numpy as np from qupulse._program.tabor import TaborSegment from qupulse.hardware.util import voltage_to_uint16 from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A') wf2 = SubsetWaveform( ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}), {'A'} ) # Sample them with proper times # For duration 2 with sample_rate 192, we get 192 samples t = np.linspace(0, 2, 192) # 192 samples over 2 time units sampled_a1 = voltage_to_uint16(wf1.unsafe_sample('A', t), 1., 0., 14) sampled_a2 = voltage_to_uint16(wf2.unsafe_sample('A', t), 1., 0., 14) print(f'sampled_a1 shape: {sampled_a1.shape}') print(f'sampled_a2 shape: {sampled_a2.shape}') print(f'sampled_a1[:5]: {sampled_a1[:5]}') print(f'sampled_a2[:5]: {sampled_a2[:5]}') print(f'sampled_a1 == sampled_a2: {np.array_equal(sampled_a1, sampled_a2)}') # Create TaborSegments seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None) seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None) print(f'seg1._hash: {seg1._hash}') print(f'seg2._hash: {seg2._hash}') print(f'seg1 == seg2: {seg1 == seg2}') print(f'seg1._hash == seg2._hash: {seg1._hash == seg2._hash}') " 2>&1
exact command
cd /qupulse && python3 -c "
import numpy as np
from qupulse._program.tabor import TaborSegment
from qupulse.hardware.util import voltage_to_uint16
from qupulse.program.waveforms import ConstantWaveform, SubsetWaveform

wf1 = ConstantWaveform(duration=2, amplitude=0.1, channel='A')
wf2 = SubsetWaveform(
    ConstantWaveform.from_mapping(duration=2, constant_values={'A': 0.1, 'B': 0.2}),
    {'A'}
)

# Sample them with proper times
# For duration 2 with sample_rate 192, we get 192 samples
t = np.linspace(0, 2, 192)  # 192 samples over 2 time units
sampled_a1 = voltage_to_uint16(wf1.unsafe_sample('A', t), 1., 0., 14)
sampled_a2 = voltage_to_uint16(wf2.unsafe_sample('A', t), 1., 0., 14)

print(f'sampled_a1 shape: {sampled_a1.shape}')
print(f'sampled_a2 shape: {sampled_a2.shape}')
print(f'sampled_a1[:5]: {sampled_a1[:5]}')
print(f'sampled_a2[:5]: {sampled_a2[:5]}')
print(f'sampled_a1 == sampled_a2: {np.array_equal(sampled_a1, sampled_a2)}')

# Create TaborSegments
seg1 = TaborSegment.from_sampled(ch_a=sampled_a1, ch_b=None, marker_a=None, marker_b=None)
seg2 = TaborSegment.from_sampled(ch_a=sampled_a2, ch_b=None, marker_a=None, marker_b=None)

print(f'seg1._hash: {seg1._hash}')
print(f'seg2._hash: {seg2._hash}')
print(f'seg1 == seg2: {seg1 == seg2}')
print(f'seg1._hash == seg2._hash: {seg1._hash == seg2._hash}')
" 2>&1
00.666s9fd96578
commandcd /qupulse && python3 -c " import sys sys.path.insert(0, '.') from tests._program.tabor_tests import TaborProgramTests import unittest from unittest import mock from qupulse.utils.types import TimeType # Create test instance test = TaborProgramTests('test_calc_sampled_segments_deduplication') test.setUp() # Let me patch _calc_sampled_segments to add debug import qupulse._program.tabor as tabor_module original_calc = tabor_module.TaborProgram._calc_sampled_segments def debug_calc(self): result = original_calc(self) segments, lengths = result print(f'DEBUG: _calc_sampled_segments returned {len(segments)} segments') for i, s in enumerate(segments): print(f' segment[{i}]._hash={s._hash}, num_points={s.num_points}') print(f'DEBUG: lengths={lengths}') return result tabor_module.TaborProgram._calc_sampled_segments = debug_calc # Run the test method try: test.test_calc_sampled_segments_deduplication() print('Test passed!') except AssertionError as e: print(f'Test failed: {e}') except Exception as e: print(f'Error: {e}') import traceback traceback.print_exc() " 2>&1
exact command
cd /qupulse && python3 -c "
import sys
sys.path.insert(0, '.')
from tests._program.tabor_tests import TaborProgramTests
import unittest
from unittest import mock
from qupulse.utils.types import TimeType

# Create test instance
test = TaborProgramTests('test_calc_sampled_segments_deduplication')
test.setUp()

# Let me patch _calc_sampled_segments to add debug
import qupulse._program.tabor as tabor_module

original_calc = tabor_module.TaborProgram._calc_sampled_segments

def debug_calc(self):
    result = original_calc(self)
    segments, lengths = result
    print(f'DEBUG: _calc_sampled_segments returned {len(segments)} segments')
    for i, s in enumerate(segments):
        print(f'  segment[{i}]._hash={s._hash}, num_points={s.num_points}')
    print(f'DEBUG: lengths={lengths}')
    return result

tabor_module.TaborProgram._calc_sampled_segments = debug_calc

# Run the test method
try:
    test.test_calc_sampled_segments_deduplication()
    print('Test passed!')
except AssertionError as e:
    print(f'Test failed: {e}')
except Exception as e:
    print(f'Error: {e}')
    import traceback
    traceback.print_exc()
" 2>&1
00.817sef541c3b
commandcd /qupulse && python3 << 'EOF' # Let me rewrite the _calc_sampled_segments function more carefully import numpy as np from typing import Sequence, Tuple # Simulated function to understand the flow def test_dedup(): # Simulate segment_lengths and waveforms segment_lengths = np.array([384, 384, 192]) # wf1, wf2, wf3 # Simulate hashes (in reality these would be computed from the segments) # For the test case, wf1 and wf2 should have the same hash, wf3 different segment_hashes = np.array([1, 1, 2]) # hash 1 for wf1 and wf2, hash 2 for wf3 # Deduplicate seen_hash_to_index = {} segments = [] unique_segment_indices = [] for i, (hash_val, seg_len) in enumerate(zip(segment_hashes, segment_lengths)): if hash_val not in seen_hash_to_index: seen_hash_to_index[hash_val] = len(segments) segments.append(f"segment_{i}") # placeholder unique_segment_indices.append(seen_hash_to_index[hash_val]) print(f"seen_hash_to_index: {seen_hash_to_index}") print(f"segments: {segments}") print(f"unique_segment_indices: {unique_segment_indices}") # Build unique lengths unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices]) # Wait, this would give [384, 384, 192] which is wrong # Actually we want unique lengths in order of first appearance # unique_lengths should be [384, 192] - the first occurrence of each unique segment # Let me redo this unique_lengths_dict = {} for i, (hash_val, seg_len) in enumerate(zip(segment_hashes, segment_lengths)): if hash_val not in unique_lengths_dict: unique_lengths_dict[hash_val] = seg_len # Now get unique lengths in order of first appearance unique_lengths_ordered = [unique_lengths_dict[hash_val] for hash_val in segment_hashes if hash_val in unique_lengths_dict] # But this might give us duplicates... # Better approach: iterate through and only add if not already added unique_lengths_final = [] seen_in_order = set() for hash_val in segment_hashes: if hash_val not in seen_in_order: unique_lengths_final.append(unique_lengths_dict[hash_val]) seen_in_order.add(hash_val) print(f"unique_lengths_dict: {unique_lengths_dict}") print(f"unique_lengths_final: {unique_lengths_final}") test_dedup() EOF
exact command
cd /qupulse && python3 << 'EOF'
# Let me rewrite the _calc_sampled_segments function more carefully

import numpy as np
from typing import Sequence, Tuple

# Simulated function to understand the flow
def test_dedup():
    # Simulate segment_lengths and waveforms
    segment_lengths = np.array([384, 384, 192])  # wf1, wf2, wf3
    
    # Simulate hashes (in reality these would be computed from the segments)
    # For the test case, wf1 and wf2 should have the same hash, wf3 different
    segment_hashes = np.array([1, 1, 2])  # hash 1 for wf1 and wf2, hash 2 for wf3
    
    # Deduplicate
    seen_hash_to_index = {}
    segments = []
    unique_segment_indices = []
    
    for i, (hash_val, seg_len) in enumerate(zip(segment_hashes, segment_lengths)):
        if hash_val not in seen_hash_to_index:
            seen_hash_to_index[hash_val] = len(segments)
            segments.append(f"segment_{i}")  # placeholder
        unique_segment_indices.append(seen_hash_to_index[hash_val])
    
    print(f"seen_hash_to_index: {seen_hash_to_index}")
    print(f"segments: {segments}")
    print(f"unique_segment_indices: {unique_segment_indices}")
    
    # Build unique lengths
    unique_lengths = np.array([segment_lengths[idx] for idx in unique_segment_indices])
    # Wait, this would give [384, 384, 192] which is wrong
    
    # Actually we want unique lengths in order of first appearance
    # unique_lengths should be [384, 192] - the first occurrence of each unique segment
    
    # Let me redo this
    unique_lengths_dict = {}
    for i, (hash_val, seg_len) in enumerate(zip(segment_hashes, segment_lengths)):
        if hash_val not in unique_lengths_dict:
            unique_lengths_dict[hash_val] = seg_len
    
    # Now get unique lengths in order of first appearance
    unique_lengths_ordered = [unique_lengths_dict[hash_val] for hash_val in segment_hashes if hash_val in unique_lengths_dict]
    # But this might give us duplicates...
    
    # Better approach: iterate through and only add if not already added
    unique_lengths_final = []
    seen_in_order = set()
    for hash_val in segment_hashes:
        if hash_val not in seen_in_order:
            unique_lengths_final.append(unique_lengths_dict[hash_val])
            seen_in_order.add(hash_val)
    
    print(f"unique_lengths_dict: {unique_lengths_dict}")
    print(f"unique_lengths_final: {unique_lengths_final}")

test_dedup()
EOF
00.372s7d00b0fd
commandcd /qupulse && python3 << 'PYEOF' # Read the current file with open('qupulse/_program/tabor.py', 'r') as f: content = f.read() # Define the new function new_func = ''' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]: \"\"\" Returns: (segments, segment_lengths) \"\"\" time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate) if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192): raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times segments = [] seen_hash_to_index = {} # maps segment hash to index in segments list unique_lengths_dict = {} # maps segment hash to its length (first occurrence) for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) assert (len(segment_a) == len(t)) assert (len(segment_b) == len(t)) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash segment_len = segment_lengths[i] if segment_hash not in seen_hash_to_index: seen_hash_to_index[segment_hash] = len(segments) unique_lengths_dict[segment_hash] = segment_len segments.append(segment) # Build unique lengths in order of first appearance unique_lengths = [] seen_in_order = set() for hash_val in [seg._hash for seg in segments]: # iterate through unique segments if hash_val not in seen_in_order: unique_lengths.append(unique_lengths_dict[hash_val]) seen_in_order.add(hash_val) # Wait, this approach won't work because we need to map original indices to unique indices # Let me rethink this... # Actually, we need to return segments and lengths that correspond 1:1 # The lengths should be the lengths of the unique segments in order return segments, np.array(unique_lengths, dtype=np.int64) ''' # Find and replace the function import re # Match the function definition and body pattern = r' def _calc_sampled_segments\(self\) -> Tuple\[Sequence\[TaborSegment\], Sequence\[int\]\]:.*?return segments, unique_lengths' # Actually, let me just replace the specific lines # Let me find the exact location and replace # First, let me just rewrite the whole function section lines = content.split('\n') new_lines = [] i = 0 while i < len(lines): if i > 465 and i < 492 and 'def _calc_sampled_segments' in lines[i]: # Replace from here to the end of the function new_lines.append(lines[i]) # def line i += 1 # Skip until we hit the return statement while i < len(lines) and 'return segments, unique_lengths' not in lines[i]: # Skip lines that are part of the old function if i < len(lines) and (lines[i].startswith(' ') or lines[i].startswith(' ')): i += 1 else: break # Now add the new function body new_func_lines = new_func.strip().split('\n') # Remove the first line (def) since we already added it new_lines.extend(new_func_lines[1:]) # Skip the old return line while i < len(lines) and 'return segments, unique_lengths' not in lines[i]: i += 1 if i < len(lines): i += 1 # skip the return line else: new_lines.append(lines[i]) i += 1 # Write back with open('qupulse/_program/tabor.py', 'w') as f: f.write('\n'.join(new_lines)) print("Replacement done") PYEOF
exact command
cd /qupulse && python3 << 'PYEOF'
# Read the current file
with open('qupulse/_program/tabor.py', 'r') as f:
    content = f.read()

# Define the new function
new_func = '''    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:
        \"\"\"
        Returns:
            (segments, segment_lengths)
        \"\"\"
        time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate)

        if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):
            raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16')

        # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times
        segments = []
        seen_hash_to_index = {}  # maps segment hash to index in segments list
        unique_lengths_dict = {}  # maps segment hash to its length (first occurrence)
        
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            assert (len(segment_a) == len(t))
            assert (len(segment_b) == len(t))
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            segment_len = segment_lengths[i]
            
            if segment_hash not in seen_hash_to_index:
                seen_hash_to_index[segment_hash] = len(segments)
                unique_lengths_dict[segment_hash] = segment_len
                segments.append(segment)
            
        # Build unique lengths in order of first appearance
        unique_lengths = []
        seen_in_order = set()
        for hash_val in [seg._hash for seg in segments]:  # iterate through unique segments
            if hash_val not in seen_in_order:
                unique_lengths.append(unique_lengths_dict[hash_val])
                seen_in_order.add(hash_val)
        
        # Wait, this approach won't work because we need to map original indices to unique indices
        # Let me rethink this...
        
        # Actually, we need to return segments and lengths that correspond 1:1
        # The lengths should be the lengths of the unique segments in order
        
        return segments, np.array(unique_lengths, dtype=np.int64)
'''

# Find and replace the function
import re
# Match the function definition and body
pattern = r'    def _calc_sampled_segments\(self\) -> Tuple\[Sequence\[TaborSegment\], Sequence\[int\]\]:.*?return segments, unique_lengths'

# Actually, let me just replace the specific lines
# Let me find the exact location and replace

# First, let me just rewrite the whole function section
lines = content.split('\n')
new_lines = []

i = 0
while i < len(lines):
    if i > 465 and i < 492 and 'def _calc_sampled_segments' in lines[i]:
        # Replace from here to the end of the function
        new_lines.append(lines[i])  # def line
        i += 1
        # Skip until we hit the return statement
        while i < len(lines) and 'return segments, unique_lengths' not in lines[i]:
            # Skip lines that are part of the old function
            if i < len(lines) and (lines[i].startswith('        ') or lines[i].startswith('            ')):
                i += 1
            else:
                break
        # Now add the new function body
        new_func_lines = new_func.strip().split('\n')
        # Remove the first line (def) since we already added it
        new_lines.extend(new_func_lines[1:])
        # Skip the old return line
        while i < len(lines) and 'return segments, unique_lengths' not in lines[i]:
            i += 1
        if i < len(lines):
            i += 1  # skip the return line
    else:
        new_lines.append(lines[i])
        i += 1

# Write back
with open('qupulse/_program/tabor.py', 'w') as f:
    f.write('\n'.join(new_lines))

print("Replacement done")
PYEOF
00.018s0e32524c
commandcd /qupulse && python3 << 'EOF' with open('qupulse/_program/tabor.py', 'r') as f: content = f.read() # Find the function and replace it old_func_start = content.find(' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:') old_func_end = content.find(' return segments, unique_lengths', old_func_start) if old_func_start == -1 or old_func_end == -1: print("Could not find function boundaries") # Let's debug import re match = re.search(r'def _calc_sampled_segments.*?(?=\n def |\Z)', content, re.DOTALL) if match: print("Found:", match.group()[:500]) else: print("No match") else: # New function new_func = ''' def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]: \"\"\" Returns: (segments, segment_lengths) \"\"\" time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate) if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192): raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times segments = [] seen_hash_to_index = {} # maps segment hash to index in segments list unique_lengths_dict = {} # maps segment hash to its length (first occurrence) for i, waveform in enumerate(self._parsed_program.waveforms): t = time_array[:segment_lengths[i]] marker_time = t[::2] segment_a = self._channel_data(waveform, t, 0) segment_b = self._channel_data(waveform, t, 1) assert (len(segment_a) == len(t)) assert (len(segment_b) == len(t)) marker_a = self._marker_data(waveform, marker_time, 0) marker_b = self._marker_data(waveform, marker_time, 1) segment = TaborSegment.from_sampled(ch_a=segment_a, ch_b=segment_b, marker_a=marker_a, marker_b=marker_b) segment_hash = segment._hash segment_len = segment_lengths[i] if segment_hash not in seen_hash_to_index: seen_hash_to_index[segment_hash] = len(segments) unique_lengths_dict[segment_hash] = segment_len segments.append(segment) # Build unique lengths in order of first appearance among unique segments unique_lengths = [] seen_in_order = set() for segment in segments: h = segment._hash if h not in seen_in_order: unique_lengths.append(unique_lengths_dict[h]) seen_in_order.add(h) return segments, np.array(unique_lengths, dtype=np.int64) ''' # Replace new_content = content[:old_func_start] + new_func + content[old_func_end + len(' return segments, unique_lengths'):] with open('qupulse/_program/tabor.py', 'w') as f: f.write(new_content) print("Replacement done") EOF
exact command
cd /qupulse && python3 << 'EOF'
with open('qupulse/_program/tabor.py', 'r') as f:
    content = f.read()

# Find the function and replace it
old_func_start = content.find('    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:')
old_func_end = content.find('        return segments, unique_lengths', old_func_start)

if old_func_start == -1 or old_func_end == -1:
    print("Could not find function boundaries")
    # Let's debug
    import re
    match = re.search(r'def _calc_sampled_segments.*?(?=\n    def |\Z)', content, re.DOTALL)
    if match:
        print("Found:", match.group()[:500])
    else:
        print("No match")
else:
    # New function
    new_func = '''    def _calc_sampled_segments(self) -> Tuple[Sequence[TaborSegment], Sequence[int]]:
        \"\"\"
        Returns:
            (segments, segment_lengths)
        \"\"\"
        time_array, segment_lengths = get_sample_times(self._parsed_program.waveforms, self._sample_rate)

        if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):
            raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16')

        # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times
        segments = []
        seen_hash_to_index = {}  # maps segment hash to index in segments list
        unique_lengths_dict = {}  # maps segment hash to its length (first occurrence)
        
        for i, waveform in enumerate(self._parsed_program.waveforms):
            t = time_array[:segment_lengths[i]]
            marker_time = t[::2]
            segment_a = self._channel_data(waveform, t, 0)
            segment_b = self._channel_data(waveform, t, 1)
            assert (len(segment_a) == len(t))
            assert (len(segment_b) == len(t))
            marker_a = self._marker_data(waveform, marker_time, 0)
            marker_b = self._marker_data(waveform, marker_time, 1)
            segment = TaborSegment.from_sampled(ch_a=segment_a,
                                               ch_b=segment_b,
                                               marker_a=marker_a,
                                               marker_b=marker_b)
            segment_hash = segment._hash
            segment_len = segment_lengths[i]
            
            if segment_hash not in seen_hash_to_index:
                seen_hash_to_index[segment_hash] = len(segments)
                unique_lengths_dict[segment_hash] = segment_len
                segments.append(segment)
        
        # Build unique lengths in order of first appearance among unique segments
        unique_lengths = []
        seen_in_order = set()
        for segment in segments:
            h = segment._hash
            if h not in seen_in_order:
                unique_lengths.append(unique_lengths_dict[h])
                seen_in_order.add(h)
        
        return segments, np.array(unique_lengths, dtype=np.int64)
'''
    
    # Replace
    new_content = content[:old_func_start] + new_func + content[old_func_end + len('        return segments, unique_lengths'):]
    
    with open('qupulse/_program/tabor.py', 'w') as f:
        f.write(new_content)
    
    print("Replacement done")
EOF
00.014s1a9437a6
commandcd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1
exact command
cd /qupulse && python3 -m pytest tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication -xvs 2>&1
01.079s7555971a
commandcd /qupulse && python3 -m pytest tests/_program/tabor_tests.py -xvs 2>&1 | head -100
exact command
cd /qupulse && python3 -m pytest tests/_program/tabor_tests.py -xvs 2>&1 | head -100
01.192s56e4dde3
commandcd /qupulse && python3 -m pytest tests/hardware/tabor_dummy_based_tests.py -xvs 2>&1 | head -80
exact command
cd /qupulse && python3 -m pytest tests/hardware/tabor_dummy_based_tests.py -xvs 2>&1 | head -80
01.647se65de3b8
commandcd /qupulse && python3 -m pytest tests/hardware/feature_awg/tabor_tests.py -xvs 2>&1 | head -80
exact command
cd /qupulse && python3 -m pytest tests/hardware/feature_awg/tabor_tests.py -xvs 2>&1 | head -80
00.196s427969ae
commandcd /qupulse && find tests -name "*tabor*" -type f
exact command
cd /qupulse && find tests -name "*tabor*" -type f
00.004s58fc8272
KindCommandExitDurationDigest
commandcd /qupulse && python3 -m pytest tests/hardware/feature_awg/tabor_new_driver_tests.py -xvs 2>&1 | head -80
exact command
cd /qupulse && python3 -m pytest tests/hardware/feature_awg/tabor_new_driver_tests.py -xvs 2>&1 | head -80
01.057sc50c56dd
commandcd /qupulse && python3 -m pytest tests/hardware/tabor_simulator_based_tests.py -xvs 2>&1 | head -80
exact command
cd /qupulse && python3 -m pytest tests/hardware/tabor_simulator_based_tests.py -xvs 2>&1 | head -80
01.043s45e09d1e
commandcd /qupulse && sed -n '466,520p' qupulse/_program/tabor.py
exact command
cd /qupulse && sed -n '466,520p' qupulse/_program/tabor.py
00.004s7e653f47
diffcapture patch
exact command
compute patch in executor staging agent1-8ebf829f459d4af88cefd1122b5f2e7b: /opt/homebrew/Cellar/git/2.53.0/bin/git -c core.hooksPath=/dev/null -c core.attributesFile=/dev/null -c diff.external= -c core.quotePath=false add -A && /opt/homebrew/Cellar/git/2.53.0/bin/git -c core.hooksPath=/dev/null -c core.attributesFile=/dev/null -c diff.external= -c core.quotePath=false diff --cached --binary --no-ext-diff --no-textconv --no-renames c8ae55c0565698e465e2e787c87dffeaf5c08851
00.046sfbc08a5d91ee
Finish summary
Fixed the redundant waveform upload issue in TaborProgram by adding hash-based deduplication in the `_calc_sampled_segments` function. The fix modifies `qupulse/_program/tabor.py` to check for unique segment hashes when creating sampled segments. When multiple waveforms produce the same segment data (same hash), only one copy is included in the output, preventing redundant uploads. Key changes: 1. Added `seen_hash_to_index` dictionary to track unique segment hashes 2. Added `unique_lengths_dict` to store the length of each unique segment (first occurrence) 3. Deduplicate segments before returning, keeping only unique ones 4. Unique lengths are collected in order of first appearance The test `test_calc_sampled_segments_deduplication` now passes (was failing with `AssertionError: 3 != 2`), and all 45 tabor tests plus 23 hardware dummy-based tests pass.
Worker outcome
finished
  • Target tests pass: yes
  • Full suite passes: yes
  • Files changed: qupulse/_program/tabor.py
  • Ran tests: yes

Witness branch w1

KindCommandExitDurationDigest
applyapply patch f2f19d468da2
exact command
git update-index -q --refresh; git apply -v --3way --recount --ignore-space-change --whitespace=nowarn /opt/receipts-f2882e8e53304df080da0df64c921d1b/incoming/f2f19d468da2a9c5f551ccd0c28cf396b6b82ace72ed61d1236e3e6bfb7a1435.diff
00.011s7595d4ac9438
verificationpytest (witness) tests/_program/tabor_tests.py tests/pulses/sequencing_dummies.py
exact command
/opt/receipts-ab18a29aee94436f860e7c17988f56e3/bin/busybox mkdir -p /opt/receipts/reports && python -I /opt/receipts-ab18a29aee94436f860e7c17988f56e3/receipts_pytest.py --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning tests/_program/tabor_tests.py tests/pulses/sequencing_dummies.py -o junit_family=xunit1 -p no:cacheprovider -rA --continue-on-collection-errors --junitxml=/opt/receipts/reports/w1-2.xml
03.080s7595d4ac9438

Gate predicate checklist

PredicateNameStatusEvidence
R1_fail_to_passFailing specification tests now passPASStarget tests passed: tests/_program/tabor_tests.py::TaborProgramTests::test_calc_sampled_segments_deduplication
R2_pass_to_passPreviously passing tests keptPASS44 baseline-passing tests still pass
R3_no_shrinkNo removed tests or new skipsPASSall 48 baseline tests collected; skips unchanged (3)
R4_patch_scopePatch scopePASSpatch touches 1 file(s), all in scope
R5_provenanceWitness chain and patch digestPASSagent chain f663ec11 -> 7e653f47 unbroken over 39 receipt(s); witness chain f663ec11 -> f1984d73 unbroken over 2 receipt(s); applied digest matches
R6_claim_auditAgent claim audit (advisory)FAILclaimed green but never ran the tests on this branch

What it said

Finish summary
Fixed the redundant waveform upload issue in TaborProgram by adding hash-based deduplication in the `_calc_sampled_segments` function. The fix modifies `qupulse/_program/tabor.py` to check for unique segment hashes when creating sampled segments. When multiple waveforms produce the same segment data (same hash), only one copy is included in the output, preventing redundant uploads. Key changes: 1. Added `seen_hash_to_index` dictionary to track unique segment hashes 2. Added `unique_lengths_dict` to store the length of each unique segment (first occurrence) 3. Deduplicate segments before returning, keeping only unique ones 4. Unique lengths are collected in order of first appearance The test `test_calc_sampled_segments_deduplication` now passes (was failing with `AssertionError: 3 != 2`), and all 45 tabor tests plus 23 hardware dummy-based tests pass.
Worker outcome
finished
  • Target tests pass: yes
  • Full suite passes: yes
  • Files changed: qupulse/_program/tabor.py
  • Ran tests: yes

What the record shows

unsupported: claimed green but never ran the tests on this branch

SWE-rebench's official grader: resolved

Agrees with the gate

Shipped patch

diff --git a/qupulse/_program/tabor.py b/qupulse/_program/tabor.pyindex b92c76f..690cfca 100644--- a/qupulse/_program/tabor.py+++ b/qupulse/_program/tabor.py@@ -473,7 +473,11 @@ class TaborProgram(ProgramEntry):         if np.any(segment_lengths % 16 > 0) or np.any(segment_lengths < 192):             raise TaborException('At least one waveform has a length that is smaller 192 or not a multiple of 16') +        # Deduplicate segments by their hash to avoid uploading identical waveforms multiple times         segments = []+        seen_hash_to_index = {}  # maps segment hash to index in segments list+        unique_lengths_dict = {}  # maps segment hash to its length (first occurrence)+                 for i, waveform in enumerate(self._parsed_program.waveforms):             t = time_array[:segment_lengths[i]]             marker_time = t[::2]@@ -484,11 +488,28 @@ class TaborProgram(ProgramEntry):             marker_a = self._marker_data(waveform, marker_time, 0)             marker_b = self._marker_data(waveform, marker_time, 1)             segment = TaborSegment.from_sampled(ch_a=segment_a,-                                   ch_b=segment_b,-                                   marker_a=marker_a,-                                   marker_b=marker_b)-            segments.append(segment)-        return segments, segment_lengths+                                               ch_b=segment_b,+                                               marker_a=marker_a,+                                               marker_b=marker_b)+            segment_hash = segment._hash+            segment_len = segment_lengths[i]+            +            if segment_hash not in seen_hash_to_index:+                seen_hash_to_index[segment_hash] = len(segments)+                unique_lengths_dict[segment_hash] = segment_len+                segments.append(segment)+        +        # Build unique lengths in order of first appearance among unique segments+        unique_lengths = []+        seen_in_order = set()+        for segment in segments:+            h = segment._hash+            if h not in seen_in_order:+                unique_lengths.append(unique_lengths_dict[h])+                seen_in_order.add(h)+        +        return segments, np.array(unique_lengths, dtype=np.int64)+      def setup_single_sequence_mode(self) -> None:         assert self.program.depth() == 1

Model and costs

Model
nvidia/Nemotron-3_5-Lightning thinking off · temperature 1.0 · top_p 0.95
Tokens
2,295,123 tokens
Model cost
$0.14
Sandbox time
2 min 28 s
Sandbox cost
Token Factory reported cost: 0.313 (unit not published)
Full environment disclosure
{
  "executor_kind": "tokenfactory",
  "lock_sha256": "5e129374525522fc992cc5e65387edc3ee6dfd4dbf771d9033bf81c402921c54",
  "model": {
    "base_url": "https://api.tokenfactory.nebius.com/v1/",
    "client": "TokenFactoryClient",
    "max_tokens": null,
    "model": "nvidia/Nemotron-3_5-Lightning",
    "temperature": 1.0,
    "thinking": false,
    "top_p": 0.95
  },
  "pytest_config_digests": {
    "pyproject.toml": "8bafba0d879c602f72308029fd44627811d72176f71bd58f8525a9d5cf4991c2",
    "setup.cfg": "ef3abc0ecdb0eb16a614d73eacb9b71d77d77099f178a07e6a7636d84c543818"
  },
  "receipts_version": "0.0.1",
  "test_digests": {
    "tests/_program/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "tests/_program/loop_tests.py": "63b6a4975f4da98af78f49a4d68724c543dead000bb55ffa042dc009bbf93d91",
    "tests/_program/seqc_tests.py": "8bff8583b641ca73c302c11b45731cd9d6d0b232e1670d4ef3075474b063087a",
    "tests/_program/tabor_tests.py": "3c989ef119193990115f2d6ee16af397930da8a7031dac24660074a3fad5c5d8",
    "tests/_program/transformation_tests.py": "886604bc276e19538fb0f58c8a837202c891f130fd15b33ca818d3a6e4652f38",
    "tests/_program/waveforms_tests.py": "441f90350e4f1630fb739dbb4458f10f42e253152e5492aa962a58726bae08e3"
  }
}

The bundle

Recorded JSON and patches. In these copies the local checkout path is removed from file paths, and the home directory is shown as ~.