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 |
|---|---|---|---|---|---|---|
Removes alignments from ``alignment_infos`` that have substantially lower Model 4 scores than the best alignment | def prune(self, alignment_infos):
alignments = []
best_score = 0
for alignment_info in alignment_infos:
score = IBMModel4.model4_prob_t_a_given_s(alignment_info, self)
best_score = max(score, best_score)
alignments.append((alignment_info, score))
thr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hillclimb(self, alignment_info, j_pegged=None):\n alignment = alignment_info # alias with shorter name\n max_probability = IBMModel4.model4_prob_t_a_given_s(alignment, self)\n\n while True:\n old_alignment = alignment\n for neighbor_alignment in self.neighboring(alig... | [
"0.6130298",
"0.59186476",
"0.58583313",
"0.57613075",
"0.55340576",
"0.54292566",
"0.53562945",
"0.52083033",
"0.52064",
"0.51962346",
"0.5181664",
"0.5160797",
"0.51300323",
"0.51119745",
"0.50493014",
"0.50335264",
"0.4981057",
"0.49788785",
"0.4958578",
"0.49504927",
"0.4... | 0.8033812 | 0 |
Starting from the alignment in ``alignment_info``, look at neighboring alignments iteratively for the best one, according to Model 4 Note that Model 4 scoring is used instead of Model 5 because the latter is too expensive to compute. There is no guarantee that the best alignment in the alignment space will be found, be... | def hillclimb(self, alignment_info, j_pegged=None):
alignment = alignment_info # alias with shorter name
max_probability = IBMModel4.model4_prob_t_a_given_s(alignment, self)
while True:
old_alignment = alignment
for neighbor_alignment in self.neighboring(alignment, j_pe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(self) -> bool:\n alignments = []\n for sw_idx in range(len(self.sw)):\n for nu_idx in range(len(self.nu)):\n alignments.append(Alignment(self.nu, self.sw, nu_idx, sw_idx, self.orig_nu))\n alignment = max(alignments, key=lambda align: align.score)\n if ... | [
"0.6601188",
"0.6398663",
"0.6118952",
"0.61056167",
"0.60626775",
"0.6023626",
"0.60167754",
"0.5994181",
"0.59916455",
"0.59730154",
"0.5915752",
"0.5887349",
"0.5867155",
"0.5839666",
"0.57940066",
"0.57413554",
"0.5679159",
"0.56668687",
"0.5643491",
"0.5640524",
"0.56384... | 0.6587548 | 1 |
Method that close a connection | def closeConnection(connection):
connection.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self._connection.close()",
"def close_connection(self, connection):\n pass",
"def close_connection(self, connection ):\n pass",
"def close_connection(self):\n\n self._connection.close()\n print(\"Closed connection....\")",
"def close(self): \n self.c... | [
"0.80904424",
"0.80650824",
"0.8032496",
"0.8001846",
"0.7983716",
"0.7976008",
"0.7946594",
"0.7946594",
"0.7932376",
"0.7921975",
"0.78874135",
"0.78827935",
"0.7838825",
"0.78090316",
"0.7802317",
"0.7776795",
"0.76978225",
"0.7654071",
"0.7624984",
"0.7618633",
"0.761622"... | 0.81997216 | 0 |
Method that reads the possible names from a file | def readNames():
namesRead = []
with open("Files/Names.txt", 'r', encoding='utf8') as f:
for line in f:
if line == "\n":
continue
namesRead.append(line.rstrip('\n').rstrip().lstrip())
f.close()
return namesRead | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readFile(fileName):\n\tf = open(fileName, 'r')\n\tnames = map(lambda s: s[1:-1], f.read().split(','))\n\tnames.sort()\n\treturn names",
"def load_names(file_name: str) -> List[str]:\n full_path_name = os.path.join(os.getcwd(), 'names', file_name)\n with open(full_path_name, 'r') as file:\n ... | [
"0.66513824",
"0.6637792",
"0.6586358",
"0.6516887",
"0.6475405",
"0.64594156",
"0.64459467",
"0.632488",
"0.62704265",
"0.6254457",
"0.62353885",
"0.62281996",
"0.62062573",
"0.6203571",
"0.6193799",
"0.61811256",
"0.6171002",
"0.6165685",
"0.61483276",
"0.6145361",
"0.61304... | 0.68021345 | 0 |
Method that reads the possible surnames from a file | def readSurnames():
surnamesRead = []
with open("Files/Surnames.txt", 'r', encoding='utf8') as f:
for line in f:
if line == "\n":
continue
surnamesRead.append(line.rstrip('\n').rstrip().lstrip())
f.close()
return surnamesRead | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_surnames(filename):\n result = []\n with open(filename, \"r\") as file:\n for line in file.readlines():\n surname = line.split('\\t')[1]\n result.append(surname)\n return result",
"def _read_names_file(self):\n filename = os.path.join(self.path, 'names.csv')\n... | [
"0.70901465",
"0.6467122",
"0.6426788",
"0.640283",
"0.6300027",
"0.6267863",
"0.62439567",
"0.61844873",
"0.61413",
"0.61241",
"0.6024531",
"0.60224545",
"0.5978379",
"0.59721935",
"0.5935341",
"0.59213847",
"0.5903446",
"0.5901011",
"0.5898721",
"0.58916605",
"0.5885895",
... | 0.7767952 | 0 |
Method that reads the possible vaccines from a file | def readVaccines():
vaccinesRead = []
with open("Files/Vaccines.txt", 'r', encoding='utf8') as vaccine_file:
for vaccine_lines in vaccine_file:
vaccineDetails = vaccine_lines.split(",")
details = []
for vaccineDetail in vaccineDetails:
details.append(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ReadAndTokenize(filename):\n global CACHE\n global VOCABULARY\n if filename in CACHE:\n return CACHE[filename]\n comment = open(filename).read()\n words = Tokenize(comment)\n\n terms = collections.Counter()\n for w in words:\n VOCABULARY[w] += 1\n terms[w] += 1\n\n ... | [
"0.59768933",
"0.5921746",
"0.5887054",
"0.5878683",
"0.5846625",
"0.58407384",
"0.58056444",
"0.5785878",
"0.5751106",
"0.57284236",
"0.5727432",
"0.5689564",
"0.5685143",
"0.56707704",
"0.56541115",
"0.5645458",
"0.5632656",
"0.56321144",
"0.56046677",
"0.55909306",
"0.5571... | 0.71953326 | 0 |
Method that finds all the nodes Person in the data base | def findAllPerson(tx):
query = (
"MATCH (p:Person) "
"RETURN p , ID(p);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_persons(self):\r\n return self.__person_repository.elements",
"def get_people(self):\n cursor = self.cur()\n cursor.execute('SELECT * FROM {tn} '.format(tn=\"person\"))\n all_people = cursor.fetchall()\n return all_people",
"def list_people():\n\n person_list =... | [
"0.7161175",
"0.70688295",
"0.6628899",
"0.6604041",
"0.658471",
"0.65612173",
"0.6507352",
"0.6468968",
"0.6391832",
"0.62645686",
"0.6208956",
"0.61638427",
"0.6148602",
"0.6058281",
"0.6046598",
"0.59861124",
"0.5982131",
"0.5963654",
"0.59491247",
"0.5935303",
"0.5908394"... | 0.7555326 | 0 |
Method that finds all the nodes House in the data base | def findAllHome(tx):
query = (
"MATCH (h:House) "
"RETURN h , ID(h);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findall_nodes(self):\n\n nodes = []\n for n in self.nodes:\n nodes += n.findall_forward()\n\n # Make sure list only contains every element once\n nodes = dict((k,1) for k in nodes)\n self.nodes = list(nodes.keys())\n self.connect_backwards()",
"def select_... | [
"0.62917864",
"0.6276443",
"0.59888303",
"0.5921003",
"0.5874497",
"0.58430326",
"0.5826976",
"0.5783992",
"0.577711",
"0.5747573",
"0.5735488",
"0.572251",
"0.57179743",
"0.5706575",
"0.5700117",
"0.56823605",
"0.56663543",
"0.56605154",
"0.5656091",
"0.56519186",
"0.5634304... | 0.6946899 | 0 |
Method that finds all the nodes Location in the data base | def findAllLocation(tx):
query = (
"MATCH (l:Location) "
"RETURN l , ID(l);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_locations(self):",
"def get_all_locations():\n rs = run_query('''select * from zlrz_office_location''')\n return [] if rs is None else list(map(lambda t: Location(t[1], t[2], t[3], t[4], t[5], t[0]), rs))",
"def locations(self):\n return self.data.get(\"locations\", [])",
"def create... | [
"0.774577",
"0.6802821",
"0.67363733",
"0.6704429",
"0.67019314",
"0.66809297",
"0.66094553",
"0.6573647",
"0.6573647",
"0.6573647",
"0.6573647",
"0.6573647",
"0.6573647",
"0.6573647",
"0.6506568",
"0.6504786",
"0.6484652",
"0.6475976",
"0.64413804",
"0.63739413",
"0.62944204... | 0.7687341 | 1 |
Method that finds all the nodes Vaccine in the data base | def findAllVaccine(tx):
query = (
"MATCH (v:Vaccine) "
"RETURN v , ID(v);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findAllGetVaccineRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:GET_VACCINE]->(n2:Vaccine) \"\n \"RETURN ID(n1) , r , r.date , r.country , r.expirationDate , ID(n2);\"\n )\n results = tx.run(query).data()\n return results",
"def listVrayNodes():\r\n return [node.name() f... | [
"0.6894898",
"0.6524139",
"0.6447016",
"0.6415178",
"0.6214899",
"0.61830765",
"0.611974",
"0.6066176",
"0.6058976",
"0.6056742",
"0.60356337",
"0.5981315",
"0.59691083",
"0.593374",
"0.59108174",
"0.58802783",
"0.5873629",
"0.5873455",
"0.58573043",
"0.5813888",
"0.5751181",... | 0.75888234 | 0 |
Method that finds all the nodes Test in the data base | def findAllTest(tx):
query = (
"MATCH (t:Test) "
"RETURN t , ID(t);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNodeTests():\n\n nodeTestsQuery = NodeTest.query.all()\n \n if nodeTestsQuery: \n nodeTestList = []\n for nodeTestQuery in nodeTestsQuery:\n nodeTestList.append(nodeTestQueryToObject(nodeTestQuery))\n return nodeTestList\n else:\n return None",
"def Lis... | [
"0.77383196",
"0.67398024",
"0.63996077",
"0.6377466",
"0.6319616",
"0.63012266",
"0.62887144",
"0.620618",
"0.61972755",
"0.6186909",
"0.609754",
"0.6096818",
"0.6086778",
"0.60831773",
"0.6025748",
"0.5991007",
"0.5980183",
"0.59563565",
"0.59473395",
"0.5940827",
"0.593546... | 0.71007687 | 1 |
Method that finds all Live relationships in the data base | def findAllLiveRelationships(tx):
query = (
"MATCH (n1:Person)-[r:LIVE]->(n2:House) "
"RETURN ID(n1) , r , ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def findAllGetVaccineRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:GET_VACCINE]->(n2:Vaccine) \"\n \"RETURN ID(n1) , r , r.date , r.country , r.expirationDate , ID(n2);\"\n )\n results = tx.run(query).data()\n return results",
"def findAllVisitRel... | [
"0.6515331",
"0.60994786",
"0.6052908",
"0.5807468",
"0.5803312",
"0.5796571",
"0.56822133",
"0.5633071",
"0.5627949",
"0.5613805",
"0.5611842",
"0.5598031",
"0.55815506",
"0.5552337",
"0.5540224",
"0.5523782",
"0.5501259",
"0.5499945",
"0.54917777",
"0.54587847",
"0.54516184... | 0.7866796 | 0 |
Method that finds all App_Contact relationships in the data base | def findAllAppContactRelationships(tx):
query = (
"MATCH (n1:Person)-[r:APP_CONTACT]->(n2:Person) "
"RETURN ID(n1) , r , r.date , r.hour, ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_contacts(self):\n self.init_db(self._testing)\n\n query = \"SELECT {} FROM {} ORDER BY id;\".format(\", \".join(Contact.columns_with_uid), Contact.table_name)\n\n data = self.db.conn.execute(query)\n\n return [Contact(*item) for item in data]",
"def get_contacts(self):\n ... | [
"0.70344734",
"0.66346985",
"0.6478732",
"0.6478041",
"0.63141716",
"0.62945706",
"0.62855613",
"0.62742424",
"0.62333655",
"0.6192098",
"0.6136291",
"0.61238366",
"0.6116576",
"0.6060181",
"0.60537875",
"0.60507864",
"0.6029192",
"0.60062426",
"0.5840281",
"0.58388346",
"0.5... | 0.75159436 | 0 |
Method that finds all VISIT relationships in the data base | def findAllVisitRelationships(tx):
query = (
"MATCH (n1:Person)-[r:VISIT]->(n2:Location) "
"RETURN ID(n1) , r , r.date , r.start_hour , r.end_hour , ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def findAllLiveRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:LIVE]->(n2:House) \"\n \"RETURN ID(n1) , r , ID(n2);\"\n )\n results = tx.run(query).data()\n return results",
"def relationship_views(self) -> Iterable[RelationshipView]:\n retur... | [
"0.670825",
"0.6381381",
"0.62247133",
"0.5903214",
"0.58438534",
"0.57981044",
"0.5787576",
"0.5742017",
"0.5724101",
"0.57024485",
"0.5691188",
"0.5671603",
"0.56212044",
"0.56135577",
"0.56042075",
"0.55915403",
"0.5561383",
"0.5561318",
"0.55501425",
"0.5537901",
"0.55105... | 0.7115678 | 0 |
Method that finds all GET (a vaccine) relationships in the data base | def findAllGetVaccineRelationships(tx):
query = (
"MATCH (n1:Person)-[r:GET_VACCINE]->(n2:Vaccine) "
"RETURN ID(n1) , r , r.date , r.country , r.expirationDate , ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findAllVaccine(tx):\n query = (\n \"MATCH (v:Vaccine) \"\n \"RETURN v , ID(v);\"\n )\n results = tx.run(query).data()\n return results",
"def relationships(self):",
"def findAllLiveRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:LIVE]->(n2:House) \"\n \"RE... | [
"0.6645363",
"0.6325363",
"0.6189448",
"0.60453117",
"0.6004555",
"0.60038614",
"0.5948619",
"0.58877844",
"0.58489853",
"0.58127844",
"0.5807687",
"0.5766347",
"0.57608616",
"0.57361",
"0.571654",
"0.5715433",
"0.5715096",
"0.56999284",
"0.5696747",
"0.5652339",
"0.56353635"... | 0.7728573 | 0 |
Method that finds all MAKE (a test) relationships in the data base | def findAllMakeTestRelationships(tx):
query = (
"MATCH (n1:Person)-[r:MAKE_TEST]->(n2:Test) "
"RETURN ID(n1) , r , r.date , r.hour , r.result , ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def test_get_relationship_templates(self):\n pass",
"def test_find_relation_types(self):\n pass",
"def get_relations(self):\n triples = list(self.get_triples())\n\n for s, p, o in triples:\n if not p.startswith(\"rel\"):\n s, o... | [
"0.6311003",
"0.59542066",
"0.5882875",
"0.56991184",
"0.56488883",
"0.56313014",
"0.56308293",
"0.56160855",
"0.555243",
"0.5523456",
"0.55009925",
"0.533547",
"0.5330354",
"0.5322995",
"0.52983755",
"0.5294025",
"0.529047",
"0.52874774",
"0.5286571",
"0.5281897",
"0.5259566... | 0.740138 | 0 |
Method that finds all INFECTED relationships in the data base | def findAllInfectedRelationships(tx):
query = (
"MATCH (n1:Person)-[r:COVID_EXPOSURE]->(n2:Person) "
"RETURN ID(n1) , r , r.date , r.name , ID(n2);"
)
results = tx.run(query).data()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def get_all_associations(self):\n return",
"def _all_edges(node: FMVGraphNode) -> Set[FMVGraphEdge]:\n rval = set([e for e in node.edges\n if e.predicate not in skip_fhir_predicates and e.type_node.node not in skip_fhir_types])\n for p in node... | [
"0.6335131",
"0.6312678",
"0.5775378",
"0.57695436",
"0.5733898",
"0.57229775",
"0.57219905",
"0.5700881",
"0.5683474",
"0.5677579",
"0.5643423",
"0.5604486",
"0.5525296",
"0.55013794",
"0.5481556",
"0.544633",
"0.5422407",
"0.5419492",
"0.5403143",
"0.5386868",
"0.53759784",... | 0.66463846 | 0 |
Method that creates the query for the creation of the vaccines node | def createNodeVaccines(vaccinesList):
vaccinesQuery = []
for vaccineEl in vaccinesList:
currentQuery = (
"CREATE (v:Vaccine {name: \"" + str(vaccineEl[int(VaccineAttribute.NAME)]) + "\" , producer: \"" +
str(vaccineEl[int(VaccineAttribute.PRODUCER)]) + "\"}); "
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createGettingVaccine(tx, query, personId, vaccineId, date, country, expDate):\n tx.run(query, personId=personId, vaccineId=vaccineId, date=date, country=country, expDate=expDate)",
"def make_query(self):",
"def createRelationshipsGetVaccine(d, pIds, vIds):\n # Choose how many new visit relationships\... | [
"0.7164774",
"0.5819601",
"0.57299334",
"0.56802905",
"0.54112285",
"0.5248462",
"0.5180487",
"0.51707035",
"0.51623213",
"0.51599586",
"0.5150354",
"0.5147532",
"0.5021065",
"0.49900708",
"0.49644697",
"0.49570605",
"0.4934976",
"0.49241465",
"0.48584074",
"0.478696",
"0.476... | 0.76611483 | 0 |
Method that creates VISIT relationships | def createRelationshipsVisit(d, pIds, lIds):
# Choose how many new visit relationships
numberOfVisits = MAX_NUMBER_OF_VISIT
for _ in range(0, numberOfVisits):
lIndex = randint(0, len(lIds) - 1)
locationId = lIds[lIndex]
pIndex = randint(0, len(pIds) - 1)
personId = pIds[pInd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def _CreateGraph(self):\n self.nodes = []\n self.edges = []\n for i, r in self.airports.set_index('airport_id').iterrows():\n self.nodes.append((i,r.to_dict()))\n for i, r in self.routes.set_index(['src_id','dst_id']).iterrows():\n sel... | [
"0.660073",
"0.5670493",
"0.5551359",
"0.5534307",
"0.55109274",
"0.5472602",
"0.5344431",
"0.5332479",
"0.5324703",
"0.5321007",
"0.5259523",
"0.5253097",
"0.52161443",
"0.52000916",
"0.5184464",
"0.5157209",
"0.513095",
"0.51219463",
"0.511944",
"0.5115102",
"0.5072005",
... | 0.6244256 | 1 |
Method that creates GET vaccine relationships | def createRelationshipsGetVaccine(d, pIds, vIds):
# Choose how many new visit relationships
numberOfVaccines = MAX_NUMBER_OF_VACCINE
for _ in range(0, numberOfVaccines):
vIndex = randint(0, len(vIds) - 1)
vaccineId = vIds[vIndex]
pIndex = randint(0, len(pIds) - 1)
personId =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findAllGetVaccineRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:GET_VACCINE]->(n2:Vaccine) \"\n \"RETURN ID(n1) , r , r.date , r.country , r.expirationDate , ID(n2);\"\n )\n results = tx.run(query).data()\n return results",
"def createGettingVaccine(tx, query, personId, vac... | [
"0.7040181",
"0.6066519",
"0.5884874",
"0.5713347",
"0.56355274",
"0.52946997",
"0.5129973",
"0.5061427",
"0.5022418",
"0.49662134",
"0.49501115",
"0.4892924",
"0.48890257",
"0.48078194",
"0.48069763",
"0.47821605",
"0.47716796",
"0.47676593",
"0.47588113",
"0.4755011",
"0.47... | 0.7255064 | 0 |
Method that creates MAKE test relationships | def createRelationshipsMakeTest(d, pIds, tIds):
# Choose how many new visit relationships
numberOfTest = MAX_NUMBER_OF_TEST
for _ in range(0, numberOfTest):
probability = random()
tIndex = randint(0, len(tIds) - 1)
testId = tIds[tIndex]
pIndex = randint(0, len(pIds) - 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findAllMakeTestRelationships(tx):\n query = (\n \"MATCH (n1:Person)-[r:MAKE_TEST]->(n2:Test) \"\n \"RETURN ID(n1) , r , r.date , r.hour , r.result , ID(n2);\"\n )\n results = tx.run(query).data()\n return results",
"def test_add_relation_types(self):\n pass",
"def test_add_... | [
"0.6820703",
"0.6809778",
"0.67368627",
"0.66004425",
"0.6538386",
"0.6388511",
"0.637721",
"0.63673156",
"0.63041615",
"0.6233009",
"0.6232004",
"0.6227628",
"0.61946553",
"0.6189991",
"0.61586624",
"0.615512",
"0.6111099",
"0.60820246",
"0.6068611",
"0.60661596",
"0.6050781... | 0.69270027 | 0 |
Method that executes the query to create a VISIT relationship | def createVisit(tx, query, personId, locationId, date, startHour, endHour):
tx.run(query, personId=personId, locationId=locationId, date=date, startHour=startHour,
endHour=endHour) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships(self):",
"def createRelationshipsVisit(d, pIds, lIds):\n # Choose how many new visit relationships\n numberOfVisits = MAX_NUMBER_OF_VISIT\n\n for _ in range(0, numberOfVisits):\n lIndex = randint(0, len(lIds) - 1)\n locationId = lIds[lIndex]\n pIndex = randint(0, l... | [
"0.5515213",
"0.5494762",
"0.54500055",
"0.52304965",
"0.4951349",
"0.4898447",
"0.4882028",
"0.4859343",
"0.48130867",
"0.48119572",
"0.47934443",
"0.47831184",
"0.47791302",
"0.47693402",
"0.47674215",
"0.47397813",
"0.47124368",
"0.46955422",
"0.4681213",
"0.46706474",
"0.... | 0.58031064 | 0 |
Method that finds all the positive person | def findAllPositivePerson():
query = (
"""
MATCH (p:Person)-[t:MAKE_TEST{result: \"Positive\"}]->()
WHERE NOT EXISTS {
MATCH (p)-[t2:MAKE_TEST{result: \"Negative\"}]->()
WHERE t2.date > t.date
}
RETURN distinct ID(p) , t.date as infectionDate , t.hour ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_candidates(self) -> list:",
"def _act_find_people(self, global_env):\n # if there are people in this node\n people_in_location = global_env.get_attr(self.location, \"people\")\n if people_in_location > 0:\n print(\"picked up: {} people\".format(people_in_location))\n ... | [
"0.5554053",
"0.5459844",
"0.54469377",
"0.5361949",
"0.53258157",
"0.52789694",
"0.52775156",
"0.5253702",
"0.5251319",
"0.5248255",
"0.5231792",
"0.5211129",
"0.52076685",
"0.5206079",
"0.517138",
"0.5147965",
"0.51300406",
"0.50793165",
"0.5072078",
"0.50638425",
"0.501978... | 0.7193914 | 0 |
Method that deletes exposure for people who made a negative test after a covid exposure | def delete_negative_after_exposure():
query = ("match ()-[c:COVID_EXPOSURE]->(p)-[m:MAKE_TEST{result:\"Negative\"}]->(t) "
"where m.date >= c.date + duration({days: 7}) "
"delete c")
with driver.session() as session:
session.run(query) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_exposure(self, expid):\n\n Exposure.objects.filter(exposure_id=expid).delete()",
"def expense(self):\n del self._expense",
"def test_expense_deletion(self):\n self.register_user()\n result = self.login_user()\n access_token = json.loads(result.data.decode())['acces... | [
"0.6750642",
"0.5988316",
"0.592803",
"0.58590585",
"0.58475167",
"0.58293736",
"0.5802172",
"0.5726755",
"0.57198924",
"0.56072134",
"0.5561569",
"0.543649",
"0.54000187",
"0.53796333",
"0.5374287",
"0.537308",
"0.5327827",
"0.5325508",
"0.5318972",
"0.5311366",
"0.53023356"... | 0.7527944 | 0 |
Method that executes the query to find the infected member of a family | def findInfectInFamily(tx, query, id):
result = tx.run(query, id=id).data()
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def family(self):",
"def load_family_members():\n\n Member.query.delete()\n\n for row in open('data/seed_data_sample_plain'):\n strip_row = row.strip()\n split_row = strip_row.split('|')\n\n member_id = split_row[0].strip()\n\n first_name = split_row[1].strip()\n\n last_n... | [
"0.5857511",
"0.56663436",
"0.5661443",
"0.5598044",
"0.54980147",
"0.5473072",
"0.53622675",
"0.53591436",
"0.52720773",
"0.5226901",
"0.52110434",
"0.52074486",
"0.51369727",
"0.5127439",
"0.51245797",
"0.50654334",
"0.50646216",
"0.5057014",
"0.5038735",
"0.50198334",
"0.5... | 0.6700535 | 0 |
Method that retrieves all the ids of Person Node | def getPersonIds(withApp=False):
with driver.session() as s:
ids = s.write_transaction(getPersonId, withApp)
pIds = []
for idEl in ids:
pIds.append(idEl["ID(p)"])
return pIds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_ids(self):\r\n return self.__person_repository.get_all_ids()",
"def findAllPerson(tx):\n query = (\n \"MATCH (p:Person) \"\n \"RETURN p , ID(p);\"\n )\n results = tx.run(query).data()\n return results",
"def get_person_ids(self) -> np.ndarray:\n return self.p... | [
"0.7406652",
"0.72724056",
"0.7271821",
"0.7182018",
"0.69669974",
"0.6920127",
"0.66888916",
"0.6681467",
"0.65701073",
"0.65534806",
"0.6541458",
"0.635309",
"0.62999123",
"0.6280396",
"0.6258627",
"0.6188425",
"0.61552095",
"0.6140766",
"0.6140766",
"0.61280906",
"0.607504... | 0.75039303 | 0 |
Method that retrieves all the ids of Location Node | def getLocationsIds():
with driver.session() as s:
ids = s.write_transaction(getLocationsId)
lIds = []
for idEl in ids:
lIds.append(idEl["ID(l)"])
return lIds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLocationsId(tx):\n query = (\n \"MATCH (l:Location)\"\n \"RETURN ID(l)\"\n )\n\n idsList = tx.run(query).data()\n return idsList",
"def findAllLocation(tx):\n query = (\n \"MATCH (l:Location) \"\n \"RETURN l , ID(l);\"\n )\n results = tx.run(query).data()\n... | [
"0.7874536",
"0.731527",
"0.7062646",
"0.7016814",
"0.7001121",
"0.6844436",
"0.6793107",
"0.67177343",
"0.6639855",
"0.6492043",
"0.63570356",
"0.6255016",
"0.6224796",
"0.6186398",
"0.61848336",
"0.6168439",
"0.61572087",
"0.613083",
"0.6110458",
"0.6097127",
"0.6097022",
... | 0.7720268 | 1 |
Method that retrieves all the ids of test Node | def getTestsIds():
with driver.session() as s:
ids = s.write_transaction(getTestsId)
tIds = []
for idEl in ids:
tIds.append(idEl["ID(t)"])
return tIds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTestsId(tx):\n query = (\n \"MATCH (t:Test)\"\n \"RETURN ID(t)\"\n )\n\n idsList = tx.run(query).data()\n return idsList",
"def getIDs():",
"def get_node_ids(self):\n \n return self.node_ids",
"def node_ids(self):\n return [self.node_id]",
"def get_ids(... | [
"0.7611002",
"0.74820614",
"0.7343042",
"0.7294262",
"0.7118903",
"0.71014166",
"0.6871869",
"0.6723846",
"0.6703445",
"0.67013633",
"0.66748416",
"0.6674061",
"0.6599396",
"0.65771914",
"0.65442926",
"0.6504613",
"0.63970214",
"0.6373796",
"0.6266002",
"0.6250796",
"0.624607... | 0.7595619 | 1 |
Method use to print the database structure using PlotDBStructure module | def printDatabase():
with driver.session() as s:
personNodes = s.read_transaction(findAllPerson)
houseNodes = s.read_transaction(findAllHome)
locationNodes = s.read_transaction(findAllLocation)
vaccineNodes = s.read_transaction(findAllVaccine)
testNodes = s.read_transaction(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_database_structure(self):\n self.analyze()\n items = []\n for model in get_models():\n names = []\n # for f, m in model._meta.get_fields_with_model():\n for f in model._meta.concrete_fields:\n names.append(f.name)\n items.appe... | [
"0.72862166",
"0.703305",
"0.6886093",
"0.6773256",
"0.67546386",
"0.67323565",
"0.66061884",
"0.65685666",
"0.6563757",
"0.6548127",
"0.65158546",
"0.65069234",
"0.64561975",
"0.6444599",
"0.64432746",
"0.6399927",
"0.6342669",
"0.63025194",
"0.62467486",
"0.6233792",
"0.621... | 0.79304254 | 0 |
Generate PW based on the current state, ie. current chunk, previously computed chunks and the current counter. | def generate_pw(self):
chunks = []
for chunk_no in range(self.CHUNKS):
if chunk_no < self.chunk:
chunks.append(self.verified_chunks[chunk_no])
elif chunk_no == self.chunk:
chunks.append(str(self.counter).zfill(self.PASSWORD_LENGTH /
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def password_generate_complex(self, ctx):\n await ctx.send(\n \"\".join(\n random.choice(string.ascii_letters[:94]) for i in range(random.randint(20, 35))\n )\n )",
"def _generate(self, event):\n N = self.numDigits.GetValue()\n \n if n... | [
"0.63229275",
"0.6210466",
"0.61542976",
"0.6128442",
"0.59861827",
"0.5977954",
"0.58935195",
"0.58218557",
"0.5725991",
"0.56999713",
"0.5637931",
"0.5622442",
"0.5614632",
"0.55738485",
"0.55629945",
"0.5555935",
"0.55490786",
"0.5536461",
"0.5524202",
"0.55031157",
"0.549... | 0.785432 | 0 |
Calculate the delta from the result. Returns a tuple of (delta, confident) Where ``delta`` is either a positive value that has been repeated at the last ``self.confirmations`` times or a negative value indicating an irregular delta. Confident is True if the value also satisfies the extra checks. | def confirm(self, result):
delta = result.source_port - self.last_source_port
self.last_source_port = result.source_port
log.debug("source_port={0}, last_source_port={1}, "
"real_delta={2}".format(
result.source_port, self.last_source_port, delta))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_delta(self):\n rho_des_index, distance, data_size = self.rho_des_index, self.distance, self.data_size\n self.result[rho_des_index[0]][1] = -1\n for i in range(1, data_size):\n for j in range(0, i):\n old_i, old_j = rho_des_index[i], rho_des_index[j]\n ... | [
"0.5485164",
"0.5410988",
"0.53473544",
"0.52948594",
"0.52594554",
"0.5210485",
"0.5185091",
"0.51780695",
"0.51453096",
"0.5131199",
"0.5126392",
"0.51253116",
"0.5115992",
"0.5030006",
"0.5028473",
"0.5013451",
"0.49988964",
"0.49855825",
"0.49762923",
"0.49669504",
"0.496... | 0.62908655 | 0 |
Sends a read request using the specified function byte. Returns a response payload containing the result of the read request; the format of its contents depend on the function byte. | def request_read(self, function_byte: int) -> bytes:
_validate_function_byte(function_byte)
message = [
_BRAVIA_READ_REQUEST_HEADER_BYTE,
_BRAVIA_REQUEST_CATEGORY_BYTE,
function_byte,
0xFF,
0xFF,
]
message.append(_calculate_che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_read_request(file_offset=1, byte_count=MAX_READ):\n return StenoPacket(\n packet_id=StenoPacket.ID_READ,\n p1=file_offset,\n p2=byte_count,\n )",
"def execute_read(function):\n raise NotImplementedError(\"execute_read() has not been implemented\")",
... | [
"0.6297108",
"0.62225974",
"0.6193018",
"0.60892624",
"0.60267603",
"0.5946476",
"0.5598523",
"0.5595243",
"0.5543839",
"0.5540499",
"0.5503857",
"0.5440764",
"0.54234314",
"0.5416054",
"0.5386143",
"0.5382996",
"0.5360565",
"0.5347526",
"0.52887887",
"0.5254913",
"0.5248941"... | 0.820644 | 0 |
Sends a write request using the specified function byte and corresponding payload. Does not return a response. | def request_write(self, function_byte: int, payload: Sequence[int]) -> None:
_validate_function_byte(function_byte)
# Length of the payload plus the checksum
message_length_byte = len(payload) + 1
if message_length_byte > 255:
raise ValueError(
f"Payload is t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_write(function):\n raise NotImplementedError(\"execute_write() has not been implemented\")",
"async def _write(self, unit, address, value, func):\n await self._connect_delay()\n async with self._lock:\n kwargs = {\"unit\": unit} if unit else {}\n await func(... | [
"0.6561378",
"0.62848",
"0.62789536",
"0.6099681",
"0.60418934",
"0.56204706",
"0.56024796",
"0.5577447",
"0.5551332",
"0.5468142",
"0.5419342",
"0.5402256",
"0.53703344",
"0.53703344",
"0.53521544",
"0.5314751",
"0.530274",
"0.5281684",
"0.5278518",
"0.52645814",
"0.5243167"... | 0.76888937 | 0 |
This function uses self.get_state to find the locations of the robot and ball and returns a number in [0, NUM_STATES) representing that state | def get_state_num(self):
robot_state = self.get_state('turtlebot3_waffle_pi','world')
ball_state = self.get_state('soccer_ball','world')
# each object is in a "box" that is RESOLUTION meters wide.
robot_xbox = np.ceil((robot_state.pose.position.x-Learn.FIELD_XLEFT)/Learn.RESOLUTION)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_arr(self):\n rpos = self.sim.getAgentPosition(self.robot_num)\n rvel = self.sim.getAgentVelocity(self.robot_num)\n rrad = self.sim.getAgentRadius(self.robot_num)\n v_pref = self.sim.getAgentMaxSpeed(self.robot_num)\n theta = math.atan2(rvel[1], rvel[0])\n # R... | [
"0.7166662",
"0.6894224",
"0.6861624",
"0.6600041",
"0.6529893",
"0.6403548",
"0.63501287",
"0.63484675",
"0.63344824",
"0.6219632",
"0.61681604",
"0.6102465",
"0.60983646",
"0.60495335",
"0.60495335",
"0.6021469",
"0.599206",
"0.59578645",
"0.59425974",
"0.5925313",
"0.59148... | 0.8323607 | 0 |
Given (x, y) coordinates for the gazebo world, moves the turtlebot to that location using self.set | def set_robot(self, x, y):
state = ModelState()
state.model_name = 'turtlebot3_waffle_pi'
state.reference_frame = 'world'
# pose
state.pose.position.x = x
state.pose.position.y = y
state.pose.position.z = 0
quaternion = tf.transformations.quaternion_from_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto(x, y):\n turtleTmp.setposition(x, y)",
"def set_new_location(self, xPos, yPos):",
"def move_to(self, x, y):\n self.x = x\n self.y = y",
"def move_to(self, x, y):\n self.x = x\n self.y = y",
"def repositionTurtle(t, x, y):\n t.up()\n t.goto(x, y)\n t.down()",... | [
"0.72980785",
"0.68223137",
"0.6769516",
"0.6769516",
"0.6756576",
"0.67504764",
"0.67297053",
"0.6659463",
"0.6652474",
"0.6623022",
"0.6590633",
"0.6578206",
"0.64994663",
"0.649511",
"0.6484023",
"0.6453467",
"0.6437511",
"0.63293874",
"0.6307494",
"0.63042516",
"0.6255841... | 0.68465525 | 1 |
Given an action in (self.MOVE_LEFT, self.STAY_PUT, self.MOVE_RIGHT], performs that action by moving the turtlebot accordingly. | def apply_action(self, action):
robot_state = self.get_state('turtlebot3_waffle_pi','world')
robot_x = robot_state.pose.position.x
robot_y = robot_state.pose.position.y
# Set the distance moved in an action such that it is at least as large as the
# minimum distance that would le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(o, action):\n # if action not in Act: raise...?\n { Act.Down : lambda: o.applyGravity(),\n Act.Left : lambda: o._tryShift(o.block,Point(-1,0)),\n Act.Right : lambda: o._tryShift(o.block,Point( 1,0)),\n Act.Drop : lambda: o._setBlock(o.shadowBlock),\n Act.Hold : lambda: o._Hol... | [
"0.6865788",
"0.68375564",
"0.68262863",
"0.681845",
"0.67499447",
"0.6709733",
"0.6702826",
"0.6600874",
"0.6599175",
"0.65985924",
"0.6597936",
"0.65388536",
"0.65373313",
"0.65184283",
"0.6489433",
"0.6484609",
"0.6464075",
"0.6452269",
"0.64365",
"0.6379417",
"0.6379417",... | 0.7721951 | 0 |
Peform the QLearning algorithm until convergence of self.Q | def algorithm(self):
convergence_threshold = 50
reward_num_threshold = 300
alpha = 1
gamma = 0.5
while (self.reward_num < reward_num_threshold) and (self.count<convergence_threshold):
print('------')
print('Iteration', self.reward_num, '/', reward_num_thre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qlearning(env, iterations=1000, gamma=0.9, alpha=0.1):\n nS = env.nS # number of states\n nA = env.nA # number of actions\n Q_value = np.zeros((nS, nA))\n policy = np.ones((env.nS,env.nA))/env.nA\n epsilon = 1\n s_t1 = env.reset() # reset the environment and place the agent in the start sq... | [
"0.7476597",
"0.7048921",
"0.6965554",
"0.68989587",
"0.6872403",
"0.6778621",
"0.668104",
"0.6651404",
"0.6628057",
"0.6619447",
"0.65897125",
"0.6540257",
"0.65138745",
"0.650373",
"0.6488787",
"0.64733046",
"0.6472302",
"0.6450761",
"0.6444047",
"0.6443331",
"0.6420884",
... | 0.7540043 | 0 |
Get a dictionary containing the total score for ``obj`` and the number of votes it's received. Thus, it can be used to calculate the best rated objects in a very simplified scale. This isn't a very good rating function right now, because an object that has got a lot of up and downvotes is a reflection of its popularity... | def get_score(self, obj):
content_type = ContentType.objects.get_for_model(obj)
result = self.filter(content_type=content_type,
object_id=obj._get_pk_val()).aggregate(
score=Sum('vote'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score(self, obj):\n ctype = ContentType.objects.get_for_model(obj)\n result = self.filter(object_id=obj._get_pk_val(),\n content_type=ctype).extra(\n select={\n 'score': 'COALESCE(SUM(vote), 0)',\n 'num_votes': 'COALESCE(COU... | [
"0.81031865",
"0.79285175",
"0.6855811",
"0.67928356",
"0.6763918",
"0.6228135",
"0.61716664",
"0.59057057",
"0.5784851",
"0.5742161",
"0.5692605",
"0.5655364",
"0.5652737",
"0.56520414",
"0.5641303",
"0.5590621",
"0.5585837",
"0.5560485",
"0.5549761",
"0.55324996",
"0.551647... | 0.80732733 | 1 |
Record a user's vote on a given object. Only allows a given user to vote once, though that vote may be changed. A zero vote indicates that any existing vote should be removed. | def record_vote(self, obj, vote, user):
if vote not in (+1, 0, -1):
raise ValueError('Invalid vote (must be +1/0/-1)')
content_type = ContentType.objects.get_for_model(obj)
# First, try to fetch the instance of this row from DB
# If that does not exist, then it is the first t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_vote(self, obj, user, vote):\r\n if vote not in (+1, 0, -1):\r\n raise ValueError('Invalid vote (must be +1/0/-1)')\r\n ctype = ContentType.objects.get_for_model(obj)\r\n try:\r\n v = self.get(user=user, content_type=ctype,\r\n object_id... | [
"0.85912955",
"0.80805624",
"0.70674664",
"0.68415457",
"0.6664023",
"0.65120435",
"0.6498817",
"0.648873",
"0.6425544",
"0.6396006",
"0.6346099",
"0.6249975",
"0.6247208",
"0.61925924",
"0.61074173",
"0.60815287",
"0.60402983",
"0.6006947",
"0.59739923",
"0.59494007",
"0.591... | 0.8415383 | 1 |
Get the top N scored objects for a given model. Yields (object, score) tuples. | def get_top(self, model, limit=10, inverted=False):
content_type= ContentType.objects.get_for_model(model)
#Get a queryset of all the objects of the model. Get their scores
results = self.filter(content_type=content_type).values('object_id').annotate(score=Sum('vote'))
if inverted:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top(self, Model, limit=10, reversed=False):\n ctype = ContentType.objects.get_for_model(Model)\n query = \"\"\"\n SELECT object_id, SUM(vote) as %s\n FROM %s\n WHERE content_type_id = %%s\n GROUP BY object_id\"\"\" % (\n connection.ops.quote_name('score'... | [
"0.6620148",
"0.6568486",
"0.6029523",
"0.5966627",
"0.5958777",
"0.588728",
"0.57843107",
"0.57750875",
"0.5712884",
"0.5682572",
"0.5677662",
"0.5639743",
"0.5635089",
"0.5624442",
"0.5623601",
"0.55735147",
"0.5531635",
"0.5519599",
"0.55086815",
"0.5506289",
"0.5492053",
... | 0.7162024 | 0 |
Get the vote made on the given object by the given user, or ``None`` if no matching vote exists. | def get_for_user(self, obj, user):
if not user.is_authenticated:
return None
content_object = ContentType.objects.get_for_model(obj)
try:
vote = self.get(voter=user, content_type=content_object, object_id=obj._get_pk_val())
except ObjectDoesNotExist:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_for_user(self, obj, user):\n if not user.is_authenticated():\n return None\n ctype = ContentType.objects.get_for_model(obj)\n try:\n vote = self.get(content_type=ctype, object_id=obj._get_pk_val(),\n user=user)\n except models.Obj... | [
"0.83463514",
"0.8317188",
"0.75515354",
"0.71140134",
"0.6328592",
"0.6223597",
"0.6184133",
"0.6064872",
"0.5983577",
"0.59810215",
"0.59462565",
"0.58576053",
"0.58417827",
"0.57884955",
"0.5786087",
"0.57498264",
"0.5686267",
"0.5686267",
"0.5666457",
"0.5636173",
"0.5636... | 0.8563331 | 0 |
Gets the number of upvotes made on the object by all users | def get_upvotes(self, obj):
content_type = ContentType.objects.get_for_model(obj)
votes = self.filter(content_type=content_type, object_id=obj._get_pk_val(), vote__exact=UPVOTE).aggregate(upvotes=Sum('vote'))
if votes['upvotes'] is None:
votes['upvotes'] = 0
return votes['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_upvotes(self):\n return self.filter(value=1).count()",
"def get_total_upvotes(self, suggestions, main_suggestion):\n total_upvoted_users = main_suggestion.upvoted_users.all()\n for suggestion in suggestions.all():\n total_upvoted_users |= suggestion.upvoted_users.all()\n... | [
"0.8053709",
"0.7087659",
"0.6881225",
"0.6833426",
"0.6637999",
"0.6490542",
"0.6454659",
"0.63448167",
"0.63270116",
"0.631257",
"0.62989783",
"0.6298624",
"0.62497115",
"0.6242473",
"0.62353253",
"0.6199192",
"0.61926293",
"0.61874974",
"0.61717516",
"0.6157083",
"0.611163... | 0.80163234 | 1 |
Gets the number of downvotes on the object by all users | def get_downvotes(self, obj):
content_type = ContentType.objects.get_for_model(obj)
votes = self.filter(content_type=content_type, object_id=obj._get_pk_val(), vote__exact=DOWNVOTE).aggregate(downvotes=Sum('vote'))
if votes['downvotes'] is None:
votes['downvotes'] = 0
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_downvotes(self):\n return self.filter(value=-1).count()",
"def count_upvotes(self):\n return self.filter(value=1).count()",
"def get_upvotes(self, obj):\n content_type = ContentType.objects.get_for_model(obj)\n\n votes = self.filter(content_type=content_type, object_id=obj... | [
"0.762536",
"0.6708461",
"0.6653797",
"0.6466711",
"0.6283814",
"0.59941554",
"0.5965759",
"0.5957265",
"0.59383214",
"0.58846676",
"0.58008784",
"0.5792616",
"0.5792616",
"0.5763257",
"0.5761557",
"0.5698882",
"0.5678017",
"0.5666268",
"0.5663854",
"0.56521255",
"0.5651946",... | 0.7843331 | 0 |
Append additional fields to the self.list_display. | def get_list_display(self, request):
list_display = self.list_display
if 'admin_created' not in list_display:
list_display += ('admin_created', )
if 'admin_modified' not in list_display:
list_display += ('admin_modified', )
return list_display | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_display(self, request):\n delete = partial(self.remove, request=request)\n delete.short_description = \"\"\n delete.allow_tags = True\n list_display = list(self.list_display)\n for index, field_name in enumerate(list_display):\n field = getattr(self.model,... | [
"0.6392549",
"0.6073667",
"0.6061075",
"0.59967446",
"0.5952772",
"0.587858",
"0.57881814",
"0.57162535",
"0.5623907",
"0.55740386",
"0.556877",
"0.5475366",
"0.54707587",
"0.5459969",
"0.54526514",
"0.54518634",
"0.54348624",
"0.5419972",
"0.5400993",
"0.5349254",
"0.5331610... | 0.6505207 | 0 |
Ask the user if he wants to reboot and use adhoc reboot command | def choose_reboot():
while True:
choice = input("Would you like to reboot now ? [y\\N] ")
if choice.lower() == 'n' or choice == '':
return
elif choice.lower() == 'y':
break
else:
continue
if os.name == 'nt':
call('shutdown /r /t 00')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def system_reboot(self):\n confirmation = input(\"Do you want to reboot the camera? (Y or N)\\n\")\n if confirmation in ('Y', 'y'):\n return self.mycam.devicemgmt.SystemReboot()\n return None",
"def reboot(self,request):\n\t\tresult = True\n\t\tPopen(['/sbin/reboot']) # that's all... | [
"0.7725278",
"0.7503559",
"0.7453776",
"0.73682946",
"0.7227929",
"0.7211871",
"0.7188908",
"0.717906",
"0.7136062",
"0.7126615",
"0.69618595",
"0.6878219",
"0.683283",
"0.6796591",
"0.67501",
"0.67242324",
"0.66379255",
"0.66211015",
"0.66104424",
"0.6596329",
"0.645953",
... | 0.80323696 | 0 |
Returns a list of 25 random tweets from the authenticated user's lists. | def grab_tweets():
tweets = []
long_tweets = []
for each in lists:
tweets = tweets + twitter.GetListTimeline(list_id=each.id,
count=count,
include_rts=True)
for tweet in tweets:
if len(t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_tweets():\n tweets = []\n tuples = query_db('''\n select message.*, user.* from message, user\n where message.author_id = user.user_id\n order by message.pub_date desc limit ?''', [PER_PAGE])\n for tuple in tuples:\n tweet = {}\n tweet[\"username\"] = tuple['use... | [
"0.72753966",
"0.6963853",
"0.695688",
"0.6755268",
"0.6748927",
"0.67321634",
"0.67147475",
"0.6649648",
"0.6629068",
"0.661428",
"0.65991986",
"0.657056",
"0.6557654",
"0.65160143",
"0.64997166",
"0.6480752",
"0.64145756",
"0.6398489",
"0.6357325",
"0.6351",
"0.6348374",
... | 0.7435396 | 0 |
Returns a single randomly selected tweet. | def choose_tweet(pos_tweets):
tweet = choice(pos_tweets)
return tweet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler(event, context):\n send_tweet(random.choice(potential_tweets))",
"def handler(event, context):\n send_tweet(random.choice(potential_tweets))",
"def handler(event,context):\n send_tweet(random.choice(potential_tweets))",
"def mock_tweet():\n count = random.randint(70, 140)\n return ... | [
"0.69579417",
"0.69579417",
"0.69258714",
"0.6577981",
"0.63306475",
"0.6282631",
"0.6218992",
"0.6208195",
"0.6181834",
"0.6129136",
"0.61065483",
"0.60549045",
"0.6049556",
"0.60462",
"0.6039426",
"0.6018565",
"0.5995151",
"0.59862554",
"0.59862554",
"0.59862554",
"0.597905... | 0.7728843 | 0 |
Authenticated user likes all tweets in pos_tweets. | def like_tweets(pos_tweets):
for tweet in pos_tweets:
twitter.CreateFavorite(status_id=tweet.id)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def like_tweet(self, tag):\n self.bot.get('https://twitter.com/search?q=' + tag + '&src=typed')\n self.__wait(3, 3)\n for i in range(1, 3):\n self.bot.execute_script('window.scrollTo(0,document.body.scrollHeight)')\n self.__wait(2, 3)\n tweets = self.bot.find_eleme... | [
"0.64643073",
"0.6083664",
"0.60599387",
"0.59699297",
"0.5918097",
"0.5902641",
"0.58915097",
"0.57170844",
"0.56932944",
"0.56672335",
"0.56636506",
"0.56403744",
"0.5627154",
"0.562145",
"0.56145626",
"0.55933243",
"0.5592352",
"0.5581902",
"0.5573323",
"0.5570764",
"0.556... | 0.79324496 | 0 |
Authenticated user retweets tweet. | def retweet(tweet):
twitter.PostRetweet(tweet.id, trim_user=False)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retweet(tweet_id):\n r = requests.post(twitter_api_base + \"/statuses/retweet/\" +\n tweet_id + \".json\",\n auth=oauth_credentials)\n if r.status_code != 200:\n print(\"Attempted to retweet tweet %s\" % tweet_id)\n received_error(r)\n else:\n print(\"Success... | [
"0.66826576",
"0.66580725",
"0.664445",
"0.6615652",
"0.6569027",
"0.6567879",
"0.6546092",
"0.65177256",
"0.65040976",
"0.6480737",
"0.645635",
"0.64364004",
"0.6425227",
"0.64131695",
"0.6408457",
"0.63748854",
"0.63633084",
"0.63615364",
"0.63195086",
"0.63195086",
"0.6319... | 0.76832384 | 0 |
Wrap an html code str inside a div. | def add_div_around_html(div_html_text, output_string=False, div_style="{width: 80%}"):
div = f"""<div style="{div_style}">{div_html_text}</div>"""
if output_string:
return div
#get_ipython().set_next_input(div, 'markdown')
else:
return Markdown(div) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_div(string, cls):\n return html_simple_element(string, \"div\", 'class=\"%s\"' % cls) + \"\\n\"",
"def get_html(html: str):\r\n WRAPPER = \"\"\"<div style=\"overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem\">{}</div>\"\"\"\r\n # Newlines ... | [
"0.68858933",
"0.67504036",
"0.6205391",
"0.6190861",
"0.5886693",
"0.58730954",
"0.5765113",
"0.56943285",
"0.568877",
"0.56636864",
"0.5630165",
"0.55836976",
"0.5572767",
"0.5570544",
"0.5496482",
"0.5484527",
"0.5480989",
"0.5466087",
"0.5461017",
"0.5433532",
"0.5414356"... | 0.72967833 | 0 |
Update base branch and rebase topic branch. | def update_base_branch(self):
# Make sure base branch is up to date
print("Checking out base branch '{}'...".format(self.base_branch))
self.git.checkout(self.base_branch)
print('Updating base branch...')
self.git.pull('--rebase') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebase_topic_branch_and_push(self):\n # Rebase topic branch\n print('Checking out topic branch..')\n self.git.checkout(self.topic_branch)\n print('Updating topic branch with work from base branch...')\n self.git.rebase(self.base_branch)\n\n # Push rebased version (so i... | [
"0.85658085",
"0.6386416",
"0.6250974",
"0.6157709",
"0.607403",
"0.603884",
"0.60378253",
"0.5953686",
"0.5821291",
"0.57876724",
"0.5657849",
"0.56300837",
"0.5626506",
"0.54639095",
"0.5381909",
"0.53807336",
"0.5374803",
"0.53547436",
"0.5313713",
"0.5183402",
"0.5182366"... | 0.79265606 | 1 |
Create topic branch locally and remotely. | def create_topic_branch(self, topic_branch_name):
print("Creating topic branch locally...")
self.git.checkout(self.base_branch)
self.git.checkout('-b', topic_branch_name)
print("Pushing topic branch to base branch's remote...")
self.git.push('-u', self.base_branch_remote(), topic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(github_token, branch_name, repository, sha):\n create_branch(github_token, branch_name, repository, sha)\n click.echo(f\"Successfully created branch {branch_name}\")",
"def create_branch(self):\n os.chdir(str(self.repository_path))\n sh.git.checkout('master')\n sh.git.checkout... | [
"0.6686283",
"0.6487901",
"0.6256341",
"0.6225223",
"0.6147443",
"0.609922",
"0.6061899",
"0.60441536",
"0.5970918",
"0.591403",
"0.59020525",
"0.5832282",
"0.5827752",
"0.58189726",
"0.5775379",
"0.5697713",
"0.5670031",
"0.5617806",
"0.5587961",
"0.5563945",
"0.55238813",
... | 0.8445331 | 0 |
Return name of active branch. | def active_branch(self):
return self.repo.active_branch.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_branch_name(self):\n # type: () -> Optional[str]\n branch = self.get_current_branch()\n if branch:\n return branch.name\n return None",
"def branch_name(self):\n return f'phab-diff-{self.diff_id}'",
"def branch(self):\n return os.popen('git r... | [
"0.8120284",
"0.7759571",
"0.77387923",
"0.76723415",
"0.7610565",
"0.75223535",
"0.7266739",
"0.7229904",
"0.71897435",
"0.7162496",
"0.7041211",
"0.7009984",
"0.6989085",
"0.69307643",
"0.6906568",
"0.6906568",
"0.6826007",
"0.6765414",
"0.672135",
"0.67150354",
"0.66725886... | 0.87727827 | 0 |
Check whether a branch exists locally in the current repository. | def local_branch_exists(self, branch):
return branch in self.repo.branches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_exists(repo, branch, remote=False):\n ref = 'refs/remotes/origin/' + branch if remote else 'refs/heads/' + branch\n return subprocess.call(['git', 'show-ref', '-q', '--verify', ref],\n cwd=repo) == 0",
"def branch_exists(branch):\n\n try:\n git('show-ref', bra... | [
"0.83275986",
"0.8276479",
"0.81830424",
"0.8062521",
"0.79845",
"0.7687554",
"0.7388475",
"0.7297498",
"0.69419837",
"0.68392557",
"0.6772355",
"0.6571662",
"0.6411818",
"0.6379329",
"0.6296787",
"0.6248183",
"0.6241988",
"0.5957182",
"0.5877177",
"0.58717155",
"0.58352304",... | 0.86900705 | 0 |
Return remote of base branch. | def base_branch_remote(self):
return self.git.config('--get', 'branch.{}.remote'.format(self.base_branch)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gitlab_remote(self):\n return self.get_remote('gitlab')",
"def get_git_upstream_remote():\n cmd = \"git remote get-url upstream\"\n if run_cmd(cmd):\n return \"upstream\"\n else:\n return \"origin\"",
"def git_remote_url(self):\n return self._git_remote_url",
"def... | [
"0.68245757",
"0.67746514",
"0.674733",
"0.6530229",
"0.6530024",
"0.6505973",
"0.64553195",
"0.64203966",
"0.64174384",
"0.63947403",
"0.6328345",
"0.6312695",
"0.63110465",
"0.6287203",
"0.62429124",
"0.6184216",
"0.61142975",
"0.6098868",
"0.6066217",
"0.60564506",
"0.6037... | 0.87765974 | 0 |
Create topic branch merge helper instance. | def __init__(self, base_branch, topic_branch=None, delete_local=False):
super(TopicMerge, self).__init__(base_branch)
self.topic_branch = topic_branch
self.delete_local = delete_local
if not topic_branch:
self.topic_branch = self.active_branch()
print("Using act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_topic_branch(self, topic_branch_name):\n print(\"Creating topic branch locally...\")\n self.git.checkout(self.base_branch)\n self.git.checkout('-b', topic_branch_name)\n print(\"Pushing topic branch to base branch's remote...\")\n self.git.push('-u', self.base_branch_r... | [
"0.6248353",
"0.5955853",
"0.5725158",
"0.56283575",
"0.5605361",
"0.5596414",
"0.5378078",
"0.53646255",
"0.53271574",
"0.5255284",
"0.52101886",
"0.51747125",
"0.5091524",
"0.50761956",
"0.50503206",
"0.50297374",
"0.5002231",
"0.49973628",
"0.4993629",
"0.49935707",
"0.498... | 0.69020957 | 0 |
Rebase topic branch with work from base branch and push. | def rebase_topic_branch_and_push(self):
# Rebase topic branch
print('Checking out topic branch..')
self.git.checkout(self.topic_branch)
print('Updating topic branch with work from base branch...')
self.git.rebase(self.base_branch)
# Push rebased version (so it'll get mar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_topic_branch(self, topic_branch_name):\n print(\"Creating topic branch locally...\")\n self.git.checkout(self.base_branch)\n self.git.checkout('-b', topic_branch_name)\n print(\"Pushing topic branch to base branch's remote...\")\n self.git.push('-u', self.base_branch_r... | [
"0.67438114",
"0.6672996",
"0.65347326",
"0.6462883",
"0.6459222",
"0.618939",
"0.6010252",
"0.56230044",
"0.5605947",
"0.55762273",
"0.5462592",
"0.5313506",
"0.5272005",
"0.5262014",
"0.5259698",
"0.52522224",
"0.52197486",
"0.51008797",
"0.5083094",
"0.50617796",
"0.504515... | 0.9047255 | 0 |
Merge topic branch then delete remotely and, optionally, locally. | def merge_and_cleanup(self):
print('Checking out base branch and merging topic branch...')
self.git.checkout(self.base_branch)
self.git.merge('--ff-only', self.topic_branch)
# Push merge and delete topic branch
print('Pushing base branch with topic branch merged...')
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_out_topic_branch_from_remote(self):\n self.git.checkout('-b', self.topic_branch, '{}/{}'.format(self.base_branch_remote(), self.topic_branch))",
"def __gitDeleteBranch(self):\n self.vcs.gitDeleteRemoteBranch(self.project.getProjectPath())",
"def delete_remote():\n branch = git.curren... | [
"0.6874943",
"0.6639755",
"0.6599267",
"0.62721497",
"0.61086285",
"0.60286224",
"0.58906126",
"0.58730567",
"0.5793986",
"0.5737783",
"0.5683312",
"0.56208444",
"0.5504748",
"0.54956734",
"0.5470647",
"0.53895134",
"0.5362018",
"0.52970517",
"0.5293758",
"0.528265",
"0.52308... | 0.78640497 | 0 |
Check out local version of topic branch. | def check_out_topic_branch_from_remote(self):
self.git.checkout('-b', self.topic_branch, '{}/{}'.format(self.base_branch_remote(), self.topic_branch)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout(branch=\"lf-dev\"):\n with cd(FOLDER):\n sudo('git fetch', user='tomcat')\n sudo('git checkout %s' % branch, user='tomcat')\n status()",
"def checkout_latest():\n with cd(env.repo_path):\n run('git checkout %(branch)s;' % env)\n run('git pull origin %(branch)... | [
"0.6593687",
"0.6444415",
"0.6442575",
"0.6345166",
"0.6301744",
"0.6256093",
"0.62468576",
"0.616578",
"0.616578",
"0.61320764",
"0.6116163",
"0.6076133",
"0.6060944",
"0.59473294",
"0.58994496",
"0.5847794",
"0.57866263",
"0.577557",
"0.57550055",
"0.57492787",
"0.5731519",... | 0.7610128 | 0 |
Check whether a branch exists remotely using base branch's origin. | def remote_branch_exists(self, branch):
try:
self.git.show_ref("refs/remotes/{}/{}".format(self.base_branch_remote(), branch))
return True
except git.exc.GitCommandError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_exists(repo, branch, remote=False):\n ref = 'refs/remotes/origin/' + branch if remote else 'refs/heads/' + branch\n return subprocess.call(['git', 'show-ref', '-q', '--verify', ref],\n cwd=repo) == 0",
"def branch_exists(branch_name, local_only=False, directory=None):\n... | [
"0.7808668",
"0.73967373",
"0.73148525",
"0.73089",
"0.72829074",
"0.72582304",
"0.6801348",
"0.65513825",
"0.64167774",
"0.6403177",
"0.63310564",
"0.6277862",
"0.61876816",
"0.61740935",
"0.6012397",
"0.59845227",
"0.5948855",
"0.59156495",
"0.58973765",
"0.58918685",
"0.57... | 0.81284404 | 0 |
Return Git log output for unmerged commits. | def unmerged_log(self):
return self.git.log('{}..{}'.format(self.base_branch, self.topic_branch)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_unmerged(unmerged):\n _report_files('unmerged', unmerged)",
"def get_commit_message():\n return shell_output('git log HEAD -1 --pretty=%B')",
"def last_commit_short_log():\n subprocess.check_output('git log -1 --pretty=format:%h:%s'.split()).decode()",
"def ignore_merged_commits(self):\n ... | [
"0.605089",
"0.5828341",
"0.5793173",
"0.5702663",
"0.55771744",
"0.55349654",
"0.5473056",
"0.5455185",
"0.54213625",
"0.53958446",
"0.53584856",
"0.529324",
"0.52550614",
"0.5119616",
"0.50683516",
"0.5061825",
"0.50409853",
"0.5032785",
"0.5018177",
"0.5006762",
"0.5002617... | 0.80632204 | 0 |
Return number of unmerged commits. | def unmerged_total(self):
return int(self.git.rev_list('--count', '{}..{}'.format(self.base_branch, self.topic_branch))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_git_commiter_count(path):\n process = subprocess.Popen(['git', 'shortlog', '-sn'], cwd=path, stdout=subprocess.PIPE)\n stdout, _ = process.communicate()\n committers = stdout.decode(\"ISO-8859-1\")\n return len(committers.split('\\n'))",
"def get_commit_count():\n if COMMIT_COUNT is None:\... | [
"0.6773051",
"0.6740454",
"0.6568362",
"0.6104326",
"0.60325164",
"0.59609437",
"0.5774543",
"0.56423247",
"0.56212234",
"0.56212234",
"0.5621026",
"0.53949195",
"0.5394291",
"0.539106",
"0.5321197",
"0.5314997",
"0.5308237",
"0.5281387",
"0.52706915",
"0.52404267",
"0.522989... | 0.75320995 | 0 |
Get the current datetime (UTC+0). The accuracy is limited to milliseconds and the remaining microseconds are cleared. | def now() -> datetime:
now = datetime.now(tz=timezone.utc)
return now.replace(microsecond=now.microsecond - now.microsecond % 1000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nowUTC():\n return datetime.datetime.now(pytz.utc)",
"def now_utc() -> datetime:\n return datetime.now(timezone.utc)",
"def datetime_utc_now() -> datetime:\n return datetime.now(timezone.utc)",
"def _get_now():\n return datetime.now(tz=timezone.utc)",
"def get_now():\n return dt.datetime... | [
"0.7628507",
"0.75773877",
"0.7516025",
"0.751259",
"0.74952275",
"0.73824656",
"0.73744327",
"0.7368627",
"0.73526394",
"0.7349973",
"0.7315829",
"0.7300803",
"0.72711504",
"0.7261088",
"0.7256142",
"0.72537535",
"0.7203686",
"0.7187088",
"0.7187088",
"0.71670175",
"0.715320... | 0.82576597 | 0 |
Get a datetime (UTC+0) from a given representation. | def from_string(representation: str) -> datetime:
return parse(representation).replace(tzinfo=timezone.utc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _epoch_utc_to_datetime(epoch_utc):\n return datetime.fromtimestamp(epoch_utc)",
"def FromNowUTC(cls):\n t = pytime.time()\n utcTime = pytime.gmtime(t)\n return cls.FromStructTime(utcTime).WithZone(zDirection=0)",
"def convert_utc(utc) -> dt.datetime:\n return iso8601.parse_da... | [
"0.6436676",
"0.63259554",
"0.6290457",
"0.6282037",
"0.6262281",
"0.61762154",
"0.61416876",
"0.6114463",
"0.60666364",
"0.5983876",
"0.5970409",
"0.595779",
"0.59017533",
"0.58899635",
"0.5870173",
"0.5864908",
"0.5840024",
"0.58342457",
"0.57807434",
"0.57765967",
"0.57617... | 0.7052922 | 0 |
Update NLPIR license file if it is outofdate or missing. | def update_license_file(data_dir):
license_file = os.path.join(data_dir, LICENSE_FILENAME)
temp_dir = tempfile.mkdtemp()
gh_license_filename = os.path.join(temp_dir, LICENSE_FILENAME)
try:
_, headers = urlretrieve(LICENSE_URL, gh_license_filename)
except IOError as e:
# Python 2 uses... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_frozen_license() -> int:\n srcpath = Path(\"doc/src/license.rst\")\n dstpath = Path(\"cx_Freeze/initscripts/frozen_application_license.txt\")\n try:\n content = srcpath.read_text(encoding=\"utf-8\")\n except OSError:\n print(ERROR1, file=sys.stderr)\n return 1\n conte... | [
"0.61703426",
"0.5742456",
"0.5672786",
"0.5615723",
"0.5595802",
"0.55362254",
"0.54463863",
"0.5431519",
"0.5422802",
"0.53913784",
"0.53868955",
"0.53640527",
"0.5349856",
"0.5262421",
"0.5235656",
"0.52349484",
"0.5227492",
"0.5205454",
"0.51876825",
"0.51652694",
"0.5161... | 0.63965 | 0 |
Find rhombus from a contour If shape is not found, return none and unidentified string | def detect_rhombus(approx):
max_length_diff = Rhombuses.get_max_length_diff_in_quad(approx)
if max_length_diff > Rhombuses.MAX_SIDE_LENGTH_DIFF:
return None, Shapes.UNIDENTIFIED_SHAPE
return approx, Shapes.RHOMBUS_SHAPE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_shape(contour):\n # Initialize the shape name and approximate the contour\n shape = \"unidentified\"\n peri = cv2.arcLength(contour, True)\n approx = cv2.approxPolyDP(contour, 0.04 * peri, True)\n if len(approx) == 3:\n shape = \"triangle\"\n if len(a... | [
"0.6477798",
"0.6227886",
"0.61438435",
"0.5769389",
"0.55741864",
"0.55740094",
"0.5542627",
"0.54590064",
"0.5348797",
"0.5329123",
"0.52930325",
"0.52622515",
"0.52615017",
"0.5233085",
"0.5198105",
"0.5196476",
"0.51726085",
"0.51662135",
"0.51260275",
"0.51097596",
"0.50... | 0.66473997 | 0 |
Draw idxth rhombus on image | def __draw_rhombus(img, rhombus):
for i, point in enumerate(rhombus):
p1 = tuple(rhombus[i][0])
p2 = tuple(rhombus[(i+1) % 4][0])
cv2.line(img, p1, p2, color=(29, 131, 255), thickness=2)
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, img, idx=None):\n if idx is None:\n for rhombus in self.rhombuses:\n img = self.__draw_rhombus(img, rhombus)\n else:\n img = self.__draw_rhombus(img, self.rhombuses[idx])\n\n return img",
"def draw_rhombus(self, screen):\n pygame.gfx... | [
"0.6799747",
"0.60946214",
"0.58650184",
"0.57785463",
"0.577379",
"0.56593394",
"0.56519073",
"0.56368244",
"0.5629976",
"0.5611365",
"0.5590604",
"0.55857366",
"0.55807704",
"0.55708385",
"0.55639386",
"0.5496588",
"0.5472634",
"0.5464442",
"0.5405881",
"0.53580445",
"0.535... | 0.7903363 | 0 |
Find leftmost, rightmost, uppermost, and bottommost point of a quadrilateral and count maximum length between points as a rhombus | def get_max_length_diff_in_quad(points):
leftmost, uppermost, rightmost, bottommost = (points[0, 0] for i in range(4))
for point in points:
x = point[0, 0]
y = point[0, 1]
if x < leftmost[0]:
# Point is located on the left side of leftmost point
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_quadrature_points(self) -> int:",
"def getIndividualTopLengths(self):\n nquad = self.getNumQuads()\n lengths = np.zeros(nquad)\n for i in range(nquad):\n P0, P1, P2, P3 = self._quadrilaterals[i]\n p0 = Vector.fromPoint(P0)\n p1 = Vector.fromPoint(P1)\... | [
"0.610899",
"0.59568053",
"0.5939055",
"0.5891226",
"0.5877208",
"0.58417696",
"0.5826405",
"0.58173084",
"0.5798544",
"0.57555825",
"0.57455087",
"0.57285994",
"0.57191706",
"0.5711928",
"0.5706906",
"0.5703597",
"0.56971043",
"0.56840116",
"0.56803584",
"0.56797194",
"0.567... | 0.70866054 | 0 |
Utility method to build a the PayPal Pay request for starting the transaction process. The response will contain a payKey that will be used when we redirect the user to PayPal to complete the transaction. | def create_pay_request(donation_amount, charities):
# Try to split the donation amount equally amount all charities
l = len(charities)
split_amount = round(donation_amount/l, 2)
# Test that the amount was equally split. If it's not we must
# adjust one of the split amounts to make the sum of the d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_complete_request_body():\n return \\\n {\n \"intent\": \"sale\",\n \"payer\": {\n \"payment_method\": \"paypal\"},\n \"redirect_urls\": {\n \"return_url\": \"http://localhost:3000/payment/execute\",\n ... | [
"0.6602312",
"0.6058661",
"0.60280204",
"0.5872931",
"0.5825171",
"0.5807506",
"0.56765485",
"0.56448203",
"0.56400335",
"0.55968016",
"0.55442744",
"0.54821205",
"0.54804116",
"0.5471226",
"0.5407815",
"0.54046965",
"0.5371241",
"0.53533983",
"0.5271067",
"0.5269766",
"0.525... | 0.6259245 | 1 |
Utility method to retrieve the payKey from a PayPal response | def get_pay_key(response):
return response.get("payKey") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_key_from_response(response: requests.models.Response) -> str:\n api_key = None\n for line in response.text.splitlines():\n if \"Your API Key is: \" in line:\n api_key = line.split(\"Your API Key is: \")[1].split(\"<\")[0]\n return api_key\n ... | [
"0.59357",
"0.57256216",
"0.5548928",
"0.5383697",
"0.53185004",
"0.52857995",
"0.5276171",
"0.5259969",
"0.5204575",
"0.5185268",
"0.5182574",
"0.51728517",
"0.5126173",
"0.51261204",
"0.51226956",
"0.5106314",
"0.5106314",
"0.50934404",
"0.5050427",
"0.50257576",
"0.4965156... | 0.8757863 | 0 |
Utility method to retrieve the list of errors (if any) from a PayPal response. | def get_errors(response):
errors = response.get("error")
if errors:
return [e.get("message") for e in errors]
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_errors(self, response: response_domain_model.Response, question_code: str) -> Sequence['ValidationError']:\n ...",
"def _get_resp_body_errors(self):\n\n if self._resp_body_errors and len(self._resp_body_errors) > 0:\n return self._resp_body_errors\n\n errors = []\n ... | [
"0.6916876",
"0.68916273",
"0.65724224",
"0.6497242",
"0.64410913",
"0.64169973",
"0.6369101",
"0.6369101",
"0.6323569",
"0.6281489",
"0.6272857",
"0.62684876",
"0.6221662",
"0.6196093",
"0.61649644",
"0.6146879",
"0.6127754",
"0.6113122",
"0.6102733",
"0.6091104",
"0.604821"... | 0.80022 | 0 |
Running evaluation on test set, appending results to a submission. | def evaluate(model, dataset, append_submission, dataset_root):
with open(os.path.join(dataset_root, dataset + '.json'), 'r') as f:
image_list = json.load(f)
print('Running evaluation on {} set...'.format(dataset))
count_img=0
for img in image_list:
img_path = os.path.join(dataset_root... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, test_data):\n result = self.model.run(test_data)\n self._save_result(result)",
"def evaluate_all_submissions(root_dir, gt_dir, skip_evaluated=False):\n # all submission directory has a 'dt_txts'\n sub_id_dir_pairs = find_submissions(root_dir, 'dt_txts')\n\n for identifier, sub... | [
"0.6631348",
"0.63206565",
"0.63080895",
"0.6257351",
"0.6243088",
"0.6196527",
"0.6184294",
"0.6101646",
"0.60934335",
"0.6092591",
"0.60906154",
"0.608936",
"0.6052524",
"0.6040191",
"0.60248965",
"0.6024804",
"0.5999703",
"0.59867626",
"0.59778136",
"0.5951736",
"0.5925951... | 0.63503134 | 1 |
Asks Noembed_ for the embedding HTML code for arbitrary URLs. Sites supported include Youtube, Vimeo, Twitter and many others. Successful embeds are always cached for 30 days. Failures are cached if ``cache_failures`` is ``True`` (the default). The | def oembed_html(url, cache_failures=True):
# Thundering herd problem etc...
key = 'oembed-url-%s' % md5(url.encode('utf-8')).hexdigest()
html = cache.get(key)
if html is not None:
return html
try:
html = requests.get(
'https://noembed.com/embed',
params={
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _oembed_request(self, url):\n try:\n response = cache.get(url)\n if not response:\n resp = urllib.urlopen(url, timeout=5)\n response = json.loads(resp.read())\n cache.set('embed_'.format(url), response, 60 * 60 * 6) # 6hrs para que se a... | [
"0.61671865",
"0.557492",
"0.55536354",
"0.5506088",
"0.5394031",
"0.5333495",
"0.5313941",
"0.5254451",
"0.5248169",
"0.5236533",
"0.5202616",
"0.5186459",
"0.51711",
"0.51031286",
"0.5083401",
"0.50735337",
"0.5036362",
"0.5028727",
"0.50113606",
"0.50018126",
"0.5001552",
... | 0.7094637 | 0 |
Gets or creates a Folder based the list of folder names in hierarchical order (like breadcrumbs). get_or_create_folder(['root', 'subfolder', 'subsub folder']) creates the folders with correct parent relations and returns the 'subsub folder' instance. | def get_or_create_folder(self, folder_names):
if not len(folder_names):
return None
current_parent = None
for folder_name in folder_names:
current_parent, created = Folder.objects.get_or_create(
name=folder_name, parent=current_parent)
if creat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_folder_by_path(self, folder_path):\n\n current_parent_id = self._get_root_metadata()['id']\n\n path_folders = StoreTree.get_path_levels(folder_path)\n\n if path_folders[0] == '':\n return current_parent_id\n\n for folder_name in path_folders:\n current_p... | [
"0.6284484",
"0.5968514",
"0.591213",
"0.59022653",
"0.5900601",
"0.58238125",
"0.5787846",
"0.56719345",
"0.5648211",
"0.55549943",
"0.5534397",
"0.5528245",
"0.55195063",
"0.5439631",
"0.5409075",
"0.52300525",
"0.5180839",
"0.5164742",
"0.51623046",
"0.51155657",
"0.510715... | 0.7129039 | 0 |
Generate a dictionary of random product IDs and their prices | def generateProducts(self):
# Creates items in each category
for i in range(self.num_of_items):
self.ID_DICT[i+self.num_of_items] = random.randint(1, 10)
self.ID_DICT[i+self.num_of_items*2] = random.randint(1, 10)
self.ID_DICT[i+self.num_of_items*3] = random.ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_products(self, products: List) -> Dict[str, int]:\n\n product_request = urllib.request.Request(url=URL_PRODUCTS, headers={'User-Agent': URL_USER_AGENT})\n product_response = urllib.request.urlopen(product_request)\n all_products = json.load(product_response)\n\n product_... | [
"0.6971659",
"0.6540291",
"0.6502809",
"0.62412894",
"0.6076976",
"0.6033557",
"0.59931135",
"0.59761584",
"0.5946876",
"0.59340703",
"0.59294564",
"0.5865452",
"0.5837422",
"0.5778919",
"0.5731991",
"0.5731828",
"0.5689985",
"0.5683067",
"0.5670007",
"0.5662804",
"0.5661343"... | 0.68286663 | 1 |
Given floats used for weighted choices, random purchases are made for a customer | def generatePurchases(self, num_of_purchases, food, medical, electronics, outdoors, clothing, beauty, customer):
# Empty purchases
self.customer_purchases = []
# Customer is *likely* to buy from some categories, but anything can happen
weighted_categories = [('Food', food), ('Med... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateCustomers(self):\r\n\r\n # Counters\r\n shoppers = 0\r\n models = 0\r\n oldl = 0\r\n oldf = 0\r\n doctor = 0\r\n nudist = 0\r\n hippie = 0\r\n nerd = 0\r\n\r\n for i in range(self.num_of_customers):\r\n\r\n # With these we... | [
"0.68680906",
"0.67529637",
"0.65332425",
"0.6512736",
"0.64413524",
"0.6347539",
"0.63373226",
"0.6335294",
"0.627076",
"0.62083924",
"0.61907333",
"0.6163172",
"0.6128276",
"0.6093737",
"0.6055325",
"0.6027389",
"0.6019666",
"0.6015048",
"0.60027325",
"0.5991202",
"0.588668... | 0.7328029 | 0 |
Generate employees, each with a name, clock in, clock out, and wage | def generateEmployees(self):
# Name
maleNames = ['Perry Lovan', 'Horacio Arvidson', 'Gale Skipworth', 'Joshua Lodge', 'Noble Shutter', 'Kristopher Talor', 'Jarod Harrop', 'Joan Henrichs', 'Wilber Vitiello', 'Clayton Brannum', 'Joel Sennett', 'Wiley Maffei', 'Clemente Flore', 'Cliff Saari', 'Miquel P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_emp_man_hours(self):\n start = timezone.make_aware(dt.datetime(2016, 6, 3, 6, 30))\n stop = timezone.make_aware(dt.datetime(2016, 6, 3, 10, 30))\n emp_hours = 0\n\n expected_emp_hours = 20.95\n\n # getting employee objects that are clocked in\n clocked_in_emp = ge... | [
"0.6326731",
"0.6174064",
"0.6145489",
"0.60907257",
"0.5949069",
"0.59248495",
"0.5886534",
"0.5878822",
"0.5804044",
"0.5747758",
"0.57071424",
"0.56668836",
"0.5626319",
"0.5592785",
"0.5565836",
"0.5512038",
"0.55018",
"0.5469139",
"0.5452839",
"0.5449946",
"0.54412967",
... | 0.7532919 | 0 |
Customer data generation based on weighted random choices | def generateCustomers(self):
# Counters
shoppers = 0
models = 0
oldl = 0
oldf = 0
doctor = 0
nudist = 0
hippie = 0
nerd = 0
for i in range(self.num_of_customers):
# With these weights, our store has plenty of yo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generatePurchases(self, num_of_purchases, food, medical, electronics, outdoors, clothing, beauty, customer):\r\n\r\n # Empty purchases\r\n self.customer_purchases = []\r\n\r\n # Customer is *likely* to buy from some categories, but anything can happen\r\n weighted_categories = [('Fo... | [
"0.67562157",
"0.6674905",
"0.66366154",
"0.64034915",
"0.63300693",
"0.6307731",
"0.62676364",
"0.61813587",
"0.61580294",
"0.6153797",
"0.6138154",
"0.61247575",
"0.60950094",
"0.60847926",
"0.60655224",
"0.60615486",
"0.6052468",
"0.6047676",
"0.59948903",
"0.59820014",
"0... | 0.75274 | 0 |
This function calculates the Fourier Transform of a specific signal | def DFT(signal):
n = signal.shape[0]
omega = np.exp(((((-2) * np.pi)*1j) / n))
e_items = np.vander(omega**np.arange(n), n, True)
fourier_signal = np.dot(e_items, signal)
return fourier_signal.astype(np.complex128) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numpyFourierTransform(self,graph):\n z=[complex(*graph[i]) for i in range(len(graph))]\n return np.fft.fft(z)",
"def FourierTransform(data, nPoints):\r\n tdf = np.fft.fft(data, nPoints)\r\n return tdf",
"def fourier_transform(signal, fs):\n freqs = np.fft.rfftfreq(4*len(signal), 1/fs... | [
"0.7334551",
"0.73286504",
"0.73249704",
"0.72870594",
"0.7284747",
"0.72186106",
"0.7010064",
"0.6952721",
"0.6820437",
"0.6792979",
"0.6747964",
"0.6740338",
"0.67176574",
"0.6682443",
"0.66758895",
"0.6668562",
"0.66177744",
"0.65891063",
"0.6576105",
"0.657266",
"0.655033... | 0.75178254 | 0 |
This function calculates the magnitude of derivative of an image using convolution | def conv_der(im):
derevitive_conv = np.array([[1], [-1]])
dx = scipy.signal.convolve2d(im, derevitive_conv, 'same')
dy = scipy.signal.convolve2d(im, derevitive_conv.transpose(), 'same')
magnitude = np.sqrt(np.abs(dx)**2 + np.abs(dy)**2)
return magnitude.real.astype(np.float64) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_der(im):\n im = im.astype(np.float64)\n # set der x/y matrix\n der_x = np.array([[1, 0, -1]])\n der_y = np.array(der_x.transpose())\n # calculate the derivative to x and y\n dx = conv(im, der_x, mode='same')\n dy = conv(im, der_y, mode='same')\n\n return np.sqrt(np.abs(dx)**2 + np.... | [
"0.7183386",
"0.69026047",
"0.6638305",
"0.62914103",
"0.6233699",
"0.6149139",
"0.60923374",
"0.6032786",
"0.59937316",
"0.5830059",
"0.5819746",
"0.5730074",
"0.571061",
"0.56998205",
"0.56732875",
"0.56361973",
"0.561787",
"0.5611231",
"0.5599725",
"0.5590067",
"0.55685765... | 0.77950674 | 0 |
This function calculates the magnitude of derivative of an image using Fourier transform | def fourier_der(im):
ft_img = DFT2(im)
ft_img = np.fft.fftshift(ft_img)
n_x = im.shape[1]
coeff_x = (2 * np.pi * 1j)/n_x
u_freq = np.array([n if n < int(n_x/2) else (n-n_x) for n in range(n_x)]) * 1j
u_freq = np.array([np.fft.fftshift(u_freq)]*im.shape[0]).transpose()
dx_ft = coeff_x * IDFT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fourier_der(im):\n im = im.astype(np.float64)\n # constants\n M, N = im.shape\n u = np.meshgrid(np.arange(N), np.arange(M))[0] - N//2\n v = np.meshgrid(np.arange(N), np.arange(M))[1] - M//2\n u_der, v_der = (2 * np.pi * 1j / N), (2 * np.pi * 1j / M)\n\n # calculate dx, dy\n dx = u_der *... | [
"0.7200767",
"0.71910566",
"0.6819447",
"0.67383516",
"0.6534676",
"0.6498865",
"0.6467338",
"0.6463012",
"0.6438436",
"0.6408685",
"0.6262128",
"0.6196817",
"0.6159641",
"0.6158729",
"0.61358994",
"0.611732",
"0.6114465",
"0.6101021",
"0.6028547",
"0.60126936",
"0.60116524",... | 0.7349067 | 0 |
This is a helper method to calculate the correct approximation of the gaussian kernel according to its size. Using convolution and the binomial coefficients. | def gaus_kernel_calc(kernel_size):
base_gaus_binom = np.array([[1], [1]])
kernel = base_gaus_binom
if kernel_size == 1:
# If the kernel size is 1 we need a 2d array that keeps the image the same.
kernel = np.array([[1]])
kernel = scipy.signal.convolve2d(kernel, kernel.transpose())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_kernel(kernel_size):\n curr_kernel = _binoms(kernel_size)\n curr_kernel = curr_kernel.reshape(kernel_size, 1)\n kernel2d = convolve2d(curr_kernel.transpose(), curr_kernel)\n kernel2d = np.divide(kernel2d, np.sum(kernel2d))\n return kernel2d",
"def _gaussian_kernel_1d(kernel_size):\n ... | [
"0.7698725",
"0.7291328",
"0.7062091",
"0.70119226",
"0.70004064",
"0.6961366",
"0.6934092",
"0.69159126",
"0.68459934",
"0.67787015",
"0.6736879",
"0.672049",
"0.6705494",
"0.66477126",
"0.6604094",
"0.66021335",
"0.65580577",
"0.6506256",
"0.6482842",
"0.6423013",
"0.637182... | 0.7816964 | 0 |
This function creates blur filter with gaussian matrix, using Fourier Transform. | def blur_fourier(im, kernel_size):
kernel = gaus_kernel_calc(kernel_size)
zeros = np.zeros(im.shape)
x_mid = np.math.floor(im.shape[1] / 2)
y_mid = np.math.floor(im.shape[0] / 2)
distance = np.math.floor(kernel_size / 2)
zeros[x_mid - distance: x_mid + distance + 1, y_mid - distance: y_mid + d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blur_fourier(im, kernel_size):\n im = im.astype(np.float64)\n # build the kernel with zero padding\n kernel_base = gaussian_kernel_factory(kernel_size)\n window = np.zeros_like(im).astype(np.float64)\n M, N = im.shape\n dx, dy = kernel_base.shape\n x_middle, y_middle = N//2, M//2\n\n wi... | [
"0.7033389",
"0.6549185",
"0.6358396",
"0.6321791",
"0.6246919",
"0.6219117",
"0.62025046",
"0.61897266",
"0.6176243",
"0.61696154",
"0.61396426",
"0.61196125",
"0.61132675",
"0.61000806",
"0.60520715",
"0.6044603",
"0.60240215",
"0.6006676",
"0.5973492",
"0.5973492",
"0.5973... | 0.70527494 | 0 |
Masks the genotype call if it is not in a native segment. It does this by determining whether position is between start and end intervals for that ind (bed files are NAT_NAT regions | def ind_pos(position, ind, current_geno, chr_starts, chr_ends):
ind_starts = chr_starts[ind]
ind_ends = chr_ends[ind]
#print [position, ind, current_geno, ind_starts, ind_ends]
in_interval = False
for interval in range(len(ind_starts)):
if position > int(ind_starts[interval]) and position < ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tnuc_region_in_intron(np, beg, end):\n\n if beg.tpos == 0 or end.tpos == 0: return False\n if beg.pos == end.pos and beg.tpos*end.tpos > 0:\n return True\n if beg.pos+1 == end.pos and beg.tpos>0 and end.tpos<0:\n return True\n if end.pos+1 == beg.pos and beg.tpos<0 and end.tpos>0:\n ... | [
"0.5558654",
"0.51969874",
"0.5173438",
"0.50165325",
"0.4989496",
"0.49694717",
"0.4968496",
"0.49294603",
"0.49171147",
"0.4901071",
"0.4888251",
"0.4886161",
"0.48798653",
"0.48647732",
"0.4821777",
"0.4810842",
"0.47864586",
"0.47824484",
"0.4780181",
"0.4776257",
"0.4763... | 0.555699 | 1 |
For the selected reports (training or testing) in the database, process each report with peFinder | def processReports(self):
count = 0
for r in self.reports:
#need to change the next two lines so that the fields are not hard-coded
self.currentCase = r.id
self.currentText = r.impression.lower()
self.analyzeReport(self.currentText,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_test(self):\n\n # populate *_ps sets\n self.enter_project_file()\n\n # populate *_dir sets\n self.enter_directories()\n\n # The files in the directories makes up the largest possible set of files\n self.result_files = self.result_files_dir\n self.design_file... | [
"0.5900469",
"0.58614814",
"0.58482856",
"0.5812443",
"0.5654445",
"0.5645506",
"0.56158066",
"0.55587703",
"0.55587286",
"0.55434436",
"0.5528884",
"0.5463674",
"0.5459964",
"0.54589087",
"0.5455149",
"0.5428829",
"0.5415472",
"0.5411975",
"0.54082245",
"0.540817",
"0.540572... | 0.65057874 | 0 |
Compute the area of a geospatial value. Returns FloatingValue The area of `self` | def area(self) -> ir.FloatingValue:
return ops.GeoArea(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self) -> float:\n raise NotImplementedError",
"def area(self):\n if isinstance(self.crs, GeographicalCRS):\n major_axis = self.crs.ellipsoid.a\n minor_axis = self.crs.ellipsoid.b\n\n area = 0.0\n if major_axis == minor_axis: # Sphere\n ... | [
"0.78390014",
"0.7787656",
"0.7762487",
"0.771008",
"0.7676024",
"0.7494311",
"0.73737156",
"0.73681015",
"0.7305198",
"0.7286801",
"0.72227156",
"0.71913487",
"0.7185521",
"0.71353227",
"0.71084666",
"0.70956665",
"0.7095528",
"0.7091121",
"0.7076087",
"0.70625275",
"0.70147... | 0.89519435 | 0 |
Get the geometry as wellknown text (WKT) without the SRID data. Returns StringValue String value | def as_text(self) -> ir.StringValue:
return ops.GeoAsText(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getWKT(self):\n logger.debug(\"Entering in ocentricWKT.getWkt\")\n\n # building WKT string\n wkt = OcentricWKT.GEODCRS % (\n self.getGeoGcsName(), self.getDatumName(), self.getSpheroidName(), self.getRadius(), self.getInverseFlattening(),\n self.getRadius(), self.getA... | [
"0.65250087",
"0.6227793",
"0.6099172",
"0.59958804",
"0.59699154",
"0.58982855",
"0.5897963",
"0.58915573",
"0.5823331",
"0.57201636",
"0.5655366",
"0.5626841",
"0.5612404",
"0.55262345",
"0.5481621",
"0.5471973",
"0.5428957",
"0.54264724",
"0.5422329",
"0.5410296",
"0.53831... | 0.6646094 | 0 |
Get the geometry as wellknown bytes (WKB) with the SRID data. Returns BinaryValue WKB value | def as_ewkb(self) -> ir.BinaryValue:
return ops.GeoAsEWKB(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_wkb(self):\n return _property_op(lambda x: x, self)",
"def wkb(self): # -> bytes:\n ...",
"def as_binary(self) -> ir.BinaryValue:\n return ops.GeoAsBinary(self).to_expr()",
"def _get_geometry(self, val):\n g = OGRGeometry(val)\n return json.loads(g.json)",
"def wk... | [
"0.586647",
"0.5865369",
"0.5783438",
"0.5653033",
"0.56270975",
"0.5481678",
"0.5458133",
"0.5417851",
"0.53809196",
"0.5372961",
"0.5362368",
"0.53046584",
"0.52930826",
"0.52646327",
"0.5259626",
"0.5209731",
"0.52090925",
"0.5139013",
"0.51351386",
"0.51294726",
"0.510659... | 0.6025436 | 0 |
Check if `self` is entirely within `distance` from `right`. | def d_fully_within(
self,
right: GeoSpatialValue,
distance: ir.FloatingValue,
) -> ir.BooleanValue:
return ops.GeoDFullyWithin(self, right, distance).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d_within(\n self,\n right: GeoSpatialValue,\n distance: ir.FloatingValue,\n ) -> ir.BooleanValue:\n return ops.GeoDWithin(self, right, distance).to_expr()",
"def within_distance(self, point, distance):\n return all(distance >= seg.shortest_distance_to(point)\n ... | [
"0.7167458",
"0.66897726",
"0.65852267",
"0.6398431",
"0.631626",
"0.6159795",
"0.6069909",
"0.60572755",
"0.5953424",
"0.59026295",
"0.5893493",
"0.5875279",
"0.57910955",
"0.5758687",
"0.5736612",
"0.57315516",
"0.57160324",
"0.5710056",
"0.57049614",
"0.57049614",
"0.56849... | 0.7242819 | 0 |
Check if `self` is partially within `distance` from `right`. | def d_within(
self,
right: GeoSpatialValue,
distance: ir.FloatingValue,
) -> ir.BooleanValue:
return ops.GeoDWithin(self, right, distance).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d_fully_within(\n self,\n right: GeoSpatialValue,\n distance: ir.FloatingValue,\n ) -> ir.BooleanValue:\n return ops.GeoDFullyWithin(self, right, distance).to_expr()",
"def within_distance(self, point, distance):\n return all(distance >= seg.shortest_distance_to(point)\n... | [
"0.7420986",
"0.6674265",
"0.6413584",
"0.61454713",
"0.6127788",
"0.5950731",
"0.59127736",
"0.5828475",
"0.5825035",
"0.5794298",
"0.57647914",
"0.56845057",
"0.5664932",
"0.5646242",
"0.56445026",
"0.5642126",
"0.5579724",
"0.5579724",
"0.5560193",
"0.55255526",
"0.5500712... | 0.7225795 | 1 |
Get the 1based Nth geometry of a multi geometry. | def geometry_n(self, n: int | ir.IntegerValue) -> GeoSpatialValue:
return ops.GeoGeometryN(self, n).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMultiGeometry(geometry):\n geom = arcpy.Array()\n for feature in geometry:\n array = arcpy.Array()\n for point in feature:\n point = arcpy.Point(float(point[0]), float(point[1]))\n array.add(point)\n geom.add(array)\n return geom",
"def geom_single(self,... | [
"0.65626216",
"0.59952974",
"0.5883551",
"0.5852187",
"0.55755234",
"0.5488048",
"0.52828753",
"0.52417064",
"0.5209669",
"0.52007324",
"0.5179337",
"0.5148148",
"0.50144815",
"0.49956",
"0.49947926",
"0.49943653",
"0.49615914",
"0.4940357",
"0.4906351",
"0.4902437",
"0.48999... | 0.64696354 | 1 |
Get the type of a geometry. Returns StringValue String representing the type of `self`. | def geometry_type(self) -> ir.StringValue:
return ops.GeoGeometryType(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_geometry_type(self):\n return self.geometry_type",
"def get_geometry_type(self):\n return self._geometry_type",
"def geom_type(self):\n return _property_op(arctern.ST_GeometryType, self)",
"def geom_type(self): # -> str:\n ...",
"def GetObjectTypeString(type):\n ... | [
"0.76413125",
"0.758172",
"0.7331979",
"0.711782",
"0.69186944",
"0.6886925",
"0.6850519",
"0.6850519",
"0.68425244",
"0.68053585",
"0.67596257",
"0.6710633",
"0.6700815",
"0.6681921",
"0.6681921",
"0.6681921",
"0.66299194",
"0.6629663",
"0.6625415",
"0.6621467",
"0.65781057"... | 0.82591885 | 0 |
Compute the distance between two geospatial expressions. | def distance(self, right: GeoSpatialValue) -> ir.FloatingValue:
return ops.GeoDistance(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(a, b):\n return vincenty((float(a.longitude), float(a.latitude)),\n (float(b.longitude), float(b.latitude))).km",
"def distance(self, a, b):\n \n # -----------------------------\n # Your code\n '''R = 3963 # radius of Earth (miles)\n lat1, lo... | [
"0.67492944",
"0.67315775",
"0.6720346",
"0.66882116",
"0.66505593",
"0.6646785",
"0.66209525",
"0.6602943",
"0.6596843",
"0.65880513",
"0.6574677",
"0.6560092",
"0.6550573",
"0.6542965",
"0.6534998",
"0.65274507",
"0.6516017",
"0.64990103",
"0.6498941",
"0.648396",
"0.647728... | 0.6739062 | 1 |
Compute the length of a geospatial expression. Returns FloatingValue Length of `self` | def length(self) -> ir.FloatingValue:
return ops.GeoLength(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return _property_op(arctern.ST_Length, self)",
"def getLength(self):\n return self.geometry.length",
"def length(self) -> float:\n n = self.geodesic.extrinsicDimension()\n third = 1.0/3.0\n def distance(x,y):\n cp0 = x[:n]\n cp1 = sel... | [
"0.759075",
"0.75095755",
"0.7373766",
"0.73544824",
"0.7261306",
"0.7236807",
"0.7201984",
"0.70979667",
"0.70661324",
"0.7026694",
"0.6963566",
"0.6913003",
"0.68597555",
"0.684015",
"0.6811498",
"0.67878556",
"0.677738",
"0.6695058",
"0.66927135",
"0.6674483",
"0.6637787",... | 0.8851043 | 0 |
Compute the perimeter of a geospatial expression. Returns FloatingValue Perimeter of `self` | def perimeter(self) -> ir.FloatingValue:
return ops.GeoPerimeter(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perimeter(self):\r\n\r\n return 2*math.pi*self.__radius",
"def getPerimeter(self):\n return 2 * math.pi * self.__radius",
"def perimeter(self):\n perimeter = (2 * self.__length) + (2 * self.__width)\n\n return perimeter",
"def calculateperimeter(self):\r\n return (self.... | [
"0.778637",
"0.77440834",
"0.7668872",
"0.75241464",
"0.74811465",
"0.7469736",
"0.7424772",
"0.7394988",
"0.73506325",
"0.73477244",
"0.71799135",
"0.69433486",
"0.6926244",
"0.685806",
"0.685806",
"0.6706363",
"0.6612634",
"0.64354116",
"0.63916534",
"0.63876265",
"0.630856... | 0.9076304 | 0 |
Returns the 2dimensional max distance between two geometries in projected units. If `self` and `right` are the same geometry the function will return the distance between the two vertices most far from each other in that geometry. | def max_distance(self, right: GeoSpatialValue) -> ir.FloatingValue:
return ops.GeoMaxDistance(self, right).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcDistance(self, left, right):\n\n return math.fabs(right-left)",
"def distance(self, right: GeoSpatialValue) -> ir.FloatingValue:\n return ops.GeoDistance(self, right).to_expr()",
"def distance_to(self, other: Geometry[Scalar]) -> Scalar:\n return (self._distance_to_point(other)\n ... | [
"0.7138382",
"0.69984686",
"0.62663174",
"0.6188633",
"0.61593235",
"0.61498183",
"0.61449254",
"0.6134089",
"0.6068625",
"0.6057324",
"0.6041501",
"0.60340476",
"0.6026349",
"0.60073996",
"0.5995334",
"0.59545815",
"0.5942099",
"0.5938405",
"0.59302366",
"0.5925812",
"0.5921... | 0.7459676 | 0 |
Return the X minima of a geometry. Returns FloatingValue X minima | def x_min(self) -> ir.FloatingValue:
return ops.GeoXMin(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_min(self):\n return self.get_min_value(self.X_INDEX)",
"def getMinX(self):\n return self.minx",
"def MinX(*args, **kwargs):\n return _gdi_.DC_MinX(*args, **kwargs)",
"def argminX( self ):\n min = 1e30\n minX = None\n for i in range( 0, self.GetN() ):\n p = ( ... | [
"0.6936281",
"0.68577117",
"0.6676654",
"0.65368813",
"0.65021634",
"0.64860624",
"0.64765996",
"0.6459425",
"0.6271408",
"0.62344307",
"0.62138295",
"0.62108153",
"0.6197507",
"0.6180147",
"0.6161268",
"0.60633",
"0.6042033",
"0.59815675",
"0.59366107",
"0.58715415",
"0.5848... | 0.75810975 | 0 |
Return the X maxima of a geometry. Returns FloatingValue X maxima | def x_max(self) -> ir.FloatingValue:
return ops.GeoXMax(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x_max(self):\n return self.get_max_value(self.X_INDEX)",
"def xminmax ( self ) :\n return self.xvar.minmax()",
"def getMaxX(self):\n return self.maxx",
"def maxx(self):\n return self.__maxx",
"def MaxX(*args, **kwargs):\n return _gdi_.DC_MaxX(*args, **kwargs)",
"def... | [
"0.70034647",
"0.6844462",
"0.68119204",
"0.6744491",
"0.66253954",
"0.65137553",
"0.6445284",
"0.63773924",
"0.6355037",
"0.6352898",
"0.634081",
"0.6320554",
"0.6241515",
"0.61676",
"0.60805666",
"0.60124505",
"0.59927404",
"0.59921575",
"0.5976097",
"0.5970284",
"0.5966874... | 0.774601 | 0 |
Return the Y minima of a geometry. Returns FloatingValue Y minima | def y_min(self) -> ir.FloatingValue:
return ops.GeoYMin(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yminmax ( self ) :\n return self.yvar.minmax()",
"def argminY( self ):\n min = 1e30\n for i in range( 0, self.GetN() ):\n p = ( ROOT.Double(), ROOT.Double() )\n self.GetPoint( i, p[0], p[1] )\n if p[1] < min: min = p[1]\n return min",
"def getMinY(self):\n ... | [
"0.66017616",
"0.6561854",
"0.6507894",
"0.6417266",
"0.6388026",
"0.6362979",
"0.6347971",
"0.6301745",
"0.6212872",
"0.6202674",
"0.615909",
"0.61345196",
"0.61152333",
"0.61130464",
"0.6020709",
"0.5908351",
"0.579901",
"0.57950985",
"0.57829785",
"0.5726",
"0.5721702",
... | 0.7229437 | 0 |
Return the Y maxima of a geometry. Returns FloatingValue Y maxima | def y_max(self) -> ir.FloatingValue:
return ops.GeoYMax(self).to_expr() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MaxY(*args, **kwargs):\n return _gdi_.DC_MaxY(*args, **kwargs)",
"def y_max(self):\n return self.get_max_value(self.Y_INDEX)",
"def getMaxY(self):\n return self.maxy",
"def get_y_max(self):\n if len(self._statDict) == 0:\n return -1E10\n\n line_id_list = self... | [
"0.7133755",
"0.7071627",
"0.6952557",
"0.69172186",
"0.68478966",
"0.67792916",
"0.6676045",
"0.6672287",
"0.66261244",
"0.66043246",
"0.65261805",
"0.6523265",
"0.65193427",
"0.6452775",
"0.6387825",
"0.6349131",
"0.6341176",
"0.6341176",
"0.6329433",
"0.63072056",
"0.62842... | 0.79806757 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.