content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
""" Write a Python program to count number of substrings from a given string of lowercase alphabets with exactly k distinct (given) characters """ def count_k_dist(str1, k): str_len = len(str1) result = 0 ctr = [0] * 27 for i in range(0, str_len): dist_ctr = 0 ctr = [0] * 27 for j in range(i, str_len): if(ctr[ord(str1[j]) - 97] == 0): dist_ctr += 1 ctr[ord(str1[j]) - 97] += 1 if(dist_ctr == k): result += 1 if(dist_ctr > k): break return result str1 = input("Input a string (lowercase alphabets):") k = int(input("Input k: ")) print("Number of substrings with exactly", k, "distinct characters : ", end = "") print(count_k_dist(str1, k))
""" Write a Python program to count number of substrings from a given string of lowercase alphabets with exactly k distinct (given) characters """ def count_k_dist(str1, k): str_len = len(str1) result = 0 ctr = [0] * 27 for i in range(0, str_len): dist_ctr = 0 ctr = [0] * 27 for j in range(i, str_len): if ctr[ord(str1[j]) - 97] == 0: dist_ctr += 1 ctr[ord(str1[j]) - 97] += 1 if dist_ctr == k: result += 1 if dist_ctr > k: break return result str1 = input('Input a string (lowercase alphabets):') k = int(input('Input k: ')) print('Number of substrings with exactly', k, 'distinct characters : ', end='') print(count_k_dist(str1, k))
def winning_score(): while True: try: winning_score = int(input("\nHow many points should " "declare the winner? ")) except ValueError: print("\nInvalid input type. Enter a positive number.") continue else: if winning_score <= 0: print("\nInvalid input value. Enter a positive number.") continue return winning_score
def winning_score(): while True: try: winning_score = int(input('\nHow many points should declare the winner? ')) except ValueError: print('\nInvalid input type. Enter a positive number.') continue else: if winning_score <= 0: print('\nInvalid input value. Enter a positive number.') continue return winning_score
''' Else Statements Code that executes if contitions checked evaluates to False. '''
""" Else Statements Code that executes if contitions checked evaluates to False. """
class Solution: def selfDividingNumbers(self, left: int, right: int) -> List[int]: ret = [] for x in range(left, right + 1): y = x while y > 0: z = y % 10 if z == 0 or x % z != 0: break; y //= 10 if y == 0: ret.append(x) return ret
class Solution: def self_dividing_numbers(self, left: int, right: int) -> List[int]: ret = [] for x in range(left, right + 1): y = x while y > 0: z = y % 10 if z == 0 or x % z != 0: break y //= 10 if y == 0: ret.append(x) return ret
# -*- coding: utf_8 -*- __author__ = 'Yagg' class ShipGroup: def __init__(self, ownerName, count, shipType, driveTech, weaponTech, shieldTech, cargoTech, cargoType, cargoQuantity): self.count = count self.shipType = shipType self.driveTech = driveTech self.weaponTech = weaponTech self.shieldTech = shieldTech self.cargoTech = cargoTech self.cargoType = cargoType self.cargoQuantity = cargoQuantity self.ownerName = ownerName self.shipMass = 0 self.number = -1 self.liveCount = 0 self.battleStatus = '' self.destinationPlanet = '' self.sourcePlanet = '' self.range = 0.0 self.speed = 0.0 self.fleetName = '' self.groupStatus = ''
__author__ = 'Yagg' class Shipgroup: def __init__(self, ownerName, count, shipType, driveTech, weaponTech, shieldTech, cargoTech, cargoType, cargoQuantity): self.count = count self.shipType = shipType self.driveTech = driveTech self.weaponTech = weaponTech self.shieldTech = shieldTech self.cargoTech = cargoTech self.cargoType = cargoType self.cargoQuantity = cargoQuantity self.ownerName = ownerName self.shipMass = 0 self.number = -1 self.liveCount = 0 self.battleStatus = '' self.destinationPlanet = '' self.sourcePlanet = '' self.range = 0.0 self.speed = 0.0 self.fleetName = '' self.groupStatus = ''
#!/usr/bin/python3 """ Analysis for a 4 load cells (2 strain gauges each) wired to give a single differential output. https://www.eevblog.com/forum/reviews/large-cheap-weight-digital-scale-options/ """ def deltav(V, R, r0, r1, r2, r3): """return the differential output voltage for the 4x load cell""" i0 = V / (4.0 * R + r0 - r3) i1 = V / (4.0 * R - r0 + r3) va = i0 * (2.0 * R - r1 - r3) vb = i1 * (2.0 * R + r2 + r3) return va - vb def main(): Ve = 5.0 Rn = 1000.0 x = deltav(Ve, Rn, 1, 1, 1, 1) print(x) x = deltav(Ve, Rn, 0, 0, 2, 2) print(x) x = deltav(Ve, Rn, 0, 2, 2, 0) print(x) x = deltav(Ve, Rn, 0, 1, 3, 0) print(x) x = deltav(Ve, Rn, 0, 0, 3, 1) print(x) x = deltav(Ve, Rn, 1, 0, 0, 3) print(x) main()
""" Analysis for a 4 load cells (2 strain gauges each) wired to give a single differential output. https://www.eevblog.com/forum/reviews/large-cheap-weight-digital-scale-options/ """ def deltav(V, R, r0, r1, r2, r3): """return the differential output voltage for the 4x load cell""" i0 = V / (4.0 * R + r0 - r3) i1 = V / (4.0 * R - r0 + r3) va = i0 * (2.0 * R - r1 - r3) vb = i1 * (2.0 * R + r2 + r3) return va - vb def main(): ve = 5.0 rn = 1000.0 x = deltav(Ve, Rn, 1, 1, 1, 1) print(x) x = deltav(Ve, Rn, 0, 0, 2, 2) print(x) x = deltav(Ve, Rn, 0, 2, 2, 0) print(x) x = deltav(Ve, Rn, 0, 1, 3, 0) print(x) x = deltav(Ve, Rn, 0, 0, 3, 1) print(x) x = deltav(Ve, Rn, 1, 0, 0, 3) print(x) main()
class MyHookExtension(object): def post_create_hook(self, archive, product): pass def post_ingest_hook(self, archive, product): pass def post_pull_hook(self, archive, product): pass def post_remove_hook(self, archive, product): pass _hook_extensions = { 'myhooks': MyHookExtension() } def hook_extensions(): return _hook_extensions.keys() def hook_extension(name): return _hook_extensions[name]
class Myhookextension(object): def post_create_hook(self, archive, product): pass def post_ingest_hook(self, archive, product): pass def post_pull_hook(self, archive, product): pass def post_remove_hook(self, archive, product): pass _hook_extensions = {'myhooks': my_hook_extension()} def hook_extensions(): return _hook_extensions.keys() def hook_extension(name): return _hook_extensions[name]
# return a go-to-goal heading vector in the robot's reference frame def calculate_gtg_heading_vector( self ): # get the inverse of the robot's pose robot_inv_pos, robot_inv_theta = self.supervisor.estimated_pose().inverse().vector_unpack() # calculate the goal vector in the robot's reference frame goal = self.supervisor.goal() goal = linalg.rotate_and_translate_vector( goal, robot_inv_theta, robot_inv_pos ) return goal # calculate translational velocity # velocity is v_max when omega is 0, # drops rapidly to zero as |omega| rises v = self.supervisor.v_max() / ( abs( omega ) + 1 )**0.5
def calculate_gtg_heading_vector(self): (robot_inv_pos, robot_inv_theta) = self.supervisor.estimated_pose().inverse().vector_unpack() goal = self.supervisor.goal() goal = linalg.rotate_and_translate_vector(goal, robot_inv_theta, robot_inv_pos) return goal v = self.supervisor.v_max() / (abs(omega) + 1) ** 0.5
# Time: O(nlogn) # Space: O(n) class Solution(object): def stoneGameVI(self, aliceValues, bobValues): """ :type aliceValues: List[int] :type bobValues: List[int] :rtype: int """ sorted_vals = sorted(((a, b) for a, b in zip(aliceValues, bobValues)), key=sum, reverse=True) return cmp(sum(a for a, _ in sorted_vals[::2]), sum(b for _, b in sorted_vals[1::2]))
class Solution(object): def stone_game_vi(self, aliceValues, bobValues): """ :type aliceValues: List[int] :type bobValues: List[int] :rtype: int """ sorted_vals = sorted(((a, b) for (a, b) in zip(aliceValues, bobValues)), key=sum, reverse=True) return cmp(sum((a for (a, _) in sorted_vals[::2])), sum((b for (_, b) in sorted_vals[1::2])))
# pylint: disable=global-statement,missing-docstring,blacklisted-name foo = "test" def broken(): global foo bar = len(foo) foo = foo[bar]
foo = 'test' def broken(): global foo bar = len(foo) foo = foo[bar]
def parse_input(): fin = open('input_day3.txt','r') inputs = [] for line in fin: inputs.append(line.strip('\n')) return inputs def plot_path(inputs, path, ref_path=None): x=0 y=0 c = 0 hits = [] for i in inputs.split(','): (d, v) = (i[0],int(i[1:])) fn = lambda x,y,p: (x,y) if d == 'R': fn = lambda x,y: (x + 1, y) elif d == 'L': fn = lambda x,y: (x - 1, y) elif d == 'U': fn = lambda x,y: (x, y + 1) elif d == 'D': fn = lambda x,y: (x, y - 1) for p in range(1,v+1): c+=1 x,y = fn(x,y) key = "{}_{}".format(x,y) if key in path: pass # first count of steps is retained else: path[key] = c # find intersections if ref_path and key in ref_path: hits.append(key) return hits def find_manhattan_dist(hits): md_list = [] for h in hits: (x,y) = map(int,h.split('_')) md_list.append(abs(x) + abs(y)) return md_list if __name__ == '__main__': inputs = parse_input() w1_path = {} w2_path = {} plot_path(inputs[0], w1_path) hits = plot_path(inputs[1], w2_path, w1_path) print('hits', hits) # part one md_list = find_manhattan_dist(hits) print('manhattan distances', md_list) print('Shortest', min(md_list)) # part two steps = [] for h in hits: steps.append(w1_path[h] + w2_path[h]) print('steps', steps); print('shortest step', min(steps))
def parse_input(): fin = open('input_day3.txt', 'r') inputs = [] for line in fin: inputs.append(line.strip('\n')) return inputs def plot_path(inputs, path, ref_path=None): x = 0 y = 0 c = 0 hits = [] for i in inputs.split(','): (d, v) = (i[0], int(i[1:])) fn = lambda x, y, p: (x, y) if d == 'R': fn = lambda x, y: (x + 1, y) elif d == 'L': fn = lambda x, y: (x - 1, y) elif d == 'U': fn = lambda x, y: (x, y + 1) elif d == 'D': fn = lambda x, y: (x, y - 1) for p in range(1, v + 1): c += 1 (x, y) = fn(x, y) key = '{}_{}'.format(x, y) if key in path: pass else: path[key] = c if ref_path and key in ref_path: hits.append(key) return hits def find_manhattan_dist(hits): md_list = [] for h in hits: (x, y) = map(int, h.split('_')) md_list.append(abs(x) + abs(y)) return md_list if __name__ == '__main__': inputs = parse_input() w1_path = {} w2_path = {} plot_path(inputs[0], w1_path) hits = plot_path(inputs[1], w2_path, w1_path) print('hits', hits) md_list = find_manhattan_dist(hits) print('manhattan distances', md_list) print('Shortest', min(md_list)) steps = [] for h in hits: steps.append(w1_path[h] + w2_path[h]) print('steps', steps) print('shortest step', min(steps))
class Solution: def detectCycle(self, head): """O(n) time | O(1) space""" fast = slow = head while fast and fast.next: fast = fast.next.next slow = slow.next if fast is slow: return find_cycle(head, slow) return None def find_cycle(head, slow): while head is not slow: head = head.next slow = slow.next return slow
class Solution: def detect_cycle(self, head): """O(n) time | O(1) space""" fast = slow = head while fast and fast.next: fast = fast.next.next slow = slow.next if fast is slow: return find_cycle(head, slow) return None def find_cycle(head, slow): while head is not slow: head = head.next slow = slow.next return slow
# This file is imported from __init__.py and exec'd from setup.py __version__ = "1.0.0+dev" VERSION = (1, 0, 0)
__version__ = '1.0.0+dev' version = (1, 0, 0)
#returns list of groups. group is a list of strings, a string per person. def getgroups(): with open('Day6.txt', 'r') as file: groupList = [] currgroup = [] for line in file: if line not in ['\n', '\n\n']: currgroup.append(line.strip()) else: groupList.append(currgroup) currgroup = [] groupList.append(currgroup) return(groupList) def option1(): groupList = getgroups() norepeatsgroups = [] for group in groupList: combined = [] for person in group: for char in person: if char not in combined: combined.append(char) norepeatsgroups.append(combined) answer = 0 for group in norepeatsgroups: answer += len(group) print(answer, "unique 'yes'es ") def option2(): groupList = getgroups() count = 0 allyesgroups = [] for group in groupList: person1 = group[0] for person in group[1:]: for char in person1: #checks against the first person since first person must contain every letter(they all do but we have to pick one ok) if char not in person: person1 = person1.replace(char,'') #removes from first person if first person has a unique letter. if person1 != '': #removes empty lists. len([''])=1 allyesgroups.append(person1) count += len(person1) print(count, " communal 'yes'es ") def menu(): #privae grievance: yes's is silly. That is all. print("\nOption 1: Number of Unique yes's(Part A) \nOption 2: Number of communal yes's(Part B)\nOption 3: Exit\n\nType a number\n\n") try: option = int(input(">> ")) if option == 1: option1() elif option == 2: option2() elif option == 3: exit() else: print("Error: Incorrect Input\n\n") menu() except ValueError: print("Error: Incorrect Input. Enter a number\n\n") menu() if __name__ == "__main__": menu()
def getgroups(): with open('Day6.txt', 'r') as file: group_list = [] currgroup = [] for line in file: if line not in ['\n', '\n\n']: currgroup.append(line.strip()) else: groupList.append(currgroup) currgroup = [] groupList.append(currgroup) return groupList def option1(): group_list = getgroups() norepeatsgroups = [] for group in groupList: combined = [] for person in group: for char in person: if char not in combined: combined.append(char) norepeatsgroups.append(combined) answer = 0 for group in norepeatsgroups: answer += len(group) print(answer, "unique 'yes'es ") def option2(): group_list = getgroups() count = 0 allyesgroups = [] for group in groupList: person1 = group[0] for person in group[1:]: for char in person1: if char not in person: person1 = person1.replace(char, '') if person1 != '': allyesgroups.append(person1) count += len(person1) print(count, " communal 'yes'es ") def menu(): print("\nOption 1: Number of Unique yes's(Part A) \nOption 2: Number of communal yes's(Part B)\nOption 3: Exit\n\nType a number\n\n") try: option = int(input('>> ')) if option == 1: option1() elif option == 2: option2() elif option == 3: exit() else: print('Error: Incorrect Input\n\n') menu() except ValueError: print('Error: Incorrect Input. Enter a number\n\n') menu() if __name__ == '__main__': menu()
""" # Definition for a Node. class Node: def __init__(self, val, children): self.val = val self.children = children """ class Solution: def levelOrder(self, root): """ :type root: Node :rtype: List[List[int]] """ if not root: return [] queue = [root] ans = [] while queue: arr = [] for _ in range(len(queue)): temp = queue.pop(0) arr.append(temp.val) for j in temp.children: queue.append(j) ans.append(arr) return ans
""" # Definition for a Node. class Node: def __init__(self, val, children): self.val = val self.children = children """ class Solution: def level_order(self, root): """ :type root: Node :rtype: List[List[int]] """ if not root: return [] queue = [root] ans = [] while queue: arr = [] for _ in range(len(queue)): temp = queue.pop(0) arr.append(temp.val) for j in temp.children: queue.append(j) ans.append(arr) return ans
#!/usr/bin/env python # -*- coding: utf-8 -*- """Exits with status 0""" if __name__ == '__main__': exit(0)
"""Exits with status 0""" if __name__ == '__main__': exit(0)
# # @lc app=leetcode id=342 lang=python # # [342] Power of Four # # https://leetcode.com/problems/power-of-four/description/ # # algorithms # Easy (39.98%) # Likes: 315 # Dislikes: 141 # Total Accepted: 114.1K # Total Submissions: 283.1K # Testcase Example: '16' # # Given an integer (signed 32 bits), write a function to check whether it is a # power of 4. # # Example 1: # # # Input: 16 # Output: true # # # # Example 2: # # # Input: 5 # Output: false # # # Follow up: Could you solve it without loops/recursion? # class Solution(object): def _isPowerOfFour(self, num): """ :type num: int :rtype: bool """ if num < 1: return False while num != 1: left, right = divmod(num, 4) if right != 0: return False num = left return True def __isPowerOfFour(self, num): """ :type num: int :rtype: bool """ if num < 1: return False length = len(format(num, 'b')) return num & num - 1 == 0 and length % 2 == 1 def ___isPowerOfFour(self, num): """ :type num: int :rtype: bool """ return num > 0 and num & num - 1 == 0 and num % 3 == 1 def isPowerOfFour(self, num): """ :type num: int :rtype: bool """ # 0x55555555 = 0b1010101010101010101010101010101 return num > 0 and num & num - 1 == 0 and num & 0x55555555 == num
class Solution(object): def _is_power_of_four(self, num): """ :type num: int :rtype: bool """ if num < 1: return False while num != 1: (left, right) = divmod(num, 4) if right != 0: return False num = left return True def __is_power_of_four(self, num): """ :type num: int :rtype: bool """ if num < 1: return False length = len(format(num, 'b')) return num & num - 1 == 0 and length % 2 == 1 def ___is_power_of_four(self, num): """ :type num: int :rtype: bool """ return num > 0 and num & num - 1 == 0 and (num % 3 == 1) def is_power_of_four(self, num): """ :type num: int :rtype: bool """ return num > 0 and num & num - 1 == 0 and (num & 1431655765 == num)
list1=['Apple','Mango',1999,2000] print(list1) del list1[2] print("After deleting value at index 2:") print(list1) list2=['Apple','Mango',1999,2000,1111,2222,3333] print(list2) del list2[0:3] print("After deleting value till index 2:") print(list2)
list1 = ['Apple', 'Mango', 1999, 2000] print(list1) del list1[2] print('After deleting value at index 2:') print(list1) list2 = ['Apple', 'Mango', 1999, 2000, 1111, 2222, 3333] print(list2) del list2[0:3] print('After deleting value till index 2:') print(list2)
# -*- coding: utf-8 -*- """ Created on Wed Dec 25 22:07:19 2019 @author: penko Returns information on all maps (e.g. Hanamura) in Overwatch, with options to return only OWL modes, and unique maps only (due to a quirk of the API). """ ''' # packages used in this function import requests import numpy as np import pandas as pd ''' # The guid's are fairly messed up within OW, with multiple guid's belonging to the # same map, each with different combinations of modes, including duplicates. # e.g. Hollywood - (Hybrid) and Hollywood - (Hybrid, Skirmish) will have different guid's # If we just want the list of unique maps and their type in the OWL then we can get rid of # duplicates and not worry about the lost guid's. # But since two matches/maps in the MatchStats might use different guid's for the same map, # it will be important to have all the possible guid's that have been used (the redundant part) # so that we can get the map name etc. This is further complicated by some 'map' values # being gone from the matches/maps section. Therefore, I will make uniqueness an argument def getMaps(unique = False, only_OWL_modes = False): maps = requests.get("https://api.overwatchleague.com/maps") if maps.status_code != 200: print("Error: Could not retrieve data from server. Code ", maps.status_code, sep='') return None m_json = maps.json() m_df = pd.DataFrame( [ { "guid": m['guid'], "id_string": m['id'], "name": m['name']['en_US'], "mode_id_name": [ (gm['Id'], gm['Name']) for gm in m['gameModes'] ] } for m in m_json if (m['guid'] not in ['0x08000000000006C7'] and m['id'] != "") ] ) # -First guid above is for VPP Green Room, which is a testing map for OWL devs # -The second part of if stmt (id string must exist) removes "maps" like Busan Sanctuary. # if this proves to be bad (e.g. a map id in the stats section needs # Busan Sactuary), then you can remove the 'and' portion. Perhaps in that # case, you could make the id_string = lower(name) # make a row for each game mode in the map m_df = m_df.explode('mode_id_name') m_df[['mode_id','mode_name']] = pd.DataFrame([*m_df.mode_id_name], m_df.index) m_df = m_df.drop(columns='mode_id_name') if only_OWL_modes == True: m_df = m_df[m_df.mode_name.isin(['Assault','Payload','Hybrid','Control'])] if unique == True: m_df.drop_duplicates(subset=['id_string','name','mode_id','mode_name'], inplace=True) # Gets rid of inaccurate Paris Hybrid entry. Otherwise left in for robustness m_df = m_df[np.logical_not(m_df.guid.isin(['0x0800000000000AF0']))] m_df.reset_index(drop=True, inplace=True) return m_df
""" Created on Wed Dec 25 22:07:19 2019 @author: penko Returns information on all maps (e.g. Hanamura) in Overwatch, with options to return only OWL modes, and unique maps only (due to a quirk of the API). """ '\n# packages used in this function\nimport requests\nimport numpy as np\nimport pandas as pd\n' def get_maps(unique=False, only_OWL_modes=False): maps = requests.get('https://api.overwatchleague.com/maps') if maps.status_code != 200: print('Error: Could not retrieve data from server. Code ', maps.status_code, sep='') return None m_json = maps.json() m_df = pd.DataFrame([{'guid': m['guid'], 'id_string': m['id'], 'name': m['name']['en_US'], 'mode_id_name': [(gm['Id'], gm['Name']) for gm in m['gameModes']]} for m in m_json if m['guid'] not in ['0x08000000000006C7'] and m['id'] != '']) m_df = m_df.explode('mode_id_name') m_df[['mode_id', 'mode_name']] = pd.DataFrame([*m_df.mode_id_name], m_df.index) m_df = m_df.drop(columns='mode_id_name') if only_OWL_modes == True: m_df = m_df[m_df.mode_name.isin(['Assault', 'Payload', 'Hybrid', 'Control'])] if unique == True: m_df.drop_duplicates(subset=['id_string', 'name', 'mode_id', 'mode_name'], inplace=True) m_df = m_df[np.logical_not(m_df.guid.isin(['0x0800000000000AF0']))] m_df.reset_index(drop=True, inplace=True) return m_df
base_vectors = [[0.001178571428571168, 1.9904285714285708, 0.0011071428571440833], [-0.013142857142857345, -0.0018571428571430015, 1.9921428571428583], [-0.0007499999999995843, 0.17799999999999994, -0.00024999999999630873], [-4.440892098500626e-16, -8.881784197001252e-16, 0.1769999999999996]] n = [8, 8, 6, 6] origin = [-3.4612499999999944, -7.169999999999995, -6.396750000000013] support_indices = [[0, 0, 1, 0], [0, 0, 1, 5], [0, 0, 5, 5], [0, 7, 1, 0], [7, 7, 0, 0]] support_xyz = [[-3.462, -6.992, -6.397], [-3.462, -6.992, -5.512], [-3.465, -6.28, -5.513], [-3.554, -7.005, 7.548], [-3.545, 6.75, 7.556]]
base_vectors = [[0.001178571428571168, 1.9904285714285708, 0.0011071428571440833], [-0.013142857142857345, -0.0018571428571430015, 1.9921428571428583], [-0.0007499999999995843, 0.17799999999999994, -0.00024999999999630873], [-4.440892098500626e-16, -8.881784197001252e-16, 0.1769999999999996]] n = [8, 8, 6, 6] origin = [-3.4612499999999944, -7.169999999999995, -6.396750000000013] support_indices = [[0, 0, 1, 0], [0, 0, 1, 5], [0, 0, 5, 5], [0, 7, 1, 0], [7, 7, 0, 0]] support_xyz = [[-3.462, -6.992, -6.397], [-3.462, -6.992, -5.512], [-3.465, -6.28, -5.513], [-3.554, -7.005, 7.548], [-3.545, 6.75, 7.556]]
def solveProblem(inputPath): floor = 0 indexFloorInfo = 0 with open(inputPath) as fileP: valueLine = fileP.readline() for floorInfo in valueLine: indexFloorInfo += 1 if floorInfo == '(': floor += 1 elif floorInfo == ')': floor -= 1 if floor == -1: return indexFloorInfo print(solveProblem('InputD01Q2.txt'))
def solve_problem(inputPath): floor = 0 index_floor_info = 0 with open(inputPath) as file_p: value_line = fileP.readline() for floor_info in valueLine: index_floor_info += 1 if floorInfo == '(': floor += 1 elif floorInfo == ')': floor -= 1 if floor == -1: return indexFloorInfo print(solve_problem('InputD01Q2.txt'))
try: tests=int(input()) k=[] for i in range(tests): z=[] count=0 find,length=[int(x) for x in input().split(" ")] list1=list(map(int,input().rstrip().split())) for i in range(len(list1)): if list1[i]==find: z.append(i+1) count=count+1 if count>1: k.append(z) else: k.append("-1") if len(k)>1: for x in k: print(*x) except: pass
try: tests = int(input()) k = [] for i in range(tests): z = [] count = 0 (find, length) = [int(x) for x in input().split(' ')] list1 = list(map(int, input().rstrip().split())) for i in range(len(list1)): if list1[i] == find: z.append(i + 1) count = count + 1 if count > 1: k.append(z) else: k.append('-1') if len(k) > 1: for x in k: print(*x) except: pass
python = {'John':35,'Eric':36,'Michael':35,'Terry':38,'Graham':37,'TerryG':34} holy_grail = {'Arthur':40,'Galahad':35,'Lancelot':39,'Knight of NI':40, 'Zoot':17} life_of_brian = {'Brian':33,'Reg':35,'Stan/Loretta':32,'Biccus Diccus':45} #membership test print('Arthur' in holy_grail) if 'Arthur' not in python: print('He\'s not here!') people = {} people1 = {} people2 = {} #method 1 update people.update(python) people.update(holy_grail) people.update(life_of_brian) print(sorted(people.items())) #method 2 comprehension for groups in (python,holy_grail,life_of_brian) : people1.update(groups) print(sorted(people1.items())) #method 3 unpacking 3.5 later people2 = {**python,**holy_grail,**life_of_brian} print(sorted(people2.items())) print('The sum of the ages: ', sum(people.values()))
python = {'John': 35, 'Eric': 36, 'Michael': 35, 'Terry': 38, 'Graham': 37, 'TerryG': 34} holy_grail = {'Arthur': 40, 'Galahad': 35, 'Lancelot': 39, 'Knight of NI': 40, 'Zoot': 17} life_of_brian = {'Brian': 33, 'Reg': 35, 'Stan/Loretta': 32, 'Biccus Diccus': 45} print('Arthur' in holy_grail) if 'Arthur' not in python: print("He's not here!") people = {} people1 = {} people2 = {} people.update(python) people.update(holy_grail) people.update(life_of_brian) print(sorted(people.items())) for groups in (python, holy_grail, life_of_brian): people1.update(groups) print(sorted(people1.items())) people2 = {**python, **holy_grail, **life_of_brian} print(sorted(people2.items())) print('The sum of the ages: ', sum(people.values()))
class Permission: """ An object representing a single permission overwrite. ``Permission(role='1234')`` allows users with role ID 1234 to use the command ``Permission(user='5678')`` allows user ID 5678 to use the command ``Permission(role='9012', allow=False)`` denies users with role ID 9012 from using the command """ def __init__(self, role=None, user=None, allow=True): if bool(role) == bool(user): raise ValueError("specify only one of role or user") self.type = 1 if role else 2 self.id = role or user self.permission = allow def dump(self): "Returns a dict representation of the permission" return {"type": self.type, "id": self.id, "permission": self.permission}
class Permission: """ An object representing a single permission overwrite. ``Permission(role='1234')`` allows users with role ID 1234 to use the command ``Permission(user='5678')`` allows user ID 5678 to use the command ``Permission(role='9012', allow=False)`` denies users with role ID 9012 from using the command """ def __init__(self, role=None, user=None, allow=True): if bool(role) == bool(user): raise value_error('specify only one of role or user') self.type = 1 if role else 2 self.id = role or user self.permission = allow def dump(self): """Returns a dict representation of the permission""" return {'type': self.type, 'id': self.id, 'permission': self.permission}
def dict_repr(self): return self.__dict__.__repr__() def dict_str(self): return self.__dict__.__str__() def round_price(price: float, exchange_precision: int) -> float: """Round prices to the nearest cent. Args: price (float) exchange_precision (int): number of decimal digits for exchange price Returns: float: The rounded price. """ return round(price, exchange_precision)
def dict_repr(self): return self.__dict__.__repr__() def dict_str(self): return self.__dict__.__str__() def round_price(price: float, exchange_precision: int) -> float: """Round prices to the nearest cent. Args: price (float) exchange_precision (int): number of decimal digits for exchange price Returns: float: The rounded price. """ return round(price, exchange_precision)
a, b, c = input().split(' ') a = float(a) b = float(b) c = float(c) areat = (a * c) / 2 areac = 3.14159 * c**2 areatp = (a + b) * c / 2 areaq = b * b arear = b * a print(f'TRIANGULO: {areat:.3f}') print(f'CIRCULO: {areac:.3f}') print(f'TRAPEZIO: {areatp:.3f}') print(f'QUADRADO: {areaq:.3f}') print(f'RETANGULO: {arear:.3f}')
(a, b, c) = input().split(' ') a = float(a) b = float(b) c = float(c) areat = a * c / 2 areac = 3.14159 * c ** 2 areatp = (a + b) * c / 2 areaq = b * b arear = b * a print(f'TRIANGULO: {areat:.3f}') print(f'CIRCULO: {areac:.3f}') print(f'TRAPEZIO: {areatp:.3f}') print(f'QUADRADO: {areaq:.3f}') print(f'RETANGULO: {arear:.3f}')
#! python3 # aoc_05.py # Advent of code: # https://adventofcode.com/2021/day/5 # https://adventofcode.com/2021/day/5#part2 # def hello_world(): return 'hello world' class ventmap: def __init__(self, xmax, ymax): self.xmax = xmax self.ymax = ymax self.map = [[0 for i in range(xmax)] for j in range(ymax)] def check_line(x1,y1,x2,y2): return x1 == x2 or y1 == y2 def find_vents(input,x,y): mymap = ventmap(x,y) with open(input, 'r') as line_list: for line in line_list.readlines(): lstart, lend = line.split(' -> ') x1,y1 = lstart.split(',') x1 = int(x1) y1 = int(y1) x2,y2 = lend.split(',') x2= int(x2) y2 = int(y2) if check_line(x1,y1,x2,y2): if x1>x2 or y1 >y2: x1,x2 = x2,x1 y1,y2 = y2,y1 for i in range(x1,x2+1): for l in range(y1,y2+1): mymap.map[l][i]+=1 else: if x1>x2: x1,x2 = x2,x1 y1,y2 = y2,y1 if x1 < x2 and y1 < y2: #print("Diag down") for i in range(0,x2-x1+1): mymap.map[y1+i][x1+i] += 1 #diag down: else: #print("Diag up") for i in range(0,x2-x1+1): mymap.map[y1-i][x1+i] += 1 danger_points = 0 for line in mymap.map: for field in line: if field > 1: danger_points +=1 return danger_points print(find_vents("aoc_05_example.txt",10,10)) print(find_vents("aoc_05_input.txt",1000,1000))
def hello_world(): return 'hello world' class Ventmap: def __init__(self, xmax, ymax): self.xmax = xmax self.ymax = ymax self.map = [[0 for i in range(xmax)] for j in range(ymax)] def check_line(x1, y1, x2, y2): return x1 == x2 or y1 == y2 def find_vents(input, x, y): mymap = ventmap(x, y) with open(input, 'r') as line_list: for line in line_list.readlines(): (lstart, lend) = line.split(' -> ') (x1, y1) = lstart.split(',') x1 = int(x1) y1 = int(y1) (x2, y2) = lend.split(',') x2 = int(x2) y2 = int(y2) if check_line(x1, y1, x2, y2): if x1 > x2 or y1 > y2: (x1, x2) = (x2, x1) (y1, y2) = (y2, y1) for i in range(x1, x2 + 1): for l in range(y1, y2 + 1): mymap.map[l][i] += 1 else: if x1 > x2: (x1, x2) = (x2, x1) (y1, y2) = (y2, y1) if x1 < x2 and y1 < y2: for i in range(0, x2 - x1 + 1): mymap.map[y1 + i][x1 + i] += 1 else: for i in range(0, x2 - x1 + 1): mymap.map[y1 - i][x1 + i] += 1 danger_points = 0 for line in mymap.map: for field in line: if field > 1: danger_points += 1 return danger_points print(find_vents('aoc_05_example.txt', 10, 10)) print(find_vents('aoc_05_input.txt', 1000, 1000))
# # PySNMP MIB module RAQMON-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RAQMON-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:52:12 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) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ConstraintsIntersection, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueSizeConstraint") InetPortNumber, InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetPortNumber", "InetAddress", "InetAddressType") rmon, = mibBuilder.importSymbols("RMON-MIB", "rmon") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") Bits, IpAddress, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, NotificationType, Counter64, Gauge32, iso, Integer32, Counter32, ModuleIdentity, Unsigned32, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "IpAddress", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "NotificationType", "Counter64", "Gauge32", "iso", "Integer32", "Counter32", "ModuleIdentity", "Unsigned32", "ObjectIdentity") RowPointer, DisplayString, RowStatus, TruthValue, DateAndTime, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowPointer", "DisplayString", "RowStatus", "TruthValue", "DateAndTime", "TextualConvention") raqmonMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 16, 31)) raqmonMIB.setRevisions(('2006-10-10 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: raqmonMIB.setRevisionsDescriptions(('Initial version, published as RFC 4711.',)) if mibBuilder.loadTexts: raqmonMIB.setLastUpdated('200610100000Z') if mibBuilder.loadTexts: raqmonMIB.setOrganization('IETF RMON MIB Working Group') if mibBuilder.loadTexts: raqmonMIB.setContactInfo('WG Charter: http://www.ietf.org/html.charters/rmonmib-charter.html Mailing lists: General Discussion: rmonmib@ietf.org To Subscribe: rmonmib-requests@ietf.org In Body: subscribe your_email_address Chair: Andy Bierman Email: ietf@andybierman.com Editor: Dan Romascanu Avaya Email: dromasca@avaya.com') if mibBuilder.loadTexts: raqmonMIB.setDescription('Real-Time Application QoS Monitoring MIB. Copyright (c) The Internet Society (2006). This version of this MIB module is part of RFC 4711; See the RFC itself for full legal notices.') raqmonNotifications = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 0)) raqmonSessionAlarm = NotificationType((1, 3, 6, 1, 2, 1, 16, 31, 0, 1)).setObjects(("RAQMON-MIB", "raqmonParticipantAddr"), ("RAQMON-MIB", "raqmonParticipantName"), ("RAQMON-MIB", "raqmonParticipantPeerAddrType"), ("RAQMON-MIB", "raqmonParticipantPeerAddr"), ("RAQMON-MIB", "raqmonQoSEnd2EndNetDelay"), ("RAQMON-MIB", "raqmonQoSInterArrivalJitter"), ("RAQMON-MIB", "raqmonQosLostPackets"), ("RAQMON-MIB", "raqmonQosRcvdPackets")) if mibBuilder.loadTexts: raqmonSessionAlarm.setStatus('current') if mibBuilder.loadTexts: raqmonSessionAlarm.setDescription('A notification generated by an entry in the raqmonSessionExceptionTable.') raqmonMIBObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 1)) raqmonSession = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 1)) raqmonParticipantTable = MibTable((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1), ) if mibBuilder.loadTexts: raqmonParticipantTable.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantTable.setDescription('This table contains information about participants in both active and closed (terminated) sessions.') raqmonParticipantEntry = MibTableRow((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1), ).setIndexNames((0, "RAQMON-MIB", "raqmonParticipantStartDate"), (0, "RAQMON-MIB", "raqmonParticipantIndex")) if mibBuilder.loadTexts: raqmonParticipantEntry.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantEntry.setDescription('Each row contains information for a single session (application) run by one participant. Indexation by the start time of the session aims to ease sorting by management applications. Agents MUST NOT report identical start times for any two sessions on the same host. Rows are removed for inactive sessions when implementation-specific age or space limits are reached.') raqmonParticipantStartDate = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 1), DateAndTime()) if mibBuilder.loadTexts: raqmonParticipantStartDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantStartDate.setDescription('The date and time of this entry. It will be the date and time of the first report received.') raqmonParticipantIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: raqmonParticipantIndex.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIndex.setDescription('The index of the conceptual row, which is for SNMP purposes only and has no relation to any protocol value. There is no requirement that these rows be created or maintained sequentially. The index will be unique for a particular date and time.') raqmonParticipantReportCaps = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 3), Bits().clone(namedValues=NamedValues(("raqmonPartRepDsrcName", 0), ("raqmonPartRepRecvName", 1), ("raqmonPartRepDsrcPort", 2), ("raqmonPartRepRecvPort", 3), ("raqmonPartRepSetupTime", 4), ("raqmonPartRepSetupDelay", 5), ("raqmonPartRepSessionDuration", 6), ("raqmonPartRepSetupStatus", 7), ("raqmonPartRepRTEnd2EndNetDelay", 8), ("raqmonPartRepOWEnd2EndNetDelay", 9), ("raqmonPartApplicationDelay", 10), ("raqmonPartRepIAJitter", 11), ("raqmonPartRepIPDV", 12), ("raqmonPartRepRcvdPackets", 13), ("raqmonPartRepRcvdOctets", 14), ("raqmonPartRepSentPackets", 15), ("raqmonPartRepSentOctets", 16), ("raqmonPartRepCumPacketsLoss", 17), ("raqmonPartRepFractionPacketsLoss", 18), ("raqmonPartRepCumDiscards", 19), ("raqmonPartRepFractionDiscards", 20), ("raqmonPartRepSrcPayloadType", 21), ("raqmonPartRepDestPayloadType", 22), ("raqmonPartRepSrcLayer2Priority", 23), ("raqmonPartRepSrcTosDscp", 24), ("raqmonPartRepDestLayer2Priority", 25), ("raqmonPartRepDestTosDscp", 26), ("raqmonPartRepCPU", 27), ("raqmonPartRepMemory", 28), ("raqmonPartRepAppName", 29)))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantReportCaps.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantReportCaps.setDescription('The Report capabilities of the participant, as perceived by the Collector. If the participant can report the Data Source Name as defined in [RFC4710], Section 5.3, then the raqmonPartRepDsrcName bit will be set. If the participant can report the Receiver Name as defined in [RFC4710], Section 5.4, then the raqmonPartRepRecvName bit will be set. If the participant can report the Data Source Port as defined in [RFC4710], Section 5.5, then the raqmonPartRepDsrcPort bit will be set. If the participant can report the Receiver Port as defined in [RFC4710], Section 5.6, then the raqmonPartRepRecvPort bit will be set. If the participant can report the Session Setup Time as defined in [RFC4710], Section 5.7, then the raqmonPartRepSetupTime bit will be set. If the participant can report the Session Setup Delay as defined in [RFC4710], Section 5.8, then the raqmonPartRepSetupDelay bit will be set. If the participant can report the Session Duration as defined in [RFC4710], Section 5.9, then the raqmonPartRepSessionDuration bit will be set. If the participant can report the Setup Status as defined in [RFC4710], Section 5.10, then the raqmonPartRepSetupStatus bit will be set. If the participant can report the Round-Trip End-to-end Network Delay as defined in [RFC4710], Section 5.11, then the raqmonPartRepRTEnd2EndNetDelay bit will be set. If the participant can report the One-way End-to-end Network Delay as defined in [RFC4710], Section 5.12, then the raqmonPartRepOWEnd2EndNetDelay bit will be set. If the participant can report the Application Delay as defined in [RFC4710], Section 5.13, then the raqmonPartApplicationDelay bit will be set. If the participant can report the Inter-Arrival Jitter as defined in [RFC4710], Section 5.14, then the raqmonPartRepIAJitter bit will be set. If the participant can report the IP Packet Delay Variation as defined in [RFC4710], Section 5.15, then the raqmonPartRepIPDV bit will be set. If the participant can report the number of application packets received as defined in [RFC4710], Section 5.16, then the raqmonPartRepRcvdPackets bit will be set. If the participant can report the number of application octets received as defined in [RFC4710], Section 5.17, then the raqmonPartRepRcvdOctets bit will be set. If the participant can report the number of application packets sent as defined in [RFC4710], Section 5.18, then the raqmonPartRepSentPackets bit will be set. If the participant can report the number of application octets sent as defined in [RFC4710], Section 5.19, then the raqmonPartRepSentOctets bit will be set. If the participant can report the number of cumulative packets lost as defined in [RFC4710], Section 5.20, then the raqmonPartRepCumPacketsLoss bit will be set. If the participant can report the fraction of packet loss as defined in [RFC4710], Section 5.21, then the raqmonPartRepFractionPacketsLoss bit will be set. If the participant can report the number of cumulative discards as defined in [RFC4710], Section 5.22, then the raqmonPartRepCumDiscards bit will be set. If the participant can report the fraction of discards as defined in [RFC4710], Section 5.23, then the raqmonPartRepFractionDiscards bit will be set. If the participant can report the Source Payload Type as defined in [RFC4710], Section 5.24, then the raqmonPartRepSrcPayloadType bit will be set. If the participant can report the Destination Payload Type as defined in [RFC4710], Section 5.25, then the raqmonPartRepDestPayloadType bit will be set. If the participant can report the Source Layer 2 Priority as defined in [RFC4710], Section 5.26, then the raqmonPartRepSrcLayer2Priority bit will be set. If the participant can report the Source DSCP/ToS value as defined in [RFC4710], Section 5.27, then the raqmonPartRepSrcToSDscp bit will be set. If the participant can report the Destination Layer 2 Priority as defined in [RFC4710], Section 5.28, then the raqmonPartRepDestLayer2Priority bit will be set. If the participant can report the Destination DSCP/ToS Value as defined in [RFC4710], Section 5.29, then the raqmonPartRepDestToSDscp bit will be set. If the participant can report the CPU utilization as defined in [RFC4710], Section 5.30, then the raqmonPartRepCPU bit will be set. If the participant can report the memory utilization as defined in [RFC4710], Section 5.31, then the raqmonPartRepMemory bit will be set. If the participant can report the Application Name as defined in [RFC4710], Section 5.32, then the raqmonPartRepAppName bit will be set. The capability of reporting of a specific metric does not mandate that the metric must be reported permanently by the data source to the respective collector. Some data sources MAY be configured not to send a metric, or some metrics may not be relevant to the specific application.') raqmonParticipantAddrType = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 4), InetAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAddrType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrType.setDescription('The type of the Internet address of the participant for this session.') raqmonParticipantAddr = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 5), InetAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAddr.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddr.setDescription('The Internet Address of the participant for this session. Formatting of this object is determined by the value of raqmonParticipantAddrType.') raqmonParticipantSendPort = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 6), InetPortNumber()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantSendPort.setReference('Section 5.5 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSendPort.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSendPort.setDescription('Port from which session data is sent. If the value was not reported to the collector, this object will have the value 0.') raqmonParticipantRecvPort = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 7), InetPortNumber()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantRecvPort.setReference('Section 5.6 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantRecvPort.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantRecvPort.setDescription('Port on which session data is received. If the value was not reported to the collector, this object will have the value 0.') raqmonParticipantSetupDelay = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setReference('Section 5.8 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setDescription('Session setup time. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantName = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 9), SnmpAdminString()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantName.setReference('Section 5.3 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantName.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantName.setDescription('The data source name for the participant.') raqmonParticipantAppName = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 10), SnmpAdminString()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAppName.setReference('Section 5.32 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppName.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppName.setDescription("A string giving the name and possibly the version of the application generating the stream, e.g., 'videotool 1.2.' This information may be useful for debugging purposes and is similar to the Mailer or Mail-System-Version SMTP headers. The tool value is expected to remain constant for the duration of the session.") raqmonParticipantQosCount = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 11), Gauge32()).setUnits('entries').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantQosCount.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantQosCount.setDescription('The current number of entries in the raqmonQosTable for this participant and session.') raqmonParticipantEndDate = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 12), DateAndTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantEndDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantEndDate.setDescription('The date and time of the most recent report received.') raqmonParticipantDestPayloadType = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 127), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setReference('RFC 3551 and Section 5.25 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setDescription('Destination Payload Type. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantSrcPayloadType = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 127), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setReference('RFC 3551 and Section 5.24 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setDescription('Source Payload Type. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantActive = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 15), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantActive.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantActive.setDescription("Value 'true' indicates that the session for this participant is active (open). Value 'false' indicates that the session is closed (terminated).") raqmonParticipantPeer = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 16), RowPointer()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantPeer.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeer.setDescription('The pointer to the corresponding entry in this table for the other peer participant. If there is no such entry in the participant table of the collector represented by this SNMP agent, then the value will be { 0 0 }. ') raqmonParticipantPeerAddrType = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 17), InetAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantPeerAddrType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeerAddrType.setDescription('The type of the Internet address of the peer participant for this session.') raqmonParticipantPeerAddr = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 18), InetAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantPeerAddr.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeerAddr.setDescription('The Internet Address of the peer participant for this session. Formatting of this object is determined by the value of raqmonParticipantPeerAddrType.') raqmonParticipantSrcL2Priority = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 7), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setReference('Section 5.26 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setDescription('Source Layer 2 Priority. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantDestL2Priority = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 7), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setReference('Section 5.28 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setDescription('Destination Layer 2 Priority. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantSrcDSCP = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 63), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setReference('Section 5.27 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setDescription('Source Layer 3 DSCP value. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantDestDSCP = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 63), ))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setReference('Section 5.29 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setDescription('Destination Layer 3 DSCP value.') raqmonParticipantCpuMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 23), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantCpuMean.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMean.setDescription('Mean CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantCpuMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 24), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantCpuMin.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMin.setDescription('Minimum CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantCpuMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantCpuMax.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMax.setDescription('Maximum CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantMemoryMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setDescription('Mean memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantMemoryMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 27), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setDescription('Minimum memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantMemoryMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setDescription('Maximum memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetRTTMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 29), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setDescription('Mean round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetRTTMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 30), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setDescription('Minimum round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetRTTMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 31), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setDescription('Maximum round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIAJitterMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 32), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setDescription('Mean inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIAJitterMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 33), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setDescription('Minimum inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIAJitterMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 34), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setDescription('Maximum inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIPDVMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 35), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setDescription('Mean IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIPDVMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 36), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setDescription('Minimum IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantIPDVMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 37), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setDescription('Maximum IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetOwdMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 38), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setReference('Section 5.12 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setDescription('Mean Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetOwdMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 39), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setReference('Section 5.12 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setDescription('Minimum Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantNetOwdMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 40), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setReference('Section 5.1 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setDescription('Maximum Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantAppDelayMean = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 41), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setDescription('Mean application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantAppDelayMin = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 42), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setDescription('Minimum application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantAppDelayMax = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 43), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setDescription('Maximum application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantPacketsRcvd = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 44), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setReference('Section 5.16 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setDescription('Count of packets received for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantPacketsSent = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 45), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setReference('Section 5.17 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setDescription('Count of packets sent for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantOctetsRcvd = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 46), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('Octets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setReference('Section 5.18 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setDescription('Count of octets received for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantOctetsSent = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 47), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('Octets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setReference('Section 5.19 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setDescription('Count of octets sent for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantLostPackets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 48), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantLostPackets.setReference('Section 5.20 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantLostPackets.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantLostPackets.setDescription('Count of packets lost by this receiver for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantLostPacketsFrct = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 49), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setReference('Section 5.21 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setDescription('Fraction of lost packets out of total packets received. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantDiscards = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 50), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantDiscards.setReference('Section 5.22 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDiscards.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDiscards.setDescription('Count of packets discarded by this receiver for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmonParticipantDiscardsFrct = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 51), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 100), ))).setUnits('percents').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setReference('Section 5.23 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setDescription('Fraction of discarded packets out of total packets received. If the value was not reported to the collector, this object will have the value -1.') raqmonQosTable = MibTable((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2), ) if mibBuilder.loadTexts: raqmonQosTable.setStatus('current') if mibBuilder.loadTexts: raqmonQosTable.setDescription('Table of historical information about quality-of-service data during sessions.') raqmonQosEntry = MibTableRow((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1), ).setIndexNames((0, "RAQMON-MIB", "raqmonParticipantStartDate"), (0, "RAQMON-MIB", "raqmonParticipantIndex"), (0, "RAQMON-MIB", "raqmonQosTime")) if mibBuilder.loadTexts: raqmonQosEntry.setStatus('current') if mibBuilder.loadTexts: raqmonQosEntry.setDescription('Each entry contains information from a single RAQMON packet, related to a single session (application) run by one participant. Indexation by the start time of the session aims to ease sorting by management applications. Agents MUST NOT report identical start times for any two sessions on the same host. Rows are removed for inactive sessions when implementation-specific time or space limits are reached.') raqmonQosTime = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('seconds') if mibBuilder.loadTexts: raqmonQosTime.setStatus('current') if mibBuilder.loadTexts: raqmonQosTime.setDescription('Time of this entry measured from the start of the corresponding participant session.') raqmonQoSEnd2EndNetDelay = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setStatus('current') if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setDescription('The round-trip time. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQoSInterArrivalJitter = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('milliseconds').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setStatus('current') if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setDescription('An estimate of delay variation as observed by this receiver. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosRcvdPackets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosRcvdPackets.setReference('Section 5.16 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosRcvdPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosRcvdPackets.setDescription('Count of packets received by this receiver since the previous entry. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosRcvdOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('octets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosRcvdOctets.setReference('Section 5.18 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosRcvdOctets.setStatus('current') if mibBuilder.loadTexts: raqmonQosRcvdOctets.setDescription('Count of octets received by this receiver since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosSentPackets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosSentPackets.setReference('Section 5.17 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSentPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosSentPackets.setDescription('Count of packets sent since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosSentOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('octets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosSentOctets.setReference('Section 5.19 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSentOctets.setStatus('current') if mibBuilder.loadTexts: raqmonQosSentOctets.setDescription('Count of octets sent since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosLostPackets = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 2147483647), ))).setUnits('packets').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosLostPackets.setReference('Section 5.20 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosLostPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosLostPackets.setDescription('A count of packets lost as observed by this receiver since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmonQosSessionStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 9), SnmpAdminString()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonQosSessionStatus.setReference('Section 5.10 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSessionStatus.setStatus('current') if mibBuilder.loadTexts: raqmonQosSessionStatus.setDescription('The session status. Will contain the previous value if there was no report for this time or the zero-length string if no value was ever reported.') raqmonParticipantAddrTable = MibTable((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3), ) if mibBuilder.loadTexts: raqmonParticipantAddrTable.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrTable.setDescription('Maps raqmonParticipantAddr to the index of the raqmonParticipantTable. This table allows management applications to find entries sorted by raqmonParticipantAddr rather than raqmonParticipantStartDate.') raqmonParticipantAddrEntry = MibTableRow((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3, 1), ).setIndexNames((0, "RAQMON-MIB", "raqmonParticipantAddrType"), (0, "RAQMON-MIB", "raqmonParticipantAddr"), (0, "RAQMON-MIB", "raqmonParticipantStartDate"), (0, "RAQMON-MIB", "raqmonParticipantIndex")) if mibBuilder.loadTexts: raqmonParticipantAddrEntry.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrEntry.setDescription('Each entry corresponds to exactly one entry in the raqmonParticipantEntry: the entry containing the index pair raqmonParticipantStartDate, raqmonParticipantIndex. Note that there is no concern about the indexation of this table exceeding the limits defined by RFC 2578, Section 3.5. According to [RFC4710], Section 5.1, only IPv4 and IPv6 addresses can be reported as participant addresses.') raqmonParticipantAddrEndDate = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3, 1, 1), DateAndTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonParticipantAddrEndDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrEndDate.setDescription('The value of raqmonParticipantEndDate for the corresponding raqmonParticipantEntry.') raqmonException = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 2)) raqmonSessionExceptionTable = MibTable((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2), ) if mibBuilder.loadTexts: raqmonSessionExceptionTable.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionTable.setDescription('This table defines thresholds for the management station to get notifications about sessions that encountered poor quality of service. The information in this table MUST be persistent across agent reboots.') raqmonSessionExceptionEntry = MibTableRow((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1), ).setIndexNames((0, "RAQMON-MIB", "raqmonSessionExceptionIndex")) if mibBuilder.loadTexts: raqmonSessionExceptionEntry.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionEntry.setDescription('A conceptual row in the raqmonSessionExceptionTable.') raqmonSessionExceptionIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: raqmonSessionExceptionIndex.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionIndex.setDescription('An index that uniquely identifies an entry in the raqmonSessionExceptionTable. Management applications can determine unused indices by performing GetNext or GetBulk operations on the Table.') raqmonSessionExceptionIAJitterThreshold = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 3), Unsigned32()).setUnits('milliseconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: raqmonSessionExceptionIAJitterThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionIAJitterThreshold.setDescription('Threshold for jitter. The value during a session must be greater than or equal to this value for an exception to be created.') raqmonSessionExceptionNetRTTThreshold = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 4), Unsigned32()).setUnits('milliseconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: raqmonSessionExceptionNetRTTThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionNetRTTThreshold.setDescription('Threshold for round-trip time. The value during a session must be greater than or equal to this value for an exception to be created.') raqmonSessionExceptionLostPacketsThreshold = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000))).setUnits('tenth of a percent').setMaxAccess("readcreate") if mibBuilder.loadTexts: raqmonSessionExceptionLostPacketsThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionLostPacketsThreshold.setDescription('Threshold for lost packets in units of tenths of a percent. The value during a session must be greater than or equal to this value for an exception to be created.') raqmonSessionExceptionRowStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: raqmonSessionExceptionRowStatus.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionRowStatus.setDescription("This object has a value of 'active' when exceptions are being monitored by the system. A newly-created conceptual row must have all the read-create objects initialized before becoming 'active'. A conceptual row that is in the 'notReady' or 'notInService' state MAY be removed after 5 minutes. No writeable objects can be changed while the row is active.") raqmonConfig = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 3)) raqmonConfigPort = MibScalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 1), InetPortNumber()).setMaxAccess("readwrite") if mibBuilder.loadTexts: raqmonConfigPort.setStatus('current') if mibBuilder.loadTexts: raqmonConfigPort.setDescription('The UDP port to listen on for RAQMON reports, running on transport protocols other than SNMP. If the RAQMON PDU transport protocol is SNMP, a write operation on this object has no effect, as the standard port 162 is always used. The value of this object MUST be persistent across agent reboots.') raqmonConfigPduTransport = MibScalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 2), Bits().clone(namedValues=NamedValues(("other", 0), ("tcp", 1), ("snmp", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonConfigPduTransport.setStatus('current') if mibBuilder.loadTexts: raqmonConfigPduTransport.setDescription('The PDU transport(s) used by this collector. If other(0) is set, the collector supports a transport other than SNMP or TCP. If tcp(1) is set, the collector supports TCP as a transport protocol. If snmp(2) is set, the collector supports SNMP as a transport protocol.') raqmonConfigRaqmonPdus = MibScalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 3), Counter32()).setUnits('PDUs').setMaxAccess("readonly") if mibBuilder.loadTexts: raqmonConfigRaqmonPdus.setStatus('current') if mibBuilder.loadTexts: raqmonConfigRaqmonPdus.setDescription('Count of RAQMON PDUs received by the Collector.') raqmonConfigRDSTimeout = MibScalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 4), Unsigned32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: raqmonConfigRDSTimeout.setStatus('current') if mibBuilder.loadTexts: raqmonConfigRDSTimeout.setDescription('The number of seconds since the reception of the last RAQMON PDU from a RDS after which a session between the respective RDS and the collector will be considered terminated. The value of this object MUST be persistent across agent reboots.') raqmonConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 2)) raqmonCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 2, 1)) raqmonGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 16, 31, 2, 2)) raqmonCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 16, 31, 2, 1, 1)).setObjects(("RAQMON-MIB", "raqmonCollectorGroup"), ("RAQMON-MIB", "raqmonCollectorNotificationsGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmonCompliance = raqmonCompliance.setStatus('current') if mibBuilder.loadTexts: raqmonCompliance.setDescription('Describes the requirements for conformance to the RAQMON MIB.') raqmonCollectorGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 16, 31, 2, 2, 1)).setObjects(("RAQMON-MIB", "raqmonParticipantReportCaps"), ("RAQMON-MIB", "raqmonParticipantAddrType"), ("RAQMON-MIB", "raqmonParticipantAddr"), ("RAQMON-MIB", "raqmonParticipantSendPort"), ("RAQMON-MIB", "raqmonParticipantRecvPort"), ("RAQMON-MIB", "raqmonParticipantSetupDelay"), ("RAQMON-MIB", "raqmonParticipantName"), ("RAQMON-MIB", "raqmonParticipantAppName"), ("RAQMON-MIB", "raqmonParticipantQosCount"), ("RAQMON-MIB", "raqmonParticipantEndDate"), ("RAQMON-MIB", "raqmonParticipantDestPayloadType"), ("RAQMON-MIB", "raqmonParticipantSrcPayloadType"), ("RAQMON-MIB", "raqmonParticipantActive"), ("RAQMON-MIB", "raqmonParticipantPeer"), ("RAQMON-MIB", "raqmonParticipantPeerAddrType"), ("RAQMON-MIB", "raqmonParticipantPeerAddr"), ("RAQMON-MIB", "raqmonParticipantSrcL2Priority"), ("RAQMON-MIB", "raqmonParticipantDestL2Priority"), ("RAQMON-MIB", "raqmonParticipantSrcDSCP"), ("RAQMON-MIB", "raqmonParticipantDestDSCP"), ("RAQMON-MIB", "raqmonParticipantCpuMean"), ("RAQMON-MIB", "raqmonParticipantCpuMin"), ("RAQMON-MIB", "raqmonParticipantCpuMax"), ("RAQMON-MIB", "raqmonParticipantMemoryMean"), ("RAQMON-MIB", "raqmonParticipantMemoryMin"), ("RAQMON-MIB", "raqmonParticipantMemoryMax"), ("RAQMON-MIB", "raqmonParticipantNetRTTMean"), ("RAQMON-MIB", "raqmonParticipantNetRTTMin"), ("RAQMON-MIB", "raqmonParticipantNetRTTMax"), ("RAQMON-MIB", "raqmonParticipantIAJitterMean"), ("RAQMON-MIB", "raqmonParticipantIAJitterMin"), ("RAQMON-MIB", "raqmonParticipantIAJitterMax"), ("RAQMON-MIB", "raqmonParticipantIPDVMean"), ("RAQMON-MIB", "raqmonParticipantIPDVMin"), ("RAQMON-MIB", "raqmonParticipantIPDVMax"), ("RAQMON-MIB", "raqmonParticipantNetOwdMean"), ("RAQMON-MIB", "raqmonParticipantNetOwdMin"), ("RAQMON-MIB", "raqmonParticipantNetOwdMax"), ("RAQMON-MIB", "raqmonParticipantAppDelayMean"), ("RAQMON-MIB", "raqmonParticipantAppDelayMin"), ("RAQMON-MIB", "raqmonParticipantAppDelayMax"), ("RAQMON-MIB", "raqmonParticipantPacketsRcvd"), ("RAQMON-MIB", "raqmonParticipantPacketsSent"), ("RAQMON-MIB", "raqmonParticipantOctetsRcvd"), ("RAQMON-MIB", "raqmonParticipantOctetsSent"), ("RAQMON-MIB", "raqmonParticipantLostPackets"), ("RAQMON-MIB", "raqmonParticipantLostPacketsFrct"), ("RAQMON-MIB", "raqmonParticipantDiscards"), ("RAQMON-MIB", "raqmonParticipantDiscardsFrct"), ("RAQMON-MIB", "raqmonQoSEnd2EndNetDelay"), ("RAQMON-MIB", "raqmonQoSInterArrivalJitter"), ("RAQMON-MIB", "raqmonQosRcvdPackets"), ("RAQMON-MIB", "raqmonQosRcvdOctets"), ("RAQMON-MIB", "raqmonQosSentPackets"), ("RAQMON-MIB", "raqmonQosSentOctets"), ("RAQMON-MIB", "raqmonQosLostPackets"), ("RAQMON-MIB", "raqmonQosSessionStatus"), ("RAQMON-MIB", "raqmonParticipantAddrEndDate"), ("RAQMON-MIB", "raqmonConfigPort"), ("RAQMON-MIB", "raqmonSessionExceptionIAJitterThreshold"), ("RAQMON-MIB", "raqmonSessionExceptionNetRTTThreshold"), ("RAQMON-MIB", "raqmonSessionExceptionLostPacketsThreshold"), ("RAQMON-MIB", "raqmonSessionExceptionRowStatus"), ("RAQMON-MIB", "raqmonConfigPduTransport"), ("RAQMON-MIB", "raqmonConfigRaqmonPdus"), ("RAQMON-MIB", "raqmonConfigRDSTimeout")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmonCollectorGroup = raqmonCollectorGroup.setStatus('current') if mibBuilder.loadTexts: raqmonCollectorGroup.setDescription('Objects used in RAQMON by a collector.') raqmonCollectorNotificationsGroup = NotificationGroup((1, 3, 6, 1, 2, 1, 16, 31, 2, 2, 2)).setObjects(("RAQMON-MIB", "raqmonSessionAlarm")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmonCollectorNotificationsGroup = raqmonCollectorNotificationsGroup.setStatus('current') if mibBuilder.loadTexts: raqmonCollectorNotificationsGroup.setDescription('Notifications emitted by a RAQMON collector.') mibBuilder.exportSymbols("RAQMON-MIB", raqmonParticipantPacketsRcvd=raqmonParticipantPacketsRcvd, raqmonCompliance=raqmonCompliance, raqmonParticipantSetupDelay=raqmonParticipantSetupDelay, raqmonParticipantPacketsSent=raqmonParticipantPacketsSent, raqmonSessionExceptionTable=raqmonSessionExceptionTable, raqmonParticipantDestPayloadType=raqmonParticipantDestPayloadType, raqmonMIBObjects=raqmonMIBObjects, raqmonParticipantReportCaps=raqmonParticipantReportCaps, raqmonQoSEnd2EndNetDelay=raqmonQoSEnd2EndNetDelay, raqmonParticipantPeer=raqmonParticipantPeer, raqmonConformance=raqmonConformance, raqmonParticipantAppDelayMean=raqmonParticipantAppDelayMean, raqmonParticipantCpuMax=raqmonParticipantCpuMax, raqmonParticipantNetRTTMax=raqmonParticipantNetRTTMax, raqmonSessionExceptionIAJitterThreshold=raqmonSessionExceptionIAJitterThreshold, raqmonQosRcvdOctets=raqmonQosRcvdOctets, raqmonParticipantSrcL2Priority=raqmonParticipantSrcL2Priority, raqmonParticipantEndDate=raqmonParticipantEndDate, raqmonQosSentPackets=raqmonQosSentPackets, raqmonParticipantDestDSCP=raqmonParticipantDestDSCP, raqmonSessionExceptionRowStatus=raqmonSessionExceptionRowStatus, raqmonParticipantAppName=raqmonParticipantAppName, raqmonParticipantIAJitterMax=raqmonParticipantIAJitterMax, raqmonQosEntry=raqmonQosEntry, raqmonConfigRDSTimeout=raqmonConfigRDSTimeout, raqmonParticipantActive=raqmonParticipantActive, raqmonParticipantPeerAddrType=raqmonParticipantPeerAddrType, raqmonCompliances=raqmonCompliances, raqmonSessionExceptionEntry=raqmonSessionExceptionEntry, raqmonQosRcvdPackets=raqmonQosRcvdPackets, raqmonParticipantLostPacketsFrct=raqmonParticipantLostPacketsFrct, raqmonQosSessionStatus=raqmonQosSessionStatus, raqmonParticipantOctetsRcvd=raqmonParticipantOctetsRcvd, raqmonCollectorGroup=raqmonCollectorGroup, PYSNMP_MODULE_ID=raqmonMIB, raqmonParticipantIPDVMax=raqmonParticipantIPDVMax, raqmonParticipantTable=raqmonParticipantTable, raqmonParticipantDestL2Priority=raqmonParticipantDestL2Priority, raqmonCollectorNotificationsGroup=raqmonCollectorNotificationsGroup, raqmonParticipantMemoryMin=raqmonParticipantMemoryMin, raqmonParticipantLostPackets=raqmonParticipantLostPackets, raqmonParticipantDiscardsFrct=raqmonParticipantDiscardsFrct, raqmonParticipantAddrEndDate=raqmonParticipantAddrEndDate, raqmonParticipantSrcPayloadType=raqmonParticipantSrcPayloadType, raqmonSession=raqmonSession, raqmonQosLostPackets=raqmonQosLostPackets, raqmonParticipantNetOwdMin=raqmonParticipantNetOwdMin, raqmonQosTable=raqmonQosTable, raqmonParticipantIPDVMin=raqmonParticipantIPDVMin, raqmonParticipantCpuMin=raqmonParticipantCpuMin, raqmonParticipantNetRTTMin=raqmonParticipantNetRTTMin, raqmonParticipantQosCount=raqmonParticipantQosCount, raqmonConfigPduTransport=raqmonConfigPduTransport, raqmonParticipantSendPort=raqmonParticipantSendPort, raqmonParticipantAppDelayMin=raqmonParticipantAppDelayMin, raqmonConfig=raqmonConfig, raqmonGroups=raqmonGroups, raqmonSessionExceptionIndex=raqmonSessionExceptionIndex, raqmonConfigRaqmonPdus=raqmonConfigRaqmonPdus, raqmonConfigPort=raqmonConfigPort, raqmonParticipantSrcDSCP=raqmonParticipantSrcDSCP, raqmonMIB=raqmonMIB, raqmonQosTime=raqmonQosTime, raqmonParticipantIndex=raqmonParticipantIndex, raqmonParticipantRecvPort=raqmonParticipantRecvPort, raqmonSessionAlarm=raqmonSessionAlarm, raqmonParticipantStartDate=raqmonParticipantStartDate, raqmonSessionExceptionLostPacketsThreshold=raqmonSessionExceptionLostPacketsThreshold, raqmonParticipantAppDelayMax=raqmonParticipantAppDelayMax, raqmonParticipantDiscards=raqmonParticipantDiscards, raqmonParticipantAddrType=raqmonParticipantAddrType, raqmonParticipantCpuMean=raqmonParticipantCpuMean, raqmonParticipantIAJitterMin=raqmonParticipantIAJitterMin, raqmonParticipantOctetsSent=raqmonParticipantOctetsSent, raqmonNotifications=raqmonNotifications, raqmonParticipantNetRTTMean=raqmonParticipantNetRTTMean, raqmonParticipantMemoryMax=raqmonParticipantMemoryMax, raqmonParticipantAddr=raqmonParticipantAddr, raqmonQosSentOctets=raqmonQosSentOctets, raqmonParticipantMemoryMean=raqmonParticipantMemoryMean, raqmonParticipantPeerAddr=raqmonParticipantPeerAddr, raqmonParticipantName=raqmonParticipantName, raqmonSessionExceptionNetRTTThreshold=raqmonSessionExceptionNetRTTThreshold, raqmonParticipantAddrEntry=raqmonParticipantAddrEntry, raqmonParticipantIAJitterMean=raqmonParticipantIAJitterMean, raqmonParticipantEntry=raqmonParticipantEntry, raqmonParticipantAddrTable=raqmonParticipantAddrTable, raqmonQoSInterArrivalJitter=raqmonQoSInterArrivalJitter, raqmonParticipantIPDVMean=raqmonParticipantIPDVMean, raqmonParticipantNetOwdMean=raqmonParticipantNetOwdMean, raqmonParticipantNetOwdMax=raqmonParticipantNetOwdMax, raqmonException=raqmonException)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueSizeConstraint') (inet_port_number, inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetPortNumber', 'InetAddress', 'InetAddressType') (rmon,) = mibBuilder.importSymbols('RMON-MIB', 'rmon') (snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') (object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance') (bits, ip_address, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, notification_type, counter64, gauge32, iso, integer32, counter32, module_identity, unsigned32, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'Bits', 'IpAddress', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'NotificationType', 'Counter64', 'Gauge32', 'iso', 'Integer32', 'Counter32', 'ModuleIdentity', 'Unsigned32', 'ObjectIdentity') (row_pointer, display_string, row_status, truth_value, date_and_time, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowPointer', 'DisplayString', 'RowStatus', 'TruthValue', 'DateAndTime', 'TextualConvention') raqmon_mib = module_identity((1, 3, 6, 1, 2, 1, 16, 31)) raqmonMIB.setRevisions(('2006-10-10 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: raqmonMIB.setRevisionsDescriptions(('Initial version, published as RFC 4711.',)) if mibBuilder.loadTexts: raqmonMIB.setLastUpdated('200610100000Z') if mibBuilder.loadTexts: raqmonMIB.setOrganization('IETF RMON MIB Working Group') if mibBuilder.loadTexts: raqmonMIB.setContactInfo('WG Charter: http://www.ietf.org/html.charters/rmonmib-charter.html Mailing lists: General Discussion: rmonmib@ietf.org To Subscribe: rmonmib-requests@ietf.org In Body: subscribe your_email_address Chair: Andy Bierman Email: ietf@andybierman.com Editor: Dan Romascanu Avaya Email: dromasca@avaya.com') if mibBuilder.loadTexts: raqmonMIB.setDescription('Real-Time Application QoS Monitoring MIB. Copyright (c) The Internet Society (2006). This version of this MIB module is part of RFC 4711; See the RFC itself for full legal notices.') raqmon_notifications = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 0)) raqmon_session_alarm = notification_type((1, 3, 6, 1, 2, 1, 16, 31, 0, 1)).setObjects(('RAQMON-MIB', 'raqmonParticipantAddr'), ('RAQMON-MIB', 'raqmonParticipantName'), ('RAQMON-MIB', 'raqmonParticipantPeerAddrType'), ('RAQMON-MIB', 'raqmonParticipantPeerAddr'), ('RAQMON-MIB', 'raqmonQoSEnd2EndNetDelay'), ('RAQMON-MIB', 'raqmonQoSInterArrivalJitter'), ('RAQMON-MIB', 'raqmonQosLostPackets'), ('RAQMON-MIB', 'raqmonQosRcvdPackets')) if mibBuilder.loadTexts: raqmonSessionAlarm.setStatus('current') if mibBuilder.loadTexts: raqmonSessionAlarm.setDescription('A notification generated by an entry in the raqmonSessionExceptionTable.') raqmon_mib_objects = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 1)) raqmon_session = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 1)) raqmon_participant_table = mib_table((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1)) if mibBuilder.loadTexts: raqmonParticipantTable.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantTable.setDescription('This table contains information about participants in both active and closed (terminated) sessions.') raqmon_participant_entry = mib_table_row((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1)).setIndexNames((0, 'RAQMON-MIB', 'raqmonParticipantStartDate'), (0, 'RAQMON-MIB', 'raqmonParticipantIndex')) if mibBuilder.loadTexts: raqmonParticipantEntry.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantEntry.setDescription('Each row contains information for a single session (application) run by one participant. Indexation by the start time of the session aims to ease sorting by management applications. Agents MUST NOT report identical start times for any two sessions on the same host. Rows are removed for inactive sessions when implementation-specific age or space limits are reached.') raqmon_participant_start_date = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 1), date_and_time()) if mibBuilder.loadTexts: raqmonParticipantStartDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantStartDate.setDescription('The date and time of this entry. It will be the date and time of the first report received.') raqmon_participant_index = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 2147483647))) if mibBuilder.loadTexts: raqmonParticipantIndex.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIndex.setDescription('The index of the conceptual row, which is for SNMP purposes only and has no relation to any protocol value. There is no requirement that these rows be created or maintained sequentially. The index will be unique for a particular date and time.') raqmon_participant_report_caps = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 3), bits().clone(namedValues=named_values(('raqmonPartRepDsrcName', 0), ('raqmonPartRepRecvName', 1), ('raqmonPartRepDsrcPort', 2), ('raqmonPartRepRecvPort', 3), ('raqmonPartRepSetupTime', 4), ('raqmonPartRepSetupDelay', 5), ('raqmonPartRepSessionDuration', 6), ('raqmonPartRepSetupStatus', 7), ('raqmonPartRepRTEnd2EndNetDelay', 8), ('raqmonPartRepOWEnd2EndNetDelay', 9), ('raqmonPartApplicationDelay', 10), ('raqmonPartRepIAJitter', 11), ('raqmonPartRepIPDV', 12), ('raqmonPartRepRcvdPackets', 13), ('raqmonPartRepRcvdOctets', 14), ('raqmonPartRepSentPackets', 15), ('raqmonPartRepSentOctets', 16), ('raqmonPartRepCumPacketsLoss', 17), ('raqmonPartRepFractionPacketsLoss', 18), ('raqmonPartRepCumDiscards', 19), ('raqmonPartRepFractionDiscards', 20), ('raqmonPartRepSrcPayloadType', 21), ('raqmonPartRepDestPayloadType', 22), ('raqmonPartRepSrcLayer2Priority', 23), ('raqmonPartRepSrcTosDscp', 24), ('raqmonPartRepDestLayer2Priority', 25), ('raqmonPartRepDestTosDscp', 26), ('raqmonPartRepCPU', 27), ('raqmonPartRepMemory', 28), ('raqmonPartRepAppName', 29)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantReportCaps.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantReportCaps.setDescription('The Report capabilities of the participant, as perceived by the Collector. If the participant can report the Data Source Name as defined in [RFC4710], Section 5.3, then the raqmonPartRepDsrcName bit will be set. If the participant can report the Receiver Name as defined in [RFC4710], Section 5.4, then the raqmonPartRepRecvName bit will be set. If the participant can report the Data Source Port as defined in [RFC4710], Section 5.5, then the raqmonPartRepDsrcPort bit will be set. If the participant can report the Receiver Port as defined in [RFC4710], Section 5.6, then the raqmonPartRepRecvPort bit will be set. If the participant can report the Session Setup Time as defined in [RFC4710], Section 5.7, then the raqmonPartRepSetupTime bit will be set. If the participant can report the Session Setup Delay as defined in [RFC4710], Section 5.8, then the raqmonPartRepSetupDelay bit will be set. If the participant can report the Session Duration as defined in [RFC4710], Section 5.9, then the raqmonPartRepSessionDuration bit will be set. If the participant can report the Setup Status as defined in [RFC4710], Section 5.10, then the raqmonPartRepSetupStatus bit will be set. If the participant can report the Round-Trip End-to-end Network Delay as defined in [RFC4710], Section 5.11, then the raqmonPartRepRTEnd2EndNetDelay bit will be set. If the participant can report the One-way End-to-end Network Delay as defined in [RFC4710], Section 5.12, then the raqmonPartRepOWEnd2EndNetDelay bit will be set. If the participant can report the Application Delay as defined in [RFC4710], Section 5.13, then the raqmonPartApplicationDelay bit will be set. If the participant can report the Inter-Arrival Jitter as defined in [RFC4710], Section 5.14, then the raqmonPartRepIAJitter bit will be set. If the participant can report the IP Packet Delay Variation as defined in [RFC4710], Section 5.15, then the raqmonPartRepIPDV bit will be set. If the participant can report the number of application packets received as defined in [RFC4710], Section 5.16, then the raqmonPartRepRcvdPackets bit will be set. If the participant can report the number of application octets received as defined in [RFC4710], Section 5.17, then the raqmonPartRepRcvdOctets bit will be set. If the participant can report the number of application packets sent as defined in [RFC4710], Section 5.18, then the raqmonPartRepSentPackets bit will be set. If the participant can report the number of application octets sent as defined in [RFC4710], Section 5.19, then the raqmonPartRepSentOctets bit will be set. If the participant can report the number of cumulative packets lost as defined in [RFC4710], Section 5.20, then the raqmonPartRepCumPacketsLoss bit will be set. If the participant can report the fraction of packet loss as defined in [RFC4710], Section 5.21, then the raqmonPartRepFractionPacketsLoss bit will be set. If the participant can report the number of cumulative discards as defined in [RFC4710], Section 5.22, then the raqmonPartRepCumDiscards bit will be set. If the participant can report the fraction of discards as defined in [RFC4710], Section 5.23, then the raqmonPartRepFractionDiscards bit will be set. If the participant can report the Source Payload Type as defined in [RFC4710], Section 5.24, then the raqmonPartRepSrcPayloadType bit will be set. If the participant can report the Destination Payload Type as defined in [RFC4710], Section 5.25, then the raqmonPartRepDestPayloadType bit will be set. If the participant can report the Source Layer 2 Priority as defined in [RFC4710], Section 5.26, then the raqmonPartRepSrcLayer2Priority bit will be set. If the participant can report the Source DSCP/ToS value as defined in [RFC4710], Section 5.27, then the raqmonPartRepSrcToSDscp bit will be set. If the participant can report the Destination Layer 2 Priority as defined in [RFC4710], Section 5.28, then the raqmonPartRepDestLayer2Priority bit will be set. If the participant can report the Destination DSCP/ToS Value as defined in [RFC4710], Section 5.29, then the raqmonPartRepDestToSDscp bit will be set. If the participant can report the CPU utilization as defined in [RFC4710], Section 5.30, then the raqmonPartRepCPU bit will be set. If the participant can report the memory utilization as defined in [RFC4710], Section 5.31, then the raqmonPartRepMemory bit will be set. If the participant can report the Application Name as defined in [RFC4710], Section 5.32, then the raqmonPartRepAppName bit will be set. The capability of reporting of a specific metric does not mandate that the metric must be reported permanently by the data source to the respective collector. Some data sources MAY be configured not to send a metric, or some metrics may not be relevant to the specific application.') raqmon_participant_addr_type = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 4), inet_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAddrType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrType.setDescription('The type of the Internet address of the participant for this session.') raqmon_participant_addr = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 5), inet_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAddr.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddr.setDescription('The Internet Address of the participant for this session. Formatting of this object is determined by the value of raqmonParticipantAddrType.') raqmon_participant_send_port = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 6), inet_port_number()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantSendPort.setReference('Section 5.5 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSendPort.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSendPort.setDescription('Port from which session data is sent. If the value was not reported to the collector, this object will have the value 0.') raqmon_participant_recv_port = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 7), inet_port_number()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantRecvPort.setReference('Section 5.6 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantRecvPort.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantRecvPort.setDescription('Port on which session data is received. If the value was not reported to the collector, this object will have the value 0.') raqmon_participant_setup_delay = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 8), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setReference('Section 5.8 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSetupDelay.setDescription('Session setup time. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_name = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 9), snmp_admin_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantName.setReference('Section 5.3 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantName.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantName.setDescription('The data source name for the participant.') raqmon_participant_app_name = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 10), snmp_admin_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAppName.setReference('Section 5.32 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppName.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppName.setDescription("A string giving the name and possibly the version of the application generating the stream, e.g., 'videotool 1.2.' This information may be useful for debugging purposes and is similar to the Mailer or Mail-System-Version SMTP headers. The tool value is expected to remain constant for the duration of the session.") raqmon_participant_qos_count = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 11), gauge32()).setUnits('entries').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantQosCount.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantQosCount.setDescription('The current number of entries in the raqmonQosTable for this participant and session.') raqmon_participant_end_date = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 12), date_and_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantEndDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantEndDate.setDescription('The date and time of the most recent report received.') raqmon_participant_dest_payload_type = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 13), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 127)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setReference('RFC 3551 and Section 5.25 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestPayloadType.setDescription('Destination Payload Type. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_src_payload_type = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 127)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setReference('RFC 3551 and Section 5.24 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcPayloadType.setDescription('Source Payload Type. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_active = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 15), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantActive.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantActive.setDescription("Value 'true' indicates that the session for this participant is active (open). Value 'false' indicates that the session is closed (terminated).") raqmon_participant_peer = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 16), row_pointer()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantPeer.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeer.setDescription('The pointer to the corresponding entry in this table for the other peer participant. If there is no such entry in the participant table of the collector represented by this SNMP agent, then the value will be { 0 0 }. ') raqmon_participant_peer_addr_type = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 17), inet_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantPeerAddrType.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeerAddrType.setDescription('The type of the Internet address of the peer participant for this session.') raqmon_participant_peer_addr = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 18), inet_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantPeerAddr.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPeerAddr.setDescription('The Internet Address of the peer participant for this session. Formatting of this object is determined by the value of raqmonParticipantPeerAddrType.') raqmon_participant_src_l2_priority = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 19), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 7)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setReference('Section 5.26 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcL2Priority.setDescription('Source Layer 2 Priority. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_dest_l2_priority = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 20), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 7)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setReference('Section 5.28 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestL2Priority.setDescription('Destination Layer 2 Priority. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_src_dscp = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 21), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 63)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setReference('Section 5.27 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantSrcDSCP.setDescription('Source Layer 3 DSCP value. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_dest_dscp = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 22), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 63)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setReference('Section 5.29 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDestDSCP.setDescription('Destination Layer 3 DSCP value.') raqmon_participant_cpu_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 23), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantCpuMean.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMean.setDescription('Mean CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_cpu_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 24), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantCpuMin.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMin.setDescription('Minimum CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_cpu_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 25), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantCpuMax.setReference('Section 5.30 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantCpuMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantCpuMax.setDescription('Maximum CPU utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_memory_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 26), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMean.setDescription('Mean memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_memory_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 27), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMin.setDescription('Minimum memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_memory_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 28), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setReference('Section 5.31 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantMemoryMax.setDescription('Maximum memory utilization. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_rtt_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 29), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMean.setDescription('Mean round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_rtt_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 30), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMin.setDescription('Minimum round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_rtt_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 31), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetRTTMax.setDescription('Maximum round-trip end-to-end network delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ia_jitter_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 32), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMean.setDescription('Mean inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ia_jitter_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 33), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMin.setDescription('Minimum inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ia_jitter_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 34), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIAJitterMax.setDescription('Maximum inter-arrival jitter over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ipdv_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 35), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMean.setDescription('Mean IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ipdv_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 36), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMin.setDescription('Minimum IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_ipdv_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 37), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setReference('Section 5.15 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantIPDVMax.setDescription('Maximum IP packet delay variation over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_owd_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 38), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setReference('Section 5.12 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMean.setDescription('Mean Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_owd_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 39), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setReference('Section 5.12 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMin.setDescription('Minimum Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_net_owd_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 40), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setReference('Section 5.1 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantNetOwdMax.setDescription('Maximum Network one-way delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_app_delay_mean = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 41), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMean.setDescription('Mean application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_app_delay_min = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 42), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMin.setDescription('Minimum application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_app_delay_max = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 43), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setReference('Section 5.13 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAppDelayMax.setDescription('Maximum application delay over the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_packets_rcvd = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 44), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setReference('Section 5.16 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPacketsRcvd.setDescription('Count of packets received for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_packets_sent = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 45), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setReference('Section 5.17 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantPacketsSent.setDescription('Count of packets sent for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_octets_rcvd = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 46), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('Octets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setReference('Section 5.18 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantOctetsRcvd.setDescription('Count of octets received for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_octets_sent = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 47), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('Octets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setReference('Section 5.19 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantOctetsSent.setDescription('Count of octets sent for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_lost_packets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 48), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantLostPackets.setReference('Section 5.20 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantLostPackets.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantLostPackets.setDescription('Count of packets lost by this receiver for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_lost_packets_frct = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 49), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setReference('Section 5.21 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantLostPacketsFrct.setDescription('Fraction of lost packets out of total packets received. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_discards = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 50), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantDiscards.setReference('Section 5.22 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDiscards.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDiscards.setDescription('Count of packets discarded by this receiver for the entire session. If the value was not reported to the collector, this object will have the value -1.') raqmon_participant_discards_frct = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 1, 1, 51), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 100)))).setUnits('percents').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setReference('Section 5.23 of the [RFC4710]') if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantDiscardsFrct.setDescription('Fraction of discarded packets out of total packets received. If the value was not reported to the collector, this object will have the value -1.') raqmon_qos_table = mib_table((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2)) if mibBuilder.loadTexts: raqmonQosTable.setStatus('current') if mibBuilder.loadTexts: raqmonQosTable.setDescription('Table of historical information about quality-of-service data during sessions.') raqmon_qos_entry = mib_table_row((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1)).setIndexNames((0, 'RAQMON-MIB', 'raqmonParticipantStartDate'), (0, 'RAQMON-MIB', 'raqmonParticipantIndex'), (0, 'RAQMON-MIB', 'raqmonQosTime')) if mibBuilder.loadTexts: raqmonQosEntry.setStatus('current') if mibBuilder.loadTexts: raqmonQosEntry.setDescription('Each entry contains information from a single RAQMON packet, related to a single session (application) run by one participant. Indexation by the start time of the session aims to ease sorting by management applications. Agents MUST NOT report identical start times for any two sessions on the same host. Rows are removed for inactive sessions when implementation-specific time or space limits are reached.') raqmon_qos_time = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setUnits('seconds') if mibBuilder.loadTexts: raqmonQosTime.setStatus('current') if mibBuilder.loadTexts: raqmonQosTime.setDescription('Time of this entry measured from the start of the corresponding participant session.') raqmon_qo_s_end2_end_net_delay = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setReference('Section 5.11 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setStatus('current') if mibBuilder.loadTexts: raqmonQoSEnd2EndNetDelay.setDescription('The round-trip time. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qo_s_inter_arrival_jitter = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('milliseconds').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setReference('Section 5.14 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setStatus('current') if mibBuilder.loadTexts: raqmonQoSInterArrivalJitter.setDescription('An estimate of delay variation as observed by this receiver. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_rcvd_packets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosRcvdPackets.setReference('Section 5.16 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosRcvdPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosRcvdPackets.setDescription('Count of packets received by this receiver since the previous entry. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_rcvd_octets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('octets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosRcvdOctets.setReference('Section 5.18 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosRcvdOctets.setStatus('current') if mibBuilder.loadTexts: raqmonQosRcvdOctets.setDescription('Count of octets received by this receiver since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_sent_packets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosSentPackets.setReference('Section 5.17 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSentPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosSentPackets.setDescription('Count of packets sent since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_sent_octets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('octets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosSentOctets.setReference('Section 5.19 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSentOctets.setStatus('current') if mibBuilder.loadTexts: raqmonQosSentOctets.setDescription('Count of octets sent since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_lost_packets = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 8), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 2147483647)))).setUnits('packets').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosLostPackets.setReference('Section 5.20 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosLostPackets.setStatus('current') if mibBuilder.loadTexts: raqmonQosLostPackets.setDescription('A count of packets lost as observed by this receiver since the previous report. Will contain the previous value if there was no report for this time, or -1 if the value has never been reported.') raqmon_qos_session_status = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 2, 1, 9), snmp_admin_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonQosSessionStatus.setReference('Section 5.10 of the [RFC4710]') if mibBuilder.loadTexts: raqmonQosSessionStatus.setStatus('current') if mibBuilder.loadTexts: raqmonQosSessionStatus.setDescription('The session status. Will contain the previous value if there was no report for this time or the zero-length string if no value was ever reported.') raqmon_participant_addr_table = mib_table((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3)) if mibBuilder.loadTexts: raqmonParticipantAddrTable.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrTable.setDescription('Maps raqmonParticipantAddr to the index of the raqmonParticipantTable. This table allows management applications to find entries sorted by raqmonParticipantAddr rather than raqmonParticipantStartDate.') raqmon_participant_addr_entry = mib_table_row((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3, 1)).setIndexNames((0, 'RAQMON-MIB', 'raqmonParticipantAddrType'), (0, 'RAQMON-MIB', 'raqmonParticipantAddr'), (0, 'RAQMON-MIB', 'raqmonParticipantStartDate'), (0, 'RAQMON-MIB', 'raqmonParticipantIndex')) if mibBuilder.loadTexts: raqmonParticipantAddrEntry.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrEntry.setDescription('Each entry corresponds to exactly one entry in the raqmonParticipantEntry: the entry containing the index pair raqmonParticipantStartDate, raqmonParticipantIndex. Note that there is no concern about the indexation of this table exceeding the limits defined by RFC 2578, Section 3.5. According to [RFC4710], Section 5.1, only IPv4 and IPv6 addresses can be reported as participant addresses.') raqmon_participant_addr_end_date = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 1, 3, 1, 1), date_and_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonParticipantAddrEndDate.setStatus('current') if mibBuilder.loadTexts: raqmonParticipantAddrEndDate.setDescription('The value of raqmonParticipantEndDate for the corresponding raqmonParticipantEntry.') raqmon_exception = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 2)) raqmon_session_exception_table = mib_table((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2)) if mibBuilder.loadTexts: raqmonSessionExceptionTable.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionTable.setDescription('This table defines thresholds for the management station to get notifications about sessions that encountered poor quality of service. The information in this table MUST be persistent across agent reboots.') raqmon_session_exception_entry = mib_table_row((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1)).setIndexNames((0, 'RAQMON-MIB', 'raqmonSessionExceptionIndex')) if mibBuilder.loadTexts: raqmonSessionExceptionEntry.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionEntry.setDescription('A conceptual row in the raqmonSessionExceptionTable.') raqmon_session_exception_index = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 65535))) if mibBuilder.loadTexts: raqmonSessionExceptionIndex.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionIndex.setDescription('An index that uniquely identifies an entry in the raqmonSessionExceptionTable. Management applications can determine unused indices by performing GetNext or GetBulk operations on the Table.') raqmon_session_exception_ia_jitter_threshold = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 3), unsigned32()).setUnits('milliseconds').setMaxAccess('readcreate') if mibBuilder.loadTexts: raqmonSessionExceptionIAJitterThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionIAJitterThreshold.setDescription('Threshold for jitter. The value during a session must be greater than or equal to this value for an exception to be created.') raqmon_session_exception_net_rtt_threshold = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 4), unsigned32()).setUnits('milliseconds').setMaxAccess('readcreate') if mibBuilder.loadTexts: raqmonSessionExceptionNetRTTThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionNetRTTThreshold.setDescription('Threshold for round-trip time. The value during a session must be greater than or equal to this value for an exception to be created.') raqmon_session_exception_lost_packets_threshold = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 1000))).setUnits('tenth of a percent').setMaxAccess('readcreate') if mibBuilder.loadTexts: raqmonSessionExceptionLostPacketsThreshold.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionLostPacketsThreshold.setDescription('Threshold for lost packets in units of tenths of a percent. The value during a session must be greater than or equal to this value for an exception to be created.') raqmon_session_exception_row_status = mib_table_column((1, 3, 6, 1, 2, 1, 16, 31, 1, 2, 2, 1, 7), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: raqmonSessionExceptionRowStatus.setStatus('current') if mibBuilder.loadTexts: raqmonSessionExceptionRowStatus.setDescription("This object has a value of 'active' when exceptions are being monitored by the system. A newly-created conceptual row must have all the read-create objects initialized before becoming 'active'. A conceptual row that is in the 'notReady' or 'notInService' state MAY be removed after 5 minutes. No writeable objects can be changed while the row is active.") raqmon_config = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 1, 3)) raqmon_config_port = mib_scalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 1), inet_port_number()).setMaxAccess('readwrite') if mibBuilder.loadTexts: raqmonConfigPort.setStatus('current') if mibBuilder.loadTexts: raqmonConfigPort.setDescription('The UDP port to listen on for RAQMON reports, running on transport protocols other than SNMP. If the RAQMON PDU transport protocol is SNMP, a write operation on this object has no effect, as the standard port 162 is always used. The value of this object MUST be persistent across agent reboots.') raqmon_config_pdu_transport = mib_scalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 2), bits().clone(namedValues=named_values(('other', 0), ('tcp', 1), ('snmp', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonConfigPduTransport.setStatus('current') if mibBuilder.loadTexts: raqmonConfigPduTransport.setDescription('The PDU transport(s) used by this collector. If other(0) is set, the collector supports a transport other than SNMP or TCP. If tcp(1) is set, the collector supports TCP as a transport protocol. If snmp(2) is set, the collector supports SNMP as a transport protocol.') raqmon_config_raqmon_pdus = mib_scalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 3), counter32()).setUnits('PDUs').setMaxAccess('readonly') if mibBuilder.loadTexts: raqmonConfigRaqmonPdus.setStatus('current') if mibBuilder.loadTexts: raqmonConfigRaqmonPdus.setDescription('Count of RAQMON PDUs received by the Collector.') raqmon_config_rds_timeout = mib_scalar((1, 3, 6, 1, 2, 1, 16, 31, 1, 3, 4), unsigned32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: raqmonConfigRDSTimeout.setStatus('current') if mibBuilder.loadTexts: raqmonConfigRDSTimeout.setDescription('The number of seconds since the reception of the last RAQMON PDU from a RDS after which a session between the respective RDS and the collector will be considered terminated. The value of this object MUST be persistent across agent reboots.') raqmon_conformance = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 2)) raqmon_compliances = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 2, 1)) raqmon_groups = mib_identifier((1, 3, 6, 1, 2, 1, 16, 31, 2, 2)) raqmon_compliance = module_compliance((1, 3, 6, 1, 2, 1, 16, 31, 2, 1, 1)).setObjects(('RAQMON-MIB', 'raqmonCollectorGroup'), ('RAQMON-MIB', 'raqmonCollectorNotificationsGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmon_compliance = raqmonCompliance.setStatus('current') if mibBuilder.loadTexts: raqmonCompliance.setDescription('Describes the requirements for conformance to the RAQMON MIB.') raqmon_collector_group = object_group((1, 3, 6, 1, 2, 1, 16, 31, 2, 2, 1)).setObjects(('RAQMON-MIB', 'raqmonParticipantReportCaps'), ('RAQMON-MIB', 'raqmonParticipantAddrType'), ('RAQMON-MIB', 'raqmonParticipantAddr'), ('RAQMON-MIB', 'raqmonParticipantSendPort'), ('RAQMON-MIB', 'raqmonParticipantRecvPort'), ('RAQMON-MIB', 'raqmonParticipantSetupDelay'), ('RAQMON-MIB', 'raqmonParticipantName'), ('RAQMON-MIB', 'raqmonParticipantAppName'), ('RAQMON-MIB', 'raqmonParticipantQosCount'), ('RAQMON-MIB', 'raqmonParticipantEndDate'), ('RAQMON-MIB', 'raqmonParticipantDestPayloadType'), ('RAQMON-MIB', 'raqmonParticipantSrcPayloadType'), ('RAQMON-MIB', 'raqmonParticipantActive'), ('RAQMON-MIB', 'raqmonParticipantPeer'), ('RAQMON-MIB', 'raqmonParticipantPeerAddrType'), ('RAQMON-MIB', 'raqmonParticipantPeerAddr'), ('RAQMON-MIB', 'raqmonParticipantSrcL2Priority'), ('RAQMON-MIB', 'raqmonParticipantDestL2Priority'), ('RAQMON-MIB', 'raqmonParticipantSrcDSCP'), ('RAQMON-MIB', 'raqmonParticipantDestDSCP'), ('RAQMON-MIB', 'raqmonParticipantCpuMean'), ('RAQMON-MIB', 'raqmonParticipantCpuMin'), ('RAQMON-MIB', 'raqmonParticipantCpuMax'), ('RAQMON-MIB', 'raqmonParticipantMemoryMean'), ('RAQMON-MIB', 'raqmonParticipantMemoryMin'), ('RAQMON-MIB', 'raqmonParticipantMemoryMax'), ('RAQMON-MIB', 'raqmonParticipantNetRTTMean'), ('RAQMON-MIB', 'raqmonParticipantNetRTTMin'), ('RAQMON-MIB', 'raqmonParticipantNetRTTMax'), ('RAQMON-MIB', 'raqmonParticipantIAJitterMean'), ('RAQMON-MIB', 'raqmonParticipantIAJitterMin'), ('RAQMON-MIB', 'raqmonParticipantIAJitterMax'), ('RAQMON-MIB', 'raqmonParticipantIPDVMean'), ('RAQMON-MIB', 'raqmonParticipantIPDVMin'), ('RAQMON-MIB', 'raqmonParticipantIPDVMax'), ('RAQMON-MIB', 'raqmonParticipantNetOwdMean'), ('RAQMON-MIB', 'raqmonParticipantNetOwdMin'), ('RAQMON-MIB', 'raqmonParticipantNetOwdMax'), ('RAQMON-MIB', 'raqmonParticipantAppDelayMean'), ('RAQMON-MIB', 'raqmonParticipantAppDelayMin'), ('RAQMON-MIB', 'raqmonParticipantAppDelayMax'), ('RAQMON-MIB', 'raqmonParticipantPacketsRcvd'), ('RAQMON-MIB', 'raqmonParticipantPacketsSent'), ('RAQMON-MIB', 'raqmonParticipantOctetsRcvd'), ('RAQMON-MIB', 'raqmonParticipantOctetsSent'), ('RAQMON-MIB', 'raqmonParticipantLostPackets'), ('RAQMON-MIB', 'raqmonParticipantLostPacketsFrct'), ('RAQMON-MIB', 'raqmonParticipantDiscards'), ('RAQMON-MIB', 'raqmonParticipantDiscardsFrct'), ('RAQMON-MIB', 'raqmonQoSEnd2EndNetDelay'), ('RAQMON-MIB', 'raqmonQoSInterArrivalJitter'), ('RAQMON-MIB', 'raqmonQosRcvdPackets'), ('RAQMON-MIB', 'raqmonQosRcvdOctets'), ('RAQMON-MIB', 'raqmonQosSentPackets'), ('RAQMON-MIB', 'raqmonQosSentOctets'), ('RAQMON-MIB', 'raqmonQosLostPackets'), ('RAQMON-MIB', 'raqmonQosSessionStatus'), ('RAQMON-MIB', 'raqmonParticipantAddrEndDate'), ('RAQMON-MIB', 'raqmonConfigPort'), ('RAQMON-MIB', 'raqmonSessionExceptionIAJitterThreshold'), ('RAQMON-MIB', 'raqmonSessionExceptionNetRTTThreshold'), ('RAQMON-MIB', 'raqmonSessionExceptionLostPacketsThreshold'), ('RAQMON-MIB', 'raqmonSessionExceptionRowStatus'), ('RAQMON-MIB', 'raqmonConfigPduTransport'), ('RAQMON-MIB', 'raqmonConfigRaqmonPdus'), ('RAQMON-MIB', 'raqmonConfigRDSTimeout')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmon_collector_group = raqmonCollectorGroup.setStatus('current') if mibBuilder.loadTexts: raqmonCollectorGroup.setDescription('Objects used in RAQMON by a collector.') raqmon_collector_notifications_group = notification_group((1, 3, 6, 1, 2, 1, 16, 31, 2, 2, 2)).setObjects(('RAQMON-MIB', 'raqmonSessionAlarm')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): raqmon_collector_notifications_group = raqmonCollectorNotificationsGroup.setStatus('current') if mibBuilder.loadTexts: raqmonCollectorNotificationsGroup.setDescription('Notifications emitted by a RAQMON collector.') mibBuilder.exportSymbols('RAQMON-MIB', raqmonParticipantPacketsRcvd=raqmonParticipantPacketsRcvd, raqmonCompliance=raqmonCompliance, raqmonParticipantSetupDelay=raqmonParticipantSetupDelay, raqmonParticipantPacketsSent=raqmonParticipantPacketsSent, raqmonSessionExceptionTable=raqmonSessionExceptionTable, raqmonParticipantDestPayloadType=raqmonParticipantDestPayloadType, raqmonMIBObjects=raqmonMIBObjects, raqmonParticipantReportCaps=raqmonParticipantReportCaps, raqmonQoSEnd2EndNetDelay=raqmonQoSEnd2EndNetDelay, raqmonParticipantPeer=raqmonParticipantPeer, raqmonConformance=raqmonConformance, raqmonParticipantAppDelayMean=raqmonParticipantAppDelayMean, raqmonParticipantCpuMax=raqmonParticipantCpuMax, raqmonParticipantNetRTTMax=raqmonParticipantNetRTTMax, raqmonSessionExceptionIAJitterThreshold=raqmonSessionExceptionIAJitterThreshold, raqmonQosRcvdOctets=raqmonQosRcvdOctets, raqmonParticipantSrcL2Priority=raqmonParticipantSrcL2Priority, raqmonParticipantEndDate=raqmonParticipantEndDate, raqmonQosSentPackets=raqmonQosSentPackets, raqmonParticipantDestDSCP=raqmonParticipantDestDSCP, raqmonSessionExceptionRowStatus=raqmonSessionExceptionRowStatus, raqmonParticipantAppName=raqmonParticipantAppName, raqmonParticipantIAJitterMax=raqmonParticipantIAJitterMax, raqmonQosEntry=raqmonQosEntry, raqmonConfigRDSTimeout=raqmonConfigRDSTimeout, raqmonParticipantActive=raqmonParticipantActive, raqmonParticipantPeerAddrType=raqmonParticipantPeerAddrType, raqmonCompliances=raqmonCompliances, raqmonSessionExceptionEntry=raqmonSessionExceptionEntry, raqmonQosRcvdPackets=raqmonQosRcvdPackets, raqmonParticipantLostPacketsFrct=raqmonParticipantLostPacketsFrct, raqmonQosSessionStatus=raqmonQosSessionStatus, raqmonParticipantOctetsRcvd=raqmonParticipantOctetsRcvd, raqmonCollectorGroup=raqmonCollectorGroup, PYSNMP_MODULE_ID=raqmonMIB, raqmonParticipantIPDVMax=raqmonParticipantIPDVMax, raqmonParticipantTable=raqmonParticipantTable, raqmonParticipantDestL2Priority=raqmonParticipantDestL2Priority, raqmonCollectorNotificationsGroup=raqmonCollectorNotificationsGroup, raqmonParticipantMemoryMin=raqmonParticipantMemoryMin, raqmonParticipantLostPackets=raqmonParticipantLostPackets, raqmonParticipantDiscardsFrct=raqmonParticipantDiscardsFrct, raqmonParticipantAddrEndDate=raqmonParticipantAddrEndDate, raqmonParticipantSrcPayloadType=raqmonParticipantSrcPayloadType, raqmonSession=raqmonSession, raqmonQosLostPackets=raqmonQosLostPackets, raqmonParticipantNetOwdMin=raqmonParticipantNetOwdMin, raqmonQosTable=raqmonQosTable, raqmonParticipantIPDVMin=raqmonParticipantIPDVMin, raqmonParticipantCpuMin=raqmonParticipantCpuMin, raqmonParticipantNetRTTMin=raqmonParticipantNetRTTMin, raqmonParticipantQosCount=raqmonParticipantQosCount, raqmonConfigPduTransport=raqmonConfigPduTransport, raqmonParticipantSendPort=raqmonParticipantSendPort, raqmonParticipantAppDelayMin=raqmonParticipantAppDelayMin, raqmonConfig=raqmonConfig, raqmonGroups=raqmonGroups, raqmonSessionExceptionIndex=raqmonSessionExceptionIndex, raqmonConfigRaqmonPdus=raqmonConfigRaqmonPdus, raqmonConfigPort=raqmonConfigPort, raqmonParticipantSrcDSCP=raqmonParticipantSrcDSCP, raqmonMIB=raqmonMIB, raqmonQosTime=raqmonQosTime, raqmonParticipantIndex=raqmonParticipantIndex, raqmonParticipantRecvPort=raqmonParticipantRecvPort, raqmonSessionAlarm=raqmonSessionAlarm, raqmonParticipantStartDate=raqmonParticipantStartDate, raqmonSessionExceptionLostPacketsThreshold=raqmonSessionExceptionLostPacketsThreshold, raqmonParticipantAppDelayMax=raqmonParticipantAppDelayMax, raqmonParticipantDiscards=raqmonParticipantDiscards, raqmonParticipantAddrType=raqmonParticipantAddrType, raqmonParticipantCpuMean=raqmonParticipantCpuMean, raqmonParticipantIAJitterMin=raqmonParticipantIAJitterMin, raqmonParticipantOctetsSent=raqmonParticipantOctetsSent, raqmonNotifications=raqmonNotifications, raqmonParticipantNetRTTMean=raqmonParticipantNetRTTMean, raqmonParticipantMemoryMax=raqmonParticipantMemoryMax, raqmonParticipantAddr=raqmonParticipantAddr, raqmonQosSentOctets=raqmonQosSentOctets, raqmonParticipantMemoryMean=raqmonParticipantMemoryMean, raqmonParticipantPeerAddr=raqmonParticipantPeerAddr, raqmonParticipantName=raqmonParticipantName, raqmonSessionExceptionNetRTTThreshold=raqmonSessionExceptionNetRTTThreshold, raqmonParticipantAddrEntry=raqmonParticipantAddrEntry, raqmonParticipantIAJitterMean=raqmonParticipantIAJitterMean, raqmonParticipantEntry=raqmonParticipantEntry, raqmonParticipantAddrTable=raqmonParticipantAddrTable, raqmonQoSInterArrivalJitter=raqmonQoSInterArrivalJitter, raqmonParticipantIPDVMean=raqmonParticipantIPDVMean, raqmonParticipantNetOwdMean=raqmonParticipantNetOwdMean, raqmonParticipantNetOwdMax=raqmonParticipantNetOwdMax, raqmonException=raqmonException)
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Coupon_validity, obj[4]: Gender, obj[5]: Age, obj[6]: Children, obj[7]: Education, obj[8]: Occupation, obj[9]: Income, obj[10]: Bar, obj[11]: Coffeehouse, obj[12]: Restaurant20to50, obj[13]: Direction_same, obj[14]: Distance # {"feature": "Passanger", "instances": 127, "metric_value": 0.9978, "depth": 1} if obj[0]<=1: # {"feature": "Bar", "instances": 75, "metric_value": 0.971, "depth": 2} if obj[10]<=1.0: # {"feature": "Coupon", "instances": 45, "metric_value": 0.8673, "depth": 3} if obj[2]>0: # {"feature": "Occupation", "instances": 36, "metric_value": 0.9436, "depth": 4} if obj[8]<=14: # {"feature": "Coffeehouse", "instances": 31, "metric_value": 0.9812, "depth": 5} if obj[11]<=2.0: # {"feature": "Education", "instances": 27, "metric_value": 0.999, "depth": 6} if obj[7]>0: # {"feature": "Time", "instances": 17, "metric_value": 0.9367, "depth": 7} if obj[1]>0: # {"feature": "Age", "instances": 12, "metric_value": 1.0, "depth": 8} if obj[5]<=4: # {"feature": "Restaurant20to50", "instances": 10, "metric_value": 0.971, "depth": 9} if obj[12]>0.0: # {"feature": "Income", "instances": 8, "metric_value": 1.0, "depth": 10} if obj[9]>0: # {"feature": "Direction_same", "instances": 7, "metric_value": 0.9852, "depth": 11} if obj[13]<=0: # {"feature": "Coupon_validity", "instances": 6, "metric_value": 1.0, "depth": 12} if obj[3]<=0: # {"feature": "Distance", "instances": 5, "metric_value": 0.971, "depth": 13} if obj[14]>1: # {"feature": "Gender", "instances": 4, "metric_value": 1.0, "depth": 14} if obj[4]>0: # {"feature": "Children", "instances": 3, "metric_value": 0.9183, "depth": 15} if obj[6]<=0: return 'True' elif obj[6]>0: return 'False' else: return 'False' elif obj[4]<=0: return 'True' else: return 'True' elif obj[14]<=1: return 'False' else: return 'False' elif obj[3]>0: return 'True' else: return 'True' elif obj[13]>0: return 'False' else: return 'False' elif obj[9]<=0: return 'True' else: return 'True' elif obj[12]<=0.0: return 'False' else: return 'False' elif obj[5]>4: return 'True' else: return 'True' elif obj[1]<=0: return 'False' else: return 'False' elif obj[7]<=0: # {"feature": "Coupon_validity", "instances": 10, "metric_value": 0.8813, "depth": 7} if obj[3]>0: # {"feature": "Distance", "instances": 6, "metric_value": 1.0, "depth": 8} if obj[14]<=1: return 'True' elif obj[14]>1: return 'False' else: return 'False' elif obj[3]<=0: return 'True' else: return 'True' else: return 'True' elif obj[11]>2.0: return 'False' else: return 'False' elif obj[8]>14: return 'False' else: return 'False' elif obj[2]<=0: return 'False' else: return 'False' elif obj[10]>1.0: # {"feature": "Age", "instances": 30, "metric_value": 0.9871, "depth": 3} if obj[5]>0: # {"feature": "Income", "instances": 27, "metric_value": 0.951, "depth": 4} if obj[9]<=4: # {"feature": "Occupation", "instances": 21, "metric_value": 0.9984, "depth": 5} if obj[8]>1: # {"feature": "Restaurant20to50", "instances": 18, "metric_value": 0.9911, "depth": 6} if obj[12]>0.0: # {"feature": "Distance", "instances": 16, "metric_value": 1.0, "depth": 7} if obj[14]<=2: # {"feature": "Time", "instances": 14, "metric_value": 0.9852, "depth": 8} if obj[1]>0: # {"feature": "Education", "instances": 10, "metric_value": 0.8813, "depth": 9} if obj[7]<=3: # {"feature": "Children", "instances": 9, "metric_value": 0.7642, "depth": 10} if obj[6]<=0: # {"feature": "Gender", "instances": 7, "metric_value": 0.8631, "depth": 11} if obj[4]<=0: # {"feature": "Coupon_validity", "instances": 6, "metric_value": 0.65, "depth": 12} if obj[3]<=0: return 'True' elif obj[3]>0: # {"feature": "Coffeehouse", "instances": 2, "metric_value": 1.0, "depth": 13} if obj[11]>2.0: return 'False' elif obj[11]<=2.0: return 'True' else: return 'True' else: return 'False' elif obj[4]>0: return 'False' else: return 'False' elif obj[6]>0: return 'True' else: return 'True' elif obj[7]>3: return 'False' else: return 'False' elif obj[1]<=0: # {"feature": "Coupon", "instances": 4, "metric_value": 0.8113, "depth": 9} if obj[2]>3: return 'False' elif obj[2]<=3: return 'True' else: return 'True' else: return 'False' elif obj[14]>2: return 'False' else: return 'False' elif obj[12]<=0.0: return 'False' else: return 'False' elif obj[8]<=1: return 'True' else: return 'True' elif obj[9]>4: return 'True' else: return 'True' elif obj[5]<=0: return 'False' else: return 'False' else: return 'True' elif obj[0]>1: # {"feature": "Coupon", "instances": 52, "metric_value": 0.8667, "depth": 2} if obj[2]>1: # {"feature": "Coupon_validity", "instances": 38, "metric_value": 0.6892, "depth": 3} if obj[3]<=0: # {"feature": "Income", "instances": 20, "metric_value": 0.2864, "depth": 4} if obj[9]>1: return 'True' elif obj[9]<=1: # {"feature": "Age", "instances": 4, "metric_value": 0.8113, "depth": 5} if obj[5]<=3: return 'True' elif obj[5]>3: return 'False' else: return 'False' else: return 'True' elif obj[3]>0: # {"feature": "Age", "instances": 18, "metric_value": 0.9183, "depth": 4} if obj[5]<=4: # {"feature": "Occupation", "instances": 12, "metric_value": 1.0, "depth": 5} if obj[8]<=7: # {"feature": "Income", "instances": 7, "metric_value": 0.8631, "depth": 6} if obj[9]<=5: # {"feature": "Coffeehouse", "instances": 6, "metric_value": 0.65, "depth": 7} if obj[11]<=2.0: return 'False' elif obj[11]>2.0: # {"feature": "Time", "instances": 2, "metric_value": 1.0, "depth": 8} if obj[1]>2: return 'False' elif obj[1]<=2: return 'True' else: return 'True' else: return 'False' elif obj[9]>5: return 'True' else: return 'True' elif obj[8]>7: # {"feature": "Coffeehouse", "instances": 5, "metric_value": 0.7219, "depth": 6} if obj[11]>0.0: return 'True' elif obj[11]<=0.0: return 'False' else: return 'False' else: return 'True' elif obj[5]>4: return 'True' else: return 'True' else: return 'True' elif obj[2]<=1: # {"feature": "Bar", "instances": 14, "metric_value": 0.9852, "depth": 3} if obj[10]>0.0: # {"feature": "Age", "instances": 9, "metric_value": 0.9183, "depth": 4} if obj[5]>3: return 'True' elif obj[5]<=3: # {"feature": "Income", "instances": 4, "metric_value": 0.8113, "depth": 5} if obj[9]>2: return 'False' elif obj[9]<=2: return 'True' else: return 'True' else: return 'False' elif obj[10]<=0.0: return 'False' else: return 'False' else: return 'False' else: return 'True'
def find_decision(obj): if obj[0] <= 1: if obj[10] <= 1.0: if obj[2] > 0: if obj[8] <= 14: if obj[11] <= 2.0: if obj[7] > 0: if obj[1] > 0: if obj[5] <= 4: if obj[12] > 0.0: if obj[9] > 0: if obj[13] <= 0: if obj[3] <= 0: if obj[14] > 1: if obj[4] > 0: if obj[6] <= 0: return 'True' elif obj[6] > 0: return 'False' else: return 'False' elif obj[4] <= 0: return 'True' else: return 'True' elif obj[14] <= 1: return 'False' else: return 'False' elif obj[3] > 0: return 'True' else: return 'True' elif obj[13] > 0: return 'False' else: return 'False' elif obj[9] <= 0: return 'True' else: return 'True' elif obj[12] <= 0.0: return 'False' else: return 'False' elif obj[5] > 4: return 'True' else: return 'True' elif obj[1] <= 0: return 'False' else: return 'False' elif obj[7] <= 0: if obj[3] > 0: if obj[14] <= 1: return 'True' elif obj[14] > 1: return 'False' else: return 'False' elif obj[3] <= 0: return 'True' else: return 'True' else: return 'True' elif obj[11] > 2.0: return 'False' else: return 'False' elif obj[8] > 14: return 'False' else: return 'False' elif obj[2] <= 0: return 'False' else: return 'False' elif obj[10] > 1.0: if obj[5] > 0: if obj[9] <= 4: if obj[8] > 1: if obj[12] > 0.0: if obj[14] <= 2: if obj[1] > 0: if obj[7] <= 3: if obj[6] <= 0: if obj[4] <= 0: if obj[3] <= 0: return 'True' elif obj[3] > 0: if obj[11] > 2.0: return 'False' elif obj[11] <= 2.0: return 'True' else: return 'True' else: return 'False' elif obj[4] > 0: return 'False' else: return 'False' elif obj[6] > 0: return 'True' else: return 'True' elif obj[7] > 3: return 'False' else: return 'False' elif obj[1] <= 0: if obj[2] > 3: return 'False' elif obj[2] <= 3: return 'True' else: return 'True' else: return 'False' elif obj[14] > 2: return 'False' else: return 'False' elif obj[12] <= 0.0: return 'False' else: return 'False' elif obj[8] <= 1: return 'True' else: return 'True' elif obj[9] > 4: return 'True' else: return 'True' elif obj[5] <= 0: return 'False' else: return 'False' else: return 'True' elif obj[0] > 1: if obj[2] > 1: if obj[3] <= 0: if obj[9] > 1: return 'True' elif obj[9] <= 1: if obj[5] <= 3: return 'True' elif obj[5] > 3: return 'False' else: return 'False' else: return 'True' elif obj[3] > 0: if obj[5] <= 4: if obj[8] <= 7: if obj[9] <= 5: if obj[11] <= 2.0: return 'False' elif obj[11] > 2.0: if obj[1] > 2: return 'False' elif obj[1] <= 2: return 'True' else: return 'True' else: return 'False' elif obj[9] > 5: return 'True' else: return 'True' elif obj[8] > 7: if obj[11] > 0.0: return 'True' elif obj[11] <= 0.0: return 'False' else: return 'False' else: return 'True' elif obj[5] > 4: return 'True' else: return 'True' else: return 'True' elif obj[2] <= 1: if obj[10] > 0.0: if obj[5] > 3: return 'True' elif obj[5] <= 3: if obj[9] > 2: return 'False' elif obj[9] <= 2: return 'True' else: return 'True' else: return 'False' elif obj[10] <= 0.0: return 'False' else: return 'False' else: return 'False' else: return 'True'
def fib(x): if x < 2: return x return fib(x - 1) + fib(x-2) if __name__ == "__main__": N = int(input()) while N > 0: x = int(input()) print(fib(x)) N = N - 1
def fib(x): if x < 2: return x return fib(x - 1) + fib(x - 2) if __name__ == '__main__': n = int(input()) while N > 0: x = int(input()) print(fib(x)) n = N - 1
T = int(input()) for _ in range(T): for i in range(1, 1001): print(i**2) a = int(input()) if a==0: continue else: break
t = int(input()) for _ in range(T): for i in range(1, 1001): print(i ** 2) a = int(input()) if a == 0: continue else: break
"""Tiered Lists - a simple way to group items into tiers (at insertion time) while maintaining uniqueness.""" class TieredLists(object): def __init__(self, tiers): self.tiers = sorted(tiers, reverse=True) self.bags = {} for t in self.tiers: self.bags[t] = set() def get_tier(self, key): """Determine in which tier a key should be inserted. Returns ------- int if the value is greater than at least one of the tiers None if the value is less than the least tier.""" tier = None for t in self.tiers: if key >= t: tier = t break return tier def add(self, key, value): """Adds a value to a tier based upon where key fits in the tiers Parameters ---------- key : int used to select the tier into which this value will be inserted value : basestring to be inserted in the set for the tier. Returns ------- int int identifying into which tier the item was inserted. None if the key was too low for the lowest tier.""" tier = self.get_tier(key) if tier is not None: self.bags[tier].add(value) return tier def bag(self, tier): return self.bags[tier] def __str__(self): msg = "{{ tiers: {}, bags: {{".format(self.tiers) for t, vals in sorted(self.bags.items(), reverse=True): msg += "\n{}: {}, {}".format(t, len(vals), vals) msg += "} }" return msg
"""Tiered Lists - a simple way to group items into tiers (at insertion time) while maintaining uniqueness.""" class Tieredlists(object): def __init__(self, tiers): self.tiers = sorted(tiers, reverse=True) self.bags = {} for t in self.tiers: self.bags[t] = set() def get_tier(self, key): """Determine in which tier a key should be inserted. Returns ------- int if the value is greater than at least one of the tiers None if the value is less than the least tier.""" tier = None for t in self.tiers: if key >= t: tier = t break return tier def add(self, key, value): """Adds a value to a tier based upon where key fits in the tiers Parameters ---------- key : int used to select the tier into which this value will be inserted value : basestring to be inserted in the set for the tier. Returns ------- int int identifying into which tier the item was inserted. None if the key was too low for the lowest tier.""" tier = self.get_tier(key) if tier is not None: self.bags[tier].add(value) return tier def bag(self, tier): return self.bags[tier] def __str__(self): msg = '{{ tiers: {}, bags: {{'.format(self.tiers) for (t, vals) in sorted(self.bags.items(), reverse=True): msg += '\n{}: {}, {}'.format(t, len(vals), vals) msg += '} }' return msg
class BaseException(object): ''' The base exception class (equivalent to System.Exception) ''' def __init__(self): self.message = None
class Baseexception(object): """ The base exception class (equivalent to System.Exception) """ def __init__(self): self.message = None
"""Module responsible for client implementation """ class ScrollClient: """ ScrollClient ------------ Class responsible for client implementation """ def __init__(self): self._comm_channel = None @property def comm_channel(self): return self._comm_channel @comm_channel.setter def comm_channel(self, channel_obj): self._comm_channel = channel_obj def show_commands_output(self, cmd_output): cmd_output = cmd_output.decode("utf8") print(cmd_output) def command_loop(self): command_input = "" while command_input != "quit": command_input = input(">> ") command_to_send = self.parse_command_input(command_input) cmd_output = self._comm_channel.send_command(command_to_send) self.show_commands_output(cmd_output)
"""Module responsible for client implementation """ class Scrollclient: """ ScrollClient ------------ Class responsible for client implementation """ def __init__(self): self._comm_channel = None @property def comm_channel(self): return self._comm_channel @comm_channel.setter def comm_channel(self, channel_obj): self._comm_channel = channel_obj def show_commands_output(self, cmd_output): cmd_output = cmd_output.decode('utf8') print(cmd_output) def command_loop(self): command_input = '' while command_input != 'quit': command_input = input('>> ') command_to_send = self.parse_command_input(command_input) cmd_output = self._comm_channel.send_command(command_to_send) self.show_commands_output(cmd_output)
class Name(object): def __init__(self, normal: str, folded: str): self.normal = normal self.folded = folded
class Name(object): def __init__(self, normal: str, folded: str): self.normal = normal self.folded = folded
#!/usr/bin/env python # -*- coding: utf-8 -*- """ author: meng.xiang date: 2019-05-08 description: """ class CAP_STYLE(object): round = 1 flat = 2 square = 3 class JOIN_STYLE(object): round = 1 mitre = 2 bevel = 3
""" author: meng.xiang date: 2019-05-08 description: """ class Cap_Style(object): round = 1 flat = 2 square = 3 class Join_Style(object): round = 1 mitre = 2 bevel = 3
n = int(input()) x = list(map(int, input().split())) m = 0 e = 0 c = 0 for n in x: m += abs(n) e += n ** 2 c = max(c, abs(n)) print(m) print(e ** 0.5) print(c)
n = int(input()) x = list(map(int, input().split())) m = 0 e = 0 c = 0 for n in x: m += abs(n) e += n ** 2 c = max(c, abs(n)) print(m) print(e ** 0.5) print(c)
class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(strs) == 1: output = strs[0] if strs == []: output = "" else: output = '' j = 0 Flag = True try: while Flag: tmp = 0 for i in range(len(strs)): if strs[i] == "": return "" elif strs[0][j] == strs[i][j]: tmp += 1 if tmp == len(strs): output += strs[0][j] j += 1 else: Flag = False except IndexError: pass return output
class Solution(object): def longest_common_prefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(strs) == 1: output = strs[0] if strs == []: output = '' else: output = '' j = 0 flag = True try: while Flag: tmp = 0 for i in range(len(strs)): if strs[i] == '': return '' elif strs[0][j] == strs[i][j]: tmp += 1 if tmp == len(strs): output += strs[0][j] j += 1 else: flag = False except IndexError: pass return output
""" @date: 5-14-16 Description: Creates the conflict and broad outlines of story relations """ class Conflict: def __init__(relation_outline_array=None): self.conflict_outline = relation_outline_array def add_relation(relation_outline): self.conflict_outline.append(relation_outline)
""" @date: 5-14-16 Description: Creates the conflict and broad outlines of story relations """ class Conflict: def __init__(relation_outline_array=None): self.conflict_outline = relation_outline_array def add_relation(relation_outline): self.conflict_outline.append(relation_outline)
#!/usr/bin/env python3 # String to be evaluated s = "azcbobobegghakl" # Initialize count count = 0 # Vowels that will be evaluted inside s vowels = "aeiou" # For loop to count vowels in var s for letter in s: if letter in vowels: count += 1 # Prints final count to terminal print("Number of vowels in " + s + ": " + str(count))
s = 'azcbobobegghakl' count = 0 vowels = 'aeiou' for letter in s: if letter in vowels: count += 1 print('Number of vowels in ' + s + ': ' + str(count))
class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ ls=s.split(" ") lt=[] for x in ls: x=x[::-1] lt.append(x) return " ".join(lt)
class Solution(object): def reverse_words(self, s): """ :type s: str :rtype: str """ ls = s.split(' ') lt = [] for x in ls: x = x[::-1] lt.append(x) return ' '.join(lt)
def diglet(i_buraco_origem, buracos): if buracos[i_buraco_origem] == -99: return 0 else: i_buraco_destino = buracos[i_buraco_origem] - 1 buracos[i_buraco_origem] = -99 return 1 + diglet(i_buraco_destino, buracos) def mdc_euclide(a, b): if b == 0: return a else: return mdc_euclide(b, a % b) n = int(input()) buracos = list(map(int, input().split())) caminhos = [] for i in range(0, n): ciclo = diglet(i, buracos) if ciclo != 0: caminhos.append(ciclo) mmc = caminhos[0] for j in range(0, len(caminhos) - 1): mmc = mmc * caminhos[j+1] / mdc_euclide(mmc, caminhos[j+1]) print("%i" % mmc)
def diglet(i_buraco_origem, buracos): if buracos[i_buraco_origem] == -99: return 0 else: i_buraco_destino = buracos[i_buraco_origem] - 1 buracos[i_buraco_origem] = -99 return 1 + diglet(i_buraco_destino, buracos) def mdc_euclide(a, b): if b == 0: return a else: return mdc_euclide(b, a % b) n = int(input()) buracos = list(map(int, input().split())) caminhos = [] for i in range(0, n): ciclo = diglet(i, buracos) if ciclo != 0: caminhos.append(ciclo) mmc = caminhos[0] for j in range(0, len(caminhos) - 1): mmc = mmc * caminhos[j + 1] / mdc_euclide(mmc, caminhos[j + 1]) print('%i' % mmc)
x = ['happy','sad','cheerful'] print('{0},{1},{2}'.format(x[0],x[1].x[2])) ##-------------------------------------------## a = "{x}, {y}".format(x=5, y=12) print(a)
x = ['happy', 'sad', 'cheerful'] print('{0},{1},{2}'.format(x[0], x[1].x[2])) a = '{x}, {y}'.format(x=5, y=12) print(a)
class UpdateContext: """ Used when updating data. Helps keeping track of whether the data was updated or not. """ data: str data_was_updated: bool = False def __init__(self, data: str): self.data = data def override_data(self, new_data: str) -> None: self.data = new_data self.data_was_updated = True
class Updatecontext: """ Used when updating data. Helps keeping track of whether the data was updated or not. """ data: str data_was_updated: bool = False def __init__(self, data: str): self.data = data def override_data(self, new_data: str) -> None: self.data = new_data self.data_was_updated = True
""" MadQt - Tutorials and Tools for PyQt and PySide All the Code in this package can be used freely for personal and commercial projects under a MIT License but remember that because this is an extension of the PyQt framework you will need to abide to the QT licensing scheme when releasing. ## $MADQT_BEGIN_LICENSE ## MIT License ## ## Copyright (c) 2021 Fabio Goncalves ## ## Permission is hereby granted, free of charge, to any person obtaining a copy ## of this software and associated documentation files (the "Software"), to deal ## in the Software without restriction, including without limitation the rights ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: ## ## The above copyright notice and this permission notice shall be included in all ## copies or substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ## SOFTWARE. ## $MADQT_END_LICENSE ## $QT_BEGIN_LICENSE:BSD$ ## Commercial License Usage ## Licensees holding valid commercial Qt licenses may use this file in ## accordance with the commercial license agreement provided with the ## Software or, alternatively, in accordance with the terms contained in ## a written agreement between you and The Qt Company. For licensing terms ## and conditions see https://www.qt.io/terms-conditions. For further ## information use the contact form at https://www.qt.io/contact-us. ## ## BSD License Usage ## Alternatively, you may use this file under the terms of the BSD license ## as follows: ## ## "Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in ## the documentation and/or other materials provided with the ## distribution. ## * Neither the name of The Qt Company Ltd nor the names of its ## contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ## $QT_END_LICENSE$ """
""" MadQt - Tutorials and Tools for PyQt and PySide All the Code in this package can be used freely for personal and commercial projects under a MIT License but remember that because this is an extension of the PyQt framework you will need to abide to the QT licensing scheme when releasing. ## $MADQT_BEGIN_LICENSE ## MIT License ## ## Copyright (c) 2021 Fabio Goncalves ## ## Permission is hereby granted, free of charge, to any person obtaining a copy ## of this software and associated documentation files (the "Software"), to deal ## in the Software without restriction, including without limitation the rights ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: ## ## The above copyright notice and this permission notice shall be included in all ## copies or substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ## SOFTWARE. ## $MADQT_END_LICENSE ## $QT_BEGIN_LICENSE:BSD$ ## Commercial License Usage ## Licensees holding valid commercial Qt licenses may use this file in ## accordance with the commercial license agreement provided with the ## Software or, alternatively, in accordance with the terms contained in ## a written agreement between you and The Qt Company. For licensing terms ## and conditions see https://www.qt.io/terms-conditions. For further ## information use the contact form at https://www.qt.io/contact-us. ## ## BSD License Usage ## Alternatively, you may use this file under the terms of the BSD license ## as follows: ## ## "Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in ## the documentation and/or other materials provided with the ## distribution. ## * Neither the name of The Qt Company Ltd nor the names of its ## contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ## $QT_END_LICENSE$ """
class Book: def __init__(self,title,author): self.title = title self.author = author def __str__(self): return '{} by {}'.format(self.title,self.author) class Bookcase(): def __init__(self,books=None): self.books = books @classmethod def create_bookcase(cls,book_list): books = [] for title, author in book_list: books.append(Book(title,author)) return cls(books)
class Book: def __init__(self, title, author): self.title = title self.author = author def __str__(self): return '{} by {}'.format(self.title, self.author) class Bookcase: def __init__(self, books=None): self.books = books @classmethod def create_bookcase(cls, book_list): books = [] for (title, author) in book_list: books.append(book(title, author)) return cls(books)
class FileSystemWatcher(Component): """ Listens to the file system change notifications and raises events when a directory,or file in a directory,changes. FileSystemWatcher() FileSystemWatcher(path: str) FileSystemWatcher(path: str,filter: str) """ def ZZZ(self): """hardcoded/mock instance of the class""" return FileSystemWatcher() instance=ZZZ() """hardcoded/returns an instance of the class""" def BeginInit(self): """ BeginInit(self: FileSystemWatcher) Begins the initialization of a System.IO.FileSystemWatcher used on a form or used by another component. The initialization occurs at run time. """ pass def Dispose(self): """ Dispose(self: FileSystemWatcher,disposing: bool) Releases the unmanaged resources used by the System.IO.FileSystemWatcher and optionally releases the managed resources. disposing: true to release both managed and unmanaged resources; false to release only unmanaged resources. """ pass def EndInit(self): """ EndInit(self: FileSystemWatcher) Ends the initialization of a System.IO.FileSystemWatcher used on a form or used by another component. The initialization occurs at run time. """ pass def GetService(self,*args): """ GetService(self: Component,service: Type) -> object Returns an object that represents a service provided by the System.ComponentModel.Component or by its System.ComponentModel.Container. service: A service provided by the System.ComponentModel.Component. Returns: An System.Object that represents a service provided by the System.ComponentModel.Component,or null if the System.ComponentModel.Component does not provide the specified service. """ pass def MemberwiseClone(self,*args): """ MemberwiseClone(self: MarshalByRefObject,cloneIdentity: bool) -> MarshalByRefObject Creates a shallow copy of the current System.MarshalByRefObject object. cloneIdentity: false to delete the current System.MarshalByRefObject object's identity,which will cause the object to be assigned a new identity when it is marshaled across a remoting boundary. A value of false is usually appropriate. true to copy the current System.MarshalByRefObject object's identity to its clone,which will cause remoting client calls to be routed to the remote server object. Returns: A shallow copy of the current System.MarshalByRefObject object. MemberwiseClone(self: object) -> object Creates a shallow copy of the current System.Object. Returns: A shallow copy of the current System.Object. """ pass def OnChanged(self,*args): """ OnChanged(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Changed event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def OnCreated(self,*args): """ OnCreated(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Created event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def OnDeleted(self,*args): """ OnDeleted(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Deleted event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def OnError(self,*args): """ OnError(self: FileSystemWatcher,e: ErrorEventArgs) Raises the System.IO.FileSystemWatcher.Error event. e: An System.IO.ErrorEventArgs that contains the event data. """ pass def OnRenamed(self,*args): """ OnRenamed(self: FileSystemWatcher,e: RenamedEventArgs) Raises the System.IO.FileSystemWatcher.Renamed event. e: A System.IO.RenamedEventArgs that contains the event data. """ pass def WaitForChanged(self,changeType,timeout=None): """ WaitForChanged(self: FileSystemWatcher,changeType: WatcherChangeTypes) -> WaitForChangedResult A synchronous method that returns a structure that contains specific information on the change that occurred,given the type of change you want to monitor. changeType: The System.IO.WatcherChangeTypes to watch for. Returns: A System.IO.WaitForChangedResult that contains specific information on the change that occurred. WaitForChanged(self: FileSystemWatcher,changeType: WatcherChangeTypes,timeout: int) -> WaitForChangedResult A synchronous method that returns a structure that contains specific information on the change that occurred,given the type of change you want to monitor and the time (in milliseconds) to wait before timing out. changeType: The System.IO.WatcherChangeTypes to watch for. timeout: The time (in milliseconds) to wait before timing out. Returns: A System.IO.WaitForChangedResult that contains specific information on the change that occurred. """ pass def __enter__(self,*args): """ __enter__(self: IDisposable) -> object """ pass def __exit__(self,*args): """ __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """ pass def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self,path=None,filter=None): """ __new__(cls: type) __new__(cls: type,path: str) __new__(cls: type,path: str,filter: str) """ pass def __str__(self,*args): pass CanRaiseEvents=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value indicating whether the component can raise an event. """ DesignMode=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value that indicates whether the System.ComponentModel.Component is currently in design mode. """ EnableRaisingEvents=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets a value indicating whether the component is enabled. Get: EnableRaisingEvents(self: FileSystemWatcher) -> bool Set: EnableRaisingEvents(self: FileSystemWatcher)=value """ Events=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the list of event handlers that are attached to this System.ComponentModel.Component. """ Filter=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the filter string used to determine what files are monitored in a directory. Get: Filter(self: FileSystemWatcher) -> str Set: Filter(self: FileSystemWatcher)=value """ IncludeSubdirectories=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets a value indicating whether subdirectories within the specified path should be monitored. Get: IncludeSubdirectories(self: FileSystemWatcher) -> bool Set: IncludeSubdirectories(self: FileSystemWatcher)=value """ InternalBufferSize=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the size (in bytes) of the internal buffer. Get: InternalBufferSize(self: FileSystemWatcher) -> int Set: InternalBufferSize(self: FileSystemWatcher)=value """ NotifyFilter=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the type of changes to watch for. Get: NotifyFilter(self: FileSystemWatcher) -> NotifyFilters Set: NotifyFilter(self: FileSystemWatcher)=value """ Path=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the path of the directory to watch. Get: Path(self: FileSystemWatcher) -> str Set: Path(self: FileSystemWatcher)=value """ Site=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets an System.ComponentModel.ISite for the System.IO.FileSystemWatcher. Get: Site(self: FileSystemWatcher) -> ISite Set: Site(self: FileSystemWatcher)=value """ SynchronizingObject=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the object used to marshal the event handler calls issued as a result of a directory change. Get: SynchronizingObject(self: FileSystemWatcher) -> ISynchronizeInvoke Set: SynchronizingObject(self: FileSystemWatcher)=value """ Changed=None Created=None Deleted=None Error=None Renamed=None
class Filesystemwatcher(Component): """ Listens to the file system change notifications and raises events when a directory,or file in a directory,changes. FileSystemWatcher() FileSystemWatcher(path: str) FileSystemWatcher(path: str,filter: str) """ def zzz(self): """hardcoded/mock instance of the class""" return file_system_watcher() instance = zzz() 'hardcoded/returns an instance of the class' def begin_init(self): """ BeginInit(self: FileSystemWatcher) Begins the initialization of a System.IO.FileSystemWatcher used on a form or used by another component. The initialization occurs at run time. """ pass def dispose(self): """ Dispose(self: FileSystemWatcher,disposing: bool) Releases the unmanaged resources used by the System.IO.FileSystemWatcher and optionally releases the managed resources. disposing: true to release both managed and unmanaged resources; false to release only unmanaged resources. """ pass def end_init(self): """ EndInit(self: FileSystemWatcher) Ends the initialization of a System.IO.FileSystemWatcher used on a form or used by another component. The initialization occurs at run time. """ pass def get_service(self, *args): """ GetService(self: Component,service: Type) -> object Returns an object that represents a service provided by the System.ComponentModel.Component or by its System.ComponentModel.Container. service: A service provided by the System.ComponentModel.Component. Returns: An System.Object that represents a service provided by the System.ComponentModel.Component,or null if the System.ComponentModel.Component does not provide the specified service. """ pass def memberwise_clone(self, *args): """ MemberwiseClone(self: MarshalByRefObject,cloneIdentity: bool) -> MarshalByRefObject Creates a shallow copy of the current System.MarshalByRefObject object. cloneIdentity: false to delete the current System.MarshalByRefObject object's identity,which will cause the object to be assigned a new identity when it is marshaled across a remoting boundary. A value of false is usually appropriate. true to copy the current System.MarshalByRefObject object's identity to its clone,which will cause remoting client calls to be routed to the remote server object. Returns: A shallow copy of the current System.MarshalByRefObject object. MemberwiseClone(self: object) -> object Creates a shallow copy of the current System.Object. Returns: A shallow copy of the current System.Object. """ pass def on_changed(self, *args): """ OnChanged(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Changed event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def on_created(self, *args): """ OnCreated(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Created event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def on_deleted(self, *args): """ OnDeleted(self: FileSystemWatcher,e: FileSystemEventArgs) Raises the System.IO.FileSystemWatcher.Deleted event. e: A System.IO.FileSystemEventArgs that contains the event data. """ pass def on_error(self, *args): """ OnError(self: FileSystemWatcher,e: ErrorEventArgs) Raises the System.IO.FileSystemWatcher.Error event. e: An System.IO.ErrorEventArgs that contains the event data. """ pass def on_renamed(self, *args): """ OnRenamed(self: FileSystemWatcher,e: RenamedEventArgs) Raises the System.IO.FileSystemWatcher.Renamed event. e: A System.IO.RenamedEventArgs that contains the event data. """ pass def wait_for_changed(self, changeType, timeout=None): """ WaitForChanged(self: FileSystemWatcher,changeType: WatcherChangeTypes) -> WaitForChangedResult A synchronous method that returns a structure that contains specific information on the change that occurred,given the type of change you want to monitor. changeType: The System.IO.WatcherChangeTypes to watch for. Returns: A System.IO.WaitForChangedResult that contains specific information on the change that occurred. WaitForChanged(self: FileSystemWatcher,changeType: WatcherChangeTypes,timeout: int) -> WaitForChangedResult A synchronous method that returns a structure that contains specific information on the change that occurred,given the type of change you want to monitor and the time (in milliseconds) to wait before timing out. changeType: The System.IO.WatcherChangeTypes to watch for. timeout: The time (in milliseconds) to wait before timing out. Returns: A System.IO.WaitForChangedResult that contains specific information on the change that occurred. """ pass def __enter__(self, *args): """ __enter__(self: IDisposable) -> object """ pass def __exit__(self, *args): """ __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """ pass def __init__(self, *args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self, path=None, filter=None): """ __new__(cls: type) __new__(cls: type,path: str) __new__(cls: type,path: str,filter: str) """ pass def __str__(self, *args): pass can_raise_events = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets a value indicating whether the component can raise an event.\n\n\n\n' design_mode = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets a value that indicates whether the System.ComponentModel.Component is currently in design mode.\n\n\n\n' enable_raising_events = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets a value indicating whether the component is enabled.\n\n\n\nGet: EnableRaisingEvents(self: FileSystemWatcher) -> bool\n\n\n\nSet: EnableRaisingEvents(self: FileSystemWatcher)=value\n\n' events = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the list of event handlers that are attached to this System.ComponentModel.Component.\n\n\n\n' filter = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets the filter string used to determine what files are monitored in a directory.\n\n\n\nGet: Filter(self: FileSystemWatcher) -> str\n\n\n\nSet: Filter(self: FileSystemWatcher)=value\n\n' include_subdirectories = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets a value indicating whether subdirectories within the specified path should be monitored.\n\n\n\nGet: IncludeSubdirectories(self: FileSystemWatcher) -> bool\n\n\n\nSet: IncludeSubdirectories(self: FileSystemWatcher)=value\n\n' internal_buffer_size = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets the size (in bytes) of the internal buffer.\n\n\n\nGet: InternalBufferSize(self: FileSystemWatcher) -> int\n\n\n\nSet: InternalBufferSize(self: FileSystemWatcher)=value\n\n' notify_filter = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets the type of changes to watch for.\n\n\n\nGet: NotifyFilter(self: FileSystemWatcher) -> NotifyFilters\n\n\n\nSet: NotifyFilter(self: FileSystemWatcher)=value\n\n' path = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets the path of the directory to watch.\n\n\n\nGet: Path(self: FileSystemWatcher) -> str\n\n\n\nSet: Path(self: FileSystemWatcher)=value\n\n' site = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets an System.ComponentModel.ISite for the System.IO.FileSystemWatcher.\n\n\n\nGet: Site(self: FileSystemWatcher) -> ISite\n\n\n\nSet: Site(self: FileSystemWatcher)=value\n\n' synchronizing_object = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets or sets the object used to marshal the event handler calls issued as a result of a directory change.\n\n\n\nGet: SynchronizingObject(self: FileSystemWatcher) -> ISynchronizeInvoke\n\n\n\nSet: SynchronizingObject(self: FileSystemWatcher)=value\n\n' changed = None created = None deleted = None error = None renamed = None
# # Copyright (c) 2017 - The MITRE Corporation # For license information, see the LICENSE.txt file __version__ = "1.3.0"
__version__ = '1.3.0'
class car(): def __init__(self, make, model, year ): self.make = make self.model = model self.year = year self.odometer = 0 def describe_car(self): long_name = str(self.year)+' '+self.make+' '+self.model return long_name.title() def read_odometer(self): print('This car has '+str(self.odometer)+' miles on it.') def update_odometer(self, mileage): if mileage < self.odometer: print('You cannot roll back the odometer !') else: print('The odometer has updated !') def increase_odometer(self, increment): self.odometer += increment
class Car: def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.odometer = 0 def describe_car(self): long_name = str(self.year) + ' ' + self.make + ' ' + self.model return long_name.title() def read_odometer(self): print('This car has ' + str(self.odometer) + ' miles on it.') def update_odometer(self, mileage): if mileage < self.odometer: print('You cannot roll back the odometer !') else: print('The odometer has updated !') def increase_odometer(self, increment): self.odometer += increment
expected_output = { "route-information": { "route-table": [ { "active-route-count": "16", "destination-count": "16", "hidden-route-count": "0", "holddown-route-count": "0", "rt": [ { "rt-announced-count": "1", "rt-destination": "10.1.0.0", "rt-entry": { "as-path": "AS path: I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "2"}, "rt-prefix-length": "24", }, { "rt-announced-count": "1", "rt-destination": "10.64.4.4", "rt-entry": { "as-path": "AS path: I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "2"}, "rt-prefix-length": "32", }, { "rt-announced-count": "1", "rt-destination": "10.145.0.0", "rt-entry": { "as-path": "AS path: I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "2"}, "rt-prefix-length": "24", }, { "active-tag": "* ", "rt-announced-count": "1", "rt-destination": "192.168.220.0", "rt-entry": { "as-path": "AS path: I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "1"}, "rt-prefix-length": "24", }, { "active-tag": "* ", "rt-announced-count": "1", "rt-destination": "192.168.240.0", "rt-entry": { "as-path": "AS path: 200000 4 5 6 I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "200000 4 5 6 I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "1"}, "rt-prefix-length": "24", }, { "active-tag": "* ", "rt-announced-count": "1", "rt-destination": "192.168.205.0", "rt-entry": { "as-path": "AS path: 200000 4 7 8 I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "200000 4 7 8 I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "1"}, "rt-prefix-length": "24", }, { "active-tag": "* ", "rt-announced-count": "1", "rt-destination": "192.168.115.0", "rt-entry": { "as-path": "AS path: 200000 4 100000 8 I", "bgp-path-attributes": { "attr-as-path-effective": { "aspath-effective-string": "AS path:", "attr-value": "200000 4 100000 8 I", } }, "bgp-rt-flag": "Accepted", "local-preference": "100", "nh": {"to": "10.64.4.4"}, }, "rt-entry-count": {"#text": "1"}, "rt-prefix-length": "24", }, ], "table-name": "inet.0", "total-route-count": "19", }, { "active-route-count": "18", "destination-count": "18", "hidden-route-count": "0", "holddown-route-count": "0", "table-name": "inet6.0", "total-route-count": "20", }, ] } }
expected_output = {'route-information': {'route-table': [{'active-route-count': '16', 'destination-count': '16', 'hidden-route-count': '0', 'holddown-route-count': '0', 'rt': [{'rt-announced-count': '1', 'rt-destination': '10.1.0.0', 'rt-entry': {'as-path': 'AS path: I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': 'I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '2'}, 'rt-prefix-length': '24'}, {'rt-announced-count': '1', 'rt-destination': '10.64.4.4', 'rt-entry': {'as-path': 'AS path: I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': 'I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '2'}, 'rt-prefix-length': '32'}, {'rt-announced-count': '1', 'rt-destination': '10.145.0.0', 'rt-entry': {'as-path': 'AS path: I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': 'I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '2'}, 'rt-prefix-length': '24'}, {'active-tag': '* ', 'rt-announced-count': '1', 'rt-destination': '192.168.220.0', 'rt-entry': {'as-path': 'AS path: I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': 'I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '1'}, 'rt-prefix-length': '24'}, {'active-tag': '* ', 'rt-announced-count': '1', 'rt-destination': '192.168.240.0', 'rt-entry': {'as-path': 'AS path: 200000 4 5 6 I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': '200000 4 5 6 I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '1'}, 'rt-prefix-length': '24'}, {'active-tag': '* ', 'rt-announced-count': '1', 'rt-destination': '192.168.205.0', 'rt-entry': {'as-path': 'AS path: 200000 4 7 8 I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': '200000 4 7 8 I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '1'}, 'rt-prefix-length': '24'}, {'active-tag': '* ', 'rt-announced-count': '1', 'rt-destination': '192.168.115.0', 'rt-entry': {'as-path': 'AS path: 200000 4 100000 8 I', 'bgp-path-attributes': {'attr-as-path-effective': {'aspath-effective-string': 'AS path:', 'attr-value': '200000 4 100000 8 I'}}, 'bgp-rt-flag': 'Accepted', 'local-preference': '100', 'nh': {'to': '10.64.4.4'}}, 'rt-entry-count': {'#text': '1'}, 'rt-prefix-length': '24'}], 'table-name': 'inet.0', 'total-route-count': '19'}, {'active-route-count': '18', 'destination-count': '18', 'hidden-route-count': '0', 'holddown-route-count': '0', 'table-name': 'inet6.0', 'total-route-count': '20'}]}}
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? https://projecteuler.net/problem=7 """ # Cache a few primes to get the algorithm started. # Note: the odd values allow the step of 2 in next_prime() primes = [2, 3, 5] # Shortcut for multi-use: save the largest non-prime # tested for subsequent prime searches # test_val = primes[-1] def prime_number(count): """ Returns the nth prime. Adapted from code in prob3.py """ test_val = primes[-1] while len(primes) <= count: # No point testing even numbers test_val += 2 divisible = False # Compare to known primes for i in primes: if test_val % i == 0: divisible = True break if not divisible: # New prime found! primes.append(test_val) # print(primes, count, primes[count - 1]) result = primes[count - 1] # print("Prime #{} is {}".format(count, result)) return primes[count - 1] assert prime_number(1) == 2 assert prime_number(2) == 3 assert prime_number(3) == 5 assert prime_number(4) == 7 assert prime_number(5) == 11 assert prime_number(6) == 13 print(prime_number(10001))
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? https://projecteuler.net/problem=7 """ primes = [2, 3, 5] def prime_number(count): """ Returns the nth prime. Adapted from code in prob3.py """ test_val = primes[-1] while len(primes) <= count: test_val += 2 divisible = False for i in primes: if test_val % i == 0: divisible = True break if not divisible: primes.append(test_val) result = primes[count - 1] return primes[count - 1] assert prime_number(1) == 2 assert prime_number(2) == 3 assert prime_number(3) == 5 assert prime_number(4) == 7 assert prime_number(5) == 11 assert prime_number(6) == 13 print(prime_number(10001))
command = input() numbers = [int(n) for n in input().split()] command_numbers = [] def add_command_numbers(num): if (num % 2 == 0 and command == "Even") or (num % 2 != 0 and command == "Odd"): command_numbers.append(num) for n in numbers: add_command_numbers(n) print(sum(command_numbers)*len(numbers))
command = input() numbers = [int(n) for n in input().split()] command_numbers = [] def add_command_numbers(num): if num % 2 == 0 and command == 'Even' or (num % 2 != 0 and command == 'Odd'): command_numbers.append(num) for n in numbers: add_command_numbers(n) print(sum(command_numbers) * len(numbers))
class Env(object): user='test' password='test' port=5432 host='localhost' dbname='todo' development=False env = Env()
class Env(object): user = 'test' password = 'test' port = 5432 host = 'localhost' dbname = 'todo' development = False env = env()
def get_phase_dir(self): """Return the Rotation direction of the stator phases Parameters ---------- self : LUT A LUT object Returns ------- phase_dir : int Rotation direction of the stator phase """ return self.output_list[0].elec.phase_dir
def get_phase_dir(self): """Return the Rotation direction of the stator phases Parameters ---------- self : LUT A LUT object Returns ------- phase_dir : int Rotation direction of the stator phase """ return self.output_list[0].elec.phase_dir
day09 = __import__("day-09") process = day09.process_gen rotor = { 0: {'N': 'W', 'W': 'S', 'S': 'E', 'E': 'N'}, 1: {'N': 'E', 'E': 'S', 'S': 'W', 'W': 'N'}, } diff = { 'N': (0, 1), 'E': (1, 0), 'S': (0, -1), 'W': (-1, 0), } def draw(data, panels): direction = 'N' coord = (0, 0) try: inp = [] g = process(data, inp) while True: current_color = panels.get(coord, 0) inp.append(current_color) color = next(g) panels[coord] = color rotate = next(g) direction = rotor[rotate][direction] dd = diff[direction] coord = coord[0] + dd[0], coord[1] + dd[1] except StopIteration: pass return panels def test_case1(): with open('day-11.txt', 'r') as f: text = f.read().strip() data = [int(x) for x in text.split(',')] panels = dict() draw(data, panels) xmin = min(x[0] for x in panels.keys()) xmax = max(x[0] for x in panels.keys()) ymin = min(x[1] for x in panels.keys()) ymax = max(x[1] for x in panels.keys()) w = xmax - xmin h = ymax - ymin for j in range(ymin, ymax): for i in range(xmin, xmax): c = (i, j) color = panels.get(c, 0) print('#' if color == 1 else '.', end='') print() assert len(panels) == 2339 def test_case2(): with open('day-11.txt', 'r') as f: text = f.read().strip() data = [int(x) for x in text.split(',')] panels = dict() panels[(0, 0)] = 1 draw(data, panels) xmin = min(x[0] for x in panels.keys()) - 2 xmax = max(x[0] for x in panels.keys()) + 2 ymin = min(x[1] for x in panels.keys()) - 2 ymax = max(x[1] for x in panels.keys()) + 2 w = xmax - xmin h = ymax - ymin for j in range(ymax, ymin, -1): for i in range(xmin, xmax): c = (i, j) color = panels.get(c, 0) print('#' if color == 1 else '.', end='') print() assert False
day09 = __import__('day-09') process = day09.process_gen rotor = {0: {'N': 'W', 'W': 'S', 'S': 'E', 'E': 'N'}, 1: {'N': 'E', 'E': 'S', 'S': 'W', 'W': 'N'}} diff = {'N': (0, 1), 'E': (1, 0), 'S': (0, -1), 'W': (-1, 0)} def draw(data, panels): direction = 'N' coord = (0, 0) try: inp = [] g = process(data, inp) while True: current_color = panels.get(coord, 0) inp.append(current_color) color = next(g) panels[coord] = color rotate = next(g) direction = rotor[rotate][direction] dd = diff[direction] coord = (coord[0] + dd[0], coord[1] + dd[1]) except StopIteration: pass return panels def test_case1(): with open('day-11.txt', 'r') as f: text = f.read().strip() data = [int(x) for x in text.split(',')] panels = dict() draw(data, panels) xmin = min((x[0] for x in panels.keys())) xmax = max((x[0] for x in panels.keys())) ymin = min((x[1] for x in panels.keys())) ymax = max((x[1] for x in panels.keys())) w = xmax - xmin h = ymax - ymin for j in range(ymin, ymax): for i in range(xmin, xmax): c = (i, j) color = panels.get(c, 0) print('#' if color == 1 else '.', end='') print() assert len(panels) == 2339 def test_case2(): with open('day-11.txt', 'r') as f: text = f.read().strip() data = [int(x) for x in text.split(',')] panels = dict() panels[0, 0] = 1 draw(data, panels) xmin = min((x[0] for x in panels.keys())) - 2 xmax = max((x[0] for x in panels.keys())) + 2 ymin = min((x[1] for x in panels.keys())) - 2 ymax = max((x[1] for x in panels.keys())) + 2 w = xmax - xmin h = ymax - ymin for j in range(ymax, ymin, -1): for i in range(xmin, xmax): c = (i, j) color = panels.get(c, 0) print('#' if color == 1 else '.', end='') print() assert False
# from enum import IntEnum LEVEL_UNKNOWN_DEATH = int(0) LEVEL_NOS = int(-1) LEVEL_FINISHED = int(-2) LEVEL_MAX = 21 LEVELS_PER_ZONE = 4 TOTAL_ZONES = 5 # class LevelSpecial(IntEnum): # UNKNOWN_DEATH = 0, # NOS = -1, # FINISHED = -2 # # # class Level(object): # @staticmethod # def fromstr(level_str: str) -> int or None: # args = level_str.split('-') # if len(args) == 2: # try: # zone = int(args[0]) # lvl = int(args[1]) # if (1 <= zone <= TOTAL_ZONES and 1 <= lvl <= LEVELS_PER_ZONE) or (zone == 5 and lvl == 5): # return Level(zone=zone, level=lvl) # except ValueError: # return None # return None # # def __init__( # self, # zone: int = None, # level: int = None, # total_level: int = None, # level_special: LevelSpecial = None # ) -> None: # if total_level is not None: # self.zone = min(((total_level - 1) // LEVELS_PER_ZONE) + 1, TOTAL_ZONES) # self.level = total_level - LEVELS_PER_ZONE * (self.zone - 1) # # self.zone = zone # self.level = level # self.level_special = level_special # # def __int__(self) -> int: # if self.is_normal_level: # return 4*(self.zone - 1) + self.level # else: # return int(self.level_special) # # def __str__(self) -> str: # if self.is_normal_level is None: # return '{0}-{1}'.format(self.zone, self.level) # elif self.is_normal_level == LevelSpecial.UNKNOWN_DEATH: # return 'unknown death' # elif self.is_normal_level == LevelSpecial.NOS: # return 'unknown' # elif self.is_normal_level == LevelSpecial.FINISHED: # return 'finished' # # @property # def is_normal_level(self) -> bool: # return self.level_special is not None # # def sortval(self, reverse: bool = False) -> int: # if self.level_special == LevelSpecial.FINISHED: # return LEVEL_MAX + 1 # elif reverse: # return LEVEL_MAX - self.__int__() if self.__init__() > 0 else 0 # else: # return self.__int__() def from_str(level_str: str) -> int: """With level_str in the form x-y, return the level as a number from 1 to 21, or LEVEL_NOS if invalid""" args = level_str.split('-') if len(args) == 2: try: world = int(args[0]) lvl = int(args[1]) if (1 <= world <= TOTAL_ZONES and 1 <= lvl <= LEVELS_PER_ZONE) or (world == 5 and lvl == 5): return LEVELS_PER_ZONE*(world-1) + lvl except ValueError: return LEVEL_NOS return LEVEL_NOS def to_str(level: int) -> str: """Convert a level number from 1 to 21 into the appropriate x-y format; otherwise return an empty string.""" if 1 <= level <= LEVEL_MAX: world = min(((level-1) // LEVELS_PER_ZONE) + 1, TOTAL_ZONES) lvl = level - LEVELS_PER_ZONE*(world-1) return '{0}-{1}'.format(world, lvl) else: return '' def level_sortval(level: int, reverse=False) -> int: """Return an int that will cause levels to sort correctly.""" if level == LEVEL_FINISHED: return LEVEL_MAX + 1 elif reverse: return LEVEL_MAX - level if level > 0 else level else: return level
level_unknown_death = int(0) level_nos = int(-1) level_finished = int(-2) level_max = 21 levels_per_zone = 4 total_zones = 5 def from_str(level_str: str) -> int: """With level_str in the form x-y, return the level as a number from 1 to 21, or LEVEL_NOS if invalid""" args = level_str.split('-') if len(args) == 2: try: world = int(args[0]) lvl = int(args[1]) if 1 <= world <= TOTAL_ZONES and 1 <= lvl <= LEVELS_PER_ZONE or (world == 5 and lvl == 5): return LEVELS_PER_ZONE * (world - 1) + lvl except ValueError: return LEVEL_NOS return LEVEL_NOS def to_str(level: int) -> str: """Convert a level number from 1 to 21 into the appropriate x-y format; otherwise return an empty string.""" if 1 <= level <= LEVEL_MAX: world = min((level - 1) // LEVELS_PER_ZONE + 1, TOTAL_ZONES) lvl = level - LEVELS_PER_ZONE * (world - 1) return '{0}-{1}'.format(world, lvl) else: return '' def level_sortval(level: int, reverse=False) -> int: """Return an int that will cause levels to sort correctly.""" if level == LEVEL_FINISHED: return LEVEL_MAX + 1 elif reverse: return LEVEL_MAX - level if level > 0 else level else: return level
class MagicalGirlLevelOneDivTwo: def theMinDistance(self, d, x, y): return min( sorted( (a ** 2 + b ** 2) ** 0.5 for a in xrange(x - d, x + d + 1) for b in xrange(y - d, y + d + 1) ) )
class Magicalgirllevelonedivtwo: def the_min_distance(self, d, x, y): return min(sorted(((a ** 2 + b ** 2) ** 0.5 for a in xrange(x - d, x + d + 1) for b in xrange(y - d, y + d + 1))))
test = 1 while True: n = int(input()) if n == 0: break participantes = [int(x) for x in input().split()] vencedor = [participantes[x] for x in range(n) if participantes[x] == (x + 1)] print(f'Teste {test}') test += 1 print(vencedor[0]) print()
test = 1 while True: n = int(input()) if n == 0: break participantes = [int(x) for x in input().split()] vencedor = [participantes[x] for x in range(n) if participantes[x] == x + 1] print(f'Teste {test}') test += 1 print(vencedor[0]) print()
# Check if there are two adjacent digits that are the same def adjacent_in_list(li=()): for c in range(0, len(li)-1): if li[c] == li[c+1]: return True return False # Check if the list doesn't get smaller as the index increases def list_gets_bigger(li=()): for c in range(0, len(li)-1): if li[c] > li[c+1]: return False else: return True def password_criteria(n, mini, maxi): n_list = [] n = str(n) for c in range(0, len(n)): n_list += [int(n[c])] if int(n) > maxi or int(n) < mini: # Check if the number is in the range return False elif not adjacent_in_list(n_list): return False elif list_gets_bigger(n_list): return True passwords = [] for c0 in range(146810, 612564): if password_criteria(c0, 146810, 612564): passwords += [c0] print(len(passwords), passwords)
def adjacent_in_list(li=()): for c in range(0, len(li) - 1): if li[c] == li[c + 1]: return True return False def list_gets_bigger(li=()): for c in range(0, len(li) - 1): if li[c] > li[c + 1]: return False else: return True def password_criteria(n, mini, maxi): n_list = [] n = str(n) for c in range(0, len(n)): n_list += [int(n[c])] if int(n) > maxi or int(n) < mini: return False elif not adjacent_in_list(n_list): return False elif list_gets_bigger(n_list): return True passwords = [] for c0 in range(146810, 612564): if password_criteria(c0, 146810, 612564): passwords += [c0] print(len(passwords), passwords)
FARMINGPRACTICES_TYPE_URI = "https://w3id.org/okn/o/sdm#FarmingPractices" FARMINGPRACTICES_TYPE_NAME = "FarmingPractices" POINTBASEDGRID_TYPE_URI = "https://w3id.org/okn/o/sdm#PointBasedGrid" POINTBASEDGRID_TYPE_NAME = "PointBasedGrid" SUBSIDY_TYPE_URI = "https://w3id.org/okn/o/sdm#Subsidy" SUBSIDY_TYPE_NAME = "Subsidy" GRID_TYPE_URI = "https://w3id.org/okn/o/sdm#Grid" GRID_TYPE_NAME = "Grid" TIMEINTERVAL_TYPE_URI = "https://w3id.org/okn/o/sdm#TimeInterval" TIMEINTERVAL_TYPE_NAME = "TimeInterval" EMPIRICALMODEL_TYPE_URI = "https://w3id.org/okn/o/sdm#EmpiricalModel" EMPIRICALMODEL_TYPE_NAME = "EmpiricalModel" GEOSHAPE_TYPE_URI = "https://w3id.org/okn/o/sdm#GeoShape" GEOSHAPE_TYPE_NAME = "GeoShape" MODEL_TYPE_URI = "https://w3id.org/okn/o/sdm#Model" MODEL_TYPE_NAME = "Model" REGION_TYPE_URI = "https://w3id.org/okn/o/sdm#Region" REGION_TYPE_NAME = "Region" GEOCOORDINATES_TYPE_URI = "https://w3id.org/okn/o/sdm#GeoCoordinates" GEOCOORDINATES_TYPE_NAME = "GeoCoordinates" SPATIALLYDISTRIBUTEDGRID_TYPE_URI = "https://w3id.org/okn/o/sdm#SpatiallyDistributedGrid" SPATIALLYDISTRIBUTEDGRID_TYPE_NAME = "SpatiallyDistributedGrid" EMULATOR_TYPE_URI = "https://w3id.org/okn/o/sdm#Emulator" EMULATOR_TYPE_NAME = "Emulator" MODELCONFIGURATION_TYPE_URI = "https://w3id.org/okn/o/sdm#ModelConfiguration" MODELCONFIGURATION_TYPE_NAME = "ModelConfiguration" THEORYGUIDEDMODEL_TYPE_URI = "https://w3id.org/okn/o/sdm#Theory-GuidedModel" THEORYGUIDEDMODEL_TYPE_NAME = "Theory-GuidedModel" NUMERICALINDEX_TYPE_URI = "https://w3id.org/okn/o/sdm#NumericalIndex" NUMERICALINDEX_TYPE_NAME = "NumericalIndex" PROCESS_TYPE_URI = "https://w3id.org/okn/o/sdm#Process" PROCESS_TYPE_NAME = "Process" HYBRIDMODEL_TYPE_URI = "https://w3id.org/okn/o/sdm#HybridModel" HYBRIDMODEL_TYPE_NAME = "HybridModel" MODELCONFIGURATIONSETUP_TYPE_URI = "https://w3id.org/okn/o/sdm#ModelConfigurationSetup" MODELCONFIGURATIONSETUP_TYPE_NAME = "ModelConfigurationSetup" CAUSALDIAGRAM_TYPE_URI = "https://w3id.org/okn/o/sdm#CausalDiagram" CAUSALDIAGRAM_TYPE_NAME = "CausalDiagram" SPATIALRESOLUTION_TYPE_URI = "https://w3id.org/okn/o/sdm#SpatialResolution" SPATIALRESOLUTION_TYPE_NAME = "SpatialResolution" EQUATION_TYPE_URI = "https://w3id.org/okn/o/sdm#Equation" EQUATION_TYPE_NAME = "Equation" INTERVENTION_TYPE_URI = "https://w3id.org/okn/o/sdm#Intervention" INTERVENTION_TYPE_NAME = "Intervention" SAMPLEEXECUTION_TYPE_URI = "https://w3id.org/okn/o/sd#SampleExecution" SAMPLEEXECUTION_TYPE_NAME = "SampleExecution" VISUALIZATION_TYPE_URI = "https://w3id.org/okn/o/sd#Visualization" VISUALIZATION_TYPE_NAME = "Visualization" IMAGE_TYPE_URI = "https://w3id.org/okn/o/sd#Image" IMAGE_TYPE_NAME = "Image" SOURCECODE_TYPE_URI = "https://w3id.org/okn/o/sd#SourceCode" SOURCECODE_TYPE_NAME = "SourceCode" ORGANIZATION_TYPE_URI = "https://w3id.org/okn/o/sd#Organization" ORGANIZATION_TYPE_NAME = "Organization" DATASETSPECIFICATION_TYPE_URI = "https://w3id.org/okn/o/sd#DatasetSpecification" DATASETSPECIFICATION_TYPE_NAME = "DatasetSpecification" UNIT_TYPE_URI = "https://w3id.org/okn/o/sd#Unit" UNIT_TYPE_NAME = "Unit" CONFIGURATIONSETUP_TYPE_URI = "https://w3id.org/okn/o/sd#ConfigurationSetup" CONFIGURATIONSETUP_TYPE_NAME = "ConfigurationSetup" ICASAVARIABLE_TYPE_URI = "https://w3id.org/okn/o/sd#ICASAVariable" ICASAVARIABLE_TYPE_NAME = "ICASAVariable" SAMPLECOLLECTION_TYPE_URI = "https://w3id.org/okn/o/sd#SampleCollection" SAMPLECOLLECTION_TYPE_NAME = "SampleCollection" STANDARDVARIABLE_TYPE_URI = "https://w3id.org/okn/o/sd#StandardVariable" STANDARDVARIABLE_TYPE_NAME = "StandardVariable" SOFTWAREIMAGE_TYPE_URI = "https://w3id.org/okn/o/sd#SoftwareImage" SOFTWAREIMAGE_TYPE_NAME = "SoftwareImage" SOFTWARE_TYPE_URI = "https://w3id.org/okn/o/sd#Software" SOFTWARE_TYPE_NAME = "Software" VARIABLEPRESENTATION_TYPE_URI = "https://w3id.org/okn/o/sd#VariablePresentation" VARIABLEPRESENTATION_TYPE_NAME = "VariablePresentation" SOFTWARECONFIGURATION_TYPE_URI = "https://w3id.org/okn/o/sd#SoftwareConfiguration" SOFTWARECONFIGURATION_TYPE_NAME = "SoftwareConfiguration" SOFTWAREVERSION_TYPE_URI = "https://w3id.org/okn/o/sd#SoftwareVersion" SOFTWAREVERSION_TYPE_NAME = "SoftwareVersion" FUNDINGINFORMATION_TYPE_URI = "https://w3id.org/okn/o/sd#FundingInformation" FUNDINGINFORMATION_TYPE_NAME = "FundingInformation" SAMPLERESOURCE_TYPE_URI = "https://w3id.org/okn/o/sd#SampleResource" SAMPLERESOURCE_TYPE_NAME = "SampleResource" PARAMETER_TYPE_URI = "https://w3id.org/okn/o/sd#Parameter" PARAMETER_TYPE_NAME = "Parameter" SVOVARIABLE_TYPE_URI = "https://w3id.org/okn/o/sd#SVOVariable" SVOVARIABLE_TYPE_NAME = "SVOVariable" PERSON_TYPE_URI = "https://w3id.org/okn/o/sd#Person" PERSON_TYPE_NAME = "Person" VARIABLE_TYPE_URI = "https://w3id.org/okn/o/sd#Variable" VARIABLE_TYPE_NAME = "Variable"
farmingpractices_type_uri = 'https://w3id.org/okn/o/sdm#FarmingPractices' farmingpractices_type_name = 'FarmingPractices' pointbasedgrid_type_uri = 'https://w3id.org/okn/o/sdm#PointBasedGrid' pointbasedgrid_type_name = 'PointBasedGrid' subsidy_type_uri = 'https://w3id.org/okn/o/sdm#Subsidy' subsidy_type_name = 'Subsidy' grid_type_uri = 'https://w3id.org/okn/o/sdm#Grid' grid_type_name = 'Grid' timeinterval_type_uri = 'https://w3id.org/okn/o/sdm#TimeInterval' timeinterval_type_name = 'TimeInterval' empiricalmodel_type_uri = 'https://w3id.org/okn/o/sdm#EmpiricalModel' empiricalmodel_type_name = 'EmpiricalModel' geoshape_type_uri = 'https://w3id.org/okn/o/sdm#GeoShape' geoshape_type_name = 'GeoShape' model_type_uri = 'https://w3id.org/okn/o/sdm#Model' model_type_name = 'Model' region_type_uri = 'https://w3id.org/okn/o/sdm#Region' region_type_name = 'Region' geocoordinates_type_uri = 'https://w3id.org/okn/o/sdm#GeoCoordinates' geocoordinates_type_name = 'GeoCoordinates' spatiallydistributedgrid_type_uri = 'https://w3id.org/okn/o/sdm#SpatiallyDistributedGrid' spatiallydistributedgrid_type_name = 'SpatiallyDistributedGrid' emulator_type_uri = 'https://w3id.org/okn/o/sdm#Emulator' emulator_type_name = 'Emulator' modelconfiguration_type_uri = 'https://w3id.org/okn/o/sdm#ModelConfiguration' modelconfiguration_type_name = 'ModelConfiguration' theoryguidedmodel_type_uri = 'https://w3id.org/okn/o/sdm#Theory-GuidedModel' theoryguidedmodel_type_name = 'Theory-GuidedModel' numericalindex_type_uri = 'https://w3id.org/okn/o/sdm#NumericalIndex' numericalindex_type_name = 'NumericalIndex' process_type_uri = 'https://w3id.org/okn/o/sdm#Process' process_type_name = 'Process' hybridmodel_type_uri = 'https://w3id.org/okn/o/sdm#HybridModel' hybridmodel_type_name = 'HybridModel' modelconfigurationsetup_type_uri = 'https://w3id.org/okn/o/sdm#ModelConfigurationSetup' modelconfigurationsetup_type_name = 'ModelConfigurationSetup' causaldiagram_type_uri = 'https://w3id.org/okn/o/sdm#CausalDiagram' causaldiagram_type_name = 'CausalDiagram' spatialresolution_type_uri = 'https://w3id.org/okn/o/sdm#SpatialResolution' spatialresolution_type_name = 'SpatialResolution' equation_type_uri = 'https://w3id.org/okn/o/sdm#Equation' equation_type_name = 'Equation' intervention_type_uri = 'https://w3id.org/okn/o/sdm#Intervention' intervention_type_name = 'Intervention' sampleexecution_type_uri = 'https://w3id.org/okn/o/sd#SampleExecution' sampleexecution_type_name = 'SampleExecution' visualization_type_uri = 'https://w3id.org/okn/o/sd#Visualization' visualization_type_name = 'Visualization' image_type_uri = 'https://w3id.org/okn/o/sd#Image' image_type_name = 'Image' sourcecode_type_uri = 'https://w3id.org/okn/o/sd#SourceCode' sourcecode_type_name = 'SourceCode' organization_type_uri = 'https://w3id.org/okn/o/sd#Organization' organization_type_name = 'Organization' datasetspecification_type_uri = 'https://w3id.org/okn/o/sd#DatasetSpecification' datasetspecification_type_name = 'DatasetSpecification' unit_type_uri = 'https://w3id.org/okn/o/sd#Unit' unit_type_name = 'Unit' configurationsetup_type_uri = 'https://w3id.org/okn/o/sd#ConfigurationSetup' configurationsetup_type_name = 'ConfigurationSetup' icasavariable_type_uri = 'https://w3id.org/okn/o/sd#ICASAVariable' icasavariable_type_name = 'ICASAVariable' samplecollection_type_uri = 'https://w3id.org/okn/o/sd#SampleCollection' samplecollection_type_name = 'SampleCollection' standardvariable_type_uri = 'https://w3id.org/okn/o/sd#StandardVariable' standardvariable_type_name = 'StandardVariable' softwareimage_type_uri = 'https://w3id.org/okn/o/sd#SoftwareImage' softwareimage_type_name = 'SoftwareImage' software_type_uri = 'https://w3id.org/okn/o/sd#Software' software_type_name = 'Software' variablepresentation_type_uri = 'https://w3id.org/okn/o/sd#VariablePresentation' variablepresentation_type_name = 'VariablePresentation' softwareconfiguration_type_uri = 'https://w3id.org/okn/o/sd#SoftwareConfiguration' softwareconfiguration_type_name = 'SoftwareConfiguration' softwareversion_type_uri = 'https://w3id.org/okn/o/sd#SoftwareVersion' softwareversion_type_name = 'SoftwareVersion' fundinginformation_type_uri = 'https://w3id.org/okn/o/sd#FundingInformation' fundinginformation_type_name = 'FundingInformation' sampleresource_type_uri = 'https://w3id.org/okn/o/sd#SampleResource' sampleresource_type_name = 'SampleResource' parameter_type_uri = 'https://w3id.org/okn/o/sd#Parameter' parameter_type_name = 'Parameter' svovariable_type_uri = 'https://w3id.org/okn/o/sd#SVOVariable' svovariable_type_name = 'SVOVariable' person_type_uri = 'https://w3id.org/okn/o/sd#Person' person_type_name = 'Person' variable_type_uri = 'https://w3id.org/okn/o/sd#Variable' variable_type_name = 'Variable'
# # @lc app=leetcode id=49 lang=python3 # # [49] Group Anagrams # # https://leetcode.com/problems/group-anagrams/description/ # # algorithms # Medium (60.66%) # Likes: 7901 # Dislikes: 277 # Total Accepted: 1.2M # Total Submissions: 1.9M # Testcase Example: '["eat","tea","tan","ate","nat","bat"]' # # Given an array of strings strs, group the anagrams together. You can return # the answer in any order. # # An Anagram is a word or phrase formed by rearranging the letters of a # different word or phrase, typically using all the original letters exactly # once. # # # Example 1: # Input: strs = ["eat","tea","tan","ate","nat","bat"] # Output: [["bat"],["nat","tan"],["ate","eat","tea"]] # Example 2: # Input: strs = [""] # Output: [[""]] # Example 3: # Input: strs = ["a"] # Output: [["a"]] # # # Constraints: # # # 1 <= strs.length <= 10^4 # 0 <= strs[i].length <= 100 # strs[i] consists of lowercase English letters. # # # # @lc code=start class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: d = {} for str in strs: str_sort = ''.join(sorted(str)) if str_sort in d: d[str_sort].append(str) else: d[str_sort] = [str] return list(d.values()) # @lc code=end
class Solution: def group_anagrams(self, strs: List[str]) -> List[List[str]]: d = {} for str in strs: str_sort = ''.join(sorted(str)) if str_sort in d: d[str_sort].append(str) else: d[str_sort] = [str] return list(d.values())
# Copyright (c) 2019 Pavel Vavruska # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. class Config: def __init__( self, fov, is_perspective_correction_on, is_metric_on, pixel_size, dynamic_lighting, texture_filtering ): self.__fov = fov self.__is_perspective_correction_on = is_perspective_correction_on self.__is_metric_on = is_metric_on self.__pixel_size = pixel_size self.__dynamic_lighting = dynamic_lighting self.__texture_filtering = texture_filtering @property def fov(self): return self.__fov @property def is_perspective_correction_on(self): return self.__is_perspective_correction_on @property def is_metric_on(self): return self.__is_metric_on @property def pixel_size(self): return self.__pixel_size @property def dynamic_lighting(self): return self.__dynamic_lighting @property def texture_filtering(self): return self.__texture_filtering def set_fov(self, fov): self.__fov = fov def toggle_perspective_correction_on(self): self.__is_perspective_correction_on = not self.is_perspective_correction_on def toggle_metric_on(self): self.__is_metric_on = not self.__is_metric_on def set_pixel_size(self, pixel_size): self.__pixel_size = pixel_size def increase_pixel_size(self): if self.pixel_size < 10: self.__pixel_size = self.pixel_size + 1 def decrease_pixel_size(self): if self.pixel_size > 1: self.__pixel_size = self.pixel_size - 1 def toggle_dynamic_lighting(self): self.__dynamic_lighting = not self.__dynamic_lighting def toggle_texture_filtering(self): self.__texture_filtering = not self.__texture_filtering
class Config: def __init__(self, fov, is_perspective_correction_on, is_metric_on, pixel_size, dynamic_lighting, texture_filtering): self.__fov = fov self.__is_perspective_correction_on = is_perspective_correction_on self.__is_metric_on = is_metric_on self.__pixel_size = pixel_size self.__dynamic_lighting = dynamic_lighting self.__texture_filtering = texture_filtering @property def fov(self): return self.__fov @property def is_perspective_correction_on(self): return self.__is_perspective_correction_on @property def is_metric_on(self): return self.__is_metric_on @property def pixel_size(self): return self.__pixel_size @property def dynamic_lighting(self): return self.__dynamic_lighting @property def texture_filtering(self): return self.__texture_filtering def set_fov(self, fov): self.__fov = fov def toggle_perspective_correction_on(self): self.__is_perspective_correction_on = not self.is_perspective_correction_on def toggle_metric_on(self): self.__is_metric_on = not self.__is_metric_on def set_pixel_size(self, pixel_size): self.__pixel_size = pixel_size def increase_pixel_size(self): if self.pixel_size < 10: self.__pixel_size = self.pixel_size + 1 def decrease_pixel_size(self): if self.pixel_size > 1: self.__pixel_size = self.pixel_size - 1 def toggle_dynamic_lighting(self): self.__dynamic_lighting = not self.__dynamic_lighting def toggle_texture_filtering(self): self.__texture_filtering = not self.__texture_filtering
def dijkstra(graph): start = "A" times = {a: float("inf") for a in graph.keys()} times[start] = 0 a = list(times) while a: node_selected = min(a, key=lambda k: times[k]) print("node selected", node_selected) a.remove(node_selected) for node, t in graph[node_selected].items(): if times[node_selected] + t < times[node]: times[node] = times[node_selected] + t print(times) graph = { "A": {"B": 4, "D": 3}, "B": {"C": 1}, "C": {}, "D": {"B": 1, "C": 3} } dijkstra(graph)
def dijkstra(graph): start = 'A' times = {a: float('inf') for a in graph.keys()} times[start] = 0 a = list(times) while a: node_selected = min(a, key=lambda k: times[k]) print('node selected', node_selected) a.remove(node_selected) for (node, t) in graph[node_selected].items(): if times[node_selected] + t < times[node]: times[node] = times[node_selected] + t print(times) graph = {'A': {'B': 4, 'D': 3}, 'B': {'C': 1}, 'C': {}, 'D': {'B': 1, 'C': 3}} dijkstra(graph)
# Nodes in lattice graph and associated modules class LatticeNode: def __init__(self, dimensions: tuple): self._parents = list() self._children = list() self._is_pruned = False self.superpattern_count = -1 self.dimensions = dimensions def is_node_pruned(self): return self._is_pruned def prune_node(self): self._is_pruned = True def add_parents(self, parents: list) -> None: """Args: parents (list): list of lattice node instances """ self._parents.extend(parents) def get_parents(self) -> list: return self._parents def add_children(self, children: list) -> None: """Args: children (list): list of lattice node instances """ self._children.extend(children) def get_children(self) -> list: return self._children
class Latticenode: def __init__(self, dimensions: tuple): self._parents = list() self._children = list() self._is_pruned = False self.superpattern_count = -1 self.dimensions = dimensions def is_node_pruned(self): return self._is_pruned def prune_node(self): self._is_pruned = True def add_parents(self, parents: list) -> None: """Args: parents (list): list of lattice node instances """ self._parents.extend(parents) def get_parents(self) -> list: return self._parents def add_children(self, children: list) -> None: """Args: children (list): list of lattice node instances """ self._children.extend(children) def get_children(self) -> list: return self._children
globalVar = 0 dataset = 'berlin' max_len = 1024 nb_features = 36 nb_attention_param = 256 attention_init_value = 1.0 / 256 nb_hidden_units = 512 # number of hidden layer units dropout_rate = 0.5 nb_lstm_cells = 128 nb_classes = 7 frame_size = 0.025 # 25 msec segments step = 0.01 # 10 msec time step
global_var = 0 dataset = 'berlin' max_len = 1024 nb_features = 36 nb_attention_param = 256 attention_init_value = 1.0 / 256 nb_hidden_units = 512 dropout_rate = 0.5 nb_lstm_cells = 128 nb_classes = 7 frame_size = 0.025 step = 0.01
# new_user() # show_global_para() # run_pdf() # read_calib_file_new() # check_latest_scan_id(init_guess=60000, search_size=100) ################################### def load_xanes_ref(*arg): """ load reference spectrum, use it as: ref = load_xanes_ref(Ni, Ni2, Ni3) each spectrum is two-column array, containing: energy(1st column) and absortion(2nd column) It returns a dictionary, which can be used as: spectrum_ref['ref0'], spectrum_ref['ref1'] .... """ num_ref = len(arg) assert num_ref > 1, "num of reference should larger than 1" spectrum_ref = {} for i in range(num_ref): spectrum_ref[f"ref{i}"] = arg[i] return spectrum_ref def fit_2D_xanes_non_iter(img_xanes, eng, spectrum_ref, error_thresh=0.1): """ Solve equation of Ax=b, where: Inputs: ---------- A: reference spectrum (2-colume array: xray_energy vs. absorption_spectrum) X: fitted coefficient of each ref spectrum b: experimental 2D XANES data Outputs: ---------- fit_coef: the 'x' in the equation 'Ax=b': fitted coefficient of each ref spectrum cost: cost between fitted spectrum and raw data """ num_ref = len(spectrum_ref) spec_interp = {} comp = {} A = [] s = img_xanes.shape for i in range(num_ref): tmp = interp1d( spectrum_ref[f"ref{i}"][:, 0], spectrum_ref[f"ref{i}"][:, 1], kind="cubic" ) A.append(tmp(eng).reshape(1, len(eng))) spec_interp[f"ref{i}"] = tmp(eng).reshape(1, len(eng)) comp[f"A{i}"] = spec_interp[f"ref{i}"].reshape(len(eng), 1) comp[f"A{i}_t"] = comp[f"A{i}"].T # e.g., spectrum_ref contains: ref1, ref2, ref3 # e.g., comp contains: A1, A2, A3, A1_t, A2_t, A3_t # A1 = ref1.reshape(110, 1) # A1_t = A1.T A = np.squeeze(A).T M = np.zeros([num_ref + 1, num_ref + 1]) for i in range(num_ref): for j in range(num_ref): M[i, j] = np.dot(comp[f"A{i}_t"], comp[f"A{j}"]) M[i, num_ref] = 1 M[num_ref] = np.ones((1, num_ref + 1)) M[num_ref, -1] = 0 # e.g. # M = np.array([[float(np.dot(A1_t, A1)), float(np.dot(A1_t, A2)), float(np.dot(A1_t, A3)), 1.], # [float(np.dot(A2_t, A1)), float(np.dot(A2_t, A2)), float(np.dot(A2_t, A3)), 1.], # [float(np.dot(A3_t, A1)), float(np.dot(A3_t, A2)), float(np.dot(A3_t, A3)), 1.], # [1., 1., 1., 0.]]) M_inv = np.linalg.inv(M) b_tot = img_xanes.reshape(s[0], -1) B = np.ones([num_ref + 1, b_tot.shape[1]]) for i in range(num_ref): B[i] = np.dot(comp[f"A{i}_t"], b_tot) x = np.dot(M_inv, B) x = x[:-1] x[x < 0] = 0 x_sum = np.sum(x, axis=0, keepdims=True) x = x / x_sum cost = np.sum((np.dot(A, x) - b_tot) ** 2, axis=0) / s[0] cost = cost.reshape(s[1], s[2]) x = x.reshape(num_ref, s[1], s[2]) # cost = compute_xanes_fit_cost(img_xanes, x, spec_interp) mask = compute_xanes_fit_mask(cost, error_thresh) mask = mask.reshape(s[1], s[2]) mask_tile = np.tile(mask, (x.shape[0], 1, 1)) x = x * mask_tile cost = cost * mask return x, cost def fit_2D_xanes_iter( img_xanes, eng, spectrum_ref, coef0=None, learning_rate=0.005, n_iter=10, bounds=[0, 1], error_thresh=0.1, ): """ Solve the equation A*x = b iteratively Inputs: ------- img_xanes: 3D xanes image stack eng: energy list of xanes spectrum_ref: dictionary, obtained from, e.g. spectrum_ref = load_xanes_ref(Ni2, Ni3) coef0: initial guess of the fitted coefficient, it has dimention of [num_of_referece, img_xanes.shape[1], img_xanes.shape[2]] learning_rate: float n_iter: int bounds: [low_limit, high_limit] can be 'None', which give no boundary limit error_thresh: float used to generate a mask, mask[fitting_cost > error_thresh] = 0 Outputs: --------- w: fitted 2D_xanes coefficient it has dimention of [num_of_referece, img_xanes.shape[1], img_xanes.shape[2]] cost: 2D fitting cost """ num_ref = len(spectrum_ref) A = [] for i in range(num_ref): tmp = interp1d( spectrum_ref[f"ref{i}"][:, 0], spectrum_ref[f"ref{i}"][:, 1], kind="cubic" ) A.append(tmp(eng).reshape(1, len(eng))) A = np.squeeze(A).T Y = img_xanes.reshape(img_xanes.shape[0], -1) if not coef0 is None: W = coef0.reshape(coef0.shape[0], -1) w, cost = lsq_fit_iter2(A, Y, W, learning_rate, n_iter, bounds, print_flag=1) w = w.reshape(len(w), img_xanes.shape[1], img_xanes.shape[2]) cost = cost.reshape(cost.shape[0], img_xanes.shape[1], img_xanes.shape[2]) mask = compute_xanes_fit_mask(cost[-1], error_thresh) mask_tile = np.tile(mask, (w.shape[0], 1, 1)) w = w * mask_tile mask_tile2 = np.tile(mask, (cost.shape[0], 1, 1)) cost = cost * mask_tile2 return w, cost def compute_xanes_fit_cost(img_xanes, fit_coef, spec_interp): # compute the cost num_ref = len(spec_interp) y_fit = np.zeros(img_xanes.shape) for i in range(img_xanes.shape[0]): for j in range(num_ref): y_fit[i] = y_fit[i] + fit_coef[j] * np.squeeze(spec_interp[f"ref{j}"])[i] y_dif = np.power(y_fit - img_xanes, 2) cost = np.sum(y_dif, axis=0) / img_xanes.shape[0] return cost def compute_xanes_fit_mask(cost, error_thresh=0.1): mask = np.ones(cost.shape) mask[cost > error_thresh] = 0 return mask def xanes_fit_demo(): f = h5py.File("img_xanes_normed.h5", "r") img_xanes = np.array(f["img"]) eng = np.array(f["X_eng"]) f.close() img_xanes = bin_ndarray( img_xanes, (img_xanes.shape[0], int(img_xanes.shape[1] / 2), int(img_xanes.shape[2] / 2)), ) Ni = np.loadtxt( "/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/Ni_xanes_norm.txt" ) Ni2 = np.loadtxt( "/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/NiO_xanes_norm.txt" ) Ni3 = np.loadtxt( "/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/LiNiO2_xanes_norm.txt" ) spectrum_ref = load_xanes_ref(Ni2, Ni3) w1, c1 = fit_2D_xanes_non_iter(img_xanes, eng, spectrum_ref, error_thresh=0.1) plt.figure() plt.subplot(121) plt.imshow(w1[0]) plt.subplot(122) plt.imshow(w1[1]) def temp(): # os.mkdir('recon_image') scan_id = np.arange(15198, 15256) n = len(scan_id) for i in range(n): fn = f"fly_scan_id_{int(scan_id[i])}.h5" print(f"reconstructing: {fn} ... ") img = get_img(db[int(scan_id[i])], sli=[0, 1]) s = img.shape if s[-1] > 2000: sli = [200, 1900] binning = 2 else: sli = [100, 950] binning = 1 rot_cen = find_rot(fn) recon(fn, rot_cen, sli=sli, binning=binning) try: f_recon = ( f"recon_scan_{int(scan_id[i])}_sli_{sli[0]}_{sli[1]}_bin{binning}.h5" ) f = h5py.File(f_recon, "r") sli_choose = int((sli[0] + sli[1]) / 2) img_recon = np.array(f["img"][sli_choose], dtype=np.float32) sid = scan_id[i] f.close() fn_img_save = f"recon_image/recon_{int(sid)}_sli_{sli_choose}.tiff" print(f"saving {fn_img_save}\n") io.imsave(fn_img_save, img_recon) except: pass def multipos_tomo( exposure_time, x_list, y_list, z_list, out_x, out_y, out_z, out_r, rs, relative_rot_angle=185, period=0.05, relative_move_flag=0, traditional_sequence_flag=1, repeat=1, sleep_time=0, note="", ): n = len(x_list) txt = f"starting multiposition_flyscan: (repeating for {repeat} times)" insert_text(txt) for rep in range(repeat): for i in range(n): txt = f"\n################\nrepeat #{rep+1}:\nmoving to the {i+1} position: x={x_list[i]}, y={y_list[i]}, z={z_list[i]}" print(txt) insert_text(txt) yield from mv(zps.sx, x_list[i], zps.sy, y_list[i], zps.sz, z_list[i]) yield from fly_scan( exposure_time=exposure_time, relative_rot_angle=relative_rot_angle, period=period, chunk_size=20, out_x=out_x, out_y=out_y, out_z=out_z, out_r=out_r, rs=rs, simu=False, relative_move_flag=relative_move_flag, traditional_sequence_flag=traditional_sequence_flag, note=note, md=None, ) print(f"sleeping for {sleep_time:3.1f} s") yield from bps.sleep(sleep_time) def create_lists(x0, y0, z0, dx, dy, dz, Nx, Ny, Nz): Ntotal = Nx * Ny * Nz x_list = np.zeros(Ntotal) y_list = np.zeros(Ntotal) z_list = np.zeros(Ntotal) j = 0 for iz in range(Nz): for ix in range(Nx): for iy in range(Ny): j = iy + ix * Ny + iz * Ny * Nx #!!! y_list[j] = y0 + dy * iy x_list[j] = x0 + dx * ix z_list[j] = z0 + dz * iz return x_list, y_list, z_list def fan_scan( eng_list, x_list_2d, y_list_2d, z_list_2d, r_list_2d, x_list_3d, y_list_3d, z_list_3d, r_list_3d, out_x, out_y, out_z, out_r, relative_rot_angle, rs=3, exposure_time=0.05, chunk_size=4, sleep_time=0, repeat=1, relative_move_flag=True, note="", ): export_pdf(1) insert_text("start multiposition 2D xanes and 3D xanes") for i in range(repeat): print(f"\nrepeat # {i+1}") # print(f'start xanes 2D scan:') # yield from multipos_2D_xanes_scan2(eng_list, x_list_2d, y_list_2d, z_list_2d, r_list_2d, out_x, out_y, out_z, out_r, repeat_num=1, exposure_time=exposure_time, sleep_time=1, chunk_size=chunk_size, simu=False, relative_move_flag=relative_move_flag, note=note, md=None) print("\n\nstart multi 3D xanes:") yield from multi_pos_xanes_3D( eng_list, x_list_3d, y_list_3d, z_list_3d, r_list_3d, exposure_time=exposure_time, relative_rot_angle=relative_rot_angle, period=exposure_time, out_x=out_x, out_y=out_y, out_z=out_z, out_r=out_r, rs=rs, simu=False, relative_move_flag=relative_move_flag, traditional_sequence_flag=1, note=note, sleep_time=0, repeat=1, ) insert_text("finished multiposition 2D xanes and 3D xanes") export_pdf(1) Ni_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_xanes_standard_101pnt.txt" ) Ni_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_xanes_standard_63pnt.txt" ) Ni_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_s_xanes_standard_21pnt.txt" ) Mn_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_xanes_standard_101pnt.txt" ) Mn_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_xanes_standard_63pnt.txt" ) Mn_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_s_xanes_standard_21pnt.txt" ) Co_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_xanes_standard_101pnt.txt" ) Co_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_xanes_standard_63pnt.txt" ) Co_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_s_xanes_standard_21pnt.txt" ) Fe_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_xanes_standard_101pnt.txt" ) Fe_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_xanes_standard_63pnt.txt" ) Fe_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_s_xanes_standard_21pnt.txt" ) V_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_xanes_standard_101pnt.txt" ) V_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_xanes_standard_63pnt.txt" ) V_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_s_xanes_standard_21pnt.txt" ) Cr_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_xanes_standard_101pnt.txt" ) Cr_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_xanes_standard_63pnt.txt" ) Cr_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_s_xanes_standard_21pnt.txt" ) Cu_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_xanes_standard_101pnt.txt" ) Cu_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_xanes_standard_63pnt.txt" ) Cu_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_s_xanes_standard_21pnt.txt" ) Zn_eng_list_101pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_xanes_standard_101pnt.txt" ) Zn_eng_list_63pnt = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_xanes_standard_63pnt.txt" ) Zn_eng_list_wl = np.genfromtxt( "/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_s_xanes_standard_21pnt.txt" ) # def scan_3D_2D_overnight(n): # # Ni_eng_list_insitu = np.arange(8.344, 8.363, 0.001) # pos1 = [30, -933, -578] # pos2 = [-203, -1077, 563] # x_list = [pos1[0]] # y_list = [pos1[1], pos2[1]] # z_list = [pos1[2], pos2[2]] # r_list = [-71, -71] # # # # # #RE(multipos_2D_xanes_scan2(Ni_eng_list_insitu, x_list, y_list, z_list, [-40, -40], out_x=None, out_y=None, out_z=-2500, out_r=-90, repeat_num=1, exposure_time=0.1, sleep_time=1, chunk_size=5, simu=False, relative_move_flag=0, note='NC_insitu')) # # RE(mv(zps.sx, pos1[0], zps.sy, pos1[1], zps.sz, pos1[2], zps.pi_r, 0)) # RE(xanes_scan2(Ni_eng_list_insitu, exposure_time=0.1, chunk_size=5, out_x=None, out_y=None, out_z=-3000, out_r=-90, simu=False, relative_move_flag=0, note='NC_insitu') # # pos1 = [30, -929, -568] # pos_cen = [-191, -813, -563] # for i in range(5): # print(f'repeating {i+1}/{5}') # # RE(mv(zps.sx, pos1[0], zps.sy, pos1[1], zps.sz, pos1[2], zps.pi_r, -72)) # RE(xanes_3D(Ni_eng_list_insitu, exposure_time=0.1, relative_rot_angle=138, period=0.1, out_x=None, out_y=None, out_z=-3000, out_r=-90, rs=2, simu=False, relative_move_flag=0, traditional_sequence_flag=1, note='NC_insitu')) # # # RE(mv(zps.sx, pos_cen[0], zps.sy, pos_cen[1], zps.sz, pos_cen[2], zps.pi_r, 0)) # RE(raster_2D_scan(x_range=[-1,1],y_range=[-1,1],exposure_time=0.1, out_x=None, out_y=None, out_z=-3000, out_r=-90, img_sizeX=640,img_sizeY=540,pxl=80, simu=False, relative_move_flag=0,rot_first_flag=1,note='NC_insitu')) # # RE(raster_2D_xanes2(Ni_eng_list_insitu, x_range=[-1,1],y_range=[-1,1],exposure_time=0.1, out_x=None, out_y=None, out_z=-3000, out_r=-90, img_sizeX=640, img_sizeY=540, pxl=80, simu=False, relative_move_flag=0, rot_first_flag=1,note='NC_insitu')) # # RE(mv(zps.sx, pos1[0], zps.sy, pos1[1], zps.sz, pos1[2], zps.pi_r, -72)) # RE(fly_scan(exposure_time=0.1, relative_rot_angle =138, period=0.1, chunk_size=20, out_x=None, out_y=None, out_z=-3000, out_r=-90, rs=1.5, simu=False, relative_move_flag=0, traditional_sequence_flag=0, note='NC_insitu')) # # RE(bps.sleep(600)) # print('sleep for 600sec') ############################### def mono_scan_repeatibility_test(pzt_cm_bender_pos_list, pbsl_y_pos_list, eng_start, eng_end, steps, delay_time=0.5, repeat=1): for ii in range(repeat): yield from load_cell_scan(pzt_cm_bender_pos_list, pbsl_y_pos_list, 1, eng_start, eng_end, steps, delay_time=delay_time)
def load_xanes_ref(*arg): """ load reference spectrum, use it as: ref = load_xanes_ref(Ni, Ni2, Ni3) each spectrum is two-column array, containing: energy(1st column) and absortion(2nd column) It returns a dictionary, which can be used as: spectrum_ref['ref0'], spectrum_ref['ref1'] .... """ num_ref = len(arg) assert num_ref > 1, 'num of reference should larger than 1' spectrum_ref = {} for i in range(num_ref): spectrum_ref[f'ref{i}'] = arg[i] return spectrum_ref def fit_2_d_xanes_non_iter(img_xanes, eng, spectrum_ref, error_thresh=0.1): """ Solve equation of Ax=b, where: Inputs: ---------- A: reference spectrum (2-colume array: xray_energy vs. absorption_spectrum) X: fitted coefficient of each ref spectrum b: experimental 2D XANES data Outputs: ---------- fit_coef: the 'x' in the equation 'Ax=b': fitted coefficient of each ref spectrum cost: cost between fitted spectrum and raw data """ num_ref = len(spectrum_ref) spec_interp = {} comp = {} a = [] s = img_xanes.shape for i in range(num_ref): tmp = interp1d(spectrum_ref[f'ref{i}'][:, 0], spectrum_ref[f'ref{i}'][:, 1], kind='cubic') A.append(tmp(eng).reshape(1, len(eng))) spec_interp[f'ref{i}'] = tmp(eng).reshape(1, len(eng)) comp[f'A{i}'] = spec_interp[f'ref{i}'].reshape(len(eng), 1) comp[f'A{i}_t'] = comp[f'A{i}'].T a = np.squeeze(A).T m = np.zeros([num_ref + 1, num_ref + 1]) for i in range(num_ref): for j in range(num_ref): M[i, j] = np.dot(comp[f'A{i}_t'], comp[f'A{j}']) M[i, num_ref] = 1 M[num_ref] = np.ones((1, num_ref + 1)) M[num_ref, -1] = 0 m_inv = np.linalg.inv(M) b_tot = img_xanes.reshape(s[0], -1) b = np.ones([num_ref + 1, b_tot.shape[1]]) for i in range(num_ref): B[i] = np.dot(comp[f'A{i}_t'], b_tot) x = np.dot(M_inv, B) x = x[:-1] x[x < 0] = 0 x_sum = np.sum(x, axis=0, keepdims=True) x = x / x_sum cost = np.sum((np.dot(A, x) - b_tot) ** 2, axis=0) / s[0] cost = cost.reshape(s[1], s[2]) x = x.reshape(num_ref, s[1], s[2]) mask = compute_xanes_fit_mask(cost, error_thresh) mask = mask.reshape(s[1], s[2]) mask_tile = np.tile(mask, (x.shape[0], 1, 1)) x = x * mask_tile cost = cost * mask return (x, cost) def fit_2_d_xanes_iter(img_xanes, eng, spectrum_ref, coef0=None, learning_rate=0.005, n_iter=10, bounds=[0, 1], error_thresh=0.1): """ Solve the equation A*x = b iteratively Inputs: ------- img_xanes: 3D xanes image stack eng: energy list of xanes spectrum_ref: dictionary, obtained from, e.g. spectrum_ref = load_xanes_ref(Ni2, Ni3) coef0: initial guess of the fitted coefficient, it has dimention of [num_of_referece, img_xanes.shape[1], img_xanes.shape[2]] learning_rate: float n_iter: int bounds: [low_limit, high_limit] can be 'None', which give no boundary limit error_thresh: float used to generate a mask, mask[fitting_cost > error_thresh] = 0 Outputs: --------- w: fitted 2D_xanes coefficient it has dimention of [num_of_referece, img_xanes.shape[1], img_xanes.shape[2]] cost: 2D fitting cost """ num_ref = len(spectrum_ref) a = [] for i in range(num_ref): tmp = interp1d(spectrum_ref[f'ref{i}'][:, 0], spectrum_ref[f'ref{i}'][:, 1], kind='cubic') A.append(tmp(eng).reshape(1, len(eng))) a = np.squeeze(A).T y = img_xanes.reshape(img_xanes.shape[0], -1) if not coef0 is None: w = coef0.reshape(coef0.shape[0], -1) (w, cost) = lsq_fit_iter2(A, Y, W, learning_rate, n_iter, bounds, print_flag=1) w = w.reshape(len(w), img_xanes.shape[1], img_xanes.shape[2]) cost = cost.reshape(cost.shape[0], img_xanes.shape[1], img_xanes.shape[2]) mask = compute_xanes_fit_mask(cost[-1], error_thresh) mask_tile = np.tile(mask, (w.shape[0], 1, 1)) w = w * mask_tile mask_tile2 = np.tile(mask, (cost.shape[0], 1, 1)) cost = cost * mask_tile2 return (w, cost) def compute_xanes_fit_cost(img_xanes, fit_coef, spec_interp): num_ref = len(spec_interp) y_fit = np.zeros(img_xanes.shape) for i in range(img_xanes.shape[0]): for j in range(num_ref): y_fit[i] = y_fit[i] + fit_coef[j] * np.squeeze(spec_interp[f'ref{j}'])[i] y_dif = np.power(y_fit - img_xanes, 2) cost = np.sum(y_dif, axis=0) / img_xanes.shape[0] return cost def compute_xanes_fit_mask(cost, error_thresh=0.1): mask = np.ones(cost.shape) mask[cost > error_thresh] = 0 return mask def xanes_fit_demo(): f = h5py.File('img_xanes_normed.h5', 'r') img_xanes = np.array(f['img']) eng = np.array(f['X_eng']) f.close() img_xanes = bin_ndarray(img_xanes, (img_xanes.shape[0], int(img_xanes.shape[1] / 2), int(img_xanes.shape[2] / 2))) ni = np.loadtxt('/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/Ni_xanes_norm.txt') ni2 = np.loadtxt('/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/NiO_xanes_norm.txt') ni3 = np.loadtxt('/NSLS2/xf18id1/users/2018Q1/MING_Proposal_000/xanes_ref/LiNiO2_xanes_norm.txt') spectrum_ref = load_xanes_ref(Ni2, Ni3) (w1, c1) = fit_2_d_xanes_non_iter(img_xanes, eng, spectrum_ref, error_thresh=0.1) plt.figure() plt.subplot(121) plt.imshow(w1[0]) plt.subplot(122) plt.imshow(w1[1]) def temp(): scan_id = np.arange(15198, 15256) n = len(scan_id) for i in range(n): fn = f'fly_scan_id_{int(scan_id[i])}.h5' print(f'reconstructing: {fn} ... ') img = get_img(db[int(scan_id[i])], sli=[0, 1]) s = img.shape if s[-1] > 2000: sli = [200, 1900] binning = 2 else: sli = [100, 950] binning = 1 rot_cen = find_rot(fn) recon(fn, rot_cen, sli=sli, binning=binning) try: f_recon = f'recon_scan_{int(scan_id[i])}_sli_{sli[0]}_{sli[1]}_bin{binning}.h5' f = h5py.File(f_recon, 'r') sli_choose = int((sli[0] + sli[1]) / 2) img_recon = np.array(f['img'][sli_choose], dtype=np.float32) sid = scan_id[i] f.close() fn_img_save = f'recon_image/recon_{int(sid)}_sli_{sli_choose}.tiff' print(f'saving {fn_img_save}\n') io.imsave(fn_img_save, img_recon) except: pass def multipos_tomo(exposure_time, x_list, y_list, z_list, out_x, out_y, out_z, out_r, rs, relative_rot_angle=185, period=0.05, relative_move_flag=0, traditional_sequence_flag=1, repeat=1, sleep_time=0, note=''): n = len(x_list) txt = f'starting multiposition_flyscan: (repeating for {repeat} times)' insert_text(txt) for rep in range(repeat): for i in range(n): txt = f'\n################\nrepeat #{rep + 1}:\nmoving to the {i + 1} position: x={x_list[i]}, y={y_list[i]}, z={z_list[i]}' print(txt) insert_text(txt) yield from mv(zps.sx, x_list[i], zps.sy, y_list[i], zps.sz, z_list[i]) yield from fly_scan(exposure_time=exposure_time, relative_rot_angle=relative_rot_angle, period=period, chunk_size=20, out_x=out_x, out_y=out_y, out_z=out_z, out_r=out_r, rs=rs, simu=False, relative_move_flag=relative_move_flag, traditional_sequence_flag=traditional_sequence_flag, note=note, md=None) print(f'sleeping for {sleep_time:3.1f} s') yield from bps.sleep(sleep_time) def create_lists(x0, y0, z0, dx, dy, dz, Nx, Ny, Nz): ntotal = Nx * Ny * Nz x_list = np.zeros(Ntotal) y_list = np.zeros(Ntotal) z_list = np.zeros(Ntotal) j = 0 for iz in range(Nz): for ix in range(Nx): for iy in range(Ny): j = iy + ix * Ny + iz * Ny * Nx y_list[j] = y0 + dy * iy x_list[j] = x0 + dx * ix z_list[j] = z0 + dz * iz return (x_list, y_list, z_list) def fan_scan(eng_list, x_list_2d, y_list_2d, z_list_2d, r_list_2d, x_list_3d, y_list_3d, z_list_3d, r_list_3d, out_x, out_y, out_z, out_r, relative_rot_angle, rs=3, exposure_time=0.05, chunk_size=4, sleep_time=0, repeat=1, relative_move_flag=True, note=''): export_pdf(1) insert_text('start multiposition 2D xanes and 3D xanes') for i in range(repeat): print(f'\nrepeat # {i + 1}') print('\n\nstart multi 3D xanes:') yield from multi_pos_xanes_3_d(eng_list, x_list_3d, y_list_3d, z_list_3d, r_list_3d, exposure_time=exposure_time, relative_rot_angle=relative_rot_angle, period=exposure_time, out_x=out_x, out_y=out_y, out_z=out_z, out_r=out_r, rs=rs, simu=False, relative_move_flag=relative_move_flag, traditional_sequence_flag=1, note=note, sleep_time=0, repeat=1) insert_text('finished multiposition 2D xanes and 3D xanes') export_pdf(1) ni_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_xanes_standard_101pnt.txt') ni_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_xanes_standard_63pnt.txt') ni_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Ni/eng_list_Ni_s_xanes_standard_21pnt.txt') mn_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_xanes_standard_101pnt.txt') mn_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_xanes_standard_63pnt.txt') mn_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Mn/eng_list_Mn_s_xanes_standard_21pnt.txt') co_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_xanes_standard_101pnt.txt') co_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_xanes_standard_63pnt.txt') co_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Co/eng_list_Co_s_xanes_standard_21pnt.txt') fe_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_xanes_standard_101pnt.txt') fe_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_xanes_standard_63pnt.txt') fe_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Fe/eng_list_Fe_s_xanes_standard_21pnt.txt') v_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_xanes_standard_101pnt.txt') v_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_xanes_standard_63pnt.txt') v_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/V/eng_list_V_s_xanes_standard_21pnt.txt') cr_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_xanes_standard_101pnt.txt') cr_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_xanes_standard_63pnt.txt') cr_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cr/eng_list_Cr_s_xanes_standard_21pnt.txt') cu_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_xanes_standard_101pnt.txt') cu_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_xanes_standard_63pnt.txt') cu_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Cu/eng_list_Cu_s_xanes_standard_21pnt.txt') zn_eng_list_101pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_xanes_standard_101pnt.txt') zn_eng_list_63pnt = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_xanes_standard_63pnt.txt') zn_eng_list_wl = np.genfromtxt('/NSLS2/xf18id1/SW/xanes_ref/Zn/eng_list_Zn_s_xanes_standard_21pnt.txt') def mono_scan_repeatibility_test(pzt_cm_bender_pos_list, pbsl_y_pos_list, eng_start, eng_end, steps, delay_time=0.5, repeat=1): for ii in range(repeat): yield from load_cell_scan(pzt_cm_bender_pos_list, pbsl_y_pos_list, 1, eng_start, eng_end, steps, delay_time=delay_time)
# Problem: https://docs.google.com/document/d/1D-3t64PnsEpcF6kKz5ZaquoMMB-r5UyYGyZzM4hjyi0/edit?usp=sharing def create_dict(): ''' Create a dictionary including the roles and their damages. ''' n = int(input('Enter the number of your party members: ')) party = {} # initialize a dictionary named party for _ in range(n): # prompt the user for the role and its damage inputs = input('Enter the role and its nominal damage (separated by a space): ').split() role = inputs[0] damage = float(inputs[1]) party[damage] = role return party def main(): ''' define main function. ''' party = create_dict() # determine the dictionary named party sorted_damage = sorted(party) # sorted the roles' damage print() # for readability # determine and display the role who attacks from front damage_front = party[sorted_damage[-1]] print('The role who attacks from front:', damage_front) # determine and display the role who attacks from one side damage_side = party[sorted_damage[-3]] print('The role who attacks from one side:', damage_side) # determine and display the role who attacks from other side damage_other_side = party[sorted_damage[-4]] print('The role who attacks from other side:', damage_other_side) # determine and display the role who attacks from back damage_back = party[sorted_damage[-2]] print('The role who attacks from back:', damage_back) # determine and display the total damaged total_damaged = sorted_damage[-1]/2 + sum(sorted_damage[-4:-2]) + sorted_damage[-2]*2 print('The total damage dealt to the cyclops by the party:', total_damaged) # call main funciton main()
def create_dict(): """ Create a dictionary including the roles and their damages. """ n = int(input('Enter the number of your party members: ')) party = {} for _ in range(n): inputs = input('Enter the role and its nominal damage (separated by a space): ').split() role = inputs[0] damage = float(inputs[1]) party[damage] = role return party def main(): """ define main function. """ party = create_dict() sorted_damage = sorted(party) print() damage_front = party[sorted_damage[-1]] print('The role who attacks from front:', damage_front) damage_side = party[sorted_damage[-3]] print('The role who attacks from one side:', damage_side) damage_other_side = party[sorted_damage[-4]] print('The role who attacks from other side:', damage_other_side) damage_back = party[sorted_damage[-2]] print('The role who attacks from back:', damage_back) total_damaged = sorted_damage[-1] / 2 + sum(sorted_damage[-4:-2]) + sorted_damage[-2] * 2 print('The total damage dealt to the cyclops by the party:', total_damaged) main()
class Solution: def kthGrammar(self, n: int, k: int) -> int: if n == 1: return 0 noOfBits = (2 ** (n-1) ) / 2 if k <= noOfBits: return self.kthGrammar(n-1, k) else: return int (not self.kthGrammar(n-1, k - noOfBits))
class Solution: def kth_grammar(self, n: int, k: int) -> int: if n == 1: return 0 no_of_bits = 2 ** (n - 1) / 2 if k <= noOfBits: return self.kthGrammar(n - 1, k) else: return int(not self.kthGrammar(n - 1, k - noOfBits))
# Testing def print_hi(name): print(f'Hi, {name}') # Spewcialized max function # arr = [2, 5, 6, 1, 7, 4] def my_bad_max(a_list): temp_max = 0 counter = 0 for index, num in enumerate(a_list): for other_num in a_list[0:index]: counter = counter + 1 value = num - other_num if value > temp_max: temp_max = value print(f'I\'ve itrerated {counter} times...') return temp_max def my_good_max(a_list): temp_max = 0 temp_max_value = 0 counter = 0 for value in reversed(a_list): counter = counter + 1 if value > temp_max_value: temp_max_value = value if temp_max_value - value > temp_max: temp_max = temp_max_value - value print(f'I\'ve itrerated {counter} times...') return temp_max if __name__ == '__main__': arr = [2, 5, 6, 1, 7, 4] print(my_good_max(arr))
def print_hi(name): print(f'Hi, {name}') def my_bad_max(a_list): temp_max = 0 counter = 0 for (index, num) in enumerate(a_list): for other_num in a_list[0:index]: counter = counter + 1 value = num - other_num if value > temp_max: temp_max = value print(f"I've itrerated {counter} times...") return temp_max def my_good_max(a_list): temp_max = 0 temp_max_value = 0 counter = 0 for value in reversed(a_list): counter = counter + 1 if value > temp_max_value: temp_max_value = value if temp_max_value - value > temp_max: temp_max = temp_max_value - value print(f"I've itrerated {counter} times...") return temp_max if __name__ == '__main__': arr = [2, 5, 6, 1, 7, 4] print(my_good_max(arr))
""" # Definition for a QuadTree node. class Node: def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): self.val = val self.isLeaf = isLeaf self.topLeft = topLeft self.topRight = topRight self.bottomLeft = bottomLeft self.bottomRight = bottomRight """ class Solution: def intersect(self, quadTree1, quadTree2): """ :type quadTree1: Node :type quadTree2: Node :rtype: Node """ if quadTree1.isLeaf: return quadTree1.val and quadTree1 or quadTree2 elif quadTree2.isLeaf: return quadTree2.val and quadTree2 or quadTree1 else: topLeft = self.intersect(quadTree1.topLeft, quadTree2.topLeft) topRight = self.intersect(quadTree1.topRight, quadTree2.topRight) bottomLeft = self.intersect(quadTree1.bottomLeft, quadTree2.bottomLeft) bottomRight = self.intersect(quadTree1.bottomRight, quadTree2.bottomRight) children = [topLeft, topRight, bottomLeft, bottomRight] leaves = [child.isLeaf for child in children] values = [child.val for child in children] if all(leaves) and (sum(values) in (0, 4)): return Node(topLeft.val, True, None, None, None, None) else: return Node(False, False, topLeft, topRight, bottomLeft, bottomRight)
""" # Definition for a QuadTree node. class Node: def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): self.val = val self.isLeaf = isLeaf self.topLeft = topLeft self.topRight = topRight self.bottomLeft = bottomLeft self.bottomRight = bottomRight """ class Solution: def intersect(self, quadTree1, quadTree2): """ :type quadTree1: Node :type quadTree2: Node :rtype: Node """ if quadTree1.isLeaf: return quadTree1.val and quadTree1 or quadTree2 elif quadTree2.isLeaf: return quadTree2.val and quadTree2 or quadTree1 else: top_left = self.intersect(quadTree1.topLeft, quadTree2.topLeft) top_right = self.intersect(quadTree1.topRight, quadTree2.topRight) bottom_left = self.intersect(quadTree1.bottomLeft, quadTree2.bottomLeft) bottom_right = self.intersect(quadTree1.bottomRight, quadTree2.bottomRight) children = [topLeft, topRight, bottomLeft, bottomRight] leaves = [child.isLeaf for child in children] values = [child.val for child in children] if all(leaves) and sum(values) in (0, 4): return node(topLeft.val, True, None, None, None, None) else: return node(False, False, topLeft, topRight, bottomLeft, bottomRight)
class ForthException(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg class CompileException(ForthException): pass
class Forthexception(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg class Compileexception(ForthException): pass
detik_input = int(input()) jam = detik_input // 3600 detik_input -= jam * 3600 menit = detik_input // 60 detik_input -= menit * 60 detik = detik_input print(jam) print(menit) print(detik)
detik_input = int(input()) jam = detik_input // 3600 detik_input -= jam * 3600 menit = detik_input // 60 detik_input -= menit * 60 detik = detik_input print(jam) print(menit) print(detik)
word1 = input() word2 = input() # How many letters does the longest word contain? len_word1 = len(word1) len_word2 = len(word2) max_len = 0 if len_word1 >= len_word2: max_len = len_word1 else: max_len = len_word2 print(max_len)
word1 = input() word2 = input() len_word1 = len(word1) len_word2 = len(word2) max_len = 0 if len_word1 >= len_word2: max_len = len_word1 else: max_len = len_word2 print(max_len)
def _(line): new_indent = 0 for section in line: if (section != ''): break new_indent = new_indent + 1 return new_indent
def _(line): new_indent = 0 for section in line: if section != '': break new_indent = new_indent + 1 return new_indent
class Something: def __eq__(self, other: object) -> bool: pass class Reference: pass __book_url__ = "dummy" __book_version__ = "dummy" associate_ref_with(Reference)
class Something: def __eq__(self, other: object) -> bool: pass class Reference: pass __book_url__ = 'dummy' __book_version__ = 'dummy' associate_ref_with(Reference)
""" # COURSE SCHEDULE II There are a total of n courses you have to take labelled from 0 to n - 1. Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you must take the course bi before the course ai. Given the total number of courses numCourses and a list of the prerequisite pairs, return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array. Example 1: Input: numCourses = 2, prerequisites = [[1,0]] Output: [0,1] Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1]. Example 2: Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]] Output: [0,2,1,3] Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. Example 3: Input: numCourses = 1, prerequisites = [] Output: [0] Constraints: 1 <= numCourses <= 2000 0 <= prerequisites.length <= numCourses * (numCourses - 1) prerequisites[i].length == 2 0 <= ai, bi < numCourses ai != bi All the pairs [ai, bi] are distinct. """ class Solution: def __init__(self): self.flag = True def findOrder(self, numCourses: int, prerequisites): d = {} for x in prerequisites: if x[0] not in d: d[x[0]] = [x[1]] else: d[x[0]].append(x[1]) perm = [] for x in range(numCourses): temp = set() if x in perm: continue self.check(x, perm, temp, d) if not self.flag: return [] return perm def check(self, n, perm, temp, d): if n in perm: return if n in temp: self.flag = False return temp.add(n) if n in d: for m in d[n]: self.check(m, perm, temp, d) temp.remove(n) perm.append(n)
""" # COURSE SCHEDULE II There are a total of n courses you have to take labelled from 0 to n - 1. Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you must take the course bi before the course ai. Given the total number of courses numCourses and a list of the prerequisite pairs, return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array. Example 1: Input: numCourses = 2, prerequisites = [[1,0]] Output: [0,1] Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1]. Example 2: Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]] Output: [0,2,1,3] Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3]. Example 3: Input: numCourses = 1, prerequisites = [] Output: [0] Constraints: 1 <= numCourses <= 2000 0 <= prerequisites.length <= numCourses * (numCourses - 1) prerequisites[i].length == 2 0 <= ai, bi < numCourses ai != bi All the pairs [ai, bi] are distinct. """ class Solution: def __init__(self): self.flag = True def find_order(self, numCourses: int, prerequisites): d = {} for x in prerequisites: if x[0] not in d: d[x[0]] = [x[1]] else: d[x[0]].append(x[1]) perm = [] for x in range(numCourses): temp = set() if x in perm: continue self.check(x, perm, temp, d) if not self.flag: return [] return perm def check(self, n, perm, temp, d): if n in perm: return if n in temp: self.flag = False return temp.add(n) if n in d: for m in d[n]: self.check(m, perm, temp, d) temp.remove(n) perm.append(n)
class RSI(object): def __init__(self, OHLC, period): self.OHLC = OHLC self.period = period self.gain_loss = self.gain_loss_calc() def gain_loss_calc(self): data = self.OHLC["close"] gain_loss = [] for i in range(1, len(data)): change = float(data[i]) - float(data[i-1]) if change >= 0: gain_loss.append({"gain": change, "loss": 0}) else: gain_loss.append({"gain": 0, "loss": abs(change)}) return gain_loss def first_avg_calc(self): gain_loss = self.gain_loss gain = 0 loss = 0 for i in range(0, self.period): gain += gain_loss[i]["gain"] loss += gain_loss[i]["loss"] gain = gain / self.period loss = loss / self.period return {"gain": gain, "loss": loss} def rsi_calc(self): gain_loss = self.gain_loss prev_avg_gain_loss = self.first_avg_calc() avg_gain = 0 avg_loss = 0 for i in range(self.period, len(gain_loss)): avg_gain = ((prev_avg_gain_loss["gain"] * (self.period - 1)) + gain_loss[i]["gain"]) / self.period prev_avg_gain_loss["gain"] = avg_gain avg_loss = ((prev_avg_gain_loss["loss"] * (self.period - 1)) + gain_loss[i]["loss"]) / self.period prev_avg_gain_loss["loss"] = avg_loss rs = avg_gain / avg_loss rsi = 100 - (100 / (1 + rs)) return rsi
class Rsi(object): def __init__(self, OHLC, period): self.OHLC = OHLC self.period = period self.gain_loss = self.gain_loss_calc() def gain_loss_calc(self): data = self.OHLC['close'] gain_loss = [] for i in range(1, len(data)): change = float(data[i]) - float(data[i - 1]) if change >= 0: gain_loss.append({'gain': change, 'loss': 0}) else: gain_loss.append({'gain': 0, 'loss': abs(change)}) return gain_loss def first_avg_calc(self): gain_loss = self.gain_loss gain = 0 loss = 0 for i in range(0, self.period): gain += gain_loss[i]['gain'] loss += gain_loss[i]['loss'] gain = gain / self.period loss = loss / self.period return {'gain': gain, 'loss': loss} def rsi_calc(self): gain_loss = self.gain_loss prev_avg_gain_loss = self.first_avg_calc() avg_gain = 0 avg_loss = 0 for i in range(self.period, len(gain_loss)): avg_gain = (prev_avg_gain_loss['gain'] * (self.period - 1) + gain_loss[i]['gain']) / self.period prev_avg_gain_loss['gain'] = avg_gain avg_loss = (prev_avg_gain_loss['loss'] * (self.period - 1) + gain_loss[i]['loss']) / self.period prev_avg_gain_loss['loss'] = avg_loss rs = avg_gain / avg_loss rsi = 100 - 100 / (1 + rs) return rsi
class Recipe(object): """ This class provides a Recipe for an Order. It is a list (or dictionary) of tuples (str machineName, int timeAtMachine). """ def __init__(self): """ recipe is a list (or dictionary) that contains the tuples of time information for the Recipe. """ self.recipe = [] def indexOfMachine(self, machineName): """ Returns the index of the Machine with machineName in the recipe list. """ for i, r in enumerate(self.recipe): if r[0] == machineName: return i return -1 def calcMinProcTime(self, plant, machineName = None): """ This method calculates the minimum processing time of the Recipe starting from Machine with machineName (Considers the constant plant delays for the crane movement time between machines). """ if machineName == None or machineName == "": index = 0 else: index = self.indexOfMachine(machineName) res = (len(self.recipe) - 1 - index) * plant.craneMoveTime while index < len(self.recipe): res += self.recipe[index][1] if self.recipe[index][1] == 0: res -= plant.craneMoveTime index += 1 return res def __getitem__(self, key): """ Returns the time in the Recipe at Machine with name key. """ assert type(key) == str or type(key) == unicode for r in self.recipe: if r[0] == key: return r[1] return None def __setitem__(self, key, value): """ Adds a Recipe item (a tuple of (str machineName, int time)) to the Recipe list (or dictionary). It will not add the item if machineName is already in the list. """ assert type(key) == str or type(key) == unicode assert type(value) == int if self.__getitem__(key) == None: self.recipe.append([key, value]) else: for i, r in enumerate(self.recipe): if r[0] == key: del self.recipe[i] self.recipe.insert(i, [key, value]) return @staticmethod def fromXml(element): """ A static method that creates a Recipe instance from an XML tree node and returns it. """ recipe = Recipe() for e in element.getElementsByTagName("machine"): recipe[e.getAttribute("name").lower()] = int(e.getAttribute("time")) return recipe
class Recipe(object): """ This class provides a Recipe for an Order. It is a list (or dictionary) of tuples (str machineName, int timeAtMachine). """ def __init__(self): """ recipe is a list (or dictionary) that contains the tuples of time information for the Recipe. """ self.recipe = [] def index_of_machine(self, machineName): """ Returns the index of the Machine with machineName in the recipe list. """ for (i, r) in enumerate(self.recipe): if r[0] == machineName: return i return -1 def calc_min_proc_time(self, plant, machineName=None): """ This method calculates the minimum processing time of the Recipe starting from Machine with machineName (Considers the constant plant delays for the crane movement time between machines). """ if machineName == None or machineName == '': index = 0 else: index = self.indexOfMachine(machineName) res = (len(self.recipe) - 1 - index) * plant.craneMoveTime while index < len(self.recipe): res += self.recipe[index][1] if self.recipe[index][1] == 0: res -= plant.craneMoveTime index += 1 return res def __getitem__(self, key): """ Returns the time in the Recipe at Machine with name key. """ assert type(key) == str or type(key) == unicode for r in self.recipe: if r[0] == key: return r[1] return None def __setitem__(self, key, value): """ Adds a Recipe item (a tuple of (str machineName, int time)) to the Recipe list (or dictionary). It will not add the item if machineName is already in the list. """ assert type(key) == str or type(key) == unicode assert type(value) == int if self.__getitem__(key) == None: self.recipe.append([key, value]) else: for (i, r) in enumerate(self.recipe): if r[0] == key: del self.recipe[i] self.recipe.insert(i, [key, value]) return @staticmethod def from_xml(element): """ A static method that creates a Recipe instance from an XML tree node and returns it. """ recipe = recipe() for e in element.getElementsByTagName('machine'): recipe[e.getAttribute('name').lower()] = int(e.getAttribute('time')) return recipe
# -*- coding: utf8 -*- __author__ = 'D. Belavin' class NodeTree: __slots__ = ['key', 'payload', 'parent', 'left', 'right', 'height'] def __init__(self, key, payload, parent=None, left=None, right=None): self.key = key self.payload = payload self.parent = parent self.left = left self.right = right self.height = 1 def has_left_child(self): return self.left def has_right_child(self): return self.right def is_left_knot(self): return self.parent and self.parent.left == self def is_right_knot(self): return self.parent and self.parent.right == self def is_root(self): return not self.parent def has_leaf(self): return not(self.left or self.right) def has_any_children(self): return self.left or self.right def has_both_children(self): return self.left and self.right def replace_node_date(self, key, payload, left, right): # swap root and his child (left or right) self.key = key self.payload = payload self.left = left self.right = right if self.has_left_child(): self.left.parent = self if self.has_right_child(): self.right.parent = self def find_min(self): curr = self while curr.has_left_child(): curr = curr.left return curr def find_successor(self): succ = None # has right child if self.has_right_child(): succ = self.right.find_min() else: if self.parent: # self.parent.left == self if self.is_left_knot(): succ = self.parent else: self.parent.right = None # say that there is no right child succ = self.parent.find_successor() # from the left of the parent self.parent.right = self # return the right child to the place return succ def splice_out(self): # cut off node if self.has_leaf(): # self.parent.left == self if self.is_left_knot(): self.parent.left = None # self.parent.right == self else: self.parent.right = None # self has left or right child elif self.has_any_children(): # has left child if self.has_left_child(): # self.parent.left == self if self.is_left_knot(): self.parent.left = self.left # self.parent.right == self else: self.parent.right = self.left # give away parent self.left.parent = self.parent # has right child else: # self.parent.left == self if self.is_left_knot(): self.parent.left = self.right # self.parent.right == self else: self.parent.right = self.right # give away parent self.right.parent = self.parent def __iter__(self): if self: if self.has_left_child(): for element in self.left: yield element yield self.key if self.has_right_child(): for element in self.right: yield element class AVLTree: def __init__(self): self.root = None self.size = 0 def _height(self, node): if node: return node.height return 0 def _get_balance(self, node): if node: return self._height(node.left) - self._height(node.right) return 0 def _height_up(self, node): # exhibit the height return 1 + max(self._height(node.left), self._height(node.right)) def _left_rotate(self, rot_node): # rot_node.right = rot_node.right.left new_node = rot_node.right rot_node.right = new_node.left # give away left child if new_node.has_left_child(): new_node.left.parent = rot_node # give away parent new_node.parent = rot_node.parent # rot_node == self.root if rot_node.is_root(): self.root = new_node new_node.parent = None else: # rot_node.parent.left == rot_node if rot_node.is_left_knot(): rot_node.parent.left = new_node # rot_node.parent.right == rot_node else: rot_node.parent.right = new_node # rot_node is left child new_node new_node.left = rot_node rot_node.parent = new_node # exhibit the height rot_node.height = self._height_up(rot_node) new_node.height = self._height_up(new_node) def _right_rotate(self, rot_node): # rot_node.left = rot_node.left.right new_node = rot_node.left rot_node.left = new_node.right # give away right child if new_node.has_right_child(): new_node.right.parent = rot_node # give away parent new_node.parent = rot_node.parent # rot_node == self.root if rot_node.is_root(): self.root = new_node new_node.parent = None else: # rot_node.parent.left == rot_node if rot_node.is_left_knot(): rot_node.parent.left = new_node # rot_node.parent.right == rot_node else: rot_node.parent.right = new_node # rot_node is right child new_node new_node.right = rot_node rot_node.parent = new_node # exhibit the height rot_node.height = self._height_up(rot_node) new_node.height = self._height_up(new_node) def _fix_balance(self, node): node.height = self._height_up(node) balance = self._get_balance(node) if balance > 1: # big left rotate if self._get_balance(node.left) < 0: self._left_rotate(node.left) self._right_rotate(node) # small right rotate else: self._right_rotate(node) elif balance < -1: # big right rotate if self._get_balance(node.right) > 0: self._right_rotate(node.right) self._left_rotate(node) # small left rotate else: self._left_rotate(node) def _insert(self, key, payload, curr_node): # Important place. Responsible for inserting duplicate keys. # If you remove these conditions, you can set duplicate keys. # If we leave, we get the structure of a dict (map). # If we leave this condition, and remove the payload, # then we get the basis for the "set" structure. if key == curr_node.key: curr_node.payload = payload else: # go to the left if key < curr_node.key: if curr_node.has_left_child(): self._insert(key, payload, curr_node.left) else: # curr_node.left == None curr_node.left = NodeTree(key, payload, parent=curr_node) self.size += 1 # go to the right else: if curr_node.has_right_child(): self._insert(key, payload, curr_node.right) else: # curr_node.right == None curr_node.right = NodeTree(key, payload, parent=curr_node) self.size += 1 self._fix_balance(curr_node) def insert(self, key, payload): if self.root: self._insert(key, payload, self.root) else: self.root = NodeTree(key, payload) self.size += 1 def _get(self, key, curr_node): # find not key, stop recursion if not curr_node: return None # find key, stop recursion elif key == curr_node.key: return curr_node # go to the left elif key < curr_node.key: return self._get(key, curr_node.left) # go to the right else: return self._get(key, curr_node.right) def get(self, key): if self.root: res = self._get(key, self.root) if res: return res.payload else: return None # can be replaced by an "raise KeyError" else: return None # can be replaced by an "raise KeyError" def _delete(self, node): if node.has_leaf(): # node not has children # node.parent.left == node if node.is_left_knot(): node.parent.left = None # node.parent.right == node else: node.parent.right = None self._fix_balance(node.parent) elif node.has_both_children(): # node has two children succ = node.find_successor() succ.splice_out() node.key = succ.key node.payload = succ.payload self._fix_balance(succ.parent) else: # node has any child if node.has_any_children(): # has left child if node.has_left_child(): # node.parent.left == node if node.is_left_knot(): node.parent.left = node.left node.left.parent = node.parent self._fix_balance(node.parent) # node.parent.right == node elif node.is_right_knot(): node.parent.right = node.left node.left.parent = node.parent self._fix_balance(node.parent) else: # node has not parent, means node == self.root # but node has left child node.replace_node_date(node.left.key, node.left.payload, node.left.left, node.left.right) self._fix_balance(node) # has right child else: # node.parent.left == node if node.is_left_knot(): node.parent.left = node.right node.right.parent = node.parent self._fix_balance(node.parent) # node.parent.right == node elif node.is_right_knot(): node.parent.right = node.right node.right.parent = node.parent self._fix_balance(node.parent) else: # node has not parent, means node == self.root # but node has right child node.replace_node_date(node.right.key, node.right.payload, node.right.left, node.right.right) self._fix_balance(node) def delete(self, key): if self.size > 1: remove_node = self._get(key, self.root) if remove_node: self._delete(remove_node) self.size -= 1 else: raise KeyError('key not in tree.') elif self.size == 1 and self.root.key == key: self.root = None self.size -= 1 else: raise KeyError('key not in tree.') def __len__(self): return self.size def __setitem__(self, key, payload): self.insert(key, payload) def __delitem__(self, key): self.delete(key) def __getitem__(self, key): return self.get(key) def __contains__(self, key): if self._get(key, self.root): return True else: return False def __iter__(self): if self.root: return self.root.__iter__() return iter([]) def clear_tree(self): self.root = None self.size = 0
__author__ = 'D. Belavin' class Nodetree: __slots__ = ['key', 'payload', 'parent', 'left', 'right', 'height'] def __init__(self, key, payload, parent=None, left=None, right=None): self.key = key self.payload = payload self.parent = parent self.left = left self.right = right self.height = 1 def has_left_child(self): return self.left def has_right_child(self): return self.right def is_left_knot(self): return self.parent and self.parent.left == self def is_right_knot(self): return self.parent and self.parent.right == self def is_root(self): return not self.parent def has_leaf(self): return not (self.left or self.right) def has_any_children(self): return self.left or self.right def has_both_children(self): return self.left and self.right def replace_node_date(self, key, payload, left, right): self.key = key self.payload = payload self.left = left self.right = right if self.has_left_child(): self.left.parent = self if self.has_right_child(): self.right.parent = self def find_min(self): curr = self while curr.has_left_child(): curr = curr.left return curr def find_successor(self): succ = None if self.has_right_child(): succ = self.right.find_min() elif self.parent: if self.is_left_knot(): succ = self.parent else: self.parent.right = None succ = self.parent.find_successor() self.parent.right = self return succ def splice_out(self): if self.has_leaf(): if self.is_left_knot(): self.parent.left = None else: self.parent.right = None elif self.has_any_children(): if self.has_left_child(): if self.is_left_knot(): self.parent.left = self.left else: self.parent.right = self.left self.left.parent = self.parent else: if self.is_left_knot(): self.parent.left = self.right else: self.parent.right = self.right self.right.parent = self.parent def __iter__(self): if self: if self.has_left_child(): for element in self.left: yield element yield self.key if self.has_right_child(): for element in self.right: yield element class Avltree: def __init__(self): self.root = None self.size = 0 def _height(self, node): if node: return node.height return 0 def _get_balance(self, node): if node: return self._height(node.left) - self._height(node.right) return 0 def _height_up(self, node): return 1 + max(self._height(node.left), self._height(node.right)) def _left_rotate(self, rot_node): new_node = rot_node.right rot_node.right = new_node.left if new_node.has_left_child(): new_node.left.parent = rot_node new_node.parent = rot_node.parent if rot_node.is_root(): self.root = new_node new_node.parent = None elif rot_node.is_left_knot(): rot_node.parent.left = new_node else: rot_node.parent.right = new_node new_node.left = rot_node rot_node.parent = new_node rot_node.height = self._height_up(rot_node) new_node.height = self._height_up(new_node) def _right_rotate(self, rot_node): new_node = rot_node.left rot_node.left = new_node.right if new_node.has_right_child(): new_node.right.parent = rot_node new_node.parent = rot_node.parent if rot_node.is_root(): self.root = new_node new_node.parent = None elif rot_node.is_left_knot(): rot_node.parent.left = new_node else: rot_node.parent.right = new_node new_node.right = rot_node rot_node.parent = new_node rot_node.height = self._height_up(rot_node) new_node.height = self._height_up(new_node) def _fix_balance(self, node): node.height = self._height_up(node) balance = self._get_balance(node) if balance > 1: if self._get_balance(node.left) < 0: self._left_rotate(node.left) self._right_rotate(node) else: self._right_rotate(node) elif balance < -1: if self._get_balance(node.right) > 0: self._right_rotate(node.right) self._left_rotate(node) else: self._left_rotate(node) def _insert(self, key, payload, curr_node): if key == curr_node.key: curr_node.payload = payload else: if key < curr_node.key: if curr_node.has_left_child(): self._insert(key, payload, curr_node.left) else: curr_node.left = node_tree(key, payload, parent=curr_node) self.size += 1 elif curr_node.has_right_child(): self._insert(key, payload, curr_node.right) else: curr_node.right = node_tree(key, payload, parent=curr_node) self.size += 1 self._fix_balance(curr_node) def insert(self, key, payload): if self.root: self._insert(key, payload, self.root) else: self.root = node_tree(key, payload) self.size += 1 def _get(self, key, curr_node): if not curr_node: return None elif key == curr_node.key: return curr_node elif key < curr_node.key: return self._get(key, curr_node.left) else: return self._get(key, curr_node.right) def get(self, key): if self.root: res = self._get(key, self.root) if res: return res.payload else: return None else: return None def _delete(self, node): if node.has_leaf(): if node.is_left_knot(): node.parent.left = None else: node.parent.right = None self._fix_balance(node.parent) elif node.has_both_children(): succ = node.find_successor() succ.splice_out() node.key = succ.key node.payload = succ.payload self._fix_balance(succ.parent) elif node.has_any_children(): if node.has_left_child(): if node.is_left_knot(): node.parent.left = node.left node.left.parent = node.parent self._fix_balance(node.parent) elif node.is_right_knot(): node.parent.right = node.left node.left.parent = node.parent self._fix_balance(node.parent) else: node.replace_node_date(node.left.key, node.left.payload, node.left.left, node.left.right) self._fix_balance(node) elif node.is_left_knot(): node.parent.left = node.right node.right.parent = node.parent self._fix_balance(node.parent) elif node.is_right_knot(): node.parent.right = node.right node.right.parent = node.parent self._fix_balance(node.parent) else: node.replace_node_date(node.right.key, node.right.payload, node.right.left, node.right.right) self._fix_balance(node) def delete(self, key): if self.size > 1: remove_node = self._get(key, self.root) if remove_node: self._delete(remove_node) self.size -= 1 else: raise key_error('key not in tree.') elif self.size == 1 and self.root.key == key: self.root = None self.size -= 1 else: raise key_error('key not in tree.') def __len__(self): return self.size def __setitem__(self, key, payload): self.insert(key, payload) def __delitem__(self, key): self.delete(key) def __getitem__(self, key): return self.get(key) def __contains__(self, key): if self._get(key, self.root): return True else: return False def __iter__(self): if self.root: return self.root.__iter__() return iter([]) def clear_tree(self): self.root = None self.size = 0
class Member(object): def __init__(self, interval, membership): self.interval = interval self.membership = membership def is_max(self): return self.membership == 1.0 def __str__(self): return str(self.membership) + "/" + str(self.interval) def __hash__(self): return self.interval
class Member(object): def __init__(self, interval, membership): self.interval = interval self.membership = membership def is_max(self): return self.membership == 1.0 def __str__(self): return str(self.membership) + '/' + str(self.interval) def __hash__(self): return self.interval
class SparkConstants: SIMPLE_CRED = 'org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider' TEMP_CRED = 'org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider' CRED_PROVIDER_KEY = 'spark.hadoop.fs.s3a.aws.credentials.provider' CRED_ACCESS_KEY = 'spark.hadoop.fs.s3a.access.key' CRED_SECRET_KEY = 'spark.hadoop.fs.s3a.secret.key' CRED_TOKEN_KEY = 'spark.hadoop.fs.s3a.session.token'
class Sparkconstants: simple_cred = 'org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider' temp_cred = 'org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider' cred_provider_key = 'spark.hadoop.fs.s3a.aws.credentials.provider' cred_access_key = 'spark.hadoop.fs.s3a.access.key' cred_secret_key = 'spark.hadoop.fs.s3a.secret.key' cred_token_key = 'spark.hadoop.fs.s3a.session.token'
"""Check if string is blank. Set boolean _blank to _true if string _s is empty, or null, or contains only whitespace ; _false otherwise. Source: programming-idioms.org """ # Implementation author: TinyFawks # Created on 2016-02-18T16:58:03.22685Z # Last modified on 2019-09-26T20:40:16.940019Z # Version 6 blank = s.strip() == ""
"""Check if string is blank. Set boolean _blank to _true if string _s is empty, or null, or contains only whitespace ; _false otherwise. Source: programming-idioms.org """ blank = s.strip() == ''
""" Test no choices given .. ignored: """
""" Test no choices given .. ignored: """
#!/usr/bin/env python """ _JobSplitting_ A set of algorithms to allocate work to a set of jobs split along lines like event, run, lumi, file. """ __all__ = []
""" _JobSplitting_ A set of algorithms to allocate work to a set of jobs split along lines like event, run, lumi, file. """ __all__ = []
load(":providers.bzl", "PrismaDataModel") def _prisma_datamodel_impl(ctx): return [ PrismaDataModel(datamodels = ctx.files.srcs), DefaultInfo( files = depset(ctx.files.srcs), runfiles = ctx.runfiles(files = ctx.files.srcs), ), ] prisma_datamodel = rule( implementation = _prisma_datamodel_impl, attrs = { "srcs": attr.label_list( allow_files = [".prisma"], allow_empty = False, mandatory = True, ), }, )
load(':providers.bzl', 'PrismaDataModel') def _prisma_datamodel_impl(ctx): return [prisma_data_model(datamodels=ctx.files.srcs), default_info(files=depset(ctx.files.srcs), runfiles=ctx.runfiles(files=ctx.files.srcs))] prisma_datamodel = rule(implementation=_prisma_datamodel_impl, attrs={'srcs': attr.label_list(allow_files=['.prisma'], allow_empty=False, mandatory=True)})
instr = input() deviate = int(input()) for x in instr: if x.isalpha(): uni = ord(x) if x.islower(): x = chr(97 + ((uni + deviate) - 97) % 26) elif x.isupper(): x = chr(65 + ((uni + deviate) - 65) % 26) print(x, end="") print()
instr = input() deviate = int(input()) for x in instr: if x.isalpha(): uni = ord(x) if x.islower(): x = chr(97 + (uni + deviate - 97) % 26) elif x.isupper(): x = chr(65 + (uni + deviate - 65) % 26) print(x, end='') print()
def centered_average(nums): """ take out 1 value of the smallest and largst compute and return the mean of the rest int div --> truncate the floating part? ASSUME: +3 ints pos/neg unsorted dupes possible Intutition: - computing an average (sum / # of points) Approach: 1. Simple - compute the min - compute the max - sum the whole list - subtract (min), and subtract max - return (remaining_sum) by (len = 2) Edge Cases: - all negatives --> normal - if in prod and saw input that broke constraints --> Error """ # - compute the min # - compute the max min_val, max_val = min(nums), max(nums) # - sum the whole list total = sum(nums) # - subtract (min), and subtract max remaining_sum = total - (min_val + max_val) # - return (remaining_sum) by (len = 2) return int(remaining_sum / (len(nums) - 2))
def centered_average(nums): """ take out 1 value of the smallest and largst compute and return the mean of the rest int div --> truncate the floating part? ASSUME: +3 ints pos/neg unsorted dupes possible Intutition: - computing an average (sum / # of points) Approach: 1. Simple - compute the min - compute the max - sum the whole list - subtract (min), and subtract max - return (remaining_sum) by (len = 2) Edge Cases: - all negatives --> normal - if in prod and saw input that broke constraints --> Error """ (min_val, max_val) = (min(nums), max(nums)) total = sum(nums) remaining_sum = total - (min_val + max_val) return int(remaining_sum / (len(nums) - 2))
dd, mm, aa = input().split('/') print(f'{dd}-{mm}-{aa}') print(f'{mm}-{dd}-{aa}') print(f'{aa}/{mm}/{dd}')
(dd, mm, aa) = input().split('/') print(f'{dd}-{mm}-{aa}') print(f'{mm}-{dd}-{aa}') print(f'{aa}/{mm}/{dd}')
MODULUS_NUM = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 MODULUS_BITS = 381 LIMB_SIZES = [55, 55, 51, 55, 55, 55, 55] WORD_SIZE = 64 # Check that MODULUS_BITS is correct assert(2**MODULUS_BITS > MODULUS_NUM) assert(2**(MODULUS_BITS - 1) < MODULUS_NUM) # Check that limb sizes are correct tmp = 0 for i in range(0, len(LIMB_SIZES)): assert(LIMB_SIZES[i] < WORD_SIZE) tmp += LIMB_SIZES[i] assert(tmp == MODULUS_BITS) # Compute the value of the modulus in this representation MODULUS = [] tmp = MODULUS_NUM print("MODULUS = [") for i in range(0, len(LIMB_SIZES)): this_modulus_num = tmp & ((2**LIMB_SIZES[i]) - 1) MODULUS.append(this_modulus_num) tmp = tmp >> LIMB_SIZES[i] print("\t", hex(this_modulus_num), ",") print("]") # Each word in our representation has an associated "magnitude" M # in which the word is guaranteed to be less than or equal to (2^LIMB_SIZE - 1)*M # Initialize LARGEST_MAGNITUDE_CARRIES to some high number LARGEST_MAGNITUDE_CARRIES = 2**WORD_SIZE - 1 for i in range(0, len(LIMB_SIZES)): largest_mag = int(2**WORD_SIZE / (2**LIMB_SIZES[i])) assert((((2**LIMB_SIZES[i]) - 1)*largest_mag) < 2**WORD_SIZE) assert((((2**LIMB_SIZES[i]) - 1)*(largest_mag+1)) > 2**WORD_SIZE) if LARGEST_MAGNITUDE_CARRIES > largest_mag: LARGEST_MAGNITUDE_CARRIES = largest_mag print("Largest magnitude allowed for carries:", LARGEST_MAGNITUDE_CARRIES) NEGATION_MULTIPLES_OF_MODULUS = 0 for i in range(0, len(LIMB_SIZES)): tmp = 0 while (tmp * MODULUS[i]) <= ((2**LIMB_SIZES[i]) - 1): tmp = tmp + 1 if NEGATION_MULTIPLES_OF_MODULUS < tmp: NEGATION_MULTIPLES_OF_MODULUS = tmp print("Scale necessary for negations:", NEGATION_MULTIPLES_OF_MODULUS)
modulus_num = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 modulus_bits = 381 limb_sizes = [55, 55, 51, 55, 55, 55, 55] word_size = 64 assert 2 ** MODULUS_BITS > MODULUS_NUM assert 2 ** (MODULUS_BITS - 1) < MODULUS_NUM tmp = 0 for i in range(0, len(LIMB_SIZES)): assert LIMB_SIZES[i] < WORD_SIZE tmp += LIMB_SIZES[i] assert tmp == MODULUS_BITS modulus = [] tmp = MODULUS_NUM print('MODULUS = [') for i in range(0, len(LIMB_SIZES)): this_modulus_num = tmp & 2 ** LIMB_SIZES[i] - 1 MODULUS.append(this_modulus_num) tmp = tmp >> LIMB_SIZES[i] print('\t', hex(this_modulus_num), ',') print(']') largest_magnitude_carries = 2 ** WORD_SIZE - 1 for i in range(0, len(LIMB_SIZES)): largest_mag = int(2 ** WORD_SIZE / 2 ** LIMB_SIZES[i]) assert (2 ** LIMB_SIZES[i] - 1) * largest_mag < 2 ** WORD_SIZE assert (2 ** LIMB_SIZES[i] - 1) * (largest_mag + 1) > 2 ** WORD_SIZE if LARGEST_MAGNITUDE_CARRIES > largest_mag: largest_magnitude_carries = largest_mag print('Largest magnitude allowed for carries:', LARGEST_MAGNITUDE_CARRIES) negation_multiples_of_modulus = 0 for i in range(0, len(LIMB_SIZES)): tmp = 0 while tmp * MODULUS[i] <= 2 ** LIMB_SIZES[i] - 1: tmp = tmp + 1 if NEGATION_MULTIPLES_OF_MODULUS < tmp: negation_multiples_of_modulus = tmp print('Scale necessary for negations:', NEGATION_MULTIPLES_OF_MODULUS)
DICTIONARY = {'A': 'awesome', 'C': 'confident', 'B': 'beautiful', 'E': 'eager', 'D': 'disturbing', 'G': 'gregarious', 'F': 'fantastic', 'I': 'ingestable', 'H': 'hippy', 'K': 'klingon', 'J': 'joke', 'M': 'mustache', 'L': 'literal', 'O': 'oscillating', 'N': 'newtonian', 'Q': 'queen', 'P': 'perfect', 'S': 'stylish', 'R': 'rant', 'U': 'underlying', 'T': 'turn', 'W': 'weird', 'V': 'volcano', 'Y': 'yogic', 'X': 'xylophone', 'Z': 'zero'} def make_backronym(acronym): return ' '.join(DICTIONARY[a] for a in acronym.upper())
dictionary = {'A': 'awesome', 'C': 'confident', 'B': 'beautiful', 'E': 'eager', 'D': 'disturbing', 'G': 'gregarious', 'F': 'fantastic', 'I': 'ingestable', 'H': 'hippy', 'K': 'klingon', 'J': 'joke', 'M': 'mustache', 'L': 'literal', 'O': 'oscillating', 'N': 'newtonian', 'Q': 'queen', 'P': 'perfect', 'S': 'stylish', 'R': 'rant', 'U': 'underlying', 'T': 'turn', 'W': 'weird', 'V': 'volcano', 'Y': 'yogic', 'X': 'xylophone', 'Z': 'zero'} def make_backronym(acronym): return ' '.join((DICTIONARY[a] for a in acronym.upper()))
_ALLOWED_VOLUME_KEYS = ["claim_name", "mount_path"] def parse(volume_str): """Parse combined k8s volume string into a dict. Args: volume_str: The string representation for k8s volume, e.g. "claim_name=c1,mount_path=/path1". Return: A Python dictionary parsed from the given volume string. """ kvs = volume_str.split(",") volume_keys = [] parsed_volume_dict = {} for kv in kvs: k, v = kv.split("=") if k not in volume_keys: volume_keys.append(k) else: raise ValueError( "The volume string contains duplicate volume key: %s" % k ) if k not in _ALLOWED_VOLUME_KEYS: raise ValueError( "%s is not in the allowed list of volume keys: %s" % (k, _ALLOWED_VOLUME_KEYS) ) parsed_volume_dict[k] = v return parsed_volume_dict
_allowed_volume_keys = ['claim_name', 'mount_path'] def parse(volume_str): """Parse combined k8s volume string into a dict. Args: volume_str: The string representation for k8s volume, e.g. "claim_name=c1,mount_path=/path1". Return: A Python dictionary parsed from the given volume string. """ kvs = volume_str.split(',') volume_keys = [] parsed_volume_dict = {} for kv in kvs: (k, v) = kv.split('=') if k not in volume_keys: volume_keys.append(k) else: raise value_error('The volume string contains duplicate volume key: %s' % k) if k not in _ALLOWED_VOLUME_KEYS: raise value_error('%s is not in the allowed list of volume keys: %s' % (k, _ALLOWED_VOLUME_KEYS)) parsed_volume_dict[k] = v return parsed_volume_dict
# find the non-repeating integer in an array # set operations (including 'in' operation) are O(1) on average, and one loop that runs n times makes O(n) def single(array): repeated = set() not_repeated = set() for i in array: if i in repeated: continue elif i in not_repeated: repeated.add(i) not_repeated.remove(i) else: not_repeated.add(i) return not_repeated array1 = [2, 'a', 'l', 3, 'l', 5, 4, 'k', 2, 3, 4, 'a', 6, 'c', 4, 'm', 6, 'm', 'k', 9, 10, 9, 8, 7, 8, 10, 7] print(single(array1)) # {'c', 5}
def single(array): repeated = set() not_repeated = set() for i in array: if i in repeated: continue elif i in not_repeated: repeated.add(i) not_repeated.remove(i) else: not_repeated.add(i) return not_repeated array1 = [2, 'a', 'l', 3, 'l', 5, 4, 'k', 2, 3, 4, 'a', 6, 'c', 4, 'm', 6, 'm', 'k', 9, 10, 9, 8, 7, 8, 10, 7] print(single(array1))
def lstrip0(iterable, obj): i = 0 iterable_list = list(iterable) while i < len(iterable_list): if iterable_list[i] != obj: break i += 1 for k in range(i, len(iterable_list)): yield iterable_list[k] def lstrip(iterable, obj, key_func=None): if not key_func: key_func = lambda x: x == obj i = 0 iterable_list = list(iterable) while i < len(iterable_list): if key_func(iterable_list[i]) is False: break i += 1 for k in range(i, len(iterable_list)): yield iterable_list[k] if __name__ == "__main__": lstrip0([1,1,1], 1) lstrip([1,1,1], 1)
def lstrip0(iterable, obj): i = 0 iterable_list = list(iterable) while i < len(iterable_list): if iterable_list[i] != obj: break i += 1 for k in range(i, len(iterable_list)): yield iterable_list[k] def lstrip(iterable, obj, key_func=None): if not key_func: key_func = lambda x: x == obj i = 0 iterable_list = list(iterable) while i < len(iterable_list): if key_func(iterable_list[i]) is False: break i += 1 for k in range(i, len(iterable_list)): yield iterable_list[k] if __name__ == '__main__': lstrip0([1, 1, 1], 1) lstrip([1, 1, 1], 1)
def extendList(val, lst=[]): lst.append(val) return lst list1 = extendList(10) list2 = extendList(123,[]) list3 = extendList('a') print("list1 = %s" % list1) print("list2 = %s" % list2) print("list3 = %s" % list3)
def extend_list(val, lst=[]): lst.append(val) return lst list1 = extend_list(10) list2 = extend_list(123, []) list3 = extend_list('a') print('list1 = %s' % list1) print('list2 = %s' % list2) print('list3 = %s' % list3)
# Given an array nums of integers, # return how many of them contain an even number of digits. def find_numbers_easy(nums): even_number_count = 0 for num in nums: if len(str(num)) % 2 == 0: even_number_count += 1 return even_number_count def find_numbers_hard(nums): even_number_count = 0 for num in nums: digit_count = 0 while num > 0: digit_count += 1 print(digit_count) num = num // 10 # normal integer division print(num) if digit_count % 2 == 0: even_number_count += 1 return even_number_count nums = [12, 345, 2, 6, 7896] find_numbers_easy(nums) # ? find_numbers_hard(nums) # ?
def find_numbers_easy(nums): even_number_count = 0 for num in nums: if len(str(num)) % 2 == 0: even_number_count += 1 return even_number_count def find_numbers_hard(nums): even_number_count = 0 for num in nums: digit_count = 0 while num > 0: digit_count += 1 print(digit_count) num = num // 10 print(num) if digit_count % 2 == 0: even_number_count += 1 return even_number_count nums = [12, 345, 2, 6, 7896] find_numbers_easy(nums) find_numbers_hard(nums)
# GENERATED VERSION FILE # TIME: Tue Sep 28 14:27:47 2021 __version__ = '1.0rc1+c42460f' short_version = '1.0rc1'
__version__ = '1.0rc1+c42460f' short_version = '1.0rc1'
#!/usr/bin/env python3 bag_of_words = __import__('0-bag_of_words').bag_of_words sentences = ["Holberton school is Awesome!", "Machine learning is awesome", "NLP is the future!", "The children are our future", "Our children's children are our grandchildren", "The cake was not very good", "No one said that the cake was not very good", "Life is beautiful"] E, F = bag_of_words(sentences) print(E) print(F)
bag_of_words = __import__('0-bag_of_words').bag_of_words sentences = ['Holberton school is Awesome!', 'Machine learning is awesome', 'NLP is the future!', 'The children are our future', "Our children's children are our grandchildren", 'The cake was not very good', 'No one said that the cake was not very good', 'Life is beautiful'] (e, f) = bag_of_words(sentences) print(E) print(F)
x=4 itersLeft=x Sum=0 while(itersLeft!=0): Sum=Sum+x itersLeft=itersLeft-1 print(Sum) print(itersLeft) print(str(x)+"**"+" 2 = "+str(Sum))
x = 4 iters_left = x sum = 0 while itersLeft != 0: sum = Sum + x iters_left = itersLeft - 1 print(Sum) print(itersLeft) print(str(x) + '**' + ' 2 = ' + str(Sum))
class Solution: def minSubArrayLen(self, s, nums): """ :type s: int :type nums: List[int] :rtype: int """ i, j, size, sum, min_len = 0, 0, len(nums), 0, len(nums) if size == 0: return 0 while j < size: sum += nums[j] while sum >= s: sum -= nums[i] i += 1 min_len = min(min_len, j - i + 2) j += 1 return min_len if i != 0 else 0
class Solution: def min_sub_array_len(self, s, nums): """ :type s: int :type nums: List[int] :rtype: int """ (i, j, size, sum, min_len) = (0, 0, len(nums), 0, len(nums)) if size == 0: return 0 while j < size: sum += nums[j] while sum >= s: sum -= nums[i] i += 1 min_len = min(min_len, j - i + 2) j += 1 return min_len if i != 0 else 0
QUIP_ACCESS_TOKEN = "1ee2demdo33=|03e39j94r4|komes234mfmf+wapdmeodmemdfg2y6hMfAHko=" # This is a fake token :D QUIP_BASE_URL = "https://platform.quip.com" ENV = "DEBUG" LOGS_PREFIX = ":quip.quip:" USER_JSON = { "name": "John Doe", "id": "1234", "is_robot": False, "affinity": 0.0, "desktop_folder_id": "abc1234", "archive_folder_id": "abc5678", "starred_folder_id": "abc9101", "private_folder_id": "abc1121", "trash_folder_id": "abc3141", "shared_folder_ids": ["abc5161", "abc7181"], "group_folder_ids": ["abc9202", "abc1222"], "profile_picture_url": f"{QUIP_BASE_URL}/pic.jpg", "subdomain": None, "url": QUIP_BASE_URL, } FOLDER_JSON = { "children": [{"thread_id": "abc7181"}, {"folder_id": "abc5161"}], "folder": { "created_usec": 1606998498297926, "creator_id": "1234", "id": "abc9101", "title": "Starred", "updated_usec": 1609328575547507, }, "member_ids": ["1234"], } THREAD_JSON = { "access_levels": { "1234": {"access_level": "OWN"}, }, "expanded_user_ids": ["1234"], "thread": { "author_id": "1234", "thread_class": "document", "id": "567mnb", "created_usec": 1608114559763651, "updated_usec": 1609261609357637, "link": f"{QUIP_BASE_URL}/abcdefg12345", "type": "spreadsheet", "title": "My Spreadsheet", "document_id": "9876poiu", "is_deleted": False, }, "user_ids": [], "shared_folder_ids": ["abc1234"], "invited_user_emails": [], "html": "<h1 id='9876poiu'>My Spreadsheet</h1>", } SPREADSHEET_CONTENT = """<h1 id='9876poiu'>My Spreadsheet</h1> <div data-section-style='13'> <table id='Aec9CAvyP44' title='Sheet1' style='width: 237.721em'> <thead> <tr> <th class='empty' style='width: 2em'/> <th id='Aec9CAACdyH' class='empty' style='width: 1.8em'>A<br/></th> <th id='Aec9CAH7YBR' class='empty' style='width: 7.46667em'>B<br/></th> <th id='Aec9CAwvN9F' class='empty' style='width: 19.9333em'>C<br/></th> <th id='Aec9CAe1yQ0' class='empty' style='width: 6.71634em'>D<br/></th> <th id='Aec9CAAIaj1' class='empty' style='width: 6em'>T<br/></th> <th id='Aec9CAWcoFU' class='empty' style='width: 6em'>U<br/></th> <th id='Aec9CAkrCad' class='empty' style='width: 6em'>V<br/></th> </tr> </thead> <tbody> <tr id='Aec9CAmLjDE'> <td style='background-color:#f0f0f0'>1</td> <td id='s:Aec9CAmLjDE_Aec9CA0oPBj' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAmLjDE_Aec9CA0oPBj'>TECH TRACK</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CAWFNOe' style=''> <span id='s:Aec9CAmLjDE_Aec9CAWFNOe'>\u200b</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CAHOMxq' style=''> <span id='s:Aec9CAmLjDE_Aec9CAHOMxq'>\u200b</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CAf7d0s' style=''> <span id='s:Aec9CAmLjDE_Aec9CAf7d0s'>\u200b</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CAEwmwC' style=''> <span id='s:Aec9CAmLjDE_Aec9CAEwmwC'>\u200b</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CA0lijP' style=''> <span id='s:Aec9CAmLjDE_Aec9CA0lijP'>\u200b</span> <br/> </td> <td id='s:Aec9CAmLjDE_Aec9CA003da' style=''> <span id='s:Aec9CAmLjDE_Aec9CA0lijP'>\u200b</span> <br/> </td> </tr> <tr id='Aec9CAITZFz'> <td style='background-color:#f0f0f0'>2</td> <td id='s:Aec9CAITZFz_Aec9CA0oPBj' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CA0oPBj'>\u200b</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CAWFNOe' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CAWFNOe'>Date</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CAHOMxq' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CAHOMxq'>Title</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CAf7d0s' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CAf7d0s'>Location</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CAwdFrL' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CAwdFrL'>Language</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CAEwmwC' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CAEwmwC'>Capacity</span> <br/> </td> <td id='s:Aec9CAITZFz_Aec9CA0lijP' style='background-color:#FFDF99;' class='bold'> <span id='s:Aec9CAITZFz_Aec9CA0lijP'>Owner</span> <br/> </td> </tr> <tr id='Aec9CADeBjI'> <td style='background-color:#f0f0f0'>3</td> <td id='s:Aec9CADeBjI_Aec9CA0oPBj' style='background-color:#AFEFA9;'> <span id='s:Aec9CADeBjI_Aec9CA0oPBj'>\u200b</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CAWFNOe' style=''> <span id='s:Aec9CADeBjI_Aec9CAWFNOe'>Date</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CAHOMxq' style=''> <span id='s:Aec9CADeBjI_Aec9CAHOMxq'>Intro to ML on AWS</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CAf7d0s' style=''> <span id='s:Aec9CADeBjI_Aec9CAf7d0s'>Virtual (Chime)</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CAwdFrL' style=''> <span id='s:Aec9CADeBjI_Aec9CAwdFrL'>ES</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CAEwmwC' style=''> <span id='s:Aec9CADeBjI_Aec9CAEwmwC'>50</span> <br/> </td> <td id='s:Aec9CADeBjI_Aec9CA0lijP' style=''> <span id='s:Aec9CADeBjI_Aec9CA0lijP'>John Doe</span> <br/> </td> </tr> </tbody> </table> </div>"""
quip_access_token = '1ee2demdo33=|03e39j94r4|komes234mfmf+wapdmeodmemdfg2y6hMfAHko=' quip_base_url = 'https://platform.quip.com' env = 'DEBUG' logs_prefix = ':quip.quip:' user_json = {'name': 'John Doe', 'id': '1234', 'is_robot': False, 'affinity': 0.0, 'desktop_folder_id': 'abc1234', 'archive_folder_id': 'abc5678', 'starred_folder_id': 'abc9101', 'private_folder_id': 'abc1121', 'trash_folder_id': 'abc3141', 'shared_folder_ids': ['abc5161', 'abc7181'], 'group_folder_ids': ['abc9202', 'abc1222'], 'profile_picture_url': f'{QUIP_BASE_URL}/pic.jpg', 'subdomain': None, 'url': QUIP_BASE_URL} folder_json = {'children': [{'thread_id': 'abc7181'}, {'folder_id': 'abc5161'}], 'folder': {'created_usec': 1606998498297926, 'creator_id': '1234', 'id': 'abc9101', 'title': 'Starred', 'updated_usec': 1609328575547507}, 'member_ids': ['1234']} thread_json = {'access_levels': {'1234': {'access_level': 'OWN'}}, 'expanded_user_ids': ['1234'], 'thread': {'author_id': '1234', 'thread_class': 'document', 'id': '567mnb', 'created_usec': 1608114559763651, 'updated_usec': 1609261609357637, 'link': f'{QUIP_BASE_URL}/abcdefg12345', 'type': 'spreadsheet', 'title': 'My Spreadsheet', 'document_id': '9876poiu', 'is_deleted': False}, 'user_ids': [], 'shared_folder_ids': ['abc1234'], 'invited_user_emails': [], 'html': "<h1 id='9876poiu'>My Spreadsheet</h1>"} spreadsheet_content = "<h1 id='9876poiu'>My Spreadsheet</h1>\n<div data-section-style='13'>\n <table id='Aec9CAvyP44' title='Sheet1' style='width: 237.721em'>\n <thead>\n <tr>\n <th class='empty' style='width: 2em'/>\n <th id='Aec9CAACdyH' class='empty' style='width: 1.8em'>A<br/></th>\n <th id='Aec9CAH7YBR' class='empty' style='width: 7.46667em'>B<br/></th>\n <th id='Aec9CAwvN9F' class='empty' style='width: 19.9333em'>C<br/></th>\n <th id='Aec9CAe1yQ0' class='empty' style='width: 6.71634em'>D<br/></th>\n <th id='Aec9CAAIaj1' class='empty' style='width: 6em'>T<br/></th>\n <th id='Aec9CAWcoFU' class='empty' style='width: 6em'>U<br/></th>\n <th id='Aec9CAkrCad' class='empty' style='width: 6em'>V<br/></th>\n </tr>\n </thead>\n <tbody>\n <tr id='Aec9CAmLjDE'>\n <td style='background-color:#f0f0f0'>1</td>\n <td id='s:Aec9CAmLjDE_Aec9CA0oPBj' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAmLjDE_Aec9CA0oPBj'>TECH TRACK</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CAWFNOe' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CAWFNOe'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CAHOMxq' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CAHOMxq'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CAf7d0s' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CAf7d0s'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CAEwmwC' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CAEwmwC'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CA0lijP' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CA0lijP'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAmLjDE_Aec9CA003da' style=''>\n <span id='s:Aec9CAmLjDE_Aec9CA0lijP'>\u200b</span>\n <br/>\n </td>\n </tr>\n <tr id='Aec9CAITZFz'>\n <td style='background-color:#f0f0f0'>2</td>\n <td id='s:Aec9CAITZFz_Aec9CA0oPBj' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CA0oPBj'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CAWFNOe' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CAWFNOe'>Date</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CAHOMxq' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CAHOMxq'>Title</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CAf7d0s' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CAf7d0s'>Location</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CAwdFrL' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CAwdFrL'>Language</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CAEwmwC' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CAEwmwC'>Capacity</span>\n <br/>\n </td>\n <td id='s:Aec9CAITZFz_Aec9CA0lijP' style='background-color:#FFDF99;' class='bold'>\n <span id='s:Aec9CAITZFz_Aec9CA0lijP'>Owner</span>\n <br/>\n </td>\n </tr>\n <tr id='Aec9CADeBjI'>\n <td style='background-color:#f0f0f0'>3</td>\n <td id='s:Aec9CADeBjI_Aec9CA0oPBj' style='background-color:#AFEFA9;'>\n <span id='s:Aec9CADeBjI_Aec9CA0oPBj'>\u200b</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CAWFNOe' style=''>\n <span id='s:Aec9CADeBjI_Aec9CAWFNOe'>Date</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CAHOMxq' style=''>\n <span id='s:Aec9CADeBjI_Aec9CAHOMxq'>Intro to ML on AWS</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CAf7d0s' style=''>\n <span id='s:Aec9CADeBjI_Aec9CAf7d0s'>Virtual (Chime)</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CAwdFrL' style=''>\n <span id='s:Aec9CADeBjI_Aec9CAwdFrL'>ES</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CAEwmwC' style=''>\n <span id='s:Aec9CADeBjI_Aec9CAEwmwC'>50</span>\n <br/>\n </td>\n <td id='s:Aec9CADeBjI_Aec9CA0lijP' style=''>\n <span id='s:Aec9CADeBjI_Aec9CA0lijP'>John Doe</span>\n <br/>\n </td>\n </tr>\n </tbody>\n </table>\n</div>"