Skip to content

Commit

Permalink
Merge branch 'master' into ff_method_minimal_stable
Browse files Browse the repository at this point in the history
  • Loading branch information
hephysicist authored Feb 14, 2025
2 parents b3cc09f + da70a68 commit a99bdd8
Show file tree
Hide file tree
Showing 29 changed files with 1,574 additions and 513 deletions.
4 changes: 2 additions & 2 deletions analysis_templates/cms_minimal/law.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ default_keep_reduced_events: True
# slightly to the left to avoid them being excluded from the last bin; None leads to automatic mode
default_histogram_last_edge_inclusive: None

# boolean flag that, if True, sets the *hists* output of cf.SelectEvents and cf.MergeSelectionStats to optional
default_selection_hists_optional: True
# boolean flag that, if True, configures cf.SelectEvents to create statistics histograms
default_create_selection_hists: False

# wether or not the ensure_proxy decorator should be skipped, even if used by task's run methods
skip_ensure_proxy: False
Expand Down
613 changes: 613 additions & 0 deletions columnflow/calibration/cms/egamma.py

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions columnflow/columnar_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import multiprocessing
import multiprocessing.pool
from functools import partial
from collections import namedtuple, OrderedDict, deque
from collections import namedtuple, OrderedDict, deque, defaultdict

import law
import order as od
Expand Down Expand Up @@ -1848,6 +1848,9 @@ def __init__(
f"to set: {e.args[0]}",
)
raise e

# remove keyword from further processing
kwargs.pop(attr)
else:
try:
deps = set(law.util.make_list(getattr(self.__class__, attr)))
Expand All @@ -1862,11 +1865,15 @@ def __init__(
# also register a set for storing instances, filled in create_dependencies
setattr(self, f"{attr}_instances", set())

# set all other keyword arguments as instance attributes
for attr, value in kwargs.items():
setattr(self, attr, value)

# dictionary of dependency class to instance, set in create_dependencies
self.deps = DotDict()

# dictionary of keyword arguments mapped to dependenc classes to be forwarded to their init
self.deps_kwargs = DotDict()
self.deps_kwargs = defaultdict(dict) # TODO: avoid using `defaultdict`

# deferred part of the initialization
if deferred_init:
Expand Down Expand Up @@ -1931,8 +1938,15 @@ def deferred_init(self, instance_cache: dict | None = None) -> dict:
self.init_func()

# instantiate dependencies again, but only perform updates
self.create_dependencies(instance_cache, only_update=True)
# self.create_dependencies(instance_cache, only_update=True)

# NOTE: the above does not correctly propagate `deps_kwargs` to the dependencies.
# As a workaround, instantiate all dependencies fully a second time by
# invalidating the instance cache and setting `only_update` to False
instance_cache = {}
self.create_dependencies(instance_cache, only_update=False)

# NOTE: return value currently not being used anywhere -> remove?
return instance_cache

def create_dependencies(
Expand Down
2 changes: 2 additions & 0 deletions columnflow/hist_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from __future__ import annotations

__all__ = []

import law
import order as od

Expand Down
Loading

0 comments on commit a99bdd8

Please sign in to comment.