Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions | Variables
diff-jobo-cfg Namespace Reference

Functions

def dump_seq (seq)
 
def cxx_sort (dpp)
 
def load_cfg_file (fname)
 
def dict_diff (ref, chk)
 
def cmp_component_db (ref, chk, verbose=True)
 

Variables

 __author__
 
 parser
 
 usage
 
 _add
 
 dest
 
 help
 
 action
 
 default
 
 options
 
 args
 
 ref_fname
 
 chk_fname
 
 ref_db
 
 chk_db
 
 sc
 

Function Documentation

◆ cmp_component_db()

def diff-jobo-cfg.cmp_component_db (   ref,
  chk,
  verbose = True 
)
compare 2 dicts of components
dicts are of the form:
 { 'comp_type' : <name of component>,
   'cxx_type'  : <C++ type of the component>,
   'props' : { 'property-name' : 'property-value', }
   }

Definition at line 76 of file diff-jobo-cfg.py.

76 def cmp_component_db(ref, chk, verbose=True):
77  """ compare 2 dicts of components
78  dicts are of the form:
79  { 'comp_type' : <name of component>,
80  'cxx_type' : <C++ type of the component>,
81  'props' : { 'property-name' : 'property-value', }
82  }
83  """
84  common_keys = []
85  ref_keys = set(ref.keys())
86  chk_keys = set(chk.keys())
87 
88  common_keys = ref_keys & chk_keys
89  ref_only_keys = ref_keys - chk_keys
90  chk_only_keys = chk_keys - ref_keys
91 
92  print ("::: components in both files: [%5s]" % (len(common_keys),))
93  print ("::: components in ref only: [%5s]" % (len(ref_only_keys),))
94  if len(ref_only_keys)>0:
95  dump_seq(ref_only_keys)
96  print ("="*80)
97  print ("::: components in chk only: [%5s]" % (len(chk_only_keys),))
98  if len(chk_only_keys)>0:
99  dump_seq(chk_only_keys)
100  print ("="*80)
101 
102  diff = []
103  for comp_name in common_keys:
104  comp_ref = ref[comp_name]
105  comp_chk = chk[comp_name]
106 
107  ref_props = sorted([(k,v) for k,v in comp_ref['props'].iteritems()])
108  chk_props = sorted([(k,v) for k,v in comp_chk['props'].iteritems()])
109  if ref_props != chk_props:
110  diff.append((comp_name, ref_props, chk_props,
111  dict_diff(ref=comp_ref['props'],
112  chk=comp_chk['props'])))
113  pass
114 
115  print ("::: components with different properties: [%5s]" % (len(diff),))
116  for name, ref_props, chk_props, diff_props in diff:
117  print ("::: - component: [%s]" % (name,))
118  for prop_name, prop_value in diff_props.iteritems():
119  ref_value = prop_value[0]
120  chk_value = prop_value[1]
121  if isinstance(ref_value, list):
122  ref_value = sorted(ref_value)
123  if isinstance(chk_value, list):
124  chk_value = sorted(chk_value)
125 
126  if isinstance(ref_value, list) and isinstance(chk_value, list):
127  dref_value = set(ref_value) - set(chk_value)
128  dchk_value = set(chk_value) - set(ref_value)
129  ref_value = sorted(list(dref_value))
130  chk_value = sorted(list(dchk_value))
131  print ("-%s: %r" %(prop_name, ref_value,))
132  print ("+%s: %r" %(prop_name, chk_value,))
133 
134 
135  if (len(ref_only_keys) > 0 or
136  len(chk_only_keys) > 0 or
137  len(diff) > 0):
138  return 1
139  return 0
140 

◆ cxx_sort()

def diff-jobo-cfg.cxx_sort (   dpp)

Definition at line 29 of file diff-jobo-cfg.py.

29 def cxx_sort(dpp):
30  from collections import defaultdict
31  cxx_dpp = defaultdict(list)
32 
33  for k,v in dpp.iteritems():
34  #print (v['cxx_type'])
35  cxx_dpp[v['cxx_type']].append({k:v})
36 
37  for k,v in cxx_dpp.iteritems():
38  print ('---',k)
39  for vv in v:
40  print ('------',vv.keys())
41  print ('---------',vv.values())#['comp_type']
42  return cxx_dpp
43 

◆ dict_diff()

def diff-jobo-cfg.dict_diff (   ref,
  chk 
)
Return a dict of keys that differ with another config object.  If a value is
    not found in one fo the configs, it will be represented by KEYNOTFOUND.
    @param ref:   First dictionary to diff.
    @param chk:   Second dicationary to diff.
    @return diff:   Dict of Key => (ref.val, chk.val)

Definition at line 56 of file diff-jobo-cfg.py.

56 def dict_diff(ref, chk):
57  """ Return a dict of keys that differ with another config object. If a value is
58  not found in one fo the configs, it will be represented by KEYNOTFOUND.
59  @param ref: First dictionary to diff.
60  @param chk: Second dicationary to diff.
61  @return diff: Dict of Key => (ref.val, chk.val)
62  """
63  diff = {}
64  # Check all keys in ref dict
65  for k in ref.iterkeys():
66  if not (k in chk):
67  diff[k] = (ref[k], '<KEYNOTFOUND>')
68  elif (ref[k] != chk[k]):
69  diff[k] = (ref[k], chk[k])
70  # Check all keys in chk dict to find missing
71  for k in chk.iterkeys():
72  if not (k in ref):
73  diff[k] = ('<KEYNOTFOUND>', chk[k])
74  return diff
75 

◆ dump_seq()

def diff-jobo-cfg.dump_seq (   seq)

Definition at line 24 of file diff-jobo-cfg.py.

24 def dump_seq(seq):
25  for i in seq:
26  print (i)
27  pass
28 

◆ load_cfg_file()

def diff-jobo-cfg.load_cfg_file (   fname)
return the dictionary of components and their properties

Definition at line 44 of file diff-jobo-cfg.py.

44 def load_cfg_file(fname):
45  """return the dictionary of components and their properties
46  """
47  comps_db = {}
48  try:
49  import shelve
50  comps_db = shelve.open(fname, 'r')
51  return comps_db['all-cfgs']
52  except Exception:
53  exec (open(fname).read(), comps_db)
54  return comps_db['d']
55 

Variable Documentation

◆ __author__

diff-jobo-cfg.__author__
private

Definition at line 17 of file diff-jobo-cfg.py.

◆ _add

diff-jobo-cfg._add
private

Definition at line 146 of file diff-jobo-cfg.py.

◆ action

diff-jobo-cfg.action

Definition at line 165 of file diff-jobo-cfg.py.

◆ args

diff-jobo-cfg.args

Definition at line 171 of file diff-jobo-cfg.py.

◆ chk_db

diff-jobo-cfg.chk_db

Definition at line 194 of file diff-jobo-cfg.py.

◆ chk_fname

diff-jobo-cfg.chk_fname

Definition at line 177 of file diff-jobo-cfg.py.

◆ default

diff-jobo-cfg.default

Definition at line 167 of file diff-jobo-cfg.py.

◆ dest

diff-jobo-cfg.dest

Definition at line 150 of file diff-jobo-cfg.py.

◆ help

diff-jobo-cfg.help

Definition at line 151 of file diff-jobo-cfg.py.

◆ options

diff-jobo-cfg.options

Definition at line 171 of file diff-jobo-cfg.py.

◆ parser

diff-jobo-cfg.parser

Definition at line 143 of file diff-jobo-cfg.py.

◆ ref_db

diff-jobo-cfg.ref_db

Definition at line 191 of file diff-jobo-cfg.py.

◆ ref_fname

diff-jobo-cfg.ref_fname

Definition at line 174 of file diff-jobo-cfg.py.

◆ sc

diff-jobo-cfg.sc

Definition at line 197 of file diff-jobo-cfg.py.

◆ usage

diff-jobo-cfg.usage

Definition at line 144 of file diff-jobo-cfg.py.

read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.Bindings.iteritems
iteritems
Definition: Control/AthenaPython/python/Bindings.py:820
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
diff-jobo-cfg.dict_diff
def dict_diff(ref, chk)
Definition: diff-jobo-cfg.py:56
diff-jobo-cfg.dump_seq
def dump_seq(seq)
Definition: diff-jobo-cfg.py:24
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
diff-jobo-cfg.cxx_sort
def cxx_sort(dpp)
Definition: diff-jobo-cfg.py:29
Trk::open
@ open
Definition: BinningType.h:40
diff-jobo-cfg.load_cfg_file
def load_cfg_file(fname)
Definition: diff-jobo-cfg.py:44
diff-jobo-cfg.cmp_component_db
def cmp_component_db(ref, chk, verbose=True)
Definition: diff-jobo-cfg.py:76