-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement histogram LH5 specification #15
Comments
So I experimented a bit with a possible implementation. @gipert had the idea to implement a |
The implementation so far looks like this btw: class Histogram(LGDO,Hist):
def __init__(self,
*in_args: hist.AxisTypes | hist.Storage | str,
storage: hist.Storage | str | None = None,
metadata: Any = None,
data: np.typing.NDArray[Any] | None = None,
label: str | None = None,
name: str | None = None,
attrs: dict[str, Any] = None,) -> None:
LGDO.__init__(self,attrs)
hist.Hist.__init__(self,in_args,storage,metadata,data,label,name) |
Indeed: >>> from hist import Hist
>>> from lgdo import LGDO
>>>
>>> class Histogram(LGDO, Hist):
>>> def __init__(
>>> self,
>>> attrs=None,
>>> **kwargs,
>>> ):
>>> super(LGDO).__init__(attrs)
>>> super(Hist).__init__(**kwargs)
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases But I'm not an expert, I guess some more research is needed. Also |
So the problem is really that from hist import Hist
from lgdo import LGDO
class Histogram(LGDO, Hist):
pass is already throwing. But from abc import ABCMeta
from hist import Hist
from lgdo import LGDO
class HistogramMeta(ABCMeta, Hist.__class__):
pass
class Histogram(LGDO, Hist, metaclass=HistogramMeta):
pass is working :-) But I have to look further into this if this actually works... edit: Further down the line this does not work. I failed to even call the Hist constructor with this wrapping. |
Serialization/deserialization of hist.Hist objects to LH5.
Specification: https://legend-exp.github.io/legend-data-format-specs/dev/hdf5/#Histograms
The text was updated successfully, but these errors were encountered: