def contains_structures(self, structures): structures_in_population = set( utils.hash_structure(sample.structure) for sample in self.samples) return [ utils.hash_structure(structure) in structures_in_population for structure in structures ]
def _get_unique(self, samples): unique_population = data.Population() unique_structures = set() for sample in samples: hashed_structure = utils.hash_structure(sample.structure) if hashed_structure in unique_structures: continue unique_structures.add(hashed_structure) unique_population.add_samples([sample]) return unique_population
def _filter(self, samples, blacklist): blacklist = set( utils.hash_structure(structure) for structure in blacklist) return Population( sample for sample in samples if utils.hash_structure(sample.structure) not in blacklist)