Skip to content

Commit

Permalink
Lint notebooks with black, nbqa, and pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Sep 15, 2021
1 parent 6a83fb6 commit f78c437
Show file tree
Hide file tree
Showing 11 changed files with 436 additions and 293 deletions.
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.1.1
hooks:
- id: nbqa-isort
- id: nbqa-pyupgrade
args:
- --py36-plus
30 changes: 16 additions & 14 deletions charmm-gui-gmx/charmm-gui-gmx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
"source": [
"class charmm_ethane(mb.Compound):\n",
" def __init__(self):\n",
" super(charmm_ethane, self).__init__()\n",
" mb.load('files/ethane.mol2', compound=self)\n",
" self.name='ETHA'"
" super().__init__()\n",
" mb.load(\"files/ethane.mol2\", compound=self)\n",
" self.name = \"ETHA\""
]
},
{
Expand Down Expand Up @@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"ethane_box.save('box.gro', residues=['ETHA'], overwrite=True)"
"ethane_box.save(\"box.gro\", residues=[\"ETHA\"], overwrite=True)"
]
},
{
Expand All @@ -118,13 +118,13 @@
"metadata": {},
"outputs": [],
"source": [
"with open('box.top', 'w') as f:\n",
" f.write(\"#include \\\"files/charmm36.itp\\\" \\n\")\n",
" f.write(\"#include \\\"files/ETHA.itp\\\" \\n\")\n",
"with open(\"box.top\", \"w\") as f:\n",
" f.write('#include \"files/charmm36.itp\" \\n')\n",
" f.write('#include \"files/ETHA.itp\" \\n')\n",
" f.write(\"[ System ] \\n\")\n",
" f.write('mBuild box of ethane\\n')\n",
" f.write(\"mBuild box of ethane\\n\")\n",
" f.write(\"[ Molecules ] \\n\")\n",
" f.write(\"{} {}\".format(prototype.name, n_ethane))"
" f.write(f\"{prototype.name} {n_ethane}\")"
]
},
{
Expand Down Expand Up @@ -189,7 +189,8 @@
"outputs": [],
"source": [
"import mdtraj\n",
"traj = mdtraj.load('npt.xtc', top='npt.gro')\n",
"\n",
"traj = mdtraj.load(\"npt.xtc\", top=\"npt.gro\")\n",
"rho = mdtraj.density(traj)"
]
},
Expand All @@ -209,14 +210,15 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"%matplotlib inline\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"\n",
"ref = np.loadtxt('ref/rho.dat')\n",
"fig, ax = plt.subplots(1,1)\n",
"ax.scatter(traj.time, rho, label='Simulated', alpha=0.6)\n",
"ax.scatter(ref[:,0], ref[:,1], label='Reference', alpha=0.6)\n",
"ref = np.loadtxt(\"ref/rho.dat\")\n",
"fig, ax = plt.subplots(1, 1)\n",
"ax.scatter(traj.time, rho, label=\"Simulated\", alpha=0.6)\n",
"ax.scatter(ref[:, 0], ref[:, 1], label=\"Reference\", alpha=0.6)\n",
"ax.legend()\n",
"ax.set_ylabel(r\"Density (kg m$^{{-3}}$)\")\n",
"ax.set_xlabel(\"Time (ps)\")"
Expand Down
Loading

0 comments on commit f78c437

Please sign in to comment.