query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Compute the gini impurity for a list of classes. This is a measure of how often a randomly chosen element drawn from the class_vector would be incorrectly labeled if it was randomly labeled according to the distribution of the labels in the class_vector. It reaches its minimum at zero when all elements of class_vector ... | def gini_impurity(class_vector):
total = len(class_vector)
num_pos = class_vector.count(1)
num_neg = total - num_pos
if total > 0:
prob_pos = num_pos/float(total)
prob_neg = num_neg/float(total)
return 2*prob_pos*prob_neg
else:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gini(rows):\n counts = class_counts(rows)\n print(counts)\n impurity = 1\n for lbl in counts:\n prob_of_lbl = counts[lbl] / float(len(rows))\n impurity -= prob_of_lbl**2\n return impurity",
"def gini_impurity(data):\n\n prob = []\n n = len(data.index) # total data points\n ... | [
"0.73807025",
"0.72979903",
"0.72321737",
"0.6795068",
"0.6787479",
"0.65622467",
"0.637955",
"0.6291121",
"0.62651414",
"0.6215346",
"0.5804098",
"0.56925905",
"0.5678609",
"0.5619187",
"0.5607442",
"0.54986185",
"0.54914355",
"0.5460855",
"0.5442869",
"0.54351074",
"0.54223... | 0.8378685 | 0 |
Compute the gini impurity gain between the previous and current classes. | def gini_gain(previous_classes, current_classes):
I_parent = gini_impurity(previous_classes)
I_child = 0
for elem in current_classes:
I_child += len(elem)/float(len(previous_classes))*gini_impurity(elem)
return I_parent - I_child | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gini_impurity(data):\n\n prob = []\n n = len(data.index) # total data points\n classes = sorted(data.iloc[:,-1].unique()) # get classes (avoids div by 0 problem later on)\n\n # iterate over classes and find probabilities for each class\n for c in classes:\n prob.append(len(data[data.iloc[... | [
"0.6717809",
"0.65849155",
"0.6540638",
"0.63112986",
"0.6284041",
"0.6152256",
"0.6056489",
"0.605309",
"0.6051348",
"0.5977174",
"0.59221053",
"0.5906966",
"0.58728397",
"0.5866957",
"0.5843274",
"0.5791209",
"0.5774667",
"0.57709247",
"0.573686",
"0.5736089",
"0.57012635",... | 0.82698166 | 0 |
Create a decision tree with a set depth limit. Starts with an empty root. | def __init__(self, depth_limit=float(20)):
self.root = None
self.depth_limit = depth_limit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_decision_tree():\n\n decision_tree_root = None\n decision_tree_root = DecisionNode(None,None,lambda feature:feature[0]==1)\n decision_tree_root.left = DecisionNode(None,None,None,1)\n decision_tree_root.right = DecisionNode(None,None,lambda feature:feature[3]==1)\n decision_tree_root.right... | [
"0.7243814",
"0.67364293",
"0.6695248",
"0.662333",
"0.64469296",
"0.6406112",
"0.63924885",
"0.63921726",
"0.6292732",
"0.6279034",
"0.62635165",
"0.6196487",
"0.61914337",
"0.61779404",
"0.6171936",
"0.6135046",
"0.6105986",
"0.6077639",
"0.60717064",
"0.6065135",
"0.606319... | 0.6852223 | 1 |
Split dataset into folds. Randomly split data into k equal subsets. Fold is a tuple (training_set, test_set). Set is a tuple (examples, classes). | def generate_k_folds(dataset, k):
# TODO: finish this.
folds = []
dataset = np.concatenate((dataset[0], np.array(dataset[1]).reshape(-1,1)), axis=1)
dataset_shape = dataset.shape
shape_test_set = int(round(dataset_shape[0]/k,0))
split_dataset = np.array_split(dataset,k,axis=0)
for i in rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def k_random_subsets(x, y, k):\n if k > len(y):\n raise Exception(\n \"Cannot split a dataset into more folds than it has rows.\")\n if k < 2:\n raise Exception(\"Cannot split a dataset into fewer than 2 fold.\")\n # Randomly shuffle dataset\n y = [[i] for i in y]\n z = np.a... | [
"0.7701635",
"0.7620068",
"0.7475226",
"0.73234177",
"0.7238",
"0.7129637",
"0.7060088",
"0.7036836",
"0.70088094",
"0.6983006",
"0.69669735",
"0.69508415",
"0.68966025",
"0.6885709",
"0.68854755",
"0.68635947",
"0.6855857",
"0.68378973",
"0.6836148",
"0.6834271",
"0.6826395"... | 0.8221672 | 0 |
Classify a list of features. Classify each feature in features as either 0 or 1. | def classify(self, features):
# TODO: finish this.
features = np.array(features)
return self.classifier.classify(features) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify(self, features):\n\n # TODO: finish this.\n class_labels = []\n # TODO: finish this.\n features = np.array(features)\n feat_shape = features.shape\n for i in range(feat_shape[0]):\n vote = np.zeros((self.num_trees))\n for j in range(self.... | [
"0.7402364",
"0.73885024",
"0.6713816",
"0.64241976",
"0.63950205",
"0.631107",
"0.62228155",
"0.6192509",
"0.61612105",
"0.6115401",
"0.6105908",
"0.6075346",
"0.6052753",
"0.6027766",
"0.60236615",
"0.602179",
"0.6021103",
"0.5999694",
"0.5990289",
"0.59827054",
"0.59547025... | 0.78751546 | 0 |
Find row with max sum using loops. This function searches through the first 100 rows, looking for the row with the max sum. (ie, add all the values in that row together). | def non_vectorized_slice(self, data):
max_sum = 0
max_sum_index = 0
for row in range(100):
temp_sum = 0
for col in range(data.shape[1]):
temp_sum += data[row][col]
if temp_sum > max_sum:
max_sum = temp_sum
max_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxsum(A):\n\tmax_ending_here = max_so_far = A[0]\n\tfor x in A[1:]:\n\t\tmax_ending_here = max(x, max_ending_here + x)\n\t\tmax_so_far = max(max_so_far, max_ending_here)\n\treturn max_so_far",
"def find_max_sum(triangle):\n while len(triangle) > 1:\n _reduce_triangle(triangle)\n return triangle... | [
"0.6447428",
"0.6199141",
"0.6182926",
"0.61813325",
"0.6149333",
"0.61328304",
"0.61170936",
"0.61016166",
"0.6083617",
"0.5933973",
"0.58219665",
"0.58142495",
"0.57945657",
"0.5766161",
"0.5755104",
"0.57222974",
"0.56822574",
"0.568043",
"0.56753737",
"0.56315535",
"0.561... | 0.6267424 | 1 |
Returns length of dtrs variable. | def __len__(self):
return len(self.dtrs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DLEN(self):",
"def CDSlen(self):\n return sum(self.exonLengths)",
"def length(self):\n\t\treturn self.n",
"def length(self):\n return self.n * self.t.length()",
"def dr_length(self):\n # note: DR chain length is a function of current IR chain state\n return self.chain_length(self.dr... | [
"0.757367",
"0.7310768",
"0.72853035",
"0.720181",
"0.71916074",
"0.7180401",
"0.7141069",
"0.7132346",
"0.7041266",
"0.7041266",
"0.7041266",
"0.7041266",
"0.7032072",
"0.6966018",
"0.6959772",
"0.6945247",
"0.69438255",
"0.6913884",
"0.6913884",
"0.6912945",
"0.69097924",
... | 0.75836295 | 0 |
Get a slice from the dtrs variable. | def __getslice__(self, i, j):
return self.dtrs[i:j] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getslice__(self, start, stop):\n return self.__getitem__(slice(start, stop, None))",
"def _get_slice(series, start, length):\n return [ int(s) for s in series[start:start+length] ]",
"def getSlice(properties=None, **kw):",
"def get_slice(self):\n return self.locs[tuple(self.indices), :... | [
"0.73521453",
"0.7051251",
"0.6853217",
"0.6842169",
"0.6817592",
"0.67877597",
"0.67511845",
"0.6736823",
"0.6705232",
"0.6694609",
"0.6642566",
"0.6573203",
"0.6558231",
"0.6538147",
"0.65251565",
"0.6510867",
"0.65033716",
"0.6498101",
"0.64980555",
"0.6453085",
"0.6450066... | 0.78590274 | 0 |
Add a chunk or token to the end of the sentence. Sets the sentence as the value of the parents variable on the chunk or token. Arguments chunkOrToken a Chunk or a Token | def add(self, chunkOrToken):
chunkOrToken.setParent(self)
self.dtrs.append(chunkOrToken)
self.positionCount += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift(self, chunk_or_token):\n # TODO if we make a new chunk, we should try to merge with previous chunk\n self.append(chunk_or_token)\n self.leaves.extend(chunk_or_token.leaves) # SPEED: do we need to keep track of leaves?\n # should probability include btp like chunkability?\n ... | [
"0.5812037",
"0.5553041",
"0.5377327",
"0.5303293",
"0.48920614",
"0.4793207",
"0.47814932",
"0.47535655",
"0.47223377",
"0.4682509",
"0.46818078",
"0.46497297",
"0.46326748",
"0.45800984",
"0.45655662",
"0.4562505",
"0.45475686",
"0.4543947",
"0.45319873",
"0.45275787",
"0.4... | 0.65574163 | 0 |
Set the parent feature of the sentence to the document. Also copies the postionCount variable of the parent to the position variable of the sentence. Arguments parent a Document | def setParent(self, parent):
self.parent = parent
self.position = parent.positionCount | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_parent(self, parent: \"BaseSegment\") -> None:\n self._parent = weakref.ref(parent)",
"def _set_parent(self, parent):\n self.__parent = parent",
"def _set_parent(self, parent):\n assert self._parent == None # implementing reparenting requires more work\n self._parent = paren... | [
"0.66021985",
"0.6460322",
"0.64285755",
"0.64018303",
"0.64018303",
"0.63796777",
"0.63580436",
"0.63079876",
"0.6304347",
"0.62769717",
"0.62769717",
"0.62769717",
"0.62769717",
"0.62743866",
"0.6249328",
"0.6204276",
"0.612029",
"0.6092895",
"0.608906",
"0.60476637",
"0.60... | 0.70319754 | 0 |
Appends a tuple of event location and event id to the eventList. Arguments evLoc an integer eid an eid | def storeEventLocation(self, evLoc, eid):
self.eventList.append((evLoc, eid)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handlelocationevent2(self, rxnemid, eid, data):\n events = LocationEvent()\n events.restore(data)\n for event in events:\n (txnemid, attrs) = event\n if \"latitude\" not in attrs or \"longitude\" not in attrs or \\\n \"altitude\" not in attrs:\n ... | [
"0.5450551",
"0.51780105",
"0.51709306",
"0.5111472",
"0.4976095",
"0.4862548",
"0.48563048",
"0.4840931",
"0.4836031",
"0.4836031",
"0.48325822",
"0.4829554",
"0.48189795",
"0.47806895",
"0.47720587",
"0.4771295",
"0.4748524",
"0.4742618",
"0.47393817",
"0.47321013",
"0.4731... | 0.8113859 | 0 |
Return the list of eLocationeid tuples of the sentence. | def get_event_list(self):
event_list = []
eventLocation = -1
for element in self:
eventLocation += 1
if element.isChunk():
event = element.embedded_event()
if event:
event_list.append((eventLocation, event.eid))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agent_locs_idx(self):\n return tuple(self.agent_locs.T)",
"def coordinates(self):\n logging.debug('Get coordinates from text')\n result = []\n blocks = self.del_comm(blocks=True)\n coor = re.compile('[FXYZ][+-]?[0-9]+(\\.[0-9]+)?')\n for line in blocks:\n ... | [
"0.5807326",
"0.57990974",
"0.5704699",
"0.5669914",
"0.5662926",
"0.5652699",
"0.5636579",
"0.5613602",
"0.5611871",
"0.5596081",
"0.5584683",
"0.55661976",
"0.55420744",
"0.55292267",
"0.55075",
"0.55",
"0.54832613",
"0.5474122",
"0.5407019",
"0.5403631",
"0.5395337",
"0.... | 0.5813015 | 0 |
Set the value of self.eventList to the list of eLocationeid tuples in the sentence. This is used by Slinket. | def set_event_list(self):
self.eventList = self.get_event_list() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storeEventLocation(self, evLoc, eid):\n self.eventList.append((evLoc, eid))",
"def set_race_events_list(self, race_events_list):\n self.race_events_list = race_events_list",
"def set_epv_list(context, epv_list):\n context.epv_list = epv_list",
"def event_list(self):\n return self.... | [
"0.61517996",
"0.58935857",
"0.5648276",
"0.5477679",
"0.54704666",
"0.54223245",
"0.54210645",
"0.53587496",
"0.5234321",
"0.52324474",
"0.52288526",
"0.5118432",
"0.5114164",
"0.5082622",
"0.50746375",
"0.507231",
"0.5070629",
"0.5049791",
"0.50336015",
"0.49970332",
"0.499... | 0.7486504 | 0 |
Returns True if the given tag occurs in the last position of the embeddedTags list, return False otherwise. Arguments tag a string indicating the tag name | def hasEmbedded(self, tag):
if self.embeddedTags and self.embeddedTags[-1] == tag:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_desired_tag(self, tag):\n if self._tags is None:\n return True\n\n if self._ignore_namespace:\n for desired_tag in self._tags:\n if tag.localname == desired_tag.localname:\n return True\n else:\n for desired_tag in self... | [
"0.6600191",
"0.65413404",
"0.65413404",
"0.6334318",
"0.6244077",
"0.6231498",
"0.6000919",
"0.59919655",
"0.5925771",
"0.59052545",
"0.58483815",
"0.5821384",
"0.5722859",
"0.5653377",
"0.5650666",
"0.5644951",
"0.5617543",
"0.5584996",
"0.55833226",
"0.5508402",
"0.5498268... | 0.81114715 | 0 |
Remove the last element of the embeddedTags list if it matches the given tag name. Arguments tag string indicating the tag name | def removeEmbedded(self, tag):
self.embeddedTags = self.embeddedTags[:-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_tag(self, tag):\n if tag in self.tags:\n index = self.tags.index(tag)\n self.tags[index:index + 1] = []\n self.stop_times[index:index + 1] = []",
"def remove_tag(self, tag: str) -> None:\n tags = self.get_tag_index()\n tags.remove(tag)\n sel... | [
"0.71258783",
"0.6490413",
"0.6207118",
"0.6183512",
"0.6183056",
"0.61378187",
"0.61319816",
"0.6104512",
"0.6059679",
"0.603455",
"0.5999017",
"0.5979706",
"0.59525454",
"0.59372836",
"0.5866756",
"0.58603024",
"0.58594096",
"0.57957584",
"0.5780259",
"0.5708107",
"0.570458... | 0.78072757 | 0 |
Create a new student task | def create_student_task(conn, student):
sql = ''' INSERT INTO Member(UID, Name, Recently, Email, Redeem, Time)
VALUES(?,?,?,?,?,?) '''
cur = conn.cursor()
cur.execute(sql, student)
conn.commit()
return cur.lastrowid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_task(self, name, date, isComplete):\n user = User.objects.create(username='userdemo')\n user.set_password('calnote24')\n user.save()\n Task.objects.create(task=name, dueDate=date, isComplete=isComplete, user_id=user.id)",
"def new_task(self):\n print \"Create a new t... | [
"0.74762267",
"0.7249947",
"0.7233924",
"0.7113564",
"0.7112261",
"0.71000606",
"0.70567805",
"0.69224226",
"0.680644",
"0.6736561",
"0.6680868",
"0.6646366",
"0.6627438",
"0.661825",
"0.66119105",
"0.66100055",
"0.655097",
"0.6484516",
"0.6440904",
"0.6434972",
"0.6434531",
... | 0.72654957 | 1 |
Import and return the Zookeeper client's scheme module. | def get_scheme_module(scheme):
plugin = None
for ep in pkg_resources.iter_entry_points(
group='zookeeper_scheme', name=scheme):
plugin = ep.load()
if plugin is None:
raise NotImplementedError('Unknown Zookeeper scheme %r' % scheme)
return plugin | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getScheme(self):\n return self._scheme",
"def _get_client_impl(self):\n api_version = self._get_api_version(None)\n if api_version not in self._client_impls:\n self._create_client_impl(api_version)\n return self._client_impls[api_version]",
"def get_backend():\n re... | [
"0.57166326",
"0.5436306",
"0.5384354",
"0.5384354",
"0.5381085",
"0.53738284",
"0.53738284",
"0.53217",
"0.5314759",
"0.53062403",
"0.52776396",
"0.52307713",
"0.5215055",
"0.52129185",
"0.51731104",
"0.5164843",
"0.51269597",
"0.51231045",
"0.5075184",
"0.50594074",
"0.5023... | 0.71707296 | 0 |
This function uses the runner.py module (passed from main()) to interact with the spoofer. Commands are cached in the runner object, then executed in the order in which they are cached without pause. | def load_and_run(runner):
#**************************************************************************************************************************
#Cache commands to be executed.
#If using -object spoofs, -enable option needs to be added as either a standalone command or an option in another command... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n while True:\n self.command = input(\"> cmd >>> \")\n self.invoker.run(self.command)",
"def run_run(self, cmds):\n pass",
"def runner():\n return CliRunner()",
"def run(self):\n self.cmdloop()",
"def run_cmd(self):\r\n self.run = True",
... | [
"0.6400778",
"0.6255735",
"0.61629844",
"0.6152687",
"0.60859656",
"0.5957929",
"0.5957929",
"0.59270674",
"0.5920345",
"0.5918524",
"0.5899732",
"0.58783096",
"0.58727956",
"0.5861363",
"0.5793535",
"0.5793535",
"0.5793535",
"0.5793535",
"0.57912457",
"0.57888985",
"0.578373... | 0.7607462 | 0 |
Calculates Trima IP address based on Trima Machine ID | def calculate_trima_address(testMachine):
_machineBase = int(testMachine/256)
_machineRemainder = int(testMachine-(_machineBase*256))
_machineBase = str(_machineBase)
_machineRemainder = str(_machineRemainder)
_address = "172.21."+_machineBase+"."+_machineRemainder
return _address | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getnetwork(ipaddr):\n return '192.168.1.0/24'",
"def find_my_IP_and_MAC():\n mac = ':'.join(re.findall('..', '%012x' % getnode()))\n # I write IP and not domain cause i want to save time.\n p = sr1(IP(dst=\"google.com\", ttl=0) / ICMP() / \"XXXXXXXXXXX\",verbose=0,timeout=5) #verbose = withuot ou... | [
"0.63714236",
"0.6345155",
"0.6292933",
"0.62112045",
"0.61601764",
"0.5959484",
"0.59357166",
"0.59201795",
"0.59106916",
"0.5841847",
"0.5831155",
"0.582097",
"0.58053356",
"0.5792286",
"0.5765562",
"0.57654613",
"0.57493234",
"0.5747046",
"0.5728458",
"0.5726557",
"0.57251... | 0.6829826 | 0 |
Persistently tests the Trima telnet socket, exits when socket is available | def auto_connect(address):
_connected=False
_timeout=100
_count = 0
while not _connected:
try:
_c = telnetlib.Telnet(address)
if _c.sock is not None:
_connected = True
except socket.error:
_count = _count + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def telnet(self):\n self.log.info(\"connect-via-telnet\")\n telnet = distutils.spawn.find_executable(\"telnet\")\n os.execv(telnet, (\"telnet\", \"localhost\", str(self.qemu.monitor_port)))",
"def test_direct_access_telnet_mode(self):\n self.assert_enter_command_mode()\n\n # go... | [
"0.6695768",
"0.65164167",
"0.64087623",
"0.6359258",
"0.62263113",
"0.61645794",
"0.6164214",
"0.61316687",
"0.6074833",
"0.60248387",
"0.6012199",
"0.60066915",
"0.6005622",
"0.59678847",
"0.5946606",
"0.5919905",
"0.5919853",
"0.58962697",
"0.5892783",
"0.5869362",
"0.5834... | 0.7031772 | 0 |
Installs the cli from the package_name | def _install_cli(self, package_name):
self.logger.info('Installing CLI')
self._execute_command('rpm -i {0}'.format(package_name), sudo=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(ctx: click.Context) -> None:\n pkg = read_package_from_file(PACKAGE_PATH)\n ctx.obj = pkg",
"def _install(package_name, package_version, options_path, app_id, cli, app,\n yes):\n\n if cli is False and app is False:\n # Install both if neither flag is specified\n cli = a... | [
"0.7080663",
"0.7058383",
"0.6961199",
"0.66153574",
"0.66055477",
"0.6596424",
"0.6547508",
"0.6413335",
"0.6406427",
"0.6329891",
"0.62676996",
"0.62452245",
"0.61811274",
"0.6162434",
"0.60319626",
"0.6025439",
"0.60217357",
"0.5980085",
"0.5961066",
"0.59439105",
"0.59246... | 0.83964264 | 0 |
Update the remote bootstrap inputs file. | def _update_inputs_file(self, additional_inputs):
# Retrieve inputs from cli vm
inputs_file = StringIO()
fab.get(self.remote_bootstrap_inputs_path, inputs_file)
inputs = yaml.load(inputs_file.getvalue())
# Update the inputs to include the additional inputs
inputs.update(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n self.save_config_file()",
"async def update(self) -> None:\n # pause logic\n if not self.running.is_set():\n self.add_to_output(\"Paused...\")\n await self.running.wait()\n\n # tell the user we are updating\n self.add_to_output(f\"Updating.... | [
"0.59347224",
"0.5556256",
"0.54522485",
"0.54481006",
"0.53520066",
"0.53520066",
"0.53147256",
"0.5312098",
"0.52917486",
"0.52783805",
"0.5275859",
"0.5236612",
"0.5234436",
"0.5219503",
"0.5201954",
"0.5128426",
"0.51037234",
"0.5083602",
"0.507815",
"0.5077419",
"0.50774... | 0.75550455 | 0 |
Upload blueprint to the vm | def _upload_blueprint(self, blueprint_path, blueprint_id,
blueprint_name):
self._execute_command('blueprints upload -p {0}/blueprint.yaml'
' -b {1}'.format(blueprint_path,
blueprint_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_blueprint(blueprint_path, blueprint_id, environment):\n environment.add_cleanup(\n environment.cfy.blueprints.delete,\n kwargs={\n 'blueprint_id': blueprint_id,\n },\n )\n environment.cfy.blueprints.upload(\n blueprint_path=blueprint_path,\n bluepri... | [
"0.65127957",
"0.6102187",
"0.6026222",
"0.5991054",
"0.5846473",
"0.57867235",
"0.5629633",
"0.5614624",
"0.5601592",
"0.55498195",
"0.55361706",
"0.54841506",
"0.54840523",
"0.5479049",
"0.5425803",
"0.54044706",
"0.5398172",
"0.5396657",
"0.5387243",
"0.5377103",
"0.535729... | 0.72788787 | 0 |
Receives an url and translate the netloc part (portless) to an ip, and retrieves a tuple with the source netloc and the translated ip | def _resolve_url_to_ip_and_netloc(self, url):
netloc = urlparse.urlsplit(url).netloc
url_base = netloc.split(':')[0] if ':' in netloc else netloc
return gethostbyname(url_base), url_base | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urlToIp(self, url):\n return str(socket.gethostbyname(url))",
"def get_adjusted_url(url: str, addr: AddressTupleVXType) -> str:\n if len(addr) < 4:\n return url\n\n addr = cast(AddressTupleV6Type, addr)\n\n if not addr[3]:\n return url\n\n data = urlsplit(url)\n try:\n ... | [
"0.68437105",
"0.6665156",
"0.6502783",
"0.6373734",
"0.6336872",
"0.6209224",
"0.5958879",
"0.5928628",
"0.58836883",
"0.5867913",
"0.5862978",
"0.58541363",
"0.58308536",
"0.5799374",
"0.5778159",
"0.5757957",
"0.57384354",
"0.573182",
"0.57005626",
"0.5699861",
"0.56700546... | 0.730634 | 0 |
Runs a command on a remote machine using fabric (would work only on machines with fabric). | def _run_cmd_on_custom_machine(self, cmd, fab_conf, sudo=False, retries=3):
with fab_env(**fab_conf):
self._execute_command(cmd, sudo=sudo, retries=retries) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _run_cmd_on_remote_machine(machine_name, command, vm_executor=None):\n if not vm_executor:\n vm_executor = get_vm_executor(machine_name)\n rc, _, error = vm_executor.run_cmd(cmd=shlex.split(command))\n if rc:\n logger.error(\n \"Failed to run command %s on %s, error: %s\",\n ... | [
"0.72550815",
"0.6988814",
"0.69370776",
"0.68817985",
"0.66340566",
"0.6467718",
"0.64534795",
"0.6369463",
"0.6357612",
"0.62907887",
"0.6241285",
"0.6171651",
"0.6158896",
"0.6134466",
"0.61164546",
"0.6072727",
"0.60724485",
"0.6060877",
"0.6060648",
"0.6044946",
"0.60299... | 0.7038928 | 1 |
Retrieves manager kp to the local machine. | def _get_manager_kp(self):
remote_manager_kp_path = self.bootstrap_inputs['ssh_key_filename']
local_manager_kp = fab.get(remote_manager_kp_path, self.workdir)[0]
os.chmod(local_manager_kp, stat.S_IRUSR | stat.S_IWUSR)
return local_manager_kp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetMachineKey():\n return platform.node()",
"def get_master_key():\n query = {\n \"type\": \"op\",\n \"cmd\": \"<show><system><masterkey-properties></masterkey-properties></system></show>\",\n }\n\n return __proxy__[\"panos.call\"](query)",
"def get_manager_ip():\n return os.envi... | [
"0.5841112",
"0.5680606",
"0.5378721",
"0.53647625",
"0.5353442",
"0.5296647",
"0.52624357",
"0.5253235",
"0.52426684",
"0.5199374",
"0.5137175",
"0.512449",
"0.5099789",
"0.50872433",
"0.5084363",
"0.50633115",
"0.5050942",
"0.5049516",
"0.50137377",
"0.49826017",
"0.4980333... | 0.69865656 | 0 |
Returns inputs for the file server vm. | def _get_file_server_inputs(self):
return {
'prefix': '{0}-FileServer'.format(self.prefix),
'external_network': self.env.external_network_name,
'os_username': self.env.keystone_username,
'os_password': self.env.keystone_password,
'os_tenant_name': self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inputs(self):\n return {\n \"path_to_result_folder\": File_IO(self.node.inputs[0]),\n \"path_to_dtb_json_file\": File_IO(self.node.inputs[1]),\n \"path_to_reference_DTB\": File_IO(self.node.inputs[2])\n }",
"def get_input_contents(self):\n ... | [
"0.665514",
"0.6524866",
"0.64851344",
"0.6328322",
"0.6287372",
"0.62354547",
"0.6069412",
"0.604539",
"0.60342443",
"0.60341674",
"0.601997",
"0.601997",
"0.6015647",
"0.60103893",
"0.60103893",
"0.60103893",
"0.5998729",
"0.5978003",
"0.5948531",
"0.58620423",
"0.5851868",... | 0.74200696 | 0 |
Boots up the file server vm. | def boot(self):
self.logger.info('Initializing file server env')
self.local_env = local.init_env(self.blueprint_path,
inputs=self.inputs,
name='File-Server',
ignored_modules=cli_consta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boot_VM(self, server, vmfile):\n vmaddr = \"\"\n fail = False\n \n #print vmfile\n #-----read template into string -------------------------\n #s=open('./share/examples/ubuntu_context.one','r').read()\n \n s = open(os.path.expanduser(vmfile), 'r').read()\n ... | [
"0.683669",
"0.6447494",
"0.6205833",
"0.6192802",
"0.61910427",
"0.606847",
"0.60515213",
"0.5951176",
"0.58654577",
"0.583818",
"0.5828927",
"0.58267725",
"0.5775121",
"0.5748484",
"0.57223445",
"0.5719519",
"0.5716458",
"0.5713793",
"0.5611921",
"0.55675846",
"0.5564731",
... | 0.79838514 | 0 |
A helper method which calls the _process_resources method. | def process_resources(self):
self.processed_inputs = self._process_resources(self.resources)
return self.processed_inputs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanupResources():\n None",
"def resources():\n check_resources()",
"def process_resource_listing(self, resources, context):\n pass",
"def pre_process_resource(self):\n\n # get list of resource files\n files = [os.path.join(self.resource_folder, f) for f in os.listdir(self.resou... | [
"0.6298208",
"0.6276404",
"0.60778886",
"0.5955417",
"0.59016514",
"0.58245045",
"0.5729675",
"0.5619209",
"0.55990064",
"0.55025375",
"0.54845834",
"0.54775596",
"0.54441214",
"0.54441214",
"0.54441214",
"0.5442113",
"0.5442113",
"0.5442113",
"0.54214376",
"0.53472185",
"0.5... | 0.65505105 | 0 |
Downloads the supplied resource to the file server and returns an url on the file server | def _process_resource(self, url):
url_parts = urlparse.urlsplit(url)
rel_path = url_parts.path[1:]
fs_path = os.path.join(self.fileserver_path, rel_path)
self.logger.info('Downloading {0} to {1}'.format(url, fs_path))
self._execute_command('curl --create-dirs -Lo {0} {1}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getFile_httplib(self, _src, _dst):\n\n #-------------------- \n # Pre-download callbacks\n #-------------------- \n self.runEventCallbacks('downloadStarted', _src, -1)\n self.runEventCallbacks('downloading', _src, 0)\n\n\n\n #-----------------... | [
"0.70962745",
"0.6961678",
"0.69553584",
"0.6765684",
"0.6765684",
"0.6732035",
"0.66910666",
"0.6672155",
"0.6671619",
"0.6602121",
"0.65979594",
"0.6570972",
"0.6558804",
"0.6554229",
"0.6550992",
"0.6540445",
"0.64977056",
"0.64618903",
"0.6446249",
"0.6444038",
"0.6435746... | 0.7102686 | 0 |
tears down the file server vm | def teardown(self):
self.logger.info('Tearing down file server vm')
self.local_env.execute('uninstall', task_retries=40,
task_retry_interval=30) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def down():\n\n # Stop the program if no init has occurred.\n Vagrant.stop_if_not_init()\n\n # Run vagrant halt from the vagrant folder.\n command = [\"vagrant\", \"halt\"]\n cwd = Settings.devbox_folder\n try:\n result = subprocess.check_call(command, cwd=cwd)\... | [
"0.62946844",
"0.6023637",
"0.59142655",
"0.5879233",
"0.58045673",
"0.58014715",
"0.57061315",
"0.56284416",
"0.56023043",
"0.55892366",
"0.55795544",
"0.55300033",
"0.5502892",
"0.5448816",
"0.54444844",
"0.5427505",
"0.54094344",
"0.5400994",
"0.53717744",
"0.5357987",
"0.... | 0.6838251 | 0 |
Starts up the file server service on the running vm | def run(self):
# Needed in order to start the file server in detached mode.
self._execute_command('yum install -y screen', sudo=True, retries=5)
self.logger.info('Starting up SimpleHTTPServer on {0}'
.format(self.port))
self._execute_command('cd {0} && screen -d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boot(self):\n self.logger.info('Initializing file server env')\n self.local_env = local.init_env(self.blueprint_path,\n inputs=self.inputs,\n name='File-Server',\n ignored_modules=... | [
"0.6858126",
"0.6602053",
"0.6480615",
"0.62400424",
"0.6163618",
"0.6163618",
"0.6140013",
"0.6119713",
"0.61066234",
"0.61063904",
"0.60983294",
"0.6067171",
"0.6067169",
"0.6064662",
"0.60223347",
"0.5941057",
"0.59391016",
"0.59325516",
"0.58686256",
"0.58279663",
"0.5816... | 0.67515 | 1 |
Estimate the diffusion coefficient of a PFAS. Based on a linear regression of the diffusion coefficient of 10 PFAS against their structural properties. | def estimate_diffusion_coefficient(n_CFx: int) -> t.Diffusivity:
return t.Diffusivity(10 ** (-4.5360 + -0.1088 * n_CFx), "cm^2/s") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate(self):\n\n tp = self.confusion_matrix.tp\n tn = self.confusion_matrix.tn\n fp = self.confusion_matrix.fp\n fn = self.confusion_matrix.fn\n n = self.confusion_matrix.n\n\n fp_tn = tn + fp\n tp_fn = fn + tp\n tn_fn = tn + fn\n tp_fp = fp + ... | [
"0.56449187",
"0.5518597",
"0.542095",
"0.537209",
"0.53410685",
"0.5261813",
"0.5241331",
"0.52351385",
"0.5195364",
"0.51907176",
"0.5185065",
"0.51823",
"0.5179632",
"0.5149934",
"0.5141564",
"0.51331025",
"0.5114608",
"0.51085895",
"0.5102013",
"0.50847006",
"0.50690573",... | 0.5830109 | 0 |
Update distributed bag of words model ("PVDBOW") by training on a single document. Called internally from `Doc2Vec.train()` and `Doc2Vec.infer_vector()`. The document is provided as `doc_words`, a list of word tokens which are looked up in the model's vocab dictionary, and `doctag_indexes`, which provide indexes into t... | def train_document_dbow(model, doc_words, doctag_indexes, alpha, work=None,
train_words=False, learn_doctags=True, learn_words=True, learn_hidden=True,
word_vectors=None, word_locks=None, doctag_vectors=None, doctag_locks=None):
if doctag_vectors is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_document_dm(model, doc_words, doctag_indexes, alpha, work=None, neu1=None,\n learn_doctags=True, learn_words=True, learn_hidden=True,\n word_vectors=None, word_locks=None, doctag_vectors=None, doctag_locks=None):\n if word_vectors is None:\n ... | [
"0.79926264",
"0.75502294",
"0.63222104",
"0.6145164",
"0.5955723",
"0.586933",
"0.5594037",
"0.5588973",
"0.54804456",
"0.54591274",
"0.5432434",
"0.54141957",
"0.5407816",
"0.53829443",
"0.5375107",
"0.53585047",
"0.53382105",
"0.5225454",
"0.5224787",
"0.52226096",
"0.5211... | 0.79236776 | 1 |
Update distributed memory model ("PVDM") by training on a single document. Called internally from `Doc2Vec.train()` and `Doc2Vec.infer_vector()`. This method implements the DM model with a projection (input) layer that is either the sum or mean of the context vectors, depending on the model's `dm_mean` configuration fi... | def train_document_dm(model, doc_words, doctag_indexes, alpha, work=None, neu1=None,
learn_doctags=True, learn_words=True, learn_hidden=True,
word_vectors=None, word_locks=None, doctag_vectors=None, doctag_locks=None):
if word_vectors is None:
word... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_document_dm_concat(model, doc_words, doctag_indexes, alpha, work=None, neu1=None, learn_doctags=True,\n learn_words=True, learn_hidden=True, word_vectors=None, word_locks=None,\n doctag_vectors=None, doctag_locks=None):\n if word_vect... | [
"0.7603625",
"0.70882034",
"0.66423994",
"0.65848994",
"0.65817595",
"0.64278585",
"0.6005313",
"0.58777744",
"0.5845338",
"0.5782057",
"0.56629074",
"0.5568347",
"0.55581313",
"0.549562",
"0.549104",
"0.5476602",
"0.544543",
"0.5405451",
"0.54015756",
"0.5399115",
"0.5364533... | 0.78327817 | 0 |
Update distributed memory model ("PVDM") by training on a single document, using a concatenation of the context window word vectors (rather than a sum or average). Called internally from `Doc2Vec.train()` and `Doc2Vec.infer_vector()`. The document is provided as `doc_words`, a list of word tokens which are looked up in... | def train_document_dm_concat(model, doc_words, doctag_indexes, alpha, work=None, neu1=None, learn_doctags=True,
learn_words=True, learn_hidden=True, word_vectors=None, word_locks=None,
doctag_vectors=None, doctag_locks=None):
if word_vectors is N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_document_dm(model, doc_words, doctag_indexes, alpha, work=None, neu1=None,\n learn_doctags=True, learn_words=True, learn_hidden=True,\n word_vectors=None, word_locks=None, doctag_vectors=None, doctag_locks=None):\n if word_vectors is None:\n ... | [
"0.78781396",
"0.7300068",
"0.67850834",
"0.6427141",
"0.6403372",
"0.6146062",
"0.6120217",
"0.60193247",
"0.59781265",
"0.5820815",
"0.5796284",
"0.57647747",
"0.5731081",
"0.57290953",
"0.5727865",
"0.57001203",
"0.56555825",
"0.56341076",
"0.56302285",
"0.5595509",
"0.558... | 0.7702963 | 1 |
Update the model's neural weights from a sequence of sentences (can be a onceonly generator stream). The `documents` iterable can be simply a list of TaggedDocument elements. To support linear learningrate decay from (initial) alpha to min_alpha, and accurate progresspercentage logging, either total_examples (count of ... | def train(self, documents, total_examples=None, total_words=None,
epochs=None, start_alpha=None, end_alpha=None,
word_count=0, queue_factor=2, report_delay=1.0, callbacks=()):
super(Doc2Vec, self).train(
documents, total_examples=total_examples, total_words=total_words,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(self, documents):\n n_words_trained = 0\n tokens, self.vocab, data, self._frequencies, self.diction, self.reverse_diction = self._build_dataset(\n documents)\n n_tokens = len(tokens)\n n_vocab = len(self.vocab)\n words_per_epoch = n_vocab / self.n_epochs\n ... | [
"0.6867098",
"0.64065486",
"0.6115484",
"0.5885383",
"0.5835043",
"0.5814519",
"0.5678231",
"0.56766325",
"0.5675677",
"0.5671914",
"0.5653446",
"0.5640399",
"0.5640204",
"0.5636078",
"0.55998266",
"0.55976844",
"0.5581285",
"0.55693275",
"0.5545936",
"0.5542861",
"0.55382824... | 0.65039164 | 1 |
Return the number of words in a given job. | def _raw_word_count(self, job):
return sum(len(sentence.words) for sentence in job) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordCount(document):\n return float(len(document.split(None)))",
"def count(word):\n\n return len(word)",
"def count_word(doc):\n count = count = 0\n for w in document.split(\" \"):\n count = count + 1\n return count",
"def word_count(self):\n print(self.words())\n ... | [
"0.6820945",
"0.6817843",
"0.6798632",
"0.6723702",
"0.66908073",
"0.66856277",
"0.6659709",
"0.6657253",
"0.6635957",
"0.6606215",
"0.6599631",
"0.65776736",
"0.6558064",
"0.6525626",
"0.6511784",
"0.6482664",
"0.6470974",
"0.6446207",
"0.6417434",
"0.64114434",
"0.6386982",... | 0.81130654 | 0 |
Estimated memory for tag lookup; 0 if using pure int tags. | def estimated_lookup_memory(self):
return 60 * len(self.docvecs.offset2doctag) + 140 * len(self.docvecs.doctags) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag(self):\n if self.is_int():\n return OCamlValue.INT_TAG\n else:\n hd = self.hd()\n if hd is None:\n return OCamlValue.OUT_OF_HEAP_TAG\n return hd & 0xFF",
"def memory_get_usage():\n raise NotImplementedError()",
"def byte_count(self):\n if hasattr(s... | [
"0.6647687",
"0.5648259",
"0.56104136",
"0.5584556",
"0.5584297",
"0.55617744",
"0.5505808",
"0.54545164",
"0.543588",
"0.53140754",
"0.5297253",
"0.5268041",
"0.5267242",
"0.5246451",
"0.5196994",
"0.519184",
"0.5179596",
"0.5162446",
"0.5143764",
"0.514188",
"0.5141004",
... | 0.6860363 | 0 |
Test discrete RGB colormap | def test_colormap_discrete():
with TestingCanvas(size=size, bgcolor='w') as c:
idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
data = idata.reshape((size[0], size[1]))
image = Image(cmap=Colormap(colors=['r', 'g', 'b'],
interpolation='zero'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_colormap() -> None:\n colors_arr_rgb = color_utils.create_colormap(\n color_list=[RED_HEX, GREEN_HEX], n_colors=10\n )\n assert np.logical_and(0 <= colors_arr_rgb, colors_arr_rgb <= 1).all()\n\n assert colors_arr_rgb.shape == (10, 3)",
"def test_colormap_discrete_nu():\n wit... | [
"0.73026437",
"0.7008918",
"0.6819962",
"0.6733769",
"0.6619444",
"0.633556",
"0.6261674",
"0.6238701",
"0.6235097",
"0.6226245",
"0.6161842",
"0.6145873",
"0.6128191",
"0.6102514",
"0.6097905",
"0.60928637",
"0.6082302",
"0.60775137",
"0.605983",
"0.6054012",
"0.6042657",
... | 0.7960902 | 0 |
Test discrete colormap with nonuniformly distributed controlpoints | def test_colormap_discrete_nu():
with TestingCanvas(size=size, bgcolor='w') as c:
idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
data = idata.reshape((size[0], size[1]))
image = Image(cmap=Colormap(np.array([[0, .75, 0], [.75, .25, .5]]),
[0., .25, 1.], i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_colormap_discrete():\n with TestingCanvas(size=size, bgcolor='w') as c:\n idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)\n data = idata.reshape((size[0], size[1]))\n image = Image(cmap=Colormap(colors=['r', 'g', 'b'],\n interpolation='zero'),\n ... | [
"0.6624429",
"0.63820595",
"0.61120087",
"0.6093965",
"0.60340226",
"0.5970917",
"0.5850683",
"0.58167857",
"0.5809207",
"0.58063346",
"0.57994497",
"0.57855386",
"0.577427",
"0.57374465",
"0.573375",
"0.5728843",
"0.5728843",
"0.5728843",
"0.5713697",
"0.5713697",
"0.5713697... | 0.6497417 | 1 |
Test colormap support using a single hue() | def test_colormap_single_hue():
with TestingCanvas(size=size, bgcolor='w') as c:
idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
data = idata.reshape((size[0], size[1]))
image = Image(cmap=get_colormap('single_hue', 255),
clim='auto', parent=c.scene)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_colormap() -> None:\n colors_arr_rgb = color_utils.create_colormap(\n color_list=[RED_HEX, GREEN_HEX], n_colors=10\n )\n assert np.logical_and(0 <= colors_arr_rgb, colors_arr_rgb <= 1).all()\n\n assert colors_arr_rgb.shape == (10, 3)",
"def uniqueish_color(color_data):\n # r... | [
"0.65957767",
"0.6550086",
"0.6411379",
"0.6387446",
"0.634306",
"0.62573284",
"0.61561096",
"0.61391234",
"0.61386985",
"0.6109136",
"0.6089537",
"0.60745263",
"0.6070712",
"0.6044432",
"0.6033722",
"0.59900755",
"0.59316707",
"0.5897581",
"0.5896951",
"0.57999164",
"0.57962... | 0.76788133 | 0 |
Test colormap support using coolwarm preset colormap | def test_colormap_coolwarm():
with TestingCanvas(size=size, bgcolor='w') as c:
idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
data = idata.reshape((size[0], size[1]))
image = Image(cmap='coolwarm', clim='auto', parent=c.scene)
image.set_data(data)
assert_image_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_colormap():\n with TestingCanvas(size=size, bgcolor='w') as c:\n idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)\n data = idata.reshape((size[0], size[1]))\n image = Image(cmap=Colormap(colors=['k', 'w', 'r'],\n controls=[0.0, 0.1, 1.0]),\n ... | [
"0.7019453",
"0.6978676",
"0.66126335",
"0.65915483",
"0.648212",
"0.64730215",
"0.6012968",
"0.59697264",
"0.5965611",
"0.59373826",
"0.59310603",
"0.59185946",
"0.5891947",
"0.58199126",
"0.5767285",
"0.57639974",
"0.57369447",
"0.5725524",
"0.57183725",
"0.56433",
"0.56433... | 0.78419524 | 0 |
Test colormap support using cubehelix colormap in only blues | def test_colormap_CubeHelix():
with TestingCanvas(size=size, bgcolor='w') as c:
idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)
data = idata.reshape((size[0], size[1]))
image = Image(cmap=get_colormap('cubehelix', rot=0, start=0),
clim='auto', parent=c.sce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_colormap() -> None:\n colors_arr_rgb = color_utils.create_colormap(\n color_list=[RED_HEX, GREEN_HEX], n_colors=10\n )\n assert np.logical_and(0 <= colors_arr_rgb, colors_arr_rgb <= 1).all()\n\n assert colors_arr_rgb.shape == (10, 3)",
"def test_colormap_single_hue():\n with... | [
"0.67263085",
"0.6543223",
"0.63570994",
"0.6314773",
"0.63106954",
"0.6275166",
"0.62280506",
"0.6093436",
"0.6074464",
"0.6061234",
"0.6043875",
"0.60259485",
"0.5951045",
"0.5941131",
"0.5916475",
"0.5878508",
"0.58566594",
"0.58320254",
"0.57350576",
"0.5683548",
"0.56795... | 0.755083 | 0 |
Directly solve the full master equation using a stiff ODE solver. Pass the reaction `network` to solve, the temperature `T` in K and pressure `P` in Pa to solve at, the energies `Elist` in J/mol to use, the output time points `tlist` in s, the initial total populations `x0`, the full master equation matrix `M`, the acc... | def solveFullME(T, P, Elist, tlist, x0, M, indices, densStates, Nisom, Nreac, Nprod):
Ngrains = len(Elist)
Ntime = len(tlist)
# Get equilibrium distributions
eqDist = numpy.zeros_like(densStates)
for i in range(Nisom):
eqDist[i,:] = densStates[i,:] * numpy.exp(-Elist / constants.R / T)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solveReducedME(T, P, Elist, tlist, x0, K, p0, Nisom, Nreac, Nprod):\n \n Ngrains = len(Elist)\n Ntime = len(tlist)\n\n # Set up ODEs\n ode = scipy.integrate.ode(residual, jacobian)\n ode.set_integrator('vode', method='bdf', with_jacobian=True, atol=1e-16, rtol=1e-8)\n ode.set_initial_value... | [
"0.60879964",
"0.53004754",
"0.5215178",
"0.51665604",
"0.5158384",
"0.5117445",
"0.50782996",
"0.5022356",
"0.49960172",
"0.49876896",
"0.49730378",
"0.495564",
"0.4951337",
"0.49296185",
"0.49192217",
"0.4840896",
"0.48262826",
"0.4819862",
"0.47377893",
"0.47311056",
"0.47... | 0.68325925 | 0 |
Directly solve a reduced master equation (set of phenomenological rate coefficients) using a stiff ODE solver. Pass the reaction `network` to solve, the temperature `T` in K and pressure `P` in Pa to solve at, the energies `Elist` in J/mol to use, the output time points `tlist` in s, the initial total populations `x0`,... | def solveReducedME(T, P, Elist, tlist, x0, K, p0, Nisom, Nreac, Nprod):
Ngrains = len(Elist)
Ntime = len(tlist)
# Set up ODEs
ode = scipy.integrate.ode(residual, jacobian)
ode.set_integrator('vode', method='bdf', with_jacobian=True, atol=1e-16, rtol=1e-8)
ode.set_initial_value(x0, 0.0).set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solveFullME(T, P, Elist, tlist, x0, M, indices, densStates, Nisom, Nreac, Nprod):\n\n Ngrains = len(Elist)\n Ntime = len(tlist)\n\n # Get equilibrium distributions\n eqDist = numpy.zeros_like(densStates)\n for i in range(Nisom):\n eqDist[i,:] = densStates[i,:] * numpy.exp(-Elist / constan... | [
"0.636756",
"0.5585631",
"0.5429672",
"0.53759384",
"0.5198647",
"0.5082748",
"0.5073756",
"0.5061823",
"0.50435406",
"0.5030891",
"0.50239396",
"0.499394",
"0.49857205",
"0.49410942",
"0.49370608",
"0.49353394",
"0.4931221",
"0.4906773",
"0.48926893",
"0.4883455",
"0.4871335... | 0.6954911 | 0 |
Check all files in the supplied database file. If modification data disagrees, files are listed in the summary. Newly added files and removed files are detected and reported. | def check(self):
self.logger.info("Performing check ... (database file: '%s')" % self.config.database)
# read the database file
try:
f = open(self.config.database)
data = json.load(f)
f.close()
except Exception, ex:
self.logger.error("Could... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_new_files(self):\r\n in_file_system = self._find_data_files(self.basepath,\r\n self.data_file_extension, [])\r\n status_msg('Search for data files. Found: {0}'.format(\r\n len(in_file_system)), True\r\n )\r\n status_msg('... | [
"0.6623592",
"0.6483976",
"0.62696517",
"0.62353367",
"0.62219197",
"0.6210582",
"0.6160347",
"0.61149067",
"0.6111934",
"0.6090724",
"0.60488236",
"0.6032923",
"0.5979085",
"0.5929752",
"0.59277785",
"0.5921432",
"0.58732927",
"0.5862061",
"0.5861869",
"0.5854398",
"0.582454... | 0.73983574 | 0 |
Setup an example patients generator instance so can use the record | def setUp(self):
patientgen = PatientsGenerator(0, 1, 0, 'a')
self.record = patientgen.data.find('record')
self.gender_sex = patientgen.gender_sex_list
self.ethnicities = patientgen.ethnicity_list
# self.female_names = patientgen.data_generator.first_names_female
# self.m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n bed_patient = PatientsGenerator(0, 1, 0, 'a')\n self.admitgen = AdmissionsGenerator(bed_patient, [-1])",
"def generator_setup():\n PaaSPureGenerator()",
"def setUp(self):\n gen = UsersGenerator({})\n gen.generate_adt_user()\n self.record = gen.class_data... | [
"0.71427894",
"0.66291034",
"0.6351889",
"0.6007622",
"0.5995672",
"0.59895307",
"0.59630615",
"0.59570193",
"0.5947998",
"0.5933524",
"0.5921211",
"0.58482414",
"0.5835242",
"0.58160454",
"0.58036965",
"0.58016294",
"0.5794783",
"0.5776991",
"0.5760297",
"0.57565296",
"0.575... | 0.77882487 | 0 |
Make sure the date of birth field is correct | def test_dob_field(self):
dob_field = self.record.find('field[@name=\'dob\']')
dob_date = datetime.strptime(dob_field.text, '%Y-%m-%d %H:%M:%S')
self.assertTrue(isinstance(dob_date, datetime), 'Date isn\'t correct') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_birth_date(self):\n\n sent_date = self.cleaned_data['birth_date']\n current_date = localtime(now()).date()\n\n if (sent_date - current_date) > datetime.timedelta(seconds=1):\n raise ValidationError(INVALID_BIRTH_DATE_VALUE)\n else:\n return sent_date",
... | [
"0.77759165",
"0.73787755",
"0.7354402",
"0.7318125",
"0.717385",
"0.71735734",
"0.71554697",
"0.70415664",
"0.7004581",
"0.6977824",
"0.6909213",
"0.68945795",
"0.6813687",
"0.6761482",
"0.6706015",
"0.6702303",
"0.66850865",
"0.6673903",
"0.66576815",
"0.66422725",
"0.65526... | 0.75534785 | 1 |
Make sure that the gender and sex selection is in the options and both as the same | def test_gender_sex(self):
gender_field = self.record.find('field[@name=\'gender\']')
sex_field = self.record.find('field[@name=\'sex\']')
self.assertIn(gender_field.text, self.gender_sex,
'Gender not in selection')
self.assertIn(sex_field.text, self.gender_sex,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _forcesetgender(self, ctx, *args):\n if len(args) < 2:\n await ctx.send(\"Include both a name and a gender!\")\n return\n\n god = database.getGodName(args[0], ctx.guild.id)\n if god:\n if len(args[1]) > 19:\n await ctx.send(\"Please cho... | [
"0.631765",
"0.62156385",
"0.600688",
"0.5938154",
"0.58843684",
"0.5872416",
"0.5591465",
"0.5574258",
"0.55489534",
"0.5503156",
"0.54436326",
"0.5412696",
"0.54055613",
"0.5380048",
"0.5342449",
"0.5327033",
"0.53126705",
"0.5310153",
"0.5305882",
"0.52982527",
"0.5273115"... | 0.72093195 | 0 |
Make sure that the ethnicity is in the ethnicity list | def test_ethnicity(self):
ethnicity_field = self.record.find('field[@name=\'ethnicity\']')
self.assertIn(ethnicity_field.text, self.ethnicities,
'Ethnicity not in the options') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ethnicity_ontology_term_id(self):\n\n # If organism_ontolology_term_id is \"NCBITaxon:9606\" for Homo sapiens,\n # this MUST be either a HANCESTRO term or \"unknown\" if unavailable.\n self.validator.adata.obs[\"organism_ontology_term_id\"][0] = \"NCBITaxon:9606\"\n self.valida... | [
"0.5805901",
"0.57099026",
"0.57011706",
"0.5435024",
"0.5362998",
"0.53140974",
"0.528038",
"0.5266432",
"0.5223643",
"0.5222157",
"0.51078445",
"0.5096213",
"0.5088896",
"0.5065306",
"0.50623506",
"0.5052547",
"0.5036733",
"0.50183624",
"0.49820358",
"0.4965812",
"0.4963622... | 0.7727078 | 0 |
Make sure the patient identifier is in NHSNUM0000 | def test_patient_identifier(self):
patient_id_field = \
self.record.find('field[@name=\'patient_identifier\']')
self.assertEqual(patient_id_field.text, 'NHSNUM0000',
'Patient Identifier incorrect') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_identifier(identifier: str) -> bool:\n if identifier[:2] == 'NR':\n return True\n\n if len(identifier) < 9:\n return False\n\n try:\n d = int(identifier[-7:])\n if d == 0:\n return False\n except ValueError:\n ... | [
"0.6227075",
"0.58241826",
"0.57453054",
"0.5722022",
"0.5658585",
"0.56198573",
"0.5532343",
"0.5529381",
"0.5491678",
"0.54758656",
"0.5471566",
"0.54567116",
"0.5449605",
"0.5417778",
"0.5379098",
"0.5364162",
"0.5342147",
"0.533969",
"0.5339025",
"0.5334108",
"0.53334147"... | 0.6610489 | 0 |
Make sure the other identifier is in HOSNUM0000 | def test_other_identifier(self):
other_id_field = \
self.record.find('field[@name=\'other_identifier\']')
self.assertEqual(other_id_field.text, 'HOSNUM0000',
'other Identifier incorrect') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accession_old(self):\n if not self.obo_id and self.short_form:\n log = logging.getLogger('ols_errors')\n log.error('[NO_OBO_ID][%s][%s]', self.short_form, self.iri)\n # guess\n sp = self.short_form.split('_')\n if len(sp) == 2:\n self... | [
"0.56494665",
"0.5617209",
"0.5536485",
"0.5514803",
"0.5508785",
"0.5386164",
"0.5369357",
"0.53556854",
"0.53371954",
"0.5216614",
"0.5182966",
"0.51656324",
"0.5131948",
"0.51188236",
"0.51137173",
"0.5095753",
"0.50841594",
"0.5067937",
"0.50158286",
"0.50096875",
"0.5005... | 0.59916264 | 0 |
Make sure the current location id is the bed | def test_current_location_id_bed(self):
bed_field = self.record.find('field[@name=\'current_location_id\']')
self.assertEqual(bed_field.attrib['ref'],
'nhc_def_conf_location_wa_b1',
'Incorrect bed defined') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_current_location_id_ward(self):\n ward_data = PatientsGenerator(0, 0, 1, 'a')\n record = ward_data.data.find('record')\n bed_field = record.find('field[@name=\\'current_location_id\\']')\n self.assertEqual(bed_field.attrib['ref'],\n 'nhc_def_conf_locatio... | [
"0.7753004",
"0.6446672",
"0.63836956",
"0.6188404",
"0.61282825",
"0.6036391",
"0.5994112",
"0.5794608",
"0.5779505",
"0.57673836",
"0.57654405",
"0.5751814",
"0.5710679",
"0.5700644",
"0.56914634",
"0.56741476",
"0.5642299",
"0.56307256",
"0.56280136",
"0.56235397",
"0.5611... | 0.7855332 | 0 |
Make sure the current location id is the bed | def test_current_location_id_ward(self):
ward_data = PatientsGenerator(0, 0, 1, 'a')
record = ward_data.data.find('record')
bed_field = record.find('field[@name=\'current_location_id\']')
self.assertEqual(bed_field.attrib['ref'],
'nhc_def_conf_location_wa',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_current_location_id_bed(self):\n bed_field = self.record.find('field[@name=\\'current_location_id\\']')\n self.assertEqual(bed_field.attrib['ref'],\n 'nhc_def_conf_location_wa_b1',\n 'Incorrect bed defined')",
"def test_openmrs_location_uuid_... | [
"0.7855332",
"0.6446672",
"0.63836956",
"0.6188404",
"0.61282825",
"0.6036391",
"0.5994112",
"0.5794608",
"0.5779505",
"0.57673836",
"0.57654405",
"0.5751814",
"0.5710679",
"0.5700644",
"0.56914634",
"0.56741476",
"0.5642299",
"0.56307256",
"0.56280136",
"0.56235397",
"0.5611... | 0.7753004 | 1 |
Gets 2d pose from image. | def pose_2d_pts(self,image):
'''
image- rgb image
return:-
pts - list of 2d pose landmarks as img coords
image- rgb image on which the 2d pose landmarks are drawn
'''
pts=[]
imgRGB=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
results=pose.process(imgR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_pose(np_img):\n\n # Prepare extraction\n current_dir = os.getcwd()\n os.chdir(OPEN_FACE_BINARY_PATH)\n timestamp = datetime.now().timestamp()\n\n # Extract action units using OpenFace\n np_img *= 255\n np_img = np_img.astype(np.uint8)\n imsave('{}.jpg'.format(timestamp), np_img)... | [
"0.6803498",
"0.67718405",
"0.6578046",
"0.6462229",
"0.61903125",
"0.6116809",
"0.61097723",
"0.6008456",
"0.59463865",
"0.5886136",
"0.5862527",
"0.57885146",
"0.5777729",
"0.5766698",
"0.57608443",
"0.5759201",
"0.5756002",
"0.5739679",
"0.57014626",
"0.5678801",
"0.567520... | 0.75043064 | 0 |
Creates linelist marker in kinect_frame. | def create_line_list(self,depth_arr):
'''
depth_arr- depth image as numpy array
'''
try:
body=[['shoulder_line',[self.rpts[11],self.rpts[12]]],['waist_line',[self.rpts[23],self.rpts[24]]],['left_shoulder_waist',[self.rpts[11],self.rpts[23]]],['right_shoulder_waist',[self.rp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linelist(self):\n line_list = Marker()\n line_list.header = self._header\n line_list.type = Marker.LINE_LIST\n line_list.action = Marker.ADD\n line_list.scale.x = 0.005\n line_list.color = self.YELLOW\n line_list.pose = deepcopy(self.POSE)\n\n line_list.p... | [
"0.7204715",
"0.6253658",
"0.618761",
"0.5972563",
"0.59579426",
"0.5891577",
"0.5788625",
"0.57596844",
"0.5753134",
"0.5735517",
"0.57352555",
"0.5704545",
"0.5704545",
"0.5703307",
"0.56611234",
"0.56589293",
"0.5639964",
"0.56304866",
"0.5599117",
"0.5581409",
"0.5579776"... | 0.75666314 | 0 |
Creates sphere list marker in kinect_frame. | def create_spheres(self,depth_arr):
'''
depth_arr- depth image as numpy array
'''
try:
#points=[nose,left_wrist,right,wrist,left_ankle,right ankle]
points=[self.rpts[0],self.rpts[15],self.rpts[16],self.rpts[27],self.rpts[28]]
self.spheres.points=[]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_sphere(self):\n self.scenes[self.current_scene].add_object(Sphere())\n self.redraw()",
"def create_marker_for_position(self, position):\n\n marker = Marker()\n marker.header.frame_id = '/world'\n marker.type = marker.SPHERE\n marker.action = marker.ADD\n m... | [
"0.63042283",
"0.6089321",
"0.60284626",
"0.6005117",
"0.5952845",
"0.5920016",
"0.5911139",
"0.5871804",
"0.5814114",
"0.57494426",
"0.57445484",
"0.57007575",
"0.56946874",
"0.5686285",
"0.5676667",
"0.5642764",
"0.56264365",
"0.55908763",
"0.55392164",
"0.5520569",
"0.5477... | 0.69496816 | 0 |
xyz from u,v image coords | def depth_to_xyz(self,u,v,depth_val):
'''
u - x image coordinate
v - y image coodrinate
depth_val - depth value at that (u,v) from depth_image
'''
fx=self.cam_intrin[0]
fy=self.cam_intrin[4]
cx=self.cam_intrin[2]
cy=self.cam_intrin[5]
z =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uv_at_xy(self, x, y, x0, y0, s0):\n dx, dy = self.distance(x0, y0, x, y)\n #print 'dx, dy:', dx, dy\n rr2 = (dx**2 + dy**2)**-1\n u = - s0 * dy * r_twopi * rr2\n v = s0 * dx * r_twopi * rr2\n #print 'u, v', u, v\n return u, v",
"def _uv_to_xy(self, uv: np.ndar... | [
"0.7228563",
"0.7134046",
"0.7081523",
"0.7022611",
"0.6837065",
"0.6717034",
"0.6695962",
"0.65979034",
"0.65862006",
"0.6532136",
"0.64494437",
"0.6444157",
"0.6409712",
"0.6406701",
"0.6345715",
"0.6327058",
"0.627148",
"0.6268713",
"0.6249921",
"0.62084967",
"0.61691314",... | 0.7625158 | 0 |
Rewinds (moves the reading position) back to the start of the file (f) | def rewind(f):
f.seek(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rewind(f):\n\tf.seek(0)",
"def attempt_file_reset(f):\r\n if hasattr(f, 'seek'):\r\n f.seek(0)",
"def rewind():",
"def rewind(self):\n self.seek(0)",
"def advance_in_file(self, file_pos):\n if self.is_open:\n try:\n self.fd.seek(file_pos)\n ... | [
"0.8195537",
"0.71154076",
"0.67926633",
"0.67174745",
"0.6703349",
"0.6678233",
"0.6145125",
"0.6052448",
"0.6034547",
"0.6005848",
"0.59068817",
"0.58931226",
"0.5791",
"0.57822955",
"0.5764034",
"0.57529867",
"0.5697037",
"0.5684315",
"0.560783",
"0.55483586",
"0.5518975",... | 0.8172433 | 1 |
Prints the current line of the file specified (f) | def print_a_line(line_count, f):
print (line_count, f.readline()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_a_line(line_count, f):\n\tprint line_count, f.readline()",
"def print_file(self, file, line):\n self._file = file\n self._line = line\n try:\n self._file = open(file)\n except IOError:\n print \"can't open\", file \n \n n = 0\n re... | [
"0.7941534",
"0.67998123",
"0.6511062",
"0.6413484",
"0.62451315",
"0.60461897",
"0.5928848",
"0.5926247",
"0.5837924",
"0.57815206",
"0.5778826",
"0.5688815",
"0.5662524",
"0.5650336",
"0.56378293",
"0.56378293",
"0.56240386",
"0.5608132",
"0.5602575",
"0.55989134",
"0.55829... | 0.78779405 | 1 |
Set the mean match candidates | def set_mean_match_candidates(self, mean_match_candidates: _t_mmc):
self.mean_match_candidates = mean_match_candidates
self._mmc_formatted = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mean_match_reg(\n mean_match_candidates,\n bachelor_preds,\n candidate_preds,\n candidate_values,\n random_state,\n hashed_seeds,\n):\n\n if mean_match_candidates == 0:\n imp_values = bachelor_preds\n\n else:\n _to_2d(bachelor_preds)\n _to_2d(candidate_preds)\n\n ... | [
"0.6346328",
"0.62343895",
"0.6154672",
"0.57222503",
"0.5569058",
"0.5444682",
"0.5351281",
"0.5348636",
"0.530202",
"0.52570087",
"0.52518",
"0.52295405",
"0.5220104",
"0.5220104",
"0.5164484",
"0.51522696",
"0.5105812",
"0.509307",
"0.50791615",
"0.507863",
"0.5044214",
... | 0.77353865 | 0 |
Overwrite the current mean matching functions for certain objectives. | def set_mean_match_function(self, mean_match_functions: _t_obj_func):
for objective, function in mean_match_functions.items():
self._add_mmf(objective, function) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modelmean(self, model_params, this_data, this_suff_stat):\n pass",
"def mean(self, like_params):\n\t\traise NotImplementedError",
"def _initialize_mean_function(self,\n mean_function: str,\n input_dim: int,\n ... | [
"0.59037656",
"0.5860598",
"0.58174765",
"0.57146555",
"0.5524873",
"0.53116494",
"0.53116494",
"0.5305057",
"0.525733",
"0.5203678",
"0.5165622",
"0.516089",
"0.51524436",
"0.51197916",
"0.51197916",
"0.50924563",
"0.5060772",
"0.5045501",
"0.5028893",
"0.50163394",
"0.50011... | 0.74748105 | 0 |
Easy way to determine which lightgbm objectives will require candidate predictions to run mean matching. Returns list of objectives. | def get_objectives_requiring_candidate_preds(self):
objs = []
for objective, obj_args in self.objective_args.items():
if "candidate_preds" in obj_args:
objs.append(objective)
return objs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_candidate_objects(output, img_size, classes, anchors, threshold):\n\n #threshold = 0.8\n iou_threshold = 0.4\n\n boxes, probs = parse_yolo_output_v2(output, img_size, len(classes), anchors)\n filter_mat_probs = (probs >= threshold)\n filter_mat_boxes = np.nonzero(filter_mat_probs)[0:3]\n ... | [
"0.5756041",
"0.5589991",
"0.558836",
"0.5552275",
"0.5530067",
"0.54684156",
"0.5361542",
"0.5355622",
"0.53529894",
"0.53006727",
"0.52579904",
"0.5245937",
"0.52195024",
"0.52150536",
"0.52046734",
"0.51991576",
"0.51856154",
"0.5183697",
"0.518344",
"0.51792735",
"0.51645... | 0.5654909 | 1 |
Determine what arguments we need to procure for a mean matching function. | def get_mean_match_args(self, objective):
try:
obj_args = self.objective_args[objective]
except:
raise ValueError(
f"Could not get mean matching args for objective {objective}"
+ "Add this objective to the MeanMatchSchema by using .set_mean_match_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findMean (*args):\r\n total = my_module.addStuff(*args)\r\n return total/len(args)",
"def find_arithmetic_mean( *args):\n sum = 0\n for value in args:\n sum += value\n return sum/len(args)",
"def evaluate_argument_mention(test_graphs, threshold):\r\n pred_graphs = [predict_argument... | [
"0.62553585",
"0.62131405",
"0.5855826",
"0.57468903",
"0.5550934",
"0.5387625",
"0.5363354",
"0.5355117",
"0.5336092",
"0.5304856",
"0.5271103",
"0.52342796",
"0.5233305",
"0.52302593",
"0.52176046",
"0.5203489",
"0.52034277",
"0.51927465",
"0.51910853",
"0.5190152",
"0.5157... | 0.66358805 | 0 |
Returns a filtered copy of the list that only contains source packages derived from the base package, minus any vendored packages. | def _filter_pkgs(self, pkgs):
pkgs = [pkg.strip() for pkg in pkgs]
return [
pkg for pkg in pkgs
if pkg.startswith(self.base_pkg) and not pkg.startswith(os.path.join(self.base_pkg, "vendor/"))
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_installed_packages(self, packages):\n filtered_packages = []\n for package in packages:\n name = package.name\n for installed in self._top_installed_repository.find_packages(name):\n if installed.key == package.key:\n break\n ... | [
"0.597424",
"0.5852693",
"0.5777234",
"0.5735486",
"0.5725861",
"0.570108",
"0.5622519",
"0.55674773",
"0.5560942",
"0.5553165",
"0.5496367",
"0.5443476",
"0.5442816",
"0.542846",
"0.5423466",
"0.53853345",
"0.53678995",
"0.5353318",
"0.5338533",
"0.5337924",
"0.53338253",
... | 0.7564647 | 0 |
Returns all dependency and test info for every package | def _get_all_pkg_info(self):
all_pkgs = self._filter_pkgs(self._go_list("./..."))
# for every package, list the deps, the test files, the test imports, and the external package test imports
big_list = self._go_list(
"-f", "{{.ImportPath}}:{{.Deps}}:{{.TestImports}}:{{.XTestImports}}"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_package(all: bool = False) -> List[List[str]]:\n if not all:\n pkgs_info = read_installation_records()\n else:\n pkgs_info = []\n for pkg in pkg_resources.working_set:\n pkgs_info.append([pkg.project_name, pkg.version])\n\n return pkgs_info",
"def _get_package_da... | [
"0.7067536",
"0.7035788",
"0.6996556",
"0.69814414",
"0.69051695",
"0.6827827",
"0.66596454",
"0.65772116",
"0.64771664",
"0.64341027",
"0.6410273",
"0.63306904",
"0.6312919",
"0.62856",
"0.6277369",
"0.62648284",
"0.626043",
"0.62584096",
"0.6244886",
"0.6231426",
"0.6229496... | 0.787858 | 0 |
Returns the cover profile that should be produced for a package. | def get_coverprofile_filename(self, pkg):
items = ("coverage", "txt")
if self.buildtags:
items = ("coverage", self.buildtags.replace(",", ".").replace(" ", ""), "txt")
return os.path.join(pkg.replace(self.base_pkg + "/", ""), ".".join(items)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"profile\")",
"def get_profile():\n # Create the netCDF file\n nc = make_ctd_file()\n\n # Return a profile object with all available chemicals in the CTD data\n return ambient.Profile(nc, chem_names='all')",
"def g... | [
"0.61685103",
"0.60460216",
"0.6027843",
"0.60040224",
"0.59798723",
"0.5978862",
"0.5947687",
"0.5917323",
"0.5863209",
"0.5819697",
"0.57627463",
"0.575286",
"0.575286",
"0.5729103",
"0.5630178",
"0.5630178",
"0.5628706",
"0.5591462",
"0.5591462",
"0.55809015",
"0.55529803"... | 0.7115861 | 0 |
Returns all package dependencies for which coverage should be generated this includes the actual package recursive dependencies, as well as the recursive test dependencies for that package. | def get_pkg_recursive_deps(self, pkg):
return self.recursive_pkg_deps[pkg].union(
*[self.recursive_pkg_deps[test_import] for test_import in self.test_imports.get(pkg, ())]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies(self):\n return self._dependency_analyzer.GetDependencies(\n [self.stacktrace.crash_stack] if self.stacktrace else [])",
"def get_dependencies(self):\n return [\"make\", \"g++\", \"gcc\", \"cmake-2.8.12.1\", \"boost_1_56_0\"]",
"def find_with_deps(self, package_names):",
"de... | [
"0.6634744",
"0.6585641",
"0.6575574",
"0.65393186",
"0.6506564",
"0.6462583",
"0.6442971",
"0.6400214",
"0.6357308",
"0.6335129",
"0.6269198",
"0.62657756",
"0.62277746",
"0.6219536",
"0.61846364",
"0.61794895",
"0.6166633",
"0.6143098",
"0.6103272",
"0.6076177",
"0.6071365"... | 0.7410739 | 0 |
Print out any packages for which there are test dependencies not returned by {{.Deps}} | def print_test_deps_not_in_package_deps(self):
extras = []
for key, rec_deps in self.recursive_pkg_deps.items():
any = self.test_imports.get(key, set()).difference(rec_deps, set([key]))
if any:
extras.append((key, any))
if extras:
print("Packa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_missing(packages, verbose):\n if not packages:\n print(\"## No Rez packages were found.\")\n print(\"No data found\")\n\n return\n\n print(\"## Your command affects these Rez packages.\")\n\n template = \"{package.name}\"\n\n if verbose:\n template = \"{package.na... | [
"0.7087315",
"0.6487221",
"0.64659935",
"0.64055705",
"0.63874286",
"0.62767315",
"0.60279006",
"0.60175484",
"0.6006788",
"0.600218",
"0.5987311",
"0.5945144",
"0.5938399",
"0.59061456",
"0.58985656",
"0.5837104",
"0.58231425",
"0.5813738",
"0.58081484",
"0.57979715",
"0.578... | 0.82419014 | 0 |
histogram_function(r_min, a, N, nbins) | def histogram_function(r_min, a, N, nbins):
r_min_no_selfdistance = r_min - np.identity(len(r_min)) #remove identitity matrix so own distance will be treated as 0
histarray = np.array(r_min_no_selfdistance).flatten()
histogram = np.histogram(histarray,bins=np.linspace(0,a,nbins))
histogram[0][0] = histo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arelfreq(a,numbins=10,defaultreallimits=None):\r\n h,l,b,e = histogram(a,numbins,defaultreallimits)\r\n h = N.array(h/float(a.shape[0]))\r\n return h,l,b,e",
"def hist(a,bins):\n n=searchsorted(sort(a),bins)\n n=concatenate([n,[len(a)]])\n n=array(list(map(float,n)))\n# n=array(n)\n r... | [
"0.6936947",
"0.68892324",
"0.68761754",
"0.6834968",
"0.65973526",
"0.65251994",
"0.64930004",
"0.63818604",
"0.630117",
"0.6246265",
"0.62286496",
"0.6214732",
"0.6194422",
"0.61841726",
"0.6147557",
"0.6100962",
"0.6068889",
"0.6008663",
"0.60074645",
"0.597237",
"0.596926... | 0.87125486 | 0 |
If which is 'scramble', then return a worker that scrambles an egg when given an egg; if which is 'boil', then return a worker that boils an egg when given an egg; otherwise, return a worker that is confused about what to do with eggs and returns an appropriate error message asking for help on the egg. | def hire_egg_worker(which):
return 'junk' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def func(self):\n char = self.character\n if not self.args:\n char.msg(\"Usage: wear <obj> [wear style]\")\n return\n clothing = char.search(self.arglist[0], candidates=char.contents)\n wearstyle = True\n if not clothing:\n return\n if not ... | [
"0.55458176",
"0.5480698",
"0.53874844",
"0.53766596",
"0.51063794",
"0.50789034",
"0.50436914",
"0.503999",
"0.5000281",
"0.4934145",
"0.49071297",
"0.49002698",
"0.48916593",
"0.4875484",
"0.4862809",
"0.48399255",
"0.48287508",
"0.48285353",
"0.48257828",
"0.4817983",
"0.4... | 0.6777338 | 0 |
Do the initialization for the l2 gateway service plugin here. | def __init__(self):
config.register_l2gw_opts_helper()
self.service_type_manager = st_db.ServiceTypeManager.get_instance()
add_provider_configuration(self.service_type_manager, constants.L2GW)
self._load_drivers()
super(L2GatewayPlugin, self).__init__()
l2gateway_db.subsc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initService(self):",
"def initialize(self, config, context):\n pass",
"def initialize(self, context: InitCommandContext) -> None:\n super().initialize(context)\n self.handler.initialize(context, self.logger)",
"def init(): \n\tset_verbosity()\n\t_set_threads()\n\t_set_heartbeat()\n... | [
"0.67884475",
"0.64767593",
"0.64718515",
"0.64607656",
"0.64541477",
"0.6439634",
"0.64098597",
"0.6404605",
"0.6376705",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083",
"0.6369083... | 0.848148 | 0 |
Loads plugindrivers specified in configuration. | def _load_drivers(self):
self.drivers, self.default_provider = service_base.load_drivers(
'L2GW', self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_drivers(self):\n self.drivers, self.default_provider = service_base.load_drivers(\n taas_consts.TAAS, self)",
"def loadDrivers(self):\n\n self.sources = {}\n for source in self.config['sources']:\n sourceConf = self.config['sources'][source]\n baseC... | [
"0.6771009",
"0.6510184",
"0.6265225",
"0.6019771",
"0.5977574",
"0.59142417",
"0.58064735",
"0.578184",
"0.57750535",
"0.5752513",
"0.5686436",
"0.5670421",
"0.5610772",
"0.5610056",
"0.5605797",
"0.5599636",
"0.55271316",
"0.5524405",
"0.552201",
"0.55170864",
"0.5510567",
... | 0.6967268 | 0 |
Get `count` random objects for a model object `model` or from a queryset. Returns an iterator that yield one object at a time. You model must have an auto increment id for it to work and it should be available on the `id` attribute. | def get_random_objects(model=None, queryset=None, count=float('+inf')):
if not queryset:
try:
queryset = model.objects.all()
except AttributeError:
raise ValueError("You must provide a model or a queryset")
max_ = queryset.aggregate(Max('id'))['id__max']
i = 0
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_count(self):\n\n command = Command()\n modellist = command.get_modellist()\n for model_name, count in modellist:\n # taking model class by it's name\n model = ContentType.objects.get(model=model_name).model_class()\n # testing we've counted objects in ... | [
"0.60889995",
"0.60029674",
"0.576663",
"0.5426091",
"0.5388276",
"0.53461957",
"0.531792",
"0.52934",
"0.52816635",
"0.5267472",
"0.52015036",
"0.5173127",
"0.51120204",
"0.5088402",
"0.50771165",
"0.5065016",
"0.49864575",
"0.4975259",
"0.49693018",
"0.4957315",
"0.49563217... | 0.8170692 | 0 |
Returns the button label. | def GetBtnLabel(self):
if self.GetWindowStyleFlag() & CP_GTK_EXPANDER:
return self.GetLabel()
return self.GetLabel() + (self.IsCollapsed() and [" >>"] or [" <<"])[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_button_label(self,index):\r\n self.l_debug(\"_get_button_label\",\"index=%d\" % (index))\r\n # TODO: Make sure it's a valid index?\r\n return self.parent.harmony_config['info']['functions'][index]['label']",
"def get_label ( self ):\n return self.label",
"def label(self) ->... | [
"0.8197363",
"0.7610237",
"0.75547886",
"0.7538115",
"0.7538115",
"0.7538115",
"0.7538115",
"0.74440265",
"0.74440265",
"0.74057263",
"0.74037004",
"0.73968625",
"0.73918253",
"0.73918253",
"0.73918253",
"0.73918253",
"0.73918253",
"0.73918253",
"0.73918253",
"0.73864347",
"0... | 0.83336055 | 0 |
Collapses or expands the pane window. | def Collapse(self, collapse=True):
# optimization
if self.IsCollapsed() == collapse:
return
self.Freeze()
# update our state
self._pPane.Show(not collapse)
self._bCollapsed = collapse
self.Thaw()
# update button label
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expand_or_collapse(control_instance, resize_button):\n # Hide the control\n if control_instance.isVisible():\n state = False\n # Show the control\n else:\n state = True\n ControllerControlWidget.set_expanded(control_instance, resize_button,\n ... | [
"0.6017432",
"0.5961824",
"0.5894596",
"0.58776236",
"0.5828001",
"0.58111924",
"0.58034605",
"0.5796458",
"0.57804763",
"0.57564986",
"0.57489055",
"0.57027537",
"0.57013804",
"0.56860054",
"0.5649473",
"0.56272846",
"0.55986077",
"0.5584183",
"0.55655074",
"0.5557718",
"0.5... | 0.6129804 | 0 |
Sets the button label. | def SetLabel(self, label):
self._strLabel = label
self._pButton.SetLabel(self.GetBtnLabel())
self._pButton.SetInitialSize()
self._pButton.Refresh()
self.Layout() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setButtonLabel( self, cCtrlName, cLabel ):\n oControl = self.getControl( cCtrlName )\n oControl.setLabel( cLabel )",
"def setLabel(self, label):\r\n\t\tself.label = label",
"def setLabel(self, label):\r\n\t\tself.label = label",
"def setLabel(self, label):\r\n\t\tself.label = label",
"def... | [
"0.8229209",
"0.7858006",
"0.7858006",
"0.7858006",
"0.78141004",
"0.7575104",
"0.75416356",
"0.74866223",
"0.7397651",
"0.7384349",
"0.7338512",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
"0.7323399",
... | 0.8413556 | 0 |
Assign a new button to PyCollapsiblePane. This button can be the standard wx.Button or any of the generic implementations which live in wx.lib.buttons. | def SetButton(self, button):
if self._pButton:
if not self.HasFlag(CP_USE_STATICBOX):
self._sz.Replace(self._pButton, button)
self.Unbind(wx.EVT_BUTTON, self._pButton)
self._pButton.Destroy()
self._pButton = button
self.SetLabel(button... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnButton(self, event):\r\n\r\n if event.GetEventObject() != self._pButton:\r\n event.Skip()\r\n return\r\n\r\n self.Collapse(not self.IsCollapsed())\r\n\r\n # this change was generated by the user - send the event\r\n ev = wx.CollapsiblePaneEvent(self, self.Get... | [
"0.64140683",
"0.6325811",
"0.62175363",
"0.619679",
"0.61711425",
"0.61232746",
"0.6112308",
"0.61007667",
"0.6097091",
"0.6074209",
"0.60696244",
"0.6028274",
"0.5926246",
"0.58324873",
"0.5800489",
"0.5751404",
"0.57510805",
"0.57339567",
"0.5724154",
"0.5709597",
"0.56939... | 0.66264814 | 0 |
Handles the wx.EVT_BUTTON event for PyCollapsiblePane. | def OnButton(self, event):
if event.GetEventObject() != self._pButton:
event.Skip()
return
self.Collapse(not self.IsCollapsed())
# this change was generated by the user - send the event
ev = wx.CollapsiblePaneEvent(self, self.GetId(), self.IsCollapsed(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnButton(self,event):\n\t\tprint '\\nFrame Children: '\n\t\tfor child in self.GetChildren():\n\t\t\tprint \"%s\" % repr(child)\n\t\t\n\t\tprint '\\nPanel FindWindowById: '\n\t\tbutton = self.panel.FindWindowById(self.btnId)\n\t\tprint \"%s\" % repr(button)\n\t\tbutton.SetLabel(\"Changed Label\")\t\t\t# Change ... | [
"0.6240299",
"0.60624653",
"0.6062247",
"0.5984614",
"0.59749734",
"0.5955732",
"0.5946784",
"0.59231377",
"0.5904752",
"0.5862346",
"0.58618283",
"0.5851343",
"0.5762592",
"0.57623875",
"0.5747452",
"0.5728012",
"0.56948894",
"0.56561077",
"0.56561077",
"0.562525",
"0.562127... | 0.81052554 | 0 |
Drawing routine to paint the GTKstyle expander. | def OnDrawGTKStyle(self, event):
dc = wx.AutoBufferedPaintDC(self._pButton)
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.Clear()
self.OnDrawGTKExpander(dc)
self.OnDrawGTKText(dc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnDrawGTKExpander(self, dc):\r\n\r\n self._pButton.OnDrawGTKExpander(dc)",
"def OnPaint(self, event):\r\n\r\n dc = wx.AutoBufferedPaintDC(self)\r\n cli_rect = wx.RectPS(wx.Point(0, 0), self.GetClientSize())\r\n\r\n horizontal = True\r\n if self._agwStyle & AUI_TB_VERTICAL:\... | [
"0.70505583",
"0.6686123",
"0.6505161",
"0.640079",
"0.62739336",
"0.6273409",
"0.62223166",
"0.62175196",
"0.6158108",
"0.6115396",
"0.6057515",
"0.6006625",
"0.5998781",
"0.5993235",
"0.59832895",
"0.5939669",
"0.5936209",
"0.5862006",
"0.5857074",
"0.5800589",
"0.57890546"... | 0.7799583 | 0 |
Overridable method to draw the GTKstyle expander. | def OnDrawGTKExpander(self, dc):
self._pButton.OnDrawGTKExpander(dc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnDrawGTKStyle(self, event):\r\n\r\n dc = wx.AutoBufferedPaintDC(self._pButton)\r\n dc.SetBackground(wx.Brush(self.GetBackgroundColour()))\r\n dc.Clear()\r\n \r\n self.OnDrawGTKExpander(dc)\r\n self.OnDrawGTKText(dc)",
"def decorate(self):\n\n c = self.canvas\... | [
"0.72631824",
"0.6022415",
"0.60151124",
"0.5943031",
"0.584598",
"0.5803697",
"0.57422835",
"0.5725449",
"0.57190037",
"0.5691516",
"0.56386286",
"0.5620919",
"0.5575415",
"0.55617386",
"0.55540913",
"0.5536321",
"0.5528973",
"0.5521331",
"0.54680276",
"0.5458602",
"0.543961... | 0.7376922 | 0 |
Stateless identity transformation that leaves input gradients untouched. | def identity() -> GradientTransformation:
def init_fn(_):
return EmptyState()
def update_fn(updates, state, params=None):
del params
return updates, state
return GradientTransformation(init_fn, update_fn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identity(inputs: torch.Tensor):\n return inputs",
"def identity(state: State) -> State:\n return state",
"def idn(x):\n\n def grad(dy):\n return dy\n\n return tf.ones_like(x), grad",
"def identity(features):\n features = tf.convert_to_tensor(features)\n return tf.identity(features)",... | [
"0.654061",
"0.63789064",
"0.61930794",
"0.6179915",
"0.6158657",
"0.5901717",
"0.5885808",
"0.57707673",
"0.5758652",
"0.57229537",
"0.5707053",
"0.57059085",
"0.56792724",
"0.56792676",
"0.56582284",
"0.56580484",
"0.56562716",
"0.56497425",
"0.56497425",
"0.56497425",
"0.5... | 0.80531585 | 0 |
Returns a 64 x 64 patch with the given patch_id. Catch container images to reduce loading from disk. | def GetPatchImage(patch_id, container_dir):
# Define constants. Each container image is of size 1024x1024. It packs at
# most 16 rows and 16 columns of 64x64 patches, arranged from left to right,
# top to bottom.
PATCHES_PER_IMAGE = 16 * 16
PATCHES_PER_ROW = 16
PATCH_SIZE = 64
# Calculate t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_patchify(file_name, patch_size, patch_num):\n img = imageio.imread(file_name)\n w, h, c = img.shape\n patches = np.zeros((patch_num, patch_size, patch_size, c), dtype=np.uint8)\n assert w == h\n patch_n_single = int(np.floor(np.sqrt(patch_num)))\n step = w//patch_n_single\n offset =... | [
"0.6201207",
"0.60380596",
"0.5927875",
"0.566358",
"0.5646754",
"0.5632543",
"0.56178045",
"0.5605348",
"0.556101",
"0.5560943",
"0.5532757",
"0.5485201",
"0.54657656",
"0.54645336",
"0.5449628",
"0.544221",
"0.53976697",
"0.53922313",
"0.53832805",
"0.5320497",
"0.5315148",... | 0.807523 | 0 |
Key length in bits. | def key_length(self):
if hasattr(self, '_m_key_length'):
return self._m_key_length if hasattr(self, '_m_key_length') else None
self._m_key_length = self.rsa_n.length_in_bits
return self._m_key_length if hasattr(self, '_m_key_length') else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_size(self) -> int:\n pass",
"def key_size(self) -> int:\n pass",
"def bit_length(self): # real signature unknown; restored from __doc__\n pass",
"def bit_length(self): # real signature unknown; restored from __doc__\n pass",
"def bit_length(self): # real signature unknow... | [
"0.80768776",
"0.80768776",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7576323",
"0.7514389",
"0.72238845",
"0.7106643",
... | 0.8158661 | 0 |
This function takes a key and message as input the key is the date which changes daily and message is the data to be hashed. It returns a hashed object for that message | def daily_signature(key, message):
byte_key = binascii.unhexlify(key)
message = message.encode()
return hmac.new(byte_key, message, hashlib.sha256).hexdigest().upper() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monthly_signature(key, message):\n byte_key = binascii.unhexlify(key)\n message = message.encode()\n return hmac.new(byte_key, message, hashlib.sha256).hexdigest().upper()",
"def messageHash(msg, keys = ['From', 'Cc', 'To', 'Date', 'Subject', 'Message-ID']):\n ho = hashlib.md5()\n ok, ko = 0, ... | [
"0.6442566",
"0.64086205",
"0.6201464",
"0.6052882",
"0.60258067",
"0.6010885",
"0.5868692",
"0.58530396",
"0.5833914",
"0.5812929",
"0.5773596",
"0.5769754",
"0.5758008",
"0.57373905",
"0.57372874",
"0.5736726",
"0.5736726",
"0.57070947",
"0.5692386",
"0.5660123",
"0.5646539... | 0.71441954 | 0 |
Similar to the daily_signatue function. The key(month) changes every first day of the month | def monthly_signature(key, message):
byte_key = binascii.unhexlify(key)
message = message.encode()
return hmac.new(byte_key, message, hashlib.sha256).hexdigest().upper() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_sic_monthly():\n # Set variable\n nc_file = '/home/disk/sipn/rclancy/ecmwf/pf/predictability/SIC/SIC.nc'\n var_name = 'SIC'\n var_date_name = 'SIC_dates'\n\n # Get variables\n var, var_dates =read_nc_var(nc_file, var_name, var_date_name)\n # Get associated dates\n var_year, var... | [
"0.5338325",
"0.51746994",
"0.5139804",
"0.5134837",
"0.51120234",
"0.50786996",
"0.5062588",
"0.5028473",
"0.5016877",
"0.49839368",
"0.49839368",
"0.4980193",
"0.49511695",
"0.49318656",
"0.49011654",
"0.48623136",
"0.48620287",
"0.48602793",
"0.48423478",
"0.4829905",
"0.4... | 0.5855716 | 0 |
this function returns a kafka producer instance which connects to the broker | def connect_kafka_producer():
producer = KafkaProducer(bootstrap_servers='0.0.0.0:9092', value_serializer=lambda v: json.dumps(v).encode('utf-8'))
return producer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_kafka_producer():\n _producer = None\n kafka_url = 'localhost:9092'\n try:\n _producer = KafkaProducer(bootstrap_servers=kafka_url,\n value_serializer=lambda value: json.dumps(value).encode())\n except Exception as ex:\n print('Exception while ... | [
"0.8122594",
"0.7818107",
"0.77717716",
"0.76888186",
"0.7676086",
"0.75530577",
"0.75071543",
"0.7300573",
"0.7205273",
"0.71351206",
"0.7087157",
"0.70741254",
"0.6859906",
"0.6833182",
"0.678626",
"0.6715454",
"0.6639544",
"0.66031206",
"0.65238243",
"0.65039504",
"0.64114... | 0.8171209 | 0 |
this function takes the producer , topic name , column name and the value to push to kafka on that particular topic | def publish_message(producer_instance, topic_name, key, value):
key_serializer = repr(key).encode()
value_serializer = repr(value).encode()
producer_instance.send(topic_name, key=key_serializer, value=value_serializer)
producer_instance.flush()
print('Message published successfully.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_stream_to_kafka(self, df: pd.DataFrame) -> None:\n for row in df.values.tolist():\n value = dict(zip(self.get_value_structure(), row))\n key = dict(zip(self.get_key_structure(), [row[13]]))\n # key = {\"npi\": int(row[0])}\n # key = str(uuid.uuid4())\n ... | [
"0.6705549",
"0.6556304",
"0.6489454",
"0.6438795",
"0.6383224",
"0.6328097",
"0.6269287",
"0.6269287",
"0.6267636",
"0.6032173",
"0.6030657",
"0.60208875",
"0.5811532",
"0.5788518",
"0.57678866",
"0.5727949",
"0.5710474",
"0.5700423",
"0.56976736",
"0.5683676",
"0.5676896",
... | 0.6902852 | 0 |
Returns the highest quality mimetypestring that client and server can agree on. Returns ``None``, if no suitable type is found. | def get_best_mimetype():
# find out what the client accepts
return request.accept_mimetypes.best_match(
current_app.blueprints[request.blueprint].response_mimetypes.keys()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_mime_type(accept_string, default):\n accepts = re.split(\"\\s*,\\s*\", accept_string)\n for accept in accepts:\n if accept == \"text/html\":\n return \"html\"\n elif accept == \"application/rdf+xml\":\n return \"pretty-xml\"\n el... | [
"0.71058255",
"0.70101297",
"0.64935607",
"0.6437843",
"0.6385521",
"0.63580006",
"0.63048387",
"0.6247063",
"0.6242983",
"0.6206114",
"0.61716264",
"0.6141305",
"0.6102814",
"0.60999954",
"0.6064664",
"0.6035307",
"0.60245746",
"0.5991766",
"0.5983697",
"0.59698886",
"0.5907... | 0.75652003 | 0 |
Serializes a response using a specified serializer. If ``response_data`` is an instance of | def serialize_response(response_data, content_type=None):
content_type = content_type or get_best_mimetype()
if not content_type:
abort(406)
rv = current_app.blueprints[request.blueprint]\
.response_mimetypes[content_type](response_data)
response = make_response(rv)
if isinstance... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_response(self, request, data, response_class=HttpResponse, **response_kwargs):\n desired_format = self.determine_format(request)\n serialized = self.serialize(request, data, desired_format)\n return response_class(content=serialized, content_type=build_content_type(desired_format), ... | [
"0.6623695",
"0.64812064",
"0.6258819",
"0.6216426",
"0.6129398",
"0.5985117",
"0.5982559",
"0.58265007",
"0.5823068",
"0.58032537",
"0.5705232",
"0.5591172",
"0.5517693",
"0.5409627",
"0.53862536",
"0.5383542",
"0.53263575",
"0.52856606",
"0.5273497",
"0.526373",
"0.5259677"... | 0.66624653 | 0 |
merge all clip data as one dictionary (1 column) | def MergeClipData(clip_im_dir):
image_list_dict = {'image_id':[]}
clip_img = os.listdir(clip_im_dir)
for folder_clip in clip_img :
clip_path = os.path.join(clip_im_dir, folder_clip)
# clip_path = clip_im_dir + '/' + folder_clip
clip_list = os.listdir(clip_path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_data(spectras, compounds) :\n final = {}\n for hmdb_id, spec_objs in spectras.items() :\n c = compounds.pop(hmdb_id, None)\n if not c :\n continue\n c.spectras = spec_objs\n final[hmdb_id] = c\n return final",
"def ana_merge_datas(datas):\n return {\n 'searches':ana_merg... | [
"0.6627072",
"0.59916484",
"0.5884026",
"0.58334225",
"0.581925",
"0.577244",
"0.5727121",
"0.564094",
"0.56109655",
"0.5604247",
"0.5587592",
"0.5557625",
"0.5521113",
"0.5442192",
"0.5427656",
"0.54081696",
"0.5406866",
"0.5344405",
"0.5279141",
"0.5262178",
"0.5193641",
... | 0.6515092 | 1 |
create a dataframe with clip and matting data in a single dataframe sava data as csv. | def MergeDataframe(clip_im_dir, matting_dir):
clip_dict = MergeClipData(clip_im_dir)
mate_dict = MergeMateData(matting_dir)
clip_df = pd.DataFrame.from_dict(clip_dict)
mate_df = pd.DataFrame.from_dict(mate_dict)
data_df = pd.merge(clip_df, mate_df, left_index=True, right_index=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __create_output_csv(self, df, score_list, elapsed_list):\n df['Similar']=score_list\n df['Elapsed']=elapsed_list\n df.to_csv('Output.csv',index=False)\n return df",
"def create_csvfile(options_path, recept_info,df):\n df_csv = df.copy()\n df_csv.index.names = ['Interacting p... | [
"0.64685977",
"0.6338719",
"0.6281418",
"0.6134436",
"0.6117885",
"0.5979423",
"0.5969765",
"0.5957886",
"0.59506416",
"0.5934334",
"0.58852875",
"0.5879117",
"0.58698547",
"0.58654606",
"0.58606637",
"0.5856644",
"0.58529085",
"0.5829848",
"0.5819718",
"0.5815047",
"0.578407... | 0.6808439 | 0 |
create a train and test dataLoader from the images directories and csv file. train and test are separated regarding the split proportion ([0,1]) | def create_train_test(option, transform, params, split=0.2):
clip_im_dir = option.clip_im_dir
matting_dir = option.matting_dir
csv_path = option.csv_path
print("create datasets")
data_df = pd.read_csv(csv_path)
# data_df = MergeDataframe(clip_im_dir, matting_dir)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_test_loaders(dataset, validation_ratio=0.2, **kwargs):\n dataset_size = len(dataset)\n test_size = int(np.floor(validation_ratio * dataset_size))\n train_size = dataset_size - test_size\n print('TRAIN SIZE {}'.format(train_size))\n print('TEST SIZE {}'.format(test_size))\n train_dataset... | [
"0.76035875",
"0.7358849",
"0.73044246",
"0.7215763",
"0.7209182",
"0.7208987",
"0.7201006",
"0.7191484",
"0.7177327",
"0.7167517",
"0.70895123",
"0.70827246",
"0.70128286",
"0.70114017",
"0.70097095",
"0.6963703",
"0.6933479",
"0.6915748",
"0.69120777",
"0.6892816",
"0.68696... | 0.7384016 | 1 |
Bidirectional streaming rpc to allow user to get and add movies to collection | def getAndUpdateMovieLibrary(self, request_iterator, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listMovies(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def movie_videos(request, pk):\n if request.method == 'GET':\n videos_list = MovieVideos.objects.... | [
"0.68756163",
"0.61448747",
"0.584386",
"0.5808096",
"0.56962866",
"0.5659108",
"0.56537026",
"0.5605271",
"0.56017655",
"0.55731195",
"0.5557545",
"0.5541448",
"0.5540803",
"0.54997796",
"0.5486436",
"0.5484103",
"0.54049665",
"0.53932863",
"0.53905815",
"0.539024",
"0.53794... | 0.6388322 | 1 |
server side streaming rpc to allow user to fetch movies from the server | def listMovies(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_streaming(self) -> global___Snippet.ServerStreaming:",
"def video_feed():\n print('before response function')\n return Response(stream_with_context(gen()),#gen(Camera()),\n mimetype='multipart/x-mixed-replace; boundary=frame')",
"def video_feed(username):\n\tforeman.assignWo... | [
"0.6613245",
"0.6607566",
"0.63445246",
"0.62630606",
"0.62606865",
"0.6195006",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6150142",
"0.6113381",
... | 0.66535634 | 0 |
The exclude and include patterns are used to match per record. That is a record wth 3 urls will be returned/excluded if any one of the URLs match the include/exclude patterns | def query_urls(
self,
exclude=None,
include=None,
versioned=None,
offset=0,
limit=1000,
fields="did,urls",
**kwargs
):
raise NotImplementedError("TODO") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _excludes(self, method, url):\n if method != 'GET':\n return False\n # maybe change to a dict?\n for excl in self.excludes:\n if excl == \"topInfo\" and \"info.json\" in url:\n return True\n if str(excl) + \".json\" in url:\n r... | [
"0.5808535",
"0.5786685",
"0.576104",
"0.53969103",
"0.53901464",
"0.535678",
"0.53509974",
"0.53147054",
"0.53115964",
"0.5279933",
"0.5279933",
"0.52327234",
"0.5227774",
"0.5204561",
"0.51893955",
"0.5154055",
"0.5132615",
"0.5111435",
"0.5109775",
"0.51064247",
"0.5102779... | 0.61077726 | 0 |
Queries urls_metadata based on provided key and value | def query_metadata_by_key(
self,
key,
value,
url=None,
versioned=None,
offset=0,
limit=1000,
fields="dir,urls,rev",
**kwargs
):
raise NotImplementedError("TODO") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(self, key):",
"def lookup(self, url):\n return {'url': url}",
"def create_urls_metadata(urls_metadata, record, session):\n urls = {u.url for u in record.urls}\n for url, url_metadata in iteritems(urls_metadata):\n if url not in urls:\n raise UserError(\n ... | [
"0.58166593",
"0.570598",
"0.5697302",
"0.55538285",
"0.5456808",
"0.54249465",
"0.5384687",
"0.53615624",
"0.5347372",
"0.5311973",
"0.5296742",
"0.5270764",
"0.52625626",
"0.52349716",
"0.5232526",
"0.5220796",
"0.5182758",
"0.5168612",
"0.51635224",
"0.51580817",
"0.514830... | 0.7721946 | 0 |
String to report on simulation progress. Assumes that the average time per Monte Carlo/trajectorylevel step is constant throughout the simulation. These are trajectorylevel steps in to distinguish them from molecular dynamics (time) steps in path sampling these are Monte Carlo steps; in order simulations (committor) th... | def progress_string(n_steps_completed, n_steps_total, time_elapsed):
try:
time_per_step = time_elapsed / n_steps_completed
except ZeroDivisionError:
return "Starting simulation...\nWorking on first step\n"
time_to_finish = (n_steps_total - n_steps_completed) * time_per_step
output_str = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_progress(self):\n print(\n 'E {} S {} TR {:6.2f} G {:6.2f} Reg {:6.5f} Loss {:6.5f} AvgQ {:6.2f}'\n ' MinR {:6.2f} MaxR {:6.2f}'.format(\n self.episode, self.episode_step, self.tracker.total_reward, self.tracker.discounted_rewards,\n self.reg_lo... | [
"0.6558308",
"0.6350678",
"0.632168",
"0.6309233",
"0.6270681",
"0.6212692",
"0.6171361",
"0.6170355",
"0.60557026",
"0.60386324",
"0.60237175",
"0.60233355",
"0.6007543",
"0.5965028",
"0.59493315",
"0.5948319",
"0.592909",
"0.5900821",
"0.5844238",
"0.58429754",
"0.58319557"... | 0.73999774 | 0 |
Ensure that the existing file matches the old contents. If the file exists and we don't know the old contents/hash, trust the file (probably first initialization). If the file does not exist, this write the file. If the file exists, check that its contents (based on hash digest). If these match the original contents, w... | def ensure_file(filename, old_contents=None, old_hash=None):
hash_function = lambda text: hashlib.sha1(text.encode('utf-8')).digest()
if old_hash is None and old_contents is not None:
old_hash = hash_function(old_contents)
if not os.path.exists(filename):
# write the file if it doesn't exi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verifyFile(source, destination):\n\tsourceHash = hashlib.sha256(open(source, 'rb').read()).digest()\n\tdestinationHash = hashlib.sha256(open(destination, 'rb').read()).digest()\n\n\tif sourceHash == destinationHash:\n\t\treturn (True, str(sourceHash))\n\n\treturn False",
"def write_if_diff(filename, contents... | [
"0.6654198",
"0.64693105",
"0.64394",
"0.6312463",
"0.61940026",
"0.6186783",
"0.6179579",
"0.6121708",
"0.60995346",
"0.6048317",
"0.60166174",
"0.6014873",
"0.6000543",
"0.59918547",
"0.59409076",
"0.593846",
"0.59197056",
"0.58637863",
"0.58141124",
"0.58135056",
"0.580845... | 0.8015777 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.