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

Reaction balancing v2 #43

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Reaction balancing v2 #43

wants to merge 6 commits into from

Conversation

marcosfelt
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

@marcosfelt marcosfelt left a comment

Choose a reason for hiding this comment

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

My overall comments:

  • It would be helpful to have in the body of the PR (you should be able to edit it?) a description of the overall idea of the balancing algorithm. I think I roughly get that the right hand side and the left hand side of the reaction are balanced separately and then combined? But I'm not really sure.
  • Also, why is balancerxn recursive?
  • In terms of style, I've made some notes in different places but generally python has a specific naming convention we should follow: https://google.github.io/styleguide/pyguide.html#316-naming
  • Finally, can you add some tests to a file named test/test_balancing.py following the convention from the other test files of creating functions starting with test_? That way pytest will automatically pick up on the tests and run them in Github actions whenever new changes are pushed.

Also, it might be best to close this PR and create a new one with you as the author.

agterrordict={}

# Generate reactant and product dictionaries (raise error if SMILES issue or missing reactants/products)
if getattr(reaction,"reactant_compounds"):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do you need to check if reactant_compounds if it is part of the Reaction API?

Comment on lines +823 to +824
IP (Optional[Dict], optional): Input parameters. Defaults to IP.
**kwargs: Additional input parameters. IP will be updated with these.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer if most of the arguments were in the function definition for two reasons:

  1. It enables autocomplete/type ahead in code editors to help people discover options without having to always look in the documentation
  2. It improves the automatic documentation (once we get there)

Also, please add type hints to the arguments. I'll get this all written up in a style guide at some point.

def balance_reaction(reaction:Reaction, IP:Optional[Dict]=IP, rctstorgts=True, **kwargs):
"""_summary_

Args:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines -85 to +827
Dict: Compound dictionary with ID as key and another dictionary with the
following keys: 'atomdict' (Output of atomtypes, dictionary with atom
elements and count), 'charge' (Overall charge of mol),'smiles'
(smiles of mol),'formula' (chemical formula),'count' (instance number, always 1)
_type_: _description_
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer if this function returned an updated Reaction object.



def balancerxn(
Rdata,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these should be snake case -> follow this style guide on naming: https://google.github.io/styleguide/pyguide.html#316-naming

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.

2 participants