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 |
|---|---|---|---|---|---|---|
Returns the signed difference between two angles (rad) The difference is calculated as target_angle source_angle. The difference will thus be positive if target_angle > source_angle. | def delta_angle(source_angle, target_angle, hi=2 * np.pi):
diff = target_angle - source_angle
def mod(a, n): return (a % n + n) % n
return mod(diff + hi / 2, hi) - hi / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle_diff(self, a, b):\n a = self.angle_normalize(a)\n b = self.angle_normalize(b)\n d1 = a-b\n d2 = 2*math.pi - math.fabs(d1)\n if d1 > 0:\n d2 *= -1.0\n if math.fabs(d1) < math.fabs(d2):\n return d1\n else:\n return d2",
"de... | [
"0.6784113",
"0.66581917",
"0.6620481",
"0.6620481",
"0.66021883",
"0.66021883",
"0.6544369",
"0.6539233",
"0.6524171",
"0.65140384",
"0.6370633",
"0.62325966",
"0.6179326",
"0.6162608",
"0.6084999",
"0.6075657",
"0.60453475",
"0.5996615",
"0.5986001",
"0.5958576",
"0.5936489... | 0.6755501 | 1 |
This method takes a dictionary of item ids to their respective properties, extracts the key data fields for each item, and returns a dictionary of item ids to their respective extracted data. | def extract_key_item_data(item_data):
extracted_item_data = {}
for item_id in item_data:
key_data = {}
key_data["id"] = item_id
key_data["name"] = item_data[item_id]["name"]
key_data["image"] = item_data[item_id]["image"]["full"]
key_data["gold"] = item_data[item_id]["gold"]["total"]
key_da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_dict(dict_item):\n info = {}\n item_info = None\n\n for k, v in dict_item.items():\n if k == 'ItemType':\n info[k] = api.item_dict_inv[dict_item['ItemType']]\n elif k == 'Item':\n item_info = colectica.parse_xml(v, api.item_dict_inv[dict_item['ItemType']])\n... | [
"0.6092631",
"0.6067828",
"0.60617733",
"0.6028937",
"0.5863528",
"0.5696433",
"0.5608552",
"0.55642694",
"0.55462956",
"0.55306554",
"0.5478335",
"0.5476924",
"0.5460027",
"0.5456423",
"0.54379886",
"0.5426146",
"0.5422652",
"0.5422065",
"0.5379292",
"0.5375101",
"0.5372952"... | 0.7907337 | 0 |
returns average of local clustering coefficients | def clustering_coefficient(graph):
count = 0
sumOfClusteringCoefficients = 0
for vertex in graph:
count += 1
sumOfClusteringCoefficients += local_clustering_coefficient(graph, vertex)
return sumOfClusteringCoefficients / count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GlobalClusteringCoefficient(graph):\n coef = np.mean(list(nx.clustering(graph).values()))\n return coef",
"def SquareClusteringCoefficient(graph):\n coef = np.mean(list(nx.square_clustering(graph).values()))\n return coef",
"def cluster_cal(self):\n self.Cluster = []\n for i in ra... | [
"0.74364084",
"0.6687801",
"0.65657526",
"0.6507998",
"0.6330402",
"0.6327586",
"0.62386185",
"0.60642046",
"0.6037065",
"0.59907097",
"0.5903807",
"0.58887535",
"0.584757",
"0.57932895",
"0.5768591",
"0.57648635",
"0.57550263",
"0.57174104",
"0.56907356",
"0.5685301",
"0.567... | 0.69418436 | 1 |
finds the distance (the length of the shortest path) from the source to every other vertex in the same component using breadthfirst search, and returns the value of the largest distance found | def max_dist(graph, source):
q = queue.Queue()
found = {}
distance = {}
for vertex in graph:
found[vertex] = 0
distance[vertex] = -1
max_distance = 0
found[source] = 1
distance[source] = 0
q.put(source)
while q.empty() == False:
current = q.get()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def std_bfs(graph, src_vertex):\n # this sssp yields (node, level) in a breadth first search\n res = nx.single_source_shortest_path_length(graph, src_vertex)\n\n return [dist+1 for _, dist in sorted(res.items())]",
"def shortest_combined_wire_path(grid):\n current_minimum = sys.maxsize\n\n for cro... | [
"0.6498419",
"0.6417174",
"0.6412791",
"0.639987",
"0.63898635",
"0.63288945",
"0.6257384",
"0.6251373",
"0.6233719",
"0.6225941",
"0.62100583",
"0.6209474",
"0.61876315",
"0.61588436",
"0.60992855",
"0.60745585",
"0.6067401",
"0.6062507",
"0.6048969",
"0.6018151",
"0.6005745... | 0.71585447 | 0 |
returns the diameter of a graph by finding greatest max distance | def diameter(graph):
max_distance = 0
for vertex in graph:
new_dist = max_dist(graph, vertex)
if new_dist > max_distance:
max_distance = new_dist
return max_distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diameter(self):\n\n v = self.vertices()\n pairs = [ (v[i],v[j]) for i in range(len(v)-1) for j in range(i+1, len(v))]\n smallest_paths = []\n for (s,e) in pairs:\n paths = self.find_all_path(s,e)\n smallest = sorted(paths, key=len)[0]\n smallest_path... | [
"0.73363787",
"0.7249815",
"0.7026748",
"0.666575",
"0.65678686",
"0.6497069",
"0.6471133",
"0.6458646",
"0.6384776",
"0.6333823",
"0.6312993",
"0.6240806",
"0.62322974",
"0.6172251",
"0.6165411",
"0.60725904",
"0.6060118",
"0.6053263",
"0.6025451",
"0.600312",
"0.59992427",
... | 0.85918725 | 0 |
diameter and clustering coefficient vs rewiring prob with k trials | def diameter_clustering_vs_prob_ws(num_nodes, k):
xdata = []
ydata = []
zdata = []
prob = 0.0005
while prob < 1:
xdata += [prob]
diameters = []
coeffs = []
for i in range(k):
graph = make_ws_graph(num_nodes, 8, prob)
diameters += [di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_purity(D, k):\n ti = np.array(D.groupby(by=\"cluster\").count()['x1'])\n ci = np.array(D.groupby(by=\"label\").count()['x1'])\n total_observations = 0\n for i in range(k):\n total_observations += min(ti[i], ci[i])\n purity = total_observations / D.shape[0]\n return purity",
... | [
"0.6533492",
"0.6453961",
"0.6248546",
"0.6242631",
"0.6210361",
"0.61629087",
"0.6087399",
"0.6042287",
"0.6032177",
"0.6013144",
"0.6012423",
"0.5967039",
"0.59623754",
"0.5951409",
"0.5901097",
"0.58950704",
"0.58583415",
"0.5852265",
"0.5821665",
"0.5807835",
"0.5776957",... | 0.69475347 | 0 |
Match protein names of MS and Uniprot's proteome. | def MatchProtNames(ProteomeDict, MS_names, MS_seqs):
matchedNames, seqs, Xidx = [], [], []
counter = 0
for i, MS_seq in enumerate(MS_seqs):
MS_seqU = MS_seq.upper()
MS_name = MS_names[i].strip()
if MS_name in ProteomeDict and MS_seqU in ProteomeDict[MS_name]:
Xidx.append(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findmotif(MS_seq, MS_name, ProteomeDict, motif_size):\n MS_seqU = MS_seq.upper()\n try:\n UP_seq = ProteomeDict[MS_name]\n assert MS_seqU in UP_seq, \"check \" + MS_name + \" with seq \" + MS_seq + \". Protein sequence found: \" + UP_seq\n regexPattern = re.compile(MS_seqU)\n ... | [
"0.5665962",
"0.5651878",
"0.53951806",
"0.5392965",
"0.539256",
"0.5364423",
"0.5346171",
"0.52936655",
"0.5278408",
"0.5257746",
"0.52572376",
"0.52282745",
"0.52014524",
"0.5189774",
"0.5179715",
"0.516316",
"0.5145174",
"0.51316696",
"0.5128949",
"0.5123912",
"0.5123605",... | 0.73574924 | 0 |
Loads the specified song. | def load(self, song):
self.currentSongName = song
self.currentSong = pygame.mixer.music.load(song) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_song(self, path):\n self._menu_select('File->Open')\n self._open_file(path)\n try:\n # Get the annoying Comments window out of the way\n self._app.Comments.minimize()\n except MatchError:\n pass",
"def loadSong(fileName):\n with open (fileN... | [
"0.6981721",
"0.6755066",
"0.6409486",
"0.6405645",
"0.63767195",
"0.62946016",
"0.6293204",
"0.62171227",
"0.6199908",
"0.6159191",
"0.61466426",
"0.6089316",
"0.60279983",
"0.6003873",
"0.6002119",
"0.60020953",
"0.59768283",
"0.59588265",
"0.5956575",
"0.5947801",
"0.59323... | 0.82048696 | 0 |
Mark an existing task in the heap as REMOVED and delete it from the entry_finder. Raise KeyError if not found. | def remove(self, task):
entry = self.entry_finder.pop(task)
entry[-1] = self.REMOVED | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_task(self, task):\n for i, item in enumerate(self.tasks):\n if item is task:\n del self.tasks[i]",
"def delete(self, node):\n\n # logger_cagada.debug(\"norrando nodo %s\" % (type(node)))\n entry = self.entry_finder.pop(node)\n # logger_cagada.debug... | [
"0.66694623",
"0.66056",
"0.64539456",
"0.64364725",
"0.6317414",
"0.6294466",
"0.6164615",
"0.6152803",
"0.6139779",
"0.60942066",
"0.604369",
"0.6039398",
"0.6034774",
"0.60207504",
"0.6006805",
"0.6004575",
"0.59795797",
"0.5877806",
"0.58768666",
"0.5874761",
"0.58690476"... | 0.7819699 | 0 |
Remove and return the lowest priority task from the heap. Raise KeyError if empty. | def pop(self):
while self.pq:
priority, count, task = heapq.heappop(self.pq)
if task is not self.REMOVED:
del self.entry_finder[task]
return task
raise KeyError('pop from an empty priority queue') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_min(self):\r\n # Should raise an exception of size is 0...\r\n if self._size == 0: raise KeyError # Can't remove from an empty heap\r\n result = self._data[0] # remember the smallest\r\n self._data[0] = None # None is so we don't have a reference.\r\n ... | [
"0.7668255",
"0.7574757",
"0.74667835",
"0.7422379",
"0.7402254",
"0.7376742",
"0.73750573",
"0.7343455",
"0.7297022",
"0.72484124",
"0.7206744",
"0.7189073",
"0.71608317",
"0.71471757",
"0.7085695",
"0.70759726",
"0.7072348",
"0.7043073",
"0.70376694",
"0.7022937",
"0.699216... | 0.79744154 | 0 |
Check if device is online and add the entity. | def add_entity(device: SmartPlug, async_add_entities):
# Attempt to get the sysinfo. If it fails, it will raise an
# exception that is caught by async_add_entities_retry which
# will try again later.
device.get_sysinfo()
async_add_entities([SmartPlugSwitch(device)], update_before_add=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_added_to_hass(self):\n self.hass.data[DOMAIN].add_entity_id(self.entity_id)\n self.hass.data[DOMAIN].add_sensor(self)",
"def is_online(self, device):\n # TODO: Add info for the device if it is actually ONLINE\n return device in self.backends",
"def poll_device(self):... | [
"0.6015471",
"0.5891063",
"0.5770823",
"0.5731657",
"0.57188225",
"0.56620145",
"0.5643109",
"0.56374156",
"0.5606649",
"0.55505234",
"0.55300385",
"0.551577",
"0.5509076",
"0.5490396",
"0.54673177",
"0.54582417",
"0.5448342",
"0.5441688",
"0.54276526",
"0.5424822",
"0.540992... | 0.61210483 | 0 |
Turn the switch off. | def turn_off(self, **kwargs):
self.smartplug.turn_off() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def off_switch(self):\n self._switch_callback = None",
"def turn_off(self):\n self.handleCommand(1)\n self._state = STATE_OFF",
"def turn_off(self, **kwargs):\n set_sonoff_state(self._host, \"off\")\n self._state = False",
"def turn_off(self):\n print(\"Turning the l... | [
"0.867637",
"0.85906535",
"0.8523712",
"0.84588856",
"0.84180963",
"0.8404447",
"0.8398465",
"0.8375364",
"0.83491224",
"0.83192796",
"0.82949907",
"0.8277566",
"0.81680954",
"0.8155346",
"0.8112255",
"0.8091075",
"0.8072859",
"0.8058921",
"0.8058517",
"0.8041678",
"0.8036265... | 0.870139 | 0 |
Return the plug from the context. | def _plug_from_context(self):
children = self.smartplug.sys_info["children"]
return next(c for c in children if c["id"] == self.smartplug.context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_plug(self, name):\n return self.plug_dict[name]",
"def get_plugin(self, name):",
"def plugin_instance(self):\n return self.__plugin_instance",
"def default_context(plugin, context):\n return {\"plugin\": plugin}",
"def driver(self):\r\n ext = self.extensions[0]\r\n re... | [
"0.72836846",
"0.66230196",
"0.62327284",
"0.61789984",
"0.60942245",
"0.5989904",
"0.59802115",
"0.5973542",
"0.5973542",
"0.5973542",
"0.5973542",
"0.5973542",
"0.5973542",
"0.5973542",
"0.5966448",
"0.5966448",
"0.5947939",
"0.59386843",
"0.5848881",
"0.5837955",
"0.581756... | 0.7972013 | 0 |
Takes a string, e.g., `'0.17603'` or a float, e.g., `0.17603` and returns a tuple where the first element is the Fraction and the second element is the difference to the original value as a proportion of the original value. | def frac(amount, limit=100):
frac = Fraction(amount).limit_denominator(limit)
frac_double = frac.numerator / frac.denominator
try:
frac_diff = frac_double - amount
except TypeError: # amount is a string
amt = float(amount)
frac_diff = frac_double - amt
relative_diff = f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage_to_fraction(percentage):\n return float(percentage / 100.0)",
"def _fraction_string_to_decimal(fraction: str) -> Decimal:\n parts = fraction.split(\"/\")\n numerator = int(parts[0])\n denominator = int(parts[1])\n return Decimal(numerator / denominator)",
"def change_to_rational(n... | [
"0.6407023",
"0.6283856",
"0.61930007",
"0.6166878",
"0.61665225",
"0.61538124",
"0.59310925",
"0.5849572",
"0.584075",
"0.56524926",
"0.5635948",
"0.56213564",
"0.55592436",
"0.5557316",
"0.55544513",
"0.5553573",
"0.5552682",
"0.5548242",
"0.5509264",
"0.5495675",
"0.547697... | 0.6342941 | 1 |
Computes the simplest (smallest denominator) fraction that approximates (within `max_diff amount`) amount. By default, increases the limit by 1 each time (slow) but will definitely stop at the first result that is sufficiently simple. Alternatively, pass a function (stepfunc is a func of type (int) > int | def simplest_frac(amount, max_diff=0.01, stepfunc=None, debug=DEBUG_MODE):
current_diff = max_diff + 1
current_result = None
current_limit = 1
while abs(current_diff) > max_diff:
current_result = frac(amount, current_limit)
if debug:
print(f'max diff: {max_diff}')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self) -> float:\n step = DEFAULT_STEP\n value_range = abs(self.max_value - self.min_value)\n if value_range != 0:\n while value_range <= step:\n step /= 10.0\n return step",
"def do_work(limit):\n no_of_fractions = 0\n\n # First denominator and... | [
"0.63305366",
"0.62399054",
"0.6199106",
"0.5956308",
"0.58406585",
"0.5658276",
"0.56511635",
"0.55913764",
"0.5573046",
"0.5540557",
"0.5475563",
"0.54754543",
"0.54716456",
"0.5400629",
"0.53267694",
"0.5317078",
"0.5296209",
"0.528592",
"0.52608585",
"0.5249198",
"0.52491... | 0.8158577 | 0 |
Instantiates generator and discriminator with parameters. | def instantiate_network_objects(params):
# Instantiate generator.
generator = generators.Generator(
input_shape=(params["latent_size"]),
kernel_regularizer=tf.keras.regularizers.l1_l2(
l1=params["generator_l1_regularization_scale"],
l2=params["generator_l2_regularization_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, generator:Model,\n discriminator:Model,\n latent_dim:Optional[Union[int, Tuple]]=None,\n n_disc:int=3,\n epochs:int=100, \n batch_size:int=32,\n optimizer:Optional[Union[str, Dict]]=None,\n ... | [
"0.6810049",
"0.6650364",
"0.66342735",
"0.6625637",
"0.6547958",
"0.647228",
"0.64604884",
"0.6410235",
"0.63588136",
"0.6335196",
"0.6238652",
"0.61622006",
"0.6111083",
"0.6055124",
"0.6044253",
"0.6030763",
"0.60140043",
"0.59965104",
"0.5979334",
"0.5970905",
"0.59499454... | 0.7294676 | 0 |
Vanilla GAN custom Estimator model function. | def vanilla_gan_model(params):
# Instantiate generator and discriminator objects.
network_dict = instantiate_network_objects(params)
# Instantiate generator optimizer.
generator_optimizer = instantiate_optimizer(params, scope="generator")
# Instantiate discriminator optimizer.
discriminator_op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_gan(g_model, d_model):\r\n # make weights in the discriminator (some shared with the q model) as not trainable\r\n d_model.trainable = False\r\n # connect g outputs to d inputs\r\n d_output = d_model(g_model.output)\r\n # define composite model\r\n model = Model(g_model.input, d_output... | [
"0.6353647",
"0.6304419",
"0.62466717",
"0.61459804",
"0.6136398",
"0.61236703",
"0.60471606",
"0.6017594",
"0.5973777",
"0.5947182",
"0.5872416",
"0.58470273",
"0.58395267",
"0.5826521",
"0.58180445",
"0.5812097",
"0.58079636",
"0.5790119",
"0.5785252",
"0.57568234",
"0.5736... | 0.63768333 | 0 |
return URL for HITRAN 12 parfile | def url_HITRAN12():
url=u"https://www.cfa.harvard.edu/HITRAN/HITRAN2012/HITRAN2012/By-Molecule/Uncompressed-files/"
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_HITEMP():\n url=u\"https://hitran.org/hitemp/data/bzip2format/\"\n return url",
"def file_url(self, fname):\n gs_url = f\"{self.gs_base_url}/{fname}\"\n return f\"{gs_url}\"",
"def url_HITRANCIA():\n url=u\"https://hitran.org/data/CIA/\"\n return url",
"def url(self):\n ... | [
"0.6452669",
"0.63440126",
"0.63233215",
"0.6274853",
"0.6237435",
"0.6148489",
"0.60967404",
"0.6084041",
"0.6079517",
"0.60351443",
"0.60044044",
"0.593875",
"0.59196824",
"0.591958",
"0.58905053",
"0.58827263",
"0.58819574",
"0.58723444",
"0.5845488",
"0.5835844",
"0.58177... | 0.7261343 | 0 |
return URL for HITRAN CIA ciafile | def url_HITRANCIA():
url=u"https://hitran.org/data/CIA/"
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_HITRAN12():\n url=u\"https://www.cfa.harvard.edu/HITRAN/HITRAN2012/HITRAN2012/By-Molecule/Uncompressed-files/\"\n return url",
"def _file_url(self, fid):\n base = self.tq.threatq_host + '/files/'\n return base + str(fid) + '/details'",
"def remote_url(self) -> str:\n return f... | [
"0.70408565",
"0.6138763",
"0.60811234",
"0.60591507",
"0.60352266",
"0.60036784",
"0.5966616",
"0.5932678",
"0.59245706",
"0.5885469",
"0.58848125",
"0.58844715",
"0.58674806",
"0.58364475",
"0.58210564",
"0.5757505",
"0.573669",
"0.571453",
"0.5692179",
"0.5679866",
"0.5678... | 0.7466736 | 0 |
return URL for HITEMP bz2 parfile | def url_HITEMP():
url=u"https://hitran.org/hitemp/data/bzip2format/"
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_HITRAN12():\n url=u\"https://www.cfa.harvard.edu/HITRAN/HITRAN2012/HITRAN2012/By-Molecule/Uncompressed-files/\"\n return url",
"def get_file_url(self):\n return ('/user-media/addons/3615/delicious_bookmarks-2.1.072-fx.xpi?'\n 'filehash=sha256%3A3808b13ef8341378b9c8305ca6482009... | [
"0.5839622",
"0.5803024",
"0.565694",
"0.54593",
"0.5396386",
"0.5365379",
"0.535061",
"0.5326004",
"0.5297789",
"0.5255205",
"0.52542067",
"0.52349323",
"0.52242327",
"0.52028143",
"0.51905954",
"0.5163859",
"0.5162223",
"0.5153333",
"0.5113982",
"0.51062846",
"0.5091156",
... | 0.69981384 | 0 |
return URL for ExoMol | def url_ExoMol():
url=u"http://www.exomol.com/db/"
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Url(self) -> str:",
"def get_url(self):\r\n if self.mod.filename:\r\n return self.mod.service.get_mirror() + self.mod.filename",
"def url():\n ...",
"def url(self):\n if not os.path.exists(self.path):\n self.save()\n return self.uset.url(os.path.join(self.fol... | [
"0.7125014",
"0.6848426",
"0.6735453",
"0.66766655",
"0.6581823",
"0.65701824",
"0.65248775",
"0.64309263",
"0.63389313",
"0.630634",
"0.6301364",
"0.6301364",
"0.6278326",
"0.62764597",
"0.62506",
"0.6248224",
"0.62394494",
"0.6173976",
"0.6173976",
"0.6173976",
"0.6173976",... | 0.8471234 | 0 |
Construct nonlocal game object from a binary constraint system game. | def from_bcs_game(cls, constraints: list[np.ndarray], reps: int = 1) -> "NonlocalGame":
num_constraints = len(constraints)
if num_constraints == 0:
raise ValueError("At least 1 constraint is required")
num_variables = constraints[0].ndim
# Retrieve dependent variables for ea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_game(self, req):\n return models.BattleShip.create(req.left, req.right)",
"def __init__(self, game, current=None, gameInner=None, pieceInner=None, enemyEnv=None):\n\n self.game = game\n self.gameEnv = GameEnvironment(self.game, self)\n if Q_USE_CONVOLUTIONAL_LAYERS:\n ... | [
"0.5283068",
"0.52795315",
"0.5256074",
"0.52275246",
"0.5195833",
"0.5193166",
"0.5190906",
"0.51309246",
"0.5112733",
"0.5102261",
"0.50863975",
"0.50775015",
"0.50729334",
"0.5063152",
"0.50593895",
"0.50592047",
"0.5057185",
"0.5038618",
"0.5004604",
"0.49999434",
"0.4995... | 0.5664861 | 0 |
r""" Compute a lower bound on the quantum value of a nonlocal game [LD07]_. Calculates a lower bound on the maximum value that the specified nonlocal game can take on in quantum mechanical settings where Alice and Bob each have access to `dim`dimensional quantum system. This function works by starting with a randomlyge... | def quantum_value_lower_bound(
self,
dim: int = 2,
iters: int = 5,
tol: float = 10e-6,
):
# Get number of inputs and outputs.
_, num_outputs_bob, _, num_inputs_bob = self.pred_mat.shape
best_lower_bound = float("-inf")
for _ in range(iters):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimaxLocalSearch(gamestate, depth, timeTotal, alpha, beta, maxEntity):\n bonus = 0\n isTerminalState = gamestate.board.checkTerminalState(gamestate.currentPlayer.noPlayer)\n # Basis Rekursif\n if ((depth == 0) or (time.time() > timeTotal) or (isTerminalState)):\n if (isTerminalState) and (... | [
"0.57273936",
"0.5695391",
"0.56469387",
"0.5637769",
"0.5607225",
"0.5496913",
"0.54709166",
"0.54532737",
"0.54181194",
"0.5404801",
"0.53838634",
"0.53466105",
"0.532478",
"0.52901936",
"0.52881795",
"0.52795726",
"0.5252258",
"0.5250768",
"0.5213736",
"0.5203388",
"0.5202... | 0.66929513 | 0 |
Compute an upper bound on the commuting measurement value of the nonlocal game. This function calculates an upper bound on the commuting measurement value by using klevels of the NPA hierarchy [NPA]_. The NPA hierarchy is a uniform family of semidefinite programs that converges to the commuting measurement value of any... | def commuting_measurement_value_upper_bound(self, k: int | str = 1) -> float:
alice_out, bob_out, alice_in, bob_in = self.pred_mat.shape
mat = defaultdict(cvxpy.Variable)
for x_in in range(alice_in):
for y_in in range(bob_in):
mat[x_in, y_in] = cvxpy.Variable(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_pp(level):\n base_pp = 6\n level_pp = 2 * level\n return base_pp + (level_pp - 2)",
"def calc_level(xp, dominion):\n if xp < 3:\n xp_potential = 1\n if xp >= 3 and xp < 6:\n xp_potential = 2\n if xp >= 6 and xp < 12:\n xp_potential = 3\n if xp >= 12 and xp < 24:\... | [
"0.56043136",
"0.5423251",
"0.5390842",
"0.5316683",
"0.52712446",
"0.5253936",
"0.5244817",
"0.52361995",
"0.5169396",
"0.514784",
"0.50897783",
"0.5058986",
"0.5043447",
"0.5019133",
"0.50130534",
"0.4990135",
"0.4977293",
"0.49693656",
"0.49640068",
"0.49362233",
"0.492511... | 0.61479115 | 0 |
return True if word starts or ends with a word from wordlist | def isWordPartOf(self,word,wordlist):
for w in wordlist:
if w in self._part_of_badword:
return True
if w.startswith(word) or w.endswith(word):
self._part_of_badword[w] = True
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_word(wordlist, word):\n word = word.lower()\n word = word.strip(\" !@#$%^&*()-_+={}[]|\\:;'<>?,./\\\"\")\n return word in wordlist",
"def isWord(wordList, word):\n word = word.lower()\n word = word.strip(\" !@#$%^&*()-_+={}[]|\\\\:;'<>?,./\\\"\")\n return word in wordList",
"def isWord... | [
"0.71524596",
"0.704898",
"0.704898",
"0.704898",
"0.68477887",
"0.68353873",
"0.68219405",
"0.6771139",
"0.67498654",
"0.67202973",
"0.66723657",
"0.6666607",
"0.66264325",
"0.6624651",
"0.6590032",
"0.6564156",
"0.6558892",
"0.6540614",
"0.65204513",
"0.64893687",
"0.648818... | 0.7566571 | 0 |
Returns the result of detect intent with an audio file as input. Using the same `session_id` between requests allows continuation of the conversation. | def detect_intent_audio():
audio_file_path = "/home/gal/toibot_ws/src/ToiBot1/src/speech_to_text/speech_wavs/filename.wav"
session_client = dialogflow.SessionsClient()
# Note: hard coding audio_encoding and sample_rate_hertz for simplicity.
audio_encoding = dialogflow.enums.AudioEncoding.AUDIO_ENCODING... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize(self, session_id):\n session_client = dialogflow.SessionsClient()\n\n # Note: hard coding audio_encoding and sample_rate_hertz for simplicity.\n audio_encoding = dialogflow.enums.AudioEncoding.AUDIO_ENCODING_LINEAR_16\n sample_rate_hertz = 16000\n\n session = sessio... | [
"0.78198",
"0.695255",
"0.6603663",
"0.6244179",
"0.60823435",
"0.6044113",
"0.5958468",
"0.5925653",
"0.5858983",
"0.58178073",
"0.5726882",
"0.5590196",
"0.5583141",
"0.5570892",
"0.55702007",
"0.5562698",
"0.55581576",
"0.5537515",
"0.55369747",
"0.5535112",
"0.5524328",
... | 0.7353236 | 1 |
Create a VirtualNetworkAppliance resource with the given unique name, props, and options. | def __init__(__self__,
resource_name: str,
args: VirtualNetworkApplianceArgs,
opts: Optional[pulumi.ResourceOptions] = None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n name: Optional[pulumi.Input[str]] = None,\n virtual_hub_id: Optional[pulumi.Input[str]] = None) -> 'VirtualNetworkAppliance':\n opts = pulumi.ResourceOptions.me... | [
"0.6483709",
"0.637213",
"0.6368308",
"0.60333127",
"0.5933028",
"0.5920531",
"0.589828",
"0.57977635",
"0.5757888",
"0.5748333",
"0.5737162",
"0.5731979",
"0.5704052",
"0.56233805",
"0.56227636",
"0.5603627",
"0.55801874",
"0.555959",
"0.55522823",
"0.55382586",
"0.55228966"... | 0.71253884 | 0 |
Get an existing VirtualNetworkAppliance resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
name: Optional[pulumi.Input[str]] = None,
virtual_hub_id: Optional[pulumi.Input[str]] = None) -> 'VirtualNetworkAppliance':
opts = pulumi.ResourceOptions.merge(opts, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n force: Optional[pulumi.Input[bool]] = None,\n instance_id: Optional[pulumi.Input[str]] = None,\n state: Optional[pulumi.Input[str]] = None) -> 'InstanceStat... | [
"0.6201526",
"0.57982093",
"0.5736015",
"0.5646393",
"0.5609894",
"0.5605176",
"0.5562416",
"0.5540888",
"0.5526297",
"0.5516919",
"0.54881024",
"0.54570943",
"0.54539675",
"0.5443733",
"0.5311846",
"0.53039557",
"0.52989674",
"0.5293997",
"0.5219828",
"0.5211493",
"0.5136214... | 0.75466305 | 0 |
check if pie chart is plotted correctly (using default style). | def test_plot_pie_chart_default_style(self):
pie_plot = PiePlot(
wedge_sizes=[20, 40, 30, 10],
labels=["light-flavour jets", "c-jets", "b-jets", "tau-jets"],
)
plotname = "test_pie_chart_default_style.png"
pie_plot.savefig(f"{self.actual_plots_dir}/{plotname}")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_plot_pie_chart_custom_style(self):\n pie_plot = PiePlot(\n wedge_sizes=[20, 40, 30, 10],\n labels=[\"light-flavour jets\", \"c-jets\", \"b-jets\", \"tau-jets\"],\n draw_legend=True,\n colours=get_good_colours()[:4],\n # have a look at the possi... | [
"0.6810645",
"0.6215535",
"0.5943787",
"0.59015816",
"0.57677025",
"0.5628101",
"0.56067884",
"0.55829704",
"0.5552299",
"0.5546897",
"0.55407673",
"0.5468097",
"0.5450928",
"0.54284465",
"0.53893375",
"0.53854704",
"0.53848565",
"0.53733534",
"0.5364938",
"0.53586507",
"0.53... | 0.701249 | 0 |
check if pie chart is plotted correctly (using default style). | def test_plot_pie_chart_custom_style(self):
pie_plot = PiePlot(
wedge_sizes=[20, 40, 30, 10],
labels=["light-flavour jets", "c-jets", "b-jets", "tau-jets"],
draw_legend=True,
colours=get_good_colours()[:4],
# have a look at the possible kwargs for matp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_plot_pie_chart_default_style(self):\n pie_plot = PiePlot(\n wedge_sizes=[20, 40, 30, 10],\n labels=[\"light-flavour jets\", \"c-jets\", \"b-jets\", \"tau-jets\"],\n )\n plotname = \"test_pie_chart_default_style.png\"\n pie_plot.savefig(f\"{self.actual_plot... | [
"0.7013918",
"0.62174886",
"0.5943961",
"0.59015816",
"0.57674253",
"0.56307137",
"0.5607042",
"0.55853486",
"0.5553504",
"0.5548517",
"0.55420166",
"0.5469935",
"0.54514027",
"0.5428705",
"0.53906536",
"0.5386055",
"0.53860503",
"0.537129",
"0.5366187",
"0.5360201",
"0.53196... | 0.6812573 | 1 |
Run OCR for all the boxes. | def run_ocr_in_chart(chart, pad=0, psm=PSM.SINGLE_LINE):
img = chart.image
# add a padding to the initial figure
fpad = 1
img = cv2.copyMakeBorder(img.copy(), fpad, fpad, fpad, fpad, cv2.BORDER_CONSTANT, value=(255, 255, 255))
fh, fw, _ = img.shape
api = PyTessBaseAPI(psm=psm, lang='eng')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_textboxes(gt_boxes, boxes):\n assert len(gt_boxes) == len(boxes)\n \n iou = 0\n # compute IOU per image\n for i in range(len(boxes)):\n if len(boxes[i]) == 0 or len(gt_boxes[i]) == 0:\n continue\n \n max_dim = np.max(np.max(boxes[i]))\n shape =... | [
"0.65326566",
"0.6261916",
"0.6236352",
"0.61314714",
"0.6113341",
"0.6108616",
"0.5936302",
"0.59256",
"0.5911103",
"0.5908094",
"0.5882378",
"0.5880716",
"0.5813167",
"0.58092713",
"0.5807783",
"0.57885075",
"0.5769818",
"0.5737877",
"0.5705715",
"0.5673986",
"0.5651309",
... | 0.63410026 | 1 |
Reads the contents of a pfile. Returns a tuple (features, labels), where both elements are lists of 2D numpy arrays. Each element of a list corresponds to a sentence; each row of a 2D array corresponds to a frame. In the case where the pfile doesn't contain labels, "labels" will be None. | def readPfile(filename):
with smart_open(filename, "rb") as f:
# Read header
# Assuming all data are consistent
for line in f:
tokens = line.decode().split()
if tokens[0] == "-pfile_header":
headerSize = int(tokens[4])
elif tokens[0] == "-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_features_from_file(filename):\n\tf = np.loadtxt(filename)\n\treturn f[:,:4],f[:,4:] # feature locations, descriptors",
"def read_data(feature_file, label_file):",
"def read_file(filename):\n contents, labels = [], []\n with open_file(filename) as f:\n for line in f:\n try:\n ... | [
"0.6479107",
"0.64477426",
"0.63880754",
"0.6314104",
"0.63055766",
"0.62895685",
"0.6252734",
"0.6156262",
"0.6133945",
"0.61212313",
"0.61121446",
"0.6105066",
"0.61001927",
"0.60388434",
"0.5959132",
"0.59425837",
"0.59364706",
"0.5934543",
"0.59034926",
"0.5866229",
"0.58... | 0.7912509 | 0 |
Writes "features" and "labels" to a pfile. Both "features" and "labels" should be lists of 2D numpy arrays. Each element of a list corresponds to a sentence; each row of a 2D array corresponds to a frame. In the case where there is only one label per frame, the elements of the "labels" list can be 1D arrays. | def writePfile(filename, features, labels = None):
nSentences = len(features)
nFrames = sum(len(x) for x in features)
nFeatures = len(numpy.array(features[0][0]).ravel())
nLabels = len(numpy.array(labels[0][0]).ravel()) if labels is not None else 0
nCols = 2 + nFeatures + nLabels
headerSize = 3... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_feature_labels(output, feature_labels):\n with open(os.path.join(output, 'features.list'), 'w') as out_file:\n out_file.write('\\n'.join(feature_labels))",
"def writeFeatures(features, labels, output_filename):\n\twith open(output_filename, 'w') as csvfile:\n\t fieldnames = features[0].key... | [
"0.7423558",
"0.7189319",
"0.6823785",
"0.67402846",
"0.661547",
"0.6509026",
"0.6493378",
"0.6491411",
"0.6418999",
"0.6394735",
"0.6366539",
"0.63443375",
"0.63089496",
"0.6292406",
"0.62670076",
"0.62670076",
"0.6166569",
"0.61093026",
"0.59354526",
"0.5918788",
"0.58827",... | 0.7796732 | 0 |
Builds phi (longitudinal) spectrogram from a sanitized particle data structure. | def mms_pgs_make_phi_spec(data_in, resolution=32):
data = data_in.copy()
n_phi = resolution
# zero inactive bins to ensure areas with no data are represented as NaN
zero_bins = np.argwhere(data['bins'] == 0)
if zero_bins.size != 0:
for item in zero_bins:
data['data'][item[0], it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_phi(self):\n self.phi = np.empty((100, self.K))\n for i, point in enumerate(self.X):\n for j, center in enumerate(self.centers):\n self.phi[i][j] = np.exp(-self.gamma * distance.euclidean(point, center) ** 2)\n self.phi = np.concatenate((self.phi, np.ones... | [
"0.5458877",
"0.53676385",
"0.5313945",
"0.5233425",
"0.5209792",
"0.5116669",
"0.50947446",
"0.5071428",
"0.50414526",
"0.50410014",
"0.50201",
"0.501828",
"0.5016945",
"0.49950805",
"0.49817097",
"0.49776",
"0.49595466",
"0.4944712",
"0.49397746",
"0.49216998",
"0.4919174",... | 0.5455222 | 1 |
Add an attribute with a ``ajax.Update`` value | def add_ajax_attribute(self, name, value):
# Generate a XHR request
xml.add_attribute(self, name, value.generate_action(self._actions[0], self.renderer)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_js_attribute(self, name, value):\n self.set(name, value.generate_action(None, self.renderer))",
"def add_method_attribute(self, name, value):\n # Transcode the method to javascript\n xml.add_attribute(self, name, ajax.JS(value))",
"def _attr_updated(self, name, value):\n event = Attribu... | [
"0.68151414",
"0.6515366",
"0.6233622",
"0.6075469",
"0.5787591",
"0.57643515",
"0.5748664",
"0.5742068",
"0.5690859",
"0.5606841",
"0.56038415",
"0.5575926",
"0.55740505",
"0.5551931",
"0.554361",
"0.5536292",
"0.55248076",
"0.55197036",
"0.5480152",
"0.5480152",
"0.5480152"... | 0.7841153 | 0 |
Add an attribute with a function value | def add_function_attribute(self, name, value):
# Transcode the function to javascript
xml.add_attribute(self, name, ajax.JS(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_attrib(self, key, func, func_args):\n if key in self.aux_attrib:\n raise KeyError(\"Attribute '{0}' already exists, please use 'set_attrib'.\".format(key))\n else:\n self.set_attrib(key, func, func_args)",
"def add_function(self, func_name, *args, **kwargs):\n i... | [
"0.73063284",
"0.72746456",
"0.7231678",
"0.7195455",
"0.707141",
"0.7026056",
"0.69747573",
"0.6970949",
"0.696804",
"0.69499767",
"0.6926322",
"0.6922663",
"0.691625",
"0.6868396",
"0.68668944",
"0.6850461",
"0.6821584",
"0.68176943",
"0.680651",
"0.6790069",
"0.6734101",
... | 0.7730336 | 0 |
Add an attribute with a method value | def add_method_attribute(self, name, value):
# Transcode the method to javascript
xml.add_attribute(self, name, ajax.JS(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_attribute(self, attr):\n self.add(attr)",
"def add_attribute(self, attr):\n self.attrs.add_attribute(attr)",
"def addattribute(self, uid, field, value):\n\n raise NotImplementedError",
"def add_attrib(self, key, func, func_args):\n if key in self.aux_attrib:\n r... | [
"0.72672397",
"0.70987725",
"0.6989709",
"0.69685096",
"0.69390506",
"0.69300306",
"0.6916354",
"0.68777883",
"0.6869262",
"0.6845307",
"0.68409324",
"0.6807101",
"0.67792225",
"0.6776735",
"0.6774255",
"0.6766906",
"0.6755039",
"0.6735037",
"0.6719012",
"0.67090887",
"0.6702... | 0.761008 | 0 |
Add an attribute with a ``ajax.JS`` value | def add_js_attribute(self, name, value):
self.set(name, value.generate_action(None, self.renderer)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_ajax_attribute(self, name, value):\n # Generate a XHR request\n xml.add_attribute(self, name, value.generate_action(self._actions[0], self.renderer))",
"def add_function_attribute(self, name, value):\n # Transcode the function to javascript\n xml.add_attribute(self, name, ajax.JS(value))",
... | [
"0.78889525",
"0.7223823",
"0.7151742",
"0.59485906",
"0.5572903",
"0.54335433",
"0.52503747",
"0.5216377",
"0.5129981",
"0.51049256",
"0.509444",
"0.50548637",
"0.5052543",
"0.5051976",
"0.5036709",
"0.49863476",
"0.49621892",
"0.49498203",
"0.49498203",
"0.49498203",
"0.494... | 0.7985821 | 0 |
Convert a relative URL of a static content to an absolute one | def absolute_url(url, static):
if url.startswith('#'):
return url
i = url.find(':')
if ((i == -1) or not url[:i].isalpha()) and url and (url[0] != '/'):
# If this is a relative URL, it's relative to the statics directory
if not static.endswith('/') and not url.startswith('/'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remap_static_url(original_url, course):\r\n # Ick: this should be possible without having to quote and unquote the URL...\r\n input_url = \"'\" + original_url + \"'\"\r\n output_url = replace_static_urls(\r\n input_url,\r\n getattr(course, 'data_dir', None),\r\n course_id=course.i... | [
"0.6940429",
"0.68051386",
"0.6632963",
"0.64693373",
"0.6446491",
"0.64338994",
"0.63079447",
"0.6306596",
"0.6290737",
"0.6266544",
"0.6254872",
"0.62398434",
"0.62171376",
"0.62120706",
"0.62011",
"0.61750597",
"0.6109502",
"0.60486513",
"0.60411066",
"0.6038771",
"0.60081... | 0.7290656 | 0 |
Renderer initialisation The ``HeadRenderer`` keeps track of the javascript and css used by every views, to be able to concatenate them into the ```` section. | def __init__(self, static_url):
super(HeadRenderer, self).__init__()
# Directory where are located the static contents of the application
self.static_url = static_url
self._named_css = {} # CSS code
self._css_url = {} # CSS URLs
self._named_javascript ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(self, h, *args):\n\n # Create the tags to include the CSS styles and the javascript codes\n\n head = self.root\n\n if isinstance(head, ET.ElementBase) and (head.tag == 'head'):\n # If a ``<head>`` tag already exist, take its content\n head = self.head(head[:], dict(head.attrib))\n... | [
"0.6792161",
"0.6449125",
"0.58466434",
"0.5689005",
"0.55307853",
"0.55128866",
"0.5467106",
"0.54037964",
"0.53657",
"0.53409976",
"0.5316373",
"0.5263636",
"0.5252489",
"0.52406925",
"0.52315617",
"0.5227174",
"0.52092224",
"0.5201493",
"0.5186905",
"0.5182038",
"0.5177873... | 0.72004354 | 0 |
Memorize an inline named css style | def css(self, name, style, **kw):
self._named_css.setdefault(name, (self._order, style, kw))
self._order += 1
return () | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateInlineCSS():",
"def _css(self, style):\n self._anonymous_css.append((self._order, style))\n self._order += 1",
"def cache_style_content(self, content, inline=False):\n\t\tif inline:\n\t\t\tsheet = cssutils.parseStyle(content)\n\t\telse:\n\t\t\tsheet = cssutils.parseString(content, hre... | [
"0.72046155",
"0.67504823",
"0.62656724",
"0.6125977",
"0.59719205",
"0.59340906",
"0.5891716",
"0.5886623",
"0.58833194",
"0.5823726",
"0.5817398",
"0.57964844",
"0.57822603",
"0.57586986",
"0.5738716",
"0.56741893",
"0.5671205",
"0.5650821",
"0.5650079",
"0.5635341",
"0.563... | 0.67921805 | 1 |
Memorize an inline named javascript code | def javascript(self, name, script, **kw):
if callable(script):
# Transcode the function or the method to javascript code
script = ajax.javascript(script)
if isinstance(script, ajax.JS):
# Transcoded javascript needs a helper
self.javascript_url('/static/n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_javascript_in_anonfct(js_data):\n return \"(function(){\"+js_data+\"})()\"",
"def js_minify2(js):\n log.debug(\"Obfuscating Javascript variables names inside functions.\")\n # if eval() or with{} is used on JS is not too Safe to Obfuscate stuff.\n is_ok = \"eval(\" not in js and \"with{\" no... | [
"0.6899933",
"0.64296746",
"0.6203096",
"0.6180724",
"0.6160276",
"0.61385953",
"0.58633286",
"0.585141",
"0.58496076",
"0.5697568",
"0.56682783",
"0.5664831",
"0.5648165",
"0.56456304",
"0.5525566",
"0.54634964",
"0.54531133",
"0.5352807",
"0.53292936",
"0.53059787",
"0.5297... | 0.6545581 | 1 |
Memorize a javascript URL | def javascript_url(self, url, **kw):
self._javascript_url.setdefault(absolute_url(url, self.static_url), (self._order, kw))
self._order += 1
return () | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def propeller_javascript_url():\n return javascript_url()",
"def ajax_url(url):\n\n hashbang_index = url.find('#!')\n if hashbang_index != -1:\n base = url[:hashbang_index]\n joiner = '?' if '?' not in base else '&'\n url = ''.join((base, joiner, '_escaped_fragment_=',\n ... | [
"0.6716826",
"0.6287909",
"0.59694946",
"0.5952668",
"0.5952474",
"0.58800566",
"0.5849158",
"0.583355",
"0.57910466",
"0.57712585",
"0.57588375",
"0.57173413",
"0.56773674",
"0.5629055",
"0.5622679",
"0.557159",
"0.5567627",
"0.55660737",
"0.55287856",
"0.5492426",
"0.547981... | 0.6487602 | 1 |
Return the list of the inline named css styles, sorted by order of insertion | def _get_named_css(self):
return [(name, style, attributes) for (name, (order, style, attributes)) in sorted(self._named_css.items(), key=operator.itemgetter(1))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_anonymous_css(self):\n return [css for (order, css) in sorted(self._anonymous_css)]",
"def proc_style(self, tokens):\n # FIXME: Implement style attributes.\n return []",
"def getstyle(self, tag):\n try:\n styledict = tag.style.__dict__\n except AttributeEr... | [
"0.7197739",
"0.67697215",
"0.6636097",
"0.6589225",
"0.64021933",
"0.631277",
"0.63127476",
"0.6253289",
"0.6182361",
"0.6136956",
"0.6096252",
"0.60787004",
"0.6058815",
"0.60491645",
"0.60416996",
"0.5828495",
"0.5809348",
"0.579352",
"0.5786266",
"0.5776939",
"0.5715244",... | 0.77601963 | 0 |
Return the list of css URLs, sorted by order of insertion | def _get_css_url(self):
return [(url, attributes) for (url, (order, attributes)) in sorted(self._css_url.items(), key=operator.itemgetter(1))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_urls(urls):\n order = {\"css\": 0, \"js\": 1}\n urls.sort(key=lambda x: order.get(x.rsplit(\".\")[-1].lower(), 2))\n return urls",
"def get_css(soup, fileDict):\r\n for link in soup.findAll('link'):\r\n if link['type'] == 'text/css':\r\n css = DOMAIN + link['href']\r\n ... | [
"0.6759898",
"0.65670496",
"0.6496946",
"0.63735026",
"0.62205386",
"0.62195784",
"0.6213182",
"0.6068431",
"0.6044544",
"0.60424286",
"0.59850913",
"0.59765625",
"0.59358805",
"0.59200627",
"0.58554524",
"0.5838407",
"0.58196706",
"0.5811292",
"0.57994336",
"0.57936436",
"0.... | 0.7716838 | 0 |
Return the list of named javascript codes, sorted by order of insertion | def _get_named_javascript(self):
return [(name, js, attributes) for (name, (order, js, attributes)) in sorted(self._named_javascript.items(), key=operator.itemgetter(1))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_anonymous_javascript(self):\n return [js for (order, js) in sorted(self._anonymous_javascript)]",
"def nameList(self):\r\n return [self.name.lower(), self.code] + self._otherNames",
"def get_code():\n return inspect.getsource(sort)",
"def list():\n\n return cache.codeTableList()"... | [
"0.715811",
"0.6300202",
"0.60737324",
"0.60523796",
"0.59363806",
"0.5925758",
"0.58533365",
"0.578013",
"0.57658386",
"0.57317615",
"0.56563723",
"0.5631284",
"0.56270975",
"0.5598216",
"0.5595417",
"0.55879956",
"0.55612814",
"0.55516833",
"0.55338776",
"0.54731494",
"0.54... | 0.7621781 | 0 |
Return the list of javascript URLs, sorted by order of insertion | def _get_javascript_url(self):
return [(url, attributes) for (url, (order, attributes)) in sorted(self._javascript_url.items(), key=operator.itemgetter(1))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_urls(urls):\n order = {\"css\": 0, \"js\": 1}\n urls.sort(key=lambda x: order.get(x.rsplit(\".\")[-1].lower(), 2))\n return urls",
"def _get_anonymous_javascript(self):\n return [js for (order, js) in sorted(self._anonymous_javascript)]",
"def get_urls():\r\n return []",
"def ... | [
"0.7061752",
"0.67775434",
"0.6522144",
"0.63693315",
"0.6277138",
"0.6155464",
"0.61204743",
"0.6007929",
"0.5985964",
"0.5912752",
"0.58802736",
"0.5813567",
"0.57517964",
"0.5739859",
"0.57275695",
"0.5709757",
"0.5709638",
"0.57080024",
"0.56940836",
"0.56722206",
"0.5649... | 0.7669407 | 0 |
Register a synchronous action | def sync_action(self, renderer, action, with_request):
self.set(self._actions[1], renderer.register_callback(self._actions[0], action, with_request)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def perform_action(self) -> None:",
"def register_action(self, name, command):\n action_name = command['action_name']\n if action_name not in self.al_clients:\n action_type = self.get_interface_type(command['interface_type'], '.action')\n self.al_clients[action_name] = A... | [
"0.6163529",
"0.61518764",
"0.60082024",
"0.5948825",
"0.5912427",
"0.58522606",
"0.5807863",
"0.5774992",
"0.5769407",
"0.5764641",
"0.5739238",
"0.570953",
"0.57032704",
"0.56630397",
"0.5657883",
"0.55930287",
"0.558469",
"0.55544263",
"0.55245966",
"0.5490227",
"0.5487672... | 0.6893943 | 0 |
Register an asynchronous action | def async_action(self, renderer, action, with_request):
if not isinstance(action, ajax.Update):
action = ajax.Update(action=action, with_request=with_request)
self.set(self._actions[2], action.generate_action(self._actions[0], renderer)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_action(self, renderer, action, with_request):\n self.set(self._actions[1], renderer.register_callback(self._actions[0], action, with_request))",
"async def perform_action(self) -> None:",
"def action(self, tag, action, with_request):\n tag.async_action(self, action, with_request)",
"de... | [
"0.65998065",
"0.6508633",
"0.64818287",
"0.62131906",
"0.6178128",
"0.6048961",
"0.5997042",
"0.59651434",
"0.59346753",
"0.59256625",
"0.581508",
"0.57448465",
"0.5705868",
"0.5680487",
"0.5638908",
"0.56294847",
"0.56239974",
"0.56195617",
"0.561077",
"0.55405813",
"0.5539... | 0.6518126 | 1 |
Register a synchronous action The action will have to return the image data | def sync_action(self, renderer, action, with_request):
f = partial.Partial(self._set_content_type, _action=action, with_request=with_request)
self.set('src', renderer.add_sessionid_in_url(sep=';') + ';' + renderer.register_callback(2, f, with_request=True)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_action(self, renderer, action, with_request):\n self.set(self._actions[1], renderer.register_callback(self._actions[0], action, with_request))",
"def do_start(self, action):\n StaticFile = Pool().get('nereid.static.file')\n\n static_file = StaticFile(Transaction().context.get('activ... | [
"0.61154354",
"0.604753",
"0.5784594",
"0.5754564",
"0.5661058",
"0.56537765",
"0.52781683",
"0.5231107",
"0.52116144",
"0.5155357",
"0.51319826",
"0.5126661",
"0.5122823",
"0.51012886",
"0.50637245",
"0.50510484",
"0.503998",
"0.5019895",
"0.50023127",
"0.49943146",
"0.49915... | 0.6150861 | 0 |
Create an associated asynchronous HTML renderer | def AsyncRenderer(self, *args, **kw):
# If no arguments are given, this renderer becomes the parent of the
# newly created renderer
if not args and not kw:
args = (self,)
return AsyncRenderer(*args, **kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AsyncRenderer(self, *args, **kw):\n # If no arguments are given, this renderer becomes the parent of the\n # newly created renderer\n if not args and not kw:\n args = (self,)\n\n return self.__class__(*args, **kw)",
"def render(self):\n raise NotImplementedError(... | [
"0.710635",
"0.5953376",
"0.59113735",
"0.58568114",
"0.5802428",
"0.5719081",
"0.5716875",
"0.5715162",
"0.5706176",
"0.56993824",
"0.56985855",
"0.5662752",
"0.5657352",
"0.56467086",
"0.5646058",
"0.5620385",
"0.5608474",
"0.5581224",
"0.5558615",
"0.5558548",
"0.55566925"... | 0.7090812 | 1 |
Generate the DOCTYPE of the document If a doctype was set on the response object, use it Else, use the HTML ou XHTML doctypes of this renderer | def doctype(self):
response = self.response
if response.doctype is not None:
return response.doctype
return self.XML_DOCTYPE if response.xml_output else self.HTML_DOCTYPE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xmldoc(self, doctype):\n # we hack in the DOCTYPE using the parser\n docstr = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE %s SYSTEM \"file:///usr/share/emane/dtd/%s.dtd\">\n <%s/>\"\"\" % (doctype, doctype, doctype)\n # normally this would be: doc = Document(... | [
"0.6120321",
"0.54680014",
"0.5340721",
"0.5258562",
"0.51871645",
"0.5171257",
"0.5152302",
"0.5116068",
"0.5028383",
"0.50265384",
"0.50095177",
"0.50023174",
"0.49935582",
"0.49037078",
"0.48833546",
"0.48567227",
"0.48562366",
"0.4814372",
"0.47897103",
"0.470156",
"0.463... | 0.76996183 | 0 |
Generate the content type of the document If a content type was set on the response object, use it Else, use the HTML ou XHTML content type of this renderer | def content_type(self):
response = self.response
if response.content_type:
return response.content_type
return 'application/xhtml+xml' if response.xml_output else 'text/html' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CONTENT_TYPE(self):",
"def content_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"content_type\")",
"def content_type(self) -> str:\n return pulumi.get(self, \"content_type\")",
"def content_type(self):\r\n return self.__content_type",
"def content_type(self):\n ... | [
"0.6765369",
"0.6763161",
"0.6675109",
"0.6672418",
"0.65277874",
"0.645715",
"0.6426409",
"0.6417607",
"0.63847506",
"0.63470113",
"0.63402563",
"0.6328932",
"0.6328278",
"0.62982404",
"0.6285868",
"0.6284358",
"0.6283006",
"0.6272976",
"0.6272383",
"0.6260134",
"0.6251464",... | 0.8085524 | 0 |
Register a synchronous action on a tag | def action(self, tag, action, with_request):
tag.sync_action(self, action, with_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self, tag, action, with_request):\n tag.async_action(self, action, with_request)",
"def push_tag(self, tag):\n _tag_entity('task', self.task_id, tag)",
"def sync_action(self, renderer, action, with_request):\n self.set(self._actions[1], renderer.register_callback(self._actions[0... | [
"0.72214663",
"0.60455585",
"0.5851493",
"0.57009196",
"0.5500962",
"0.5495582",
"0.5483852",
"0.54292995",
"0.54260516",
"0.5349953",
"0.534746",
"0.5329074",
"0.5291505",
"0.52782446",
"0.52682793",
"0.52675897",
"0.5250884",
"0.52481234",
"0.5213831",
"0.5185042",
"0.51850... | 0.71138674 | 1 |
During the rendering, highlight an element that has an error | def decorate_error(self, element, error):
if error is None:
return element
div = self.div(class_='nagare-error-input')
div.append(element)
return self.div(
div,
self.div(error, class_='nagare-error-message'),
class_='nagare-error-field'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _try_highlight(code: str) -> str:\n pretty = pygments.highlight(code, lexer, signature_formatter).strip()\n if '<span class=\"err\">' not in pretty:\n return pretty\n else:\n return html.escape(code)",
"def _highlight_error(doc: str, err_lineno: int) -> str:\n ... | [
"0.6315305",
"0.6040992",
"0.60155904",
"0.60121435",
"0.6011253",
"0.5966383",
"0.59566885",
"0.59525627",
"0.59378624",
"0.5895664",
"0.5884718",
"0.5851046",
"0.58482516",
"0.5827483",
"0.5770929",
"0.57320607",
"0.57220846",
"0.5695249",
"0.56752497",
"0.56749165",
"0.566... | 0.6175157 | 1 |
Add the session and continuation ids into an url Forward this call to the sessions manager | def add_sessionid_in_url(self, u='', params=None, sep='&'):
i = u.find(':')
if ((i == -1) or not u[:i].isalpha()) and (not u or (u[0] != '/')):
u = self.url + '/' + u
if params is None:
params = ()
if self.session:
u += '?' + sep.join(self.session.se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, action, uids):\n uids = \",\".join(uids)\n url = \"{}/courier_shipment?uids={}\".format(self.back_url, uids)\n return self.redirect(redirect_url=url)",
"def generate_auth_sub_url(next, scopes, secure=False, session=True,\n request_url=atom.http_core.parse_uri(\n ... | [
"0.52751213",
"0.5235955",
"0.5218152",
"0.520356",
"0.51765317",
"0.5126691",
"0.51162815",
"0.5115808",
"0.5087683",
"0.50780606",
"0.49630216",
"0.4914782",
"0.49137837",
"0.49079183",
"0.4866877",
"0.47644067",
"0.47576442",
"0.47518677",
"0.47369367",
"0.47294745",
"0.47... | 0.56874806 | 0 |
Memorize an inline anonymous css style | def _css(self, style):
self._anonymous_css.append((self._order, style))
self._order += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateInlineCSS():",
"def generateInlineCSS(self, *args, **kwargs): \n return \"\"\"\n .googleLoading.googleMapView #CustomGoogleMap { \n height:520px;\n background: url(\"../image/map/stripeHorz.gif\") repeat-x scroll 0 0 transparent;\n padding: 20px;\n ... | [
"0.7789631",
"0.64866835",
"0.60587925",
"0.6024121",
"0.59967977",
"0.5881994",
"0.57379484",
"0.57242656",
"0.5719525",
"0.56941307",
"0.56649125",
"0.56587523",
"0.5635615",
"0.5622646",
"0.5617564",
"0.56134486",
"0.56113535",
"0.5573434",
"0.55668753",
"0.5535555",
"0.54... | 0.68824816 | 1 |
Memorize an inline anonymous javascript code | def _javascript(self, script):
self._anonymous_javascript.append((self._order, script))
self._order += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_javascript_in_anonfct(js_data):\n return \"(function(){\"+js_data+\"})()\"",
"def code():",
"def js_minify2(js):\n log.debug(\"Obfuscating Javascript variables names inside functions.\")\n # if eval() or with{} is used on JS is not too Safe to Obfuscate stuff.\n is_ok = \"eval(\" not in js... | [
"0.7441437",
"0.6073743",
"0.6041061",
"0.59601086",
"0.58316284",
"0.5755714",
"0.56314254",
"0.5598951",
"0.55498785",
"0.5523802",
"0.5402592",
"0.5402403",
"0.5378602",
"0.53712034",
"0.53552216",
"0.5354268",
"0.53472936",
"0.5322025",
"0.53124946",
"0.52592057",
"0.5254... | 0.6128811 | 1 |
Return the list of the inline anonymous css styles, sorted by order of insertion | def _get_anonymous_css(self):
return [css for (order, css) in sorted(self._anonymous_css)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_named_css(self):\n\n return [(name, style, attributes) for (name, (order, style, attributes)) in sorted(self._named_css.items(), key=operator.itemgetter(1))]",
"def proc_style(self, tokens):\n # FIXME: Implement style attributes.\n return []",
"def _css(self, style):\n self... | [
"0.7230669",
"0.6899848",
"0.6571776",
"0.6504407",
"0.65043885",
"0.64826506",
"0.643032",
"0.6383127",
"0.62738925",
"0.6034242",
"0.59477663",
"0.5926201",
"0.59257543",
"0.5914245",
"0.5897163",
"0.5893435",
"0.58758426",
"0.5852099",
"0.5830343",
"0.58041245",
"0.5780828... | 0.77384955 | 0 |
Return the list of anonymous javascript codes, sorted by order of insertion | def _get_anonymous_javascript(self):
return [js for (order, js) in sorted(self._anonymous_javascript)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_named_javascript(self):\n return [(name, js, attributes) for (name, (order, js, attributes)) in sorted(self._named_javascript.items(), key=operator.itemgetter(1))]",
"def _javascript(self, script):\n self._anonymous_javascript.append((self._order, script))\n self._order += 1",
"de... | [
"0.7072183",
"0.6108628",
"0.599285",
"0.59644276",
"0.5930817",
"0.5765333",
"0.5730981",
"0.5686627",
"0.5684599",
"0.56248623",
"0.55959797",
"0.5586417",
"0.5547204",
"0.55260557",
"0.55190676",
"0.55190426",
"0.5511106",
"0.5398968",
"0.53989315",
"0.53965914",
"0.539187... | 0.79115456 | 0 |
Create an associated asynchronous HTML renderer | def AsyncRenderer(self, *args, **kw):
# If no arguments are given, this renderer becomes the parent of the
# newly created renderer
if not args and not kw:
args = (self,)
return self.__class__(*args, **kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AsyncRenderer(self, *args, **kw):\n # If no arguments are given, this renderer becomes the parent of the\n # newly created renderer\n if not args and not kw:\n args = (self,)\n\n return AsyncRenderer(*args, **kw)",
"def AsyncRenderer(self, *args, **kw):\n # If no... | [
"0.7091472",
"0.7091472",
"0.594948",
"0.5911716",
"0.5854364",
"0.58015937",
"0.5716082",
"0.5714984",
"0.5713032",
"0.57068735",
"0.5698525",
"0.56964815",
"0.56612664",
"0.5654472",
"0.56453305",
"0.56444037",
"0.5617823",
"0.5607098",
"0.55799204",
"0.5559009",
"0.5557173... | 0.7106957 | 0 |
Register an asynchronous action on a tag | def action(self, tag, action, with_request):
tag.async_action(self, action, with_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self, tag, action, with_request):\n tag.sync_action(self, action, with_request)",
"def async_action(self, renderer, action, with_request):\n if not isinstance(action, ajax.Update):\n action = ajax.Update(action=action, with_request=with_request)\n\n self.set(self._actio... | [
"0.6502161",
"0.59794897",
"0.58341646",
"0.5751508",
"0.57190454",
"0.56805253",
"0.56396633",
"0.55127037",
"0.54871196",
"0.5465213",
"0.537171",
"0.53155005",
"0.5300982",
"0.52875805",
"0.52851075",
"0.52552724",
"0.5253015",
"0.5245315",
"0.52284205",
"0.51902205",
"0.5... | 0.75662386 | 0 |
The name of the machine | def machine_name(self) -> str:
return pulumi.get(self, "machine_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_machine_name(self):\n self.machine = platform.uname().node\n return self.machine",
"def computer_name(self) -> str:\n return pulumi.get(self, \"computer_name\")",
"def machine():\n return uname().machine",
"def machine():\n return uname().machine",
"def machine_name(self... | [
"0.8530881",
"0.83184624",
"0.8035836",
"0.8035836",
"0.80100316",
"0.80100316",
"0.7528964",
"0.74322504",
"0.7399433",
"0.7358223",
"0.7357329",
"0.7301388",
"0.7256131",
"0.72033924",
"0.7202233",
"0.7151172",
"0.71449375",
"0.710232",
"0.710175",
"0.70895344",
"0.7066498"... | 0.90458274 | 0 |
Azure resource Id of the workspace the machine is attached to | def workspace_id(self) -> str:
return pulumi.get(self, "workspace_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_workspace_id() -> str:\n token = BaseHook.get_connection(AirflowConns.TERRAFORM).password\n terraform_api = TerraformApi(token)\n\n # Get organization\n organization = Variable.get(AirflowVars.TERRAFORM_ORGANIZATION)\n\n # Get workspace\n environment = Variable.get(AirflowVars.ENVIRONMENT... | [
"0.72242045",
"0.72234267",
"0.72091603",
"0.71540064",
"0.71540064",
"0.70464975",
"0.6891388",
"0.6891388",
"0.6812387",
"0.66599363",
"0.65873826",
"0.6529958",
"0.6398516",
"0.6271846",
"0.6264693",
"0.6120342",
"0.6120342",
"0.6120342",
"0.6056778",
"0.6056778",
"0.60567... | 0.76052606 | 0 |
The Sql database name installed on the machine | def database_name(self) -> str:
return pulumi.get(self, "database_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDatabaseName(self):\n return self._base.getDatabaseName()",
"def getDatabaseName(self):\n raise NotImplementedError",
"def database_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"database_name\")",
"def get_db_name(self):\n\t\treturn conf.db_name",
"def db_name(se... | [
"0.80053836",
"0.793443",
"0.79146576",
"0.776606",
"0.7692705",
"0.7633034",
"0.7602243",
"0.7477083",
"0.74397504",
"0.7425721",
"0.73586315",
"0.72684866",
"0.71109664",
"0.707927",
"0.7013845",
"0.69296294",
"0.6894068",
"0.6840425",
"0.67579883",
"0.67426413",
"0.673065"... | 0.80771595 | 0 |
The name of the machine | def machine_name(self) -> str:
return pulumi.get(self, "machine_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_machine_name(self):\n self.machine = platform.uname().node\n return self.machine",
"def computer_name(self) -> str:\n return pulumi.get(self, \"computer_name\")",
"def machine():\n return uname().machine",
"def machine():\n return uname().machine",
"def machine_name(self... | [
"0.8532088",
"0.8318477",
"0.8037362",
"0.8037362",
"0.8010908",
"0.8010908",
"0.7529093",
"0.74321127",
"0.7400003",
"0.73594725",
"0.7358173",
"0.730195",
"0.72559154",
"0.72024065",
"0.720158",
"0.71506864",
"0.71440697",
"0.7101558",
"0.7101514",
"0.70889777",
"0.7065817"... | 0.90468234 | 1 |
The Sql server name installed on the machine | def server_name(self) -> str:
return pulumi.get(self, "server_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db_server_name(self):\n if self.db_config_file.key_exists(\"server_name\"):\n return self.db_config_file_value(\"server_name\").strip('\"')\n return self.get_system_id()",
"def get_host_name(self):\n return self.get_command_output(\"hostname\").strip(\"\\n\")",
"def get_... | [
"0.70862",
"0.6715162",
"0.66858387",
"0.66587603",
"0.66587603",
"0.66160357",
"0.66100967",
"0.6593616",
"0.6554033",
"0.65457565",
"0.6545528",
"0.65286964",
"0.65076476",
"0.6498059",
"0.64489233",
"0.64489233",
"0.64475244",
"0.64432335",
"0.64315045",
"0.64294493",
"0.6... | 0.6821417 | 1 |
Azure resource Id of the workspace the machine is attached to | def workspace_id(self) -> str:
return pulumi.get(self, "workspace_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_workspace_id() -> str:\n token = BaseHook.get_connection(AirflowConns.TERRAFORM).password\n terraform_api = TerraformApi(token)\n\n # Get organization\n organization = Variable.get(AirflowVars.TERRAFORM_ORGANIZATION)\n\n # Get workspace\n environment = Variable.get(AirflowVars.ENVIRONMENT... | [
"0.72242045",
"0.72234267",
"0.72091603",
"0.71540064",
"0.71540064",
"0.70464975",
"0.6891388",
"0.6891388",
"0.6812387",
"0.66599363",
"0.65873826",
"0.6529958",
"0.6398516",
"0.6271846",
"0.6264693",
"0.6120342",
"0.6120342",
"0.6120342",
"0.6056778",
"0.6056778",
"0.60567... | 0.76052606 | 1 |
Name of the company of the partner | def partner_name(self) -> str:
return pulumi.get(self, "partner_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_name(self):\n if \"companyName\" in self._prop_dict:\n return self._prop_dict[\"companyName\"]\n else:\n return None",
"def _get_name(self):\n partner = self\n name = partner.name or ''\n\n if partner.company_name or partner.parent_id:\n ... | [
"0.76758903",
"0.75698215",
"0.7544758",
"0.7507912",
"0.7061919",
"0.6872663",
"0.6865251",
"0.676369",
"0.6688448",
"0.6614327",
"0.6614327",
"0.6613212",
"0.65558517",
"0.6515439",
"0.64176357",
"0.6416026",
"0.64144844",
"0.6400489",
"0.63944924",
"0.63944405",
"0.6386602... | 0.78047764 | 1 |
Azure resource ID of the policy definition that turns this assessment calculation on | def policy_definition_id(self) -> str:
return pulumi.get(self, "policy_definition_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_id(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"policy_id\")",
"def policy_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"policy_id\")",
"def policyid(self):\n return self._policyid",
"def policy_id(self) -> pulumi.Output[Optional[str]]:\n return... | [
"0.68844306",
"0.687918",
"0.6872656",
"0.6835604",
"0.6645063",
"0.6645063",
"0.66422343",
"0.6623568",
"0.648301",
"0.648301",
"0.648301",
"0.6418869",
"0.6418869",
"0.63896173",
"0.62850535",
"0.62806606",
"0.62457865",
"0.62367773",
"0.62367773",
"0.62367773",
"0.6202891"... | 0.753271 | 0 |
The severity level of the assessment | def severity(self) -> str:
return pulumi.get(self, "severity") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def severity(self):\n return self._severity",
"def severity(self):\n return self._severity",
"def severity(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"severity\")",
"def severity(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"severity\")",
"def s... | [
"0.82292265",
"0.82292265",
"0.8184784",
"0.801551",
"0.7976034",
"0.77871335",
"0.77871335",
"0.77871335",
"0.76659864",
"0.71346414",
"0.7123284",
"0.7088337",
"0.7083264",
"0.6930347",
"0.6812457",
"0.678891",
"0.6676945",
"0.6643234",
"0.6637242",
"0.6548396",
"0.65459704... | 0.8408239 | 1 |
True if this assessment is in preview release status | def preview(self) -> Optional[bool]:
return pulumi.get(self, "preview") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def is_previewable(self, **parameters):\n if not hasattr(self, '_is_previewable'):\n self._is_previewable = True\n return self._is_previewable",
"def is_on(self) -> bool:\n current = self... | [
"0.7212936",
"0.6533736",
"0.6367383",
"0.63376224",
"0.6307647",
"0.6133312",
"0.5996001",
"0.5985087",
"0.59606266",
"0.59270465",
"0.5891324",
"0.58804035",
"0.5822516",
"0.582101",
"0.582101",
"0.58103555",
"0.57750773",
"0.57650584",
"0.5734912",
"0.57282776",
"0.5716517... | 0.71290624 | 1 |
The user impact of the assessment | def user_impact(self) -> Optional[str]:
return pulumi.get(self, "user_impact") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_impact(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"user_impact\")",
"def user_impact(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"user_impact\")",
"def user_impact(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"user_im... | [
"0.7757892",
"0.7385608",
"0.7385608",
"0.705583",
"0.6925266",
"0.64094913",
"0.6353756",
"0.63442504",
"0.623233",
"0.61492014",
"0.6068278",
"0.6068278",
"0.60317314",
"0.6017876",
"0.59702986",
"0.5966446",
"0.5962166",
"0.5954543",
"0.5910639",
"0.59077024",
"0.58973444"... | 0.7439828 | 1 |
Name of the company of the partner | def partner_name(self) -> str:
return pulumi.get(self, "partner_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_name(self):\n if \"companyName\" in self._prop_dict:\n return self._prop_dict[\"companyName\"]\n else:\n return None",
"def _get_name(self):\n partner = self\n name = partner.name or ''\n\n if partner.company_name or partner.parent_id:\n ... | [
"0.76758903",
"0.75698215",
"0.7544758",
"0.7507912",
"0.7061919",
"0.6872663",
"0.6865251",
"0.676369",
"0.6688448",
"0.6614327",
"0.6614327",
"0.6613212",
"0.65558517",
"0.6515439",
"0.64176357",
"0.6416026",
"0.64144844",
"0.6400489",
"0.63944924",
"0.63944405",
"0.6386602... | 0.78047764 | 0 |
transforms a list of points from ego_vehicle/lidar/lidar1/ frame to map frame using tf2 and the current transformation | def transform_lidar_into_map_coords(self, points):
poses = []
for p in points:
pose = PoseStamped()
pose.header.frame_id = "ego_vehicle/lidar/lidar1"
pose.header.stamp = rospy.Time.now()
pose.pose.position.x = p[0]
pose.pose.position.y = p[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_obj_list(object_list,M,M2 = None):\n \n for i, obj in enumerate(object_list):\n points = obj.all\n num_points = len(points)\n \n \n # add third row\n ones = np.ones([num_points,1])\n points3d = np.concatenate((points,ones),1)\n points3d = ... | [
"0.62087893",
"0.5920398",
"0.57568246",
"0.5627396",
"0.5621936",
"0.56183314",
"0.56157327",
"0.55580515",
"0.5551266",
"0.5515611",
"0.5498045",
"0.5467242",
"0.54564303",
"0.5456426",
"0.5451013",
"0.5434744",
"0.54346627",
"0.5427823",
"0.54127014",
"0.5392363",
"0.53859... | 0.64119387 | 0 |
calculates distance of the closest point in points and returns its distance | def calc_dist(self, points):
dist_x = [self._current_pose.position.x - p.pose.position.x for p in points]
dist_y = [self._current_pose.position.y - p.pose.position.y for p in points]
dist = np.hypot(dist_x,dist_y)
if len(dist) > 0:
return min(dist) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(self, point):\n if not isinstance(point, Point):\n point = Point(*point)\n\n distances = [(point.distance_to_point(p), p) for p in self.points]\n sortpoints = sorted(distances, key=lambda x: x[0])\n closest = sortpoints[0][1]\n\n vc = Vector(*closest)\... | [
"0.7559835",
"0.75238806",
"0.7506208",
"0.73734766",
"0.7328789",
"0.73241305",
"0.7315014",
"0.7296735",
"0.7279474",
"0.7258013",
"0.7245505",
"0.722329",
"0.7189812",
"0.7188848",
"0.7178517",
"0.7162702",
"0.71596414",
"0.7153017",
"0.7134312",
"0.71279836",
"0.70956284"... | 0.7669649 | 0 |
Gets right and left Lanelet of current_lanelet | def get_right_and_left_lanelet(self):
if self.scenario is not None:
possible_lanelet_ids = self.scenario.lanelet_network.find_lanelet_by_position([np.array(list(self.current_pos))])[0]
self.current_lanelet = None
self.right_lanelet = None
self.left_lanelet = N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lane(self):\n return self.lane",
"def _get_potential_right_way(self, lanelet):\n if lanelet.adj_right:\n if lanelet.adj_right_same_direction:\n potential_right_way = self.left_ways.get(lanelet.adj_right)\n else:\n potential_right_way = sel... | [
"0.69697505",
"0.6693879",
"0.65481895",
"0.6400882",
"0.6338087",
"0.6309185",
"0.6169792",
"0.61585784",
"0.61184555",
"0.6088736",
"0.60837555",
"0.60834515",
"0.6081923",
"0.60523117",
"0.6044031",
"0.6035172",
"0.60120726",
"0.59962624",
"0.5978671",
"0.59441257",
"0.589... | 0.879685 | 0 |
Check_lanelet_free. The function is registered as a ROSService. The service definition file is located in | def check_lanelet_free(self, req):
lanelet_id = req.lanelet_id
if lanelet_id != 0:
lanelet = self.scenario.lanelet_network.find_lanelet_by_id(lanelet_id)
if self.points is None:
return False
points = list(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lantern_check():\n if not app.config.get(\"ENABLE_LANTERN\", False):\n print \"[{x}] Not checking Lantern jobs - interface disabled\".format(x=dates.now())\n return\n print \"[{x}] Checking Lantern jobs\".format(x=dates.now())\n LanternApi.check_jobs()",
"def XCAFDoc_ShapeTool_IsFree(*... | [
"0.53509796",
"0.49458748",
"0.49050424",
"0.48977044",
"0.48960072",
"0.488118",
"0.48679265",
"0.48391494",
"0.47779852",
"0.47708476",
"0.47547635",
"0.47248513",
"0.47162852",
"0.46940163",
"0.4656274",
"0.4647027",
"0.4643872",
"0.4643811",
"0.4625",
"0.46155718",
"0.460... | 0.67785156 | 0 |
Function to extract rider level temporal patterns | def _extract_temporal_patterns(self):
# extract hour and day of week
self.df_transaction['hour'] = self.df_transaction['trxtime'].apply(lambda x: x.hour)
self.df_transaction['day_of_week'] = self.df_transaction['trxtime'].apply(lambda x: x.dayofweek) # monday=0, sunday=6
# counting dai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __extract_pattern_nodes(graph):\n tp_nodes = graph.subjects(RDF.type, AGORA.TriplePattern)\n for tpn in tp_nodes:\n subject = list(graph.objects(tpn, AGORA.subject)).pop()\n predicate = list(graph.objects(tpn, AGORA.predicate)).pop()\n obj = list(graph.objects(tpn, AGORA.object)).pop... | [
"0.5510267",
"0.52542937",
"0.525195",
"0.5220616",
"0.5148889",
"0.5143544",
"0.5133086",
"0.51217085",
"0.5068871",
"0.5026059",
"0.5012949",
"0.50099546",
"0.49786222",
"0.49588096",
"0.49438012",
"0.49356502",
"0.4911912",
"0.49105886",
"0.49089172",
"0.4899446",
"0.48757... | 0.6346698 | 0 |
Function to extract rider level geographical patterns | def _extract_geographical_patterns(self):
# take onehot encoding of zipcodes
onehot = pd.get_dummies(self.df_transaction['zipcode'], prefix='zipcode')
rider_id = pd.DataFrame(data={'riderID': self.df_transaction['riderID']})
frames = [rider_id, onehot]
df_onehot = pd.concat(frame... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_regions_mask(self, input):",
"def ffgs_regions():\n return [\n ('Hispaniola', 'hispaniola'),\n ('Central America', 'centralamerica')\n ]",
"def get_zone(text_reg):\n posi_zone = []\n gray_zone = []\n for txt in text_reg:\n x1, y1, x2, y2 = txt[0], txt[1], txt[2], txt... | [
"0.5798934",
"0.5676824",
"0.55530095",
"0.5447797",
"0.54079866",
"0.5355692",
"0.53391874",
"0.53265494",
"0.52204746",
"0.520599",
"0.51960975",
"0.51955533",
"0.51670206",
"0.51228994",
"0.51193917",
"0.50905097",
"0.5084017",
"0.5071909",
"0.50690395",
"0.5055916",
"0.50... | 0.67227197 | 0 |
Function to extract one purchasing feature | def _get_one_purchase_feature(self, feature):
# take onehot encoding of the purchasing feature columns
onehot = pd.get_dummies(self.df_transaction[feature], prefix=feature)
rider_id = pd.DataFrame(data={'riderID': self.df_transaction['riderID']})
frames = [rider_id, onehot]
df_on... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purchase(self, item_type):",
"def after_purchase():\n\n return [\"MCAR\", \"MD\", \"NI\", \"MAR\",\"MAR\"]",
"def extract_feature(self, article) :\n pass",
"def productactivate():\n pass",
"def _extract_ticket_purchasing_patterns(self):\n list_df_purchase_count = []\n\n for f... | [
"0.5571388",
"0.54234684",
"0.5408792",
"0.5228844",
"0.517373",
"0.5148059",
"0.51403916",
"0.51266134",
"0.50367516",
"0.5029217",
"0.5013141",
"0.49834538",
"0.49649334",
"0.49609634",
"0.49595377",
"0.4956056",
"0.4929668",
"0.4919164",
"0.49121955",
"0.49118873",
"0.4909... | 0.6703345 | 0 |
Function to label riders by their total number of trips | def _label_rider_by_trip_frequency(self, rider):
if rider['total_num_trips'] <= 5*self.duration:
label = 0
elif rider['total_num_trips'] <= 20*self.duration:
label = 1
elif rider['total_num_trips'] > 20*self.duration:
label = 2
else:
label ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_labels(self) -> int:\n raise NotImplementedError",
"def make_labels(self, ilines):\n\n llist = []\n for lind, lstr in enumerate(ilines):\n # get label and value list\n rv, label, vals = self.get_label_vals(lstr)\n if rv < 1: continue\n\n nvals = len(vals)\n\n ... | [
"0.62115324",
"0.62078524",
"0.6168908",
"0.59179735",
"0.59134716",
"0.5711058",
"0.56915367",
"0.56866425",
"0.56840545",
"0.5661594",
"0.5646231",
"0.5631034",
"0.5630065",
"0.5607377",
"0.5585696",
"0.55522656",
"0.55182344",
"0.55077565",
"0.54725116",
"0.5469419",
"0.54... | 0.7017241 | 0 |
Function to label riders as either commuter rail rider or others | def _label_commuter_rail_rider(self, rider):
if (rider['servicebrand_Commuter Rail'] > 0) and (rider['zonecr_1a'] == 0):
label = 'CR except zone 1A'
else:
label = 'others'
return label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _label_rider_by_trip_frequency(self, rider):\n if rider['total_num_trips'] <= 5*self.duration:\n label = 0\n elif rider['total_num_trips'] <= 20*self.duration:\n label = 1\n elif rider['total_num_trips'] > 20*self.duration:\n label = 2\n else:\n ... | [
"0.61879206",
"0.6081442",
"0.6048964",
"0.59177494",
"0.58201796",
"0.57484347",
"0.5720458",
"0.56168586",
"0.55854166",
"0.5579104",
"0.557112",
"0.55050945",
"0.5465426",
"0.545311",
"0.5416637",
"0.53969747",
"0.53866935",
"0.53793013",
"0.5374424",
"0.53614503",
"0.5354... | 0.7601737 | 0 |
Fit an estimator on the training data and then score it on the testing data | def fit_score(estimator, train_data, test_data):
estimator.fit(*train_data)
return estimator.score(*test_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fit_and_score(estimator, X, modality, y, scorer, train, test, verbose,\n parameters, return_train_score=False,\n return_parameters=False, return_n_test_samples=False,\n return_times=False):\n\n X = X[modality]\n\n # Adjust length of sample weights\n ... | [
"0.76107645",
"0.7543218",
"0.75375515",
"0.7517675",
"0.74909353",
"0.7400457",
"0.7224176",
"0.7108566",
"0.70855176",
"0.70284665",
"0.69677943",
"0.69219077",
"0.6902353",
"0.69022137",
"0.6899991",
"0.68701804",
"0.6868485",
"0.6868485",
"0.68650854",
"0.6844149",
"0.683... | 0.8566178 | 0 |
Index each array in a tuple of arrays. If the arrays tuple contains a ``None``, the entire tuple will be returned as is. | def select(arrays, index):
if arrays is None or any(i is None for i in arrays):
return arrays
return tuple(i.ravel()[index] for i in arrays) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aind(x):\n\treturn tuple(x.T)",
"def index(self, arr, idx, temp = True, name = None):\n \n temp = temp or name is not None\n \n arr_t = arr.type\n\n if isinstance(arr_t, ScalarT):\n # even though it's not correct externally, it's\n # often more convenient to treat indexing\n # i... | [
"0.5842294",
"0.55760646",
"0.55092984",
"0.5497843",
"0.54363334",
"0.52967614",
"0.5283771",
"0.5263889",
"0.5225666",
"0.5220214",
"0.5194468",
"0.51706874",
"0.51583457",
"0.5133251",
"0.51113605",
"0.5105309",
"0.5093947",
"0.50427014",
"0.50376666",
"0.5035451",
"0.4927... | 0.7136496 | 0 |
This fuction opens bot_admin file Then returns 1 if id is in the file (is admin) Returns 0 otherwise | def is_admin(id):
with open('bot_admin', 'r') as myfile:
if id in myfile.read():
return 1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin():\n commands = os.listdir(adminDir)\n if len(commands) > 0:\n return True\n else:\n return False",
"def check_if_admin(bot, update, *args, **kwargs):\n user_id = update._effective_user\n # print(\"cerco user con id \" + str(user_id) + \", nel database\")\n ... | [
"0.5988642",
"0.5855251",
"0.58323574",
"0.573519",
"0.57336074",
"0.563821",
"0.552184",
"0.5445745",
"0.54403436",
"0.5414914",
"0.5295082",
"0.51754415",
"0.5171889",
"0.5087034",
"0.50759846",
"0.5023059",
"0.50092083",
"0.49878058",
"0.4981291",
"0.49573648",
"0.49339414... | 0.8447236 | 0 |
This function Opens the Tracked users file And checks if the given user is in the file returns 1 on success returns 0 if user not found | def check_user_del(user):
with open('tracked_users', 'r') as myfile:
userfile = myfile.read()
if user.lower() in userfile.lower():
return 1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_find(file):\n username1 = input(\"Enter your username: \")\n username = username1.lower()\n for row in file:\n if row[0] == username:\n print(\"\\n username found \" + username +\"\\n\")\n user_found = [row[0],row[1]]\n pass_check(user_found)\n g... | [
"0.72001135",
"0.6392704",
"0.6380288",
"0.60906875",
"0.59361774",
"0.58851326",
"0.5845398",
"0.58390796",
"0.5828219",
"0.5755387",
"0.5733727",
"0.5731585",
"0.5705902",
"0.56972355",
"0.5690812",
"0.5672853",
"0.56608915",
"0.5633513",
"0.56234914",
"0.5618595",
"0.56107... | 0.7034657 | 1 |
This function opens Tracked users file to delete a given user And deletes the data of the given user returns 1 on success return 1 and prints content of the file on fail for recovery purpose | def del_user(user):
try:
myfile = open('tracked_users', 'r')
lines = myfile.readlines()
myfile.close()
myfile = open('tracked_users', 'w')
for line in lines:
if line.lower() != user.lower()+'\n':
myfile.write(line.lower())
myfile.close()
os.remove('data/'+user.lower())
return 1
except Exception... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_users(self, filename):\n f_id = self.face.FACES.files.find_one({ \"filename\" : filename }, { \"_id\" : 1 })\n self.face_fs.delete(f_id['_id'])",
"def check_user_del(user):\n\twith open('tracked_users', 'r') as myfile:\n\t\tuserfile = myfile.read()\n\t\tif user.lower() in userfile.lower(... | [
"0.72505856",
"0.6862722",
"0.6805278",
"0.6782408",
"0.6610334",
"0.6485585",
"0.6411243",
"0.63377917",
"0.6297156",
"0.6207489",
"0.6204286",
"0.61876947",
"0.6148491",
"0.61326313",
"0.6066154",
"0.6051134",
"0.60115385",
"0.5980973",
"0.59755516",
"0.59708357",
"0.596860... | 0.8196673 | 0 |
This function process an image and returns the most present pixel in it as an hex int if fail, it returs default color | def av_color(file):
try:
image = Image.open(file)
w, h = image.size
pixels = image.getcolors(w * h)
most_frequent_pixel = pixels[0]
for count, colour in pixels:
if count > most_frequent_pixel[0]:
most_frequent_pixel = (count, colour)
dbg = int('0x%02x%02x%02x' % most_frequent_pixel[1], 16)
print(d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_reddest_pixel(img):\n # HINTS/ADVICE-------------\n # Use a nested for loop here.\n #\n # BE CAREFUL DOING ARITHMETIC WITH UNSIGNED INTEGERS: \n # >>> a = np.array([2], dtype='uint8')\n # >>> b = np.array([3], dtype='uint8')\n # >>> a - b\n # array([255], dtype=uint8)\n #\n ... | [
"0.67914766",
"0.6712479",
"0.6589963",
"0.6425963",
"0.6399882",
"0.63659",
"0.6218228",
"0.6203629",
"0.6185864",
"0.6180609",
"0.617545",
"0.61731213",
"0.60577923",
"0.6015999",
"0.5913961",
"0.5890827",
"0.5828751",
"0.58275735",
"0.5809326",
"0.57891506",
"0.57731843",
... | 0.71025014 | 0 |
Used to download a picture Returns 1 on succes Ro 1 on fail | async def dl_image(url, filename):
try:
with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
test = await resp.read()
with open('data/tmp/'+filename.lower(), "wb") as f:
f.write(test)
return 0
except Exception as e:
print('[!ERROR!] in Get image')
print(e)
return -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_picture(inPath):\n success = False\n consoleFeedback = exec_console_command(constants.copyFileToStatic.format(inPath))\n print(consoleFeedback)\n\n if \"SUCCESS\" in consoleFeedback:\n success = True\n else:\n raise IOError(constants.pictureNotFound)\n\n return success"... | [
"0.67260003",
"0.67189807",
"0.6644087",
"0.6582544",
"0.65628064",
"0.65265995",
"0.6522943",
"0.64578414",
"0.6457213",
"0.6372547",
"0.6365554",
"0.62701195",
"0.62566346",
"0.62408376",
"0.6234943",
"0.6145252",
"0.61320657",
"0.6111227",
"0.6094474",
"0.6086137",
"0.6084... | 0.6896206 | 0 |
Returns the Unicode flag symbol For a given ISO 31661 alpha2 Coutry code | def flag(code):
OFFSET = ord('🇦') - ord('A')
if not code:
return u''
points = list(map(lambda x: ord(x) + OFFSET, code.upper()))
try:
return chr(points[0]) + chr(points[1])
except ValueError:
return ('\\U%08x\\U%08x' % tuple(points)).decode('unicode-escape') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flag(countrycode: str) -> str:\r\n\r\n code = [c for c in countrycode.lower() if c in ASCII_LOWER]\r\n if len(code) == 2:\r\n # Regional indicator symbols\r\n return flag_regional_indicator(code)\r\n if len(code) > 2 and len(code) < 7:\r\n # Tag sequence\r\n return flag_tag... | [
"0.64730406",
"0.64475",
"0.63321203",
"0.62854385",
"0.6161302",
"0.60630107",
"0.6045155",
"0.6037729",
"0.60337454",
"0.59990394",
"0.5994314",
"0.5979302",
"0.592053",
"0.5904522",
"0.5877021",
"0.58428967",
"0.58397055",
"0.5797212",
"0.5775551",
"0.5729321",
"0.57204676... | 0.74334806 | 0 |
Load Speech Enhancement STFT UNET masking deep learning model. | def deep_masking(model: str = 'resnet-unet', quantized: bool = False, **kwargs):
model = model.lower()
if model not in _masking_availability:
raise ValueError(
'model not supported, please check supported models from `malaya_speech.speech_enhancement.available_deep_masking()`.'
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonlearning():\n\taT.featureAndTrain(['../../AudioData/chunked_data_sorted/pos', '../../AudioData/chunked_data_sorted/neg'], \n\t\t\t\t\t\t1.0, 1.0, aT.shortTermWindow, aT.shortTermStep, \n \"svm\", \"emotion_classifier\", True)",
"def load_model(self):\n self.pred_net.load((self.save_p... | [
"0.59340066",
"0.5911736",
"0.5900582",
"0.57844377",
"0.5723234",
"0.56802684",
"0.5617355",
"0.55857116",
"0.55831295",
"0.5580721",
"0.55755264",
"0.5573632",
"0.5558571",
"0.5548964",
"0.5547449",
"0.55412763",
"0.54874104",
"0.548048",
"0.54715073",
"0.5469528",
"0.54626... | 0.62793493 | 0 |
Adds a period to a line that is missing a period | def fix_missing_period(line):
if "@highlight" in line: return line
if line=="": return line
if line[-1] in END_TOKENS: return line
# print line[-1]
return line + " ." | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_missing_period(line):\n if \"@highlight\" in line:\n return line\n if line == \"\":\n return line\n if line[-1] in END_TOKENS:\n return line\n return line + \" .\"",
"def test_trailing_period(self):\r\n self.assertEqual(4.0, calc.evaluator({}, {}, '4.'))",
"def p... | [
"0.6506273",
"0.58323836",
"0.57100993",
"0.54586047",
"0.5438765",
"0.5400417",
"0.52904093",
"0.518897",
"0.5163461",
"0.51524025",
"0.50683826",
"0.49437892",
"0.4940815",
"0.49108043",
"0.49103516",
"0.48758814",
"0.48758078",
"0.48758078",
"0.4828564",
"0.48167768",
"0.4... | 0.63101846 | 1 |
Reads the tokenized .story files corresponding to the urls listed in the url_file and writes them to a out_file. | def write_to_bin(url_file, out_file_article, out_file_abstract, cnn_tokenized_stories_dir, dm_tokenized_stories_dir):
print("Making bin file for URLs listed in %s..." % url_file)
url_list = read_text_file(url_file)
url_hashes = get_url_hashes(url_list)
story_fnames = [s+".story" for s in url_hashes]
num_stori... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_urls_to_file(urls, file_name):\n with open(file_name, 'w') as file_handler:\n for url in urls:\n content = read_url(url)\n pretty_content = pretty_print_content(content)\n file_handler.write(pretty_content)",
"def write_url(url_list):\r\n with open(\"URLS.t... | [
"0.62645054",
"0.58563197",
"0.5821562",
"0.57902795",
"0.57028097",
"0.56542486",
"0.56383413",
"0.56162834",
"0.55391157",
"0.55385387",
"0.54912",
"0.5453684",
"0.54283243",
"0.53994155",
"0.5358935",
"0.53502476",
"0.53414875",
"0.5339555",
"0.5327423",
"0.5316142",
"0.53... | 0.65715915 | 0 |
The main program takes in two arguments input_file_path(a txt file) and output_file_path(a kml file) and converts the txt file to kml file | def main():
input_file_path = sys.argv[1]
output_file_path = sys.argv[2]
gps_df = create_df(input_file_path) # creates a data frame
gps_df = clean_data(gps_df) # cleans the data
print('Cleaning done')
write_to_kml(gps_df, output_file_path) # writes to kml file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(input_filepath, output_model_filepath):\n logger = logging.getLogger(__name__)\n logger.info('training hotel cluster embeddings models')\n\n input_file = os.path.join(input_filepath, 'sentences.pkl')\n output_model_file = os.path.join(output_model_filepath, 'hotelcluster2vec.bin')\n\n train... | [
"0.6632069",
"0.6444081",
"0.6348496",
"0.6317812",
"0.6302665",
"0.6273071",
"0.6177123",
"0.6177123",
"0.61510634",
"0.6150506",
"0.6132754",
"0.6043515",
"0.58791876",
"0.5868927",
"0.58523566",
"0.5841822",
"0.5827696",
"0.5798412",
"0.57972443",
"0.5789804",
"0.5754245",... | 0.6799259 | 0 |
Reads in a txt file and creates a pandas data frame with columns representing Latitude and its direction, Longitude and its direction, quality and dilution. | def create_df(file_path):
columns = ['Lat', 'Lat_dir', 'Long', 'Long_dir', 'Quality', 'Dilution']
speeds = []
validity = []
rows = []
with open(file_path, encoding='utf-8', errors='ignore') as f:
for line in f.readlines()[5:]:
words = line.strip().split(",")
if len(wo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def txt_to_dataframe(folder,name_parcellation):\n column_weight = ['patients','degree', 'density', 'global_efficiency', 'transitivity', 'assortavity', 'clustering_coef',\n 'fiedler_value', 'small_worldness','Null']\n\n file_name=folder+name_parcellation+'.txt'\n data=pd.read_csv(file_n... | [
"0.6931486",
"0.6567923",
"0.60308295",
"0.60107195",
"0.58846587",
"0.58273214",
"0.5817731",
"0.5799361",
"0.57866096",
"0.5752707",
"0.57501096",
"0.56600416",
"0.5650866",
"0.56462586",
"0.5641389",
"0.5616411",
"0.5613479",
"0.5582875",
"0.5572268",
"0.5540163",
"0.55275... | 0.6993391 | 0 |
Find the stack frame of the caller so that we can note the source file name, line number and function name. | def findCaller(cls):
f = currentframe()
# On some versions of IronPython, currentframe() returns None if
# IronPython isn't run with -X:Frames.
if f is not None:
f = f.f_back
rv = "(unknown file)", 0, "(unknown function)"
while hasattr(f, "f_code"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _findCaller(stack_info=False):\n f = logging.currentframe()\n #On some versions of IronPython, currentframe() returns None if\n #IronPython isn't run with -X:Frames.\n if f is not None:\n f = f.f_back\n rv = \"(unknown file)\", 0, \"(unknown function)\", None\n while hasattr(f, \"f_cod... | [
"0.7930418",
"0.7792423",
"0.7783527",
"0.7717714",
"0.76556414",
"0.7586453",
"0.75716466",
"0.74985564",
"0.74963945",
"0.7413992",
"0.73594606",
"0.73560166",
"0.72826964",
"0.7263826",
"0.7234214",
"0.71918005",
"0.71639085",
"0.71572584",
"0.71543473",
"0.7149359",
"0.71... | 0.7862673 | 1 |
Returns the likelihood for data xs, assumed to be multivariate Gaussian with the given means and covariance. | def correlated_gaussian_loglikelihood(xs, means, cov):
lu,piv=sl.lu_factor(cov)
lambdas=np.diag(lu)
ndim=xs.shape[0]
ds=(xs-means)*sl.lu_solve((lu,piv), xs-means)/2.0
return -np.log(2.0*np.pi)*(ndim/2.0)-0.5*np.sum(np.log(lambdas))-np.sum(ds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def likelihood_bivariate_normal(X, mu, cov):\n \n dist = multivariate_normal(mu, cov)\n P = dist.pdf(X)\n return P",
"def multivariate_gaussian(pos, mu, Sigma):\r\n\r\n n = mu.shape[0]\r\n Sigma_det = np.linalg.det(Sigma)\r\n Sigma_inv = np.linalg.inv(Sigma)\r\n N = np.sqrt((2*np.pi)**n *... | [
"0.7061533",
"0.69797194",
"0.69187695",
"0.6848097",
"0.6845057",
"0.67813957",
"0.6697071",
"0.6683684",
"0.667868",
"0.6657556",
"0.6601283",
"0.6573809",
"0.65730196",
"0.656916",
"0.6557741",
"0.6553713",
"0.6550848",
"0.6544307",
"0.6529757",
"0.65168965",
"0.6497047",
... | 0.7507182 | 0 |
Returns an array of quantiles for each of the xs in the correlated Gaussian distribution with the given mean and covariance. | def correlated_gaussian_quantiles(xs, means, cov):
L = sl.cholesky(cov, lower=True)
ys = sl.solve(L, xs-means)
return ss.norm.cdf(ys) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_multi_gaussian(X):\n m, n = X.shape\n mu = mean(X, axis=0)\n sigma = cov_matrix(X, mu)\n\n return mu, sigma",
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n ... | [
"0.62254775",
"0.6103563",
"0.6049607",
"0.598576",
"0.59617925",
"0.59495264",
"0.5938824",
"0.5892896",
"0.5885811",
"0.5877937",
"0.5797762",
"0.57833624",
"0.57510304",
"0.5727639",
"0.5709559",
"0.5681378",
"0.566666",
"0.5659615",
"0.5648411",
"0.5610717",
"0.55851966",... | 0.79821897 | 0 |
Return the residuals for the rv model with parameters ``p`` and the observations of radial velocitys ``rv`` at times ``t`` | def residuals(self, ts, rvs, p):
if p.npl == 0:
return rvs
else:
rvmodel = np.sum(rv.rv_model(ts,p), axis=0)
return rvs - rvmodel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def residuals_linear(params, t, data):\n \n #Get an ordered dictionary of parameter values\n v = params.valuesdict()\n \n #Cubic model\n model = v['a']*t**3 + v['b']*t**2 + v['c']*t + v['d']\n\n return model - data #Return residuals",
"def residual(t, x, xdot, result):\n result[0] = x... | [
"0.6360294",
"0.62171745",
"0.6073643",
"0.600488",
"0.595743",
"0.58258915",
"0.5814308",
"0.5789692",
"0.5789692",
"0.5789692",
"0.5775249",
"0.57112926",
"0.5624764",
"0.55967015",
"0.55801696",
"0.55782723",
"0.5524036",
"0.5520603",
"0.55015445",
"0.5492828",
"0.5464734"... | 0.77084005 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.