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
feab0166
Commit
feab0166
authored
4 years ago
by
Jacob Wahlman
Browse files
Options
Downloads
Patches
Plain Diff
added test files and utils module
parent
a1eeb37b
No related branches found
Branches containing commit
No related tags found
2 merge requests
!33
Resolve "Load/Save SFG to file"
,
!27
Resolve "Load/Save SFG to file"
Pipeline
#13728
failed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/__init__.py
+1
-0
1 addition, 0 deletions
b_asic/__init__.py
b_asic/utils.py
+31
-0
31 additions, 0 deletions
b_asic/utils.py
test/test_load_save_structure.py
+41
-0
41 additions, 0 deletions
test/test_load_save_structure.py
with
73 additions
and
0 deletions
b_asic/__init__.py
+
1
−
0
View file @
feab0166
...
...
@@ -12,3 +12,4 @@ from b_asic.signal_flow_graph import *
from
b_asic.signal
import
*
from
b_asic.simulation
import
*
from
b_asic.special_operations
import
*
from
b_asic.utils
import
*
\ No newline at end of file
This diff is collapsed.
Click to expand it.
b_asic/utils.py
0 → 100644
+
31
−
0
View file @
feab0166
"""
@package docstring
B-ASIC Utils Module.
This module contains functions that are used as utilities by other modules or by the user.
"""
from
typing
import
Optional
import
pickle
from
b_asic
import
AbstractOperation
def
save_structure
(
struct
:
AbstractOperation
,
path
:
Optional
[
str
]
=
None
)
->
str
:
"""
Saves the structure to a specific path using the pickle module.
Returns the path to the struct if save succeeds.
Arguments:
struct: The structure to save.
Keyword Arguments:
path: The path to which the structure will be saved.
"""
pass
def
load_structure
(
path
:
str
)
->
AbstractOperation
:
"""
Saves the structure to a specific path using the pickle module.
Returns the struct that was loaded from the path.
Keyword Arguments:
path: The path to which the structure will be loaded from.
"""
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/test_load_save_structure.py
0 → 100644
+
41
−
0
View file @
feab0166
from
os.path
import
isfile
import
pytest
from
b_asic
import
SFG
,
Output
,
load_structure
,
save_structure
class
TestSaveStructures
:
def
test_save_sfg
(
self
,
large_operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
large_operation_tree
)])
path
=
save_structure
(
sfg
)
assert
path
is
not
None
assert
isfile
(
path
)
def
test_load_sfg
(
self
,
large_operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
large_operation_tree
)])
path
=
save_structure
(
sfg
)
_sfg
=
load_structure
(
path
)
assert
isinstance
(
_sfg
,
SFG
)
assert
sfg
.
components
==
_sfg
.
components
def
test_save_sfg_custom_path
(
self
,
large_operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
large_operation_tree
)])
path
=
save_structure
(
sfg
,
path
=
"
structures/test
"
)
assert
path
is
not
None
assert
isfile
(
path
)
def
test_load_sfg_custom_path
(
self
,
large_operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
large_operation_tree
)])
path
=
save_structure
(
sfg
,
path
=
"
structures/test
"
)
_sfg
=
load_structure
(
path
)
assert
isinstance
(
_sfg
,
SFG
)
assert
sfg
.
components
==
_sfg
.
components
This diff is collapsed.
Click to expand it.
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