From 4a5b0277cb6f4fda6da5ec769e707201abf4dc33 Mon Sep 17 00:00:00 2001 From: Paul Saxe Date: Wed, 21 Aug 2019 15:51:21 -0400 Subject: [PATCH 1/3] Added support for versioneer. Updated __init__.py to get the version information. --- packmol_step/__init__.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packmol_step/__init__.py b/packmol_step/__init__.py index 9851bcc..f7e5c6f 100644 --- a/packmol_step/__init__.py +++ b/packmol_step/__init__.py @@ -1,15 +1,23 @@ # -*- coding: utf-8 -*- -"""Top-level package for packmol step.""" - -__author__ = """Paul Saxe""" -__email__ = 'psaxe@molssi.org' -__version__ = '0.1.0' +""" +packmol_step +A step for building fluid boxes using Packmol +""" # Bring up the classes so that they appear to be directly in # the packmol_step package. -from packmol_step.packmol import PACKMOL # noqa: F401 -from packmol_step.packmol_parameters import PACKMOL_Parameters # noqa: F401 -from packmol_step.packmol_step import PACKMOLStep # noqa: F401 -from packmol_step.tk_packmol import TkPACKMOL # noqa: F401 +from packmol_step.packmol import Packmol # noqa: F401 +from packmol_step.packmol_parameters import PackmolParameters # noqa: F401 +from packmol_step.packmol_step import PackmolStep # noqa: F401 +from packmol_step.tk_packmol import TkPackmol # noqa: F401 + +# Handle versioneer +from ._version import get_versions +__author__ = """Paul Saxe""" +__email__ = 'psaxe@molssi.org' +versions = get_versions() +__version__ = versions['version'] +__git_revision__ = versions['full-revisionid'] +del get_versions, versions From 71c2d55068f6cd1f99653f72c18f2310c5b0206b Mon Sep 17 00:00:00 2001 From: Paul Saxe Date: Wed, 21 Aug 2019 15:52:07 -0400 Subject: [PATCH 2/3] Fixed the task description for new interface. I am changing the handling of the description of steps, so needed to make small changes in this step to conform. Also corrected the capitalization of Packmol throughout. --- packmol_step/packmol.py | 67 +++++++++++++++++------------- packmol_step/packmol_parameters.py | 10 ++--- packmol_step/packmol_step.py | 12 +++--- packmol_step/tk_packmol.py | 12 +++--- setup.py | 4 +- 5 files changed, 56 insertions(+), 49 deletions(-) diff --git a/packmol_step/packmol.py b/packmol_step/packmol.py index 0498eb3..6340e02 100644 --- a/packmol_step/packmol.py +++ b/packmol_step/packmol.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -"""A node or step for PACKMOL in a seamm""" +"""A node or step for Packmol in a seamm""" import logging import mendeleev @@ -18,24 +18,47 @@ printer = printing.getPrinter('packmol') -class PACKMOL(seamm.Node): +class Packmol(seamm.Node): def __init__(self, flowchart=None, extension=None): - '''Setup the main PACKMOL step + '''Setup the main Packmol step Keyword arguments: ''' - logger.debug('Creating PACKMOL {}'.format(self)) + logger.debug('Creating Packmol {}'.format(self)) super().__init__( - flowchart=flowchart, title='PACKMOL', extension=extension + flowchart=flowchart, title='Packmol', extension=extension ) - self.parameters = packmol_step.PACKMOL_Parameters() + self.parameters = packmol_step.PackmolParameters() - def description(self, P): - """Prepare information about what this node will do + @property + def version(self): + """The semantic version of this module. """ + return packmol_step.__version__ + + @property + def git_revision(self): + """The git version of this module. + """ + return packmol_step.__git_revision__ + + def description_text(self, P=None): + """Return a short description of this step. + + Return a nicely formatted string describing what this step will + do. + + Keyword arguments: + P: a dictionary of parameter values, which may be variables + or final values. If None, then the parameters values will + be used as is. + """ + + if not P: + P = self.parameters.values_to_dict() text = 'Creating a cubic supercell ' if P['method'][0] == '$': @@ -74,24 +97,8 @@ def description(self, P): return text - def describe(self, indent='', json_dict=None): - """Write out information about what this node will do - If json_dict is passed in, add information to that dictionary - so that it can be written out by the controller as appropriate. - """ - - next_node = super().describe(indent, json_dict) - - P = self.parameters.values_to_dict() - - text = self.description(P) - - job.job(__(text, **P, indent=self.indent + ' ')) - - return next_node - def run(self): - """Run a PACKMOL building step + """Run a Packmol building step """ next_node = super().run(printer) @@ -104,7 +111,7 @@ def run(self): logger.info('submethod = {}'.format(P['submethod'])) # Print what we are doing - text = self.description(P) + text = self.description_text(P) printer.important(__(text, **P, indent=' ')) size = None @@ -197,7 +204,7 @@ def run(self): n_atoms = len(atoms['elements']) if n_atoms_per_molecule * n_molecules != n_atoms: raise RuntimeError( - 'Serious problem in PACKMOL with the number of atoms' + 'Serious problem in Packmol with the number of atoms' ' {} != {}'.format( n_atoms, n_atoms_per_molecule * n_molecules ) @@ -239,7 +246,7 @@ def run(self): printer.important(__(string, indent=' ', **tmp)) logger.log( - 0, 'Structure created by PACKMOL:\n\n' + + 0, 'Structure created by Packmol:\n\n' + pprint.pformat(data.structure) ) @@ -258,8 +265,8 @@ def calculate( """Work out the other variables given any two independent ones""" if data.structure is None: - logger.error('PACKMOL run(): there is no structure!') - raise RuntimeError('PACKMOL run(): there is no structure!') + logger.error('Packmol run(): there is no structure!') + raise RuntimeError('Packmol run(): there is no structure!') elements = data.structure['atoms']['elements'] n_atoms_per_molecule = len(elements) diff --git a/packmol_step/packmol_parameters.py b/packmol_step/packmol_parameters.py index 5c6d669..50a7af8 100644 --- a/packmol_step/packmol_parameters.py +++ b/packmol_step/packmol_parameters.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Control parameters for PACKMOL, currently for packing fluids +"""Control parameters for Packmol, currently for packing fluids """ import logging @@ -8,8 +8,8 @@ logger = logging.getLogger(__name__) -class PACKMOL_Parameters(seamm.Parameters): - """The control parameters for PACKMOL packing fluids +class PackmolParameters(seamm.Parameters): + """The control parameters for Packmol packing fluids """ methods = { 'size of cubic cell': ( @@ -76,7 +76,7 @@ class PACKMOL_Parameters(seamm.Parameters): "description": "Gap around cell:", "help_text": ( - "Since PACKMOL does not support periodic systems " + "Since Packmol does not support periodic systems " "we will build a box with this gap around the " "atoms, then make it periodic. The gap ensures " "that molecules at the boundary do not hit images" @@ -138,6 +138,6 @@ def __init__(self, defaults={}, data=None): parameters given in the class""" super().__init__( - defaults={**PACKMOL_Parameters.parameters, **defaults}, + defaults={**PackmolParameters.parameters, **defaults}, data=data ) diff --git a/packmol_step/packmol_step.py b/packmol_step/packmol_step.py index 7ed9582..dfd7ab0 100644 --- a/packmol_step/packmol_step.py +++ b/packmol_step/packmol_step.py @@ -8,11 +8,11 @@ import packmol_step -class PACKMOLStep(object): +class PackmolStep(object): my_description = { - 'description': 'An interface for PACKMOL', + 'description': 'An interface for Packmol', 'group': 'Building', - 'name': 'PACKMOL' + 'name': 'Packmol' } def __init__(self, flowchart=None, gui=None): @@ -25,12 +25,12 @@ def __init__(self, flowchart=None, gui=None): def description(self): """Return a description of what this extension does """ - return PACKMOLStep.my_description + return PackmolStep.my_description def create_node(self, flowchart=None, **kwargs): """Return the new node object""" - return packmol_step.PACKMOL(flowchart=flowchart, **kwargs) + return packmol_step.Packmol(flowchart=flowchart, **kwargs) def create_tk_node(self, canvas=None, **kwargs): """Return the graphical Tk node object""" - return packmol_step.TkPACKMOL(canvas=canvas, **kwargs) + return packmol_step.TkPackmol(canvas=canvas, **kwargs) diff --git a/packmol_step/tk_packmol.py b/packmol_step/tk_packmol.py index 9e06a50..eb21bee 100644 --- a/packmol_step/tk_packmol.py +++ b/packmol_step/tk_packmol.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -"""The graphical part of a PACKMOL step""" +"""The graphical part of a Packmol step""" import logging import seamm @@ -13,8 +13,8 @@ logger = logging.getLogger(__name__) -class TkPACKMOL(seamm.TkNode): - """Graphical interface for using PACKMOL for fluid boxes +class TkPackmol(seamm.TkNode): + """Graphical interface for using Packmol for fluid boxes """ def __init__( @@ -50,7 +50,7 @@ def create_dialog(self): self.toplevel, buttons=('OK', 'Help', 'Cancel'), master=self.toplevel, - title='Edit PACKMOL step', + title='Edit Packmol step', command=self.handle_dialog ) self.dialog.withdraw() @@ -76,7 +76,7 @@ def create_dialog(self): self.reset_dialog() def reset_dialog(self, widget=None): - methods = packmol_step.PACKMOL_Parameters.methods + methods = packmol_step.Packmol_Parameters.methods method = self['method'].get() submethod = self['submethod'].get() @@ -154,7 +154,7 @@ def right_click(self, event): self.popup_menu.tk_popup(event.x_root, event.y_root, 0) def edit(self): - """Present a dialog for editing the PACKMOL input + """Present a dialog for editing the Packmol input """ if self.dialog is None: self.create_dialog() diff --git a/setup.py b/setup.py index c284995..7fe682b 100644 --- a/setup.py +++ b/setup.py @@ -85,10 +85,10 @@ ], entry_points={ 'org.molssi.seamm': [ - 'PACKMOL = packmol_step:PACKMOLStep', + 'Packmol = packmol_step:PackmolStep', ], 'org.molssi.seamm.tk': [ - 'PACKMOL = packmol_step:PACKMOLStep', + 'Packmol = packmol_step:PackmolStep', ], } ) From 4dd2c23d9eac3562aa75e33c123576ec1f8afe68 Mon Sep 17 00:00:00 2001 From: Paul Saxe Date: Tue, 27 Aug 2019 08:26:54 -0400 Subject: [PATCH 3/3] Cleaned up the text output. First pass. --- packmol_step/packmol.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packmol_step/packmol.py b/packmol_step/packmol.py index 6340e02..ab6705c 100644 --- a/packmol_step/packmol.py +++ b/packmol_step/packmol.py @@ -49,7 +49,7 @@ def description_text(self, P=None): """Return a short description of this step. Return a nicely formatted string describing what this step will - do. + do. Keyword arguments: P: a dictionary of parameter values, which may be variables @@ -95,7 +95,7 @@ def description_text(self, P=None): "Don't recognize the submethod {}".format(P['submethod']) ) - return text + return self.header + '\n' + __(text, **P, indent=4*' ').__str__() def run(self): """Run a Packmol building step @@ -111,8 +111,7 @@ def run(self): logger.info('submethod = {}'.format(P['submethod'])) # Print what we are doing - text = self.description_text(P) - printer.important(__(text, **P, indent=' ')) + printer.important(__(self.description_text(P), indent=self.indent)) size = None volume = None @@ -244,6 +243,7 @@ def run(self): string += ' for a total of {n_atoms} atoms in the cell' string += ' and a density of {density:.5~P}.' printer.important(__(string, indent=' ', **tmp)) + printer.important('') logger.log( 0, 'Structure created by Packmol:\n\n' +