From 0551cceebac179a61d10aac6207bc6a47fa20747 Mon Sep 17 00:00:00 2001 From: Tamas Gal <tgal@km3net.de> Date: Fri, 2 Oct 2020 16:07:15 +0200 Subject: [PATCH] Restructure definitions --- km3io/_definitions/__init__.py | 0 .../fitparameters.py | 0 .../mc_header.py | 0 .../reconstruction.py | 0 .../{definitions => _definitions}/trigger.py | 0 .../w2list_genhen.py | 0 .../w2list_gseagen.py | 0 km3io/definitions.py | 29 +++++++++++++++++++ km3io/definitions/__init__.py | 23 --------------- km3io/tools.py | 7 ----- 10 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 km3io/_definitions/__init__.py rename km3io/{definitions => _definitions}/fitparameters.py (100%) rename km3io/{definitions => _definitions}/mc_header.py (100%) rename km3io/{definitions => _definitions}/reconstruction.py (100%) rename km3io/{definitions => _definitions}/trigger.py (100%) rename km3io/{definitions => _definitions}/w2list_genhen.py (100%) rename km3io/{definitions => _definitions}/w2list_gseagen.py (100%) create mode 100644 km3io/definitions.py delete mode 100644 km3io/definitions/__init__.py diff --git a/km3io/_definitions/__init__.py b/km3io/_definitions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/km3io/definitions/fitparameters.py b/km3io/_definitions/fitparameters.py similarity index 100% rename from km3io/definitions/fitparameters.py rename to km3io/_definitions/fitparameters.py diff --git a/km3io/definitions/mc_header.py b/km3io/_definitions/mc_header.py similarity index 100% rename from km3io/definitions/mc_header.py rename to km3io/_definitions/mc_header.py diff --git a/km3io/definitions/reconstruction.py b/km3io/_definitions/reconstruction.py similarity index 100% rename from km3io/definitions/reconstruction.py rename to km3io/_definitions/reconstruction.py diff --git a/km3io/definitions/trigger.py b/km3io/_definitions/trigger.py similarity index 100% rename from km3io/definitions/trigger.py rename to km3io/_definitions/trigger.py diff --git a/km3io/definitions/w2list_genhen.py b/km3io/_definitions/w2list_genhen.py similarity index 100% rename from km3io/definitions/w2list_genhen.py rename to km3io/_definitions/w2list_genhen.py diff --git a/km3io/definitions/w2list_gseagen.py b/km3io/_definitions/w2list_gseagen.py similarity index 100% rename from km3io/definitions/w2list_gseagen.py rename to km3io/_definitions/w2list_gseagen.py diff --git a/km3io/definitions.py b/km3io/definitions.py new file mode 100644 index 0000000..358a668 --- /dev/null +++ b/km3io/definitions.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +from km3io._definitions.mc_header import data as mc_header + +from km3io._definitions.trigger import data as trigger +from km3io._definitions.fitparameters import data as fitparameters +from km3io._definitions.reconstruction import data as reconstruction +from km3io._definitions.w2list_genhen import data as w2list_genhen +from km3io._definitions.w2list_gseagen import data as w2list_gseagen + + +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 + + +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()} +w2list_genhen_idx = {v: k for k, v in w2list_genhen.items()} +w2list_gseagen_idx = {v: k for k, v in w2list_gseagen.items()} diff --git a/km3io/definitions/__init__.py b/km3io/definitions/__init__.py deleted file mode 100644 index 22a8c7d..0000000 --- a/km3io/definitions/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 - -from km3io.tools import AttrDict - -from .mc_header import data as mc_header - -from .trigger import data as trigger -from .fitparameters import data as fitparameters -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()} -w2list_genhen_idx = {v: k for k, v in w2list_genhen.items()} -w2list_gseagen_idx = {v: k for k, v in w2list_gseagen.items()} diff --git a/km3io/tools.py b/km3io/tools.py index a1f8297..be07110 100644 --- a/km3io/tools.py +++ b/km3io/tools.py @@ -13,13 +13,6 @@ 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): -- GitLab