[autoqueue] r285 committed - make number of neighbours a constant (for now)

0 views
Skip to first unread message

codesite...@google.com

unread,
Sep 26, 2009, 9:13:18 AM9/26/09
to auto...@googlegroups.com
Revision: 285
Author: this...@gmail.com
Date: Sat Sep 26 06:12:05 2009
Log: make number of neighbours a constant (for now)
http://code.google.com/p/autoqueue/source/detail?r=285

Modified:
/trunk/autoqueue.py
/trunk/mirage.py

=======================================
--- /trunk/autoqueue.py Sat Sep 26 05:52:06 2009
+++ /trunk/autoqueue.py Sat Sep 26 06:12:05 2009
@@ -54,6 +54,9 @@
# be nice to last.fm
WAIT_BETWEEN_REQUESTS = timedelta(0, 1)

+# XXX make configurable
+NEIGHBOURS = 20
+
def exhaust(iterator):
for i in iterator:
yield
@@ -681,7 +684,7 @@
track_id, artist_id = track[0], track[1]
db = Db(self.get_db_path())
yield
- if db.has_scores(track_id):
+ if db.has_scores(track_id, no=NEIGHBOURS):
return
yield
scms = db.get_track(track_id)
@@ -696,7 +699,8 @@
if add_neighbours:
exclude_ids = self.get_artist_tracks(artist_id)
for dummy in db.add_neighbours(track_id, scms,
- exclude_ids=exclude_ids):
+ exclude_ids=exclude_ids,
+ add=NEIGHBOURS):
yield
return

=======================================
--- /trunk/mirage.py Sat Sep 26 05:57:15 2009
+++ /trunk/mirage.py Sat Sep 26 06:12:05 2009
@@ -452,13 +452,12 @@
connection.commit()
self.close_database_connection(connection)

- def add_neighbours(self, trackid, scms, exclude_ids=None):
+ def add_neighbours(self, trackid, scms, exclude_ids=None, add=20):
connection = self.get_database_connection()
connection.execute("DELETE FROM distance WHERE track_1 = ?",
(trackid,))
connection.commit()
self.close_database_connection(connection)
yield
- min_add = 10
if not exclude_ids:
exclude_ids = []
c = ScmsConfiguration(20)
@@ -469,12 +468,12 @@
continue
other = instance_from_picklestring(buf)
dist = int(distance(scms, other, c) * 1000)
- if len(best) > min_add - 1:
+ if len(best) > add - 1:
if dist > best[-1][0]:
continue
best.append((dist, trackid, otherid))
best.sort()
- while len(best) > min_add:
+ while len(best) > add:
best.pop()
yield
added = 0

Reply all
Reply to author
Forward
0 new messages