Skip to content

Commit

Permalink
Merge branch 'main' into redirect-faq
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshanuikabundi authored Oct 1, 2024
2 parents 71a34e9 + 31e4c4b commit b3273e9
Show file tree
Hide file tree
Showing 50 changed files with 370 additions and 455 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
disable_search: true
fail_ci_if_error: true
14 changes: 5 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install linters
- name: Install ruff
run: |
pip install black isort
pip install ruff
- name: Run black
- name: Run ruffblack
run: |
black --check openff
- name: Run isort
run: |
isort --check openff
ruff check .
31 changes: 3 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,10 @@ ci:
autoupdate_schedule: "quarterly"
files: ^openff|(^examples/((?!deprecated).)*$)|^docs|(^utilities/((?!deprecated).)*$)
repos:
- repo: https://github.com/psf/black
rev: 24.4.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 7.1.0
hooks:
- id: flake8
files: ^openff|(^utilities/((?!deprecated).)*$)
additional_dependencies: [
'flake8-absolute-import',
'flake8-no-pep420',
'flake8-bugbear',
]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
hooks:
- id: nbqa-pyupgrade
args:
- --py39-plus
- id: nbqa-isort
- id: nbqa-flake8
args:
- '--select=F'
- id: ruff
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
Expand Down
3 changes: 1 addition & 2 deletions devtools/scripts/build_cookiecutter_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import json

import sys

release_tag = sys.argv[1]
python_version = sys.argv[2]
Expand Down
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# openff-toolkit documentation build configuration file, created by
# sphinx-quickstart on Sun Dec 3 23:12:54 2017.
Expand All @@ -19,12 +18,12 @@
#
import os
import sys
from importlib.util import find_spec as find_import_spec

import openff.toolkit

sys.path.insert(0, os.path.abspath("."))

import sphinx

import openff.toolkit

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -128,8 +127,6 @@
# sphinx-notfound-page
# https://github.com/readthedocs/sphinx-notfound-page
# Renders a 404 page with absolute links
from importlib.util import find_spec as find_import_spec

if find_import_spec("notfound"):
extensions.append("notfound.extension")

Expand Down Expand Up @@ -292,7 +289,10 @@
"OpenFF Toolkit Documentation",
author,
"openff-toolkit",
"A modern, extensible library for molecular mechanics force field science from the Open Force Field Consortium.",
(
"A modern, extensible library for molecular mechanics force field science from the Open Force "
"Field Consortium.",
),
"Miscellaneous",
),
]
5 changes: 2 additions & 3 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
* `minor` increments add features but do not break API compatibility
* `micro` increments represent bugfix releases or improvements in documentation

## Upcoming Release
## Current development

### Improved documentation and warnings

- [PR #1939](https://github.com/openforcefield/openff-toolkit/pull/1939): Resolves [#1587](https://github.com/openforcefield/openff-toolkit/pull/1587) by emitting a warning when from_openeye or from_rdkit try to load a molecule with multiple disconnected components.
- [PR #1934](https://github.com/openforcefield/openff-toolkit/pull/1934): Fold the Toolkit FAQ into the new org-level FAQ: <https://docs.openforcefield.org/faq>


## 0.16.4

### Bugfixes
Expand Down
12 changes: 6 additions & 6 deletions docs/users/molecule_cookbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
"source": [
"# Workaround for https://github.com/conda-forge/qcfractal-feedstock/issues/43\n",
"try:\n",
" import qcportal # noqa\n",
" import qcportal # noqa: RUF100\n",
"except ImportError:\n",
" pass\n",
"import sys\n",
"\n",
"ipython = get_ipython() # noqa\n",
"ipython = get_ipython() # noqa: RUF100\n",
"\n",
"\n",
"def hide_traceback(\n",
Expand Down Expand Up @@ -1413,9 +1413,9 @@
}
],
"source": [
"from openmm.app.pdbfile import PDBFile\n",
"import openmm.app\n",
"\n",
"openmm_topology = PDBFile(\"zw_l_alanine.pdb\").getTopology()\n",
"openmm_topology = openmm.app.PDBFile(\"zw_l_alanine.pdb\").getTopology()\n",
"openff_topology = Topology.from_openmm(openmm_topology, unique_molecules=[zw_l_alanine])\n",
"\n",
"from_openmm_topology = openff_topology.molecule(0)\n",
Expand Down Expand Up @@ -1492,9 +1492,9 @@
}
],
"source": [
"from mdtraj import load_pdb\n",
"import mdtraj\n",
"\n",
"mdtraj_topology = load_pdb(\"zw_l_alanine.pdb\").topology\n",
"mdtraj_topology = mdtraj.load_pdb(\"zw_l_alanine.pdb\").topology\n",
"openff_topology = Topology.from_mdtraj(mdtraj_topology, unique_molecules=[zw_l_alanine])\n",
"\n",
"from_mdtraj_topology = openff_topology.molecule(0)\n",
Expand Down
5 changes: 2 additions & 3 deletions docs/users/pdb_cookbook/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@
"outputs": [],
"source": [
"import sys\n",
"import warnings\n",
"\n",
"from openff.toolkit import Molecule, Topology\n",
"\n",
"ipython = get_ipython() # noqa\n",
"ipython = get_ipython()\n",
"\n",
"\n",
"def hide_traceback(\n",
Expand All @@ -93,8 +94,6 @@
"ipython.showtraceback = hide_traceback\n",
"\n",
"# Hide NumPy warnings\n",
"import warnings\n",
"\n",
"warnings.filterwarnings(\n",
" \"ignore\",\n",
" r\"The value of the smallest subnormal for \",\n",
Expand Down
6 changes: 5 additions & 1 deletion examples/conformer_energies/conformer_energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ def compute_conformer_energies_from_file(filename):

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Perform energy minimization on a molecule, potentially with many conformers. For each conformer, this script will provide the initial energy, minimized energy, and RMSD between the initial and minimized structure (both as STDOUT and a csv file). The minimized conformers will be written out to SDF."
description=(
"Perform energy minimization on a molecule, potentially with many conformers. For each conformer, this "
"script will provide the initial energy, minimized energy, and RMSD between the initial and minimized "
"structure (both as STDOUT and a csv file). The minimized conformers will be written out to SDF."
),
)
parser.add_argument(
"-f", "--filename", help="Name of an input file containing conformers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
}
],
"source": [
"# Create a parameterized OpenMM System from the PDB topology without bond constraints so we can convert to other packages\n",
"# Create a parameterized OpenMM System from the PDB topology without bond constraints\n",
"# so we can convert to other packages\n",
"system = forcefield.createSystem(\n",
" pdbfile.topology,\n",
" nonbondedMethod=app.PME,\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"source": [
"# Retrieve protein and ligand files for BRD4 and a docked inhibitor from the benchmark systems GitHub repository\n",
"# https://github.com/MobleyLab/benchmarksets\n",
"import parmed\n",
"import requests\n",
"from openmm import XmlSerializer, app, unit\n",
"from openmm.app import HBonds, NoCutoff, PDBFile\n",
"\n",
"repo_url = (\n",
" \"https://raw.githubusercontent.com/MobleyLab/benchmarksets/master/input_files/\"\n",
Expand Down Expand Up @@ -92,16 +95,6 @@
"</div>"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from openmm import XmlSerializer, app, unit\n",
"from openmm.app import HBonds, NoCutoff, PDBFile"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand All @@ -120,8 +113,6 @@
"ligand_pdbfile = PDBFile(\"ligand.pdb\")\n",
"\n",
"# Convert OpenMM System object containing ligand parameters into a ParmEd Structure.\n",
"import parmed\n",
"\n",
"ligand_structure = parmed.openmm.load_topology(\n",
" ligand_pdbfile.topology, ligand_system, xyz=ligand_pdbfile.positions\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,8 @@
}
],
"source": [
"fluorine = [atom for atom in ligand.atoms if atom.symbol == \"F\"][0]\n",
"carbon = [neighbor_atom for neighbor_atom in fluorine.bonded_atoms][0]\n",
"fluorine = next(atom for atom in ligand.atoms if atom.symbol == \"F\")\n",
"carbon = next(iter(fluorine.bonded_atoms))\n",
"fluorine_carbon_bond_indices = (\n",
" fluorine.molecule_atom_index,\n",
" carbon.molecule_atom_index,\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/virtual_sites/vsite_showcase.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@
"_energy_difference = from_openmm(energy_difference)\n",
"\n",
"print(\n",
" f\"Results for: OpenFF – OpenMM comparison (per molecule) \\n\"\n",
" f\"Results for: OpenFF – OpenMM comparison (per molecule) \\n\" # noqa: RUF001\n",
" f\"Energy difference ({_energy_difference.units}):\\n\\t\"\n",
" f\"{_energy_difference.m:0.3e}\\n\"\n",
" f\"Coordinates difference ({coordinate_difference.units}, norm):\\n\\t\"\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/visualization/visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
},
"outputs": [],
"source": [
"from openff.toolkit import Molecule, Topology"
"from openff.toolkit import Molecule, Topology\n",
"from openff.toolkit.utils import get_data_file_path"
]
},
{
Expand Down Expand Up @@ -225,7 +226,7 @@
}
],
"source": [
"display(m) # noqa"
"display(m)"
]
},
{
Expand Down Expand Up @@ -733,7 +734,6 @@
},
"outputs": [],
"source": [
"from openff.toolkit.utils.utils import get_data_file_path\n",
"\n",
"topology = Topology.from_pdb(\n",
" get_data_file_path(\"systems/test_systems/T4_lysozyme_water_ions.pdb\")\n",
Expand Down
4 changes: 1 addition & 3 deletions openff/toolkit/_tests/_stale_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ def test_electrostatics_options(self):
# Change electrostatics method
forcefield.forces["Electrostatics"].method = method
f = partial(check_system_creation_from_molecule, forcefield, molecule)
f.description = "Testing {} parameter assignment using molecule {}".format(
offxml_file_path, molecule.name
)
f.description = f"Testing {offxml_file_path} parameter assignment using molecule {molecule.name}"
# yield f
# TODO: Implement a similar test, where we compare OpenMM energy evals from an
# AMBER-parameterized system to OFF-parameterized systems
Expand Down
4 changes: 2 additions & 2 deletions openff/toolkit/_tests/create_molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ def propane_from_smiles_w_vsites():
def tip5_water():
# Make a TIP5 water
molecule = Molecule.from_smiles("[H][O][H]")
O1 = [atom for atom in molecule.atoms if atom.atomic_number == 8][0]
H1, H2 = [atom for atom in O1.bonded_atoms if atom.atomic_number == 1]
O1 = next(atom for atom in molecule.atoms if atom.atomic_number == 8)
H1, H2 = (atom for atom in O1.bonded_atoms if atom.atomic_number == 1)
molecule.add_divalent_lone_pair_virtual_site(
(H1, O1, H2),
0.7 * unit.angstrom,
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_reference(constrained, mol):
by version 0.8.0 of the toolkit"""
# TODO: Also test periodic vs. vacuum
with open(
get_data_file_path("reference_energies/reference_after_1007.json"), "r"
get_data_file_path("reference_energies/reference_after_1007.json")
) as fi:
reference = json.loads(fi.read())

Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def find_readme_examples() -> list[str]:
if readme_file_path is None:
return list()

with open(readme_file_path, "r") as f:
with open(readme_file_path) as f:
readme_content = f.read()

return re.findall("```python(.*?)```", readme_content, flags=re.DOTALL)
Expand Down
Loading

0 comments on commit b3273e9

Please sign in to comment.