<s> from __future__ import division , print_function , unicode_literals <EOL> from sacred . utils import iter_prefixes , join_paths <EOL> class ConfigSummary ( dict ) : <EOL> def __init__ ( self , added = ( ) , modified = ( ) , typechanged = ( ) , <EOL> ignored_fallbacks = ( ) ) : <EOL> super ( ConfigSummary , self ) . __init__ ( ) <EOL> self . added = set ( added ) <EOL> self . modified = set ( modified ) <EOL> self . typechanged = dict ( typechanged ) <EOL> self . ignored_fallbacks = set ( ignored_fallbacks ) <EOL> self . ensure_coherence ( ) <EOL> def update_from ( self , config_mod , path = '<STR_LIT>' ) : <EOL> added = config_mod . added <EOL> updated = config_mod . modified <EOL> typechanged = config_mod . typechanged <EOL> self . added &= { join_paths ( path , a ) for a in added } <EOL> self . modified |= { join_paths ( path , u ) for u in updated } <EOL> self . typechanged . update ( { join_paths ( path , k ) : v <EOL> for k , v in typechanged . items ( ) } ) <EOL> self . ensure_coherence ( ) <EOL> def update_add ( self , config_mod , path = '<STR_LIT>' ) : <EOL> added = config_mod . added <EOL> updated = config_mod . modified <EOL> typechanged = config_mod . typechanged <EOL> self . added |= { join_paths ( path , a ) for a in added } <EOL> self . modified |= { join_paths ( path , u ) for u in updated } <EOL> self . typechanged . update ( { join_paths ( path , k ) : v <EOL> for k , v in typechanged . items ( ) } ) <EOL> self . ensure_coherence ( ) <EOL> def ensure_coherence ( self ) : <EOL> self . modified |= { p for a in self . added for p in iter_prefixes ( a ) } <EOL> self . modified |= { p for u in self . modified for p in iter_prefixes ( u ) } <EOL> self . modified |= { p for t in self . typechanged <EOL> for p in iter_prefixes ( t ) } <EOL> self . added -= set ( self . typechanged . keys ( ) ) <EOL> self . modified -= set ( self . typechanged . keys ( ) ) <EOL> self . modified -= self . added </s>
