changeset 252:40e7d08e0123

combine_subdict optionally lets you set the name, permanent-ness
author David McClosky <dmcc@bigasterisk.com>
date Wed, 15 Jun 2005 04:14:18 +0000
parents 1843386704b8
children a92b6d1ac072
files light9/Submaster.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/light9/Submaster.py	Wed Jun 15 03:56:44 2005 +0000
+++ b/light9/Submaster.py	Wed Jun 15 04:14:18 2005 +0000
@@ -124,10 +124,19 @@
                      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