Skip to content

Commit

Permalink
feat: Add sequences concatenation alias
Browse files Browse the repository at this point in the history
Pure syntactic sugar
  • Loading branch information
alecandido committed Sep 3, 2024
1 parent 408ae3b commit 571faec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/qibolab/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from collections import UserList
from collections.abc import Callable, Iterable
from copy import deepcopy
from typing import Any, Union

from pydantic import TypeAdapter
Expand Down Expand Up @@ -104,6 +105,25 @@ def concatenate(self, other: "PulseSequence") -> None:
_synchronize(self, other.channels)
self.extend(other)

def __ior__(self, other: "PulseSequence") -> "PulseSequence":
"""Juxtapose two sequences.
Alias to :meth:`concatenate`.
"""
self.concatenate(other)
return self

def __or__(self, other: "PulseSequence") -> "PulseSequence":
"""Juxtapose two sequences.
A copy is made, and no input is altered.
Other than that, it is based on :meth:`concatenate`.
"""
copy = deepcopy(self)
copy |= other
return copy

def align(self, channels: list[ChannelId]) -> Align:
"""Introduce align commands to the sequence."""
align = Align()
Expand Down

0 comments on commit 571faec

Please sign in to comment.