choderalab / YankTools

Test systems for Yank
GNU General Public License v2.0
0 stars 2 forks source link

Add analytical results as member functions #3

Open kyleabeauchamp opened 10 years ago

kyleabeauchamp commented 10 years ago

I changed the test systems to be classes, so that we can add member functions that calculate various analytical (or experimental) properties that will be useful for unit testing.

PS: we should also include docstrings with references and some equations, if necessary. The point here is for the member functions for calculating analytical properties to be self-documenting.

kyleabeauchamp commented 10 years ago

PS: at some point we might want to create an abstract base class for all these test system classes

jchodera commented 10 years ago

PS: at some point we might want to create an abstract base class for all these test system classes

Agreed. How about a TestSystem object with some methods for computing analytical properties?

Which properties would we want to compute? I could imagine

Are others useful?

jchodera commented 10 years ago

Should we create a single method getAnalyticalProperties() that returns a dict of analytical properties, or should we have separate get* functions such as getPotentialEnergyMean, getPotentialEnergyStddev, that return None if this property is unavailable?

If we use a dict, what naming convention is best? PotentialEnergyMean, or potential_energy_mean, or a double-dict with property['potential energy']['mean'] and property['potential energy']['stddev'], etc?

kyleabeauchamp commented 10 years ago

So I think we should just have one function per analytical property.

A member function can be accessed in the same manner as a dict object, but has the added benefit of having a docstring attached to it. To me, that's a huge benefit, as it allows us to attaching provenance and derivations directly to the data.

kyleabeauchamp commented 10 years ago

There are other ways we could handle this, obviously, but to me this is the most obvious one.

jchodera commented 10 years ago

Good point. We'll effectively be using introspection to see what analytical results are available.

jchodera commented 10 years ago

Is there any advantage to having a base class that implements all possible analytical result methods and returns a NotImplementedException for all of them? Or is introspection the more Pythonic way to do this?

kyleabeauchamp commented 10 years ago

I don't see any major advantage to that.

To me, one main benefit of having an abstract base class is to teach new developers how to create their own test systems--by listing the necessary member functions, we define a clear interface for future test additions.

kyleabeauchamp commented 10 years ago

PS: the base class would also be at the top of the module and say "This is how you create a new test..."