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
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-17 01:51 +0000
1import warnings
3from .cpp_classes import Coords, DataArray
4from .util import VisibleDeprecationWarning
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 )
18def _deprecated_attrs(cls: DataArray) -> Coords:
19 """
20 Dict of attrs.
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
30def _deprecated_meta(cls: DataArray) -> Coords:
31 """
32 Dict of coords and attrs.
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
42def _deprecated_drop_attrs(cls: DataArray, *args: str) -> DataArray:
43 """
44 Drop attrs.
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)