def __repr__(self): if len(self.d.items()) == 0: return "Empty DDist" else: dictRepr = reduce(operator.add, [util.prettyString(k)+": "+\ util.prettyString(p)+", " \ for (k, p) in self.d.items()]) return "DDist(" + dictRepr[:-2] + ")"
def __str__(self): return ( "Sonar: " + util.prettyString(self.sonars) + "; Odo: " + util.prettyString(self.odometry) + "; Analog: " + util.prettyString(self.analogInputs) )
def plotSlime(self): maxT = len(self.slimeData) if maxT == 0: print 'No slime to plot' return slimeX = [p[0] for p in self.slimeData] slimeY = [p[1] for p in self.slimeData] (xLower, xUpper, yLower, yUpper) = self.getEquallyScaledBounds(slimeX, slimeY) xRange = xUpper - xLower yRange = yUpper - yLower if util.within(xRange, 0, 0.001): return if self.slimeWindow: self.slimeWindow.destroy() self.slimeWindow = dw.DrawingWindow(\ self.windowSize, self.windowSize, xLower, xUpper, yLower, yUpper, 'slime') # Draw dimensions self.slimeWindow.drawText(xLower + 0.1 * xRange, yLower + 0.05 * yRange, util.prettyString(xLower), color="black") self.slimeWindow.drawText(xUpper - 0.1 * xRange, yLower + 0.05 * yRange, util.prettyString(xUpper), color="black") self.slimeWindow.drawText(xLower + 0.05 * xRange, yLower + 0.1 * yRange, util.prettyString(yLower), color="black") self.slimeWindow.drawText(xLower + 0.05 * xRange, yUpper - 0.1 * yRange, util.prettyString(yUpper), color="black") # Draw axes xMin = min(slimeX) xMax = max(slimeX) yMin = min(slimeY) yMax = max(slimeY) self.slimeWindow.drawLineSeg(xMin, yMin, xUpper - 0.1 * xRange, yMin, 'gray') self.slimeWindow.drawLineSeg(xMin, yMin, xMin, yUpper - 0.1 * yRange, 'gray') # Draw slime for i in range(maxT): self.slimeWindow.drawRobot( slimeX[i], slimeY[i], slimeX[i], slimeY[i], colors.RGBToPyColor(colors.HSVtoRGB(i * 360.0 / maxT, 1.0, 1.0)), 2)
def __str__(self): result = 'DE: y[n] = ' for i in range(len(self.cCoeffs)): result += util.prettyString(self.cCoeffs[i])+'y[n-'+str(i+1)+'] + ' for i in range(len(self.dCoeffs)): if i == 0: result += util.prettyString(self.dCoeffs[i])+'x[n] + ' else: result +=util.prettyString(self.dCoeffs[i])+'x[n-'+str(i)+'] + ' return result[:-2]
def __str__(self): result = 'DE: y[n] = ' for i in range(len(self.cCoeffs)): result += util.prettyString( self.cCoeffs[i]) + 'y[n-' + str(i + 1) + '] + ' for i in range(len(self.dCoeffs)): if i == 0: result += util.prettyString(self.dCoeffs[i]) + 'x[n] + ' else: result += util.prettyString( self.dCoeffs[i]) + 'x[n-' + str(i) + '] + ' return result[:-2]
def plotSlime(self): maxT = len(self.slimeData) if maxT == 0: print 'No slime to plot' return slimeX = [p[0] for p in self.slimeData] slimeY = [p[1] for p in self.slimeData] (xLower, xUpper, yLower, yUpper) = self.getEquallyScaledBounds(slimeX, slimeY) xRange = xUpper - xLower yRange = yUpper - yLower if util.within(xRange, 0, 0.001): return if self.slimeWindow: self.slimeWindow.destroy() self.slimeWindow = dw.DrawingWindow(\ self.windowSize, self.windowSize, xLower, xUpper, yLower, yUpper, 'slime') # Draw dimensions self.slimeWindow.drawText(xLower + 0.1 * xRange, yLower + 0.05 * yRange, util.prettyString(xLower), color = "black") self.slimeWindow.drawText(xUpper - 0.1 * xRange, yLower + 0.05 * yRange, util.prettyString(xUpper), color = "black") self.slimeWindow.drawText(xLower + 0.05 * xRange, yLower + 0.1 * yRange, util.prettyString(yLower), color = "black") self.slimeWindow.drawText(xLower + 0.05 * xRange, yUpper - 0.1 * yRange, util.prettyString(yUpper), color = "black") # Draw axes xMin = min(slimeX) xMax = max(slimeX) yMin = min(slimeY) yMax = max(slimeY) self.slimeWindow.drawLineSeg(xMin, yMin, xUpper - 0.1 * xRange, yMin, 'gray') self.slimeWindow.drawLineSeg(xMin, yMin, xMin, yUpper - 0.1 * yRange, 'gray') # Draw slime for i in range(maxT): self.slimeWindow.drawRobot(slimeX[i], slimeY[i], slimeX[i], slimeY[i], colors.RGBToPyColor(colors.HSVtoRGB(i*360.0/maxT, 1.0, 1.0)), 2)
def printDebugInfo(self, depth, state, nextState, inp, out, debugParams): """ Default method for printing out all of the debugging information for a primitive machine. """ self.guaranteeName() if debugParams.verbose and not debugParams.compact: if debugParams.printInput: print ' '*depth, self.name, "In:", \ util.prettyString(inp), \ "Out:", util.prettyString(out), \ "Next State:", util.prettyString(nextState) else: print ' '*depth, self.name, \ "Out:", util.prettyString(out), \ "Next State:", util.prettyString(nextState) self.doTraceTasks(inp, state, out, debugParams)
def getNextValues(self, state, inp): out = None first = True while not out in self.legalInputs: if not first: print 'Illegal input:', out out = raw_input('Type an input (' + \ util.prettyString(self.legalInputs) + \ ' ): ') if not out == 'quit': out = int(out) first = False return (out == 'quit', out)
def getNextValues(self, state, inp): out = None first = True while not out in self.legalInputs: if not first: print "Illegal input:", out out = raw_input("Type an input (" + util.prettyString(self.legalInputs) + " ): ") if not out == "quit": out = int(out) first = False return (out == "quit", out)
def __str__(self): return 'Act: ' + '(fvel = ' + util.prettyString(self.fvel) + \ ', rvel = ' + util.prettyString(self.rvel) + ')'
def __str__(self): return 'Sonar: ' + util.prettyString(self.sonars) + \ "; Odo: " + util.prettyString(self.odometry) +\ "; Analog: " + util.prettyString(self.analogInputs)
def __str__(self): return "Act: " + "(fvel = " + util.prettyString(self.fvel) + ", rvel = " + util.prettyString(self.rvel) + ")"
def __str__(self): return 'Circuit: '+util.prettyString(self.components)
def __str__(self): return 'Circuit: ' + util.prettyString(self.components)