content
stringlengths
7
1.05M
#def divisor is from: #https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php def divisor(n): for i in range(n): x = len([i for i in range(1, n+1) if not n % i]) return x nums = [] i = 0 while i < 20: preNum = int(input()) if(preNum > 0): nums.append([divisor(preNum), preNum]) i += 1 nums.sort() f=nums[len(nums)-1] x=f.copy() y = (x[::-1]) print(*y, sep=" ")
class Solution: def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ low = 0 high = len(nums) - 1 while low <= high: mid = (low + high)//2 if nums[mid] == target: return mid elif nums[mid] > target: high = mid - 1 elif nums[mid] < target: low = mid + 1 return low
s, t = 7, 11 a, b = 5, 15 m, n = 3, 2 apple = [-2, 2, 1] orange = [5, -6] a_score, b_score = 0, 0 ''' too slow for i in apple: if (a + i) in list(range(s, t+1)): a_score +=1 for i in orange: if (b + i) in list(range(s, t+1)): b_score +=1 ''' for i in apple: if (a+i >= s) and (a+i <= t): a_score += 1 for i in orange: if (b+i >= s) and (b+i <= t): b_score +=1
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # File name: system.py # Description: Basic System Functions # Author: irreq (irreq@protonmail.com) # Date: 17/12/2021 """Documentation""" def set_brightness(brightness): """Sets brightness for Thinkpad Laptop""" if int(brightness) > 15: raise TypeError("Need int 0 < and > 15") elif int(brightness) < 0: raise TypeError("Need int 0 < and > 15") with open("/sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness","w") as bright: bright.write(str(brightness)) bright.close() class SysData(): def __init__(self): self.path = "/proc/cpuinfo" self.stat = "/proc/stat" # temperature = cat /sys/class/thermal/thermal_zone*/temp self.cpus = dict() self.temp = 0 self.refresh() def refresh(self): self.cpus = ["cpu?*"] self.cpus = {"cpus": self.cpus, "last": {}, "list": []} for line in self._get_stat(): fields = line.split() cpu_name = fields[0] for local_filter in self.cpus["cpus"]: if fnmatch(cpu_name, local_filter): self.cpus["list"].append(cpu_name) def _get_tempinfo(self): # Fix this as it is hardcoded to work only for thermal_zone0 and # that could be anything on a multisensor system. with open(r"/sys/class/thermal/thermal_zone0/temp", "r") as f: temp = [i.split("\n")[0] for i in f][0] return str(int(float(temp) / 1e3)) def _get_cpuinfo(self): with open(self.path, "r") as f: return [float(line.split()[-1]) for line in f if "cpu MHz" in line] def _calc_cpu_freqs(self, cpu_freqs): """Min, mean and max""" freqs = [min(cpu_freqs), sum(cpu_freqs) / len(cpu_freqs), max(cpu_freqs)] return [round(i / 1e3, 2) for i in freqs] def _calc_cpu_percent(self, cpu): name, idle, total = cpu last_idle = self.cpus["last"].get(name, {}).get("idle", 0) last_total = self.cpus["last"].get(name, {}).get("total", 0) used_percent = 0 if total != last_total: used_percent = (1 - (idle - last_idle) / (total - last_total)) * 100 self.cpus["last"].setdefault(name, {}).update( zip(["name", "idle", "total"], cpu) ) return used_percent def _get_stat(self): # kernel/system statistics. man -P 'less +//proc/stat' procfs stat = [] with open(self.stat, "r") as f: for line in f: if "cpu" in line: stat.append(line) else: return stat def _filter_stat(self, stat, avg=False): if avg: fields = stat[0].split() return "avg", int(fields[4]), sum(int(x) for x in fields[1:]) new_stat = [] for line in stat: fields = line.split() cpu_name = fields[0] if self.cpus["cpus"]: for _filter in self.cpus["cpus"]: if fnmatch(cpu_name, _filter): if cpu_name not in self.cpus["list"]: self.cpus["list"].append(cpu_name) if cpu_name not in self.cpus["list"]: continue new_stat.append((cpu_name, int(fields[4]), sum(int(x) for x in fields[1:]))) return new_stat def _calc_cpu_percent_wrapper(self): stat = self._get_stat() cpu = self._filter_stat(stat, avg=False) return [self._calc_cpu_percent(i) for i in cpu] class Status(): def __init__(self, verbose=True, status_items=["cpu"]): self.verbose = verbose self.status_items = status_items self.values = {item:[str, *(int,)*3] for item in self.status_items} self.dynamic_cpu = SysData() def make_correct(self, string, length, suffix="", filler="0"): difference = length-len(string) return string[:length] + filler*difference*(difference >= 0) + suffix def cpu(self): cpu_info = self.dynamic_cpu._get_cpuinfo() low, mean, high = self.dynamic_cpu._calc_cpu_freqs(cpu_info) core_usage = self.dynamic_cpu._calc_cpu_percent_wrapper() temperature = int(self.dynamic_cpu._get_tempinfo()) # speed = self.make_correct(str(mean), 4) cpu_percentage = int(sum(core_usage)/len(core_usage)) if not self.verbose: HOT = 80 COLD = 19 temp = abs(continuous_rectifier(COLD, temperature, HOT)-COLD)/(HOT-COLD)*100 avg = (cpu_percentage + temp) // 2 else: avg = cpu_percentage # Do we seriously need the CPU-frequency? text = "CPU: {}°C {}%".format(temperature, cpu_percentage) return text, temperature, cpu_percentage def audio(self): percentage = 100 # return "VOL: Master {}%".format(percentage), 0, 0 return "VOL: <UNFINISHED>", 0, 0 def network(self): return "NET: <UNFINISHED>", 0, 0 def memory(self, path="/proc/meminfo", head=40): """Calculate: total memory, used memory and percentage From 'htop': Total used memory = MemTotal - MemFree Non cache/buffer memory (green) = Total used memory - (Buffers + Cached memory) Buffers (blue) = Buffers Cached memory (yellow) = Cached + SReclaimable - Shmem Swap = SwapTotal - SwapFree """ with open(path, "r") as f: info = [next(f).split() for _ in range(head)] mem_values = {fields[0]: float(fields[1]) for fields in info} total = mem_values["MemTotal:"] used = total - mem_values['MemFree:'] - (mem_values['Buffers:'] + (mem_values['Cached:'] + mem_values['SReclaimable:'] - mem_values['Shmem:'])) # 2^20 = 1048576 total, used = [int(i/1048576*100)/100 for i in (total, used)] percentage = int(used / total * 100) text = "RAM: {}GB {}%".format(used, percentage) return text, used, percentage def storage(self, disk="/"): total, used, free = shutil.disk_usage("/") status = int(used/(2**30)*100)/100 capacity = int(used/total*100) text = "SSD: {}GB {}%".format(status, capacity) return text, status, capacity def storage_test(self): return "SSD: <TESTING>", 0, 80 def battery(self): capacity = "-" status = "Error" try: status = get_from_file("/sys/class/power_supply/BAT0/status") capacity = int(get_from_file("/sys/class/power_supply/BAT0/capacity")) except Exception: pass if not self.verbose: if status == "Error": return 0 else: return int(status) text = "BAT: {} {}%".format(status, capacity) return text, status, capacity def datetime(self): current = datetime.now() # date = "{date:%Y-%m-%d}".format(date=current) # time = "{time:%H:%M:%S}".format(time=current) # # return str(type(current)) return "{date:%Y-%m-%d %H:%M:%S}".format(date=datetime.now()), 0, 0
class Customer: id = 1 def __init__(self, name, address, email): self.name = name self.address = address self.email = email self.id = Customer.id Customer.id += 1 def __repr__(self): return f"Customer <{self.id}> {self.name}; Address: {self.address}; Email: {self.email}" @staticmethod def get_next_id(): return Customer.id
SECRET_KEY = "abc" FILEUPLOAD_ALLOWED_EXTENSIONS = ["png"] # FILEUPLOAD_PREFIX = "/cool/upload" # FILEUPLOAD_LOCALSTORAGE_IMG_FOLDER = "images/boring/" FILEUPLOAD_RANDOM_FILE_APPENDIX = True FILEUPLOAD_CONVERT_TO_SNAKE_CASE = True
""" Exercise 5 Write a program to read through the mail box data and when you find line that starts with "From", you will split the line into words using the split function. We are interested in who sent the message which is the second word on the From line. From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 You will parse the From line and print out the second word for each From line and then you will also count the number of From (not From:) lines and print out a count at the end. This is a sample good output with a few lines removed: python fromcount.py Enter a file name: mbox-short.txt stephen.marquard@uct.ac.za louis@media.berkeley.edu zqian@umich.edu [...some output removed...] ray@media.berkeley.edu cwen@iupui.edu cwen@iupui.edu cwen@iupui.edu There were 27 lines in the file with From as the first word """ file_name = open("mbox-short.txt") lines = [ line.strip("\n") for line in file_name if line.startswith("From") and not line.startswith("From:") ] count = 0 for line in lines: words = line.split() print(words[1]) count += 1 print("There were %d lines in the file with From as the first word" % count)
# 6. Math Power def math_power(n, p): power_output = n ** p print(power_output) number = float(input()) power = float(input()) math_power(number, power)
# https://atcoder.jp/contests/math-and-algorithm/tasks/math_and_algorithm_bj n = int(input()) xx = [0] * n yy = [0] * n for i in range(n): xx[i], yy[i] = map(int, input().split()) xx.sort() yy.sort() ax = 0 ay = 0 cx = 0 cy = 0 for i in range(n): ax += xx[i] * i - cx cx += xx[i] ay += yy[i] * i - cy cy += yy[i] print(ax + ay)
"""Defines a rule for runtime test targets.""" load("@io_bazel_rules_go//go:def.bzl", "go_test") # runtime_test is a macro that will create targets to run the given test target # with different runtime options. def runtime_test( lang, image, shard_count = 50, size = "enormous", blacklist_file = ""): args = [ "--lang", lang, "--image", image, ] data = [ ":runner", ] if blacklist_file != "": args += ["--blacklist_file", "test/runtimes/" + blacklist_file] data += [blacklist_file] # Add a test that the blacklist parses correctly. blacklist_test(lang, blacklist_file) sh_test( name = lang + "_test", srcs = ["runner.sh"], args = args, data = data, size = size, shard_count = shard_count, tags = [ # Requires docker and runsc to be configured before the test runs. "manual", "local", ], ) def blacklist_test(lang, blacklist_file): """Test that a blacklist parses correctly.""" go_test( name = lang + "_blacklist_test", embed = [":runner"], srcs = ["blacklist_test.go"], args = ["--blacklist_file", "test/runtimes/" + blacklist_file], data = [blacklist_file], ) def sh_test(**kwargs): """Wraps the standard sh_test.""" native.sh_test( **kwargs )
_version_major = 0 _version_minor = 1 _version_micro = 0 __version__ = "{0:d}.{1:d}.{2:d}".format( _version_major, _version_minor, _version_micro)
"""Descrição de varias llinhas""" """ Esse módul é usado para descrever um codigo qu funções especificas levando em conta a usabilidade do usuário. """ variavel = 'valor' def funcao(): return 1
def troca(i,j,lista): if (i >= 0 and j >= 0) and (i <= (len(lista) - 1) and j <= (len(lista) - 1)): aux = lista[i] lista[i] = lista[j] lista[j] = aux return lista def main(): n = int(input()) lista = [] for k in range(n): lista.append(int(input())) i = int(input()) j = int(input()) lista = troca(i,j,lista) for h in lista: print(h) main()
velocidade = float(input('Digite a velocidade atual do carro: ')) multa = (velocidade - 80) * 7 if velocidade > 80: print('Você excedeu o limite de velocidade que é de 80 KM/h') print('Sua multa é de R$ {:.2f}'.format(multa)) else: print('Dirija com segurança! ')
## У будинку кілька під'їздів. У кожному під'їзді однакову кількість квартир. Квартири нумеруються підряд, починаючи з одиниці. Чи може в деякому під'їзді перша квартира мати номер x, а остання - номер y? ## Формат введення # Вводяться два натуральних числа x і y (x ≤ y), що не перевищують 10000. ## Формат виведення # Виведіть слово YES (заголовними латинськими літерами), якщо таке можливо, і NO у протилежному випадку. a = int(input()) b = int(input()) if a == 1: print("YES") elif b % (b - a + 1) == 0: print("YES") else: print("NO")
# test def addTwoNumbers(a, b): sum = a + b return sum def addList(l1): sum = 0 for i in l1: sum += i return sum add = lambda x, y : x + y num1 = 1 num2 = 2 print("The sum is ", addTwoNumbers(num1, num2)) numlist = (1, 2, 3) print(add(10, 20)) print("The sum is ", addList(numlist)) for i in range(16, 11, -1): print(i) print([x for x in range(16) if x > 2]) x = ('apple', 'banana', 'cherry') y = enumerate(x) print(list(y)) dict1 = {i: i**2 for i in range(1, 11)} print(dict1) txt = "The rain in Spain stays mainly in the plain" x = "ain" in txt print(x) def finite_sequence(): num = 0 while num < 10000: yield num num += 1 def tupletest(): return 1, 2 x,y = tupletest() print(tupletest(), x, y)
# # PySNMP MIB module MITEL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MITEL-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:02:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") ModuleIdentity, Gauge32, Counter64, Unsigned32, Bits, NotificationType, MibIdentifier, internet, ObjectIdentity, IpAddress, enterprises, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Integer32, iso, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "Gauge32", "Counter64", "Unsigned32", "Bits", "NotificationType", "MibIdentifier", "internet", "ObjectIdentity", "IpAddress", "enterprises", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Integer32", "iso", "TimeTicks") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") mitel = MibIdentifier((1, 3, 6, 1, 4, 1, 1027)) snmpV2 = MibIdentifier((1, 3, 6, 1, 6)) snmpDomains = MibIdentifier((1, 3, 6, 1, 6, 1)) snmpUDPDomain = MibIdentifier((1, 3, 6, 1, 6, 1, 1)) class InterfaceIndex(Integer32): pass class TruthValue(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("true", 1), ("false", 2)) class RowStatus(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6)) namedValues = NamedValues(("active", 1), ("notInService", 2), ("notReady", 3), ("createAndGo", 4), ("createAndWait", 5), ("destroy", 6)) class TimeStamp(TimeTicks): pass class TimeInterval(Integer32): subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) mitelIdentification = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1)) mitelExperimental = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 2)) mitelExtensions = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 3)) mitelProprietary = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4)) mitelConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5)) mitelIdMgmtPlatforms = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 1)) mitelIdCallServers = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 2)) mitelIdTerminals = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 3)) mitelIdInterfaces = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 4)) mitelIdCtiPlatforms = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 5)) mitelIdMgmtOpsMgr = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 1, 1)) mitelIdCsMc2 = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 2, 1)) mitelIdCs2000Light = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 2, 2)) mitelExtInterfaces = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 3, 2)) mitelPropApplications = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 1)) mitelPropTransmission = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 2)) mitelPropProtocols = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 3)) mitelPropUtilities = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 4)) mitelPropHardware = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 5)) mitelPropNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 6)) mitelPropReset = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 7)) mitelAppCallServer = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 1, 1)) mitelNotifTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 6, 1)) mitelConfCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 1)) mitelConfGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2)) mitelGrpCommon = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1)) mitelGrpOpsMgr = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 2)) mitelGrpCs2000 = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 3)) mitelConfAgents = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 3)) class TDomain(ObjectIdentifier): pass class TAddress(OctetString): subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 255) class MitelIfType(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1)) namedValues = NamedValues(("dnic", 1)) class MitelNotifyTransportType(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3)) namedValues = NamedValues(("mitelNotifTransV1Trap", 1), ("mitelNotifTransV2Trap", 2), ("mitelNotifTransInform", 3)) mitelIfNumber = MibScalar((1, 3, 6, 1, 4, 1, 1027, 3, 2, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIfNumber.setStatus('mandatory') mitelIfTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 3, 2, 2), ) if mibBuilder.loadTexts: mitelIfTable.setStatus('mandatory') mitelIfTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 3, 2, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: mitelIfTableEntry.setStatus('mandatory') mitelIfTblType = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 3, 2, 2, 1, 1), MitelIfType()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIfTblType.setStatus('mandatory') mitelResetReason = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 7, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("shutdown", 1), ("coldStart", 2), ("warmStart", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelResetReason.setStatus('mandatory') mitelResetPlatform = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 7, 2), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelResetPlatform.setStatus('mandatory') mitelResetAgent = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 7, 3), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelResetAgent.setStatus('mandatory') mitelNotifCount = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 6, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifCount.setStatus('mandatory') mitelNotifEnableTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3), ) if mibBuilder.loadTexts: mitelNotifEnableTable.setStatus('mandatory') mitelNotifEnableTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1), ).setIndexNames((0, "MITEL-MIB", "mitelNotifEnblTblIndex")) if mibBuilder.loadTexts: mitelNotifEnableTableEntry.setStatus('mandatory') mitelNotifEnblTblIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifEnblTblIndex.setStatus('mandatory') mitelNotifEnblTblOid = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 2), ObjectIdentifier()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifEnblTblOid.setStatus('mandatory') mitelNotifEnblTblEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 3), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifEnblTblEnable.setStatus('mandatory') mitelNotifEnblTblAck = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 4), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifEnblTblAck.setStatus('mandatory') mitelNotifEnblTblOccurrences = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifEnblTblOccurrences.setStatus('mandatory') mitelNotifEnblTblDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 3, 1, 6), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifEnblTblDescr.setStatus('mandatory') mitelNotifManagerTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4), ) if mibBuilder.loadTexts: mitelNotifManagerTable.setStatus('mandatory') mitelNotifManagerTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1), ).setIndexNames((0, "MITEL-MIB", "mitelNotifMgrTblIndex")) if mibBuilder.loadTexts: mitelNotifManagerTableEntry.setStatus('mandatory') mitelNotifMgrTblIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifMgrTblIndex.setStatus('mandatory') mitelNotifMgrTblStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 2), RowStatus().clone('active')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblStatus.setStatus('mandatory') mitelNotifMgrTblTransport = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 3), MitelNotifyTransportType().clone('mitelNotifTransV1Trap')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblTransport.setStatus('mandatory') mitelNotifMgrTblDomain = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 4), TDomain().clone((1, 3, 6, 1, 6, 1, 1))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblDomain.setStatus('mandatory') mitelNotifMgrTblAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 5), TAddress().clone(hexValue="c00002000489")).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblAddress.setStatus('mandatory') mitelNotifMgrTblTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 6), TimeInterval().clone(1000)).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblTimeout.setStatus('mandatory') mitelNotifMgrTblRetries = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10)).clone(3)).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblRetries.setStatus('mandatory') mitelNotifMgrTblLife = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 8), TimeInterval().clone(8640000)).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblLife.setStatus('mandatory') mitelNotifMgrTblCommunity = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 9), OctetString().clone('public')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblCommunity.setStatus('mandatory') mitelNotifMgrTblName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 4, 1, 10), DisplayString().clone('None specified.')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifMgrTblName.setStatus('mandatory') mitelNotifHistoryMax = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 6, 5), Integer32().clone(100)).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifHistoryMax.setStatus('mandatory') mitelNotifHistorySize = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 6, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistorySize.setStatus('mandatory') mitelNotifHistoryTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7), ) if mibBuilder.loadTexts: mitelNotifHistoryTable.setStatus('mandatory') mitelNotifHistoryTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1), ).setIndexNames((0, "MITEL-MIB", "mitelNotifHistTblIndex")) if mibBuilder.loadTexts: mitelNotifHistoryTableEntry.setStatus('mandatory') mitelNotifHistTblIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistTblIndex.setStatus('mandatory') mitelNotifHistTblId = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistTblId.setStatus('mandatory') mitelNotifHistTblTime = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1, 3), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistTblTime.setStatus('mandatory') mitelNotifHistTblIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1, 4), InterfaceIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistTblIfIndex.setStatus('mandatory') mitelNotifHistTblConfirmed = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 7, 1, 5), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifHistTblConfirmed.setStatus('mandatory') mitelNotifUnackTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8), ) if mibBuilder.loadTexts: mitelNotifUnackTable.setStatus('mandatory') mitelNotifUnackTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1), ).setIndexNames((0, "MITEL-MIB", "mitelNotifUnackTblIndex")) if mibBuilder.loadTexts: mitelNotifUnackTableEntry.setStatus('mandatory') mitelNotifUnackTblIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifUnackTblIndex.setStatus('mandatory') mitelNotifUnackTblStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 6))).clone(namedValues=NamedValues(("active", 1), ("notInService", 2), ("destory", 6)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelNotifUnackTblStatus.setStatus('mandatory') mitelNotifUnackTblHistory = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifUnackTblHistory.setStatus('mandatory') mitelNotifUnackTblManager = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifUnackTblManager.setStatus('mandatory') mitelNotifUnackTblRetriesLeft = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 6, 8, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifUnackTblRetriesLeft.setStatus('mandatory') mitelNotifAgentAddress = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 6, 9), TAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelNotifAgentAddress.setStatus('mandatory') mitelTrapsCommLost = NotificationType((1, 3, 6, 1, 4, 1, 1027, 4, 6, 1) + (0,1)).setObjects(("MITEL-MIB", "mitelNotifUnackTblStatus"), ("MITEL-MIB", "mitelNotifMgrTblDomain"), ("MITEL-MIB", "mitelNotifMgrTblAddress")) mitelTrapsReset = NotificationType((1, 3, 6, 1, 4, 1, 1027, 4, 6, 1) + (0,2)).setObjects(("MITEL-MIB", "mitelNotifUnackTblStatus"), ("MITEL-MIB", "mitelResetReason")) mitelGrpCmnNotifBasic = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 2)) mitelGrpCmnNotifManagers = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 3)) mitelGrpCmnNotifHistory = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 4)) mitelGrpCmnNotifAck = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 5)) mitelGrpCmnInterfaces = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 6)) mitelGrpCmnReset = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 2, 1, 7)) mitelComplMitel = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 5, 1, 1)) mibBuilder.exportSymbols("MITEL-MIB", snmpUDPDomain=snmpUDPDomain, mitelNotifMgrTblLife=mitelNotifMgrTblLife, mitelNotifMgrTblStatus=mitelNotifMgrTblStatus, mitelIdInterfaces=mitelIdInterfaces, TimeStamp=TimeStamp, mitelGrpCommon=mitelGrpCommon, mitelNotifHistoryTableEntry=mitelNotifHistoryTableEntry, mitelExtInterfaces=mitelExtInterfaces, mitelGrpCmnNotifBasic=mitelGrpCmnNotifBasic, TruthValue=TruthValue, mitelPropProtocols=mitelPropProtocols, mitelNotifUnackTableEntry=mitelNotifUnackTableEntry, mitelResetReason=mitelResetReason, mitelNotifEnableTable=mitelNotifEnableTable, mitelNotifMgrTblRetries=mitelNotifMgrTblRetries, RowStatus=RowStatus, MitelNotifyTransportType=MitelNotifyTransportType, mitelNotifHistoryMax=mitelNotifHistoryMax, mitelTrapsCommLost=mitelTrapsCommLost, mitelGrpCmnInterfaces=mitelGrpCmnInterfaces, mitelNotifMgrTblDomain=mitelNotifMgrTblDomain, mitelNotifEnblTblEnable=mitelNotifEnblTblEnable, mitelResetAgent=mitelResetAgent, mitelNotifEnblTblOid=mitelNotifEnblTblOid, snmpV2=snmpV2, mitelNotifHistoryTable=mitelNotifHistoryTable, mitelConformance=mitelConformance, mitelIdMgmtOpsMgr=mitelIdMgmtOpsMgr, mitelResetPlatform=mitelResetPlatform, mitelPropTransmission=mitelPropTransmission, snmpDomains=snmpDomains, mitelPropReset=mitelPropReset, InterfaceIndex=InterfaceIndex, mitelNotifUnackTblStatus=mitelNotifUnackTblStatus, mitelPropHardware=mitelPropHardware, MitelIfType=MitelIfType, mitelGrpCmnReset=mitelGrpCmnReset, mitelGrpOpsMgr=mitelGrpOpsMgr, mitelNotifMgrTblAddress=mitelNotifMgrTblAddress, mitelNotifHistTblConfirmed=mitelNotifHistTblConfirmed, mitelIfTable=mitelIfTable, mitelNotifUnackTblRetriesLeft=mitelNotifUnackTblRetriesLeft, mitelNotifHistTblTime=mitelNotifHistTblTime, mitelNotifHistTblIndex=mitelNotifHistTblIndex, mitelPropApplications=mitelPropApplications, mitelPropNotifications=mitelPropNotifications, mitelNotifMgrTblIndex=mitelNotifMgrTblIndex, mitelConfAgents=mitelConfAgents, mitelNotifTraps=mitelNotifTraps, mitelConfGroups=mitelConfGroups, mitelIfTableEntry=mitelIfTableEntry, mitelGrpCmnNotifHistory=mitelGrpCmnNotifHistory, mitelNotifMgrTblTimeout=mitelNotifMgrTblTimeout, mitelPropUtilities=mitelPropUtilities, mitelNotifHistTblIfIndex=mitelNotifHistTblIfIndex, mitelNotifEnblTblDescr=mitelNotifEnblTblDescr, mitelIdCsMc2=mitelIdCsMc2, mitelExtensions=mitelExtensions, mitelNotifAgentAddress=mitelNotifAgentAddress, mitelNotifMgrTblTransport=mitelNotifMgrTblTransport, mitelNotifManagerTableEntry=mitelNotifManagerTableEntry, TAddress=TAddress, mitelNotifHistorySize=mitelNotifHistorySize, mitelComplMitel=mitelComplMitel, mitelNotifCount=mitelNotifCount, TDomain=TDomain, mitelIdCtiPlatforms=mitelIdCtiPlatforms, mitelIdTerminals=mitelIdTerminals, mitelGrpCmnNotifAck=mitelGrpCmnNotifAck, mitelNotifHistTblId=mitelNotifHistTblId, mitelIdCs2000Light=mitelIdCs2000Light, mitelNotifMgrTblName=mitelNotifMgrTblName, mitelNotifMgrTblCommunity=mitelNotifMgrTblCommunity, mitelConfCompliances=mitelConfCompliances, mitelIdCallServers=mitelIdCallServers, mitelNotifEnableTableEntry=mitelNotifEnableTableEntry, mitelIfNumber=mitelIfNumber, TimeInterval=TimeInterval, mitelProprietary=mitelProprietary, mitelNotifEnblTblOccurrences=mitelNotifEnblTblOccurrences, mitelNotifUnackTblManager=mitelNotifUnackTblManager, mitelNotifUnackTable=mitelNotifUnackTable, mitelIdMgmtPlatforms=mitelIdMgmtPlatforms, mitelIfTblType=mitelIfTblType, mitelNotifUnackTblIndex=mitelNotifUnackTblIndex, mitelTrapsReset=mitelTrapsReset, mitelNotifUnackTblHistory=mitelNotifUnackTblHistory, mitelNotifEnblTblIndex=mitelNotifEnblTblIndex, mitelAppCallServer=mitelAppCallServer, mitel=mitel, mitelNotifEnblTblAck=mitelNotifEnblTblAck, mitelIdentification=mitelIdentification, mitelExperimental=mitelExperimental, mitelNotifManagerTable=mitelNotifManagerTable, mitelGrpCmnNotifManagers=mitelGrpCmnNotifManagers, mitelGrpCs2000=mitelGrpCs2000)
#!/usr/bin/python3 def print_matrix_integer(matrix=[[]]): "prints a matrix of integers" row_len = len(matrix) col_len = len(matrix[0]) for i in range(row_len): for j in range(col_len): if j != col_len - 1: print("{:d}".format(matrix[i][j]), end=' ') else: print("{:d}".format(matrix[i][j]), end='') print("")
def sum_of_squares(n): total = 0 for i in range(n): if i * i < n: total += i * i else: break return total
#!/usr/bin/python # -*- coding: utf-8 -*- __author__ = "Fireclaw the Fox" __license__ = """ Simplified BSD (BSD 2-Clause) License. See License.txt or http://opensource.org/licenses/BSD-2-Clause for more info """
_base_ = [ '../_base_/models/fcn_r50-d8.py', '../_base_/datasets/pascal_context.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' ] model = dict( decode_head=dict(num_classes=60), auxiliary_head=dict(num_classes=60), test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320))) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)
pares = 0 numeros = (int(input('Digite um número: ')), int(input('Digite outro número: ')), int(input('Digite mais um número: ')), int(input('Digite um último número: '))) print(f'Você digitou os valores {numeros}') print(f'O valor 9 apareceu {numeros.count(9)} vezes') if numeros.count(3) == 0: print('O valor 3 não foi digitado') else: # Ou "if 3 in numeros: print(f'O valor 3 apareceu em {numeros.index(3)+1}º') # for n in numeros: # if n % 2 == 0: # pares += 1 # if pares > 0: # print('O(s) valor(es) par(es): ', end='') # for n in numeros: # if n % 2 == 0: # print(n, end=' ') print('O(s) valor(es) par(es): ', end='') for n in numeros: if n % 2 == 0: print(n, end=' ') pares += 1 if pares == 0: print('Nenhum')
_base_ = [ '../_base_/models/irrpwc.py', '../_base_/datasets/flyingthings3d_subset_bi_with_occ_384x768.py', '../_base_/schedules/schedule_s_fine_half.py', '../_base_/default_runtime.py' ] custom_hooks = [dict(type='EMAHook')] data = dict( train_dataloader=dict( samples_per_gpu=1, workers_per_gpu=5, drop_last=True), val_dataloader=dict(samples_per_gpu=1, workers_per_gpu=5, shuffle=False), test_dataloader=dict(samples_per_gpu=1, workers_per_gpu=5, shuffle=False)) # Train on FlyingChairsOcc and finetune on FlyingThings3D_subset load_from = 'https://download.openmmlab.com/mmflow/irr/irrpwc_8x1_sshort_flyingchairsocc_384x448.pth' # noqa
class Solution: def isAlienSorted(self, words, order): lookup = {c: i for i, c in enumerate(order)} for i in range(len(words) - 1): word1 = words[i] word2 = words[i + 1] for j in range(min(len(word1), len(word2))): if word1[j] != word2[j]: if lookup[word1[j]] > lookup[word2[j]]: return False break else: if len(word1) > len(word2): return False return True if __name__ == '__main__': words = ["apap","app"] order = "abcdefghijklmnopqrstuvwxyz" s = Solution() print(s.isAlienSorted(words, order))
#!/usr/bin/python # sorting.py items = { "coins": 7, "pens": 3, "cups": 2, "bags": 1, "bottles": 4, "books": 5 } for key in sorted(items.keys()): print ("%s: %s" % (key, items[key])) print ("####### #######") for key in sorted(items.keys(), reverse=True): print ("%s: %s" % (key, items[key]))
# variants model_type = 'SepDisc' runner = 'SepDiscRunner01' lambda_img = 0.001 lambda_lidar = 0.001 src_acc_threshold = 0.6 tgt_acc_threshold = 0.6 img_disc = dict(type='FCDiscriminatorCE', in_dim=64) img_opt = dict(type='Adam', lr=0.0002, weight_decay=0.001) lidar_disc = dict(type='FCDiscriminatorCE', in_dim=64) lidar_opt = dict(type='Adam', lr=0.0002, weight_decay=0.001) return_fusion_feats = False point_cloud_range = [-50, 0, -5, 50, 50, 3] anchor_generator_ranges = [[-50, 0, -1.8, 50, 50, -1.8]] scatter_shape = [200, 400] voxel_size = [0.25, 0.25, 8] src_train = 'mmda_xmuda_split/train_usa.pkl' tgt_train = 'mmda_xmuda_split/train_singapore.pkl' ann_val = 'mmda_xmuda_split/test_singapore.pkl' img_feat_channels = 64 model = dict( type=model_type, img_backbone=dict( type='UNetResNet34', out_channels=img_feat_channels, pretrained=True), img_seg_head=dict( type='SepDiscHead', img_feat_dim=img_feat_channels, seg_pts_dim=4, num_classes=5, lidar_fc=[64, 64], concat_fc=[128, 64], class_weights=[2.68678412, 4.36182969, 5.47896839, 3.89026883, 1.]) ) train_cfg = None test_cfg = None class_names = [ 'vehicle', # car, truck, bus, trailer, cv 'pedestrian', # pedestrian 'bike', # motorcycle, bicycle 'traffic_boundary' # traffic_cone, barrier # background ] data_root = '/home/xyyue/xiangyu/nuscenes_unzip/' input_modality = dict( use_lidar=True, use_camera=True, use_radar=False, use_map=False, use_external=False) file_client_args = dict(backend='disk') train_pipeline = [ dict(type='LoadSegDetPointsFromFile', # 'points', 'seg_points', 'seg_label' load_dim=5, use_dim=5), dict(type='LoadFrontImage'), # filter 'seg_points', 'seg_label', 'seg_pts_indices' inside front camera; 'img' dict(type='SegDetPointsRangeFilter', point_cloud_range=point_cloud_range), # filter 'points', 'seg_points' within point_cloud_range dict(type='MergeCat'), # merge 'seg_label', 'gt_labels_3d' (from 10 classes to 4 classes, without background) dict(type='SegDetFormatBundle'), dict(type='Collect3D', keys=['img', 'seg_points', 'seg_pts_indices', 'seg_label']) ] test_pipeline = [ dict( type='LoadSegDetPointsFromFile', load_dim=5, use_dim=5), dict(type='LoadFrontImage'), # filter 'seg_points', 'seg_label', 'seg_pts_indices' inside front camera; 'img' dict(type='SegDetPointsRangeFilter', point_cloud_range=point_cloud_range), # filter 'points', 'seg_points' within point_cloud_range dict(type='MergeCat'), # merge 'seg_label', 'gt_labels_3d' (from 10 classes to 4 classes, without background) dict(type='SegDetFormatBundle'), dict(type='Collect3D', keys=['img', 'seg_points', 'seg_pts_indices', 'seg_label']) ] # dataset dataset_type = 'MMDAMergeCatDataset' data = dict( samples_per_gpu=4, workers_per_gpu=4, source_train=dict( type=dataset_type, data_root=data_root, ann_file=data_root + src_train, pipeline=train_pipeline, classes=class_names, modality=input_modality, filter_empty_gt=False, test_mode=False, box_type_3d='LiDAR'), target_train=dict( type=dataset_type, data_root=data_root, ann_file=data_root + tgt_train, pipeline=train_pipeline, classes=class_names, modality=input_modality, filter_empty_gt=False, test_mode=False, box_type_3d='LiDAR'), val=dict( type=dataset_type, data_root=data_root, ann_file=data_root + ann_val, pipeline=test_pipeline, classes=class_names, modality=input_modality, filter_empty_gt=False, test_mode=True, box_type_3d='LiDAR'), test=dict( type=dataset_type, data_root=data_root, ann_file=data_root + ann_val, pipeline=test_pipeline, classes=class_names, modality=input_modality, filter_empty_gt=False, test_mode=True, box_type_3d='LiDAR')) evaluation = dict(interval=100) # shedule_2x.py optimizer = dict(type='AdamW', lr=0.001, weight_decay=0.01) # optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) lr_config = dict( policy='step', warmup='linear', warmup_iters=1000, warmup_ratio=1.0 / 1000, step=[12, 18]) momentum_config = None total_epochs = 24 # default_runtime.py checkpoint_config = dict(interval=1) log_config = dict( interval=50, hooks=[ dict(type='TextLoggerHook'), dict(type='TensorboardLoggerHook') ]) # yapf:enable dist_params = dict(backend='nccl') log_level = 'INFO' work_dir = None load_from = None resume_from = None workflow = [('train', 1)]
def debug(x): print(x) ### Notebook Magics # %matplotlib inline def juptyerConfig(pd, max_columns=500, max_rows = 500, float_format = '{:,.6f}', max_info_rows = 1000, max_categories = 500): pd.options.display.max_columns = 500 pd.options.display.max_rows = 500 pd.options.display.float_format = float_format.format pd.options.display.max_info_rows = 1000 pd.options.display.max_categories = 500 # from IPython.core.interactiveshell import InteractiveShell # InteractiveShell.ast_node_interactivity = "all" def createDataFilePath(data_dir='', data_file_name=''): return data_dir + data_file_name
# Scores old stuff # # Helper functions # # FIXME: use ticks instead, teams are either up for the whole tick or down for the whole tick def _get_uptime_for_team(team_id, cursor): """Calculate the uptime for a team. The uptime is normalized to 0 to 100. An uptime of 100 means the team was online for the entire tick, while an uptime of 0 means it was not online at all. :param int team_id: ID of the team. :param cursor: Cursor that points to the MySQL database. :return: Uptime of the team, between [0, 100] """ # FIXME: This currently does not work for disabled and enabled services. # We should calculate the uptime per tick. # Fetch total number of total tests made cursor.execute("""SELECT COUNT(id) AS count, service_id FROM team_service_state WHERE team_id = %s GROUP BY service_id""", (team_id,)) total_counts = dict() for result in cursor.fetchall(): total_counts[result["service_id"]] = result["count"] # Fetch number of tests that were successful (up and working) cursor.execute("""SELECT COUNT(id) AS count, service_id FROM team_service_state WHERE team_id = %s AND state = 'up' GROUP BY service_id""", (team_id,)) up_counts = {} for result in cursor.fetchall(): up_counts[result["service_id"]] = result["count"] # Calculate the average uptime services = len(total_counts.keys()) avg_uptime = 0 for service_id, total in total_counts.items(): up_ = up_counts[service_id] uptime = (up_ * 1.) / (total * 1.) avg_uptime += uptime / services return avg_uptime * 100 @app.route("/scores_deprecated") @requires_auth def scores_deprecated(): """The ``/scores`` endpoint requires authentication and expects no additional argument. It is used to retrieve the current scores for each team. It can be reached at ``/scores?secret=<API_SECRET>``. The JSON response is:: { "scores": {team_id: {score: int, sla: int (0-100, percentage), raw_score: int }} } :return: a JSON dictionary containing status information on the flag. """ cursor = mysql.cursor() cursor.execute("""SELECT team_id, name as team_name, SUM(score) AS score FROM team_score JOIN teams ON teams.id = team_score.team_id GROUP BY team_id""") scores_ = {} # Currently, we are multiplying overall score with overall SLA. Do we # actually want to do this, or do we want do calculate this per tick? for result in cursor.fetchall(): team_id = result["team_id"] team_name = result["team_name"] raw_score = int(result["score"]) sla_percentage = _get_uptime_for_team(team_id, cursor) scores_[team_id] = {"team_name": team_name, "raw_score": raw_score, "sla": int(sla_percentage), "score": raw_score * (sla_percentage / 100.)} return json.dumps({"scores": scores_})
# Copyright 2008-2012 Nokia Siemens Networks Oyj # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """A module to handle different character widths on the console. Some East Asian characters have width of two on console, and combining characters themselves take no extra space. See issue 604 [1] for more details about East Asian characters. The issue also contains `generate_wild_chars.py` script that was originally used to create `_EAST_ASIAN_WILD_CHARS` mapping. An updated version of the script is attached to issue 1096. Big thanks for xieyanbo for the script and the original patch. Note that Python's `unicodedata` module is not used here because importing it takes several seconds on Jython. [1] http://code.google.com/p/robotframework/issues/detail?id=604 [2] http://code.google.com/p/robotframework/issues/detail?id=1096 """ def get_char_width(char): char = ord(char) if _char_in_map(char, _COMBINING_CHARS): return 0 if _char_in_map(char, _EAST_ASIAN_WILD_CHARS): return 2 return 1 def _char_in_map(char, map): for begin, end in map: if char < begin: break if begin <= char <= end: return True return False _COMBINING_CHARS = [(768, 879)] _EAST_ASIAN_WILD_CHARS = [ (888, 889), (895, 899), (907, 907), (909, 909), (930, 930), (1316, 1328), (1367, 1368), (1376, 1376), (1416, 1416), (1419, 1424), (1480, 1487), (1515, 1519), (1525, 1535), (1540, 1541), (1564, 1565), (1568, 1568), (1631, 1631), (1806, 1806), (1867, 1868), (1970, 1983), (2043, 2304), (2362, 2363), (2382, 2383), (2389, 2391), (2419, 2426), (2432, 2432), (2436, 2436), (2445, 2446), (2449, 2450), (2473, 2473), (2481, 2481), (2483, 2485), (2490, 2491), (2501, 2502), (2505, 2506), (2511, 2518), (2520, 2523), (2526, 2526), (2532, 2533), (2555, 2560), (2564, 2564), (2571, 2574), (2577, 2578), (2601, 2601), (2609, 2609), (2612, 2612), (2615, 2615), (2618, 2619), (2621, 2621), (2627, 2630), (2633, 2634), (2638, 2640), (2642, 2648), (2653, 2653), (2655, 2661), (2678, 2688), (2692, 2692), (2702, 2702), (2706, 2706), (2729, 2729), (2737, 2737), (2740, 2740), (2746, 2747), (2758, 2758), (2762, 2762), (2766, 2767), (2769, 2783), (2788, 2789), (2800, 2800), (2802, 2816), (2820, 2820), (2829, 2830), (2833, 2834), (2857, 2857), (2865, 2865), (2868, 2868), (2874, 2875), (2885, 2886), (2889, 2890), (2894, 2901), (2904, 2907), (2910, 2910), (2916, 2917), (2930, 2945), (2948, 2948), (2955, 2957), (2961, 2961), (2966, 2968), (2971, 2971), (2973, 2973), (2976, 2978), (2981, 2983), (2987, 2989), (3002, 3005), (3011, 3013), (3017, 3017), (3022, 3023), (3025, 3030), (3032, 3045), (3067, 3072), (3076, 3076), (3085, 3085), (3089, 3089), (3113, 3113), (3124, 3124), (3130, 3132), (3141, 3141), (3145, 3145), (3150, 3156), (3159, 3159), (3162, 3167), (3172, 3173), (3184, 3191), (3200, 3201), (3204, 3204), (3213, 3213), (3217, 3217), (3241, 3241), (3252, 3252), (3258, 3259), (3269, 3269), (3273, 3273), (3278, 3284), (3287, 3293), (3295, 3295), (3300, 3301), (3312, 3312), (3315, 3329), (3332, 3332), (3341, 3341), (3345, 3345), (3369, 3369), (3386, 3388), (3397, 3397), (3401, 3401), (3406, 3414), (3416, 3423), (3428, 3429), (3446, 3448), (3456, 3457), (3460, 3460), (3479, 3481), (3506, 3506), (3516, 3516), (3518, 3519), (3527, 3529), (3531, 3534), (3541, 3541), (3543, 3543), (3552, 3569), (3573, 3584), (3643, 3646), (3676, 3712), (3715, 3715), (3717, 3718), (3721, 3721), (3723, 3724), (3726, 3731), (3736, 3736), (3744, 3744), (3748, 3748), (3750, 3750), (3752, 3753), (3756, 3756), (3770, 3770), (3774, 3775), (3781, 3781), (3783, 3783), (3790, 3791), (3802, 3803), (3806, 3839), (3912, 3912), (3949, 3952), (3980, 3983), (3992, 3992), (4029, 4029), (4045, 4045), (4053, 4095), (4250, 4253), (4294, 4303), (4349, 4447), (4515, 4519), (4602, 4607), (4681, 4681), (4686, 4687), (4695, 4695), (4697, 4697), (4702, 4703), (4745, 4745), (4750, 4751), (4785, 4785), (4790, 4791), (4799, 4799), (4801, 4801), (4806, 4807), (4823, 4823), (4881, 4881), (4886, 4887), (4955, 4958), (4989, 4991), (5018, 5023), (5109, 5120), (5751, 5759), (5789, 5791), (5873, 5887), (5901, 5901), (5909, 5919), (5943, 5951), (5972, 5983), (5997, 5997), (6001, 6001), (6004, 6015), (6110, 6111), (6122, 6127), (6138, 6143), (6159, 6159), (6170, 6175), (6264, 6271), (6315, 6399), (6429, 6431), (6444, 6447), (6460, 6463), (6465, 6467), (6510, 6511), (6517, 6527), (6570, 6575), (6602, 6607), (6618, 6621), (6684, 6685), (6688, 6911), (6988, 6991), (7037, 7039), (7083, 7085), (7098, 7167), (7224, 7226), (7242, 7244), (7296, 7423), (7655, 7677), (7958, 7959), (7966, 7967), (8006, 8007), (8014, 8015), (8024, 8024), (8026, 8026), (8028, 8028), (8030, 8030), (8062, 8063), (8117, 8117), (8133, 8133), (8148, 8149), (8156, 8156), (8176, 8177), (8181, 8181), (8191, 8191), (8293, 8297), (8306, 8307), (8335, 8335), (8341, 8351), (8374, 8399), (8433, 8447), (8528, 8530), (8585, 8591), (9001, 9002), (9192, 9215), (9255, 9279), (9291, 9311), (9886, 9887), (9917, 9919), (9924, 9984), (9989, 9989), (9994, 9995), (10024, 10024), (10060, 10060), (10062, 10062), (10067, 10069), (10071, 10071), (10079, 10080), (10133, 10135), (10160, 10160), (10175, 10175), (10187, 10187), (10189, 10191), (11085, 11087), (11093, 11263), (11311, 11311), (11359, 11359), (11376, 11376), (11390, 11391), (11499, 11512), (11558, 11567), (11622, 11630), (11632, 11647), (11671, 11679), (11687, 11687), (11695, 11695), (11703, 11703), (11711, 11711), (11719, 11719), (11727, 11727), (11735, 11735), (11743, 11743), (11825, 12350), (12352, 19903), (19968, 42239), (42540, 42559), (42592, 42593), (42612, 42619), (42648, 42751), (42893, 43002), (43052, 43071), (43128, 43135), (43205, 43213), (43226, 43263), (43348, 43358), (43360, 43519), (43575, 43583), (43598, 43599), (43610, 43611), (43616, 55295), (63744, 64255), (64263, 64274), (64280, 64284), (64311, 64311), (64317, 64317), (64319, 64319), (64322, 64322), (64325, 64325), (64434, 64466), (64832, 64847), (64912, 64913), (64968, 65007), (65022, 65023), (65040, 65055), (65063, 65135), (65141, 65141), (65277, 65278), (65280, 65376), (65471, 65473), (65480, 65481), (65488, 65489), (65496, 65497), (65501, 65511), (65519, 65528), (65534, 65535), ]
""" PASSENGERS """ numPassengers = 435 passenger_arriving = ( (2, 1, 1, 0, 1, 0, 0, 1, 2, 1, 1, 0), # 0 (1, 5, 1, 0, 0, 0, 2, 2, 0, 1, 0, 0), # 1 (1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0), # 2 (0, 2, 1, 1, 1, 0, 3, 2, 1, 0, 0, 0), # 3 (0, 1, 1, 1, 0, 0, 4, 1, 0, 0, 0, 0), # 4 (1, 0, 0, 1, 0, 0, 1, 3, 0, 1, 0, 0), # 5 (2, 2, 1, 0, 0, 0, 2, 1, 1, 0, 0, 0), # 6 (1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 1, 0), # 7 (1, 1, 0, 2, 0, 0, 1, 0, 1, 0, 1, 0), # 8 (0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0), # 9 (1, 1, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0), # 10 (2, 2, 3, 2, 0, 0, 0, 1, 0, 1, 0, 0), # 11 (2, 1, 0, 0, 1, 0, 0, 4, 1, 0, 0, 0), # 12 (0, 0, 0, 0, 1, 0, 1, 2, 3, 0, 0, 0), # 13 (0, 1, 1, 1, 0, 0, 1, 1, 3, 0, 0, 0), # 14 (0, 2, 2, 1, 1, 0, 1, 1, 1, 0, 0, 0), # 15 (0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0), # 16 (1, 1, 4, 0, 0, 0, 1, 2, 3, 1, 0, 0), # 17 (0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 0, 0), # 18 (0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0), # 19 (0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0), # 20 (0, 0, 0, 1, 0, 0, 1, 2, 0, 1, 0, 0), # 21 (0, 0, 0, 0, 0, 0, 1, 1, 3, 2, 1, 0), # 22 (1, 1, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0), # 23 (0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0), # 24 (0, 2, 3, 1, 0, 0, 0, 2, 2, 1, 0, 0), # 25 (0, 1, 0, 0, 0, 0, 0, 0, 2, 1, 1, 0), # 26 (0, 2, 2, 0, 1, 0, 0, 5, 0, 1, 1, 0), # 27 (1, 4, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0), # 28 (1, 1, 1, 1, 0, 0, 3, 1, 0, 1, 0, 0), # 29 (0, 1, 0, 1, 0, 0, 0, 3, 1, 0, 0, 0), # 30 (0, 0, 2, 1, 0, 0, 1, 0, 2, 1, 0, 0), # 31 (0, 3, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0), # 32 (1, 2, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), # 33 (0, 1, 1, 0, 0, 0, 0, 2, 0, 1, 1, 0), # 34 (1, 1, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0), # 35 (1, 2, 0, 1, 0, 0, 1, 0, 2, 2, 0, 0), # 36 (1, 2, 0, 0, 0, 0, 0, 3, 1, 2, 1, 0), # 37 (2, 0, 1, 1, 0, 0, 2, 1, 2, 1, 0, 0), # 38 (0, 1, 1, 0, 0, 0, 0, 2, 2, 1, 0, 0), # 39 (0, 0, 0, 2, 0, 0, 5, 2, 2, 1, 0, 0), # 40 (0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0), # 41 (1, 1, 0, 2, 0, 0, 0, 1, 1, 1, 1, 0), # 42 (0, 2, 3, 1, 1, 0, 0, 1, 0, 0, 0, 0), # 43 (1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0), # 44 (0, 1, 1, 1, 0, 0, 0, 2, 1, 0, 1, 0), # 45 (0, 2, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0), # 46 (1, 3, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0), # 47 (0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 0, 0), # 48 (0, 0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0), # 49 (0, 0, 2, 1, 0, 0, 0, 0, 0, 2, 0, 0), # 50 (1, 1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0), # 51 (0, 0, 2, 0, 0, 0, 0, 1, 0, 1, 2, 0), # 52 (1, 2, 0, 1, 0, 0, 3, 1, 1, 0, 0, 0), # 53 (1, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0), # 54 (1, 3, 3, 0, 0, 0, 0, 0, 2, 1, 0, 0), # 55 (1, 3, 1, 0, 1, 0, 2, 1, 1, 1, 0, 0), # 56 (1, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0), # 57 (0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 58 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 59 ) station_arriving_intensity = ( (0.5299303116769096, 1.3592921401515152, 1.59884720437018, 1.2672554347826086, 1.4286057692307692, 0.951358695652174), # 0 (0.53490440200956, 1.3744083197425647, 1.607483107504999, 1.274312877415459, 1.4393133012820511, 0.9510344278381644), # 1 (0.5398216954443468, 1.3893002805836139, 1.6159140245644101, 1.2812149758454108, 1.4497948717948719, 0.9507002415458937), # 2 (0.544678017998244, 1.4039519531250002, 1.6241337965938305, 1.2879558423913042, 1.4600408653846157, 0.9503561820652175), # 3 (0.5494691956882256, 1.4183472678170597, 1.6321362646386746, 1.2945295893719808, 1.470041666666667, 0.9500022946859903), # 4 (0.5541910545312653, 1.4324701551101293, 1.6399152697443586, 1.3009303291062801, 1.4797876602564102, 0.9496386246980676), # 5 (0.5588394205443372, 1.4463045454545456, 1.6474646529562986, 1.3071521739130436, 1.4892692307692308, 0.9492652173913044), # 6 (0.5634101197444152, 1.4598343693006453, 1.6547782553199086, 1.3131892361111113, 1.4984767628205131, 0.9488821180555557), # 7 (0.5678989781484733, 1.4730435570987652, 1.6618499178806059, 1.3190356280193236, 1.507400641025641, 0.9484893719806764), # 8 (0.5723018217734855, 1.4859160392992425, 1.668673481683805, 1.3246854619565218, 1.51603125, 0.9480870244565218), # 9 (0.5766144766364257, 1.4984357463524132, 1.6752427877749214, 1.3301328502415461, 1.5243589743589745, 0.9476751207729468), # 10 (0.5808327687542679, 1.5105866087086142, 1.6815516771993715, 1.335371905193237, 1.5323741987179487, 0.9472537062198069), # 11 (0.584952524143986, 1.5223525568181817, 1.6875939910025708, 1.3403967391304348, 1.5400673076923077, 0.9468228260869564), # 12 (0.5889695688225538, 1.5337175211314538, 1.6933635702299341, 1.3452014643719807, 1.5474286858974362, 0.9463825256642512), # 13 (0.5928797288069457, 1.5446654320987658, 1.6988542559268778, 1.3497801932367148, 1.5544487179487179, 0.9459328502415458), # 14 (0.5966788301141351, 1.5551802201704543, 1.7040598891388172, 1.3541270380434782, 1.5611177884615386, 0.9454738451086957), # 15 (0.6003626987610965, 1.5652458157968576, 1.7089743109111684, 1.3582361111111112, 1.567426282051282, 0.9450055555555557), # 16 (0.6039271607648035, 1.5748461494283108, 1.713591362289346, 1.3621015247584543, 1.5733645833333334, 0.9445280268719808), # 17 (0.6073680421422301, 1.5839651515151516, 1.7179048843187663, 1.365717391304348, 1.5789230769230773, 0.9440413043478261), # 18 (0.6106811689103502, 1.592586752507716, 1.7219087180448445, 1.3690778230676328, 1.5840921474358975, 0.9435454332729469), # 19 (0.613862367086138, 1.600694882856341, 1.725596704512996, 1.37217693236715, 1.5888621794871796, 0.943040458937198), # 20 (0.6169074626865673, 1.6082734730113633, 1.728962684768638, 1.3750088315217392, 1.5932235576923075, 0.9425264266304348), # 21 (0.6198122817286118, 1.6153064534231203, 1.7320004998571836, 1.3775676328502415, 1.5971666666666664, 0.9420033816425122), # 22 (0.6225726502292459, 1.6217777545419474, 1.7347039908240505, 1.3798474486714978, 1.600681891025641, 0.9414713692632852), # 23 (0.6251843942054434, 1.6276713068181818, 1.7370669987146528, 1.3818423913043478, 1.6037596153846154, 0.9409304347826087), # 24 (0.6276433396741781, 1.6329710407021605, 1.7390833645744075, 1.383546573067633, 1.6063902243589743, 0.9403806234903382), # 25 (0.6299453126524241, 1.6376608866442197, 1.740746929448729, 1.384954106280193, 1.6085641025641024, 0.9398219806763285), # 26 (0.6320861391571554, 1.6417247750946968, 1.7420515343830332, 1.3860591032608698, 1.610271634615385, 0.9392545516304349), # 27 (0.6340616452053459, 1.6451466365039282, 1.7429910204227366, 1.3868556763285025, 1.611503205128205, 0.9386783816425122), # 28 (0.6358676568139694, 1.6479104013222505, 1.7435592286132533, 1.3873379378019326, 1.6122491987179488, 0.9380935160024155), # 29 (0.6375000000000001, 1.6500000000000001, 1.7437500000000001, 1.3875000000000002, 1.6125, 0.9375), # 30 (0.6390274056905372, 1.6517357599431817, 1.7436069897342994, 1.3874707312091505, 1.6124087322695038, 0.9366752519573547), # 31 (0.6405218350383632, 1.6534485795454548, 1.743182004830918, 1.387383496732026, 1.612136879432624, 0.9354049516908214), # 32 (0.6419839593989769, 1.6551382457386365, 1.742481114130435, 1.3872391544117648, 1.6116873670212766, 0.933701536731634), # 33 (0.6434144501278772, 1.6568045454545457, 1.74151038647343, 1.3870385620915036, 1.611063120567376, 0.9315774446110279), # 34 (0.6448139785805627, 1.6584472656249998, 1.7402758907004832, 1.3867825776143792, 1.610267065602837, 0.9290451128602366), # 35 (0.646183216112532, 1.6600661931818186, 1.7387836956521738, 1.3864720588235295, 1.6093021276595747, 0.9261169790104948), # 36 (0.6475228340792839, 1.6616611150568183, 1.7370398701690821, 1.3861078635620916, 1.6081712322695034, 0.9228054805930368), # 37 (0.6488335038363171, 1.6632318181818182, 1.7350504830917874, 1.3856908496732026, 1.606877304964539, 0.919123055139097), # 38 (0.6501158967391305, 1.6647780894886364, 1.7328216032608694, 1.385221875, 1.6054232712765957, 0.91508214017991), # 39 (0.6513706841432225, 1.666299715909091, 1.7303592995169084, 1.384701797385621, 1.6038120567375884, 0.9106951732467099), # 40 (0.6525985374040921, 1.6677964843749997, 1.7276696407004832, 1.3841314746732027, 1.6020465868794327, 0.9059745918707315), # 41 (0.6538001278772378, 1.6692681818181823, 1.724758695652174, 1.3835117647058823, 1.6001297872340428, 0.9009328335832084), # 42 (0.6549761269181587, 1.6707145951704545, 1.7216325332125604, 1.3828435253267974, 1.5980645833333333, 0.8955823359153756), # 43 (0.656127205882353, 1.6721355113636365, 1.7182972222222224, 1.382127614379085, 1.59585390070922, 0.8899355363984673), # 44 (0.6572540361253196, 1.6735307173295455, 1.7147588315217395, 1.3813648897058823, 1.5935006648936172, 0.8840048725637182), # 45 (0.6583572890025576, 1.6749000000000003, 1.711023429951691, 1.3805562091503267, 1.59100780141844, 0.8778027819423623), # 46 (0.6594376358695653, 1.6762431463068184, 1.707097086352657, 1.3797024305555556, 1.5883782358156031, 0.8713417020656339), # 47 (0.6604957480818415, 1.6775599431818184, 1.7029858695652174, 1.3788044117647058, 1.5856148936170213, 0.8646340704647678), # 48 (0.6615322969948849, 1.6788501775568179, 1.698695848429952, 1.3778630106209153, 1.58272070035461, 0.8576923246709978), # 49 (0.6625479539641944, 1.680113636363636, 1.6942330917874397, 1.3768790849673205, 1.5796985815602838, 0.8505289022155589), # 50 (0.6635433903452687, 1.681350106534091, 1.689603668478261, 1.375853492647059, 1.5765514627659574, 0.8431562406296852), # 51 (0.6645192774936062, 1.682559375, 1.684813647342995, 1.374787091503268, 1.5732822695035462, 0.8355867774446111), # 52 (0.6654762867647059, 1.683741228693182, 1.6798690972222223, 1.373680739379085, 1.5698939273049648, 0.8278329501915709), # 53 (0.6664150895140666, 1.6848954545454544, 1.6747760869565216, 1.3725352941176472, 1.5663893617021278, 0.8199071964017991), # 54 (0.6673363570971866, 1.6860218394886364, 1.6695406853864734, 1.3713516135620916, 1.5627714982269505, 0.8118219536065301), # 55 (0.6682407608695652, 1.6871201704545453, 1.6641689613526571, 1.3701305555555556, 1.5590432624113477, 0.8035896593369982), # 56 (0.6691289721867009, 1.6881902343750004, 1.6586669836956522, 1.3688729779411766, 1.555207579787234, 0.7952227511244377), # 57 (0.6700016624040921, 1.689231818181818, 1.6530408212560386, 1.3675797385620916, 1.5512673758865247, 0.7867336665000834), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_arriving_acc = ( (2, 1, 1, 0, 1, 0, 0, 1, 2, 1, 1, 0), # 0 (3, 6, 2, 0, 1, 0, 2, 3, 2, 2, 1, 0), # 1 (4, 7, 3, 1, 2, 0, 2, 4, 2, 2, 1, 0), # 2 (4, 9, 4, 2, 3, 0, 5, 6, 3, 2, 1, 0), # 3 (4, 10, 5, 3, 3, 0, 9, 7, 3, 2, 1, 0), # 4 (5, 10, 5, 4, 3, 0, 10, 10, 3, 3, 1, 0), # 5 (7, 12, 6, 4, 3, 0, 12, 11, 4, 3, 1, 0), # 6 (8, 14, 7, 5, 3, 0, 13, 12, 6, 4, 2, 0), # 7 (9, 15, 7, 7, 3, 0, 14, 12, 7, 4, 3, 0), # 8 (9, 18, 7, 7, 3, 0, 14, 16, 7, 4, 3, 0), # 9 (10, 19, 7, 7, 4, 0, 19, 16, 7, 4, 3, 0), # 10 (12, 21, 10, 9, 4, 0, 19, 17, 7, 5, 3, 0), # 11 (14, 22, 10, 9, 5, 0, 19, 21, 8, 5, 3, 0), # 12 (14, 22, 10, 9, 6, 0, 20, 23, 11, 5, 3, 0), # 13 (14, 23, 11, 10, 6, 0, 21, 24, 14, 5, 3, 0), # 14 (14, 25, 13, 11, 7, 0, 22, 25, 15, 5, 3, 0), # 15 (14, 26, 13, 11, 7, 0, 22, 25, 16, 6, 3, 0), # 16 (15, 27, 17, 11, 7, 0, 23, 27, 19, 7, 3, 0), # 17 (15, 27, 17, 11, 7, 0, 24, 29, 21, 7, 3, 0), # 18 (15, 27, 17, 11, 7, 0, 25, 30, 21, 8, 3, 0), # 19 (15, 28, 19, 11, 7, 0, 26, 30, 21, 8, 3, 0), # 20 (15, 28, 19, 12, 7, 0, 27, 32, 21, 9, 3, 0), # 21 (15, 28, 19, 12, 7, 0, 28, 33, 24, 11, 4, 0), # 22 (16, 29, 21, 12, 7, 0, 29, 34, 25, 12, 4, 0), # 23 (16, 30, 22, 12, 7, 0, 30, 34, 25, 12, 4, 0), # 24 (16, 32, 25, 13, 7, 0, 30, 36, 27, 13, 4, 0), # 25 (16, 33, 25, 13, 7, 0, 30, 36, 29, 14, 5, 0), # 26 (16, 35, 27, 13, 8, 0, 30, 41, 29, 15, 6, 0), # 27 (17, 39, 27, 13, 8, 0, 30, 43, 29, 15, 6, 0), # 28 (18, 40, 28, 14, 8, 0, 33, 44, 29, 16, 6, 0), # 29 (18, 41, 28, 15, 8, 0, 33, 47, 30, 16, 6, 0), # 30 (18, 41, 30, 16, 8, 0, 34, 47, 32, 17, 6, 0), # 31 (18, 44, 31, 17, 8, 0, 34, 48, 33, 17, 6, 0), # 32 (19, 46, 31, 17, 8, 0, 35, 49, 34, 17, 6, 0), # 33 (19, 47, 32, 17, 8, 0, 35, 51, 34, 18, 7, 0), # 34 (20, 48, 32, 17, 8, 0, 36, 54, 34, 18, 7, 0), # 35 (21, 50, 32, 18, 8, 0, 37, 54, 36, 20, 7, 0), # 36 (22, 52, 32, 18, 8, 0, 37, 57, 37, 22, 8, 0), # 37 (24, 52, 33, 19, 8, 0, 39, 58, 39, 23, 8, 0), # 38 (24, 53, 34, 19, 8, 0, 39, 60, 41, 24, 8, 0), # 39 (24, 53, 34, 21, 8, 0, 44, 62, 43, 25, 8, 0), # 40 (24, 53, 36, 21, 8, 0, 44, 62, 43, 25, 9, 0), # 41 (25, 54, 36, 23, 8, 0, 44, 63, 44, 26, 10, 0), # 42 (25, 56, 39, 24, 9, 0, 44, 64, 44, 26, 10, 0), # 43 (26, 56, 39, 24, 9, 0, 44, 64, 46, 26, 10, 0), # 44 (26, 57, 40, 25, 9, 0, 44, 66, 47, 26, 11, 0), # 45 (26, 59, 41, 25, 9, 0, 44, 67, 47, 26, 12, 0), # 46 (27, 62, 42, 25, 9, 0, 44, 68, 48, 28, 12, 0), # 47 (27, 62, 43, 25, 9, 0, 46, 69, 49, 29, 12, 0), # 48 (27, 62, 44, 25, 9, 0, 47, 71, 49, 29, 12, 0), # 49 (27, 62, 46, 26, 9, 0, 47, 71, 49, 31, 12, 0), # 50 (28, 63, 47, 26, 10, 0, 47, 73, 49, 31, 12, 0), # 51 (28, 63, 49, 26, 10, 0, 47, 74, 49, 32, 14, 0), # 52 (29, 65, 49, 27, 10, 0, 50, 75, 50, 32, 14, 0), # 53 (30, 66, 49, 27, 10, 0, 51, 77, 50, 32, 14, 0), # 54 (31, 69, 52, 27, 10, 0, 51, 77, 52, 33, 14, 0), # 55 (32, 72, 53, 27, 11, 0, 53, 78, 53, 34, 14, 0), # 56 (33, 72, 55, 29, 11, 0, 53, 78, 54, 34, 14, 0), # 57 (33, 72, 57, 29, 11, 0, 53, 78, 54, 34, 14, 0), # 58 (33, 72, 57, 29, 11, 0, 53, 78, 54, 34, 14, 0), # 59 ) passenger_arriving_rate = ( (0.5299303116769096, 1.087433712121212, 0.959308322622108, 0.5069021739130434, 0.2857211538461538, 0.0, 0.951358695652174, 1.1428846153846153, 0.7603532608695651, 0.6395388817480719, 0.271858428030303, 0.0), # 0 (0.53490440200956, 1.0995266557940517, 0.9644898645029993, 0.5097251509661835, 0.2878626602564102, 0.0, 0.9510344278381644, 1.1514506410256409, 0.7645877264492754, 0.6429932430019996, 0.27488166394851293, 0.0), # 1 (0.5398216954443468, 1.111440224466891, 0.9695484147386461, 0.5124859903381642, 0.28995897435897433, 0.0, 0.9507002415458937, 1.1598358974358973, 0.7687289855072464, 0.646365609825764, 0.27786005611672276, 0.0), # 2 (0.544678017998244, 1.1231615625, 0.9744802779562982, 0.5151823369565216, 0.2920081730769231, 0.0, 0.9503561820652175, 1.1680326923076925, 0.7727735054347825, 0.6496535186375322, 0.280790390625, 0.0), # 3 (0.5494691956882256, 1.1346778142536476, 0.9792817587832047, 0.5178118357487923, 0.29400833333333337, 0.0, 0.9500022946859903, 1.1760333333333335, 0.7767177536231885, 0.6528545058554698, 0.2836694535634119, 0.0), # 4 (0.5541910545312653, 1.1459761240881035, 0.9839491618466152, 0.5203721316425121, 0.295957532051282, 0.0, 0.9496386246980676, 1.183830128205128, 0.7805581974637681, 0.6559661078977435, 0.28649403102202586, 0.0), # 5 (0.5588394205443372, 1.1570436363636363, 0.9884787917737792, 0.5228608695652174, 0.29785384615384614, 0.0, 0.9492652173913044, 1.1914153846153845, 0.7842913043478261, 0.6589858611825195, 0.28926090909090907, 0.0), # 6 (0.5634101197444152, 1.1678674954405162, 0.9928669531919452, 0.5252756944444444, 0.2996953525641026, 0.0, 0.9488821180555557, 1.1987814102564105, 0.7879135416666667, 0.6619113021279635, 0.29196687386012904, 0.0), # 7 (0.5678989781484733, 1.1784348456790121, 0.9971099507283635, 0.5276142512077294, 0.3014801282051282, 0.0, 0.9484893719806764, 1.2059205128205128, 0.7914213768115942, 0.6647399671522423, 0.29460871141975303, 0.0), # 8 (0.5723018217734855, 1.188732831439394, 1.001204089010283, 0.5298741847826087, 0.30320624999999995, 0.0, 0.9480870244565218, 1.2128249999999998, 0.7948112771739131, 0.6674693926735219, 0.2971832078598485, 0.0), # 9 (0.5766144766364257, 1.1987485970819305, 1.0051456726649528, 0.5320531400966184, 0.3048717948717949, 0.0, 0.9476751207729468, 1.2194871794871796, 0.7980797101449276, 0.6700971151099685, 0.2996871492704826, 0.0), # 10 (0.5808327687542679, 1.2084692869668912, 1.0089310063196228, 0.5341487620772947, 0.3064748397435897, 0.0, 0.9472537062198069, 1.2258993589743588, 0.8012231431159421, 0.6726206708797485, 0.3021173217417228, 0.0), # 11 (0.584952524143986, 1.2178820454545454, 1.0125563946015423, 0.5361586956521739, 0.30801346153846154, 0.0, 0.9468228260869564, 1.2320538461538462, 0.8042380434782609, 0.6750375964010282, 0.30447051136363634, 0.0), # 12 (0.5889695688225538, 1.2269740169051628, 1.0160181421379604, 0.5380805857487923, 0.30948573717948724, 0.0, 0.9463825256642512, 1.237942948717949, 0.8071208786231884, 0.6773454280919736, 0.3067435042262907, 0.0), # 13 (0.5928797288069457, 1.2357323456790126, 1.0193125535561267, 0.5399120772946859, 0.31088974358974353, 0.0, 0.9459328502415458, 1.2435589743589741, 0.8098681159420289, 0.6795417023707511, 0.30893308641975314, 0.0), # 14 (0.5966788301141351, 1.2441441761363634, 1.0224359334832902, 0.5416508152173912, 0.3122235576923077, 0.0, 0.9454738451086957, 1.2488942307692308, 0.8124762228260869, 0.6816239556555268, 0.31103604403409085, 0.0), # 15 (0.6003626987610965, 1.252196652637486, 1.025384586546701, 0.5432944444444444, 0.3134852564102564, 0.0, 0.9450055555555557, 1.2539410256410255, 0.8149416666666667, 0.6835897243644673, 0.3130491631593715, 0.0), # 16 (0.6039271607648035, 1.2598769195426485, 1.0281548173736075, 0.5448406099033817, 0.31467291666666664, 0.0, 0.9445280268719808, 1.2586916666666665, 0.8172609148550726, 0.6854365449157384, 0.3149692298856621, 0.0), # 17 (0.6073680421422301, 1.2671721212121212, 1.0307429305912597, 0.5462869565217392, 0.31578461538461544, 0.0, 0.9440413043478261, 1.2631384615384618, 0.8194304347826088, 0.6871619537275064, 0.3167930303030303, 0.0), # 18 (0.6106811689103502, 1.2740694020061727, 1.0331452308269067, 0.547631129227053, 0.3168184294871795, 0.0, 0.9435454332729469, 1.267273717948718, 0.8214466938405797, 0.6887634872179377, 0.3185173505015432, 0.0), # 19 (0.613862367086138, 1.2805559062850727, 1.0353580227077976, 0.5488707729468599, 0.31777243589743587, 0.0, 0.943040458937198, 1.2710897435897435, 0.82330615942029, 0.6902386818051983, 0.32013897657126816, 0.0), # 20 (0.6169074626865673, 1.2866187784090906, 1.0373776108611827, 0.5500035326086956, 0.31864471153846147, 0.0, 0.9425264266304348, 1.2745788461538459, 0.8250052989130435, 0.691585073907455, 0.32165469460227264, 0.0), # 21 (0.6198122817286118, 1.292245162738496, 1.0392002999143102, 0.5510270531400966, 0.31943333333333324, 0.0, 0.9420033816425122, 1.277733333333333, 0.8265405797101449, 0.6928001999428733, 0.323061290684624, 0.0), # 22 (0.6225726502292459, 1.2974222036335579, 1.0408223944944301, 0.551938979468599, 0.3201363782051282, 0.0, 0.9414713692632852, 1.2805455128205128, 0.8279084692028986, 0.6938815963296201, 0.32435555090838947, 0.0), # 23 (0.6251843942054434, 1.3021370454545453, 1.0422401992287915, 0.552736956521739, 0.3207519230769231, 0.0, 0.9409304347826087, 1.2830076923076923, 0.8291054347826087, 0.694826799485861, 0.32553426136363633, 0.0), # 24 (0.6276433396741781, 1.3063768325617282, 1.0434500187446445, 0.5534186292270532, 0.32127804487179484, 0.0, 0.9403806234903382, 1.2851121794871794, 0.8301279438405799, 0.6956333458297629, 0.32659420814043205, 0.0), # 25 (0.6299453126524241, 1.3101287093153757, 1.0444481576692373, 0.5539816425120772, 0.32171282051282046, 0.0, 0.9398219806763285, 1.2868512820512819, 0.8309724637681158, 0.6962987717794915, 0.32753217732884393, 0.0), # 26 (0.6320861391571554, 1.3133798200757574, 1.0452309206298198, 0.5544236413043478, 0.32205432692307695, 0.0, 0.9392545516304349, 1.2882173076923078, 0.8316354619565218, 0.6968206137532132, 0.32834495501893934, 0.0), # 27 (0.6340616452053459, 1.3161173092031424, 1.045794612253642, 0.5547422705314009, 0.322300641025641, 0.0, 0.9386783816425122, 1.289202564102564, 0.8321134057971015, 0.6971964081690946, 0.3290293273007856, 0.0), # 28 (0.6358676568139694, 1.3183283210578003, 1.046135537167952, 0.554935175120773, 0.32244983974358976, 0.0, 0.9380935160024155, 1.289799358974359, 0.8324027626811595, 0.6974236914453013, 0.3295820802644501, 0.0), # 29 (0.6375000000000001, 1.32, 1.0462500000000001, 0.555, 0.3225, 0.0, 0.9375, 1.29, 0.8325000000000001, 0.6975, 0.33, 0.0), # 30 (0.6390274056905372, 1.3213886079545452, 1.0461641938405797, 0.5549882924836602, 0.3224817464539007, 0.0, 0.9366752519573547, 1.2899269858156028, 0.8324824387254903, 0.6974427958937197, 0.3303471519886363, 0.0), # 31 (0.6405218350383632, 1.3227588636363636, 1.0459092028985506, 0.5549533986928104, 0.3224273758865248, 0.0, 0.9354049516908214, 1.2897095035460993, 0.8324300980392155, 0.6972728019323671, 0.3306897159090909, 0.0), # 32 (0.6419839593989769, 1.3241105965909092, 1.045488668478261, 0.5548956617647058, 0.3223374734042553, 0.0, 0.933701536731634, 1.2893498936170211, 0.8323434926470589, 0.696992445652174, 0.3310276491477273, 0.0), # 33 (0.6434144501278772, 1.3254436363636364, 1.044906231884058, 0.5548154248366014, 0.3222126241134752, 0.0, 0.9315774446110279, 1.2888504964539007, 0.8322231372549022, 0.696604154589372, 0.3313609090909091, 0.0), # 34 (0.6448139785805627, 1.3267578124999997, 1.0441655344202898, 0.5547130310457516, 0.3220534131205674, 0.0, 0.9290451128602366, 1.2882136524822696, 0.8320695465686275, 0.6961103562801932, 0.3316894531249999, 0.0), # 35 (0.646183216112532, 1.3280529545454547, 1.0432702173913042, 0.5545888235294117, 0.3218604255319149, 0.0, 0.9261169790104948, 1.2874417021276596, 0.8318832352941177, 0.6955134782608695, 0.3320132386363637, 0.0), # 36 (0.6475228340792839, 1.3293288920454547, 1.0422239221014493, 0.5544431454248366, 0.32163424645390065, 0.0, 0.9228054805930368, 1.2865369858156026, 0.831664718137255, 0.6948159480676328, 0.33233222301136367, 0.0), # 37 (0.6488335038363171, 1.3305854545454545, 1.0410302898550725, 0.5542763398692809, 0.3213754609929078, 0.0, 0.919123055139097, 1.2855018439716313, 0.8314145098039215, 0.6940201932367149, 0.33264636363636363, 0.0), # 38 (0.6501158967391305, 1.331822471590909, 1.0396929619565216, 0.55408875, 0.3210846542553191, 0.0, 0.91508214017991, 1.2843386170212765, 0.831133125, 0.6931286413043477, 0.33295561789772726, 0.0), # 39 (0.6513706841432225, 1.3330397727272727, 1.0382155797101449, 0.5538807189542484, 0.32076241134751765, 0.0, 0.9106951732467099, 1.2830496453900706, 0.8308210784313727, 0.6921437198067633, 0.3332599431818182, 0.0), # 40 (0.6525985374040921, 1.3342371874999996, 1.03660178442029, 0.553652589869281, 0.3204093173758865, 0.0, 0.9059745918707315, 1.281637269503546, 0.8304788848039216, 0.6910678562801932, 0.3335592968749999, 0.0), # 41 (0.6538001278772378, 1.3354145454545456, 1.0348552173913044, 0.5534047058823529, 0.3200259574468085, 0.0, 0.9009328335832084, 1.280103829787234, 0.8301070588235294, 0.6899034782608696, 0.3338536363636364, 0.0), # 42 (0.6549761269181587, 1.3365716761363635, 1.0329795199275362, 0.5531374101307189, 0.31961291666666664, 0.0, 0.8955823359153756, 1.2784516666666665, 0.8297061151960784, 0.688653013285024, 0.3341429190340909, 0.0), # 43 (0.656127205882353, 1.337708409090909, 1.0309783333333333, 0.552851045751634, 0.31917078014184397, 0.0, 0.8899355363984673, 1.2766831205673759, 0.829276568627451, 0.6873188888888889, 0.33442710227272726, 0.0), # 44 (0.6572540361253196, 1.3388245738636362, 1.0288552989130437, 0.5525459558823529, 0.3187001329787234, 0.0, 0.8840048725637182, 1.2748005319148936, 0.8288189338235293, 0.6859035326086957, 0.33470614346590905, 0.0), # 45 (0.6583572890025576, 1.33992, 1.0266140579710146, 0.5522224836601306, 0.31820156028368796, 0.0, 0.8778027819423623, 1.2728062411347518, 0.828333725490196, 0.6844093719806764, 0.33498, 0.0), # 46 (0.6594376358695653, 1.3409945170454545, 1.0242582518115941, 0.5518809722222222, 0.3176756471631206, 0.0, 0.8713417020656339, 1.2707025886524823, 0.8278214583333333, 0.6828388345410626, 0.3352486292613636, 0.0), # 47 (0.6604957480818415, 1.3420479545454547, 1.0217915217391305, 0.5515217647058823, 0.3171229787234042, 0.0, 0.8646340704647678, 1.268491914893617, 0.8272826470588235, 0.6811943478260869, 0.33551198863636367, 0.0), # 48 (0.6615322969948849, 1.3430801420454541, 1.0192175090579711, 0.5511452042483661, 0.31654414007092196, 0.0, 0.8576923246709978, 1.2661765602836879, 0.8267178063725492, 0.6794783393719807, 0.33577003551136353, 0.0), # 49 (0.6625479539641944, 1.3440909090909086, 1.0165398550724638, 0.5507516339869282, 0.31593971631205675, 0.0, 0.8505289022155589, 1.263758865248227, 0.8261274509803923, 0.6776932367149758, 0.33602272727272714, 0.0), # 50 (0.6635433903452687, 1.3450800852272726, 1.0137622010869565, 0.5503413970588236, 0.31531029255319143, 0.0, 0.8431562406296852, 1.2612411702127657, 0.8255120955882354, 0.6758414673913044, 0.33627002130681816, 0.0), # 51 (0.6645192774936062, 1.3460474999999998, 1.010888188405797, 0.5499148366013071, 0.31465645390070923, 0.0, 0.8355867774446111, 1.258625815602837, 0.8248722549019608, 0.673925458937198, 0.33651187499999996, 0.0), # 52 (0.6654762867647059, 1.3469929829545455, 1.0079214583333334, 0.549472295751634, 0.31397878546099295, 0.0, 0.8278329501915709, 1.2559151418439718, 0.824208443627451, 0.6719476388888889, 0.3367482457386364, 0.0), # 53 (0.6664150895140666, 1.3479163636363634, 1.004865652173913, 0.5490141176470589, 0.31327787234042553, 0.0, 0.8199071964017991, 1.2531114893617021, 0.8235211764705883, 0.6699104347826086, 0.33697909090909084, 0.0), # 54 (0.6673363570971866, 1.348817471590909, 1.001724411231884, 0.5485406454248366, 0.31255429964539005, 0.0, 0.8118219536065301, 1.2502171985815602, 0.822810968137255, 0.6678162741545893, 0.33720436789772723, 0.0), # 55 (0.6682407608695652, 1.3496961363636362, 0.9985013768115942, 0.5480522222222222, 0.3118086524822695, 0.0, 0.8035896593369982, 1.247234609929078, 0.8220783333333334, 0.6656675845410628, 0.33742403409090904, 0.0), # 56 (0.6691289721867009, 1.3505521875000002, 0.9952001902173913, 0.5475491911764706, 0.3110415159574468, 0.0, 0.7952227511244377, 1.2441660638297871, 0.821323786764706, 0.6634667934782609, 0.33763804687500004, 0.0), # 57 (0.6700016624040921, 1.3513854545454542, 0.991824492753623, 0.5470318954248365, 0.31025347517730495, 0.0, 0.7867336665000834, 1.2410139007092198, 0.8205478431372549, 0.6612163285024154, 0.33784636363636356, 0.0), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_allighting_rate = ( (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 0 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 1 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 2 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 3 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 4 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 5 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 6 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 7 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 8 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 9 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 10 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 11 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 12 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 13 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 14 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 15 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 16 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 17 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 18 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 19 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 20 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 21 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 22 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 23 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 24 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 25 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 26 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 27 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 28 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 29 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 30 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 31 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 32 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 33 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 34 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 35 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 36 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 37 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 38 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 39 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 40 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 41 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 42 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 43 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 44 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 45 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 46 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 47 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 48 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 49 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 50 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 51 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 52 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 53 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 54 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 55 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 56 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 57 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 58 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 59 ) """ parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html """ #initial entropy entropy = 258194110137029475889902652135037600173 #index for seed sequence child child_seed_index = ( 1, # 0 39, # 1 )
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) class ZookeeperBenchmark(MavenPackage): """It is designed to measure the per-request latency of a ZooKeeper ensemble for a predetermined length of time""" homepage = "http://zookeeper.apache.org" git = "https://github.com/brownsys/zookeeper-benchmark.git" version('master', branch='master') depends_on('zookeeper', type=('build', 'run')) def build(self, spec, prefix): zookeeper_version = self.spec['zookeeper'].version.string mvn = which('mvn') mvn('-DZooKeeperVersion=' + zookeeper_version, 'package')
n = [ 1 ] + [ 50 ] * 10 + [ 1 ] with open('8.in', 'r') as f: totn, m, k, op = [ int(x) for x in f.readline().split() ] for i in range(m): f.readline() for i, v in enumerate(n): with open('p%d.in' % i, 'w') as o: o.write('%d 0 %d 2\n' % (v, k)) for j in range(v): o.write(f.readline() + '\n')
# Configuration file for ipython-console. c = get_config() #------------------------------------------------------------------------------ # ZMQTerminalIPythonApp configuration #------------------------------------------------------------------------------ # ZMQTerminalIPythonApp will inherit config from: TerminalIPythonApp, # BaseIPythonApplication, Application, InteractiveShellApp, IPythonConsoleApp, # ConnectionFileMixin # The Logging format template # c.ZMQTerminalIPythonApp.log_format = '[%(name)s]%(highlevel)s %(message)s' # List of files to run at IPython startup. # c.ZMQTerminalIPythonApp.exec_files = [] # set the stdin (ROUTER) port [default: random] # c.ZMQTerminalIPythonApp.stdin_port = 0 # set the iopub (PUB) port [default: random] # c.ZMQTerminalIPythonApp.iopub_port = 0 # Execute the given command string. # c.ZMQTerminalIPythonApp.code_to_run = '' # The name of the IPython directory. This directory is used for logging # configuration (through profiles), history storage, etc. The default is usually # $HOME/.ipython. This option can also be specified through the environment # variable IPYTHONDIR. # c.ZMQTerminalIPythonApp.ipython_dir = '' # A file to be run # c.ZMQTerminalIPythonApp.file_to_run = '' # Run the module as a script. # c.ZMQTerminalIPythonApp.module_to_run = '' # Whether to display a banner upon starting IPython. # c.ZMQTerminalIPythonApp.display_banner = True # Enable GUI event loop integration with any of ('glut', 'gtk', 'gtk3', 'osx', # 'pyglet', 'qt', 'qt5', 'tk', 'wx'). # c.ZMQTerminalIPythonApp.gui = None # Start IPython quickly by skipping the loading of config files. # c.ZMQTerminalIPythonApp.quick = False # Set the log level by value or name. # c.ZMQTerminalIPythonApp.log_level = 30 # Path to the ssh key to use for logging in to the ssh server. # c.ZMQTerminalIPythonApp.sshkey = '' # The SSH server to use to connect to the kernel. # c.ZMQTerminalIPythonApp.sshserver = '' # lines of code to run at IPython startup. # c.ZMQTerminalIPythonApp.exec_lines = [] # Pre-load matplotlib and numpy for interactive use, selecting a particular # matplotlib backend and loop integration. # c.ZMQTerminalIPythonApp.pylab = None # Path to an extra config file to load. # # If specified, load this config file in addition to any other IPython config. # c.ZMQTerminalIPythonApp.extra_config_file = '' # set the shell (ROUTER) port [default: random] # c.ZMQTerminalIPythonApp.shell_port = 0 # The IPython profile to use. # c.ZMQTerminalIPythonApp.profile = 'default' # JSON file in which to store connection info [default: kernel-<pid>.json] # # This file will contain the IP, ports, and authentication key needed to connect # clients to this kernel. By default, this file will be created in the security # dir of the current profile, but can be specified by absolute path. # c.ZMQTerminalIPythonApp.connection_file = '' # Run the file referenced by the PYTHONSTARTUP environment variable at IPython # startup. # c.ZMQTerminalIPythonApp.exec_PYTHONSTARTUP = True # Should variables loaded at startup (by startup files, exec_lines, etc.) be # hidden from tools like %who? # c.ZMQTerminalIPythonApp.hide_initial_ns = True # Whether to install the default config files into the profile dir. If a new # profile is being created, and IPython contains config files for that profile, # then they will be staged into the new directory. Otherwise, default config # files will be automatically generated. # c.ZMQTerminalIPythonApp.copy_config_files = False # Whether to overwrite existing config files when copying # c.ZMQTerminalIPythonApp.overwrite = False # Configure matplotlib for interactive use with the default matplotlib backend. # c.ZMQTerminalIPythonApp.matplotlib = None # Set to display confirmation dialog on exit. You can always use 'exit' or # 'quit', to force a direct exit without any confirmation. # c.ZMQTerminalIPythonApp.confirm_exit = True # If a command or file is given via the command-line, e.g. 'ipython foo.py', # start an interactive shell after executing the file or command. # c.ZMQTerminalIPythonApp.force_interact = False # # c.ZMQTerminalIPythonApp.transport = 'tcp' # set the control (ROUTER) port [default: random] # c.ZMQTerminalIPythonApp.control_port = 0 # dotted module name of an IPython extension to load. # c.ZMQTerminalIPythonApp.extra_extension = '' # Set the kernel's IP address [default localhost]. If the IP address is # something other than localhost, then Consoles on other machines will be able # to connect to the Kernel, so be careful! # c.ZMQTerminalIPythonApp.ip = '' # If true, IPython will populate the user namespace with numpy, pylab, etc. and # an ``import *`` is done from numpy and pylab, when using pylab mode. # # When False, pylab mode should not import any names into the user namespace. # c.ZMQTerminalIPythonApp.pylab_import_all = True # set the heartbeat port [default: random] # c.ZMQTerminalIPythonApp.hb_port = 0 # The date format used by logging formatters for %(asctime)s # c.ZMQTerminalIPythonApp.log_datefmt = '%Y-%m-%d %H:%M:%S' # The name of the default kernel to start. # c.ZMQTerminalIPythonApp.kernel_name = 'python' # Create a massive crash report when IPython encounters what may be an internal # error. The default is to append a short message to the usual traceback # c.ZMQTerminalIPythonApp.verbose_crash = False # A list of dotted module names of IPython extensions to load. # c.ZMQTerminalIPythonApp.extensions = [] # Connect to an already running kernel # c.ZMQTerminalIPythonApp.existing = '' # Suppress warning messages about legacy config files # c.ZMQTerminalIPythonApp.ignore_old_config = False #------------------------------------------------------------------------------ # ZMQTerminalInteractiveShell configuration #------------------------------------------------------------------------------ # A subclass of TerminalInteractiveShell that uses the 0MQ kernel # ZMQTerminalInteractiveShell will inherit config from: # TerminalInteractiveShell, InteractiveShell # Set the editor used by IPython (default to $EDITOR/vi/notepad). # c.ZMQTerminalInteractiveShell.editor = 'vi' # 'all', 'last', 'last_expr' or 'none', specifying which nodes should be run # interactively (displaying output from expressions). # c.ZMQTerminalInteractiveShell.ast_node_interactivity = 'last_expr' # Set the color scheme (NoColor, Linux, or LightBG). # c.ZMQTerminalInteractiveShell.colors = 'Linux' # Autoindent IPython code entered interactively. # c.ZMQTerminalInteractiveShell.autoindent = True # Whether to include output from clients other than this one sharing the same # kernel. # # Outputs are not displayed until enter is pressed. # c.ZMQTerminalInteractiveShell.include_other_output = False # A list of ast.NodeTransformer subclass instances, which will be applied to # user input before code is run. # c.ZMQTerminalInteractiveShell.ast_transformers = [] # # c.ZMQTerminalInteractiveShell.readline_parse_and_bind = ['tab: complete', '"\\C-l": clear-screen', 'set show-all-if-ambiguous on', '"\\C-o": tab-insert', '"\\C-r": reverse-search-history', '"\\C-s": forward-search-history', '"\\C-p": history-search-backward', '"\\C-n": history-search-forward', '"\\e[A": history-search-backward', '"\\e[B": history-search-forward', '"\\C-k": kill-line', '"\\C-u": unix-line-discard'] # Enable deep (recursive) reloading by default. IPython can use the deep_reload # module which reloads changes in modules recursively (it replaces the reload() # function, so you don't need to change anything to use it). deep_reload() # forces a full reload of modules whose code may have changed, which the default # reload() function does not. When deep_reload is off, IPython will use the # normal reload(), but deep_reload will still be available as dreload(). # c.ZMQTerminalInteractiveShell.deep_reload = False # Save multi-line entries as one entry in readline history # c.ZMQTerminalInteractiveShell.multiline_history = True # Callable object called via 'callable' image handler with one argument, `data`, # which is `msg["content"]["data"]` where `msg` is the message from iopub # channel. For exmaple, you can find base64 encoded PNG data as # `data['image/png']`. # c.ZMQTerminalInteractiveShell.callable_image_handler = None # # c.ZMQTerminalInteractiveShell.separate_out2 = '' # Don't call post-execute functions that have failed in the past. # c.ZMQTerminalInteractiveShell.disable_failing_post_execute = False # Start logging to the given file in append mode. # c.ZMQTerminalInteractiveShell.logappend = '' # # c.ZMQTerminalInteractiveShell.separate_in = '\n' # # c.ZMQTerminalInteractiveShell.readline_use = True # Make IPython automatically call any callable object even if you didn't type # explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically. # The value can be '0' to disable the feature, '1' for 'smart' autocall, where # it is not applied if there are no more arguments on the line, and '2' for # 'full' autocall, where all callable objects are automatically called (even if # no arguments are present). # c.ZMQTerminalInteractiveShell.autocall = 0 # Enable auto setting the terminal title. # c.ZMQTerminalInteractiveShell.term_title = False # Automatically call the pdb debugger after every exception. # c.ZMQTerminalInteractiveShell.pdb = False # Deprecated, use PromptManager.in_template # c.ZMQTerminalInteractiveShell.prompt_in1 = 'In [\\#]: ' # The part of the banner to be printed after the profile # c.ZMQTerminalInteractiveShell.banner2 = '' # # c.ZMQTerminalInteractiveShell.wildcards_case_sensitive = True # # c.ZMQTerminalInteractiveShell.readline_remove_delims = '-/~' # Deprecated, use PromptManager.out_template # c.ZMQTerminalInteractiveShell.prompt_out = 'Out[\\#]: ' # # c.ZMQTerminalInteractiveShell.xmode = 'Context' # Use colors for displaying information about objects. Because this information # is passed through a pager (like 'less'), and some pagers get confused with # color codes, this capability can be turned off. # c.ZMQTerminalInteractiveShell.color_info = True # Command to invoke an image viewer program when you are using 'stream' image # handler. This option is a list of string where the first element is the # command itself and reminders are the options for the command. Raw image data # is given as STDIN to the program. # c.ZMQTerminalInteractiveShell.stream_image_handler = [] # Set the size of the output cache. The default is 1000, you can change it # permanently in your config file. Setting it to 0 completely disables the # caching system, and the minimum value accepted is 20 (if you provide a value # less than 20, it is reset to 0 and a warning is issued). This limit is # defined because otherwise you'll spend more time re-flushing a too small cache # than working # c.ZMQTerminalInteractiveShell.cache_size = 1000 # # c.ZMQTerminalInteractiveShell.ipython_dir = '' # Command to invoke an image viewer program when you are using 'tempfile' image # handler. This option is a list of string where the first element is the # command itself and reminders are the options for the command. You can use # {file} and {format} in the string to represent the location of the generated # image file and image format. # c.ZMQTerminalInteractiveShell.tempfile_image_handler = [] # Deprecated, use PromptManager.in2_template # c.ZMQTerminalInteractiveShell.prompt_in2 = ' .\\D.: ' # Enable magic commands to be called without the leading %. # c.ZMQTerminalInteractiveShell.automagic = True # # c.ZMQTerminalInteractiveShell.separate_out = '' # Timeout for giving up on a kernel (in seconds). # # On first connect and restart, the console tests whether the kernel is running # and responsive by sending kernel_info_requests. This sets the timeout in # seconds for how long the kernel can take before being presumed dead. # c.ZMQTerminalInteractiveShell.kernel_timeout = 60 # Deprecated, use PromptManager.justify # c.ZMQTerminalInteractiveShell.prompts_pad_left = True # The shell program to be used for paging. # c.ZMQTerminalInteractiveShell.pager = 'less' # The name of the logfile to use. # c.ZMQTerminalInteractiveShell.logfile = '' # If True, anything that would be passed to the pager will be displayed as # regular output instead. # c.ZMQTerminalInteractiveShell.display_page = False # auto editing of files with syntax errors. # c.ZMQTerminalInteractiveShell.autoedit_syntax = False # Handler for image type output. This is useful, for example, when connecting # to the kernel in which pylab inline backend is activated. There are four # handlers defined. 'PIL': Use Python Imaging Library to popup image; 'stream': # Use an external program to show the image. Image will be fed into the STDIN # of the program. You will need to configure `stream_image_handler`; # 'tempfile': Use an external program to show the image. Image will be saved in # a temporally file and the program is called with the temporally file. You # will need to configure `tempfile_image_handler`; 'callable': You can set any # Python callable which is called with the image data. You will need to # configure `callable_image_handler`. # c.ZMQTerminalInteractiveShell.image_handler = None # Show rewritten input, e.g. for autocall. # c.ZMQTerminalInteractiveShell.show_rewritten_input = True # The part of the banner to be printed before the profile # c.ZMQTerminalInteractiveShell.banner1 = 'Python 3.4.0 (default, Apr 11 2014, 13:05:18) \nType "copyright", "credits" or "license" for more information.\n\nIPython 3.0.0-rc1 -- An enhanced Interactive Python.\n? -> Introduction and overview of IPython\'s features.\n%quickref -> Quick reference.\nhelp -> Python\'s own help system.\nobject? -> Details about \'object\', use \'object??\' for extra details.\n' # Set to confirm when you try to exit IPython with an EOF (Control-D in Unix, # Control-Z/Enter in Windows). By typing 'exit' or 'quit', you can force a # direct exit without any confirmation. # c.ZMQTerminalInteractiveShell.confirm_exit = True # Preferred object representation MIME type in order. First matched MIME type # will be used. # c.ZMQTerminalInteractiveShell.mime_preference = ['image/png', 'image/jpeg', 'image/svg+xml'] # # c.ZMQTerminalInteractiveShell.history_length = 10000 # # c.ZMQTerminalInteractiveShell.object_info_string_level = 0 # # c.ZMQTerminalInteractiveShell.debug = False # Start logging to the default log file. # c.ZMQTerminalInteractiveShell.logstart = False # Number of lines of your screen, used to control printing of very long strings. # Strings longer than this number of lines will be sent through a pager instead # of directly printed. The default value for this is 0, which means IPython # will auto-detect your screen size every time it needs to print certain # potentially long strings (this doesn't change the behavior of the 'print' # keyword, it's only triggered internally). If for some reason this isn't # working well (it needs curses support), specify it yourself. Otherwise don't # change the default. # c.ZMQTerminalInteractiveShell.screen_length = 0 # Prefix to add to outputs coming from clients other than this one. # # Only relevant if include_other_output is True. # c.ZMQTerminalInteractiveShell.other_output_prefix = '[remote] ' # # c.ZMQTerminalInteractiveShell.quiet = False #------------------------------------------------------------------------------ # KernelManager configuration #------------------------------------------------------------------------------ # Manages a single kernel in a subprocess on this host. # # This version starts kernels with Popen. # KernelManager will inherit config from: ConnectionFileMixin # # c.KernelManager.transport = 'tcp' # set the shell (ROUTER) port [default: random] # c.KernelManager.shell_port = 0 # Set the kernel's IP address [default localhost]. If the IP address is # something other than localhost, then Consoles on other machines will be able # to connect to the Kernel, so be careful! # c.KernelManager.ip = '' # set the stdin (ROUTER) port [default: random] # c.KernelManager.stdin_port = 0 # JSON file in which to store connection info [default: kernel-<pid>.json] # # This file will contain the IP, ports, and authentication key needed to connect # clients to this kernel. By default, this file will be created in the security # dir of the current profile, but can be specified by absolute path. # c.KernelManager.connection_file = '' # set the heartbeat port [default: random] # c.KernelManager.hb_port = 0 # set the iopub (PUB) port [default: random] # c.KernelManager.iopub_port = 0 # set the control (ROUTER) port [default: random] # c.KernelManager.control_port = 0 # Should we autorestart the kernel if it dies. # c.KernelManager.autorestart = False # DEPRECATED: Use kernel_name instead. # # The Popen Command to launch the kernel. Override this if you have a custom # kernel. If kernel_cmd is specified in a configuration file, IPython does not # pass any arguments to the kernel, because it cannot make any assumptions about # the arguments that the kernel understands. In particular, this means that the # kernel does not receive the option --debug if it given on the IPython command # line. # c.KernelManager.kernel_cmd = [] #------------------------------------------------------------------------------ # ProfileDir configuration #------------------------------------------------------------------------------ # An object to manage the profile directory and its resources. # # The profile directory is used by all IPython applications, to manage # configuration, logging and security. # # This object knows how to find, create and manage these directories. This # should be used by any code that wants to handle profiles. # Set the profile location directly. This overrides the logic used by the # `profile` option. # c.ProfileDir.location = '' #------------------------------------------------------------------------------ # Session configuration #------------------------------------------------------------------------------ # Object for handling serialization and sending of messages. # # The Session object handles building messages and sending them with ZMQ sockets # or ZMQStream objects. Objects can communicate with each other over the # network via Session objects, and only need to work with the dict-based IPython # message spec. The Session will handle serialization/deserialization, security, # and metadata. # # Sessions support configurable serialization via packer/unpacker traits, and # signing with HMAC digests via the key/keyfile traits. # # Parameters ---------- # # debug : bool # whether to trigger extra debugging statements # packer/unpacker : str : 'json', 'pickle' or import_string # importstrings for methods to serialize message parts. If just # 'json' or 'pickle', predefined JSON and pickle packers will be used. # Otherwise, the entire importstring must be used. # # The functions must accept at least valid JSON input, and output *bytes*. # # For example, to use msgpack: # packer = 'msgpack.packb', unpacker='msgpack.unpackb' # pack/unpack : callables # You can also set the pack/unpack callables for serialization directly. # session : bytes # the ID of this Session object. The default is to generate a new UUID. # username : unicode # username added to message headers. The default is to ask the OS. # key : bytes # The key used to initialize an HMAC signature. If unset, messages # will not be signed or checked. # keyfile : filepath # The file containing a key. If this is set, `key` will be initialized # to the contents of the file. # The UUID identifying this session. # c.Session.session = '' # Threshold (in bytes) beyond which an object's buffer should be extracted to # avoid pickling. # c.Session.buffer_threshold = 1024 # The maximum number of items for a container to be introspected for custom # serialization. Containers larger than this are pickled outright. # c.Session.item_threshold = 64 # The name of the unpacker for unserializing messages. Only used with custom # functions for `packer`. # c.Session.unpacker = 'json' # path to file containing execution key. # c.Session.keyfile = '' # Metadata dictionary, which serves as the default top-level metadata dict for # each message. # c.Session.metadata = {} # Debug output in the Session # c.Session.debug = False # The digest scheme used to construct the message signatures. Must have the form # 'hmac-HASH'. # c.Session.signature_scheme = 'hmac-sha256' # The name of the packer for serializing messages. Should be one of 'json', # 'pickle', or an import name for a custom callable serializer. # c.Session.packer = 'json' # Username for the Session. Default is your system username. # c.Session.username = 'vagrant' # The maximum number of digests to remember. # # The digest history will be culled when it exceeds this value. # c.Session.digest_history_size = 65536 # execution key, for extra authentication. # c.Session.key = b'' # Threshold (in bytes) beyond which a buffer should be sent without copying. # c.Session.copy_threshold = 65536
"""Constants for the WLED integration.""" # Integration domain DOMAIN = "wled" # Attributes ATTR_COLOR_PRIMARY = "color_primary" ATTR_DURATION = "duration" ATTR_FADE = "fade" ATTR_INTENSITY = "intensity" ATTR_LED_COUNT = "led_count" ATTR_MAX_POWER = "max_power" ATTR_ON = "on" ATTR_PALETTE = "palette" ATTR_PLAYLIST = "playlist" ATTR_PRESET = "preset" ATTR_REVERSE = "reverse" ATTR_SEGMENT_ID = "segment_id" ATTR_SOFTWARE_VERSION = "sw_version" ATTR_SPEED = "speed" ATTR_TARGET_BRIGHTNESS = "target_brightness" ATTR_UDP_PORT = "udp_port" # Units of measurement CURRENT_MA = "mA" # Services SERVICE_EFFECT = "effect" SERVICE_PRESET = "preset"
"""Wrapper macro around parcel cli""" load("@aspect_bazel_lib//lib:utils.bzl", "path_to_workspace_root") load("@npm//parcel-bundler:index.bzl", _parcel = "parcel") def parcel(name, entry_html, data = [], **kwargs): """Wrapper macro around parcel cli""" _parcel( name = name, args = [ "build", "%s/$(execpath %s)" % (path_to_workspace_root(), entry_html), "--out-dir=%s/$(@D)" % path_to_workspace_root(), ], chdir = native.package_name(), data = data + [entry_html], output_dir = True, )
def fib(n): '''Takes in a number n, and returns the nth fibonacci number, starting with: 1, 1, 2, 3, 5,...''' if n <= 1: return n else: return fib(n - 1) + fib(n - 2)
class Column(object): def __init__(self, name, dataType): self._number = 0 self._name = name self._dataType = dataType self._length = None self._default = None self._notNull = False self._unique = False self._constraint = None self._check = [] self._primaryKey = False self._foreignKey = None self._autoincrement = False # TODO FOREIGN KEY implementation # {'refTable':None,'refColumn':None} {'Referenced table': None} def __str__(self): return self._name @property def name(self): return self._name @name.setter def name(self, name): self._name = name @property def dataType(self): return self._dataType @dataType.setter def dataType(self, dataType): self._dataType = dataType @property def length(self): return self._length @length.setter def length(self, length): self._length = length @property def notNull(self): return self._notNull @notNull.setter def notNull(self, notNull): self._notNull = notNull @property def primaryKey(self): return self._primaryKey @primaryKey.setter def primaryKey(self, primaryKey): self._primaryKey = primaryKey @property def number(self): return self._number @number.setter def number(self, number): self._number = number @property def foreignKey(self): return self._foreignKey @foreignKey.setter def foreignKey(self, foreignKey): self._foreignKey = foreignKey @property def unique(self): return self._unique @unique.setter def unique(self, unique): self._unique = unique @property def constraint(self): return self._constraint @constraint.setter def constraint(self, constraint): self._constraint = constraint @property def default(self): return self._default @default.setter def default(self, default): self._default = default @property def autoincrement(self): return self._autoincrement @autoincrement.setter def autoincrement(self, autoincrement): self._autoincrement = autoincrement @property def check(self): return self._check @check.setter def check(self, check): self._check = check
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def middleNode(self, head): """ :type head: ListNode :rtype: ListNode """ if not head: return None fastRuner, slowRuner = head, head while fastRuner and fastRuner.next: fastRuner = fastRuner.next.next slowRuner = slowRuner.next return slowRuner
""" author: name : Do Viet Chinh personal email: dovietchinh1998@mgail.com personal facebook: https://www.facebook.com/profile.php?id=100005935236259 VNOpenAI team: vnopenai@gmail.com via team : date: 26.3.2021 """
# Definisikan class Karyawan class Karyawan: def __init__(self, nama, usia, pendapatan, insentif_lembur): self.nama = nama self.usia = usia self.pendapatan = pendapatan self.pendapatan_tambahan = 0 self.insentif_lembur = insentif_lembur def lembur(self): self.pendapatan_tambahan += self.insentif_lembur def tambahan_proyek(self, jumlah_tambahan): self.pendapatan_tambahan += jumlah_tambahan def total_pendapatan(self): return self.pendapatan + self.pendapatan_tambahan # Definisikan class Perusahaan class Perusahaan: def __init__(self, nama, alamat, nomor_telepon): self.nama = nama self.alamat = alamat self.nomor_telepon = nomor_telepon self.list_karyawan = [] def aktifkan_karyawan(self, karyawan): self.list_karyawan.append(karyawan) def nonaktifkan_karyawan(self, nama_karyawan): karyawan_nonaktif = None for karyawan in self.list_karyawan: if karyawan.nama == nama_karyawan: karyawan_nonaktif = karyawan break if karyawan_nonaktif is not None: self.list_karyawan.remove(karyawan_nonaktif)
# Faça um programa que leia um numero real e imprima num_real = float(input('Entre com um numero real: ')) print(f'O numero real digitado foi: {num_real}')
TEMPLATE = """import numpy as np import unittest from {name}.algorithm.research_algorithm import {name_upper}Estimator class Test{name_upper}Estimator(unittest.TestCase): def test_predict(self): multiplier = 2 input_data = np.random.random([1, 2]) expected_result = input_data * multiplier estimator = {name_upper}Estimator(multiplier=multiplier) result = estimator.predict(input_data) self.assertTrue(np.allclose(result, expected_result)) """ def get_template(name: str): return TEMPLATE.format(name=name.lower(), name_upper=name.capitalize())
"""A module for defining WORKSPACE dependencies required for rules_foreign_cc""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load( "//foreign_cc/private/shell_toolchain/toolchains:ws_defs.bzl", shell_toolchain_workspace_initalization = "workspace_part", ) load("//toolchains:toolchains.bzl", "built_toolchains", "prebuilt_toolchains", "preinstalled_toolchains") # buildifier: disable=unnamed-macro def rules_foreign_cc_dependencies( native_tools_toolchains = [], register_default_tools = True, cmake_version = "3.19.6", make_version = "4.3", ninja_version = "1.10.2", register_preinstalled_tools = True, register_built_tools = True, additional_shell_toolchain_mappings = [], additional_shell_toolchain_package = None): """Call this function from the WORKSPACE file to initialize rules_foreign_cc \ dependencies and let neccesary code generation happen \ (Code generation is needed to support different variants of the C++ Starlark API.). Args: native_tools_toolchains: pass the toolchains for toolchain types '@rules_foreign_cc//toolchains:cmake_toolchain' and '@rules_foreign_cc//toolchains:ninja_toolchain' with the needed platform constraints. If you do not pass anything, registered default toolchains will be selected (see below). register_default_tools: If True, the cmake and ninja toolchains, calling corresponding preinstalled binaries by name (cmake, ninja) will be registered after 'native_tools_toolchains' without any platform constraints. The default is True. cmake_version: The target version of the cmake toolchain if `register_default_tools` or `register_built_tools` is set to `True`. make_version: The target version of the default make toolchain if `register_built_tools` is set to `True`. ninja_version: The target version of the ninja toolchain if `register_default_tools` or `register_built_tools` is set to `True`. register_preinstalled_tools: If true, toolchains will be registered for the native built tools installed on the exec host register_built_tools: If true, toolchains that build the tools from source are registered additional_shell_toolchain_mappings: Mappings of the shell toolchain functions to execution and target platforms constraints. Similar to what defined in @rules_foreign_cc//foreign_cc/private/shell_toolchain/toolchains:toolchain_mappings.bzl in the TOOLCHAIN_MAPPINGS list. Please refer to example in @rules_foreign_cc//toolchain_examples. additional_shell_toolchain_package: A package under which additional toolchains, referencing the generated data for the passed additonal_shell_toolchain_mappings, will be defined. This value is needed since register_toolchains() is called for these toolchains. Please refer to example in @rules_foreign_cc//toolchain_examples. """ shell_toolchain_workspace_initalization( additional_shell_toolchain_mappings, additional_shell_toolchain_package, ) native.register_toolchains(*native_tools_toolchains) if register_default_tools: prebuilt_toolchains(cmake_version, ninja_version) if register_built_tools: built_toolchains( cmake_version = cmake_version, make_version = make_version, ninja_version = ninja_version, ) if register_preinstalled_tools: preinstalled_toolchains() maybe( http_archive, name = "bazel_skylib", sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", ], )
class Solution: def wordSquares(self, words): """ :type words: List[str] :rtype: List[List[str]] """ n = len(words[0]) pres = collections.defaultdict(list) for word in words: for i in range(n): pres[word[:i]].append(word) def build(square): if len(square) == n: squares.append(square) return for word in pres[''.join(list(zip(*square))[len(square)])]: build(square + [word]) squares = [] for word in words: build([word]) return squares
#!/usr/bin/env python # encoding: utf-8 name = "Non Atom Centered Platts Groups" shortDesc = "" longDesc = """ """ entry( index = -3, label = "R", group = """ 1 * R u0 """, solute = None, shortDesc = """""", longDesc = """ """, ) entry( index = -2, label = "CO", group = """ 1 * CO u0 """, solute = None, shortDesc = """""", longDesc = """ """, ) entry( index = 1, label = "Oss(CdsOd)", group = """ 1 * CO u0 {2,S} {3,S} {4,D} 2 O2s u0 {1,S} {5,S} 3 [Cs,Cd,Cdd,Ct,Cb,Cbf,CO,H] u0 {1,S} 4 O2d u0 {1,D} 5 R!H u0 {2,S} """, solute = SoluteData( S = -0.225, B = -0.206, E = -0.113, L = -0.39, A = 0, ), shortDesc = """Platts fragment 43 non-cyclic ester""", longDesc = """ """, ) entry( index = 4, label = "Cs(OssH)Cs(OssH)", group = """ 1 * Cs u0 {2,S} {3,S} {4,S} {5,S} 2 R u0 {1,S} 3 R u0 {1,S} 4 O2s u0 {1,S} {6,S} 5 Cs u0 {1,S} {7,S} {8,S} {9,S} 6 H u0 {4,S} 7 R u0 {5,S} 8 R u0 {5,S} 9 O2s u0 {5,S} {10,S} 10 H u0 {9,S} """, solute = SoluteData( S = 0.026, B = 0, E = -0.0215, L = 0.05, A = 0, ), shortDesc = """Platts fragment 68 1,2 diol""", longDesc = """ """, ) entry( index = 6, label = "CbCsOssH", group = """ 1 * Cb u0 {2,S} 2 Cs u0 {1,S} {3,S} 3 O2s u0 {2,S} {4,S} 4 H u0 {3,S} """, solute = SoluteData( S = 0, B = 0.131, E = 0, L = -0.145, A = 0, ), shortDesc = """Platts fragment 79 benzyl alcohol""", longDesc = """ """, ) entry( index = 8, label = "OssH", group = """ 1 * O2s u0 {2,S} {3,S} 2 H u0 {1,S} 3 [Cs,Cd,Ct,CO,O2s,H] u0 {1,S} """, solute = SoluteData( S = 0, B = 0, E = 0, L = 0, A = 0.345, ), shortDesc = """-OH (connected to aliphatic) correction for A""", longDesc = """ """, ) entry( index = 7, label = "phenol", group = """ 1 * O2s u0 {2,S} {3,S} 2 H u0 {1,S} 3 [Cb,Cbf] u0 {1,S} """, solute = SoluteData( S = 0, B = 0, E = 0, L = 0, A = 0.543, ), shortDesc = """phenol correction for A""", longDesc = """ """, ) entry( index = 9, label = "OxRing", group = "OR{OxR3, OxR4, OxR5, OxR6, OxR7}", solute = SoluteData( S = 0, B = 0.12, E = -0.001, L = -0.001, A = 0, ), shortDesc = """Correction for an Oss group in a ring""", longDesc = """ """, ) entry( index = 30, label = "N3sH2-benz", group = """ 1 * N3s u0 {2,S} {3,S} {4,S} 2 H u0 {1,S} 3 H u0 {1,S} 4 Cb u0 {1,S} {5,B} {9,B} 5 Cb u0 {4,B} {6,B} 6 Cb u0 {5,B} {7,B} 7 Cb u0 {6,B} {8,B} 8 Cb u0 {7,B} {9,B} 9 Cb u0 {4,B} {8,B} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = 0.247, ), shortDesc = """aniline correction for A (fragment 4)""", longDesc = """ """, ) entry( index = 31, label = "Cd(O2d)NH2", group = """ 1 * N3s u0 {2,S} {3,S} {4,S} 2 H u0 {1,S} 3 H u0 {1,S} 4 CO u0 {1,S} {5,D} 5 O2d u0 {4,D} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = 0.275, ), shortDesc = """primary amide correction for A (fragment 10)""", longDesc = """ """, ) entry( index = 32, label = "Cd(O2d)NHR", group = """ 1 * N3s u0 {2,S} {3,S} {4,S} 2 H u0 {1,S} 3 R!H u0 {1,S} 4 CO u0 {1,S} {5,D} 5 O2d u0 {4,D} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = 0.281, ), shortDesc = """secondary amide correction for A (fragment 11)""", longDesc = """ """, ) entry( index = 33, label = "Cd(O2d)NH-arom", group = """ 1 * N3s u0 {2,S} {3,S} {4,S} 2 H u0 {1,S} 3 [Cb,N3b] u0 {1,S} 4 CO u0 {1,S} {5,D} 5 O2d u0 {4,D} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = -0.091, ), shortDesc = """aromatic amide correction for A (fragment 12)""", longDesc = """ """, ) entry( index = 34, label = "N3sHCd(O2d)N3sH", group = """ 1 * N3s u0 {2,S} {3,S} 2 H u0 {1,S} 3 CO u0 {1,S} {4,D} {5,S} 4 O2d u0 {3,D} 5 N3s u0 {3,S} {6,S} 6 H u0 {5,S} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = -0.0825, ), shortDesc = """urea correction for A (fragment 14)""", longDesc = """ """, ) entry( index = 35, label = "N3sCd(O2d)N3sH", group = """ 1 * N3s u0 {2,S} {3,S} {7,S} 2 R!H u0 {1,S} 3 CO u0 {1,S} {4,D} {5,S} 4 O2d u0 {3,D} 5 N3s u0 {3,S} {6,S} 6 H u0 {5,S} 7 R!H u0 {1,S} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = -0.119, ), shortDesc = """urea correction for A (fragment 15)""", longDesc = """ """, ) entry( index = 36, label = "CdsNdNsNs", group = """ 1 * Cd u0 {2,D} {3,S} {4,S} 2 N3d u0 {1,D} {5,S} 3 N3s u0 {1,S} {6,S} {7,S} 4 N3s u0 {1,S} {8,S} {9,S} 5 H u0 {2,S} 6 H u0 {3,S} 7 H u0 {3,S} 8 H u0 {4,S} 9 H u0 {4,S} """, solute = SoluteData( S = 0.0, B = 0.0, E = 0.0, L = 0.0, A = 0.17, ), shortDesc = """guanidine correction for A (fragment 17)""", longDesc = """ """, ) tree( """ L1: R L2: CO L3: Oss(CdsOd) L2: Cs(OssH)Cs(OssH) L2: CbCsOssH L2: OssH L2: phenol L2: OxRing L2: N3sH2-benz L2: N3sHCd(O2d)N3sH L2: Cd(O2d)NH2 L2: Cd(O2d)NHR L3: Cd(O2d)NH-arom L2: N3sCd(O2d)N3sH L2: CdsNdNsNs """ )
def permutations(arr): arr1 = arr.copy() print(" ".join(arr1), end=" ") count = len(arr1) for x in range(len(arr)): tmp = [] for i in arr: for k in arr1: if i not in k: tmp.append(k + i) count += 1 print(" ".join(tmp), end=" ") arr1 = tmp arr = input().split() permutations(arr)
#!/bin/pypy3 with open("be2.txt", "r") as f: #beolvasás seged=f.readlines() be=[] for sor in seged: #mátrixba szétszedés asor = sor.split("\n")[0] be.append(asor.split("\t")) sordiff=[] for i in range(len(be)): for j in range(len(be[i])): be[i][j]=int(be[i][j]) #konvertálás intre min=be[i][0] max=be[i][0] for j in range(1, len(be[i])): #minmax kiválasztás if be[i][j]<min: min=be[i][j] if be[i][j]>max: max=be[i][j] sordiff.append(max-min) print("sordiff elemszáma:", len(sordiff)) print(sum(sordiff))
class AvailableCashError(Exception): def __init__(self, available_amount, requested_amount): error_message = ( 'There is not enough available cash in the account. ' + 'Amount available is {available_amount}, amount requested is {requested_amount}. ' + '\nPlease add funds or reduce the requested amount.' ).format(available_amount=available_amount, requested_amount=requested_amount) super().__init__(error_message) class InvalidAmountError(Exception): def __init__(self, amount, denomination): error_message = ( 'The amount of {amount} is not in the denomination of {denomination}.' ).format(amount=amount, denomination=denomination) super().__init__(error_message) class UnevenDivisionError(Exception): def __init__(self, numerator, denominator): error_message = ( 'The provided amount of {numerator} is not evenly divisable by {denominator}' ).format(numerator=numerator, denominator=denominator) super().__init__(error_message) class AvailableLoansError(Exception): def __init__(self): error_message = ('There are no notes available that match the provided criteria. ' + ' Either specify an alternative filter, or wait until additional ' + ' notes have been listed on the market.') super().__init__(error_message)
# -------------- ##File path for the file file_path #Code starts here def read_file(path): f=open(path,'r') sentence=f.readline() f.close() return sentence sample_message=read_file(file_path) print(sample_message) # -------------- #Code starts here file_path_1 file_path_2 def fuse_msg(message_a,message_b): a=int(message_a) b=int(message_b) quotient=b // a return str(quotient) message_1=read_file(file_path_1) message_2=read_file(file_path_2) print(message_1) print(message_2) secret_msg_1=fuse_msg(message_1,message_2) print(secret_msg_1) # -------------- #Code starts here file_path_3 def substitute_msg(message_c): if message_c == 'Red': sub='Army General' elif message_c == 'Green': sub='Data Scientist' else: sub='Marine Biologist' return sub message_3 = read_file(file_path_3) print(message_3) secret_msg_2=substitute_msg(message_3) print(secret_msg_2) # -------------- # File path for message 4 and message 5 file_path_4 file_path_5 #Code starts here def compare_msg(message_d,message_e): a_list = message_d.split() b_list = message_e.split() c_list = [x for x in a_list if x not in b_list] final_msg = " ".join(c_list) return final_msg message_4=read_file(file_path_4) message_5=read_file(file_path_5) print(message_4) print(message_5) secret_msg_3=compare_msg(message_4,message_5) print(secret_msg_3) # -------------- #Code starts here file_path_6 def extract_msg(message_f): a_list = message_f.split() even_word = lambda x: len(x) % 2 == 0 b_list = filter(even_word,a_list) final_msg = " ".join(b_list) return final_msg message_6 = read_file(file_path_6) print(message_6) secret_msg_4 = extract_msg(message_6) print(secret_msg_4) # -------------- #Secret message parts in the correct order message_parts=[secret_msg_3, secret_msg_1, secret_msg_4, secret_msg_2] final_path= user_data_dir + '/secret_message.txt' #Code starts here def write_file(secret_msg,path): fopen = open(path,'a+') fopen.write(secret_msg) fopen.close() secret_msg = " ".join(message_parts) print(secret_msg) write_file(secret_msg,final_path)
# # Copyright SAS Institute # # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # class SASConfigNotFoundError(Exception): def __init__(self, path: str): self.path = path def __str__(self): return 'Configuration path {} does not exist.'.format(self.path) class SASConfigNotValidError(Exception): def __init__(self, defn: str, msg: str=None): self.defn = defn if defn else 'N/A' self.msg = msg def __str__(self): return 'Configuration definition {} is not valid. {}'.format(self.defn, self.msg) class SASIONotSupportedError(Exception): def __init__(self, method: str, alts: list=None): self.method = method self.alts = alts def __str__(self): if self.alts is not None: alt_text = 'Try the following: {}'.format(', '.join(self.alts)) else: alt_text = '' return 'Cannot use {} I/O module on Windows. {}'.format(self.method, alt_text) class SASHTTPauthenticateError(Exception): def __init__(self, msg: str): self.msg = msg def __str__(self): return 'Failure in GET AuthToken.\n {}'.format(self.msg) class SASHTTPconnectionError(Exception): def __init__(self, msg: str): self.msg = msg def __str__(self): return 'Failure in GET Connection.\n {}'.format(self.msg) class SASHTTPsubmissionError(Exception): def __init__(self, msg: str): self.msg = msg def __str__(self): return 'Failure in submit().\n {}'.format(self.msg)
#!/usr/bin/env python # -*- coding: utf-8 -*- # ## Onera M6 configuration module for geoGen # # Adrien Crovato def getParams(): p = {} # Wing parameters (nP planforms for half-wing) p['airfPath'] = '../airfoils' # path pointing the airfoils directory (relative to this config file) p['airfName'] = ['oneraM6.dat', 'oneraM6.dat'] # names of file containing airfoil (Selig formatted) data (size: nP+1) p['span'] = [1.196] # span of each planform (size: nP) p['taper'] = [0.562] # taper of each planform (size: nP) p['sweep'] = [30] # leading edge sweep of each planform (size: nP) p['dihedral'] = [0] # dihedral angle of each planform (size: nP) p['twist'] = [0, 0] # twist angle of each airfoil (size: nP+1) p['rootChord'] = 0.8059 # root chord p['offset'] = [0., 0.] # x and z offset at the leading edge root p['coWingtip'] = True # cut-off wingtip (not supported yet) # Sphere p['domType'] = 'sphere' # domain type ('sphere' or 'box') p['rSphere'] = 50*p['rootChord'] return p
# A function is a block of organized, reusable code that is used to perform a single, related action. # Define a function. def fun(): print("What's a Funtion ?") # Functions with Arguments. def funArg(arg1,arg2): print(arg1," ",arg2) # return(arg1," ",arg2) #Functions that returns a value def funX(a): return a+a # Calling the Function. fun() funArg(50,50) print(funArg(50,50)) print(funX(50))
# TASK 1 # Write a function called oops that explicitly raises an IndexError exception when called. # Then write another function that calls oops inside a try/except state­ment to catch the error. # What happens if you change oops to raise KeyError instead of IndexError? def oops(): raise IndexError try: IndexError except: print("This is an IndexError") def oops1(): pass try: def oops(): raise IndexError except: print("Oopsi daisy") ########## With Key error########## def oops(): raise KeyError try: KeyError except: print("This is an KeyError") def oops1(): pass try: def oops(): raise KeyError except: print("Oopsi daisy") # TASK 2 # Write a function that takes in two numbers from the user via input(), # call the numbers a and b, and then returns the value of squared a divided by b, # construct a try-except block which raises an exception if the two values given by the input function were not numbers, # and if value b was zero (cannot divide by zero). def TwoNumbers(a, b): return # Hi. You just need to name function arguments as a and b and do math operation on them. a = [] b =[] c = a + b [c*c / b]
""" Contains choice collections for model fields. Add choices here instead of writing them in models.py. """ # Menu Item MENU_ITEM_CHOICES = (("VEGETARIAN", "Vegetarian"), ("ALL", "All")) MENU_ITEM_CATEGORY = ( ("CHINESE", "Chinese Food"), ("SOUTH INDIAN", "South Indian Food"), ("FAST FOOD", "Fast Food"), ("DRINKS", "Drinks"), ("ITALIAN", "Italian"), ) # Order.payment_mode PAYMENT_MODE_CHOICES = ( ("ONLINE", "Online Payment Gateway"), ("COD", "Cash on Counter/ Delivery"), ) # Order.status # Dictionary for easy editing or access. STATUS_DICTIONARY = { "Not picked up": -3, "Rejected by Canteen": -2, "Cancelled by User": -1, "New": 0, "Preparing": 1, "Prepared": 2, "En-route": 3, } # Create a reversed dictionary from the above STATUS_DICTIONARY_REVERSE = dict( zip(STATUS_DICTIONARY.values(), STATUS_DICTIONARY.keys()) ) # Create a reversed choices list from the above dictionary for Order.status STATUS_CHOICES = tuple(STATUS_DICTIONARY_REVERSE.items())
# Frames Per Second FPS = 60 # SCREEN SCREEN_COLUMNS_NUMBER = 6 SCREEN_ROWS_NUMBER = 7 SCREEN_COLUMN_SIZE = 96 SCREEN_ROW_SIZE = 96 SCREEN_WIDTH = SCREEN_COLUMNS_NUMBER * SCREEN_COLUMN_SIZE SCREEN_HEIGHT = SCREEN_ROWS_NUMBER * SCREEN_ROW_SIZE # Colors for display. COLOR_WHITE = (255, 255, 255) COLOR_BLACK = (0, 0, 0) COLOR_GREEN = (0, 128, 0) COLOR_BLUE = (0, 0, 128) COLOR_RED = (255, 0, 0) COLOR_GRAY = (224, 224, 224) COLOR_BROWN = (160, 82, 45) PLAYER_INDEX = 21 BOTS_MAX_4ROWS = 5 BOTS_MAX_ALL_ROAD = 10 COUNT_LOCK = 10
número = int(input('Digite um número qualquer: ')) if número % 2 == 0: print('O número {} é PAR'.format(número)) else: print('O número {} é ÍMPAR'.format(número))
def deny(blacklist): """ Decorates a handler to filter out a blacklist of commands. The decorated handler will not be called if message.command is in the blacklist: @deny(['A', 'B']) def handle_everything_except_a_and_b(client, message): pass Single-item blacklists may be passed as a string: @deny('THIS') def handle_everything_except_this(client, message): pass """ blacklist = [blacklist] if isinstance(blacklist, str) else blacklist def inner_decorator(handler): def wrapped(client, message): if message.command not in blacklist: handler(client=client, message=message) return wrapped return inner_decorator def allow(whitelist): """ Decorates a handler to filter all except a whitelist of commands The decorated handler will only be called if message.command is in the whitelist: @allow(['A', 'B']) def handle_only_a_and_b(client, message): pass Single-item whitelists may be passed as a string: @allow('THIS') def handle_only_this(client, message): pass """ whitelist = [whitelist] if isinstance(whitelist, str) else whitelist def inner_decorator(handler): def wrapped(client, message): if message.command in whitelist: handler(client=client, message=message) return wrapped return inner_decorator
class Linked_List(): def __init__(self, head): self.head = head class Node(): def __init__(self, data): self.data = data self.next = None # O(N) space and O(N) time def partition_linked_list(linked_list, partition): less_than = [] greater_than_or_equal = [] next_one = linked_list.head while next_one is not None: if next_one.data < partition: less_than.append(next_one.data) else: greater_than_or_equal.append(next_one.data) next_one = next_one.next next_one = linked_list.head while next_one is not None: if len(less_than) > 0: next_one.data = less_than.pop() else: next_one.data = greater_than_or_equal.pop() next_one = next_one.next return linked_list
# -*- coding: utf-8 -*- # See LICENSE file for full copyright and licensing details. { 'name': 'Library Management system odoo', 'version': "10.0.1.0.6", 'author': "David Kimolo", 'category': 'School Management', 'website': '', 'license': "AGPL-3", 'summary': """A Module For Library Management For School Library Management Library School Library Books """, 'complexity': 'easy', 'depends': ['report_intrastat', 'school', 'stock', 'account_accountant', 'product'], 'data': ['security/library_security.xml', 'security/ir.model.access.csv', 'views/report_view.xml', 'views/qrcode_label.xml', 'views/library_data.xml', 'views/library_view.xml', 'views/library_sequence.xml', 'views/library_category_data.xml', 'data/library_card_schedular.xml', 'wizard/update_prices_view.xml', 'wizard/update_book_view.xml', 'wizard/book_issue_no_view.xml', 'wizard/card_no_view.xml'], 'demo': ['demo/library_demo.xml'], 'image': ['static/description/SchoolLibrary.png'], 'installable': True, 'application': True }
""" 回溯算法,会提示超时因为时间复杂度为2的N次方 class Solution: def climbStairs(self, n: int) -> int: return self.go(n,0) def go(self,n,cur) -> int: if cur == n: return 1 if cur > n: return 0 return self.go(n,cur + 1) + self.go(n,cur + 2) """ """ 从起点递推到终点 """ class Solution: def climbStairs(self, n: int) -> int: if n <= 1: return n res = 2 pre = 1 for _ in range(3,n+1): res,pre = res + pre,res return res
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # External libraries # Markdown 'markdownx', # Bootstrap 'bootstrap4', # Our apps 'apps.blocks', 'apps.bot', 'apps.custom_admin', 'apps.lp', 'apps.results', 'apps.services', 'apps.tags', 'apps.quiz', 'apps.lms', 'apps.social', 'apps.users', 'apps.course', 'apps.lesson', ]
#!/usr/bin/python # Copyright (c) 2010 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """PyAuto Errors.""" class JSONInterfaceError(RuntimeError): """Represent an error in the JSON ipc interface.""" pass class NTPThumbnailNotShownError(RuntimeError): """Represent an error from attempting to manipulate a NTP thumbnail that is not visible to a real user.""" pass
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ************************************************ @Time : 2019-06-13 01:11 @Author : zxp @Project : AlgorithmAndDataStructure @File : IgnoreErroAndNotRelative.py @Description: ================================== 忽略错误文件,忽略没有对应Gt的图像,转而读取下一行 @license: (C) Copyright 2013-2019. ************************************************ """
class Sorting: @staticmethod def insertion_sort(arr): for i in range(1, len(arr)): curr = arr[i] j = i - 1 while j >= 0 and curr < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = curr return arr if __name__ == "__main__": obj = Sorting() print(obj.insertion_sort([3, 2, 5, 7, 6]))
# coding: utf-8 # (C) Copyright IBM Corp. 2018, 2019. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class SynthesizeCallback(object): def __init__(self): pass def on_connected(self): """ Called when a Websocket connection was made """ def on_error(self, error): """ Called when there is an error in the Websocket connection. """ def on_content_type(self, content_type): """ Called when the service responds with the format of the audio response """ def on_timing_information(self, timing_information): """ Called when the service returns timing information """ def on_audio_stream(self, audio_stream): """ Called when the service sends the synthesized audio as a binary stream of data in the indicated format. """ def on_data(self, data): """ Called when the service returns results. The data is returned unparsed. """ def on_close(self): """ Called when the Websocket connection is closed """
HERO = {'B': 'Batman', 'J': 'Joker', 'R': 'Robin'} OUTPUT = '{}: {}'.format class BatmanQuotes(object): @staticmethod def get_quote(quotes, hero): for i, a in enumerate(hero): if i == 0: hero = HERO[a] elif a.isdigit(): quotes = quotes[int(a)] break return OUTPUT(hero, quotes)
numBlanks = 0 golden = ["Emptiness", "fear", "mountain"] newLines = [] with open('fill-blanks.txt', 'r') as f: for line in f: if '...' in line: blank = input("Fill the blank in " + line) if blank == golden[numBlanks]: newLine = line.replace("...", blank) else: newLine = line numBlanks += 1 else: newLine = line newLines.append(newLine) print(newLines)
""" 6974. Long Division 작성자: xCrypt0r 언어: Python 3 사용 메모리: 29,088 KB 소요 시간: 72 ms 해결 날짜: 2020년 11월 26일 """ def main(): n = int(input()) for _ in range(n): a, b = map(int, [input(), input()]) print(a // b) print(a % b) print() if __name__ == '__main__': main()
print('-' * 30) print('GERADOR DE TABUADA COM WHILE') print('-' * 30, '\n') cont = 0 while True: tabuada = int(input('Digite um número: ')) if tabuada < 0: break while cont <= 10: print(f'{tabuada} x {cont} = {tabuada * cont}') cont += 1 cont = 0 print('-' * 30) print('Obrigado por utilizar o Gerador de Tabuadas. ' '\n\033[42mVolte Sempre!\033[m')
array = [116, 176382, 94, 325, 3476, 4, 2542, 9, 21, 56, 322, 322] print(array) SENTINEL = 10**12 def merge(array, left, mid, right): L = array[left:mid] R = array[mid:right] L.append(SENTINEL) R.append(SENTINEL) i = j = 0 for k in range(left, right): if L[i] <= R[j]: array[k] = L[i] i += 1 else: array[k] = R[j] j += 1 def mergeSort(array, left, right): if (left + 1 < right): mid = (left + right) // 2 mergeSort(array, left, mid) mergeSort(array, mid, right) merge(array, left, mid, right) mergeSort(array, 0, len(array)) print(array)
ACTIONS = ["Attribution", "CommericalUse", "DerivativeWorks", "Distribution", "Notice", "Reproduction", "ShareAlike", "Sharing", "SourceCode", "acceptTracking", "adHocShare", "aggregate", "annotate", "anonymize", "append", "appendTo", "archive", "attachPolicy", "attachSource", "attribute", "commercialize", "compensate", "concurrentUse", "copy", "delete", "derive", "digitize", "display", "distribute", "ensureExclusivity", "execute", "export", "extract", "extractChar", "extractPage", "extractWord", "give", "grantUse", "include", "index", "inform", "install", "lease", "lend", "license", "modify", "move", "nextPolicy", "obtainConsent", "pay", "play", "present", "preview", "print", "read", "reproduce", "reviewPolicy", "secondaryUse", "sell", "share", "stream", "synchronize", "textToSpeech", "transfer", "transform", "translate", "uninstall", "use", "watermark", "write", "writeTo"] ATTRIBUTION = "Attribution" COMMERCIALUSE = "CommericalUse" DERIVATIVE_WORKS = "DerivativeWorks" DISTRIBUTION = "Distribution" NOTICE = "Notice" REPRODUCTION = "Reproduction" SHARE_ALIKE = "ShareAlike" SHARING = "Sharing" SOURCECODE = "SourceCode" ACCEPTTRACKING = "acceptTracking" AGGREGATE = "aggregate" ANNOTATE = "annotate" ANONYMIZE = "anonymize" ARCHIVE = "archive" ATTRIBUTE = "attribute" COMPENSATE = "compensate" CONCURRENTUSE = "concurrentUse" DELETE = "delete" DERIVE = "derive" DIGITIZE = "digitize" DISPLAY = "display" DISTRIBUTE = "distribute" ENSUREEXCLUSIVITY = "ensureExclusivity" EXECUTE = "execute" EXTRACT = "extract" GIVE = "give" GRANTUSE = "grantUse" INCLUDE = "include" INDEX = "index" INFORM = "inform" INSTALL = "install" MODIFY = "modify" MOVE = "move" NEXTPOLICY = "nextPolicy" OBTAINCONSENT = "obtainConsent" PLAY = "play" PRESENT = "present" PRINT = "print" READ = "read" REPRODUCE = "reproduce" REVIEWPOLICY = "reviewPolicy" SELL = "sell" STREAM = "stream" SYNCHRONIZE = "synchronize" TEXTTOSPEECH = "textToSpeech" TRANSFER = "transfer" TRANSFORM = "transform" TRANSLATE = "translate" UNINSTALL = "uninstall" WATERMARK = "watermark" USE = "use" ARBRE_DERIVE = { DERIVE: { PRINT: {}, PLAY: { DISPLAY: {} } } } ARBRE = { USE: { REPRODUCE: { REPRODUCTION: { CONCURRENTUSE: {}, DIGITIZE: {} } }, MOVE: { DELETE: {} }, SHARING: { DERIVE: { PRINT: {}, PLAY: { DISPLAY: {} } } }, DERIVATIVE_WORKS: { DERIVE: { PRINT: {}, PLAY: { DISPLAY: {} } }, SHARE_ALIKE: {} }, DISTRIBUTION: { DISTRIBUTE: {}, PRESENT: {}, STREAM: {}, TEXTTOSPEECH: {} }, MODIFY: { ANONYMIZE: {}, TRANSFORM: {} }, COMMERCIALUSE: {}, NOTICE: {}, SOURCECODE: {}, ACCEPTTRACKING: {}, AGGREGATE: {}, ANNOTATE: {}, ARCHIVE: {}, ATTRIBUTE: {}, ATTRIBUTION: {}, COMPENSATE: {}, ENSUREEXCLUSIVITY: {}, EXECUTE: {}, EXTRACT: {}, GRANTUSE: {}, INCLUDE: {}, INDEX: {}, INFORM: {}, INSTALL: {}, NEXTPOLICY: {}, OBTAINCONSENT: {}, READ: {}, REVIEWPOLICY: {}, SYNCHRONIZE: {}, TRANSFORM: {}, TRANSLATE: {}, UNINSTALL: {}, WATERMARK: {}, TRANSFER: { GIVE: {}, SELL: {} } } }
_base_ = [ '../_base_/models/regnet/regnetx_400mf.py', '../_base_/datasets/imagenet_bs32.py', '../_base_/schedules/imagenet_bs1024_coslr.py', '../_base_/default_runtime.py' ] # Precise BN hook will update the bn stats, so this hook should be executed # before CheckpointHook, which has priority of 'NORMAL'. So set the # priority of PreciseBNHook to 'ABOVE_NORMAL' here. custom_hooks = [ dict( type='PreciseBNHook', num_samples=8192, interval=1, priority='ABOVE_NORMAL') ] # sgd with nesterov, base ls is 0.8 for batch_size 1024, # 0.4 for batch_size 512 and 0.2 for batch_size 256 when training ImageNet1k optimizer = dict(lr=0.8, nesterov=True) # dataset settings dataset_type = 'ImageNet' # normalization params, in order of BGR NORM_MEAN = [103.53, 116.28, 123.675] NORM_STD = [57.375, 57.12, 58.395] # lighting params, in order of RGB, from repo. pycls EIGVAL = [0.2175, 0.0188, 0.0045] EIGVEC = [[-0.5675, 0.7192, 0.4009], [-0.5808, -0.0045, -0.814], [-0.5836, -0.6948, 0.4203]] train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='RandomResizedCrop', size=224), dict(type='RandomFlip', flip_prob=0.5, direction='horizontal'), dict( type='Lighting', eigval=EIGVAL, eigvec=EIGVEC, alphastd=25.5, # because the value range of images is [0,255] to_rgb=True ), # BGR image from cv2 in LoadImageFromFile, convert to RGB here dict(type='Normalize', mean=NORM_MEAN, std=NORM_STD, to_rgb=True), # RGB2BGR dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ] test_pipeline = [ dict(type='LoadImageFromFile'), dict(type='Resize', size=(256, -1)), dict(type='CenterCrop', crop_size=224), dict(type='Normalize', mean=NORM_MEAN, std=NORM_STD, to_rgb=False), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']) ] data = dict( samples_per_gpu=128, workers_per_gpu=8, train=dict( type=dataset_type, data_prefix='data/imagenet/train', pipeline=train_pipeline), val=dict( type=dataset_type, data_prefix='data/imagenet/val', ann_file='data/imagenet/meta/val.txt', pipeline=test_pipeline), test=dict( # replace `data/val` with `data/test` for standard test type=dataset_type, data_prefix='data/imagenet/val', ann_file='data/imagenet/meta/val.txt', pipeline=test_pipeline))
cars = ['audi', 'bmw', 'subaru', 'toyoto'] #使用if判断 for car in cars: if car == 'bmw': print(car.upper()) else: print(car) #多个判断条件 if xx ==xx and xx == xx #只有要一个满足使用 if xx ==xx or xx == xx #检查特定值是否包含在列表中 in 'xx' in xxList #检查特定值是否不包含在列表中 not in | if user not in bannedUsers car = 'subaru' print("Is car == 'subaru'? I predict Ture.") print(car == 'audi') #if的写法 if 1 == 1 : print("1=1") else: print("budengyu") #还可以写成 if-elif-else结构 if 1 == 1: print("1=1") elif 2 ==2: print("2 = 2") else: print("都不等于") #多个elif if-elif-elif-elif-else if 1 == 1: print("1=1") elif 2 ==2: print("2 = 2") elif 3 ==3: print("3 = 3") elif 4 ==4: print("4 = 4") else: print("都不等于") #省略else if 1 == 1: print("1=1") elif 2 ==2: print("2 = 2")
########################################################################### # # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ########################################################################### conversionStatus_Schema = [[{ 'name': 'childDirectedTreatment', 'type': 'BOOLEAN', 'mode': 'NULLABLE' }, { 'name': 'customVariables', 'type': 'RECORD', 'mode': 'REPEATED', 'fields': [{ 'description': '', 'name': 'kind', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': 'U1, U10, U100, U11, U12, U13, U14, U15, U16, U17, U18, U19, U2, ' 'U20, U21, U22, U23, U24, U25, U26, U27, U28, U29, U3, U30, U31, ' 'U32, U33, U34, U35, U36, U37, U38, U39, U4, U40, U41, U42, U43, ' 'U44, U45, U46, U47, U48, U49, U5, U50, U51, U52, U53, U54, U55, ' 'U56, U57, U58, U59, U6, U60, U61, U62, U63, U64, U65, U66, U67, ' 'U68, U69, U7, U70, U71, U72, U73, U74, U75, U76, U77, U78, U79, ' 'U8, U80, U81, U82, U83, U84, U85, U86, U87, U88, U89, U9, U90, ' 'U91, U92, U93, U94, U95, U96, U97, U98, U99', 'name': 'type', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'value', 'type': 'STRING', 'mode': 'NULLABLE' }] }, { 'description': '', 'name': 'encryptedUserId', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'name': 'encryptedUserIdCandidates', 'type': 'STRING', 'mode': 'REPEATED' }, { 'description': '', 'name': 'floodlightActivityId', 'type': 'INT64', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'floodlightConfigurationId', 'type': 'INT64', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'gclid', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'kind', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'name': 'limitAdTracking', 'type': 'BOOLEAN', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'mobileDeviceId', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'name': 'nonPersonalizedAd', 'type': 'BOOLEAN', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'ordinal', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'quantity', 'type': 'INT64', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'timestampMicros', 'type': 'INT64', 'mode': 'NULLABLE' }, { 'name': 'treatmentForUnderage', 'type': 'BOOLEAN', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'value', 'type': 'FLOAT64', 'mode': 'NULLABLE' }], { 'name': 'errors', 'type': 'RECORD', 'mode': 'REPEATED', 'fields': [{ 'description': 'INTERNAL, INVALID_ARGUMENT, NOT_FOUND, PERMISSION_DENIED', 'name': 'code', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'kind', 'type': 'STRING', 'mode': 'NULLABLE' }, { 'description': '', 'name': 'message', 'type': 'STRING', 'mode': 'NULLABLE' }] }, { 'description': '', 'name': 'kind', 'type': 'STRING', 'mode': 'NULLABLE' }]
with open("input") as file: lines = [line.split(" ") for line in file.read().strip().split("\n")] register_names = set([line[0] for line in lines]) registers = {} for name in register_names: registers[name] = 0 operations = { "dec": lambda r,v: r-v, "inc": lambda r,v: r+v } comparisons = { ">": lambda a,b: a > b, ">=": lambda a,b: a >= b, "<": lambda a,b: a < b, "<=": lambda a,b: a <= b, "==": lambda a,b: a == b, "!=": lambda a,b: a != b } for line in lines: if comparisons[line[5]](registers[line[4]],int(line[6])): registers[line[0]] = operations[line[1]](registers[line[0]],int(line[2])) print(max(registers.values()))
# Source: https://github.com/kenshohara/3D-ResNets-PyTorch/blob/master/mean.py def get_mean(norm_value=255, dataset='activitynet'): # Below values are in RGB order assert dataset in ['activitynet', 'kinetics', 'ucf101'] if dataset == 'activitynet': return [114.7748/norm_value, 107.7354/norm_value, 99.4750/norm_value] elif dataset == 'kinetics': # Kinetics (10 videos for each class) return [110.63666788/norm_value, 103.16065604/norm_value, 96.29023126/norm_value] elif dataset == 'ucf101': return [101.00131/norm_value, 97.3644226/norm_value, 89.42114168/norm_value] def get_std(norm_value=255): # Kinetics (10 videos for each class) return [38.7568578/norm_value, 37.88248729/norm_value, 40.02898126/norm_value]
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"say_hello": "00_core.ipynb", "say_bye": "00_core.ipynb", "optimize_bayes_param": "01_bayes_opt.ipynb", "ReadTabBatchIdentity": "02_tab_ae.ipynb", "TabularPandasIdentity": "02_tab_ae.ipynb", "TabDataLoaderIdentity": "02_tab_ae.ipynb", "RecreatedLoss": "02_tab_ae.ipynb", "BatchSwapNoise": "02_tab_ae.ipynb", "TabularAE": "02_tab_ae.ipynb", "HyperparamsGenerator": "03_param_finetune.ipynb", "XgboostParamGenerator": "03_param_finetune.ipynb", "LgbmParamGenerator": "03_param_finetune.ipynb", "CatParamGenerator": "03_param_finetune.ipynb", "RFParamGenerator": "03_param_finetune.ipynb", "ModelIterator": "04_model_zoo.ipynb"} modules = ["core.py", "bayes_opt.py", "tab_ae.py", "params.py", "model_iterator.py"] doc_url = "https://DavidykZhao.github.io/Yikai_helper_funcs/" git_url = "https://github.com/DavidykZhao/Yikai_helper_funcs/tree/master/" def custom_doc_links(name): return None
C = "C" CPP = "Cpp" CSHARP = "CSharp" GO = "Go" JAVA = "Java" JAVASCRIPT = "JavaScript" OBJC = "ObjC" PYTHON = "Python" # synonym for PYTHON3 PYTHON2 = "Python2" PYTHON3 = "Python3" RUST = "Rust" SWIFT = "Swift" def supported(): """Returns the supported languages. Returns: the list of supported languages. """ return [C, CPP, GO, JAVA, OBJC, PYTHON, PYTHON2, PYTHON3]
class Student: # Konstruktor może przyjąć argumenty def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name self.promoted = False student = Student() # Obiekty możemy przekazywać jako argumenty do funkcji def print_student(student): print(f"Student: {student.first_name} {student.last_name}, promoted: {student.promoted}") # W funkcji możemy zmodyfikować stan obiektu (side effect) def promote_student(student): student.promoted = True def run_example(): student = Student(first_name="Ola", last_name="Nowak") print_student(student) other_student = Student("Jerzy", "Jurkowski") print_student(other_student) promote_student(student) print_student(student) if __name__ == '__main__': run_example()
""" Build rule for open source tf.text libraries. """ def py_tf_text_library( name, srcs = [], deps = [], visibility = None, cc_op_defs = [], cc_op_kernels = []): """Creates build rules for TF.Text ops as shared libraries. Defines three targets: <name> Python library that exposes all ops defined in `cc_op_defs` and `py_srcs`. <name>_cc C++ library that registers any c++ ops in `cc_op_defs`, and includes the kernels from `cc_op_kernels`. python/ops/_<name>.so Shared library exposing the <name>_cc library. Args: name: The name for the python library target build by this rule. srcs: Python source files for the Python library. deps: Dependencies for the Python library. visibility: Visibility for the Python library. cc_op_defs: A list of c++ src files containing REGISTER_OP definitions. cc_op_kernels: A list of c++ targets containing kernels that are used by the Python library. """ binary_path = "python/ops" if srcs: binary_path_end_pos = srcs[0].rfind("/") binary_path = srcs[0][0:binary_path_end_pos] binary_name = binary_path + "/_" + cc_op_kernels[0][1:] + ".so" if cc_op_defs: binary_name = binary_path + "/_" + name + ".so" library_name = name + "_cc" native.cc_library( name = library_name, srcs = cc_op_defs, copts = select({ # Android supports pthread natively, -pthread is not needed. "@org_tensorflow//tensorflow:mobile": [], "//conditions:default": ["-pthread"], }), alwayslink = 1, deps = cc_op_kernels + select({ "@org_tensorflow//tensorflow:mobile": [ "@org_tensorflow//tensorflow/core:portable_tensorflow_lib_lite", ], "//conditions:default": [], }), ) native.cc_binary( name = binary_name, copts = select({ "@org_tensorflow//tensorflow:mobile": [], "//conditions:default": ["-pthread"], }), linkshared = 1, deps = [ ":" + library_name, ] + select({ "@org_tensorflow//tensorflow:mobile": [ "@org_tensorflow//tensorflow/core:portable_tensorflow_lib_lite", ], "//conditions:default": [], }), ) if srcs: native.py_library( name = name, srcs = srcs, srcs_version = "PY2AND3", visibility = visibility, data = [":" + binary_name], deps = deps, ) def tf_cc_library( name, srcs = [], hdrs = [], deps = [], tf_deps = [], copts = [], compatible_with = None, testonly = 0, alwayslink = 0): """ A rule to build a TensorFlow library or OpKernel. Just like cc_library, but: * Adds alwayslink=1 for kernels (name has kernel in it) * Separates out TF deps for when building for Android. Args: name: Name of library srcs: Source files hdrs: Headers files deps: All non-TF dependencies tf_deps: All TF depenedencies copts: C options compatible_with: List of environments target can be built for testonly: If library is only for testing alwayslink: If symbols should be exported """ if "kernel" in name: alwayslink = 1 # These are "random" deps likely needed by each library (http://b/142433427) oss_deps = [ "@com_google_absl//absl/strings:cord", ] deps += select({ "@org_tensorflow//tensorflow:mobile": [ "@org_tensorflow//tensorflow/core:portable_tensorflow_lib_lite", ], "//conditions:default": [ "@local_config_tf//:libtensorflow_framework", "@local_config_tf//:tf_header_lib", ] + tf_deps + oss_deps, }) native.cc_library( name = name, srcs = srcs, hdrs = hdrs, deps = deps, copts = copts, compatible_with = compatible_with, testonly = testonly, alwayslink = alwayslink)
# Sander Viirmaa # 19.12.2018 # Ülesanne 08 - 02 class auto: mark = ' ' aasta = 0 hind = 0 värv = ' ' kiirus = 0 def __init__(self, x, y, z, q, w): self.mark = x self.aasta = y self.hind = z self.kiirus = q self.varv = w def lisaMark(self, x): self.mark = x def lisaAasta(self, x): self.aasta = x def lisaVarv(self, x): self.varv = x def lisaKiirus(self, x): self.kiirus = x def kuva(self): print( '\nMark: {0}\nAasta: {1}\nHind: {2}\nVärvus: {3}\nTippkiirus: {4}'. format(self.mark, self.aasta, self.hind, self.varv, self.kiirus)) liikur = auto('Audi', 1988, 600, 180, 'Kirss Punane') liikur.kuva() liikur2 = auto('Mercedes-Benz', 1980, 2400, 140, 'Sinine') liikur2.kuva()
list_of_numbers_as_strings = input().split(", ") for index in range(len(list_of_numbers_as_strings)): number = int(list_of_numbers_as_strings[index]) if number == 0: list_of_numbers_as_strings.remove(str(0)) list_of_numbers_as_strings.append(str(0)) print(list_of_numbers_as_strings)
## # Copyright (c) 2006-2018 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ## """ PyKerberos Function Description. """ class KrbError(Exception): pass class BasicAuthError(KrbError): pass class GSSError(KrbError): pass def checkPassword(user, pswd, service, default_realm): """ This function provides a simple way to verify that a user name and password match those normally used for Kerberos authentication. It does this by checking that the supplied user name and password can be used to get a ticket for the supplied service. If the user name does not contain a realm, then the default realm supplied is used. For this to work properly the Kerberos must be configured properly on this machine. That will likely mean ensuring that the edu.mit.Kerberos preference file has the correct realms and KDCs listed. IMPORTANT: This method is vulnerable to KDC spoofing attacks and it should only used for testing. Do not use this in any production system - your security could be compromised if you do. @param user: A string containing the Kerberos user name. A realm may be included by appending an C{"@"} followed by the realm string to the actual user id. If no realm is supplied, then the realm set in the default_realm argument will be used. @param pswd: A string containing the password for the user. @param service: A string containing the Kerberos service to check access for. This will be of the form C{"sss/xx.yy.zz"}, where C{"sss"} is the service identifier (e.g., C{"http"}, C{"krbtgt"}), and C{"xx.yy.zz"} is the hostname of the server. @param default_realm: A string containing the default realm to use if one is not supplied in the user argument. Note that Kerberos realms are normally all uppercase (e.g., C{"EXAMPLE.COM"}). @return: True if authentication succeeds, false otherwise. """ def changePassword(user, oldpswd, newpswd): """ This function allows to change the user password on the KDC. @param user: A string containing the Kerberos user name. A realm may be included by appending a C{"@"} followed by the realm string to the actual user id. If no realm is supplied, then the realm set in the default_realm argument will be used. @param oldpswd: A string containing the old (current) password for the user. @param newpswd: A string containing the new password for the user. @return: True if password changing succeeds, false otherwise. """ def getServerPrincipalDetails(service, hostname): """ This function returns the service principal for the server given a service type and hostname. Details are looked up via the C{/etc/keytab} file. @param service: A string containing the Kerberos service type for the server. @param hostname: A string containing the hostname of the server. @return: A string containing the service principal. """ """ GSSAPI Function Result Codes: -1 : Error 0 : GSSAPI step continuation (only returned by 'Step' function) 1 : GSSAPI step complete, or function return OK """ # Some useful result codes AUTH_GSS_CONTINUE = 0 AUTH_GSS_COMPLETE = 1 # Some useful gss flags GSS_C_DELEG_FLAG = 1 GSS_C_MUTUAL_FLAG = 2 GSS_C_REPLAY_FLAG = 4 GSS_C_SEQUENCE_FLAG = 8 GSS_C_CONF_FLAG = 16 GSS_C_INTEG_FLAG = 32 GSS_C_ANON_FLAG = 64 GSS_C_PROT_READY_FLAG = 128 GSS_C_TRANS_FLAG = 256 def authGSSClientInit(service, **kwargs): """ Initializes a context for GSSAPI client-side authentication with the given service principal. L{authGSSClientClean} must be called after this function returns an OK result to dispose of the context once all GSSAPI operations are complete. @param service: A string containing the service principal in the form C{"type@fqdn"}. @param principal: Optional string containing the client principal in the form C{"user@realm"}. @param gssflags: Optional integer used to set GSS flags. (e.g. C{GSS_C_DELEG_FLAG|GSS_C_MUTUAL_FLAG|GSS_C_SEQUENCE_FLAG} will allow for forwarding credentials to the remote host) @param delegated: Optional server context containing delegated credentials @param mech_oid: Optional GGS mech OID @return: A tuple of (result, context) where result is the result code (see above) and context is an opaque value that will need to be passed to subsequent functions. """ def authGSSClientClean(context): """ Destroys the context for GSSAPI client-side authentication. This function is provided for compatibility with earlier versions of PyKerberos but does nothing. The context object destroys itself when it is reclaimed. @param context: The context object returned from L{authGSSClientInit}. @return: A result code (see above). """ def authGSSClientInquireCred(context): """ Get the current user name, if any, without a client-side GSSAPI step. If the principal has already been authenticated via completed client-side GSSAPI steps then the user name of the authenticated principal is kept. The user name will be available via authGSSClientUserName. @param context: The context object returned from L{authGSSClientInit}. @return: A result code (see above). """ """ Address Types for Channel Bindings https://docs.oracle.com/cd/E19455-01/806-3814/6jcugr7dp/index.html#reference-9 """ GSS_C_AF_UNSPEC = 0 GSS_C_AF_LOCAL = 1 GSS_C_AF_INET = 2 GSS_C_AF_IMPLINK = 3 GSS_C_AF_PUP = 4 GSS_C_AF_CHAOS = 5 GSS_C_AF_NS = 6 GSS_C_AF_NBS = 7 GSS_C_AF_ECMA = 8 GSS_C_AF_DATAKIT = 9 GSS_C_AF_CCITT = 10 GSS_C_AF_SNA = 11 GSS_C_AF_DECnet = 12 GSS_C_AF_DLI = 13 GSS_C_AF_LAT = 14 GSS_C_AF_HYLINK = 15 GSS_C_AF_APPLETALK = 16 GSS_C_AF_BSC = 17 GSS_C_AF_DSS = 18 GSS_C_AF_OSI = 19 GSS_C_AF_X25 = 21 GSS_C_AF_NULLADDR = 255 def channelBindings(**kwargs): """ Builds a gss_channel_bindings_struct which can be used to pass onto L{authGSSClientStep} to bind onto the auth. Details on Channel Bindings can be foud at https://tools.ietf.org/html/rfc5929. More details on the struct can be found at https://docs.oracle.com/cd/E19455-01/806-3814/overview-52/index.html @param initiator_addrtype: Optional integer used to set the initiator_addrtype, defaults to GSS_C_AF_UNSPEC if not set @param initiator_address: Optional byte string containing the initiator_address @param acceptor_addrtype: Optional integer used to set the acceptor_addrtype, defaults to GSS_C_AF_UNSPEC if not set @param acceptor_address: Optional byte string containing the acceptor_address @param application_data: Optional byte string containing the application_data. An example would be 'tls-server-end-point:{cert-hash}' where {cert-hash} is the hash of the server's certificate @return: A tuple of (result, gss_channel_bindings_struct) where result is the result code and gss_channel_bindings_struct is the channel bindings structure that can be passed onto L{authGSSClientStep} """ def authGSSClientStep(context, challenge, **kwargs): """ Processes a single GSSAPI client-side step using the supplied server data. @param context: The context object returned from L{authGSSClientInit}. @param challenge: A string containing the base64-encoded server data (which may be empty for the first step). @param channel_bindings: Optional channel bindings to bind onto the auth request. This struct can be built using :{channelBindings} and if not specified it will pass along GSS_C_NO_CHANNEL_BINDINGS as a default. @return: A result code (see above). """ def authGSSClientResponse(context): """ Get the client response from the last successful GSSAPI client-side step. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the base64-encoded client data to be sent to the server. """ def authGSSClientResponseConf(context): """ Determine whether confidentiality was enabled in the previously unwrapped buffer. @param context: The context object returned from L{authGSSClientInit}. @return: C{1} if confidentiality was enabled in the previously unwrapped buffer, C{0} otherwise. """ def authGSSClientUserName(context): """ Get the user name of the principal authenticated via the now complete GSSAPI client-side operations, or the current user name obtained via authGSSClientInquireCred. This method must only be called after authGSSClientStep or authGSSClientInquireCred return a complete response code. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the user name. """ def authGSSClientUnwrap(context, challenge): """ Perform the client side GSSAPI unwrap step. @param challenge: A string containing the base64-encoded server data. @return: A result code (see above) """ def authGSSClientWrap(context, data, user=None, protect=0): """ Perform the client side GSSAPI wrap step. @param data: The result of the L{authGSSClientResponse} after the L{authGSSClientUnwrap}. @param user: The user to authorize. @param protect: If C{0}, then just provide integrity protection. If C{1}, then provide confidentiality as well. @return: A result code (see above) """ def authGSSServerInit(service): """ Initializes a context for GSSAPI server-side authentication with the given service principal. authGSSServerClean must be called after this function returns an OK result to dispose of the context once all GSSAPI operations are complete. @param service: A string containing the service principal in the form C{"type@fqdn"}. To initialize the context for the purpose of accepting delegated credentials, pass the literal string C{"DELEGATE"}. @return: A tuple of (result, context) where result is the result code (see above) and context is an opaque value that will need to be passed to subsequent functions. """ def authGSSServerClean(context): """ Destroys the context for GSSAPI server-side authentication. This function is provided for compatibility with earlier versions of PyKerberos but does nothing. The context object destroys itself when it is reclaimed. @param context: The context object returned from L{authGSSClientInit}. @return: A result code (see above). """ def authGSSServerStep(context, challenge): """ Processes a single GSSAPI server-side step using the supplied client data. @param context: The context object returned from L{authGSSClientInit}. @param challenge: A string containing the base64-encoded client data. @return: A result code (see above). """ def authGSSServerResponse(context): """ Get the server response from the last successful GSSAPI server-side step. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the base64-encoded server data to be sent to the client. """ def authGSSServerHasDelegated(context): """ Checks whether a server context has delegated credentials. @param context: The context object returned from L{authGSSClientInit}. @return: A bool saying whether delegated credentials are available. """ def authGSSServerUserName(context): """ Get the user name of the principal trying to authenticate to the server. This method must only be called after L{authGSSServerStep} returns a complete or continue response code. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the user name. """ def authGSSServerTargetName(context): """ Get the target name if the server did not supply its own credentials. This method must only be called after L{authGSSServerStep} returns a complete or continue response code. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the target name. """ def authGSSServerStoreDelegate(context): """ Save the ticket sent to the server in the file C{/tmp/krb5_pyserv_XXXXXX}. This method must only be called after L{authGSSServerStep} returns a complete or continue response code. @param context: The context object returned from L{authGSSClientInit}. @return: A result code (see above). """ def authGSSServerCacheName(context): """ Get the name of the credential cache created with L{authGSSServerStoreDelegate}. This method must only be called after L{authGSSServerStoreDelegate}. @param context: The context object returned from L{authGSSClientInit}. @return: A string containing the cache name. """
""" Provide friendlier Kotlin rule exports. """ load( "@io_bazel_rules_kotlin//kotlin:kotlin.bzl", _kt_jvm_binary = "kt_jvm_binary", _kt_jvm_library = "kt_jvm_library", ) kt_jvm_library = _kt_jvm_library kt_jvm_binary = _kt_jvm_binary
def query(self, sql, *args): '''Mixin method for the XXXBase class. conn should be a cm.db.Connection instance.''' conn = self._get_connection() return conn.query(sql, *args) def get_connection(self): '''Mixin method for the XXXBase class. Returns a cm.db.Connection instance.''' raise 'No implementation.' class ObjectBase: '''I am the basis of the model class.''' seq_name = None # The name of the autoincrement id column in the table. def _set_defaults(self, kw): '''Sets the default values for certain 'always there' columns. This method is usually called in a update/insert operation. Returns the modified keyword dictionary. ''' return kw def get_id(self): '''Returns an ID (unique identifier) for the object instance.''' if self.seq_name is None: raise 'There is no autoincrement column.' else: sql = """select nextval('%s');""" % self.seq_name rs = self._query(sql) for r in rs: _id = r.nextval return _id def _get_sort_order(self, kw, default=None): '''Returns the sort order according to key:value parsed in. This method is usually called in a get/select operation. ''' order = kw.get('sort_order') if order == 'up': order_sql = 'asc' elif order == 'down': order_sql = 'desc' else: if default is None: order_sql = 'asc' elif default == 'up': order_sql = 'asc' elif default == 'down': order_sql = 'desc' else: order_sql = 'asc' return order_sql _query = query _get_connection = get_connection class StatusBase: '''I am the basis of the 'type'/'status' listing class. ''' def ids(self): '''Returns a list of ID.''' return [i for (i, s) in self._data] def descs(self): '''Returns a list of Description.''' return [s for (i, s) in self._data] def get_id(self, desc): '''Given a description, returns the related ID.''' ret = [i for (i, s) in self._data if desc == s] if ret is not None: return ret[0] else: raise 'No such desc <%s>.' % desc _query = query _get_connection = get_connection
##Config file for lifetime_spyrelet.py in spyre/spyre/spyrelet/ # Device List devices = { 'vna':[ 'lantz.drivers.VNA_Keysight.E5071B', ['TCPIP0::A-E5071B-03400::inst0::INSTR'], {} ], 'source':[ 'lantz.drivers.mwsource.SynthNVPro', ['ASRL16::INSTR'], {} ] } # Experiment List spyrelets = { 'freqSweep_Keysight':[ 'spyre.spyrelets.freqSweep_VNA_Keysight_spyrelet.Sweep', {'vna': 'vna','source': 'source'}, {} ], }
height = int(input()) for i in range(1, height + 1): for j in range(1,i+1): if(i == height or j == 1 or i == j): print(i,end=" ") else: print(end=" ") print() # Sample Input :- 5 # Output :- # 1 # 2 2 # 3 3 # 4 4 # 5 5 5 5 5
# -*- coding:utf-8-*- name = ["gyj","dzj","why","zz","wwb","zke","ljx","syb","yxd"] print(name) name.reverse() print(name) print(len(name))
""" Exercise 08: Write a Python program to sort a list of elements using quick sort algorithm. """ def quickSort(alist): """ Quick sort algrithm, In-place version. """ def partition(alist, left, right): pivot = alist[right - 1] i = left - 1 for j in range(left, right): if alist[j] < pivot: i += 1 (alist[i], alist[j]) = (alist[j], alist[i]) if alist[right - 1] < alist[i + 1]: (alist[i + 1], alist[right - 1]) = (alist[right - 1], alist[i + 1]) return i + 1 def sort(alist, left, right): if left < right: storeIndex = partition(alist, left, right) sort(alist, left, storeIndex) sort(alist, storeIndex + 1, right) sort(alist, 0, len(alist)) return alist if __name__ == '__main__': alist = [54, 26, 93, 17, 77, 31, 44, 55, 20] print(quickSort(alist)) print(alist)
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ Topic: sample Desc : Python操作PDF: 1. 读取内容使用slate 0.4.1(基于PDFMiner),只能用于Python2 2. 各种PDF操作,包括读取内容、合并、分割、旋转、提取页面等等使用PyPDF2 目前最好的做法是使用PDFMiner,安装之后: pdf2txt.py -o pc.txt /home/mango/work/perfect.pdf 然后自己去分享pc.txt文件即可 """
def flatten(seq): r = [] for x in seq: if type(x) == list: r += flatten(x) else: r.append(x) return r seq = [1,[2,3],4] seq = [1,[2,[5,6],3],4] print(seq, '-->', flatten(seq))
# parsetab.py # This file is automatically generated. Do not edit. _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'nonassocLESSMOREEQUALSTOMOREEQUALLESSEQUALNOTEQUALleftPLUSMINUSleftTIMESDIVIDEleftANDORrightUMINUSINT FLOAT PLUS MINUS TIMES DIVIDE EQUALS LPAREN RPAREN LCURLBRACKET RCURLBRACKET ID COMMENT STRING ASSIGN SEMICOLON COMMA POINT NOT EQUALSTO MORE LESS MOREEQUAL LESSEQUAL NOTEQUAL AND OR INCREMENT DECREMENT BREAK CASE CHAN CONST CONTINUE DEFAULT DEFER ELSE FALLTHROUGH FOR FUNC GO GOTO IF IMPORT INTERFACE MAP PACKAGE RANGE RETURN SELECT STRUCT SWITCH TYPE VAR MAIN FMT PRINT SCAN TRUE FALSEstatement : PACKAGE MAIN IMPORT STRING FUNC MAIN LPAREN RPAREN LCURLBRACKET list RCURLBRACKET\n | PACKAGE MAIN IMPORT STRING FUNC MAIN LPAREN RPAREN LCURLBRACKET RCURLBRACKETlist : inst\n | inst listassignment : ID ASSIGN expressionAR\n | ID ASSIGN expressionBo\n | ID EQUALS expressionAR\n | ID EQUALS expressionBo\n | ID INCREMENT\n | ID DECREMENTinst : FOR expressionBo LCURLBRACKET list RCURLBRACKET\n | FOR assignment SEMICOLON expressionBo SEMICOLON assignment LCURLBRACKET list RCURLBRACKETinst : assignment SEMICOLONinst : IF expressionBo LCURLBRACKET list RCURLBRACKET ELSE LCURLBRACKET list RCURLBRACKET\n | IF expressionBo LCURLBRACKET list RCURLBRACKETlistID : expressionAR\n | expressionBo\n | expressionBo COMMA listID\n | expressionAR COMMA listIDIDlist : ID\n | ID COMMA IDlistinst : FMT POINT PRINT LPAREN listID RPAREN SEMICOLON\n | FMT POINT SCAN LPAREN IDlist RPAREN SEMICOLON\n | FMT POINT PRINT LPAREN RPAREN SEMICOLON\n | FMT POINT SCAN LPAREN RPAREN SEMICOLONexpressionAR : expressionAR PLUS expressionAR\n | expressionAR MINUS expressionAR\n | expressionAR TIMES expressionAR\n | expressionAR DIVIDE expressionAR\n | IDexpressionAR : INTexpressionAR : MINUS expressionAR %prec UMINUSexpressionAR : FLOATexpressionAR : LPAREN expressionAR RPARENexpressionBo : expressionAR MORE expressionAR\n | expressionAR LESS expressionAR\n | expressionAR MOREEQUAL expressionAR\n | expressionAR LESSEQUAL expressionAR\n | expressionBo NOTEQUAL expressionBo\n | expressionAR NOTEQUAL expressionAR\n | expressionBo EQUALSTO expressionBo\n | expressionAR EQUALSTO expressionAR\n | expressionBo AND expressionBo\n | expressionBo OR expressionBoexpressionBo : NOT expressionBo %prec UMINUSexpressionBo : TRUE\n | FALSEexpressionBo : LPAREN expressionBo RPAREN' _lr_action_items = {'PACKAGE':([0,],[2,]),'$end':([1,12,19,],[0,-2,-1,]),'MAIN':([2,6,],[3,7,]),'IMPORT':([3,],[4,]),'STRING':([4,],[5,]),'FUNC':([5,],[6,]),'LPAREN':([7,14,16,24,27,29,36,37,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,62,63,66,89,106,107,],[8,27,27,27,27,60,66,66,27,27,27,27,27,60,60,60,60,60,60,60,60,60,60,60,89,90,66,66,66,66,]),'RPAREN':([8,25,26,30,31,34,56,57,58,59,70,71,72,73,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,97,98,99,101,114,115,117,],[9,-46,-47,-31,-33,-30,-45,85,86,-32,-39,-41,-43,-44,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,86,96,100,86,104,-16,-17,108,-20,-19,-18,-21,]),'LCURLBRACKET':([9,21,25,26,30,31,33,34,38,39,56,59,64,65,67,68,70,71,72,73,75,76,77,78,79,80,81,82,83,84,85,86,102,103,],[10,40,-46,-47,-31,-33,61,-30,-9,-10,-45,-32,-5,-6,-7,-8,-39,-41,-43,-44,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,111,112,]),'RCURLBRACKET':([10,11,13,20,32,69,88,92,94,105,109,113,116,118,119,120,121,],[12,19,-3,-4,-13,92,94,-11,-15,-24,-25,-22,-23,120,121,-12,-14,]),'FOR':([10,13,32,40,61,92,94,105,109,111,112,113,116,120,121,],[14,14,-13,14,14,-11,-15,-24,-25,14,14,-22,-23,-12,-14,]),'IF':([10,13,32,40,61,92,94,105,109,111,112,113,116,120,121,],[16,16,-13,16,16,-11,-15,-24,-25,16,16,-22,-23,-12,-14,]),'FMT':([10,13,32,40,61,92,94,105,109,111,112,113,116,120,121,],[17,17,-13,17,17,-11,-15,-24,-25,17,17,-22,-23,-12,-14,]),'ID':([10,13,14,16,24,27,29,32,36,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,61,66,89,90,92,93,94,105,106,107,109,110,111,112,113,116,120,121,],[18,18,28,34,34,34,34,-13,34,34,18,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,18,34,34,101,-11,18,-15,-24,34,34,-25,101,18,18,-22,-23,-12,-14,]),'NOT':([14,16,24,27,36,37,41,42,43,44,45,66,89,106,107,],[24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,]),'TRUE':([14,16,24,27,36,37,41,42,43,44,45,66,89,106,107,],[25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,]),'FALSE':([14,16,24,27,36,37,41,42,43,44,45,66,89,106,107,],[26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,]),'INT':([14,16,24,27,29,36,37,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,66,89,106,107,],[30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,]),'MINUS':([14,16,23,24,27,28,29,30,31,34,36,37,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,58,59,60,64,66,67,75,76,77,78,79,80,81,82,83,84,86,87,89,91,97,106,107,],[29,29,53,29,29,-30,29,-31,-33,-30,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,53,-32,29,53,29,53,53,53,53,53,53,53,-26,-27,-28,-29,-34,53,29,53,53,29,29,]),'FLOAT':([14,16,24,27,29,36,37,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,66,89,106,107,],[31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,]),'SEMICOLON':([15,22,25,26,30,31,34,38,39,56,59,64,65,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,96,100,104,108,],[32,45,-46,-47,-31,-33,-30,-9,-10,-45,-32,-5,-6,-7,-8,-39,-41,-43,-44,93,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,105,109,113,116,]),'POINT':([17,],[35,]),'ASSIGN':([18,28,],[36,36,]),'EQUALS':([18,28,],[37,37,]),'INCREMENT':([18,28,],[38,38,]),'DECREMENT':([18,28,],[39,39,]),'NOTEQUAL':([21,23,25,26,28,30,31,33,34,56,57,58,59,64,65,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,91,97,98,],[41,50,-46,-47,-30,-31,-33,41,-30,-45,41,50,-32,50,41,50,41,None,None,-43,-44,41,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,50,50,41,]),'EQUALSTO':([21,23,25,26,28,30,31,33,34,56,57,58,59,64,65,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,91,97,98,],[42,51,-46,-47,-30,-31,-33,42,-30,-45,42,51,-32,51,42,51,42,None,None,-43,-44,42,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,51,51,42,]),'AND':([21,25,26,30,31,33,34,56,57,59,65,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,98,],[43,-46,-47,-31,-33,43,-30,-45,43,-32,43,43,43,43,-43,-44,43,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,43,]),'OR':([21,25,26,30,31,33,34,56,57,59,65,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,98,],[44,-46,-47,-31,-33,44,-30,-45,44,-32,44,44,44,44,-43,-44,44,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,44,]),'MORE':([23,28,30,31,34,58,59,64,67,81,82,83,84,86,91,97,],[46,-30,-31,-33,-30,46,-32,46,46,-26,-27,-28,-29,-34,46,46,]),'LESS':([23,28,30,31,34,58,59,64,67,81,82,83,84,86,91,97,],[47,-30,-31,-33,-30,47,-32,47,47,-26,-27,-28,-29,-34,47,47,]),'MOREEQUAL':([23,28,30,31,34,58,59,64,67,81,82,83,84,86,91,97,],[48,-30,-31,-33,-30,48,-32,48,48,-26,-27,-28,-29,-34,48,48,]),'LESSEQUAL':([23,28,30,31,34,58,59,64,67,81,82,83,84,86,91,97,],[49,-30,-31,-33,-30,49,-32,49,49,-26,-27,-28,-29,-34,49,49,]),'PLUS':([23,28,30,31,34,58,59,64,67,75,76,77,78,79,80,81,82,83,84,86,87,91,97,],[52,-30,-31,-33,-30,52,-32,52,52,52,52,52,52,52,52,-26,-27,-28,-29,-34,52,52,52,]),'TIMES':([23,28,30,31,34,58,59,64,67,75,76,77,78,79,80,81,82,83,84,86,87,91,97,],[54,-30,-31,-33,-30,54,-32,54,54,54,54,54,54,54,54,54,54,-28,-29,-34,54,54,54,]),'DIVIDE':([23,28,30,31,34,58,59,64,67,75,76,77,78,79,80,81,82,83,84,86,87,91,97,],[55,-30,-31,-33,-30,55,-32,55,55,55,55,55,55,55,55,55,55,-28,-29,-34,55,55,55,]),'COMMA':([25,26,30,31,34,56,59,70,71,72,73,75,76,77,78,79,80,81,82,83,84,85,86,97,98,101,],[-46,-47,-31,-33,-30,-45,-32,-39,-41,-43,-44,-35,-36,-37,-38,-40,-42,-26,-27,-28,-29,-48,-34,106,107,110,]),'PRINT':([35,],[62,]),'SCAN':([35,],[63,]),'ELSE':([94,],[103,]),} _lr_action = {} for _k, _v in _lr_action_items.items(): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'statement':([0,],[1,]),'list':([10,13,40,61,111,112,],[11,20,69,88,118,119,]),'inst':([10,13,40,61,111,112,],[13,13,13,13,13,13,]),'assignment':([10,13,14,40,61,93,111,112,],[15,15,22,15,15,102,15,15,]),'expressionBo':([14,16,24,27,36,37,41,42,43,44,45,66,89,106,107,],[21,33,56,57,65,68,70,71,72,73,74,57,98,98,98,]),'expressionAR':([14,16,24,27,29,36,37,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,60,66,89,106,107,],[23,23,23,58,59,64,67,23,23,23,23,23,75,76,77,78,79,80,81,82,83,84,87,91,97,97,97,]),'listID':([89,106,107,],[95,114,115,]),'IDlist':([90,110,],[99,117,]),} _lr_goto = {} for _k, _v in _lr_goto_items.items(): for _x, _y in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [ ("S' -> statement","S'",1,None,None,None), ('statement -> PACKAGE MAIN IMPORT STRING FUNC MAIN LPAREN RPAREN LCURLBRACKET list RCURLBRACKET','statement',11,'p_statement_expr','plintax.py',17), ('statement -> PACKAGE MAIN IMPORT STRING FUNC MAIN LPAREN RPAREN LCURLBRACKET RCURLBRACKET','statement',10,'p_statement_expr','plintax.py',18), ('list -> inst','list',1,'p_list','plintax.py',26), ('list -> inst list','list',2,'p_list','plintax.py',27), ('assignment -> ID ASSIGN expressionAR','assignment',3,'p_assignment','plintax.py',34), ('assignment -> ID ASSIGN expressionBo','assignment',3,'p_assignment','plintax.py',35), ('assignment -> ID EQUALS expressionAR','assignment',3,'p_assignment','plintax.py',36), ('assignment -> ID EQUALS expressionBo','assignment',3,'p_assignment','plintax.py',37), ('assignment -> ID INCREMENT','assignment',2,'p_assignment','plintax.py',38), ('assignment -> ID DECREMENT','assignment',2,'p_assignment','plintax.py',39), ('inst -> FOR expressionBo LCURLBRACKET list RCURLBRACKET','inst',5,'p_inst_For','plintax.py',53), ('inst -> FOR assignment SEMICOLON expressionBo SEMICOLON assignment LCURLBRACKET list RCURLBRACKET','inst',9,'p_inst_For','plintax.py',54), ('inst -> assignment SEMICOLON','inst',2,'p_inst_assignment','plintax.py',62), ('inst -> IF expressionBo LCURLBRACKET list RCURLBRACKET ELSE LCURLBRACKET list RCURLBRACKET','inst',9,'p_inst_If','plintax.py',67), ('inst -> IF expressionBo LCURLBRACKET list RCURLBRACKET','inst',5,'p_inst_If','plintax.py',68), ('listID -> expressionAR','listID',1,'p_listID','plintax.py',75), ('listID -> expressionBo','listID',1,'p_listID','plintax.py',76), ('listID -> expressionBo COMMA listID','listID',3,'p_listID','plintax.py',77), ('listID -> expressionAR COMMA listID','listID',3,'p_listID','plintax.py',78), ('IDlist -> ID','IDlist',1,'p_IDlist','plintax.py',85), ('IDlist -> ID COMMA IDlist','IDlist',3,'p_IDlist','plintax.py',86), ('inst -> FMT POINT PRINT LPAREN listID RPAREN SEMICOLON','inst',7,'p_inst_func','plintax.py',102), ('inst -> FMT POINT SCAN LPAREN IDlist RPAREN SEMICOLON','inst',7,'p_inst_func','plintax.py',103), ('inst -> FMT POINT PRINT LPAREN RPAREN SEMICOLON','inst',6,'p_inst_func','plintax.py',104), ('inst -> FMT POINT SCAN LPAREN RPAREN SEMICOLON','inst',6,'p_inst_func','plintax.py',105), ('expressionAR -> expressionAR PLUS expressionAR','expressionAR',3,'p_expressionAR_binop','plintax.py',115), ('expressionAR -> expressionAR MINUS expressionAR','expressionAR',3,'p_expressionAR_binop','plintax.py',116), ('expressionAR -> expressionAR TIMES expressionAR','expressionAR',3,'p_expressionAR_binop','plintax.py',117), ('expressionAR -> expressionAR DIVIDE expressionAR','expressionAR',3,'p_expressionAR_binop','plintax.py',118), ('expressionAR -> ID','expressionAR',1,'p_expressionAR_binop','plintax.py',119), ('expressionAR -> INT','expressionAR',1,'p_expressionAR_int','plintax.py',134), ('expressionAR -> MINUS expressionAR','expressionAR',2,'p_expressionAR_inverse','plintax.py',139), ('expressionAR -> FLOAT','expressionAR',1,'p_expressionAR_float','plintax.py',144), ('expressionAR -> LPAREN expressionAR RPAREN','expressionAR',3,'p_expressionAR_group','plintax.py',149), ('expressionBo -> expressionAR MORE expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',156), ('expressionBo -> expressionAR LESS expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',157), ('expressionBo -> expressionAR MOREEQUAL expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',158), ('expressionBo -> expressionAR LESSEQUAL expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',159), ('expressionBo -> expressionBo NOTEQUAL expressionBo','expressionBo',3,'p_expressionBo_binop','plintax.py',160), ('expressionBo -> expressionAR NOTEQUAL expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',161), ('expressionBo -> expressionBo EQUALSTO expressionBo','expressionBo',3,'p_expressionBo_binop','plintax.py',162), ('expressionBo -> expressionAR EQUALSTO expressionAR','expressionBo',3,'p_expressionBo_binop','plintax.py',163), ('expressionBo -> expressionBo AND expressionBo','expressionBo',3,'p_expressionBo_binop','plintax.py',164), ('expressionBo -> expressionBo OR expressionBo','expressionBo',3,'p_expressionBo_binop','plintax.py',165), ('expressionBo -> NOT expressionBo','expressionBo',2,'p_expressionBo_inverse','plintax.py',186), ('expressionBo -> TRUE','expressionBo',1,'p_expressionBo_int','plintax.py',192), ('expressionBo -> FALSE','expressionBo',1,'p_expressionBo_int','plintax.py',193), ('expressionBo -> LPAREN expressionBo RPAREN','expressionBo',3,'p_expressionBo_group','plintax.py',201), ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # Created by Hai-Tao Yu # 26/09/2018 # https://y-research.github.io """Description """
class Level: def __init__(self, current_level=1, current_xp=0, level_up_base=30, level_up_factor=30): #Original (self, current_level=1, current_xp=0, level_up_base=200, level_up_factor=150) self.current_level = current_level self.current_xp = current_xp self.level_up_base = level_up_base self.level_up_factor = level_up_factor @property def experience_to_next_level(self): return self.level_up_base + self.current_level * self.level_up_factor def add_xp(self, xp): self.current_xp += xp if self.current_xp > self.experience_to_next_level: self.current_xp -= self.experience_to_next_level self.current_level += 1 return True else: return False
version = 1 disable_existing_loggers = False loggers = { 'sanic.root': { 'level': 'DEBUG', 'handlers': ['console', 'root_file'], 'propagate': True }, 'sanic.error': { 'level': 'ERROR', 'handlers': ['error_file'], 'propagate': True }, 'sanic.access': { 'level': 'INFO', 'handlers': ['access_file'], 'propagate': True } } handlers = { 'console': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'generic' }, 'root_file': { 'class': 'logging.handlers.RotatingFileHandler', 'level': 'INFO', 'formatter': 'generic', 'encoding': 'utf-8', 'filename': './runtime/log/root.log', 'maxBytes': 2000000, 'backupCount': 5 }, 'error_file': { 'class': 'logging.handlers.RotatingFileHandler', 'level': 'ERROR', 'formatter': 'generic', 'encoding': 'utf-8', 'filename': './runtime/log/error.log', 'maxBytes': 2000000, 'backupCount': 5 }, 'access_file': { 'class': 'logging.handlers.RotatingFileHandler', 'level': 'INFO', 'formatter': 'access', 'encoding': 'utf-8', 'filename': './runtime/log/access.log', 'maxBytes': 2000000, 'backupCount': 5 } } formatters = { 'generic': { 'format': '%(asctime)s %(levelname)s %(name)s:%(lineno)d | %(message)s' }, 'access': { 'format': '%(asctime)s - %(levelname)s - %(name)s:%(lineno)d %(byte)d | %(request)s' } }
#Printing Stars in 'C' Shape ! ''' **** * * * * * **** ''' for row in range(7): for col in range(5): if (col==0 and (row!=0 and row!=6)) or (row==0 or row==6) and (col>0): print('*',end='') else: print(end=' ') print()
# Copyright (c) 2019 Kevin Weiss, for HAW Hamburg <kevin.weiss@haw-hamburg.de> # # This file is subject to the terms and conditions of the MIT License. See the # file LICENSE in the top level directory for more details. # SPDX-License-Identifier: MIT """packet init for BPH PAL """
# Copyright 2018, OpenCensus Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class TagMap(object): """ A tag map is a map of tags from key to value :type tags: list(:class: '~opencensus.tags.tag.Tag') :param tags: a list of tags """ def __init__(self, tags=None): self._map = {} if tags is not None: self.tags = tags for tag in self.tags: for tag_key, tag_value in tag.items(): self._map[tag_key] = tag_value else: self.tags = {} @property def map(self): """The current map of tags""" return self._map def insert(self, key, value): """Inserts a key and value in the map if the map does not already contain the key. :type key: :class: '~opencensus.tags.tag_key.TagKey' :param key: a tag key to insert into the map :type value: :class: '~opencensus.tags.tag_value.TagValue' :param value: a tag value that is associated with the tag key and the value to insert into the tag map """ if key not in self._map: self._map[key] = value def delete(self, key): """ Deletes a tag from the map if the key is in the map :type key: str :param key: A string representing a possible tag key :returns: the value of the key in the dictionary if it is in there, or None if it is not. """ self._map.pop(key, None) def update(self, key, value): """ Updates the map by updating the value of a key :type key: :class: '~opencensus.tags.tag_key.TagKey' :param key: A tag key to be updated :type value: str :param value: The value to update the key to in the map """ if key in self._map: self._map[key] = value def tag_key_exists(self, key): """ Checking if the tag key exists in the map :type key: str :param key: A string to check to see if that is a key in the map :returns: True if the key is in map, False is it is not """ return key in self._map def get_value(self, key): """ Gets the value of the key passed in if the key exists in the map :type key: str :param key: A string representing a key to get the value of in the map :returns: A KeyError if the value is None, else returns the value """ value = self._map.get(key, None) if value is None: raise KeyError('Key is not in map.') return value
def Main(): a = 1 b = 2 c = 3 e = 4 d = a + b - c * e return d
# Parameters: # MON_PERIOD : Number of seconds the temperature is read. # MON_INTERVAL : Number of seconds the temperature is checked. # TEMP_HIGH : Value in Celsius degree on that a warning e-mail is sent if temperature is above it. # TEMP_CRITICAL : Value in Celsius degree on that the device is shutted down to protect it. MON_PERIOD = 1 MON_INTERVAL = 600 TEMP_HIGH = 85.0 TEMP_CRITICAL = 90.0