def test_write_read_memory(self):
        img = np.ones((self.height, self.width), np.int16)
        path = "/vsimem/test_write_read_memory.tif"
        ds = ImageIO.write_to_memory(img, path, self.projection,
                                     self.coordinates)

        arr = ds.ReadAsArray()
        self.assertTrue((arr == img).all())
        self.assertEqual(ds.GetGeoTransform(), self.coordinates)
        # Compare projections by removing all spaces cause of multiline string
        self.assertEqual(ds.GetProjection().replace(" ", ""),
                         self.projection.replace(" ", ""))
        ds = None  # Always remember to dereference :)
        FileSystem.remove_file(path)
    def get_ds(self):
        """
        Return a new copy of a :class:`gdal.Dataset`.

        :return: A gdal dataset object
        """
        p_out = "/vsimem/" + uuid.uuid4().hex
        try:
            nodata = self.nodata_value
        except AttributeError:
            nodata = None
        return ImageIO.write_to_memory(self.array,
                                       p_out,
                                       self.projection,
                                       self.geotransform,
                                       nodata=nodata)