MCPcopy Create free account
hub / github.com/ActiveState/code / sumInDict2

Function sumInDict2

recipes/Python/278259_Dictionary_Tools/recipe-278259.py:261–273  ·  view source on GitHub ↗

Given a dict: {'A':{'S': [s11,s12,s13], 'V':[v11,v12,v13], ...}, 'B':{'S': [s21,s22,s23], 'V':[v21,v22,v23], ...}, 'C':{'S': [s31,s32,s33], 'V':[v31,v32,v33], ...}, ... } Return a dict: {'S': [s1,s2,s3], 'V':[v1,v2,v3], ...} where s1 = s11 + s21 +

(D)

Source from the content-addressed store, hash-verified

259#========================================================================
260
261def sumInDict2(D):
262 ''' Given a dict:
263 {'A':{'S': [s11,s12,s13], 'V':[v11,v12,v13], ...},
264 'B':{'S': [s21,s22,s23], 'V':[v21,v22,v23], ...},
265 'C':{'S': [s31,s32,s33], 'V':[v31,v32,v33], ...}, ...
266 }
267 Return a dict:
268 {'S': [s1,s2,s3], 'V':[v1,v2,v3], ...}
269
270 where s1 = s11 + s21 + s31 + ...
271 s2 = s12 + s22 + s32 + ...
272 '''
273 return sumInDict(D.values())
274
275#========================================================================
276

Callers

nothing calls this directly

Calls 2

sumInDictFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected