Skip to content

Commit

Permalink
Temp as value (#306)
Browse files Browse the repository at this point in the history
* update hooks

* fix conversion

* black update

* fix test

* merge fix

* pr suggestion
  • Loading branch information
t-young31 authored Oct 17, 2023
1 parent d1b502e commit eab64b4
Show file tree
Hide file tree
Showing 147 changed files with 154 additions and 1,049 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.9.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
rev: v1.5.1
hooks:
- id: mypy
exclude: "tests/|doc/|examples/"
Expand Down
11 changes: 4 additions & 7 deletions autode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import importlib.metadata

from autode import methods
from autode import geom
from autode import pes
Expand Down Expand Up @@ -25,14 +27,10 @@
from autode.utils import temporary_config

"""
Bumping the version number requires following the release proceedure:
- Update changelog (doc/changelog.rst)
Bumping the version number requires following the release procedure:
- Run tests/benchmark.py with both organic and organometallic sets
- Change __version__ here and in setup.py
- Release on conda-forge
- Fork https://github.com/conda-forge/autode-feedstock
- Make a local branch
Expand All @@ -41,8 +39,7 @@
- Merge when tests pass
"""

__version__ = "1.4.1"

__version__ = importlib.metadata.version("autode")

__all__ = [
"KeywordsSet",
Expand Down
5 changes: 0 additions & 5 deletions autode/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def group(self) -> int:
"""

for group_idx in range(1, 18):

if self.label in PeriodicTable.group(group_idx):
return group_idx

Expand All @@ -242,7 +241,6 @@ def period(self) -> int:
"""

for period_idx in range(1, 7):

if self.label in PeriodicTable.period(period_idx):
return period_idx

Expand Down Expand Up @@ -692,7 +690,6 @@ def moi(self) -> MomentOfInertia:
moi = MomentOfInertia(np.zeros(shape=(3, 3)), units="amu Å^2")

for atom in self:

mass, (x, y, z) = atom.mass, atom.coord

moi[0, 0] += mass * (y**2 + z**2)
Expand Down Expand Up @@ -887,7 +884,6 @@ def are_planar(self, distance_tol: Distance = Distance(1e-3, "Å")) -> bool:
normal_vec = np.cross(arr[1, :] - x0, arr[2, :] - x0)

for i in range(3, len(self)):

# Calculate the 0->i atomic vector, which must not have any
# component in the direction in the normal if the atoms are planar
if np.dot(normal_vec, arr[i, :] - x0) > distance_tol_float:
Expand Down Expand Up @@ -1253,7 +1249,6 @@ def dihedral(self, w: int, x: int, y: int, z: int) -> Angle:


class PeriodicTable:

# fmt: off
table = np.array(
[['H', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'He'],
Expand Down
4 changes: 0 additions & 4 deletions autode/bond_rearrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def add_bond_rearrangment(bond_rearrangs, reactant, product, fbonds, bbonds):
bbond_atoms = [atom for bbond in bbonds for atom in bbond]
for fbond in fbonds:
for idx in fbond:

if (
reactant.graph.degree(idx)
== reactant.atoms[idx].maximal_valance
Expand Down Expand Up @@ -358,7 +357,6 @@ def get_fbonds_bbonds_2b(
for bbond1, bbond2 in itertools.product(
all_possible_bbonds[0], all_possible_bbonds[1]
):

possible_brs = add_bond_rearrangment(
possible_brs, reac, prod, fbonds=[], bbonds=[bbond1, bbond2]
)
Expand Down Expand Up @@ -672,7 +670,6 @@ def strip_equiv_bond_rearrs(possible_brs, mol, depth=6):

# Compare bond_rearrang to all those already considered to be unique,
for unique_br in unique_brs:

if unique_br.get_active_atom_neighbour_lists(
species=mol, depth=depth
) == br.get_active_atom_neighbour_lists(species=mol, depth=depth):
Expand Down Expand Up @@ -736,7 +733,6 @@ def prune_small_ring_rearrs(possible_brs, mol):

# Check against all other rearrangements
for j, other_br in enumerate(possible_brs):

# Only consider brs with the same set of elements
if elems[i] != elems[j]:
continue
Expand Down
3 changes: 0 additions & 3 deletions autode/calculations/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(
n_cores: int = 1,
point_charges: Optional[List[PointCharge]] = None,
):

# Calculation names that start with "-" can break EST methods
self.name = f"{_string_without_leading_hyphen(name)}_{method.name}"

Expand Down Expand Up @@ -185,7 +184,6 @@ def _no_except_set_hessian(self) -> None:
self.molecule.hessian = self.method.hessian_from(self)

def clean_up(self, force: bool = False, everything: bool = False) -> None:

if not self.method.uses_external_io: # Then there are no i/o files
return None

Expand All @@ -203,7 +201,6 @@ def clean_up(self, force: bool = False, everything: bool = False) -> None:
logger.info(f"Deleting: {set(filenames)}")

for filename in [fn for fn in set(filenames) if fn is not None]:

try:
os.remove(filename)
except FileNotFoundError:
Expand Down
2 changes: 0 additions & 2 deletions autode/calculations/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class CalculationOutput:
def __init__(self, filename: Optional[str] = None):

self._filename = filename

@property
Expand All @@ -17,7 +16,6 @@ def filename(self) -> Optional[str]:

@filename.setter
def filename(self, value: str):

self._filename = str(value)
self.clear()

Expand Down
1 change: 0 additions & 1 deletion autode/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ def __setattr__(self, key, value):
value = Allocation(value).to("MB")

if key == "freq_scale_factor":

if value is not None:
if not (0.0 < value <= 1.0):
raise ValueError(
Expand Down
6 changes: 2 additions & 4 deletions autode/conformers/conf_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _get_atoms_rotated_stereocentres(species, atoms, rand):
]

# Check on every pair of stereocenters
for (i, j) in combinations(stereocentres, 2):
for i, j in combinations(stereocentres, 2):
if (i, j) not in species.graph.edges:
continue

Expand Down Expand Up @@ -232,8 +232,7 @@ def _add_dist_consts_for_stereocentres(species, dist_consts):
dist_consts[(atom_i, atom_j)] = species.distance(atom_i, atom_j)

# Check on every pair of stereocenters
for (atom_i, atom_j) in combinations(stereocentres, 2):

for atom_i, atom_j in combinations(stereocentres, 2):
# If they are not bonded don't alter
if (atom_i, atom_j) not in species.graph.edges:
continue
Expand All @@ -243,7 +242,6 @@ def _add_dist_consts_for_stereocentres(species, dist_consts):
for i_neighbour in species.graph.neighbors(atom_i):
for j_neighbour in species.graph.neighbors(atom_j):
if i_neighbour != atom_j and j_neighbour != atom_i:

# Fix the distance to the current value
dist = species.distance(i_neighbour, j_neighbour)
dist_consts[(i_neighbour, j_neighbour)] = dist
Expand Down
1 change: 0 additions & 1 deletion autode/conformers/conformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def atoms(self, value: Optional[Atoms]):
return

for i, atom in enumerate(value):

parent_atom = self._parent_atoms[i]
if atom.label != parent_atom.label:
raise ValueError(
Expand Down
4 changes: 0 additions & 4 deletions autode/conformers/conformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def prune_on_energy(
idxs_with_energy = [j for j in idxs_with_energy if j < len(self)]

if np.abs(conf.energy - avg_e) / std_dev_e > n_sigma:

logger.warning(
f"Conformer {idx} had an energy >{n_sigma}σ "
f"from the average - removing"
Expand All @@ -150,7 +149,6 @@ def prune_on_energy(
for o_idx in idxs_with_energy
if o_idx != idx
):

logger.info(f"Conformer {idx} had a non unique energy")
del self[idx]
continue
Expand Down Expand Up @@ -195,15 +193,13 @@ def prune_on_rmsd(
# Only enumerate up to but not including the final index, as at
# least one of the conformers must be unique in geometry
for idx in reversed(range(len(self) - 1)):

conf = self[idx]

if any(
calc_heavy_atom_rmsd(conf.atoms, other.atoms) < rmsd_tol
for o_idx, other in enumerate(self)
if o_idx != idx
):

logger.info(
f"Conformer {idx} was close in geometry to at "
f"least one other - removing"
Expand Down
1 change: 0 additions & 1 deletion autode/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Constants:

n_a = 6.022140857e23 # molecules mol-1

ha_to_kcalmol = ha2kcalmol = 627.509 # Hartree^-1 kcal mol^-1
Expand Down
1 change: 0 additions & 1 deletion autode/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def get_neighbour_list(

dists_and_atom_labels = {}
for atom_j, dist in enumerate(distance_vector):

if index_set is not None and atom_j not in index_set:
continue

Expand Down
5 changes: 0 additions & 5 deletions autode/hessians.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@


class Hessian(ValueArray):

implemented_units = [
ha_per_ang_sq,
ha_per_a0_sq,
Expand Down Expand Up @@ -220,7 +219,6 @@ def _proj_matrix(self) -> np.ndarray:
m_half = np.diag(np.sqrt(masses))

for t_i in (t1, t2, t3, t4, t5, t6):

t_i[:] = np.dot(m_half, np.array(t_i))
t_i /= np.linalg.norm(t_i)

Expand Down Expand Up @@ -427,7 +425,6 @@ def __init__(
shift: Distance,
n_cores: Optional[int] = None,
):

self._species = species
self._method = method
self._keywords = self._validated(keywords)
Expand Down Expand Up @@ -467,7 +464,6 @@ def calculate(self) -> None:

# Although n_rows may be < n_cores there will not be > n_rows processes
with ProcessPool(max_workers=self._n_total_cores) as pool:

func_name = "_cdiff_row" if self._do_c_diff else "_diff_row"

jobs = [
Expand Down Expand Up @@ -541,7 +537,6 @@ def _idxs_to_calculate(self) -> Iterator:
need to be calculated"""

for row_idx in range(self._n_rows):

if row_idx not in self._calculated_rows:
self._calculated_rows.append(row_idx)

Expand Down
4 changes: 0 additions & 4 deletions autode/input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def xyz_file_to_atoms(filename: str) -> Atoms:
n_atoms = 0

for i, line in enumerate(open(filename, "r")):

if i == 0: # First line in an xyz file is the number of atoms
n_atoms = _n_atoms_from_first_xyz_line(line)
continue
Expand Down Expand Up @@ -118,7 +117,6 @@ def xyz_file_to_molecules(filename: str) -> Sequence["Molecule"]:
molecules = []

for i in range(0, len(lines), n_atoms + 2):

atoms = []
title_line = StringDict(lines[i + 1])
for j, line in enumerate(lines[i + 2 : i + n_atoms + 2]):
Expand Down Expand Up @@ -152,7 +150,6 @@ def attrs_from_xyz_title_line(filename: str) -> StringDict:


def _check_xyz_file_exists(filename: str) -> None:

if not os.path.exists(filename):
raise XYZfileDidNotExist(f"{filename} did not exist")

Expand All @@ -168,7 +165,6 @@ def _set_attr_from_title_line(
title_line: StringDict,
key_in_line: Optional[str] = None,
) -> None:

if key_in_line is None:
key_in_line = attr # Default to e.g. charge attribute is "charge = 0"
try:
Expand Down
2 changes: 0 additions & 2 deletions autode/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def get_first_available_method(
(autode.exceptions.MethodUnavailable):
"""
for method in possibilities:

if method.is_available:
return method

Expand All @@ -137,7 +136,6 @@ def get_defined_method(name, possibilities) -> "Method":

for method in possibilities:
if method.name.lower() == name.lower():

if method.is_available:
return method

Expand Down
Loading

0 comments on commit eab64b4

Please sign in to comment.