Skip to content
Snippets Groups Projects
Commit 5d370edd authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Use AttrDict for definitions

parent 022ef40d
No related branches found
No related tags found
No related merge requests found
Pipeline #14212 failed
#!/usr/bin/env python3
from km3io.tools import AttrDict
from .mc_header import data as mc_header
from .trigger import data as trigger
......@@ -8,6 +10,12 @@ from .reconstruction import data as reconstruction
from .w2list_genhen import data as w2list_genhen
from .w2list_gseagen import data as w2list_gseagen
trigger = AttrDict(trigger)
fitparameters = AttrDict(fitparameters)
reconstruction = AttrDict(reconstruction)
w2list_genhen = AttrDict(w2list_genhen)
w3list_gseagen = AttrDict(w2list_gseagen)
trigger_idx = {v: k for k, v in trigger.items()}
fitparameters_idx = {v: k for k, v in fitparameters.items()}
reconstruction_idx = {v: k for k, v in reconstruction.items()}
......
......@@ -11,6 +11,13 @@ BASKET_CACHE_SIZE = 110 * 1024**2
BASKET_CACHE = uproot.cache.ThreadSafeArrayCache(BASKET_CACHE_SIZE)
class AttrDict(dict):
"""A dictionary which allows access to its key through attributes."""
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
class cached_property:
"""A simple cache decorator for properties."""
def __init__(self, function):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment