def METHOD_NAME(compress):
    """
    Test writing and reading a rice compressed image
    """
    nrows = 5
    ncols = 20
    if compress in ['rice', 'hcompress'] or 'gzip' in compress:
        dtypes = ['u1', 'i1', 'u2', 'i2', 'u4', 'i4', 'f4', 'f8']
        # dtypes = ['u2']
    elif compress == 'plio':
        dtypes = ['i1', 'i2', 'i4', 'f4', 'f8']
    else:
        raise ValueError('unexpected compress %s' % compress)
    if 'lossless' in compress:
        qlevel = None
    else:
        qlevel = 16
    seed = 1919
    rng = np.random.RandomState(seed)
    with tempfile.TemporaryDirectory() as tmpdir:
        fname = os.path.join(tmpdir, 'test.fits')
        with FITS(fname, 'rw') as fits:
            # note i8 not supported for compressed!
            for dtype in dtypes:
                if dtype[0] == 'f':
                    data = rng.normal(size=(nrows, ncols))
                    if compress == 'plio':
                        data = data.clip(min=0)
                    data = data.astype(dtype)
                else:
                    data = np.arange(
                        nrows * ncols, dtype=dtype,
                    ).reshape(nrows, ncols)
                csend = compress.replace('_lossless', '')
                fits.write_image(data, compress=csend, qlevel=qlevel)
                rdata = fits[-1].read()
                if dtype[0] == 'f':
                    compare_array_abstol(
                        data,
                        rdata,
                        0.2,
                        "%s compressed images ('%s')" % (compress, dtype),
                    )
                else:
                    # for integers we have chosen a wide range of values, so
                    # there will be no quantization and we expect no
                    # information loss
                    compare_array(
                        data, rdata,
                        "%s compressed images ('%s')" % (compress, dtype)
                    )
        with FITS(fname) as fits:
            for ii in range(len(dtypes)):
                i = ii + 1
                assert fits[i].is_compressed(), "is compressed"