-
Notifications
You must be signed in to change notification settings - Fork 1
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
Glue code #1
base: master
Are you sure you want to change the base?
Conversation
I'll take a look soon. |
example_glue.py
Outdated
def decorator(func): | ||
@wraps(func) | ||
def wrapper(self, *args, **kwargs): | ||
if getattr(self, varname) is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getattr
will raise an exception if the attribute is not present and when no default argument is provided. Would be better to have one getattr
call also. E.g. like
val = getattr(self, varname, None)
if val is None:
val = func(self, *args, **kwargs)
setattr(self, varname, val)
return val
@matt-chan Could you add docstrings to the decorator functions and the classes |
Unit tests with example usage and expecte behavior would also facilitate the review. It does not have to be complete coverage etc. Just some examples that show the aim of the decorators would make it easier to understand and comment. |
@tovrstra good ideas! How does it look now? |
@matt-chan Sorry for the slow reaction from my side. I looked at it once again and I start to get the idea now. I'll have to let this percolate once more. I would like to figure out if the same result (as shown in the example) can be obtained with a simpler code structure. Would the following description be right? The idea is to define a program as a dependency graph: if a result is requested, it's inputs must be looked up (either mandatory inputs or optional ones with sensible defaults) and then the results can be computed. This may go a few layers deep where inputs of inputs are needed to compute intermediate results. |
@tovrstra it's okay! Yes, that's essentially the gist of it. The additional criteria I'd say is that the nodes in the dependency graph should be distinct (nodes aren't composed of other nodes). It seems to keep things simpler I think. It forces us to write a class to pass parameters (or select default ones for passing) between the nodes though. The newest push contains most of the code necessary for a HF/DFT program I think. We're missing the meanfield and grid modules though. |
Thanks! Looks good already, so fine by me to merge. I just need some unperturbed thinking time to come up with useful suggestions. At the moment, that is really hard, so it may take a little while. Sorry... |
Can you guys take a look at this PR and also the code in the repo and let me know what you think? Is it a reasonable API for HORTON 3's porcelain? I think this might be a better way of doing settling on API instead of meeting and talking. At least we can play with code this way and let things mull. |
I'll let others actually look at the code for cleanness and structure. The porcelain should meet a very high standard of code as it is the thing that is most likely to be We should also include David and Kumru probably in this. Matt, I think all of my thoughts are in the specification we worked out ~9 months ago (in terms of input requirements, optional arguments, procedures for determining charge/multiplicity/geometry/etc. from "easy" input, etc.. As long as you hit those requirements and the code is pristine, I think things will be OK. |
A preliminary implementation of the glue code for HORTON 3.
You can ignore the test_snippet.py for the review.
Just want to get some feedback before going too much further when filling in details. The skeleton is mostly there though. There's some examples at the bottom to show what the user would write.
A few design decisions which I'd like comments on in particular: