Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pulse_lib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
QuTech QDLabs
pulse_lib
Commits
19ef9b2b
Commit
19ef9b2b
authored
1 year ago
by
Sander de Snoo
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
d7cfac8a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pulse_lib/segments/data_classes/data_generic.py
+14
-13
14 additions, 13 deletions
pulse_lib/segments/data_classes/data_generic.py
with
14 additions
and
13 deletions
pulse_lib/segments/data_classes/data_generic.py
+
14
−
13
View file @
19ef9b2b
"""
Generic data class where all others should be derived from.
"""
import
copy
import
uuid
import
logging
from
abc
import
ABC
,
abstractmethod
import
numpy
as
np
from
pulse_lib.segments.data_classes.lru_cache
import
LruCache
import
copy
logger
=
logging
.
getLogger
(
__name__
)
class
parent_data
(
ABC
):
"""
Abstract class hosting some functions that take care of rendering and caching of data and
...
...
@@ -49,7 +50,7 @@ class parent_data(ABC):
raise
NotImplementedError
()
@abstractmethod
def
reset_time
(
self
,
time
=
None
):
def
reset_time
(
self
,
time
=
None
):
raise
NotImplementedError
()
@abstractmethod
...
...
@@ -82,7 +83,7 @@ class parent_data(ABC):
@abstractmethod
def
_render
(
self
,
sample_rate
,
ref_channel_states
,
LO
):
'''
make a full rendering of the waveform at a predetermined sample rate.
This should be defined in the child of this class.
make a full rendering of the waveform at a predetermined sample rate.
'''
raise
NotImplementedError
()
...
...
@@ -99,15 +100,15 @@ class parent_data(ABC):
data
=
cache_entry
.
data
if
(
data
is
None
or
data
[
'
sample_rate
'
]
!=
sample_rate
or
data
[
'
ref_states
'
]
!=
ref_channel_states
or
data
[
'
LO
'
]
!=
LO
):
or
data
[
'
sample_rate
'
]
!=
sample_rate
or
data
[
'
ref_states
'
]
!=
ref_channel_states
or
data
[
'
LO
'
]
!=
LO
):
waveform
=
self
.
_render
(
sample_rate
,
ref_channel_states
,
LO
)
cache_entry
.
data
=
{
'
sample_rate
'
:
sample_rate
,
'
waveform
'
:
waveform
,
'
ref_states
'
:
ref_channel_states
,
'
LO
'
:
LO
'
sample_rate
'
:
sample_rate
,
'
waveform
'
:
waveform
,
'
ref_states
'
:
ref_channel_states
,
'
LO
'
:
LO
}
else
:
waveform
=
data
[
'
waveform
'
]
...
...
@@ -140,7 +141,7 @@ def map_index(index, shape):
# TODO investigate numpy solution: np.broadcast_to using the broader shape.
result
=
list
(
index
)
result
=
result
[
-
len
(
shape
):]
for
i
,
n
in
enumerate
(
shape
):
for
i
,
n
in
enumerate
(
shape
):
if
n
==
1
:
result
[
i
]
=
0
return
tuple
(
result
)
...
...
@@ -148,7 +149,7 @@ def map_index(index, shape):
class
data_container
(
np
.
ndarray
):
def
__new__
(
subtype
,
input_type
=
None
,
shape
=
(
1
,)):
def
__new__
(
subtype
,
input_type
=
None
,
shape
=
(
1
,)):
obj
=
super
(
data_container
,
subtype
).
__new__
(
subtype
,
shape
,
object
)
if
input_type
is
not
None
:
...
...
@@ -186,7 +187,7 @@ class data_container(np.ndarray):
return
times
def
__copy__
(
self
):
cpy
=
data_container
(
shape
=
self
.
shape
)
cpy
=
data_container
(
shape
=
self
.
shape
)
for
i
in
range
(
self
.
size
):
cpy
.
flat
[
i
]
=
copy
.
copy
(
self
.
flat
[
i
])
...
...
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