nomad-coe / nomad

NOMAD lets you manage and share your materials science data in a way that makes it truly useful to you, your group, and the community.
https://nomad-lab.eu
Apache License 2.0
77 stars 19 forks source link

replace deprecated ase.atoms.get_number_of_atoms() by ase.atoms.get_global_number_of_atoms() #71

Closed mdforti closed 1 year ago

mdforti commented 1 year ago

Usage of ase.Atoms.get_number_of_atoms() as for example in

https://github.com/nomad-coe/nomad/blob/develop/nomad/normalizing/common.py#L153

raises a warning:

/scratch/AnacondaEnvironments/anaconda3/envs/nomad/lib/python3.9/site-packages/ase/atoms.py:920: VisibleDeprecationWarning: Use get_global_number_of_atoms() instead
  warnings.warn('Use get_global_number_of_atoms() instead',

on a fresh install of nomad package. for example:

https://github.com/nomad-coe/nomad/blob/develop/nomad/normalizing/common.py#L153

this fixes:

https://github.com/nomad-coe/nomad/compare/develop...mdforti:nomad:develop

mdforti commented 1 year ago

In a similar manner, I am also getting this warnings,

/scratch/AnacondaEnvironments/anaconda3/envs/nomad/lib/python3.9/site-packages/ase/cell.py:97: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
  cell = np.array(cell, float)

and

/scratch/AnacondaEnvironments/anaconda3/envs/nomad/lib/python3.9/site-packages/ase/atoms.py:424: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
  a = np.array(a, dtype, order='C')

but still need to track down the origin - the warning message do not show the exact line causing this and warnings filter in my scripts are not working for some reason.

lauri-codes commented 1 year ago

Thanks @mdforti for reporting these!

Indeed you are right in both cases. We can handle these two issues (#71 and #72) in one go. I would, however, do slight changes to your suggested fixes:

I will prepare a fix and let you know.

lauri-codes commented 1 year ago

This is now fixed in the develop branch by this commit.