Changeset - 40e7d08e0123
[Not reviewed]
default
0 1 0
David McClosky - 20 years ago 2005-06-15 04:14:18
dmcc@bigasterisk.com
combine_subdict optionally lets you set the name, permanent-ness
1 file changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/Submaster.py
Show inline comments
 
@@ -124,10 +124,19 @@ def sub_maxes(*subs):
 
                     dict_max(*[sub.levels for sub in nonzero_subs]),
 
                     temporary=1)
 

	
 
def combine_subdict(subdict):
 
    """A subdict is { Submaster objects : values }"""
 
def combine_subdict(subdict, name=None, permanent=False):
 
    """A subdict is { Submaster objects : levels }.  We combine all
 
    submasters first by multiplying the submasters by their corresponding
 
    levels and then max()ing them together.  Returns a new Submaster
 
    object.  You can give it a better name than the computed one that it
 
    will get or make it permanent if you'd like it to be saved to disk.
 
    Serves 8."""
 
    scaledsubs = [sub * level for sub, level in subdict.items()]
 
    maxes = sub_maxes(*scaledsubs)
 
    if name:
 
        maxes.name = name
 
    if permanent:
 
        maxes.temporary = False
 

	
 
    return maxes
 

	
0 comments (0 inline, 0 general)