annotate light8/util.py @ 15:c76b62eccdec

put **kw back in, they now go to the scale and can override the defaults. put **kw back in, they now go to the scale and can override the defaults. for our purposes, we probably want to edit the defaults so we don't have them in every call.
author dmcc
date Sun, 07 Jul 2002 06:18:40 +0000
parents f974a462133f
children 62c47c3a90cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
1
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 def maxes(dicts):
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 ({'a' : 5, 'b' : 9}, {'a' : 10, 'b' : 943})
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 newdict = {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 for d in dicts:
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 for k,v in d.items():
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 newdict[k] = max(v, newdict.get(k, 0))
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 return newdict
45b12307c695 Initial revision
drewp
parents:
diff changeset
11
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 def scaledict(d,scl):
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 # scales all values in dict and returns a new dict
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 return dict([(k,v*scl) for k,v in d.items()])
45b12307c695 Initial revision
drewp
parents:
diff changeset
15
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 # class Setting that scales, maxes