Coverage for install/scipp/core/counts.py: 33%
6 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
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Matthew Andrew
6from .._scipp import core as _cpp
7from ._cpp_wrapper_util import call_func as _call_cpp_func
10def counts_to_density(
11 x: _cpp.DataArray | _cpp.Dataset, dim: str
12) -> _cpp.DataArray | _cpp.Dataset:
13 """Converts counts to count density on a given dimension.
15 Parameters
16 ----------
17 x:
18 Data as counts.
19 dim:
20 Dimension on which to convert.
22 Returns
23 -------
24 :
25 Data as count density.
26 """
27 return _call_cpp_func(_cpp.counts_to_density, x, dim)
30def density_to_counts(
31 x: _cpp.DataArray | _cpp.Dataset, dim: str
32) -> _cpp.DataArray | _cpp.Dataset:
33 """Converts counts to count density on a given dimension.
35 Parameters
36 ----------
37 x:
38 Data as count density.
39 dim:
40 Dimension on which to convert.
42 Returns
43 -------
44 :
45 Data as counts.
46 """
47 return _call_cpp_func(_cpp.density_to_counts, x, dim)