def printStats(self, stats): allGenotypes = stats["genotypes"] summaryGenotypes = [] count = 0 for genotypes in allGenotypes: centerOfGravity = getCenterOfGravity(genotypes) summaryGenotypes += genotypes print "Herd " + str(count) count += 1 print "CenterOfGravity: ", centerOfGravity print "Summary CenterOfGravity: ", getCenterOfGravity(summaryGenotypes)
def actualStats(self, stats): genotypes = stats['genotypes'] for i in xrange(len(genotypes)): herd_genotypes = genotypes[i] if len(self._min) <= i: maxVal = None minVal = None self._min.insert(i, 0) self._max.insert(i, 0) else: maxVal = self._max[i] minVal = self._min[i] CoG = getCenterOfGravity(herd_genotypes) maxDist = getDist(herd_genotypes[0], CoG) minDist = maxDist for i in xrange(1, len(herd_genotypes)): dist = getDist(herd_genotypes[i], CoG) maxDist = max(maxDist, dist) minDist = min(minDist, dist) if maxVal is None: maxVal = maxDist minVal = minDist maxVal = max(maxVal, maxDist) minVal = min(minVal, minDist) self._min[i] = minVal self._max[i] = maxVal
def actualStats(self, stats): genotypes = stats["genotypes"] for i in xrange(len(genotypes)): herd_genotypes = genotypes[i] CoG = getCenterOfGravity(herd_genotypes) if len(self._prevCoG) <= i: self._prevCoG.insert(i, CoG) self._sum.insert(i, 0) self._count.insert(i, 0) prevCoG = self._prevCoG[i] dist = getDist(prevCoG, CoG) if len(self._max) <= i: maxVal = dist else: maxVal = self._max[i] maxVal = max(maxVal, dist) self._max[i] = maxVal sumVal = self._sum[i] self._sum[i] = sumVal + dist count = self._count[i] self._count[i] = count + 1 self._prevCoG[i] = CoG