Exemplo n.º 1
0
    def test_reshaping_along_length(self):
        cell_area = numpy.array([[1, 1, 1], [1, 1, 1]], dtype=float)
        cell_length = numpy.array([[1, 1, 1], [1, 1, 1]], dtype=float)
        rupture_area = 3.1
        rupture_length = 1.0

        slices = _float_ruptures(rupture_area, rupture_length, cell_area,
                                 cell_length)
        self.assertEqual(len(slices), 2)
        s1, s2 = slices
        self.assertEqual(s1, (slice(0, 3), slice(0, 3)))
        self.assertEqual(s2, (slice(0, 3), slice(1, 4)))

        rupture_area = 4.2
        slices = _float_ruptures(rupture_area, rupture_length, cell_area,
                                 cell_length)
        self.assertEqual(len(slices), 1)
        self.assertEqual(slices, [s1])
    def test_reshaping_along_length(self):
        cell_area = numpy.array([[1, 1, 1],
                                 [1, 1, 1]], dtype=float)
        cell_length = numpy.array([[1, 1, 1],
                                   [1, 1, 1]], dtype=float)
        rupture_area = 3.1
        rupture_length = 1.0

        slices = _float_ruptures(rupture_area, rupture_length,
                                 cell_area, cell_length)
        self.assertEqual(len(slices), 2)
        s1, s2 = slices
        self.assertEqual(s1, (slice(0, 3), slice(0, 3)))
        self.assertEqual(s2, (slice(0, 3), slice(1, 4)))

        rupture_area = 4.2
        slices = _float_ruptures(rupture_area, rupture_length,
                                 cell_area, cell_length)
        self.assertEqual(len(slices), 1)
        self.assertEqual(slices, [s1])
Exemplo n.º 3
0
    def test_reshaping_along_width(self):
        cell_area = numpy.array([[4, 4], [4, 4], [2, 2]], dtype=float)
        cell_length = numpy.array([[2, 2], [2, 2], [2, 2]], dtype=float)
        rupture_area = 13.0
        rupture_length = 12.0

        slices = _float_ruptures(rupture_area, rupture_length, cell_area,
                                 cell_length)
        self.assertEqual(len(slices), 2)
        s1, s2 = slices
        self.assertEqual(s1, (slice(0, 3), slice(0, 3)))
        self.assertEqual(s2, (slice(1, 4), slice(0, 3)))
    def test_reshaping_along_width(self):
        cell_area = numpy.array([[4, 4],
                                 [4, 4],
                                 [2, 2]], dtype=float)
        cell_length = numpy.array([[2, 2], [2, 2], [2, 2]], dtype=float)
        rupture_area = 13.0
        rupture_length = 12.0

        slices = _float_ruptures(rupture_area, rupture_length,
                                 cell_area, cell_length)
        self.assertEqual(len(slices), 2)
        s1, s2 = slices
        self.assertEqual(s1, (slice(0, 3), slice(0, 3)))
        self.assertEqual(s2, (slice(1, 4), slice(0, 3)))
Exemplo n.º 5
0
    def test_varying_width(self):
        cell_area = numpy.array([[1, 1, 1], [1, 0.1, 1], [1, 0.1, 1]],
                                dtype=float)
        cell_length = numpy.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]],
                                  dtype=float)
        rupture_area = 2.1
        rupture_length = 1.0

        slices = _float_ruptures(rupture_area, rupture_length, cell_area,
                                 cell_length)
        self.assertEqual(len(slices), 6)
        tl, tm, tr, bl, bm, br = slices
        self.assertEqual(tl, (slice(0, 3), slice(0, 2)))
        self.assertEqual(tm, (slice(0, 4), slice(1, 3)))
        self.assertEqual(tr, (slice(0, 3), slice(2, 4)))
        self.assertEqual(bl, (slice(1, 4), slice(0, 2)))
        self.assertEqual(bm, (slice(1, 4), slice(1, 3)))
        self.assertEqual(br, (slice(1, 4), slice(2, 4)))
    def test_varying_width(self):
        cell_area = numpy.array([[1, 1, 1],
                                 [1, 0.1, 1],
                                 [1, 0.1, 1]], dtype=float)
        cell_length = numpy.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]],
                                  dtype=float)
        rupture_area = 2.1
        rupture_length = 1.0

        slices = _float_ruptures(rupture_area, rupture_length,
                                 cell_area, cell_length)
        self.assertEqual(len(slices), 6)
        tl, tm, tr, bl, bm, br = slices
        self.assertEqual(tl, (slice(0, 3), slice(0, 2)))
        self.assertEqual(tm, (slice(0, 4), slice(1, 3)))
        self.assertEqual(tr, (slice(0, 3), slice(2, 4)))
        self.assertEqual(bl, (slice(1, 4), slice(0, 2)))
        self.assertEqual(bm, (slice(1, 4), slice(1, 3)))
        self.assertEqual(br, (slice(1, 4), slice(2, 4)))