当前位置: 首页>>代码示例>>Python>>正文


Python Analyzer.stop方法代码示例

本文整理汇总了Python中analyzer.Analyzer.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.stop方法的具体用法?Python Analyzer.stop怎么用?Python Analyzer.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在analyzer.Analyzer的用法示例。


在下文中一共展示了Analyzer.stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __trainModel

# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import stop [as 别名]
 def __trainModel(self, verbose=False, trainRatio=.5):
     if verbose:
         analyzer = Analyzer(self.__model, self.__dataset, trainRatio)
         analyzer.start()
     if self.__dataset.trainSampleCount > 0:
         self.__model.train(self.__dataset.trainSamples, self.__dataset.trainResponses)
     if verbose:
         analyzer.stop()
         analyzer.analyze()
         print analyzer
开发者ID:xsyann,项目名称:ocr,代码行数:12,代码来源:ocr.py

示例2: __trainModel

# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import stop [as 别名]
 def __trainModel(self, trainRatio=.5, errorsIteration=0, log=None):
     if log:
         analyzer = Analyzer(self.__model, self.__dataset, trainRatio)
         analyzer.start()
     self.__model.train(self.__dataset.trainSamples,
                        self.__dataset.trainResponses)
     samples, responses = self.__dataset.testSamples, self.__dataset.testResponses
     i = 0
     while responses.any() and i < errorsIteration:
         samples, responses = self.__injectErrors(samples, responses)
         i += 1
     self.__dataset.testSamples = samples
     self.__dataset.testResponses = responses
     if log:
         analyzer.stop()
         analyzer.analyze()
         log(str(analyzer))
开发者ID:xsyann,项目名称:mediocre,代码行数:19,代码来源:ocr.py

示例3: analyze

# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import stop [as 别名]
    def analyze(self, cell_obs, detection=True, mute=True, lat=None, lon=None):
        print "analyzing"
        cellobs_id = cell_obs.id
        s_ranks = []
        cellscan = CellTowerScan(cellobservation_id=cellobs_id, sample_rate=self.sample_rate, rec_time_sec=self.rec_time_sec, timestamp=datetime.datetime.now())
        if self.store_capture:
            db_session = session_class()
            db_session.add(cellscan)
            db_session.commit()
        udp_port = 2333
        if detection:
            detector_man = DetectorManager(udp_port=udp_port)
            #detector_man.addDetector(Detector('test_detector', cellobs_id))
            detector_man.addDetector(A5Detector('a5_detector', cellobs_id))
            detector_man.addDetector(IDRequestDetector('id_request_detector', cellobs_id))
            detector_man.addDetector(CellReselectionOffsetDetector('cell_reselection_offset_detector', cellobs_id))
            detector_man.addDetector(CellReselectionHysteresisDetector('cell_reselection_offset_hysteresis', cellobs_id))
            detector_man.addDetector(TIC('tic', cellobs_id, lat, lon))
            proc = Thread(target=detector_man.start)
            proc.start()
            if mute:
                # silence rtl_sdr output:
                # open 2 fds
                null_fds = [os.open(os.devnull, os.O_RDWR) for x in xrange(2)]
                # save the current file descriptors to a tuple
                save = os.dup(1), os.dup(2)
                # put /dev/null fds on 1 and 2
                os.dup2(null_fds[0], 1)
                os.dup2(null_fds[1], 2)
            analyzer = Analyzer(gain=self.gain, samp_rate=self.sample_rate,
                                ppm=self.ppm, arfcn=cell_obs.arfcn, capture_id=cellscan.getCaptureFileName(),
                                udp_ports=[udp_port], rec_length=self.rec_time_sec, max_timeslot=2,
                                verbose=False, test=False, store_capture=self.store_capture)
            analyzer.start()
            analyzer.wait()
            analyzer.stop()
            if mute:
                # restore file descriptors so we can print the results
                os.dup2(save[0], 1)
                os.dup2(save[1], 2)
                # close the temporary fds
                os.close(null_fds[0])
                os.close(null_fds[1])

            print "analyzer stopped"
            s_ranks = detector_man.stop()
            print "detector stopping..."

            proc.join()

            #proc.terminate()
            print "detector stopped"
            # print s_ranks
            # for r in rankings:
            #     total_rank += r['s_rank']
            # cell_obs.s_rank = total_rank

        else:
            # silence rtl_sdr output:
            # open 2 fds
            null_fds = [os.open(os.devnull, os.O_RDWR) for x in xrange(2)]
            # save the current file descriptors to a tuple
            save = os.dup(1), os.dup(2)
            # put /dev/null fds on 1 and 2
            os.dup2(null_fds[0], 1)
            os.dup2(null_fds[1], 2)
            analyzer = Analyzer(gain=self.gain, samp_rate=self.sample_rate,
                                ppm=self.ppm, arfcn=cell_obs.arfcn, capture_id=cellscan.getCaptureFileName(),
                                udp_ports=[udp_port], rec_length=self.rec_time_sec, max_timeslot=2,
                                verbose=False, test=True)
            analyzer.start()
            analyzer.wait()
            analyzer.stop()
            # restore file descriptors so we can print the results
            os.dup2(save[0], 1)
            os.dup2(save[1], 2)
            # close the temporary fds
            os.close(null_fds[0])
            os.close(null_fds[1])
            print "analyzer stopped"

        return s_ranks
开发者ID:santiag0aragon,项目名称:icc,代码行数:84,代码来源:runner.py


注:本文中的analyzer.Analyzer.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。