Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change input file's behavior of loading families through kineticFamilies field. #195

Merged
merged 9 commits into from Apr 3, 2014

Conversation

connie
Copy link
Member

@connie connie commented Mar 31, 2014

Please look at commit msg to observe current behavior.

Some issues I have with this current implementation:
Setting kineticFamilies to 'default' should probably have use a set of recommended families instead of loading all of them- we have those 'recommended' families flags but they aren't really used. This way we can turn certain families off for most people.
Setting kineticsFamilies to an empty list should probably give some error, instead of making it load all the families, we should probably force people to use the 'all' or 'none' or 'default' flags.
I don't like how omitting the kineticsFamilies entirely leads to setting it to 'default.' I think we should create an assertion any time the kineticsFamilies is not set to anything in the input file. Again, people should use the 'all','none', or 'default flags.'

Any thoughts?

rmg.kineticsFamilies = kineticsFamilies
pass
elif kineticsFamilies == 'none':
rmg.kineticsFamilies = kineticsFamilies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks here like the 'none' behavior is the same as the 'all' behavior, but I see now that kineticsFamilies contains a different value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically could condense to the first 3 if/elif statements into 1.

@rwest
Copy link
Member

rwest commented Mar 31, 2014

I like your suggestions:
More error handling and exception throwing, and a 'default' flag that doesn't just mean 'all'.
Want to add those changes to this pull request before we merge? I'm happy either way

Now the following options for kineticsFamilies in the input file are allowed:

- When kineticsFamilies field is set to 'default', the RMG recommended families
  are loaded from the database.  This is also selected when the kineticsFamilies
  field is completely missing

- 'all' indicates all families are turned on.

- 'none' means none of the families are turned on.  This is good for debugging.

- A list of families means only those are selected, e.g. ['H_Abstraction','R_Recombination'].
  You can also deselect all but certain families by using the ! flag,
  e.g. ['!Intra_Disproportionation','Substitution_O']

Added additional error raising in rmgpy.data.kinetics in case any of the if/elif
statements fall through when code changes occur.
@connie
Copy link
Member Author

connie commented Apr 3, 2014

I think now it has the behavior we actually want, which is:

  • When kineticsFamilies field is set to 'default', the RMG recommended families are loaded from the database (located under input/kinetics/families/recommended.py). This is also selected when the kineticsFamilies field is completely missing
  • 'all' indicates all families are turned on.
  • 'none' means none of the families are turned on.
  • A list of families means only those are selected, e.g. ['H_Abstraction','R_Recombination'].
    You can also deselect all but certain families by using the ! flag,
    e.g. ['!Intra_Disproportionation','Substitution_O']. No longer allowing empty lists.

…t file.

Less code, hopefully easier to understand.
With this commit, the recommended.py file in 
RMG-database/input/kinetics/families/recommended.py
should just contain a dictionary, not a function call

recommendedFamilies = {
   '1,2-Birad_to_alkene': True,
   '1,2_Insertion': False,
  }

I'll make a corresponding commit in the RMG-database project.

Other changes:
Reduced code duplication, tidied up comments, and added more 
sanity checks on input, eg. we check that the list is all 
true or all false, not a mix, and we check that all the requested
families can be found in the database (before we just silently skipped them)
and check that all families in the database are listed in the recommended.py 
file as either True or False (in case we forget to add them).
This is a small change, but it changes the indentation of 
a huge block of code so looks like a big one.
The loading of the recommendation list has been moved to its own method
because it was getting complicated, and we want to be able to store this
more permanently, even if we aren't going to use it. This will allow us
to interrogate it, and, for example, to export the Java-style database with it.
(is this still going to be neccessarry?)
Now that we have this data to hand, we may as well preserve it
and pass it along.
@rwest
Copy link
Member

rwest commented Apr 3, 2014

This looks good. But then I started tweaking it, and got carried away. Ended up sending you a pull request (onto this pull request) - connie#1
That one is currently: Build Status

…ies.

An exercise that showed me how bad I am at making unit tests quickly.
@rwest
Copy link
Member

rwest commented Apr 3, 2014

Excellent. Good work with the unit test! And Travis says it's safe to merge. Will do so now.

rwest added a commit that referenced this pull request Apr 3, 2014
Change input file's behavior of loading families through `kineticFamilies` field, and various fixes.

There's a lot more error checking now, and the error checking is tested in a unit test!
@rwest rwest merged commit 5b5349c into ReactionMechanismGenerator:master Apr 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants