def __init__(self, adata, key=None):
    self._connectivities = None
    self._distances = None
    if ((key is None) or (key == 'neighbors')):
        if ('neighbors' not in adata.uns):
            raise KeyError('No "neighbors" in .uns')
        self._neighbors_dict = adata.uns['neighbors']
        self._conns_key = 'connectivities'
        self._dists_key = 'distances'
    else:
        if (key not in adata.uns):
            raise KeyError(f'No "{key}" in .uns')
        self._neighbors_dict = adata.uns[key]
        self._conns_key = self._neighbors_dict['connectivities_key']
        self._dists_key = self._neighbors_dict['distances_key']
    if (self._conns_key in adata.obsp):
        self._connectivities = adata.obsp[self._conns_key]
    if (self._dists_key in adata.obsp):
        self._distances = adata.obsp[self._dists_key]
    (self._connectivities, self._distances) = _fallback_to_uns(self._neighbors_dict, self._connectivities, self._distances, self._conns_key, self._dists_key)
def __init__(self, adata, key=None):
    self._connectivities = None
    self._distances = None
    if ((key is None) or (key == 'neighbors')):
        if ('neighbors' not in adata.uns):
            raise KeyError('No "neighbors" in .uns')
        self._neighbors_dict = adata.uns['neighbors']
        self._conns_key = 'connectivities'
        self._dists_key = 'distances'
    else:
        if (key not in adata.uns):
            raise KeyError(f'No "{key}" in .uns')
        self._neighbors_dict = adata.uns[key]
        self._conns_key = self._neighbors_dict['connectivities_key']
        self._dists_key = self._neighbors_dict['distances_key']
    if (self._conns_key in adata.obsp):
        self._connectivities = adata.obsp[self._conns_key]
    if (self._dists_key in adata.obsp):
        self._distances = adata.obsp[self._dists_key]
    (self._connectivities, self._distances) = _fallback_to_uns(self._neighbors_dict, self._connectivities, self._distances, self._conns_key, self._dists_key)