コード例 #1
0
ファイル: output_hazard_test.py プロジェクト: pslh/oq-engine
    def setUp(self):
        self.job = self.setup_classic_job()
        output_path = self.generate_output_path(self.job)
        self.display_name = os.path.basename(output_path)

        self.writer = HazardCurveDBWriter(output_path, self.job.id)
        self.reader = HazardCurveDBReader()
コード例 #2
0
ファイル: output_hazard_test.py プロジェクト: bwyss/oq-engine
    def test_deserialize(self):
        """Hazard map is read back correctly"""
        def _normalize(data):
            result = []

            key = "investigationTimeSpan"
            for pt, val in data:
                new = val.copy()
                new[key] = float(new[key])
                result.append((pt, new))

            return result

        outputs = []
        for idx, hcd in enumerate(HAZARD_CURVE_DATA()):
            output_path = self.generate_output_path(self.job,
                                                    output_type="hazard_curve")
            writer = HazardCurveDBWriter(output_path, self.job.id)
            # Call the function under test.
            writer.serialize(hcd)
            outputs.append((idx, writer.output))

        for idx, output in outputs:
            reader = HazardCurveDBReader()
            data = reader.deserialize(output.id)
            self.assertEquals(self.sort(_normalize(HAZARD_CURVE_DATA()[idx])),
                              self.sort(_normalize(data)))
コード例 #3
0
    def test_deserialize_small(self):
        data = HAZARD_CURVE_DATA(['1_1', '1_2', '2_2', '2'], 20, 4)

        self.job = self.setup_classic_job()
        output_path = self.generate_output_path(self.job)

        hcw = HazardCurveDBWriter(output_path, self.job.id)
        hcw.serialize(data)

        # deserialize
        hcr = HazardCurveDBReader()

        for i in xrange(0, 10):
            # Call the function under test.
            hcr.deserialize(hcw.output.id)