def save_state(self, hmodel, iterid, lap, evBound, doFinal=False):
    ''' Save state of the hmodel's global parameters and evBound
    '''  
    traceEvery = self.outputParams['traceEvery']
    if 0 <= traceEvery:
      traceEvery = -1
    doTrace = isEvenlyDivisibleFloat(lap, traceEvery) or iterid < 3
    
    if traceEvery > 0 and (doFinal or doTrace) and lap not in self.TraceLaps:
      # Record current evidence
      self.evTrace.append(evBound)
      self.TraceLaps.add(lap)

      # Exit here if we're not saving to disk
      if self.savedir is None:
        return
    
      # Record current state to plain-text files
      with open( self.mkfile('laps.txt'), 'a') as f:        
        f.write('%.4f\n' % (lap))
      with open( self.mkfile('evidence.txt'), 'a') as f:        
        f.write('%.9e\n' % (evBound))
      with open( self.mkfile('nObs.txt'), 'a') as f:
        f.write('%d\n' % (self.nObsProcessed))
      with open( self.mkfile('times.txt'), 'a') as f:
        f.write('%.3f\n' % (self.get_elapsed_time()))
      if self.hasMove('birth') or self.hasMove('merge'):
        with open( self.mkfile('K.txt'), 'a') as f:
          f.write('%d\n' % (hmodel.obsModel.K))

    saveEvery = self.outputParams['saveEvery']
    if saveEvery <= 0 or self.savedir is None:
      return

    doSave = isEvenlyDivisibleFloat(lap, saveEvery) or iterid < 3
    if (doFinal or doSave) and iterid not in self.SavedIters:
      self.SavedIters.add(iterid)
      with open(self.mkfile('laps-saved-params.txt'), 'a') as f:        
        f.write('%.4f\n' % (lap))
      prefix = ModelWriter.makePrefixForLap(lap)
      ModelWriter.save_model(hmodel, self.savedir, prefix,
                              doSavePriorInfo=(iterid<1), doLinkBest=True)

  # Define temporary function that creates files in this alg's output dir
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/learnalg/LearnAlg.py/LearnAlg.save_state/swapped operands of `<=`