From b57a16af759aa186024cfd29ff2494c9c5cd1804 Mon Sep 17 00:00:00 2001 From: Daniel Brown <ddb@star.sr.bham.ac.uk> Date: Fri, 6 Jan 2017 16:18:04 +0000 Subject: [PATCH] fixing ordering. Adding more intelligent remove in BlockedKatFile --- pykat/finesse.py | 18 ++++++++++++------ pykat/optics/gaussian_beams.py | 15 ++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pykat/finesse.py b/pykat/finesse.py index 147063d..f442a71 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -216,13 +216,19 @@ class BlockedKatFile(object): self.blocks = {self.__NO_BLOCK:""} self.__currentBlock = self.__NO_BLOCK - def remove(self, block): - if block not in self.ordering or block not in self.blocks: - raise Exception("%s block not found") - - self.ordering.remove(block) - self.blocks.pop(block) + def remove(self, *blocks): + if len(blocks[0]) > 1 and not isinstance(blocks[0], six.string_types): + # if we've got an iterable thing that isn't a string, eg list or tuple + # just use that + blocks = blocks[0] + for block in blocks: + if block not in self.ordering or block not in self.blocks: + raise Exception("%s block not found") + + self.ordering.remove(block) + self.blocks.pop(block) + def add(self, block, contents, addAfter=None): if block in self.ordering or block in self.blocks: diff --git a/pykat/optics/gaussian_beams.py b/pykat/optics/gaussian_beams.py index 1a1b534..9467f34 100644 --- a/pykat/optics/gaussian_beams.py +++ b/pykat/optics/gaussian_beams.py @@ -14,11 +14,6 @@ from scipy.special import hermite from pykat.math.jacobi import jacobi from pykat.SIfloat import SIfloat -class gauss_param(BeamParam): - pass - -class beam_param(BeamParam): - pass class BeamParam(object): """ @@ -499,3 +494,13 @@ def LG2HG(p,l): coefficients[j] = c * (-1.0)**p * (-2)**j * jacobi(j,n-j,m-j,0.0) return coefficients, ns, ms + + +# These classes are here as legacy classes, BeamParam should throw a warning if they are used instead. + + +class gauss_param(BeamParam): + pass + +class beam_param(BeamParam): + pass \ No newline at end of file -- GitLab