def test_merge_tiles_horizontal(self):
        tile1 = Tile()
        tile1.latitudes = np.ma.array([0.0, 1.0, 2.0, 3.0])
        tile1.longitudes = np.ma.array([0.0, -1.0, -2.0])
        tile1.times = np.ma.array([0])
        tile1.data = np.ma.arange(12).reshape((1, 4, 3))

        tile2 = Tile()
        tile2.latitudes = np.ma.array([0.0, 1.0, 2.0, 3.0])
        tile2.longitudes = np.ma.array([-3.0, -4.0, -5.0])
        tile2.times = np.ma.array([0])
        tile2.data = np.ma.arange(12, 24).reshape((1, 4, 3))

        from nexustiles.model.nexusmodel import merge_tiles

        times, lats, longs, data = merge_tiles([tile1, tile2])

        self.assertTrue(np.ma.allequal(times, np.array([0])))
        self.assertTrue(np.ma.allequal(lats, np.array([0.0, 1.0, 2.0, 3.0])))
        self.assertTrue(
            np.ma.allequal(longs, np.array([-5.0, -4.0, -3.0, -2.0, -1.0,
                                            0.0])))
        expected = np.ma.array(
            [[[14, 13, 12, 2, 1, 0], [17, 16, 15, 5, 4, 3],
              [20, 19, 18, 8, 7, 6], [23, 22, 21, 11, 10, 9]]],
            mask=False)
        self.assertTrue(
            np.ma.allequal(np.ma.getmaskarray(data),
                           np.ma.getmaskarray(expected)))
        self.assertTrue(np.ma.allequal(data, expected))
    def test_merge_tiles_overlapping(self):
        tile1 = Tile()
        tile1.latitudes = np.ma.array([0.0, 1.0, 2.0, 3.0])
        tile1.longitudes = np.ma.array([0.0, -1.0, -2.0])
        tile1.times = np.ma.array([0])
        tile1.data = np.ma.arange(12).reshape((1, 4, 3))

        tile2 = Tile()
        tile2.latitudes = np.ma.array([0.0, 1.0, 2.0, 3.0])
        tile2.longitudes = np.ma.array([0.0, -1.0, -2.0])
        tile2.times = np.ma.array([0])
        tile2.data = np.ma.arange(12, 24).reshape((1, 4, 3))

        from nexustiles.model.nexusmodel import merge_tiles

        self.assertRaises(Exception, lambda _: merge_tiles([tile1, tile2]))