def query(self,point,k=None,method='mode',slow=False,dumdumcheck=False):
		"""
		Returns class value for an unlabled point by examining its k nearest
		neighbors. 'method' determines how the class of the unlabled point is
		determined.
		"""
		if k is None:
			k = self.k
		#stime = time.time()
		if len(self.anchors) < self.num_anchors:
			self.resetAnchors()
		if not self.is_sorted:
			for a in self.anchors:
				self.data_by_anchors[a] = [ ( self.distfun(self.training_data[datai],self.training_data[a]), datai) for datai in range(len(self.training_data))]
				self.data_by_anchors[a].sort(key=lambda pnt: pnt[0])
		#select the anchor to search from
		#right now pick the anchor closest to the query point
		
		#anchor = self.anchors[0]
		#anchor_dist = self.distfun(point,self.training_data[anchor]) 
		#for i in xrange(1,len(self.anchors)):
		#	new_anchor = self.anchors[i]
		#	new_anchor_dist = self.distfun(point,self.training_data[new_anchor])
		#	if new_anchor_dist < anchor_dist:
		#		anchor = new_anchor
		#		anchor_dist = new_anchor_dist
		res = self.kdt.query(numpy.array([point,]))
		anchor = self.anchors[res[1][0]]
		anchor_dist = res[0][0]
		#print "Found the anchor",anchor,anchor_dist
		
		#now search through the list
		anchor_list = self.data_by_anchors[anchor]
		neighbors = list()
		maxd = None
		maxd_idx = 0
		for i in xrange(0,len(anchor_list)):
			nextpnt_dist = self.distfun(point,self.training_data[anchor_list[i][1]])
			self.num_checks += 1
			nextthing = (nextpnt_dist,anchor_list[i][1])
			
			#ins_idx = bisect.bisect(neighbors,nextthing)
			#if ins_idx <= k:
			#	neighbors.insert(ins_idx,nextthing)
			#	neighbors = neighbors[:k]
			#if not(slow) and len(neighbors) >= k:
			#	if anchor_dist + neighbors[k-1][0] < anchor_list[i][0]:
			#		break
			
			if len(neighbors)<k:
				if (maxd is None) or (maxd < nextpnt_dist):
					maxd = nextpnt_dist
					maxd_idx = len(neighbors)
				neighbors.append(nextthing)
			elif nextpnt_dist < maxd:
				neighbors[maxd_idx] = nextthing
				maxthing = max(neighbors)
				maxd_idx = neighbors.index(maxthing)
				maxd = maxthing[0]
			if not(slow) and len(neighbors) >= k:
				if anchor_dist + maxd < anchor_list[i][0]:
					break

		#we have the k neighbors, report the class
		#of the query point via method
		if method == 'mode':
			class_count = dict()
			for n in neighbors:
				nid = n[1]
				clss = self.data_classes[nid]
				if clss in class_count:
					tmp = class_count[clss]
				else:
					tmp = 0
				class_count[clss] = tmp+1
			bleh = max(class_count.iteritems(),key=lambda item:item[1])
			if dumdumcheck and bleh[1] == 1:
				print "aHAH!"
				print point
			rv = bleh[0]
		elif method == 'mean':
			return sum([self.data_classes[n[1]] for n in neighbors])/float(k)
		#etime = time.time()
		#print "Query time:", etime-stime
		return rv
dataset/ETHPy150Open QuantSoftware/QuantSoftwareToolkit/QSTK/qstklearn/fastknn.py/FastKNN.query/original