From dd8c75d118c733db610a007cd9ad3c3bbd3835d7 Mon Sep 17 00:00:00 2001 From: Xiaorui Dong Date: Tue, 12 Sep 2023 13:32:57 -0400 Subject: [PATCH] PEP-8 other corrections --- rdmc/conf.py | 6 ++++-- rdmc/conformer_generation/ts_optimizers.py | 2 +- rdmc/external/logparser/qchem.py | 4 ++-- rdmc/external/xtb_tools/opt.py | 2 +- rdmc/external/xyz2mol.py | 10 +++++----- rdmc/mol.py | 4 ++-- rdmc/ts.py | 4 ++-- rdmc/view.py | 6 ++++-- 8 files changed, 21 insertions(+), 17 deletions(-) diff --git a/rdmc/conf.py b/rdmc/conf.py index 31a14f73..804778f6 100644 --- a/rdmc/conf.py +++ b/rdmc/conf.py @@ -733,9 +733,11 @@ def check_dihed_angle_diff(self, if mask: # Allowing mask some dimensions - def masked_tor(tor): return np.ma.masked_array(tor, mask) + def masked_tor(tor): + return np.ma.masked_array(tor, mask) else: - def masked_tor(tor): return tor + def masked_tor(tor): + return tor # Create an array to store cluster indexes # Initializing all elements to -1 diff --git a/rdmc/conformer_generation/ts_optimizers.py b/rdmc/conformer_generation/ts_optimizers.py index defc70e8..e4c702d7 100644 --- a/rdmc/conformer_generation/ts_optimizers.py +++ b/rdmc/conformer_generation/ts_optimizers.py @@ -271,7 +271,7 @@ def extract_frequencies(self, if freq_idx: freqs = orca_data[freq_idx - 4 - dof: freq_idx - 4] freqs.reverse() - return np.array([float(l.split()[1]) for l in freqs]) + return np.array([float(line.split()[1]) for line in freqs]) else: return None diff --git a/rdmc/external/logparser/qchem.py b/rdmc/external/logparser/qchem.py index 1134d76e..caae92de 100644 --- a/rdmc/external/logparser/qchem.py +++ b/rdmc/external/logparser/qchem.py @@ -35,8 +35,8 @@ def _update_status(self): if 'Thank you very much for using Q-Chem. Have a nice day.' in line: self._finished = True time_str = re.search(self.time_regex, reverse_lines[i + 4]).group() - for l in reverse_lines[i + 1:]: - if 'MAXIMUM OPTIMIZATION CYCLES REACHED' in l: + for rline in reverse_lines[i + 1:]: + if 'MAXIMUM OPTIMIZATION CYCLES REACHED' in rline: self._success = False break else: diff --git a/rdmc/external/xtb_tools/opt.py b/rdmc/external/xtb_tools/opt.py index cad7544e..e0235872 100644 --- a/rdmc/external/xtb_tools/opt.py +++ b/rdmc/external/xtb_tools/opt.py @@ -193,7 +193,7 @@ def run_xtb_calc(mol, confId=0, job="", return_optmol=False, method="gfn2", leve if job == "--hess": with open(xtb_g98) as f: data = f.readlines() - frequencies = np.array([l.split()[-3:] for l in data if "Frequencies" in l], dtype=float).ravel() + frequencies = np.array([line.split()[-3:] for line in data if "Frequencies" in line], dtype=float).ravel() props.update({"frequencies": frequencies}) not save_dir and rmtree(temp_dir) return props diff --git a/rdmc/external/xyz2mol.py b/rdmc/external/xyz2mol.py index 00236ccb..fa7a59c4 100644 --- a/rdmc/external/xyz2mol.py +++ b/rdmc/external/xyz2mol.py @@ -300,12 +300,12 @@ def BO2mol(mol, BO_matrix, atoms, atomic_valence_electrons, """ - l = len(BO_matrix) + l1 = len(BO_matrix) l2 = len(atoms) BO_valences = list(BO_matrix.sum(axis=1)) - if (l != l2): - raise RuntimeError('sizes of adjMat ({0:d}) and Atoms {1:d} differ'.format(l, l2)) + if (l1 != l2): + raise RuntimeError('sizes of adjMat ({0:d}) and Atoms {1:d} differ'.format(l1, l2)) rwMol = Chem.RWMol(mol) @@ -315,8 +315,8 @@ def BO2mol(mol, BO_matrix, atoms, atomic_valence_electrons, 3: Chem.BondType.TRIPLE } - for i in range(l): - for j in range(i + 1, l): + for i in range(l1): + for j in range(i + 1, l1): bo = int(round(BO_matrix[i, j])) if (bo == 0): continue diff --git a/rdmc/mol.py b/rdmc/mol.py index 1f0b0f99..995fbe84 100644 --- a/rdmc/mol.py +++ b/rdmc/mol.py @@ -1906,8 +1906,8 @@ def generate_vdw_mat(rd_mol, else: atom2 = rd_mol.GetAtomWithIdx(atom2_ind) vdw_mat[atom1_ind, atom2_ind] = threshold * \ - (vdw_radii[atom1.GetAtomicNum()] + - vdw_radii[atom2.GetAtomicNum()]) + (vdw_radii[atom1.GetAtomicNum()] + + vdw_radii[atom2.GetAtomicNum()]) return vdw_mat diff --git a/rdmc/ts.py b/rdmc/ts.py index fd67ae97..a40b8216 100644 --- a/rdmc/ts.py +++ b/rdmc/ts.py @@ -106,8 +106,8 @@ def get_all_changing_bonds(r_mol: Union['RDKitMol', 'Mol'], r_bonds, p_bonds = _get_bonds_as_sets(r_mol, p_mol) formed_bonds, broken_bonds = p_bonds - r_bonds, r_bonds - p_bonds changed_bonds = [bond for bond in (r_bonds & p_bonds) - if r_mol.GetBondBetweenAtoms(*bond).GetBondTypeAsDouble() != - p_mol.GetBondBetweenAtoms(*bond).GetBondTypeAsDouble()] + if (r_mol.GetBondBetweenAtoms(*bond).GetBondTypeAsDouble() + != p_mol.GetBondBetweenAtoms(*bond).GetBondTypeAsDouble())] return list(formed_bonds), list(broken_bonds), changed_bonds diff --git a/rdmc/view.py b/rdmc/view.py index 35e8e4ca..944bb2b0 100644 --- a/rdmc/view.py +++ b/rdmc/view.py @@ -163,14 +163,16 @@ def interactive_conformer_viewer(mol, **kwargs): py3Dmol.view: The molecule viewer with slider to view different conformers. """ if isinstance(mol, list) or isinstance(mol, tuple): - def viewer(confId): return mol_viewer(obj=mol[confId], confId=0, **kwargs) + def viewer(confId): + return mol_viewer(obj=mol[confId], confId=0, **kwargs) return interact( viewer, confId=IntSlider(min=0, max=len(mol) - 1, step=1) ) else: - def viewer(confId): return mol_viewer(obj=mol, confId=confId, **kwargs) + def viewer(confId): + return mol_viewer(obj=mol, confId=confId, **kwargs) return interact( viewer, confId=IntSlider(min=0, max=mol.GetNumConformers() - 1, step=1)