From 03e12ae15ce04755b62d0721ab2ffce2b2c57b70 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Fri, 22 May 2020 20:22:30 -0700 Subject: [PATCH 1/7] Update propka/lib.py I cannot spell. Co-authored-by: Oliver Beckstein --- propka/lib.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/propka/lib.py b/propka/lib.py index fc2da5a..0a1f688 100644 --- a/propka/lib.py +++ b/propka/lib.py @@ -211,7 +211,7 @@ def build_parser(parser=None): group.add_argument("-k", "--keep-protons", dest="keep_protons", action="store_true", help="Keep protons in input file", default=False) group.add_argument("-q", "--quiet", action="store_const", const="WARNING", - dest="log_level", help="supress non-warning messages") + dest="log_level", help="suppress non-warning messages") group.add_argument("--protonate-all", dest="protonate_all", action="store_true", help="Protonate all atoms (will not influence pKa calculation)", default=False) @@ -324,4 +324,3 @@ def debug(*args): def warning(*args): """Log a WARN message""" logger.warning(_args_to_str(args)) - From 48f69eb544c37800e24895d20bbf45a43baa52b5 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Fri, 22 May 2020 20:39:22 -0700 Subject: [PATCH 2/7] Support Python 3.5 and higher. See https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429094884 --- README.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b6fb0f..b9cfbf8 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ from within a virtual environment (e.g., via [virtualenv](https://pypi.org/proje ## Requirements -* Python 3.1 or higher +* Python 3.5 or higher ## Getting started diff --git a/setup.py b/setup.py index a8363de..7eb4672 100755 --- a/setup.py +++ b/setup.py @@ -56,6 +56,6 @@ See http://propka.org/ for the PROPKA web server. ], }, zip_safe=True, - python_requires='>=3', + python_requires='>=3.5', test_suite="tests", ) From 2266e0a102f1f6e9a632877b4650f09ff3369d0e Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Fri, 22 May 2020 20:55:58 -0700 Subject: [PATCH 3/7] Consistent test naming. See https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429099054 --- tests/{regression_test.py => test_basic_regression.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{regression_test.py => test_basic_regression.py} (100%) diff --git a/tests/regression_test.py b/tests/test_basic_regression.py similarity index 100% rename from tests/regression_test.py rename to tests/test_basic_regression.py From 6288711209a4f72c3dca2ec9f51b3bec5b6f8734 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Fri, 22 May 2020 21:04:09 -0700 Subject: [PATCH 4/7] Update requirements with pandas. See https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429106093 --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 55b033e..e7257e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -pytest \ No newline at end of file +pytest +pandas \ No newline at end of file From 1b0ad999b11b2d710d60cf8c14125fbb36e36708 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Sat, 23 May 2020 08:06:54 -0700 Subject: [PATCH 5/7] Remove unnecessary exception catching. Fixes https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429063049 --- tests/test_basic_regression.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_basic_regression.py b/tests/test_basic_regression.py index f90f009..13e8e43 100644 --- a/tests/test_basic_regression.py +++ b/tests/test_basic_regression.py @@ -69,8 +69,6 @@ def run_propka(options, pdb_path, tmp_path): molecule = propka.molecular_container.Molecular_container(str(pdb_path), args) molecule.calculate_pka() molecule.write_pka() - except Exception as err: - raise err finally: os.chdir(cwd) From ebddfa1f9fcec30f1e73ef8bd6b75696c7a35863 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Sat, 23 May 2020 08:17:19 -0700 Subject: [PATCH 6/7] Add tests_require argument to setup.py. Addresses https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429100526 Since the tests_require argument is deprecated, I'm also leaving the requirements.txt file to make sure the dependencies are captured in the future. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 7eb4672..19ab89c 100755 --- a/setup.py +++ b/setup.py @@ -57,5 +57,6 @@ See http://propka.org/ for the PROPKA web server. }, zip_safe=True, python_requires='>=3.5', + tests_require=["pandas", "pytest"], test_suite="tests", ) From 73f0ce47af966a8f740b173d997b1030fc154575 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Sat, 23 May 2020 08:40:17 -0700 Subject: [PATCH 7/7] Replace pandas with numpy.testing Addresses https://github.com/jensengroup/propka-3.1/pull/36#discussion_r429104797 --- requirements.txt | 2 +- setup.py | 2 +- tests/README.md | 3 ++- tests/test_basic_regression.py | 19 ++++++++----------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/requirements.txt b/requirements.txt index e7257e4..107957b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pytest -pandas \ No newline at end of file +numpy \ No newline at end of file diff --git a/setup.py b/setup.py index 19ab89c..19d8938 100755 --- a/setup.py +++ b/setup.py @@ -57,6 +57,6 @@ See http://propka.org/ for the PROPKA web server. }, zip_safe=True, python_requires='>=3.5', - tests_require=["pandas", "pytest"], + tests_require=["pandas", "numpy"], test_suite="tests", ) diff --git a/tests/README.md b/tests/README.md index c1b9717..10e2f3c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,6 +1,7 @@ # Testing PROPKA -These tests assume that PROPKA is installed as a module on your system. +These tests assume that PROPKA is installed as a module on your system the +dependencies in `../requirements.txt` are satisfied. If you are running in a virtual environment and want to make changes to your code, module installation accomplished by ``` diff --git a/tests/test_basic_regression.py b/tests/test_basic_regression.py index 13e8e43..7e2a687 100644 --- a/tests/test_basic_regression.py +++ b/tests/test_basic_regression.py @@ -4,7 +4,7 @@ import os import re from pathlib import Path import pytest -import pandas as pd +from numpy.testing import assert_almost_equal import propka.lib import propka.molecular_container @@ -12,9 +12,10 @@ import propka.molecular_container _LOGGER = logging.getLogger(__name__) -# Maximum error set by number of decimal places in pKa output as well as need -# to make unmodified code work on WSL Ubuntu 18.04 -MAX_ERR = 0.01 +# Number of decimal places for maximum tolerable error. Set by number of +# decimal places in pKa output as well as need to make unmodified code work +# on WSL Ubuntu 18.04 +MAX_ERR_DECIMALS = 2 # This directory @@ -102,13 +103,9 @@ def compare_output(pdb, tmp_path, ref_path): m = re.search(r'([0-9]+\.[0-9]+)', line) value = float(m.group(0)) test_data.append(value) - - df = pd.DataFrame({"reference": ref_data, "test": test_data}) - df["difference"] = df["reference"] - df["test"] - max_err = df["difference"].abs().max() - if max_err > MAX_ERR: - errstr = "Error in test (%g) exceeds maximum (%g)" % (max_err, MAX_ERR) - raise ValueError(errstr) + errstr = "Error exceeds maximum allowed value (%d decimal places)" % MAX_ERR_DECIMALS + assert_almost_equal(test_data, ref_data, decimal=MAX_ERR_DECIMALS, + err_msg=errstr, verbose=True) @pytest.mark.parametrize("pdb, options", [