artemis.externals.physt.bin_utils¶
Methods for investigation and manipulation of bin arrays.
Module Contents¶
-
artemis.externals.physt.bin_utils.make_bin_array(bins) → np.ndarray¶ Turn bin data into array understood by HistogramXX classes.
- Parameters
bins (array_like) – Array of edges or array of edge tuples
Examples
>>> make_bin_array([0, 1, 2]) array([[0, 1], [1, 2]]) >>> make_bin_array([[0, 1], [2, 3]]) array([[0, 1], [2, 3]])
-
artemis.externals.physt.bin_utils.to_numpy_bins(bins) → np.ndarray¶ Convert physt bin format to numpy edges.
- Parameters
bins (array_like) – 1-D (n) or 2-D (n, 2) array of edges
- Returns
edges
- Return type
all edges
-
artemis.externals.physt.bin_utils.to_numpy_bins_with_mask(bins) → Tuple[np.ndarray, np.ndarray]¶ Numpy binning edges including gaps.
- Parameters
bins (array_like) – 1-D (n) or 2-D (n, 2) array of edges
- Returns
edges (np.ndarray) – all edges
mask (np.ndarray) – List of indices that correspond to bins that have to be included
Examples
>>> to_numpy_bins_with_mask([0, 1, 2]) (array([0., 1., 2.]), array([0, 1]))
>>> to_numpy_bins_with_mask([[0, 1], [2, 3]]) (array([0, 1, 2, 3]), array([0, 2])
-
artemis.externals.physt.bin_utils.is_rising(bins) → bool¶ Check whether the bins are in raising order.
Does not check if the bins are consecutive.
- Parameters
bins (array_like) –
-
artemis.externals.physt.bin_utils.is_consecutive(bins, rtol: float = 1e-05, atol: float = 1e-08) → bool¶ Check whether the bins are consecutive (edges match).
Does not check if the bins are in rising order.
-
artemis.externals.physt.bin_utils.is_bin_subset(sub, sup) → bool¶ Check whether all bins in one binning are present also in another:
- Parameters
sub (array_like) – Candidate for the bin subset
sup (array_like) – Candidate for the bin superset
-
artemis.externals.physt.bin_utils.is_bin_superset(sup, sub) → bool¶ Inverse of is_bin_subset