wums 0.1.5__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: wums
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: .
5
5
  Author-email: David Walter <david.walter@cern.ch>, Josh Bendavid <josh.bendavid@cern.ch>, Kenneth Long <kenneth.long@cern.ch>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wums"
7
- version = "0.1.5"
7
+ version = "0.1.6"
8
8
  description = "."
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  license = { text = "MIT" }
@@ -38,4 +38,4 @@ dependencies = [
38
38
  where = ["."]
39
39
 
40
40
  [tool.setuptools.package-data]
41
- "wums" = ["Templates/index.php"]
41
+ "wums" = ["Templates/index.php"]
@@ -601,14 +601,48 @@ def wrap_text(
601
601
  )
602
602
 
603
603
 
604
- def add_cms_decor(
605
- ax, label=None, lumi=None, loc=2, data=True, text_size=None, no_energy=False
604
+ def add_cms_decor(ax, *args, **kwargs):
605
+ add_decor(ax, "CMS", *args, **kwargs)
606
+
607
+
608
+ def add_decor(
609
+ ax, title, label=None, lumi=None, loc=2, data=True, text_size=None, no_energy=False
606
610
  ):
607
611
  text_size = get_textsize(ax, text_size)
612
+
613
+ if title in ["CMS", "ATLAS", "LHCb", "ALICE"]:
614
+ module = getattr(hep, title.lower())
615
+ make_text = module.text
616
+ make_label = module.label
617
+ else:
618
+ def make_text(text=None, **kwargs):
619
+ for key, value in dict(hep.rcParams.text._get_kwargs()).items():
620
+ if (
621
+ value is not None
622
+ and key not in kwargs
623
+ and key in inspect.getfullargspec(label_base.exp_text).kwonlyargs
624
+ ):
625
+ kwargs.setdefault(key, value)
626
+ kwargs.setdefault("italic", (False, True, False))
627
+ kwargs.setdefault("exp", title)
628
+ return hep.label.exp_text(text=text, **kwargs)
629
+
630
+ def make_label(**kwargs):
631
+ for key, value in dict(hep.rcParams.text._get_kwargs()).items():
632
+ if (
633
+ value is not None
634
+ and key not in kwargs
635
+ and key in inspect.getfullargspec(label_base.exp_text).kwonlyargs
636
+ ):
637
+ kwargs.setdefault(key, value)
638
+ kwargs.setdefault("italic", (False, True, False))
639
+ kwargs.setdefault("exp", title)
640
+ return hep.label.exp_label(**kwargs)
641
+
608
642
  if no_energy:
609
- hep.cms.text(ax=ax, text=label, loc=loc, fontsize=text_size)
643
+ make_text(ax=ax, text=label, loc=loc, fontsize=text_size)
610
644
  else:
611
- hep.cms.label(
645
+ make_label(
612
646
  ax=ax,
613
647
  lumi=lumi,
614
648
  lumi_format="{0:.3g}",
@@ -617,7 +651,32 @@ def add_cms_decor(
617
651
  data=data,
618
652
  loc=loc,
619
653
  )
620
-
654
+
655
+ # else:
656
+ # if loc==0:
657
+ # # above frame
658
+ # x = 0.0
659
+ # y = 1.0
660
+ # elif loc==1:
661
+ # # in frame
662
+ # x = 0.05
663
+ # y = 0.88
664
+ # elif loc==2:
665
+ # # upper left, label below title
666
+ # x = 0.05
667
+ # y = 0.88
668
+ # elif loc==2:
669
+ # #
670
+ # ax.text(
671
+ # x,
672
+ # y,
673
+ # args.title,
674
+ # transform=ax1.transAxes,
675
+ # fontweight="bold",
676
+ # fontsize=1.2 * text_size,
677
+ # )
678
+ # if label is not None:
679
+ # ax.text(0.05, 0.80, label, transform=ax.transAxes, fontstyle="italic")
621
680
 
622
681
  def makeStackPlotWithRatio(
623
682
  histInfo,
@@ -826,11 +885,11 @@ def makeStackPlotWithRatio(
826
885
  for x in (data_hist.sum(), hh.sumHists(stack).sum())
827
886
  ]
828
887
  varis = [
829
- x.variance if hasattr(x, "variance") else x ** 0.5
888
+ x.variance if hasattr(x, "variance") else x**0.5
830
889
  for x in (data_hist.sum(), hh.sumHists(stack).sum())
831
890
  ]
832
891
  scale = vals[0] / vals[1]
833
- unc = scale * (varis[0] / vals[0] ** 2 + varis[1] / vals[1] ** 2) ** 0.5
892
+ unc = scale * (varis[0] / vals[0] ** 2 + varis[1] / vals[1] ** 2)**0.5
834
893
  ndigits = -math.floor(math.log10(abs(unc))) + 1
835
894
  logger.info(
836
895
  f"Rescaling all processes by {round(scale,ndigits)} +/- {round(unc,ndigits)} to match data norm"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: wums
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: .
5
5
  Author-email: David Walter <david.walter@cern.ch>, Josh Bendavid <josh.bendavid@cern.ch>, Kenneth Long <kenneth.long@cern.ch>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes