Skip to content

LevelOfTheory attribute standardization#1967

Closed
cgrambow wants to merge 2 commits intomainfrom
modify_lot
Closed

LevelOfTheory attribute standardization#1967
cgrambow wants to merge 2 commits intomainfrom
modify_lot

Conversation

@cgrambow
Copy link
Copy Markdown

Motivation or Problem

LevelOfTheory standardizes all of its attributes upon initialization, which can cause issues in software like ARC that must differentiate between different string representations. See ReactionMechanismGenerator/ARC#399.

Description of Changes

Implement LevelOfTheory._std_tuple, which stores the standardized representation of the object, and no longer modify the public attributes which are provided as arguments during instance creation. LevelOfTheory._std_tuple is used for equality comparisons and hashing, thus retaining the functionality of using level of theory objects as dictionary keys and standard representations of levels of theory.

Testing

Expanded unit tests to reflect the changes.

Additional Questions

Currently, the database (quantum_corrections/data.py) uses the standard string representations for all of the attributes. Do we want to change those to use "nonstandard" strings for better readability? Not necessary for this PR and doesn't affect any Arkane functionality.

@cgrambow cgrambow added Arkane Status: Ready for Review PR is complete and ready to be reviewed labels May 27, 2020
@cgrambow cgrambow requested review from alongd and amarkpayne May 27, 2020 16:15
@cgrambow cgrambow self-assigned this May 27, 2020
Copy link
Copy Markdown
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Code looks great, I have no comments, added a minor question.
Re which representation to use in the database, it might not be a bad idea to use the non-standardized form. Since the data depends on the software used, it sounds reasonable to also replace it with the name the software used. But I'm OK with any choice.


with open(os.path.join(settings['database.directory'], 'quantum_corrections', 'lot_constraints.yml')) as f:
METHODS_THAT_REQUIRE_SOFTWARE = yaml.safe_load(f)['METHODS_THAT_REQUIRE_SOFTWARE']
with open(os.path.join(settings['database.directory'], 'quantum_corrections', 'lot_constraints.yml')) as _f:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the difference between f and _f?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I use f in a couple of the methods later on, so I wanted to avoid having a module-level variable with the same name.

@codecov
Copy link
Copy Markdown

codecov bot commented May 27, 2020

Codecov Report

Merging #1967 (eabdee0) into main (eb178e1) will decrease coverage by 1.93%.
The diff coverage is 100.00%.

❗ Current head eabdee0 differs from pull request most recent head f8a7e71. Consider uploading reports for the commit f8a7e71 to get more accurate results

@@            Coverage Diff             @@
##             main    #1967      +/-   ##
==========================================
- Coverage   48.54%   46.62%   -1.93%     
==========================================
  Files         110       88      -22     
  Lines       30812    23132    -7680     
  Branches     8054     6008    -2046     
==========================================
- Hits        14959    10786    -4173     
+ Misses      14329    11196    -3133     
+ Partials     1524     1150     -374     
Files Changed Coverage Δ
arkane/encorr/ae.py 72.88% <100.00%> (+1.08%) ⬆️
arkane/encorr/bac.py 76.54% <100.00%> (-0.34%) ⬇️
arkane/modelchem.py 96.11% <100.00%> (+0.51%) ⬆️

... and 74 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link
Copy Markdown

This pull request is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant pull request, otherwise it will automatically be closed in 30 days.

@github-actions github-actions bot added the stale stale issue/PR as determined by actions bot label Jun 21, 2023
@amarkpayne
Copy link
Copy Markdown
Member

@oscarwumit would something like this be helpful or hurtful for ARC?

@github-actions github-actions bot removed the stale stale issue/PR as determined by actions bot label Jun 22, 2023
@JacksonBurns
Copy link
Copy Markdown
Contributor

Changing base to main to find out how out of date this PR is.

@JacksonBurns JacksonBurns changed the base branch from master to main June 22, 2023 13:57
@JacksonBurns
Copy link
Copy Markdown
Contributor

Conflicts were simple to resolve - @amarkpayne @oscarwumit @alongd @cgrambow please check this PR after tests run and see where we stand.

Colin Grambow added 2 commits July 24, 2023 17:14
Store LevelOfTheory attributes the same way that they are given when
initializing a LevelOfTheory object, but use the standardized
representations when checking equality and using objects as dictionary
keys (hashing).
The string representations of level of theory objects used in the
database might differ from those used in AE and BAC classes. However,
write_to_database has to edit the database file as a text file instead
of treating it as a Python module, so make sure to match the correct
string representation of the level of theory in the database.

UPDATE: upon rebasing (3 years later), it looks to me (rwest) like this commit is
redundant, so by the time I resolved the conflicts, as far as I can
tell, there is nothing left. But I'm leaving the message here.
The original commit was eabdee0
@JacksonBurns JacksonBurns mentioned this pull request Jul 25, 2023
@github-actions
Copy link
Copy Markdown

This pull request is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant pull request, otherwise it will automatically be closed in 30 days.

@github-actions github-actions bot added the stale stale issue/PR as determined by actions bot label Oct 24, 2023
@github-actions github-actions bot added the abandoned abandoned issue/PR as determined by actions bot label Nov 24, 2023
@github-actions github-actions bot closed this Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abandoned abandoned issue/PR as determined by actions bot Arkane stale stale issue/PR as determined by actions bot Status: Ready for Review PR is complete and ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants