Coverage for ase / ga / __init__.py: 62.50%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-04 10:20 +0000

1"""The ase.ga project has moved to https://dtu-energy.github.io/ase-ga/ .""" 

2 

3msg = """\ 

4The ase.ga code has moved to a separate project, ase_ga: 

5https://github.com/dtu-energy/ase-ga . 

6Please install it using e.g. pip install ase-ga. 

7Please import from ase_ga what would previously be imported from ase.ga. 

8ase.ga placeholders will be removed in a future release. 

9""" 

10 

11 

12def ase_ga_deprecated(oldmodulename, modulename=None): 

13 import importlib 

14 import warnings 

15 

16 if modulename is None: 

17 assert oldmodulename.startswith('ase.ga') 

18 modulename = oldmodulename.replace('ase.ga', 'ase_ga') 

19 

20 def __getattr__(attrname): 

21 try: 

22 module = importlib.import_module(modulename) 

23 except ImportError as err: 

24 raise ImportError(f'Cannot import {modulename}.\n{msg}') from err 

25 warnings.warn(msg, FutureWarning) 

26 return getattr(module, attrname) 

27 

28 return __getattr__ 

29 

30 

31__getattr__ = ase_ga_deprecated(__name__)