pyhs3.data.BinnedData¶
- class pyhs3.data.BinnedData(**data)[source]¶
Binned data specification for histogram data.
Represents binned/histogram data in multi-dimensional space with optional uncertainties and correlations.
- Variables:
name – Custom string identifier
type – Must be “binned”
contents – Bin contents array
axes – Axis specifications defining binning (BinnedAxis with binning info)
uncertainty – Optional uncertainty specification
- Parameters:
data (
Any)
Fields¶ Field
Type
Required
Default
list[Annotated[typing.Annotated[pyhs3.axes.RegularAxis, Tag(tag=’regular’)] | typing.Annotated[pyhs3.axes.IrregularAxis, Tag(tag=’irregular’)],Discriminator(discriminator=_binned_axis_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None),WrapValidator(func=_validator, json_schema_input_type=PydanticUndefined)]]Yes
Yes
Yes
Literal[‘binned’]No
'binned'No
NoneValidators¶ Validator
Mode
Fields
after
model
- __init__(**data)¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (
Any)
Methods
to_hist()Convert to scikit-hep hist.Hist object for visualization.
Validate binned data consistency.
Attributes
- BinnedData.to_hist()[source]¶
Convert to scikit-hep hist.Hist object for visualization.
Creates a hist.Hist histogram from this binned data. The resulting histogram can be plotted using matplotlib or other visualization tools.
Note
Correlation matrices in uncertainties are not preserved. Only the sigma values (standard deviations) are included as histogram variances.
- Returns:
- Histogram representation with:
Axes matching the data axes
Values from contents
Variances from uncertainties if present
- Return type:
Examples
>>> data = BinnedData( ... name="example", ... type="binned", ... contents=[10, 20, 15], ... axes=[{"name": "x", "min": 0, "max": 3, "nbins": 3}] ... ) >>> data.to_hist() Hist(Regular(3, 0, 3, name='x'), storage=Double()) # Sum: 45.0
- BinnedData.type¶
- BinnedData.contents¶
- BinnedData.axes¶
- BinnedData.uncertainty¶
- BinnedData.name¶