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
Merge requests
!280
Add utils module and functions
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add utils module and functions
utils1
into
master
Overview
0
Commits
1
Pipelines
1
Changes
4
Merged
Oscar Gustafsson
requested to merge
utils1
into
master
1 year ago
Overview
0
Commits
1
Pipelines
1
Changes
4
Expand
Related to
#194 (closed)
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d86cbdb8
1 commit,
1 year ago
4 files
+
77
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
b_asic/utils.py
0 → 100644
+
47
−
0
Options
"""
B-ASIC Utils.
"""
from
typing
import
List
,
Sequence
from
b_asic.types
import
Num
def
interleave
(
*
args
)
->
List
[
Num
]:
"""
Interleave a number of arrays.
For the input ``interleave([1, 2], [3, 4])``, return ``[1, 2, 3, 4]``.
Parameters
----------
*args : a number of arrays
Arrays to interleave. Must be of the same length.
Returns
-------
"""
return
[
val
for
tup
in
zip
(
*
args
)
for
val
in
tup
]
def
downsample
(
a
:
Sequence
[
Num
],
factor
:
int
,
phase
:
int
=
0
)
->
List
[
Num
]:
"""
Downsample a sequence with an integer factor.
Keeps every *factor* value, starting with *phase*.
Parameters
----------
a : array
The array to downsample.
factor : int
The factor to downsample with.
phase : int, default: 0
The phase of the downsampling.
Returns
-------
"""
return
a
[
phase
::
factor
]
Loading