From 8cd41b77354fa1f230f2fc51bca83438e77ff814 Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Sat, 20 Jul 2024 07:01:26 -0600 Subject: [PATCH 1/4] fix precommit error --- gmso/tests/base_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmso/tests/base_test.py b/gmso/tests/base_test.py index 55c7b080..09e9a8c4 100644 --- a/gmso/tests/base_test.py +++ b/gmso/tests/base_test.py @@ -420,7 +420,7 @@ def are_equivalent_connections(self, are_equivalent_atoms): } def test_connection_equality(conn1, conn2): - if not type(conn1) == type(conn2): + if type(conn1) is not type(conn2): return False conn1_eq_members = conn1.equivalent_members() conn2_eq_members = conn2.equivalent_members() From 2413e3aa36e464ef42990479c996ba85fe42dbda Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Tue, 17 Sep 2024 21:39:32 -0600 Subject: [PATCH 2/4] Fix repr method in Molecule, add residue and molecule to repr func of Site --- gmso/abc/abstract_site.py | 24 +++++++++++++----------- gmso/tests/abc/test_abc.py | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 gmso/tests/abc/test_abc.py diff --git a/gmso/abc/abstract_site.py b/gmso/abc/abstract_site.py index 399a2b6d..462c2af5 100644 --- a/gmso/abc/abstract_site.py +++ b/gmso/abc/abstract_site.py @@ -24,7 +24,7 @@ class Molecule(GMSOBase): def __repr__(self): return ( - f"Molecule(name={self.name}, residue={self.residue}, isrigid={self.isrigid}" + f"Molecule(name={self.name}, number={self.number}, isrigid={self.isrigid})" ) __iterable_attributes__: ClassVar[set] = { @@ -88,7 +88,7 @@ def __eq__(self, other): class Residue(GMSOBase): def __repr__(self): - return f"Residue(name={self.name}, residue={self.residue}" + return f"Residue(name={self.name}, number={self.number}, residue={self.residue}" __iterable_attributes__: ClassVar[set] = { "name", @@ -149,6 +149,17 @@ def default_position(): class Site(GMSOBase): + def __repr__(self): + """Return the formatted representation of the site.""" + return ( + f"<{self.__class__.__name__} {self.name},\n " + f"position: {self.position},\n " + f"label: {self.label if self.label else None},\n " + f"Molecule: {self.molecule},\n" + f"Residue: {self.residue},\n" + f"id: {id(self)}>" + ) + __iterable_attributes__: ClassVar[set] = { "name", "label", @@ -254,15 +265,6 @@ def residue(self): def serialize_position(self, position_: PositionType): return unyt_to_dict(position_) - def __repr__(self): - """Return the formatted representation of the site.""" - return ( - f"<{self.__class__.__name__} {self.name},\n " - f"position: {self.position},\n " - f"label: {self.label if self.label else None},\n " - f"id: {id(self)}>" - ) - def __str__(self): """Return the string representation of the site.""" return ( diff --git a/gmso/tests/abc/test_abc.py b/gmso/tests/abc/test_abc.py new file mode 100644 index 00000000..0ee186f5 --- /dev/null +++ b/gmso/tests/abc/test_abc.py @@ -0,0 +1,21 @@ +import pytest + +from gmso.abc.abstract_site import Molecule, Residue, Site +from gmso.tests.base_test import BaseTest + + +class TestSite(BaseTest): + def test_molecule(self): + molecule = Molecule() + molecule + assert molecule.number == 0 + assert molecule.isrigid is False + + def test_residue(self): + residue = Residue() + residue + assert residue.number == 0 + + def test_site(self): + with pytest.raises(TypeError): + Site() From 953371ca0ef301d6232eb80eb2f87c71fdb48abe Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Tue, 17 Sep 2024 22:12:33 -0600 Subject: [PATCH 3/4] call repr method in test --- gmso/tests/abc/test_abc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gmso/tests/abc/test_abc.py b/gmso/tests/abc/test_abc.py index 0ee186f5..0be1a50d 100644 --- a/gmso/tests/abc/test_abc.py +++ b/gmso/tests/abc/test_abc.py @@ -7,13 +7,13 @@ class TestSite(BaseTest): def test_molecule(self): molecule = Molecule() - molecule + molecule.__repr__() assert molecule.number == 0 assert molecule.isrigid is False def test_residue(self): residue = Residue() - residue + residue.__repr__() assert residue.number == 0 def test_site(self): From c8c62ae4c16d07cd0faa505808ecf1b70892fcb1 Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Wed, 18 Sep 2024 09:26:19 -0600 Subject: [PATCH 4/4] fix Residue repr method --- gmso/abc/abstract_site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmso/abc/abstract_site.py b/gmso/abc/abstract_site.py index 462c2af5..fec774af 100644 --- a/gmso/abc/abstract_site.py +++ b/gmso/abc/abstract_site.py @@ -88,7 +88,7 @@ def __eq__(self, other): class Residue(GMSOBase): def __repr__(self): - return f"Residue(name={self.name}, number={self.number}, residue={self.residue}" + return f"Residue(name={self.name}, number={self.number}" __iterable_attributes__: ClassVar[set] = { "name",