You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide the possibility to re-bin histograms, which probably should happen at the post-processing step. The rebinning could be done via hist and the syntax should presumably follow UHI. Generic rebinnings with bin edges provided would be ideal but require scikit-hep/hist#345.
The text was updated successfully, but these errors were encountered:
Example for how to do string conversion to slices useable for rebinning:
importrefromtypingimportOptional, Unionimporthistdef_str_to_bound(string: str) ->Optional[Union[int, complex]]:
"""Convert a string to be useable as a slice in UHI style. Currently supports indexing by bin counts (via ints), by location (via imaginary numbers) and rebinning (also via imaginary numbers). See https://uhi.readthedocs.io/ for more information about UHI. Args: string (str): string to be converted Returns: Optional[Union[int, complex]]: arguments to be put into a slice() """ifstring=="":
returnNonetry:
bound=float(string.rstrip("j"))
except:
raiseValueError(f"cannot parse rebinning string: {string}")
ifstring[-1] =="j":
returnbound*1jelse:
returnint(bound)
h=hist.new.Regular(10, 0, 1).Double().fill([0.5, 0.9])
slice_str="1:0.9j:2j"print(*(_str_to_bound(s) forsinslice_str.split(":")))
h[slice(*(_str_to_bound(s) forsinslice_str.split(":")))]
Provide the possibility to re-bin histograms, which probably should happen at the post-processing step. The rebinning could be done via
hist
and the syntax should presumably follow UHI. Generic rebinnings with bin edges provided would be ideal but require scikit-hep/hist#345.The text was updated successfully, but these errors were encountered: