Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pykat
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
finesse
pykat
Commits
dc68b69a
Commit
dc68b69a
authored
Mar 28, 2018
by
Daniel Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing parameter reference issue for detectors when deepcopying
parent
338d1358
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
pykat/detectors.py
pykat/detectors.py
+29
-7
pykat/param.py
pykat/param.py
+3
-0
No files found.
pykat/detectors.py
View file @
dc68b69a
...
...
@@ -102,6 +102,22 @@ class BaseDetector(object) :
else
:
raise
pkex
.
BasePyKatException
(
"Nodes should be a list or tuple of node names or a singular node name as a string."
)
# def __deepcopy__(self, memo):
# """
# When deep copying a kat object we need to take into account
# the instance specific properties.
# """
#
# # Here we create a copy of this object based of the base class
# # of this one, otherwise we're making a copy of a copy of a copy...
# result = self.__class__.__new__(self.__class__.__base__)
# result._unfreeze()
# memo[id(self)] = result
# result.__dict__ = copy.deepcopy(self.__dict__, memo)
#
# result._freeze()
# return result
def
__deepcopy__
(
self
,
memo
):
"""
When deep copying a kat object we need to take into account
...
...
@@ -111,11 +127,11 @@ class BaseDetector(object) :
# Here we create a copy of this object based of the base class
# of this one, otherwise we're making a copy of a copy of a copy...
result
=
self
.
__class__
.
__new__
(
self
.
__class__
.
__base__
)
result
.
_unfreeze
()
memo
[
id
(
self
)]
=
result
result
.
__dict__
=
copy
.
deepcopy
(
self
.
__dict__
,
memo
)
result
.
_freeze
()
for
_
in
result
.
_params
:
_
.
_updateOwner
(
result
)
return
result
def
_register_param
(
self
,
param
):
...
...
@@ -586,6 +602,8 @@ class pd(Detector1):
"""
When deep copying a kat object we need to take into account
the instance specific properties.
PD code needs to override this as it needs to call set_demod_attrs.
"""
# Here we create a copy of this object based of the base class
...
...
@@ -593,8 +611,12 @@ class pd(Detector1):
result
=
self
.
__class__
.
__new__
(
self
.
__class__
.
__base__
)
result
.
__dict__
=
copy
.
deepcopy
(
self
.
__dict__
,
memo
)
# Need to update f/p attrs
result
.
__set_demod_attrs
()
for
_
in
result
.
_params
:
_
.
_updateOwner
(
result
)
return
result
def
_get_fphi_str
(
self
):
...
...
@@ -661,15 +683,15 @@ class pd(Detector1):
self
.
__phase4
=
Param
(
"phase4"
,
self
,
None
)
self
.
__phase5
=
Param
(
"phase5"
,
self
,
None
)
fs
=
[
self
.
__f1
,
self
.
__f2
,
self
.
__f3
,
self
.
__f4
,
self
.
__f5
]
ps
=
[
self
.
__phase1
,
self
.
__phase2
,
self
.
__phase3
,
self
.
__phase4
,
self
.
__phase5
]
self
.
__
fs
=
[
self
.
__f1
,
self
.
__f2
,
self
.
__f3
,
self
.
__f4
,
self
.
__f5
]
self
.
__
ps
=
[
self
.
__phase1
,
self
.
__phase2
,
self
.
__phase3
,
self
.
__phase4
,
self
.
__phase5
]
for
i
in
range
(
num_demods
):
f
=
'f{0}'
.
format
(
i
+
1
)
#print("i {0} fs {1} f {2} keys {3}".format(i,len(fs),f, kwargs.keys()))
if
f
in
kwargs
:
fs
[
i
].
value
=
kwargs
[
f
]
self
.
__
fs
[
i
].
value
=
kwargs
[
f
]
else
:
raise
pkex
.
BasePyKatException
(
"Missing demodulation frequency {0} (f{0})"
.
format
(
i
+
1
))
...
...
@@ -679,7 +701,7 @@ class pd(Detector1):
if
kwargs
[
p
]
is
None
and
i
<
num_demods
-
1
:
raise
pkex
.
BasePyKatException
(
"Missing demodulation phase {0} (phase{0})"
.
format
(
i
+
1
))
ps
[
i
].
value
=
kwargs
[
p
]
self
.
__
ps
[
i
].
value
=
kwargs
[
p
]
elif
i
<
num_demods
-
1
:
raise
pkex
.
BasePyKatException
(
"Missing demodulation phase {0} (phase{0})"
.
format
(
i
+
1
))
...
...
pykat/param.py
View file @
dc68b69a
...
...
@@ -272,6 +272,9 @@ class Param(putable, putter):
return
float
(
self
.
value
)
def
getFinesseText
(
self
):
if
self
.
_owner
()
is
None
:
raise
pkex
.
BasePyKatException
(
"Owner has been removed but parameter (%s) is still referenced"
%
self
.
name
)
if
self
.
_owner
().
removed
:
raise
pkex
.
BasePyKatException
(
"{0} has been removed from the simulation"
.
format
(
self
.
_owner
().
name
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment