Skip to content
Snippets Groups Projects
Commit c5f4ac3c authored by Sander Snoo's avatar Sander Snoo
Browse files

Fixed segment slicing

parent 3948166c
No related branches found
No related tags found
No related merge requests found
"""
File containing the parent class where all segment objects are derived from.
"""
import copy
import numpy as np
import matplotlib.pyplot as plt
......@@ -10,8 +11,7 @@ from pulse_lib.segments.data_classes.data_generic import data_container
from pulse_lib.segments.utility.looping import loop_obj
from pulse_lib.segments.utility.setpoint_mgr import setpoint_mgr
from pulse_lib.segments.data_classes.data_generic import map_index
import copy
from pulse_lib.segments.utility.data_handling_functions import update_dimension
class segment_base():
......@@ -168,6 +168,8 @@ class segment_base():
item.data = data_item
if self._data_hvi_variable is not None:
if self._data_hvi_variable is not self.data:
# assert segment HVI variables has right shape.
item._data_hvi_variable.data = update_dimension(self._data_hvi_variable.data, self.shape)
item._data_hvi_variable = item._data_hvi_variable[key[0]]
else:
item._data_hvi_variable = item.data
......@@ -214,6 +216,8 @@ class segment_base():
Args:
loop_obj (loop_obj) : loop object with certain dimension to add.
'''
if not isinstance(loop_obj, float):
raise Exception(f'update_dim failed. Reload pulselib!')
return self.data_tmp
def add_HVI_marker(self, marker_name, t_off = 0):
......
from pulse_lib.tests.configurations.test_configuration import context
import pulse_lib.segments.utility.looping as lp
def test():
pulse = context.init_pulselib(n_gates=2)
n_pulses = lp.array([1,2,4,9], axis=0, name='n_pulses')
s = pulse.mk_segment()
context.segment = s
s.P1.update_dim(n_pulses)
for i,n in enumerate(n_pulses):
p1 = s.P1[i]
for _ in range(int(n)):
p1.add_ramp_ss(0, 100, -80, 80)
p1.reset_time()
s.P2.add_block(0, 100, 60)
for i in range(len(n_pulses)):
context.plot_segments([s], index=[i])
sequence = pulse.mk_sequence([s])
context.add_hw_schedule(sequence)
for n in sequence.n_pulses.values:
sequence.n_pulses(n)
context.plot_awgs(sequence, ylim=(-0.100,0.100))
return None
if __name__ == '__main__':
ds = test()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment