query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Delete all game objects in database.
def delete_all(sid): Game.objects.all().delete()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def delete_all_games(self):\n all_games = await ex.conn.fetch(\"SELECT gameid FROM blackjack.games\")\n for games in all_games:\n game_id = games[0]\n await self.delete_game(game_id)", "def delete_all(cls):\n cls.dbm().modelclass_deleteall(cls)", "def deleteAll(...
[ "0.7558716", "0.7451959", "0.7310933", "0.72619975", "0.72330093", "0.72307104", "0.7189395", "0.702915", "0.70258915", "0.7018561", "0.70178777", "0.69849235", "0.69767076", "0.6947214", "0.69419783", "0.6908184", "0.68683773", "0.68426365", "0.68415046", "0.6840984", "0.683...
0.80226487
0
Determine if a repository is a Firefox repository.
def is_firefox_repo(repo): try: if len(repo) and repo[0].hex() == FIREFOX_ROOT_NODE: return True except error.FilteredRepoLookupError: pass # Backdoor for testing. return repo.vfs.exists('IS_FIREFOX_REPO')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identify_repo(repo):\n repo_root = repo.ui.config('mozilla', 'repo_root', '/repo/hg/mozilla')\n if not repo_root.endswith('/'):\n repo_root += '/'\n\n d = {\n 'firefox': is_firefox_repo(repo),\n 'thunderbird': is_thunderbird_repo(repo),\n 'publishing': repo.ui.configbool('p...
[ "0.7308661", "0.64443415", "0.6425791", "0.6104476", "0.60261166", "0.6015556", "0.59261096", "0.59261096", "0.57900804", "0.57796836", "0.5663567", "0.55708253", "0.5556107", "0.5546782", "0.55137646", "0.54955333", "0.5491645", "0.539184", "0.53543836", "0.53132266", "0.529...
0.8278516
0
Determine if a repository is a Thunderbird repository.
def is_thunderbird_repo(repo): try: if len(repo) and repo[0].hex() == THUNDERBIRD_ROOT_NODE: return True except error.FilteredRepoLookupError: pass # Backdoor for testing. return repo.vfs.exists('IS_THUNDERBIRD_REPO')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_git_repo(template_repo):\n return template_repo.startswith(\"git@\") or \\\n template_repo.startswith(\"https://\")", "def is_git_repo(template_repo):\n return template_repo.startswith(\"git@\") or \\\n template_repo.startswith(\"https://\")", "def is_docker_hub(repository):\n ret...
[ "0.6485536", "0.6485536", "0.63009167", "0.6284621", "0.62410414", "0.62088764", "0.60371786", "0.57730424", "0.57722294", "0.5746184", "0.57141906", "0.5656342", "0.5609316", "0.54819727", "0.54176277", "0.53619325", "0.52856714", "0.5241295", "0.51687944", "0.5166422", "0.5...
0.8249476
0
Check GRID proxy >>> hasGridProxy ()
def hasGridProxy(): import os from subprocess import Popen, PIPE arguments = 'dirac-proxy-info --checkvalid' arguments = ['dirac-command'] + arguments.split() logger.verbose ( 'hasGridProxy:use Popen(%s)' % arguments) p = Popen(arguments, stdout=PIPE, stderr=PIPE) (cout, cerr) = p.comm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proxy_check(self, proxy):", "def proxies_get(self) -> bool:\n return True", "def is_bound(proxy):\n try:\n current_object(proxy)\n except UnboundProxyError:\n return False\n else:\n return True", "def test_need_proxy(self):\n os.environ['no_proxy'] = 'blah.com,...
[ "0.72894657", "0.6674798", "0.66601354", "0.6262091", "0.6189779", "0.6188301", "0.60288423", "0.59987336", "0.59448695", "0.59432656", "0.5932499", "0.5919514", "0.5895336", "0.5844185", "0.5822261", "0.57646286", "0.5723686", "0.56801885", "0.5607211", "0.5580686", "0.55748...
0.771145
0
Get the files from Bookkeeping DB valid GRID proxy is needed! >>> request = ... >>> files = filesFromBK ( request )
def filesFromBK(request): if not hasGridProxy(): logger.error('filesFromBK: No Grig proxy!') return [] if isinstance ( request , tuple ) : request = BKRequest ( *request ) elif isinstance ( request , dict ) : request = BKRequest ( **request ) path = request.path nmax ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def files(self, start=None, limit=None):\r\n params = base.get_params(None, locals())\r\n url = '{0}/files'.format(self.get_url())\r\n return http.Request('GET', url, params), parsers.parse_json", "def files(self, start=None, limit=None):\r\n params = base.get_params(None, locals())\r...
[ "0.6558046", "0.6558046", "0.6558046", "0.64741325", "0.64492", "0.64468104", "0.63758737", "0.6245564", "0.6214236", "0.6200066", "0.61985886", "0.6178122", "0.6109232", "0.61078346", "0.6092919", "0.6060358", "0.6049451", "0.6029149", "0.6018365", "0.5991038", "0.5925975", ...
0.78951913
0
Initialises the node with children and a handler
def __init__(self, handler=None): self.children = defaultdict(RouteTrieNode) self.handler = handler
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_db(self, parent_type, child_type):\n self.parent = Node(self.handler, parent_type)\n self.children = [ Node(self.handler, child_type) for x in range(0, self.SIZE) ]\n for node in self.children:\n Link(self.handler, self.parent.node, node.node, child_type.upper())", "def _...
[ "0.6854232", "0.66364855", "0.6558508", "0.65346444", "0.6506634", "0.6495653", "0.6488797", "0.6487924", "0.6487924", "0.6480149", "0.64634603", "0.644207", "0.6433212", "0.6403547", "0.6403547", "0.6403547", "0.63985157", "0.6396257", "0.6388987", "0.6380935", "0.637384", ...
0.6989251
1
Initialises trie with a root node and root handler
def __init__(self, root_handler=None): self.root = RouteTrieNode(root_handler)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, handler=None):\n self.root = RouteTrieNode(handler=handler)", "def __init__(self):\n self.root = self.TrieNode(0)", "def __init__(self):\n self.root = self.TrieNode(None)", "def __init__(self):\n self.root=TrieNode()", "def __init__(self):\n self.root=T...
[ "0.80115473", "0.78774226", "0.7809918", "0.77427226", "0.77427226", "0.77102625", "0.7547998", "0.75354844", "0.7342355", "0.7339628", "0.73328793", "0.7313797", "0.7303609", "0.7303609", "0.7302819", "0.7302819", "0.7302819", "0.7302819", "0.7302819", "0.7302819", "0.730281...
0.81519413
0
Adds a handler for a path
def add_handler(self, path, handler) -> None: if self.__test_path(path) and self.__test_path(handler): path_parts = self.__split_path(path) # Splits parts into constituent components self.route_trie.insert(path_parts, handler) # Passes parts on for addition to ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_handler(self, path, handler):\n if path: # guard against Null path, we assume handler could be Null\n path_list = self.split_path(path)\n self.trie.insert(step_list=path_list, handler=handler)", "def register_handler(self, method, path, fn):\n if not(method in self.ha...
[ "0.8366175", "0.7557731", "0.7365812", "0.7264261", "0.71948415", "0.6904948", "0.6904236", "0.6826481", "0.6768612", "0.67261535", "0.65624624", "0.65400296", "0.6414063", "0.6391095", "0.6358848", "0.6326726", "0.6206793", "0.6205492", "0.61878026", "0.61793965", "0.6146285...
0.85792696
0
Lookup path and return its handler
def lookup(self, path) -> str: if self.__test_path(path): path_parts = self.__split_path(path) # Splits parts into constituent components handler = self.route_trie.find(path_parts) # Stores result of path search return handler if handler else self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup(self, path):\n\n path_list = self.split_path(path)\n return_handler = self.trie.find(prefix=path_list)\n\n if return_handler:\n return return_handler\n else:\n return self.not_found_handler", "def _find_url_handler(self, req):\n # First try - lo...
[ "0.8171178", "0.73559314", "0.68021876", "0.6668805", "0.6506093", "0.64750767", "0.64577895", "0.6412674", "0.64054465", "0.6383391", "0.63511366", "0.63122034", "0.6276047", "0.61854106", "0.61347514", "0.6107696", "0.5994779", "0.5990019", "0.59125984", "0.5912008", "0.591...
0.82154274
0
Splits path into its constituent parts
def __split_path(path: str) -> List[str]: return [part for part in path.split('/') if part] # Splits path at '/', handles extra slashes in the process
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitpath(path):\n\n # FIXME perhaps call op.split repetitively would be better.\n #s = string.split( path, '/' ) # we work with fwd slash only inside.\n\n#We have decided to use all kind of separator\n s = []\n while True:\n first, second = op.split(path)\n s.append(second)\n ...
[ "0.8204391", "0.8174964", "0.8085845", "0.8003212", "0.7822543", "0.78090787", "0.7783582", "0.7781801", "0.7724184", "0.7705158", "0.7695372", "0.7639305", "0.76013774", "0.75980574", "0.75946397", "0.75852054", "0.7545167", "0.74679285", "0.73923457", "0.73623455", "0.73456...
0.82463825
0
Checks by pattern if roll is a valid dice roll. This includes `nDy`, `ndy` and mixes with numbers `+` and ``.
def is_dice_roll(roll: str) -> Optional[re.Match]: matcher = DICE_REGEX.match(roll) return matcher
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dice_roller():\n\n print('Use the xDy+z format to roll the dice. Example: \"2D6+4\"')\n roll = input(\"Enter the dice: \").lower()\n\n if roll.count('d') > 1:\n return \"Wrong input!\"\n\n validate = roll.replace(\"d\", \"\").replace(\"+\", \"\").replace('-', \"\")\n\n # \"validate\" vari...
[ "0.6716512", "0.64137495", "0.6404577", "0.639976", "0.63927776", "0.61627877", "0.6144643", "0.61264604", "0.6005426", "0.58808833", "0.58372337", "0.58366555", "0.5821892", "0.57933265", "0.5792328", "0.57741827", "0.5772054", "0.57653105", "0.5753985", "0.57494026", "0.574...
0.65113264
1
initialize zmq publisher socket
def __get_zmq_pub(self): print("Publishing to tcp://127.0.0.1:%d channel: tweets" % self.port) context = zmq.Context() socket = context.socket(zmq.PUB) socket.bind("tcp://127.0.0.1:%d" % self.port) return socket
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, ip='127.0.0.1', port='50020'):\n self.ip = ip \n self.port = port\n self.ctx = zmq.Context()\n self.socket = zmq.Socket(self.ctx, zmq.REQ) # this is pub socket", "def initzmq(self):\n\n if \"topics\" not in self.configData:\n raise Exception(\"Topi...
[ "0.78729033", "0.695564", "0.6900721", "0.6871261", "0.68266183", "0.6776164", "0.67308486", "0.6717901", "0.6422498", "0.6096077", "0.60760754", "0.6049589", "0.5961509", "0.5946767", "0.5928848", "0.59046185", "0.58697796", "0.583556", "0.5797219", "0.5789976", "0.5779875",...
0.6983764
1
Checks if a guess letter matches a target letter
def match(self, target, guess): return guess == target
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_guess(self): # relies on the results from replace_letter() | helper function to display_correct_guess()\n if len(self.guess) == 1:\n if self.guess in self.chosen_word:\n self.replace_letter() # replaces display_word with correctly guessed letters\n retu...
[ "0.724141", "0.6917954", "0.68295354", "0.6773037", "0.6772409", "0.6756728", "0.67525744", "0.67267394", "0.66725117", "0.6660826", "0.66500235", "0.6632575", "0.661038", "0.6583722", "0.6575876", "0.65603286", "0.6557356", "0.6556453", "0.6552717", "0.65468127", "0.6529176"...
0.75668406
0
Checks if a letter in a guess is above the target letter in the alphabet Return true if up, false is assumed to be down since this should never be called if there is a match
def up(self, target, guess): return ord(target) < ord(guess)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self, target, guess):\r\n return ord(target)-5 <= ord(guess) and ord(guess) <= ord(target)+5", "def check_guess(self, user_guess):\n return user_guess in self.active_phrase", "def check_the_guess(guess, a_followers, b_followers):\n if a_followers > b_followers:\n return guess ...
[ "0.64126676", "0.6217245", "0.6208104", "0.6193162", "0.60669065", "0.5858622", "0.5852677", "0.5843748", "0.58351785", "0.58032477", "0.5785905", "0.5779188", "0.5771472", "0.57190967", "0.57088804", "0.56698114", "0.5663471", "0.56380683", "0.55878186", "0.55864286", "0.557...
0.7994412
0
Check if the guess letter is within 5 letters of the target
def close(self, target, guess): return ord(target)-5 <= ord(guess) and ord(guess) <= ord(target)+5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_condition(self):\n if self.letters_wrong < 5:\n if '__ ' in self.new_string:\n return False\n else:\n return True\n else:\n return True", "def check_win(secret_word, old_letters_guessed):\n j=len(secret_word)\n for...
[ "0.6635689", "0.62288874", "0.60756695", "0.60500956", "0.59797996", "0.59784883", "0.59515333", "0.5945887", "0.5917881", "0.59072113", "0.587977", "0.5826533", "0.581762", "0.58094823", "0.580905", "0.5776484", "0.57689565", "0.5765766", "0.5741309", "0.57358634", "0.573325...
0.6528206
1
Get the names of all test programs by evaluating the SConscript file
def resolve_test_progs(sconscript_filename): reprg = re.compile(r"""^env.Program\(["'](.*?)['"]""") progs = [] for line in open(sconscript_filename): m = reprg.match(line.strip()) if m: progs.append(m.group(1)) return progs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_test_cases(program):\n\n return list(INFO[program].test_cases)", "def test(): \n\treturn [\"vice.yields.ccsne.import\", \n\t\t[ \n\t\t\ttest_LC18_import(), \n\t\t\ttest_CL13_import(), \n\t\t\ttest_CL04_import(), \n\t\t\ttest_WW95_import(), \n\t\t\ttest_NKT13_import(), \n\t\t\ttest_S16_import() \n\t\t...
[ "0.63810515", "0.6367894", "0.591205", "0.58999985", "0.5880722", "0.5872503", "0.5852329", "0.5840184", "0.58356047", "0.5792614", "0.5738614", "0.5733553", "0.5706752", "0.5701584", "0.56863666", "0.5659798", "0.5630291", "0.55575275", "0.554375", "0.5530323", "0.55250484",...
0.6682637
0
Counts the number of ways to run up a stair with n steps
def count_ways(n): if n < 0: return 0 elif n == 0: return 1 else: total = 0 for i in range(1, min(n, 3) + 1): total += count_ways(n - i) return total
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_stair_ways(n):\n if n == 1:\n return 1\n if n == 2:\n return 2\n return count_stair_ways(n - 1) + count_stair_ways(n - 2)", "def num_of_ways(n):\n if n == 0 or n == 1:\n return 1\n \n n_minus_2_step = 1\n n_minus_1_step = 1\n n_step = None\n\n #num_of_way...
[ "0.7937585", "0.74169403", "0.7050495", "0.6761067", "0.6650301", "0.6604587", "0.65189266", "0.64957833", "0.6475029", "0.6464334", "0.64047503", "0.63859785", "0.63114244", "0.6301743", "0.6287839", "0.6278423", "0.6262987", "0.62302816", "0.622684", "0.6208675", "0.6200962...
0.75719696
1
Similar to the passing cars problem, the passing fish eat each other. Each downstream fish is pushed onto the downstream stack. Upstream fish are considered survivors if not eaten. When an upstream fish is encountered the downstream fish in its path are popped Each fish size is compared and teh smaller discarded.
def solution(A, B): downstream = [] survivor = [] for i in range(0, len(A)): print(f'pass {i}') if B[i]: # If a fish is swimming downstream place him in that stack downstream.append(A[i]) # print(f'survivor: <--{survivor}, downstream: {downstream}--> {A[i]} is A[{i}]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PantrySorterEmptyShelf(Shelf: Shelf, stackableFood, unstackableFood):\n print(stackableFood, unstackableFood)\n unstackableFood = sorted(unstackableFood, reverse=True)\n stackableFood = sorted(stackableFood, reverse=True)\n print(\"sorted\\n{}\\n{}\".format(unstackableFood, stackableFood))\n for...
[ "0.63782394", "0.56742114", "0.5668357", "0.5521426", "0.5511266", "0.54922324", "0.54876566", "0.542339", "0.5420904", "0.5413091", "0.53986907", "0.53806275", "0.5353128", "0.5341598", "0.5308404", "0.5303239", "0.5296814", "0.52952766", "0.52823764", "0.5276772", "0.526822...
0.7700281
0
Load a package from a filesystem path. Infer the name and version of the package from the path.
def package_from_path(path): partial_path, version = os.path.split(path) base_path, name = os.path.split(partial_path) p = Package(name, version, path) return p
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _from_path(cls, path):\n with open(path, encoding='utf-8') as open_file:\n pkg = cls._load(open_file)\n return pkg", "def load_from_path(path):\n module, attr = path.rsplit('.', 1)\n mod = importlib.import_module(module)\n return getattr(mod, attr)", "def load(path):\n ...
[ "0.72946215", "0.6350694", "0.63120604", "0.62729806", "0.6185737", "0.60219616", "0.6021483", "0.5967492", "0.5905551", "0.5905551", "0.5899823", "0.5853805", "0.58521056", "0.5845826", "0.583879", "0.58262366", "0.581041", "0.5792163", "0.5784363", "0.5765604", "0.57580024"...
0.73681134
0
Load a package from a yaml receipt file.
def package_from_yaml(yaml_file): with open(yaml_file) as f: yaml_rep = yaml.load(f) name = yaml_rep['name'] version = yaml_rep['version'] base_path, receipt_file = os.path.split(yaml_file) p = Package(name, version, base_path) try: p.direct_dependencies = yaml_rep['dependen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_autopkg_recipe(path):\n recipe = None\n\n if path.endswith(\".yaml\"):\n try:\n # try to read it as yaml\n with open(path, \"rb\") as f:\n recipe = yaml.safe_load(f)\n except Exception as err:\n print(\"{}: yaml parsing error: {}\".format...
[ "0.6303922", "0.6289447", "0.6278501", "0.6247403", "0.6126887", "0.60465944", "0.60452366", "0.6026429", "0.5979628", "0.596223", "0.59619045", "0.5955822", "0.5950138", "0.59431976", "0.5911328", "0.59020746", "0.5893535", "0.58713704", "0.5863882", "0.58628803", "0.5861409...
0.7605227
0
List all installed packages.
def list_packages(): shelf_dir = settings.shelf_dir package_list = os.listdir(shelf_dir) package_list.sort() return package_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_packages(self):\n for tag, pkg in PACKAGES.iteritems():\n print \"{tag} - {label}\".format(tag=tag, label=pkg['label'])", "def get_installed_packages():\n global INSTALLED_PACKAGES\n chk = Popen(\"{} -m pip freeze\".format(sys.executable),\n shell=True, stdout=PIPE...
[ "0.7494529", "0.72714067", "0.71055263", "0.69917494", "0.69516325", "0.68876415", "0.6830791", "0.6806516", "0.6731782", "0.6642389", "0.66308403", "0.6553867", "0.65283746", "0.65177107", "0.6454239", "0.6392868", "0.6387223", "0.6369047", "0.63391745", "0.6325736", "0.6282...
0.7367697
1
Load all installed packages.
def load_all_packages(): package_dict = dict((n, load_component_by_name(n)) for n in list_packages()) return package_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _LoadPackages():\n return {module.__name__.split('.')[-1]: module for module in\n import_util.LoadModulesForPath(__path__, __name__)}", "def packages(self):\n\n if self._packages:\n return self._packages\n\n self._load()\n return self._packages", "def load_plugins(...
[ "0.7246274", "0.7029434", "0.684438", "0.675976", "0.6676979", "0.6629688", "0.65730417", "0.6394994", "0.6333747", "0.6324303", "0.63189465", "0.6227781", "0.6209056", "0.6157023", "0.6069455", "0.59823287", "0.59752005", "0.5964119", "0.5946842", "0.59437484", "0.5934385", ...
0.74235123
0
Creates batch of warping coordinates.
def _make_warp(batch_size, warp_height, warp_width, dtype): x, y = np.meshgrid(np.linspace(0, warp_width - 1, warp_width), np.linspace(0, warp_height - 1, warp_height)) warp = np.concatenate((x.reshape([warp_height, warp_width, 1]), y.reshape([warp_height, warp_width, 1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_all_locations(grid, shape):", "def prep_ships(self):\n self.ships = Group()\n for ship_number in range(self.stats.ships_left):\n ship = Ship(self.ai_settings, self.screen)\n ship.rect.x = 10 + ship_number * ship.rect.width\n ship.rect.y = 10\n self.ships.add(ship)",...
[ "0.56328344", "0.5563046", "0.54961437", "0.54955286", "0.5456121", "0.542565", "0.53909725", "0.536948", "0.536837", "0.53514147", "0.53505296", "0.5334579", "0.5306303", "0.5297764", "0.52908945", "0.52849275", "0.5259853", "0.5256899", "0.52537173", "0.5246708", "0.5238761...
0.5722996
0
does this graph have stereo of any kind?
def has_stereo(gra): return bool(atom_stereo_keys(gra) or bond_stereo_keys(gra))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected(geo, stereo=True):\n return len(components_graph(geo, stereo=stereo)) == 1", "def is_multigraph(self):\n # TO DO: Call coloring algorithm\n return True", "def is_multigraph(self):\n # TO DO: Call coloring algorithm\n return False", "def process_stereo(self, image1...
[ "0.5916504", "0.59065694", "0.58779186", "0.57271165", "0.5674469", "0.5657861", "0.5590091", "0.5554247", "0.555055", "0.5433868", "0.54046094", "0.535443", "0.5328535", "0.5321897", "0.5259553", "0.52561355", "0.52349555", "0.52111995", "0.51804113", "0.51804113", "0.516871...
0.6523304
0
all stereomers compatible with this graph's assignments
def substereomers(gra): _assigned = functools.partial( dict_.filter_by_value, func=lambda x: x is not None) known_atm_ste_par_dct = _assigned(atom_stereo_parities(gra)) known_bnd_ste_par_dct = _assigned(bond_stereo_parities(gra)) def _is_compatible(sgr): atm_ste_par_dct = _assigned(ato...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_full_graph(self):", "def pass_assign_for_mentor(cls):\n assignments_list = cls.list_from_sql()\n return assignments_list", "def assign_passengers(self):\n\n # Update the state of the parallel server after every assignment.\n self.parallel_server.update_state()\n\n # While the as...
[ "0.54077244", "0.53233546", "0.529461", "0.5199094", "0.51901215", "0.5178197", "0.5165792", "0.5160593", "0.5153728", "0.5084569", "0.505208", "0.50347584", "0.501747", "0.50132996", "0.49907267", "0.49830773", "0.49814856", "0.49584734", "0.4938241", "0.49313956", "0.492645...
0.5362716
1
get the neighbor keys of an atom sorted by stereo priority
def stereo_sorted_atom_neighbor_keys(gra, atm_key, atm_ngb_keys): atm_ngb_keys = list(atm_ngb_keys) # explicitly create an object array because otherwise the argsort # interprets [()] as [] atm_pri_vecs = numpy.empty(len(atm_ngb_keys), dtype=numpy.object_) atm_pri_vecs[:] = [stereo_priority_vector(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def atom_stereo_keys(sgr):\n atm_ste_keys = dict_.keys_by_value(atom_stereo_parities(sgr),\n lambda x: x in [True, False])\n return atm_ste_keys", "def _keys_in_sorted(move):\n return (move.picking_id.id, move.product_id.responsible_id.id)", "def keys(self...
[ "0.64455867", "0.5702487", "0.5683594", "0.5632385", "0.5532785", "0.5505051", "0.5495498", "0.54925495", "0.5450763", "0.5449452", "0.5423081", "0.53951913", "0.5394365", "0.53459764", "0.53347504", "0.5302554", "0.5298473", "0.5288237", "0.5263176", "0.52053976", "0.5203688...
0.7218674
0
Make a cover song analogy; given audio for (A, A'), and B, \ make B'
def makeAnalogy(X, Fs, beatsA, filename_b, hopSize, winSize, ws, TempoBias, MFCCWeight = 1.0, HPCPWeight = 1.0): #Step 1: Load in new example from artist 1 (B song) print("Loading new example...") XA = X[:, 0] XAp = X[:, 1] XB, Fs2 = librosa.load(filename_b) XB = librosa.core.to_mono(XB) #S...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mix_in_audio_sample(track_data, track_offset, sample_data, sample_offset,\n clip_duration, sample_volume, ramp_in, ramp_out):\n ramp_out_index = clip_duration - ramp_out\n track_end = min(track_offset + clip_duration, track_data.shape[0])\n track_end = min(track_end,\n ...
[ "0.6006216", "0.58060926", "0.5637287", "0.5634883", "0.5594459", "0.5594459", "0.55667746", "0.55425465", "0.55012476", "0.5492657", "0.54915565", "0.548919", "0.54564226", "0.54428786", "0.5437798", "0.5433615", "0.5421229", "0.5392255", "0.5341979", "0.5328841", "0.53193",...
0.59700465
1
Set names for the each block
def set_blockname(self, names: Iterable): if len(names) != self.n_blocks_: raise TypeError(f'length mismatch [self.n_blocks_: {self.n_blocks_}, names(given): {len(names)}]') self.block_names_ = names
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _genBlocksByName(self):\n self.blocksByName = {\n block.getName(): block for block in self.getBlocks(includeAll=True)\n }", "def list_blocks(self, _):\n print(self.data.name)", "def genBlocksByLocName(self):\n self.blocksByLocName = {\n block.getLocation():...
[ "0.7619002", "0.6661282", "0.64977086", "0.592721", "0.59218395", "0.5869824", "0.5778553", "0.5733629", "0.5602355", "0.5550933", "0.5550933", "0.55498064", "0.5536557", "0.55123836", "0.54910976", "0.5476435", "0.54742354", "0.54710126", "0.5457501", "0.5434298", "0.5430053...
0.7410156
1
Assign reduction rule to a gate PPCA
def set_gate_reducer(self, reducer: ReductionRule): self.gate_reducer_ = reducer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_assign(g, op, block):\n\n out = g.get_node(op.input(\"X\")[0])\n g.add_node(op.output(\"Out\")[0], out)", "def convert_reduce(g, op, block):\n\n op_map = {\n \"reduce_all\": \"all\",\n \"reduce_any\": \"any\",\n \"reduce_max\": \"max\",\n \"reduce_min\": \"min\",\...
[ "0.5356251", "0.5183916", "0.5143067", "0.5094079", "0.50892544", "0.5080843", "0.50643283", "0.50482136", "0.5025356", "0.5016265", "0.50033015", "0.50028324", "0.49897406", "0.49796098", "0.49785227", "0.49708816", "0.49432823", "0.49322098", "0.4927745", "0.49176073", "0.4...
0.5607902
0
Reconstruct the input from the intermediate reduced representation. that means a flow, X > intermediate reduction > intermediate recon.
def reconstruct_intermediate(self, X: numpy.ndarray) -> numpy.ndarray: reduced_repr_intr = self.intermediate_transform(X) return self.intermediate_inverse_transform(reduced_repr_intr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reconstruct(self, X: numpy.ndarray) -> numpy.ndarray:\n\n reduced_repr = self.transform(X)\n return self.inverse_transform(reduced_repr)", "def reconstruct(self, X):", "def reconstruct(self, X):", "def reconstruct(self, x):\n return self.inverse_transform(self.transform(x))", "def ...
[ "0.6733002", "0.669029", "0.669029", "0.6568794", "0.6450592", "0.64080805", "0.63954407", "0.61722416", "0.61493784", "0.60019034", "0.59541947", "0.58344096", "0.5821323", "0.57803905", "0.5773008", "0.57342213", "0.57054216", "0.5696215", "0.5630937", "0.5615154", "0.56018...
0.7525129
0
Installs the standard syntax directives.
def install_syntax_functions(self): self.syntax_functions[':head'] = head_prediction_generator self.syntax_functions[':optional'] = optional_prediction_generator self.syntax_functions[':sequence'] = sequence_prediction_generator self.syntax_functions[':any'] = any_prediction_generator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install() -> None:\n # Get locals from parent frame\n frames = inspect.getouterframes(inspect.currentframe())\n if len(frames) > 1:\n parent_frame = frames[1]\n parent_locals = parent_frame.frame.f_locals\n locals().update(parent_locals)\n\n # For tab completion and arrow key s...
[ "0.56438464", "0.5318523", "0.5294665", "0.5194252", "0.5179585", "0.51310945", "0.5099968", "0.50895035", "0.5047722", "0.50111884", "0.498702", "0.4986996", "0.49659818", "0.49514064", "0.4923191", "0.48950475", "0.48576126", "0.4807199", "0.48069134", "0.47965986", "0.4784...
0.6467446
0
Checks to see if any preparsers would like to handle the token. If not, None is returned, otherwise the result of preparsing the token is returned.
def check_preparsers(self, token): for [matcher, function] in self.preparsers: match = matcher.match(token) if match is None or match.end() != len(token): pass else: return function(token) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preparse(self, token):\n result = self.check_preparsers(token)\n if result is None:\n return token\n else:\n return result", "def _handle_token(self, token: str) -> Optional[str]:\n return token or self._token_handler.token", "def _handle_token(self, token: str) -> Optional[str]:\...
[ "0.86988527", "0.6444068", "0.6082054", "0.58015805", "0.57239443", "0.5629078", "0.5507728", "0.5504912", "0.55046606", "0.54920423", "0.5478602", "0.54365534", "0.54039836", "0.5380746", "0.5339962", "0.5317274", "0.52795863", "0.5271098", "0.5268484", "0.5233755", "0.51466...
0.7874867
1
Runs the token through any relevant preparser.
def preparse(self, token): result = self.check_preparsers(token) if result is None: return token else: return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def process(self, tokens):\n return await self.parser.process(tokens)", "def parse(token):\n\n pass", "def handle_input(self, token):\n self.pipeline.handle_input(token)", "def parse_tokens(self, tokens):\n for token in tokens:\n self.parse_token(token)", "def next_...
[ "0.637824", "0.62770957", "0.60263747", "0.5982428", "0.5950361", "0.59161896", "0.5890809", "0.5738108", "0.5696121", "0.567717", "0.5516384", "0.55131054", "0.5486995", "0.54364085", "0.5401569", "0.5397503", "0.5392797", "0.5386328", "0.5379222", "0.5370733", "0.5370733", ...
0.68738174
0
Adds a phrasal pattern to a class. The phrasal_pattern argument is a string using the phrasal pattern syntax,
def add_phrasal_pattern(self, base, phrasal_pattern): if not base in self.phrasal_patterns: self.phrasal_patterns[base] = [phrasal_pattern] else: self.phrasal_patterns[base].append(phrasal_pattern) pattern_parser = PhrasalPatternParser(stem=self.stem) pp_obj = pattern_parser.parse(phrasal_pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_pattern(self, pattern):\n self.patterns.append(pattern)", "def __init__(self, pattern):\n self._pattern = re.compile(pattern)", "def add_pattern(self, pattern, callback):\n self.patterns.append((pattern, callback))", "def __init__(self, pattern):\r\n self.pattern = pattern...
[ "0.65718514", "0.62494636", "0.61294127", "0.61095756", "0.6079538", "0.5993424", "0.5964391", "0.59567755", "0.5663467", "0.5644707", "0.56338227", "0.56133646", "0.5608848", "0.55708647", "0.54960144", "0.54752636", "0.53281647", "0.5323162", "0.5294432", "0.5294158", "0.52...
0.7822084
0
Adds a prediction to the set of anytime predictions.
def index_anytime_prediction(self, prediction): if self.debug > 1: print 'Indexing anytime prediction %s' % (prediction,) self.index_prediction(self.anytime_predictions, prediction)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_prediction(self, truth_label, prediction, doc_id, doc_price=0):\n assert (truth_label == '1' or truth_label == '-1')\n \n if truth_label == prediction:\n if truth_label == '1':\n self.tp += 1\n else:\n self.tn += 1\n else:\n ...
[ "0.65096253", "0.6502434", "0.62210304", "0.61110085", "0.605963", "0.5962398", "0.5924518", "0.58317405", "0.5813396", "0.5808941", "0.5747288", "0.5687968", "0.56817526", "0.567845", "0.56692386", "0.55811673", "0.5569443", "0.5561001", "0.55457646", "0.5533378", "0.5454818...
0.6842723
0
Adds a prediction to the set of dynamic predictions.
def index_dynamic_prediction(self, prediction): if self.debug > 1: print 'Indexing dynamic prediction %s' % (prediction,) self.index_prediction(self.dynamic_predictions, prediction)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predictions(self, predictions):\n\n self._predictions = predictions", "def add_prediction(self, truth_label, prediction, doc_id, doc_price=0):\n assert (truth_label == '1' or truth_label == '-1')\n \n if truth_label == prediction:\n if truth_label == '1':\n ...
[ "0.7123987", "0.6687101", "0.6608172", "0.6588574", "0.6438798", "0.63834846", "0.63128114", "0.6136088", "0.6132608", "0.61325115", "0.59819067", "0.59658396", "0.58679914", "0.5849889", "0.58309", "0.5822418", "0.5814575", "0.5764383", "0.57549876", "0.573824", "0.5735496",...
0.70860356
1
Checks whether a term in a phrasal pattern is a syntax
def is_syntax_directive(self, term): if isinstance(term, list): if term[0] in self.syntax_functions: return True raise Error('%s is not a valid syntax function.' % (term[0],)) else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_logic_syntax(string):\n return logExp.matches(string)", "def _CheckExceptionTerm(self, term, rules):\n flag = False\n for keyword in rules:\n if rules[keyword] == 'starts':\n flag = flag or term.startswith(keyword)\n if rules[keyword] == 'ends':\n flag = flag or term.e...
[ "0.6473199", "0.6298758", "0.62886566", "0.6095183", "0.6074437", "0.6054373", "0.6012495", "0.59231627", "0.59226996", "0.5920593", "0.5886903", "0.5808357", "0.57052237", "0.56754154", "0.5669591", "0.5662537", "0.56541157", "0.56399435", "0.56335765", "0.56320757", "0.5630...
0.72898144
0
Creates a description with the specified base class and slots.
def find_frame(self, base, slots): return logic.Description(base, slots)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, name=None, slots=None):\n default_attr = dict(name=str(),\n slots=dict())\n self.name = name\n self.slots = slots\n self._set_default_attr(default_attr)", "def generate_slot(slot_name, slot_description, slot_raw_filename):\n slot = {\n ...
[ "0.58070856", "0.5718173", "0.5609317", "0.5423587", "0.5419044", "0.53676623", "0.5367074", "0.5291225", "0.5291225", "0.5285099", "0.5282149", "0.5216667", "0.51968807", "0.5177209", "0.51751906", "0.5170609", "0.5164997", "0.5153529", "0.51534", "0.51493376", "0.51250994",...
0.6458275
0
If the prediction is waiting for a slotfiller, and the item we saw can fill the slot, add the slot with filler to the predictions slots.
def extend_slots(self, prediction, item): spec = prediction.phrasal_pattern[0] slots = prediction.slots if is_role_specifier(spec): new_slots = copy(slots) new_slot = self.role_specifier(spec) if new_slot in new_slots: raise DuplicateSlotError('Slot %s already exists in %s.' % ( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_slot(self, slot):\n slot.set_location(len(self.slots)+1)\n self.slots.append(slot)", "def merge_slots(self, pred_slots, item_slots):\n for slot in pred_slots:\n if slot in item_slots:\n raise DuplicateSlotError('Slot %s already has the value %s.' % (\n slot, item_slots[slo...
[ "0.58766544", "0.57055455", "0.56512886", "0.55791277", "0.5512329", "0.54924816", "0.5338965", "0.5329639", "0.52402145", "0.5155657", "0.51417106", "0.5121062", "0.50382066", "0.5012749", "0.4931047", "0.49296585", "0.49216405", "0.48618618", "0.48344553", "0.4827673", "0.4...
0.70102435
0
Looks up the constraint on the specified slot for item.
def slot_constraint(self, item, role_spec): return self.kb.slot_value( logic.expr(item), CONSTRAINT_EXPR, logic.expr(role_spec))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_slot(item_id):\n if item_id in all_items:\n return all_items[item_id]['slot']\n return None", "def get_slot(self, idx):\n assert (idx >= 0) and (idx < self.size()), \"Index is out of range\"\n return self.slots[idx]", "def containing_slot(self, point):\n for i, bounds in enume...
[ "0.6716188", "0.6055658", "0.59715843", "0.5913708", "0.56738085", "0.56528217", "0.5513649", "0.5497099", "0.54896563", "0.54380274", "0.5436859", "0.5412239", "0.5348998", "0.5327917", "0.5307018", "0.52860284", "0.5240431", "0.5230452", "0.5210546", "0.51916254", "0.518645...
0.7476286
0
Parses a string containing a phrasal pattern into a tree representation.
def parse(self, pattern): phrasal_pattern = self.convert_parse_tree_to_phrasal_pattern( self.parse_tree(pattern)) return phrasal_pattern
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_tree(s):\n return parser.parse(lexer=lexer, input=s)", "def tree_string_parser(tree_string):\n tree_hash = create_hash(tree_string)\n tree_string = tree_string.replace(\"(\", \"{\")\n tree_string = tree_string.replace(\")\", \"}\")\n tree_string = \"{\" + tree_string + \"}\"\n tree_st...
[ "0.6565261", "0.6406509", "0.62351835", "0.6228951", "0.61783403", "0.6132944", "0.58582824", "0.5843517", "0.5839673", "0.5832786", "0.57039857", "0.5695232", "0.5673272", "0.5672355", "0.56367236", "0.5616294", "0.55375797", "0.5523444", "0.5484524", "0.5459082", "0.5456929...
0.73521155
0
Installs an index set.
def install(self, index_set): index_set.indices = map(self.stem, index_set.indices) index_set.required_indices = map(self.stem, index_set.required_indices) self.unique_target_concepts[index_set.target_concept] = True for index in index_set.indices: if not index in self.target_concepts.get(index, [...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install_packages_from_index(self, env=None):\n # extract non-source packages from package list\n index_packages = [p for p in self.pkg_arguments if not\n utils.assert_package_is_source(p)]\n # skip this step if there are no packages to be installed\n if not ...
[ "0.7080118", "0.6201861", "0.61710644", "0.61431223", "0.6129671", "0.6036387", "0.5905684", "0.58934444", "0.5872627", "0.58533996", "0.5815387", "0.57821035", "0.5777143", "0.5716653", "0.56888473", "0.55257696", "0.54855067", "0.54117346", "0.5403791", "0.539142", "0.53892...
0.8006205
0
Adds an index set to the target concept. The indexsetpattern must be a string containing an indexset pattern (see IndexSetPatternParser).
def add_index_set(self, target_concept, indexsetpattern): indexset = self.index_set_pattern_parser.parse( logic.expr(target_concept), indexsetpattern) self.install(indexset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install(self, index_set):\n index_set.indices = map(self.stem, index_set.indices)\n index_set.required_indices = map(self.stem, index_set.required_indices)\n self.unique_target_concepts[index_set.target_concept] = True\n for index in index_set.indices:\n if not index in self.target_concepts.ge...
[ "0.62463635", "0.59897494", "0.5209074", "0.5204011", "0.5071411", "0.50280774", "0.49698648", "0.4935041", "0.48192346", "0.47978112", "0.4796129", "0.47408307", "0.46981147", "0.4673346", "0.4620533", "0.46111295", "0.46000364", "0.46000364", "0.45934823", "0.45888665", "0....
0.90745026
0
Parses a string containing a indexset pattern and returns an IndexSet.
def parse(self, target, pattern): indexset = IndexSet(target) return self.read(indexset, pattern, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_range(raw):\n if not raw:\n return None\n\n indices = set()\n try:\n with open(raw, 'r') as f:\n for l in f:\n l = l.strip()\n if len(l) == 0 or l[0] == '#':\n continue\n if \" \" in l:\n ...
[ "0.5334464", "0.5226054", "0.5198872", "0.5191598", "0.51036763", "0.50414246", "0.49094805", "0.4886336", "0.4885104", "0.47790274", "0.47279197", "0.47008738", "0.46219444", "0.462135", "0.45989233", "0.45287374", "0.45258093", "0.45004886", "0.44923663", "0.44205198", "0.4...
0.5955374
0
return list of slots in order of their signups, from least to highest.
def get_ordered_slots(scheduled_slots, vols): vol_cnts = {} for s_slot in scheduled_slots: s_key = "{}-{}-{}".format(s_slot.day, s_slot.time_period, s_slot.type) vol_cnts[s_key] = 0 for vol in vols: for a_slot in vol.available_slots: a_key = "{}-{}".format(a_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sorted_signers(self) -> List[Address]:\n return sorted(self.signers)", "def get_grouped_available_slots(vols):\n vol_cnts = {}\n for vol in vols:\n slot_amt = len(vol.available_slots)\n if slot_amt < 1:\n continue\n if slot_amt in vol_cnts:\n vol_cn...
[ "0.61842656", "0.59229034", "0.59142065", "0.587465", "0.5765517", "0.57114506", "0.5706217", "0.56994545", "0.5667812", "0.5661197", "0.55991334", "0.55856377", "0.5568477", "0.5548975", "0.5524309", "0.54853594", "0.54852694", "0.54820555", "0.54611295", "0.5451059", "0.544...
0.633528
0
return relevant volunteers grouped by the amount of slots possible.
def get_grouped_available_slots(vols): vol_cnts = {} for vol in vols: slot_amt = len(vol.available_slots) if slot_amt < 1: continue if slot_amt in vol_cnts: vol_cnts[slot_amt].append(vol) else: vol_cnts[slot_amt] = [vol] #sorted_vol_cnts =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_vote_tally(self):\r\n voters = []\r\n tally = {}\r\n for b in reversed(self.blocks):\r\n if b.user_id not in voters and type(b) == VoteBlock:\r\n voters.append(b.user_id)\r\n if b.choice in tally.keys():\r\n tally[b.choice] +=...
[ "0.616679", "0.5977285", "0.5965824", "0.5698484", "0.5640452", "0.558289", "0.55814004", "0.55739164", "0.5554357", "0.5514152", "0.545814", "0.545814", "0.5409656", "0.53948075", "0.5380464", "0.5376231", "0.5353561", "0.5309577", "0.52577823", "0.5255719", "0.5249501", "...
0.6292542
0
Returns true if it OK add the olunteer to this slot as far as experience goes. That is if the other person assigned to the slot is experienced. Only returns false if someone else already assigned to slot and the current volunteer is inexperienced. so seeks to avoid all inexperienced persons at slot.
def experience_match(volunteer, volunteers, slot): if not volunteer.first_time: return True elif slot.type != 'coach2': return True #Brittle alert. Uses knowledge of the task: that this only matters currently for persons at coach 2 else: for volunteer2 in volunteers: for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fully_booked(slots, attendees, user_name):\n if len(attendees) >= 2:\n return False\n else:\n return True", "def check_if_enough_skill_points(self):\r\n for skill_string in self.__skills:\r\n if (self.__skills[skill_string].points_to_up >\r\n self.__sk...
[ "0.5966585", "0.58720344", "0.57698774", "0.57312316", "0.5658507", "0.5489901", "0.5485378", "0.5485378", "0.546458", "0.54519045", "0.54474586", "0.54375637", "0.5426604", "0.54058903", "0.5361417", "0.5335454", "0.53330934", "0.53311485", "0.5301933", "0.52844775", "0.5264...
0.64037406
0
Load a list of vector embeddings from a pd.Dataframe
def load_embeddings(db): size = db['size'].values emb = db['embedding'].values emb = [np.load(i).flatten() for i in emb] return emb, size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embeddings(filename):\n labels = []\n rows = []\n with open(filename, encoding='utf-8') as infile:\n for i, line in enumerate(infile):\n items = line.rstrip().split(' ')\n if len(items) == 2:\n # This is a header row giving the shape of the matrix\n ...
[ "0.67976797", "0.6629015", "0.62132424", "0.61987644", "0.61634785", "0.608386", "0.6048953", "0.5975803", "0.5965511", "0.5949263", "0.5895469", "0.58472", "0.5844589", "0.58138406", "0.58073044", "0.5799596", "0.57825804", "0.5748438", "0.57151216", "0.56519526", "0.5644582...
0.6641269
1
Save a histogram depicting the face sizes.
def hist_face_sizes(X, measure, output_dir): os.makedirs(output_dir, exist_ok=True) plt.clf() plt.hist(X, bins=100) plt.xlabel('Face bounding box') plt.ylabel('Frequency') plt.savefig(join(output_dir, 'face_' + measure + '.png'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_histogram(\n self, filename: [str, Path, BinaryIO], bins: int = 10, **kwargs\n ) -> None:\n self.plot_histogram(bins, show=False)\n plt.savefig(filename, **kwargs)\n if not isinstance(filename, BytesIO):\n print(f\"Picket fence histogram saved to: {osp.abspath(fil...
[ "0.706048", "0.7014267", "0.6871516", "0.6740837", "0.67147917", "0.6555688", "0.6508386", "0.6440228", "0.6383919", "0.6303205", "0.62309504", "0.615724", "0.6102644", "0.6074065", "0.6046084", "0.6015698", "0.59425527", "0.5941457", "0.5939888", "0.5929775", "0.5921403", ...
0.75264275
0
Clean up noise samples and compute Silhouette score. Since DBSCAN assigns a 1 label to those samples that are not attached to any cluster, we should dismiss those ones from the point of view of validation.
def measure_silhouette(X, labels, metric, with_noise=True): if get_number_clusters(labels) < 2: return -1 if -1 in labels: if with_noise: return silhouette_score(X, labels, metric=metric) else: idx2keep = [] for i, x in enumerate(labels): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def silhouette_samples(X, labels, metric='euclidean', **kwds):\n distances = pairwise_distances(X, metric=metric, **kwds)\n n = labels.shape[0]\n A = np.array([_intra_cluster_distance(distances[i], labels, i)\n for i in range(n)])\n B = np.array([_nearest_cluster_distance(distances[i],...
[ "0.6510874", "0.6369514", "0.635986", "0.62310797", "0.6025459", "0.601955", "0.59956837", "0.59785324", "0.59346735", "0.5932225", "0.5925631", "0.59135884", "0.5869151", "0.5866978", "0.58561087", "0.58439296", "0.58116424", "0.577271", "0.5763137", "0.57414037", "0.5739155...
0.6825846
0
Returns the sum of all the primes below n. >>> solution(1000) 76127 >>> solution(5000) 1548136 >>> solution(10000) 5736396 >>> solution(7) 10
def solution(n: int = 2000000) -> int: return sum(takewhile(lambda x: x < n, prime_generator()))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primesupto(n):\n # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188\n sieve = [True] * (n//2)\n for i in range(3,int(n**0.5)+1,2):\n if sieve[i//2]:\n sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)\n return [2] + [2*i+...
[ "0.7467311", "0.7343437", "0.7302786", "0.71355885", "0.71004784", "0.7057291", "0.703228", "0.69721013", "0.6956273", "0.69070196", "0.69021696", "0.6899741", "0.689087", "0.68867993", "0.6867779", "0.68633753", "0.68523663", "0.68466914", "0.6844139", "0.68319136", "0.67879...
0.80684763
0
ESTIMATEGAUSSIAN This function estimates the parameters of a Gaussian distribution using the data in X [mu sigma2] = estimateGaussian(X), The input X is the dataset with each ndimensional data point in one row The output is an ndimensional vector mu, the mean of the data set and the variances sigma^2, an n x 1 vector
def estimateGaussian(X): mu = X.mean(0, keepdims=True).T sigma2 = X.var(0, keepdims=True).T return mu, sigma2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def estimateGaussian(X):\n\tmu = np.mean(X, axis=0)\n\tsigma2 = np.std(X, axis=0) ** 2\n\treturn mu, sigma2", "def estimate_uni_gaussian(X):\n mu = mean(X, axis=0)\n sigma2 = var(X, axis=0)\n return mu, sigma2", "def estimate_gaussian_params(X):\n mu = X.mean(axis=0)\n var = X.std(axis=0)**2.0\n...
[ "0.7859824", "0.7347176", "0.7337883", "0.6956588", "0.6940591", "0.6928924", "0.68244404", "0.68032956", "0.662365", "0.6578702", "0.6561422", "0.65113556", "0.6508217", "0.64527017", "0.6452224", "0.64339375", "0.6422379", "0.64214444", "0.64155674", "0.64134204", "0.639653...
0.7678695
1
MULTIVARIATEGAUSSIAN Computes the probability density function of the multivariate gaussian distribution. p = MULTIVARIATEGAUSSIAN(X, mu, Sigma2) Computes the probability density function of the examples X under the multivariate gaussian distribution with parameters mu and Sigma2. If Sigma2 is a matrix, it is treated a...
def multivariateGaussian(X, mu, Sigma2): k = mu.shape[0] if Sigma2.shape[1] == 1 or Sigma2.shape[0] == 1: Sigma2 = np.diag(Sigma2[:, 0]) X = (X-mu.T).copy() p = (2*np.pi)**(-k/2)*np.linalg.det(Sigma2)**-0.5 p = p*np.exp(-0.5*(X.dot(np.linalg.pinv(Sigma2))*X).sum(1, keepdims=True)) retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multivariateGaussian(X, mu, sigma2):\n\tk = len(mu)\n\n\tif sigma2.ndim == 1:\n\t\t# convert sigma2 to a diagonal matrix\n\t\tsigma2 = np.diag(sigma2)\n\n\t# vectorized version of Multivariate Gaussian Distribution\n\tX = X - mu\n\t# p is a vector contains all probabilities of each examples\n\tp = (2 * np.pi) ...
[ "0.7436147", "0.70535463", "0.6552553", "0.6514739", "0.6439178", "0.6319203", "0.60270005", "0.5780886", "0.57091594", "0.57025003", "0.56856954", "0.56552154", "0.5488051", "0.5474055", "0.54697037", "0.5448944", "0.5433295", "0.5429303", "0.5429244", "0.54279035", "0.54174...
0.7175663
1
VISUALIZEFIT Visualize the dataset and its estimated distribution. VISUALIZEFIT(X, p, mu, sigma2) This visualization shows you the probability density function of the Gaussian distribution. Each example has a location (x1, x2) that depends on its feature values.
def visualizeFit(X, mu, sigma2): X1 = np.arange(0, 35.1, .5) X2 = np.arange(0, 35.1, .5) X1, X2 = np.meshgrid(X1, X2) Z = multivariateGaussian(np.c_[X1.flatten(), X2.flatten()], mu, sigma2) Z = Z.reshape(X1.shape) plt.figure() plt.plot(X[:, 0], X[:, 1], 'bx') # Do not plot if there are ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_fit(self):\n self.fft_fit_plotter.plot(self.ax)\n plt.draw()", "def plot_data(self, plot_input=True, plot_fitted=True,plotfile=None, show=None):\n if not self.fitted:\n raise RuntimeError(\"Please run fit() before attempting to plot the results\")\n\n fitted_data =...
[ "0.5769036", "0.56943357", "0.5680741", "0.5669008", "0.55950904", "0.5514858", "0.54367095", "0.5405027", "0.5348903", "0.53205526", "0.5303339", "0.5293988", "0.52836484", "0.52553016", "0.52499604", "0.5218861", "0.51786095", "0.51578337", "0.51521975", "0.5151396", "0.514...
0.68592554
0
SELECTTHRESHOLD Find the best threshold (epsilon) to use for selecting outliers [bestEpsilon bestF1] = SELECTTHRESHOLD(yval, pval) finds the best threshold to use for selecting outliers based on the results from a validation set (pval) and the ground truth (yval).
def selectThreshold(yval, pval): bestEpsilon = 0 bestF1 = 0 F1 = 0 stepsize = (pval.max()-pval.min())/1000 for epsilon in np.arange(pval.min(), pval.max()+stepsize/2, stepsize): predictions = (pval < epsilon) tp = ((predictions == 1) & (yval == 1)).sum() fp = ((predictions =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def selectThreshold(yval, pval):\n\tbestEpsilon = 0\n\tbestF1 = 0\n\tstepsize = (np.max(pval) - np.min(pval)) / 1000\n\n\tfor epsilon in np.arange(np.min(pval), np.max(pval), stepsize):\n\t\tpredictions = (pval < epsilon) + 0\n\t\ttp = np.sum((yval == 1) & (predictions == 1))\n\t\tfp = np.sum((yval == 0) & (predic...
[ "0.7637404", "0.6577474", "0.6432618", "0.63751316", "0.6364954", "0.61214995", "0.60790485", "0.6060021", "0.59685284", "0.59358245", "0.5918413", "0.58912176", "0.5870182", "0.58629036", "0.5786894", "0.5751271", "0.57167", "0.5685529", "0.56417114", "0.5627823", "0.5611794...
0.7630243
1
COFICOSTFUNC Collaborative filtering cost function [J, grad] = COFICOSTFUNC(params, Y, R, num_users, num_movies, ... num_features, lambda) returns the cost and gradient for the collaborative filtering problem.
def cofiCostFunc(params, Y, R, num_users, num_movies, num_features, lbd): X = np.reshape(params[:num_movies*num_features], (num_movies, num_features)) Theta = np.reshape(params[num_movies*num_features:], (num_users, num_features)) # J=sum((X*Theta'-Y)^2) where R[i,j]==1 h = X.dot(Theta.T)-Y M = h**...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cofiCostFunc(params, Y, R, num_users, num_movies, num_features, reg_lambda, returnCostOnly=False,\n returnGradOnly=False):\n\n # Unfold the U and W matrices from params\n X = params[0:num_movies * num_features].reshape((num_movies, num_features))\n Theta = params[num_movies * num_featu...
[ "0.8002528", "0.72502065", "0.6108871", "0.57345927", "0.57172936", "0.5682062", "0.56794614", "0.5547408", "0.5493439", "0.5474869", "0.5458474", "0.54476273", "0.5372544", "0.5371089", "0.5368994", "0.5344341", "0.5344016", "0.5269173", "0.5230837", "0.5183692", "0.5162195"...
0.7602335
1
COMPUTENUMERICALGRADIENT Computes the gradient using "finite differences" and gives us a numerical estimate of the gradient. numgrad = COMPUTENUMERICALGRADIENT(J, theta) computes the numerical gradient of the function J around theta. Calling y = J(theta) should return the function value at theta.
def computeNumericalGradient(J, theta): numgrad = np.zeros(theta.size) perturb = np.zeros(theta.size) e = 1e-4 for p in range(theta.size): # Set perturbation vector perturb[p] = e loss1 = J(theta - perturb)[0] loss2 = J(theta + perturb)[0] # Compute Numerical Grad...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def computeNumericalGradient(J, theta):\n numgrad = np.zeros_like(theta).reshape(-1)\n perturb = np.zeros_like(theta).reshape(-1)\n e = 1e-4\n for p in range(theta.size):\n # Set perturbation vector\n perturb[p] = e\n loss1, _ = J(theta - perturb.reshape(theta.shape))\n loss...
[ "0.7404099", "0.6591238", "0.6295547", "0.62560546", "0.62262666", "0.6171367", "0.6171367", "0.6063131", "0.60142076", "0.59528935", "0.59496725", "0.59108096", "0.59023327", "0.58785945", "0.5851465", "0.58256984", "0.58197623", "0.575046", "0.5730485", "0.57108414", "0.570...
0.74444306
0
CHECKCOSTFUNCTION Creates a collaborative filering problem to check your cost function and gradients CHECKCOSTFUNCTION(lambda) Creates a collaborative filering problem to check your cost function and gradients, it will output the analytical gradients produced by your code and the numerical gradients (computed using com...
def checkCostFunction(lbd=0): # Create small problem X_t = np.random.rand(4, 3) Theta_t = np.random.rand(5, 3) # Zap out most entries Y = X_t.dot(Theta_t.T) Y[np.random.rand(Y.shape[0], Y.shape[1]) > .5] = 0 R = np.zeros(Y.shape) R[Y == 0] = 1 # Run Gradient Checking X = np.ran...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_function(symbol, forward=None, backward=None, grad_input_vars=None,\n shape=None, dtype=None, in_range=None, values=None,\n exclude_targets=None, only_targets=None,\n additional_params=None,\n numerical_grads=None, numerical_grads_pa...
[ "0.594035", "0.58975935", "0.5887315", "0.58429676", "0.5820648", "0.58180976", "0.56850296", "0.56849337", "0.5643986", "0.5643095", "0.5579458", "0.55547184", "0.55505186", "0.54298055", "0.5423791", "0.53822243", "0.52979624", "0.5283935", "0.52480435", "0.5244632", "0.523...
0.6569059
0
GETMOVIELIST reads the fixed movie list in movie.txt and returns a cell array of the words movieList = GETMOVIELIST() reads the fixed movie list in movie.txt and returns a cell array of the words in movieList.
def loadMovieList(): # Read the fixed movieulary list fid = open('movie.txt', 'r', encoding='UTF-8') ls = fid.readlines() fid.close() movieList = [i[i.find(' ')+1:-1] for i in ls] return movieList
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getVocabList():\n vocab_list = []\n with open('vocab.txt') as f_obj:\n while True:\n vocab_line = f_obj.readline()\n if not vocab_line:\n break\n word = re.search(r'\\t(\\w+)', vocab_line).group(1)\n vocab_list.append(word)\n return voc...
[ "0.6709577", "0.648282", "0.62326944", "0.6198604", "0.61928093", "0.60708266", "0.6070315", "0.6035897", "0.59378856", "0.5916645", "0.59033954", "0.58966136", "0.5863689", "0.58624583", "0.58624583", "0.58624583", "0.585424", "0.5835306", "0.58195555", "0.5803572", "0.57604...
0.81582546
0
NORMALIZERATINGS Preprocess data by subtracting mean rating for every movie (every row) [Ynorm, Ymean] = NORMALIZERATINGS(Y, R) normalized Y so that each movie has a rating of 0 on average, and returns the mean rating in Ymean.
def normalizeRatings(Y, R): m, n = Y.shape Ymean = np.zeros((m, 1)) Ynorm = np.zeros(Y.shape) for i in range(m): idx = np.where(R[i] == 1)[0] Ymean[i, 0] = Y[i, idx].mean() Ynorm[i, idx] = Y[i, idx]-Ymean[i, 0] return Ynorm, Ymean
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalizeRatings(Y, R):\n\n m, n = Y.shape\n Ymean = np.zeros(m)\n Ynorm = np.zeros(Y.shape)\n\n for i in range(m):\n idx = R[i] == 1\n y = Y[i, idx]\n\n Ymean[i] = np.mean(y)\n Ynorm[i, idx] = y - Ymean[i]\n\n return Ynorm, Ymean", "def normalize(dataset):\n ret...
[ "0.714793", "0.6533668", "0.6453761", "0.6344558", "0.6208749", "0.6180315", "0.61512446", "0.61158943", "0.610423", "0.6082433", "0.60785216", "0.60010606", "0.59637064", "0.5939617", "0.59323406", "0.59188473", "0.5907955", "0.5896943", "0.5888731", "0.5886372", "0.58828217...
0.7204803
0
Gradientdescent to learn ratings
def RatingsGradientDescent(params, Y, R, num_users, num_movies, num_features, lbd, alpha, num_iters): J_history = np.zeros(num_iters) for i in range(num_iters): J_history[i], grad = cofiCostFunc(params, Y, R, num_users, num_movies, num_features, lbd) params = params-alpha*grad if i % 100...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_gradient(self, learning_rate):\n raise NotImplementedError()", "def _ci_grads(preds, dtrain):\n # predictions: np.array with shape of (n, )\n n = preds.shape[0]\n y_hat = preds\n\n # labels: np.array with shape of (n, )\n labels = dtrain.get_label().astype('int')\n E = (labels ...
[ "0.6332611", "0.63145196", "0.62612844", "0.622522", "0.6213547", "0.6210447", "0.6207228", "0.61697274", "0.6164421", "0.6163743", "0.61341023", "0.6130062", "0.6113881", "0.61076546", "0.61035484", "0.61020714", "0.6100461", "0.60973877", "0.6088086", "0.60739964", "0.60663...
0.66002995
0
Make an empty environment with the outer environment specified
def makeenv(outer=None): retval = {'outer': outer} return retval
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_empty_env():\n return EvalEnvironment(namespaces={})", "def get_empty_env():\n return EvalEnvironment(namespaces={})", "def base_env(*args, **kwargs):\n try:\n # regular gym\n env = gym.make(*args, **kwargs)\n except:\n try:\n # gym retro\n env = r...
[ "0.76089615", "0.76089615", "0.64476967", "0.6409842", "0.634659", "0.6296848", "0.6287654", "0.6220598", "0.6174979", "0.6111547", "0.60660183", "0.60641164", "0.60411716", "0.603954", "0.603954", "0.5998172", "0.5967356", "0.595362", "0.5953504", "0.58625597", "0.58617914",...
0.7615676
0
Find a symbol in env If symbol not in env or any of its outer, return None
def find(sym, env): try: if sym in env: return env[sym] else: return find(sym, env['outer']) except TypeError: # once hit here, sym is nowhere to be found raise NameError("Undefined atom {0!r}".format(sym))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_symbol(self, op):\n for ii in self.__symbols:\n if ii.get_name() == op:\n return ii\n return None", "def top_level(symbol):\n return (symbol and ('.' not in symbol)) or None", "def checkLookup(self, name):\n if not self.symbols.has_key(name):\n # we don't care\n ...
[ "0.6370924", "0.62944776", "0.6078659", "0.60524756", "0.6004943", "0.5947626", "0.5891099", "0.5712541", "0.56552565", "0.56427425", "0.56182706", "0.5615034", "0.5589886", "0.55879825", "0.55729616", "0.55723345", "0.5512622", "0.55066395", "0.545123", "0.545123", "0.543885...
0.7866419
0
Converge the orders we currently have in the book with what we want to be in the book. This involves amending any open orders and creating new ones if any have filled completely. We start from the closest orders outward.
def converge_orders(self, buy_orders, sell_orders, order_status): tickLog = self.exchange.get_instrument()['tickLog'] to_amend = [] to_create = [] to_cancel = [] buys_matched = 0 sells_matched = 0 existing_orders = self.exchange.get_orders() # Check all ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place_orders(self):\n buy_orders = []\n sell_orders = []\n buy_stop_order = {}\n sell_stop_order = {}\n order_status = 0\n \"\"\"order_status参数说明\n 0: running_qty为0, 维持原样\n 1: self.running_qty > 0, 买卖都变化, 买单按照offset2, 卖单按照offset3\n 2: 买...
[ "0.6256506", "0.61004424", "0.60048115", "0.60048115", "0.5979889", "0.590376", "0.5839191", "0.57591915", "0.5754883", "0.57441545", "0.5730442", "0.5697442", "0.5606702", "0.5579016", "0.55562407", "0.55487514", "0.5543467", "0.5517832", "0.5501182", "0.5500108", "0.5445915...
0.6941159
0
Set up the iCloud Scanner.
def setup_scanner(hass, config, see): from pyicloud import PyiCloudService from pyicloud.exceptions import PyiCloudFailedLoginException from pyicloud.exceptions import PyiCloudNoDevicesException # Get the username and password from the configuration username = config.get(CONF_USERNAME) password...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_cloud_api(self, args=None):\n pass", "def setup_clouds(auth=None):\n get_operator_cloud(auth)\n get_openstack_cloud(auth)", "def setup_clouds(auth=None):\n get_operator_cloud(auth)\n get_openstack_cloud(auth)", "def setUp(self):\n self._plugin = spotlight_volume.SpotlightVolume...
[ "0.5866603", "0.5790116", "0.5790116", "0.5620999", "0.55827475", "0.5516062", "0.54825497", "0.53748256", "0.533198", "0.53023446", "0.52686286", "0.52626604", "0.5261257", "0.5261257", "0.5261257", "0.52435845", "0.52435845", "0.52435845", "0.52435845", "0.52435845", "0.524...
0.68545204
0
Keeps authenticating iCloud connection.
def keep_alive(now): api.authenticate() _LOGGER.info("Authenticate against iCloud")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate(self):\n\n LOGGER.info(f\"Authenticating as {self.user['apple_id']}\")\n\n data = dict(self.user)\n\n # We authenticate every time, so \"remember me\" is not needed\n #data.update({\"extended_login\": False})\n data.update({\"extended_login\": True})\n\n t...
[ "0.60142636", "0.58762807", "0.5862534", "0.58443606", "0.5819822", "0.5804538", "0.57355726", "0.5642202", "0.558887", "0.5545338", "0.5468961", "0.5466535", "0.54000777", "0.5383877", "0.5376469", "0.5353568", "0.53381795", "0.52868426", "0.522603", "0.52217215", "0.521283"...
0.8251854
0
Perform bad channel detection. The recording is assumed to be filtered. If not, a highpass filter is applied on the fly.
def detect_bad_channels( recording, method="coherence+psd", std_mad_threshold=5, psd_hf_threshold=0.02, dead_channel_threshold=-0.5, noisy_channel_threshold=1.0, outside_channel_threshold=-0.75, n_neighbors=11, nyquist_threshold=0.8, direction="y", chunk_duration_s=0.3, n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_bad_channels_ibl(\n raw,\n fs,\n psd_hf_threshold,\n dead_channel_thr=-0.5,\n noisy_channel_thr=1.0,\n outside_channel_thr=-0.75,\n n_neighbors=11,\n nyquist_threshold=0.8,\n welch_window_ms=0.3,\n):\n _, nc = raw.shape\n raw = raw - np.mean(raw, axis=0)[np.newaxis, :]\n...
[ "0.6451672", "0.62761134", "0.6208499", "0.5965947", "0.5960218", "0.5822532", "0.5812152", "0.56674945", "0.5547122", "0.5531795", "0.5470612", "0.5420324", "0.5415153", "0.5385043", "0.53281367", "0.5241387", "0.5231101", "0.51918143", "0.5190904", "0.51698804", "0.51601934...
0.6694439
0
Bad channels detection for Neuropixel probes developed by IBL
def detect_bad_channels_ibl( raw, fs, psd_hf_threshold, dead_channel_thr=-0.5, noisy_channel_thr=1.0, outside_channel_thr=-0.75, n_neighbors=11, nyquist_threshold=0.8, welch_window_ms=0.3, ): _, nc = raw.shape raw = raw - np.mean(raw, axis=0)[np.newaxis, :] nperseg = int(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_badchannels(raw, picks, ref_meg=\"auto\", significance_level=0.05):\n\n gesd_args = {'alpha': significance_level}\n\n if (picks == \"mag\") or (picks == \"grad\"):\n chinds = mne.pick_types(raw.info, meg=picks, ref_meg=ref_meg, exclude='bads')\n elif picks == \"meg\":\n chinds = m...
[ "0.6287099", "0.60764647", "0.6043073", "0.59790766", "0.5947519", "0.5931392", "0.58910775", "0.5872547", "0.57613003", "0.5647657", "0.5642624", "0.56293416", "0.55950636", "0.55592114", "0.5558336", "0.5542864", "0.55260485", "0.55084145", "0.55017304", "0.54997927", "0.54...
0.6900998
0
Subtract the trend from a vector The trend is a median filtered version of the said vector with tapering
def detrend(x, nmed): ntap = int(np.ceil(nmed / 2)) xf = np.r_[np.zeros(ntap) + x[0], x, np.zeros(ntap) + x[-1]] import scipy.signal xf = scipy.signal.medfilt(xf, nmed)[ntap:-ntap] return x - xf
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def msub(trace):\n \n return(trace - np.mean(trace))", "def mad(v):\n return np.median(np.abs(v-np.median(v)))", "def subtract_filters(tod,az,el,filter_tod, filter_coefficients, atmos, atmos_coefficient):\n tod_out = tod - filter_tod*filter_coefficients -\\\n Statistics.AtmosGroundMode...
[ "0.61765325", "0.5848676", "0.57519156", "0.573888", "0.56955457", "0.5648303", "0.5647168", "0.56332374", "0.5627263", "0.5606333", "0.5601126", "0.5601126", "0.5601126", "0.55868834", "0.5551623", "0.55299646", "0.5528388", "0.5499842", "0.5426456", "0.5414013", "0.5376006"...
0.6236731
0
Return the CPSSORTER version, location and Python powering it.
def version_msg(): python_version = sys.version[:3] location = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) message = 'CPS-SORTER %(version)s from {} (Python {})' return message.format(location, python_version)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system_info() -> str:\n return \"\\n\".join(\n [\n f\"Python version: {platform.python_version()}\",\n f\"Python implementation: {platform.python_implementation()}\",\n f\"Python compiler: {platform.python_compiler()}\",\n f\"PyTorch version: {torch.__versi...
[ "0.6168813", "0.5991945", "0.5864778", "0.58291036", "0.57870007", "0.57867646", "0.5765549", "0.57526255", "0.5737532", "0.57125515", "0.57054865", "0.56973195", "0.5696263", "0.5696263", "0.567503", "0.5664359", "0.56593263", "0.5656099", "0.5653776", "0.5653776", "0.564697...
0.6110174
1
Creates a grid image from a list of tiles.
def build_grid(tiles, tile_size, grid_rows=None, grid_cols=None): if grid_rows is None or grid_cols is None: grid_rows = int(math.sqrt(len(tiles))) grid_cols = int(math.ceil(len(tiles) / grid_rows)) grid = np.zeros( (grid_rows * tile_size[1], grid_cols * tile_size[0], 3), np.uint8) for tile_id, tile ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_grid(images, n_rows=4, n_cols=4):\n k = min(n_rows * n_cols, len(images))\n indices = [i for i in range(k)]\n return _create_grid(images, indices, n_rows, n_cols)", "def createTiles():\n Renderer.Clear()\n map = []\n w, h = len(testmap[0]), len(testmap)\n x, y = 0, 0\n for row ...
[ "0.70259213", "0.6990671", "0.6980882", "0.6948259", "0.68473595", "0.6711176", "0.66005284", "0.65379393", "0.6532611", "0.65262944", "0.6488695", "0.64755493", "0.64710665", "0.6470593", "0.6410475", "0.6399757", "0.6379704", "0.6372506", "0.634613", "0.634", "0.63370925", ...
0.73709124
0
Colorizes a label map.
def colorize_label_map(label): if label.ndim != 2: raise ValueError('Expect 2-D input label. Got {}'.format(label.shape)) colormap = colormap_ade20k label_mod = np.mod(label, len(colormap)) return colormap[label_mod].astype(np.uint8)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_label_colormap():\n colormap = np.array([\n [128, 64, 128],\n [244, 35, 232],\n [ 70, 70, 70],\n [102, 102, 156],\n [190, 153, 153],\n [153, 153, 153],\n [250, 170, 30],\n [220, 220, 0],\n [107, 142, 35],\n [152, 251, 152],...
[ "0.7158274", "0.6700223", "0.66767853", "0.65805185", "0.65408355", "0.65408355", "0.6459192", "0.64117914", "0.64117914", "0.6396002", "0.63941085", "0.63720775", "0.6268199", "0.62457615", "0.62457615", "0.62457615", "0.62457615", "0.62456137", "0.6224787", "0.62216127", "0...
0.76586264
0
Visualizes GT fragment fields.
def visualize_gt_frag( gt_obj_ids, gt_obj_masks, gt_frag_labels, gt_frag_weights, gt_frag_coords, output_size, model_store, vis_prefix, vis_dir): # Consider the first (i.e. the closest) fragment. frag_ind = 0 centers_vis = np.zeros((output_size[1], output_size[0], 3)) for gt_id, obj_id in enumerate...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visualize(self):\n dot = Graph()\n \n for k, v in self.vs.items():\n if v.observed:\n dot.node(v.word, style=\"filled\")\n else:\n dot.node(v.word)\n\n for i, (k, v) in enumerate(self.fs.items()):\n dot.node(str(i), shap...
[ "0.55321085", "0.5522345", "0.5433646", "0.5431757", "0.5373131", "0.5313519", "0.5297603", "0.52738523", "0.5157684", "0.5131119", "0.50463957", "0.50377893", "0.5006303", "0.4998228", "0.49903286", "0.4951498", "0.4939597", "0.49295256", "0.49017107", "0.4890147", "0.486571...
0.61502445
0
Visualizes predicted fragment fields.
def visualize_pred_frag( frag_confs, frag_coords, output_size, model_store, vis_prefix, vis_dir, vis_ext='png'): num_objs = frag_confs.shape[2] tiles_centers = [] tiles_coords = [] tiles_reconst = [] for obj_id in range(1, num_objs + 1): # Fragment confidences of shape [field_h, field_w, num_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_predictions(self):\n self.vis.draw_predictions()", "def visualize(self):\n\n self.check_model()\n show(prepare(self.model, self.vectorized_data, self.vectorizer, mds='tsne'))", "def learning_viz(self) :\n self.train\n history = self.history\n plot_loss(history...
[ "0.6237396", "0.58392346", "0.5504426", "0.54394037", "0.54047847", "0.5402861", "0.53779405", "0.5372202", "0.53684616", "0.53396916", "0.5336576", "0.5331659", "0.53001356", "0.5289845", "0.52895397", "0.52718323", "0.5260922", "0.5260298", "0.52548635", "0.5251781", "0.522...
0.6102499
1
Pass in target movie_id, target days and full comments data. Comments data is automatically filtered based on parameters. Raise value error if days out of range
def __init__(self, movie_id, days_window: list, comments): self.movie_id = movie_id dcs_uid = brands[brands['brand_ods_id'] == self.movie_id]['data_profile_dcs_uid'].values self.comments = comments self.comments = self.comments[self.comments['post_author_dcs_uid'].isin(dcs_uid)] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_comments_for_one_day(self, y,m,d):\n in_date = date(y,m,d)\n\n start = self.utc_to_unix_time(in_date - timedelta(1)) \n end = self.utc_to_unix_time(in_date) \n return self.get_comments_between(start,end)", "def get_comments(subreddit, start_date, end_date, limit):\n api = P...
[ "0.5074537", "0.47782722", "0.47501183", "0.4745651", "0.46918073", "0.46691847", "0.46658993", "0.45897898", "0.45842305", "0.4573905", "0.4556693", "0.45527554", "0.454822", "0.45028967", "0.449018", "0.4468614", "0.4454364", "0.44383335", "0.44142863", "0.43958214", "0.438...
0.6544567
0
Create a word count bar chart. Choose the amount of words to include, as well as whether to clean the comment text before plotting. If no words are found on a particular day, the function will automatically find the next
def count_plot(self, top_words=25, clean=True): if top_words > 25: warnings.warn('Including more than 25 words on the plot will cause labels to be excluded') daily_comments = self.comments[(self.comments['days_after_release'].\ isin(list(range(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_words_bar_chart(df, n=10):\n messages = df['message'].values\n word_counts = {}\n for message in messages:\n tokens = tokenize(message)\n for token in tokens:\n if token in word_counts:\n word_counts[token] += 1\n else:\n word_count...
[ "0.7079399", "0.67071533", "0.62005866", "0.61314", "0.6073859", "0.6038004", "0.60302097", "0.60053146", "0.59687704", "0.5862463", "0.58548695", "0.57932806", "0.5750061", "0.5748947", "0.57324004", "0.5716763", "0.57065487", "0.56946385", "0.565803", "0.5639725", "0.559574...
0.7242556
0
Apply lemmatization to cleaned comments
def _proc(dat): def lemma(text): lemmatizer = WordNetLemmatizer() w_tokenizer = WhitespaceTokenizer() return [lemmatizer.lemmatize(w) for w in w_tokenizer.tokenize(text)] dat['text_lemmatized'] = dat['clean_comments'].apply(lemma) dat['text_lemmatized'] = dat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lemmatize_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = None\n if self.lemmatize_method == 'wordnet':\n cleaned_tokens = [self.lemmatizer.lemmatize(token) for token in tokens]\n else:\n cleaned_tokens = [self.lemmatizer.stem(token) for token in...
[ "0.7497414", "0.69905686", "0.6854682", "0.66385305", "0.6468014", "0.64453566", "0.6444136", "0.6443159", "0.64086497", "0.6401282", "0.6396557", "0.6334729", "0.6331374", "0.6327046", "0.63106084", "0.6305712", "0.6254337", "0.6175787", "0.61659825", "0.614558", "0.6141945"...
0.76389426
0
Open webcam through OpenCV.
def openWebcam(self): # Récupérer l'id de la caméra entré par l'utilisateur self.device_id = int(self.device_id_text.text()) # Prendre la main sur la webcam en créant un objet VideoCapture self.webcam = cv2.VideoCapture(self.device_id) # Verbose ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_cam(width, height):\n\n logging.info('start web cam')\n cap = cv2.VideoCapture(0)\n\n # Check success\n if not cap.isOpened():\n raise ConnectionError(\"Could not open video device\")\n \n # Set properties. Each returns === True on success (i.e. correct resolution)\n assert cap...
[ "0.7465654", "0.7350664", "0.7223432", "0.7108686", "0.7093217", "0.701221", "0.7001169", "0.6957629", "0.6868298", "0.68425375", "0.672854", "0.67270094", "0.666812", "0.66563153", "0.66343963", "0.66135263", "0.65414745", "0.6515322", "0.64338577", "0.64204544", "0.63682413...
0.8227863
0
Shows mean values of RGB channels next to the frame from the webcam.
def showAverageRGB(self): # Affichage dans les boxes self.red_label.setText("Mean RED: "+str(int(round(self.R.mean())))) self.red_label.adjustSize() self.green_label.setText("Mean GREEN: "+str(int(round(self.G.mean())))) self.green_label.adjustSize() self.blue_la...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def meanColor(self):\n return self.image[self.x, self.y]", "def current_average_luma(camera):\n camera.capture('/home/pi/Desktop/image1.jpg')#camera take picture\n img = Image.open(\"/home/pi/Desktop/image1.jpg\") #opens image\n \n luma=0 #sum of the lumenance of each pixels\n pixels = img....
[ "0.67817515", "0.659468", "0.65413666", "0.64140654", "0.63425577", "0.6320953", "0.62316763", "0.6121077", "0.6084322", "0.5991751", "0.5955584", "0.5944211", "0.5944211", "0.5944211", "0.5944211", "0.5944211", "0.5944211", "0.58618677", "0.58269626", "0.5824946", "0.5823764...
0.6885815
0
Convert cv2 image (BGR numpy array) to QPixelmap object to display it the GUI.
def convertToQPixelmap(self, imgToConvert): # Conversion en image QImage if ( len(imgToConvert.shape) == 3 ): img_qimg = QtGui.QImage(imgToConvert.data, imgToConvert.shape[1], imgToConvert.shape[0], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_cv_qt(self, cv_img):\n rgb_image = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)\n h, w, ch = rgb_image.shape\n bytes_per_line = ch * w\n convert_to_Qt_format = QtGui.QImage(rgb_image.data, w, h, bytes_per_line, QtGui.QImage.Format_RGB888)\n p = convert_to_Qt_format.scaled(...
[ "0.718548", "0.718548", "0.718548", "0.7123519", "0.71096885", "0.71096885", "0.7105883", "0.7094785", "0.7086501", "0.70823795", "0.70712984", "0.7009322", "0.68332046", "0.6717237", "0.66939294", "0.6532576", "0.65172887", "0.64648676", "0.6361938", "0.632177", "0.629296", ...
0.7442458
0
Upload a model checkpoint to the specified bucket in GCS.
def upload_checkpoint( bucket_namespace: str, bucket_name: str,prefix:str, checkpoint_filepath: Union[Path, str] ): bucket_prefix = prefix dst_path = f"{bucket_prefix}/{checkpoint_filepath}" # dst_path = f"{bucket_prefix}/{target_filepath}" print('Uploading {} => {}'.format(checkpoint_filep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model_to_gcp(self, model_name):\n local_model_name = f'{model_name}.joblib'\n # saving the trained model to disk (which does not really make sense\n # if we are running this code on GCP, because then this file cannot be accessed once the code finished its execution)\n joblib.du...
[ "0.6675769", "0.6465549", "0.63573015", "0.6309598", "0.6173304", "0.5960331", "0.5890611", "0.58213955", "0.5812179", "0.5769049", "0.5753088", "0.5706468", "0.56932503", "0.56821054", "0.5661021", "0.5624393", "0.56197286", "0.55618644", "0.552092", "0.5520645", "0.5492323"...
0.72291005
0
Tests that finalize_fn is not run with multiple threads.
def test_finalize_fn_uses_single_thread(ray_start_regular_shared): block_refs_iter = itertools.starmap( lambda block, metadata: (ray.put(block), metadata), block_generator(num_blocks=20, num_rows=2), ) q = queue.Queue() semaphore = threading.Semaphore(value=1) def finalize_enforce_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finalize():\n pass", "def finalize():\n pass", "def finalize() -> None:\n collective.finalize()", "def finalize():", "def finalize():", "def finalize():", "def finalize(self, interrupted=False):\n pass", "def finalize_worker():\n if SAMPLER_POOL is not None:\n for _ in range...
[ "0.6559201", "0.6559201", "0.6393924", "0.6308009", "0.6308009", "0.6308009", "0.5953244", "0.58854395", "0.58499384", "0.5809321", "0.57099277", "0.5622887", "0.56003356", "0.5595621", "0.55558133", "0.55535084", "0.54888344", "0.5488354", "0.5486915", "0.5448982", "0.540425...
0.66419667
0
given a list of URLs to JSON schema files return a SchemaTemplate object
def _load(self, list_of_schema_urls): for uri in list_of_schema_urls: with urllib.request.urlopen(uri) as url: data = {} try: data = json.loads(url.read().decode()) except: print("Failed t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_url_schema():\n json_str = json.dumps({'fields': [\n {'name': 'url', 'type': 'STRING', 'mode': 'NULLABLE'},\n {'name': 'count', 'type': 'INTEGER', 'mode': 'NULLABLE'},\n {'name': 'ts', 'type': 'TIMESTAMP', 'mode': 'NULLABLE'}]})\n return parse_table_schema_from_json(js...
[ "0.641576", "0.63740885", "0.62452924", "0.61295396", "0.59485245", "0.59202313", "0.584993", "0.58236873", "0.57742834", "0.56165123", "0.5564679", "0.55167973", "0.54723084", "0.5468001", "0.541009", "0.5409211", "0.53917426", "0.53839236", "0.535626", "0.53263766", "0.5314...
0.7021566
0
load a JSON schema representation
def _load_schema(self, json_schema): # use jsonrefs to resolve all $refs in json data = jsonref.loads(json.dumps(json_schema)) return self.__initialise_template(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_schema(self):\n\n schema = {\n \"type\": \"object\",\n \"properties\": {}\n }\n\n msd = self.parse_xml(self.schema_path)\n for concept in msd.findall('.//Concept'):\n concept_id = self.alter_key(concept.attrib['id'])\n self.add_item_t...
[ "0.7583523", "0.7520712", "0.74996924", "0.7430722", "0.7415444", "0.7349981", "0.7319478", "0.7192056", "0.7140964", "0.71265936", "0.7098515", "0.70178914", "0.6897158", "0.6762067", "0.67160565", "0.66375107", "0.6575512", "0.6442525", "0.6335049", "0.6334846", "0.63198113...
0.7622569
0
Read two files (networkr.csv, user_by_city) and create the Graph object. (user_id's will be reordered because Graph object needs consecutive integers for indices of the graph.)
def read_file(network_filename, user_by_city_filename=None): graph = read_dictlist_from_file(network_filename) gg = Graph(directed=False) # new Graph object user_id_map = {} # storing new id info new_id = 0 for user_id in graph: temp_users = [] temp_users.append(user_id) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_graph_from_csvs(path, sep=\";,.\", num_files=None):\n assert type(path)==str, \"Path must be string type\"\n\n if path[-1] == '/':\n path = path[:-1]\n\n file_list = glob.glob(path+'/*.csv')\n\n if not num_files:\n num_files = len(file_list)\n\n graph = nx.DiGraph()\n\n fo...
[ "0.6084426", "0.6013192", "0.5921239", "0.57427114", "0.57265186", "0.5637249", "0.5591132", "0.5589975", "0.5519558", "0.5494048", "0.54668725", "0.5440877", "0.54308814", "0.54280937", "0.5413682", "0.5358772", "0.53454447", "0.5342393", "0.5335665", "0.53317857", "0.531984...
0.79204625
0
Returns the contents read from the CSV file filename. This function reads the contents of the file filename and returns the contents as a 2dimensional list. Each element of the list is a row, with the first row being the header. Cells in each row are all interpreted as strings; it is up to the programmer to interpret t...
def read_csv(filename): # Implement this function file = open(filename) wrapper = csv.reader(file) result = [] for rpos in wrapper: result = result + [rpos] file.close() return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_csv(filename):\n with open(filename) as csv:\n return [csv_line.strip().split(',') for csv_line in csv]", "def import_csv(filename):\n with open(filename, newline='') as csvfile:\n reader_obj = csv.reader(csvfile, delimiter=',', quotechar='\"')\n data = list(reader_obj)\n r...
[ "0.74909246", "0.7454272", "0.7397418", "0.737931", "0.73525816", "0.7320116", "0.72919524", "0.72789633", "0.7226385", "0.720839", "0.7207552", "0.7207479", "0.7180073", "0.71576065", "0.71297944", "0.7055001", "0.7043814", "0.7033059", "0.7027407", "0.7022255", "0.70219046"...
0.7575302
0
Returns true if the time takes place during the day. A time is during the day if it is after sunrise but before sunset, as indicated by the daycycle dicitionary. A daycycle dictionary has keys for several years (as int). The value for each year is also a dictionary, taking strings of the form 'mmdd'. The value for that...
def daytime(time,daycycle): # HINT: Use the code from the previous exercise to get sunset AND sunrise # Add a timezone to time if one is missing (the one from the daycycle) from dateutil.parser import parse dYear = str(time.strftime('%Y')) dMonDay = str(time.strftime('%m-%d')) mk = '' m = ''...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_time_type_state_is_afternoon(day):\n\n assert day_time_info(day.hours_0).is_afternoon is False\n assert day_time_info(day.hours_1).is_afternoon is False\n assert day_time_info(day.hours_2).is_afternoon is False\n assert day_time_info(day.hours_3).is_afternoon is False\n assert day_time_info...
[ "0.6449394", "0.64007175", "0.6371306", "0.6301575", "0.6152317", "0.59922785", "0.590649", "0.57754403", "0.5772595", "0.57206595", "0.57047856", "0.5666967", "0.55771357", "0.5550245", "0.5542482", "0.54408264", "0.541284", "0.5396091", "0.53877", "0.53581625", "0.5350125",...
0.7860913
0
Returns (a copy of) a row of the table with the given id. Table is a twodimensional list where the first element of each row is an identifier (string). This function searches table for the row with the matching identifier and returns a COPY of that row. If there is no match, this function returns None. This function is...
def get_for_id(id,table): # Implement this function for row in range(1, len(table)): for col in range(len(table[0])): if id in table[row][col]: return table[row]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_table_by_id(soup, id):\n # dont include .tbody after the find() for some reason\n html_table = soup.find(id=id)\n if html_table is None:\n return None\n rows = html_table.find_all('tr')[1:]\n return [row.contents for row in rows]", "def rpc_database_get_row_by_id(self, row_id):\n\t\...
[ "0.64286244", "0.63104653", "0.6236567", "0.6154454", "0.61423177", "0.6114756", "0.595511", "0.5797238", "0.5750377", "0.57493246", "0.56794655", "0.56740063", "0.56564826", "0.5519462", "0.5502018", "0.54621154", "0.5460119", "0.5443191", "0.54360026", "0.54353404", "0.5422...
0.71067375
0
Given a boolean specifying whether to use local disk or S3, setup filesystem
def setup_fs(s3, key="", secret="", endpoint="", region="",cert="", passwords={}): if s3: import s3fs block_size = 55 * 1024 * 1024 if "amazonaws" in endpoint: fs = s3fs.S3FileSystem(key=key, secret=secret, default_block_size=block_size) elif cert != "": fs...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, source_path, output_path):\n self.storage_type = 's3' if 's3' in source_path else 'local'\n self.source_path = source_path\n self.output_path = output_path", "def get_filesystem(self, silent=True):\n if self._filesystem:\n return self._filesystem\n ...
[ "0.6136107", "0.61083025", "0.5886789", "0.56999713", "0.55318826", "0.5386369", "0.5384897", "0.5347873", "0.5322004", "0.53185993", "0.52828926", "0.527598", "0.5212449", "0.5212169", "0.52068335", "0.5196238", "0.51807004", "0.5143956", "0.51013356", "0.50991315", "0.50977...
0.70687497
0
Given a list of DBC file paths, create a list of conversion rule databases
def load_dbc_files(dbc_paths): import can_decoder from pathlib import Path db_list = [] for dbc in dbc_paths: db = can_decoder.load_dbc(Path(__file__).parent / dbc) db_list.append(db) return db_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pdblist(pdblist, addext = 0):\n\n\t#Load the pdblist, and convert to a list.\n\tlistfile = open(pdblist, 'r')\n\tpdbs = listfile.readlines()\n\t\n\tfor pdb in pdbs:\n\t\tpdbname = pdb.strip()\n\t\tif (addext):\n\t\t\tpdbname = pdb.strip() + '.pdb'\n\t\t\n\t\tcmd.load(pdbname)", "def table_collector(path...
[ "0.57001996", "0.5689761", "0.565364", "0.56203485", "0.55612475", "0.5559682", "0.5539606", "0.5530373", "0.5513971", "0.5467378", "0.54303205", "0.5418948", "0.5383131", "0.5382098", "0.5376149", "0.5364787", "0.5357825", "0.53471833", "0.53178245", "0.5315089", "0.5298326"...
0.72360516
0
Given a list of device paths, list log files from specified filesystem. Data is loaded based on the list of start datetimes
def list_log_files(fs, devices, start_times, verbose=True, passwords={}): import canedge_browser log_files = [] if len(start_times): for idx, device in enumerate(devices): start = start_times[idx] log_files_device = canedge_browser.get_log_files(fs, [device], start_date=sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_logs(self, log_format):\n # print(self.path)\n r, d, files = next(os.walk(self.path))\n # TODO use regex to find logs\n files = list(filter(lambda x: log_format in x, files))\n files = [os.path.join(r, f) for f in files]\n ctimes = [os.path.getctime(os.path.join(self.pa...
[ "0.6728006", "0.6695421", "0.6667964", "0.65992254", "0.6544616", "0.6534836", "0.6399142", "0.6344492", "0.6294777", "0.6196148", "0.6186986", "0.61749536", "0.6134531", "0.61090463", "0.5961263", "0.59397554", "0.5871865", "0.5811617", "0.58008575", "0.5787555", "0.57859534...
0.76617414
0
Rename Signal names by prefixing the full CAN ID (in hex) and/or J1939 PGN
def add_signal_prefix(df_phys, can_id_prefix=False, pgn_prefix=False, bus_prefix=False): from J1939_PGN import J1939_PGN if df_phys.empty: return df_phys else: prefix = "" if bus_prefix: prefix += df_phys["BusChannel"].apply(lambda x: f"{x}.") if can_id_pref...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mangle(signal):\n if type(signal) is list:\n return [mangle(s) for s in signal]\n else:\n (name, index) = signal\n return name + '_' + str.join('_', [str(x) for x in index])", "def _signal_to_common_name(signal: domain.Signal) -> str: # pragma: no cover\n stationb_map: domain.SIGNAL_MAP = {\n ...
[ "0.6341284", "0.618658", "0.58944404", "0.5803514", "0.56855726", "0.5682436", "0.5643482", "0.5629958", "0.56288826", "0.5605033", "0.5587481", "0.5485764", "0.54565454", "0.5455336", "0.5408659", "0.54004014", "0.53873926", "0.53735286", "0.53688616", "0.5349927", "0.534874...
0.63069767
1
Illustrative example for how to extract a signal and evaluate statistical values vs. defined thresholds. The function can be easily modified for your needs.
def test_signal_threshold(df_phys, signal, threshold): df_signal = df_phys[df_phys["Signal"] == signal]["Physical Value"] stats = df_signal.agg(["count", "min", "max", "mean", "std"]) delta = stats["max"] - stats["min"] if delta > threshold: print(f"{signal} exhibits a 'max - min' delta of {de...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signal_significance(\n y_true, y_proba, sig2incl_ratio, threshold=None, sample_weight=None\n):\n fpr, tpr, thresholds = roc_curve(y_true, y_proba, sample_weight=sample_weight)\n n_bkg = (1 - sig2incl_ratio) * 100\n n_sig = sig2incl_ratio * 100\n B = n_bkg * fpr\n S = n_sig * tpr\n signific...
[ "0.61532384", "0.61456704", "0.6120584", "0.61185485", "0.60634893", "0.60165465", "0.59483373", "0.59300256", "0.5880095", "0.5865144", "0.58355635", "0.5829337", "0.5825964", "0.5804376", "0.57418394", "0.573643", "0.5662644", "0.56473243", "0.56338394", "0.5594367", "0.559...
0.6491543
0
Helper function for calculating a new signal based on two signals and a function. Returns a dataframe with the new signal name and physical values
def add_custom_sig(df_phys, signal1, signal2, function, new_signal): import pandas as pd try: s1 = df_phys[df_phys["Signal"] == signal1]["Physical Value"].rename(signal1) s2 = df_phys[df_phys["Signal"] == signal2]["Physical Value"].rename(signal2) df_new_sig = pd.merge_ordered( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_signals():\n x = np.linspace(390, 410, 200)\n doublet = [(399, 1), (401, 1)]\n y = add_signals(x, doublet, 1)\n X = np.array([x for x, _ in ADD_SIGNALS_DATASET])\n Y = np.array([y / 2 for _, y in ADD_SIGNALS_DATASET]) # scale to match\n print(y)\n print(Y)\n assert np.array_eq...
[ "0.55726427", "0.55375326", "0.54029214", "0.5381461", "0.53808427", "0.53580076", "0.5323321", "0.52420646", "0.5232329", "0.5229146", "0.5227639", "0.5204138", "0.5184703", "0.51758593", "0.51096946", "0.5088613", "0.5079434", "0.50712466", "0.5067344", "0.5062894", "0.5003...
0.76016694
0
Given df of raw data and list of decoding databases, create new def with physical values (no duplicate signals and optionally filtered/rebaselined)
def extract_phys(self, df_raw): import can_decoder import pandas as pd df_phys = pd.DataFrame() df_phys_temp = [] for db in self.db_list: df_decoder = can_decoder.DataFrameDecoder(db) for bus, bus_group in df_raw.groupby("BusChannel"): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_FEMA_P58_bldg_redtag_db(\n source_file,\n target_data_file='bldg_redtag_DB_FEMA_P58_2nd.csv',\n target_meta_file='bldg_redtag_DB_FEMA_P58_2nd.json'):\n\n # parse the source file\n df = pd.read_excel(source_file, sheet_name='Summary', header=2, index_col=1,\n ...
[ "0.59248036", "0.5922244", "0.5877572", "0.5856754", "0.5853021", "0.5813514", "0.58091724", "0.574842", "0.565548", "0.5630156", "0.56003445", "0.5574408", "0.557013", "0.5540441", "0.5514523", "0.55128217", "0.5479409", "0.5468362", "0.54644877", "0.5457218", "0.54571164", ...
0.62812114
0
Given a df of physical values, this offsets the timestamp to be equal to today, minus a given number of days.
def rebaseline_data(self, df_phys): from datetime import datetime, timezone import pandas as pd delta_days = (datetime.now(timezone.utc) - df_phys.index.min()).days - self.days_offset df_phys.index = df_phys.index + pd.Timedelta(delta_days, "day") return df_phys
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def daily_returns(self, df):\n daily_returns = df.copy()\n daily_returns[1:] = (df[1:] / df[:-1].values) - 1\n daily_returns.ix[0] = 0\n return daily_returns", "def align_index_to_local_cdays(self):\n self.setup_class()\n date_range = pd.date_range(start=self.tsdf.first_...
[ "0.5707972", "0.55130273", "0.53883445", "0.52876997", "0.52724236", "0.52668387", "0.52399904", "0.5213567", "0.5184036", "0.51482123", "0.5135267", "0.5123454", "0.5121073", "0.5113842", "0.5008443", "0.5001906", "0.49927956", "0.49903804", "0.49891898", "0.49804872", "0.49...
0.6362852
0
Given a df of physical values, return only signals matched by filter
def filter_signals(self, df_phys): if not df_phys.empty and len(self.signals): df_phys = df_phys[df_phys["Signal"].isin(self.signals)] return df_phys
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mut_filter(df, rate, binary_cutoff=12):\n get_min_count = lambda s: s.value_counts().min() if len(s.unique()) > 1 else -1\n df = df[df.apply(get_min_count, axis=1) > binary_cutoff]\n cc = H.screen_feature(rate, rev_kruskal, df)\n\n fc_apply = lambda s: fc(s, rate)\n direction = df.apply(fc_apply...
[ "0.64054054", "0.6110009", "0.60705125", "0.59736735", "0.5903753", "0.58663183", "0.5819775", "0.57466286", "0.57170045", "0.5706719", "0.56877935", "0.567983", "0.5672527", "0.5629999", "0.5559911", "0.5537252", "0.55131197", "0.54510593", "0.54250556", "0.54237044", "0.542...
0.71506196
0
Extract a df of raw data and device ID from log file. Optionally include LIN bus data by setting lin=True
def get_raw_data(self, log_file, passwords={},lin=False): import mdf_iter with self.fs.open(log_file, "rb") as handle: mdf_file = mdf_iter.MdfFile(handle, passwords=passwords) device_id = self.get_device_id(mdf_file) if lin: df_raw_lin = mdf_file.get...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_linelog():", "def hoomdlog(filename):\r\n\r\n data = pd.read_csv(filename, sep = '\\s+')\r\n return data", "def log_to_dataframe(log_file, regex, headers):\n log_messages = []\n linecount = 0\n\n with open(log_file, 'r') as fin:\n logs = fin.readlines()\n logs = [j.strip()...
[ "0.59124273", "0.587135", "0.57448095", "0.570323", "0.56453687", "0.5628275", "0.5556992", "0.5550915", "0.5534511", "0.5524232", "0.5510892", "0.54958004", "0.54886043", "0.5483201", "0.54807746", "0.54399705", "0.5434385", "0.5400373", "0.53594816", "0.5350207", "0.5348396...
0.75194466
0
function to map all of the stops and add popups to them showing the various values
def map(stop_id,base,future,colmn_per,colmn_per_str,colmn_diff,df,col_func,rad_func,lat,lon): #sets the map zoomed into san fran with a scale bar mapa = folium.Map([37.765, -122.45], zoom_start=13, tiles='cartodbpositron', control_scale = True) #set...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def demo_one_map():\n radii = [2, 5, 7.1, 0.3, 10]\n demo_1(radii)\n demo_2(radii)", "def create_popups(web_map, project_name, layer_names):\r\n if layer_names:\r\n for layer_name in layer_names:\r\n # popup\r\n feature_layer_popup(\r\n map_service_name='{}...
[ "0.5821836", "0.5777538", "0.55118066", "0.5333158", "0.53221834", "0.5259219", "0.5246929", "0.52346987", "0.523304", "0.5226837", "0.5213859", "0.5206291", "0.5205278", "0.5203672", "0.51721615", "0.5124725", "0.5114918", "0.50976086", "0.5096673", "0.5094198", "0.50739485"...
0.6849664
0
Computes the squareroot of the sum of the squares for the combined list of numbers in the args list
def sqrt_sum_of_squares(*args): out = 0.0 for arg in args: out += float(arg) * float(arg) return out ** 0.5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _root_sum_of_squares(list):\n return sum((el ** 2 for el in list)) ** (0.5)", "def lsquare_of_sums(inlist):\r\n s = sum(inlist)\r\n return float(s)*s", "def square_nums(number_list):", "def square(numbers):\n\n # Needs only one argument\n\n return numbers[0] ** 2", "def _square_rooted(x)...
[ "0.7207651", "0.70310223", "0.69647837", "0.6624666", "0.6612508", "0.659189", "0.6584653", "0.65279794", "0.6487088", "0.645869", "0.63872254", "0.63788384", "0.6244868", "0.6227605", "0.62028605", "0.6177799", "0.6174678", "0.6172443", "0.6172443", "0.6172443", "0.6172443",...
0.78436637
0