Skip to content

Commit

Permalink
Add test for get_charge_number_map_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbbeyer committed Jun 12, 2024
1 parent a13fe76 commit 01dff61
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ unit_tests:
${PYTHON} testsuite/setup_salt_ions_unit_tests.py
${PYTHON} testsuite/globular_protein_unit_tests.py
${PYTHON} testsuite/analysis_tests.py
${PYTHON} testsuite/charge_number_map_tests.py

functional_tests:
${PYTHON} testsuite/cph_ideal_tests.py
Expand Down
82 changes: 82 additions & 0 deletions testsuite/charge_number_map_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# Copyright (C) 2024 pyMBE-dev team
#
# This file is part of pyMBE.
#
# pyMBE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyMBE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Import pyMBE and other libraries
import pyMBE
import numpy as np

# Create an instance of pyMBE library
pmb = pyMBE.pymbe_library(seed=42)

def check_charge_number_map(input_parameters):
"""
Checks if pyMBE stores in the pmb.df the input parameters for acid/base particles correctly.
Args:
input_parameters(`dict`): dictionary with the input parameters for define_particle.
"""
pmb.define_particle(**input_parameters)
print(pmb.get_charge_number_map())

if input_parameters["acidity"] == "inert":
np.testing.assert_equal(actual=pmb.get_charge_number_map(),
desired={0: input_parameters["z"]},
verbose=True)
elif input_parameters["acidity"] == "acidic":
np.testing.assert_equal(actual=pmb.get_charge_number_map(),
desired={0: 0, 1: -1},
verbose=True)
elif input_parameters["acidity"] == "basic":
np.testing.assert_equal(actual=pmb.get_charge_number_map(),
desired={0: 1, 1: 0},
verbose=True)

print("*** get_charge_number_map unit tests ***")
print("*** Unit test: check that get_charge_number_map works correctly for inert particles***")
# Clean pmb.df
pmb.setup_df()
input_parameters={"name":"I",
"acidity": "inert",
"pka": np.nan,
"z":5}

check_charge_number_map(input_parameters)

print("*** Unit test passed ***")
print("*** Unit test: check that get_charge_number_map works correctly for acidic particles***")
# Clean pmb.df
pmb.setup_df()
input_parameters={"name":"A",
"acidity": "acidic",
"pka":4}

check_charge_number_map(input_parameters)

print("*** Unit test passed ***")
print("*** Unit test: check that get_charge_number_map works correctly for basic particles***")
# Clean pmb.df
pmb.setup_df()
input_parameters={"name":"B",
"acidity": "basic",
"pka":4}

check_charge_number_map(input_parameters)

print("*** Unit test passed ***")
print("*** All unit tests passed ***")
2 changes: 1 addition & 1 deletion testsuite/set_particle_acidity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_acid_base_setup(input_parameters,acidity_setup):
Args:
input_parameters(`dict`): dictionary with the input parameters for define_particle.
acidity_setup(`dict`): dictionary with the expected setup that pyMBE should do in the pmb.df foor acid/base particles.
acidity_setup(`dict`): dictionary with the expected setup that pyMBE should do in the pmb.df for acid/base particles.
"""
pmb.define_particle(**input_parameters)
Expand Down

0 comments on commit 01dff61

Please sign in to comment.