

def is_dendro(file, **kwargs):
    if is_hdf5(file):
        import h5py
        f = h5py.File(file, 'r')
        return (('data' in f) and ('index_map' in f) and ('newick' in f))
    elif is_fits(file):
        from astropy.io import fits
        hdulist = fits.open(file, ignore_missing_end=True)
        try:
            hdulist['DATA']
            hdulist['INDEX_MAP']
            hdulist['NEWICK']
        except KeyError:
            pass
        else:
            return True
        if (len(hdulist) != 4):
            return False
        if ((hdulist[1].name != '') or (hdulist[2].name != '') or (hdulist[3].name != '')):
            return False
        if (hdulist[0].data is not None):
            return False
        if ((hdulist[1].data is None) or (hdulist[2].data is None) or (hdulist[3].data is None)):
            return False
        if (hdulist[1].data.shape != hdulist[2].data.shape):
            return False
        if (hdulist[3].data.ndim != 1):
            return False
        return True
    else:
        return False

dataset/ETHPy150Open glue-viz/glue/glue/plugins/dendro_viewer/data_factory.py is_dendro/original