Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
d73a3b90
Commit
d73a3b90
authored
2 years ago
by
Mikael Henriksson
Browse files
Options
Downloads
Patches
Plain Diff
resources.py: add add_process and remove_process methods to ProcessCollection
parent
3f26530c
Branches
Branches containing commit
No related tags found
1 merge request
!354
resources.py: add add_process and remove_process methods to ProcessCollection
Pipeline
#96741
passed
1 year ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/resources.py
+20
-2
20 additions, 2 deletions
b_asic/resources.py
test/test_resources.py
+15
-2
15 additions, 2 deletions
test/test_resources.py
with
35 additions
and
4 deletions
b_asic/resources.py
+
20
−
2
View file @
d73a3b90
...
@@ -443,7 +443,7 @@ class ProcessCollection:
...
@@ -443,7 +443,7 @@ class ProcessCollection:
return
self
.
_schedule_time
return
self
.
_schedule_time
def
__len__
(
self
):
def
__len__
(
self
):
return
len
(
self
.
_
collection
)
return
len
(
self
.
collection
)
def
add_process
(
self
,
process
:
Process
):
def
add_process
(
self
,
process
:
Process
):
"""
"""
...
@@ -454,7 +454,25 @@ class ProcessCollection:
...
@@ -454,7 +454,25 @@ class ProcessCollection:
process : Process
process : Process
The process object to be added to the collection.
The process object to be added to the collection.
"""
"""
self
.
_collection
.
add
(
process
)
self
.
collection
.
add
(
process
)
def
remove_process
(
self
,
process
:
Process
):
"""
Remove a processes from this process collection.
Raises KeyError if the process is not in this collection.
Parameters
----------
process : Process
The processes object to remove from this collection
"""
if
process
not
in
self
.
collection
:
raise
KeyError
(
f
"
Can
'
t remove process:
'
{
process
}
'
, as it is not in collection.
"
)
else
:
self
.
collection
.
remove
(
process
)
def
plot
(
def
plot
(
self
,
self
,
...
...
This diff is collapsed.
Click to expand it.
test/test_resources.py
+
15
−
2
View file @
d73a3b90
...
@@ -37,8 +37,8 @@ class TestProcessCollectionPlainMemoryVariable:
...
@@ -37,8 +37,8 @@ class TestProcessCollectionPlainMemoryVariable:
fig
,
ax
=
plt
.
subplots
(
1
,
2
)
fig
,
ax
=
plt
.
subplots
(
1
,
2
)
assignment
=
simple_collection
.
left_edge_cell_assignment
()
assignment
=
simple_collection
.
left_edge_cell_assignment
()
for
cell
in
assignment
:
for
cell
in
assignment
:
assignment
[
cell
].
plot
(
ax
=
ax
[
1
],
row
=
cell
)
assignment
[
cell
].
plot
(
ax
=
ax
[
1
],
row
=
cell
)
# type: ignore
simple_collection
.
plot
(
ax
[
0
])
simple_collection
.
plot
(
ax
[
0
])
# type:ignore
return
fig
return
fig
def
test_cell_assignment_matrix_transposer
(
self
):
def
test_cell_assignment_matrix_transposer
(
self
):
...
@@ -132,3 +132,16 @@ class TestProcessCollectionPlainMemoryVariable:
...
@@ -132,3 +132,16 @@ class TestProcessCollectionPlainMemoryVariable:
def
test_show
(
self
,
simple_collection
:
ProcessCollection
):
def
test_show
(
self
,
simple_collection
:
ProcessCollection
):
simple_collection
.
show
()
simple_collection
.
show
()
def
test_add_remove_process
(
self
,
simple_collection
:
ProcessCollection
):
new_proc
=
PlainMemoryVariable
(
1
,
0
,
{
0
:
3
})
assert
len
(
simple_collection
)
==
7
assert
new_proc
not
in
simple_collection
simple_collection
.
add_process
(
new_proc
)
assert
len
(
simple_collection
)
==
8
assert
new_proc
in
simple_collection
simple_collection
.
remove_process
(
new_proc
)
assert
len
(
simple_collection
)
==
7
assert
new_proc
not
in
simple_collection
This diff is collapsed.
Click to expand it.
Mikael Henriksson
@mikhe33
mentioned in issue
#241
·
1 year ago
mentioned in issue
#241
mentioned in issue #241
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment