dont simplify everything away, ever

This commit is contained in:
Laura Klünder 2017-11-16 23:06:15 +01:00
parent f9ccbd7b95
commit 3dc32aff3f

View file

@ -177,9 +177,10 @@ class MapHistory:
def simplify(self):
logging.info('simplify!')
# remove updates that have no longer any array cells
new_updates = ((update, (self.data == i)) for i, update in enumerate(self.updates))
new_updates = ((i, update, (self.data == i)) for i, update in enumerate(self.updates))
logging.info('before: %s' % (self.updates, ))
self.updates, new_affected = zip(*((update, affected) for update, affected in new_updates if affected.any()))
self.updates, new_affected = zip(*((update, affected) for i, update, affected in new_updates
if i == 0 or affected.any()))
logging.info('after: %s' % (self.updates, ))
for i, affected in enumerate(new_affected):
self.data[affected] = i