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

AttributeError: Neither Quantity object nor its magnitude has attribute 'value_in_unit' #1

Open
pmorerio opened this issue Dec 1, 2023 · 2 comments

Comments

@pmorerio
Copy link

pmorerio commented Dec 1, 2023

Hello,
thank for your great project and for sharing it.

I am trying to process the dataset and I get the following error at line
https://github.com/choderalab/refit-espaloma/blob/3cd067dff15705ec21db3486a729c51e775f6c9d/openff-default/01-create-dataset/script/getgraph_hdf5.py#L41C31-L41C31

AttributeError: Neither Quantity object nor its magnitude ([-0.39356641  0.21017327  0.07214046  0.0592334   0.0592334   0.11263118
  0.06580188 -0.34651846  0.12482916  0.0667118  -0.30928986  0.1285253
  0.067798   -0.38553921  0.21082074  0.16681495  0.08811324 -0.26960329
  0.3512127  -0.24550466 -0.17608724  0.13016322 -0.38348353  0.15774996
  0.15774996 -0.0031005   0.06773816  0.01510226  0.08220104  0.26792246
 -0.75611123 -0.27631777 -0.31557541  0.08424206  0.06006785  0.06006785
  0.11341671  0.0658284  -0.34649272  0.12485553  0.06671223 -0.30928941
  0.12852447  0.067798   -0.38553921  0.21082074  0.16674677  0.088112
 -0.27115692  0.33003539 -0.24769285 -0.27393269  0.17468578  0.25296493
 -0.26941576  0.01993044  0.06967396  0.01685234  0.08226606  0.26792246
 -0.75611123 -0.27631777 -0.31557586  0.08421528  0.06006742  0.06006742
  0.11262143  0.06580153 -0.34652057  0.11281356  0.06586736 -0.38741949
  0.21072221  0.12772983  0.06777097 -0.3855668   0.2108202   0.16671936
  0.08811155 -0.27115738  0.33003539 -0.24769285 -0.27393269  0.17468578
  0.25296493 -0.26941576  0.01993044  0.06967396  0.01685234  0.08226606]) has attribute 'value_in_unit'

Looks like the partial_charges attribute is a Quantity object, but no method value_in_unit is actually found.

I appreciate any help.

Best,
P.

@kntkb
Copy link
Collaborator

kntkb commented Dec 8, 2023

Thanks your interest. I think this is related to this issue.

Can you confirm your openff-toolkit version? Also, I recently updated the conda environment file. Some packages could not be properly installed with pip.

@pmorerio
Copy link
Author

Thank you very much, the issue you linked provides a working solution.
I added .to_openmm() to the quantity:

charges = offmol.partial_charges.to_openmm().value_in_unit(esp.units.CHARGE_UNIT)

Also I found that this workaround could also be used since units are the same for charge (correct me if I am wrong)

charges = offmol.partial_charges.magnitude #esp charge units are the same: openmm.unit.elementary_charge

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