Skip to content

Commit

Permalink
Make Transformation and NonTransformation subclass `Transformatio…
Browse files Browse the repository at this point in the history
…nBase` (#311)

* Make `Transformation` and `NonTransformation` subclass `TransformationBase`

In some cases it can be awkward for `NonTransformation` to be a subclass
of `Transformation`, such as in `alchemiscale`, for cases where
`NonTransformation` should be handled very differently. Switching to a
shared, abstract base class for `Transformation` and `NonTransformation`
simplifies this.

* Address mypy complaints

* Updated repr tests for Transformation, NonTransformation

* Moved protocol property to TranformationBase

* Update gufe/transformations/transformation.py

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>

* Add attribute types to TransformationBase, NonTransformation on @atravitz suggestion

* Backticks fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 10, 2024
1 parent 4ee7647 commit 387ae03
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 127 deletions.
4 changes: 2 additions & 2 deletions gufe/tests/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def complex_equilibrium(solvated_complex):

class TestTransformation(GufeTokenizableTestsMixin):
cls = Transformation
repr = "Transformation(stateA=ChemicalSystem(name=, components={'ligand': SmallMoleculeComponent(name=toluene), 'solvent': SolventComponent(name=O, K+, Cl-)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>)"
repr = "Transformation(stateA=ChemicalSystem(name=, components={'ligand': SmallMoleculeComponent(name=toluene), 'solvent': SolventComponent(name=O, K+, Cl-)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>, name=None)"

@pytest.fixture
def instance(self, absolute_transformation):
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_deprecation_warning_on_dict_mapping(self, solvated_ligand, solvated_com
class TestNonTransformation(GufeTokenizableTestsMixin):

cls = NonTransformation
repr = "NonTransformation(stateA=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>)"
repr = "NonTransformation(system=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>, name=None)"

@pytest.fixture
def instance(self, complex_equilibrium):
Expand Down
Loading

0 comments on commit 387ae03

Please sign in to comment.