diff --git a/nomad/metainfo/util.py b/nomad/metainfo/util.py index 85a5b2f3a73e5452cfa14f91613d6a66ba50f9e1..903fc88e76b2aeacb9172786ba7bf457018de75a 100644 --- a/nomad/metainfo/util.py +++ b/nomad/metainfo/util.py @@ -33,6 +33,19 @@ import pandas as pd import pint import pytz +# All platforms do not support 128 bit numbers +float128_set = set() +complex256_set = set() +try: + float128_set.add(np.float128) +except AttributeError: + pass +try: + complex256_set.add(np.complex256) +except AttributeError: + pass + + from nomad.units import ureg __hash_method = 'sha1' # choose from hashlib.algorithms_guaranteed @@ -79,14 +92,14 @@ def normalize_complex(value, complex_type, to_unit: Union[str, ureg.Unit, None]) f'due to possibility of loss of precision.' ) - def __check_unix(): - if os.name != 'nt' and _type in (np.float128, np.complex256): + def __check_128bit(): + if _type in float128_set | complex256_set: raise precision_error if complex_type in (np.complex128, complex): # 64-bit complex if _type in (np.int64, np.uint64): raise precision_error - __check_unix() + __check_128bit() elif complex_type == np.complex64: # 32-bit complex if _type in ( int, @@ -99,7 +112,7 @@ def normalize_complex(value, complex_type, to_unit: Union[str, ureg.Unit, None]) np.complex128, ): raise precision_error - __check_unix() + __check_128bit() if isinstance(value, pint.Quantity): scaled: np.ndarray = value.to(to_unit).magnitude if to_unit else value.magnitude @@ -221,12 +234,8 @@ class MTypes: } int_python = {int} int = int_python | int_numpy - float_numpy = {np.float16, np.float32, np.float64} | ( - set() if os.name == 'nt' else {np.float128} - ) - complex_numpy = {np.complex64, np.complex128} | ( - set() if os.name == 'nt' else {np.complex256} - ) + float_numpy = {np.float16, np.float32, np.float64} | float128_set + complex_numpy = {np.complex64, np.complex128} | complex256_set float_python = {float} complex_python = {complex} float = float_python | float_numpy diff --git a/pyproject.toml b/pyproject.toml index 05c5f7c763d595a14f7ada02331b727e751b68bb..f9a939c23b4b0072a05a290f9c99cea578c26577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,9 +42,9 @@ dependencies = [ 'panedr>=0.2', 'parmed>=3.0.0', 'mdanalysis==2.5.0', + 'h5py>=3.6.0', 'xarray>=0.20.2', - 'phonopy~=2.11.0', - 'pymatgen>=2023.2.28', + 'pymatgen>=2023.5.10', 'bitarray>=2.3.5', 'scikit-learn>=1.0.2', 'toposort', @@ -65,7 +65,7 @@ parsing = [ 'h5py==3.6.0', 'pyzeo==0.1.4', 'quippy-ase==0.9.14', - 'pybis==1.36.3' + 'pybis==1.36.3', ] infrastructure = [ 'h5grove[fastapi]==1.3.0',