Skip to content
Snippets Groups Projects
Commit 677a5c3a authored by whooie's avatar whooie
Browse files

rearrange arg order for Sequence.*c_data; add a __iadd__ method for Sequence

parent 00cc796e
No related branches found
No related tags found
No related merge requests found
...@@ -433,8 +433,8 @@ class Sequence: ...@@ -433,8 +433,8 @@ class Sequence:
return self return self
@staticmethod @staticmethod
def from_digital_data(T: list[float], S: list[int], board: int, def from_digital_data(board: int, connector: int, mask: int,
connector: int, mask: int) -> Sequence: T: list[float], S: list[int]) -> Sequence:
""" """
Construct a Sequence of digital events on `board`, `connector` with Construct a Sequence of digital events on `board`, `connector` with
`mask` from lists of times and states. `mask` is applied globally to all `mask` from lists of times and states. `mask` is applied globally to all
...@@ -464,8 +464,8 @@ class Sequence: ...@@ -464,8 +464,8 @@ class Sequence:
]) ])
@staticmethod @staticmethod
def from_digital1_data(T: list[float], S: list[int], board: int, def from_digital1_data(board: int, connector: int, channel: int,
connector: int, channel: int) -> Sequence: T: list[float], S: list[int]) -> Sequence:
""" """
Construct a Sequence of digital events on `board`, `connector`, Construct a Sequence of digital events on `board`, `connector`,
`channel` from lists of times and states. `channel` from lists of times and states.
...@@ -490,8 +490,8 @@ class Sequence: ...@@ -490,8 +490,8 @@ class Sequence:
]) ])
@staticmethod @staticmethod
def from_digitalc_data(T: list[float], S: list[int], def from_digitalc_data(conn: DigitalConnection,
conn: DigitalConnection, with_delay: bool=True) -> Sequence: T: list[float], S: list[int], with_delay: bool=True) -> Sequence:
""" """
Construct a Sequence of digital events on `conn` from lists of times and Construct a Sequence of digital events on `conn` from lists of times and
states, optionally using delay information from `conn`. states, optionally using delay information from `conn`.
...@@ -514,8 +514,8 @@ class Sequence: ...@@ -514,8 +514,8 @@ class Sequence:
) )
@staticmethod @staticmethod
def from_analog_data(T: list[float], V: list[float], board: int, def from_analog_data(board: int, channel: int,
channel: int) -> Sequence: T: list[float], V: list[float]) -> Sequence:
""" """
Construct a Sequence of analog events on `board`, `channel` from lists Construct a Sequence of analog events on `board`, `channel` from lists
of times and voltages. of times and voltages.
...@@ -541,8 +541,8 @@ class Sequence: ...@@ -541,8 +541,8 @@ class Sequence:
]) ])
@staticmethod @staticmethod
def from_analogc_data(T: list[float], V: list[float], def from_analogc_data(conn: AnalogConnection,
conn: AnalogConnection, with_delay: bool=True) -> Sequence: T: list[float], V: list[float], with_delay: bool=True) -> Sequence:
""" """
Construct a Sequence of analog events on `conn` from lists of times and Construct a Sequence of analog events on `conn` from lists of times and
voltages, optionally using delay information from `conn`. voltages, optionally using delay information from `conn`.
...@@ -1100,6 +1100,17 @@ class Sequence: ...@@ -1100,6 +1100,17 @@ class Sequence:
else: else:
raise NotImplemented raise NotImplemented
def __iadd__(self, other):
if isinstance(other, Sequence):
self.events.append(other.events)
elif isinstance(other, list):
assert all(
isinstance(e, Event) and e.time is not None for e in other), \
"__iadd__: all Events must have times"
self.events += other
else:
raise NotImplemented
def join(self, other: Sequence): def join(self, other: Sequence):
assert isinstance(other, Sequence), "join: can only join Sequences" assert isinstance(other, Sequence), "join: can only join Sequences"
return self + other return self + other
......
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