Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Flake8 on CI and fix issues #11147

Merged
merged 5 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Static Analysis
on: [push, pull_request]
jobs:
python-linting:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2

- name: set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: install Python packages
run: |
pip install --upgrade pip
pip install --upgrade flake8

- name: Run flake8 to verify PEP8-compliance of Python code
run: flake8 -j3
boegel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sources = [
]
checksums = [
'a1a2e3e763ef5baecea258732518d75775639db26e60af1634ab385ed89224d1', # stable_3Mar2020.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
]

local_source_dir_name = '%(namelower)s-%(version)s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sources = [
patches = ['lammps-stable_3Mar2020_hack_openmp_gcc9.patch']
checksums = [
'a1a2e3e763ef5baecea258732518d75775639db26e60af1634ab385ed89224d1', # stable_3Mar2020.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
'41a0bcb828be22d38bb489bbd4b1fd7803d7771a2308371f01e961c52b8c869f', # lammps-stable_3Mar2020_hack_openmp_gcc9.patch
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sources = [
]
checksums = [
'a1a2e3e763ef5baecea258732518d75775639db26e60af1634ab385ed89224d1', # stable_3Mar2020.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
]

local_source_dir_name = '%(namelower)s-%(version)s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sources = [
patches = ['LAMMPS-3Mar2020_fix-docs-build.patch']
checksums = [
'a1a2e3e763ef5baecea258732518d75775639db26e60af1634ab385ed89224d1', # stable_3Mar2020.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
'7f010853d81022f286cf32e3babe252d5cc7c0bfb274bee5a2c64e810e170239', # LAMMPS-3Mar2020_fix-docs-build.patch
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sources = [
]
checksums = [
'5380c1689a93d7922e3d65d9c186401d429878bb3cbe9a692580d3470d6a253f', # stable_7Aug2019.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
]

local_source_dir_name = '%(namelower)s-%(version)s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sources = [
]
checksums = [
'5380c1689a93d7922e3d65d9c186401d429878bb3cbe9a692580d3470d6a253f', # stable_7Aug2019.tar.gz
'5e5211f64113e8a38c102f8542fd59169b689fdb92afbff29c3b88f802f1a96c', # lammps_vs_yaff_test_single_point_energy.py
'c28fa5a1ea9608e4fd8686937be501c3bed8cc03ce1956f1cf0a1efce2c75349', # lammps_vs_yaff_test_single_point_energy.py
]

local_source_dir_name = '%(namelower)s-%(version)s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@

import numpy as np
import os
import h5py
from mpi4py import MPI
from glob import glob
from yaff import *
from yaff import log, System, angstrom, ForceField, swap_noncovalent_lammps
from molmod import kjmol
from io import StringIO
import tempfile


Expand All @@ -42,31 +39,34 @@ def main():
np.random.seed(5)
# Turn off logging for all processes, it can be turned on for one selected process later on
log.set_level(log.silent)
if rank==0: log.set_level(log.medium)
if rank == 0:
log.set_level(log.medium)

# Load in the structure and the force field
system = System.from_file(init_chk)

# Initialize the Yaff and LAMMPS force fields
rcut = 12*angstrom
ff_yaff = ForceField.generate(system, pars_txt, rcut=rcut, smooth_ei=False, gcut_scale=1.5, alpha_scale=3.2)#, tailcorrections=True)
ff = swap_noncovalent_lammps(ff_yaff, fn_system='lammps.dat', fn_log="log.lammps", suffix='', fn_table='lammps_smoothei2.table', comm=comm)
rcut = 12 * angstrom
ff_yaff = ForceField.generate(system, pars_txt, rcut=rcut, smooth_ei=False,
gcut_scale=1.5, alpha_scale=3.2) # , tailcorrections=True)
ff = swap_noncovalent_lammps(ff_yaff, fn_system='lammps.dat', fn_log="log.lammps",
suffix='', fn_table='lammps_smoothei2.table', comm=comm)

# Print out the Yaff single-point energy
print('Yaff energy')
energy_yaff = ff_yaff.compute()
print(energy_yaff/kjmol)
print(energy_yaff / kjmol)
for part in ff_yaff.parts:
print('%s: %.3f kJ/mol' %(part.name,part.energy/kjmol))
print('%s: %.3f kJ/mol' % (part.name, part.energy / kjmol))

# Print out the LAMMPS single-point energy
print('LAMMPS energy')
energy_lammps = ff.compute()
print(energy_lammps/kjmol)
print(energy_lammps / kjmol)
for part in ff.parts:
print('%s: %.3f kJ/mol' %(part.name,part.energy/kjmol))
print('%s: %.3f kJ/mol' % (part.name, part.energy / kjmol))

assert np.abs(energy_yaff- energy_lammps) < 1*kjmol, "The two energies are not the same"
assert np.abs(energy_yaff - energy_lammps) < 1 * kjmol, "The two energies are not the same"


INIT_CHK = """bonds kind=intar 592,2
Expand Down Expand Up @@ -1274,7 +1274,7 @@ def main():

# Bond parameters
# ----------------------------------------------------
# KEY label0 label1 P_AB
# KEY label0 label1 P_AB
# ----------------------------------------------------
FIXQ:BOND C_PH C_PH 0.0000928607
FIXQ:BOND C_CA C_PC 0.0432515406
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

model.fit(x_train, y_train, epochs=5)

model.evaluate(x_test, y_test, verbose=2)
model.evaluate(x_test, y_test, verbose=2)