Take the 2-minute tour ×  I wrote this function (used later to
select elite species in the genetic algorithm) to select k best
values out of n, where not all n values are unique. First of
all, I'd massively appreciate any comments to the code, but I'm
primarily concerned with the fact that for some reason values in
second vector (var2) are also set to 0. If instead of array I
use list, this doesn't happen, but of course I want to use
arrays rather than lists! So any comments are very welcome
import numpy  import tkMessageBox  'v1 is the vector of values
from which k best must be selected for maximization problems'
class kbest():      def val_report(self,k,v1):         if k>n:
while (l<k):                 'v1=numpy.delete(v1, best_now)'
'print l,v2;'         return v2      def trigger1(self):
tkMessageBox.showwarning('Wrong value','Select the correct
value')     elite=kbest().val_report(3, var1);     print elite
print var2 share|improve this question Format your code. – 