mirror of
				https://github.com/wting/autojump
				synced 2025-06-13 12:54:07 +00:00 
			
		
		
		
	increment path weights on a log scale
This commit is contained in:
		
							parent
							
								
									900e3889e7
								
							
						
					
					
						commit
						f98b13641f
					
				| @ -2,6 +2,7 @@ | ||||
| from __future__ import division, print_function | ||||
| 
 | ||||
| import argparse | ||||
| import math | ||||
| from operator import itemgetter | ||||
| import os | ||||
| import re | ||||
| @ -34,10 +35,12 @@ class Database: | ||||
|         self.data = {} | ||||
|         self.load() | ||||
| 
 | ||||
|     # TODO: increase logarithmically as opposed to linear | ||||
|     def add(self, key, increment = 1): | ||||
|     def add(self, path, increment=1): | ||||
|         """ Increment existing paths or initialize new ones to 0. """ | ||||
|         self.data[key] = self.data.get(key, 0.) + increment | ||||
|         if path not in self.data: | ||||
|             self.data[path] = 10 | ||||
|         else: | ||||
|             self.data[path] = math.sqrt((self.data[path]**2)+100) | ||||
| 
 | ||||
|     def decay(self): | ||||
|         """ Decay database entries. """ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user