Skip to content

Commit

Permalink
PEP-8 other corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoruiDong committed Sep 12, 2023
1 parent ca4c585 commit dd8c75d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
6 changes: 4 additions & 2 deletions rdmc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rdmc/conformer_generation/ts_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions rdmc/external/logparser/qchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rdmc/external/xtb_tools/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions rdmc/external/xyz2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rdmc/mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions rdmc/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 4 additions & 2 deletions rdmc/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dd8c75d

Please sign in to comment.