Skip to content
Snippets Groups Projects
Commit 145d725b authored by Mikael Henriksson's avatar Mikael Henriksson :runner:
Browse files

resources.py: add contains method for ProcessCollection

parent a314aa83
No related branches found
No related tags found
1 merge request!435Contains
Pipeline #103761 passed
......@@ -502,6 +502,17 @@ class ProcessCollection:
else:
self.collection.remove(process)
def __contains__(self, process: Process) -> bool:
"""
Test if a process is part of this ProcessCollection
Parameters
----------
process : :class:`~b_asic.process.Process`
The process to test.
"""
return process in self.collection
def plot(
self,
ax: Optional[Axes] = None,
......
......@@ -38,6 +38,15 @@ class TestProcessCollectionPlainMemoryVariable:
)
assert len(collection_split) == 3
def test_contains(self):
collection = ProcessCollection([], schedule_time=10, cyclic=True)
m1 = PlainMemoryVariable(0, 0, {0: 3})
assert m1 not in collection
collection.add_process(m1)
assert m1 in collection
collection.remove_process(m1)
assert m1 not in collection
def test_split_sequence_raises(self, simple_collection: ProcessCollection):
with pytest.raises(KeyError, match="processes in `sequence` must be"):
simple_collection.split_ports_sequentially(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment