query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns the number of milliseconds for the given number of jiffies (a weird timing unit used the kernel).
def calculate_time_ms(self, jiffies): return int((jiffies * 1000.0) / self._jiffies_per_sec)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __calculate_time_cs(self, jiffies):\n\n return int((jiffies * 100.0) / self._jiffies_per_sec)", "def jiffies(_load_time=time.time()):\n return int(100*(time.time()-_load_time))", "def millis(): \n return int(round(monotonic.monotonic() * C.MILLISECONDS))", "def millis(): \r\n re...
[ "0.73772615", "0.7025039", "0.6870207", "0.6851476", "0.6639381", "0.6579558", "0.6533067", "0.63947713", "0.6242466", "0.61780435", "0.6164305", "0.6149434", "0.61466753", "0.6125577", "0.61053866", "0.6076043", "0.6049589", "0.60407495", "0.60054356", "0.59866726", "0.59761...
0.82893556
0
Returns the number of milliseconds the system has been up.
def __get_uptime_ms(self): if self._boot_time_ms is None: # We read /proc/uptime once to get the current boot time. uptime_file = None try: uptime_file = open("/proc/uptime", "r") # The first number in the file is the number of seconds since # boot time. So, we just use that to calculate the milliseconds # past epoch. self._boot_time_ms = int(time.time()) * 1000 - int( float(uptime_file.readline().split()[0]) * 1000.0 ) finally: if uptime_file is not None: uptime_file.close() # Calculate the uptime by just taking current time and subtracting out # the boot time. return int(time.time()) * 1000 - self._boot_time_ms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sys_up_time():\n\n with open('/proc/uptime', 'r') as f:\n uptime_seconds = float(f.readline().split()[0])\n return int(uptime_seconds)", "def getUpTime(self):\n return self.__upTime + time() - self.__fingerTime", "def uptime(self):\n return self._call_txtrader_api('up...
[ "0.76271576", "0.74804974", "0.7351499", "0.7336892", "0.7335807", "0.7160131", "0.6963318", "0.69100386", "0.68876153", "0.6848875", "0.67855483", "0.67283034", "0.67062175", "0.6680035", "0.6660014", "0.66218805", "0.66216844", "0.6590366", "0.6590068", "0.6582871", "0.6569...
0.74130756
2
Gathers the metrics from the stat file.
def gather_sample(self, stat_file, collector=None): if not collector: collector = {} # The file format is just a single line of all the fields. line = stat_file.readlines()[0] # Chop off first part which is the pid and executable file. The # executable file is terminated with a paren so just search for that. line = line[(line.find(") ") + 2) :] fields = line.split() # Then the fields we want are just at fixed field positions in the # string. Just grab them. # See http://man7.org/linux/man-pages/man5/proc.5.html for reference on field numbers # Keep in mind that we chop first 3 values away (pid, command line, state), so you need to # subtract 3 from the field numbers from the man page (e.g. on the man page nice is number # 19, but in our case it's 16 aka 19 - 3) process_uptime = self.__get_uptime_ms() - self.calculate_time_ms( int(fields[19]) ) collector.update( { Metric("app.cpu", "user"): self.__calculate_time_cs(int(fields[11])), Metric("app.cpu", "system"): self.__calculate_time_cs(int(fields[12])), Metric("app.uptime", None): process_uptime, Metric("app.nice", None): float(fields[16]), Metric("app.threads", None): int(fields[17]), Metric("app.mem.majflt", None): int(fields[9]), Metric("app.io.wait", None): int(fields[39]) if len(fields) >= 39 else 0, } ) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gather_sample(self, stat_file, collector=None):\n\n if not collector:\n collector = {}\n\n for line in stat_file:\n # Each line has a format of:\n # Tag: Value\n #\n # We parse out all lines looking like that and match the stats we care about...
[ "0.6764025", "0.67190164", "0.6688609", "0.65135384", "0.6446264", "0.6374985", "0.63547957", "0.6333468", "0.63260734", "0.6261242", "0.6237093", "0.6232534", "0.61950576", "0.618388", "0.6182165", "0.6152383", "0.6111384", "0.6086403", "0.6057407", "0.6038634", "0.60113156"...
0.7137697
0
Gathers the metrics from the status file.
def gather_sample(self, stat_file, collector=None): if not collector: collector = {} for line in stat_file: # Each line has a format of: # Tag: Value # # We parse out all lines looking like that and match the stats we care about. m = re.search(r"^(\w+):\s*(\d+)", line) if m is None: continue field_name = m.group(1) int_value = int(m.group(2)) # FDSize is not the same as the number of open file descriptors. Disable # for now. # if field_name == "FDSize": # self.print_sample("app.fd", int_value) if field_name == "VmSize": collector.update({Metric("app.mem.bytes", "vmsize"): int_value * 1024}) elif field_name == "VmPeak": collector.update( {Metric("app.mem.bytes", "peak_vmsize"): int_value * 1024} ) elif field_name == "VmRSS": collector.update( {Metric("app.mem.bytes", "resident"): int_value * 1024} ) elif field_name == "VmHWM": collector.update( {Metric("app.mem.bytes", "peak_resident"): int_value * 1024} ) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_status(self):\n\n # Memory information can be found in status and statm /proc/PID files\n # status file VmRSS equivalent to top's RES column\n # statm disagrees with status VmRSS, I think it may not include\n # sub-processes\n # From: man proc\n # * VmPeak...
[ "0.6695974", "0.6339612", "0.6311073", "0.62527573", "0.6087654", "0.60828906", "0.60479605", "0.5964161", "0.5951921", "0.5916135", "0.5879056", "0.5801343", "0.5773241", "0.57671124", "0.57634276", "0.5756819", "0.5740762", "0.5738426", "0.5729482", "0.57033396", "0.5692026...
0.5690548
21
Gathers the metrics from the io file.
def gather_sample(self, stat_file, collector=None): if not collector: collector = {} # File format is single value per line with "fieldname:" prefix. for x in stat_file: fields = x.split() if len(fields) == 0: continue if not collector: collector = {} if fields[0] == "rchar:": collector.update({Metric("app.disk.bytes", "read"): int(fields[1])}) elif fields[0] == "syscr:": collector.update({Metric("app.disk.requests", "read"): int(fields[1])}) elif fields[0] == "wchar:": collector.update({Metric("app.disk.bytes", "write"): int(fields[1])}) elif fields[0] == "syscw:": collector.update({Metric("app.disk.requests", "write"): int(fields[1])}) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_metrics_file(self):\n\n with open(self.metrics_path, \"w+\") as f_metrics:\n\n f_metrics.write(get_metrics_file_form())", "def read_metrics(self):\n raise NotImplementedError()", "def emit_metrics(self):\n parse_time = time.perf_counter() - self._parsing_start_time\n ...
[ "0.69621795", "0.6846196", "0.5868116", "0.5818642", "0.58145773", "0.569007", "0.553364", "0.55294347", "0.5510199", "0.5496143", "0.5489615", "0.54809064", "0.5451518", "0.54069734", "0.54033786", "0.5399427", "0.5393153", "0.538728", "0.5384428", "0.5374179", "0.53578675",...
0.5644732
6
Gathers the metrics from the netstate file.
def gather_sample(self, stat_file, collector=None): # This file format is weird. Each set of stats is outputted in two # lines. First, a header line that list the field names. Then a # a value line where each value is specified in the appropriate column. # You have to match the column name from the header line to determine # what that column's value is. Also, each pair of lines is prefixed # with the same name to make it clear they are tied together. all_lines = stat_file.readlines() # We will create an array of all of the column names in field_names # and all of the corresponding values in field_values. field_names = [] field_values = [] # To simplify the stats, we add together the two forms of retransmit # I could find in the netstats. Those to fast retransmit Reno and those # to selective Ack. retransmits = 0 found_retransmit_metric = False # Read over lines, looking at adjacent lines. If their row names match, # then append their column names and values to field_names # and field_values. This will break if the two rows are not adjacent # but I do not think that happens in practice. If it does, we just # won't report the stats. for i in range(0, len(all_lines) - 1): names_split = all_lines[i].split() values_split = all_lines[i + 1].split() # Check the row names are the same. if names_split[0] == values_split[0] and len(names_split) == len( values_split ): field_names.extend(names_split) field_values.extend(values_split) if not collector: collector = {} # Now go back and look for the actual stats we care about. for i in range(0, len(field_names)): if field_names[i] == "InOctets": collector.update({Metric("app.net.bytes", "in"): field_values[i]}) elif field_names[i] == "OutOctets": collector.update({Metric("app.net.bytes", "out"): field_values[i]}) elif field_names[i] == "TCPRenoRecovery": retransmits += int(field_values[i]) found_retransmit_metric = True elif field_names[i] == "TCPSackRecovery": retransmits += int(field_values[i]) found_retransmit_metric = True # If we found both forms of retransmit, add them up. if found_retransmit_metric: collector.update({Metric("app.net.tcp_retransmits", None): retransmits}) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_metrics(self):\n raise NotImplementedError()", "def gather_sample(self, stat_file, collector=None):\n\n if not collector:\n collector = {}\n\n for line in stat_file:\n # We just look for the different \"inuse\" lines and output their\n # socket type ...
[ "0.59211487", "0.5842457", "0.5809869", "0.5712683", "0.5633532", "0.56009007", "0.55989665", "0.5477207", "0.54482716", "0.5303792", "0.5302852", "0.5279958", "0.52649426", "0.5263945", "0.52634865", "0.5221303", "0.5212169", "0.52069163", "0.5195175", "0.5184402", "0.518232...
0.56973577
4
Gathers the metrics from the sockstat file.
def gather_sample(self, stat_file, collector=None): if not collector: collector = {} for line in stat_file: # We just look for the different "inuse" lines and output their # socket type along with the count. m = re.search(r"(\w+): inuse (\d+)", line) if m is not None: collector.update( { Metric("app.net.sockets_in_use", m.group(1).lower()): int( m.group(2) ) } ) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gather_sample(self, stat_file, collector=None):\n\n # This file format is weird. Each set of stats is outputted in two\n # lines. First, a header line that list the field names. Then a\n # a value line where each value is specified in the appropriate column.\n # You have to match...
[ "0.6393384", "0.6306739", "0.60562605", "0.6037875", "0.597491", "0.59416795", "0.5933875", "0.5916901", "0.57845867", "0.577276", "0.5749845", "0.571024", "0.5700701", "0.56980515", "0.5637241", "0.5629849", "0.56119055", "0.55269897", "0.5518267", "0.55144465", "0.5510193",...
0.71067053
0
Collects the metrics from the gathers
def collect(self): collector = {} for gather in self.gathers: try: stats = gather.run_single_cycle(collector=collector) if stats: collector.update(stats) except Exception as ex: self._logger.exception( "Exception while collecting metrics for PID: %s of type: %s. Details: %s", self.pid, type(gather), repr(ex), ) return collector
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect(self): # pylint: disable=no-self-use\n start = time.time()\n for metric in metric_rq():\n yield metric\n\n gauge = GaugeMetricFamily(\n \"nautobot_rq_metrics_processing_ms\", \"Time in ms to generate the app metrics endpoint\"\n )\n duration = t...
[ "0.6958763", "0.69119155", "0.68189895", "0.66842306", "0.66356134", "0.6568736", "0.6555862", "0.6482938", "0.64655095", "0.64260054", "0.641891", "0.63836133", "0.63763535", "0.62167543", "0.62135196", "0.62097865", "0.6177793", "0.61742324", "0.61667204", "0.61239713", "0....
0.7913655
0
Return the process of the agent.
def current_process(self): return self._current_process
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _launchAgentProcess( self ):\n return subprocess.Popen( [ sys.executable, os.path.join( sys.path[0], 'agentProcess.py' ), str( _processPid ) ], stdin=subprocess.PIPE, stdout=subprocess.PIPE )", "def get_process(self, pid):\n return self.processes.get(pid, None)", "def get_my_process():\n r...
[ "0.69227177", "0.68076235", "0.66409147", "0.65917194", "0.6577045", "0.65301675", "0.6481512", "0.6463723", "0.6425003", "0.639765", "0.6345163", "0.6329305", "0.63107604", "0.63107604", "0.6309831", "0.6220328", "0.6186098", "0.61813504", "0.6084275", "0.6083225", "0.605136...
0.69763553
0
Given a string, match the processes on the name
def get_matches_commandline(self, match_pattern): matches = [] for _process in self.processes: if re.search(match_pattern, _process["cmd"]): matches.append(_process["pid"]) return matches
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ps_find(name):\n for proc in psutil.process_iter():\n if proc.name() == name:\n return True\n return False", "def findPIDs(name, user = os.getpid()):\n\n pids = []\n\n ps = subprocess.Popen(['ps', '-u', user, 'w'], stdout=subprocess.PIPE).communicate()[0]\n processes = ps.spl...
[ "0.67669374", "0.6710715", "0.66695976", "0.64684063", "0.64647824", "0.6255509", "0.60690784", "0.6056705", "0.60546", "0.595144", "0.59447294", "0.5906793", "0.5887537", "0.58319217", "0.58199763", "0.57570976", "0.5753294", "0.572602", "0.57223743", "0.5722138", "0.5618653...
0.611642
6
Given a process id, return all children processes (recursively)
def get_child_processes(self, ppid): all_children = [] children_to_explore = set() for _pid in self.parent_to_children_map[ppid]: all_children.append(_pid) children_to_explore.add(_pid) # get the children 'recursively' while children_to_explore: # the invariant child_to_explore = children_to_explore.pop() if not self.parent_to_children_map.get(child_to_explore): continue unvisited = self.parent_to_children_map[child_to_explore] for node in unvisited: if node not in all_children: children_to_explore.add(node) all_children.append(node) return list(set(all_children))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_children(ppid):\n\n pid_dct = {}\n for proc in build_process_list():\n proc[\"_children\"] = []\n pid_dct[proc[\"pid\"]] = proc\n\n # fill in children array\n for pid in list(pid_dct.keys()):\n parent_pid = pid_dct[pid][\"parent_pid\"]\n\n if parent_pid in pid_dct:\n...
[ "0.8440308", "0.78711176", "0.7738845", "0.73896194", "0.73563373", "0.7110651", "0.6810038", "0.66680056", "0.651955", "0.6309715", "0.62305254", "0.603989", "0.59731925", "0.5933038", "0.5905366", "0.5880942", "0.5819915", "0.57845265", "0.5777258", "0.5750268", "0.574295",...
0.7898279
1
Returns a list of all running process ids
def get_running_processes(self): all_processes = [] for _process in self.processes: all_processes.append(_process["pid"]) return all_processes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pid_list():\r\n pids = [int(x) for x in os.listdir('/proc') if x.isdigit()]\r\n return pids", "def pids(self):\n return self._pidToProcess.iterkeys()", "def running_procs(self) -> List[int]:\n return [p.model_id for p in self.primary_scheduler.queue_nodes.run_q]", "def getActivePr...
[ "0.7804924", "0.7730347", "0.7697995", "0.7590113", "0.7520795", "0.7483522", "0.7411062", "0.7385953", "0.7380598", "0.73299384", "0.73251057", "0.7316895", "0.7233392", "0.7152342", "0.71504444", "0.71448386", "0.7116604", "0.7027047", "0.69536257", "0.6934355", "0.6899609"...
0.813076
0
Like get_matches_commandline method, given a string, match the processes on the name but also returns the matched processes' children
def get_matches_commandline_with_children(self, match_pattern): matched_pids = self.get_matches_commandline(match_pattern) for matched_pid in matched_pids: matched_pids.extend(self.get_child_processes(matched_pid)) return list(set(matched_pids))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matches_commandline(self, match_pattern):\n\n matches = []\n for _process in self.processes:\n if re.search(match_pattern, _process[\"cmd\"]):\n matches.append(_process[\"pid\"])\n return matches", "def find(name, arg=None):\r\n for p in get_processes():\...
[ "0.69588715", "0.63922125", "0.61809975", "0.6156374", "0.6085242", "0.602419", "0.59251225", "0.5850459", "0.58301437", "0.58174837", "0.58165544", "0.5804579", "0.58037686", "0.57153285", "0.56987065", "0.5696199", "0.5649648", "0.5642261", "0.55726624", "0.5563265", "0.555...
0.75858635
0
For a process, record the metrics in a historical metrics collector Collects the historical result of each metric per process in __metrics_history
def record_metrics(self, pid, metrics): for _metric, _metric_value in metrics.items(): if not self.__metrics_history[pid].get(_metric): self.__metrics_history[pid][_metric] = [] self.__metrics_history[pid][_metric].append(_metric_value) # only keep the last 2 running history for any metric self.__metrics_history[pid][_metric] = self.__metrics_history[pid][_metric][ -2: ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_aggregated_metrics(self):\n\n # using the historical values, calculate the aggregate\n # there are two kinds of metrics:\n # a) cumulative metrics - only the delta of the last 2 recorded values is used (eg cpu cycles)\n # b) absolute metrics - the last absolute value is u...
[ "0.6638309", "0.61203325", "0.6019831", "0.59060955", "0.59058285", "0.55844504", "0.54852", "0.54657155", "0.53771794", "0.53647846", "0.5356617", "0.5345713", "0.5341496", "0.53098404", "0.52967745", "0.5279151", "0.5278557", "0.52188367", "0.52059686", "0.51821625", "0.517...
0.7013191
0
At the beginning of each process metric calculation, the absolute (noncumulative) metrics need to be overwritten to the combined process(es) result. Only the cumulative metrics need the previous value to calculate delta. We should set the absolute metric to 0 in the beginning of this "epoch"
def _reset_absolute_metrics(self): for pid, process_metrics in self.__metrics_history.items(): for _metric, _metric_values in process_metrics.items(): if not _metric.is_cumulative: self.__aggregated_metrics[_metric] = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_aggregated_metrics(self):\n\n # using the historical values, calculate the aggregate\n # there are two kinds of metrics:\n # a) cumulative metrics - only the delta of the last 2 recorded values is used (eg cpu cycles)\n # b) absolute metrics - the last absolute value is u...
[ "0.66141224", "0.5771144", "0.57508063", "0.5575068", "0.5574594", "0.55501413", "0.5535069", "0.54281497", "0.53845894", "0.535291", "0.5337103", "0.5333742", "0.5300862", "0.5274768", "0.5269434", "0.52690667", "0.52612674", "0.5259409", "0.52576226", "0.5246559", "0.524457...
0.75371194
0
Calculates the aggregated metric values based on the current running processes and the historical metric record
def _calculate_aggregated_metrics(self): # using the historical values, calculate the aggregate # there are two kinds of metrics: # a) cumulative metrics - only the delta of the last 2 recorded values is used (eg cpu cycles) # b) absolute metrics - the last absolute value is used running_pids_set = set(self.__pids) for pid, process_metrics in self.__metrics_history.items(): for _metric, _metric_values in process_metrics.items(): if not self.__aggregated_metrics.get(_metric): self.__aggregated_metrics[_metric] = 0 if _metric.is_cumulative: if pid in running_pids_set: if len(_metric_values) > 1: # only report the cumulative metrics for more than one sample self.__aggregated_metrics[_metric] += ( _metric_values[-1] - _metric_values[-2] ) else: if pid in running_pids_set: # absolute metric - accumulate the last reported value self.__aggregated_metrics[_metric] += _metric_values[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_metrics(self):\n pass", "def _reset_absolute_metrics(self):\n\n for pid, process_metrics in self.__metrics_history.items():\n for _metric, _metric_values in process_metrics.items():\n if not _metric.is_cumulative:\n self.__aggregated_metrics[...
[ "0.65272045", "0.6503945", "0.6044549", "0.5962655", "0.5960727", "0.5932751", "0.58754987", "0.5782237", "0.5775919", "0.5757956", "0.57359225", "0.57347035", "0.5726887", "0.57170856", "0.57170856", "0.56863284", "0.56776404", "0.56517655", "0.56427175", "0.5625753", "0.561...
0.8260474
0
Collect the perprocess tracker for the monitored process(es).
def gather_sample(self): for _pid in self._select_processes(): if not self.__trackers.get(_pid): self.__trackers[_pid] = ProcessTracker(_pid, self._logger, self.__id) self._reset_absolute_metrics() for _tracker in self.__trackers.values(): _metrics = _tracker.collect() self.record_metrics(_tracker.pid, _metrics) self._calculate_aggregated_metrics() self._remove_dead_processes() self.print_metrics()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _proc_collect(self) -> None:\n while True:\n self.process_num_threads.set(self._process.num_threads())\n self.process_memory_bytes.set(self._process.memory_info().rss)\n self.process_cpu_percent.set(self._process.cpu_percent())\n\n sleep(self.process_scrape_in...
[ "0.70074445", "0.70008403", "0.65227914", "0.6477468", "0.64733964", "0.6447299", "0.64127636", "0.6285023", "0.6207518", "0.6167097", "0.6145146", "0.61055756", "0.6044723", "0.6031808", "0.5893498", "0.58866787", "0.58456194", "0.5834667", "0.5807094", "0.5745234", "0.57324...
0.7125841
0
Returns true if the current process is still running.
def __is_running(pid): try: # signal flag 0 does not actually try to kill the process but does an error # check that is useful to see if a process is still running. os.kill(pid, 0) return True except OSError as e: # Errno #3 corresponds to the process not running. We could get # other errors like this process does not have permission to send # a signal to self.pid. But, if that error is returned to us, we # know the process is running at least, so we ignore the error. return e.errno != errno.ESRCH
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_running(self):\r\n if self._gone:\r\n return False\r\n try:\r\n # Checking if pid is alive is not enough as the pid might\r\n # have been reused by another process.\r\n # pid + creation time, on the other hand, is supposed to\r\n # identif...
[ "0.8082826", "0.8080181", "0.8026835", "0.8013894", "0.8012157", "0.7952827", "0.78069186", "0.77576995", "0.7746866", "0.77379435", "0.7681154", "0.76794994", "0.7676883", "0.76404685", "0.7629628", "0.76252586", "0.75991505", "0.7584161", "0.75792927", "0.75562996", "0.7544...
0.7129584
59
Returns a list of the process ids of processes that fulfills the match criteria. This will either use the commandline matcher or the target pid to find the process. If no process is matched, an empty list is returned.
def _select_processes(self): # check if at least one process is running is_running = False for pid in self.__pids: if ProcessMonitor.__is_running(pid): is_running = True break # at least one process is running if is_running: if not self.__aggregate_multiple_processes: return self.__pids # aggregate metrics, check the last discovered time if ( self.__last_discovered and time.time() * 1000 - self.__last_discovered < self.__process_discovery_interval * 1000 ): return self.__pids ps = ProcessList() if self.__commandline_matcher: self.__last_discovered = time.time() * 1000 if self.__include_child_processes: matched_processes = ps.get_matches_commandline_with_children( self.__commandline_matcher ) else: matched_processes = ps.get_matches_commandline( self.__commandline_matcher ) self.__pids = matched_processes if not self.__aggregate_multiple_processes and len(self.__pids) > 1: # old behaviour where multiple processes were not supported for aggregation self._logger.warning( "Multiple processes match the command '%s'. Returning existing pid. " "You can turn on the multi process aggregation support by adding the " "aggregate_multiple_processes configuration to true" % self.__commandline_matcher, limit_once_per_x_secs=300, limit_key="linux-process-monitor-existing-pid", ) self.__pids = [self.__pids[0]] else: # See if the specified target pid is running. If so, then return it. # Special cases: # '$$' mean this process. # '$$TBD' mean that the PID of the target process has not been determined yet and it will be set later. pids = [] if self.__target_pids: for t_pid in self.__target_pids: if t_pid == "$$": t_pid = int(os.getpid()) # skip this until it will be replaced with a real PID. elif t_pid == "$$TBD": continue else: t_pid = int(t_pid) pids.append(t_pid) self.__pids = pids return self.__pids
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_matching_pids(pattern):\n cmd = [\"pgrep\", \"-f\", pattern]\n rc, output, err = run_cmd_output(cmd)\n if rc == 0:\n # One or more processes matched\n pids = [int(p) for p in output.split('\\n') if p != \"\"]\n elif rc == 1:\n # No processes matched\n pids = []\n ...
[ "0.7879332", "0.7805906", "0.7679771", "0.7294594", "0.70915145", "0.67127335", "0.6696709", "0.6683365", "0.6582418", "0.65806013", "0.64939845", "0.6404458", "0.63337654", "0.6324033", "0.6305915", "0.63057446", "0.6257686", "0.62433344", "0.6234016", "0.612377", "0.6083050...
0.72393227
4
Set the PID of the process that was marked as $$TBD.
def set_pid(self, pid): # type: (int) -> None for i in range(len(self.__target_pids)): if self.__target_pids[i] == "$$TBD": self.__target_pids[i] = pid break
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def def_pid(self,pid):\n self.pid=int(pid)", "def pid(self, pid):\n\n self._pid = pid", "def pid(self, pid):\n\n self._pid = pid", "def _update_PID(self):\n self.pid = PID(p=self.paramP, i=self.paramI, d=self.paramD, setpoint=self.voltageSetpoint, memory=self.paramMemory)", "def...
[ "0.6045698", "0.6005458", "0.6005458", "0.5414311", "0.5351061", "0.5235025", "0.5235025", "0.52202576", "0.52202576", "0.51928914", "0.51871926", "0.50754386", "0.5040368", "0.5033574", "0.49666995", "0.49178597", "0.49152836", "0.49008197", "0.4899533", "0.48833144", "0.488...
0.79088074
0
Infer class scores from the input image. This function defines the networks architecture.
def inference(self, image_rgb): s = image_rgb.get_shape().as_list() with tf.name_scope('image-preprocessing'): MEAN = [103.939, 116.779, 123.68] assert s[1:] == [227, 227, 3] red, green, blue = tf.split(image_rgb, 3, 3) bgr = tf.concat([ blue - MEAN[0], green - MEAN[1], red - MEAN[2], ], 3) # 1st Layer: Conv (w ReLu) -> Pool -> Lrn conv1 = conv(bgr, 11, 11, 96, 4, 4, padding='VALID', name='conv1') pool1 = max_pool(conv1, 3, 3, 2, 2, padding='VALID', name='pool1') norm1 = lrn(pool1, 2, 2e-05, 0.75, name='norm1') # 2nd Layer: Conv (w ReLu) -> Pool -> Lrn conv2 = conv(norm1, 5, 5, 256, 1, 1, name='conv2', groups=2) pool2 = max_pool(conv2, 3, 3, 2, 2, padding='VALID', name='pool2') norm2 = lrn(pool2, 2, 2e-05, 0.75, name='norm2') # 3rd Layer: Conv (w ReLu) conv3 = conv(norm2, 3, 3, 384, 1, 1, name='conv3') # 4th Layer: Conv (w ReLu) conv4 = conv(conv3, 3, 3, 384, 1, 1, name='conv4', groups=2) # 5th Layer: Conv (w ReLu) -> Pool conv5 = conv(conv4, 3, 3, 256, 1, 1, name='conv5', groups=2) pool5 = max_pool(conv5, 3, 3, 2, 2, padding='VALID', name='pool5') # 6th Layer: Flatten -> FC (w ReLu) -> Dropout flattened = tf.reshape(pool5, [-1, 6*6*256]) fc6 = fc(flattened, 6*6*256, 4096, name='fc6') dropout6 = dropout(fc6, self.KEEP_PROB) # 7th Layer: FC (w ReLu) -> Dropout fc7 = fc(dropout6, 4096, 4096, name='fc7') dropout7 = dropout(fc7, self.KEEP_PROB) # 8th Layer: FC and return unscaled activations (for tf.nn.softmax_cross_entropy_with_logits) score_imagenet_classes = fc(dropout7, 4096, 1000, relu=False, name='fc8') # New score layer for the new task (network is shared up to this point) score_retrained = fc(dropout7, 4096, self.NUM_CLASSES, relu=False, name='fc8_new') return score_imagenet_classes, score_retrained
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def classify_images():\n\n # Load the desired image\n img_path = 'dataset/colorize_images/n02085782_919.jpg'\n img = image.load_img(img_path, target_size=(299, 299))\n x = image.img_to_array(img)\n x = np.expand_dims(x, axis=0)\n x = preprocess_input(x)\n\n model = InceptionV3(weights=\"imagen...
[ "0.6846357", "0.658142", "0.6509911", "0.64659", "0.6432261", "0.6414406", "0.6399443", "0.6369863", "0.63570625", "0.6340332", "0.6332008", "0.6302619", "0.6292333", "0.6278609", "0.62669504", "0.6261403", "0.62539554", "0.62080777", "0.6207685", "0.61810887", "0.6176677", ...
0.0
-1
Return the count of the highest order model used.
def order(self): return self.n
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_last_order_number_used():\n return Order.__last_order_number_used", "def _get_top_models_to_improve(self):\n self._validate_top_models_to_improve()\n if self.top_models_to_improve == \"auto\":\n if self._get_mode() == \"Explain\":\n return 0\n if ...
[ "0.6919758", "0.64155287", "0.63922703", "0.6360874", "0.62786955", "0.622468", "0.61927", "0.6129268", "0.6083907", "0.60793793", "0.6077859", "0.5981426", "0.5938052", "0.57794553", "0.5749997", "0.57499874", "0.57459366", "0.573959", "0.5728474", "0.57043415", "0.57005787"...
0.0
-1
Get the probability of a word following a context. i.e. The conditional probability P(word|context)
def prob(self, word, context=None): if not context: context = () else: context = tuple(context) prob = 0 for i in range(len(context) + 1): prob += self.weights[i] * self.ngram_cpd[context[i:]][word] return prob
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prob(self, word, context):\n\n context = tuple(context)\n \n context_lenth = len(context) \n if context_lenth == 0:\n line = ''\n elif context_lenth == 1:\n line = context[0]\n elif context_lenth >= 2:\n line = context[0]\n f...
[ "0.8106743", "0.75592023", "0.74971807", "0.7463757", "0.7168955", "0.7168955", "0.7081482", "0.707541", "0.69993883", "0.69632804", "0.6952478", "0.6929444", "0.6909919", "0.67921746", "0.6687317", "0.6680557", "0.66741383", "0.66102266", "0.6583568", "0.6526557", "0.6460864...
0.8385041
0
Number of (nonbackground) categories. Returns int Number of (nonbackground) categories.
def num_class(self): return self._num_class
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_number_of_categories() -> List[int]:\n\n return [len(cats) for cats in wiki_data[\"categories\"]]", "def category_count(self, cat):\n res = self.con.execute('select count from cc where category=\"%s\"'\n %(cat)).fetchone()\n if res == None:\n return 0\n e...
[ "0.7708821", "0.7072953", "0.6978198", "0.64453894", "0.64185804", "0.6267535", "0.62063515", "0.61772865", "0.6093896", "0.60898095", "0.6053971", "0.6049354", "0.6049354", "0.60457516", "0.6007069", "0.59920245", "0.59676576", "0.5959858", "0.58949566", "0.58928066", "0.588...
0.0
-1
Return names of (nonbackground) categories. Returns iterable of str Names of (nonbackground) categories.
def classes(self): return self._classes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def category_names(self):\n return list(self.categories.keys())", "def category_names(self):\n return self._category_names", "def CategoryNames(self):\r\n return sorted(self.getSampleMetadata(self.SampleIds[0]).keys()) \\\r\n if len(self.SampleIds) > 0 else []", "def categorie...
[ "0.79573333", "0.7846303", "0.73073953", "0.7111364", "0.7110502", "0.70963407", "0.70941347", "0.7074836", "0.6971838", "0.6940362", "0.6827828", "0.68070495", "0.67111456", "0.66973966", "0.6610056", "0.6607805", "0.65921", "0.65612626", "0.6545443", "0.653917", "0.65071493...
0.0
-1
YOLOV3 network hybrid forward.
def hybrid_forward(self, F, x, *args): all_box_centers = [] all_box_scales = [] all_objectness = [] all_class_pred = [] all_anchors = [] all_offsets = [] all_feat_maps = [] all_detections = [] routes = [] for stage, block, output in zip(self.stages, self.yolo_blocks, self.yolo_outputs): x = stage(x) routes.append(x) # the YOLO output layers are used in reverse order, i.e., from very deep layers to shallow for i, block, output in zip(range(len(routes)), self.yolo_blocks, self.yolo_outputs): x, tip = block(x) if autograd.is_training(): dets, box_centers, box_scales, objness, class_pred, anchors, offsets = output(tip) all_box_centers.append(box_centers.reshape((0, -3, -1))) all_box_scales.append(box_scales.reshape((0, -3, -1))) all_objectness.append(objness.reshape((0, -3, -1))) all_class_pred.append(class_pred.reshape((0, -3, -1))) all_anchors.append(anchors) all_offsets.append(offsets) # here we use fake featmap to reduce memory consuption, only shape[2, 3] is used fake_featmap = F.zeros_like(tip.slice_axis( axis=0, begin=0, end=1).slice_axis(axis=1, begin=0, end=1)) all_feat_maps.append(fake_featmap) else: dets = output(tip) all_detections.append(dets) if i >= len(routes) - 1: break # add transition layers x = self.transitions[i](x) # upsample feature map reverse to shallow layers upsample = _upsample(x, stride=2) route_now = routes[::-1][i + 1] x = F.concat(F.slice_like(upsample, route_now * 0, axes=(2, 3)), route_now, dim=1) if autograd.is_training(): # during training, the network behaves differently since we don't need detection results if autograd.is_recording(): # generate losses and return them directly box_preds = F.concat(*all_detections, dim=1) all_preds = [F.concat(*p, dim=1) for p in [ all_objectness, all_box_centers, all_box_scales, all_class_pred]] all_targets = self._target_generator(box_preds, *args) return self._loss(*(all_preds + all_targets)) # return raw predictions, this is only used in DataLoader transform function. return (F.concat(*all_detections, dim=1), all_anchors, all_offsets, all_feat_maps, F.concat(*all_box_centers, dim=1), F.concat(*all_box_scales, dim=1), F.concat(*all_objectness, dim=1), F.concat(*all_class_pred, dim=1)) # concat all detection results from different stages result = F.concat(*all_detections, dim=1) # apply nms per class if self.nms_thresh > 0 and self.nms_thresh < 1: result = F.contrib.box_nms( result, overlap_thresh=self.nms_thresh, valid_thresh=0.01, topk=self.nms_topk, id_index=0, score_index=1, coord_start=2, force_suppress=False) if self.post_nms > 0: result = result.slice_axis(axis=1, begin=0, end=self.post_nms) ids = result.slice_axis(axis=-1, begin=0, end=1) scores = result.slice_axis(axis=-1, begin=1, end=2) bboxes = result.slice_axis(axis=-1, begin=2, end=None) return ids, scores, bboxes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x):\n for name, module in self.base._modules.items():\n if name == 'avgpool':\n break\n\n if name == 'layer3':\n l2 = Variable(x)\n\n x = Variable(module(x))\n l4 = Variable(x)\n\n \"\"\"for name, param in sel...
[ "0.65314513", "0.6292418", "0.6263829", "0.6261159", "0.62541807", "0.6251553", "0.6219152", "0.62162906", "0.61927277", "0.6178997", "0.6141839", "0.6136382", "0.6127676", "0.6119838", "0.6111306", "0.61022437", "0.6099669", "0.60930973", "0.60845137", "0.60679704", "0.60615...
0.7524717
0
Set nonmaximum suppression parameters.
def set_nms(self, nms_thresh=0.45, nms_topk=400, post_nms=100): self._clear_cached_op() self.nms_thresh = nms_thresh self.nms_topk = nms_topk self.post_nms = post_nms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_suppress_flow(self):\n self.suppressed = self.packet_count\n self.fcip.update_one({'hash': self.fcip_hash},\n {'$set': {'suppressed': self.suppressed},})", "def non_maxima_suppression(boxes, probs, classes_num, thr=0.2):\n for i, box in enumerate(boxes):\n ...
[ "0.5966529", "0.55709445", "0.55309284", "0.5446378", "0.5345884", "0.5345884", "0.5295788", "0.52417874", "0.5239064", "0.52170867", "0.52112365", "0.520788", "0.5186509", "0.51748765", "0.51727885", "0.5166071", "0.510891", "0.50601727", "0.5058307", "0.50549585", "0.504755...
0.59055877
1
Reset class categories and class predictors.
def reset_class(self, classes): self._clear_cached_op() self._classes = classes if self._pos_iou_thresh >= 1: self._target_generator = YOLOV3TargetMerger(len(classes), self._ignore_iou_thresh) for outputs in self.yolo_outputs: outputs.reset_class(classes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.pred_classes.clear()\n self.gold_classes.clear()\n self.pred_probas.clear()\n self.gold_probas.clear()\n self.loss = 0\n self.nb_batches = 0\n self.prec_rec_f1 = None\n self.acc = None\n self.mcc = None", "def reset(self):\n ...
[ "0.72172534", "0.6899433", "0.6748963", "0.6726632", "0.66773576", "0.6629043", "0.6529936", "0.6484326", "0.6478405", "0.6478405", "0.6471619", "0.6466328", "0.6457058", "0.62709737", "0.6202787", "0.61770207", "0.6149169", "0.612528", "0.60959744", "0.6091237", "0.6087531",...
0.70744306
1
YOLO3 multiscale with darknet53 base network on VOC dataset.
def yolo3_darknet53_voc(pretrained_base=True, pretrained=False, num_sync_bn_devices=-1, **kwargs): from ...data import VOCDetection pretrained_base = False if pretrained else pretrained_base base_net = darknet53( pretrained=pretrained_base, num_sync_bn_devices=num_sync_bn_devices, **kwargs) stages = [base_net.features[:15], base_net.features[15:24], base_net.features[24:]] anchors = [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]] strides = [8, 16, 32] classes = VOCDetection.CLASSES return get_yolov3( 'darknet53', stages, [512, 256, 128], anchors, strides, classes, 'voc', pretrained=pretrained, num_sync_bn_devices=num_sync_bn_devices, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n # TODO\n self.confThreshold = 0.6\n self.nmsThreshold = 0.5\n self.inpWidth = 320\n self.inpHeight = 320\n classesFile = \"/content/drive/My Drive/tracking_course/Detection/yolo_workshop/coco.names\"\n self.classes = None\n with open(cla...
[ "0.6369418", "0.6306215", "0.6232091", "0.6182974", "0.60732025", "0.5921903", "0.5916691", "0.5855269", "0.5853199", "0.5839653", "0.57973075", "0.5778595", "0.574271", "0.573733", "0.57194585", "0.5616862", "0.55473757", "0.5541811", "0.554155", "0.5500795", "0.5457074", ...
0.6497924
0
Update information about a host
def update(self, compute_node=None, service=None): @utils.synchronized((self.hostname, compute_node)) def _locked_update(self, compute_node, service): if compute_node is not None: LOG.debug('Update host state from compute node: %s', compute_node) self._update_from_compute_node(compute_node) if service is not None: LOG.debug('Update host state with service: %s', service) self.service = service return _locked_update(self, compute_node, service)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update(self, host):\n pass", "def update_host(self, conf, tenant_id, network_id, host_id, body):\n\t\tpass", "def update(self, host, values):\n body = dict(host=values)\n return self._update(\"/os-hosts/%s\" % host, body, response_key='host')", "def update(self, **kwargs):\n\n ...
[ "0.837656", "0.7654533", "0.71974707", "0.7100948", "0.69615793", "0.68412817", "0.67987186", "0.674337", "0.6699968", "0.6577405", "0.6523611", "0.6492715", "0.6492715", "0.63358724", "0.63345975", "0.62820405", "0.62123007", "0.62056744", "0.617595", "0.61610746", "0.616107...
0.0
-1
Update information about a host from a Compute object
def _update_from_compute_node(self, compute_node): if (self.updated and compute_node.updated_at and self.updated > compute_node.updated_at): return self.uuid = compute_node.rp_uuid self.mem_available = compute_node.mem_available self.mem_total = compute_node.mem_total self.mem_free = compute_node.mem_free self.mem_used = compute_node.mem_used self.cpus = compute_node.cpus self.cpu_used = compute_node.cpu_used self.disk_total = compute_node.disk_total self.disk_used = compute_node.disk_used self.numa_topology = compute_node.numa_topology self.labels = compute_node.labels self.pci_stats = pci_stats.PciDeviceStats( stats=compute_node.pci_device_pools) self.disk_quota_supported = compute_node.disk_quota_supported self.runtimes = compute_node.runtimes self.enable_cpu_pinning = compute_node.enable_cpu_pinning self.updated = compute_node.updated_at
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update(self, host):\n pass", "def update_host(self, conf, tenant_id, network_id, host_id, body):\n\t\tpass", "def update(self, **kwargs):\n\n host = self.get()\n if not host:\n self.raiseNotFoundError()\n return host.update(**kwargs)", "def update(self, host, value...
[ "0.7401245", "0.7244819", "0.67560756", "0.6739064", "0.63846487", "0.63500065", "0.6329535", "0.62974095", "0.61992675", "0.6124308", "0.60235953", "0.6017592", "0.598866", "0.5938988", "0.59209824", "0.58763146", "0.58476484", "0.5826684", "0.5826684", "0.582578", "0.573376...
0.5865002
16
Incrementally update host state from a Container object.
def consume_from_request(self, container): @utils.synchronized(self._lock_name) @set_update_time_on_success def _locked(self, container): # Scheduler API is inherently multi-threaded as every incoming RPC # message will be dispatched in its own green thread. So the # shared host state should be consumed in a consistent way to make # sure its data is valid under concurrent write operations. self._locked_consume_from_request(container) return _locked(self, container)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _increment(state: Dict, host: str = None) -> Dict:\n logger.info(f'view-count@{host}: {state[host] + 1}')\n\n return {\n **state,\n host: state[host] + 1\n }", "def _inc_counter(self) -> None:\n self._state_storage.increment_counter()", "def _update_container(self):\n c...
[ "0.6660293", "0.6045445", "0.561173", "0.5611655", "0.5515509", "0.54336005", "0.5417022", "0.5400421", "0.53642195", "0.53447664", "0.5336348", "0.5238454", "0.5179859", "0.5147485", "0.5103677", "0.5096942", "0.50933737", "0.50852305", "0.50512236", "0.50192106", "0.4984766...
0.0
-1
Set updated time of HostState when consuming succeed.
def set_update_time_on_success(function): @functools.wraps(function) def decorated_function(self, container): return_value = None try: return_value = function(self, container) except Exception as e: # Ignores exception raised from consume_from_request() so that # booting container would fail in the resource claim of compute # node, other suitable node may be chosen during scheduling retry. LOG.warning("Selected host: %(host)s failed to consume from " "container. Error: %(error)s", {'host': self.hostname, 'error': e}) else: self.updated = timeutils.utcnow() return return_value return decorated_function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host_up(self, host):\n with self.cond:\n if self.state is not None:\n LOG.warning(\"host_up called, but we think host is already up\")\n self._host_down()\n\n # Wait until all operations using a previous state generation are\n # complete bef...
[ "0.6223716", "0.61008537", "0.6037427", "0.5854355", "0.568859", "0.5629717", "0.56151396", "0.5608436", "0.5571809", "0.5568824", "0.55633", "0.5542896", "0.5542896", "0.5508925", "0.549049", "0.5477234", "0.5477234", "0.54645914", "0.54598725", "0.5455025", "0.54405177", ...
0.5197365
64
The uri returned from request.uri is not properly urlencoded (sometimes it's partially urldecoded) This is a weird hack to get werkzeug to return the proper urlencoded string uri
def _get_uri_from_request(request): uri = request.base_url if request.query_string: uri += '?' + request.query_string.decode('utf-8') return uri
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _urlnorm(self, uri):\r\n (scheme, authority, path, query, fragment) = parse_uri(uri)\r\n if not scheme or not authority:\r\n raise Exception(\"Only absolute URIs are allowed. uri = %s\" % uri)\r\n authority = authority.lower()\r\n scheme = scheme.lower()\r\n if not...
[ "0.67314285", "0.65002495", "0.6443756", "0.6264452", "0.6258882", "0.6235578", "0.6230169", "0.6225036", "0.61642367", "0.6159104", "0.61166435", "0.6091703", "0.60887986", "0.6040494", "0.602881", "0.6023126", "0.60162497", "0.6009078", "0.6009078", "0.5996785", "0.5991015"...
0.68531525
0
Defines, parses, checks, and returns command line arguments
def parse_arguments(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--adj', help=""".adj file regulon""", type=argparse.FileType(mode='r'), required=True) parser.add_argument('--expr_genes', help="""list of gene IDs in expression matrix (first column of expr matrix)""", type=argparse.FileType(mode='r'), required=True) # parser.add_argument('--cutoff_percent', help="""remove entire row (regulator plus genes) # if percent (out of 100) of genes remaining is below this value AND # genes remaining is below # the cutoff_number argument""", type=int, required=False, default=30) parser.add_argument('--cutoff_number', help=""""remove entire row (regulator plus regulon genes) if number of genes remaining is below this value, defaults to 25""", type=int, required=False, default=25) args = parser.parse_args() return args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def command_line_arguments():\n\n try:\n parser = argparse.ArgumentParser(description='Log Handler/Cleaner/Copier for Idemia DocAuth')\n\n # Add required arguments.\n parser.add_argument('action', choices=['clean', 'download'], type=str, help='clean or downlo...
[ "0.76032376", "0.7410202", "0.7344581", "0.7313167", "0.7288181", "0.7207524", "0.7184706", "0.71445954", "0.71318215", "0.7104654", "0.70891064", "0.70799434", "0.7070761", "0.7066492", "0.704149", "0.70361483", "0.7026928", "0.7025998", "0.70166886", "0.7002696", "0.7000962...
0.0
-1
Parse arguments, filter regulon, and print to stdout.
def main(): # get commmand line args args = parse_arguments() adj_file = args.adj # open("UCSC_VIPER/pathways/extended_pathways_transcriptional.adj", "r") # this set isn't actually used in the script, but I was curious... adj_gene_set = set() cutoff_number = args.cutoff_number #cutoff_percent = args.cutoff_percent expr_gene_file = args.expr_genes #open("stanford_batchK1-12.HUGO_only_genes.lst", 'r') expr_genes = [line.strip() for line in expr_gene_file] # for each line, check that the regulator and other genes are in the # expression matrix gene set. if not, remove them, or remove the whole # line if the regulator isn't in the set or if too few genes remain for line in adj_file: line_list = line.strip().split() regulator_plus_gene_list = [x for x in line_list if x !="1.0"] regulator = regulator_plus_gene_list[0] if regulator not in expr_genes: # remove the whole regulator + regulon print("Skipped a line (regulator not in expr genes): ", line_list[0], file=sys.stderr) continue gene_list = regulator_plus_gene_list[1:] list_size = len(gene_list) adj_gene_set.update(gene_list) how_many_to_remove= 0 good_genes = [] for gene in gene_list: if gene not in expr_genes: how_many_to_remove += 1 else: good_genes.append(gene) #print("\n") #pdb.set_trace() #if (100-how_many_to_remove/list_size*100 < cutoff_percent) and (list_size-how_many_to_remove < cutoff_number): if (list_size-how_many_to_remove < cutoff_number): print("Skipped a line (too many removed): ", line_list[0], file=sys.stderr) else: # re-generate the new line of the .adj file with kept genes #genes_to_print = good_genes.insert(0, regulator) regulated_genes = "\t1.0\t".join(good_genes) print(regulator+"\t"+regulated_genes+"\t1.0")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_filters():\n print('Hello! Let\\'s explore some US bikeshare data!')", "def main():\n filter_freq = 1.e4\n re_sample_freq = 1.e5\n glob_search = '*.log'\n\n # parse the command line arguments\n parser = argparse.ArgumentParser(description=\"Filters files in a directory based on a file e...
[ "0.6211614", "0.6186331", "0.6099759", "0.60936326", "0.60703206", "0.5910186", "0.5906957", "0.5856465", "0.5850204", "0.58114266", "0.577527", "0.5722053", "0.57207435", "0.56683946", "0.56594044", "0.5633427", "0.55837566", "0.5580852", "0.55734587", "0.5561661", "0.555925...
0.0
-1
Converts the Csv file into required data format for Time Series prediction
def preprocess(dataframe_csvpath, cols_x, cols_y, window_in, window_out, data_div_frac, popu_size): #Loading .CSV file and creating dataframe df = pd.read_csv(dataframe_csvpath) len_ser = len(df[df['Series_No'] == 1]) #randomly shuffle different series permute = np.random.permutation(range(1, len(set(df['Series_No'])))) train_series_seq = permute[: int(len(set(df['Series_No'])) * data_div_frac)] test_series_seq = permute[int( len(set(df['Series_No'])) * data_div_frac):] #taking relevent columns from dataframe df_x = df[cols_x] df_y = df[cols_y] #Innitialize empty lists which are later to be appended train_seq, test_seq = [], [] x_test = [] y_true =[] #Creating time series data for series_no in train_series_seq: #new dataframe variable assignment for particular series drom df_x, df_y series_df_x = df_x[df_x['Series_No'] == series_no] series_df_y = df_x[df_y['Series_No'] == series_no] #converting into numpy arrays array_x = np.array(series_df_x) array_y = np.array(series_df_y) #for loop to append to x_train y_train arrays according to window_in, window_out for idx in range(len(series_df_x) - window_in - window_out + 1): #'len(series_df_x) - window_in - window_out + 1' needs to be checked arrayx = array_x.copy() x = arrayx [idx:idx + window_in, : len(cols_x) - 1] #print(x) x[:,0:3] = x[:,0:3] / popu_size #print(x) arrayy = array_y.copy() y = arrayy[idx + window_in :idx + window_in + window_out, : len(cols_y) - 1] y = y / popu_size train_seq.append((x, y)) #out col_x and col_y has last item 'Series number' so to remove that [, : len(cols_x)] #y_train.append(array_y[idx + window_in :idx + window_in + window_out, : len(cols_y) - 1]) #print(train_seq) #repeat for test sequence for series_no in test_series_seq: #new dataframe variable assignment for particular series drom df_x, df_y series_df_x = df_x[df_x['Series_No'] == series_no] series_df_y = df_x[df_y['Series_No'] == series_no] #converting into numpy arrays array_x = np.array(series_df_x) array_y = np.array(series_df_y) #for loop to append to x_train y_train arrays according to window_in, window_out for idx in range(len(series_df_x) - window_in - window_out + 1): #'len(series_df_x) - window_in - window_out + 1' needs to be checked arrayx = array_x.copy() x = arrayx[idx:idx + window_in, : len(cols_x) - 1] x[:,0:3] = x[:,0:3] / popu_size x_test.append(x) arrayy = array_y.copy() y = arrayy[idx + window_in :idx + window_in + window_out, : len(cols_y) - 1] y = y / popu_size y_true.append(y) test_seq.append((x, y)) #test_seq.append((array_x[idx:idx + window_in, : len(cols_x) - 1], array_y[idx + window_in :idx + window_in + window_out, : len(cols_y) - 1])) #out col_x and col_y has last item 'Series number' so to remove that [, : len(cols_x)] #y_test.append(array_y[idx + window_in :idx + window_in + window_out, : len(cols_y) - 1]) win_len_per_ser = len_ser - window_in - window_out + 1 return np.array(train_seq), np.array(test_seq), len_ser, win_len_per_ser, np.array(x_test), np.array(y_true)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_training_data(self, csv_path):\n data = pd.read_csv(csv_path)\n data[['Hashrate', 'Addresses', 'Supply', 'Trx_Fee', 'Daily_Trx']] = data[['Hashrate', 'Addresses', 'Supply', 'Trx_Fee', 'Daily_Trx']].apply(pd.to_numeric)\n data[['Timestamp']] = data[['Timestamp']].apply(pd.to_datetime)\n...
[ "0.6448471", "0.64109224", "0.63845986", "0.6249481", "0.6204732", "0.6172775", "0.6129716", "0.61131644", "0.6100166", "0.6092652", "0.6074208", "0.60713947", "0.6030789", "0.6018793", "0.60126376", "0.59962356", "0.59944284", "0.5981371", "0.5959057", "0.5953626", "0.593562...
0.0
-1
Visualize a particular column of Y_pred anf Y_test for a particular series
def visualize_data(y_test, x_test, window_out, num_plots, num_win_ser, cols_y, col_idx): ser_idx = [i for i in range(0, len(y_test), num_win_ser)] if num_plots > len(ser_idx): print("Too many plots, reduce the mumber") else: indx = ser_idx[0:num_plots] days = range(num_win_ser) for idx in indx: CR = x_test[idx][0][3] #pred = y_pred[idx : idx+num_win_ser, window_out -1, col_idx] true = y_test[idx : idx+num_win_ser, window_out -1, col_idx] plt.title("Y_True, CR: "+ str(CR)) plt.xlabel('Days') plt.ylabel(cols_y[col_idx]) #plt.plot(days, pred, label = 'Pred') plt.plot(days, true, label = 'True') plt.legend() plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visualize_pred(y_test, y_pred, test_seq, window_out, num_plots, num_win_ser, cols_y, col_idx):\n \n \n ser_idx = [i for i in range(0, len(y_test), num_win_ser)]\n if num_plots > len(ser_idx):\n print(\"Too many plots, reduce the mumber\")\n else:\n indx = ser_idx[0:num_plots]\n ...
[ "0.6890531", "0.65764153", "0.6521914", "0.6249297", "0.61620384", "0.61183745", "0.60831374", "0.60805416", "0.60410786", "0.6039407", "0.60239905", "0.6023398", "0.6006061", "0.5991418", "0.5943231", "0.593769", "0.59314346", "0.59314346", "0.5888226", "0.58814496", "0.5877...
0.6406863
3
Makes Predictions for time series data using the model trained.
def predictions(loader, model, win_len_per_ser, criterion, device, window_out = 1 ): model.eval() num_win_per_ser = win_len_per_ser #num windows #print(num_win_per_ser) y_pred = [] y_true = [] with torch.no_grad(): for idx, (x, y) in enumerate(loader): #for i in range(0, len(y_test), num_win_per_ser): # i takes index values of first windows of different series win_start = torch.tensor(x[0]).float().to(device) # saving the first window of each series #print('win_start:', win_start) CR = win_start[0][3] # saving the CR value for particular series -> to be used for prediction #print('CR:', CR) win = win_start # window variable which will be updated for new windows, takes first value as the starting window #print(win) win = win.reshape((1, win.shape[0], win.shape[1])) #print(win.shape) for j in range(num_win_per_ser): # prediction loop y_hat = model(win) # predicting values wrt win variable #print('y_hat ', y_hat) y_pred.append(y_hat[0].cpu().detach().numpy()) # add the value to y_pred #print('y_pred:', y_pred) y_true.append(y[j].cpu().detach().numpy()) # add the value to y_pred #print('y_true:', y_true) cr_dummy = torch.empty((1, window_out, 1), dtype=torch.float32).to(device) y_hat = torch.cat((y_hat, cr_dummy.fill_(float(CR))), 2).float() #y_hat = tf.concat([y_hat, tf.fill(dims = (1, window_out, 1), value = CR)], axis = 2) # adding CR value y_hat for furter predictions #print('cr added to y_hat', y_hat) win = torch.cat((win, y_hat), 1) #win = tf.concat([win, y_hat], axis = 1) # adding our prediction to win #print('win', win) win = win[:,window_out:,:] # updating win by removing the starting elements #print('new_win for next iter', win) y_pred = torch.tensor(y_pred).to(device) y_true = torch.tensor(y_true).to(device) assert (y_pred.shape == y_true.shape) mae = criterion(y_pred, y_true) #mae = tf.reduce_sum(tf.keras.metrics.mean_absolute_error(y_pred, y_test)) print(f'The error is: " {mae: .5f}') model.train() return y_pred.cpu().detach().numpy(), y_true.cpu().detach().numpy(), mae.cpu().detach().numpy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_predict(train_file_arg):\n\n # Load command line arguments\n train_file = train_file_arg\n parameter_file = \"prophet/lstm/trainingConfig.json\"\n\n # Load training parameters\n params = json.loads(open(parameter_file).read())\n\n # Load time series dataset, and split it into train and ...
[ "0.6817948", "0.66349447", "0.6473964", "0.6437722", "0.6398785", "0.63897544", "0.6377936", "0.6365075", "0.6336138", "0.62935156", "0.62524164", "0.6220017", "0.6206941", "0.6185454", "0.61810833", "0.6175819", "0.6175819", "0.6175819", "0.6175819", "0.6175819", "0.61737525...
0.0
-1
Visualize a particular column of Y_pred anf Y_test for a particular series
def visualize_pred(y_test, y_pred, test_seq, window_out, num_plots, num_win_ser, cols_y, col_idx): ser_idx = [i for i in range(0, len(y_test), num_win_ser)] if num_plots > len(ser_idx): print("Too many plots, reduce the mumber") else: indx = ser_idx[0:num_plots] days = range(num_win_ser) for idx in indx: CR = test_seq[idx][0][0][3] pred = y_pred[idx : idx+num_win_ser, window_out -1, col_idx] true = y_test[idx : idx+num_win_ser, window_out -1, col_idx] plt.title("Y_True V/S Y_Pred, CR: "+ str(CR)) plt.xlabel('Days') plt.ylabel(cols_y[col_idx]) plt.plot(days, pred, label = 'Pred') plt.plot(days, true, label = 'True') plt.legend() plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def actual_pred_plot(preds):\r\n actual_pred = pd.DataFrame(columns=['Cost', 'prediction'])\r\n actual_pred['Cost'] = all_data['2020':].iloc[:, -1][1:len(preds) + 1]\r\n actual_pred['prediction'] = preds[:, -1]\r\n\r\n from keras.metrics import MeanSquaredError\r\n m = MeanSquaredError()\r\n m.up...
[ "0.6575989", "0.65215456", "0.6404881", "0.62492937", "0.6163107", "0.61196136", "0.60816854", "0.6080583", "0.6039545", "0.6038659", "0.6025292", "0.60227543", "0.6006382", "0.59930116", "0.5945069", "0.5939615", "0.5928846", "0.5928846", "0.5887865", "0.5881625", "0.5878290...
0.6889194
0
Mock out the tkinter canvas and all graphics
def setUp(self): self.screentype_patcher = mock.patch( 'turtle._Screen', new=mock.Mock ) self.mock_screentype = self.screentype_patcher.start() self.screen_patcher = mock.patch('turtle.Turtle._screen') self.mock_screen = self.screen_patcher.start() self.mock_screen.xscale = 1.0 self.mock_screen.yscale = 1.0 self.mock_screen.mode.return_value = 'standard' self.update_patcher = mock.patch( 'aioturtle.aioturtle.AioBaseTurtle._update_graphics' ) self.mock_update = self.update_patcher.start()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_canvas(self):\n # create frame to contain canvas\n self.world_container = tk.Frame(self,\n width = self.world_size[1],\n height = self.world_size[0])\n self.world_container.grid(row = 1, column = 0, sticky ...
[ "0.6882413", "0.67479193", "0.6690179", "0.64564663", "0.64564663", "0.64564663", "0.64194477", "0.6331927", "0.626784", "0.62565655", "0.61583567", "0.6147961", "0.6143228", "0.6132862", "0.6108119", "0.609335", "0.603408", "0.6019643", "0.59988374", "0.59641194", "0.5958032...
0.5550649
59
Test the AioBaseTurtle._calc_move function
def test_calc_move(self): t = AioBaseTurtle() t.speed(speed=5) steps, delta = t._calc_move(Vec2D(0, 100)) self.assertEqual(steps, 20) self.assertAlmostEqual(delta[0], 0.0) self.assertAlmostEqual(delta[1], 5.0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_move_step(self):\n t = AioBaseTurtle()\n t._move_step(Vec2D(-100, 0), 20, Vec2D(10,5))\n self.assertAlmostEqual(t._position[0], 100)\n self.assertAlmostEqual(t._position[1], 100)\n t.screen._drawline.assert_called_once_with(\n t.currentLineItem,\n (...
[ "0.77467954", "0.67991954", "0.67526376", "0.6682421", "0.6611246", "0.66024905", "0.65450394", "0.65094215", "0.6458481", "0.6436995", "0.6424645", "0.64221406", "0.6376048", "0.63608104", "0.6327564", "0.63082105", "0.6292444", "0.62719584", "0.62709236", "0.62575185", "0.6...
0.88943046
0
Test the AioBaseTurtle._calc_rotation function
def test_calc_rotation(self): t = AioBaseTurtle() t.speed(speed=2) orient, steps, delta = t._calc_rotation(120) self.assertEqual(steps, 21) self.assertAlmostEqual(delta, 120.0 / 21.0) self.assertAlmostEqual(orient[0], math.cos(math.radians(120))) self.assertAlmostEqual(orient[1], math.sin(math.radians(120)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_rotation_angle(self):\n\n self.test_shape.azimuth_placement_angle = [45, 135, 225, 315]\n test_volume = self.test_shape.volume()\n self.test_shape.rotation_angle = 180\n assert self.test_shape.volume() == pytest.approx(test_volume * 0.5)", "def test_rotation(self, tol):\n ...
[ "0.72649866", "0.71997005", "0.7070056", "0.6858857", "0.67564845", "0.6559771", "0.65583205", "0.6543984", "0.65229213", "0.6519182", "0.64923644", "0.64011544", "0.63578784", "0.632081", "0.62979436", "0.62914723", "0.62909883", "0.62908113", "0.6243588", "0.62338036", "0.6...
0.91761756
0
Test the AioBaseTurtle._calc_circle function
def test_calc_circle(self): t = AioBaseTurtle() steps, step_len, rot_step = t._calc_circle(100, extent=180) self.assertEqual(steps, 14) self.assertAlmostEqual(rot_step, 180.0 / 14.0) self.assertAlmostEqual(step_len, 22.3928952207)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_circle(c):\n turtle.circle(c.radius)", "def draw_circle(c):\n turtle.circle(c.radius)", "def GetCircle(circle):\r\n pass", "def test_get_radius():\n center = Coordinates(7, 3)\n radius = 12\n\n returned_rad = get_radius(center, radius, 30)\n\n assert returned_rad == radius\n...
[ "0.734142", "0.734142", "0.72636837", "0.703413", "0.6813236", "0.6676832", "0.6654256", "0.66349846", "0.6573545", "0.65500736", "0.6521824", "0.6442423", "0.64218247", "0.6412573", "0.63668287", "0.63393223", "0.6279476", "0.6262953", "0.6237789", "0.6233661", "0.6233039", ...
0.8547868
0
Test the AioBaseTurtle._move_step function
def test_move_step(self): t = AioBaseTurtle() t._move_step(Vec2D(-100, 0), 20, Vec2D(10,5)) self.assertAlmostEqual(t._position[0], 100) self.assertAlmostEqual(t._position[1], 100) t.screen._drawline.assert_called_once_with( t.currentLineItem, ((-100.0, 0.0), (100.0, 100.0)), # called with mutable _position "black", 1, False ) self.mock_update.assert_called_once_with()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step(self, move):", "def test_calc_move(self):\n t = AioBaseTurtle()\n t.speed(speed=5)\n steps, delta = t._calc_move(Vec2D(0, 100))\n self.assertEqual(steps, 20)\n self.assertAlmostEqual(delta[0], 0.0)\n self.assertAlmostEqual(delta[1], 5.0)", "def move(self, dire...
[ "0.7820133", "0.7763472", "0.6788755", "0.6762144", "0.6700953", "0.66414285", "0.6528104", "0.651918", "0.6467042", "0.644896", "0.6419937", "0.639203", "0.637763", "0.63649815", "0.6354341", "0.63443154", "0.63338375", "0.63002443", "0.6289629", "0.62895745", "0.62881094", ...
0.8622489
0
run the tesselation on a empty image
def test_on_map_of_0s(synthetic_checkerboard): img = synthetic_checkerboard['img'] di = np.zeros_like(img) cpp_vorimg = tess.tessellate_labimg(img,di) py_vorimg = pytess.tessellate_labimg(img,di) assert np.alltrue(py_vorimg[:4,:4] == 1) printers.store_ndarray("py_voronoi_on_map_of_0s_output.txt",py_vorimg) assert cpp_vorimg.size > 0 assert cpp_vorimg.shape == synthetic_checkerboard['img'].shape assert np.alltrue(synthetic_checkerboard['img'][1:3,1:3] == 1) printers.store_ndarray("cpp_voronoi_input.txt",img) printers.store_ndarray("cpp_voronoi_on_map_of_0s_output.txt",cpp_vorimg) assert np.alltrue(cpp_vorimg[:4,:4] == 1) assert np.alltrue(cpp_vorimg == py_vorimg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_stuff(self):\n self.create_tourism_raster()", "def write_stitched_image(self):\r\n\r\n self.write_debug(\"End of train detected. Writing stitched image.\")\r\n cv2.imwrite(os.path.join(self.output_dir_stitched, 'stitched.jpg'), self.stitched_image)", "def final_plain():\n\n\tconfig ...
[ "0.61748016", "0.5833619", "0.57900006", "0.57824117", "0.5640208", "0.5631252", "0.56215304", "0.56194323", "0.5608988", "0.56024307", "0.5585959", "0.55422133", "0.5494821", "0.54943854", "0.54853487", "0.5449842", "0.54339325", "0.54300725", "0.54207504", "0.5395208", "0.5...
0.0
-1
run the tesselation on a empty image
def test_on_map_of_constants(synthetic_checkerboard): img = synthetic_checkerboard['img'] di = synthetic_checkerboard['cdi'] cpp_vorimg = tess.tessellate_labimg(img,di) py_vorimg = pytess.tessellate_labimg(img,di) assert np.alltrue(py_vorimg[:4,:4] == 1) printers.store_ndarray("py_voronoi_on_map_of_constants_output.txt",py_vorimg) assert cpp_vorimg.size > 0 assert cpp_vorimg.shape == synthetic_checkerboard['img'].shape assert np.alltrue(synthetic_checkerboard['img'][1:3,1:3] == 1) printers.store_ndarray("cpp_voronoi_input.txt",img) printers.store_ndarray("cpp_voronoi_on_map_of_constants_output.txt",cpp_vorimg) assert np.alltrue(cpp_vorimg[:4,:4] == 1) assert np.alltrue(cpp_vorimg == py_vorimg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_stuff(self):\n self.create_tourism_raster()", "def write_stitched_image(self):\r\n\r\n self.write_debug(\"End of train detected. Writing stitched image.\")\r\n cv2.imwrite(os.path.join(self.output_dir_stitched, 'stitched.jpg'), self.stitched_image)", "def final_plain():\n\n\tconfig ...
[ "0.6173433", "0.5833571", "0.5788354", "0.5786499", "0.56434995", "0.56299114", "0.56189775", "0.5616973", "0.5609669", "0.5601143", "0.5585079", "0.55399793", "0.549523", "0.5494799", "0.5486404", "0.5449044", "0.5434429", "0.543015", "0.5419234", "0.53946966", "0.5386449", ...
0.0
-1
run the tesselation on a empty image
def test_on_map_of_sinus(synthetic_checkerboard): img = synthetic_checkerboard['img'] di = synthetic_checkerboard['sindi'] cpp_vorimg = tess.tessellate_labimg(img,di) py_vorimg = pytess.tessellate_labimg(img,di) assert np.alltrue(py_vorimg[:4,:4] == 1) printers.store_ndarray("py_voronoi_on_map_of_sinus_output.txt",py_vorimg) assert cpp_vorimg.size > 0 assert cpp_vorimg.shape == synthetic_checkerboard['img'].shape assert np.alltrue(synthetic_checkerboard['img'][1:3,1:3] == 1) printers.store_ndarray("cpp_voronoi_input.txt",img) printers.store_ndarray("cpp_voronoi_on_map_of_sinus_output.txt",cpp_vorimg) assert np.alltrue(cpp_vorimg[:4,:4] == 1) assert np.alltrue(cpp_vorimg == py_vorimg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_stuff(self):\n self.create_tourism_raster()", "def write_stitched_image(self):\r\n\r\n self.write_debug(\"End of train detected. Writing stitched image.\")\r\n cv2.imwrite(os.path.join(self.output_dir_stitched, 'stitched.jpg'), self.stitched_image)", "def final_plain():\n\n\tconfig ...
[ "0.6175", "0.5833953", "0.5790842", "0.5783519", "0.56402856", "0.5631712", "0.56218964", "0.56209666", "0.56089985", "0.5602803", "0.5586337", "0.55410194", "0.54952884", "0.54952645", "0.5484749", "0.545018", "0.54336417", "0.54323924", "0.5420694", "0.5396064", "0.53868186...
0.0
-1
run the tesselation on a empty image
def test_on_map_of_noise(synthetic_checkerboard): img = synthetic_checkerboard['img'] di = synthetic_checkerboard['distimg'] cpp_vorimg = tess.tessellate_labimg(img,di) py_vorimg = pytess.tessellate_labimg(img,di) printers.store_ndarray("py_voronoi_on_map_of_noise_output.txt",py_vorimg) assert cpp_vorimg.size > 0 assert cpp_vorimg.shape == synthetic_checkerboard['img'].shape assert np.alltrue(synthetic_checkerboard['img'][1:3,1:3] == 1) printers.store_ndarray("cpp_voronoi_input.txt",img) printers.store_ndarray("cpp_voronoi_on_map_of_noise_output.txt",cpp_vorimg) # assert np.alltrue(cpp_vorimg[:4,:4] == 1) assert np.alltrue(cpp_vorimg == py_vorimg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_stuff(self):\n self.create_tourism_raster()", "def write_stitched_image(self):\r\n\r\n self.write_debug(\"End of train detected. Writing stitched image.\")\r\n cv2.imwrite(os.path.join(self.output_dir_stitched, 'stitched.jpg'), self.stitched_image)", "def final_plain():\n\n\tconfig ...
[ "0.6175", "0.5833953", "0.5790842", "0.5783519", "0.56402856", "0.5631712", "0.56218964", "0.56209666", "0.56089985", "0.5602803", "0.5586337", "0.55410194", "0.54952884", "0.54952645", "0.5484749", "0.545018", "0.54336417", "0.54323924", "0.5420694", "0.5396064", "0.53868186...
0.0
-1
Temporarily overwrite the settings with test settings. This allows to use test datasets for testing.
def generate_test_settings(tmpdir, dataset): # When `tmpdir` is a path convert it to a string if isinstance(tmpdir, py._path.local.LocalPath): tmpdir = str(tmpdir) test_settings = { 'datasets': { 'mnist': { 'train': { 'images': "file://" + tmpdir + "/" + dataset + "/server/train-images-idx3-ubyte.gz", 'labels': "file://" + tmpdir + "/" + dataset + "/server/train-labels-idx1-ubyte.gz" }, 'test': { 'images': "file://" + tmpdir + "/" + dataset + "/server/t10k-images-idx3-ubyte.gz", 'labels': "file://" + tmpdir + "/" + dataset + "/server/t10k-labels-idx1-ubyte.gz" }, }, }, 'data-dir': tmpdir + "/" + dataset + "/data" } overwrite_settings(test_settings)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def force_test_setting(dm, tsm, output_path):\n if dm is not None:\n data_json_path = os.path.join(output_path, 'cur_data_setting.json')\n dm.data_par['datapro']['dataset']['prepare_data'] = False\n dm.data_par['datapro']['reg']['max_num_for_loading'] = [1, 1, -1, 1]\n dm.save(data_j...
[ "0.69389164", "0.6621101", "0.6452525", "0.64237857", "0.64121604", "0.6407746", "0.6387266", "0.6371625", "0.6295202", "0.6287137", "0.6241228", "0.6236511", "0.62239265", "0.6192211", "0.6178279", "0.61352205", "0.6134868", "0.6040336", "0.6021929", "0.6021816", "0.6011449"...
0.6982843
0
Generate archive files for the given test dataset in tmpdir
def generate_test_dataset_archive(filepath, dataset): # 'file:///some/path' to '/some/path' if filepath[:7] == 'file://': filepath = filepath[7:] # Check if the dataset exists. # When not been generate it. if not os.path.isfile(filepath): print("Generating", filepath) data = get_test_dataset(dataset) ensure_dir(os.path.dirname(filepath)) idxgz.save(filepath, data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_test_environment(tmpdir, dataset):\n\n # Overwrite settings with test settings\n generate_test_settings(tmpdir, dataset)\n\n # Generate the archive files\n for usage in ['train', 'test']:\n \n for dstype in ['images', 'labels']:\n \n dataset_type = usage...
[ "0.7358341", "0.6791461", "0.6418583", "0.63508826", "0.63468665", "0.6301004", "0.6291766", "0.61660707", "0.6096657", "0.6091523", "0.60853094", "0.6035293", "0.602757", "0.59755576", "0.595753", "0.59322333", "0.5913556", "0.5871974", "0.58634", "0.5859327", "0.58383375", ...
0.75224614
0
Generate a test environment using the given dataset. The settings are temporarily overwritten to use the test data.
def generate_test_environment(tmpdir, dataset): # Overwrite settings with test settings generate_test_settings(tmpdir, dataset) # Generate the archive files for usage in ['train', 'test']: for dstype in ['images', 'labels']: dataset_type = usage + '.' + dstype mnist_dataset = 'datasets.mnist.' + dataset_type filepath = get_setting(mnist_dataset) test_dataset = dataset + '.' + dataset_type generate_test_dataset_archive(filepath, test_dataset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_environment(dataset, tmpdir):\n\n print(\">>> Test environment:\")\n print(\"dataset:\", dataset)\n print(\"tmpdir:\", tmpdir)\n\n generate_test_environment(tmpdir, dataset)\n\n return { 'dataset': dataset, 'tmpdir': tmpdir }", "def test_generate_test_environment(dataset):\n\n prin...
[ "0.7599391", "0.72667193", "0.69813424", "0.66441184", "0.64025056", "0.6268748", "0.625678", "0.6244715", "0.61173195", "0.60907793", "0.60787404", "0.60093623", "0.5926749", "0.5911557", "0.5894079", "0.58914727", "0.58914727", "0.58914727", "0.58914727", "0.58877015", "0.5...
0.7804764
0
For debugging test environments
def test_generate_test_environment(dataset): print("## =========================================================") print("## Dataset:", dataset) print("## ---------------------------------------------------------") print("") tmpdir = "/tmp/collagen" generate_test_environment(tmpdir, dataset) # Generate the archive files for usage in ['train', 'test']: for dstype in ['images', 'labels']: dataset_type = usage + '.' + dstype mnist_dataset = 'datasets.mnist.' + dataset_type filepath = get_setting(mnist_dataset) # 'file:///some/path' to '/some/path' if filepath[:7] == 'file://': filepath = filepath[7:] # Unpack print("") print("{}: {}".format(mnist_dataset, filepath)) print("") data = idxgz.load(filepath) print("data:", data) print("type:", type(data)) print("dtype:", data.dtype) print("shape:", data.shape) print("")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def debug():", "def debugging_tests():\n logging.warning(\"Running debugging tests...\")\n pass", "def debug() -> bool:", "def test_debug(self) -> Debug:\n return self._test_debug", "def test_debug_info():\n # Just check a sample we control.\n assert version.__version__ in _env_info", ...
[ "0.76501894", "0.74378276", "0.7319192", "0.7256087", "0.7246349", "0.7120246", "0.7063667", "0.69600326", "0.6871428", "0.67112607", "0.6628233", "0.66059375", "0.65979975", "0.65336007", "0.6533267", "0.6531516", "0.6531516", "0.6531516", "0.65074044", "0.64774877", "0.6432...
0.0
-1
Extracts (typically) overlapping regular patches from a grayscale image Changing the offset and stride parameters will result in images reconstructed by reconstruct_from_grayscale_patches having different dimensions! Callers should pad and unpad as necessary!
def extract_grayscale_patches( img, shape, offset=(0,0), stride=(1,1) ): px, py = np.meshgrid( np.arange(shape[1]),np.arange(shape[0])) l, t = np.meshgrid( np.arange(offset[1],img.shape[1]-shape[1]+1,stride[1]), np.arange(offset[0],img.shape[0]-shape[0]+1,stride[0]) ) l = l.ravel() t = t.ravel() x = np.tile( px[None,:,:], (t.size,1,1)) + np.tile( l[:,None,None], (1,shape[0],shape[1])) y = np.tile( py[None,:,:], (t.size,1,1)) + np.tile( t[:,None,None], (1,shape[0],shape[1])) return img[y.ravel(),x.ravel()].reshape((t.size,shape[0],shape[1])), (t,l)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _extract_patches_and_positions_from_image(\n image, patch_size, patch_stride, hse_grid_size,\n n_crops, h, w,\n c, scale_id, max_seq_len):\n p = tf.image.extract_patches(\n image, [1, patch_size, patch_size, 1], [1, patch_stride, patch_stride, 1],\n [1, 1, 1, 1],\n padding='SAME')\n\n ...
[ "0.69615763", "0.6910621", "0.6902872", "0.6756077", "0.6684931", "0.6669656", "0.66367173", "0.66181797", "0.6613878", "0.6597331", "0.65837264", "0.65633184", "0.65623057", "0.652115", "0.6456871", "0.6398756", "0.6369198", "0.6359843", "0.63577175", "0.6351932", "0.6345157...
0.7973168
0
Rebuild an image from a set of patches by averaging The reconstructed image will have different dimensions than the original image if the strides and offsets of the patches were changed from the defaults!
def reconstruct_from_grayscale_patches( patches, origin, epsilon=1e-12 ): patch_width = patches.shape[2] patch_height = patches.shape[1] img_width = np.max( origin[1] ) + patch_width img_height = np.max( origin[0] ) + patch_height out = np.zeros( (img_height,img_width) ) wgt = np.zeros( (img_height,img_width) ) for i in range(patch_height): for j in range(patch_width): out[origin[0]+i,origin[1]+j] += patches[:,i,j] wgt[origin[0]+i,origin[1]+j] += 1.0 return out/np.maximum( wgt, epsilon ), wgt
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reconstruct_avg(img, nnf, patch_size=5):\r\n\r\n final = np.zeros_like(img)\r\n for i in range(img.shape[0]):\r\n for j in range(img.shape[1]):\r\n\r\n dx0 = dy0 = patch_size // 2\r\n dx1 = dy1 = patch_size // 2 + 1\r\n dx0 = min(j, dx0)\r\n dx1 = min(im...
[ "0.75404114", "0.6949689", "0.6838472", "0.68046606", "0.67437595", "0.66327584", "0.6593758", "0.6556427", "0.6351604", "0.6174992", "0.6122615", "0.60943955", "0.6007776", "0.5980942", "0.59666556", "0.59625", "0.5957962", "0.5952175", "0.59199303", "0.58981425", "0.5874043...
0.64738786
8
This is the base "correct" case (they have enough money, are bidders, haven't passed, etc).
def testInitializeMove(self): bid_move = self._move() context = self._context() bfpc = BiddingForPrivateCompany() self.assertTrue(bfpc.run(bid_move, context), bfpc.errors())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_amount_not_enough(self):\n item, change, _ = give_item_and_change('coke', .50)\n self.assertIsNone(item)\n self.assertEqual(change, 0.5)", "def check_for_offer(self, bid, commodity, limit, actual, quantity, price):\n if bid:\n if len(self.trades[\"buys\"][commodity...
[ "0.67128986", "0.67048556", "0.66379863", "0.6527508", "0.6469274", "0.64126986", "0.63823014", "0.63767564", "0.63319266", "0.6226689", "0.62261546", "0.61649483", "0.6154119", "0.61476374", "0.6144717", "0.613952", "0.6133715", "0.61022395", "0.6094778", "0.60594314", "0.60...
0.0
-1
Make sure they have enough money.
def testInsufficientCash(self): bid_move = self._move() context = self._context() context.players[0].cash = 200 bfpc = BiddingForPrivateCompany() self.assertFalse(bfpc.run(bid_move, context), bfpc.errors())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_amount_not_enough(self):\n item, change, _ = give_item_and_change('coke', .50)\n self.assertIsNone(item)\n self.assertEqual(change, 0.5)", "def check_costs(self):\r\n if self.cost > self.owner.player.char_ob.currency:\r\n self.add_error(\r\n \"celebr...
[ "0.73113734", "0.7142943", "0.6958009", "0.683706", "0.6807364", "0.6756622", "0.6750081", "0.6689734", "0.6550323", "0.65317523", "0.6529866", "0.65116155", "0.6492988", "0.6469569", "0.64487016", "0.64354503", "0.6415727", "0.6402978", "0.6386353", "0.637824", "0.6367256", ...
0.6613819
8
Make sure they have enough money.
def testPassedAlready(self): _pass_move = self._pass_move() bid_move = self._move() context = self._context() bfpc = BiddingForPrivateCompany() self.assertTrue(bfpc.run(_pass_move, context), bfpc.errors()) self.assertEqual(_pass_move.move_type, BidType.PASS) self.assertEqual(len(context.private_companies[1].passed_by), 1) self.assertFalse(bfpc.run(bid_move, context), bfpc.errors()) self.assertIn("You can only keep bidding until you've passed once.", bfpc.errors())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_amount_not_enough(self):\n item, change, _ = give_item_and_change('coke', .50)\n self.assertIsNone(item)\n self.assertEqual(change, 0.5)", "def check_costs(self):\r\n if self.cost > self.owner.player.char_ob.currency:\r\n self.add_error(\r\n \"celebr...
[ "0.7311504", "0.71432513", "0.6958015", "0.6837109", "0.68072706", "0.6756763", "0.6750037", "0.6689844", "0.66139734", "0.6550322", "0.6531817", "0.65297884", "0.65116364", "0.6493205", "0.64698845", "0.6448786", "0.6435723", "0.64158696", "0.6403044", "0.6386391", "0.637806...
0.0
-1
If the last person passes, you should assign the new owner asap.
def testAutopurchaseOnLastPass(self): _pass_move = self._pass_move() context = self._context() bfpc = BiddingForPrivateCompany() self.assertTrue(bfpc.run(_pass_move, context), bfpc.errors()) self.assertEqual(_pass_move.move_type, BidType.PASS) self.assertEqual(len(context.private_companies[1].passed_by), 1) self.assertTrue(context.private_companies[1].hasOwner()) self.assertNotEqual(context.private_companies[1].belongs_to, _pass_move.player, context.private_companies[1].belongs_to.id ) self.assertEqual( context.private_companies[1].belongs_to, context.players[1], context.private_companies[1].belongs_to.id )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testOwnershipAfterCreate(self):\n self.simulateATGUIInteraction(task='create')\n self.failUnlessEqual(self.person.getOwnerTuple()[1], 'abc123')", "def add_to(self, newowner):\n self.prevai = newowner.ai\n newowner.ai = self", "def possessed_by(self, other):\r\n self.owner...
[ "0.677503", "0.64477986", "0.6446304", "0.63864005", "0.6358", "0.62971616", "0.62954915", "0.6290303", "0.6241448", "0.6205976", "0.6128244", "0.6090834", "0.6000378", "0.5993534", "0.5971924", "0.594644", "0.5895443", "0.5857133", "0.5824147", "0.58180535", "0.58094245", ...
0.0
-1
Get the identifier of person
def identifier(self): return self._identifier
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_identifier(self):", "def getIdent (self) :\n return self.id", "def get_identifier(self) -> str:\n return self.identifier", "def get_person_id(person_data):\n person_ref = person_data['Casualty_Reference']\n veh_ref = person_data['Vehicle_Reference']\n acc_id = get_acc_id_from_d...
[ "0.75057507", "0.7319578", "0.7309798", "0.7292267", "0.71864873", "0.7161316", "0.70634836", "0.6956172", "0.6956172", "0.6955756", "0.6924296", "0.6895861", "0.68554884", "0.68335015", "0.6826491", "0.6826491", "0.68212664", "0.68004686", "0.67956805", "0.67936885", "0.6743...
0.68210834
21
Get the name of person
def name(self): return self._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def person_name(self):\n return self._person_name", "def persona_name(self) -> str:\n return self._persona_name", "def get_name() -> str:", "def get_person_name(self, person_id):\n res = requests.get(url=\"https://api.ciscospark.com/v1/people/{}\".format(person_id),\n ...
[ "0.8474906", "0.8018867", "0.78476787", "0.77369803", "0.76065636", "0.75772613", "0.7530738", "0.750647", "0.74815065", "0.7397122", "0.736096", "0.7346389", "0.73411", "0.73411", "0.73411", "0.73353255", "0.7317605", "0.7317605", "0.7317605", "0.7317226", "0.73119605", "0...
0.0
-1
Get the surname of person
def surname(self): return self._surname
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def surname(self):\n return self.__surname", "def surname(self):\n if \"surname\" in self._prop_dict:\n return self._prop_dict[\"surname\"]\n else:\n return None", "def surname(self):\n if \"surname\" in self._prop_dict:\n return self._prop_dict[\"su...
[ "0.84594584", "0.8456766", "0.8456766", "0.7657546", "0.75671947", "0.7503995", "0.71551466", "0.7144786", "0.6926863", "0.68105274", "0.67284966", "0.66660845", "0.6651198", "0.6651198", "0.6651198", "0.6651198", "0.6651198", "0.66335547", "0.6632711", "0.65882415", "0.65831...
0.8435841
4
Get the phone of person
def phone(self): return self._phone
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPhone(self):\n return self.phone", "def phone(self) -> str:\n return pulumi.get(self, \"phone\")", "def phone(self):\n return self._phone", "def phone(self):\n return self._phone", "def phone(self):\n return self._phone", "def personal_phone(self):\n retur...
[ "0.7979565", "0.7934985", "0.7780116", "0.7780116", "0.7780116", "0.7700906", "0.76863", "0.75520843", "0.7512064", "0.7512064", "0.7222818", "0.7215174", "0.7091844", "0.70915896", "0.7069842", "0.69753623", "0.6879566", "0.6879566", "0.6869756", "0.681976", "0.6818524", "...
0.7533967
8
Get the address of person
def address(self): return self._address
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAddress(user):", "def get_address(self):\n if self.get_entity: # needs an entity to work\n if self.building:\n address = self.get_entity.get_institutional_address()\n address.extend(self.building.get_postal_address())\n return address\n ...
[ "0.7992872", "0.7607708", "0.75525093", "0.73847014", "0.7379411", "0.737529", "0.73570526", "0.7323264", "0.722714", "0.71870494", "0.7097504", "0.7097504", "0.7092015", "0.7092015", "0.7092015", "0.7066334", "0.7032395", "0.69323504", "0.69010234", "0.69005394", "0.6900194"...
0.6411183
70
Get the mail of person
def mail(self): return self._mail
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recipient(self, recipient, model):\n if recipient == \"hod\":\n workmails = model.address_id, model.work_email\n workmail = {workmail for workmail in workmails if workmail}\n workmail = workmail.pop() if workmail else model.work_email\n if not isinstance(workm...
[ "0.7303463", "0.7285791", "0.72157747", "0.72157747", "0.7144919", "0.70124036", "0.6947377", "0.6876924", "0.6824107", "0.6776341", "0.67702425", "0.67517656", "0.6741758", "0.6727407", "0.67177004", "0.6696528", "0.6696528", "0.6696528", "0.6696325", "0.6682962", "0.6642721...
0.6388883
45
Get the url of person
def url(self): return self._url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getURLForThing(thing):", "def get_absolute_url(self):\n if self.kind == \"persona_profile\":\n p = Persona.query.filter(Persona.profile_id == self.id).first()\n return url_for(\"persona\", id=p.id)\n elif self.kind == \"group_profile\":\n g = Group.query.filter(...
[ "0.72001034", "0.7117052", "0.71160406", "0.7037918", "0.7014563", "0.7014563", "0.6958404", "0.6889335", "0.6881808", "0.68336815", "0.68336815", "0.67946136", "0.67801034", "0.677251", "0.6765108", "0.6752407", "0.6691526", "0.6678413", "0.6663654", "0.6660274", "0.6658939"...
0.6515759
40
Model with no features.Always predicts a passenger did not survive.
def predictions_0(data): predictions=[] for _, passenger in data.iterrows(): #Predict the survival of 'passenger' predictions.append(0) #Return our predictions return pd.Series(predictions) #make the predictions predictions=predictions_0(data) ''' Question 1 Using the RMS Titanic data,how accurate would a prediction be that none of the passengers survived? Hint:Run the code cell below to see the accuracy of this prediction. ''' print accuracy_score(outcomes,predictions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_only(self):", "def nonlearning():\n\taT.featureAndTrain(['../../AudioData/chunked_data_sorted/pos', '../../AudioData/chunked_data_sorted/neg'], \n\t\t\t\t\t\t1.0, 1.0, aT.shortTermWindow, aT.shortTermStep, \n \"svm\", \"emotion_classifier\", True)", "def train_naive(): # add argu...
[ "0.7398218", "0.6274821", "0.60658264", "0.6061463", "0.6021806", "0.5954597", "0.5936909", "0.5917042", "0.59065545", "0.58827984", "0.5858222", "0.5814856", "0.5814105", "0.57477957", "0.5726169", "0.57161635", "0.5714358", "0.57077813", "0.568969", "0.56806886", "0.5669478...
0.5549601
38
Model with multiple features.Makes a prediction with an accuracy of at least 90%
def predictions_3(data): predictions=[] for _,passenger in data.iterrows(): if passenger['Sex']=='female' or passenger['Sex']=='male' and passenger['Age']<16 and passenger['SibSp']<2: predictions.append(1) else: predictions.append(0) #Return our predictions return pd.Series(predictions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_only(self):", "def trainModel( self, featureTrain, classTrain):", "def predict(self, model, arg):\n prediction = model.predict(arg)\n\n return prediction\n\n #def getAccuracyScore(self, n_splits):\n \"\"\"\n Gives an cross-validated accuracy score for the new model.\n...
[ "0.69236994", "0.6804752", "0.66647077", "0.6594891", "0.6577277", "0.6555848", "0.6513031", "0.65010685", "0.64928365", "0.6475141", "0.6472414", "0.64383626", "0.6421993", "0.6405277", "0.6402431", "0.63951135", "0.63951135", "0.638529", "0.63590425", "0.63344693", "0.63329...
0.0
-1
Initialize monitor with name and units.
def __init__(self, pvname: str, units: str, controller: Controller) -> None: self.units = units.split(":") self.pvname = pvname self.controller = controller
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __initializeMonitor( self ):\n if self.__moduleProperties[ 'standalone' ]:\n self.monitor = gMonitor\n else:\n self.monitor = MonitoringClient()\n self.monitor.setComponentType( self.monitor.COMPONENT_AGENT )\n self.monitor.setComponentName( self.__moduleProperties[ 'fullName' ] )\n se...
[ "0.69244856", "0.5961898", "0.5762785", "0.5757067", "0.5748094", "0.5743669", "0.5689868", "0.5632864", "0.56286836", "0.5607507", "0.55625767", "0.5536116", "0.5534481", "0.5490145", "0.5483726", "0.5446595", "0.54104185", "0.54083985", "0.5397087", "0.539698", "0.53613365"...
0.53771675
20
Collects image data via appropriate protocol and builds image data dictionary. Returns dict Dictionary mapping image components to values.
def poll(self) -> Dict[str, list]: try: value = self.controller.get_image(self.pvname) except TimeoutError: print(f"No process variable found for {self.pvname}") return DEFAULT_IMAGE_DATA # now prepare the value using method defined by the model return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_imagenet_as_dict(self):\n real_file_path = os.path.realpath(self.map_file)\n if not os.path.exists(real_file_path):\n raise IOError(\"map file {} not exists\".format(self.map_file))\n\n label_dict = {}\n with open(real_file_path) as fp:\n line = fp.readlin...
[ "0.65801144", "0.6529789", "0.6423225", "0.63869387", "0.62811023", "0.6264642", "0.62389845", "0.6179889", "0.61555016", "0.61398166", "0.6100159", "0.6036023", "0.59768283", "0.59654045", "0.59536004", "0.59490883", "0.593953", "0.5929546", "0.59160763", "0.5884778", "0.583...
0.0
-1
Collects image data via appropriate protocol and returns time and data.
def poll(self) -> Tuple[np.ndarray]: t = time.time() try: v = self.controller.get(self.pvname) except TimeoutError: print(f"No process variable found for {self.pvname}") v = DEFAULT_SCALAR_VALUE[self.pvname] self.time = np.append(self.time, t) self.data = np.append(self.data, v) return self.time - self.tstart, self.data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data(self):\n global CAM\n while CAM.isOpened():\n _, frame = CAM.read()\n _, jpeg = cv2.imencode('.jpg', frame)\n encoded_img = \"data:image/jpg;base64,\" + str(base64.b64encode(jpeg.tobytes()).decode())\n SIO.emit('video_frame',\n ...
[ "0.58509904", "0.5848849", "0.5797124", "0.5720454", "0.5719993", "0.5676541", "0.5621858", "0.5572144", "0.55561996", "0.55333614", "0.5499547", "0.54932874", "0.5475753", "0.54749036", "0.5426874", "0.5406819", "0.54067355", "0.53759944", "0.5365759", "0.53495574", "0.53261...
0.0
-1
Collects image data via appropriate protocol and returns time and data.
def poll(self) -> Tuple[np.ndarray]: try: v = self.controller.get(self.pvname) except TimeoutError: print(f"No process variable found for {self.pvname}") v = DEFAULT_SCALAR_VALUE return v
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data(self):\n global CAM\n while CAM.isOpened():\n _, frame = CAM.read()\n _, jpeg = cv2.imencode('.jpg', frame)\n encoded_img = \"data:image/jpg;base64,\" + str(base64.b64encode(jpeg.tobytes()).decode())\n SIO.emit('video_frame',\n ...
[ "0.5853295", "0.5850195", "0.5799188", "0.5721936", "0.57214046", "0.56789905", "0.562323", "0.5574254", "0.55553085", "0.5534616", "0.54999393", "0.5493341", "0.5476053", "0.5475871", "0.54282975", "0.5408226", "0.54078424", "0.53759134", "0.53672683", "0.534906", "0.5328712...
0.0
-1
Encode image for Dash Application
def encodedImage(imageFile): imageFile = "".join([METRICS_PATH, imageFile]) encoded = base64.b64encode(open(imageFile, 'rb').read()) return 'data:image/jpg;base64,{}'.format(encoded.decode())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode(image):\n from encoder import launch\n launch(image)", "def encode(self, image) -> bytes:\n raise NotImplementedError()", "def prepare_output(image: np.ndarray) -> str:\n response_image = Image.fromarray(np.uint8(image * 255))\n buffer = BytesIO()\n response_image.save(buffer, ...
[ "0.7395458", "0.71863705", "0.6997544", "0.69900215", "0.6834343", "0.67835957", "0.67522126", "0.6698545", "0.6664718", "0.6626647", "0.65300465", "0.643985", "0.64295864", "0.6397522", "0.63932425", "0.6282071", "0.62708914", "0.6267106", "0.625478", "0.62303776", "0.617828...
0.62895167
15
assert json schema for requests from api.openweathermap.org
def validate_schema_openweathermap(self, actual, schema): resources_dir = os.path.abspath(os.getcwd()) relative_schema_path = valid_json_schema if schema == 'Valid' else error_json_schema schema_data = open(os.path.join(resources_dir, relative_schema_path)) self.validate_schema(actual, json.load(schema_data)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_complete_data_schema(self):\n response = self.client.get(self.url)\n data = response.data\n self.assertIn('id', data)\n self.assertIn('title', data)\n self.assertIn('release_year', data)\n self.assertIn('casting', data)\n self.assertIn('directors', data)\n ...
[ "0.62621653", "0.6240114", "0.6214563", "0.6125648", "0.5942485", "0.5931073", "0.575438", "0.57441986", "0.57291126", "0.57290787", "0.57119447", "0.56926596", "0.5668845", "0.5663258", "0.5649895", "0.5649895", "0.5649045", "0.56264323", "0.5599427", "0.5597548", "0.5595037...
0.6302012
0
Count the number of nonempty dicts/lists or other objects
def recursive_count(o): if isinstance(o, dict): c = 0 for v in o.values(): c += recursive_count(v) return c elif isinstance(o, list): c = 0 for v in o: c += recursive_count(v) return c else: return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_empty(self):\n count = 0\n for i in self.__buckets:\n if i.size() == 0:\n count += 1\n return count", "def __len__(self):\n total_objs = 0\n\n if self._shelve is not None:\n total_objs += len(self._shelve)\n\n if self._dict is...
[ "0.71943367", "0.71715474", "0.69646627", "0.6960094", "0.6950782", "0.6901174", "0.6860939", "0.6854527", "0.68178976", "0.6807361", "0.6695624", "0.6688045", "0.6622141", "0.6599806", "0.6558737", "0.6528312", "0.6516975", "0.64872235", "0.6447478", "0.6436087", "0.641087",...
0.7272351
0
Reorganize xarray object a bit for netcdf files
def process_lidar(radial_file, scan_file, wind_file, site, period, netcdf_path): lidar = rasp.lidar_from_csv(radial_file, scan_file, wind=wind_file) # remove status==0 data (if we have the whole data) if 'Status' in lidar.data_vars: lidar['CNR'] = lidar['CNR'].where(lidar['Status']) lidar['DRWS'] = lidar['DRWS'].where(lidar['Status']) # remove unneeded variables if they exist to_drop = list(set(lidar.data_vars) & set(['Status', 'Error', 'Confidence', 'RWS'])) lidar = lidar.drop(to_drop) lidar = lidar.rasp.cf_compliant() lidar.to_netcdf(netcdf_path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_netCDF_to_memory(self):\n f = cfdm.example_field(4)\n f.data.to_memory() # on non-compressed array\n f.compress(\"indexed_contiguous\", inplace=True)\n f.data.to_memory() # on compressed array", "def __init__(self, xarray_obj):\n super(RasterDataArray, self).__init__...
[ "0.57716465", "0.5675053", "0.5598693", "0.5529777", "0.5516983", "0.54658604", "0.54497313", "0.54397637", "0.53918636", "0.5390577", "0.5377511", "0.5367062", "0.5363264", "0.5362354", "0.53438973", "0.5343177", "0.5296879", "0.5289519", "0.5279383", "0.5264651", "0.5245457...
0.0
-1
Taken a word, if it is an abbreviation it returns the meaning
def get_abbr(self, word): assert (self.collection is not None) for conv in self.collection: ln = conv.split("*") if word == ln[0]: return ln[1] return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_abbrev(word):\r\n return abbreviations[word.lower()] if word.lower() in abbreviations.keys() else word", "def aux_lemma(word):\n if re.match(r\"(does|did|doing)\", word):\n return (\"do\")\n elif re.match(r\"(had|has|'ve|having)\", word):\n return (\"have\")\n elif re.match(...
[ "0.6904979", "0.68378323", "0.6644737", "0.6541667", "0.6537515", "0.6440209", "0.6420517", "0.6390089", "0.63880235", "0.6369538", "0.63481516", "0.63338417", "0.6322253", "0.6277778", "0.62644935", "0.6260187", "0.62546563", "0.62457216", "0.6238056", "0.6238056", "0.619860...
0.66452616
2
Create an instance of all possible analysis. If you're not able to create it... you're not able to use it.
def build_all_analysis(self, matrix_handler, trajectory_handler): distance_matrix = matrix_handler.distance_matrix self.all_possible_analysis = {} # Pure queries self.all_possible_analysis["Details"] = Analysis("Details", self.analysis_function_details) self.all_possible_analysis["NumClusters"] = Analysis("Number of clusters", self.analysis_function_num_clusters) self.all_possible_analysis["NumClusteredElems"] = Analysis("Number of clustered elements", self.analysis_function_total_elements) self.all_possible_analysis["MeanClusterSize"] = Analysis("Mean cluster size", self.analysis_function_mean_cluster_size) self.all_possible_analysis["PercentInTop4"] = Analysis("Percent in top 4 clusters", self.analysis_function_top_4) self.all_possible_analysis["PercentInTop"] = Analysis("Percent in top cluster", self.analysis_function_top_percent) self.all_possible_analysis["ClustersTo90"] = Analysis("Clusters to 90", self.analysis_function_num_clusters_to_percent, 90) self.all_possible_analysis["NoiseLevel"] = Analysis("Noise level", self.analysis_function_noise_level, distance_matrix.row_length) # Evaluators self.all_possible_analysis["MirrorCohesion"] = Analysis("MirrorCohesion", self.evaluate_with_calculator, {"class":MirrorCohesionCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Cohesion"] = Analysis("Cohesion", self.evaluate_with_calculator, {"class":CohesionCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Separation"] = Analysis("Separation", self.evaluate_with_calculator, {"class":SeparationCalculator,"matrix":distance_matrix}) self.all_possible_analysis["MinimumMeanSeparation"] = Analysis("MinimumMeanSeparation", self.evaluate_with_calculator, {"class":MeanMinimumDistanceCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Silhouette"] = Analysis("Silhouette", self.evaluate_with_calculator, {"class":SilhouetteCoefficientCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Calinski-Harabasz"] = Analysis("Calinski-Harabasz", self.evaluate_with_calculator, {"class":CalinskiHarabaszCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Dunn"] = Analysis("Dunn", self.evaluate_with_calculator, {"class":DunnCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Davies-Bouldin"] = Analysis("Davies-Bouldin", self.evaluate_with_calculator, {"class":DaviesBouldinCalculator,"matrix":distance_matrix}) self.all_possible_analysis["GaussianSeparation"] = Analysis("GaussianSeparation", self.evaluate_with_calculator, {"class":GaussianSeparationCalculator,"matrix":distance_matrix}) self.all_possible_analysis["Compactness"] = Analysis("Compactness", self.evaluate_with_calculator, {"class":CompactnessCalculator,"matrix":distance_matrix}) # Cython self.all_possible_analysis["CythonMirrorCohesion"] = Analysis("CythonMirrorCohesion", self.evaluate_with_calculator, {"class":CythonMirrorCohesionCalculator,"matrix":distance_matrix}) self.all_possible_analysis["CythonMinimumMeanSeparation"] = Analysis("CythonMinimumMeanSeparation", self.evaluate_with_calculator, {"class":CythonMeanMinimumDistanceCalculator,"matrix":distance_matrix}) self.all_possible_analysis["CythonSilhouette"] = Analysis("CythonSilhouette", self.evaluate_with_calculator, {"class":CythonSilhouetteCoefficientCalculator,"matrix":distance_matrix}) # Graph self.all_possible_analysis["RatioCut"] = Analysis("RatioCut", self.evaluate_with_calculator, {"class":RatioCut,"matrix":distance_matrix}) self.all_possible_analysis["NCut"] = Analysis("NCut", self.evaluate_with_calculator, {"class":NCut,"matrix":distance_matrix}) self.all_possible_analysis["NormNCut"] = Analysis("NormNCut", self.analysis_function_norm_n_cut,distance_matrix) self.all_possible_analysis["MinMaxCut"] = Analysis("MinMaxCut", self.evaluate_with_calculator, {"class":MinMaxCut,"matrix":distance_matrix}) # Cython & Graph self.all_possible_analysis["CythonNormNCut"] = Analysis("CythonNormNCut", self.analysis_function_cython_norm_n_cut,distance_matrix) # PCA self.all_possible_analysis["PCAanalysis"] = Analysis("PCAanalysis", self.analysis_function_pca, trajectory_handler)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_analysis_tools(self):\r\n raise NotImplementedError()", "def analysis_setup(self):\n pass", "def init():\n # analyzer es utilizado para interactuar con el modelo\n analyzer = model.newAnalyzer()\n return analyzer", "def analysis(self, checkid):\r\n return analysis.Analysi...
[ "0.6476997", "0.64702034", "0.63428855", "0.62444305", "0.623065", "0.5992507", "0.59902406", "0.59565115", "0.5947113", "0.5947113", "0.59458697", "0.5939853", "0.59148765", "0.58706826", "0.5858152", "0.58355874", "0.58180684", "0.5758296", "0.5750707", "0.57501674", "0.574...
0.60086685
5
Generates the list of required analyzers.
def get_analysis_list(self): analysys_list = [] analysis_types = AnalysisPopulator.get_query_and_evaluation_analysis_types(self.parameters) for analysis_type in analysis_types: if analysis_type in self.all_possible_analysis: analysys_list.append(self.all_possible_analysis[analysis_type]) else: print "[WARNING]", analysis_type, "is not an allowed analysis type" return analysys_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_analyzers(args: argparse.Namespace):\n first = True\n queue = [tuple(c) + (\"lookout.\",) for c in pkgutil.iter_modules(lookout.__path__)]\n while queue:\n importer, name, ispkg, prefix = queue.pop(0)\n\n if not ispkg or name == \"core\":\n continue\n\n m = importe...
[ "0.69321376", "0.6514944", "0.57968", "0.5703347", "0.5684623", "0.5570689", "0.54497045", "0.53985465", "0.5392003", "0.5353222", "0.53327596", "0.52788645", "0.525477", "0.52528656", "0.5236998", "0.51388603", "0.49939647", "0.49732646", "0.4960888", "0.49380273", "0.487532...
0.46405792
47
Returns a list formed by all the analysis we need to calculate, without repetition, from the data in parameters.
def get_query_and_evaluation_analysis_types(self, parameters): queries = parameters["clustering"]["evaluation"]["query_types"] queries.extend(AnalysisPopulator.get_evaluation_analysis_types(parameters)) return list(set(queries))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_analysis_list(self):\n analysys_list = []\n\n analysis_types = AnalysisPopulator.get_query_and_evaluation_analysis_types(self.parameters)\n\n for analysis_type in analysis_types:\n if analysis_type in self.all_possible_analysis:\n analysys_list.append(self.all...
[ "0.62758255", "0.6011133", "0.5986083", "0.59858525", "0.5896374", "0.58353883", "0.58151305", "0.57914615", "0.57429975", "0.5728949", "0.571652", "0.57030505", "0.5637215", "0.5610428", "0.55925506", "0.559063", "0.5552268", "0.5549528", "0.5538644", "0.5536552", "0.5535558...
0.5309142
65
Returns a list formed by the evaluation types present in criteria.
def get_evaluation_analysis_types(self, parameters): eval_types =[] for evaluation_criteria_id in parameters["clustering"]["evaluation"]["evaluation_criteria"]: # for subcriteria in parameters["clustering"]["evaluation"]["evaluation_criteria"][evaluation_criteria_id]: # eval_types.append(subcriteria) eval_types.extend(parameters["clustering"]["evaluation"]["evaluation_criteria"][evaluation_criteria_id].keys()) return list(set(eval_types))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_query_and_evaluation_analysis_types(self, parameters):\n queries = parameters[\"clustering\"][\"evaluation\"][\"query_types\"]\n queries.extend(AnalysisPopulator.get_evaluation_analysis_types(parameters))\n return list(set(queries))", "def getResultDefs(self, type=None):\n res...
[ "0.67036015", "0.615326", "0.59587413", "0.5896585", "0.5799256", "0.5777026", "0.5747461", "0.5745", "0.5661408", "0.5641381", "0.5631738", "0.551762", "0.551464", "0.5496893", "0.5494026", "0.54865164", "0.54589295", "0.5457875", "0.5433231", "0.54234606", "0.5407233", "0...
0.76133484
0
Returns the 'details' field of a clustering.
def analysis_function_details(self,clustering): return clustering.details
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_details(self):\n return self.details", "def get_details(self):\n return self.details", "def get_details(self):\n return self.details", "def details(self) -> \"dict\":\n return self._attrs.get(\"details\")", "def details(self):\n return self._details", "def detai...
[ "0.6636939", "0.6636939", "0.6636939", "0.6543469", "0.64725894", "0.63629097", "0.62274104", "0.6106484", "0.60739094", "0.6035391", "0.6035391", "0.60135996", "0.6000487", "0.5963064", "0.59448", "0.5934605", "0.5902071", "0.5895396", "0.58460885", "0.5807865", "0.57522964"...
0.7595597
0
Returns the number of cluster a clustering has.
def analysis_function_num_clusters(self,clustering): return len(clustering.clusters)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cluster_count(self) -> int:\n return len(self.get_all_cluster_ids())", "def cluster_count(self) -> int:\n cluster_count = max(1, round(16**3 * (self.vein.purity / 100.0) / self.cluster_size))\n return self.distribution.scale_cluster_count(cluster_count)", "def n_clusters(self):\n ...
[ "0.8762908", "0.84918106", "0.80784905", "0.77352", "0.71900326", "0.7170602", "0.7130262", "0.70022637", "0.6933635", "0.68955094", "0.6862841", "0.6851633", "0.68233424", "0.68233424", "0.6755365", "0.6752718", "0.66931707", "0.66912186", "0.6680638", "0.66151196", "0.66151...
0.81173706
2
Returns the number of elements that are clusterized in this clustering (which may not be the total number of elements of the dataset if there were noisy elements)
def analysis_function_total_elements(self,clustering): return clustering.total_number_of_elements
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def n_clusters(self):\n return len(self.clusters)", "def get_cluster_count(self) -> int:\n return len(self.get_all_cluster_ids())", "def count_elements_in_dataset(dataset):\n return dataset.count()", "def cluster_count(self) -> int:\n cluster_count = max(1, round(16**3 * (self.vein.pu...
[ "0.7475261", "0.73660713", "0.7281601", "0.7209829", "0.7184535", "0.71797055", "0.71275187", "0.7005667", "0.6999668", "0.69551873", "0.68624055", "0.68511283", "0.67983764", "0.6792057", "0.6780994", "0.6774845", "0.6771099", "0.66886616", "0.66632557", "0.66320395", "0.661...
0.74841356
0
Returns the percentage of elements of the clustering that are in the 4 bigger clusters.
def analysis_function_top_4(self,clustering): clustering.sort_clusters_by_size() total = 0 percents = clustering.get_population_percent_of_n_bigger_clusters(4) for p in percents: total = total+p return total
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dissimilarity(clusters):\n totDist = 0\n for c in clusters:\n totDist += c.variability()\n return totDist", "def purity_score(clusters, classes):\n clusters = np.array(clusters)\n classes = np.array(classes)\n A = np.c_[(clusters,classes)]\n\n n_accurate = 0.\n\n ...
[ "0.68239075", "0.66668284", "0.6481002", "0.6474694", "0.6268896", "0.6198322", "0.61978954", "0.6153407", "0.6145863", "0.61173046", "0.6088561", "0.6067123", "0.60514313", "0.605035", "0.60220045", "0.6007003", "0.59786797", "0.5954374", "0.5944898", "0.591898", "0.5904012"...
0.7220413
0
Returns the maximum number of clusters needed to have a percent of the total number of clustered elements.
def analysis_function_num_clusters_to_percent(self,clustering,percent): return clustering.number_of_clusters_to_get_percent(percent)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cluster_count(self) -> int:\n cluster_count = max(1, round(16**3 * (self.vein.purity / 100.0) / self.cluster_size))\n return self.distribution.scale_cluster_count(cluster_count)", "def get_clust_num_perc(model, vis_perc=0.9):\n\tnc = len(np.where(model.allocmodel.Nk > 0)[0])\n\tidx = np.argsort...
[ "0.73421067", "0.72231865", "0.6814632", "0.6761012", "0.67437637", "0.6737779", "0.6622332", "0.66150904", "0.6535396", "0.649745", "0.64956445", "0.6430533", "0.64143646", "0.6354163", "0.63429755", "0.63404", "0.6339005", "0.632302", "0.6261867", "0.62327045", "0.62271553"...
0.6772024
3
Returns the percent of elements over the total number of elements of the clustering, that have been clustered into the bigger cluster.
def analysis_function_top_percent(self,clustering): clustering.sort_clusters_by_size() return clustering.get_population_percent_of_cluster(0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analysis_function_num_clusters_to_percent(self,clustering,percent):\n return clustering.number_of_clusters_to_get_percent(percent)", "def analysis_function_top_4(self,clustering):\n clustering.sort_clusters_by_size()\n total = 0\n percents = clustering.get_population_percent_of_n_...
[ "0.7153438", "0.704848", "0.6598043", "0.65899014", "0.65830696", "0.6483606", "0.6449112", "0.6421873", "0.63327456", "0.62887275", "0.6227568", "0.6170871", "0.61646694", "0.6152447", "0.6065469", "0.6052555", "0.6034332", "0.60112214", "0.6000157", "0.5957048", "0.5954154"...
0.6579574
5
Returns the percent of noise elements in the dataset.
def analysis_function_noise_level(self, clustering, total_elements): return 100.-(clustering.total_number_of_elements/float(total_elements))*100.
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compute_noise_level(self, data):\n noise = max(data)\n noise_min = 2600\n noise_max = 4095\n ratio = (noise - noise_min)/(noise_max - noise_min)\n return int(ratio*100)", "def getNoiseVar(img,fraction=0.95):\n last_val = np.percentile(img,fraction)\n #si(img<last_val...
[ "0.68183047", "0.67847115", "0.6347133", "0.62229025", "0.61716366", "0.61085075", "0.6024723", "0.59983605", "0.59494674", "0.5946805", "0.5945206", "0.5942025", "0.5883616", "0.58745587", "0.58745587", "0.5860042", "0.5856353", "0.5841199", "0.5834648", "0.57891965", "0.578...
0.70178664
0
Returns the mean cluster size.
def analysis_function_mean_cluster_size(self,clustering): sizes = get_cluster_sizes(clustering.clusters)[1] return numpy.mean(sizes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_cluster(self, labelled_cluster):\n sum_of_points = self.sum_cluster(labelled_cluster)\n size_cluster = len(labelled_cluster)\n if self.sigma_cl1:\n size_cluster += np.sqrt(2)*self.sigma_cl1*np.random.randn()\n mean_of_points = sum_of_points * (1.0 / size_cluster)\n ...
[ "0.7243587", "0.7179832", "0.7015998", "0.7009933", "0.68922645", "0.68876517", "0.684724", "0.6808377", "0.669405", "0.6671428", "0.6667033", "0.6651806", "0.65882844", "0.6482646", "0.63869536", "0.63827366", "0.63742137", "0.63045746", "0.6303817", "0.62123394", "0.6193753...
0.8215371
0
Creates a calculator using a class.
def evaluate_with_calculator(self, clustering, key_args): calculator = key_args['class']() return calculator.evaluate(clustering, key_args['matrix'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n model = Calculator()", "def __init__(self, mode=\"Normal\"):\n\n self.mode = mode\n # minor optimization\n # apparently [] is 5x faster than list()\n # https://youtu.be/YjHsOrOOSuI?t=19m30s\n self.button = []\n \"\"\"button: List of buttons.\"\"\"\n\n ...
[ "0.6303939", "0.5606582", "0.5468204", "0.5322988", "0.53078365", "0.529308", "0.5283356", "0.5271009", "0.52677727", "0.5266936", "0.5252997", "0.5238419", "0.5233305", "0.5231769", "0.5197301", "0.51828855", "0.5182773", "0.5162779", "0.51625335", "0.51475465", "0.51475465"...
0.0
-1
This method create a project in pivotal tracker
def create_project(): client = RequestManager() project_name = "".join(choices(string.ascii_letters + string.digits, k=10)) client.set_method("POST") client.set_endpoint("/projects") body = {"name": project_name} client.set_body(json.dumps(body)) response = client.execute_request() STORED_ID['project_id'] = response.json()['id']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def project_create(project):\n client.project.create(project)", "def test_create_project(self):\n pass", "def test_create_project(self):\n pass", "def test_create_project(self):\n pass", "def create_project(self, **kwargs):\n save = kwargs.get('save', True) \n if kwarg...
[ "0.7641362", "0.74125963", "0.74125963", "0.74125963", "0.73800826", "0.7369805", "0.72611123", "0.7240642", "0.72367054", "0.7189181", "0.71309054", "0.70826024", "0.70679694", "0.7061639", "0.6987262", "0.698142", "0.696992", "0.6924102", "0.69188553", "0.6910896", "0.69103...
0.75777197
1
Static method for delete a project.
def delete_project(project_id): client = RequestManager() client.set_method("DELETE") client.set_endpoint("/projects/{0}".format(project_id)) client.execute_request()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_project(project):\n with BMI(_username, _password, constants.BMI_ADMIN_PROJECT) as bmi:\n ret = bmi.delete_project(project)\n if ret[constants.STATUS_CODE_KEY] == 200:\n click.echo(\"Success\")\n else:\n click.echo(ret[constants.MESSAGE_KEY])", "def delete...
[ "0.8128038", "0.80633974", "0.8028948", "0.78569174", "0.78183025", "0.7728668", "0.76615155", "0.7630471", "0.76140267", "0.76140267", "0.7583802", "0.75670856", "0.75328547", "0.74872017", "0.7375651", "0.7375104", "0.7346846", "0.7337656", "0.7324851", "0.73165905", "0.730...
0.76985204
6
Static method for delete all projects.
def delete_all_projects(): client = RequestManager() client.set_method("GET") client.set_endpoint("/projects") response = client.execute_request() for project in response.json(): try: ProjectHelper.delete_project(project["id"]) except TypeError: LOGGER.info(project)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n for project in Project.objects:\n project.delete()", "def __remove_all_projects__():\n p = subprocess.Popen('rm -rf {}/.wcscanner/*'.format(context.__BASE_PATH__), shell=True)\n p.wait()", "def clean_project(self, app_name=None, delete_all=False):\n\n if not ap...
[ "0.7438387", "0.74334717", "0.7418019", "0.6865698", "0.6836307", "0.6812033", "0.6775198", "0.6739514", "0.6739514", "0.6619207", "0.6606535", "0.65799767", "0.65798426", "0.65713173", "0.6563861", "0.6534334", "0.64856863", "0.6476536", "0.6473611", "0.6437883", "0.6420292"...
0.8597782
0
Static method who read all projects
def read_project(response): STORED_ID['project_id'] = response.json()["id"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_read_project(self):\n pass", "def test_read_project(self):\n pass", "def project():", "def project():", "def project():", "def test_get_projects(self):\n pass", "def get_projects_data():\n wcscanner_path = context.__BASE_PATH__ + '/.wcscanner'\n\n data = []\n for ...
[ "0.7262337", "0.7262337", "0.7255745", "0.7255745", "0.7255745", "0.7112538", "0.7085046", "0.7018626", "0.70128983", "0.6937012", "0.6859167", "0.67931646", "0.67931646", "0.67831695", "0.6778349", "0.6751696", "0.6723736", "0.67085075", "0.67051655", "0.66691184", "0.666777...
0.0
-1
Static method for delete a project.
def delete_stored_project(): client = RequestManager() client.set_method("DELETE") client.set_endpoint("/projects/{0}".format(STORED_ID['project_id'])) client.execute_request()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_project(project):\n with BMI(_username, _password, constants.BMI_ADMIN_PROJECT) as bmi:\n ret = bmi.delete_project(project)\n if ret[constants.STATUS_CODE_KEY] == 200:\n click.echo(\"Success\")\n else:\n click.echo(ret[constants.MESSAGE_KEY])", "def delete...
[ "0.8127805", "0.8062877", "0.802956", "0.7817713", "0.7729044", "0.7698603", "0.766216", "0.7631897", "0.7615524", "0.7615524", "0.7582872", "0.7567336", "0.7534077", "0.7488375", "0.73751706", "0.73750573", "0.7347409", "0.7338061", "0.73248214", "0.7316373", "0.73060185", ...
0.7856347
3
Decorator that returns 403 status if user isn't logged in instead of redirecting to the LOGIN_URL
def login_required_403(view): @wraps(view) def dec_view(request, *args, **kwargs): if not request.user.is_authenticated(): return JsonResponse({"detail": "You have to log in"}, status=403) return view(request, *args, **kwargs) return dec_view
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_required(f):\n @functools.wraps(f)\n def wrap(*args, **kwargs):\n if not user_session.is_auth:\n raise Forbidden()\n return f(*args, **kwargs)\n return wrap", "def not_authenticated(func):\n def decorated(request, *args, **kwargs):\n if request.user.is_authen...
[ "0.7650609", "0.7616408", "0.7589018", "0.7559412", "0.7558609", "0.7510281", "0.7494149", "0.7491331", "0.7440667", "0.74237275", "0.74189824", "0.74179274", "0.7398192", "0.73772556", "0.7373833", "0.73519063", "0.7316154", "0.7309339", "0.7299229", "0.7293337", "0.7288219"...
0.79399925
0
Decide where to go, dashboard if logged in, login form if not
def start_view(request): if request.user and Employee.objects.filter(user__pk=request.user.pk).exists(): if Employee.objects.get(user__pk=request.user.pk).is_manager: return HttpResponseRedirect('/dashboard') else: return HttpResponseRedirect('/employee/show/%d/' % request.user.employee_user.first().pk) else: return HttpResponseRedirect('/login/')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login(self):\n identity = request.environ.get('repoze.who.identity')\n came_from = str(request.GET.get('came_from', '')) or \\\n url('/')\n if identity:\n redirect(url(came_from))\n else:\n c.came_from = came_from\n c.login_counter...
[ "0.7260029", "0.7014417", "0.69468075", "0.6839301", "0.6821525", "0.67518455", "0.67216855", "0.6685984", "0.6685984", "0.65857905", "0.6580526", "0.657079", "0.65570045", "0.6549986", "0.65449136", "0.65154564", "0.6505277", "0.65018094", "0.64914584", "0.6470852", "0.64603...
0.0
-1
Login with an accesscode
def accesscode(request, code): employee = Employee.objects.get(access_code=code) user = employee.user user.backend = 'django.contrib.auth.backends.ModelBackend' login(request, user) return HttpResponseRedirect('/')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login():", "def login():", "def login(self):\n self.open(self.urls['login'])\n self.select_form(nr=0)\n\n self.form['custno'] = self.username\n self.form['password'] = self.password\n res = self.submit()\n \n return res", "def login():\n url = AUTH_URL ...
[ "0.7269786", "0.7269786", "0.70734197", "0.70426136", "0.6852028", "0.6803463", "0.67843354", "0.6739689", "0.6730675", "0.6720502", "0.6683724", "0.6669751", "0.66376764", "0.65688664", "0.65634507", "0.6525562", "0.651685", "0.651685", "0.649879", "0.64984405", "0.6491229",...
0.74460435
0
View for all employees (in company) or for current user dependent on employee role
def all_employees(request, company_id=None): current_employee = Employee.objects.get(user__pk=request.user.pk) company_super_user = current_employee.isCompanySuperUserOrHigher() if company_id: company = Company.objects.get(pk=company_id) else: company = current_employee.company if not current_employee.isEnsoUser() and current_employee.company.pk != company.pk: raise PermissionDenied() change_company_form = ChangeCompanyForm(initial=dict(company=company)) return TemplateResponse( request, 'all_employees.html', { 'user': request.user, 'company_super_user': company_super_user, 'company': company, 'change_company_form': change_company_form, } )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_all_employees():\n if not g.user:\n flash(\"Please login to access\", \"danger\")\n return redirect(\"/\")\n if g.user.is_admin == False:\n flash (\"Unauthorized\", \"danger\")\n return redirect(\"/login\")\n\n employees = Employee.query.all()\n \n \n ## rig...
[ "0.75012994", "0.676221", "0.675863", "0.66391176", "0.659517", "0.65067995", "0.63182765", "0.6227569", "0.62267536", "0.6176886", "0.61206603", "0.6090563", "0.6077315", "0.60686785", "0.6056699", "0.59416133", "0.5920941", "0.5915269", "0.5865308", "0.5852588", "0.5848536"...
0.7280209
1
Get all employees as json
def employees_json(request): # current_employee = Employee.objects.get(user__pk=request.user.pk) employee_list = Employee.objects.filter(manager=request.user.employee_user) employees = list() for employee in employee_list: manager_dict = model_to_dict(employee) manager_dict['first_name'] = employee.user.first_name manager_dict['last_name'] = employee.user.last_name employees.append(manager_dict) data = {"employees": employees} return JsonResponse(data=data, content_type='application/json', safe=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n employees = self.service.get_employees(strategy=selectinload)\n return self.schema.dump(employees, many=True), 200", "def employees(employee_id=None):\n\tif not employee_id:\n\t\temployee_data = _serialize_list(Employee.query.all())\n\telse:\n\t\temployee_data = _serialize_model(Em...
[ "0.80177975", "0.79526293", "0.78115326", "0.72639924", "0.7209743", "0.71376187", "0.71241915", "0.7055127", "0.7054203", "0.7002898", "0.68735474", "0.6857624", "0.68054706", "0.67973894", "0.6706132", "0.66616935", "0.6618934", "0.6581776", "0.6578094", "0.65394276", "0.64...
0.760211
3