def check_structure(self, _=None): if self.structure is None: self.text.value = "" else: self.text.value = "" self.mfchk = MOFChecker.from_ase(self.structure, primitive=False) issue_found = False for (check_name, check) in self.mfchk.checks.items(): if check_name in ENABLED_CHECKS: if not check.is_ok: issue_found = True self.text.value += "\u2705 OK: " if check.is_ok else "\u274C Fail: " self.text.value += f"{check.description} </br>" self.check_button.button_style = "danger" if issue_found else "success"
def test_lone_molecule_past_issue(): atoms = read(os.path.join(THIS_DIR, "test_files", "floating_check.cif")) mofchecker = MOFChecker.from_ase(atoms) assert len(mofchecker.lone_molecule_indices) == 1 assert len(mofchecker.lone_molecule_indices[0]) == 5 species = [] for ind in mofchecker.lone_molecule_indices[0]: species.append(str(mofchecker.structure[ind].specie)) assert set(species) == set(["H", "H", "H", "H", "C"]) assert mofchecker.has_lone_molecule == True mofchecker = MOFChecker( Structure.from_file( os.path.join(THIS_DIR, "test_files", "OTOXIF_clean.cif"))) assert mofchecker.has_lone_molecule == False
def test_lone_molecule(): mofchecker = MOFChecker( Structure.from_file( os.path.join(THIS_DIR, "test_files", "ABAVIJ_clean.cif"))) assert mofchecker.has_lone_molecule == False mofchecker = MOFChecker( Structure.from_file( os.path.join(THIS_DIR, "test_files", "HKUST_floating.cif"))) assert mofchecker.has_lone_molecule == True assert mofchecker.lone_molecule_indices == [[144]] atoms = read(os.path.join(THIS_DIR, "test_files", "overvalent_h.cif")) mofchecker = MOFChecker.from_ase(atoms, primitive=False) assert len(mofchecker.lone_molecule_indices) == 3
def check_structure(self, _=None): if self.structure is None: return self.mfchk = MOFChecker.from_ase(self.structure, primitive=False) self.checks = [] if self.structure: self.checks = [ check for (check_name, check) in self.mfchk.checks.items() if check_name in ENABLED_CHECKS ] issue_found = False with self._output: clear_output() for check in self.checks: if not check.is_ok: issue_found = True try: selection = list( chain.from_iterable(check.flagged_indices)) except TypeError: selection = check.flagged_indices button = ipw.Button(description="Select", layout={"width": "initial"}) button.on_click( fct.partial(self._select_atoms, selection=selection)) text = ipw.HTML("Found " + check.name.lower()) display(ipw.HBox([text, button])) if (self.mfchk.undercoordinated_c_candidate_positions + self.mfchk.undercoordinated_n_candidate_positions): self.missing_h_button.disabled = False self.missing_h_button.on_click(self.add_missing_hydrogens) display( ipw.HBox([ ipw.HTML("Missing hydrogens found"), self.missing_h_button ])) if not issue_found: display(ipw.HTML("No issues found \u2705"))