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


Python PathDefaults.getTempDir方法代码示例

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


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

示例1: testEstimate

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getTempDir [as 别名]
    def testEstimate(self):
        #Lets set up a simple model based on normal dist
        abcParams = ABCParameters()
        
        epsilonArray = numpy.array([0.5, 0.2, 0.1])
        posteriorSampleSize = 20

        #Lets get an empirical estimate of Sprime
        model = NormalModel(abcMetrics)
        model.setMu(theta[0])
        model.setSigma(theta[1])
        
        Sprime = abcMetrics.summary(model.simulate()) 
        logging.debug(("Real summary statistic: " + str(Sprime)))

        thetaDir = PathDefaults.getTempDir()
        
        abcSMC = ABCSMC(epsilonArray, createNormalModel, abcParams, thetaDir)
        abcSMC.maxRuns = 100000
        abcSMC.setPosteriorSampleSize(posteriorSampleSize)
        thetasArray = abcSMC.run()
        thetasArray = numpy.array(thetasArray)

        meanTheta = numpy.mean(thetasArray, 0)
        logging.debug((thetasArray.shape))
        logging.debug(thetasArray)
        logging.debug(meanTheta)

        print(thetasArray.shape[0], posteriorSampleSize)

        #Note only mean needs to be similar
        self.assertTrue(thetasArray.shape[0] >= posteriorSampleSize)
        self.assertEquals(thetasArray.shape[1], 2)
        self.assertTrue(numpy.linalg.norm(theta[0] - meanTheta[0]) < 0.2)
开发者ID:charanpald,项目名称:sandbox,代码行数:36,代码来源:ABCSMCTest.py

示例2: testLoadParams

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getTempDir [as 别名]
    def testLoadParams(self):
        try:
            lmbda = 0.01

            alterRegressor = PrimalRidgeRegression(lmbda)
            egoRegressor = PrimalRidgeRegression(lmbda)
            predictor = EgoEdgeLabelPredictor(alterRegressor, egoRegressor)

            params = [0.1, 0.2]
            paramFuncs = [egoRegressor.setLambda, alterRegressor.setLambda]
            fileName = PathDefaults.getTempDir() + "tempParams.pkl"

            predictor.saveParams(params, paramFuncs, fileName)

            params2 = predictor.loadParams(fileName)

            self.assertTrue(params2[0][0] == "apgl.predictors.PrimalRidgeRegression")
            self.assertTrue(params2[0][1] == "setLambda")
            self.assertTrue(params2[0][2] == 0.1)

            self.assertTrue(params2[1][0] == "apgl.predictors.PrimalRidgeRegression")
            self.assertTrue(params2[1][1] == "setLambda")
            self.assertTrue(params2[1][2] == 0.2)
        except IOError as e:
            logging.warn(e)
开发者ID:charanpald,项目名称:sandbox,代码行数:27,代码来源:AbstractEdgeLabelPredictorTest.py

示例3: testSaveParams

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getTempDir [as 别名]
    def testSaveParams(self):
        try:
            lmbda = 0.01

            alterRegressor = PrimalRidgeRegression(lmbda)
            egoRegressor = PrimalRidgeRegression(lmbda)
            predictor = EgoEdgeLabelPredictor(alterRegressor, egoRegressor)

            params = [0.1, 0.2]
            paramFuncs = [egoRegressor.setLambda, alterRegressor.setLambda]
            fileName = PathDefaults.getTempDir() + "tempParams.pkl"

            predictor.saveParams(params, paramFuncs, fileName)
        except IOError as e:
            logging.warn(e)
开发者ID:charanpald,项目名称:sandbox,代码行数:17,代码来源:AbstractEdgeLabelPredictorTest.py

示例4: profile

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getTempDir [as 别名]
    def profile(command, globalVars, localVars, numStats=30):
        """
        Just profile the given command with the global and local variables
        and print out the cumulative and function times. 
        """
        try:
            import pstats
            import cProfile
        except ImportError:
            raise ImportError("profile() requires pstats and cProfile")

        tempDirectory = PathDefaults.getTempDir()
        profileFileName = tempDirectory + "profile.cprof"

        logging.info("Starting to profile ...")
        cProfile.runctx(command, globalVars, localVars, profileFileName)
        logging.info("Done")
        stats = pstats.Stats(profileFileName)
        stats.strip_dirs().sort_stats("cumulative").print_stats(numStats)
        stats.strip_dirs().sort_stats("time").print_stats(numStats)
开发者ID:charanpald,项目名称:sandbox,代码行数:22,代码来源:ProfileUtils.py


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