-
Notifications
You must be signed in to change notification settings - Fork 169
Create and test new attributes for the NBO parser #1251
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
Conversation
test/testdata
Outdated
@@ -309,6 +309,7 @@ SP Psi4 PsiHFSPTest basicPsi4-1.7 dvb_sp_r | |||
SP Psi4 PsiSPTest basicPsi4-1.7 dvb_sp_rks.out | |||
SP QChem GenericSPTest basicQChem5.1 dvb_sp.out | |||
SP QChem GenericSPTest basicQChem5.4 dvb_sp.out | |||
SP NBO NBOSPTest basicNBO7.0 basicORCA5.0/dvb_sp.out |
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.
This might need to be dvb_sp.nbo.out
for just the NBO section.
cclib/parser/data.py
Outdated
@@ -160,6 +161,7 @@ class ccData: | |||
"optdone": Attribute(list, 'done', 'optimization'), | |||
"optstatus": Attribute(numpy.ndarray, 'status', 'optimization'), | |||
"polarizabilities": Attribute(list, 'polarizabilities', 'N/A'), | |||
"populations": Attribute(list, 'natural population analysis', 'properties'), |
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.
'natural population analysis' -> 'population analysis' since this can hold other types of population analyses.
also I think you forgot to change the type from list
to dict
here
test/testdata
Outdated
@@ -309,6 +309,7 @@ SP Psi4 PsiHFSPTest basicPsi4-1.7 dvb_sp_r | |||
SP Psi4 PsiSPTest basicPsi4-1.7 dvb_sp_rks.out | |||
SP QChem GenericSPTest basicQChem5.1 dvb_sp.out | |||
SP QChem GenericSPTest basicQChem5.4 dvb_sp.out | |||
SP NBO NBOSPTest basicNBO7.0/basicORCA5.0 dvb_sp.nbo.out |
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.
Can you put this in alphabetical order regarding the parser name?
test/data/testSP.py
Outdated
"""Is the number of atoms equal to 3?""" | ||
assert self.data.natom == 3 | ||
|
||
def testatomcharges(self): |
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.
Since only the key name is different from Mulliken, Lowdin, ... in the superclass, can you factor this out into a helper function?
test/data/testSP.py
Outdated
"""Customized restricted single point unittest""" | ||
def testpopulations(self): | ||
assert self.data.populations.keys == list(['nao', 'atom', 'no', 'lang', 'type', 'occupancy', 'energy']) | ||
assert isinstance(self.data.populations['nao'], List[int]) |
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.
I'm not sure this test is getting run, because
>>> l = [1, 2, 3]
>>> import typing
>>> isinstance(l, typing.List)
True
>>> isinstance(l, typing.List[int])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ejberqu/.pyenv/versions/3.10.11/lib/python3.10/typing.py", line 994, in __instancecheck__
return self.__subclasscheck__(type(obj))
File "/Users/ejberqu/.pyenv/versions/3.10.11/lib/python3.10/typing.py", line 997, in __subclasscheck__
raise TypeError("Subscripted generics cannot be used with"
TypeError: Subscripted generics cannot be used with class and instance checks
typing
is also not for runtime type checking, if you wanted to do that over abstract container types it would be from collections.abc
, and then checking element types would be a list comprehension over the container.
@@ -159,6 +165,9 @@ def extract(self, inputfile, line): | |||
|
|||
self.atomcharges["nbo"] = charges | |||
|
|||
if not hasattr(self, "natom"): | |||
self.set_attribute('natom', len(self.atomcharges["nbo"])) |
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.
👍
cclib/parser/nboparser.py
Outdated
} | ||
|
||
if not hasattr(self, "populations"): | ||
self.set_attribute('populations', npa_dict) |
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.
Didn't we want self.populations["npa"] = {"nao": ..., ...}
?
Something is still happening with the NBO test not being run: https://github.com/cclib/cclib/actions/runs/5903735648/job/16014303794?pr=1251#step:8:873 |
Whenever I run the tests, there's a couple of errors popping up But they appear even after I delete the |
Sorry I missed this. I don't develop using the container, though I should, but I'd expect CI to catch this,, since CI is always using the latest image. I'll try reproducing this today. |
@weronikazak How are you running the tests? I know we need documentation for this. |
I can reproduce this with cd /home/eric/development/forks/python/cclib_pr_review
sudo devcontainer up --workspace-folder .
sudo docker exec -it bold_heisenberg /bin/bash # using the randomized container name
cd /workspaces/cclib_pr_review
python -m pytest test -k 'not test_method' because
I will see what it takes to get the NBO test to run. It probably has something to do with the nested directory in the |
The stuff to import NBO for testing was missing: diff --git a/cclib/parser/__init__.py b/cclib/parser/__init__.py
index ab680909..e9e38ac6 100644
--- a/cclib/parser/__init__.py
+++ b/cclib/parser/__init__.py
@@ -25,6 +25,7 @@ from cclib.parser.jaguarparser import Jaguar
from cclib.parser.molcasparser import Molcas
from cclib.parser.molproparser import Molpro
from cclib.parser.mopacparser import MOPAC
+from cclib.parser.nboparser import NBO
from cclib.parser.nwchemparser import NWChem
from cclib.parser.orcaparser import ORCA
from cclib.parser.psi3parser import Psi3
diff --git a/test/data/testSP.py b/test/data/testSP.py
index f198ef2c..d42f4566 100644
--- a/test/data/testSP.py
+++ b/test/data/testSP.py
@@ -604,10 +604,6 @@ class NBOSPTest(GenericSPTest):
def testnatom(self):
"""Is the number of atoms equal to 3?"""
assert self.data.natom == 3
-
- def testatomchargesnbo(self):
- """Are atomic charges consistent with natom?"""
- self.testatomcharges()
class TurbomoleSPTest(GenericSPTest):
"""Customized restricted single point KS unittest"""
diff --git a/test/test_data.py b/test/test_data.py
index 3164c31e..a7c0acf5 100644
--- a/test/test_data.py
+++ b/test/test_data.py
@@ -27,7 +27,7 @@ sys.path.insert(1, os.path.join(__filedir__, 'data'))
parser_names = [
"ADF", "DALTON", "FChk", "GAMESS", "GAMESSDAT", "GAMESSUK", "Gaussian", "Jaguar",
- "Molpro", "Molcas", "MOPAC", "NWChem", "ORCA", "Psi4", "QChem",
+ "Molpro", "Molcas", "MOPAC", "NBO", "NWChem", "ORCA", "Psi4", "QChem",
"Turbomole",
]
all_parsers = {name: getattr(cclib.parser, name) for name in parser_names} I think you should replace |
I use |
46b1cf8
to
8efe207
Compare
I will fix the line ending problem so you don't have to. |
The merge commit didn't contain any proper changes, so this branch is up-to-date with For the tests, I'm getting
|
0e75bb0
to
514f936
Compare
Sorry, I just saw this comment! |
Hmm, it doesn't work 😕 |
Yes. The problem is that you've combined Git operations (checkout, add, commit, or some combination, I'm not sure) on Windows with some inside the container. (The following explanation isn't great and might not be fully correct without reproducing it myself but should be enough.) When you clone a repo on an operating system, Git by default will transparently not mess up line endings in files if they're different on the remote (GitHub) from your local copy. The settings for how this works are different on Windows than on Linux and macOS. If you have the same checkout that crosses operating systems (like the container bind mount), you can violate these settings. The result is that you can inadvertently change the line endings of every file in the repo. The best explanation I've found for how to understand this and fix it for Git is https://kuantingchen04.github.io/line-endings/. I have |
I can see how this works on Windows but it will be a few more hours. |
Co-authored-by: Eric Berquist <[email protected]>
8527027
to
d095240
Compare
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.
I got rid of the merge commit and the last commit which didn't do what was expected with the line endings. Also the second ~half of commits looked to be the reverse of the first half, so dropped those in the interactive rebase.
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.
We can remove rtd fully now that github actions builds docs. ill open a separate issue for that
Thank you! |
This pull request aims to introduce new attributes for the NBO parser, along with corresponding tests for these attributes.