query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Shows the levels and stats of a user. | async def _me_stats(self, ctx):
if has_post_permission(ctx.guild.id, ctx.channel.id):
await ctx.send(users.print_account(ctx.user_object, printequipment=False)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showUserStats(self) :\n self.getAllStats()\n self.getNbTotalLevelsPlayed()\n Scenario.messageAllStats(self.level_history[0].created_at)\n self.showBestStats()\n self.showWorstStats()\n self.showAverageStats()",
"def display_user_stats(self):\n\n self.user_fram... | [
"0.81691813",
"0.7022499",
"0.6978554",
"0.6930742",
"0.65434587",
"0.65393674",
"0.65197104",
"0.6493204",
"0.6438436",
"0.64063543",
"0.64054185",
"0.6405407",
"0.6352828",
"0.6350688",
"0.63383704",
"0.6274365",
"0.6255612",
"0.6255341",
"0.6231478",
"0.62271357",
"0.62045... | 0.5969752 | 42 |
Checks if the current time is a different day and resets everyone's daily progress. | async def reset_dailies(self):
await self.bot.wait_until_ready()
while not self.bot.is_closed():
if pc_helpers.is_next_day():
pc_helpers.reset_dailies()
print('dailies updated successfully')
await asyncio.sleep(TICK_SECONDS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_day_advance(self):\n days_ago = datetime.now().toordinal() - self.start_time.toordinal()\n if days_ago:\n # New day. Save data for the old day.\n self.save(days_ago = days_ago)\n self.start_time = datetime.now()\n # Reset all counters back to 0:00... | [
"0.6460523",
"0.6061517",
"0.59513575",
"0.5827571",
"0.580728",
"0.5756918",
"0.57260054",
"0.5628393",
"0.5625456",
"0.5613559",
"0.5606751",
"0.5550192",
"0.5522786",
"0.55055195",
"0.5501299",
"0.5501062",
"0.54610264",
"0.54459375",
"0.5432968",
"0.5391588",
"0.53851056"... | 0.53728604 | 21 |
Compare pvalue with alpha. The 'compute_pvalue' method needs to be evaluated first. | def pvalue_test(self, alpha=0.01):
CL = int((1-alpha)*100) # confidence level
if self.p_value < alpha:
print("Null hypothesis rejected at {:d}%CL => distributions are different".format(CL))
else:
print("Null hypothesis NOT rejected => distributions are t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pvalue_alpha(self):\n return _handle_ab(self._pvalues_all, self.use_const)[0]",
"def pvalue_alpha(self):\n return self._pvalue_alpha",
"def _result(self, p, alpha):\n\n if p < alpha:\n self._verbose('reject H0')\n return False\n else:\n self._ve... | [
"0.76247334",
"0.7300634",
"0.66975635",
"0.6309796",
"0.6250278",
"0.62002856",
"0.6131462",
"0.6099995",
"0.60863453",
"0.6078437",
"0.60200673",
"0.6011325",
"0.59004015",
"0.58796567",
"0.5879302",
"0.5879302",
"0.5879302",
"0.5839784",
"0.5822486",
"0.5811683",
"0.578805... | 0.7278204 | 2 |
read file and make list of the content of the file, and \n>'' | def lineReadfile(filename):
# "input:filename output=readlines() "
f = open(filename)
list1 =[]
while 1:
s = f.readline()
if s=="":
break
s=string.replace(s,"\n","")
if s=="":
continue
list1.append(s)
f.close()
return list1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_list(list_file):\r\n return [line.strip('\\n').strip('\\r') for line in open(list_file)]",
"def make_list(list_file):\n return [line.strip('\\n').strip('\\r') for line in open(list_file)]",
"def read_list(file_name):\n with open(file_name, 'r') as f:\n text = f.read().splitlines()\n ... | [
"0.7155553",
"0.7011796",
"0.700364",
"0.683458",
"0.6744403",
"0.667458",
"0.666899",
"0.6651556",
"0.6608669",
"0.6569813",
"0.6522272",
"0.65104836",
"0.6499903",
"0.6489195",
"0.64538974",
"0.64278674",
"0.63977563",
"0.6396454",
"0.6391034",
"0.6382648",
"0.6369004",
"... | 0.6252156 | 31 |
Iterate over the corpus. If corpus was already batchified, return batches. Otherwise return a single indexed sentence at a time. | def __iter__(self):
while True:
if self.batches is None:
for indexed_sentence in self.indexed_sentences:
yield indexed_sentence
else:
for batch in self.batches:
yield batch[:-1, :], batch[1:, :] # Return batch and t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_batch(corpus, ind, vocab_size, device, emsize=300):\r\n batch_size = len(ind)\r\n data_batch = np.zeros((batch_size, vocab_size))\r\n\r\n for i, doc_id in enumerate(ind):\r\n doc = corpus[doc_id.data]\r\n L = len(doc)\r\n if doc_id != -1:\r\n for word_id in doc:\r\n... | [
"0.6667007",
"0.63389766",
"0.63235193",
"0.6252998",
"0.62049",
"0.6185451",
"0.6163989",
"0.60826665",
"0.608046",
"0.60062975",
"0.5961425",
"0.59541905",
"0.5936558",
"0.5933394",
"0.5921012",
"0.5921012",
"0.58837223",
"0.5854147",
"0.58537567",
"0.5822864",
"0.5822864",... | 0.6869459 | 0 |
Returns the simulated 'healthy'/'unhealthy' status of the server. | def health():
global _is_healthy
template = render_template('health.html', healthy=_is_healthy)
return make_response(template, 200 if _is_healthy else 500) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_health(self):\n return self.__healthy",
"def get_health(self):\n return {'status': 'ok'}",
"def health_status(self) -> str:\n return pulumi.get(self, \"health_status\")",
"def health_status(self) -> str:\n return pulumi.get(self, \"health_status\")",
"def healthy(self):\... | [
"0.73638076",
"0.71246064",
"0.7018728",
"0.7018728",
"0.6884675",
"0.6833523",
"0.66984886",
"0.66973335",
"0.66087794",
"0.65907645",
"0.65640926",
"0.6512779",
"0.6496031",
"0.6481071",
"0.64703673",
"0.6463084",
"0.6457128",
"0.6438911",
"0.64127326",
"0.6386287",
"0.6385... | 0.6965366 | 4 |
Test parse of a filter param no time filter. | def test_parse_filter_params_no_time(self):
filter_params = {
"region": FAKE.word(),
"payer_tenant_id": FAKE.uuid4(),
"instance_type": FAKE.word(),
}
serializer = OCIFilterSerializer(data=filter_params)
self.assertTrue(serializer.is_valid()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_filter_params_success(self):\n filter_params = {\n \"resolution\": \"daily\",\n \"time_scope_value\": \"-10\",\n \"time_scope_units\": \"day\",\n \"region\": FAKE.word(),\n \"payer_tenant_id\": FAKE.uuid4(),\n \"product_service... | [
"0.6720833",
"0.65087473",
"0.61677974",
"0.6083507",
"0.6065226",
"0.6057863",
"0.6046605",
"0.5964981",
"0.59552073",
"0.59505635",
"0.5887956",
"0.5869627",
"0.5834402",
"0.58257705",
"0.5778015",
"0.5774181",
"0.5717222",
"0.5694095",
"0.5679404",
"0.56767136",
"0.5676713... | 0.74389374 | 0 |
Test parse of filter params for invalid fields. | def test_filter_params_invalid_fields(self):
filter_params = {"invalid": "param"}
serializer = OCIFilterSerializer(data=filter_params)
with self.assertRaises(serializers.ValidationError):
serializer.is_valid(raise_exception=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_filterval(filterval):\n if filterval != 'description' and filterval != 'fulldescription' and filterval != 'completed':\n return False\n else:\n return True",
"def test_filter_params_invalid_limit(self):\n filter_params = {\n \"resolution\": \"mon... | [
"0.7271532",
"0.71388686",
"0.7096295",
"0.70950526",
"0.69934624",
"0.69505024",
"0.6913582",
"0.6888075",
"0.68010545",
"0.67305076",
"0.6686237",
"0.6670382",
"0.66702795",
"0.6633449",
"0.6485494",
"0.6432723",
"0.64264333",
"0.6405936",
"0.6370691",
"0.63435113",
"0.6213... | 0.7751567 | 0 |
Test parse of filter params for invalid daily time_scope_units. | def test_filter_params_invalid_time_scope_daily(self):
filter_params = {"resolution": "daily", "time_scope_value": "-1", "time_scope_units": "day"}
serializer = OCIFilterSerializer(data=filter_params)
with self.assertRaises(serializers.ValidationError):
serializer.is_valid(raise_exce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_filter_params_invalid_time_scope_monthly(self):\n filter_params = {\"resolution\": \"monthly\", \"time_scope_value\": \"-10\", \"time_scope_units\": \"month\"}\n serializer = OCIFilterSerializer(data=filter_params)\n with self.assertRaises(serializers.ValidationError):\n se... | [
"0.7610319",
"0.74666846",
"0.6622102",
"0.65876245",
"0.6431835",
"0.63949174",
"0.6318742",
"0.62995577",
"0.6282231",
"0.61682594",
"0.61197054",
"0.610867",
"0.600287",
"0.5956584",
"0.5938147",
"0.59147674",
"0.5890246",
"0.5862609",
"0.5817062",
"0.5772816",
"0.57585",
... | 0.8158492 | 0 |
Test parse of filter params for invalid resolution time_scope_units. | def test_filter_params_invalid_limit_time_scope_resolution(self):
filter_params = {"resolution": "monthly", "time_scope_value": "-10", "time_scope_units": "day"}
serializer = OCIFilterSerializer(data=filter_params)
with self.assertRaises(serializers.ValidationError):
serializer.is_va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_filter_params_invalid_time_scope_daily(self):\n filter_params = {\"resolution\": \"daily\", \"time_scope_value\": \"-1\", \"time_scope_units\": \"day\"}\n serializer = OCIFilterSerializer(data=filter_params)\n with self.assertRaises(serializers.ValidationError):\n serialize... | [
"0.77109426",
"0.7643143",
"0.68005836",
"0.66362035",
"0.6534466",
"0.6324122",
"0.6274827",
"0.6158578",
"0.6154997",
"0.60168433",
"0.6004294",
"0.6002046",
"0.59824705",
"0.5975555",
"0.59039766",
"0.5876063",
"0.5870864",
"0.5856936",
"0.5842652",
"0.57993525",
"0.578028... | 0.78302085 | 0 |
Test parse of group_by params for invalid fields. | def test_group_by_params_invalid_fields(self):
group_params = {"region": [FAKE.word()], "invalid": "param"}
serializer = OCIGroupBySerializer(data=group_params)
with self.assertRaises(serializers.ValidationError):
serializer.is_valid(raise_exception=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_groupby_fields(groupby_fields):\r\n # NOTE(terriyu): Currently, metadata fields are not supported in our\r\n # group by statistics implementation\r\n valid_fields = set(['user_id', 'resource_id', 'project_id', 'source'])\r\n\r\n invalid_fields = set(groupby_fields) - valid_fields\r\n i... | [
"0.7524916",
"0.71455574",
"0.69295084",
"0.6384155",
"0.62468886",
"0.61945975",
"0.61482936",
"0.61100626",
"0.61078596",
"0.607455",
"0.6073177",
"0.6056115",
"0.60418767",
"0.60262805",
"0.60047853",
"0.596763",
"0.5894986",
"0.5872457",
"0.58607495",
"0.58437365",
"0.582... | 0.7685201 | 0 |
Test that the output array is of type uint8. | def test_out_dtype(self):
byt = bytscl(self.array1)
dtype = byt.dtype
self.assertEqual(dtype, 'uint8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dtype_byte_gtiff(self):\n self.assertEqual(_test_array(landsat_gtiff, dtype='byte').dtype, 'uint8')",
"def one_2_uint8(one_arr):\n assert (one_arr.dtype == 'float' and np.max(one_arr <= 1.0)), \\\n 'improc.one_2_uint8() only accepts floats arrays from 0 to 1.'\n return (255*one_arr).... | [
"0.66685957",
"0.6596452",
"0.65869844",
"0.651735",
"0.64219433",
"0.62898594",
"0.61857265",
"0.61634403",
"0.6156263",
"0.6106203",
"0.6034091",
"0.6017976",
"0.59139544",
"0.5870529",
"0.5859585",
"0.58485717",
"0.58320916",
"0.58291703",
"0.58214",
"0.58163875",
"0.58081... | 0.7416645 | 0 |
Return lowest common multiple of 1 or more integers. Examples >>> lcm(5) 5 >>> lcm(30, 40) 120 >>> lcm(120, 40, 60) 120 | def lcm(*numbers):
def lcm(a, b):
return (a * b) // gcd(a, b)
return reduce(lcm, numbers, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lcm(L):\n lcm, M = 1, []\n for i in L:\n for j in M:\n if i % j == 0:\n i //= j\n while i > 1:\n lcm *= low_prime(i)\n M.append(low_prime(i))\n i //= low_prime(i)\n return lcm",
"def lcm(*args):\r\n\treturn functools.reduce(lam... | [
"0.81527907",
"0.8072617",
"0.80314237",
"0.80181545",
"0.8002417",
"0.79648894",
"0.79210895",
"0.78938544",
"0.7893031",
"0.78370124",
"0.7823611",
"0.7823611",
"0.78217775",
"0.7809821",
"0.7804664",
"0.7804664",
"0.7804664",
"0.7804664",
"0.7804664",
"0.7804664",
"0.78046... | 0.79516876 | 6 |
Get the bindings dependencies for this configuration item | def dependencies(self, configuration):
for typ, binding_options in self.bindings.items():
if typ in configuration:
for item in binding_options.wanted(configuration[typ].values()):
if item in configuration[typ]:
yield configuration[typ][item... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies(self) -> typing.Optional[typing.List[aws_cdk.core.IDependable]]:\n return self._values.get('dependencies')",
"def get_dependency_configurations(self):\n deps = []\n\n for variant in self.resolve_variants():\n # Note: the variants have already been resolved\n # This for loo... | [
"0.6958315",
"0.66978264",
"0.660991",
"0.6569745",
"0.63485926",
"0.6325884",
"0.62155646",
"0.61045873",
"0.6097252",
"0.608737",
"0.5985237",
"0.5934503",
"0.5864146",
"0.58450717",
"0.5816706",
"0.5760295",
"0.57166797",
"0.57104576",
"0.57050216",
"0.5704221",
"0.5663951... | 0.6742327 | 1 |
Get back (exists, current) for this config | def get_current(self, config):
try:
url = "/{0}/{1}".format(config.typ, config.name)
content_type = self.content_type(config.typ)
current = self.get(url, content_type=content_type)
return True, current
except BadNetScaler as error:
msg = error.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config() -> Optional[Config]:\n return CurrentConfig.get()",
"def __previous_config(self):\n if self.__during_ha_import:\n return self.__config_before_ha_import\n try:\n return self.core.config_manager.get(\n self.NAME,\n which_configur... | [
"0.69969046",
"0.69082505",
"0.67289513",
"0.6674991",
"0.6581849",
"0.6539241",
"0.64462054",
"0.64425504",
"0.64288723",
"0.6413998",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934",
"0.6388934... | 0.67833674 | 2 |
Gets the ticker label for the stocks in dataset. | def get_stock_labels(self):
return self.stock_labels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_label(self):\n return ThreeCardPokerHand.all_labels[self.rank]",
"def ticker(self):\n return self.__train_prop[\"ticker\"]",
"def get_label ( self ):\n return self.label",
"def _get_label(self):\n return self.label",
"def get_label(self):\n return self.label",
"... | [
"0.6800865",
"0.6458131",
"0.6314701",
"0.6311462",
"0.63044775",
"0.63044775",
"0.63044775",
"0.63044775",
"0.62723583",
"0.62489575",
"0.6221464",
"0.6198633",
"0.6184881",
"0.61542374",
"0.61493295",
"0.61493295",
"0.61351824",
"0.60679054",
"0.60620624",
"0.60176915",
"0.... | 0.73723894 | 0 |
a and b are packets packets are lists or ints (may be nested) Return 1 if a b This can be used as a comparator | def packet_in_correct_order(self, a, b) -> bool:
res = self.elements_in_order(a, b, depth=0, debug=False)
return -1 if res else 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorted_are_equal(a, b):\n\n def int_sort(x):\n return sorted(x.astype(numpy.int32))\n\n return int_sort(a) == int_sort(b)",
"def comparator(a, b):\n\n # first compare q values\n result = -cmp(a[2], b[2])\n if result is not 0:\n # q values differ, no ne... | [
"0.64400196",
"0.6348703",
"0.62699956",
"0.62214756",
"0.6171453",
"0.6152621",
"0.610649",
"0.6084915",
"0.60667944",
"0.60585934",
"0.6014313",
"0.5998065",
"0.59808534",
"0.59648234",
"0.5929483",
"0.5910543",
"0.58833003",
"0.5868059",
"0.58467495",
"0.58246297",
"0.5823... | 0.7024052 | 0 |
Return the sum of the indices of the pairs that are in order | def part_one(self) -> int:
sum_of_indices_of_in_order_pairs: int = 0
for i in range(0, len(self.packets), 2):
if self.packet_in_correct_order(self.packets[i], self.packets[i+1]) == -1:
# Because we want the index of the pair, rather than of the packet
# we nee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def twoSum(self, nums, target):\n for index_i, i in enumerate(nums):\n for index_j, j in enumerate(nums[index_i+1:]):\n if j + i == target:\n return [index_i + 1, index_j + index_i + 2]",
"def sum_pairs(arr: list, sum: int):\n pair_count = 0\n count_map =... | [
"0.64383143",
"0.6359465",
"0.6350773",
"0.6292224",
"0.62760055",
"0.6256426",
"0.62192696",
"0.62122595",
"0.61148226",
"0.61118937",
"0.61001295",
"0.60718256",
"0.60504526",
"0.6045381",
"0.602317",
"0.6021156",
"0.6017912",
"0.6008013",
"0.5988563",
"0.5973825",
"0.59488... | 0.68311673 | 0 |
Override the equal operator | def __eq__(self, other):
return self.item_id == other.item_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n raise NotImplementedError('must be implemented by subclass')",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n ... | [
"0.7795165",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.7772337",
"0.7772337",
"0.775098",
"0.775098",
"0.775098",
"0.77436566",
"0.77436566",
"0.77436566",
"0.77... | 0.0 | -1 |
Returns the name of the item | def get_name(item_id):
if item_id in all_items:
return all_items[item_id]['name']
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_name(self):\n return self.__item_name",
"def getName(self,item):\n return item.s",
"def get_item_name(self, i):\n for item in self.items:\n if item['id'] == i:\n return item['localized_name']\n return 'Unknown Item'",
"def get_name(self):\n ... | [
"0.9020054",
"0.8990347",
"0.8091048",
"0.805832",
"0.7946445",
"0.79148144",
"0.78918225",
"0.7814328",
"0.7692716",
"0.7649157",
"0.760299",
"0.7569946",
"0.75132275",
"0.74614924",
"0.74534607",
"0.74534607",
"0.74534607",
"0.7448909",
"0.7439888",
"0.7439888",
"0.74221456... | 0.7923903 | 5 |
Constructor for a PoisonEffect | def __init__(self, _item, p_source):
self.p_id = "{}_{}".format(_item.item_id, p_source)
self.dam = _item.prop['poison']
self.dur = _item.prop['duration'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, particles):\n self.particles = particles",
"def __init__(self, p=0.5):\n self.p = p",
"def __init__(self, p, multiplier=1e-1):\r\n super().__init__(multiplier=multiplier)\r\n self.p = p",
"def __init__(self, strength, constitution, dexterity,\r\n ... | [
"0.6111748",
"0.6068915",
"0.60570157",
"0.6020604",
"0.60116273",
"0.5990433",
"0.5988238",
"0.5914012",
"0.589367",
"0.589367",
"0.58877116",
"0.58848286",
"0.58779037",
"0.5865742",
"0.58635855",
"0.5859797",
"0.58528435",
"0.58492893",
"0.584343",
"0.58426166",
"0.5775549... | 0.66233367 | 0 |
Override the equal operator | def __eq__(self, other):
return self.p_id == other.p_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n raise NotImplementedError('must be implemented by subclass')",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n ... | [
"0.7795165",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.77812034",
"0.7772337",
"0.7772337",
"0.775098",
"0.775098",
"0.775098",
"0.77436566",
"0.77436566",
"0.77436566",
"0.77... | 0.0 | -1 |
r""" String representation of the object. | def _repr_(self):
if self._tensor._name is not None:
name = self._tensor._name
else:
name = 'X'
if self._con == '':
return name + '_' + self._cov
elif self._cov == '':
return name + '^' + self._con
else:
return name + '^... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.__dict__['_obj'])",
"def __str__(self):\n return str(self.serialize())",
"def as_string(self):\n return self.__repr__()",
"def __str__(self):\n return str(self.obj)",
"def __str__(self):\n return repr(self)",
"def toString(se... | [
"0.8314811",
"0.83131737",
"0.8141416",
"0.81265575",
"0.8124195",
"0.81134546",
"0.8111107",
"0.8111107",
"0.8098341",
"0.8098341",
"0.8098341",
"0.8098341",
"0.8098341",
"0.80722225",
"0.8065788",
"0.80409765",
"0.80188066",
"0.7999481",
"0.796723",
"0.796723",
"0.796723",
... | 0.0 | -1 |
Process a row of columnar entries from the poly(A) call file into a dictionary of values. | def next(self):
try:
# get entries:
entries = self.fhandle.readline().rstrip().split()
# if not a polya-samples row, skip it:
if (entries[0] != 'polya-samples'):
return next(self)
# format row and return:
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_line(line):\n parts = line.strip().split('\\t')\n\n output = {}\n\n if len(parts) != len(COLUMNS):\n raise Exception('Incorrect number of columns in line.', parts, COLUMNS)\n\n for key, value in zip(COLUMNS, parts):\n if key == 'attributes':\n output[key] = parse_attr... | [
"0.58197576",
"0.5631563",
"0.5623386",
"0.5572082",
"0.5527829",
"0.54525125",
"0.5408792",
"0.54046434",
"0.53973174",
"0.5378931",
"0.5364883",
"0.53536254",
"0.5341481",
"0.53275746",
"0.5312663",
"0.52973783",
"0.5282404",
"0.5277898",
"0.5244735",
"0.52215916",
"0.52032... | 0.49151155 | 78 |
Helper function that sets dtype to that of the given data in the fitting step. Fixes inv_eps data type to that of input data. | def _update_dtype(self) -> None:
self.inv_eps = np.array([self.inv_eps]).astype(self.dtype)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast(self, dtype):\n self.dtype = np.dtype(dtype)\n self.preprocess = False\n self.set_data(self.data)",
"def _convert_data(self, data):\n if isinstance(data, Tensor):\n data = data.asnumpy()\n elif isinstance(data, list):\n data = np.array(data)\n ... | [
"0.612807",
"0.5669411",
"0.56674576",
"0.56642234",
"0.5659786",
"0.55416834",
"0.5471718",
"0.53629225",
"0.5299172",
"0.5283636",
"0.524403",
"0.5222983",
"0.5202983",
"0.5190106",
"0.5179996",
"0.5149133",
"0.51054776",
"0.5089787",
"0.5062818",
"0.5041003",
"0.50399274",... | 0.8101427 | 0 |
Create a deep copy of this client. Returns WOQLClient The copied client instance. Examples | def copy(self) -> "WOQLClient":
return copy.deepcopy(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n new_client = self._client.copy()\n return self.__class__(self.instance_id, new_client,\n self._cluster_location_id,\n display_name=self.display_name)",
"def copy(self, **kwargs):\n\n # Future versions may add new opt... | [
"0.69454944",
"0.6172662",
"0.60668427",
"0.60249084",
"0.5981692",
"0.5963893",
"0.5948893",
"0.59245646",
"0.59202266",
"0.59026885",
"0.5897046",
"0.5853876",
"0.5846904",
"0.5842724",
"0.58397835",
"0.58397835",
"0.5826108",
"0.582209",
"0.582209",
"0.582209",
"0.582209",... | 0.85636854 | 0 |
Get the current database. Returns str The current database identifier. Examples | def db(self) -> str:
return self._db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"database\")",
"def database(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"database\")",
"def database(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"database\")",
"def database(self) -> Opt... | [
"0.79443175",
"0.7683129",
"0.7656967",
"0.7656967",
"0.7642972",
"0.76349634",
"0.75983447",
"0.75898194",
"0.7558618",
"0.7528919",
"0.7504084",
"0.7482693",
"0.7444181",
"0.7435971",
"0.7412634",
"0.73912346",
"0.72364855",
"0.71959",
"0.71725464",
"0.713493",
"0.71276045"... | 0.75677705 | 8 |
Get the account identifier. Returns str The current account name. Examples | def account(self) -> str:
return self._account | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_id():\n return client.get_caller_identity()['Account']",
"def id(self) -> str:\n account_id = self.__session.client(\"sts\").get_caller_identity().get(\"Account\")\n if account_id:\n return account_id\n raise ValueError(\"get_caller_identity did not return Account\"... | [
"0.8006036",
"0.7899546",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7895239",
"0.7843793",
"0.7843793",
"0.7843793",
"0.7800712",
"0.7800712",
"0.7569997",
"0.7533123",
"0.7477138",
"0.7477138",
"0.7477138",
"0.7477138",
"... | 0.7509389 | 17 |
Set or get the repository identifier. If repoid is not provided, then the config will not be updated. | def repo(self, repoid: Optional[str] = None) -> str:
if repoid:
self._repo = repoid
return self._repo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repository_id(self) -> str:\n raise NotImplementedError",
"def repository_name(self) -> Optional[str]:\n return pulumi.get(self, \"repository_name\")",
"def repository_name(self) -> Optional[str]:\n return pulumi.get(self, \"repository_name\")",
"def repository_name(self) -> Opti... | [
"0.64819914",
"0.573495",
"0.573495",
"0.573495",
"0.5599369",
"0.546896",
"0.5394508",
"0.53903854",
"0.53500366",
"0.5300593",
"0.51603866",
"0.5096333",
"0.50858",
"0.5063177",
"0.5002114",
"0.5002114",
"0.49713087",
"0.49406955",
"0.49337834",
"0.48938486",
"0.48876157",
... | 0.7765039 | 0 |
Get metadata as GeoDataFrame | def meta_as_geopandas(infiles, multiprocessing_above=40):
if multiprocessing_above is not None and len(infiles) > multiprocessing_above:
nprocs = multiprocessing.cpu_count()
with concurrent.futures.ProcessPoolExecutor(nprocs) as executor:
gss = list(executor.map(_get_meta_as_geoseries_fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raster_to_geodataframe(*a, **kw) -> gpd.GeoDataFrame:\n kw[\"geo\"] = True\n return raster_to_dataframe(*a, **kw)",
"def gdf(self) -> gpd.GeoDataFrame:\n path = str(get_path(\"geojson/FeatureCollection02.json\"))\n df = gpd.read_file(path)\n return df",
"def gdf(self) -> gpd.GeoD... | [
"0.65096146",
"0.6496599",
"0.63679963",
"0.6333591",
"0.63039553",
"0.6258158",
"0.6248611",
"0.62454545",
"0.61592084",
"0.605968",
"0.6046729",
"0.6038987",
"0.6001251",
"0.5967043",
"0.5965353",
"0.596476",
"0.5959358",
"0.59422266",
"0.5934539",
"0.5931223",
"0.593103",
... | 0.0 | -1 |
median lenght, rough approximation | def nearest_neighbour_heuristic(self, city_count):
return 1.0 / (500.0 * city_count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMedian(self, alist):\n\n \"\"\"TO BE DONE\"\"\"\n return 0",
"def median(self):\n # TO DO\n pass",
"def median(self):\r\n\t\t_sorted = sorted(self.sample)\r\n\t\t_len\t= len(self.sample)\r\n\t\treturn _sorted[(_len - 1)//2] if _len % 2 == 1 else (_sorted[(_len - 1)//2] + _sor... | [
"0.8007823",
"0.78969514",
"0.77564573",
"0.7621833",
"0.7580164",
"0.7575248",
"0.7538985",
"0.75274956",
"0.7513776",
"0.7491808",
"0.74547285",
"0.7437953",
"0.7414458",
"0.74045753",
"0.738794",
"0.73654443",
"0.73572767",
"0.73572564",
"0.7351814",
"0.73263496",
"0.73256... | 0.0 | -1 |
Return the player's disc colour (Player 1 is always 'X'). | def get_player_disc_colour(self, name):
player_number = self.game["players"].index(name)
return self.player_discs[player_number] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player(self):\n return self._color",
"def get_colour(self):\n return self.colour",
"def get_color(self):\r\n if self.color:\r\n return \"RED\"\r\n else:\r\n return \"BLACK\"",
"def getCurrentColor(self):\n if self.__currentnode__ is None:\n ... | [
"0.7429318",
"0.68470377",
"0.67481935",
"0.6625655",
"0.6557002",
"0.64882207",
"0.6455063",
"0.6435626",
"0.6432927",
"0.6418421",
"0.6401265",
"0.6357334",
"0.63209325",
"0.6310094",
"0.6308087",
"0.62127215",
"0.621267",
"0.61601156",
"0.60931325",
"0.60735196",
"0.604145... | 0.83922756 | 0 |
Get the name of the Redis key. | def redis_key(self):
return 'tesseract:table:%s' % self.table_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_name(self) -> str:\n return pulumi.get(self, \"key_name\")",
"def key_name(self):\n return self._key_name",
"def get_name(self):\n return self.key().name().split(':', 1)[1]",
"def key_name(self) -> Optional[str]:\n return pulumi.get(self, \"key_name\")",
"def name(self):... | [
"0.8182606",
"0.7997518",
"0.7838483",
"0.77446216",
"0.7507293",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
"0.7498547",
... | 0.0 | -1 |
Generate a random table name. | def __random_table_name(self):
return 'tmp_%s_%s' % (self._xid(), ''.join(
random.choice('abcdefghijklmnopqrstuvwxyz')
for _ in range(8)
)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def s3_table_random_name():\n\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n return ''.join(random.choice(alpha) for _ in range(8))",
"def table_name() -> str:\n pass",
"def _get_random_name(self, base_name):\n return base_name + '_' + self.__id_generator()",
"def generate_rand_name()... | [
"0.8155827",
"0.75677574",
"0.7060786",
"0.6989789",
"0.6926941",
"0.68452805",
"0.6824041",
"0.6813894",
"0.67685103",
"0.66852903",
"0.6665112",
"0.66630435",
"0.66264844",
"0.6622886",
"0.6601651",
"0.6598609",
"0.6592808",
"0.6573126",
"0.6568668",
"0.65446025",
"0.654069... | 0.86728096 | 0 |
Build a list of files at ``relative_paths`` with respect to the root ``root_directory`` directory Returns a list of absolute paths and a list of any relative paths that were not found. Falls back to a full recursive search of ``relative_paths`` with ``pathlib.Path.rglob`` to enable pathlib style pattern matching. | def available_files(root_directory, relative_paths):
root_directory = pathlib.Path(root_directory).resolve()
if isinstance(relative_paths, str):
relative_paths = [relative_paths]
available_files = []
not_found = []
for relative_path in relative_paths:
file_list = []
absolute... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_paths(root_path, excludes):\n files_list = []\n files_tree = (root_path.name, [], [])\n\n exclude_spec = (\n excludes\n if isinstance(excludes, pathspec.PathSpec)\n else pathspec.PathSpec.from_lines(\"gitwildmatch\", excludes)\n )\n\n for subpath in root_path.iterdir():... | [
"0.6552884",
"0.655058",
"0.6510189",
"0.6302782",
"0.62780374",
"0.62780374",
"0.6139298",
"0.61177266",
"0.60061085",
"0.5984799",
"0.5975271",
"0.5971495",
"0.5901511",
"0.58819145",
"0.58761376",
"0.58685964",
"0.5866942",
"0.58556235",
"0.5839728",
"0.58288354",
"0.58172... | 0.76436776 | 0 |
Return the longest common file path prefix. The edge case of a single path is handled by returning the parent directory | def longest_common_path_prefix(file_list):
if isinstance(file_list, str) or isinstance(file_list, pathlib.Path):
file_list = [file_list]
file_list = [pathlib.Path(path) for path in file_list]
number_of_files = len(file_list)
if number_of_files < 1:
raise RuntimeError("No files in 'file_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_common_parent(paths: 'List[str]') -> str:\n return os.path.commonprefix([path + '/' for path in paths]).rstrip('/')",
"def _keep_common_path(paths: Iterable[str]) -> str:\n common_path: Optional[str] = None\n for path in paths:\n if common_path is None:\n common_path = path\n ... | [
"0.76350385",
"0.6845331",
"0.6800973",
"0.67515665",
"0.65777344",
"0.6432661",
"0.64265466",
"0.64255476",
"0.6406732",
"0.6372219",
"0.6257661",
"0.62535745",
"0.6244957",
"0.623368",
"0.62305105",
"0.6173464",
"0.6131038",
"0.6084803",
"0.60728383",
"0.60520583",
"0.60519... | 0.823794 | 0 |
Check if char c is part of a number. | def is_number_char(c: str) -> bool:
return c.isdigit() or c == "." | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_number(c):\n return '0' <= c <= '9'",
"def is_num_char(x):\n return ord('0') <= ord(x) <= ord('9')",
"def isnum(self, x):\n\n return x in '1234567890.-'",
"def is_number(s):\r\n try:\r\n int(s)\r\n return True\r\n except ValueError:\r\n return False",
"def isn... | [
"0.8534505",
"0.7860635",
"0.7279074",
"0.7113034",
"0.70901036",
"0.70710176",
"0.6992018",
"0.697007",
"0.6964018",
"0.6963145",
"0.6908057",
"0.68372893",
"0.6672422",
"0.6671802",
"0.66528183",
"0.66478175",
"0.6638793",
"0.6629772",
"0.6600584",
"0.6545828",
"0.6528396",... | 0.8007064 | 1 |
Set the Y range on the histogram plot. This disables autoscaling. | def setHistogramRange(self, mn, mx, padding=0.1):
self.vb.enableAutoRange(self.vb.YAxis, False)
if self.orientation == 'horizontal':
self.vb.setXRange(mn, mx, padding)
elif self.orientation == 'vertical':
self.vb.setYrange(mn, mx, padding)
# mn -= d*padding
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetYAxisRange(self, lower, upper):\n self.Y_AXIS_RANGE = (lower, upper)",
"def autoHistogramRange(self):\n self.vb.enableAutoRange(self.vb.XAxis, True)\n self.vb.enableAutoRange(self.vb.YAxis, True)\n # self.range = None\n # self.updateRange()\n # self.vb.setMouseEna... | [
"0.770465",
"0.73213285",
"0.704145",
"0.6781482",
"0.66490066",
"0.6538384",
"0.6378235",
"0.63495",
"0.633836",
"0.6328066",
"0.63124216",
"0.63065165",
"0.6299676",
"0.6297037",
"0.6208088",
"0.6172041",
"0.61706746",
"0.61642826",
"0.6117473",
"0.6108551",
"0.610324",
"... | 0.65926754 | 5 |
Proxy for the underlying connection's ``__enter__`` method. | def __enter__(self):
return self.connection.__enter__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enter__(self) -> None:\n raise NotImplementedError()",
"def __enter__(self):\r\n pass",
"def __enter__(self):\n pass",
"def __enter__(self):\n pass",
"def __enter__(self):\n raise NotImplementedError",
"def __enter__(self):\n self.connect()\n return ... | [
"0.7537354",
"0.74938166",
"0.74534523",
"0.74534523",
"0.73512274",
"0.73095393",
"0.7271211",
"0.7175744",
"0.7146947",
"0.71201944",
"0.71201944",
"0.7112627",
"0.7108524",
"0.70493174",
"0.7042512",
"0.7021737",
"0.6987961",
"0.69667435",
"0.69667435",
"0.6930869",
"0.693... | 0.84196335 | 0 |
Extracts a floating point number from string in data, if possible. | def float_from_string(data):
return float(maybe_number(data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_float(self, s: str) -> float:\n f = re.findall(r'([0-9]*[.]*[0-9]+)', s)\n return float(f[0]) if len(f) > 0 else None",
"def parse_reading(data):\n pat =re.compile('([1-9][0-9]*)')\n datum = data.split('\\n')\n #print datum\n for d in datum:\n m = pat.search(d)\n ... | [
"0.755782",
"0.7219522",
"0.71647894",
"0.7011425",
"0.683637",
"0.68265843",
"0.6761156",
"0.6747051",
"0.67294866",
"0.6692276",
"0.65983623",
"0.65970683",
"0.65940166",
"0.6585006",
"0.6562844",
"0.6544855",
"0.65241283",
"0.65172917",
"0.64691854",
"0.6428348",
"0.642470... | 0.8111424 | 0 |
Counts pairs that can't form in sequence. Sequence must have a Pairs property that acts like a dictionary containing a 2element tuple for each valid pair. Can also pass in the pairs explicitly. | def mismatches(self, sequence, pairs=None):
mismatches = 0
if pairs is None:
try:
pairs = sequence.Alphabet.Pairs
except AttributeError:
pairs = sequence.Pairs
for up, down in self.directed():
curr = (sequence[up], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_pairs(seq):\n n = len(seq)\n return int(n * (n-1)/2) # sum of arphmetic progression (n-1)...1",
"def howmany_sequences(listOfTuples):\r\n #initialize number of pairs as 0\r\n pairs = 0\r\n #count pairs\r\n for n in listOfTuples:\r\n pairs += 1\r\n k = 1\r\n #find numbe... | [
"0.6764654",
"0.64866036",
"0.6195914",
"0.6179769",
"0.61465794",
"0.61052096",
"0.58531255",
"0.56959087",
"0.56959087",
"0.55879396",
"0.5585179",
"0.55750227",
"0.5555663",
"0.5551605",
"0.5490842",
"0.5490247",
"0.54788613",
"0.5419092",
"0.54078573",
"0.54038346",
"0.53... | 0.6443498 | 2 |
Get list of connectors for a given project. | def get(self, request, p_name):
project = Project.objects.get(name=p_name)
connectors = project.connector_set.all()
serializer = ConnectorSerializer(connectors, many=True)
return JsonResponse({'connectors': [data['name'] for data in serializer.data]}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_connectors_list(self):\n pass",
"def getConnectionList(self):\n return []",
"def get_all(self) -> typing.List[Connection]:\n return [Connection.from_dict(conn) for conn in self.query(CONNECTION_URL)]",
"async def get_all(self) -> typing.List[Connection]:\n return [Con... | [
"0.63358647",
"0.60401684",
"0.59972143",
"0.5953142",
"0.58265674",
"0.57676953",
"0.5742635",
"0.57345635",
"0.5640241",
"0.55795395",
"0.5573758",
"0.5571501",
"0.55375767",
"0.553626",
"0.54609215",
"0.54108053",
"0.5363112",
"0.535898",
"0.53459543",
"0.53381914",
"0.533... | 0.63066024 | 1 |
Function for the TensorBoard summaries Adds the mean, standard deviation and histogram to the TensorBoard summaries | def variable_summaries(var):
mean = tf.reduce_mean(var)
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
tf.summary.scalar('mean', mean)
tf.summary.scalar('stddev', stddev)
tf.summary.histogram('histogram', var) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_summaries(self):\n self._loss_summary = tf.summary.scalar('loss', self._loss)\n self._perplexity_summary = tf.summary.scalar('average_perplexity_per_sentence', self._average_perplexity)",
"def build_summaries(self):\n\n # Loss summary.\n tf.summary.scalar('loss', self.loss)\n\n ... | [
"0.7271124",
"0.72650415",
"0.72650415",
"0.72441274",
"0.7190665",
"0.7118744",
"0.71183115",
"0.7065941",
"0.70522046",
"0.6875914",
"0.6794841",
"0.66870236",
"0.66827965",
"0.6650891",
"0.6640594",
"0.6622778",
"0.6620697",
"0.6608753",
"0.6601737",
"0.6597463",
"0.657823... | 0.6585561 | 20 |
Converts an index to the row/column indicies. | def convert_index(index:int, total_columns:int)->Tuple[int,int]:
index_row, index_column = divmod(index, total_columns)
return index_row, index_column-1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_to_xy(index):\n x = index % columns\n y = index // columns\n return x, y",
"def ind2coord(self, index):\n\n # assert (index >= 0)\n # assert(index < self.n - 1)\n\n col = index // self.rows\n row = index % self.rows\n\n return [row, col]",
"def get_row_col_... | [
"0.7331156",
"0.7257097",
"0.66820073",
"0.6592278",
"0.6565376",
"0.65388197",
"0.6299478",
"0.6297067",
"0.62251425",
"0.6159972",
"0.6128612",
"0.61249006",
"0.60653645",
"0.6020815",
"0.5975301",
"0.58782876",
"0.58668065",
"0.5865818",
"0.5834999",
"0.57963645",
"0.57797... | 0.6619981 | 3 |
Return the index of the maximum in a numpy array. | def max_index(X):
i = 0
j = 0
# TODO
if not(isinstance(X,np.ndarray )):
raise ValueError('you should enter an array')
if len(X.shape)!=2:
raise ValueError('you should enter a 2-D array')
argmax=np.argmax(X)
(i,j)=np.unravel_index(argmax, X.shape)
return i,j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_index(a):\n return a.argmax()",
"def get_max_index(a):\n return a.argmax()",
"def get_max_index(a):\n return a.argmax()",
"def max(self):\n max = 0\n a = self.array_form\n for i in xrange(len(a)):\n if a[i] != i and a[i] > max:\n max = a[i]\... | [
"0.8426581",
"0.8426581",
"0.8426581",
"0.8021864",
"0.77716297",
"0.7517045",
"0.74010915",
"0.74010915",
"0.73741704",
"0.7339149",
"0.73191357",
"0.7299885",
"0.7298626",
"0.7276159",
"0.7229451",
"0.720949",
"0.7146336",
"0.7121334",
"0.7116714",
"0.7046598",
"0.6985995",... | 0.796435 | 4 |
Apply translation to transformation matrix | def translate(self, x=0, y=0, z=0):
translation = np.identity(4)
translation[0, 3] += x
translation[1, 3] += y
translation[2, 3] += z
self.matrix = np.matmul(self.matrix, translation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Translate(*args, **kwargs):\n return _gdi_.GraphicsMatrix_Translate(*args, **kwargs)",
"def __compose_transformation(self):\n s = self.scale\n rotR = self.rotation\n t = self.translation\n T = np.eye(4)\n T[0:3, 3] = t\n R = np.eye(4)\n R[0:3, 0:3] = ro... | [
"0.7344373",
"0.71070033",
"0.70376515",
"0.70143545",
"0.6978896",
"0.69560623",
"0.6838419",
"0.68325746",
"0.6813717",
"0.67443657",
"0.6740027",
"0.6729803",
"0.6703098",
"0.6701878",
"0.6614008",
"0.654868",
"0.6510238",
"0.6466499",
"0.64654547",
"0.64600724",
"0.643911... | 0.7269791 | 1 |
Writes the record dictionary to JSON Using the record dictionary we will write it to the backup filepath setup during initialization. | def write_to_json(self):
logging.info('Writing records to JSON')
with open(self.backup, 'w') as fp:
json.dump(self.record, fp)
logging.info("Finished writing records to JSON") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_json(\n output_path, records\n):\n output_path.write_text(json.dumps(records))",
"def save(self, filename):\n with open(filename, \"w\") as f:\n m = {\n \"order\": self.order,\n \"pad\": self.pad,\n \"records\": {str(k): v for k, v in ... | [
"0.7086049",
"0.70803404",
"0.69009393",
"0.6821454",
"0.67451125",
"0.6525242",
"0.65124065",
"0.65117645",
"0.64960265",
"0.6495757",
"0.64890444",
"0.6430608",
"0.64062184",
"0.63896364",
"0.63645947",
"0.63552165",
"0.63542473",
"0.6343033",
"0.6332018",
"0.632005",
"0.63... | 0.821372 | 0 |
Returns the list of queries that the user has subscribed to | def subscribedQueries(self):
return map(Query.get, self.subscriptions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subscriptions(self):\n return self.subscriptions.all()",
"def getAllSubscriptions(self):\n return self.request(\n \"getAllSubscriptions\",\n )",
"def get_user_subscriptions(self, use_threading=False):\r\n \r\n subs = self.get_subscriptions(use_threading)\r\... | [
"0.68164206",
"0.6681832",
"0.6594357",
"0.6507611",
"0.6497931",
"0.6449514",
"0.6430979",
"0.6429039",
"0.6401978",
"0.637252",
"0.63264805",
"0.6317181",
"0.6281191",
"0.62794113",
"0.62331855",
"0.6230512",
"0.621619",
"0.6209856",
"0.6203647",
"0.61974454",
"0.6156554",
... | 0.8313021 | 0 |
adds the given query to the user's subscriptions if not already subscribed | def add_subscription(self, query):
key = query.key()
if key not in self.subscriptions:
self.subscriptions += [key]
self.put() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_subscription(self, query, price):\n session = Session()\n sub = self.cart.add_subscription(query, price)\n offers = session.search(query, self.lat, self.lon, self.radius)\n list(sub.handle_offers(offers))\n sub.check_offers()\n self.config_updated()",
"def subscr... | [
"0.6374994",
"0.59569687",
"0.5804311",
"0.57796645",
"0.5702056",
"0.56925344",
"0.5676158",
"0.5606909",
"0.5556698",
"0.5553765",
"0.5496701",
"0.5492802",
"0.5478927",
"0.54748666",
"0.5455696",
"0.54477394",
"0.5425517",
"0.5420002",
"0.5353651",
"0.53360057",
"0.5330451... | 0.8049637 | 0 |
Return a datetime object representation of the start date and time | def start_datetime(self):
date_string = self.data.get('Start date')
time_string = self.data.get('Start time')
start_datetime_string = "{date} {time}".format(date=date_string, time=time_string)
return datetime.datetime.strptime(start_datetime_string, self.datetime_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_datetime(self):\n\n start = \"{0} {1}\".format(self.data.get('Start date'), self.data.get('Start time'))\n return datetime.datetime.strptime(start, self.datetime_format)",
"def start_datetime(self):\n\n start = self.data.get('start').split(\"+\")[0]\n return datetime.datetim... | [
"0.8442556",
"0.807055",
"0.7946708",
"0.7845828",
"0.77040994",
"0.76179266",
"0.75686806",
"0.74587137",
"0.744614",
"0.7374583",
"0.7351325",
"0.7220931",
"0.71761405",
"0.7164468",
"0.7133027",
"0.71056896",
"0.7083072",
"0.7081929",
"0.70203364",
"0.70203364",
"0.7014949... | 0.8394814 | 1 |
Return a datetime object representation of the start date and time | def start_datetime(self):
start = "{0} {1}".format(self.data.get('Start date'), self.data.get('Start time'))
return datetime.datetime.strptime(start, self.datetime_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_datetime(self):\n date_string = self.data.get('Start date')\n time_string = self.data.get('Start time')\n start_datetime_string = \"{date} {time}\".format(date=date_string, time=time_string)\n return datetime.datetime.strptime(start_datetime_string, self.datetime_format)",
"... | [
"0.8394814",
"0.807055",
"0.7946708",
"0.7845828",
"0.77040994",
"0.76179266",
"0.75686806",
"0.74587137",
"0.744614",
"0.7374583",
"0.7351325",
"0.7220931",
"0.71761405",
"0.7164468",
"0.7133027",
"0.71056896",
"0.7083072",
"0.7081929",
"0.70203364",
"0.70203364",
"0.7014949... | 0.8442556 | 0 |
Return a datetime object representation of the start date and time | def start_datetime(self):
start = self.data.get('start').split("+")[0]
return datetime.datetime.strptime(start, self.datetime_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_datetime(self):\n\n start = \"{0} {1}\".format(self.data.get('Start date'), self.data.get('Start time'))\n return datetime.datetime.strptime(start, self.datetime_format)",
"def start_datetime(self):\n date_string = self.data.get('Start date')\n time_string = self.data.get('S... | [
"0.8442556",
"0.8394814",
"0.7946708",
"0.7845828",
"0.77040994",
"0.76179266",
"0.75686806",
"0.74587137",
"0.744614",
"0.7374583",
"0.7351325",
"0.7220931",
"0.71761405",
"0.7164468",
"0.7133027",
"0.71056896",
"0.7083072",
"0.7081929",
"0.70203364",
"0.70203364",
"0.701494... | 0.807055 | 2 |
3dDeconvolve with multiple inputs. | def deconv(log, stdoutdir, inputset, deconv_fnames):
log.info('Deconvolve ramps.')
log.info('Outpref: %s', deconv_fnames['outpref'])
tdir = '/mnt/lnif-storage/urihas/AVaudvisppi/timing'
sf_list = []
for i in range(6):
sf_list.append(os.path.join(tdir,
'con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convolve3_old(data, h, dev=None):\n\n if dev is None:\n dev = get_device()\n\n if dev is None:\n raise ValueError(\"no OpenCLDevice found...\")\n\n dtype = data.dtype.type\n\n dtypes_options = {np.float32: \"\",\n np.uint16: \"-D SHORTTYPE\"}\n\n if not dtype ... | [
"0.65188265",
"0.6501941",
"0.642022",
"0.6204043",
"0.6180585",
"0.59953636",
"0.5964941",
"0.5890555",
"0.58856446",
"0.58729553",
"0.58644444",
"0.58540785",
"0.5769093",
"0.57579046",
"0.57470447",
"0.57253677",
"0.57224745",
"0.57165873",
"0.5709052",
"0.5709052",
"0.570... | 0.55428743 | 70 |
Transition to basket page | def go_to_basket(self):
link = self.browser.find_element(*BasePageLocators.BASKET_LINK)
link.click() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_basket(request):\n\n return render(request, 'basket/basket.html')",
"def view_basket(request):\n\n if request.GET:\n if 'q' in request.GET:\n return redirect(get_search_request(request))\n\n context = {\n 'view': 'basket'\n }\n\n return render(request, 'basket/bas... | [
"0.6700586",
"0.66839695",
"0.66816956",
"0.6663487",
"0.65550375",
"0.64891684",
"0.6325859",
"0.6210368",
"0.6102068",
"0.5982805",
"0.5971532",
"0.59343696",
"0.59066445",
"0.58864886",
"0.58712906",
"0.5831746",
"0.5788494",
"0.57087815",
"0.57087815",
"0.57087815",
"0.57... | 0.749148 | 0 |
Function to remove html tags. | def strip_html_tags(text):
if text is np.nan:
return text
regex = re.compile(r"<.*?>")
return re.sub(regex, "", text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_html_tags_fun(self):\n cleaner = re.compile('<.*?>')\n cleaned_text = re.sub(cleaner, '', self.doc)\n cleaned_text = re.sub('[\\n\\t]', '', cleaned_text)\n self.doc = cleaned_text",
"def remove_html_tags(self,text):\n #https://medium.com/@jorlugaqui/how-to-strip-html... | [
"0.8933504",
"0.8669408",
"0.8387825",
"0.8356436",
"0.8356436",
"0.8321704",
"0.8281729",
"0.8259817",
"0.82189393",
"0.81578255",
"0.81566375",
"0.8149778",
"0.8145298",
"0.81348276",
"0.8119738",
"0.8105272",
"0.8078383",
"0.8078383",
"0.80572355",
"0.8028358",
"0.80017114... | 0.7961071 | 21 |
Make a plot of the detector's exposure | def show(self, view = None, save = False, savename = None, cmap = None):
# define the style
if cmap == None:
style = PlotStyle(cmap_name = 'macplus')
else:
style = PlotStyle(cmap_name = cmap)
# default is skymap
if view == None:
v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exposure_plots(self, energy=1000.):\n cfg = configuration.Configuration(os.path.expandvars('.'), quiet=True);\n exp = cfg.irfs.exposure(0, energy) \n hf = hpm.HPskyfun('front-1000 exp', exp, 64);\n expf = hf.getcol()\n emeanf = expf.mean()\n ... | [
"0.7131385",
"0.6327257",
"0.62717843",
"0.62560207",
"0.6169152",
"0.61292404",
"0.59710896",
"0.5960917",
"0.59589154",
"0.59421265",
"0.5902232",
"0.5860999",
"0.5842394",
"0.5833555",
"0.5813926",
"0.5810965",
"0.5805624",
"0.5790395",
"0.5783922",
"0.5777166",
"0.5775552... | 0.5640063 | 40 |
Draw a line marking the edge of the detector's exposure. | def draw_exposure_lim(self, skymap):
rightascensions = np.linspace(-180, 180, self.num_points)
limiting_dec = self.limiting_dec.deg
boundary_decs = np.tile(limiting_dec, self.num_points)
c = SkyCoord(ra = rightascensions * u.degree,
dec = boundary_decs * u.degree,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawLine(img, start, end, color = (0,0,255), thickness = 3):\n\tcv2.line(img, start, end, color, thickness)",
"def _createline(self):\n return self.cv.create_line(0, 0, 0, 0, fill=\"\", width=2,\n capstyle = TK.ROUND)",
"def draw_line(mat, pt1, pt2, color=(0, 0, 255... | [
"0.6470188",
"0.61930037",
"0.6103336",
"0.606673",
"0.6030914",
"0.60294956",
"0.6024785",
"0.60088515",
"0.5994126",
"0.59701174",
"0.59507483",
"0.591901",
"0.5910069",
"0.5904537",
"0.5886255",
"0.58550847",
"0.58204764",
"0.57815695",
"0.5775708",
"0.5766204",
"0.5765443... | 0.53786737 | 53 |
Returns the row index of the given transistor name. | def get_row_index(self, name):
# type: (str) -> Tuple[str, int]
if name == 'but':
name = 'casc'
if name not in self._row_lookup:
raise ValueError('row %s not found.' % name)
return self._row_lookup[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_row_index(self):\n for row in range(self.model.rowCount()):\n name_item = self.model.item(row, self.COL_NAME)\n fullpath = name_item.data(self.ROLE_FULLPATH)\n if fullpath == self.filepath:\n return row",
"def _get_row_index(self, row: Row) -> int:\n... | [
"0.7154485",
"0.6555717",
"0.62896043",
"0.6271246",
"0.61939764",
"0.6120093",
"0.61105597",
"0.6097573",
"0.6015041",
"0.60059005",
"0.5945495",
"0.5879304",
"0.584931",
"0.5836516",
"0.58325493",
"0.58269495",
"0.58244103",
"0.58224356",
"0.57373387",
"0.5725114",
"0.57194... | 0.7787664 | 0 |
Returns True if at least one of the digits of k is a 7, False otherwise. >>> has_seven(3) False >>> has_seven(7) True >>> has_seven(2734) True >>> has_seven(2634) False >>> has_seven(734) True >>> has_seven(7777) True >>> from construct_check import check >>> check(HW_SOURCE_FILE, 'has_seven', ... ['Assign', 'AugAssign... | def has_seven(k):
if k == 0:
return False
else:
if k%10 == 7:
return True
return has_seven(k//10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_seven(k):\n\tif k % 10 == 7:\n\t\treturn True\n\telif k < 10:\n\t\treturn False\n\telse:\n\t\treturn has_seven(k // 10)",
"def has_seven(k):\n if k % 10 == 7:\n return True\n elif k < 10:\n return False\n else:\n return has_seven(k // 10)",
"def has_seven(k):\n if k % 1... | [
"0.8422782",
"0.8167209",
"0.8167209",
"0.8167209",
"0.81542903",
"0.5718169",
"0.562933",
"0.533635",
"0.5200341",
"0.5120379",
"0.508192",
"0.5079923",
"0.50689566",
"0.50628406",
"0.5033837",
"0.50293195",
"0.5010518",
"0.49650836",
"0.4963276",
"0.49314642",
"0.49256438",... | 0.81315416 | 5 |
Check if the user has a permission on a specific object. Returns boolean. | def has_perm(context, perm, obj):
return access.has_perm(context['request'].user, perm, obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, obj):\n return request.user == obj",
"def has_object_permission(self, request, view, obj):\n\n return request.user == obj",
"def has_object_permission(self, request, view, obj):\n\n if request.method in permissions.SAFE_METHODS:\n r... | [
"0.84080106",
"0.8395755",
"0.83648664",
"0.83601016",
"0.8297963",
"0.8297465",
"0.82912165",
"0.82658327",
"0.8210199",
"0.8193177",
"0.81619567",
"0.81552976",
"0.81460965",
"0.8138135",
"0.8135119",
"0.81144565",
"0.8103343",
"0.8072119",
"0.80661094",
"0.8064911",
"0.806... | 0.82467103 | 8 |
Check if the user has a permission or owns the object. Ownership is determined by comparing perm_obj.field_name to the user in context. | def has_perm_or_owns(context, perm, obj, perm_obj, field_name='creator'):
user = context['request'].user
if user.is_anonymous():
return False
return access.has_perm_or_owns(user, perm, obj, perm_obj, field_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, obj):\n if request.user.is_superuser:\n return True\n if request.user.profile.role == UserRole.CLIENT and obj.owner != request.user:\n return False\n if request.user.profile.role == UserRole.EXECUTOR and obj.executor != reque... | [
"0.80214953",
"0.7787865",
"0.7784035",
"0.77189565",
"0.7712523",
"0.76838154",
"0.7657391",
"0.7649249",
"0.7647127",
"0.76313275",
"0.7628494",
"0.7626478",
"0.76214373",
"0.76107144",
"0.7604496",
"0.7597459",
"0.7594831",
"0.75788295",
"0.7576019",
"0.7575273",
"0.756498... | 0.8491552 | 0 |
Inverts the pixels of an `image` above a certain `threshold`. | def solarize(image, threshold, name=None):
_check_image_dtype(image)
with tf.name_scope(name or "solarize"):
threshold = tf.cast(threshold, image.dtype)
inverted_image = invert(image)
solarized_image = tf.where(image < threshold, image, inverted_image)
return solarized_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threshold_mask(image, threshold):\n image = image.copy()\n if threshold == None:\n threshold = skimage.filters.threshold_isodata(image)\n image[image > threshold] = 255\n image[image <= threshold] = 0\n return image",
"def invert(img):\n print(\"invert image\")\n # Should we edit ... | [
"0.7089746",
"0.69118756",
"0.6902617",
"0.6795254",
"0.67894113",
"0.67894113",
"0.67894113",
"0.66447294",
"0.65949637",
"0.64090466",
"0.63662684",
"0.6238197",
"0.6207296",
"0.6177463",
"0.6154518",
"0.6055879",
"0.5994631",
"0.59379",
"0.593744",
"0.59322757",
"0.5881737... | 0.5671955 | 33 |
Equalizes the histogram of a grayscale (2D) image. | def equalize_grayscale(image_channel):
bins = tf.constant(256, tf.int32)
histogram = tf.math.bincount(image_channel, minlength=bins)
nonzero = tf.where(tf.math.not_equal(histogram, 0))
nonzero_histogram = tf.reshape(tf.gather(histogram, nonzero), [-1])
step =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def histogram_equalize(im_orig):\n if im_orig.ndim == 3:\n return _histogram_equalize_rgb(im_orig)\n return _histogram_equalize_grayscale(im_orig)",
"def histogram_equalization(img):\n\n if len(img.shape) == 3:\n img_copy = np.copy(img)\n\n blue = img_copy[:,:,0]\n blue = his... | [
"0.80498624",
"0.7737783",
"0.76677626",
"0.74716926",
"0.74577636",
"0.74470735",
"0.7421014",
"0.7396376",
"0.73674595",
"0.73609906",
"0.7358955",
"0.734753",
"0.7195066",
"0.71570283",
"0.71212757",
"0.7057941",
"0.70332956",
"0.6886283",
"0.67977077",
"0.67902124",
"0.67... | 0.65032023 | 32 |
Extract query id from file name. | def _GetQueryId(filename: str) -> Optional[str]:
match = re.match(r'(.*/)?q?([0-9]+[ab]?)\.sql$', filename)
if match:
return match.group(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_id(file_path):\n # An example of file path is AlkEthOH_tripos/AlkEthOH_chain_filt1/AlkEthOH_c555.crd\n return os.path.splitext(os.path.basename(file_path))[0][9:]",
"def _get_aso_id_from_file_name(self, filename: str) -> str:\n id_parts = filename.split('/')\n prefix = id_... | [
"0.6883117",
"0.67513525",
"0.6550357",
"0.6394347",
"0.6213194",
"0.61280656",
"0.61213773",
"0.6094093",
"0.6089687",
"0.6080195",
"0.60369694",
"0.60317045",
"0.60203123",
"0.59576195",
"0.5928019",
"0.59126025",
"0.5906766",
"0.58831525",
"0.5881412",
"0.58564776",
"0.585... | 0.79092497 | 0 |
Initializes the workload with AppCrawlerWorkUnits. Initializes workload attribute with many AppCrawlerWorkUnits, configured with configurations coming from config file. | def init_default_workload(self, pkg, args_file=None, tests_dir=None):
self.workload = WorkLoad()
config = self.__load_config_file()
max_tests_per_app = self.get_config("tests_per_app", 20)
for i in range(0, max_tests_per_app):
wk = DroidBotWorkUnit(self.executable_prefix)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_configs(self):\n\n # get current location\n self.script_dir = os.path.dirname(__file__)\n\n # load configuration file\n with open(os.path.join(self.script_dir, \"config.json\")) as f:\n self.configs = json.load(f)\n \n # load some configs as attributes\... | [
"0.60698134",
"0.5841843",
"0.5801487",
"0.571989",
"0.56594145",
"0.5658567",
"0.5650999",
"0.55947536",
"0.55689925",
"0.55557066",
"0.5548184",
"0.55367625",
"0.5514136",
"0.55045736",
"0.55022645",
"0.5500091",
"0.5450607",
"0.54477733",
"0.54475707",
"0.5433647",
"0.5427... | 0.70429766 | 0 |
This function return the actual hour. | def actual_hour():
actual_hour = datetime.now()
return str(actual_hour.hour) + ':' + str(actual_hour.minute) + ':' + str(actual_hour.second) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hour(self) -> int:\n return pulumi.get(self, \"hour\")",
"def hour(self) -> int:\r\n return self._hour",
"def hour(self) -> int:\r\n return self._hour",
"def hour(self):\n return self._hour",
"def hour(self):\n return \"%s:00:00\" % self.timestamp[:13]",
"def getHou... | [
"0.8546035",
"0.8330114",
"0.8330114",
"0.8289124",
"0.8058077",
"0.799573",
"0.79943264",
"0.79889685",
"0.7908588",
"0.7908588",
"0.7908588",
"0.7786807",
"0.77731854",
"0.7713117",
"0.7707409",
"0.76532084",
"0.7601065",
"0.7320924",
"0.72807765",
"0.72200453",
"0.7198588"... | 0.8004799 | 5 |
Test NGroupSplitter alongside with the reversal of the order of spit out datasets | def test_n_group_split(self):
# Test 2 groups like HalfSplitter first
hs = NGroupPartitioner(2)
for isreversed, splitter in enumerate((hs, hs)):
if isreversed:
spl = Splitter(attr='partitions', reverse=True)
else:
spl = Splitter(attr='part... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_chunk_size_priority_over_n_splits(self):\n with self.subTest(input='list', chunk_size=1, n_splits=6):\n self.assertEqual(get_n_chunks(self.test_data, iterable_len=None, chunk_size=1, n_splits=6, n_jobs=None), 13)\n with self.subTest(input='numpy', chunk_size=1, n_splits=6):\n ... | [
"0.68311375",
"0.6592899",
"0.6578127",
"0.63387126",
"0.62665665",
"0.6192359",
"0.61918896",
"0.61779445",
"0.61767304",
"0.6143197",
"0.610464",
"0.6080793",
"0.60456276",
"0.6042441",
"0.60224473",
"0.6016693",
"0.599408",
"0.5982329",
"0.59721696",
"0.59473497",
"0.59439... | 0.8082041 | 0 |
r"""Test that `_givens_matrix` builds the correct Givens rotation matrices. | def test_givens_matrix(a, b, left):
grot_mat = _givens_matrix(a, b, left)
assert np.isreal(grot_mat[0, 1]) and np.isreal(grot_mat[1, 1])
rotated_vector = grot_mat @ np.array([a, b]).T
result_element = b / np.abs(b) * np.hypot(np.abs(a), np.abs(b)) if b else 1.0
rvec = np.array([0.0, result_element... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_givens_rotate(shape, indices, row, left):\n matrix = np.random.rand(*shape) * 1j + np.random.rand(*shape)\n unitary, (i, j) = matrix.copy(), indices\n if row:\n a, b = matrix[indices, j - 1]\n grot_mat = _givens_matrix(a, b, left)\n unitary[indices] = grot_mat @ unitary[indic... | [
"0.72518843",
"0.6978185",
"0.6266273",
"0.6247118",
"0.61445117",
"0.60841614",
"0.60031706",
"0.59559727",
"0.59314954",
"0.5929475",
"0.58726823",
"0.5852261",
"0.5838742",
"0.582861",
"0.5727887",
"0.5666725",
"0.5637228",
"0.56362426",
"0.56059223",
"0.55997443",
"0.5595... | 0.74653274 | 0 |
return a TokenList with the mentions tokens (with acronyms expanded) that are not symbols, stop words, or common group words. | def importantTokenList(self, ignoreSemanticTagList=[]):
list = tokenlist.TokenList()
for token in self.tokens:
if token.isAcronym():
expansion = token.getAcronymExpansion()
# print token.text, '=',
# for t in expansion:
# print t.text,
# print
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interestingLemmas(self):\n lemmas = set([])\n for token in self.importantTokenList():\n if token.isStopWord() == False:\n lemmas.add(token.lemma) \n return lemmas",
"def tokens(self):\n\t\tlabels_and_synonyms = list(itertools.chain.from_iterable(list(self.term_to_tokens.values())))\n\... | [
"0.68181217",
"0.6731075",
"0.66251916",
"0.64552665",
"0.6452468",
"0.6414509",
"0.6391794",
"0.63228506",
"0.6313925",
"0.6306399",
"0.6260907",
"0.62403584",
"0.62347203",
"0.6226176",
"0.61970437",
"0.61720175",
"0.6102917",
"0.60629946",
"0.6052487",
"0.60445684",
"0.604... | 0.70068365 | 0 |
return the list of words (actual token text) in mention. Do not filter out any text | def allWords(self):
words = set([])
for token in self.tokens:
words.add(token.text)
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interestingWords(self):\n words = set([])\n for token in self.importantTokenList():\n if token.isStopWord() == False:\n words.add(token.text.lower())\n return words",
"def importantWords(self, ignoreSemanticTagList=[]):\n words = set([])\n for token in self.importantTokenList(ignor... | [
"0.75205255",
"0.72772205",
"0.7101586",
"0.7048652",
"0.70209545",
"0.6907876",
"0.6894764",
"0.6894764",
"0.6894619",
"0.68776697",
"0.6833491",
"0.6825688",
"0.68131024",
"0.6809152",
"0.673239",
"0.6717672",
"0.6681532",
"0.6669037",
"0.66661894",
"0.66627425",
"0.6662259... | 0.7089172 | 3 |
return list of important words (actual token text) in mention. Exclude symbols and ['the','a','of', 'an', 'group', 'groups','arm', 'had'] | def importantWords(self, ignoreSemanticTagList=[]):
words = set([])
for token in self.importantTokenList(ignoreSemanticTagList=ignoreSemanticTagList):
words.add(token.text.lower())
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interestingWords(self):\n words = set([])\n for token in self.importantTokenList():\n if token.isStopWord() == False:\n words.add(token.text.lower())\n return words",
"def _words_and_emoticons(self):\n wes = self.text.split()\n words_punc_dict = self._words_plus_punc()\n ... | [
"0.7632719",
"0.7365619",
"0.731918",
"0.71499056",
"0.6999598",
"0.6959447",
"0.6705039",
"0.6627817",
"0.66056615",
"0.6571179",
"0.6539035",
"0.6538817",
"0.6528402",
"0.6497419",
"0.64748526",
"0.64306045",
"0.63868517",
"0.638122",
"0.63695484",
"0.6353311",
"0.634189",
... | 0.77576894 | 0 |
return list of important lemmas (lemma of actual token text) in mention. Exclude symbols and ['the','a','of', 'an', 'group', 'groups','arm', 'had'] | def importantLemmas(self, ignoreSemanticTagList=[]):
lemmas = set([])
for token in self.importantTokenList(ignoreSemanticTagList=ignoreSemanticTagList):
lemmas.add(token.lemma.lower())
return lemmas | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interestingLemmas(self):\n lemmas = set([])\n for token in self.importantTokenList():\n if token.isStopWord() == False:\n lemmas.add(token.lemma) \n return lemmas",
"def lemmatized_phrases(self):\n phrases = [set(lower_words(TextBlob(p).words.lemmatize()))\n f... | [
"0.78210175",
"0.7099474",
"0.69423145",
"0.68825656",
"0.67949134",
"0.67949134",
"0.6741339",
"0.67152625",
"0.6660616",
"0.66185766",
"0.6528543",
"0.65127474",
"0.65070057",
"0.6483213",
"0.6474462",
"0.646695",
"0.6448815",
"0.6425245",
"0.64224833",
"0.64033395",
"0.639... | 0.79324937 | 0 |
return the set of lemmas in the mention that are not symbols, stop words, or common group words | def interestingLemmas(self):
lemmas = set([])
for token in self.importantTokenList():
if token.isStopWord() == False:
lemmas.add(token.lemma)
return lemmas | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def importantLemmas(self, ignoreSemanticTagList=[]):\n lemmas = set([])\n for token in self.importantTokenList(ignoreSemanticTagList=ignoreSemanticTagList):\n lemmas.add(token.lemma.lower())\n return lemmas",
"def lemmatized_phrases(self):\n phrases = [set(lower_words(TextBlob(p).words.lemma... | [
"0.7484814",
"0.69189405",
"0.6774722",
"0.6717577",
"0.66284263",
"0.6553996",
"0.653918",
"0.651242",
"0.64191705",
"0.6410705",
"0.6370175",
"0.6365117",
"0.6360182",
"0.63402086",
"0.63402086",
"0.6303887",
"0.62870455",
"0.62384754",
"0.622087",
"0.621689",
"0.61757904",... | 0.7699475 | 0 |
return the set of words in the mention that are not symbols, stop words, or common group words | def interestingWords(self):
words = set([])
for token in self.importantTokenList():
if token.isStopWord() == False:
words.add(token.text.lower())
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def known(words: list[str]) -> list[str]:\n return [z for z in list(set(words)) if z in self.words]",
"def known(words):\r\n return set(w for w in words if w in WORDS)",
"def words(self):\n # BEGIN Question 2\n x= str(self.text).lower()\n # m = str(x).translate(string.punctua... | [
"0.71346545",
"0.70909905",
"0.707125",
"0.7068036",
"0.69499826",
"0.68125534",
"0.68009627",
"0.6760351",
"0.6702838",
"0.66900724",
"0.66473407",
"0.6638761",
"0.66048694",
"0.6596988",
"0.657948",
"0.6571927",
"0.65484476",
"0.65443814",
"0.65243626",
"0.65189874",
"0.650... | 0.74152803 | 0 |
return the number of nonstopword, nonsymbol tokens in the positional overlap between this mention and the given annotated mention. The overlap is based on position in the sentence. | def countOverlapTokens(self, annotatedMention):
if self.tokens[0].sentence != annotatedMention.tokens[0].sentence:
return 0 # mentions in different sentences, no overlap
if self.end < annotatedMention.start or self.start > annotatedMention.end:
return 0 # mention ends before or starts a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _does_token_overlap_with_annotation(\n token: Token, annot_start: int, annot_end: int\n) -> bool:\n\n return (\n annot_start <= token.idx <= annot_end\n or token.idx <= annot_start <= token.idx + len(token)\n )",
"def sentence_count(self, doc):\n\n return len(sent_tokenize(doc))... | [
"0.59847397",
"0.5822316",
"0.56207633",
"0.56020826",
"0.5597752",
"0.55727875",
"0.55027694",
"0.5490109",
"0.5450844",
"0.5441014",
"0.5434364",
"0.54072094",
"0.5399751",
"0.52970916",
"0.52939355",
"0.5293714",
"0.5287647",
"0.52833784",
"0.5250938",
"0.52500004",
"0.524... | 0.8331072 | 0 |
Generate an altered version of a nickname that caused a collision in an effort to create an unused related name for subsequent registration. | def alterCollidedNick(self, nickname):
return nickname + '^' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_nickname_for_user(cls, user):\n name = nickname = user.email().split('@', 1)[0]\n next_char = chr(ord(nickname[0].lower())+1)\n existing_nicks = [account.lower_nickname\n for account in cls.gql(('WHERE lower_nickname >= :1 AND '\n ... | [
"0.65738004",
"0.652622",
"0.652622",
"0.6411534",
"0.63314277",
"0.6291293",
"0.6260818",
"0.6217638",
"0.6191276",
"0.61710066",
"0.6148368",
"0.6127089",
"0.6016413",
"0.5986026",
"0.59544337",
"0.59229255",
"0.5879868",
"0.5863843",
"0.5855191",
"0.5850092",
"0.5839864",
... | 0.65603524 | 1 |
Normal vector at v Normal vector at v | def normal_f_v(self, v):
gv = self.grad_f_v(v)
gvn = np.linalg.norm(gv, axis=1)
return (gv / gvn[:, np.newaxis]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(self, u, v):\n result = np.cross(self.du(u, v), self.dv(u, v))\n result = result / np.sqrt(vectordot(result, result))[:, None]\n return result",
"def normal_at(self, u, v, world=True):\n u = u * pi\n v = v * PI2\n x = cos(u) * sin(v)\n y = sin(u) * sin(... | [
"0.808961",
"0.7777928",
"0.7612097",
"0.75472355",
"0.74701715",
"0.74098366",
"0.7264414",
"0.72299755",
"0.72165364",
"0.7211524",
"0.7131051",
"0.7068893",
"0.70622516",
"0.705551",
"0.7027712",
"0.696597",
"0.695656",
"0.69412875",
"0.6937271",
"0.6936448",
"0.6924996",
... | 0.78114426 | 1 |
Applies replacements to env and kw. | def apply_replacements(self, env, **kw):
ovr = self.replacements.apply(env)
kw = self.replacements.apply(kw, True)
return (env.Override(ovr), kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_environment(**kwargs):\n for key, value in kwargs.items():\n os.environ[key.upper()] = str(value)\n\n yield\n\n for key in kwargs:\n if key.upper() in os.environ:\n del os.environ[key.upper()]",
"def handle_kw_phrases(self, text: str\n ) -> str... | [
"0.63780546",
"0.6186776",
"0.5726015",
"0.56851",
"0.5642801",
"0.56234396",
"0.5606323",
"0.5564118",
"0.55023897",
"0.5486018",
"0.5468531",
"0.54321545",
"0.5331313",
"0.5305731",
"0.52920645",
"0.5283365",
"0.5270817",
"0.52574927",
"0.5222636",
"0.5219035",
"0.52135867"... | 0.7270186 | 0 |
Returns the string that word2 maps to, using word1 and key as the key for a chartochar mapping. Raises KeyError if word2 includes any characters not in word1. It is assumed that the letters in word1 are mapped consistently to the chars in key, i.e. that every occurrence of char X in word1 is mapped to the same char Y i... | def translate(word1, key, word2):
key = dict(zip(word1, key))
return ''.join(key[sym] for sym in word2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tostring(key1: bytes, key2: bytes=b'\\x00'):\r\n\r\n # Those are normal characters, simply decode to their respective string literals\r\n if key2 == b'\\x00':\r\n return key1.decode('latin1')\r\n else:\r\n return KeyCodes.CombinationCharacters[(key1, key2)]",
"def m... | [
"0.68999416",
"0.6366879",
"0.59578866",
"0.5761041",
"0.57436913",
"0.57308483",
"0.5491457",
"0.5462704",
"0.5238012",
"0.52363217",
"0.5190533",
"0.51380503",
"0.50953144",
"0.5089767",
"0.50745773",
"0.5052357",
"0.50384426",
"0.5009672",
"0.4976689",
"0.49600413",
"0.495... | 0.7534547 | 0 |
Create and configure a new app instance for each test. | def app():
# create a temporary file to isolate the database for each test
# create the app with common test config
app = create_app({"TESTING": True, "DATABASE_NAME": "AAPI_DB_Test"})
# create the database and load test data
with app.app_context():
init_db()
yield app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_app():\n param = {\n 'DEBUG': True,\n 'TESTING': True\n }\n _app = create_app(settings_override=param)\n\n ctx = _app.app_context()\n ctx.push()\n yield _app\n ctx.pop()",
"def create_app(self):\n app.config.from_object('config.TestingConfig')\n return ap... | [
"0.7984731",
"0.7973278",
"0.7952626",
"0.7774617",
"0.7610121",
"0.75586873",
"0.7514867",
"0.748489",
"0.7457632",
"0.7457632",
"0.7457632",
"0.74221593",
"0.7392862",
"0.7378533",
"0.73515075",
"0.7331986",
"0.7303747",
"0.7297693",
"0.7282327",
"0.7275915",
"0.7273931",
... | 0.7423435 | 11 |
Writes te plt to a csv format | def export_to_csv(self, csv_path, data_sets=None, data_sets_operations=None):
if not data_sets:
data_sets = self._data_sets.keys()
with open(csv_path, "wb") as csv_file:
for data_set in data_sets:
data = [data_set] + [str(x) for x in self._data_sets[data_set]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_csv(df):\n # remove existing plot\n if os.path.exists(\"files/converted.csv\"):\n os.remove(\"files/converted.csv\")\n # save csv\n df.to_csv('files/converted.csv')",
"def export_csv(self, path):\r\n\r\n with open(path, 'w') as f:\r\n f.write('# h,hr,m')\r\n\r\n ... | [
"0.7071125",
"0.700507",
"0.68645436",
"0.6772939",
"0.67049706",
"0.659019",
"0.6566172",
"0.65297526",
"0.6488416",
"0.64864486",
"0.6480746",
"0.6395022",
"0.63751966",
"0.63560915",
"0.6336254",
"0.6314688",
"0.6295094",
"0.6294207",
"0.6282209",
"0.62731856",
"0.625395",... | 0.0 | -1 |
Initialize a RunFromText instance with rules collection. | def __init__(self, collection):
self.collection = collection | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, rulespath=None):\n if rulespath is None:\n rulespath = path.join(path.dirname(path.realpath(__file__)), 'pattern_sentence_filter.yaml')\n\n self.rulespath = rulespath\n self.rules = Rules(yaml.safe_load(open(rulespath)))",
"def __init__(self, rules: Union[Dict[s... | [
"0.62595606",
"0.5783694",
"0.57742023",
"0.5690404",
"0.5666691",
"0.5653171",
"0.5643387",
"0.56314296",
"0.56272453",
"0.5619323",
"0.5599984",
"0.5595632",
"0.5582686",
"0.55695283",
"0.55594057",
"0.5517832",
"0.5514935",
"0.5483685",
"0.5470324",
"0.546789",
"0.5458907"... | 0.0 | -1 |
Load json from file at path. | def from_path(cls, path: str):
with open(path) as f:
return json.load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(path):\n with open(path) as data_file:\n return json.load(data_file)",
"def load_json(path):\n with open(normpath(path), 'r', encoding='utf-8') as file:\n return json.load(file)",
"def load(self, path):\n with open(path, \"rt\") as open_file:\n data = json.lo... | [
"0.87353",
"0.86052334",
"0.86043715",
"0.84109616",
"0.83911884",
"0.8288491",
"0.8279082",
"0.8256817",
"0.8174376",
"0.81695944",
"0.8165952",
"0.81521696",
"0.81354743",
"0.8118189",
"0.80910146",
"0.8088549",
"0.80864394",
"0.8058881",
"0.80484354",
"0.8003946",
"0.79896... | 0.8335796 | 5 |
Serialize mapping to string. | def to_content(cls, data: Mapping) -> str:
return json.dumps(data, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))",
"def string(self):\n return str(self._dict)",
"def __str__(self):\n sio = StringIO()\n for k in self:\n sio.write(\"... | [
"0.82183963",
"0.7204121",
"0.6642456",
"0.65922433",
"0.6446452",
"0.64427364",
"0.6402611",
"0.63784313",
"0.63705784",
"0.6354923",
"0.6297855",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.62688416",
"0.6256627... | 0.0 | -1 |
Load data from yaml formatted string. | def from_content(cls, content: str) -> Any:
cls._check_yaml()
return yaml.safe_load(content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml_string(cls, string):\n return cls(_yaml_load(string))",
"def _yaml_load(src):\n if not isinstance(src, str):\n try:\n src_name = src.name\n except AttributeError:\n src_name = '<yaml stringio>'\n # Force-load file streams as that allows the parse... | [
"0.75267714",
"0.71212053",
"0.70336205",
"0.7005339",
"0.69791245",
"0.6961655",
"0.69315034",
"0.6912102",
"0.6910845",
"0.6895913",
"0.6864176",
"0.683359",
"0.6808981",
"0.6806027",
"0.6752888",
"0.67240447",
"0.6704119",
"0.6595653",
"0.65911555",
"0.65749264",
"0.654575... | 0.68321246 | 12 |
Load data from path containing a yaml file. | def from_path(cls, path: str) -> Any:
cls._check_yaml()
with open(path) as f:
return yaml.safe_load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LoadYaml(path):\n #NOTE(g): Import is done here, instead of the top of the file, to not require this module if it is not used\n import yaml\n \n fp = None\n try:\n fp = open(path)\n \n data = yaml.load(fp)\n \n finally:\n if fp:\n fp.close()\n \n return data",
"def load_yaml_file(se... | [
"0.8245972",
"0.81248933",
"0.7858508",
"0.78034705",
"0.78005546",
"0.75352955",
"0.7512427",
"0.7505387",
"0.748309",
"0.7475744",
"0.7465097",
"0.74182844",
"0.7405493",
"0.7358135",
"0.7326122",
"0.73151976",
"0.7309648",
"0.72987473",
"0.7225925",
"0.71979517",
"0.715375... | 0.7909828 | 2 |
Serialize mapping to string. | def to_content(cls, data: Mapping) -> str:
cls._check_yaml()
s = yaml.safe_dump(data, default_flow_style=False)
s = '---\n' + s
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))",
"def string(self):\n return str(self._dict)",
"def __str__(self):\n sio = StringIO()\n for k in self:\n sio.write(\"... | [
"0.82183963",
"0.7204121",
"0.6642456",
"0.65922433",
"0.6446452",
"0.64427364",
"0.6402611",
"0.63784313",
"0.63705784",
"0.6354923",
"0.6297855",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.62688416",
"0.6256627... | 0.0 | -1 |
Serialize mapping to string. | def to_content(cls, data: Mapping) -> str:
cls._check_toml()
s = toml.dumps(OrderedDict(sorted(data.items())))
s = s.replace('\n[', '\n\n[')
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))",
"def string(self):\n return str(self._dict)",
"def __str__(self):\n sio = StringIO()\n for k in self:\n sio.write(\"... | [
"0.82183963",
"0.7204121",
"0.6642456",
"0.65922433",
"0.6446452",
"0.64427364",
"0.6402611",
"0.63784313",
"0.63705784",
"0.6354923",
"0.6297855",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.6287331",
"0.62688416",
"0.6256627... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cmat, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
print("Normalized.")
cmat = cmat.astype('float') / cmat.sum(axis=1)[:, np.newaxis]
plt.imshow(cmat,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.0 | -1 |
Always predict the previous day's Y value | def persistence_baseline(d, mode='test'):
y = getattr(d, mode + "Y")
preds = shift(y, 1, cval=0.0)
return (get_mse(d, preds, mode), get_mae(d, preds, mode),
get_mape(d, preds, mode)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, X: np.ndarray) -> np.ndarray:\n if not self._fitted:\n raise ValueError(\"Model is not fitted.\")\n\n X = (X / self.timestamp_interval).astype(int)\n shift = (X - self.y.size) // self.ts_period\n inds = X - self.ts_period * (1 + shift)\n\n if np.any(i... | [
"0.6405679",
"0.6252587",
"0.62223417",
"0.62130874",
"0.61953014",
"0.6139881",
"0.60652834",
"0.6041764",
"0.6036851",
"0.59749174",
"0.59699637",
"0.5963044",
"0.59580517",
"0.59262055",
"0.59192497",
"0.5874986",
"0.587133",
"0.58677804",
"0.5864295",
"0.5864295",
"0.5864... | 0.0 | -1 |
Indent an XML document by inserting newlines and indentation space after elements. tree is the ElementTree or Element to modify. The (root) element itself will not be changed, but the tail text of all elements in its subtree will be adapted. space is the whitespace to insert for each indentation level, two space charac... | def indent(tree: Union[ET.ElementTree, ET.Element], space=" ", level=0):
if isinstance(tree, ET.ElementTree):
tree = tree.getroot()
if level < 0:
raise ValueError(f"Initial indentation level must be >= 0, got {level}")
if not len(tree):
return
# Reduce the memory consumption by... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _xml_indent(elem, level=0):\n i = \"\\n\" + level * \" \"\n if len(elem) != 0:\n if not (elem.text and elem.text.strip()):\n elem.text = i + \" \"\n for e in elem:\n _xml_indent(e, level + 1)\n if not (e.tail and e.tail.strip()):\n e.tail = i\n e... | [
"0.6343905",
"0.6279833",
"0.57824814",
"0.56691325",
"0.5639944",
"0.56115377",
"0.55853206",
"0.55853206",
"0.5443844",
"0.52399105",
"0.5238794",
"0.51072747",
"0.5069729",
"0.50547427",
"0.5006501",
"0.4998406",
"0.4985729",
"0.4985729",
"0.49748728",
"0.4968278",
"0.4962... | 0.7260658 | 0 |
Define Residual Block showed in Zhuang (2019) CONV => BATCH => RELU => DROPOUT => CONV => BATCH | | | SHARED LAYER | | def ResBlock(input_tensor, filters):
conv_1 = Conv2D(filters = filters, kernel_size = 3, padding = 'same', kernel_initializer = 'he_normal')
conv_1a = conv_1(input_tensor) # Shared weights conv layer
batch_1 = BatchNormalization()(conv_1a)
relu_1 = Activation("relu")(batch_1)
drop_1 =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet101_base(freeze_blocks=[1,2,3], weight_regularizer=None, bias_regularizer=None):\n img_input = Input(shape=(None, None, 3))\n bn_axis = 3\n train1 = 1 not in freeze_blocks\n x = Conv2D(64, (7, 7), strides=(2, 2), padding='same', name='conv1', trainable=train1, use_bias=False,\n ... | [
"0.6686205",
"0.66425824",
"0.6553319",
"0.64887875",
"0.6457436",
"0.6445349",
"0.6370009",
"0.6346104",
"0.6310595",
"0.6291182",
"0.628418",
"0.62781084",
"0.62603647",
"0.62469715",
"0.62353355",
"0.62347627",
"0.6233347",
"0.6230214",
"0.62244767",
"0.6214197",
"0.621175... | 0.625466 | 13 |
Convert an axisangle rotation into a 4x4 transformation matrix | def rot_from_axisangle(vec):
angle = torch.norm(vec, 2, 2, True)
axis = vec / (angle + 1e-7)
ca = torch.cos(angle)
sa = torch.sin(angle)
C = 1 - ca
x = axis[..., 0].unsqueeze(1)
y = axis[..., 1].unsqueeze(1)
z = axis[..., 2].unsqueeze(1)
xs = x * sa
ys = y * sa
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axis2rotmat(axis):\n return quat2rotmat(axis2quat(axis))",
"def rotation_matrix(angle, axis):\n about_z = rotation_about_z(angle)\n z_to_axis = z_to_vector(axis)\n axis_to_z = np.linalg.inv(z_to_axis)\n return reduce(np.dot, [z_to_axis, about_z, axis_to_z])",
"def rotation(self, angle, axis)... | [
"0.77115244",
"0.73975813",
"0.7377383",
"0.7102505",
"0.70717114",
"0.6948339",
"0.6948339",
"0.68917334",
"0.6866125",
"0.684384",
"0.6811629",
"0.6698329",
"0.66897124",
"0.66434497",
"0.66267127",
"0.6610687",
"0.6588424",
"0.65657914",
"0.6565408",
"0.65514225",
"0.65482... | 0.6112975 | 77 |
Convert a translation vector into a 4x4 transformation matrix | def get_translation_matrix(translation_vector):
T = torch.zeros(translation_vector.shape[0], 4, 4).to(device=translation_vector.device)
t = translation_vector.contiguous().view(-1, 3, 1)
T[:, 0, 0] = 1
T[:, 1, 1] = 1
T[:, 2, 2] = 1
T[:, 3, 3] = 1
T[:, :3, 3, None] = t
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translation_matrix(direction):\n M = numpy.identity(4)\n M[:3, 3] = direction[:3]\n return M",
"def get_4x4_transform(scale_x, scale_y, trans_x, trans_y, trans_z):\r\n transform = [[scale_x, 0.0, 0.0, trans_x],\r\n [0.0, scale_y, 0.0, trans_y],\r\n [0.0, 0.0, 1.0, ... | [
"0.7007117",
"0.70055926",
"0.68361574",
"0.6773908",
"0.67304254",
"0.66777366",
"0.6620615",
"0.66142714",
"0.659806",
"0.6578421",
"0.65442073",
"0.6473578",
"0.63781995",
"0.6365026",
"0.6361383",
"0.63528883",
"0.6328717",
"0.6317793",
"0.6236431",
"0.6167888",
"0.615644... | 0.7313729 | 0 |
Return datetime formatted string | def timestamp(date, time, timezone):
if date and time and timezone:
# return datetime.datetime.strptime(date + time[:6], '%Y%m%d%H%M%S')
return timezone.localize(datetime.datetime.strptime(date + time[:6], '%Y%m%d%H%M%S'), timezone)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_datetime_str():\n return time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime())",
"def dtstr():\n return dt.strftime(dt.now(),'%Y %m %d, %H:%M:%S')",
"def getFormattedDate(self, dt):\n if DATE_FORMAT_STRING == '':\n return time.strftime('%Y-%m-%d %H:%M:%S', dt.timetuple())\n ... | [
"0.7997798",
"0.77770823",
"0.76630706",
"0.76426226",
"0.75177515",
"0.73710805",
"0.7323137",
"0.7318248",
"0.724719",
"0.72237486",
"0.72237486",
"0.71478397",
"0.7129341",
"0.71061337",
"0.70944095",
"0.7075704",
"0.70343536",
"0.70224285",
"0.70098084",
"0.69884104",
"0.... | 0.0 | -1 |
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager. | def get_queryset(self):
return self._queryset_class(
model=self.model,
using=self._db,
hints=self._hints,
query=CustomQuery(self.model)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self) -> QuerySet:\n raise NotImplementedError()",
"def qs(self) -> MIZQuerySet:\n if isinstance(self, type):\n raise TypeError(\n f\"Calling qs() from class level is prohibited. Use {self.__name__}.objects instead.\"\n )\n # noinspection... | [
"0.7948888",
"0.7931393",
"0.77572906",
"0.7595054",
"0.75879604",
"0.7561867",
"0.7481679",
"0.7441888",
"0.7441205",
"0.7320367",
"0.73123765",
"0.72582096",
"0.7242138",
"0.723204",
"0.7203037",
"0.7075036",
"0.6977017",
"0.68811005",
"0.6878501",
"0.6877603",
"0.6873012",... | 0.814202 | 0 |
Show API version details Use raw_request in order to have access to the endpoints minus version and project in order to add version only back. For a full list of available parameters, please refer to the official | def show_version(self, version):
version_url = urljoin(self._get_base_version_url(), version + '/')
headers = self.get_headers()
headers['X-Auth-Token'] = self.token
resp, body = self.raw_request(version_url, 'GET', headers=headers)
self._error_checker(resp, body)
body =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_api_version(self):\n version_resp = self._session.get('/api/version',\n logon_required=False)\n self._api_version = version_resp\n return self._api_version",
"def show(self, request):\n # data = VERSIONS[request.url_version]\n L... | [
"0.68244195",
"0.67963713",
"0.6789128",
"0.6607861",
"0.6575691",
"0.65686363",
"0.6542279",
"0.6368842",
"0.62973464",
"0.6294424",
"0.6278644",
"0.62525284",
"0.62256086",
"0.62120175",
"0.6207745",
"0.62050945",
"0.61999255",
"0.61521757",
"0.61321557",
"0.6085211",
"0.60... | 0.6877292 | 0 |
Called when the user specifies an intent for this skill | def on_intent(intent_request, session):
print("on_intent requestId: %s, Session: %s" % (intent_request['requestId'], session))
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your skill's intent handlers
if intent_name == "SendHevantePoints":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_intent(intent_request, session):\n\n intent = intent_request['intent']\n intent_name = intent_request['intent']['name']\n\n # Dispatch to your skill's intent handlers\n\n if intent_name not in skillmap:\n intent_name = \"NullSkill\"\n\n if intent_name in skillmap:\n try:\n ... | [
"0.7143966",
"0.6956116",
"0.6949057",
"0.6905333",
"0.68928874",
"0.67641324",
"0.6754843",
"0.6722764",
"0.6720773",
"0.67161995",
"0.6699252",
"0.6691263",
"0.6670276",
"0.6645522",
"0.6642719",
"0.6638686",
"0.6607724",
"0.6594981",
"0.6575682",
"0.65620786",
"0.65609014"... | 0.6570076 | 19 |
This function merges a bounding box based on bounding boxes from dets. It averages coordinates of `dets` proportional to their score. | def merge_bboxes_to_one(bboxes, probs, img_size, padding_ratio=0.05):
# Merging BBOX
pic_height, pic_width = img_size
final_bbox = numpy.zeros(shape=4)
assert probs.min() >= 0
if probs.max() == 0:
for i in range(bboxes.shape[0]):
final_bbox += bboxes[i] / bboxes.shape[0]
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nms(self, dets, scores):\n x1 = dets[:, 0] #xmin\n y1 = dets[:, 1] #ymin\n x2 = dets[:, 2] #xmax\n y2 = dets[:, 3] #ymax\n\n areas = (x2 - x1) * (y2 - y1) # the size of bbox\n order = scores.argsort()[::-1] # sort bounding box... | [
"0.6488668",
"0.64282006",
"0.61744756",
"0.5937983",
"0.57044613",
"0.5593589",
"0.54668784",
"0.5348895",
"0.5347397",
"0.5327971",
"0.52798074",
"0.5219619",
"0.5205347",
"0.51898164",
"0.51837665",
"0.5183669",
"0.51730627",
"0.51685834",
"0.51186675",
"0.5108181",
"0.510... | 0.5146696 | 18 |
Tokenizes the text using the rules in pattern tokens_re | def tokenize(text):
return tokens_re.findall(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n wt = nltk.RegexpTokenizer(pattern=r'\\s+', gaps=True)\n tokens = wt.tokenize(text)\n return tokens",
"def tokenize(self, text):\n # text = convert_to_unicode(text)\n\n output_tokens = []\n for token in split_by_whitespace(text):\n chars = list(token)... | [
"0.7344497",
"0.72871596",
"0.7249173",
"0.7206536",
"0.71866214",
"0.7163994",
"0.71570456",
"0.71203876",
"0.710686",
"0.71013886",
"0.7100129",
"0.70861703",
"0.7083121",
"0.70809937",
"0.7072553",
"0.70716727",
"0.7067638",
"0.7033012",
"0.70195645",
"0.7012334",
"0.69996... | 0.781842 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.