From 379b6634a5db8c357aeabb2dca1b68f9af918a5b Mon Sep 17 00:00:00 2001 From: Max Liu Date: Mon, 30 Sep 2019 12:43:01 -0400 Subject: [PATCH 1/2] Standardize module names in rmgpy.tools --- ipython/mechanism_analyzer.ipynb | 2 +- rmgpy/rmg/main.py | 2 +- rmgpy/tools/{canteraModel.py => canteramodel.py} | 0 rmgpy/tools/{canteraTest.py => canteramodelTest.py} | 6 +++--- rmgpy/tools/{extractInfoFromckcsv.py => ckcsvparser.py} | 0 rmgpy/tools/{diff_models.py => diffmodels.py} | 0 rmgpy/tools/{diff_modelsTest.py => diffmodelsTest.py} | 2 +- rmgpy/tools/{fluxtest.py => fluxdiagramTest.py} | 0 rmgpy/tools/{generate_reactions.py => generatereactions.py} | 0 .../{testGenerateReactions.py => generatereactionsTest.py} | 2 +- rmgpy/tools/{merge_models.py => mergemodels.py} | 0 rmgpy/tools/{merge_modelsTest.py => mergemodelsTest.py} | 2 +- .../{observablesRegression.py => observablesregression.py} | 2 +- rmgpy/tools/regression.py | 4 ++-- scripts/checkModels.py | 2 +- scripts/diffModels.py | 2 +- scripts/generateReactions.py | 4 ++-- scripts/mergeModels.py | 2 +- 18 files changed, 16 insertions(+), 16 deletions(-) rename rmgpy/tools/{canteraModel.py => canteramodel.py} (100%) rename rmgpy/tools/{canteraTest.py => canteramodelTest.py} (96%) rename rmgpy/tools/{extractInfoFromckcsv.py => ckcsvparser.py} (100%) rename rmgpy/tools/{diff_models.py => diffmodels.py} (100%) rename rmgpy/tools/{diff_modelsTest.py => diffmodelsTest.py} (98%) rename rmgpy/tools/{fluxtest.py => fluxdiagramTest.py} (100%) rename rmgpy/tools/{generate_reactions.py => generatereactions.py} (100%) rename rmgpy/tools/{testGenerateReactions.py => generatereactionsTest.py} (99%) rename rmgpy/tools/{merge_models.py => mergemodels.py} (100%) rename rmgpy/tools/{merge_modelsTest.py => mergemodelsTest.py} (98%) rename rmgpy/tools/{observablesRegression.py => observablesregression.py} (99%) diff --git a/ipython/mechanism_analyzer.ipynb b/ipython/mechanism_analyzer.ipynb index 2c719c1b29..f59f25aca6 100644 --- a/ipython/mechanism_analyzer.ipynb +++ b/ipython/mechanism_analyzer.ipynb @@ -92,7 +92,7 @@ "source": [ "import networkx as nx\n", "import matplotlib.pyplot as plt\n", - "from rmgpy.tools.extractInfoFromckcsv import get_concentration_dict_from_ckcsv, get_rop_from_ckcsv, get_flux_graph_edges_dict\n", + "from rmgpy.tools.ckcsvparser import get_concentration_dict_from_ckcsv, get_rop_from_ckcsv, get_flux_graph_edges_dict\n", "from rmgpy.chemkin import get_species_identifier\n", "from IPython.display import display\n", "import numpy as np\n", diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 6d05e8b26c..f49867cf41 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -1036,7 +1036,7 @@ def run_uncertainty_analysis(self): else: import re import random - from rmgpy.tools.canteraModel import Cantera + from rmgpy.tools.canteramodel import Cantera from rmgpy.tools.muq import ReactorPCEFactory if self.uncertainty is not None and self.uncertainty['local']: diff --git a/rmgpy/tools/canteraModel.py b/rmgpy/tools/canteramodel.py similarity index 100% rename from rmgpy/tools/canteraModel.py rename to rmgpy/tools/canteramodel.py diff --git a/rmgpy/tools/canteraTest.py b/rmgpy/tools/canteramodelTest.py similarity index 96% rename from rmgpy/tools/canteraTest.py rename to rmgpy/tools/canteramodelTest.py index ae522c9e0b..cbcadd7e6d 100644 --- a/rmgpy/tools/canteraTest.py +++ b/rmgpy/tools/canteramodelTest.py @@ -34,7 +34,7 @@ import rmgpy from rmgpy.quantity import Quantity -from rmgpy.tools.canteraModel import find_ignition_delay, CanteraCondition, Cantera +from rmgpy.tools.canteramodel import find_ignition_delay, CanteraCondition, Cantera class CanteraTest(unittest.TestCase): @@ -115,7 +115,7 @@ def test_species_conversion(self): """ Test that species objects convert properly """ - from rmgpy.tools.canteraModel import check_equivalent_cantera_species + from rmgpy.tools.canteramodel import check_equivalent_cantera_species for i in range(len(self.ctSpecies)): self.assertTrue(check_equivalent_cantera_species(self.ctSpecies[i], self.rmg_ctSpecies[i])) @@ -123,6 +123,6 @@ def test_reaction_conversion(self): """ Test that species objects convert properly """ - from rmgpy.tools.canteraModel import check_equivalent_cantera_reaction + from rmgpy.tools.canteramodel import check_equivalent_cantera_reaction for i in range(len(self.ctReactions)): self.assertTrue(check_equivalent_cantera_reaction(self.ctReactions[i], self.rmg_ctReactions[i])) diff --git a/rmgpy/tools/extractInfoFromckcsv.py b/rmgpy/tools/ckcsvparser.py similarity index 100% rename from rmgpy/tools/extractInfoFromckcsv.py rename to rmgpy/tools/ckcsvparser.py diff --git a/rmgpy/tools/diff_models.py b/rmgpy/tools/diffmodels.py similarity index 100% rename from rmgpy/tools/diff_models.py rename to rmgpy/tools/diffmodels.py diff --git a/rmgpy/tools/diff_modelsTest.py b/rmgpy/tools/diffmodelsTest.py similarity index 98% rename from rmgpy/tools/diff_modelsTest.py rename to rmgpy/tools/diffmodelsTest.py index ee662ad700..9b322d933f 100644 --- a/rmgpy/tools/diff_modelsTest.py +++ b/rmgpy/tools/diffmodelsTest.py @@ -31,7 +31,7 @@ import shutil import unittest -from rmgpy.tools.diff_models import execute +from rmgpy.tools.diffmodels import execute class DiffModelsTest(unittest.TestCase): diff --git a/rmgpy/tools/fluxtest.py b/rmgpy/tools/fluxdiagramTest.py similarity index 100% rename from rmgpy/tools/fluxtest.py rename to rmgpy/tools/fluxdiagramTest.py diff --git a/rmgpy/tools/generate_reactions.py b/rmgpy/tools/generatereactions.py similarity index 100% rename from rmgpy/tools/generate_reactions.py rename to rmgpy/tools/generatereactions.py diff --git a/rmgpy/tools/testGenerateReactions.py b/rmgpy/tools/generatereactionsTest.py similarity index 99% rename from rmgpy/tools/testGenerateReactions.py rename to rmgpy/tools/generatereactionsTest.py index c51ff3e9c1..b4c06a5bf3 100644 --- a/rmgpy/tools/testGenerateReactions.py +++ b/rmgpy/tools/generatereactionsTest.py @@ -35,7 +35,7 @@ import rmgpy from rmgpy.rmg.main import RMG -from rmgpy.tools.generate_reactions import execute +from rmgpy.tools.generatereactions import execute @attr('functional') diff --git a/rmgpy/tools/merge_models.py b/rmgpy/tools/mergemodels.py similarity index 100% rename from rmgpy/tools/merge_models.py rename to rmgpy/tools/mergemodels.py diff --git a/rmgpy/tools/merge_modelsTest.py b/rmgpy/tools/mergemodelsTest.py similarity index 98% rename from rmgpy/tools/merge_modelsTest.py rename to rmgpy/tools/mergemodelsTest.py index d0fd814b56..aff1d1633c 100644 --- a/rmgpy/tools/merge_modelsTest.py +++ b/rmgpy/tools/mergemodelsTest.py @@ -31,7 +31,7 @@ import os.path import unittest -from rmgpy.tools.merge_models import get_models_to_merge, combine_models +from rmgpy.tools.mergemodels import get_models_to_merge, combine_models class MergeModelsTest(unittest.TestCase): diff --git a/rmgpy/tools/observablesRegression.py b/rmgpy/tools/observablesregression.py similarity index 99% rename from rmgpy/tools/observablesRegression.py rename to rmgpy/tools/observablesregression.py index 113e0c45fa..9dc6747201 100644 --- a/rmgpy/tools/observablesRegression.py +++ b/rmgpy/tools/observablesregression.py @@ -32,7 +32,7 @@ import numpy as np from rmgpy.chemkin import load_chemkin_file -from rmgpy.tools.canteraModel import Cantera, generate_cantera_conditions, get_rmg_species_from_user_species +from rmgpy.tools.canteramodel import Cantera, generate_cantera_conditions, get_rmg_species_from_user_species from rmgpy.tools.plot import GenericPlot, SimulationPlot, find_nearest diff --git a/rmgpy/tools/regression.py b/rmgpy/tools/regression.py index a756d9bc6a..026464a14c 100644 --- a/rmgpy/tools/regression.py +++ b/rmgpy/tools/regression.py @@ -39,8 +39,8 @@ from rmgpy.molecule import Molecule from rmgpy.quantity import Quantity from rmgpy.species import Species -from rmgpy.tools.observablesRegression import ObservablesTestCase -from rmgpy.tools.canteraModel import CanteraCondition +from rmgpy.tools.observablesregression import ObservablesTestCase +from rmgpy.tools.canteramodel import CanteraCondition observables = [] setups = None diff --git a/scripts/checkModels.py b/scripts/checkModels.py index 704f37680f..efbee3da1c 100644 --- a/scripts/checkModels.py +++ b/scripts/checkModels.py @@ -31,7 +31,7 @@ import logging import math -from rmgpy.tools.diff_models import execute +from rmgpy.tools.diffmodels import execute logger = logging.getLogger('checkModels') diff --git a/scripts/diffModels.py b/scripts/diffModels.py index 26d3dcd03c..dd779088bc 100644 --- a/scripts/diffModels.py +++ b/scripts/diffModels.py @@ -51,7 +51,7 @@ --commonDiffOnly Only show species and reactions present in BOTH models which have different values ======================= ==================================================================================== """ -import rmgpy.tools.diff_models as diff_models +import rmgpy.tools.diffmodels as diff_models ################################################################################ diff --git a/scripts/generateReactions.py b/scripts/generateReactions.py index 086c71429c..84b567c222 100644 --- a/scripts/generateReactions.py +++ b/scripts/generateReactions.py @@ -34,14 +34,14 @@ The input file is a subset of that used with regular RMG jobs. """ -import rmgpy.tools.generate_reactions as generate_reactions +import rmgpy.tools.generatereactions ################################################################################ def main(): - generate_reactions.main() + rmgpy.tools.generatereactions.main() if __name__ == '__main__': diff --git a/scripts/mergeModels.py b/scripts/mergeModels.py index 783d1c19eb..2ef35b644b 100644 --- a/scripts/mergeModels.py +++ b/scripts/mergeModels.py @@ -39,7 +39,7 @@ ``species_dictionary.txt`` in the execution directory. """ -import rmgpy.tools.merge_models as merge_models +import rmgpy.tools.mergemodels as merge_models ################################################################################ From 6262bec5e2c80965da01570266c3f6ee0677b7aa Mon Sep 17 00:00:00 2001 From: Max Liu Date: Tue, 29 Oct 2019 12:27:34 -0400 Subject: [PATCH 2/2] Add renamed modules to rmg2to3.py --- scripts/rmg2to3.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/rmg2to3.py b/scripts/rmg2to3.py index a46b3dacd6..59272f68c3 100644 --- a/scripts/rmg2to3.py +++ b/scripts/rmg2to3.py @@ -82,6 +82,21 @@ from tqdm import tqdm +# Module names +MODULES = { + 'canteraModel': 'canteramodel', + 'canteraTest': 'canteramodelTest', + 'extractInfoFromckcsv': 'ckcsvparser', + 'diff_models': 'diffmodels', + 'diff_modelsTest': 'diffmodelsTest', + 'fluxtest': 'fluxdiagramTest', + 'generate_reactions': 'generatereactions', + 'testGenerateReactions': 'generatereactionsTest', + 'merge_models': 'mergemodels', + 'merge_modelsTest': 'mergemodelsTest', + 'observablesRegression': 'observablesregression', +} + # Global variables and functions GLOBALS1 = { # Arkane @@ -1818,6 +1833,7 @@ 'terminationTime': 'termination_time', } +# Names which are risky to replace using regex DANGEROUS = ['SMILES', 'InChI', 'R', 'Run', 'atomTypes', 'format', 'F'] @@ -1947,6 +1963,7 @@ def find_name_in_line(pattern, line, replacement=None): replacements = [] if arguments.both_stages or arguments.stage1: + replacements.extend(compile_regex(MODULES, args=False, attr=False, words=words, avoid_danger=avoid_danger)) replacements.extend(compile_regex(GLOBALS1, args=False, attr=False, words=words, avoid_danger=avoid_danger)) replacements.extend(compile_regex(METHODS1, args=False, attr=attr, words=words, avoid_danger=avoid_danger)) replacements.extend(compile_regex(ATTRIBUTES1, args=False, attr=attr, words=words, avoid_danger=avoid_danger))