Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19749

Re: Generator problem: parent class not seen

Subject Re: Generator problem: parent class not seen
From Russell Owen <rowen@uw.edu>
Date 2012-02-01 14:50 -0800
References <rowen-5B5D5C.13003901022012@news.gmane.org> <CAMZYqRSD1OEjLNTYLMQ2ZS6cXK1r7H9yDHBf0GzFpjE6jd4PqA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5330.1328137483.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Feb 1, 2012, at 2:34 PM, Chris Rebert wrote:

> On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen <rowen@uw.edu> wrote:
>> I have an odd and very intermittent problem in Python script.
>> Occasionally it fails with this error:
>> 
>> Traceback (most recent call last):
>>  File
>> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas
>> eFocusScript.py", line 884, in run
>>  File
>> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas
>> eFocusScript.py", line 1690, in initAll
>> TypeError: unbound method initAll() must be called with BaseFocusScript
>> instance as first argument (got ScriptClass instance instead)
> <snip>
>> The code looks like this:
>> 
>>    def run(self, sr):
>>        try:
>>            self.initAll()
> <snip>
>> I am puzzled why Python thinks the class type is wrong, given the output
>> of inspect.getclasstree. Any ideas on what might be wrong and how to
>> track it down (and why it would be so intermittent)?
> 
> What's the offending line of initAll() [#1690 in BaseFocusScript.py]
> look like? The lines preceding it would also be helpful for context.

Here you go. The offending line #169 is marked with ***

-- Russell

class ImagerFocusScript(BaseFocusScript):
   """..."""
    def __init__(self,
        sr,
        instName,
        imageViewerTLName = None,
        defRadius = 5.0,
        defBinFactor = 1,
        maxFindAmpl = None,
        doWindow = False,
        windowOrigin = 1,
        windowIsInclusive = True,
        doZeroOverscan = False,
        helpURL = None,
        debug = False,
    ):
    ...
        BaseFocusScript.__init__(self,
            sr = sr,
            gcamActor = gcamActor,
            instName = instName,
            imageViewerTLName = imageViewerTLName,
            defRadius = defRadius,
            defBinFactor = defBinFactor,
            maxFindAmpl = maxFindAmpl,
            doWindow = doWindow,
            windowOrigin = windowOrigin,
            windowIsInclusive = windowIsInclusive,
            helpURL = helpURL,
            debug = debug,
        )
        self.doZeroOverscan = bool(doZeroOverscan)
        ....

    def initAll(self):
        """Override the default initAll to record initial bin factor, if relevant
        """
***   BaseFocusScript.initAll(self)
        if self.exposeModel.instInfo.numBin > 0:
            self.finalBinFactor = self.exposeModel.bin.getInd(0)[0]


Also, here is BaseFocusScript:

class BaseFocusScript(object):
    """Basic focus script object.
    
    This is a virtual base class. The inheritor must:
    - Provide widgets
    - Provide a "run" method
    """
    cmd_Find = "find"
    cmd_Measure = "measure"
    cmd_Sweep = "sweep"

    # constants
    #DefRadius = 5.0 # centroid radius, in arcsec
    #NewStarRad = 2.0 # amount of star position change to be considered a new star
    DefFocusNPos = 5  # number of focus positions
    DefFocusRange = 200 # default focus range around current focus
    FocusWaitMS = 1000 # time to wait after every focus adjustment (ms)
    BacklashComp = 0 # amount of backlash compensation, in microns (0 for none)
    WinSizeMult = 2.5 # window radius = centroid radius * WinSizeMult
    FocGraphMargin = 5 # margin on graph for x axis limits, in um
    MaxFocSigmaFac = 0.5 # maximum allowed sigma of best fit focus as a multiple of focus range
    MinFocusIncr = 10 # minimum focus increment, in um
    def __init__(self,
        sr,
        gcamActor,
        instName,
        tccInstPrefix = None,
        imageViewerTLName = None,
        defRadius = 5.0,
        defBinFactor = 1,
        finalBinFactor = None,
        canSetStarPos = True,
        maxFindAmpl = None,
        doWindow = True,
        windowOrigin = 0,
        windowIsInclusive = True,
        helpURL = None,
        debug = False,
    ):
        """...."""
        self.sr = sr
        self.sr.debug = bool(debug)
        self.gcamActor = gcamActor

    ....
    def initAll(self):
        """Initialize variables, table and graph.
        """
        # initialize shared variables
        self.doTakeFinalImage = False
        self.focDir = None
        self.currBoreXYDeg = None
        self.begBoreXYDeg = None
        self.instScale = None
        self.arcsecPerPixel = None
        self.instCtr = None
        self.instLim = None
        self.cmdMode = None
        self.focPosToRestore = None
        self.expTime = None
        self.absStarPos = None
        self.relStarPos = None
        self.binFactor = None
        self.window = None # LL pixel is 0, UR pixel is included

        self.enableCmdBtns(False)

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Generator problem: parent class not seen Russell Owen <rowen@uw.edu> - 2012-02-01 14:50 -0800

csiph-web