wums 0.1.4__tar.gz → 0.1.5__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.4
3
+ Version: 0.1.5
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.4"
7
+ version = "0.1.5"
8
8
  description = "."
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  license = { text = "MIT" }
@@ -1,5 +1,9 @@
1
1
  import copyreg
2
2
  import pickle
3
+ import sys
4
+
5
+ import wums
6
+ sys.modules['narf.ioutils'] = sys.modules['wums.ioutils'] # backwards compatibility to use old files
3
7
 
4
8
  import boost_histogram as bh
5
9
  import h5py
@@ -6,6 +6,7 @@ import shutil
6
6
  import socket
7
7
  import sys
8
8
  import textwrap
9
+ import importlib
9
10
 
10
11
  import hist
11
12
  import matplotlib as mpl
@@ -1780,3 +1781,44 @@ def make_summary_plot(
1780
1781
  ax1.xaxis.set_major_locator(ticker.LinearLocator(numticks=5))
1781
1782
 
1782
1783
  return fig
1784
+
1785
+
1786
+ def load_config(config_path):
1787
+ if config_path is None:
1788
+ return {}
1789
+ # load a python module
1790
+ spec = importlib.util.spec_from_file_location("config", config_path)
1791
+ config = importlib.util.module_from_spec(spec)
1792
+ spec.loader.exec_module(config)
1793
+ return config
1794
+
1795
+
1796
+ def read_axis_label(x, labels, with_unit=True):
1797
+ if x in labels:
1798
+ label = labels[x]
1799
+ if isinstance(label, str):
1800
+ return label
1801
+ elif with_unit:
1802
+ return f'{label["label"]} ({label["unit"]})'
1803
+ else:
1804
+ return label["label"]
1805
+ else:
1806
+ return x
1807
+
1808
+
1809
+ def get_axis_label(config, default_keys=None, label=None, is_bin=False):
1810
+ if label is not None:
1811
+ return label
1812
+
1813
+ if default_keys is None:
1814
+ return "Bin index"
1815
+
1816
+ labels = getattr(config, "axis_labels", {})
1817
+
1818
+ if len(default_keys) == 1:
1819
+ if is_bin:
1820
+ return f"{read_axis_label(default_keys[0], labels, False)} bin"
1821
+ else:
1822
+ return read_axis_label(default_keys[0], labels)
1823
+ else:
1824
+ return f"({', '.join([read_axis_label(a, labels, False) for a in default_keys])}) bin"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: wums
3
- Version: 0.1.4
3
+ Version: 0.1.5
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