Coverage for install/scipp/core/deprecation.py: 50%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-17 01:51 +0000

1import warnings 

2 

3from .cpp_classes import Coords, DataArray 

4from .util import VisibleDeprecationWarning 

5 

6 

7def _warn_attr_removal() -> None: 

8 warnings.warn( 

9 "sc.DataArray.attrs has been deprecated and will be removed in Scipp v24.12.0. " 

10 "The deprecation includes sc.DataArray.meta and sc.DataArray.drop_attrs. " 

11 "For unaligned coords, use sc.DataArray.coords and unset the alignment flag. " 

12 "For other attributes, use a higher-level data structure.", 

13 VisibleDeprecationWarning, 

14 stacklevel=3, 

15 ) 

16 

17 

18def _deprecated_attrs(cls: DataArray) -> Coords: 

19 """ 

20 Dict of attrs. 

21 

22 .. deprecated:: 23.9.0 

23 Use :py:attr:`coords` with unset alignment flag instead, or 

24 store attributes in higher-level data structures. 

25 """ 

26 _warn_attr_removal() 

27 return cls.deprecated_attrs 

28 

29 

30def _deprecated_meta(cls: DataArray) -> Coords: 

31 """ 

32 Dict of coords and attrs. 

33 

34 .. deprecated:: 23.9.0 

35 Use :py:attr:`coords` with unset alignment flag instead, or 

36 store attributes in higher-level data structures. 

37 """ 

38 _warn_attr_removal() 

39 return cls.deprecated_meta 

40 

41 

42def _deprecated_drop_attrs(cls: DataArray, *args: str) -> DataArray: 

43 """ 

44 Drop attrs. 

45 

46 .. deprecated:: 23.9.0 

47 Use :py:attr:`coords` with unset alignment flag instead, or 

48 store attributes in higher-level data structures. 

49 """ 

50 _warn_attr_removal() 

51 return cls.deprecated_drop_attrs(*args)