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 |
|---|---|---|---|---|---|---|
Test that we can decode the energy sums. These can be tricky b/c the baseline is encoded in IEEE 754 format. | def test_decode_energy_sums(self):
self.assertEqual(td.esums(decoded=True),
decoder.decode_energy_sums(BytesIO(td.esums(True)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_internal_energy(self):\n buff_score = self.pdb[0].get_internal_energy(ff=self.ff)\n self.assertAlmostEqual(buff_score.total_energy, -3722.49, places=2)",
"def test_energy():\n # Test something\n \n from nose.tools import assert_equal\n assert_equal(energy([0.0,0.0],1.0), 0)\n assert_e... | [
"0.6065364",
"0.59546584",
"0.58342063",
"0.5746904",
"0.57446885",
"0.5736451",
"0.5714147",
"0.57141185",
"0.56794614",
"0.565437",
"0.5632818",
"0.5597184",
"0.55819803",
"0.5568268",
"0.5568061",
"0.5558533",
"0.55471855",
"0.55132204",
"0.55014616",
"0.55003136",
"0.5491... | 0.8079843 | 0 |
Tests that we can decode external timestamps appropriately. | def test_decode_external_timestamp(self):
self.assertEqual(td.external_timestamp(), decoder.decode_external_timestamp(
BytesIO(td.external_timestamp(True)), self.mask)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_process_timestamp() -> None:\n datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt_util.UTC)\n datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0)\n est = dt_util.get_time_zone(\"US/Eastern\")\n datetime_est_timezone = datetime(2016, 7, 9, 11, 0, 0, tzinfo=est)\n nst ... | [
"0.6826415",
"0.678895",
"0.6769374",
"0.67243725",
"0.6696744",
"0.6450985",
"0.6423673",
"0.6392706",
"0.63700205",
"0.63413143",
"0.6326594",
"0.629541",
"0.62936324",
"0.62907755",
"0.62751067",
"0.62236845",
"0.6223447",
"0.6193005",
"0.61763287",
"0.6139348",
"0.6137388... | 0.87496525 | 0 |
Tests that we can decode the QDC header into an array. | def test_decode_qdc(self):
self.assertEqual(td.qdc(), decoder.decode_qdc(BytesIO(td.qdc(True)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_header(self):\r\n\r\n # Default header, should not generate any errors/warnings\r\n header = ['SampleID', 'BarcodeSequence', 'LinkerPrimerSequence',\r\n 'Description']\r\n errors = []\r\n warnings = []\r\n\r\n errors, warnings = check_header(header... | [
"0.5721757",
"0.56352746",
"0.56029373",
"0.55741435",
"0.5571948",
"0.5553872",
"0.5409489",
"0.53822374",
"0.5372538",
"0.53498983",
"0.53497857",
"0.53476274",
"0.534357",
"0.53414613",
"0.5300027",
"0.5283559",
"0.52749854",
"0.52655655",
"0.5253365",
"0.5250469",
"0.5244... | 0.7044205 | 0 |
Tests that we can decode a trace from the data stream. | def test_decode_trace(self):
self.assertEqual(td.trace(), decoder.decode_trace(BytesIO(td.trace(True)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_decode(self):\n pass # TODO(tlarsen)",
"def testDecode(self):\n test_cases = [\n ('1\\n', '\\n'),\n ('1 ', ' '),\n ('3a 3b', 'aaabbb'),\n ('1a 1 1b', 'a b'),\n ('3\\n', '\\n\\n\\n'),\n ('11 22 33', '122333'),\n ... | [
"0.6836183",
"0.6604363",
"0.6448971",
"0.6442332",
"0.6401186",
"0.6361264",
"0.6157366",
"0.6095047",
"0.5986678",
"0.5910711",
"0.5854313",
"0.583977",
"0.58035004",
"0.575414",
"0.5735243",
"0.5728554",
"0.5705553",
"0.5687723",
"0.56629175",
"0.5657399",
"0.562537",
"0... | 0.860621 | 0 |
Tests that we raise a Value Error when decoding a bad header length. | def test_process_optional_header_data_bad_header_length(self):
with self.assertRaises(ValueError):
decoder.process_optional_header_data(BytesIO(td.external_timestamp(True)), 3, self.mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_control_packet_header(self, data):\n with pytest.raises(StreamError) as e:\n ControlHeaderStruct.parse(data)",
"def test_bad_control_packet_header(self, data):\n with pytest.raises(StreamError) as e:\n ControlHeaderStruct.parse(data)",
"def test_error_message_he... | [
"0.69578516",
"0.69578516",
"0.69512135",
"0.6904783",
"0.6873048",
"0.6832096",
"0.6810115",
"0.68085086",
"0.67901564",
"0.67745537",
"0.67745537",
"0.67485756",
"0.67124915",
"0.66635495",
"0.66243625",
"0.6623286",
"0.6604393",
"0.64992744",
"0.64364654",
"0.6372474",
"0.... | 0.75773674 | 0 |
Resolves a list of requirements for the same package. Given a list of package details in the form of `packaging.requirements.Requirement` objects, combine the specifier, extras, url and marker information to create a new requirement object. | def resolve_requirement_versions(package_versions):
resolved = Requirement(str(package_versions[0]))
for package_version in package_versions[1:]:
resolved.specifier = resolved.specifier & package_version.specifier
resolved.extras = resolved.extras.union(package_version.extras)
resolved.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dependencies(package=\"sunpy\", extras=None):\n requirements = get_requirements(package)\n installed_requirements = {}\n missing_requirements = defaultdict(list)\n extras = extras or [\"required\"]\n for group in requirements:\n if group not in extras:\n continue\n ... | [
"0.6731303",
"0.6638183",
"0.64004624",
"0.6214947",
"0.60815656",
"0.6050588",
"0.60242367",
"0.6014201",
"0.5969914",
"0.59190315",
"0.58537954",
"0.5825504",
"0.578931",
"0.5785204",
"0.5728535",
"0.57212466",
"0.56810987",
"0.56708723",
"0.5663251",
"0.5650628",
"0.563003... | 0.7085873 | 0 |
List installed and missing dependencies. Given a package and, optionally, a tuple of extras, identify any packages which should be installed to match the requirements and return any which are missing. | def find_dependencies(package="sunpy", extras=None):
requirements = get_requirements(package)
installed_requirements = {}
missing_requirements = defaultdict(list)
extras = extras or ["required"]
for group in requirements:
if group not in extras:
continue
for package, pack... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missing_dependencies_by_extra(package=\"sunpy\", exclude_extras=None):\n exclude_extras = exclude_extras or []\n requirements = get_requirements(package)\n missing_dependencies = {}\n for group in requirements.keys():\n if group in exclude_extras:\n continue\n missing_depen... | [
"0.76459414",
"0.6849081",
"0.67575186",
"0.666805",
"0.6547717",
"0.654318",
"0.6514373",
"0.6467595",
"0.6462847",
"0.6381039",
"0.6121573",
"0.6098772",
"0.6093863",
"0.6074484",
"0.60300785",
"0.5925275",
"0.59156656",
"0.5831861",
"0.582028",
"0.58077604",
"0.5804144",
... | 0.818115 | 0 |
Get all the specified extras for a package and report any missing dependencies. This function will also return a "required" item in the dict which is the dependencies associated with no extras. | def missing_dependencies_by_extra(package="sunpy", exclude_extras=None):
exclude_extras = exclude_extras or []
requirements = get_requirements(package)
missing_dependencies = {}
for group in requirements.keys():
if group in exclude_extras:
continue
missing_dependencies[group]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dependencies(package=\"sunpy\", extras=None):\n requirements = get_requirements(package)\n installed_requirements = {}\n missing_requirements = defaultdict(list)\n extras = extras or [\"required\"]\n for group in requirements:\n if group not in extras:\n continue\n ... | [
"0.750957",
"0.72501034",
"0.67800206",
"0.66262317",
"0.6523681",
"0.6490982",
"0.63194853",
"0.62972224",
"0.62286425",
"0.60691607",
"0.60094035",
"0.59347016",
"0.58882934",
"0.5886922",
"0.5747453",
"0.57250464",
"0.5711906",
"0.5701838",
"0.5681736",
"0.5658716",
"0.562... | 0.7773356 | 0 |
Load zoning districts from the given shapefile. | def load_zoning_districts(source=ZONING_DATA_FILE):
layer = DataSource(source)[0]
for feature in layer:
try:
_save_base_district(feature)
except:
print ('Could not save base district for feature with OBJECTID=%s.'
' Skipping.') % feature['OBJECTID']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_graph(self, graph: nx.Graph) -> None:\n\n self.pos = dict()\n self.polygons = dict()\n districts = len(self.data[\"features\"])\n\n for i in range(districts):\n\n # Get shape information from file\n nodes = self.data[\"features\"][i][\"geometry\"][\"coor... | [
"0.63071585",
"0.62551874",
"0.62253094",
"0.60826",
"0.6047353",
"0.5942383",
"0.5731001",
"0.5591916",
"0.5538651",
"0.54869246",
"0.53558475",
"0.5330665",
"0.529415",
"0.5255251",
"0.5226903",
"0.51566815",
"0.514738",
"0.5143",
"0.51270646",
"0.512447",
"0.5090616",
"0... | 0.72876954 | 0 |
Extract the hidden message fro the given image. Authenticate the hidden message by validating the hmac hash sliced from the hidden message. | def get_msg(img):
i = Image.open('%s.ste' % img)
secret = stg.extract_msg(i)
mac = secret.split('--:--')[0]
print 'HMAC hex is: \n%s\n' % mac.encode('hex')
data = secret.split('--:--')[1]
print 'The hidden message is: \n%s\n' % data
check_hmac(mac)
i.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide(self, img, message):\r\n encoded = img.copy()\r\n width, height = img.size\r\n index = 0\r\n\r\n message = message + '~~~'\r\n message_bits = \"\".join(tools.a2bits_list(message))\r\n\r\n npixels = width * height\r\n if len(message_bits) > npixels * 3:\r\n ... | [
"0.6304911",
"0.5306204",
"0.5240656",
"0.5205463",
"0.51036364",
"0.5082488",
"0.50332326",
"0.50201464",
"0.49953687",
"0.4965542",
"0.4962028",
"0.49606332",
"0.49157923",
"0.49048188",
"0.4883517",
"0.48731127",
"0.48006538",
"0.47986904",
"0.47594568",
"0.47593972",
"0.4... | 0.8221424 | 0 |
Check if the given hmac ist valid by creating a new hmac with the supplied password and the data. | def check_hmac(mac, data):
h_mac = hmac.new(args['m'], bytes(data), digestmod=hashlib.sha256).digest()
print 'HMAC validation: \n%s\n' % str(h_mac == mac) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_hmac(self, payload):\r\n \r\n new_hmac = hmac.new(bytes(self.passphrase), b'%s'%(payload['eiv']) , hashlib.sha224)\r\n new_hmac.update(b'%s'%(payload['enid']))\r\n new_hmac.update(b'%s'%(payload['ed']))\r\n new_hmac.update(self.sessionID)\r\n #print(new_hmac.digest... | [
"0.67652047",
"0.6743941",
"0.64469117",
"0.63084877",
"0.6117735",
"0.60767394",
"0.6014057",
"0.60025823",
"0.5932569",
"0.58754456",
"0.5839325",
"0.5813827",
"0.5786236",
"0.57454073",
"0.5742142",
"0.57346916",
"0.57076555",
"0.56693023",
"0.5610851",
"0.5534866",
"0.552... | 0.7753446 | 0 |
If s is the numer of sides in a polygon, then the formula for the nth | def polygonal_number(s, n):
return (n*n*(s-2)-n*(s-4))/2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_polygon(n, s):\n area = ((float(1)/float(4)) * n * s ** 2) / (math.tan(math.pi / n))\n return area",
"def polysum(n, s):\n area = 0\n \n #avoiding division by zero\n if n != 0: \n area = (0.25 * n * (s**2)) / math.tan(math.pi / n)\n perimeter = n * s\n \n return ... | [
"0.7027547",
"0.6960124",
"0.6618643",
"0.62399167",
"0.6210337",
"0.6153565",
"0.60968953",
"0.6084945",
"0.6028545",
"0.60198605",
"0.59947395",
"0.58944356",
"0.58530086",
"0.5812029",
"0.5808305",
"0.57551855",
"0.5749107",
"0.5730243",
"0.57258356",
"0.5722142",
"0.57036... | 0.8311902 | 0 |
Create a list of figurate numbers for a given s, between 1000 and 9999, with the additional property that the third digit of each number will not be 0. | def figurate_list(s):
f = polygon_gen(s)
ans = []
c = next(f)
while c < 999: c = next(f)
while c < 10000:
c = str(c)
if c[2] != '0': ans.append(FigurateNode(c[:2], c[-2:], s))
c = next(f)
return ans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fnum(num, sf = 0):\n\n\ts = []\n\tnf = 0\n\tppos = -1\n\tfor x in str(num):\n#\t\tprint((x, s))\n\t\tif x == '.':\n\t\t\tppos = len(s)\n\t\t\tcontinue\n\t\tif nf == 0 and ppos < 0 and x == '0':\n\t\t\tcontinue\n\t\ts.append(x)\n\t\tif x != '-' and (x != '0' or nf > 0):\n\t\t\tnf += 1\n\t\tif ppos >= 0 and sf >... | [
"0.617936",
"0.61459374",
"0.5946138",
"0.5857729",
"0.5823544",
"0.57899886",
"0.57853043",
"0.5770208",
"0.5769795",
"0.57615775",
"0.5737207",
"0.57371724",
"0.5700131",
"0.56913346",
"0.56819487",
"0.566019",
"0.5638854",
"0.56227523",
"0.56187755",
"0.5614714",
"0.557821... | 0.66711605 | 0 |
Finds all complete figurate cycles for given svalues. | def figurate_cycles(*s_vals):
assert len(s_vals) > 1 #incomplete sanity check
# Since a DFS has to start SOMEWHERE and we're looking for cycles, we
# arbitrarily take the first list of figurates and use them as the
# roots of our search.
roots = figurate_list(s_vals[0])
# Make a big list of all ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_cycles(s,graph):\n\n grph = u.edge_to_list_dict(graph)\n node_cnt = len(grph)\n k = z.Int(\"k\")\n syms = [z.Int('node%s'%i) for i in range(node_cnt)]\n\n # s.add(syms[0] == 0) # start node is a 0\n s.add(k < node_cnt)\n s.add(k > 1)\n\n o = z.Optimize()\n\n #... | [
"0.6175425",
"0.57670933",
"0.5475402",
"0.53936297",
"0.5329402",
"0.522589",
"0.52258706",
"0.5211429",
"0.51233554",
"0.5099929",
"0.5068521",
"0.5063437",
"0.5032627",
"0.5028338",
"0.49907324",
"0.4966183",
"0.49148342",
"0.49041694",
"0.48915786",
"0.4890928",
"0.488326... | 0.7913429 | 0 |
Checks that when we have no more candidates, that our path 'endpoints' are cyclical. | def have_cycle(candidates, path):
return (not candidates and path[0].prefix == path[-1].suffix) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_paths(self):\n for path in self.paths:\n # check that arc starts at s\n arc = path[0]\n arc_start = self.arc_info[arc][\"start\"]\n assert(arc_start == self.source()), \"Path does not start at s\"\n # check that internal arcs are valid\n ... | [
"0.64591026",
"0.64028496",
"0.62922645",
"0.6263719",
"0.62504596",
"0.6250248",
"0.62022024",
"0.6092906",
"0.60610884",
"0.6022989",
"0.6006082",
"0.5956604",
"0.595369",
"0.5885716",
"0.58702284",
"0.58571595",
"0.5837033",
"0.5828162",
"0.5810018",
"0.5783266",
"0.576298... | 0.6560611 | 0 |
Checks that we have at least one candidate whose prefix is cyclical with the new element's suffix. | def have_dead_end(candidates, new_elem):
return new_elem.suffix not in map(lambda x: x.prefix, candidates) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def have_cycle(candidates, path):\n return (not candidates and path[0].prefix == path[-1].suffix)",
"def find_all_cycles(candidates, new_elem, path=[]):\n \n def have_cycle(candidates, path):\n \"\"\" Checks that when we have no more candidates, that our path\n 'endpoints' are cyclical... | [
"0.688956",
"0.67497593",
"0.6492469",
"0.58144426",
"0.57607526",
"0.57607526",
"0.57380426",
"0.5663673",
"0.56448567",
"0.55977595",
"0.5587944",
"0.55387944",
"0.55290985",
"0.54872364",
"0.5447168",
"0.5441908",
"0.5441635",
"0.5411554",
"0.5400539",
"0.53535",
"0.532922... | 0.69614404 | 0 |
Returns a new list where all sgonal candidates have been removed. | def remove_sgons(s_value, candidates):
return list(filter(lambda x: x.s != s_value,
candidates)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup():\n for s in [missiles, explosions, bonus]:\n\n set_to_remove = set([])\n for m in s:\n if m.isDead:\n set_to_remove.add(m)\n\n s.difference_update(set_to_remove)",
"def rm(x, l):\n return [y for y in l if x != y]",
"def removed_vms(self) -> Lis... | [
"0.62687725",
"0.6201206",
"0.61726826",
"0.6111378",
"0.60760725",
"0.6075531",
"0.6048856",
"0.59979814",
"0.59737307",
"0.59074605",
"0.59073585",
"0.5861006",
"0.58275676",
"0.58228827",
"0.5821122",
"0.58096284",
"0.57756793",
"0.577101",
"0.5767358",
"0.57616895",
"0.57... | 0.718452 | 0 |
Prunes the obtained tree according to the minimal gain (entropy or Gini). | def prune(tree, minGain, evaluationFunction=entropy, notify=False):
# recursive call for each branch
if tree.trueBranch.results == None: prune(tree.trueBranch, minGain, evaluationFunction, notify)
if tree.falseBranch.results == None: prune(tree.falseBranch, minGain, evaluationFunction, notify)
# merge ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prune( tree, impurity_crit, dataSet, treeSeq ):\n\n\t\tsaved = {}\n\n\t\ttotal_leaf_impurity, num_leaves = DecisionTree._fetch(tree, impurity_crit, dataSet, saved)\n\n\t\tnodes, sets, G = saved['node'], saved['set'], saved['G']\n\n\t\t# choose TreeNode such that g is minimum to prune\n\t\tmin_g_ind = np.argmi... | [
"0.71780753",
"0.6755928",
"0.6264333",
"0.6245853",
"0.61987823",
"0.61671454",
"0.6129602",
"0.6123983",
"0.6105711",
"0.60467637",
"0.603748",
"0.599225",
"0.5975164",
"0.5917185",
"0.5786919",
"0.5713195",
"0.5691192",
"0.5679927",
"0.56610376",
"0.5647163",
"0.56247056",... | 0.7445959 | 0 |
Loads a CSV file and converts all floats and ints into basic datatypes. | def loadCSV(file):
def convertTypes(s):
s = s.strip()
try:
return float(s) if '.' in s else int(s)
except ValueError:
return s
reader = csv.reader(open(file, 'rt'))
return [[convertTypes(item) for item in row] for row in reader] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadCSV(input_file):",
"def load_csv():\n df = pd.read_csv(datafolder+filename, decimal=decimal).astype(\n {'min': 'float', 'max': 'float'})\n return df",
"def place_types_read_csv(self, csv_input):\n csv_data = pd.read_csv(csv_input, encoding='UTF-8', sep=',', na_values=[''])\n ... | [
"0.7278124",
"0.7128511",
"0.7073164",
"0.6921024",
"0.69140124",
"0.6835938",
"0.6834292",
"0.68103707",
"0.6777402",
"0.6776886",
"0.674985",
"0.67280674",
"0.6687896",
"0.6687714",
"0.66312677",
"0.6607438",
"0.65860206",
"0.6575137",
"0.65615463",
"0.6559472",
"0.6544173"... | 0.7568201 | 0 |
Ban an ip from all DDNet servers in given region. Minutes need to be greater than 0. Region needs to be the 3 char server code. | async def global_ban_region(self, ctx: commands.Context, region: str, ip: str, name: str, minutes: int, *, reason: clean_content):
await self._global_ban(ctx, ip, name, minutes, reason, region) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exclude_ip_ban(self):\n pass",
"def ban_host(self, host, hard=False, duration=None):\n # TODO: Timed bans?\n logger.verbose(\"Banning IP {0}\".format(host))\n self.ip_bans.add(host, hard)",
"async def global_unban(self, ctx: commands.Context, *, name: str):\n if re.m... | [
"0.5752577",
"0.5619576",
"0.5450576",
"0.54234755",
"0.5233336",
"0.5208012",
"0.51359165",
"0.51315814",
"0.5063948",
"0.4974001",
"0.4927776",
"0.48956954",
"0.48733237",
"0.48646176",
"0.4827561",
"0.48271024",
"0.48046353",
"0.4773166",
"0.47669205",
"0.47156936",
"0.471... | 0.6312553 | 0 |
Unban an ip from all DDNet servers. If you pass a name, all currently globally banned ips associated with that name will be unbanned. | async def global_unban(self, ctx: commands.Context, *, name: str):
if re.match(r'^[\d\.-]*$', name) is None:
query = 'SELECT ip FROM ddnet_bans WHERE name = $1;'
ips = [r['ip'] for r in await self.bot.pool.fetch(query, name)]
if not ips:
return await ctx.send(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unban(self, ctx, name: str):\n try:\n bans = await self.bot.get_bans(ctx.message.server)\n user = discord.utils.get(bans, name=name)\n if user is not None:\n await self.bot.unban(ctx.message.server, user)\n except discord.Forbidden:\n ... | [
"0.69601077",
"0.62606454",
"0.62166715",
"0.5990166",
"0.5937297",
"0.59223866",
"0.5848375",
"0.5733963",
"0.5713095",
"0.5705937",
"0.57039034",
"0.5630587",
"0.56287026",
"0.5598197",
"0.55778",
"0.5549266",
"0.55139863",
"0.547942",
"0.54626197",
"0.5460259",
"0.5442353"... | 0.8504455 | 0 |
Get the definition of this managed folder. The definition contains name, description checklists, tags, connection and path parameters, metrics and checks setup. | def get_definition(self):
return self.client._perform_json(
"GET", "/projects/%s/managedfolders/%s" % (self.project_key, self.odb_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_definition(self):\n return self.definition",
"def get_definition(self):\n return self.client._perform_json(\n \"GET\", \"/admin/groups/%s\" % self.name)",
"def definition(self):\n\n return self._definition",
"def definition(self):\n\n return self._definition",
... | [
"0.5817693",
"0.57296735",
"0.5583368",
"0.5583368",
"0.5496289",
"0.5493704",
"0.5425934",
"0.5191441",
"0.51887023",
"0.51887023",
"0.51505697",
"0.5133599",
"0.5114542",
"0.511077",
"0.510388",
"0.50844294",
"0.5081377",
"0.5072677",
"0.5038703",
"0.5038015",
"0.50089884",... | 0.65869796 | 0 |
Set the definition of this managed folder. | def set_definition(self, definition):
return self.client._perform_json(
"PUT", "/projects/%s/managedfolders/%s" % (self.project_key, self.odb_id),
body=definition) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def definition(self, definition):\n\n self._definition = definition",
"def set_definition(self, definition):\n return self.client._perform_json(\n \"PUT\", \"/admin/groups/%s\" % self.name,\n body = definition)",
"def _set_definition(self, definition: Dict[str, Any]):\n ... | [
"0.6675459",
"0.6660227",
"0.63897157",
"0.6099818",
"0.60483444",
"0.5964043",
"0.58501714",
"0.5540315",
"0.55372936",
"0.5477834",
"0.5394551",
"0.5355961",
"0.5321546",
"0.53073615",
"0.5296438",
"0.5226685",
"0.52230346",
"0.52160645",
"0.5206463",
"0.5166973",
"0.515407... | 0.7764521 | 0 |
Get a file from the managed folder | def get_file(self, path):
return self.client._perform_raw(
"GET", "/projects/%s/managedfolders/%s/contents/%s" % (self.project_key, self.odb_id, utils.quote(path))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fs_get_file(url, working_dir):\n if not os.path.isabs(url) and working_dir:\n url = os.path.join(working_dir, url)\n\n try:\n with codecs.open(url, 'r', encoding='utf-8') as f:\n return f.read()\n except Exception as e:\n raise ScrBaseExcept... | [
"0.6983217",
"0.6982181",
"0.67835194",
"0.67477846",
"0.6745828",
"0.6731098",
"0.66658807",
"0.6599749",
"0.6590214",
"0.654747",
"0.65451306",
"0.65048134",
"0.6465553",
"0.64533436",
"0.64236987",
"0.6402294",
"0.6359911",
"0.6332184",
"0.6332184",
"0.63053685",
"0.629940... | 0.75442284 | 0 |
Delete a file from the managed folder | def delete_file(self, path):
return self.client._perform_empty(
"DELETE", "/projects/%s/managedfolders/%s/contents/%s" % (self.project_key, self.odb_id, utils.quote(path))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, filename):\n pass",
"def delete_file(file_id):\n file_obj = Data.objects.get(id=file_id)\n print(\"Removing file: \", file_obj.name)\n print(file_obj.file.path)\n file_dir = file_obj.file.path\n os.remove(file_dir)\n print(\"Done.\")",
"def delete(self, filename, **kw)... | [
"0.77171427",
"0.7711893",
"0.7555799",
"0.7529862",
"0.7435636",
"0.7412828",
"0.7405208",
"0.7381543",
"0.7283083",
"0.72761863",
"0.72573847",
"0.7255518",
"0.7244785",
"0.7224803",
"0.721601",
"0.7209082",
"0.718607",
"0.7183738",
"0.7181639",
"0.7163021",
"0.7153897",
... | 0.7846849 | 0 |
Upload the content of a folder to a managed folder. | def upload_folder(self, path, folder):
for root, _, files in os.walk(folder):
for file in files:
filename = os.path.join(root, file)
with open(filename, "rb") as f:
rel_posix_path = "/".join(os.path.relpath(filename, folder).split(os.sep))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload(self, folder, recursive=True, test=False):\n return self._gphotocli_image_tasks.upload(folder, recursive, test)",
"def UploadFolderToGD(token_path, source_path, gd_folder): \n google_drive = ConnectGoogleDrive(token_path)\n file_cmd = spike.FileCMD()\n file_list = file_cmd.ListFiles(so... | [
"0.6675317",
"0.65023863",
"0.65004486",
"0.63931644",
"0.6374531",
"0.6330987",
"0.62475437",
"0.6244524",
"0.61936384",
"0.6177249",
"0.61518073",
"0.6149765",
"0.6138441",
"0.6122861",
"0.6103507",
"0.60236096",
"0.6016508",
"0.60020953",
"0.59947294",
"0.5948904",
"0.5944... | 0.7008945 | 0 |
Get the last values of the metrics on this managed folder. | def get_last_metric_values(self):
return ComputedMetrics(self.client._perform_json(
"GET", "/projects/%s/managedfolders/%s/metrics/last" % (self.project_key, self.odb_id))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last(self):\n data = self._http_get(\"last\")\n return data.json()",
"def getLatestSpectrumMeasurements(self): \n return self.spectrum[len(self.spectrum)-1]",
"def getLatestMeasurement(self): \n return self.measurement[len(self.measurement)-1]",
"def last_value(s... | [
"0.64085966",
"0.63444847",
"0.63409215",
"0.62631094",
"0.62495613",
"0.62179077",
"0.61889714",
"0.61730325",
"0.6146713",
"0.61448973",
"0.6101925",
"0.6096707",
"0.6094985",
"0.6079614",
"0.60533327",
"0.60533327",
"0.6048",
"0.6036222",
"0.6022216",
"0.594147",
"0.593541... | 0.80391484 | 0 |
Get the history of the values of a metric on this managed folder. | def get_metric_history(self, metric):
return self.client._perform_json(
"GET", "/projects/%s/managedfolders/%s/metrics/history" % (self.project_key, self.odb_id),
params={'metricLookup' : metric if isinstance(metric, str) or isinstance(metric, unicode) else json.dumps(metric)}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value_history(self):\n return self.value_history",
"def get_history(self):\n return self.history",
"def history(self):\n return self.info['history']",
"def get_history(self):\n return self.__history[:]",
"def get_history(self):\r\n\r\n return self.board_history",
"d... | [
"0.7165081",
"0.7030458",
"0.6927986",
"0.68705124",
"0.6810044",
"0.6718102",
"0.6691567",
"0.6691567",
"0.6686829",
"0.6673763",
"0.6653554",
"0.6653554",
"0.65635055",
"0.65367013",
"0.65315855",
"0.6509732",
"0.64998275",
"0.6481372",
"0.64430577",
"0.6438002",
"0.6354089... | 0.77961314 | 0 |
Get the flow zone of this managed folder. | def get_zone(self):
return self.project.get_flow().get_zone_of_object(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zone(self):\n return self._zone",
"def access_zone(self):\n return self._access_zone",
"def zone(self) -> str:\n return self._zone",
"def zone(self) -> str:\n return pulumi.get(self, \"zone\")",
"def zone(self) -> str:\n return pulumi.get(self, \"zone\")",
"def loca... | [
"0.64082503",
"0.6311886",
"0.6157333",
"0.6036838",
"0.6036838",
"0.59640765",
"0.59602046",
"0.5879423",
"0.58616424",
"0.58191",
"0.5772731",
"0.5772731",
"0.5696067",
"0.56114745",
"0.55910367",
"0.55511653",
"0.55193275",
"0.54935896",
"0.5492465",
"0.54857844",
"0.54575... | 0.75278246 | 0 |
Move this object to a flow zone. | def move_to_zone(self, zone):
if isinstance(zone, basestring):
zone = self.project.get_flow().get_zone(zone)
zone.add_item(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_stage_to_z(self, z):\n raise NotImplementedError",
"def move(self):\n pass",
"def move(self):\n raise NotImplementedError",
"def move_to(self, mobject_or_point):\n layer_center = self.surrounding_rectangle.get_center()\n if isinstance(mobject_or_point, Mobject):\n ... | [
"0.6282164",
"0.6204604",
"0.5991178",
"0.5983192",
"0.59183925",
"0.5749237",
"0.5678627",
"0.5613564",
"0.557024",
"0.5564908",
"0.55558306",
"0.5479993",
"0.5476635",
"0.54687375",
"0.545523",
"0.54463863",
"0.54068005",
"0.53963697",
"0.53693956",
"0.53560627",
"0.5351554... | 0.72328943 | 0 |
Share this object to a flow zone. | def share_to_zone(self, zone):
if isinstance(zone, basestring):
zone = self.project.get_flow().get_zone(zone)
zone.add_shared(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_zone(self, zone):\n if isinstance(zone, basestring):\n zone = self.project.get_flow().get_zone(zone)\n zone.add_item(self)",
"def flow(self, flow):\n\n self._flow = flow",
"def update_flow(self, flow):\r\n self.flow = flow",
"def transfer(self):\n pass... | [
"0.5932415",
"0.59072703",
"0.5562259",
"0.55534965",
"0.54047054",
"0.53833073",
"0.536776",
"0.5333624",
"0.5330987",
"0.5305724",
"0.52923506",
"0.5281795",
"0.5245011",
"0.52386606",
"0.52386606",
"0.52386606",
"0.5230287",
"0.5215504",
"0.516134",
"0.5156009",
"0.5132243... | 0.7893951 | 0 |
Unshare this object from a flow zone. | def unshare_from_zone(self, zone):
if isinstance(zone, basestring):
zone = self.project.get_flow().get_zone(zone)
zone.remove_shared(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpossessed(self):\r\n self.owner = None",
"def unblock(self, source):\n raise NotImplementedError",
"def unShare(sharedItem):\n sharedItem.store.query(Share, Share.sharedItem == sharedItem).deleteFromStore()",
"def unassign_instance(InstanceId=None):\n pass",
"def __del__(self):\n ... | [
"0.601934",
"0.59649634",
"0.59522724",
"0.57343334",
"0.5674939",
"0.56622416",
"0.5578648",
"0.55039036",
"0.5499391",
"0.54815376",
"0.5437976",
"0.5432895",
"0.54314196",
"0.542576",
"0.53983927",
"0.5378879",
"0.5366127",
"0.53503096",
"0.53274274",
"0.5304955",
"0.52901... | 0.8114609 | 0 |
Get a handle to manage discussions on the managed folder. | def get_object_discussions(self):
return DSSObjectDiscussions(self.client, self.project_key, "MANAGED_FOLDER", self.odb_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object_discussions(self):\n return DSSObjectDiscussions(self.client, self.project_key, \"RECIPE\", self.recipe_name)",
"def discussion(cls, user, discussion):\n pass",
"def discussion(cls, user, discussion):\r\n pass",
"def get_discussion(course):\r\n\r\n # the discussion_... | [
"0.54230756",
"0.5351559",
"0.53328663",
"0.5113142",
"0.5088055",
"0.5067406",
"0.48653966",
"0.4814929",
"0.47993654",
"0.47993654",
"0.4738103",
"0.47297895",
"0.4671899",
"0.4656283",
"0.4654367",
"0.46461034",
"0.46381405",
"0.46381405",
"0.46381405",
"0.46081758",
"0.45... | 0.61799204 | 0 |
Save the changes to the settings on the managed folder. | def save(self):
self.folder.client._perform_empty(
"PUT", "/projects/%s/managedfolders/%s" % (self.folder.project_key, self.folder.odb_id),
body=self.settings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\n self.client._perform_empty(\"PUT\", \"/project-folders/%s/settings\" % (self.project_folder_id), body = self.settings)",
"def saveSettings(self):\n self.userFiles.applyData()\n self.userPersonal.applyData()",
"def save(self):\n return self.client._perform_empty(\"P... | [
"0.76129395",
"0.72382766",
"0.7231987",
"0.7208549",
"0.7072421",
"0.70549095",
"0.69852805",
"0.6924624",
"0.6886411",
"0.68704027",
"0.684195",
"0.6815835",
"0.6777165",
"0.67606515",
"0.6706621",
"0.6703455",
"0.66838694",
"0.66620696",
"0.66322386",
"0.6589611",
"0.65859... | 0.7415783 | 1 |
Add a discrete partitioning dimension. | def add_discrete_partitioning_dimension(self, dim_name):
self.settings["partitioning"]["dimensions"].append({"name": dim_name, "type": "value"}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_partition(self):\n\t\treturn handle_to_object(call_sdk_function('PrlVmDevHd_AddPartition', self.handle))",
"def add_time_partitioning_dimension(self, dim_name, period=\"DAY\"):\n self.settings[\"partitioning\"][\"dimensions\"].append({\"name\": dim_name, \"type\": \"time\", \"params\":{\"period\":... | [
"0.5996331",
"0.59021497",
"0.5741625",
"0.563048",
"0.563048",
"0.55876046",
"0.5564135",
"0.55327845",
"0.54887104",
"0.5450582",
"0.5427648",
"0.54159683",
"0.5277757",
"0.5268855",
"0.5246866",
"0.5199661",
"0.513178",
"0.50552285",
"0.5037322",
"0.5004306",
"0.49957278",... | 0.8221045 | 0 |
Add a time partitioning dimension. | def add_time_partitioning_dimension(self, dim_name, period="DAY"):
self.settings["partitioning"]["dimensions"].append({"name": dim_name, "type": "time", "params":{"period": period}}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_discrete_partitioning_dimension(self, dim_name):\n self.settings[\"partitioning\"][\"dimensions\"].append({\"name\": dim_name, \"type\": \"value\"})",
"def add_timedim(data, date=\"1970-01-01\"):\n if isinstance(data, xr.DataArray):\n if \"time\" in data.dims:\n raise ValueErr... | [
"0.63332134",
"0.6205126",
"0.56875503",
"0.5681772",
"0.5438656",
"0.5215479",
"0.52103144",
"0.52042055",
"0.5199717",
"0.5189618",
"0.5118998",
"0.5118998",
"0.511268",
"0.5108713",
"0.50541395",
"0.5043726",
"0.50367475",
"0.5027835",
"0.5004906",
"0.49656916",
"0.4962021... | 0.8382509 | 0 |
Set the partitioning pattern of the folder. The pattern indicates which paths inside the folder belong to | def set_partitioning_file_pattern(self, pattern):
self.settings["partitioning"]["filePathPattern"] = pattern | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSplitPattern(self, value):\n return self._set(splitPattern=value)",
"def setSplitPattern(self, value):\n return self._set(splitPattern=value)",
"def pattern(self, pattern):\n if pattern is None:\n raise ValueError(\"Invalid value for `pattern`, must not be `None`\") # no... | [
"0.6177902",
"0.6177902",
"0.5773725",
"0.57375664",
"0.5704174",
"0.558471",
"0.54004574",
"0.522178",
"0.522178",
"0.5215508",
"0.5176763",
"0.51129144",
"0.51109886",
"0.5100194",
"0.5096467",
"0.5093923",
"0.5066452",
"0.5036985",
"0.49579346",
"0.4954718",
"0.4954279",
... | 0.83221745 | 0 |
Get the predicted cost for each of the actions given the provided context. | def get_costs_per_action(self, context: np.ndarray) -> Dict[Action, Cost]:
costs_per_action = {}
for action in self._get_actions():
if self.categorize_actions:
action_one_hot = self._get_actions_one_hot(action)
x = np.append(action_one_hot, context)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, context: np.ndarray) -> np.ndarray:\n n_rounds_of_new_data = context.shape[0]\n ones_n_rounds_arr = np.ones(n_rounds_of_new_data, int)\n estimated_rewards_by_reg_model = np.zeros(\n (n_rounds_of_new_data, self.n_actions, self.len_list)\n )\n for actio... | [
"0.6950889",
"0.6194891",
"0.6161221",
"0.5940927",
"0.5893304",
"0.5862886",
"0.5833096",
"0.57626337",
"0.57062304",
"0.56541",
"0.5639965",
"0.5606558",
"0.5593295",
"0.5560387",
"0.5553072",
"0.55465263",
"0.5540782",
"0.55235296",
"0.55216396",
"0.54918563",
"0.54878634"... | 0.748326 | 0 |
Predict an action given a context. | def predict(
self,
context: np.ndarray,
epsilon: Prob = 0.05,
exploration_width: int = 1,
exploration_strategy: str = "smart",
) -> Tuple[Action, Prob]:
def _get_direction(action_change: Action) -> Optional[str]:
if action_change < 0:
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_fn(future_action, state):\n model = get_model()\n rewards = model((state, future_action))\n return {\"reward\": rewards}",
"def fit_predict(\n self,\n context: np.ndarray,\n action: np.ndarray,\n reward: np.ndarray,\n pscore: Optional[np.ndarray] = None,\n ... | [
"0.68578327",
"0.66418797",
"0.66278553",
"0.6600217",
"0.6558365",
"0.6513659",
"0.6338011",
"0.6164591",
"0.6121328",
"0.61089677",
"0.61044675",
"0.6058313",
"0.6042822",
"0.601579",
"0.59879005",
"0.59817743",
"0.5955881",
"0.5951787",
"0.5791318",
"0.5769036",
"0.5753873... | 0.6694794 | 1 |
Tests na_element gets appended as child. | def test_setter_na_element(self):
root = netapp_api.NaElement('root')
root['e1'] = netapp_api.NaElement('nested')
self.assertEqual(len(root.get_children()), 1)
e1 = root.get_child_by_name('e1')
self.assertIsInstance(e1, netapp_api.NaElement)
self.assertIsInstance(e1.get_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_setter_na_element(self):\n root = netapp_api.NaElement('root')\n root['e1'] = netapp_api.NaElement('nested')\n self.assertEqual(1, len(root.get_children()))\n e1 = root.get_child_by_name('e1')\n self.assertIsInstance(e1, netapp_api.NaElement)\n self.assertIsInstan... | [
"0.67987376",
"0.63512254",
"0.6176601",
"0.6144186",
"0.60023457",
"0.5950926",
"0.59426093",
"0.5894436",
"0.5872535",
"0.58458453",
"0.58127284",
"0.58080167",
"0.5802401",
"0.5756666",
"0.57045996",
"0.5687755",
"0.5677121",
"0.5653698",
"0.5644743",
"0.56394815",
"0.5633... | 0.67678875 | 1 |
Tests dict is appended as child to root. | def test_setter_child_dict(self):
root = netapp_api.NaElement('root')
root['d'] = {'e1': 'v1', 'e2': 'v2'}
e1 = root.get_child_by_name('d')
self.assertIsInstance(e1, netapp_api.NaElement)
sub_ch = e1.get_children()
self.assertEqual(len(sub_ch), 2)
for c in sub_ch:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_setter_child_dict(self):\n root = netapp_api.NaElement('root')\n root['d'] = {'e1': 'v1', 'e2': 'v2'}\n e1 = root.get_child_by_name('d')\n self.assertIsInstance(e1, netapp_api.NaElement)\n sub_ch = e1.get_children()\n self.assertEqual(2, len(sub_ch))\n for ... | [
"0.692969",
"0.62596947",
"0.6051907",
"0.6033617",
"0.6024387",
"0.6024387",
"0.6024387",
"0.6024387",
"0.6024387",
"0.5993601",
"0.5961713",
"0.5925168",
"0.5859408",
"0.58378726",
"0.58262926",
"0.58179736",
"0.58094585",
"0.5797076",
"0.575363",
"0.57313854",
"0.57068044"... | 0.6954826 | 0 |
Tests list/tuple are appended as child to root. | def test_setter_child_list_tuple(self):
root = netapp_api.NaElement('root')
root['l'] = ['l1', 'l2']
root['t'] = ('t1', 't2')
l = root.get_child_by_name('l')
self.assertIsInstance(l, netapp_api.NaElement)
t = root.get_child_by_name('t')
self.assertIsInstance(t, ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_setter_child_list_tuple(self):\n root = netapp_api.NaElement('root')\n root['l'] = ['l1', 'l2']\n root['t'] = ('t1', 't2')\n l_element = root.get_child_by_name('l')\n self.assertIsInstance(l_element, netapp_api.NaElement)\n t = root.get_child_by_name('t')\n ... | [
"0.70010734",
"0.65542954",
"0.63257587",
"0.6279599",
"0.62566125",
"0.6221631",
"0.6212001",
"0.6183939",
"0.6152893",
"0.61014795",
"0.60733724",
"0.60378975",
"0.59894735",
"0.5981031",
"0.5951861",
"0.5948126",
"0.5942114",
"0.59398097",
"0.5915376",
"0.5901368",
"0.5882... | 0.70634353 | 0 |
Get sentiment analysis immediately on document save | def get_sentiment_analysis(sender, instance, **kwargs):
text_analysis = TextAnalysis(instance.text)
# Prevent sentiment_analysis API call every time the document is saved
if instance.sentiment_analysis is None:
instance.get_sentiment_analysis() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_analytics(self):\n\n headers = {\n # Request headers\n 'Content-Type': 'application/json',\n 'Ocp-Apim-Subscription-Key': self.keys['text_analytics'],\n }\n \n sentiment_url = 'https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/senti... | [
"0.66183805",
"0.63964885",
"0.63705045",
"0.63385326",
"0.63300335",
"0.6323211",
"0.62792253",
"0.61452967",
"0.61425865",
"0.6107899",
"0.608918",
"0.60816747",
"0.60478175",
"0.6037236",
"0.59819293",
"0.59520787",
"0.5950468",
"0.5949469",
"0.5940747",
"0.5906748",
"0.59... | 0.69361526 | 0 |
This function is used in the property self.embeddings. | def set_embeddings(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_movie_embedding(self):\n raise NotImplementedError(\"has to be overwritten\")",
"def add_embedding(self):\n ### YOUR CODE HERE (~4-6 lines)\n embeddingTensor = tf.Variable(self.pretrained_embeddings)\n embeddings = tf.nn.embedding_lookup(embeddingTensor, self.input_placeholder... | [
"0.74282503",
"0.702405",
"0.68440545",
"0.6790293",
"0.6766997",
"0.6700022",
"0.6659412",
"0.6578466",
"0.6472033",
"0.6452144",
"0.6434908",
"0.6428523",
"0.6398044",
"0.6394544",
"0.6383916",
"0.6372758",
"0.63573927",
"0.63538617",
"0.63432187",
"0.633421",
"0.6262197",
... | 0.8120444 | 0 |
For each string, output 1 if the DFA accepts it, 0 otherwise. The input is guaranteed to be a DFA. | def task_4(parser):
dfa = parser.parse_fa()
test_strings = parser.parse_test_strings()
# calculate and print acceptance for each string
for string in test_strings:
if follow_dfa(dfa["graph"][dfa["start"]], string):
print("1")
else:
print("0")
print("end") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, s):\n state = self._initial\n try:\n for sym in s:\n state = self._trans_matrix[state][self._syms_to_indices[sym]]\n except KeyError:\n raise NotInAlphabetError(sym) from None\n return state in self._accepting",
"def isogram():\n... | [
"0.6033226",
"0.5742265",
"0.5733216",
"0.56888366",
"0.56711626",
"0.56197566",
"0.5588654",
"0.5418547",
"0.5407468",
"0.5398522",
"0.5388671",
"0.5385906",
"0.5385906",
"0.5385906",
"0.5385906",
"0.53602785",
"0.53272057",
"0.52750105",
"0.5264539",
"0.5249218",
"0.5243929... | 0.63068765 | 0 |
get access token from wxapi this is the second step to login with wechat after the client get the code | def get_access_token(self, code):
url = get_config("login.wechat.access_token_url") % code
r = self._access_wxapi_or_raise(url)
return (r["access_token"], r["openid"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token(self, code):\n\n # live need post a form to get token\n headers = {'Content-type': 'application/x-www-form-urlencoded'}\n data = {\n 'client_id': get_config('login.live.client_id'),\n 'client_secret': get_config('login.live.client_secret'),\n 'red... | [
"0.6793707",
"0.67241335",
"0.6619643",
"0.6482753",
"0.64813423",
"0.6452798",
"0.6423836",
"0.64193034",
"0.64193034",
"0.63922495",
"0.63754576",
"0.6291259",
"0.6257184",
"0.62232846",
"0.6198705",
"0.6198705",
"0.6197053",
"0.61913085",
"0.6176826",
"0.61711794",
"0.6151... | 0.7249641 | 0 |
get user info from wxapi this is the final step to login with wechat | def get_user_info(self, access_token, openid):
url = get_config("login.wechat.user_info_url") % (access_token, openid)
return self._access_wxapi_or_raise(url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_login():\n \n data = user_obj.user_login()\n return data",
"def login(self):",
"def login():",
"def login():",
"def log_in(self, ctx: Context):\n email = json.loads(ctx.users)['username']\n password = json.loads(ctx.users)['password']\n InputFunctions.send_keys_to_ele... | [
"0.6570302",
"0.6333091",
"0.62763906",
"0.62763906",
"0.6231804",
"0.6212389",
"0.620589",
"0.6194151",
"0.612593",
"0.6112595",
"0.61102265",
"0.6109876",
"0.60988086",
"0.6087747",
"0.6087747",
"0.606966",
"0.6067771",
"0.6058907",
"0.60572743",
"0.6048634",
"0.60352176",
... | 0.65810204 | 0 |
Get qq access token | def get_token(self, code, redirect_uri):
token_resp = get_remote(get_config("login.qq.access_token_url") % (redirect_uri, code))
if token_resp.find('callback') == 0:
error = json.loads(token_resp[10:-4])
raise Exception(error)
query = qs_dict(token_resp)
return q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_access_token(self, request) -> str or Exception:\n pass",
"def access_token(self):\n return self.access_token_str",
"def getAccessToken(self):\r\n\r\n #lets see if we have an oauth code\r\n if self.oauthToken is None:\r\n self.oauthToken = self.createAccessToken\r\n\r... | [
"0.7010284",
"0.6989711",
"0.6904486",
"0.68345237",
"0.6801059",
"0.67715067",
"0.6744162",
"0.67331374",
"0.67299163",
"0.66792107",
"0.6677348",
"0.66704553",
"0.66563576",
"0.6632723",
"0.66103107",
"0.66000867",
"0.65999943",
"0.65748245",
"0.6555147",
"0.6550575",
"0.65... | 0.7126429 | 0 |
generate 2 random numbers to add get input as addition answer check if correct, if right countdown to get 3 in a row right to end program if wrong lets keep adding and restart the 3 in a row count down | def main():
min_random = 10 #keeping constant for the min random number range
max_random = 99 #keeping constant for the max random number range
count = 0 #creating a counter variable to keep track of user's answers in a row
while count != 3: #this loop will keep goin until user get 3 answers correct i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n correct = 0\n\n while correct < GOAL:\n #random.seed(1)\n ##set up addition problem:\n num1 = random.randint(RAND_MIN, RAND_MAX)\n num2 = random.randint(RAND_MIN, RAND_MAX)\n ans = num1 + num2\n\n ##print and solve addition problem:\n print(\"Wha... | [
"0.73614657",
"0.70625",
"0.6931597",
"0.67691684",
"0.65652305",
"0.6021567",
"0.5964148",
"0.5895458",
"0.58120376",
"0.5797901",
"0.5791938",
"0.5759847",
"0.57452613",
"0.57439905",
"0.573757",
"0.56791544",
"0.5662617",
"0.56588566",
"0.5658514",
"0.5648855",
"0.5645049"... | 0.75160843 | 0 |
Loads acquisition data Returns PD DataFrame | def pd_load_acquisition_csv(acquisition_path, **kwargs):
columns = [
'loan_id', 'orig_channel', 'seller_name', 'orig_interest_rate', 'orig_upb', 'orig_loan_term',
'orig_date', 'first_pay_date', 'orig_ltv', 'orig_cltv', 'num_borrowers', 'dti', 'borrower_credit_score',
'first_home_buyer', 'lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pd_load_acquisition_csv(acquisition_path, **kwargs):\n\n cols = [\n 'loan_id', 'orig_channel', 'seller_name', 'orig_interest_rate', 'orig_upb', 'orig_loan_term',\n 'orig_date', 'first_pay_date', 'orig_ltv', 'orig_cltv', 'num_borrowers', 'dti', 'borrower_credit_score',\n 'first_home_buye... | [
"0.6419686",
"0.6402017",
"0.63575786",
"0.62864983",
"0.6271366",
"0.62537175",
"0.6238884",
"0.62184477",
"0.61879724",
"0.6175933",
"0.6175492",
"0.61639774",
"0.61547565",
"0.6142899",
"0.6125022",
"0.60660636",
"0.60647833",
"0.60528654",
"0.6033451",
"0.60246754",
"0.60... | 0.6446527 | 0 |
quote the elements of a dotted name | def quote_dotted(
name: Union["quoted_name", str], quote: functools.partial
) -> Union["quoted_name", str]:
if isinstance(name, quoted_name):
return quote(name)
result = ".".join([quote(x) for x in name.split(".")])
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dotted_name(s):\n forbidden = forbidden_chars.intersection(s)\n if forbidden:\n raise ValueError('%(s)s contains forbidden characters'\n ' (%(forbidden)s)'\n % locals())\n if not s:\n return ''\n elif s in reserved_names:\n raise ValueError('The na... | [
"0.6540108",
"0.64451617",
"0.6417363",
"0.6304107",
"0.58152014",
"0.5777598",
"0.5726563",
"0.57090414",
"0.5696863",
"0.5691718",
"0.56322443",
"0.550168",
"0.5483858",
"0.5444921",
"0.54370934",
"0.5433207",
"0.53710306",
"0.53705055",
"0.5365929",
"0.5365884",
"0.5363487... | 0.745443 | 0 |
Convert text to float or 0.0 if invalid. | def convert_to_number(text):
try:
value = float(text)
return value
except ValueError:
return 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ffloat(string):\n try:\n return float(string.strip())\n except:\n return 0",
"def _convert_to_float(s):\n try:\n return float(s)\n except:\n return s",
"def safe_float(str):\n if not str:\n return None\n try:\n return float(str)\n ... | [
"0.7549978",
"0.7463989",
"0.73810375",
"0.73316866",
"0.7268213",
"0.7146606",
"0.7116986",
"0.7115148",
"0.7079289",
"0.7048062",
"0.69954073",
"0.6994393",
"0.69855756",
"0.69264966",
"0.6895625",
"0.68766963",
"0.68540186",
"0.68069357",
"0.679633",
"0.6766438",
"0.674790... | 0.7922715 | 0 |
persist tweet data into cassandra | def persist_data(tweet_data, cassandra_session):
try:
logger.debug('Start to persist data to cassandra %s \n', tweet_data)
parsed = json.loads(tweet_data)
unit_id = str(parsed.get('_unit_id'))
gender = parsed.get('gender')
tweet_text = str(parsed.get('text'))
hashtags... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def persist_db(database, tweets):\n log.debug(\"{} tweets to db\".format(len(tweets)))\n\n for tweet in tweets:\n tweet['_id'] = tweet['id_str']\n database.update(tweets)",
"def insert_tweets(conn: Connection, fetch_data: Iterable[Dict]) -> None:\n\n s = Session(bind=conn)\n meta = MetaData... | [
"0.7387163",
"0.67616653",
"0.66996026",
"0.66227996",
"0.66101587",
"0.6543893",
"0.6499494",
"0.6354981",
"0.623357",
"0.60689884",
"0.6036905",
"0.6031254",
"0.59903",
"0.593716",
"0.59077364",
"0.5884541",
"0.58744943",
"0.5866427",
"0.58403707",
"0.5819588",
"0.5809459",... | 0.78405553 | 0 |
Create an Nbin discrete colormap from a specified input map | def discrete_cmap(N, base_cmap=None):
base = plt.get_cmap(base_cmap)
color_list = base(np.linspace(0, 1, N))
cmap_name = base.name + str(N)
return base.from_list(cmap_name, color_list, N) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n # see https://gist.github.com/jakevdp/91077b0cae40f8f8244a\n base = plt.cm.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None... | [
"0.72187954",
"0.69491076",
"0.6924096",
"0.6924096",
"0.6924096",
"0.6920645",
"0.69188344",
"0.69188344",
"0.69188344",
"0.69188344",
"0.69142735",
"0.69021994",
"0.67898613",
"0.6699816",
"0.6696647",
"0.6689399",
"0.6646159",
"0.6633695",
"0.65624946",
"0.65356964",
"0.64... | 0.73025054 | 0 |
Plot the Fisher/mutual information after the linear layer in a network of unstructured weights, averaged over many repetitions, as a function of network size. | def unstruct_weight_plot_mu(
Ns, mus, sigma, repetitions, plot, design='lognormal',
sigmaP=1., sigmaS=1., sigmaC=1., fax=None
):
# create plot
if fax is None:
fig, ax = plt.subplots(1, 1, figsize=(8, 8))
else:
fig, ax = fax
# create data arrays
data = np.zeros((Ns.size, mus.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize(self, network, f):\n import matplotlib\n matplotlib.use('Agg',warn=False)\n import matplotlib.pyplot as plt\n # Convert to a network if it is not.\n if not isinstance(network, NeuralNetwork):\n network = NeuralNetwork(network)\n \n fig = plt... | [
"0.6225357",
"0.6089174",
"0.59853345",
"0.598065",
"0.5882383",
"0.58234656",
"0.58226746",
"0.5817316",
"0.57622045",
"0.57604235",
"0.57364094",
"0.5720234",
"0.56863946",
"0.5683019",
"0.5672461",
"0.5671478",
"0.5671478",
"0.5671162",
"0.5670977",
"0.56598586",
"0.565555... | 0.6197951 | 1 |
Plots the asymptotic coefficients for the. | def plot_asymptotic_coefficients(filename, fax=None):
# create plot
labels = [1, 2, 3]
# create plot
if fax is None:
fig, ax = plt.subplots(1, 1, figsize=(8, 8))
else:
fig, ax = fax
coef_file = h5py.File(filename, 'r')
sigmaP_vals = list(coef_file)
ks = np.arange(1, 26)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_fitting_coefficients(self):\n from matplotlib import pyplot as plt\n coeff = self.linear_fit[\"coeff\"]\n order = self.linear_fit[\"order\"]\n\n data = {}\n annotations = {}\n for c, o in zip(coeff, order):\n if len(o) == 0:\n continue\n ... | [
"0.7514957",
"0.675888",
"0.66593856",
"0.66397125",
"0.65040374",
"0.6465431",
"0.64535564",
"0.64405936",
"0.6402966",
"0.63325644",
"0.63293165",
"0.63066345",
"0.6284987",
"0.62760645",
"0.62508875",
"0.62294936",
"0.6181468",
"0.61633366",
"0.6143691",
"0.6139784",
"0.61... | 0.68084884 | 1 |
Sets y attribute with exceptions | def y(self, value):
self.data_validator("y", value)
self.__y = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setY(self, y):\n self.y = y\n pass",
"def setY(self, y):\r\n\t\tself._y=y",
"def set_y(self, y: float):\n self.y = y",
"def y(self, value):\n self.validate_input(y=value)\n self.__y = value",
"def set_y(self, new_y):\r\n self.y = new_y",
"def y(self, value):\... | [
"0.73010266",
"0.7284235",
"0.7217349",
"0.7144914",
"0.7122965",
"0.71036816",
"0.7090068",
"0.707471",
"0.70422107",
"0.70308393",
"0.7030658",
"0.7030658",
"0.68635017",
"0.68199414",
"0.68199414",
"0.67532015",
"0.6728125",
"0.6710675",
"0.6618399",
"0.6606974",
"0.653372... | 0.740591 | 0 |
Regenerate key for a topic. Regenerate a shared access key for a topic. | def regenerate_key(
self, resource_group_name, topic_name, key_name, custom_headers=None, raw=False, **operation_config):
regenerate_key_request = models.TopicRegenerateKeyRequest(key_name=key_name)
# Construct URL
url = self.regenerate_key.metadata['url']
path_format_argume... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def generate_new_refesh_key(payload: dict = Depends(get_jwt_payload)):\n if payload[\"type\"] != \"refresh\":\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=\"You gave the access key, but we need the refresh key\",\n headers={\"WWW-Authe... | [
"0.6181185",
"0.5912194",
"0.57736045",
"0.5653259",
"0.5649086",
"0.5508733",
"0.5508396",
"0.5505565",
"0.547415",
"0.53989816",
"0.5356546",
"0.5315606",
"0.5276495",
"0.52314806",
"0.52309495",
"0.52278566",
"0.51943773",
"0.5139199",
"0.51312166",
"0.51285356",
"0.512390... | 0.66592574 | 0 |
Place a sell limit order with given quantity and price. | def limit_sell(self, order_id, quantity, price):
Library.functions.limit_sell(self._book, order_id, quantity, price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sell_limit_order(self, price=0, volume=0):\n auth = CoinbaseExchangeAuth(self.api_key, self.secret_key, self.passphrase)\n data = {\n \"size\": volume,\n \"price\": price,\n \"side\": \"sell\",\n \"product_id\": self.rate,\n \"type\": \"limit... | [
"0.7925371",
"0.78168416",
"0.75428194",
"0.7417188",
"0.7071134",
"0.70346624",
"0.6954648",
"0.69130063",
"0.69096357",
"0.6874446",
"0.6859875",
"0.6753681",
"0.66568744",
"0.6572149",
"0.6491404",
"0.6474029",
"0.64717853",
"0.6457523",
"0.6403897",
"0.64003015",
"0.63966... | 0.7997252 | 0 |
Return true if the order with given ID is in the book, false otherwise. | def has(self, order_id):
return Library.functions.has(self._book, order_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_bookid(self,book_id):\r\n if int(book_id) in [i.book_id for i in self.issued_books]:\r\n return True\r\n else:\r\n return False",
"def has_book(self, book):\n return self.books.filter(lists_books.c.book_id == book.id).count() > 0",
"def check_if_exists(se... | [
"0.7184754",
"0.67059475",
"0.66672266",
"0.6560992",
"0.6473398",
"0.6266325",
"0.6255005",
"0.62520516",
"0.6207968",
"0.60897744",
"0.59901696",
"0.5943703",
"0.5933619",
"0.5922701",
"0.5920018",
"0.5893061",
"0.5883331",
"0.5859028",
"0.5831498",
"0.5804595",
"0.58011097... | 0.8160919 | 0 |
Return the best sell price in the book. | def best_sell(self):
return Library.functions.best_sell(self._book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_buy(self):\n return Library.functions.best_buy(self._book)",
"def get_best_offer(self,way):\n if way==\"BUY\":\n return self.book[Trade.WAY_BUY][0].get_price()\n elif way==\"SELL\":\n return self.book[Trade.WAY_SELL][len(self.book[Trade.WAY_SELL])-1].get_price(... | [
"0.7876577",
"0.77371395",
"0.7511024",
"0.7234025",
"0.7008871",
"0.69746155",
"0.694191",
"0.6918493",
"0.6890469",
"0.685904",
"0.68445",
"0.68308765",
"0.6789738",
"0.6782889",
"0.67679006",
"0.67323667",
"0.669388",
"0.66653705",
"0.6644225",
"0.6625419",
"0.66128826",
... | 0.8430281 | 0 |
Return the best buy price in the book. | def best_buy(self):
return Library.functions.best_buy(self._book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_sell(self):\n return Library.functions.best_sell(self._book)",
"def get_best_offer(self,way):\n if way==\"BUY\":\n return self.book[Trade.WAY_BUY][0].get_price()\n elif way==\"SELL\":\n return self.book[Trade.WAY_SELL][len(self.book[Trade.WAY_SELL])-1].get_pric... | [
"0.78773767",
"0.78276116",
"0.7595051",
"0.7370348",
"0.7110304",
"0.68662673",
"0.682843",
"0.68111056",
"0.6778916",
"0.67588013",
"0.6744359",
"0.673743",
"0.66320306",
"0.66038054",
"0.6591113",
"0.65841454",
"0.6548237",
"0.653549",
"0.6532241",
"0.65042275",
"0.6503913... | 0.8379767 | 0 |
Return the best price for the given side. | def best(self, side):
return Library.functions.best(self._book, side) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_safe_price(side: str):\n return (\n const.MIN_SUM if side == const.BUY\n else const.MAX_SUM\n )",
"def get_best_offer(self,way):\n if way==\"BUY\":\n return self.book[Trade.WAY_BUY][0].get_price()\n elif way==\"SELL\":\n return self.... | [
"0.73120564",
"0.6958201",
"0.67411786",
"0.6623038",
"0.6302165",
"0.6228178",
"0.6109067",
"0.60349244",
"0.60328555",
"0.59425896",
"0.5927218",
"0.58721644",
"0.5837019",
"0.58329946",
"0.57939583",
"0.57860625",
"0.57763773",
"0.5764865",
"0.5751211",
"0.57504004",
"0.57... | 0.80683696 | 0 |
Return the volume of the sell side of the book at the given price. | def volume_sell(self, price=None):
if price is None:
return Library.functions.volume_sell(self._book)
return Library.functions.volume_sell_price(self._book, price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume(self, price=None):\n if price is None:\n return Library.functions.volume(self._book)\n return Library.functions.volume_price(self._book, price)",
"def get_own_volume_at(self, price, typ=None):\r\n volume = 0\r\n for order in self.owns:\r\n if order.pri... | [
"0.82540333",
"0.73508203",
"0.7293334",
"0.7108912",
"0.67721134",
"0.6653987",
"0.6506303",
"0.6498677",
"0.6331713",
"0.62851894",
"0.6253708",
"0.6248566",
"0.6227219",
"0.6194709",
"0.619005",
"0.618927",
"0.61563796",
"0.61169934",
"0.61134404",
"0.6086485",
"0.60847485... | 0.81967163 | 1 |
Return the volume of the buy side of the book at the given price. | def volume_buy(self, price=None):
if price is None:
return Library.functions.volume_buy(self._book)
return Library.functions.volume_buy_price(self._book, price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume(self, price=None):\n if price is None:\n return Library.functions.volume(self._book)\n return Library.functions.volume_price(self._book, price)",
"def volume_sell(self, price=None):\n if price is None:\n return Library.functions.volume_sell(self._book)\n ... | [
"0.82664984",
"0.7516078",
"0.7488547",
"0.7051576",
"0.68015915",
"0.67189145",
"0.65990806",
"0.6527134",
"0.63496965",
"0.6312829",
"0.6272654",
"0.626387",
"0.62559175",
"0.6233882",
"0.6233526",
"0.6188062",
"0.6141007",
"0.6114274",
"0.60632724",
"0.6055284",
"0.605316"... | 0.80440706 | 1 |
Return the volume of the book at the given price. | def volume(self, price=None):
if price is None:
return Library.functions.volume(self._book)
return Library.functions.volume_price(self._book, price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_own_volume_at(self, price, typ=None):\r\n volume = 0\r\n for order in self.owns:\r\n if order.price == price and (not typ or typ == order.typ):\r\n volume += order.volume\r\n return volume",
"def get_volume(self, ticker):\n return self.trading_client.... | [
"0.74667495",
"0.7274619",
"0.7216883",
"0.7213233",
"0.7152009",
"0.67414206",
"0.6649474",
"0.644604",
"0.64349836",
"0.63823044",
"0.62451017",
"0.6215957",
"0.62002635",
"0.6196766",
"0.6136535",
"0.6116863",
"0.6111729",
"0.6077984",
"0.6072128",
"0.60609454",
"0.6050351... | 0.8870716 | 0 |
Return the count at the given limit price. | def count_at(self, price):
return Library.functions.count_at(self._book, price) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_count(self):\n return self.price_set.count()",
"def Count(self, limit=None):\n if limit is None:\n count = 0\n for i in self.Run():\n count += 1\n return count\n else:\n return len(self.Get(limit))",
"def limit(self, limit):\n\n # Return between 1 and 250 ... | [
"0.68486047",
"0.6711644",
"0.62374175",
"0.6154216",
"0.60643214",
"0.60539377",
"0.5963375",
"0.5950641",
"0.59431195",
"0.5908711",
"0.58560854",
"0.58281624",
"0.5774528",
"0.57603157",
"0.5749395",
"0.574189",
"0.5730391",
"0.5728614",
"0.5705169",
"0.5687857",
"0.565394... | 0.73425525 | 0 |
Return the count of the book on the sell side. | def count_sell(self):
return Library.functions.count_sell(self._book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_buy(self):\n return Library.functions.count_buy(self._book)",
"def count(self):\n return Library.functions.count(self._book)",
"def count_at(self, price):\n return Library.functions.count_at(self._book, price)",
"def book_count(self):\n\n try:\n cur = ... | [
"0.78120375",
"0.77192485",
"0.70914364",
"0.68656915",
"0.6624515",
"0.65457547",
"0.64217335",
"0.6259992",
"0.62470585",
"0.62161124",
"0.61799794",
"0.6173208",
"0.616138",
"0.6150478",
"0.61196935",
"0.61196935",
"0.61010724",
"0.6085189",
"0.6085189",
"0.6085189",
"0.60... | 0.8766824 | 0 |
Return the count of the book on the buy side. | def count_buy(self):
return Library.functions.count_buy(self._book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_sell(self):\n return Library.functions.count_sell(self._book)",
"def count(self):\n return Library.functions.count(self._book)",
"def book_count(self):\n\n try:\n cur = self._db.cursor()\n cur.execute('SELECT COUNT(*) FROM books')\n ... | [
"0.80874604",
"0.791642",
"0.71182454",
"0.70671946",
"0.6729253",
"0.6499483",
"0.6482776",
"0.64741236",
"0.64674014",
"0.6455501",
"0.64497244",
"0.6448028",
"0.6434358",
"0.6434358",
"0.64228356",
"0.63472587",
"0.63472587",
"0.63472587",
"0.63472587",
"0.6326487",
"0.628... | 0.8772569 | 0 |
Return the total count of the book (number of orders). | def count(self):
return Library.functions.count(self._book) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_items(self):\n count = 0\n for o in self.order_lst:\n count += o.count()\n \n return count",
"def get_count(cls):\n total = 0\n for counter in SimpleCounterShard.objects.all():\n total += counter.count\n return total",
"def to... | [
"0.7326504",
"0.70894116",
"0.7065717",
"0.7048008",
"0.70059586",
"0.69761986",
"0.6889632",
"0.67862225",
"0.6757659",
"0.664989",
"0.6642463",
"0.6580156",
"0.6578201",
"0.65763205",
"0.65512884",
"0.65499413",
"0.6543359",
"0.6543359",
"0.6543359",
"0.6520974",
"0.6512532... | 0.78544945 | 0 |
Return price of Promotion from given timecall(second) | def promotion(time, sum_price):
time = second_to_minute(time)
for (pro, price) in [(24*60, 150), (12*60, 100), (8*60, 80), (3*60, 40), (60, 15), (20, 10)]:
sum_price = sum_price + (time//pro)*price
time = time % pro
oneminute = time - 3
return sum_price + oneminute if oneminute > 0 else ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_time_price(supplier_with_transaction):\n supplier_item = supplier_with_transaction.get('supplier_detail')\n transaction_item = supplier_with_transaction.get('supplier_transaction')\n # Check if there is time prices or not\n if supplier_with_transaction.get('time_price'):\n ... | [
"0.67537755",
"0.6225738",
"0.61765724",
"0.61343247",
"0.6133116",
"0.60193425",
"0.60140777",
"0.60004115",
"0.5960098",
"0.58534",
"0.583223",
"0.583061",
"0.5796537",
"0.57868993",
"0.5755165",
"0.57375234",
"0.5699371",
"0.56611836",
"0.56481266",
"0.5638357",
"0.5602969... | 0.7114384 | 0 |
Convert second to minute | def second_to_minute(time):
if time % 60 != 0:
time = time + 60
return time // 60 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def int_convert_to_minute(value):\n min = int(int(value) / 60)\n sec = int(int(value) % 60)\n return \"%02d\" % min + \":\" + \"%02d\" % sec",
"def get_minute(self):\n\n # First we get the first 8 bits stored in the minute register\n # and translate it to an integer\n minute_bcd = s... | [
"0.81158906",
"0.7529537",
"0.7427662",
"0.7400211",
"0.7394658",
"0.73557305",
"0.725303",
"0.7242647",
"0.7215991",
"0.7102178",
"0.70426196",
"0.69982487",
"0.6993329",
"0.69814235",
"0.6980721",
"0.6963728",
"0.6873445",
"0.6735053",
"0.6705921",
"0.66999775",
"0.66999775... | 0.8488949 | 0 |
The default path for auth files. Since auth is imported by common, not all functions from common are available yet, so we have to duplicate common.get_etc(). | def default_path():
return os.path.join(os.environ.get('OVERRIDE_ETC', '/etc'), 'auth') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_default_path(self):\n\n raise NotImplementedError()",
"def getuserbase():\n\tpass",
"def _get_config_path():\n return os.path.join(os.path.expanduser('~'))",
"def _get_default_path(self):\n return os.path.join(cfg.ROOT_DIR, 'data', 'KITTI')",
"def get_default_secrets_basedir():\n ... | [
"0.6578735",
"0.6543579",
"0.6311381",
"0.6221308",
"0.6197567",
"0.59966385",
"0.59602493",
"0.5944631",
"0.59310985",
"0.5916046",
"0.58995533",
"0.588715",
"0.5886533",
"0.58850485",
"0.58659554",
"0.5845714",
"0.58420026",
"0.5840689",
"0.5808696",
"0.58013254",
"0.575822... | 0.7999646 | 0 |
Return True iff a == b, and do it in constant time. | def constant_time_equals(a, b):
a = bytearray(a)
b = bytearray(b)
if len(a) != len(b):
return False
result = 0
for x, y in zip(a, b):
result |= x ^ y
return result == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_equal(self, a, b):\n return a is b",
"def _eq(a, b):\n return (a - b) % 2 == 0",
"def is_equal(self, a, b):\n return a == b",
"def equals(x, y):\n return x == y",
"def values_eq(self, a, b):\r\n return a == b",
"def _isImmediatelyConcurrentWithHelper(self, other):\n ... | [
"0.6991648",
"0.6987159",
"0.68904316",
"0.6511493",
"0.6491735",
"0.6393032",
"0.6370423",
"0.62094575",
"0.6165589",
"0.61569965",
"0.6101428",
"0.6083719",
"0.60202104",
"0.6011132",
"0.5964354",
"0.5960481",
"0.59527063",
"0.5886779",
"0.5871184",
"0.5863785",
"0.5838165"... | 0.7278765 | 0 |
Check that the authentication data directory is owned by current user, with safe permissions. throw exception if not. | def check_sane(self):
st = os.stat(self.path)
if st.st_uid != os.getuid():
raise Exception('Auth dir %s not owned by user %d.' % (
self.path, os.getuid()))
# Mode 16832 is equal to (stat.S_IFDIR | stat.S_IRWXU)
# In other words, a directory with mode bits rwx-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_owner(data=None, **kw):\n if data and 'owner_id' in data and not data['owner_id'] == current_user.id:\n raise ProcessingException(description=\"No write privileges\",\n code=401)",
"def is_admin():\n if os.name == 'nt':\n try:\n # Only Windows users with admin ... | [
"0.69111305",
"0.63244414",
"0.618211",
"0.61762416",
"0.60865843",
"0.6056135",
"0.60496074",
"0.60474795",
"0.60096633",
"0.5915627",
"0.5915164",
"0.5910356",
"0.5902933",
"0.5817912",
"0.58168834",
"0.58168834",
"0.5816142",
"0.57881606",
"0.5775639",
"0.57755697",
"0.576... | 0.7962697 | 0 |
Save data into file, with mode bits rw. | def write(self, filename, data):
owner_rw = 0600
fd = os.open(filename, os.O_WRONLY | os.O_CREAT, owner_rw)
# In case file existed already with wrong permissions, fix them.
os.chmod(filename, owner_rw)
os.write(fd, data)
os.close(fd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveOnFile(self, path, data):\n with open(path, \"w\") as f:\n f.write(data)",
"def save(self, data):\n self.write(data)",
"def saveIntoFile(self, fname, data, mode='a'):\n\t\tg = open(fname, mode)\n\t\tg.write(data)\n\t\tg.close()",
"def write(self, data):\n return self._... | [
"0.7226291",
"0.70650244",
"0.68625534",
"0.68410575",
"0.6730982",
"0.67121845",
"0.66840976",
"0.6669404",
"0.66520023",
"0.65721416",
"0.6454757",
"0.64442486",
"0.64206964",
"0.6347395",
"0.63168377",
"0.6304097",
"0.6299632",
"0.62755454",
"0.62742877",
"0.62730885",
"0.... | 0.7425339 | 0 |
Return the number of failed passwords the can be entered before logins attempts are disabled for a day. The rate limit information is stored as a count of failed attempts so far. If there have been no failed attempts, or they were more than a day ago, treat that as zero failed attempts. | def rate_limit_remaining(self):
if os.path.isfile(self.rate_limit_filename):
st = os.stat(self.rate_limit_filename)
if time.time() - st.st_ctime > self.RATE_LIMIT_DURATION:
return self.RATE_LIMIT_COUNT
else:
with open(self.rate_limit_filename, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_failed_attempts(self) -> int:\n return pulumi.get(self, \"allowed_failed_attempts\")",
"def get_retry_count(self):\r\n return self.retried_nomax + self.retried_withmax",
"def rate_limit_check():\n\n data = api.rate_limit_status()\n\n user_timeline_remaining = data['resources']['... | [
"0.72841084",
"0.6442284",
"0.63025856",
"0.62957674",
"0.6294218",
"0.6247011",
"0.6221691",
"0.6105994",
"0.6071681",
"0.6069109",
"0.60401917",
"0.6027968",
"0.6010637",
"0.6010314",
"0.59940743",
"0.59916854",
"0.5940475",
"0.5892049",
"0.5857288",
"0.5837647",
"0.5832163... | 0.7286241 | 0 |
Return whether a password file exists. | def password_exists(self):
return os.path.isfile(self.password_filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exists(file):\n try:\n Cryptography.read(file)\n return True\n except (FileNotFoundError, FileExistsError):\n return False",
"def has_credentials(credentials_file=CREDENTIALS_FILE):\n return os.path.exists(credentials_file)",
"def file_exist() -> bool:... | [
"0.73339146",
"0.72148883",
"0.711415",
"0.704762",
"0.6940705",
"0.6932751",
"0.68602616",
"0.68285614",
"0.68142194",
"0.6799496",
"0.6797534",
"0.6792931",
"0.67914045",
"0.6779414",
"0.67747366",
"0.6768138",
"0.67567444",
"0.6748446",
"0.67089844",
"0.67058",
"0.6699733"... | 0.84719884 | 0 |
Generate a CSRF prevention token. We derive this token as the SHA256 hash of the auth token, which ensures the two are bound together, preventing cookie forcing attacks. Returns a valid CSRF prevention token. | def get_csrf_token(self):
h = hashlib.new('sha256')
h.update(self.__current_authentication_token())
return h.hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_csrf_token() -> int:\r\n ...",
"def generate_csrf_token():\n if '_csrf_token' not in login_session:\n login_session['_csrf_token'] = b64encode(urandom(64)).decode() # Cryptographically secure random key\n print(\"_csrf_token:\" + login_session['_csrf_token'])\n return login_sessi... | [
"0.7412592",
"0.7199123",
"0.7178343",
"0.71217203",
"0.69856286",
"0.68552816",
"0.651522",
"0.6510274",
"0.65009046",
"0.63964945",
"0.63690513",
"0.6342274",
"0.6288062",
"0.6235347",
"0.6221905",
"0.62115526",
"0.61450565",
"0.61078674",
"0.60888135",
"0.6081029",
"0.6066... | 0.7876994 | 0 |
Return the HTTP headers required to log the user in. Specifically, set the auth cookie, the csrf token cookie, and an unsecured cookie logged_in=true, indicating the user is logged in even if the current request context doesn't have the auth cookies. The server should redirect users with the loggedin cookie to the HTTP... | def login_headers(self):
auth_token = self.regenerate_authentication_token()
csrf_token = self.get_csrf_token()
# Set the secure flag on the cookie if the login occurred over HTTPS.
secure = ''
if 'HTTPS' in os.environ:
secure = ' secure;'
return ('Set-Cookie:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout_headers(self):\n self.regenerate_authentication_token()\n return ('Set-Cookie: %s=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\\n'\n 'Set-Cookie: %s=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\\n'\n 'Set-Cookie: %s=; path=/; expires=Thu,... | [
"0.616512",
"0.58029056",
"0.5774238",
"0.57243794",
"0.572148",
"0.5703384",
"0.5694575",
"0.56380635",
"0.55908483",
"0.55858535",
"0.5576539",
"0.556314",
"0.55448025",
"0.54460526",
"0.54270995",
"0.54115784",
"0.54071826",
"0.5374451",
"0.53601944",
"0.53586346",
"0.5334... | 0.71679306 | 0 |
Return the HTTP headers required to log the user out. Specifically, delete and invalidate the auth token and CSRF token. | def logout_headers(self):
self.regenerate_authentication_token()
return ('Set-Cookie: %s=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\n'
'Set-Cookie: %s=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\n'
'Set-Cookie: %s=; path=/; expires=Thu, 01 Jan 197... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forget(self, environ, identity):\n challenge = \"MAC+BrowserID url=\\\"%s\\\"\" % (self.token_url,)\n return [(\"WWW-Authenticate\", challenge)]",
"def logout(request):\n if request.method == 'POST':\n request.token.delete()\n return json_response({\n 'status': 'succ... | [
"0.663149",
"0.6626839",
"0.64436823",
"0.6353375",
"0.62939614",
"0.6245303",
"0.6228222",
"0.6208567",
"0.61947745",
"0.6191976",
"0.6191976",
"0.6157748",
"0.6107373",
"0.6107373",
"0.6101193",
"0.6085265",
"0.6074504",
"0.60680485",
"0.6061079",
"0.60475695",
"0.6046746",... | 0.7579529 | 0 |
Return the current authentication token if it still valid, else None. | def __current_authentication_token(self):
if os.path.isfile(self.token_filename):
with open(self.token_filename, 'r') as f:
(stored_token, expires) = f.read().split(' ')
t = time.time()
if int(expires) > t:
return stored_token
return No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_token(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"auth_token\")",
"def token(self):\n if self.is_auth_needed():\n self.authorize()\n\n return self.get_from_cache('token')",
"def get_auth_token():\n auth_token_value = memcache.get('authtoken'... | [
"0.75732124",
"0.7552719",
"0.7514238",
"0.74762905",
"0.7412203",
"0.7278422",
"0.72320783",
"0.7199977",
"0.7183309",
"0.7131585",
"0.71267015",
"0.7103127",
"0.7067211",
"0.7020245",
"0.6927801",
"0.6918491",
"0.6909502",
"0.68631387",
"0.6821521",
"0.6821521",
"0.6819494"... | 0.78239816 | 0 |
Return true iff candidate authentication token matches stored one. | def is_authentication_token(self, candidate):
current_token = self.__current_authentication_token()
# TODO: Add expiry checking
if (current_token and
self.__valid_token_format(current_token) and
self.__valid_token_format(candidate) and
constant_tim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated(self):\n return self.token is not None",
"def check_token(self, user, token):\n try:\n data = signing.loads(token, max_age=properties.TOKEN_LOGIN_TIMEOUT)\n except signing.BadSignature:\n return False\n\n return (\n (\n ... | [
"0.6938202",
"0.68884546",
"0.6865633",
"0.68002206",
"0.6707966",
"0.66578394",
"0.6657788",
"0.6632563",
"0.6583302",
"0.6578111",
"0.65751725",
"0.65728736",
"0.6560326",
"0.6539685",
"0.6510684",
"0.649782",
"0.649383",
"0.64898247",
"0.64779943",
"0.64613837",
"0.6455331... | 0.84338975 | 0 |
Create and store a new random authentication token. Expires old sessions. | def regenerate_authentication_token(self):
new_token = os.urandom(self.TOKEN_LENGTH).encode('hex')
expires = int(time.time()) + Auth.SESSION_DURATION
self.write(self.token_filename, ('%s %d' % (new_token, expires)))
return new_token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_new_token(self):\n self.access_token = random_auth_key()",
"def generate_new_token(uid):\n random_token = uuid.uuid4()\n token = TokenAuth(user_id=uid, token=random_token)\n token.save()\n return random_token",
"def _generate_token(self):\n return sha1(\"%s#%s\" % (time()... | [
"0.8077118",
"0.7244117",
"0.69622195",
"0.69050765",
"0.689591",
"0.6889207",
"0.6816747",
"0.6809456",
"0.6781932",
"0.675099",
"0.6749914",
"0.67392135",
"0.67329174",
"0.6729028",
"0.66792405",
"0.6672653",
"0.6654001",
"0.66211134",
"0.650831",
"0.6499091",
"0.6493759",
... | 0.8331127 | 0 |
In the context of a CGI request, check whether an authentication cookie is present and valid. If not, render an error. | def check_authentication(self):
try:
cookies = os.environ['HTTP_COOKIE'].split('; ')
except KeyError:
cookies = []
for c in cookies:
prefix = Auth.AUTH_COOKIE_NAME + '='
if (c.startswith(prefix) and
self.is_authentication_token(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_must_authenticate():\n return Response(\n 'Could not verify your access level for that URL.\\n'\n 'You have to login with proper credentials', 401,\n {'WWW-Authenticate': 'Basic realm=\"Login Required\"'})",
"def check_auth(*args, **kwargs):\n r = cherrypy.request\n s = cherryp... | [
"0.657821",
"0.65143234",
"0.63110507",
"0.62617683",
"0.6211139",
"0.6205653",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
"0.6156784",
... | 0.67513925 | 0 |
Test that the request() wrapper passes along expected headers | def test_request_headers(mock_send, mock_format):
ClientSession().request('GET', 'https://url', access_token='token')
request_obj = mock_send.call_args[0][0]
assert request_obj.headers['Authorization'] == 'Bearer token' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_specific_headers_sent_with_request(self):\n req = self.httpbin.get_my_headers(dry_run=True)\n self.assertIn('All-Request-Headers', req.prepared_request.headers)\n request_data_headers = self.httpbin.client['get_my_headers']['headers']['All-Request-Headers']\n self.assertEqual(r... | [
"0.7787896",
"0.77121085",
"0.75712365",
"0.7443091",
"0.7166433",
"0.71009004",
"0.70632696",
"0.7058741",
"0.7019937",
"0.7008756",
"0.69866556",
"0.69617903",
"0.6924459",
"0.687052",
"0.68337685",
"0.681641",
"0.6786742",
"0.6786234",
"0.6743163",
"0.6663947",
"0.6661827"... | 0.80046374 | 0 |
wrapper to make async calls using gevent, concurrent not parallel | def asynchronous(urls, batch_size, delay=0, verbose=False):
try:
count=1
threads=[]
print(urls.strip(' ').split(","))
for url in urls.strip(" '").split(","):
print('On batch {}'.format(count))
threads.append(gevent.spawn(fetch, url, verbose))
responses... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_async(self, name, *args, **kwargs):",
"async def run():\n sem = asyncio.Semaphore(DEFAULT_SEMAPHORE_LIMIT)\n tasks = []\n\n async with ClientSession() as session:\n for u in [ROOT_URL.format(jid) for jid in DEFAULT_RANGE_IDS]:\n task = asyncio.ensure_future(bound_fetch(sem, u,... | [
"0.6448774",
"0.6373844",
"0.6306433",
"0.61689025",
"0.6099593",
"0.6085664",
"0.60487",
"0.59556615",
"0.59057474",
"0.58697575",
"0.58590627",
"0.5844879",
"0.58389485",
"0.5828767",
"0.5826276",
"0.5818216",
"0.58082384",
"0.58055556",
"0.577954",
"0.57730323",
"0.576001"... | 0.6791043 | 0 |
Main function to call This function should obtain results from generators and plot image and image intensity Create a for loop to iterate the generator functions | def display_images():
vc = cv2.VideoCapture(0) # Open webcam
figure, ax = plt.subplots(1, 2, figsize=(10, 5)) # Intiialise plot
count = 0 # Counter for number of aquired frames
intensity = [] # Append intensity across time
# For loop over generator here
intensity.append(imageintensity)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n \n # for inserting other images, add tem to /input folder and list them here\n images = (\n 'image-0',\n 'image-1',\n 'image-2'\n )\n\n for image_name in images:\n print(image_name, \"image:\")\n\n image = open_image(image_name)\n display_image(im... | [
"0.65730345",
"0.64085895",
"0.6363845",
"0.63635534",
"0.62890536",
"0.62543195",
"0.62491566",
"0.6223364",
"0.6188411",
"0.618029",
"0.61280805",
"0.61128044",
"0.61127687",
"0.6095602",
"0.60937095",
"0.60769194",
"0.6063557",
"0.6053544",
"0.6050049",
"0.60302",
"0.60264... | 0.7101953 | 0 |
This function plots image and intensity of image through time | def plot_image_and_brightness(axis, image, imageintensity, framecount):
# Plot RGB Image
axis[0].imshow(image)
axis[0].axis('off')
axis[0].set_title(f'Frame Number {framecount}')
# Plot intensity
axis[1].plot(imageintensity, '.-')
axis[1].set_ylabel('Average Intensity')
# Stuff to sho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imshow(img):\n imadd(img)\n plt.ion()\n plt.show()",
"def fn_intensitytrace(file_name,folder,data,time,i,x,y):\n import numpy as np\n import matplotlib.pyplot as plt\n\n\n figure_name=file_name+'_intensity_trace'\n for a in range(0,len(data),int(len(data)/2)):\n if i==a:\n ... | [
"0.69218147",
"0.6863551",
"0.668293",
"0.667952",
"0.66168284",
"0.657051",
"0.6569345",
"0.65316135",
"0.65316135",
"0.65316135",
"0.6529275",
"0.6461676",
"0.64531654",
"0.6427083",
"0.64266634",
"0.640738",
"0.6397536",
"0.63804084",
"0.63659954",
"0.63561183",
"0.6350481... | 0.71107686 | 0 |
Adds new reactions and metabolites to iEK1008.json while performing continuous testing | def main():
run_test_suite('../models/iEK1008.json') # runs test suite with iEK1008.json
# rewrites iEK1008.json to iMtb_H37Rv.json so original model is not overwritten
model_iek = cobra.io.load_json_model('../models/iEK1008.json')
cobra.io.save_json_model(model_iek, '../models/iMtb_H37Rv.json')
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def on_reaction_add(reaction, user):\n #Before doing anything\n #Check to see if the reaction was a karma emoji\n if reaction.emoji == initKarma.goodKarma:\n consoleMessage = 'Writing to karmaData file :: Increasing '\n consoleMessage += reaction.message.author.name\n consoleMes... | [
"0.57377374",
"0.5685594",
"0.567169",
"0.5549195",
"0.54485726",
"0.53651845",
"0.5343828",
"0.53168577",
"0.52647924",
"0.5197624",
"0.5102805",
"0.51013464",
"0.5088614",
"0.50403416",
"0.5033594",
"0.5025995",
"0.5025969",
"0.50153446",
"0.4987246",
"0.49858665",
"0.49766... | 0.69024295 | 0 |
Converts a cause of death index to a humanreadable string. | def cause_of_death_index_to_string(index: int) -> str:
if index == CauseOfDeath.STARVATION.value:
return "Starvation"
elif index == CauseOfDeath.DEHYDRATION.value:
return "Dehydration"
elif index == CauseOfDeath.EATEN.value:
return "Eaten"
else:
raise ValueError("Did not recognize CauseOfDea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"{}_human\".format(self.index)",
"def _index_to_unicode(cls, index: int) -> str:\n return \"\".join(cls._unicode_subscripts[int(_)] for _ in str(index))",
"def _make_not_found_message(index: Union[int, slice, str]) -> str:\n msg = [f\"Analysis result {index... | [
"0.5622562",
"0.54020613",
"0.5385206",
"0.5309493",
"0.52745426",
"0.5257487",
"0.5119563",
"0.5113673",
"0.51084805",
"0.5053868",
"0.501387",
"0.5013531",
"0.49857065",
"0.49503946",
"0.4940279",
"0.48666745",
"0.48354596",
"0.48203522",
"0.47872925",
"0.4776707",
"0.47206... | 0.7642903 | 0 |
Creates and returns a grouped bar chart with the death causes. The lists are expected to feature an entry for each cause of death, where the value corresponds to how many specimens died of that cause. | def create_grouped_bar_chart(stats: dict[str, list[int]]):
figure, axes = plot.subplots()
labels = [str(e) for e in CauseOfDeath]
x = numpy.arange(len(labels))
bar_width = 0.15
max_value = 0
rects = []
i = 0
for label, values in stats.items():
max_value = max(max_value, max(values))
rects.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualise_cause_of_death(data: LogData, directory: Path):\n\n rabbit_stats: list[int] = [0 for _ in CauseOfDeath]\n deer_stats: list[int] = [0 for _ in CauseOfDeath]\n wolf_stats: list[int] = [0 for _ in CauseOfDeath]\n bear_stats: list[int] = [0 for _ in CauseOfDeath]\n\n for event in data.events():\n ... | [
"0.7562296",
"0.6105632",
"0.6035507",
"0.5984834",
"0.58694273",
"0.5796705",
"0.57743406",
"0.5752848",
"0.5696702",
"0.5637777",
"0.5625334",
"0.5550093",
"0.55419266",
"0.55158776",
"0.547458",
"0.5461855",
"0.5438678",
"0.5402194",
"0.53831524",
"0.5329398",
"0.53166",
... | 0.806361 | 0 |
Produces a grouped bar chart of the different causes of deaths, arranged by the animal types. | def visualise_cause_of_death(data: LogData, directory: Path):
rabbit_stats: list[int] = [0 for _ in CauseOfDeath]
deer_stats: list[int] = [0 for _ in CauseOfDeath]
wolf_stats: list[int] = [0 for _ in CauseOfDeath]
bear_stats: list[int] = [0 for _ in CauseOfDeath]
for event in data.events():
event_type: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_grouped_bar_chart(stats: dict[str, list[int]]):\n\n figure, axes = plot.subplots()\n\n labels = [str(e) for e in CauseOfDeath]\n x = numpy.arange(len(labels))\n\n bar_width = 0.15\n max_value = 0\n\n rects = []\n i = 0\n for label, values in stats.items():\n max_value = max(max_value, max(val... | [
"0.79494953",
"0.6173366",
"0.60805166",
"0.60178256",
"0.59662867",
"0.59589386",
"0.5912419",
"0.59108937",
"0.5900395",
"0.5898058",
"0.5876276",
"0.5787513",
"0.5760313",
"0.5743132",
"0.5596977",
"0.55531824",
"0.553276",
"0.54811996",
"0.5470746",
"0.544473",
"0.5411298... | 0.7591147 | 1 |
Generates a new OperatorBuilder object. atomicTermExpr i an TorqExpression object. A sequence which matches it will be recognized an atomic item and not be parsed further. composedTermNodeLables is a list of labels. Nodes who have one of them will be recognized an expression, which may include another expression inside... | def __init__(self,
atomicTermExpr=None,
composedTermNodeLabels=None,
generatedTermLabel=None):
self.__ate = atomicTermExpr if atomicTermExpr is not None else Never()
self.__ctnls = composedTermNodeLabels
self.__gtl = generatedTermLabel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_term(self):\n\n\t\tself.outfile.write('<term>\\n')\n\n\t\tcount = 0\n\n\t\twhile(self.tokenizer.get_token() not in [')',']',';',',', '/', '|', '<', '>', '=', '*', '+', '&']):\n\t\t\tif self.tokenizer.get_token().isdigit():\n\t\t\t\tself.outfile.write(self.tokenizer.int_value())\n\t\t\telif '\"' in self... | [
"0.51256794",
"0.50364447",
"0.5035556",
"0.49387896",
"0.49171144",
"0.48688382",
"0.47859588",
"0.47263345",
"0.47252068",
"0.46344826",
"0.46341482",
"0.46032685",
"0.4565626",
"0.45439956",
"0.45345488",
"0.45064116",
"0.4506053",
"0.4453859",
"0.442932",
"0.4415429",
"0.... | 0.6599325 | 0 |
Recursively iterate over issue dictionary and print errors. | def _print_issue(issue, ntabs):
for key, value in issue.items():
if isinstance(value, dict):
tabs = TAB*ntabs
print('%s%s (section):' % (tabs, key))
ntabs += 1
print_issue(value, ntabs=ntabs)
elif isinstance(value, bool):
if value == False:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_wrapper(x):\n errors = list()\n for error_key, error_list in list(x.items()):\n for error in error_list:\n if error_key == 'non_field_errors':\n errors.append(error)\n else:\n errors.append(\"%s: %s\" % (error_key, error))\n return error... | [
"0.57348907",
"0.5411636",
"0.53937906",
"0.53712976",
"0.5358204",
"0.5333469",
"0.52884054",
"0.52464217",
"0.5168919",
"0.51145256",
"0.50778586",
"0.5039028",
"0.5036515",
"0.502055",
"0.5012484",
"0.5011434",
"0.4996432",
"0.49948236",
"0.49832422",
"0.49768898",
"0.4973... | 0.6306336 | 0 |
POST /validate Validate GeoJSON data in POST body | def validate(request):
testing = request.GET.get('testing')
if request.method == 'POST':
stringy_json = request.raw_post_data
else: # GET
try:
remote_url = request.GET['url']
stringy_json = get_remote_json(remote_url)
except KeyError: # The "url" URL param... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_geojson(data):\n \"\"\"Enforces camelcasing of properties\"\"\"\n if 'id' in data:\n del data['id']\n try:\n data['type'] = data['type'] if 'type' in data else \"Feature\"\n data['geometry'] = data['geometry'] if 'geometry' in data else None\n if 'properties' not in ... | [
"0.6258375",
"0.61013263",
"0.60835147",
"0.6058721",
"0.60300624",
"0.60212815",
"0.5967188",
"0.580679",
"0.58050185",
"0.5788679",
"0.5773974",
"0.5773974",
"0.57511264",
"0.5706149",
"0.5697552",
"0.5684848",
"0.56350404",
"0.5609239",
"0.55897486",
"0.5548948",
"0.554894... | 0.67822635 | 0 |
Get a random software license. | def software_license(self) -> str:
return self.random.choice(LICENSES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_license(self) -> APIReturn:\n return await self._request(\"GET\", \"/getLicense\")",
"def get_license():\n repo_fs()\n return LICENSE",
"def license(self): # noqa: A003\n logger.debug(\"Get license\")\n return self._raw_api.license.get()",
"def license_plate(self) ->... | [
"0.7257501",
"0.71489984",
"0.70458555",
"0.6904726",
"0.6888948",
"0.68682706",
"0.6559753",
"0.63974625",
"0.6345092",
"0.63441616",
"0.63224334",
"0.62866235",
"0.6221269",
"0.6201027",
"0.6021887",
"0.597207",
"0.5964664",
"0.593197",
"0.59197384",
"0.5912311",
"0.5888606... | 0.8545533 | 0 |
Get a random programming language from the list. | def programming_language(self) -> str:
return self.random.choice(PROGRAMMING_LANGS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def language():\r\n\r\n cursor.execute('SELECT name from languages order by RANDOM() limit 1;')\r\n return cursor.fetchone()[0]",
"def choose_language(self):\n\n current_dir = os.curdir\n path = os.path.join(current_dir, \"audio\")\n languages = os.listdir(path)\n language_num =... | [
"0.7798375",
"0.75217885",
"0.6663096",
"0.657567",
"0.6547032",
"0.6538302",
"0.6538302",
"0.6538302",
"0.6450568",
"0.6426865",
"0.62987846",
"0.6250212",
"0.624393",
"0.62252414",
"0.6214424",
"0.62047374",
"0.61436826",
"0.61385137",
"0.6122823",
"0.6067962",
"0.6052699",... | 0.7644547 | 1 |
Get a random operating system or distributive name. | def os(self) -> str:
return self.random.choice(OS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rand_name() -> str:\n suf = \"\".join(random.choices(string.ascii_uppercase + string.digits, k=6))\n return f\"exporters_{suf}\"",
"def GetOSName():\n return Config.osName_",
"def platform_distro():\n distro = platform_information()[0] or ''\n return distro.strip().lower()",
"def... | [
"0.71472675",
"0.7110732",
"0.7060906",
"0.6976703",
"0.69478893",
"0.6882059",
"0.6790889",
"0.6751498",
"0.66147846",
"0.659943",
"0.6580307",
"0.657741",
"0.6558327",
"0.653063",
"0.65062135",
"0.6499304",
"0.6496545",
"0.6487284",
"0.6480682",
"0.6479354",
"0.64615834",
... | 0.7919382 | 0 |
Get a random system quality attribute. Within systems engineering, quality attributes are realized nonfunctional requirements used to evaluate the performance of a system. These are sometimes named "ilities" after the suffix many of the words share. | def system_quality_attribute(self) -> str:
return self.random.choice(SYSTEM_QUALITY_ATTRIBUTES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ility(self) -> str:\n return self.system_quality_attribute()",
"def quality(self):\n try:\n qid = int((self.tool_metadata or {}).get(\"quality\", 0))\n except:\n qid = 0\n\n # We might be able to get the quality strings from the item's tags\n internal_... | [
"0.6713973",
"0.64897156",
"0.61726063",
"0.6065477",
"0.5870625",
"0.55420256",
"0.55384314",
"0.5526172",
"0.541174",
"0.53634155",
"0.53470075",
"0.53367925",
"0.53191906",
"0.52884704",
"0.52797884",
"0.52781254",
"0.52720535",
"0.52499086",
"0.5233074",
"0.5218162",
"0.5... | 0.8372629 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.