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

Python ValueError when running propane example #67

Closed
mattiafelice-palermo opened this issue Dec 9, 2023 · 2 comments
Closed

Python ValueError when running propane example #67

mattiafelice-palermo opened this issue Dec 9, 2023 · 2 comments

Comments

@mattiafelice-palermo
Copy link

Dear Selim,

first of all thank you very much for sharing qforce with the opensource community.

I'm trying to reproduce the propane example before embarking on more complex molecules, but I cannot move past the QM dihedral calculations.

After performing, the dihedral QM PES scan, I run qforce propane, but unfortunately the program halts with the following traceback:

Calculating the MD hessian matrix elements...
Fitting the MD hessian parameters to QM hessian values
Done!

Traceback (most recent call last):
  File "/home/user/anaconda3/envs/qforce-pip/bin/qforce", line 8, in <module>
    sys.exit(run())
 [...]
  File "/home/user/anaconda3/envs/qforce-pip/lib/python3.9/site-packages/qforce/fragment.py", line 341, in make_fragment_terms
    self.non_bonded = mol.non_bonded.subset(mol.non_bonded, self.frag_charges, map_mol_to_db)
  File "/home/user/anaconda3/envs/qforce-pip/lib/python3.9/site-packages/qforce/molecule/non_bonded.py", line 91, in subset
    if frag_charges != []:
ValueError: operands could not be broadcast together with shapes (11,) (0,)

I did some debugging, and found the issue to be in the subset class method from the molecule/non_bonded.py module. At line 90, there's an if clause to see if fragment charges has value (if frag_charges != []:), but it seems the code attempts to compare a numpy array with a python list, resulting in a ValueError.

I modified the code converting on the fly the frag_charges numpy array into a list just for the if clause, and with this modification qforce runs as expected and finishes the job gracefully.

It seems strange that this kind of bug is out in the open, perhaps there has been recent numpy library changed that became more restrictive and prevent the type mixing as shown above? Or maybe I'm just doing something wrong...

Thank you and I hope this is useful.

Mattia

@selimsami
Copy link
Owner

Hi Mattia,

Thanks a lot for bringing this up.
As you suggested it must have been a recent change in one of the dependencies - sign that I should be adding more tests!
I have now updated the code to fix this issue.
Hopefully the rest of your experience with qforce will be smoother, feel free to ask if you have any issues/questions!

Cheers,
Selim

@mattiafelice-palermo
Copy link
Author

Perfect thank you very much for your help, it's much appreciated!

Mattia

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

No branches or pull requests

2 participants