def palindrome(detect): # Strip strips all puncuation or/and spaces # see Strip.py in Everything.py's directory try: import Strip except ImportError as e: print("\nCannot find module named Strip.py" " Strip.py can be found in Dropbox\n") if DEVMODE == True: print(e) main() # If there is an error importing Strip.py # display custom error message, go back to main() detect = Strip.stripWithSpace(detect).lower() # takes detect varaible, strips all puncuation with spaces and # makes it lower case, this makes it easier to work with if detect == detect[::-1]: # reverses entire string print("\n") print(detect.capitalize(), " is a palindrome") # if its the same as it is backwards, print (detect) is a palindrome else: print("\n") print(detect.capitalize(), " is not a palindrome") # if its not the same backwards, print (detect) is not a palindrome input("any key to exit") # input any key to exit
def __init__(self, handler, noStrip=NO_STRIP_ATTACHED): super(Animator, self).__init__(SOCKET_NAME, handler) self.queue = Queue.Queue(1) if noStrip: strip = Strip.SimulationStrip(STRIP_LENGTH, ROW_LENGTH) else: strip = Strip.HardwareStrip(STRIP_LENGTH) self.strip = strip self.counter = ModCounter(len(Animation.DYNAMIC_ANIMATIONS)) self.stepper = Stepper(self.queue, Animation.ANIMATIONS[Animation.BLACKOUT], strip) self.stepper.start() if GPIO_AVAILABLE: self.buttonmonitor = ButtonMonitor() self.buttonmonitor.start() self.processCommand(ButtonEvent.SINGLEPRESS)
def addStrips(self): _antecedent = [(0, 0), (1, 0), (2, 0)] angle = [0, -15, 30] elem = [1, 1, 2] for i in range(0, len(elem)): #_antecedent if _antecedent[i][ 0] == 0: #origine depend de la taille de la fenetre antecedent = [0, 200] else: antecedent = self._strips[_antecedent[i][1]].getEndStrip() _strip = Strip.Strip(master=self.master, canvas=self.canvas, Id=_antecedent[i][0], angle=angle[_antecedent[i][0]], antecedent_x=antecedent[0], antecedent_y=antecedent[1], size_barette=elem[i]) self._strips.append(_strip) print("geometrie initialized with " + str(len(self._strips)) + " independent Strips")
def messageProcessed(message, check): logging.debug("processing message") # This is in a function as it would have to repeat this process twice # depending on whether user wants to paste from clipboard or not # If the user entered message is already english # ask them if they want to continue if check == "STRING": # gets users message as a string, turns it into uppercase, removes # all puncuation, spaces and new lines so it's easier to work wit # gets user input message = Strip.strip(message).upper() # strips the message of spaces and any puncuations # also makes the entire string uppercase, as some ciphers don't work # with lower case messages message.replace('\n', '') # this is supposed to replace new lines with nothing, so everything is on one line # TODO may not actually work logging.debug("Message processed is ") logging.debug(message) elif check == "MORSE": message.replace('\n', '') # this is supposed to replace new lines with nothing, so everything is on one line # TODO may not actually work logging.debug("Message processed is ") logging.debug(message) return message if detectEnglish.isEnglish(message) == True: print("\nThis message contains English. Do you want to continue?") print("Your message is {}".format(message)) YesorNo = input("Type Yes or No: ") if YesorNo.upper().startswith("N"): close() # returns the processed message return message
def split_in_bins_n_save(root_file, saving_dir, run, mother_particle="Lc"): ybins = Imports.getYbins() #Rapidity bins ptbins = Imports.getPTbins() if run == 1: particles = ["Lc", "Xic"] else: particles = [] particles.append(mother_particle) os.mkdir(saving_dir + "ybins/") os.mkdir(saving_dir + "ptbins/") os.mkdir(saving_dir + "y_ptbins/") tree = root_file for particle in particles: if particle == "Lc": mass_cuts = "lcplus_MM < 2375" if particle == "Xic": mass_cuts = "lcplus_MM > 2375" for ybin in ybins: ycuts = "lcplus_RAPIDITY >= {0} && lcplus_RAPIDITY < {1}".format( ybin[0], ybin[1]) allcuts = " {0} && {1}".format(ycuts, mass_cuts) Strip.strip_n_save(0, 0, allcuts, "", saving_dir + "ybins/" + particle + "_ybin_{0}-{1}.root".format(ybin[0], ybin[1]), extra_variables=[""], bins=True, tree=tree) for ptbin in ptbins: ptcuts = "lcplus_PT >= {0} && lcplus_PT < {1}".format( ptbin[0], ptbin[1]) if (ybin[0] == 2.0): allcuts = " {0} && {1}".format(ptcuts, mass_cuts) Strip.strip_n_save( 0, 0, allcuts, "", saving_dir + "ptbins/" + particle + "_ptbin_{0}-{1}.root".format(ptbin[0], ptbin[1]), extra_variables=[""], particle=mother_particle, bins=True, tree=tree) yptcut = ycuts + " && " + ptcuts allcuts = " {0} && {1}".format(yptcut, mass_cuts) Strip.strip_n_save(0, 0, allcuts, "", saving_dir + "y_ptbins/" + particle + "_ybin_{0}-{1}_ptbin_{2}-{3}.root".format( ybin[0], ybin[1], ptbin[0], ptbin[1]), extra_variables=[""], particle=mother_particle, bins=True, tree=tree)
saving_directory = dir + name + "_clusters/" os.mkdir(saving_directory) file_directory = "/dcache/bfys/jdevries/ntuples/LcAnalysis/ganga/" + element step = subjobs // 20 #carry out the process in 20 clusters of datafiles to avoid memory overflow max = step min = 0 # Loop used to apply global cuts on data while (max <= subjobs): if max == min: break Strip.strip_n_save(min, max, cuts, file_directory, saving_directory, extra_variables, particle=particle) temp = max if (max + step > subjobs): max = subjobs else: max += step min = temp clusters = os.listdir(saving_directory) final_chain = TChain("DecayTree") for element in clusters: final_chain.Add(saving_directory + element)
RAINBOWCYCLE: RainbowCycle(), BLACKOUT: StaticColor(Colors.BLACKOUT), RANDOM: RandomChoice(), #MUSIC : MusicReactive(), DROPLETS: Droplets(), ADDITIVECYCLE: Additive(False), COLORROTATE: ColorRotate(), COLORCHASE: ColorChase(4, 64), COLORSTROBE: ColorStrobe(), MULTITEST: MultiAnimation([ ColorChase(4, 32), ColorChase(4, 32), ColorChase(4, 32), ColorChase(4, 32) ], [ Strip.FirstQuarterSubstrip(True), Strip.SecondQuarterSubstrip(), Strip.ThirdQuarterSubstrip(True), Strip.FourthQuarterSubstrip() ]) }
import cProfile import Strip s = Strip.HardwareStrip(64, "/dev/spidev0.0") cProfile.run("s.setColor([127,127,127])")