1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

add weights decay back

This commit is contained in:
William Ting 2013-05-14 20:22:44 -05:00
parent 776f109b3a
commit dd7a0fbbc7

View File

@ -125,8 +125,16 @@ class Database:
def maintenance(self):
"""
If database has exceeded max_paths, remove bottom 10% entries.
Decay weights by 10%, periodically remove bottom 10% entries.
"""
try:
items = self.data.iteritems()
except AttributeError:
items = self.data.items()
for path, _ in items:
self.data[path] *= 0.9
if len(self.data) > self.config['max_paths']:
remove_cnt = int(0.1 * len(self.data))
for path in sorted(self.data, key=self.data.get)[:remove_cnt]:
@ -189,7 +197,7 @@ class Database:
def set_defaults():
config = {}
config['version'] = 'release-v21.6.4'
config['version'] = 'release-v21.6.5'
config['max_paths'] = 1000
config['separator'] = '__'
config['home'] = os.path.expanduser('HOME')