If bond_dict is provided, this function is not side effect free
        bond_dict has to be a collections.defaultdict(set)

def _update_bond_dict(self, fragment_indices,
                          positions,
                          bond_radii,
                          bond_dict=None,
                          self_bonding_allowed=False,
                          convert_index=None):
        """If bond_dict is provided, this function is not side effect free
        bond_dict has to be a collections.defaultdict(set)
        """
        assert (isinstance(bond_dict, collections.defaultdict)
                or bond_dict is None)
        fragment_indices = list(fragment_indices)
        if convert_index is None:
            convert_index = dict(enumerate(fragment_indices))
        if bond_dict is None:
            bond_dict = collections.defaultdict(set)

        frag_pos = positions[fragment_indices, :]
        frag_bond_radii = bond_radii[fragment_indices]

        bond_array = self._jit_give_bond_array(
            frag_pos, frag_bond_radii,
            self_bonding_allowed=self_bonding_allowed)
        a, b = bond_array.nonzero()
        a, b = [convert_index[i] for i in a], [convert_index[i] for i in b]
        for row, index in enumerate(a):
            # bond_dict is a collections.defaultdict(set)
            bond_dict[index].add(b[row])
        return bond_dict