def _update_magic_objects(self, level):
objects = collect(level+1)
contained_objects = set()
valid_refs = set()
for obj in objects:
if obj.invalidates_magic_network:
valid_refs.add(weakref.ref(obj))
for contained in _get_contained_objects(obj):
contained_objects.add(contained)
// check whether we should restart time, continue time, or raise an
// error
inter = valid_refs.intersection(self._previous_refs)
if len(inter) == 0:
// reset time
self.t_ = 0.0
elif len(self._previous_refs) == len(valid_refs):
After Change
// reset id -- think of this as a new Network
self.assign_id()
for obj in objects:
if obj._network is None:
obj._network = self.id
self.objects[:] = objects
logger.info("Updated MagicNetwork to include {numobjs} objects "
"with names {names}".format(
numobjs=len(self.objects),