Skip to content

Commit

Permalink
Re-run black (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson authored Jul 13, 2023
1 parent 94875c5 commit 9c9f449
Show file tree
Hide file tree
Showing 17 changed files with 2,313 additions and 997 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Black 23
94875c5bb13a5734b720f99b181e0d6b8639ba39
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
files: ^openff
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: ^openff
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
files: ^openff
2 changes: 1 addition & 1 deletion devtools/conda-envs/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
# openmmforcefields brings in the full toolkit; if that is ever re-packaged
# this should be changed to openff-toolkit-base
- openff-toolkit >= 0.12
- pydantic
- pydantic =1
- pyyaml
- qcportal>=0.15.7
- torsiondrive
Expand Down
4 changes: 3 additions & 1 deletion openff/qcsubmit/common_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
from datetime import date, datetime
from enum import Enum
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple, Union, TYPE_CHECKING

import numpy as np
import qcportal as ptl
Expand Down Expand Up @@ -36,6 +36,8 @@
from openff.qcsubmit.utils.smirnoff import split_openff_molecule


if TYPE_CHECKING:
from pydantic import AbstractSetIntStr
class DatasetConfig(BaseModel):
"""
The basic configurations for all datasets.
Expand Down
10 changes: 1 addition & 9 deletions openff/qcsubmit/tests/results/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@


class _FractalClient(BaseModel):

address: str


def _mock_molecule(entry: _BaseResult, n_conformers: int = 1) -> Molecule:

molecule: Molecule = Molecule.from_smiles(entry.cmiles)

for _ in range(n_conformers):

molecule.add_conformer(
numpy.arange(molecule.n_atoms * 3).reshape((molecule.n_atoms, 3))
* unit.angstrom
Expand All @@ -47,7 +44,6 @@ def _mock_molecule(entry: _BaseResult, n_conformers: int = 1) -> Molecule:


def mock_basic_result_collection(molecules, monkeypatch) -> BasicResultCollection:

collection = BasicResultCollection(
entries={
address: [
Expand Down Expand Up @@ -77,7 +73,7 @@ def mock_basic_result_collection(molecules, monkeypatch) -> BasicResultCollectio
status=RecordStatusEnum.complete,
client=_FractalClient(address=address),
),
molecules[address][int(entry.record_id) - 1]
molecules[address][int(entry.record_id) - 1],
)
for address, entries in self.entries.items()
for entry in entries
Expand All @@ -90,7 +86,6 @@ def mock_basic_result_collection(molecules, monkeypatch) -> BasicResultCollectio
def mock_optimization_result_collection(
molecules, monkeypatch
) -> OptimizationResultCollection:

collection = OptimizationResultCollection(
entries={
address: [
Expand Down Expand Up @@ -138,7 +133,6 @@ def mock_optimization_result_collection(
def mock_torsion_drive_result_collection(
molecules, monkeypatch
) -> TorsionDriveResultCollection:

collection = TorsionDriveResultCollection(
entries={
address: [
Expand Down Expand Up @@ -190,11 +184,9 @@ def mock_torsion_drive_result_collection(
)

def get_molecules(self):

return_value = []

for molecule_id in self.initial_molecule:

molecule = copy.deepcopy(molecules[self.client.address][int(self.id) - 1])
molecule._conformers = [molecule.conformers[int(molecule_id) - 1]]

Expand Down
16 changes: 7 additions & 9 deletions openff/qcsubmit/tests/results/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def _smiles_to_molecule(smiles: str) -> Molecule:

molecule: Molecule = Molecule.from_smiles(smiles, allow_undefined_stereo=True)
molecule.generate_conformers(n_conformers=1)

Expand Down Expand Up @@ -45,7 +44,8 @@ def tautomer_basic_result_collection(monkeypatch) -> BasicResultCollection:

smiles = {
"http://localhost:442": [
_smiles_to_molecule(smiles) for smiles in ["Oc1nnccn1", "C1=NC(=O)NN=C1", "C1=CN=NC(=O)N1"]
_smiles_to_molecule(smiles)
for smiles in ["Oc1nnccn1", "C1=NC(=O)NN=C1", "C1=CN=NC(=O)N1"]
]
}
return mock_basic_result_collection(smiles, monkeypatch)
Expand Down Expand Up @@ -116,16 +116,14 @@ def optimization_result_collection(monkeypatch) -> OptimizationResultCollection:


@pytest.fixture()
def optimization_result_collection_duplicates(monkeypatch) -> OptimizationResultCollection:
def optimization_result_collection_duplicates(
monkeypatch,
) -> OptimizationResultCollection:
"""Create a collection with duplicate enetries accross different addresses which can be reduced to a single entry."""

smiles = {
"http://localhost:442": [
_smiles_to_molecule(smiles="CCCO")
],
"http://localhost:443": [
_smiles_to_molecule(smiles="CCCO")
]
"http://localhost:442": [_smiles_to_molecule(smiles="CCCO")],
"http://localhost:443": [_smiles_to_molecule(smiles="CCCO")],
}
return mock_optimization_result_collection(smiles, monkeypatch)

Expand Down
15 changes: 3 additions & 12 deletions openff/qcsubmit/tests/results/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ def test_batched_indices():


def test_cached_fractal_client_bad_address():

with pytest.raises(ConnectionRefusedError):
cached_fractal_client("http://localhost:1234/")


def test_cached_fractal_client_snowflake():

from qcfractal import FractalSnowflake

snowflake = FractalSnowflake(start_server=False)
Expand All @@ -43,7 +41,6 @@ def test_cached_fractal_client_snowflake():


def test_cached_query_procedures(public_client):

assert len(_record_cache) == 0

record_ids = ["32651863", "32651864"]
Expand All @@ -62,7 +59,6 @@ def test_cached_query_procedures(public_client):


def test_cached_query_molecule(public_client):

assert len(_molecule_cache) == 0

molecule_ids = ["25696236", "25696152"]
Expand Down Expand Up @@ -101,10 +97,7 @@ def test_cached_query_molecule(public_client):
),
],
)
def test_record_to_molecule(
result, query_function, public_client
):

def test_record_to_molecule(result, query_function, public_client):
expected_molecule = Molecule.from_mapped_smiles(result.cmiles)

records = query_function(public_client.address, [result])
Expand All @@ -123,7 +116,7 @@ def test_record_to_molecule(

assert numpy.allclose(
molecule.conformers[0].m_as(unit.bohr),
expected_qc_molecule.geometry.reshape((molecule.n_atoms, 3))
expected_qc_molecule.geometry.reshape((molecule.n_atoms, 3)),
)

are_isomorphic, _ = Molecule.are_isomorphic(molecule, expected_molecule)
Expand All @@ -136,7 +129,6 @@ def test_record_to_molecule(


def test_cached_query_torsion_drive_results(public_client):

assert len(_grid_id_cache) == 0

result = TorsionDriveResult(
Expand All @@ -162,10 +154,9 @@ def test_cached_query_torsion_drive_results(public_client):
}

for grid_id, conformer in zip(molecule.properties["grid_ids"], molecule.conformers):

assert numpy.allclose(
conformer.m_as(unit.bohr),
expected_qc_molecules[grid_id].geometry.reshape((molecule.n_atoms, 3))
expected_qc_molecules[grid_id].geometry.reshape((molecule.n_atoms, 3)),
)

assert len(molecule.properties["grid_ids"]) == 24
Expand Down
Loading

0 comments on commit 9c9f449

Please sign in to comment.