def test_react_all_parallel(self): """ Test that the ``react_all`` function works in parallel using Python multiprocessing """ import rmgpy.rmg.main rmgpy.rmg.main.maxproc = 2 procnum = 2 spcs = [ Species().from_smiles('C=C'), Species().from_smiles('[CH3]'), Species().from_smiles('[OH]'), Species().from_smiles('CCCCCCCCCCC') ] n = len(spcs) reaction_list, spc_tuples = react_all(spcs, n, np.ones(n), np.ones([n, n]), np.ones([n, n, n]), procnum) self.assertIsNotNone(reaction_list) self.assertEqual(len(reaction_list), 94) self.assertEqual(len(spc_tuples), 94) flat_rxn_list = list(itertools.chain.from_iterable(reaction_list)) self.assertEqual(len(flat_rxn_list), 44) self.assertTrue( all([isinstance(rxn, TemplateReaction) for rxn in flat_rxn_list])) # Reset module level maxproc back to default rmgpy.rmg.main.maxproc = 1
def test_react_all(self): """ Test that the ``react_all`` function works in serial """ procnum = 1 spcs = [ Species().from_smiles('C=C'), Species().from_smiles('[CH3]'), Species().from_smiles('[OH]'), Species().from_smiles('CCCCCCCCCCC') ] n = len(spcs) reaction_list, spc_tuples = react_all(spcs, n, np.ones(n), np.ones([n, n]), np.ones([n, n, n]), procnum) self.assertIsNotNone(reaction_list) self.assertEqual(len(reaction_list), 34) self.assertEqual(len(spc_tuples), 34) flat_rxn_list = list(itertools.chain.from_iterable(reaction_list)) self.assertEqual(len(flat_rxn_list), 44) self.assertTrue( all([isinstance(rxn, TemplateReaction) for rxn in flat_rxn_list]))
def testReactAll(self): """ Test that the ``react_all`` function works in serial """ procnum = 1 spcs = [ Species().fromSMILES('C=C'), Species().fromSMILES('[CH3]'), Species().fromSMILES('[OH]'), Species().fromSMILES('CCCCCCCCCCC') ] n = len(spcs) reaction_list = react_all(spcs, n, np.ones(n), np.ones([n, n]), np.ones([n, n, n]), procnum) self.assertIsNotNone(reaction_list) self.assertEqual(len(reaction_list), 44) self.assertTrue( all([isinstance(rxn, TemplateReaction) for rxn in reaction_list]))
def testReactAllParallel(self): """ Test that the ``react_all`` function works in parallel using Python multiprocessing """ import rmgpy.rmg.main rmgpy.rmg.main.maxproc = 2 procnum = 2 spcs = [ Species().fromSMILES('C=C'), Species().fromSMILES('[CH3]'), Species().fromSMILES('[OH]'), Species().fromSMILES('CCCCCCCCCCC') ] n = len(spcs) reaction_list = react_all(spcs, n, np.ones(n), np.ones([n, n]), np.ones([n, n, n]), procnum) self.assertIsNotNone(reaction_list) self.assertEqual(len(reaction_list), 44) self.assertTrue( all([isinstance(rxn, TemplateReaction) for rxn in reaction_list]))