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 |
|---|---|---|---|---|---|---|
Get an element from a queue. Test that it is 1. | def test_get_element(self):
data = (1, 2, 3, 4)
queue = Queue_(data)
self.assertEqual(queue.get(), data[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n\t\ttry:\n\t\t\tself.logger.debug('Im trying to get item from queue')\n\t\t\titem = self.queue.get()\n\t\t\tself.logger.debug('Recevie item from queue %s'%(item))\n\t\t\treturn True, item\n\t\texcept Exception, e:\n\t\t\tself.logger.error('Error method get, error: %s'%(e),exc_info=True)\n\t\t\tretu... | [
"0.7556628",
"0.74670905",
"0.7456273",
"0.7270813",
"0.71341264",
"0.71085036",
"0.7094008",
"0.7046715",
"0.7011527",
"0.6876995",
"0.6863746",
"0.68071526",
"0.68071526",
"0.67984605",
"0.6744334",
"0.67340684",
"0.6734029",
"0.6704264",
"0.668802",
"0.66751915",
"0.667026... | 0.80578023 | 0 |
Create a Queue from an iterable object. Check that the size of queue_ equals to the size of the given tuple. | def test_new_queue_from_tuple(self):
data = (1, 2, 3, 4)
queue = Queue_(data)
self.assertFalse(queue.empty())
self.assertEqual(queue.size(), len(data))
for value in data:
test_value = queue.get()
self.assertEqual(test_value, value)
self.assertTrue(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_queue_from_list(self):\n data = [1, 3, 5, 7, 2, 4]\n queue = Queue_(data)\n self.assertFalse(queue.empty())\n self.assertEqual(queue.size(), len(data))\n self.assertEqual(queue.top(), data[0])",
"def test_new_queue_from_generator(self):\n queue = Queue_(rang... | [
"0.62171847",
"0.58740187",
"0.5855165",
"0.5600438",
"0.5446116",
"0.54402775",
"0.543408",
"0.5431774",
"0.54129475",
"0.54115546",
"0.5404512",
"0.5395198",
"0.53889567",
"0.5335712",
"0.5332964",
"0.53098434",
"0.5306954",
"0.52912533",
"0.5286187",
"0.5239695",
"0.522459... | 0.75716573 | 0 |
Create a Queue from a list. Check that the size of queue equals to the size of the queue. Check that the top element of queue equals to the latest element of the list. | def test_new_queue_from_list(self):
data = [1, 3, 5, 7, 2, 4]
queue = Queue_(data)
self.assertFalse(queue.empty())
self.assertEqual(queue.size(), len(data))
self.assertEqual(queue.top(), data[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialization_with_empty_list_last_node_check():\n queue = Queue([])\n assert queue._queue.last_node is None",
"def queue_to_stack(queue):\n stack = Stack()\n check_list = []\n\n while len(queue) != 0:\n check_list.append(queue.dequeue())\n\n check_list.reverse()\n\n while c... | [
"0.656142",
"0.6330778",
"0.6320571",
"0.6206751",
"0.61039263",
"0.60570526",
"0.604458",
"0.59754544",
"0.5956983",
"0.59466815",
"0.59238017",
"0.58860093",
"0.58682257",
"0.5859621",
"0.5830505",
"0.57924914",
"0.57899845",
"0.5778571",
"0.5774191",
"0.5771166",
"0.576109... | 0.83507144 | 0 |
Create a Queue_ from a generator. Test that its size equals to the number provided in the generator. | def test_new_queue_from_generator(self):
queue = Queue_(range(10))
self.assertFalse(queue.empty())
self.assertEqual(queue.size(), 10)
self.assertEqual(queue.top(), 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def large_queue():\n que = Queue()\n for num in range(1, 11):\n que.enqueue(num)\n return que",
"def build_generator(self, i):\n if self.rng.random() < self.freeze_probability:\n return SequenceIterator(self.rng.choice(SIZES[:SIZES.index(self.max_size)]))\n else:\n ... | [
"0.6048734",
"0.60149246",
"0.5839498",
"0.5820395",
"0.57929295",
"0.57875896",
"0.5727647",
"0.57267374",
"0.57099265",
"0.5691689",
"0.5681378",
"0.5661334",
"0.5646394",
"0.5631191",
"0.561792",
"0.5603292",
"0.55817884",
"0.5534262",
"0.55297804",
"0.5498225",
"0.5494258... | 0.80516404 | 0 |
Put an element in queue. Test that its size is 1. | def test_put_element(self):
queue = Queue_()
queue.put(1)
self.assertFalse(queue.empty())
self.assertEqual(queue.size(), 1)
self.assertEqual(queue.top(), 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insertion_of_value_increases_length(empty_queue):\n assert len(empty_queue) == 0\n empty_queue.enqueue(100)\n assert len(empty_queue) == 1",
"def push(self, element):\n if not self.full():\n heapq.heappush(self.queue, element)\n self.size += 1\n return Tr... | [
"0.77519256",
"0.7739508",
"0.7582388",
"0.7481959",
"0.7472519",
"0.74159044",
"0.7394143",
"0.7335067",
"0.73285407",
"0.7098055",
"0.70681745",
"0.70555544",
"0.7049531",
"0.70145833",
"0.6986029",
"0.6973277",
"0.6941566",
"0.6898279",
"0.689296",
"0.6888862",
"0.6868528"... | 0.8269443 | 0 |
Create an empty Queue. Test that call of get function raises Assertion error | def test_call_get_of_empty_queue_raised_error(self):
queue = Queue_()
self.assertRaises(IndexError, queue.get) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_queue_is_empty(self):\n queue = Queue_()\n self.assertTrue(queue.empty())\n self.assertEqual(queue.size(), 0)",
"def test_is_empty(self):\n queue = Queue()\n self.assertEqual(queue.is_empty(), True)\n queue.enqueue(1)\n self.assertEqual(queue.is_empty(), False)",
"... | [
"0.8160254",
"0.8153244",
"0.8052863",
"0.7911015",
"0.7905001",
"0.7894963",
"0.76920027",
"0.7689933",
"0.7631737",
"0.7544532",
"0.75173104",
"0.75173104",
"0.7458197",
"0.74333274",
"0.7330861",
"0.73305017",
"0.729531",
"0.72764575",
"0.7261248",
"0.7248773",
"0.72299206... | 0.8159753 | 1 |
Override the save method to save the first and last name to the user field. | def save(self):
# First save the parent form and get the user.
new_user = super(SignupFormExtra, self).save()
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
new_user.save()
# Userena expects to get the new user ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, commit=True):\n\n email_local_part = self.cleaned_data['email'].split('@')[0]\n username_start = email_local_part[:5] if len(email_local_part) >= 5 else email_local_part\n self.instance.username = username_start + ''.join(\n [choice(ascii_letters) for _ in range(30 - ... | [
"0.72708315",
"0.7223799",
"0.71601826",
"0.6896324",
"0.683202",
"0.6698966",
"0.66724044",
"0.6666655",
"0.6666425",
"0.66263896",
"0.66218114",
"0.6618675",
"0.65702695",
"0.6526201",
"0.65225655",
"0.64917177",
"0.6483562",
"0.64494735",
"0.6422482",
"0.64115214",
"0.6404... | 0.73729247 | 0 |
Populate the `hateword` table in MongoDB with data from CSV file. | def populate_hateword_data():
with open("./data/hate-speech-lexicons/refined_ngram_dict.csv") as f:
lst = [row.split(',', 1)[0] for row in f]
lst = lst[1:]
lst = [{
'word': word,
'category': [],
'similar_to': []
} for word in lst]
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_records():\n\n with open('seed_data/records.csv', 'rb') as csvfile:\n data = csv.reader(csvfile)\n for row in data:\n record_id, user_id, common_name, date_time, latitude, longitude, notes, seen, num_birds = row\n\n record = Record(record_id=record_id, user_id=user_i... | [
"0.62989795",
"0.61529267",
"0.60396224",
"0.5890785",
"0.58553517",
"0.58194333",
"0.58194286",
"0.5814144",
"0.5806153",
"0.57831645",
"0.5744489",
"0.5741411",
"0.57202476",
"0.569331",
"0.5675714",
"0.56400776",
"0.56394845",
"0.5633955",
"0.5550253",
"0.5521801",
"0.5515... | 0.7946996 | 0 |
Prepopulate user data for the app, including an admin account | def populate_user_data():
try:
db = mongo_client.MongoClient(config.MONGO_URI).twitter
db.user.insert_one(
{
'username': 'admin',
'password': 'admin',
}
)
print("Created an admin account")
except Exception as e:
prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n create_user(app)\n get_all_user()",
"def prefill(self, user):\n print('prefilling')\n self.username.data = user.username\n self.full_name.data = user.full_name\n self.email.data = user.email",
"def init_data_for_admin(db_data):\n administrators = db_data.get('... | [
"0.6845231",
"0.6764182",
"0.6723294",
"0.6634625",
"0.66286814",
"0.66168195",
"0.65961397",
"0.6412519",
"0.6382036",
"0.6321992",
"0.63086635",
"0.6226326",
"0.6178413",
"0.61414754",
"0.6119165",
"0.6108649",
"0.6106677",
"0.60994",
"0.60962856",
"0.6091124",
"0.60897976"... | 0.7075983 | 0 |
add a new vertex object to the graph with the given key and return the vertex | def add_vertex(self, key):
#increments the number of vertices
#creates a new vertex
#adds the new vertex to the vertex list
#returns the new vertex
if key != None:
self.num_vertices += 1
new_vertex = Vertex(key)
self.vert_list[key] = new_vertex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, key):\n vertex = Vertex(key)\n self.vertices += 1\n self.graph[key] = vertex\n\n return vertex",
"def add_vertex(self, key):\n self.vertCount += 1\n addedVertex = vertex.Vertex(key)\n self.vertList[key] = addedVertex\n return addedVerte... | [
"0.8762225",
"0.87257594",
"0.87200457",
"0.84958625",
"0.84928226",
"0.84297377",
"0.8041286",
"0.7621432",
"0.7442868",
"0.7416063",
"0.7397369",
"0.73909426",
"0.73780626",
"0.7367396",
"0.73670876",
"0.73386776",
"0.7307447",
"0.7295609",
"0.7295609",
"0.72255313",
"0.716... | 0.87494206 | 1 |
return the vertex if it exists | def get_vertex(self, n):
#returns the vertex if it is in the graph
if self.vert_list[n] != None:
return self.vert_list[n]
else:
raise KeyError("It would appear the vertex you are searching for does not exist") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vertex(self, key):\n if key in self.vertList:\n return self.vertList[key]\n else:\n return None",
"def get_vertex(self, key):\n\n vertex = None\n try: \n vertex = self.graph[key]\n except KeyError:\n raise ValueError(\"Vertex w... | [
"0.7513024",
"0.72817385",
"0.72061867",
"0.7141165",
"0.7068804",
"0.6988597",
"0.69729173",
"0.69611084",
"0.6960711",
"0.6946605",
"0.68712467",
"0.68712467",
"0.68499994",
"0.6722803",
"0.6685908",
"0.6663623",
"0.6652164",
"0.66403013",
"0.659667",
"0.65694433",
"0.65370... | 0.758258 | 0 |
add an edge from vertex f to vertex t with a cost | def add_edge(self, f, t, cost=0):
#if either vertex is not in the graph, returns an error
#if both vertices in the graph, adds the
# edge by making t a neighbor of f
#using the addNeighbor method of the Vertex class.
if (get_vertex(f) != None) and (get_vertex(t) != None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, f, t, cost=1):\n if f not in self.vertList:\n self.add_vertex(f)\n if t not in self.vertList:\n self.add_vertex(t)\n self.vertList[f].add_neighbor(self.vertList[t], cost)",
"def add_edge(self, from_vert, to_vert, cost=0):\n # if either vertex i... | [
"0.8412572",
"0.72365963",
"0.7025727",
"0.678826",
"0.66294044",
"0.6265532",
"0.6264762",
"0.6260604",
"0.623027",
"0.621927",
"0.61729574",
"0.6169615",
"0.6169615",
"0.61498934",
"0.6149495",
"0.611712",
"0.6066989",
"0.6052448",
"0.60479313",
"0.60100734",
"0.59923965",
... | 0.80194545 | 1 |
The object pk value as a string. | def object_pk(self):
if self._wrapped not in (None, empty):
return str(self._wrapped.pk)
if '_object_pk' in self.__dict__:
return self.__dict__['_object_pk']
identifier = self._get_identifier()
if identifier:
# noinspection PyBroadException
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_key(self) -> str:\n return self._values.get('object_key')",
"def _get_obj_pk(self, obj):\n if self.use_natural_keys and hasattr(obj, 'natural_key'):\n raw_nat_key = obj.natural_key()\n obj_pk = smart_text(NATURAL_KEY_JOINER.join(raw_nat_key))\n keytype = ... | [
"0.73430043",
"0.7338839",
"0.73322386",
"0.72485405",
"0.71463984",
"0.70808476",
"0.70808476",
"0.7046806",
"0.7027561",
"0.701783",
"0.70041835",
"0.70041835",
"0.69952285",
"0.6962158",
"0.6962158",
"0.6951326",
"0.6927094",
"0.69219065",
"0.68189216",
"0.6818153",
"0.680... | 0.75594234 | 0 |
Get or add a LazyModelObject instance to this dictionary. Accepts the same arguments as the LazyModelObject class. Returns a LazyModelObject instance. | def get_or_add(self, *args, **kwargs):
key = LazyModelObject.get_identifier(*args, **kwargs)
try:
return self[key]
except KeyError:
item = LazyModelObject(*args, **kwargs)
if not item:
item = None
self[key] = item
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cached_instance(self):\n\n try:\n identifier = self._get_identifier()\n except (ValueError, ObjectDoesNotExist) as error:\n if self._fail_silently:\n return None\n raise LazyModelObjectError(exc=error) from error\n\n # Get the cache key,... | [
"0.6156461",
"0.59348273",
"0.58452696",
"0.5716304",
"0.57067645",
"0.56040096",
"0.5588421",
"0.554282",
"0.5540866",
"0.54643005",
"0.5458968",
"0.54366755",
"0.5380811",
"0.5373615",
"0.5371358",
"0.5371091",
"0.5365681",
"0.5358472",
"0.5342425",
"0.5339498",
"0.53308314... | 0.795623 | 0 |
Remove any matches (and it's entries from {matches}, {read_count} and {phreds}) that have 1 or more positions with a superPhred score < {min_phred_score} Returns count total number of reads removed count_unique total number of unique reads removed | def remove_low_quality_for_matched(matches, read_count, phreds, min_phred_score, ditched_f=None):
count = count_unique = 0
kk = matches.keys()
for k in kk:
m = matches[k]
if any( x < min_phred_score for x in phreds[m.read.tostring()] ):
count += read_count[m.read.tostring()]
count_unique += 1
if ditched... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_hits(reads):\n new_reads = defaultdict(realign)\n for r in reads:\n world = {}\n sc = 0\n for p in reads[r].precursors:\n world[p] = reads[r].precursors[p].get_score(len(reads[r].sequence))\n if sc < world[p]:\n sc = world[p]\n new_r... | [
"0.65910244",
"0.5650101",
"0.5642639",
"0.5534765",
"0.5399435",
"0.5347214",
"0.53100437",
"0.5299977",
"0.5246292",
"0.52276933",
"0.51281446",
"0.51219064",
"0.5101029",
"0.5089264",
"0.50758624",
"0.5075226",
"0.50660384",
"0.50597763",
"0.50569576",
"0.49090847",
"0.490... | 0.7690688 | 0 |
Counts the total number of reads in M | def count(self):
return sum(read.copy for read in self.__iter__()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_count_reads_in_region_total(self):\n self.c.skipZeros = False\n self.c.stepSize = 200\n self.c.binLength = 200\n resp, _ = self.c.count_reads_in_region(self.chrom, 0, 200)\n nt.assert_equal(resp, np.array([[2, 4.]]))",
"def count_single_mirbase_reads(bam, counts_file):... | [
"0.662604",
"0.66033",
"0.64993536",
"0.64116496",
"0.63783777",
"0.6340389",
"0.6309031",
"0.6276263",
"0.6247988",
"0.61803967",
"0.6126196",
"0.61252856",
"0.6114868",
"0.6101939",
"0.6043354",
"0.601563",
"0.60091496",
"0.5887007",
"0.5887007",
"0.5887007",
"0.5887007",
... | 0.6607064 | 1 |
Format warnings for printing. Returns a list of warning strings with indentation. | def toStringList( self, indent='', dIndent=' ' ):
s = ['%s%s' % (indent, self.message)]
for warning in self.warningList:
s += warning.toStringList(indent + dIndent)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_print(self, warnings=False):\n msg = []\n if (warnings) and (len(self.warnings) > 0):\n msg.append(u\"Warnings:\")\n for warning in self.warnings:\n msg.append(u\" %s\" % warning)\n if len(self.errors) > 0:\n msg.append(u\"Errors:\")\... | [
"0.722904",
"0.64456606",
"0.64456606",
"0.6390865",
"0.6286236",
"0.62299055",
"0.6129529",
"0.6120169",
"0.6116671",
"0.6057338",
"0.60385865",
"0.5984471",
"0.5891208",
"0.58653736",
"0.58580256",
"0.58468646",
"0.58211756",
"0.57925606",
"0.5790896",
"0.575746",
"0.572305... | 0.6823347 | 1 |
Sets the plot title when the button is clicked with the value present in the title input box | def setPlotTitle(self):
plot_title = self.input_plot_title.text()
if plot_title:
self.plot_title = self.input_plot_title.text()
# Redraw the plot with given title
if not self.plot_inverted:
self.drawPlot(self.data_x_axis, self.data_y_axis, self.label_x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_plot_title(self):\n plot_title = self.input_plot_title.text()\n if plot_title:\n self.plot_title = self.input_plot_title.text()\n # Redraw the plot with given title\n if not self.plot_inverted:\n self.draw_plot(self.data_x_axis, self.data_y_axis... | [
"0.7686431",
"0.7370893",
"0.7333007",
"0.72645044",
"0.7250716",
"0.71819836",
"0.71057916",
"0.7100658",
"0.7095059",
"0.7093847",
"0.7082512",
"0.7081393",
"0.7071999",
"0.6987861",
"0.69744796",
"0.6965746",
"0.6932339",
"0.68831265",
"0.6823803",
"0.67966646",
"0.6791194... | 0.755215 | 1 |
Return the title of a widget | def get_widget_title(widget):
if widget['title'] != '':
return widget['title']
else:
return widget['metadata']['panels'][0]['items'][0]['jaql']['title'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(self) -> str:\n return self.tk_ref.title()",
"def title(self):\n return self.run_command('title')[0]",
"def title(self):\n return self.container['title']",
"def get_title():",
"def get_window_title(self): # real signature unknown; restored from __doc__\n return \"\"",
"d... | [
"0.7554609",
"0.7312672",
"0.7257128",
"0.7138261",
"0.7099524",
"0.7089029",
"0.7006153",
"0.6958793",
"0.6958793",
"0.69035614",
"0.68345183",
"0.6812255",
"0.6812255",
"0.6812255",
"0.6798095",
"0.67852056",
"0.6750128",
"0.67444265",
"0.6724642",
"0.6695906",
"0.6695906",... | 0.83423537 | 0 |
Return the item on which the widget must be sorted, if any | def get_widget_sorted_item(widget):
for panel in widget['metadata']['panels']:
for item in panel['items']:
if 'sort' in item['jaql']:
return item['jaql']['title']
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_comparer(self):\n return self.item_comparer_value",
"def OnCompareItems(self, item1, item2):\r\n\r\n return cmp(self.GetItemText(item1), self.GetItemText(item2))",
"def GetFirstVisibleItem(self):\r\n\r\n return self.GetNextVisible(self.GetRootItem())",
"def __getitem__(self,item... | [
"0.62678564",
"0.6071453",
"0.5718568",
"0.56606954",
"0.55855614",
"0.5572795",
"0.553234",
"0.5485188",
"0.5474386",
"0.54547495",
"0.54483056",
"0.5421757",
"0.54117554",
"0.54097724",
"0.53953743",
"0.538942",
"0.5367559",
"0.5348384",
"0.53402",
"0.53376174",
"0.53265804... | 0.73745424 | 0 |
Return the list of widget IDs in the order of appearance from the layout object | def get_dashboard_ordered_widget_ids(dashfile_data):
ordered_widget_ids = []
for column in dashfile_data['layout']['columns']:
for cell in column['cells']:
for subcell in cell['subcells']:
for element in subcell['elements']:
ordered_widget_ids.append(eleme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_list(self):\n return list(self.widget_dict.values())",
"def gui_layout_view(self) -> List[List[sg.Element]]:\n return []",
"def gui_layout_edit(self) -> List[List[sg.Element]]:\n\n return []",
"def widget_map(self):\n return self._widget_map",
"def getAllWidgets(self):\... | [
"0.6166304",
"0.61398214",
"0.61017835",
"0.60591733",
"0.5988189",
"0.581369",
"0.57681173",
"0.56985873",
"0.5695312",
"0.5651034",
"0.5631582",
"0.5631433",
"0.5525349",
"0.55079883",
"0.5484116",
"0.5450929",
"0.54188025",
"0.54106236",
"0.5409411",
"0.5408571",
"0.540493... | 0.728899 | 0 |
Return the list of widget titles present on the given dashboard, following the order defined in the dashboard layout | def get_ordered_titles(dashfile_data):
ordered_widget_ids = get_dashboard_ordered_widget_ids(dashfile_data)
kpis_id_title_mapping = {}
charts_id_title_mapping = {}
tables_id_title_mapping = {}
kpi_titles = []
chart_titles = []
table_titles = []
# Create a local mapping between the widg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dashboard_ordered_widget_ids(dashfile_data):\n ordered_widget_ids = []\n for column in dashfile_data['layout']['columns']:\n for cell in column['cells']:\n for subcell in cell['subcells']:\n for element in subcell['elements']:\n ordered_widget_ids.a... | [
"0.6569436",
"0.6078979",
"0.6001605",
"0.59308547",
"0.5854095",
"0.580947",
"0.57694864",
"0.5699261",
"0.56739503",
"0.55418026",
"0.5426727",
"0.54243344",
"0.5404837",
"0.5404529",
"0.53320867",
"0.5310989",
"0.5274873",
"0.51577336",
"0.51369613",
"0.51191705",
"0.51112... | 0.6873038 | 0 |
Update the dashboard kpi mappings file Add a dict object which key is the dashboard name and values are the dashboard's KPI titles This mapping is used by diff_kpis to name the kpis that are compared | def update_mappings(dashboard_data, mappings_file):
logging.info('update_mappings')
with open(mappings_file, 'r') as f:
try:
data = json.load(f)
except ValueError:
data = {}
if dashboard_data.slug not in data:
data[dashboard_data.slug] = {}
table_data = [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_database_map(self, path):\n if path:\n filename = path + '/APD_MAP.txt'\n else:\n filename = 'APD_MAP.txt'\n filepointer = open(filename, 'w')\n for invariom, molecule in self.map.items():\n filepointer.write(invariom + ':' + molecule + '\\n'... | [
"0.53087455",
"0.5226565",
"0.521083",
"0.5169348",
"0.5110115",
"0.51062304",
"0.50751776",
"0.5055464",
"0.48677987",
"0.4862654",
"0.48615238",
"0.48604602",
"0.48286825",
"0.47872168",
"0.4719879",
"0.47133425",
"0.47133425",
"0.4647157",
"0.46456125",
"0.46437544",
"0.46... | 0.66152465 | 0 |
Adds an import and export function to a class under the name export_data and import_data. This is currently unused and maybe should be removed. The original intention was to be able to add methods to allow json compatible output dictionaries to external functions. | def add_base_class(
existing_object: Any,
import_method: Callable[[Any], Any],
export_method: Callable[[Any], Any],
):
existing_object.export_data = types.MethodType(export_method, existing_object)
existing_object.import_data = types.MethodType(import_method, existing_object) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_(self, exported, update=False):\n for path in exported:\n kv = exported[path]\n fn = self.update if update else self.write\n fn(path, **kv)",
"def exports():",
"def export(self, class_name, method_name, export_data=False,\n export_dir='.', export... | [
"0.5648476",
"0.5640173",
"0.5598629",
"0.55643046",
"0.5322802",
"0.53223747",
"0.52671325",
"0.52416205",
"0.5182817",
"0.5167931",
"0.513596",
"0.5119927",
"0.5087243",
"0.5070539",
"0.50628704",
"0.5059321",
"0.5019335",
"0.5014842",
"0.5010461",
"0.5010175",
"0.49909532"... | 0.6563669 | 0 |
A property for the location of any parameter files that can be used to build the skeleton of the bill of materials. Returns list A list of locations of the .json that make up the paramaters to be assembled into the skeleton. Raises ConfigurationNotFullyPopulated If the property is called but the configuration has not b... | def parameters(cls) -> list:
if cls._parameters is None:
msg = (
"location of any files which contain json parameters "
"to be assembled required as a list of strings"
)
run_log.error(msg)
raise ConfigurationNotFullyPopulated(msg)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parts(cls) -> list:\n if cls._parts is None:\n msg = (\n \"location of any files which contain json parts\"\n \" to be assembled required as a list of strings\"\n )\n run_log.error(msg)\n raise ConfigurationNotFullyPopulated(msg)\... | [
"0.67385864",
"0.55904484",
"0.55675447",
"0.5486506",
"0.5365225",
"0.53188455",
"0.52505314",
"0.5213413",
"0.5184519",
"0.5162303",
"0.51546144",
"0.5019257",
"0.5015219",
"0.5014257",
"0.50114226",
"0.4997435",
"0.4982885",
"0.49784917",
"0.49784917",
"0.49784917",
"0.495... | 0.73307854 | 0 |
A property for the locations of the .json that will be loaded into the transaltor. Returns list Location of translation file. Raises ConfigurationNotFullyPopulated If the property is called but the configuration has not been populated and has the property is None. | def translations(cls) -> list:
if cls._translations is None:
msg = (
"translation location not defined, the file location"
"required as a list of strings"
)
run_log.error(msg)
raise ConfigurationNotFullyPopulated(msg)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations(self):\n return self.data.get(\"locations\", [])",
"def parts(cls) -> list:\n if cls._parts is None:\n msg = (\n \"location of any files which contain json parts\"\n \" to be assembled required as a list of strings\"\n )\n ... | [
"0.6489377",
"0.6273797",
"0.61873615",
"0.61667126",
"0.607361",
"0.5990457",
"0.5929629",
"0.58884853",
"0.58612424",
"0.58612424",
"0.58612424",
"0.58612424",
"0.58612424",
"0.58612424",
"0.58612424",
"0.57474357",
"0.57359576",
"0.57176447",
"0.57171977",
"0.5691996",
"0.... | 0.6935578 | 0 |
The parts section of the configuration are used by the parsers to contain information about parts to be parsed to form the skeleton (dictionary form) of a Bill of Materials. Returns list The object assigned to parts. Raises ConfigurationNotFullyPopulated If the property is called but the configuration has not been popu... | def parts(cls) -> list:
if cls._parts is None:
msg = (
"location of any files which contain json parts"
" to be assembled required as a list of strings"
)
run_log.error(msg)
raise ConfigurationNotFullyPopulated(msg)
return c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config(self):\n package = self.package\n if not hasattr(self, '_partconfig'):\n self._partconfig = {}\n\n if package not in self._partconfig:\n self._partconfig[package] = Parts(package, *self.parts)\n return self._partconfig[package]",
"def get_parts(self):\... | [
"0.67192507",
"0.5725723",
"0.56452507",
"0.542747",
"0.526864",
"0.52415466",
"0.52362096",
"0.5136002",
"0.50883913",
"0.5082257",
"0.5070895",
"0.504625",
"0.5042836",
"0.50137293",
"0.4963221",
"0.49042815",
"0.49025095",
"0.48889834",
"0.48752812",
"0.48612127",
"0.48544... | 0.7192802 | 0 |
The working directory for the Configuration. Returns str Path to working directory. | def working_dir(cls) -> str:
return cls._working_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def working_directory(self):\n return self._working_directory",
"def working_dir(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"working_dir\")",
"def get_working_dir(self):\r\n return self.process.get_working_dir()",
"def workDir(self):\n self.debug.printHeader(... | [
"0.8272883",
"0.80822647",
"0.80707604",
"0.7958291",
"0.7886885",
"0.7864339",
"0.786264",
"0.78127676",
"0.7802864",
"0.77705896",
"0.77094704",
"0.7702679",
"0.7647526",
"0.75679433",
"0.75248295",
"0.74807364",
"0.7449656",
"0.74102527",
"0.739319",
"0.7369031",
"0.735653... | 0.84283805 | 0 |
The default parameter type that will be assigned to all components and assemblies attribute params. Returns str String path to the param type. | def default_param_type(cls) -> str:
return cls._default_param_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_parameters(self, default_type):\n return self._default_parameters.get(default_type, {})",
"def get_param(params, key, defaults_type):\n if key in params:\n return params[key]\n else:\n if defaults_type == 'interpolation_slicing':\n return compas_slicer.parame... | [
"0.66451085",
"0.6565646",
"0.64847505",
"0.64698064",
"0.6365341",
"0.6052358",
"0.59003174",
"0.58954114",
"0.58831567",
"0.58472455",
"0.575767",
"0.5744395",
"0.5729673",
"0.56840295",
"0.5677127",
"0.5653063",
"0.5642644",
"0.5619081",
"0.56077486",
"0.56068385",
"0.5574... | 0.8177016 | 0 |
Sets the temporary directory and also changes the log handler to write in this directory. | def temp_dir(cls, value: Union[str, Path]):
start_message = (
f"Configuration Details\n\n{pprint.pformat(cls.to_dict(), indent=4)}"
)
cls._temp_dir = value
change_handler(f"{value}/run.log")
run_log.info(start_message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setTmpDir(self):\n\t\tif os.name != 'nt':\n\t\t\t# On unix use /tmp by default\n\t\t\tself.tmpDir = os.environ.get(\"TMPDIR\", \"/tmp\")\n\t\t\tself.tmpDir = os.environ.get(\"TMP\", self.tmpDir)\n\t\telse:\n\t\t\t# On Windows use the current directory\n\t\t\tself.tmpDir = os.environ.get(\"TMPDIR\", \"\")\n\t\t... | [
"0.7089073",
"0.69517523",
"0.68200475",
"0.6736389",
"0.66263765",
"0.65425605",
"0.6539801",
"0.6539801",
"0.6538104",
"0.643624",
"0.6405769",
"0.64057046",
"0.64057046",
"0.6402267",
"0.63498914",
"0.63418335",
"0.63274956",
"0.628209",
"0.6277255",
"0.62277234",
"0.61690... | 0.6963477 | 1 |
The plot directory for outputs. Returns str Path to the plot directory. | def plot_dir(cls) -> Union[str, Path]:
if cls._plot_dir is None:
msg = "plot_dir not supplied, defaulting to working_dir"
run_log.warning(msg)
return cls.working_dir
else:
return cls._plot_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_path(self):\r\n return '%s/%s' % (os.path.abspath(os.path.dirname(__file__) + 'outputs'),\r\n self.identifier)",
"def output_dir(self):\n return os.path.join(self._sandbox, 'output' + os.path.sep)",
"def create_plots() -> str:\r\n return _find_or_create_dir(... | [
"0.7019947",
"0.68157727",
"0.6806294",
"0.6789725",
"0.6714439",
"0.6688091",
"0.66791457",
"0.66611266",
"0.66524935",
"0.6600386",
"0.65862453",
"0.6566615",
"0.65542203",
"0.65312684",
"0.6526321",
"0.6523932",
"0.64745474",
"0.64738804",
"0.6455824",
"0.64281875",
"0.642... | 0.8171626 | 0 |
defines the config file. The config can be loaded from a supplied dictioanry or from a path. The intention in using a classmethod is that the config can be imported at any stage in a process after initialisation without reloading. | def define_config(
cls, config_dict: dict = {}, config_path: Optional[Union[str, Path]] = None
):
config = {}
if config_path is not None:
with open(Path(config_path), "r") as f:
config = json.load(f)
UpdateDict(config, config_dict)
cls.update_confi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, config_file_name=\"config.json\"):\n self.config_file_name = config_file_name\n self._config = self._open_config_file()",
"def __init__(self, path_to_config_file):\n self.file_path = path_to_config_file",
"def __init__(self, config_file='/etc/sfa/ldap_config.py'):\n\n ... | [
"0.75234306",
"0.7439641",
"0.7432341",
"0.7370511",
"0.7290338",
"0.7287195",
"0.72335243",
"0.71800995",
"0.7165214",
"0.71425086",
"0.69821703",
"0.69821703",
"0.69770926",
"0.6962824",
"0.69518054",
"0.6917742",
"0.6908645",
"0.68950397",
"0.68228227",
"0.68127984",
"0.68... | 0.7500606 | 1 |
Updates the config from given key word arguments. As Config utilises classmethods an classmethod is required to update it. | def update_config(cls, **kwargs):
for key, val in kwargs.items():
setattr(cls, key, val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_args(self, args):\n for cfg in args:\n keys, v = cfg.split(\"=\", maxsplit=1)\n keylist = keys.split(\".\")\n dic = self\n # print(keylist)\n if len(keylist) == 1:\n assert keylist[0] in dir(dic), \"Unknown config key: {}\".for... | [
"0.770021",
"0.7601066",
"0.6671581",
"0.6545972",
"0.65303266",
"0.6520369",
"0.6518705",
"0.6492443",
"0.6485912",
"0.6472447",
"0.64480734",
"0.63874626",
"0.63595873",
"0.6353414",
"0.63087",
"0.62969655",
"0.6281655",
"0.6270197",
"0.6191441",
"0.6169528",
"0.6153322",
... | 0.7695604 | 1 |
Converts the configuration into a dictionary format. A check is used so that properties, instances and variables within the BaseCLass are not output. Returns dict A dictionary containing all the variables specific to the class. | def to_dict(cls) -> dict:
variables = dict()
for key, val in vars(cls).items():
check = [
isinstance(val, property),
isinstance(val, classmethod),
key in vars(BaseClass).keys(),
key == "_login_details",
]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self) -> Dict[str, Any]:\n return {\n 'num_classes': self.num_classes,\n 'name': self.name,\n 'dtype': self.dtype,\n 'sparse_y_true': self.sparse_y_true,\n 'sparse_y_pred': self.sparse_y_pred,\n 'axis': self.axis,\n }",
"def as_dict(self) -> dict:\n ... | [
"0.68040526",
"0.63548714",
"0.63082737",
"0.62583035",
"0.6253618",
"0.62368757",
"0.62050885",
"0.6196911",
"0.6142708",
"0.6142708",
"0.6119696",
"0.6111287",
"0.6092527",
"0.6048673",
"0.60294574",
"0.60033596",
"0.6000471",
"0.59962076",
"0.5983463",
"0.5973468",
"0.5967... | 0.71711314 | 0 |
Inputs login details. This method stores login details if they are required. | def input_login_details(cls, domain: str = ""):
cls._login_details["username"] = str(input("username: "))
cls._login_details["password"] = str(getpass())
cls._login_details["domain"] = domain | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fake_login(self):\n self.username = self.console.input('Please type your username here:')\n self.password = self.console.input('Please type your password here:')",
"def login(self):\n\n self.__login_if_required()",
"def login():",
"def login():",
"def login(self):\n self.ope... | [
"0.7298498",
"0.7107218",
"0.69868815",
"0.69868815",
"0.6956484",
"0.6897951",
"0.6897406",
"0.6877067",
"0.68717444",
"0.6866643",
"0.6825106",
"0.6739646",
"0.67386276",
"0.67325664",
"0.6723227",
"0.66795963",
"0.6673001",
"0.66649806",
"0.6650597",
"0.6638834",
"0.662473... | 0.76552 | 0 |
Runs the login details update if any of the values are None. Returns dict The populated login details. | def login_details(cls) -> dict:
if None in list(cls._login_details.values()):
cls.input_login_details()
return cls._login_details | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_login_details(cls, domain: str = \"\"):\n cls._login_details[\"username\"] = str(input(\"username: \"))\n cls._login_details[\"password\"] = str(getpass())\n cls._login_details[\"domain\"] = domain",
"def update_user_login_data():\n if not 'user' in session:\n raise Inval... | [
"0.62196344",
"0.5900246",
"0.58829457",
"0.5867684",
"0.58169377",
"0.56897306",
"0.56831723",
"0.5669447",
"0.56359315",
"0.5604115",
"0.55840516",
"0.5552345",
"0.55519444",
"0.55302685",
"0.55302685",
"0.55230725",
"0.5508681",
"0.5496048",
"0.5488227",
"0.547313",
"0.545... | 0.71085674 | 0 |
The variables in the data. Returns np.ndarray An array of the dataframe index, if exist. | def vars(self) -> np.ndarray:
if isinstance(self.data, pd.DataFrame) is False:
return np.array([])
else:
return np.array(self.data.index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables(self):\n return self.dataset.data_vars",
"def get_variables(self) -> np.array:\n pass",
"def index(self, variables):\n return [self._variables.index(v) for v in variables]",
"def variables(self):\n return np.array(list(self._match_result_dict.keys()))",
"def get_da... | [
"0.664484",
"0.6407513",
"0.62923473",
"0.6233907",
"0.61113024",
"0.6098684",
"0.6098561",
"0.60291743",
"0.6015471",
"0.5951717",
"0.5893516",
"0.58810705",
"0.5769446",
"0.5763522",
"0.57079065",
"0.56854033",
"0.5684478",
"0.5661651",
"0.56546617",
"0.56515044",
"0.562981... | 0.7774008 | 0 |
The column count in the wrapped dataframe. Returns int Interger if a dataframe exists. Note As the DataFrame is checked and mypy finds it to return Any, the output of the shape is also found to return any. | def col_count(self):
if isinstance(self.data, pd.DataFrame) is False:
return None
else:
return self.data.shape[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columnCount(self, index=QtCore.QModelIndex()):\n # speed comparison:\n # In [23]: %timeit len(df.columns)\n # 10000000 loops, best of 3: 108 ns per loop\n\n # In [24]: %timeit df.shape[1]\n # 1000000 loops, best of 3: 440 ns per loop\n return len(self._dataFrame.column... | [
"0.7479284",
"0.7457271",
"0.74545646",
"0.7218371",
"0.72052294",
"0.7198004",
"0.7125306",
"0.71171653",
"0.71032107",
"0.70787036",
"0.7048535",
"0.70310104",
"0.69621015",
"0.6886637",
"0.68838155",
"0.68789786",
"0.68624115",
"0.68600327",
"0.6812109",
"0.6770684",
"0.67... | 0.8040465 | 0 |
Compiles all dataframes for a given storage_str into a mutable top level dataframe. | def compile_all_df(self, assembly: Any, child_str: str):
self.compiled = child_str
storages = np.array(
[
output[child_str]
for key, output in assembly.lookup(child_str).items()
if output[child_str] is not None
and key != assemb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataframe(self):\n logging.info('*** Creating the dataframes from the source files ' )\n \n for k in self.datasets_keys:\n #for k in ['igra2' , 'ncar']:\n \n logging.info('*** Creating the dataframe for the dataset: %s ' , k ) ... | [
"0.57476497",
"0.5689572",
"0.5556659",
"0.55454594",
"0.5482013",
"0.5480292",
"0.5476088",
"0.5457783",
"0.54277915",
"0.5402681",
"0.53266585",
"0.52771425",
"0.5270305",
"0.52694404",
"0.52569366",
"0.5238869",
"0.5226146",
"0.52153397",
"0.5192845",
"0.5190287",
"0.51789... | 0.6514609 | 0 |
Import a function given the string formatted as `module_name.function_name` (eg `django.utils.text.capfirst`) | def import_function(s):
a = s.split('.')
j = lambda x: '.'.join(x)
return getattr(import_module(j(a[:-1])), a[-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_function(name: str):\n module_name, function_name = name.rsplit(\".\", 1)\n module = importlib.import_module(module_name)\n return getattr(module, function_name)",
"def import_function(\n name: Optional[str]\n) -> Optional[Callable]:\n\n if name is None:\n return None\n\n ... | [
"0.7775118",
"0.71505874",
"0.6975363",
"0.6941111",
"0.6877164",
"0.6877164",
"0.6877164",
"0.6561287",
"0.6522173",
"0.6454434",
"0.6385483",
"0.6366869",
"0.636331",
"0.6330619",
"0.6164649",
"0.60861504",
"0.6066642",
"0.6003852",
"0.5984985",
"0.59510297",
"0.59288377",
... | 0.78207976 | 0 |
Sort the list of graph nodes according to their Degree. | def sorted_nodes_list(self):
full_sorted_node_list = map(lambda k: k[0], sorted(self.graph.degree(),
key=lambda k: k[1], reverse=True))
return full_sorted_node_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_nodes(center_node, nodes):\n def cmp(n1, n2):\n angle1 = (math.degrees(center_node.angle_to(n1)) + 360.) % 360\n angle2 = (math.degrees(center_node.angle_to(n2)) + 360.) % 360\n\n if angle1 < angle2:\n return -1\n elif angle1 == angle2:\n return 0\n ... | [
"0.69372827",
"0.690695",
"0.66759104",
"0.6506415",
"0.6314595",
"0.62190104",
"0.6212803",
"0.6203003",
"0.6167888",
"0.6120634",
"0.61173314",
"0.6100976",
"0.6086741",
"0.6075209",
"0.6054904",
"0.6052559",
"0.59813607",
"0.5955287",
"0.5944533",
"0.5939927",
"0.59241736"... | 0.7583487 | 0 |
Utility function that reads test_case info from json file. | def __read_test_case(test_case):
# type: (str) -> Optional[dict]
with open('data/calculator.json') as json_file:
data = json.load(json_file)
return data[test_case] if data[test_case] else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_file_contents():\n\n file_name = 'test_fooof_all'\n loaded_data = load_json(file_name, TEST_DATA_PATH)\n\n # Check settings\n for setting in OBJ_DESC['settings']:\n assert setting in loaded_data.keys()\n\n # Check results\n for result in OBJ_DESC['results']:\n assert r... | [
"0.6807032",
"0.6623511",
"0.6512052",
"0.64928055",
"0.6431132",
"0.642324",
"0.63693535",
"0.63231933",
"0.6318227",
"0.6315409",
"0.63148236",
"0.6303362",
"0.62995434",
"0.62879974",
"0.6273989",
"0.6255432",
"0.62515926",
"0.62435913",
"0.61618984",
"0.6160712",
"0.61592... | 0.77058786 | 0 |
Print DMA test result and append it to results list. | def _process_dma_result(compute_node, testfunc,
result, results_list, node):
if result:
logger.info(
'Test case for {0} with DMA PASSED on {1}.'.format(
node, testfunc))
else:
logger.error(
'Test case for {0} with DMA FAILED ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_result_of_dma(compute_ids, results):\n compute_node_names = ['Node-{}'.format(i) for i in range(\n len((compute_ids)))]\n all_computes_in_line = ''\n for compute in compute_node_names:\n all_computes_in_line += '| ' + compute + (' ' * (7 - len(compute)))\n line_of_nodes = '| Te... | [
"0.73346746",
"0.6699405",
"0.66695684",
"0.6512745",
"0.6477566",
"0.64454085",
"0.6340183",
"0.63031113",
"0.623756",
"0.6223393",
"0.6161598",
"0.6154046",
"0.6126515",
"0.60709935",
"0.6060305",
"0.60369337",
"0.6033305",
"0.60281086",
"0.593483",
"0.58824515",
"0.5849258... | 0.725888 | 1 |
Print results of DMA. | def _print_result_of_dma(compute_ids, results):
compute_node_names = ['Node-{}'.format(i) for i in range(
len((compute_ids)))]
all_computes_in_line = ''
for compute in compute_node_names:
all_computes_in_line += '| ' + compute + (' ' * (7 - len(compute)))
line_of_nodes = '| Test ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_results(self):\n pass",
"def print_results(self, data: SimData) -> None:\n pass",
"def print_out():\n pass",
"def _process_dma_result(compute_node, testfunc,\n result, results_list, node):\n if result:\n logger.info(\n 'Test ca... | [
"0.6548923",
"0.62272567",
"0.61158216",
"0.60032797",
"0.5872914",
"0.5870539",
"0.5866138",
"0.5863228",
"0.5836675",
"0.58352697",
"0.5804191",
"0.5803823",
"0.57618093",
"0.57494736",
"0.57438606",
"0.57366985",
"0.57135874",
"0.5665557",
"0.5658675",
"0.5656593",
"0.5644... | 0.7032239 | 0 |
Check DMA of each compute node. | def dma_main(bt_logger, conf, computes):
global logger
logger = bt_logger
compute_ids = []
agent_results = []
for compute_node in computes:
node_id = compute_node.get_id()
compute_ids.append(node_id)
agent_server_running = conf.is_dma_server_running(compute_node)
ag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_dma_result(compute_node, testfunc,\n result, results_list, node):\n if result:\n logger.info(\n 'Test case for {0} with DMA PASSED on {1}.'.format(\n node, testfunc))\n else:\n logger.error(\n 'Test case for {0} wit... | [
"0.6117969",
"0.5841875",
"0.53511333",
"0.5347084",
"0.53312343",
"0.52384406",
"0.5163226",
"0.50747496",
"0.5028944",
"0.5019661",
"0.49944606",
"0.49061847",
"0.48506638",
"0.4796332",
"0.4776862",
"0.47689015",
"0.4761088",
"0.47491127",
"0.47488803",
"0.47486717",
"0.47... | 0.6362029 | 0 |
return for the current row of the books dataFrame the rate of the first review | def return_first_review_overall(x, review_books_df):
asin = x.name
return review_books_df.query('asin == @asin').sort_values(by=['unixReviewTime']).iloc[0].overall | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rating(self):\n average = self.review.all().aggregate(Avg('rating'))['rating__avg']\n if not average:\n return 0\n return average",
"def get_current_rate(self):\n pass",
"def get_rating(self):\n self.total = sum(int(review['stars']) for review in self.reviews.v... | [
"0.6295078",
"0.617707",
"0.6110781",
"0.59789956",
"0.58231413",
"0.58185756",
"0.57670903",
"0.5752119",
"0.56879455",
"0.5686966",
"0.56659776",
"0.5629178",
"0.56277907",
"0.5627686",
"0.56208754",
"0.5620721",
"0.56025547",
"0.5594329",
"0.5588395",
"0.5568699",
"0.55582... | 0.6859296 | 0 |
return for the current row of the matching dataFrame a list of dictionary containing n first rating attributed to each book | def find_n_reviews(x, n, review_books_df):
asin_1 = x['asin_1']
asin_2 = x['asin_2']
overall_reviews_1 = review_books_df.query('asin == @asin_1').sort_values(
'unixReviewTime').iloc[0:(n+1)].overall.tolist()
overall_reviews_2 = review_books_df.query('asin == @asin_2').sort_values(
'unixReviewTi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ratings(book_list, user, rating):\n num = len(book_list)\n records = {'user_id': [user] * num,\n 'rating': [rating] * num,\n 'item_id': book_list,\n }\n return gl.SFrame(records)",
"def get_reviews(df, col, stars):\n log.info('Number of reviews to extrac... | [
"0.6305965",
"0.6175478",
"0.5826944",
"0.5774517",
"0.5687366",
"0.5541024",
"0.54844004",
"0.54758245",
"0.5422476",
"0.537953",
"0.533375",
"0.53205276",
"0.5310303",
"0.52701557",
"0.52414566",
"0.52219236",
"0.5207681",
"0.5187615",
"0.5184505",
"0.51826364",
"0.5180113"... | 0.63651955 | 0 |
return for the current row of the matching dataFrame a list of dictionary containing the mean of all the review from the nth | def mean_more_n_reviews(x, n, review_books_df):
asin_1 = x['asin_1']
asin_2 = x['asin_2']
dic_1 = {}
dic_2 = {}
if (len(review_books_df.query('asin == @asin_1')) > n and len(review_books_df.query('asin == @asin_2')) > 20):
overall_reviews_1 = review_books_df.query('asin == @asin_1'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mean_of_all_genres(df, merged):\n all_genres = get_all_genres_from_df(df)\n mean_genres = {}\n for genres in all_genres:\n mean_genres[genres] = df['rating'][df[genres] == 1].mean()\n\n\n change_nan(mean_genres) # change Nan value\n\n\n for genres in all_genres:\n merged.loc[me... | [
"0.6661418",
"0.6526508",
"0.63646364",
"0.6344809",
"0.62887746",
"0.62240213",
"0.6211887",
"0.620929",
"0.61768067",
"0.6172782",
"0.60722435",
"0.58878464",
"0.58816546",
"0.58502626",
"0.58459353",
"0.57977176",
"0.57909554",
"0.5758562",
"0.57548964",
"0.5753598",
"0.57... | 0.6990966 | 0 |
return the letter H or L from a rating value in this particular case return H when val is in between 4 and 5 and L otherwise | def return_category_from_value_HL(val):
val = int(val.values[0])
if val >= 4:
return 'H'
else:
return 'L' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_category_from_value_HML(val):\n val = int(val.values[0])\n if val == 5:\n return 'H'\n elif val == 4:\n return 'M'\n else:\n return 'L'",
"def get_rating(mpg):\n if mpg < 14:\n return 1\n elif mpg < 15:\n return 2\n elif mpg < 17:\n return... | [
"0.640147",
"0.5997784",
"0.5991234",
"0.59513927",
"0.58464277",
"0.57512605",
"0.57475764",
"0.56715345",
"0.5653036",
"0.56257325",
"0.5574845",
"0.55649275",
"0.5541545",
"0.55374426",
"0.55374426",
"0.5517098",
"0.5503665",
"0.5493932",
"0.5469637",
"0.53682107",
"0.5358... | 0.67449373 | 0 |
return a list of dictionarries containing the mean and the interval of confidence at 95% of each column of the specified df except asin col | def compute_stats_on_reviews_df(df):
stats = []
for col in df.columns:
if col != 'asin':
mean = np.mean(df[col])
if np.std(df[col]) != 0:
b = st.t.interval(0.95, len(df[col])-1, loc=mean, scale=st.sem(df[col]))
else:
b = (np.nan, np.nan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_confidence_intervals(df, column, ci_level=0.99):\n\n # group all the data at each date\n d = {}\n for name, group in df.groupby(['date']):\n d[name] = group\n\n # for each timepoint, calculate the CI\n for df in d.values():\n df['ci'] = calculate_ci(df[column], ci_level=ci_leve... | [
"0.59657013",
"0.59257346",
"0.57639277",
"0.57639277",
"0.57465905",
"0.5622841",
"0.5620874",
"0.55415976",
"0.55392057",
"0.5523666",
"0.5477661",
"0.54676455",
"0.5441022",
"0.5425129",
"0.5410097",
"0.5393089",
"0.5381105",
"0.5324274",
"0.5313938",
"0.5302308",
"0.52950... | 0.6726282 | 0 |
return the error value from an interval (value needed for errorplot) | def error_from_interval(interval):
return (interval[1] - interval[0]) / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(Y, X):\n return (Y - X) ** 2",
"def ultrasonic_sensor_error(raw_sensor_value):\n\treturn raw_sensor_value * 1.1",
"def _df_err(self):\n return self.n - self.k - 1",
"def yerr(self, i):\n return self.errors[1][i]",
"def linpol_error(self):\n return self._linpol_error",
"d... | [
"0.62011176",
"0.6166605",
"0.61010337",
"0.60961163",
"0.6058812",
"0.6053413",
"0.60513455",
"0.6042944",
"0.60402334",
"0.6030181",
"0.60052824",
"0.5983752",
"0.5945941",
"0.59452814",
"0.5932404",
"0.584184",
"0.58264226",
"0.5817471",
"0.58165526",
"0.57957214",
"0.5735... | 0.8264894 | 0 |
plot the errorplot with each longterm ratings mean. | def plot_lastreviews_means_and_errors(H_in_HL_mean, H_in_HL_error, L_in_HL_mean, L_in_HL_error,
H_in_HH_mean, H_in_HH_error, H_in_HM_mean, H_in_HM_error,
M_in_HM_mean, M_in_HM_error):
# plot the result in a nice plot
plt.figure(figsize=(1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_errors(self):\n\n plt.title(\"Prediction Error\")\n plt.plot(self.errors)\n plt.ylabel(\"MSE (Mean Squared Error)\")\n plt.xlabel(\"Iteration\")\n plt.show()",
"def plot_lastreviews_means_and_errors_scaled(H_in_HH_mean, H_in_HH_error, M_in_MM_mean, M_in_MM_error, L_in_... | [
"0.7123026",
"0.6633457",
"0.65329194",
"0.6492488",
"0.64087635",
"0.6374497",
"0.63542676",
"0.62802917",
"0.61992013",
"0.6183493",
"0.613223",
"0.6128087",
"0.61226404",
"0.6120966",
"0.6115421",
"0.6091699",
"0.608599",
"0.6078244",
"0.6043395",
"0.60348445",
"0.603081",... | 0.72428143 | 0 |
Function to authenticate the Spotify API with client credentials flow manager. | def authenticate_spotify_api(SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET):
auth_manager = SpotifyClientCredentials(client_id = SPOTIPY_CLIENT_ID,
client_secret=SPOTIPY_CLIENT_SECRET)
return spotipy.Spotify(auth_manager=auth_manager) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate(redirect_uri, client_cred_manager, username, scope,client_id,client_secret):\r\n\r\n sp = spotipy.Spotify(client_credentials_manager = client_cred_manager)\r\n token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)\r\n if token:\r\n sp = spotipy... | [
"0.74530387",
"0.6852122",
"0.6674616",
"0.66679966",
"0.66116095",
"0.65835315",
"0.644641",
"0.64427465",
"0.61845005",
"0.61197406",
"0.60306585",
"0.6000339",
"0.593765",
"0.593331",
"0.58841735",
"0.58841735",
"0.58746624",
"0.5839965",
"0.581103",
"0.5800786",
"0.578993... | 0.77174217 | 0 |
Function to initialize the lyrics_extractor class and to authenticate the google custom search engine. | def authenticate_extract_lyrics(GCS_API_KEY, GCS_ENGINE_ID):
# Initialize lyrics_extractor class
return SongLyrics(GCS_API_KEY, GCS_ENGINE_ID) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name='google'):\n self.engine_info = filter(lambda x: 'NAME' in x.keys() and x['NAME'] is name, SMARTSEARCH_AVAILABLE_ENGINES)[0]\n self.connection = build('customsearch', 'v1', developerKey=self.engine_info['GOOGLE_SITE_SEARCH_API_KEY'])",
"def __init__(self):\n # keys an... | [
"0.6703985",
"0.62430346",
"0.60308164",
"0.6027884",
"0.5980706",
"0.59597474",
"0.59042263",
"0.5898735",
"0.5815421",
"0.5810548",
"0.58052367",
"0.57967937",
"0.5794903",
"0.5770148",
"0.5767109",
"0.5728078",
"0.5684845",
"0.5671809",
"0.5668664",
"0.56507987",
"0.564171... | 0.7254119 | 0 |
Function to get the album image urls from tracks with the Spotify API, given a list of track id's. | def get_img_urls(track_ids, sp):
# Get a list with track information using a list of track id's
tracks = sp.tracks(track_ids)
# Initialize list to append image urls to
img_urls = []
for i in range(len(tracks['tracks'])):
images = tracks['tracks'][i]['album']['images']
seq = [x['height... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tracks_from_albums(sp, album_uri_list):\n\n track_list = [[\"track_name\", \"track_uri\", \"track_release_date\"]]\n\n print(\"Log: Pulling data from Spotify. This can take a while...\")\n\n for album_uri in album_uri_list:\n album_tracks = sp.album_tracks(album_uri, limit=50, offset=0)[\"i... | [
"0.69385874",
"0.68852514",
"0.6544861",
"0.64002246",
"0.63731915",
"0.6324169",
"0.63051",
"0.6283222",
"0.61360055",
"0.6056502",
"0.6027224",
"0.59959334",
"0.5973237",
"0.59613895",
"0.5957166",
"0.5903311",
"0.5832611",
"0.58309025",
"0.58115005",
"0.5808388",
"0.580614... | 0.8094781 | 0 |
Function to make a radar chart of the audio features of a song. | def radar_chart(song, dataset):
# Reset the index of the song dataframe
song = song.reset_index(drop = True)
# Normalize the audio features of the song using the audio features of the database.
song['tempo_norm'] = (song['tempo'] - dataset['tempo'].min())/(dataset['tempo'].max()- dataset['tempo'].min())... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def radar_map(song_id):\n c = [\"acousticness\", \"danceability\", \"energy\", \"valence\"] # Columns to Show\n N = len(c)\n values=df[df[\"track_id\"] == song_id].iloc[0][c].tolist()\n values += values[:1]\n print(values)\n angles = [n / float(N) * 2 * 3.141 for n in range(N)]\n angles += ang... | [
"0.62712663",
"0.58639205",
"0.5833647",
"0.5677688",
"0.5650228",
"0.5584993",
"0.55144435",
"0.55014986",
"0.53806454",
"0.53474057",
"0.532776",
"0.5325962",
"0.52893907",
"0.52685654",
"0.5188182",
"0.518027",
"0.51380223",
"0.5116624",
"0.51140165",
"0.5104122",
"0.50833... | 0.7620976 | 0 |
Create dataframes for the song data and the id lookup table from csv files. | def load_data_csv():
# Load lookup table
path = 'data/id_lookup.csv'
lookup_table = pd.read_csv(path, index_col=0)
# Load song data
path2 = 'data/data_lyrics_features.csv'
data = pd.read_csv(path2, index_col=0)
return data, lookup_table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_training_df(df, id_csv):\n\n train_df = fetch_training_df(df)\n \n for column_name in ['song_id', 'track_id']:\n train_df[column_name] = train_df[column_name].map(lambda x: ast.literal_eval(x).decode('utf-8'))\n \n train_df.drop(['year'], axis=1, inplace=True)\n train_df =... | [
"0.6965932",
"0.65141785",
"0.64995843",
"0.6274993",
"0.62575454",
"0.6177822",
"0.61413383",
"0.6138976",
"0.61084205",
"0.6034166",
"0.6017585",
"0.60097295",
"0.59951246",
"0.59737027",
"0.5946599",
"0.5938458",
"0.59284836",
"0.59180796",
"0.5915057",
"0.590716",
"0.5904... | 0.7432108 | 0 |
Create dataframes for the song data and the id lookup table from sql tables | def load_data_sql():
conn = mysql.connect(**st.secrets["mysql"])
data = pd.read_sql('SELECT * FROM song_data', conn)
lookup_table = pd.read_sql('SELECT * FROM lookup_table', conn)
return data, lookup_table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_df_saved_songs(api_results):\r\n #create lists for df-columns\r\n track_name = []\r\n track_id = []\r\n artist = []\r\n album = []\r\n duration = []\r\n popularity = []\r\n #loop through api_results\r\n for items in api_results[\"items\"]:\r\n try:\r\n track_... | [
"0.6467784",
"0.6313377",
"0.6313175",
"0.62454724",
"0.6208443",
"0.6207447",
"0.6163429",
"0.6080419",
"0.6073513",
"0.5993247",
"0.59899527",
"0.59840816",
"0.59701216",
"0.59040105",
"0.5885752",
"0.5883292",
"0.5880176",
"0.58707464",
"0.5863237",
"0.58616227",
"0.584839... | 0.737397 | 0 |
Function to clean the lyrics. It lowercases the lyrics, tokenizes it and removes all stopwords. | def clean_lyrics(data):
#Initialize list to store clean data, tokenizer and the set of stopwords
cleaned_data = []
tokenizer = RegexpTokenizer(r'\w+')
stopword_set = set(stopwords.words('english'))
# Clean data for all the lyrics in the list
for doc in data:
# Get lowercase of lyrics string... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_stopwords(text):\n tokens = tokenize(text)\n tokens = stopwordsRem(tokens)\n return tokens",
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n ... | [
"0.7149533",
"0.711997",
"0.71127933",
"0.70084614",
"0.7008055",
"0.6964465",
"0.69019014",
"0.6889795",
"0.6886759",
"0.6817508",
"0.680712",
"0.680712",
"0.680712",
"0.680712",
"0.680712",
"0.680712",
"0.6803836",
"0.6785484",
"0.6744621",
"0.6723114",
"0.6663751",
"0.66... | 0.80085784 | 0 |
Function to download the nltk stopwords, necessary for downloading them in deployed streamlit. | def download_nltk():
nltk.download('stopwords')
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_stopwords():\n\n try:\n stopwords = nltk.corpus.stopwords.words('english')\n except LookupError:\n nltk.download('stopwords')\n stopwords = nltk.corpus.stopwords.words('english')\n\n return stopwords",
"def getStopWords():\n import os\n cur_dir = os.getcwd()\n\n d... | [
"0.7056914",
"0.672676",
"0.65633",
"0.64674133",
"0.64260197",
"0.60864633",
"0.60857505",
"0.6040219",
"0.5840577",
"0.5820878",
"0.5693822",
"0.5691857",
"0.5678198",
"0.567216",
"0.567216",
"0.5590431",
"0.5583685",
"0.55802655",
"0.5579682",
"0.5562735",
"0.5561147",
"... | 0.8456259 | 0 |
Function to create a playlist on the Spotify account of the authenticated user. | def create_playlist(user_id, sp, recommendations, name, description):
# Get current user ID
current_user = sp.current_user()
current_user_id = current_user['id']
# Get list of track ID's
track_id_list = list(recommendations['id'].values)
# Create Empty playlist
sp.user_playlist_create(u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_playlist(access_token):\n request_body = json.dumps({\n \"name\": \"SpotiAdd\",\n \"description\": \"All Liked Youtube Videos\",\n \"public\": True\n })\n userId = getUserId(access_token)\n query = \"https://api.spotify.com/v1/users/{}/playlists\".format(\n us... | [
"0.8058813",
"0.80005246",
"0.7989324",
"0.79241043",
"0.7740644",
"0.77238566",
"0.7633254",
"0.7545742",
"0.7387511",
"0.73627365",
"0.72458297",
"0.72355944",
"0.70558184",
"0.6973023",
"0.6844902",
"0.68256104",
"0.676774",
"0.6748794",
"0.67386353",
"0.6737213",
"0.67147... | 0.80740494 | 0 |
Gets the policy_filter of this OrganizationPolicyAssignmentResponse. | def policy_filter(self):
return self._policy_filter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy(self) -> HwPolicy:\n return self._policy",
"def policy(self) -> typing.Optional[\"BucketPolicy\"]:\n return jsii.get(self, \"policy\")",
"def policy(self) -> typing.Optional[\"BucketPolicy\"]:\n return jsii.get(self, \"policy\")",
"def policy(self) -> pulumi.Output[str]:\n ... | [
"0.64426523",
"0.63347477",
"0.63347477",
"0.6254262",
"0.6254262",
"0.6254262",
"0.6232846",
"0.6154645",
"0.6054802",
"0.6038672",
"0.5961586",
"0.5961586",
"0.5961586",
"0.59271795",
"0.5914966",
"0.5914966",
"0.59142625",
"0.5909025",
"0.59050524",
"0.58475024",
"0.584271... | 0.7547869 | 0 |
Sets the policy_filter of this OrganizationPolicyAssignmentResponse. | def policy_filter(self, policy_filter):
self._policy_filter = policy_filter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPolicy(self, value):\n return self._set(policy=value)",
"def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:\n return response",
"def policy_id(self, policy_id):\n\n self._policy_id = policy_id",
"def policy_id(self, policy_id):\n\n self._policy... | [
"0.6124238",
"0.6082827",
"0.559081",
"0.559081",
"0.5558075",
"0.55172706",
"0.5390123",
"0.5359806",
"0.53372866",
"0.52970994",
"0.51797837",
"0.51797837",
"0.50907636",
"0.50907636",
"0.5052488",
"0.50252205",
"0.5023048",
"0.48849055",
"0.48635036",
"0.48629102",
"0.4804... | 0.76615846 | 0 |
Converts a quaternion frame into an Euler frame | def get_euler_frame(quaternionion_frame):
euler_frame = list(quaternionion_frame[:3])
for quaternion in gen_4_tuples(quaternionion_frame[3:]):
euler_frame += quaternion_to_euler(quaternion)
return euler_frame | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_quaternion_to_euler(quaternion_frames):\n\n def gen_4_tuples(it):\n \"\"\"Generator of n-tuples from iterable\"\"\"\n\n return list(zip(it[0::4], it[1::4], it[2::4], it[3::4]))\n\n def get_euler_frame(quaternionion_frame):\n \"\"\"Converts a quaternion frame into an Euler fra... | [
"0.7414339",
"0.73146856",
"0.71095103",
"0.7028929",
"0.69413733",
"0.6857715",
"0.68519485",
"0.6828414",
"0.67464375",
"0.65595144",
"0.6482063",
"0.6433578",
"0.641723",
"0.64079833",
"0.6349131",
"0.63428414",
"0.63100946",
"0.62874687",
"0.62510014",
"0.6169634",
"0.613... | 0.7801406 | 0 |
Converts a quaternion frame into an Euler frame | def get_euler_frame(quaternionion_frame):
euler_frame = list(quaternionion_frame[:3])
for quaternion in gen_4_tuples(quaternionion_frame[3:]):
euler_frame += quaternion_to_euler(quaternion)
return euler_frame | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_quaternion_to_euler(quaternion_frames):\n\n def gen_4_tuples(it):\n \"\"\"Generator of n-tuples from iterable\"\"\"\n\n return list(zip(it[0::4], it[1::4], it[2::4], it[3::4]))\n\n def get_euler_frame(quaternionion_frame):\n \"\"\"Converts a quaternion frame into an Euler fra... | [
"0.7414339",
"0.73146856",
"0.71095103",
"0.7028929",
"0.69413733",
"0.6857715",
"0.68519485",
"0.6828414",
"0.67464375",
"0.65595144",
"0.6482063",
"0.6433578",
"0.641723",
"0.64079833",
"0.6349131",
"0.63428414",
"0.63100946",
"0.62874687",
"0.62510014",
"0.6169634",
"0.613... | 0.7801406 | 1 |
Prepare an InteractiveSession, Open a ReproducibleSession, (optionally) Add a metadata command, Close the ReproducibleSession | def new_case_study(with_metadata_command=0):
isess = InteractiveSession(DBSession)
isess.identify({"user": "test_user"}, testing=True) # Pass just user name.
isess.open_reproducible_session(case_study_version_uuid=None,
recover_previous_state=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_start_interactive_session(sample_serial_workflow_in_db):\n with patch.multiple(\"reana_workflow_controller.k8s\",\n current_k8s_corev1_api_client=DEFAULT,\n current_k8s_extensions_v1beta1=DEFAULT) as mocks:\n kwrm = KubernetesWorkflowRunManager(sampl... | [
"0.60375863",
"0.5907077",
"0.57165277",
"0.57161325",
"0.5659394",
"0.5650892",
"0.5644861",
"0.5511649",
"0.5496762",
"0.54647994",
"0.5434915",
"0.5400358",
"0.5388621",
"0.5275898",
"0.5254386",
"0.5252777",
"0.5225612",
"0.5222021",
"0.51890284",
"0.5137504",
"0.5135676"... | 0.63685817 | 0 |
! Constructor of clustering algorithm CLARANS. The higher the value of maxneighbor, the closer is CLARANS to KMedoids, and the longer is each search of a local minima. | def __init__(self, data, number_clusters, numlocal, maxneighbor):
self.__pointer_data = data
self.__numlocal = numlocal
self.__maxneighbor = maxneighbor
self.__number_clusters = number_clusters
self.__clusters = []
self.__current = []
self.__belong = []... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster(self):\n\n result_nominatim = self.nominatim()\n try:\n coord = [(float( i['lat'] ), float( i['lon'] )) for i in result_nominatim]\n except:\n return None\n #print( \"coord\", coord )\n kms_per_radian = 6371.0088\n # Augmenter cette valeur... | [
"0.67506176",
"0.6538149",
"0.6469685",
"0.63442355",
"0.63192666",
"0.6225287",
"0.6143774",
"0.61311984",
"0.6123281",
"0.6097289",
"0.60914516",
"0.6089441",
"0.6071795",
"0.6051894",
"0.6039509",
"0.5990073",
"0.5981506",
"0.5952713",
"0.5925311",
"0.5907183",
"0.5874377"... | 0.6568333 | 1 |
! Returns clustering result representation type that indicate how clusters are encoded. (type_encoding) Clustering result representation. get_clusters() | def get_cluster_encoding(self):
return type_encoding.CLUSTER_INDEX_LIST_SEPARATION | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster_encoding(self):\n\n return type_encoding.CLUSTER_INDEX_LIST_SEPARATION",
"def cluster_type(self) -> str:\n return pulumi.get(self, \"cluster_type\")",
"def cluster_types(self):\n raise NotImplementedError",
"def clustering(self) -> 'outputs.ClusteringResponse':\n r... | [
"0.69525045",
"0.6760325",
"0.6753326",
"0.651426",
"0.62345177",
"0.61501366",
"0.60817915",
"0.6077545",
"0.6072492",
"0.59875476",
"0.5957499",
"0.5922276",
"0.59057575",
"0.5892965",
"0.58514273",
"0.58257383",
"0.5823855",
"0.58212787",
"0.57745683",
"0.5772822",
"0.5764... | 0.70536655 | 0 |
! Forms cluster in line with specified medoids by calculation distance from each point to medoids. | def __update_clusters(self, medoids):
self.__belong = [0] * len(self.__pointer_data)
self.__clusters = [[] for i in range(len(medoids))]
for index_point in range(len(self.__pointer_data)):
index_optim = -1
dist_optim = 0.0
for index in range(len(medo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __update_clusters(self, medoids):\n\n self.__belong = [0] * len(self.__pointer_data)\n self.__clusters = [[] for _ in range(len(medoids))]\n for index_point in range(len(self.__pointer_data)):\n index_optim = -1\n dist_optim = 0.0\n\n for index in range(len... | [
"0.6737825",
"0.642241",
"0.6357446",
"0.6354768",
"0.6282258",
"0.61936045",
"0.6147",
"0.6068303",
"0.58993065",
"0.58847624",
"0.5868176",
"0.5837447",
"0.57862705",
"0.5782571",
"0.57547903",
"0.57543516",
"0.57309794",
"0.5684379",
"0.5684267",
"0.56757045",
"0.563804",
... | 0.6725608 | 1 |
! Finds the another nearest medoid for the specified point that is different from the specified medoid. | def __find_another_nearest_medoid(self, point_index, current_medoid_index):
other_medoid_index = -1
other_distance_nearest = float('inf')
for index_medoid in self.__current:
if (index_medoid != current_medoid_index):
other_distance_candidate = euclidean_distance_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __find_another_nearest_medoid(self, point_index, current_medoid_index):\n other_medoid_index = -1\n other_distance_nearest = float(\"inf\")\n for index_medoid in self.__current:\n if index_medoid != current_medoid_index:\n other_distance_candidate = euclidean_dist... | [
"0.72442216",
"0.6210788",
"0.61261934",
"0.6079808",
"0.60431045",
"0.6032891",
"0.60166126",
"0.58206975",
"0.5710699",
"0.569829",
"0.56964684",
"0.56876916",
"0.5655259",
"0.5644433",
"0.5593935",
"0.55899715",
"0.558293",
"0.5577618",
"0.55623066",
"0.55480283",
"0.55458... | 0.7339319 | 0 |
Concatenate n frames before and after the current frame | def concatenate_x_frames(x, y, num_of_frames, is_y=True):
if is_y:
items_x = list()
items_y = list()
for item in range(len(x)):
x_concat = []
for i in range(num_of_frames, len(x[item]) - num_of_frames):
tmp_x = None
is_first = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_inputs(context, num_frames, adjacent_frames):\n buffer = context[0:num_frames, :]\n for i in range(0, adjacent_frames*2):\n buffer = np.concatenate((buffer, context[i + 1 : num_frames + i + 1, :]), axis=1) \n return buffer",
"def revert_frames(self, n_frames: int = 25) -> None:\n ... | [
"0.6015416",
"0.5966462",
"0.59200066",
"0.57837373",
"0.57320315",
"0.567933",
"0.56246394",
"0.5597678",
"0.55933285",
"0.5558255",
"0.5511402",
"0.5479374",
"0.5469259",
"0.54489094",
"0.5431185",
"0.5431053",
"0.5430827",
"0.54303914",
"0.5425497",
"0.53956336",
"0.539395... | 0.60769045 | 0 |
Wraps and indents a string ``s``. | def indent_wrap(s, indent=0, wrap=80):
split = wrap - indent
chunks = [indent * " " + s[i:i + split] for i in range(0, len(s), split)]
return "\n".join(chunks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_string(input_str):\r\n return textwrap.wrap(input_str, 80)",
"def to_string_wrap(s: str) -> str:\n return f\"to_string({s})\"",
"def indent(string, level=1):\n spaces = ' ' * (level * 4)\n return \"%s%s\" % (spaces, string)",
"def wrap(s, width, hyphen_break=False, break_chrs=''):\n ass... | [
"0.7181232",
"0.69954926",
"0.6415862",
"0.6409179",
"0.6396516",
"0.6327478",
"0.63242805",
"0.6322026",
"0.6222691",
"0.6214404",
"0.6214404",
"0.61937743",
"0.6112519",
"0.60538924",
"0.6023239",
"0.60085034",
"0.59799033",
"0.5958307",
"0.59397006",
"0.5934544",
"0.588300... | 0.7855075 | 0 |
Recursively traverse through iterable object ``d`` and convert all occuring ndarrays to lists to make it JSON serializable. | def serialize_ndarrays(d):
def dict_handler(d):
return d.items()
handlers = {list: enumerate, tuple: enumerate,
set: enumerate, frozenset: enumerate,
dict: dict_handler}
def serialize(o):
for typ, handler in handlers.items():
if isinstance(o, typ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_list_from_dict(d, l):\n\n new_list = []\n\n for val in l:\n subdict = d[val]\n inner_list = []\n for subval in l:\n inner_list.append(subdict[subval])\n new_list.append(inner_list)\n\n return np.array(new_list)",
"def traver... | [
"0.5972985",
"0.5779406",
"0.5766659",
"0.5579728",
"0.55737484",
"0.5479306",
"0.5460912",
"0.5404746",
"0.5390378",
"0.5390378",
"0.5390378",
"0.53863674",
"0.53602403",
"0.5325386",
"0.5264046",
"0.52487487",
"0.52456796",
"0.52453446",
"0.5200569",
"0.519804",
"0.5175681"... | 0.73105025 | 0 |
Populate dictionary with data from a given dict ``d``, and check if ``d`` has required and optional keys. Set optionals with default if not present. If input ``d`` is None and ``required_keys`` is empty, just return ``opt_keys``. | def fill_dict_defaults(d, required_keys=None, opt_keys=None, noleft=True):
if required_keys is None:
required_keys = []
if opt_keys is None:
opt_keys = {}
if d is None:
if not required_keys:
if opt_keys is None:
raise TypeError("`d` and òpt_keys` are both ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_dict(data, required=None, defaults=None):\n required = required or []\n for i in set(required) - set(data):\n raise IndexError(\"Missed: %s\" % i)\n\n defaults = defaults or {}\n for i in set(data) - set(required) - set(defaults):\n raise ValueError(\"Unexpected: %s\" % i)\n\n ... | [
"0.6829249",
"0.6829249",
"0.61653477",
"0.60751134",
"0.5929873",
"0.5821945",
"0.5796474",
"0.5693985",
"0.56603634",
"0.54797363",
"0.5449738",
"0.54321885",
"0.5375609",
"0.53658336",
"0.533189",
"0.5303772",
"0.521909",
"0.52113986",
"0.5090213",
"0.5082031",
"0.5071563"... | 0.7746933 | 0 |
Given a list of dicts/objects return a dict mapping item[key_name] > item | def list_to_map(item_list, key_name):
return {x.pop(key_name): x for x in item_list} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items_dict(slist, key=None):\n fields = slist.fields()\n items = [collections.OrderedDict((k, f) for k, f in zip(fields[0], item))\n for item in fields[1:]]\n if key:\n return collections.OrderedDict((i[key], i) for i in items)\n else:\n return items",
"def list_to_dict(... | [
"0.668586",
"0.6637244",
"0.63673234",
"0.6252041",
"0.60777247",
"0.59447753",
"0.59235644",
"0.59206873",
"0.58975065",
"0.58687013",
"0.58588576",
"0.58409035",
"0.57967824",
"0.5757043",
"0.5666372",
"0.5651253",
"0.56499344",
"0.56259024",
"0.56049645",
"0.55956835",
"0.... | 0.7173263 | 0 |
Run a command from a list with optional environemnt and return a tuple (rc, stdout_str, stderr_str) | def run_command_list(cmd_list, env=None):
rc = -1
sout = serr = None
cmd_list = run_sanitize(cmd_list)
try:
if env:
pipes = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
else:
pipes = subprocess.Popen(cmd_list, stdout=subproc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_command(lst, decode_output = True):\n if is_verbose():\n print(\"Executing command: %s\" % (\" \".join(lst)))\n proc = subprocess.Popen(lst, stdout = subprocess.PIPE, stderr = subprocess.PIPE)\n (proc_stdout, proc_stderr) = proc.communicate()\n if decode_output and not isinstance(proc_stdout, str):\... | [
"0.71225667",
"0.6955543",
"0.6849619",
"0.6824012",
"0.6708122",
"0.644725",
"0.63306963",
"0.629695",
"0.62924445",
"0.62071675",
"0.6191846",
"0.61890286",
"0.614715",
"0.6129071",
"0.6083207",
"0.59565616",
"0.593073",
"0.5911763",
"0.5898761",
"0.5893061",
"0.585685",
... | 0.8288501 | 0 |
Returns a string for use with acquire() calls optionally. Constructs a consistent id from the platform node, process_id and thread_id | def get_threadbased_id(guarantee_uniq=False):
return '{}:{}:{}:{}'.format(platform.node(), os.getpid(), str(threading.get_ident()),uuid.uuid4().hex if guarantee_uniq else '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pid_tid():\n # noinspection PyBroadException\n try:\n return \"(pid=%s) (tid=%s)\" % (\n six.text_type(os.getpid()),\n six.text_type(six.moves._thread.get_ident()),\n )\n except Exception:\n return \"(pid=%s) (tid=Unknown)\" % (six.text_type(os.getpid()))... | [
"0.6859263",
"0.67202514",
"0.6645354",
"0.6566175",
"0.65168583",
"0.6495521",
"0.64781684",
"0.645064",
"0.6420917",
"0.64113784",
"0.63737696",
"0.63713926",
"0.63129073",
"0.6301101",
"0.62372375",
"0.6235125",
"0.6218468",
"0.61973315",
"0.61922956",
"0.61841655",
"0.617... | 0.7741454 | 0 |
Convert the rfc3339 formatted string (UTC only) to a datatime object with tzinfo explicitly set to utc. Raises an exception if the parsing fails. | def rfc3339str_to_datetime(rfc3339_str):
ret = None
for fmt in rfc3339_date_input_fmts:
try:
ret = datetime.datetime.strptime(rfc3339_str, fmt)
# Force this since the formats we support are all utc formats, to support non-utc
if ret.tzinfo is None:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_date(s):\n return parse(s).astimezone(pytz.utc)",
"def datetime_parser(s):\n try:\n ts = arrow.get(s)\n # Convert UTC to local, result of get is UTC unless it specifies\n # timezone, bonfire assumes all time to be machine local\n if ts.tzinfo == arrow.get().tzinfo:\n ... | [
"0.70798886",
"0.70414937",
"0.6984492",
"0.69358456",
"0.678945",
"0.67742926",
"0.6738815",
"0.66999805",
"0.6650111",
"0.661826",
"0.65997696",
"0.6588446",
"0.65588635",
"0.6555089",
"0.6531995",
"0.6470953",
"0.6461898",
"0.64420307",
"0.63758594",
"0.63758594",
"0.63736... | 0.75160867 | 0 |
Convert an epoch int value to a RFC3339 datetime string | def epoch_to_rfc3339(epoch_int):
return datetime_to_rfc3339(datetime.datetime.utcfromtimestamp(epoch_int)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def epoch_to_str(epoch: int) -> str:\n return datetime_to_str(datetime.fromtimestamp(epoch, tz=timezone.utc))",
"def epoch_to_format(epoch, format='%Y-%m-%dT%H:%M:%SZ'):\n\n return datetime.fromtimestamp(int(epoch[:10]), tz=timezone.utc).strftime(format)",
"def epoch_to_format(format, epoch):\n\n retu... | [
"0.75380003",
"0.74161756",
"0.7317242",
"0.71895885",
"0.71866465",
"0.68813205",
"0.68426865",
"0.6692456",
"0.6676125",
"0.6659056",
"0.6645829",
"0.6564905",
"0.65551674",
"0.6492377",
"0.6463422",
"0.64625967",
"0.64381254",
"0.6437414",
"0.6381773",
"0.63762414",
"0.636... | 0.7752254 | 0 |
Takes a CPE 2.3 formatted string and returns a CPE object. This is the only supported method to create an instance of this class This is not entirely true to the spec, it does not unbind all the elements as wfn representation is not used. All of unbinding logic is concentrated in the conversion from wfn to uri format i... | def from_cpe23_fs(cpe23_fs):
cpe_parts = cpe23_fs.split(':')
if cpe_parts and len(cpe_parts) == 13:
return CPE(
part=cpe_parts[2],
vendor=cpe_parts[3],
product=cpe_parts[4],
version=cpe_parts[5],
update=cpe_par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_cpe(cpe_uri):\n parts = CPE_REGEX.match(cpe_uri)\n return parts.group(\"vendor\"), parts.group(\"package\"), parts.group(\"version\")",
"def parser(text, utcnow=None, ugc_provider=None, nwsli_provider=None):\n # Careful here, see if we have two CLIs in one product!\n return CLIProduct(text,... | [
"0.5067945",
"0.47294074",
"0.46910343",
"0.4539366",
"0.45285475",
"0.45284045",
"0.4522765",
"0.44751477",
"0.44448897",
"0.44306594",
"0.4416067",
"0.44121942",
"0.4408843",
"0.43579754",
"0.43081334",
"0.43073845",
"0.4301337",
"0.43006054",
"0.42711237",
"0.42651075",
"0... | 0.63144124 | 0 |
Helper method for escaping the Ensures that resulting version is CPE 2.3 formatted string compliant, this is necessary for as_cpe22_uri() to do its thing affected version data in nvd json data which is usually unescaped. Converts the supplied version | def update_version(self, version):
self.version = CPE.escape_for_cpe23_fs(version) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __format_golang_version(self, version):\n if '.' in version and version[0].isdigit():\n version = 'v' + version\n return version",
"def format_version(version):\n\n return \"v%03d\" % version",
"def _canonicalize_version(_version: str) -> str:\n\n try:\n version = Pyth... | [
"0.63605845",
"0.6071471",
"0.59519637",
"0.58833855",
"0.58813864",
"0.5815081",
"0.57764536",
"0.5725392",
"0.567802",
"0.56723124",
"0.56363887",
"0.5627636",
"0.5595905",
"0.5481817",
"0.5464057",
"0.5450415",
"0.54397607",
"0.5431349",
"0.5430239",
"0.54297805",
"0.54265... | 0.60912997 | 1 |
This is a very limited implementation of cpe matching. other_cpe is a wildcard ridden base cpe used by range descriptors other_cpe checked against this cpe for an exact match of part and vendor. For all the remaining components a match is positive if the other cpe is an exact match or contains the wild char | def is_match(self, other_cpe):
if not isinstance(other_cpe, CPE):
return False
if self.part == other_cpe.part and self.vendor == other_cpe.vendor:
if other_cpe.product not in ['*', self.product]:
return False
if other_cpe.version not in ['*', self.ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_cpes(lhs: ImageCpe, rhs: ImageCpe):\n vendor_cmp = compare_fields(lhs.vendor, rhs.vendor)\n if vendor_cmp != 0:\n return vendor_cmp\n\n name_cmp = compare_fields(lhs.name, rhs.name)\n if name_cmp != 0:\n return name_cmp\n\n version_cmp = compare_fields(lhs.version, rhs.vers... | [
"0.5382316",
"0.5212851",
"0.49537984",
"0.48303866",
"0.48274323",
"0.48095724",
"0.4796859",
"0.47573984",
"0.47336668",
"0.47266325",
"0.4703803",
"0.46701133",
"0.4657172",
"0.46518388",
"0.4650754",
"0.46407726",
"0.45443553",
"0.4544047",
"0.45435515",
"0.4538998",
"0.4... | 0.70947486 | 0 |
Event handler for use with ijson parsers to output floats instead of Decimals for better json serializability downstream. | def ijson_decimal_to_float(event):
if event[1] == 'number' and isinstance(event[2], decimal.Decimal):
return event[0], event[1], float(event[2])
else:
return event | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float_format(self):\n ...",
"def _serialize_decimal(val):\n return float(val)",
"def add_support_for_floats_to_dynamodb():\n\n # Ignore loss of precision rather than raising exception\n DYNAMODB_CONTEXT.clear_traps()\n\n # Keep a reference to the original serialization methods\n boto3... | [
"0.6859712",
"0.62191844",
"0.61126083",
"0.60944045",
"0.6072339",
"0.60572433",
"0.60548705",
"0.60541445",
"0.5945829",
"0.5910709",
"0.5849566",
"0.5847714",
"0.5847714",
"0.5847714",
"0.5756914",
"0.57321376",
"0.5715654",
"0.5713692",
"0.5697113",
"0.5697113",
"0.565421... | 0.7431174 | 0 |
Sync the provided roles and permissions. | def bulk_sync_roles(self, roles: Iterable[dict[str, Any]]) -> None:
existing_roles = self._get_all_roles_with_permissions()
non_dag_perms = self._get_all_non_dag_permissions()
for config in roles:
role_name = config["role"]
perms = config["perms"]
role = exis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_roles(self) -> None:\n # Create global all-dag permissions\n self.create_perm_vm_for_all_dag()\n\n # Sync the default roles (Admin, Viewer, User, Op, public) with related permissions\n self.bulk_sync_roles(self.ROLE_CONFIGS)\n\n self.add_homepage_access_to_custom_roles()... | [
"0.77906233",
"0.66263545",
"0.63187075",
"0.5924941",
"0.58685404",
"0.582195",
"0.5794141",
"0.5794141",
"0.5794141",
"0.5774081",
"0.5730462",
"0.57237566",
"0.5634548",
"0.5609491",
"0.5607976",
"0.5532661",
"0.5518215",
"0.5483266",
"0.54664904",
"0.54311615",
"0.5424220... | 0.77958214 | 0 |
Get all the roles associated with the user. | def get_user_roles(user=None):
if user is None:
user = g.user
return user.roles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_roles(self):\n url = 'userroles'\n result = self.get(url)\n return result.get('userroles', result)",
"def list(self, **kwargs):\n # TODO(adriant): Look up user by name/id\n url = '/openstack/users/%s/roles' % kwargs['user']\n return self._list(url, 'roles')"... | [
"0.83929795",
"0.79378843",
"0.7776199",
"0.76373804",
"0.7512251",
"0.7501195",
"0.7472107",
"0.73554534",
"0.73497117",
"0.73466504",
"0.73303014",
"0.72634876",
"0.7181796",
"0.71781325",
"0.71354675",
"0.7121091",
"0.711354",
"0.7098917",
"0.7070297",
"0.70572376",
"0.705... | 0.81134564 | 1 |
Gets the DAGs readable by authenticated user. | def get_readable_dags(self, user) -> Iterable[DagModel]:
warnings.warn(
"`get_readable_dags` has been deprecated. Please use `get_readable_dag_ids` instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_readable_dag_ids(self, user) -> set[str]:\n return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_READ])",
"def can_read_all_dags(self, user=None) -> bool:\n return self.has_access(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG, user)",
"def get_accessible_dag_ids(\n ... | [
"0.7089873",
"0.67098624",
"0.6468782",
"0.63686824",
"0.62738264",
"0.60500044",
"0.6023267",
"0.58576083",
"0.57512844",
"0.5697229",
"0.5695736",
"0.5688438",
"0.5622657",
"0.56148934",
"0.55736953",
"0.55663365",
"0.5542382",
"0.5535234",
"0.55239934",
"0.5515076",
"0.551... | 0.6834099 | 1 |
Gets the DAGs editable by authenticated user. | def get_editable_dags(self, user) -> Iterable[DagModel]:
warnings.warn(
"`get_editable_dags` has been deprecated. Please use `get_editable_dag_ids` instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
with warnings.catch_warnings():
warnings.simple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_editable_dag_ids(self, user) -> set[str]:\n return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_EDIT])",
"def can_edit_all_dags(self, user=None) -> bool:\n return self.has_access(permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG, user)",
"def get_editable_explorations(use... | [
"0.75425524",
"0.66582686",
"0.6618005",
"0.6526522",
"0.6415768",
"0.61828756",
"0.6021461",
"0.60081035",
"0.59142524",
"0.574658",
"0.5726433",
"0.572193",
"0.565869",
"0.5658475",
"0.56448656",
"0.5641777",
"0.5621332",
"0.5581223",
"0.5547112",
"0.551225",
"0.5500119",
... | 0.74315757 | 1 |
Gets the DAG IDs readable by authenticated user. | def get_readable_dag_ids(self, user) -> set[str]:
return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_READ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_editable_dag_ids(self, user) -> set[str]:\n return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_EDIT])",
"def get_accessible_dag_ids(\n self,\n user,\n user_actions: Container[str] | None = None,\n session: Session = NEW_SESSION,\n ) -> set[str]:\n ... | [
"0.6810618",
"0.6412881",
"0.60274273",
"0.5916253",
"0.58385724",
"0.5836793",
"0.58053106",
"0.57211167",
"0.5666801",
"0.5621901",
"0.5606045",
"0.5600266",
"0.5539903",
"0.54888976",
"0.54831",
"0.5393162",
"0.5322502",
"0.53144634",
"0.52798474",
"0.5208441",
"0.51715237... | 0.71341 | 0 |
Gets the DAG IDs editable by authenticated user. | def get_editable_dag_ids(self, user) -> set[str]:
return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_EDIT]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_readable_dag_ids(self, user) -> set[str]:\n return self.get_accessible_dag_ids(user, [permissions.ACTION_CAN_READ])",
"def get_editable_dags(self, user) -> Iterable[DagModel]:\n warnings.warn(\n \"`get_editable_dags` has been deprecated. Please use `get_editable_dag_ids` instead.... | [
"0.6775534",
"0.660425",
"0.6343545",
"0.5962925",
"0.59002167",
"0.57747674",
"0.5721568",
"0.56791186",
"0.56647104",
"0.5664357",
"0.56574374",
"0.56426185",
"0.55538565",
"0.5540895",
"0.54543847",
"0.54483676",
"0.54234356",
"0.54187673",
"0.541208",
"0.53471106",
"0.533... | 0.7752794 | 0 |
Determines whether a user has DAG read access. | def can_read_dag(self, dag_id: str, user=None) -> bool:
root_dag_id = self._get_root_dag_id(dag_id)
dag_resource_name = permissions.resource_name_for_dag(root_dag_id)
return self.has_access(permissions.ACTION_CAN_READ, dag_resource_name, user=user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_read(self, user):\n raise Return(True)",
"def has_read_permission(request):\n return request.user.is_authenticated",
"def has_access(self, action_name: str, resource_name: str, user=None) -> bool:\n if not user:\n user = g.user\n if (action_name, resource_name) in... | [
"0.7598551",
"0.7589699",
"0.7226936",
"0.7186378",
"0.71421206",
"0.7118634",
"0.70449024",
"0.6999025",
"0.69731724",
"0.6968622",
"0.6941354",
"0.69252783",
"0.69086224",
"0.6758709",
"0.6709498",
"0.66952443",
"0.6646694",
"0.6631528",
"0.6598221",
"0.65821195",
"0.657995... | 0.7601378 | 0 |
Determines whether a user has DAG delete access. | def can_delete_dag(self, dag_id: str, user=None) -> bool:
root_dag_id = self._get_root_dag_id(dag_id)
dag_resource_name = permissions.resource_name_for_dag(root_dag_id)
return self.has_access(permissions.ACTION_CAN_DELETE, dag_resource_name, user=user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_delete(self, user):\n raise Return(False)",
"def check_delete_permission(self):\n if getSecurityManager().checkPermission(\"Delete objects\", self):\n username = getSecurityManager().getUser().getUserName()\n if username == self.getOwner().getId():\n ret... | [
"0.78429",
"0.7446556",
"0.7367293",
"0.72968274",
"0.72547096",
"0.71889985",
"0.71632475",
"0.71632475",
"0.7145582",
"0.7087952",
"0.7009737",
"0.7005602",
"0.68999463",
"0.68475777",
"0.6841784",
"0.6757655",
"0.6748384",
"0.6725004",
"0.66738075",
"0.6660552",
"0.6650544... | 0.75682795 | 1 |
Returns the permission name for a DAG id. | def prefixed_dag_id(self, dag_id: str) -> str:
warnings.warn(
"`prefixed_dag_id` has been deprecated. "
"Please use `airflow.security.permissions.resource_name_for_dag` instead.",
RemovedInAirflow3Warning,
stacklevel=2,
)
root_dag_id = self._get_ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(id):\r\n\r\n graph = GraphAPI(access_token=TOKEN, version='2.5')\r\n\r\n return graph.get_object(id=str(id).split('-')[0])['name']",
"def PermissionSetName(self) -> str:",
"def acl_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"acl_name\")",
"def dag_name(self):\n ... | [
"0.6119352",
"0.589299",
"0.5748296",
"0.56348586",
"0.5568398",
"0.55251837",
"0.5521585",
"0.54744",
"0.5474207",
"0.54451746",
"0.54412836",
"0.5435674",
"0.5379868",
"0.53726",
"0.5362401",
"0.535118",
"0.5331459",
"0.5284019",
"0.5281497",
"0.5270985",
"0.52205694",
"0... | 0.6936026 | 0 |
Determines if a resource belongs to a DAG or all DAGs. | def is_dag_resource(self, resource_name: str) -> bool:
if resource_name == permissions.RESOURCE_DAG:
return True
return resource_name.startswith(permissions.RESOURCE_DAG_PREFIX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_read_all_dags(self, user=None) -> bool:\n return self.has_access(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG, user)",
"def is_dag(self):\n if nx.is_directed_acyclic_graph(Node.G):\n return True\n else:\n return False",
"def can_edit_all_dags(self, us... | [
"0.6148349",
"0.6011392",
"0.57166684",
"0.5582532",
"0.54927164",
"0.546736",
"0.5406616",
"0.5362055",
"0.53611654",
"0.52332544",
"0.522739",
"0.51649857",
"0.5148707",
"0.5101213",
"0.5099694",
"0.5078531",
"0.5074959",
"0.5069634",
"0.5061898",
"0.5059261",
"0.50497496",... | 0.73183984 | 0 |
Verify whether a given user could perform a certain action on the given resource. Example actions might include can_read, can_write, can_delete, etc. | def has_access(self, action_name: str, resource_name: str, user=None) -> bool:
if not user:
user = g.user
if (action_name, resource_name) in user.perms:
return True
if self.is_dag_resource(resource_name):
if (action_name, permissions.RESOURCE_DAG) in user.per... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can(user, action):\n\n v = bitvector.BitVector(user.access_level)\n return v.is_set(EVERYTHING) or v.is_set(action)",
"def check_permission(user, action_name, app_label, model_name):\r\n p = '%s.%s_%s' % (app_label, action_name, model_name)\r\n return user and user.is_active and user.has_perm(p)"... | [
"0.69866955",
"0.6912086",
"0.6754024",
"0.67154",
"0.67023987",
"0.6687463",
"0.6617492",
"0.6611587",
"0.660988",
"0.65471673",
"0.6348825",
"0.63040656",
"0.6253602",
"0.625236",
"0.6251293",
"0.6249416",
"0.62281436",
"0.6177559",
"0.61749506",
"0.61509055",
"0.61430466",... | 0.6915247 | 1 |
FAB leaves faulty permissions that need to be cleaned up. | def clean_perms(self) -> None:
self.log.debug("Cleaning faulty perms")
sesh = self.appbuilder.get_session
perms = sesh.query(Permission).filter(
or_(
Permission.action == None, # noqa
Permission.resource == None, # noqa
)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_perms(self) -> None:\n\n logger.info(\"Cleaning faulty perms\")\n sesh = self.get_session\n pvms = sesh.query(PermissionView).filter(\n or_(\n PermissionView.permission # pylint: disable=singleton-comparison\n == None,\n Permis... | [
"0.6777668",
"0.6655451",
"0.6426778",
"0.63922745",
"0.6263131",
"0.6173565",
"0.60162455",
"0.5943351",
"0.592031",
"0.58951074",
"0.58124304",
"0.5756105",
"0.574823",
"0.573477",
"0.57173944",
"0.57100266",
"0.57020974",
"0.57020974",
"0.5701144",
"0.5669114",
"0.5663117"... | 0.71627325 | 0 |
Add the new (action, resource) to assoc_permission_role if it doesn't exist. It will add the related entry to ab_permission and ab_resource two meta tables as well. | def _merge_perm(self, action_name: str, resource_name: str) -> None:
action = self.get_action(action_name)
resource = self.get_resource(resource_name)
perm = None
if action and resource:
perm = self.appbuilder.get_session.scalar(
select(self.permission_model).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addPermission(self, permission=None, permName=None, kvDict=None):\n return _modelActionBase(self, instance=permission, instanceName=permName, kvDict=kvDict,\n model=get_model('perm'), db=db, action='add', modelType='permission')",
"def addPermission(self, permiss... | [
"0.5865254",
"0.5865254",
"0.5848337",
"0.5837557",
"0.58164537",
"0.57867205",
"0.57089216",
"0.5665712",
"0.5634836",
"0.55668044",
"0.550847",
"0.54680765",
"0.5388977",
"0.5367029",
"0.5367029",
"0.5362631",
"0.53599876",
"0.53311914",
"0.5264665",
"0.5261038",
"0.5226682... | 0.62584925 | 0 |
Add Website.can_read access to all custom roles. | def add_homepage_access_to_custom_roles(self) -> None:
website_permission = self.create_permission(permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE)
custom_roles = [role for role in self.get_all_roles() if role.name not in EXISTING_ROLES]
for role in custom_roles:
self.add_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_granted_roles(self):",
"def addRoleAccess(self, role, read, write, catalog='*', repository='*'):\n return self._client.addRoleAccess(role, read, write, catalog, repository)",
"def is_permitted(self):\n\t\tfrom frappe.utils import has_common\n\n\t\tallowed = [\n\t\t\td.role for d in frappe.get_al... | [
"0.63643557",
"0.62228906",
"0.6118731",
"0.60232246",
"0.6011454",
"0.597188",
"0.5928835",
"0.59201527",
"0.5918606",
"0.588256",
"0.580424",
"0.57854474",
"0.5676077",
"0.56598353",
"0.5642836",
"0.563202",
"0.55289304",
"0.55146646",
"0.5463989",
"0.5431027",
"0.53917587"... | 0.7238645 | 0 |
Returns all permissions as a set of tuples with the action and resource names. | def get_all_permissions(self) -> set[tuple[str, str]]:
return set(
self.appbuilder.get_session.execute(
select(self.action_model.name, self.resource_model.name)
.join(self.permission_model.action)
.join(self.permission_model.resource)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission_resources(self):\n return self._permission_resources",
"def permission_resources(self):\n return self._permission_resources",
"def collect_all_perms(cls):\n permissions = filter(lambda perm: perm.startswith('biom_perm') or perm.startswith('entity_perm'), dir(cls))\n\n ... | [
"0.7453826",
"0.7453826",
"0.7320338",
"0.7297786",
"0.7254982",
"0.7202756",
"0.7202756",
"0.71981245",
"0.7105019",
"0.7104533",
"0.70924604",
"0.70783067",
"0.70722604",
"0.7064907",
"0.7051972",
"0.7051972",
"0.7036866",
"0.70281744",
"0.7020507",
"0.7017964",
"0.7006028"... | 0.8255731 | 0 |
Get permissions except those that are for specific DAGs. Returns a dict with a key of (action_name, resource_name) and value of permission with all permissions except those that are for specific DAGs. | def _get_all_non_dag_permissions(self) -> dict[tuple[str, str], Permission]:
return {
(action_name, resource_name): viewmodel
for action_name, resource_name, viewmodel in (
self.appbuilder.get_session.execute(
select(self.action_model.name, self.resour... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dag_specific_permissions(self) -> None:\n perms = self.get_all_permissions()\n dagbag = DagBag(read_dags_from_db=True)\n dagbag.collect_dags_from_db()\n dags = dagbag.dags.values()\n\n for dag in dags:\n root_dag_id = dag.parent_dag.dag_id if dag.parent_dag ... | [
"0.6322439",
"0.56092525",
"0.5590724",
"0.5579938",
"0.5579938",
"0.5560115",
"0.55266464",
"0.5523204",
"0.5505508",
"0.5470867",
"0.5448818",
"0.54386747",
"0.54310954",
"0.5424532",
"0.54092175",
"0.53158826",
"0.53158826",
"0.52948",
"0.52631074",
"0.52576387",
"0.525561... | 0.7711198 | 0 |
Returns a dict with a key of role name and value of role with early loaded permissions. | def _get_all_roles_with_permissions(self) -> dict[str, Role]:
return {
r.name: r
for r in self.appbuilder.get_session.scalars(
select(self.role_model).options(joinedload(self.role_model.permissions))
).unique()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_roles_setting() -> dict[str, set[type['Intent']]]:\n return {\n # the admin role has access to everything\n 'admin': {\n Public,\n Private,\n Personal,\n Secret\n },\n # the editor can do most things\n 'editor': {\n ... | [
"0.6373386",
"0.631273",
"0.63032925",
"0.626296",
"0.62269676",
"0.6022238",
"0.6016043",
"0.5985932",
"0.59825903",
"0.59076625",
"0.5885268",
"0.5858767",
"0.5834165",
"0.5824442",
"0.5819442",
"0.5761967",
"0.5714344",
"0.5677739",
"0.56501216",
"0.5647016",
"0.55830544",... | 0.7307136 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.