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

Python xml.validates_against_xml_schema函数代码示例

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

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



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

示例1: test_serialize

    def test_serialize(self):
        expected_file = helpers.get_data_path(
            "expected-dmg-dist-total.xml")

        expected_text = open(expected_file, "r").readlines()

        self.make_dist()

        self.make_data("no_damage", 1.0, 1.6)
        self.make_data("slight", 34.8, 18.3)
        self.make_data("moderate", 64.2, 19.8)
        self.make_data("extensive", 64.3, 19.7)
        self.make_data("complete", 64.3, 19.7)

        try:
            _, result_xml = tempfile.mkstemp()

            writer = DmgDistTotalXMLWriter(result_xml,
                    "ebl1", self.damage_states)

            writer.serialize(self.data)
            actual_text = open(result_xml, "r").readlines()

            self.assertEqual(expected_text, actual_text)

            self.assertTrue(xml.validates_against_xml_schema(
                    result_xml))
        finally:
            os.unlink(result_xml)
开发者ID:angri,项目名称:openquake,代码行数:29,代码来源:scenario_damage_test.py


示例2: test_serialize

    def test_serialize(self):
        expected_file = helpers.get_data_path(
            "expected-collapse-map.xml")

        expected_text = open(expected_file, "r").readlines()

        asset_1, asset_2, asset_3, asset_4 = self.make_assets()
        self.make_map()

        self.make_data(asset_1, 1.6, 1.7)
        self.make_data(asset_2, 2.9, 3.1)
        self.make_data(asset_3, 4.9, 5.1)
        self.make_data(asset_4, 10.6, 11.7)

        try:
            _, result_xml = tempfile.mkstemp()

            writer = CollapseMapXMLWriter(result_xml, "ebl1")

            writer.serialize(self.data)
            actual_text = open(result_xml, "r").readlines()

            self.assertEqual(expected_text, actual_text)

            self.assertTrue(xml.validates_against_xml_schema(
                    result_xml))
        finally:
            os.unlink(result_xml)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:28,代码来源:scenario_damage_test.py


示例3: test_write_multiple_result_nodes

    def test_write_multiple_result_nodes(self):
        result_data = [
            dict(groundMotionValue=0.25, path="filea"),
            dict(groundMotionValue=0.76, path="fileb"),
            dict(groundMotionValue=0.11, path="filec"),
        ]

        expected_result_attrib = [
            dict(groundMotionValue="0.25", path="filea"),
            dict(groundMotionValue="0.76", path="fileb"),
            dict(groundMotionValue="0.11", path="filec"),
        ]

        self.writer.open()
        self.writer.write(shapes.Site(1.0, 2.0), result_data[0])
        self.writer.write(shapes.Site(2.0, 3.0), result_data[1])
        self.writer.write(shapes.Site(3.0, 4.0), result_data[2])
        self.writer.close()

        site_nodes = self._xpath("//gml:pos")
        disagg_nodes = self._xpath("//nrml:disaggregationResultNode")
        results = self._xpath("//nrml:disaggregationResult")

        self.assertEquals(3, len(site_nodes))
        self.assertEquals(3, len(disagg_nodes))
        self.assertEquals(3, len(results))

        self.assertEquals("1.0 2.0", site_nodes[0].text)
        self.assertEquals("2.0 3.0", site_nodes[1].text)
        self.assertEquals("3.0 4.0", site_nodes[2].text)

        for i, res in enumerate(results):
            self.assertEquals(expected_result_attrib[i], res.attrib)

        self.assertTrue(xml.validates_against_xml_schema(self.FILENAME))
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:35,代码来源:hazard_nrml_test.py


示例4: test_writes_a_single_result

    def test_writes_a_single_result(self):
        data = [(shapes.Site(-122.5000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_1",
                "IMLValues": [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],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [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]})]

        path = helpers.get_output_path(TEST_FILE_SINGLE_RESULT)

        self._initialize_writer(path)
        self.writer.serialize(data)

        self.assertTrue(xml.validates_against_xml_schema(path))
        self.assertTrue(XML_METADATA in self._result_as_string(path))

        self.read_curves = self._read_curves(
                (-123.0, 38.0), (-122.0, 35.0),
                TEST_FILE_SINGLE_RESULT)

        self._assert_number_of_curves_is(1)
        self._assert_curves_are(data)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:33,代码来源:hazard_nrml_test.py


示例5: verify_quantile_haz_maps_stored_to_nrml

        def verify_quantile_haz_maps_stored_to_nrml(the_job, calculator):
            """Tests that quantile hazard map NRML files have been written,
            and that these file validate against the NRML schema.
            Does NOT test if results in NRML files are correct.
            """

            quantiles = calculator.quantile_levels

            if (the_job.params[hazard_general.POES_PARAM_NAME] != '' and
                len(quantiles) > 0):

                for poe in calculator.poes_hazard_maps:
                    for quantile in quantiles:
                        nrml_path = os.path.join(
                            "demos/classical_psha_simple/computed_output",
                            calculator.quantile_hazard_map_filename(quantile,
                                                                   poe))

                        LOG.debug("validating NRML file for quantile hazard "\
                            "map: %s" % nrml_path)

                        self.assertTrue(xml.validates_against_xml_schema(
                            nrml_path, NRML_SCHEMA_PATH),
                            "NRML instance file %s does not validate against "\
                            "schema" % nrml_path)
开发者ID:angri,项目名称:openquake,代码行数:25,代码来源:hazard_test.py


示例6: verify_quantile_haz_maps_stored_to_nrml

        def verify_quantile_haz_maps_stored_to_nrml(hazengine):
            """Tests that quantile hazard map NRML files have been written,
            and that these file validate against the NRML schema.
            Does NOT test if results in NRML files are correct.
            """

            quantiles = classical_psha._extract_values_from_config(hazengine,
                classical_psha.QUANTILE_PARAM_NAME)

            if (hazengine.params[classical_psha.POES_PARAM_NAME] != '' and
                len(quantiles) > 0):

                poes = classical_psha._extract_values_from_config(hazengine,
                    classical_psha.POES_PARAM_NAME)

                for quantile in quantiles:
                    for poe in poes:
                        nrml_path = os.path.join(
                            "smoketests/classical_psha_simple/computed_output",
                            opensha.quantile_hm_filename(quantile, poe))

                        LOG.debug("validating NRML file for quantile hazard "\
                            "map: %s" % nrml_path)

                        self.assertTrue(xml.validates_against_xml_schema(
                            nrml_path, NRML_SCHEMA_PATH),
                            "NRML instance file %s does not validate against "\
                            "schema" % nrml_path)
开发者ID:hsberlin,项目名称:openquake,代码行数:28,代码来源:hazard_unittest.py


示例7: test_writes_the_config_only_once

    def test_writes_the_config_only_once(self):
        data = [(shapes.Site(-122.5000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_1",
                "IMLValues": [5.0, 6.0, 7.0],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [0.1, 0.2, 0.3]}),
                (shapes.Site(-122.4000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_2",
                "IMLValues": [5.0, 6.0, 7.0],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [0.4, 0.5, 0.6]})]

        path = helpers.get_output_path(TEST_FILE_CONFIG_ONCE)
        self._initialize_writer(path)

        self.writer.serialize(data)
        self.assertTrue(xml.validates_against_xml_schema(path))
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:25,代码来源:hazard_nrml_test.py


示例8: test_loss_map_output_writes_and_validates

 def test_loss_map_output_writes_and_validates(self):
     xml_writer = \
         risk_output.LossMapXMLWriter(TEST_LOSS_MAP_XML_OUTPUT_PATH)
     xml_writer.serialize(SAMPLE_LOSS_MAP_DATA)
     self.assertTrue(
         xml.validates_against_xml_schema(TEST_LOSS_MAP_XML_OUTPUT_PATH,
         NRML_SCHEMA_PATH),
         "NRML instance file %s does not validate against schema" % \
         TEST_LOSS_MAP_XML_OUTPUT_PATH)
开发者ID:danciul,项目名称:openquake,代码行数:9,代码来源:loss_map_output_unittest.py


示例9: test_loss_is_serialized_to_file_and_validates

    def test_loss_is_serialized_to_file_and_validates(self):
        """Serialize loss curve to NRML and validate against schema."""
        xml_writer = risk_output.LossCurveXMLWriter(self.loss_curve_path)
        xml_writer.serialize(self.loss_curves)

        self.assertTrue(xml.validates_against_xml_schema(self.loss_curve_path,
            NRML_SCHEMA_PATH),
            "NRML instance file %s does not validate against schema" % \
            self.loss_curve_path)
开发者ID:favalex,项目名称:openquake,代码行数:9,代码来源:loss_output_unittest.py


示例10: test_serialize

    def test_serialize(self):
        data = [(shapes.Site(1.0, 1.0),
                {"groundMotionValue": 0.25, "path": "filea"}),
                (shapes.Site(1.0, 2.0),
                {"groundMotionValue": 0.35, "path": "fileb"})]

        self.writer.serialize(data)

        self.assertTrue(xml.validates_against_xml_schema(self.FILENAME))
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:9,代码来源:hazard_nrml_test.py


示例11: verify_mean_haz_curves_stored_to_nrml

        def verify_mean_haz_curves_stored_to_nrml(the_job, calculator):
            """Tests that a mean hazard curve NRML file has been written,
            and that this file validates against the NRML schema.
            Does NOT test if results in NRML file are correct.
            """

            if the_job.params['COMPUTE_MEAN_HAZARD_CURVE'].lower() == 'true':
                nrml_path = psha.nrml_path(calculator.job_ctxt, "mean")

                LOG.debug("validating NRML file %s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema"
                    % nrml_path)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:15,代码来源:hazard_test.py


示例12: test_writes_multiple_results_with_one_branch_level

    def test_writes_multiple_results_with_one_branch_level(self):
        data = [(shapes.Site(-122.5000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_1",
                "IMLValues": [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],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [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]}),
                (shapes.Site(-122.4000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_1",
                "IMLValues": [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],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [9.8784e-01, 9.8405e-01, 9.5719e-01,
                9.1955e-01, 8.5019e-01, 7.4038e-01, 5.9153e-01,
                4.2626e-01, 2.9755e-01, 2.7731e-01, 1.6218e-01,
                8.8035e-02, 4.3499e-02, 1.9065e-02, 7.0442e-03,
                2.1300e-03, 4.9498e-04, 8.1768e-05, 7.3425e-06]})]

        path = helpers.get_output_path(TEST_FILE_MULTIPLE_ONE_BRANCH)
        self._initialize_writer(path)
        self.writer.serialize(data)

        self.assertTrue(xml.validates_against_xml_schema(path))

        self.read_curves = self._read_curves(
                (-123.0, 38.0), (-120.0, 35.0),
                TEST_FILE_MULTIPLE_ONE_BRANCH)

        self._assert_number_of_curves_is(2)
        self._assert_curves_are(data)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:48,代码来源:hazard_nrml_test.py


示例13: test_write_single_result_node

    def test_write_single_result_node(self):
        result_data = dict(groundMotionValue=0.25, path="filea")
        expected_result_attrib = dict(groundMotionValue="0.25", path="filea")

        self.writer.write(shapes.Site(1.0, 2.0), result_data)
        self.writer.close()

        [site_node] = self._xpath("//gml:pos")
        disagg_nodes = self._xpath("//nrml:disaggregationResultNode")
        [result] = self._xpath("//nrml:disaggregationResult")

        self.assertEquals("1.0 2.0", site_node.text)
        self.assertEquals(1, len(disagg_nodes))
        self.assertEquals(expected_result_attrib, result.attrib)

        self.assertTrue(xml.validates_against_xml_schema(self.FILENAME))
开发者ID:dsg101,项目名称:openquake,代码行数:16,代码来源:hazard_nrml_unittest.py


示例14: verify_mean_haz_curves_stored_to_nrml

        def verify_mean_haz_curves_stored_to_nrml(hazengine):
            """Tests that a mean hazard curve NRML file has been written,
            and that this file validates against the NRML schema.
            Does NOT test if results in NRML file are correct.
            """

            if hazengine.params['COMPUTE_MEAN_HAZARD_CURVE'].lower() == 'true':
                nrml_path = os.path.join(
                    "smoketests/classical_psha_simple/computed_output",
                    opensha.mean_hc_filename())

                LOG.debug("validating NRML file %s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema" \
                    % nrml_path)
开发者ID:hsberlin,项目名称:openquake,代码行数:17,代码来源:hazard_unittest.py


示例15: verify_quantile_haz_curves_stored_to_nrml

        def verify_quantile_haz_curves_stored_to_nrml(the_job, calculator):
            """Tests that quantile hazard curve NRML files have been written,
            and that these file validate against the NRML schema.
            Does NOT test if results in NRML files are correct.
            """

            for quantile in calculator.quantile_levels:

                nrml_path = psha.nrml_path(calculator.job_ctxt, "quantile",
                                           quantile)
                LOG.debug("validating NRML file for quantile hazard curve: "
                    "%s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema"
                    % nrml_path)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:17,代码来源:hazard_test.py


示例16: verify_realization_haz_curves_stored_to_nrml

        def verify_realization_haz_curves_stored_to_nrml(the_job, calculator):
            """Tests that a NRML file has been written for each realization,
            and that this file validates against the NRML schema.
            Does NOT test if results in NRML file are correct.
            """
            realizations = int(
                the_job.params['NUMBER_OF_LOGIC_TREE_SAMPLES'])
            for realization in xrange(0, realizations):

                nrml_path = psha.nrml_path(calculator.job_ctxt, "curve",
                                           realization)

                LOG.debug("validating NRML file %s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema"
                    % nrml_path)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:18,代码来源:hazard_test.py


示例17: verify_realization_haz_curves_stored_to_nrml

        def verify_realization_haz_curves_stored_to_nrml(hazengine):
            """Tests that a NRML file has been written for each realization,
            and that this file validates against the NRML schema.
            Does NOT test if results in NRML file are correct.
            """
            realizations = int(
                hazengine.params['NUMBER_OF_LOGIC_TREE_SAMPLES'])
            for realization in xrange(0, realizations):

                nrml_path = os.path.join(
                    "smoketests/classical_psha_simple/computed_output",
                    opensha.realization_hc_filename(realization))

                LOG.debug("validating NRML file %s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema" \
                    % nrml_path)
开发者ID:hsberlin,项目名称:openquake,代码行数:19,代码来源:hazard_unittest.py


示例18: verify_quantile_haz_curves_stored_to_nrml

        def verify_quantile_haz_curves_stored_to_nrml(hazengine):
            """Tests that quantile hazard curve NRML files have been written,
            and that these file validate against the NRML schema.
            Does NOT test if results in NRML files are correct.
            """

            for quantile in hazengine.quantile_levels:

                nrml_path = os.path.join(
                    "smoketests/classical_psha_simple/computed_output",
                    hazengine.quantile_hazard_curve_filename(quantile))

                LOG.debug("validating NRML file for quantile hazard curve: "\
                    "%s" % nrml_path)

                self.assertTrue(xml.validates_against_xml_schema(
                    nrml_path, NRML_SCHEMA_PATH),
                    "NRML instance file %s does not validate against schema" \
                    % nrml_path)
开发者ID:favalex,项目名称:openquake,代码行数:19,代码来源:hazard_unittest.py


示例19: test_writes_multiple_results_with_different_branch_levels

    def test_writes_multiple_results_with_different_branch_levels(self):
        data = [(shapes.Site(-122.5000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_1",
                "IMLValues": [5.0, 6.0, 7.0],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [0.1, 0.2, 0.3]}),
                (shapes.Site(-122.5000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_2",
                "IMLValues": [5.0, 6.0, 7.0],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [0.1, 0.2, 0.3]}),
                (shapes.Site(-122.4000, 37.5000),
                {"IDmodel": "MMI_3_1",
                "investigationTimeSpan": 50.0,
                "endBranchLabel": "3_2",
                "IMLValues": [8.0, 9.0, 10.0],
                "saPeriod": 0.1,
                "saDamping": 1.0,
                "IMT": "PGA",
                "PoEValues": [0.1, 0.2, 0.3]})]

        path = helpers.get_output_path(
                TEST_FILE_MULTIPLE_DIFFERENT_BRANCHES)

        self._initialize_writer(path)
        self.writer.serialize(data)

        self.assertTrue(xml.validates_against_xml_schema(path))

        self.read_curves = self._read_curves(
                (-123.0, 38.0), (-120.0, 35.0),
                TEST_FILE_MULTIPLE_DIFFERENT_BRANCHES)

        self._assert_number_of_curves_is(3)
        self._assert_curves_are(data)
开发者ID:PseudononymousEpistle,项目名称:oq-engine,代码行数:43,代码来源:hazard_nrml_test.py


示例20: test_result_field_attrs

    def test_result_field_attrs(self):
        """Test that the various disaggregationResultField attrs are written
        correctly (including all of the optional attributes)."""
        # write a single node just to create a valid document
        self.writer.write(shapes.Site(0.0, 0.0),
                          {"groundMotionValue": 0.25, "path": "filea"})
        self.writer.close()

        [disagg_field] = self._xpath(
            "/nrml:nrml/nrml:disaggregationResultField")

        attrib = disagg_field.attrib

        self.assertEquals(str(self.POE), attrib['poE'])
        self.assertEquals(self.IMT, attrib['IMT'])
        self.assertEquals(self.END_BRANCH_LABEL, attrib['endBranchLabel'])
        self.assertEquals(self.STATISTICS, attrib['statistics'])
        self.assertEquals(str(self.QUANTILE_VALUE), attrib['quantileValue'])

        self.assertTrue(xml.validates_against_xml_schema(self.FILENAME))
开发者ID:dsg101,项目名称:openquake,代码行数:20,代码来源:hazard_nrml_unittest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python storage_factory.StorageFactory类代码示例发布时间:2022-05-27
下一篇:
Python imaputil.imapsplit函数代码示例发布时间: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