Commit 0abb97cf authored by Daniel Brown's avatar Daniel Brown
Browse files

fixing weakref updating on deepcopy for NodeGaussSetters

parent f415451c
......@@ -15,7 +15,7 @@ from pykat.SIfloat import *
from pykat.param import Param, AttrParam
import weakref
import pykat.exceptions as pkex
from copy import deepcopy
next_component_id = 1
from pykat import USE_GUI, NoGUIException
......@@ -198,7 +198,7 @@ class Component(object):
del self._params[:]
self.__removed = True
class AbstractMirrorComponent(Component):
__metaclass__ = abc.ABCMeta
......
......@@ -424,6 +424,20 @@ class kat(object):
if kat_file != None:
self.loadKatFile(kat_file)
def __deepcopy__(self, memo):
cls = self.__class__
result = cls.__new__(cls)
memo[id(self)] = result
for k, v in self.__dict__.items():
setattr(result, k, copy.deepcopy(v, memo))
# Update any weakrefs
for c in result.components:
result.components[c]._Component__update_node_setters()
return result
@property
def signals(self): return self.__signals
......@@ -919,8 +933,9 @@ class kat(object):
r = katRun()
r.yaxis = self.yaxis
r.katScript = "".join(self.generateKatScript())
r.katScript = "".join(self.generateKatScript())
if (plot==None):
# ensure we don't do any plotting. That should be handled
# by user themselves
......
......@@ -498,7 +498,7 @@ class Node(object):
def setGauss(self, component, *args):
self.__q_comp = component
if len(args) == 1:
if len(args) == 1:
self.__q_x = beam_param(self._network.kat.lambda0, q=args[0])
self.__q_y = beam_param(self._network.kat.lambda0, q=args[0])
elif len(args) == 2:
......@@ -506,7 +506,7 @@ class Node(object):
self.__q_y = beam_param(self._network.kat.lambda0, q=args[1])
else:
raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams")
def getFinesseText(self):
if self.__q_x is None or self.__q_y is None or self.__q_comp is None:
return []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment