Esempio n. 1
0
    def test_clip_imls_with_many_normal_values(self):
        """
        Test :py:method:`openquake.shapes.range_clip` to
        ensure that normal values (values within the defined IML range) are not
        changed.
        """
        valid_imls = [0.005, 0.0269, 0.0051, 0.0268]
        expected_result = numpy.array(valid_imls)

        self.assertTrue(allclose(expected_result,
            shapes.range_clip(valid_imls, self.TEST_IMLS)))
        # same test, except with numpy.array-type input:
        self.assertTrue(allclose(expected_result,
            shapes.range_clip(numpy.array(valid_imls), self.TEST_IMLS)))
Esempio n. 2
0
    def test_clip_high_imls_many_values(self):
        """
        Test :py:method:`openquake.shapes.range_clip` to
        ensure that the high values are clipped to the highest valid value in
        the IML range.
        """
        expected_imls = numpy.array([0.0269, 0.0269, 0.0269])
        test_input = [0.027, 0.3, 10]

        self.assertTrue(allclose(expected_imls,
            shapes.range_clip(test_input, self.TEST_IMLS)))
        # same test, except with a numpy.array-type input:
        self.assertTrue(allclose(expected_imls,
            shapes.range_clip(numpy.array(test_input), self.TEST_IMLS)))
Esempio n. 3
0
 def test_clip_low_iml_values(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that low values are clipped to the lowest valid value in the
     IML range.
     """
     self.assertEqual(0.005, shapes.range_clip(0.0049, self.TEST_IMLS))
Esempio n. 4
0
 def test_clip_high_iml_values(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that the high values are clipped to the highest valid value in
     the IML range.
     """
     self.assertEqual(0.0269, shapes.range_clip(0.027, self.TEST_IMLS))
Esempio n. 5
0
 def test_clip_high_iml_values(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that the high values are clipped to the highest valid value in
     the IML range.
     """
     self.assertEqual(0.0269, shapes.range_clip(0.027, self.TEST_IMLS))
Esempio n. 6
0
 def test_clip_low_iml_values(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that low values are clipped to the lowest valid value in the
     IML range.
     """
     self.assertEqual(0.005, shapes.range_clip(0.0049, self.TEST_IMLS))
Esempio n. 7
0
    def test_clip_imls_with_many_normal_values(self):
        """
        Test :py:method:`openquake.shapes.range_clip` to
        ensure that normal values (values within the defined IML range) are not
        changed.
        """
        valid_imls = [0.005, 0.0269, 0.0051, 0.0268]
        expected_result = numpy.array(valid_imls)

        self.assertTrue(
            allclose(expected_result,
                     shapes.range_clip(valid_imls, self.TEST_IMLS)))
        # same test, except with numpy.array-type input:
        self.assertTrue(
            allclose(
                expected_result,
                shapes.range_clip(numpy.array(valid_imls), self.TEST_IMLS)))
Esempio n. 8
0
    def test_clip_high_imls_many_values(self):
        """
        Test :py:method:`openquake.shapes.range_clip` to
        ensure that the high values are clipped to the highest valid value in
        the IML range.
        """
        expected_imls = numpy.array([0.0269, 0.0269, 0.0269])
        test_input = [0.027, 0.3, 10]

        self.assertTrue(
            allclose(expected_imls,
                     shapes.range_clip(test_input, self.TEST_IMLS)))
        # same test, except with a numpy.array-type input:
        self.assertTrue(
            allclose(
                expected_imls,
                shapes.range_clip(numpy.array(test_input), self.TEST_IMLS)))
Esempio n. 9
0
 def test_clip_iml_with_normal_value(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that normal values (values within the defined IML range) are not
     changed.
     """
     valid_imls = numpy.array([0.005, 0.0051, 0.0268, 0.0269])
     for i in valid_imls:
         self.assertEqual(i, shapes.range_clip(i, valid_imls))
Esempio n. 10
0
 def test_clip_iml_with_normal_value(self):
     """
     Test :py:method:`openquake.shapes.range_clip` to
     ensure that normal values (values within the defined IML range) are not
     changed.
     """
     valid_imls = numpy.array([0.005, 0.0051, 0.0268, 0.0269])
     for i in valid_imls:
         self.assertEqual(i, shapes.range_clip(i, valid_imls))