Skip to content

Commit

Permalink
Add Pylint (#55)
Browse files Browse the repository at this point in the history
* Disable PSM3 in CI pipelines

* Fix filepaths and variable names

* Python best coding practices

Address pylint rules W0611, W0102, W1401, E1120, C0121, C0123, C0325, R0124, R1714.

* Fix f-strings and incorrect indentation levels

Address pylint rules W0311, W1309.

* Add pylint

* Rewrite serialization code with safer alternatives

Address Pylint rules W0123, R1722.

* fix sample script

* fix bug when standarizing data from Landgesell

* fix bug in peptide section of the tutorial

* clean-up output from tutorials

* Allow custom Python executables

* Comply with output directory flag from argparse

* fix on running globular_protein script

* Fix exit strategy

* remove not plot condition

* Fix unit system

* remove code repetition in standarize_data.py

---------

Co-authored-by: blancoapa <[email protected]>
Co-authored-by: blancoapa <[email protected]>
Co-authored-by: Pao <[email protected]>
  • Loading branch information
4 people committed May 16, 2024
1 parent d10d172 commit 9b6cc37
Show file tree
Hide file tree
Showing 38 changed files with 784 additions and 1,417 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ permissions:
jobs:
ubuntu:
runs-on: ubuntu-latest
env:
FI_PROVIDER: "^psm3,psm3;ofi_rxd"
OMPI_MCA_mtl_ofi_provider_exclude: psm3
steps:
- name: Setup EESSI
uses: eessi/github-action-eessi@v3
Expand All @@ -20,16 +23,17 @@ jobs:
- name: Install dependencies
run: |
module load ESPResSo/4.2.1-foss-2023a
python3 -m venv --system-site-packages pymbe
source pymbe/bin/activate
python3 -m venv --system-site-packages venv
source venv/bin/activate
python3 maintainer/configure_venv.py
python3 -m pip install -r requirements.txt
python3 -m pip install "pdoc==14.3"
python3 -m pip install "pdoc==14.3" "pylint==3.0.3"
deactivate
- name: Run testsuite
run: |
module load ESPResSo/4.2.1-foss-2023a
source pymbe/bin/activate
source venv/bin/activate
make pylint
make tests
make docs
deactivate
Expand Down
45 changes: 45 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[MESSAGES CONTROL]

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
confidence=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=all

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=dangerous-default-value, # W0102
duplicate-key, # W0109
eval-used, # W0123
assert-on-tuple, # W0199
bad-indentation, # W0311
wildcard-import, # W0401
unused-import, # W0611
unused-variable, # W0612
unused-argument, # W0613
unused-wildcard-import, # W0614
f-string-without-interpolation, # W1309
anomalous-backslash-in-string, # W1401
deprecated-method, # W1505
comparison-with-itself, # R0124
cyclic-import, # R0401
trailing-comma-tuple, # R1707
consider-using-in, # R1714
consider-using-sys-exit, # R1722
singleton-comparison, # C0121
unidiomatic-typecheck, # C0123
bad-classmethod-argument, # C0202
superfluous-parens, # C0325
undefined-variable, # E0602
no-value-for-parameter, # E1120
42 changes: 24 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@
.PHONY: visual
.PHONY: clean

PYTHON = python3

docs:
mkdir -p ./documentation
pdoc ./pyMBE.py -o ./documentation --docformat google
PDOC_ALLOW_EXEC=0 ${PYTHON} -m pdoc ./pyMBE.py -o ./documentation --docformat google

tests:
python3 testsuite/lj_tests.py
python3 testsuite/set_particle_acidity_test.py
python3 testsuite/bond_tests.py
python3 testsuite/generate_perpendicular_vectors_test.py
python3 testsuite/create_molecule_position_test.py
python3 testsuite/seed_test.py
python3 testsuite/read-write-df_test.py
python3 testsuite/parameter_test.py
python3 testsuite/henderson_hasselbalch_tests.py
python3 testsuite/cph_ideal_tests.py
python3 testsuite/grxmc_ideal_tests.py
python3 testsuite/peptide_tests.py
python3 testsuite/gcmc_tests.py
python3 testsuite/weak_polyelectrolyte_dialysis_test.py
python3 testsuite/globular_protein_tests.py
${PYTHON} testsuite/lj_tests.py
${PYTHON} testsuite/set_particle_acidity_test.py
${PYTHON} testsuite/bond_tests.py
${PYTHON} testsuite/generate_perpendicular_vectors_test.py
${PYTHON} testsuite/create_molecule_position_test.py
${PYTHON} testsuite/seed_test.py
${PYTHON} testsuite/read-write-df_test.py
${PYTHON} testsuite/parameter_test.py
${PYTHON} testsuite/henderson_hasselbalch_tests.py
${PYTHON} testsuite/cph_ideal_tests.py
${PYTHON} testsuite/grxmc_ideal_tests.py
${PYTHON} testsuite/peptide_tests.py
${PYTHON} testsuite/gcmc_tests.py
${PYTHON} testsuite/weak_polyelectrolyte_dialysis_test.py
${PYTHON} testsuite/globular_protein_tests.py

sample:
python3 sample_scripts/peptide_simulation_example.py
${PYTHON} samples/peptide.py

visual:
python3 handy_scripts/vmd-traj.py
${PYTHON} visualization/vmd-traj.py
vmd -e visualization.tcl

tutorial:
jupyter-lab tutorials/pyMBE_tutorial.ipynb

pylint:
${PYTHON} -m pylint pyMBE.py lib/ testsuite/ samples/ maintainer/ visualization/
4 changes: 2 additions & 2 deletions lib/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def get_dt(data):
warn_lines = []
for i in range(1,imax):
dt = time[i] - time[i-1]
if(np.abs((dt_init - dt)/dt) > 0.01 ):
if np.abs((dt_init - dt)/dt) > 0.01:
warn_lines.append("Row {} dt = {} = {} - {} not equal to dt_init = {}")
if(len(warn_lines) > 20):
if len(warn_lines) > 20:
print("\n")
for line in warn_lines:
print(line)
Expand Down
Loading

0 comments on commit 9b6cc37

Please sign in to comment.