Пример #1
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)
Пример #2
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)
Пример #3
0
    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)))
    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)))