• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.create_job函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.utils.helpers.create_job函数的典型用法代码示例。如果您正苦于以下问题:Python create_job函数的具体用法?Python create_job怎么用?Python create_job使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_risk_mandatory_parameters

    def test_risk_mandatory_parameters(self):
        sections = [config.RISK_SECTION,
                config.HAZARD_SECTION, config.GENERAL_SECTION]

        params = {}

        engine = helpers.create_job(params, sections=sections)
        self.assertFalse(engine.is_valid()[0])

        params = {config.EXPOSURE: "/a/path/to/exposure"}

        engine = helpers.create_job(params, sections=sections)
        self.assertFalse(engine.is_valid()[0])

        params = {config.EXPOSURE: "/a/path/to/exposure",
                config.REGION_GRID_SPACING: 0.5}

        engine = helpers.create_job(params, sections=sections)
        self.assertFalse(engine.is_valid()[0])

        params = {config.EXPOSURE: "/a/path/to/exposure",
                config.INPUT_REGION: "a, polygon",
                config.REGION_GRID_SPACING: 0.5}

        engine = helpers.create_job(params, sections=sections)
        self.assertTrue(engine.is_valid()[0])
开发者ID:favalex,项目名称:openquake,代码行数:26,代码来源:validator_unittest.py


示例2: test_with_risk_processing_the_exposure_must_be_specified

    def test_with_risk_processing_the_exposure_must_be_specified(self):
        sections = [config.RISK_SECTION, "HAZARD", "general"]
        params = {}

        engine = helpers.create_job(params, sections=sections)
        self.assertFalse(engine.is_valid()[0])

        params = {config.EXPOSURE: "/a/path/to/exposure"}

        engine = helpers.create_job(params, sections=sections)
        self.assertTrue(engine.is_valid()[0])
开发者ID:johndouglas,项目名称:openquake,代码行数:11,代码来源:validator_unittest.py


示例3: setUpClass

    def setUpClass(cls):
        cls.job = engine.prepare_job()
        jp, _, _ = engine.import_job_profile(RISK_DEMO_CONFIG_FILE, cls.job)
        calc_proxy = helpers.create_job({}, job_id=cls.job.id,
                oq_job_profile=jp, oq_job=cls.job)

        # storing the basic exposure model
        ClassicalRiskCalculator(calc_proxy).store_exposure_assets()

        [em_input] = models.inputs4job(cls.job.id, input_type="exposure")
        [model] = em_input.exposuremodel_set.all()

        site = shapes.Site(1.0, 2.0)

        # more assets at same location
        models.ExposureData(
            exposure_model=model, taxonomy="NOT_USED",
            asset_ref="ASSET_1", stco=1,
            site=geos.GEOSGeometry(site.point.to_wkt()), reco=1).save()

        models.ExposureData(
            exposure_model=model, taxonomy="NOT_USED",
            asset_ref="ASSET_2", stco=1,
            site=geos.GEOSGeometry(site.point.to_wkt()), reco=1).save()

        site = shapes.Site(2.0, 2.0)

        # just one asset at location
        models.ExposureData(
            exposure_model=model, taxonomy="NOT_USED",
            asset_ref="ASSET_3", stco=1,
            site=geos.GEOSGeometry(site.point.to_wkt()), reco=1).save()
开发者ID:wmorales,项目名称:oq-engine,代码行数:32,代码来源:general_unittest.py


示例4: setUp

    def setUp(self):
        self.params = dict(
            CALCULATION_MODE='Hazard',
            REFERENCE_VS30_VALUE=500,
            SOURCE_MODEL_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_SRC_MODEL_LT,
            GMPE_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_GMPE_LT,
            BASE_PATH=SIMPLE_FAULT_BASE_PATH)

        self.imls = [5.0000e-03, 7.0000e-03,
                1.3700e-02, 1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
                7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01, 2.0300e-01,
                2.8400e-01, 3.9700e-01, 5.5600e-01, 7.7800e-01, 1.0900e+00,
                1.5200e+00, 2.1300e+00]

        self.job_ctxt = helpers.create_job(self.params)
        self.calculator = classical.ClassicalHazardCalculator(self.job_ctxt)
        self.job_id = self.job_ctxt.job_id

        self.empty_mean_curve = []

        # deleting server side cached data
        kvs.get_client().flushall()

        mean_curve = [9.8728e-01, 9.8266e-01, 9.4957e-01,
                9.0326e-01, 8.1956e-01, 6.9192e-01, 5.2866e-01, 3.6143e-01,
                2.4231e-01, 2.2452e-01, 1.2831e-01, 7.0352e-02, 3.6060e-02,
                1.6579e-02, 6.4213e-03, 2.0244e-03, 4.8605e-04, 8.1752e-05,
                7.3425e-06]

        self.site = shapes.Site(2.0, 5.0)
        self._store_curve_at(self.site, mean_curve)
开发者ID:angri,项目名称:openquake,代码行数:31,代码来源:hazard_test.py


示例5: test_prepares_blocks_using_the_exposure

    def test_prepares_blocks_using_the_exposure(self):
        """The base risk calculator is able to read the exposure file,
        split the sites into blocks and store them in KVS.
        """

        params = {
            config.EXPOSURE: os.path.join(helpers.SCHEMA_EXAMPLES_DIR,
                                          EXPOSURE_TEST_FILE),
            "BASE_PATH": "."
        }
        a_job = helpers.create_job(params)

        calculator = general.BaseRiskCalculator(a_job)

        calculator.partition()

        sites = [shapes.Site(9.15000, 45.16667),
                 shapes.Site(9.15333, 45.12200),
                 shapes.Site(9.14777, 45.17999)]

        expected = general.Block(a_job.job_id, 0, sites)

        self.assertEqual(1, len(a_job.blocks_keys))

        self.assertEqual(
            expected, general.Block.from_kvs(a_job.job_id,
                                             a_job.blocks_keys[0]))
开发者ID:kpanic,项目名称:openquake,代码行数:27,代码来源:risk_job_unittest.py


示例6: test_with_risk_jobs_we_can_trigger_hazard_only_on_exposure_sites

    def test_with_risk_jobs_we_can_trigger_hazard_only_on_exposure_sites(self):
        """When we have hazard and risk jobs, we can ask to trigger
        the hazard computation only on the sites specified
        in the exposure file."""

        sections = [config.HAZARD_SECTION, config.GENERAL_SECTION, config.RISK_SECTION]

        input_region = "46.0, 9.0, 46.0, 10.0, 45.0, 10.0, 45.0, 9.0"

        exposure = "exposure-portfolio.xml"
        exposure_path = os.path.join(helpers.SCHEMA_EXAMPLES_DIR, exposure)

        params = {
            config.INPUT_REGION: input_region,
            config.REGION_GRID_SPACING: 0.1,
            config.EXPOSURE: exposure_path,
            config.COMPUTE_HAZARD_AT_ASSETS: True,
        }

        engine = helpers.create_job(params, sections=sections, base_path=".")

        expected_sites = [
            shapes.Site(9.15000, 45.16667),
            shapes.Site(9.15333, 45.12200),
            shapes.Site(9.14777, 45.17999),
        ]

        self.assertEquals(expected_sites, engine.sites_to_compute())
开发者ID:kpanic,项目名称:openquake,代码行数:28,代码来源:job_unittest.py


示例7: setUpClass

    def setUpClass(cls):
        cls.job = engine.prepare_job()
        jp, _, _ = engine.import_job_profile(RISK_DEMO_CONFIG_FILE, cls.job)

        cls.job_ctxt = helpers.create_job({}, job_id=cls.job.id,
                                          oq_job_profile=jp, oq_job=cls.job)
        calc = ClassicalRiskCalculator(cls.job_ctxt)

        calc.store_exposure_assets()
        [input] = models.inputs4job(cls.job.id, input_type="exposure")
        model = input.model()
        assets = model.exposuredata_set.filter(taxonomy="af/ctc-D/LR")
        # Add some more assets.
        coos = [(10.000155392289116, 46.546194318563),
                (10.222034128255, 46.0071299176413),
                (10.520376165581, 46.247463385278)]
        for lat, lon in coos:
            site = shapes.Site(lat, lon)
            cls.sites.append(site)
            if assets:
                continue
            location = geos.GEOSGeometry(site.point.to_wkt())
            asset = models.ExposureData(
                exposure_model=model, taxonomy="af/ctc-D/LR",
                asset_ref=helpers.random_string(6), stco=lat * 2,
                site=location, reco=1.1 * lon)
            asset.save()
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:27,代码来源:general_test.py


示例8: test_read_gmfs

    def test_read_gmfs(self):
        """Verify _get_db_gmfs."""
        params = {
            'REGION_VERTEX': '40,-117, 42,-117, 42,-116, 40,-116',
            'REGION_GRID_SPACING': '1.0'}

        the_job = helpers.create_job(params, job_id=self.job.id)
        calculator = EventBasedRiskCalculator(the_job)

        self.assertEqual(3, len(calculator._gmf_db_list(self.job.id)))

        # only the keys in gmfs are used
        gmfs = calculator._get_db_gmfs([], self.job.id)
        self.assertEqual({}, gmfs)

        # only the keys in gmfs are used
        sites = [Site(lon, lat)
                        for lon in xrange(-117, -115)
                        for lat in xrange(40, 43)]
        gmfs = calculator._get_db_gmfs(sites, self.job.id)
        # avoid rounding errors
        for k, v in gmfs.items():
            gmfs[k] = [round(i, 1) for i in v]

        self.assertEqual({
                '0!0': [0.1, 0.5, 0.0],
                '0!1': [0.2, 0.6, 0.0],
                '1!0': [0.4, 0.8, 1.3],
                '1!1': [0.3, 0.7, 1.2],
                '2!0': [0.0, 0.0, 1.0],
                '2!1': [0.0, 0.0, 1.1],
                }, gmfs)
开发者ID:leoalvar,项目名称:oq-engine,代码行数:32,代码来源:input_risk_unittest.py


示例9: test_prepares_blocks_using_the_exposure_and_filtering

    def test_prepares_blocks_using_the_exposure_and_filtering(self):
        """When reading the exposure file, the mixin also provides filtering
        on the region specified in the REGION_VERTEX and REGION_GRID_SPACING
        paramaters."""

        region_vertex = \
            "46.0, 9.14, 46.0, 9.15, 45.0, 9.15, 45.0, 9.14"

        params = {config.EXPOSURE: os.path.join(
                helpers.SCHEMA_EXAMPLES_DIR, EXPOSURE_TEST_FILE),
                config.INPUT_REGION: region_vertex,
                config.REGION_GRID_SPACING: 0.1,
                # the calculation mode is filled to let the mixin runs
                config.CALCULATION_MODE: "Event Based"}

        a_job = helpers.create_job(params)

        expected_block = general.Block(
            (shapes.Site(9.15, 45.16667), shapes.Site(9.14777, 45.17999)))

        with Mixin(a_job, general.RiskJobMixin):
            a_job.partition()

            self.assertEqual(1, len(a_job.blocks_keys))

            self.assertEqual(
                expected_block, general.Block.from_kvs(a_job.blocks_keys[0]))
开发者ID:johndouglas,项目名称:openquake,代码行数:27,代码来源:risk_job_unittest.py


示例10: setUp

    def setUp(self):
        params = dict(
            CALCULATION_MODE='Hazard',
            SOURCE_MODEL_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_SRC_MODEL_LT,
            GMPE_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_GMPE_LT,
            BASE_PATH=SIMPLE_FAULT_BASE_PATH)

        self.job_ctxt = create_job(params)
        self.calculator = classical.ClassicalHazardCalculator(self.job_ctxt)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:9,代码来源:hazard_classical_test.py


示例11: setUp

    def setUp(self):
        params = dict(
            CALCULATION_MODE='Hazard',
            COMPUTE_MEAN_HAZARD_CURVE='true',
            SOURCE_MODEL_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_SRC_MODEL_LT,
            GMPE_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_GMPE_LT,
            BASE_PATH=SIMPLE_FAULT_BASE_PATH)

        self.calc_proxy = create_job(params)
        self.calculator = classical.ClassicalHazardCalculator(self.calc_proxy)
开发者ID:kpanic,项目名称:openquake,代码行数:10,代码来源:hazard_classical_unittest.py


示例12: test_site_keys

    def test_site_keys(self):
        """Verify _sites_to_gmf_keys"""
        params = {
            'REGION_VERTEX': '40,-117, 42,-117, 42,-116, 40,-116',
            'REGION_GRID_SPACING': '1.0'}
        with Mixin(helpers.create_job(params, job_id=self.job.id),
                   ProbabilisticEventMixin) as mixin:
            keys = mixin._sites_to_gmf_keys([Site(-117, 40), Site(-116, 42)])

            self.assertEquals(["0!0", "2!1"], keys)
开发者ID:favalex,项目名称:openquake,代码行数:10,代码来源:input_risk_unittest.py


示例13: test_site_keys

    def test_site_keys(self):
        """Verify _sites_to_gmf_keys"""
        params = {
            'REGION_VERTEX': '40,-117, 42,-117, 42,-116, 40,-116',
            'REGION_GRID_SPACING': '1.0'}

        the_job = helpers.create_job(params, job_id=self.job.id)
        calculator = EventBasedRiskCalculator(the_job)

        keys = calculator._sites_to_gmf_keys([Site(-117, 40), Site(-116, 42)])

        self.assertEqual(["0!0", "2!1"], keys)
开发者ID:leoalvar,项目名称:oq-engine,代码行数:12,代码来源:input_risk_unittest.py


示例14: test_computes_sites_in_region_with_risk_jobs

    def test_computes_sites_in_region_with_risk_jobs(self):
        """When we have hazard and risk jobs, we always use the region."""
        sections = [config.HAZARD_SECTION, config.GENERAL_SECTION, config.RISK_SECTION]

        input_region = "2.0, 1.0, 2.0, 2.0, 1.0, 2.0, 1.0, 1.0"

        params = {config.INPUT_REGION: input_region, config.REGION_GRID_SPACING: 1.0}

        engine = helpers.create_job(params, sections=sections)

        expected_sites = [shapes.Site(1.0, 1.0), shapes.Site(2.0, 1.0), shapes.Site(1.0, 2.0), shapes.Site(2.0, 2.0)]

        self.assertEquals(expected_sites, engine.sites_to_compute())
开发者ID:kpanic,项目名称:openquake,代码行数:13,代码来源:job_unittest.py


示例15: test_hazard_computation_type

    def test_hazard_computation_type(self):
        """Region (REGION_VERTEX) and specific sites (SITES)
        are not supported at the same time."""

        params = {config.SITES: "some, sites"}
        validator = config.ComputationTypeValidator(params)

        engine = helpers.create_job(params, validator=validator)
        self.assertTrue(engine.is_valid()[0])

        params = {config.INPUT_REGION: "a, polygon"}
        validator = config.ComputationTypeValidator(params)

        engine = helpers.create_job(params, validator=validator)
        self.assertTrue(engine.is_valid()[0])

        params = {config.SITES: "some, sites",
                config.INPUT_REGION: "a, polygon"}

        validator = config.ComputationTypeValidator(params)

        engine = helpers.create_job(params, validator=validator)
        self.assertFalse(engine.is_valid()[0])
开发者ID:favalex,项目名称:openquake,代码行数:23,代码来源:validator_unittest.py


示例16: test_read_curve

    def test_read_curve(self):
        """Verify _get_db_curve."""
        the_job = helpers.create_job({}, job_id=self.job.id)
        calculator = ClassicalRiskCalculator(the_job)

        curve1 = calculator._get_db_curve(Site(-122.2, 37.5))
        self.assertEqual(curve1,
                          zip([0.005, 0.007, 0.0098, 0.0137],
                              [0.354, 0.114, 0.023, 0.002]))

        curve2 = calculator._get_db_curve(Site(-122.1, 37.5))
        self.assertEqual(curve2,
                         zip([0.005, 0.007, 0.0098, 0.0137],
                             [0.454, 0.214, 0.123, 0.102]))
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:14,代码来源:input_risk_test.py


示例17: test_computes_sites_in_region_when_specified

    def test_computes_sites_in_region_when_specified(self):
        """When we have hazard jobs only, and we specify a region,
        we use the standard algorithm to split the region in sites. In this
        example, the region has just four sites (the region boundaries).
        """
        sections = [config.HAZARD_SECTION, config.GENERAL_SECTION]
        input_region = "2.0, 1.0, 2.0, 2.0, 1.0, 2.0, 1.0, 1.0"

        params = {config.INPUT_REGION: input_region, config.REGION_GRID_SPACING: 1.0}

        engine = helpers.create_job(params, sections=sections)

        expected_sites = [shapes.Site(1.0, 1.0), shapes.Site(2.0, 1.0), shapes.Site(1.0, 2.0), shapes.Site(2.0, 2.0)]

        self.assertEquals(expected_sites, engine.sites_to_compute())
开发者ID:kpanic,项目名称:openquake,代码行数:15,代码来源:job_unittest.py


示例18: test_computes_specific_sites_when_specified

    def test_computes_specific_sites_when_specified(self):
        """When we have hazard jobs only, and we specify a list of sites
        (SITES parameter in the configuration file) we trigger the
        computation only on those sites.
        """
        sections = [config.HAZARD_SECTION, config.GENERAL_SECTION]
        sites = "1.0, 1.5, 1.5, 2.5, 3.0, 3.0, 4.0, 4.5"

        params = {config.SITES: sites}

        engine = helpers.create_job(params, sections=sections)

        expected_sites = [shapes.Site(1.5, 1.0), shapes.Site(2.5, 1.5), shapes.Site(3.0, 3.0), shapes.Site(4.5, 4.0)]

        self.assertEquals(expected_sites, engine.sites_to_compute())
开发者ID:kpanic,项目名称:openquake,代码行数:15,代码来源:job_unittest.py


示例19: setUp

    def setUp(self):
        self.params = dict(
            CALCULATION_MODE='Hazard',
            REFERENCE_VS30_VALUE=500,
            SADIGH_SITE_TYPE='Rock',
            REFERENCE_DEPTH_TO_2PT5KM_PER_SEC_PARAM='5.0',
            DEPTHTO1PT0KMPERSEC='33.33',
            VS30_TYPE='measured',
            SOURCE_MODEL_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_SRC_MODEL_LT,
            GMPE_LOGIC_TREE_FILE_PATH=SIMPLE_FAULT_GMPE_LT,
            BASE_PATH=SIMPLE_FAULT_BASE_PATH)

        self.job_ctxt = helpers.create_job(self.params)
        self.calculator = classical.ClassicalHazardCalculator(self.job_ctxt)
        self.job_id = self.job_ctxt.job_id
开发者ID:leoalvar,项目名称:oq-engine,代码行数:15,代码来源:hazard_unittest.py


示例20: test_read_curve

    def test_read_curve(self):
        """Verify _get_db_curve."""
        with Mixin(helpers.create_job({}, job_id=self.job.id),
                   ClassicalPSHABasedMixin) as mixin:
            curve1 = mixin._get_db_curve(Site(-122.2, 37.5))
            self.assertEquals(list(curve1.abscissae),
                              [0.005, 0.007, 0.0098, 0.0137])
            self.assertEquals(list(curve1.ordinates),
                              [0.354, 0.114, 0.023, 0.002])

            curve2 = mixin._get_db_curve(Site(-122.1, 37.5))
            self.assertEquals(list(curve2.abscissae),
                              [0.005, 0.007, 0.0098, 0.0137])
            self.assertEquals(list(curve2.ordinates),
                              [0.454, 0.214, 0.123, 0.102])
开发者ID:favalex,项目名称:openquake,代码行数:15,代码来源:input_risk_unittest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.default_user函数代码示例发布时间:2022-05-27
下一篇:
Python grammar.get_record_grammar函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap