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 |
|---|---|---|---|---|---|---|
Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN].pop(entry.entry_id)
loaded_entries = [
entry
for entry in hass.config_entries.async_entries(DOMAIN)
if entry.state == ConfigEntryState.LOADED
]
if len(loaded_entries) == 1:
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.63978153 | 41 |
Read a file and return a list of lines. | def read_lines(filename):
with open(filename, 'r') as f:
lines = f.readlines()
return lines | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file_in_lines(filename):\r\n\twith open(filename) as infile:\r\n\t\tlines = infile.readlines()\r\n\treturn [line.strip() for line in lines]",
"def read_file_lines(filepath):\n with open(filepath, 'r', encoding='utf-8', newline=os.linesep) as f:\n return f.readlines()",
"def readlines(filenam... | [
"0.8466749",
"0.83859",
"0.82705975",
"0.82671875",
"0.81991166",
"0.8182739",
"0.81814766",
"0.807736",
"0.8065246",
"0.80635136",
"0.8050295",
"0.8034521",
"0.8034294",
"0.7927322",
"0.7892387",
"0.787995",
"0.7873965",
"0.78672296",
"0.78525054",
"0.7827237",
"0.782528",
... | 0.84185445 | 1 |
Sends a 401 response that enables basic auth | def authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8093736",
"0.80926424",
"0.7958403",
"0.7852648",
"0.7843114",
"0.7824419",
"0.776624",
"0.7754693",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.774767",
"0.771945",
"0.7667712",
"0.7664151",
"0.76493174",
"0.76140213",
"0.76131... | 0.7810746 | 24 |
Verifies a GET /transactions without parameters works properly. | async def test_txn_list(self):
paging = Mocks.make_paging_response(0, 3)
self.stream.preset_response(
head_id='2',
paging=paging,
transactions=Mocks.make_txns('2', '1', '0'))
response = await self.get_assert_200('/transactions')
controls = Mocks.make_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__transactions(self, mock_get):\n uri = 'https://test.com/v3/accounts/{}/transactions'.format(accountID)\n resp = responses[\"_v3_accounts_accountID_transactions\"]['response']\n text = json.dumps(resp)\n mock_get.register_uri('GET',\n uri,\n ... | [
"0.7169059",
"0.69467974",
"0.6778032",
"0.6481524",
"0.6469989",
"0.6469989",
"0.6335585",
"0.6310661",
"0.62317723",
"0.62232196",
"0.62192523",
"0.61250347",
"0.61121184",
"0.61057097",
"0.6085535",
"0.6076183",
"0.60663486",
"0.6055808",
"0.6050486",
"0.6022482",
"0.60224... | 0.58062303 | 37 |
Verifies GET /transactions with head and id parameters work properly. | async def test_txn_list_with_head_and_ids(self):
paging = Mocks.make_paging_response(0, 1)
self.stream.preset_response(
head_id='1',
paging=paging,
transactions=Mocks.make_txns('0'))
response = await self.get_assert_200('/transactions?id=0&head=1')
co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__transactions(self, mock_get):\n uri = 'https://test.com/v3/accounts/{}/transactions'.format(accountID)\n resp = responses[\"_v3_accounts_accountID_transactions\"]['response']\n text = json.dumps(resp)\n mock_get.register_uri('GET',\n uri,\n ... | [
"0.71942693",
"0.7015954",
"0.6984337",
"0.67370045",
"0.6549349",
"0.6416777",
"0.63829905",
"0.6363491",
"0.6275178",
"0.62376744",
"0.62364334",
"0.6227067",
"0.6224722",
"0.6088164",
"0.6002757",
"0.59749377",
"0.58598506",
"0.5795719",
"0.5793475",
"0.5744589",
"0.573464... | 0.7367473 | 0 |
Verifies a GET /transactions with a count of zero breaks properly. | async def test_txn_list_with_zero_count(self):
response = await self.get_assert_status('/transactions?count=0', 400)
self.assert_has_valid_error(response, 53) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_no_transactions(self):\n response = await self.collect(get_request_json_return_value={})\n self.assert_measurement(response, value=\"0\")",
"async def test_no_transactions(self):\n response = await self.collect(get_request_json_return_value={})\n self.assert_measurement... | [
"0.7153674",
"0.7153674",
"0.69534546",
"0.6758713",
"0.6676406",
"0.66698354",
"0.6656773",
"0.6599557",
"0.6412249",
"0.63739705",
"0.6321175",
"0.6174884",
"0.61332357",
"0.6092304",
"0.608266",
"0.6077496",
"0.6021119",
"0.5991651",
"0.59907895",
"0.5988278",
"0.5976223",... | 0.82633847 | 0 |
Verifies GET /transactions paginated just by count works properly. | async def test_txn_list_paginated_with_just_count(self):
paging = Mocks.make_paging_response(0, 4)
self.stream.preset_response(
head_id='d',
paging=paging,
transactions=Mocks.make_txns('d', 'c'))
response = await self.get_assert_200('/transactions?count=2')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_txn_list_paginated_without_count(self):\n paging = Mocks.make_paging_response(2, 4)\n self.stream.preset_response(\n head_id='d',\n paging=paging,\n transactions=Mocks.make_txns('b', 'a'))\n\n response = await self.get_assert_200('/transactions?m... | [
"0.77007246",
"0.74251974",
"0.7069925",
"0.6993161",
"0.6839938",
"0.677329",
"0.67613727",
"0.6527892",
"0.64921457",
"0.6473879",
"0.6391203",
"0.6389626",
"0.63158596",
"0.6265969",
"0.6234002",
"0.6193226",
"0.6190416",
"0.614115",
"0.61301374",
"0.6112564",
"0.610243",
... | 0.80063564 | 0 |
Verifies GET /transactions can send proper sort controls. | async def test_txn_list_sorted(self):
paging = Mocks.make_paging_response(0, 3)
transactions = Mocks.make_txns('0', '1', '2')
self.stream.preset_response(head_id='2', paging=paging, transactions=transactions)
response = await self.get_assert_200('/transactions?sort=header_signature')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_txn_list_sorted_in_reverse(self):\n paging = Mocks.make_paging_response(0, 3)\n transactions = Mocks.make_txns('2', '1', '0')\n self.stream.preset_response(head_id='2', paging=paging, transactions=transactions)\n\n response = await self.get_assert_200('/transactions?sort=... | [
"0.66676795",
"0.653254",
"0.6529262",
"0.65248364",
"0.6379392",
"0.6276524",
"0.6037245",
"0.6008399",
"0.5851362",
"0.58068824",
"0.57943296",
"0.57899666",
"0.57848036",
"0.57776695",
"0.5777194",
"0.57226545",
"0.57159024",
"0.57040507",
"0.5602949",
"0.55931306",
"0.555... | 0.7052601 | 0 |
Verifies a GET /transactions/{transaction_id} works properly. | async def test_txn_get(self):
self.stream.preset_response(transaction=Mocks.make_txns('1')[0])
response = await self.get_assert_200('/transactions/1')
self.stream.assert_valid_request_sent(transaction_id='1')
self.assertNotIn('head', response)
self.assert_has_valid_link(respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__transactions(self, mock_get):\n uri = 'https://test.com/v3/accounts/{}/transactions'.format(accountID)\n resp = responses[\"_v3_accounts_accountID_transactions\"]['response']\n text = json.dumps(resp)\n mock_get.register_uri('GET',\n uri,\n ... | [
"0.73038137",
"0.70534277",
"0.6906788",
"0.664259",
"0.64764535",
"0.64220446",
"0.6339045",
"0.62697726",
"0.6216957",
"0.61047286",
"0.6048317",
"0.60114384",
"0.600634",
"0.5985451",
"0.598312",
"0.5970697",
"0.5918381",
"0.5864118",
"0.5846506",
"0.5845201",
"0.58163637"... | 0.72029686 | 1 |
Direction of traffic to be captured. Valid values are `ingress` and `egress` | def traffic_direction(self) -> pulumi.Input[str]:
return pulumi.get(self, "traffic_direction") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traffic_direction(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"traffic_direction\")",
"def traffic_direction(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"traffic_direction\")",
"def get_direction(event):\n return event['result']['parameters']['direction']",... | [
"0.7063843",
"0.70357573",
"0.5919301",
"0.57909507",
"0.5788569",
"0.57549065",
"0.5705871",
"0.56085664",
"0.55834186",
"0.55659825",
"0.5478359",
"0.5353343",
"0.53419346",
"0.5309664",
"0.5268469",
"0.5261772",
"0.5242762",
"0.5225194",
"0.5212933",
"0.5127292",
"0.511361... | 0.7289455 | 0 |
ARN of the traffic mirror filter rule. | def arn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_rule_arn(self) -> str:\n return pulumi.get(self, \"config_rule_arn\")",
"def config_rule_arn(self) -> str:\n return pulumi.get(self, \"config_rule_arn\")",
"def rule(self) -> str:\n if self._rule:\n return self._rule\n return self._make_rule(member_param=self._... | [
"0.61595756",
"0.61595756",
"0.5683729",
"0.5549101",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
"0.54840195",
... | 0.49532038 | 74 |
Direction of traffic to be captured. Valid values are `ingress` and `egress` | def traffic_direction(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "traffic_direction") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traffic_direction(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"traffic_direction\")",
"def traffic_direction(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"traffic_direction\")",
"def get_direction(event):\n return event['result']['parameters']['direction']",
"def ge... | [
"0.7289455",
"0.70357573",
"0.5919301",
"0.57909507",
"0.5788569",
"0.57549065",
"0.5705871",
"0.56085664",
"0.55834186",
"0.55659825",
"0.5478359",
"0.5353343",
"0.53419346",
"0.5309664",
"0.5268469",
"0.5261772",
"0.5242762",
"0.5225194",
"0.5212933",
"0.5127292",
"0.511361... | 0.7063843 | 1 |
Get an existing TrafficMirrorFilterRule resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
arn: Optional[pulumi.Input[str]] = None,
description: Optional[pulumi.Input[str]] = None,
destination_cidr_block: Optional[pulumi.Input[str]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None) -> 'FirewallRule':\n opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))\n\n __props__ = dict()\n\n __props__[\"end_ip\"] = None\n __props__[\... | [
"0.62865347",
"0.6111883",
"0.5923047",
"0.57136595",
"0.5619176",
"0.55978364",
"0.5507319",
"0.52930605",
"0.5158742",
"0.5122193",
"0.50192016",
"0.5011702",
"0.5005343",
"0.4872678",
"0.48647898",
"0.48254102",
"0.48140857",
"0.4809549",
"0.47788647",
"0.47717223",
"0.474... | 0.7291407 | 0 |
ARN of the traffic mirror filter rule. | def arn(self) -> pulumi.Output[str]:
return pulumi.get(self, "arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_rule_arn(self) -> str:\n return pulumi.get(self, \"config_rule_arn\")",
"def config_rule_arn(self) -> str:\n return pulumi.get(self, \"config_rule_arn\")",
"def rule(self) -> str:\n if self._rule:\n return self._rule\n return self._make_rule(member_param=self._... | [
"0.61595756",
"0.61595756",
"0.5683729",
"0.5549101",
"0.5420084",
"0.5353957",
"0.5353957",
"0.53007644",
"0.53007644",
"0.52232647",
"0.52182466",
"0.5193646",
"0.5175938",
"0.51703745",
"0.51703745",
"0.51703745",
"0.51703745",
"0.51703745",
"0.5164615",
"0.51548624",
"0.5... | 0.54840195 | 20 |
Direction of traffic to be captured. Valid values are `ingress` and `egress` | def traffic_direction(self) -> pulumi.Output[str]:
return pulumi.get(self, "traffic_direction") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traffic_direction(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"traffic_direction\")",
"def traffic_direction(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"traffic_direction\")",
"def get_direction(event):\n return event['result']['parameters']['direction']",
... | [
"0.7289455",
"0.7063843",
"0.5919301",
"0.57909507",
"0.5788569",
"0.57549065",
"0.5705871",
"0.56085664",
"0.55834186",
"0.55659825",
"0.5478359",
"0.5353343",
"0.53419346",
"0.5309664",
"0.5268469",
"0.5261772",
"0.5242762",
"0.5225194",
"0.5212933",
"0.5127292",
"0.5113614... | 0.70357573 | 2 |
Simple methods for bracketed and the persistent brackets. | def simple(
cls, parse_context: ParseContext, crumbs: Optional[Tuple[str, ...]] = None
) -> Optional["SimpleHintType"]:
start_brackets = [
start_bracket
for _, start_bracket, _, persistent in parse_context.dialect.bracket_sets(
"bracket_pairs"
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_brackets(self):\n return self.__brackets",
"def save_bracketed(sv, lig):\r\n here,block,last=findblock(lig) # find external bracketed block\r\n while here>-1: # brackets found\r\n before=... | [
"0.67755497",
"0.6531037",
"0.6472095",
"0.62770903",
"0.62345237",
"0.6205304",
"0.6134222",
"0.6119047",
"0.61070895",
"0.5836069",
"0.58267",
"0.5812828",
"0.559637",
"0.5594679",
"0.5573223",
"0.55384165",
"0.5538288",
"0.55376315",
"0.5522027",
"0.54893625",
"0.5461417",... | 0.0 | -1 |
Test some basic default properties for drudge objects. | def test_drudge_has_default_properties(free_alg):
assert isinstance(free_alg.num_partitions, int)
assert free_alg.full_simplify
assert not free_alg.simple_merge | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_default_init(self):\n self.assertEqual(self.obj.width, 1)\n self.assertEqual(self.obj.height, 1)\n self.assertEqual(self.obj.x, 0)\n self.assertEqual(self.obj.y, 0)\n self.assertEqual(self.obj.id, 1)",
"def testDefault(self):\n for val in (1, {}, 'test', None):\n ... | [
"0.70528543",
"0.6994596",
"0.6965438",
"0.6872958",
"0.6862939",
"0.67033905",
"0.6637353",
"0.66311663",
"0.6527435",
"0.6505683",
"0.6503775",
"0.65000117",
"0.64971566",
"0.64593023",
"0.64239097",
"0.6376396",
"0.6239752",
"0.6204432",
"0.62043875",
"0.62032735",
"0.6199... | 0.688334 | 3 |
Reset mapping attributes for a fresh determination of the sampling, size, and surfacebrightness map. This is mainly used for resetting the internals when using the default sampling and size to set the map. To reconstruct | def reset_map(self):
self.x = None
self.X = None
self.y = None
self.Y = None
self.data = None
self.sampling = None
self.size = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_map(self):\n self.reset_world(self._filename)",
"def reset(self):\n self._maps = {}",
"def _reset_map(self):\n if not self.scenario_name.startswith('random'):\n self._map = self._fixed_original_map.copy()\n else:\n from environment.scenarios import ge... | [
"0.7128049",
"0.70923704",
"0.7058207",
"0.7057773",
"0.69286776",
"0.69136596",
"0.663862",
"0.66085464",
"0.6593443",
"0.6592892",
"0.6592892",
"0.6543239",
"0.6528465",
"0.6462669",
"0.64508015",
"0.64286196",
"0.6405136",
"0.63953155",
"0.6325627",
"0.63087475",
"0.627572... | 0.7794614 | 0 |
r""" The minimum size that should be used for the distribution map in arcseconds. Currently just set to 3. | def minimum_size(self):
# TODO: Allow `Source` to understand when this returns None?
return 3. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimum_size(self):\n return self.fwhm*2.",
"def minimum_size(self):\n return self.r_eff*3",
"def minimum_size(self):\n # Size in arcsec\n size = self.seeing.minimum_size()\n try:\n # Try using `intrinsic` as an object\n size = max(self.intrinsic.min... | [
"0.74468726",
"0.72707444",
"0.7155052",
"0.7057373",
"0.70292497",
"0.6817667",
"0.66245854",
"0.65981185",
"0.645702",
"0.645309",
"0.63096863",
"0.62724876",
"0.6262653",
"0.62395364",
"0.62224287",
"0.62000304",
"0.6197255",
"0.619464",
"0.61761963",
"0.61708325",
"0.6160... | 0.6856484 | 5 |
Sample the source. This interpolates the precalculated source at the requested coordinate. A `ValueError` will be thrown (see `scipy.interpolate.interp2d`_) if the coordinate is outside the bounds of the calculated map. | def __call__(self, x, y):
return self.interp(x,y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self):\n rtol = None\n dist = None\n n_new_pts = 1\n data = [] if self.data == None else self.data\n if len(data) == 0:\n return uniform(self.lower_bounds, self.upper_bounds)\n pts = math.fillpts(self.lower_bounds, self.upper_bounds, n_new_pts, data, ... | [
"0.6073271",
"0.57992303",
"0.5755491",
"0.5660392",
"0.5643768",
"0.55160844",
"0.54961294",
"0.5404775",
"0.53589106",
"0.5357067",
"0.5293388",
"0.52847767",
"0.5273042",
"0.5271924",
"0.5231634",
"0.5231629",
"0.5223583",
"0.52125466",
"0.5206058",
"0.5187688",
"0.5153643... | 0.5248061 | 14 |
Perform modular inverse on `num` in `modulus` | def mod_inverse(num: int, modulus: int) -> int:
if gcd(num, modulus) != 1:
raise ModularInverseError('gcd is equals to 1')
u_1, u_2, u_3 = 1, 0, num
v_1, v_2, v_3 = 0, 1, modulus
while v_3 != 0:
quot = u_3 // v_3
v_1, v_2, v_3, u_1, u_2, u_3 = (
u_1 - quot * v_1), (u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_mod(num):\n return num % MODULO",
"def invmod(b,n):\r\n\treturn inverse_mod(b,n)",
"def invmod(b,n):\n\treturn inverse_mod(b,n)",
"def mod_inv(val, modulus):\n return mod_exp(val, modulus - 2, modulus)",
"def modular_inverse(a, mod):\n r_prev, u_prev, v_prev, r, u, v = a, 1, 0, mod, 0, 1... | [
"0.76087075",
"0.7599907",
"0.75446355",
"0.7271277",
"0.72095096",
"0.7132916",
"0.7094081",
"0.70898604",
"0.7052463",
"0.70342475",
"0.7025433",
"0.70142114",
"0.70125234",
"0.697252",
"0.69658965",
"0.6876136",
"0.68518245",
"0.6832232",
"0.67837626",
"0.67513156",
"0.673... | 0.8381865 | 0 |
Check if an integer is prime | def is_prime(num: int) -> bool:
if num < 2:
return False
low_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
167, 173, 179, 181, 191, 193, 197, 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def is_prime(number: int):\n\n for index in range(2, (number//2) + 1):\n if number%index == 0:\n return False\n return True",
"def isprime(n):\n\treturn is_prime(n)",
"def is_prime(a):\n return all(a % i for i in xrange(2, a))",
"def is_... | [
"0.806168",
"0.8038379",
"0.80105424",
"0.80036575",
"0.8000637",
"0.7987979",
"0.7946168",
"0.79253095",
"0.7899765",
"0.7860847",
"0.7825755",
"0.77972865",
"0.77813077",
"0.7775873",
"0.77755696",
"0.77608085",
"0.77501464",
"0.7734034",
"0.77327824",
"0.77155507",
"0.7712... | 0.0 | -1 |
Writes the Config to a JSON file. | def to_file(self, fp):
dict_ = self.serialize()
with open_file(fp, mode='w') as writer:
json.dump(dict_, writer, indent=2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __write_config(self):\n with open(self.config_file, 'w') as data_file:\n config = {\"ibooks_doc_root\":self.ibooks_doc_root,\n \"library_folder\":self.library_folder,\n \"annotation_folder\":self.annotation_folder,\n \"tmp_dir\":self.tmp_dir\n } \n ... | [
"0.8363596",
"0.8205384",
"0.81158084",
"0.8101028",
"0.8083625",
"0.805155",
"0.8005258",
"0.79565126",
"0.7939603",
"0.79173857",
"0.78823084",
"0.78212786",
"0.7801197",
"0.779321",
"0.77766246",
"0.7724846",
"0.7670679",
"0.76086545",
"0.75980157",
"0.7597858",
"0.7547061... | 0.0 | -1 |
Removes comments beginning with '//' from the stream | def _parse_comments(reader):
regex = r'\s*(#|\/{2}).*$'
regex_inline = r'(:?(?:\s)*([A-Za-z\d\.{}]*)|((?<=\").*\"),?)(?:\s)*(((#|(\/{2})).*)|)$'
pipe = []
for line in reader:
if re.search(regex, line):
if re.search(r'^' + regex, line, re.IGNORECASE): continue... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_comments(self):\n new_lines = list()\n for line in self.lines:\n if ((not line.startswith(\"//\")) & (not line.isspace()) &\n (not line.startswith(\"/*\") & (not line.startswith(\"*/\")))):\n line = Parser.strip_line(line)\n new_li... | [
"0.7831763",
"0.73236525",
"0.73236525",
"0.72509706",
"0.7236525",
"0.7156754",
"0.71515924",
"0.7134593",
"0.712082",
"0.7103003",
"0.7087264",
"0.7070003",
"0.70223415",
"0.69894934",
"0.6886132",
"0.68485993",
"0.6808314",
"0.67827356",
"0.677989",
"0.66633433",
"0.662779... | 0.66310537 | 20 |
Initialize the linked list | def __init__(self):
self.front = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, lst=[]):\n self.__length = 0 # current length of the linked list\n self.__head = None # pointer to the first node in the list\n for e in lst: # initialize the list,\n self.add(e) # by adding elements one by one",
"def __init__(self):\n node = ListNode... | [
"0.7995513",
"0.7772318",
"0.7671952",
"0.7662982",
"0.76149744",
"0.75935143",
"0.7513604",
"0.751141",
"0.747434",
"0.7470124",
"0.7470124",
"0.74638146",
"0.74430084",
"0.7408837",
"0.7407841",
"0.7407383",
"0.7399193",
"0.73963195",
"0.73963195",
"0.73963195",
"0.7368044"... | 0.0 | -1 |
Append new item to front of linked list | def append_front(self, item):
self.front = Node(item, self.front) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self, item):\n self.linked_list.prepend(item)",
"def push_front(self, item):\n new_node = Node(item)\n # if the list is empty, make it head\n if self.head is None:\n self.head = new_node\n # else, \n else:\n new_node.next = self.head # new... | [
"0.80932236",
"0.79207546",
"0.7789035",
"0.77499205",
"0.743895",
"0.7411518",
"0.73832494",
"0.73774433",
"0.73671645",
"0.73671645",
"0.73597884",
"0.7335836",
"0.7333048",
"0.7306905",
"0.71927047",
"0.7173657",
"0.7128065",
"0.71021867",
"0.70872563",
"0.7061593",
"0.704... | 0.8145095 | 0 |
Return string representation of the sublist headed by node. | def str_recursive(node):
if node == None:
return ""
else:
return str(node.item) + " " + LinkedList.str_recursive(node.next) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n result = [] \n node = self.head\n while node is not None:\n result.append(str(node.value))\n node = node.next_node \n return '[' + ', '.join(result) + ']'",
"def __str__(self):\n result = [] \n node = self.head\n while no... | [
"0.7378448",
"0.7378448",
"0.7137586",
"0.70630693",
"0.70598847",
"0.6984991",
"0.6953471",
"0.69394827",
"0.69161016",
"0.6898963",
"0.6889489",
"0.68292844",
"0.6805494",
"0.67952406",
"0.6789903",
"0.6772713",
"0.6772238",
"0.67646974",
"0.67565846",
"0.6745143",
"0.67451... | 0.66982806 | 22 |
Return string representation of the reverse of the sublist headed by node. | def str_reverse_recur(node):
if node == None:
return ""
else:
return LinkedList.str_reverse_recur(node.next) + " " + str(node.item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_rev_string(self):\n\n out = []\n n = self\n\n while n:\n out.append(str(n.data))\n n = n.next\n\n return \"\".join(reversed(out))",
"def str_reverse(self):\n\n return LinkedList.str_reverse_recur(self.front)",
"def __str__(self):\n outstr =... | [
"0.7377775",
"0.7221987",
"0.6838717",
"0.6672246",
"0.6447731",
"0.640659",
"0.6405362",
"0.6306194",
"0.6304246",
"0.6295194",
"0.62737924",
"0.6251645",
"0.62411624",
"0.62411624",
"0.6238511",
"0.6226606",
"0.62258536",
"0.61988467",
"0.6184583",
"0.6136902",
"0.6131418",... | 0.7475673 | 0 |
Just return time as string | def curr_time():
try:
curr_time = datetime.datetime.now().strftime("%H:%M:%S")
except Exception as e:
print(e)
curr_time = False
return curr_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time() -> str:\n return strftime(\"%H:%M:%S\")",
"def get_time() -> str:\r\n return time.strftime(TIMEFORMAT)",
"def timestr():\n return dt.strftime(dt.now(),'%H:%M:%S')",
"def time():\n return datetime.datetime.now().strftime(\"%Y%m%dT%H%M%SZ\")",
"def _time_str(self):\n try:\n ... | [
"0.8599196",
"0.83361834",
"0.83054096",
"0.82475215",
"0.8140354",
"0.81370556",
"0.8126075",
"0.80969197",
"0.8043803",
"0.79808813",
"0.79625934",
"0.79590195",
"0.7903295",
"0.78672487",
"0.7794261",
"0.7743577",
"0.77294785",
"0.7726325",
"0.76728094",
"0.7656912",
"0.76... | 0.0 | -1 |
Check if the list a is not descending (means "rather ascending") | def is_not_in_descending_order(a):
for i in range(len(a)-1):
if a[i] > a[i+1]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_not_in_descending_order(a):\n for i in range(len(a) - 1):\n if a[i] > a[i + 1]:\n return False\n return True",
"def is_ascending2(lst):\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n return True",
"def is_ascending(self):\r\n ... | [
"0.82371575",
"0.7330693",
"0.71535647",
"0.70641845",
"0.6986995",
"0.69312114",
"0.69185233",
"0.6741396",
"0.67373383",
"0.67297494",
"0.6705234",
"0.6625769",
"0.6528101",
"0.6414327",
"0.64021415",
"0.6348714",
"0.6320354",
"0.6309863",
"0.6308104",
"0.63046575",
"0.6292... | 0.82387155 | 0 |
Delete router from L3 agent test. RBAC test for the neutron delete_l3router policy | def test_delete_router_from_l3_agent(self):
self.agents_client.create_router_on_l3_agent(
self.agent['id'], router_id=self.router['id'])
self.addCleanup(
test_utils.call_and_ignore_notfound_exc,
self.agents_client.delete_router_from_l3_agent,
self.agent['i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_router_on_l3_agent(self):\n with self.override_role():\n self.agents_client.create_router_on_l3_agent(\n self.agent['id'], router_id=self.router['id'])\n self.addCleanup(\n test_utils.call_and_ignore_notfound_exc,\n self.agents_client.de... | [
"0.72581106",
"0.70280457",
"0.68491924",
"0.65924877",
"0.6537437",
"0.6436373",
"0.6317385",
"0.6292039",
"0.6250973",
"0.62198013",
"0.6170497",
"0.6156344",
"0.6153482",
"0.6135706",
"0.6124041",
"0.60891193",
"0.6088728",
"0.60834914",
"0.60735404",
"0.60667443",
"0.6052... | 0.85685253 | 0 |
r"""A LaTeX representation of the Butcher arrays. | def latex(self):
from nodepy.snp import printable
sep = ' & '
s= r'\begin{align}' + '\n'
s+=r'\begin{array}{c|'
s+='c'*len(self)
s+='}\n'
for i in range(len(self)):
s+=printable(self.c[i]) + sep
s += sep.join([printable(aij) for aij in self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _repr_latex_(self):\n if len(self.shape) > 2:\n raise ValueError(\"bmatrix can at most display two dimensions\")\n\n def fmt(x):\n if x == 0:\n return \".\"\n if np.abs(x) < EPS:\n return \"0.\"\n return \"{:.2g}\".format(x... | [
"0.6970055",
"0.659756",
"0.6227812",
"0.6129505",
"0.6089469",
"0.6051443",
"0.60052615",
"0.5925831",
"0.58959085",
"0.5885589",
"0.5846627",
"0.5812129",
"0.58071876",
"0.5775256",
"0.5760656",
"0.57533437",
"0.5733561",
"0.56919664",
"0.56869227",
"0.56674165",
"0.5662075... | 0.7219669 | 0 |
r""" Length of negative real axis interval contained in the method's region of absolute stability. | def real_stability_interval(self,mode='exact',eps=1.e-14):
import nodepy.stability_function as stability_function
p,q=self.stability_function(mode=mode)
return stability_function.real_stability_interval(p,q,eps=eps) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intervalLen(self):\n return self.end-self.start+1",
"def get_length(self):\n return math.sqrt(self.x**2 + self.y**2)",
"def length(self):\n return pyvista.Box(self.bounds).length",
"def length(self):\n return math.sqrt(self.x * self.x + self.y * self.y)",
"def length(self):\... | [
"0.6799165",
"0.6523013",
"0.64874613",
"0.63847244",
"0.6355488",
"0.6334569",
"0.62088364",
"0.62068504",
"0.61969066",
"0.6155599",
"0.61479384",
"0.61242396",
"0.60917693",
"0.60682476",
"0.6067572",
"0.6061064",
"0.6031231",
"0.60228676",
"0.5993633",
"0.5990231",
"0.598... | 0.0 | -1 |
Set up test environment befor each test | def setUp(self):
self.db_fd, closet.app.config['DATABASE'] = tempfile.mkstemp()
closet.app.config['TESTING'] = True
self.app = closet.app.test_client()
closet.init_db() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n test_env_setup()",
"def setUpModule():\n # pull in test environment as dict\n global TestEnv\n get_test_env(TestEnv)",
"def setUpModule():\n # pull in test environment as dict\n global TestEnv\n get_test_env(TestEnv)",
"def setUp(self):\n MainTests.setUp(sel... | [
"0.8583651",
"0.77842045",
"0.77842045",
"0.75123954",
"0.75069934",
"0.744537",
"0.744537",
"0.74238944",
"0.7396395",
"0.73189193",
"0.7287442",
"0.72579896",
"0.72319895",
"0.72173023",
"0.7185263",
"0.7180003",
"0.71740633",
"0.71740633",
"0.71636385",
"0.71625495",
"0.71... | 0.0 | -1 |
Test that the delete confirmation form is accessible | def get_delete_confirmation_form(self, data):
self.add_success(data)
rv = self.get((data[self.id_field], self.delete_url))
assert not is_404(rv)
assert in_response(rv, 'Delete {}'.format(data[self.name_field]))
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete__DeleteForm__4(address_book, browser, role):\n browser.login(role)\n browser.assert_forbidden(browser.SEARCH_DELETE_URL)",
"def test_commentary_view_delete(self):\n \n test_response = self.client.get('/papers/commentary/1/delete')\n self.assertEqual(test_response.status... | [
"0.7769889",
"0.73509276",
"0.7316214",
"0.72853273",
"0.72812194",
"0.72715646",
"0.72543633",
"0.71914595",
"0.71501523",
"0.71227896",
"0.7038216",
"0.7027079",
"0.69793093",
"0.6942176",
"0.6920717",
"0.6884522",
"0.6859341",
"0.6828267",
"0.6825896",
"0.6825896",
"0.6801... | 0.7111074 | 10 |
Test that updating a model with the given data succeeds | def edit_success(self, id_, data):
rv = self.post((id_, self.edit_url), data)
assert not in_response(rv, 'Edit {}'.format(data[self.name_field]))
assert self.verify_object(data)
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_record(self):\n pass",
"def test_update_case(self):\n pass",
"def test_update_one(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_update_scenario(self):\n pass",... | [
"0.80372113",
"0.78073686",
"0.77986133",
"0.7746405",
"0.7746405",
"0.7746405",
"0.75263447",
"0.74914926",
"0.74794495",
"0.74782026",
"0.74640465",
"0.7410784",
"0.73828554",
"0.73249656",
"0.72834855",
"0.7223242",
"0.7222361",
"0.7172504",
"0.7141367",
"0.71275294",
"0.7... | 0.0 | -1 |
Test that updating a model with the given data succeeds | def update_success(self, data, new_data):
self.add_success(data)
return self.edit_success(data[self.id_field], new_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_record(self):\n pass",
"def test_update_case(self):\n pass",
"def test_update_one(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_update_scenario(self):\n pass",... | [
"0.80372113",
"0.78073686",
"0.77986133",
"0.7746405",
"0.7746405",
"0.7746405",
"0.75263447",
"0.74914926",
"0.74794495",
"0.74782026",
"0.74640465",
"0.7410784",
"0.73828554",
"0.73249656",
"0.72834855",
"0.7223242",
"0.7222361",
"0.7172504",
"0.7141367",
"0.71275294",
"0.7... | 0.0 | -1 |
Test that deleting the specified model succeeds | def delete_success(self, id_):
rv = self.post((id_, self.delete_url), dict(post='yes'))
assert not self.verify_object({self.id_field: id_})
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_deleting_works_properly(self):\r\n tm = TestModel.create(count=8, text='123456789')\r\n tm.delete()\r\n tm2 = TestModel.objects(id=tm.pk).first()\r\n self.assertIsNone(tm2)",
"def test_model_deleting_works_properly(self):\r\n tm = TestModel.create(count=8, text='... | [
"0.80975384",
"0.7919906",
"0.78289723",
"0.78166664",
"0.77419555",
"0.7649547",
"0.7505965",
"0.7486913",
"0.74762404",
"0.7381134",
"0.7380975",
"0.73404914",
"0.73338157",
"0.7329557",
"0.73083365",
"0.7297999",
"0.72765434",
"0.7254224",
"0.7244474",
"0.7240323",
"0.7239... | 0.0 | -1 |
Test that deleting the specified model fails | def delete_fail(self, id_, message):
rv = self.post((id_, self.delete_url), dict(post='yes'))
assert in_response(rv, message)
assert self.verify_object({self.id_field: id_})
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_deleting_works_properly(self):\r\n tm = TestModel.create(count=8, text='123456789')\r\n vid = tm.vid\r\n tm.delete()\r\n with self.assertRaises(TestModel.DoesNotExist):\r\n tm2 = TestModel.get(vid)",
"def test_model_deleting_works_properly(self):\r\n t... | [
"0.81226546",
"0.8114499",
"0.77762663",
"0.7746574",
"0.7677617",
"0.7623347",
"0.7561469",
"0.7559645",
"0.75229925",
"0.7488412",
"0.74052787",
"0.73805296",
"0.7347212",
"0.7329506",
"0.7327587",
"0.73252684",
"0.7309433",
"0.7275486",
"0.72648066",
"0.725491",
"0.7195645... | 0.0 | -1 |
Test that deleting a model that does not exist fails | def delete_does_not_exist_fail(self, id_):
assert is_404(self.get((id_, self.delete_url)))
self.delete_fail(id_, 'does not exist') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_deleting_works_properly(self):\r\n tm = TestModel.create(count=8, text='123456789')\r\n tm.delete()\r\n tm2 = TestModel.objects(id=tm.pk).first()\r\n self.assertIsNone(tm2)",
"def test_model_deleting_works_properly(self):\r\n tm = TestModel.create(count=8, text='... | [
"0.82551336",
"0.8216983",
"0.78420514",
"0.7746473",
"0.7627469",
"0.7567078",
"0.75271106",
"0.752426",
"0.74983686",
"0.7490778",
"0.7482861",
"0.73926353",
"0.7384732",
"0.73488843",
"0.7322199",
"0.72983235",
"0.7279115",
"0.726235",
"0.72099906",
"0.71872205",
"0.717358... | 0.0 | -1 |
Test that adding a category works | def test_add_category(self):
self.add_success(self.test_data['pants']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_add_category(self):\n self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')\n self.login('Bo_theo5@example.com', 'Bo1995')\n self.dashboard()\n rv = self.category('Breakfast')\n self.assertIn(b'Category c... | [
"0.8789025",
"0.8468232",
"0.81340444",
"0.8119902",
"0.8014354",
"0.8012194",
"0.7937554",
"0.77232605",
"0.7710287",
"0.76993555",
"0.76301783",
"0.7617197",
"0.76074386",
"0.7597755",
"0.75833964",
"0.75707746",
"0.7563386",
"0.7555715",
"0.7542039",
"0.7536718",
"0.748444... | 0.85830075 | 1 |
Test that updating a category works | def test_update_category(self):
self.update_success(self.test_data['pants'], self.test_data['shirts']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_update_category(self):\n category = sample_category()\n url = category_details_url(category.id)\n self.client.put(url, {\"name\": \"school\"})\n category.refresh_from_db()\n self.assertEqual(category.name, 'school')",
... | [
"0.9372154",
"0.8647779",
"0.8541626",
"0.8503705",
"0.8448047",
"0.82895505",
"0.8234864",
"0.8052643",
"0.7904017",
"0.7873732",
"0.7723735",
"0.7681456",
"0.76312315",
"0.7364562",
"0.71864253",
"0.7186193",
"0.7155049",
"0.712442",
"0.7080831",
"0.70298755",
"0.6947935",
... | 0.85807896 | 2 |
Test that adding a child category works | def test_add_child_category(self):
self.add_success(self.test_data['pants'])
rv = self.get('pants')
assert in_response(rv, 'This category is empty.')
self.add_success(self.test_data['jeans'])
rv = self.get('pants')
assert not in_response(rv, 'This category is empty.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_append_children_category(self):\n category = Category(catname='olympic games')\n category1 = Category(catname='Tennis')\n category.parents.append(category1)\n category.save()\n assert category.parents",
"def test_create_category(self):\n pass",
"def test_add_c... | [
"0.8334123",
"0.81077206",
"0.79081964",
"0.76863307",
"0.74448884",
"0.7418768",
"0.73700744",
"0.7333911",
"0.7316224",
"0.71865493",
"0.7157221",
"0.7122682",
"0.70886236",
"0.70684",
"0.6976651",
"0.6931385",
"0.69218314",
"0.6908338",
"0.6879238",
"0.68777645",
"0.683699... | 0.82659537 | 1 |
Test that adding/updating a category without a name fails | def test_name_required(self):
self.required_field_fail('name', self.test_data['pants']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_create_category_with_existing_name(self):\n sample_category()\n res = self.client.post(CATEGORY_URL, {\"name\": \"place\"})\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertEqual(\n res.d... | [
"0.82644504",
"0.8023558",
"0.7823317",
"0.7775177",
"0.7757664",
"0.77515596",
"0.77396804",
"0.7706122",
"0.766532",
"0.7524683",
"0.7456434",
"0.74400824",
"0.7414196",
"0.7398801",
"0.7372786",
"0.73369527",
"0.72841924",
"0.72630847",
"0.72521305",
"0.7243133",
"0.720910... | 0.0 | -1 |
Test that adding/updating a category with a nonexistent parent fails | def test_parent_does_not_exist(self):
self.bad_data_fail(self.test_data['pants'],
self.test_data['hats'], 'Parent does not exist') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_category_parent(self):\n pass",
"def test_append_children_category(self):\n category = Category(catname='olympic games')\n category1 = Category(catname='Tennis')\n category.parents.append(category1)\n category.save()\n assert category.parents",
"def test_d... | [
"0.7866154",
"0.735557",
"0.717028",
"0.70292646",
"0.69012946",
"0.6873153",
"0.68437797",
"0.6685949",
"0.6664411",
"0.66210353",
"0.65937537",
"0.65748817",
"0.65647817",
"0.65492696",
"0.653379",
"0.6526681",
"0.6460581",
"0.644151",
"0.6436295",
"0.63933766",
"0.6364703"... | 0.68960756 | 5 |
Test that adding a category with an incorrect name fails | def test_add_category_slug_special(self):
self.add_success(self.test_data['polo-shirts'])
assert self.verify_object(dict(name='Polo Shirts', slug='polo-shirts'))
self.add_fail(self.test_data['symbols'], '')
self.add_success('Add') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category_with_existing_name(self):\n sample_category()\n res = self.client.post(CATEGORY_URL, {\"name\": \"place\"})\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertEqual(\n res.data['errors']['name'][0],\n 'This field ... | [
"0.822602",
"0.7997785",
"0.7732795",
"0.7683495",
"0.76777273",
"0.7553439",
"0.73911196",
"0.7387882",
"0.7312538",
"0.7247392",
"0.7225039",
"0.72244525",
"0.7215455",
"0.71904534",
"0.71463794",
"0.7121509",
"0.71163905",
"0.7088657",
"0.7078364",
"0.70444405",
"0.7040825... | 0.67622954 | 33 |
Test that updating a category with an incorrect slug fails | def test_update_category_slug_special(self):
rv = self.app.post(self.get_category_url('add'), data=dict(
name='Pants', slug='pants'
), follow_redirects=True)
rv = self.app.post(self.get_category_url('pants', 'edit'), data=dict(
name='Polo Shirts', slug='polo shirts'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_change_slug_fails(self):\n response = self.client.patch(self.url + \"%d/\" % self.test_nutch_crawl.id,\n {'slug':'Bad Slug'}, format=\"json\")\n assert json.loads(response.content)[\"slug\"] == \"test-nutch-rest\"",
"def test_up... | [
"0.7695336",
"0.7655478",
"0.7204905",
"0.708079",
"0.70749307",
"0.7011297",
"0.69769",
"0.6953526",
"0.6927091",
"0.6923927",
"0.6873092",
"0.68357676",
"0.6801231",
"0.67697006",
"0.67422795",
"0.67262864",
"0.6654824",
"0.6620801",
"0.6579277",
"0.6575962",
"0.6561918",
... | 0.8162767 | 0 |
Get the 2nd byte as an example of something tricky and arbitrary | def pick_byte2(input):
val = int(input) >> 8
val = val & 255
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getByte(self, int: int, int2: int) -> int:\n ...",
"def next_byte(self):\r\n return self.next_bytes(1)",
"def getnextbyte(data, index):\n v = data[index]\n index += 1\n if v == 0x10:\n v = data[index]\n index += 1\n\n return v,index",
"def get_byte(model, byte):\n ... | [
"0.65566176",
"0.6398942",
"0.6311261",
"0.63094866",
"0.6190973",
"0.6147707",
"0.6116967",
"0.61056626",
"0.60690683",
"0.6042625",
"0.6022275",
"0.60192883",
"0.5963968",
"0.58648586",
"0.58168954",
"0.5805441",
"0.58045745",
"0.57504094",
"0.5721444",
"0.57174695",
"0.570... | 0.6524682 | 1 |
The learning rate scheduler | def learning_rate(epoch):
self.lr = self.lr / 1.00000001
return self.lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_learning_rate(self):\r\n self.scheduler.step(self.clock.epoch)",
"def update_learning_rate(self):\n for scheduler in self.schedulers:\n if self.opt.lr_policy == 'plateau':\n scheduler.step(self.metric)\n else:\n scheduler.step()\n\n ... | [
"0.7866744",
"0.77488226",
"0.7729407",
"0.76878625",
"0.7683168",
"0.7547539",
"0.748419",
"0.7457646",
"0.74426603",
"0.741609",
"0.72797287",
"0.72555083",
"0.7215296",
"0.71658236",
"0.71366054",
"0.710965",
"0.7103072",
"0.70940465",
"0.7075688",
"0.7066328",
"0.7052628"... | 0.6971915 | 30 |
Input n>=6, Returns a array of primes, 2 <= p < n | def primesfrom2to(n):
sieve = np.ones(n//3 + (n%6==2), dtype=np.bool)
sieve[0] = False
for i in range(int(n**0.5)//3+1):
if sieve[i]:
k=3*i+1|1
sieve[ ((k*k)//3) ::2*k] = False
sieve[(k*k+4*k-2*k*(i&1))//3::2*k] = False
return np.r_[2,3,((3*np.nonzer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probable_prime(n: int) -> [int]:\n return [6*n-1, 6*n+1]",
"def get_primes(n):\n\n return list(primes_sieve(n))",
"def prime_array(number_of_primes) -> array:\n p = array('i',list(primes(number_of_primes)))\n return p",
"def make_primes(n):\n out_list = []\n for i in range(2, n):\n ... | [
"0.78810406",
"0.78444964",
"0.77933097",
"0.7650548",
"0.7626844",
"0.75202084",
"0.75010294",
"0.7486007",
"0.74678427",
"0.74572444",
"0.7429019",
"0.74092805",
"0.73962444",
"0.73798555",
"0.7366298",
"0.7364451",
"0.7356198",
"0.7351732",
"0.73305947",
"0.7302029",
"0.72... | 0.7254512 | 23 |
Sanity Check for expected input for a particular Feature Extractor, defined by its dependency_feature_name, compared to the path of the raw_path property. If dependency_feature_name isn't set, it checks that the input path and filenames are audifiles. Also compares the stored filenames in self.x for the dependency_feat... | def trigger_dependency_warnings_if_needed(self):
input_path_warning_flag = True \
if (self.dependency_feature_name and self.source_path != (
FEATURES_DATA_PATH / self.dependency_feature_name)) \
or \
(not self.dependency_feature_name and self.source_path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_input_files(self, truth_files, decl_files):\n\n # Ensure we have list group of declaration and truth file names.\n if not isinstance(decl_files, list):\n decl_files = [decl_files]\n\n if not isinstance(truth_files, list):\n truth_files = [truth_files]\n\n ... | [
"0.60253286",
"0.58523744",
"0.56887174",
"0.5569594",
"0.5537949",
"0.5524195",
"0.5506564",
"0.54941404",
"0.54397684",
"0.5438609",
"0.54316264",
"0.54297984",
"0.5405921",
"0.5371341",
"0.5370305",
"0.53649974",
"0.5342198",
"0.53331345",
"0.529704",
"0.5291214",
"0.52909... | 0.6936945 | 0 |
Given two sparse vectors |v1| and |v2|, each represented as collection.defaultdict(float), return their dot product. You might find it useful to use sum() and a list comprehension. This function will be useful later for linear classifiers. | def sparseVectorDotProduct(v1, v2):
# BEGIN_YOUR_CODE (our solution is 4 lines of code, but don't worry if you deviate from this)
return sum(v1[k]*v2[k] for k in v1 and v2)
# END_YOUR_CODE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparseVectorDotProduct(v1, v2):\n # BEGIN_YOUR_ANSWER (our solution is 3 lines of code, but don't worry if you deviate from this)\n return sum([v1[v1_key] * v2.get(v1_key, 0) for v1_key in v1])\n # END_YOUR_ANSWER",
"def sparseVectorDotProduct(v1, v2):\n ans = 0\n for index, val in v1.items():... | [
"0.86423",
"0.8544593",
"0.8232703",
"0.8090822",
"0.7962373",
"0.78506553",
"0.7824849",
"0.77497625",
"0.7713789",
"0.7532589",
"0.74982405",
"0.7496282",
"0.7495349",
"0.7494858",
"0.7485002",
"0.74429095",
"0.73841673",
"0.73344696",
"0.73116934",
"0.72536117",
"0.7240412... | 0.84310704 | 2 |
Given two sparse vectors |v1| and |v2|, perform v1 += scale v2. This function will be useful later for linear classifiers. | def incrementSparseVector(v1, scale, v2):
# BEGIN_YOUR_CODE (our solution is 2 lines of code, but don't worry if you deviate from this)
for k in v2.keys():
v1[k] += scale*v2[k]
return v1
# END_YOUR_CODE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incrementSparseVector(v1, scale, v2):\n for index in v2:\n v1[index] += v2[index] * scale",
"def incrementSparseVector(v1, scale, v2):\n # BEGIN_YOUR_ANSWER (our solution is 2 lines of code, but don't worry if you deviate from this)\n for v2_key in v2:\n v1[v2_key] += scale * v2[v2_key... | [
"0.8317474",
"0.8016688",
"0.7265674",
"0.7116591",
"0.68092793",
"0.648811",
"0.636057",
"0.6249796",
"0.61545813",
"0.6144386",
"0.5934266",
"0.59291",
"0.59192884",
"0.58780324",
"0.5871222",
"0.57729644",
"0.57697046",
"0.5708447",
"0.56313133",
"0.5605271",
"0.56016946",... | 0.8039961 | 1 |
Initialize Pv model with input JSON data | def __init__(self, segments, display_res="1920x1080", stream_id=None):
self.segments = segments
self.display_res = display_res
self.stream_id = stream_id
self.o22 = []
self.mode = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data):\n self.data = data\n self.model_func = DecisionTree._deserialize_decision_tree_from_json(data[\"model\"])",
"def initialize(self, args):\n # You must parse model_config. JSON string is not parsed here\n self.model_config = json.loads(args['model_config'])\n ... | [
"0.6553741",
"0.64573437",
"0.6340093",
"0.6256089",
"0.614125",
"0.61199385",
"0.6113551",
"0.60440433",
"0.6033809",
"0.60328317",
"0.6029315",
"0.60049266",
"0.59983575",
"0.598196",
"0.59697783",
"0.5944968",
"0.59436524",
"0.5931014",
"0.59007895",
"0.5872175",
"0.584886... | 0.0 | -1 |
Preprocessing input image or ground truth depth. | def flip_pad_reshape_crop(self, img, flip, resize_size, crop_size, pad, pad_value=0):
if len(img.shape) == 1:
return img
# Flip
if flip:
img = np.flip(img, axis=1)
# Pad the raw image
if len(img.shape) == 3:
img_pad = np.pad(img, ((pad[0], pad... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_image(self, inputs):\n raise NotImplementedError('preprocess_image method not implemented.')",
"def preprocess_image(self, inputs):\n return utils.preprocess_image(inputs, mode='custom_tf')",
"def _build_tracking_preprocessing(input_shape):\n\n def preprocessing(input_img, **kwa... | [
"0.6998852",
"0.6732229",
"0.6644247",
"0.6618959",
"0.6618028",
"0.6553457",
"0.65250146",
"0.63845795",
"0.62805784",
"0.6262583",
"0.62548584",
"0.6249484",
"0.62440157",
"0.6225495",
"0.6223621",
"0.62102556",
"0.6196239",
"0.61716735",
"0.61636156",
"0.6110331",
"0.61093... | 0.0 | -1 |
Get a list of a user's playlists. | def getPlaylists():
allPlaylistData = []
spotifyPlaylistData = crud.getPlaylists(session)
if 'items' in spotifyPlaylistData:
allPlaylistData = spotifyPlaylistData['items']
savedPlaylistIDs = crud.getSavedPlaylistIDsByUser(int(session['user_id']))
regPlaylistData = [i for i in allPlay... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def playlists(self, user_id: str, limit: int = 20, offset: int = 0):\n return self._get(f'users/{user_id}/playlists',\n limit=limit, offset=offset)",
"def get_playlists_for_user(self, request): \n user = Account.find_by_id(request.userid)\n playlists = Playlist.find_b... | [
"0.8362418",
"0.8254638",
"0.8195101",
"0.7974434",
"0.79178256",
"0.7691519",
"0.7642135",
"0.7630549",
"0.75329334",
"0.7473043",
"0.74099374",
"0.73764855",
"0.73201317",
"0.71808696",
"0.70882946",
"0.70558065",
"0.70499766",
"0.69681185",
"0.6863668",
"0.6645491",
"0.654... | 0.7333007 | 12 |
Unicode representation of Order. | def __str__(self):
return self.shelf.item.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_item(self, order):\n return unicode(order)",
"def format_result(self, order):\n return u\"%s\" % (order)",
"def __unicode__(self):\n return str(self).decode('ascii')",
"def toString(self) -> unicode:\n ...",
"def toString(self) -> unicode:\n ...",
"def character_... | [
"0.727987",
"0.6794999",
"0.6483973",
"0.64472353",
"0.64472353",
"0.63554955",
"0.61911196",
"0.6116624",
"0.60456485",
"0.60156214",
"0.6001794",
"0.59931725",
"0.59753853",
"0.59588695",
"0.5953651",
"0.59113544",
"0.5907901",
"0.5885771",
"0.5878115",
"0.58645177",
"0.584... | 0.0 | -1 |
Test if an ATEvent object implements all relevant interfaces. | def test_implementsInterfaces(self):
self.assertTrue(IEvent.providedBy(self.obj))
self.assertTrue(IEventRecurrence.providedBy(self.obj))
self.assertTrue(IATEvent.providedBy(self.obj))
self.assertTrue(IATEventRecurrence.providedBy(self.obj))
self.assertTrue(IATEvent_ATCT.provided... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasUnoInterfaces( oObject, *cInterfaces ):\n for cInterface in cInterfaces:\n if not hasUnoInterface( oObject, cInterface ):\n return False\n return True",
"def hasUnoInterfaces( oObject, *cInterfaces ):\n for cInterface in cInterfaces:\n if not hasUnoInterface( oObject, cIn... | [
"0.6279814",
"0.6279814",
"0.6165603",
"0.6112963",
"0.59556156",
"0.5929444",
"0.5881702",
"0.58559626",
"0.5817494",
"0.5721367",
"0.5681247",
"0.5681247",
"0.56597096",
"0.5642392",
"0.5635892",
"0.5613095",
"0.5574558",
"0.55547416",
"0.55369914",
"0.5534713",
"0.55184144... | 0.71761626 | 0 |
Opens a new database connection if there is none yet for the current application context. | def get_db(_config):
if not hasattr(flask.g, 'client'):
flask.g.client, flask.g.db = connect_to_db(_config)
return flask.g.client, flask.g.db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db",
"def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)",
"def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec... | [
"0.7737639",
"0.7582971",
"0.73180443",
"0.71693045",
"0.70220166",
"0.6966687",
"0.6954785",
"0.69486743",
"0.6897534",
"0.6842663",
"0.68292314",
"0.68191963",
"0.680592",
"0.67950195",
"0.67697805",
"0.6762173",
"0.6751266",
"0.6746273",
"0.67316663",
"0.670031",
"0.668866... | 0.0 | -1 |
Check that the user is NOT logged in | def anonymous_required(function=None):
def _dec(view_func):
def _view(request, *args, **kwargs):
if request.user.is_authenticated():
return redirect(reverse('core:home'))
else:
return view_func(request, *args, **kwargs)
return _view
if fu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logged_in(self):\n return self.auth.get_user_by_session() is not None",
"def validUser(self):\n if self.state == SessionStates.LOGGED_OUT:\n return False\n\n # if self.user == None:\n # return False\n return True",
"def logged_in(self):\n return self.use... | [
"0.73652387",
"0.7342946",
"0.7264877",
"0.72366494",
"0.7186618",
"0.7144331",
"0.71151835",
"0.7073038",
"0.7073038",
"0.7073038",
"0.7073038",
"0.7049603",
"0.7023439",
"0.69996375",
"0.698806",
"0.6952942",
"0.6921483",
"0.68559563",
"0.684427",
"0.68374467",
"0.68333995"... | 0.0 | -1 |
Parses a point from the line of text | def parse(text):
parts = [int(part) for part in text.strip().split(',')]
point = Point(*parts)
actual = "{},{},{},{}".format(point.x, point.y, point.z, point.t)
assert actual == text, diff(actual, text)
return point | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_point(self, text_line):\n record_type = self.substr(text_line, sps21point['RECORD_ID'][0], sps21point['RECORD_ID'][1]).strip()\n if record_type not in (SRC_DATA_RECORD, RCV_DATA_RECORD):\n return\n self.set_definition(sps21point)\n return self.parse(text_line)",
"... | [
"0.75079757",
"0.7078823",
"0.66301596",
"0.6544174",
"0.6531106",
"0.6481116",
"0.6471549",
"0.6382969",
"0.6354874",
"0.6314013",
"0.624457",
"0.6211151",
"0.61723226",
"0.61217695",
"0.6107229",
"0.6107229",
"0.6074324",
"0.6056576",
"0.602781",
"0.59955186",
"0.59650505",... | 0.71761596 | 1 |
Computes p(w) = p(z=1) p_{copy}(w|z=0) + p(z=0) p_{softmax}(w|z=0) | def forward(self, hidden, attn, verbose=False):
# Original probabilities.
logits = self.linear(hidden)
logits[:, onmt.Constants.UNK] = -float('inf')
logits[:, onmt.Constants.PAD] = -float('inf')
prob = F.softmax(logits)
# Probability of copying p(z=1) batch
copy ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _call(self, z): \n self.a = F.softplus(self.a)\n self.w = F.softmax(self.w, dim=1)\n # Compute\n pre_sigm = self.a * z + self.b\n sigm = torch.sigmoid(pre_sigm)\n x_pre = self.w * sigm\n if (len(z.shape) > 2):\n x_pre = torch.sum(self.w * sigm, dim=1)... | [
"0.66816306",
"0.6341917",
"0.63075",
"0.6231154",
"0.6220307",
"0.62035924",
"0.6187527",
"0.61788213",
"0.61677027",
"0.6154292",
"0.6107564",
"0.6076157",
"0.6073725",
"0.60406226",
"0.60381573",
"0.60348624",
"0.60254025",
"0.60229063",
"0.6019567",
"0.5985108",
"0.598510... | 0.55286825 | 83 |
Returns an image with a random degree of brightness. | def random_brightness(image):
image = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
brightness = .25 + np.random.uniform()
image[:, :, 2] = image[:, :, 2] * brightness
image = cv2.cvtColor(image, cv2.COLOR_HSV2RGB)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_brightness(image):\n image1 = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)\n random_bright = 0.9 + 0.5 * ((2 * np.random.uniform()) - 1.0)\n image1[:, :, 2] = image1[:, :, 2] * random_bright\n image1 = cv2.cvtColor(image1, cv2.COLOR_HSV2RGB)\n return image1",
"def random_brightness(image):\n\... | [
"0.7699167",
"0.7671408",
"0.74550825",
"0.7293831",
"0.7056945",
"0.69009554",
"0.675233",
"0.67481035",
"0.6732132",
"0.6726205",
"0.6584259",
"0.645901",
"0.6430547",
"0.6338716",
"0.6319761",
"0.6315538",
"0.6281936",
"0.6273927",
"0.6265488",
"0.62469244",
"0.62175995",
... | 0.78828675 | 0 |
newimagefromfile(self, infile) > image Summary Construct a new image analysis tool using the specified image. (Also known as newimage.) Description This method returns an image analysis tool associated with the specified image. Constructing a image analysis tool in addition to the default ia tool allows the user to ope... | def newimagefromfile(self, infile):
return _image.image_newimagefromfile(self, infile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newimage(self, infile):\n return _image.image_newimage(self, infile)",
"def newimagefromimage(self, *args, **kwargs):\n return _image.image_newimagefromimage(self, *args, **kwargs)",
"def newimagefromfits(self, *args, **kwargs):\n return _image.image_newimagefromfits(self, *args, **kwa... | [
"0.74905187",
"0.64655584",
"0.5957915",
"0.5539942",
"0.5439315",
"0.5430824",
"0.54275376",
"0.5230645",
"0.5210181",
"0.5202679",
"0.5173129",
"0.51427925",
"0.5132872",
"0.5102963",
"0.5092627",
"0.50748235",
"0.5071782",
"0.5053466",
"0.5046822",
"0.50007904",
"0.499612"... | 0.7515106 | 0 |
type(self) > string Summary Return the type of this tool Description This function returns the string `image'. It can be used in a script to make sure this variable is an Image ool. | def type(self):
return _image.image_type(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _type(self) -> str:\n ...",
"def imageType(self):\n return self.__imageType",
"def image_type(self) -> ImageType:\n return self._image_type",
"def type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"type\")",
"def type(self) -> pulumi.Output[str]:\n return p... | [
"0.6884929",
"0.68443716",
"0.6739891",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
"0.66384435",
... | 0.7714822 | 0 |
pixeltype(self) > string Summary Get the pixel data type of the attached image Description This application returns the data type of the pixels of the attached image as a string. | def pixeltype(self):
return _image.image_pixeltype(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pixel_type(self):\n pass",
"def type(self):\n return _image.image_type(self)",
"def imageType(self):\n return self.__imageType",
"def image_type(self) -> ImageType:\n return self._image_type",
"def data_type(self):\n return self.unpack_dword(0xC) & DEVPROP_MASK_TYPE",... | [
"0.7601995",
"0.6762437",
"0.65570414",
"0.6318895",
"0.6052475",
"0.6008654",
"0.5970504",
"0.5954918",
"0.59392214",
"0.5908824",
"0.58805424",
"0.58754957",
"0.586327",
"0.5825481",
"0.5759723",
"0.57554764",
"0.56984425",
"0.56934017",
"0.566529",
"0.56543887",
"0.5646848... | 0.7970264 | 0 |
isconform(self, other) > bool Summary Returns true of the shape, coordinate system, and axes order of the specified image matches this image. Description Returns True if the shape, coordinate system, and axes order of the specified image matches the current image. | def isconform(self, other):
return _image.image_isconform(self, other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compatible(self, other):\n return (hasattr(other, 'fft') and getattr(other, 'fft', np.array(\n [])).shape == self.fft.shape, super(cfft, self).compatible(other))",
"def __eq__(self, other):\n if self.__class__ != other.__class__:\n return False\n return self.mesh ==... | [
"0.6306146",
"0.62065154",
"0.62064797",
"0.61074966",
"0.60226226",
"0.5990914",
"0.59463644",
"0.58837914",
"0.58684194",
"0.5861098",
"0.58139426",
"0.57853764",
"0.5775929",
"0.5770766",
"0.5757954",
"0.57332295",
"0.56849897",
"0.56110466",
"0.5566642",
"0.5565923",
"0.5... | 0.86936665 | 0 |
Generates JSON endpoint for a Category, listing all its items. | def categoryItemsJSON(category_id):
try:
category = session.query(Category).filter_by(id=category_id).one()
items = session.query(ListItem).filter_by(
category_id=category_id).all()
return jsonify(ListItems=[i.serialize for i in items])
except Exception as e:
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_categories_handler():\n categories = getAllCategories()\n return jsonify(categories=[i.serialize for i in categories])",
"def api_category_items(category_id):\n items = session.query(Item).filter(Item.category_id == category_id)\n return jsonify(json_list=[i.to_json() for i in items.all()])",... | [
"0.74364364",
"0.74330056",
"0.7388259",
"0.73846996",
"0.7369376",
"0.718654",
"0.70623934",
"0.7018258",
"0.7005053",
"0.69864446",
"0.6842182",
"0.682935",
"0.67754793",
"0.671744",
"0.67165095",
"0.67091656",
"0.67071456",
"0.6648937",
"0.66429365",
"0.6642575",
"0.659383... | 0.6540868 | 24 |
Edits an existing category. | def editCategory(category_id):
if 'username' not in login_session:
return redirect('/login')
editedCategory = session.query(Category).filter_by(id=category_id).one()
if editedCategory.user_id != login_session['user_id']:
flash('You are not the creator of %s category, and cannot modify it' ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def editCategory(category_id):\n editedCategory = session.query(Category). \\\n filter_by(id=category_id).one()\n if editedCategory.user_id != login_session['user_id']:\n flash('You are not authorized to edit this Category.\\\n Please create your own Category in order to edit.')\n ... | [
"0.7448016",
"0.73773915",
"0.72520155",
"0.72491616",
"0.7223849",
"0.7159262",
"0.7158876",
"0.7130796",
"0.7117691",
"0.70936936",
"0.70255977",
"0.679104",
"0.67657214",
"0.6726786",
"0.6685621",
"0.66422343",
"0.6603833",
"0.6603362",
"0.6590366",
"0.6538154",
"0.6503746... | 0.71838003 | 5 |
Shows all items associated to a category. | def showItems(category_id):
category = session.query(Category).filter_by(id=category_id).one()
items = session.query(ListItem).filter_by(category_id=category_id).all()
creator = getUserInfo(category.user_id)
if 'user_id' in login_session:
if category.user_id != login_session['user_id']:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showItemsByCategory(category_id):\n createSession()\n categories = db.getIndexCategories()\n category = db.getByCategory(category_id)\n items = db.getItemsByCategory(category_id)\n return render_template('category.html',\n main_category=category,\n ... | [
"0.8245045",
"0.8128328",
"0.79183465",
"0.77617884",
"0.76912117",
"0.7679575",
"0.76424646",
"0.7570494",
"0.74917156",
"0.7310864",
"0.7207436",
"0.70068157",
"0.68298787",
"0.68096113",
"0.67776626",
"0.67736363",
"0.6666207",
"0.66629463",
"0.66592",
"0.66533726",
"0.657... | 0.7423759 | 9 |
Return random variable dataloaders and generator NN. A dataloader is used to iterate through the latent space and the target distribution. The latent space dataloader is a uniform distribution sampler and the target dataloader is a normal distribution sampler. If no_target is True, just return the latent space dataload... | def get_datasets_and_generator(args, no_target=False):
# Define datasets.
uniform_dataset = datasets.UniformRVDataset(num_samples=args.num_samples,
shape=args.in_shape)
uniform_dataloader = torch.utils.data.DataLoader(uniform_dataset,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uniform_subset_dataloader(self, samples_per_label, no_grad):\n uniform_subset = self.get_uniform_subset(samples_per_label)\n if no_grad:\n data_args = self.val_data_args\n else:\n data_args = self.train_data_args\n\n uniform_dataloader = torch.utils.data.Da... | [
"0.5923972",
"0.5715177",
"0.5665696",
"0.5565205",
"0.5559021",
"0.5534524",
"0.5483504",
"0.5472646",
"0.5413885",
"0.5411865",
"0.5405384",
"0.53437614",
"0.53388894",
"0.53118294",
"0.52777106",
"0.5276128",
"0.52755857",
"0.5260868",
"0.52570456",
"0.52104247",
"0.520419... | 0.6535073 | 0 |
Set the document name. Raise CardinalityError if already defined. | def set_doc_name(self, doc, name):
if not self.doc_name_set:
doc.name = name
self.doc_name_set = True
return True
else:
raise CardinalityError('Document::Name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_name(self, document_name):\n\n self._document_name = document_name",
"def document_name(self, document_name):\n\n self._document_name = document_name",
"def document_name(self, document_name):\n\n self._document_name = document_name",
"def set_document_name(self, document_na... | [
"0.7747723",
"0.7747723",
"0.7747723",
"0.7306658",
"0.7082357",
"0.6463748",
"0.6461973",
"0.63907516",
"0.63525945",
"0.6307711",
"0.62740475",
"0.6269721",
"0.62431574",
"0.6229135",
"0.6212087",
"0.6212087",
"0.61876816",
"0.6180033",
"0.61783385",
"0.61685866",
"0.616858... | 0.82850534 | 0 |
Set the document SPDX Identifier. Raise value error if malformed value. Raise CardinalityError if already defined. | def set_doc_spdx_id(self, doc, doc_spdx_id_line):
if not self.doc_spdx_id_set:
if doc_spdx_id_line == 'SPDXRef-DOCUMENT':
doc.spdx_id = doc_spdx_id_line
self.doc_spdx_id_set = True
return True
else:
raise SPDXValueError('Doc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identifier(self, value: str):\n if Business.validate_identifier(value):\n self._identifier = value\n else:\n raise BusinessException('invalid-identifier-format', 406)",
"def set_DocumentId(self, value):\n super(DownloadDocumentInputSet, self)._set_input('DocumentId'... | [
"0.6806322",
"0.63734084",
"0.6187029",
"0.6163038",
"0.6131274",
"0.6111658",
"0.6111658",
"0.60508287",
"0.60223275",
"0.6010436",
"0.6010436",
"0.6010436",
"0.6010436",
"0.59688616",
"0.58998543",
"0.58512574",
"0.58264613",
"0.58038294",
"0.56845844",
"0.5656814",
"0.5646... | 0.6277714 | 2 |
Set the `external_document_id` attribute of the `ExternalDocumentRef` object. | def set_ext_doc_id(self, doc, ext_doc_id):
doc.add_ext_document_reference(
ExternalDocumentRef(
external_document_id=ext_doc_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_id(self, external_id):\n\n self._external_id = external_id",
"def external_id(self, external_id):\n\n self._external_id = external_id",
"def external_id(self, external_id):\n\n self._external_id = external_id",
"def external_id(self, external_id):\n if external_id is ... | [
"0.738844",
"0.738844",
"0.738844",
"0.6689075",
"0.6604646",
"0.6594093",
"0.63521045",
"0.6264925",
"0.61174864",
"0.59861606",
"0.58019435",
"0.5704018",
"0.5691114",
"0.55702615",
"0.55095255",
"0.55095255",
"0.547749",
"0.5466418",
"0.54524696",
"0.54442817",
"0.5425098"... | 0.70707786 | 3 |
Set the `spdx_document_uri` attribute of the `ExternalDocumentRef` object. | def set_spdx_doc_uri(self, doc, spdx_doc_uri):
if validations.validate_doc_namespace(spdx_doc_uri):
doc.ext_document_references[-1].spdx_document_uri = spdx_doc_uri
else:
raise SPDXValueError('Document::ExternalDocumentRef') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_doc_spdx_id(self, doc, doc_spdx_id_line):\n if not self.doc_spdx_id_set:\n if doc_spdx_id_line == 'SPDXRef-DOCUMENT':\n doc.spdx_id = doc_spdx_id_line\n self.doc_spdx_id_set = True\n return True\n else:\n raise SPDXVal... | [
"0.62746304",
"0.6217704",
"0.5873042",
"0.5867671",
"0.5800019",
"0.5800019",
"0.5780612",
"0.5715904",
"0.5715904",
"0.56537235",
"0.56537235",
"0.5602704",
"0.5485078",
"0.5480636",
"0.54584634",
"0.5340366",
"0.528663",
"0.518384",
"0.51816887",
"0.5159918",
"0.50915295",... | 0.84740543 | 0 |
Set the review comment. Raise CardinalityError if already set. Raise OrderError if no reviewer defined before. Raise SPDXValueError if comment is not free form text. | def add_review_comment(self, doc, comment):
if len(doc.reviews) != 0:
if not self.review_comment_set:
self.review_comment_set = True
if validations.validate_review_comment(comment):
doc.reviews[-1].comment = str_from_text(comment)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_doc_comment(self, doc, comment):\n if not self.doc_comment_set:\n self.doc_comment_set = True\n if validations.validate_doc_comment(comment):\n doc.comment = str_from_text(comment)\n return True\n else:\n raise SPDXValueEr... | [
"0.7057049",
"0.6887548",
"0.6858093",
"0.6854819",
"0.6820559",
"0.6779137",
"0.6715466",
"0.6704581",
"0.66766274",
"0.6652652",
"0.6610748",
"0.64181215",
"0.6412712",
"0.6360429",
"0.63485444",
"0.63485444",
"0.63485444",
"0.63485444",
"0.63485444",
"0.63485444",
"0.63485... | 0.7602701 | 0 |
Set the annotation SPDX Identifier. Raise CardinalityError if already set. Raise OrderError if no annotator defined before. | def set_annotation_spdx_id(self, doc, spdx_id):
if len(doc.annotations) != 0:
if not self.annotation_spdx_id_set:
self.annotation_spdx_id_set = True
doc.annotations[-1].spdx_id = spdx_id
return True
else:
raise CardinalityEr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setAnnotation(self, *args):\n return _libsbml.SBase_setAnnotation(self, *args)",
"def setAnnotation(self, *args):\n return _libsbml.Model_setAnnotation(self, *args)",
"def setAnnotation(self, *args):\n return _libsbml.SpeciesReference_setAnnotation(self, *args)",
"def SetAnnotation(s... | [
"0.6655752",
"0.6580016",
"0.6448447",
"0.6032588",
"0.57911277",
"0.567614",
"0.567614",
"0.5658713",
"0.56456363",
"0.5605272",
"0.5605272",
"0.5605272",
"0.5605272",
"0.5538689",
"0.5472283",
"0.5451124",
"0.5448639",
"0.5448113",
"0.5409524",
"0.5408796",
"0.5406523",
"... | 0.58795345 | 4 |
Set the Package SPDX Identifier. Raise SPDXValueError if malformed value. Raise CardinalityError if already defined. | def set_pkg_spdx_id(self, doc, spdx_id):
self.assert_package_exists()
if not self.package_spdx_id_set:
if validations.validate_pkg_spdx_id(spdx_id):
doc.package.spdx_id = spdx_id
self.package_spdx_id_set = True
return True
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identifier(self, value: str):\n if Business.validate_identifier(value):\n self._identifier = value\n else:\n raise BusinessException('invalid-identifier-format', 406)",
"def package_id(self, package_id):\n\n self._package_id = package_id",
"def identifier(self, id... | [
"0.57149756",
"0.54936916",
"0.5367692",
"0.5367692",
"0.53604573",
"0.52781177",
"0.52781177",
"0.52781177",
"0.52781177",
"0.5268717",
"0.5246041",
"0.51789856",
"0.5110418",
"0.51042926",
"0.5094257",
"0.5049992",
"0.5045584",
"0.5038243",
"0.5028689",
"0.50114274",
"0.498... | 0.6070608 | 0 |
Set the package originator, if not already set. entity Organization, Person or NoAssert. Raise CardinalityError if already has an originator. Raise OrderError if no package previously defined. | def set_pkg_originator(self, doc, entity):
self.assert_package_exists()
if not self.package_originator_set:
self.package_originator_set = True
if validations.validate_pkg_originator(entity):
doc.package.originator = entity
return True
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_origin(self, origin):\n self.origin = origin\n self.__symbol_set.update(origin)",
"def set_pkg_supplier(self, doc, entity):\n self.assert_package_exists()\n if not self.package_supplier_set:\n self.package_supplier_set = True\n if validations.validate_pkg... | [
"0.5921372",
"0.55250645",
"0.53644764",
"0.5156686",
"0.50321263",
"0.5013553",
"0.4990318",
"0.49623471",
"0.49579707",
"0.4926831",
"0.49218974",
"0.4875088",
"0.48225436",
"0.48066536",
"0.4794843",
"0.47705242",
"0.47481257",
"0.4736987",
"0.4697249",
"0.46906602",
"0.46... | 0.8140218 | 0 |
Set the package's concluded licenses. licenses License info. Raise CardinalityError if already defined. Raise OrderError if no package previously defined. Raise SPDXValueError if data malformed. | def set_pkg_licenses_concluded(self, doc, licenses):
self.assert_package_exists()
if not self.package_conc_lics_set:
self.package_conc_lics_set = True
if validations.validate_lics_conc(licenses):
doc.package.conc_lics = licenses
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_concluded_license(self, doc, lic):\n if self.has_package(doc) and self.has_file(doc):\n if not self.file_conc_lics_set:\n self.file_conc_lics_set = True\n if validations.validate_lics_conc(lic):\n self.file(doc).conc_lics = lic\n ... | [
"0.660802",
"0.6363097",
"0.6235055",
"0.6217067",
"0.6180782",
"0.6148454",
"0.6113832",
"0.5978379",
"0.5886257",
"0.58503217",
"0.56354606",
"0.5634131",
"0.5596324",
"0.55309457",
"0.5513992",
"0.550989",
"0.5470658",
"0.54414254",
"0.5421691",
"0.53720945",
"0.53478247",... | 0.75933665 | 0 |
Add a license from a file to the package. Raise SPDXValueError if data malformed. Raise OrderError if no package previously defined. | def set_pkg_license_from_file(self, doc, lic):
self.assert_package_exists()
if validations.validate_lics_from_file(lic):
doc.package.licenses_from_files.append(lic)
return True
else:
raise SPDXValueError('Package::LicensesFromFile') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_license_in_file(self, doc, lic):\n if self.has_package(doc) and self.has_file(doc):\n if validations.validate_file_lics_in_file(lic):\n self.file(doc).add_lics(lic)\n return True\n else:\n raise SPDXValueError('File::LicenseInFi... | [
"0.65451026",
"0.63048977",
"0.618981",
"0.6017855",
"0.60013866",
"0.5651887",
"0.5586394",
"0.552065",
"0.5476346",
"0.5467727",
"0.5297547",
"0.5155521",
"0.5145596",
"0.512549",
"0.5103639",
"0.50962645",
"0.50861496",
"0.5083219",
"0.5061989",
"0.50131726",
"0.49579895",... | 0.7399092 | 0 |
Set the package's declared license. Raise SPDXValueError if data malformed. Raise OrderError if no package previously defined. Raise CardinalityError if already set. | def set_pkg_license_declared(self, doc, lic):
self.assert_package_exists()
if not self.package_license_declared_set:
self.package_license_declared_set = True
if validations.validate_lics_conc(lic):
doc.package.license_declared = lic
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pkg_license_comment(self, doc, text):\n self.assert_package_exists()\n if not self.package_license_comment_set:\n self.package_license_comment_set = True\n if validations.validate_pkg_lics_comment(text):\n doc.package.license_comment = str_from_text(text)\... | [
"0.6801328",
"0.63618284",
"0.6317917",
"0.6215473",
"0.59796244",
"0.57942456",
"0.5789389",
"0.57017475",
"0.5699216",
"0.56781405",
"0.56582403",
"0.5617481",
"0.5610709",
"0.55815625",
"0.55813754",
"0.5576021",
"0.5526632",
"0.54805475",
"0.547688",
"0.54693526",
"0.5432... | 0.76700735 | 0 |
Set the package's license comment. Raise OrderError if no package previously defined. Raise CardinalityError if already set. Raise SPDXValueError if text is not free form text. | def set_pkg_license_comment(self, doc, text):
self.assert_package_exists()
if not self.package_license_comment_set:
self.package_license_comment_set = True
if validations.validate_pkg_lics_comment(text):
doc.package.license_comment = str_from_text(text)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_license_comment(self, doc, text):\n if self.has_package(doc) and self.has_file(doc):\n if not self.file_license_comment_set:\n self.file_license_comment_set = True\n if validations.validate_file_lics_comment(text):\n self.file(doc).lic... | [
"0.81494117",
"0.8046435",
"0.7594991",
"0.7152861",
"0.698146",
"0.68384457",
"0.67709124",
"0.6671191",
"0.6669421",
"0.66284496",
"0.6505174",
"0.6306473",
"0.6255196",
"0.61364514",
"0.6024993",
"0.5908839",
"0.589094",
"0.5853059",
"0.58171934",
"0.5651913",
"0.56445026"... | 0.8614442 | 0 |
Set the package's copyright text. Raise OrderError if no package previously defined. Raise CardinalityError if already set. Raise value error if text is not one of [None, NOASSERT, TEXT]. | def set_pkg_cr_text(self, doc, text):
self.assert_package_exists()
if not self.package_cr_text_set:
self.package_cr_text_set = True
if validations.validate_pkg_cr_text(text):
if isinstance(text, string_types):
doc.package.cr_text = str_from_tex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_copyright(self, doc, text):\n if self.has_package(doc) and self.has_file(doc):\n if not self.file_copytext_set:\n self.file_copytext_set = True\n if validations.validate_file_cpyright(text):\n if isinstance(text, string_types):\n ... | [
"0.7157871",
"0.70589125",
"0.6998868",
"0.6817139",
"0.6783448",
"0.6764741",
"0.6532283",
"0.650612",
"0.613413",
"0.613413",
"0.5897349",
"0.57371515",
"0.57294667",
"0.57275856",
"0.5607852",
"0.55684423",
"0.5500429",
"0.5488332",
"0.5484109",
"0.5461759",
"0.5457328",
... | 0.8474046 | 0 |
Set the `category` attribute of the `ExternalPackageRef` object. | def set_pkg_ext_ref_category(self, doc, category):
self.assert_package_exists()
if validations.validate_pkg_ext_ref_category(category):
if (len(doc.package.pkg_ext_refs) and
doc.package.pkg_ext_refs[-1].category is None):
doc.package.pkg_ext_refs[-1].categ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category(self, category):\n\n self._category = category",
"def category(self, category):\n\n self._category = category",
"def category(self, category):\n\n self._category = category",
"def category(self, category):\n\n self._category = category",
"def category(self, category... | [
"0.70325243",
"0.70325243",
"0.70325243",
"0.70325243",
"0.70325243",
"0.69428605",
"0.6879619",
"0.6653265",
"0.6124147",
"0.61012524",
"0.6057481",
"0.5979928",
"0.5976272",
"0.59347236",
"0.58687425",
"0.579529",
"0.5735041",
"0.56527996",
"0.5650938",
"0.55857307",
"0.549... | 0.82121855 | 0 |
Set the `pkg_ext_ref_type` attribute of the `ExternalPackageRef` object. | def set_pkg_ext_ref_type(self, doc, pkg_ext_ref_type):
self.assert_package_exists()
if validations.validate_pkg_ext_ref_type(pkg_ext_ref_type):
if (len(doc.package.pkg_ext_refs) and
doc.package.pkg_ext_refs[-1].pkg_ext_ref_type is None):
doc.package.pkg_ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_typ(self, refobj, typ):\n try:\n enum = JB_ReftrackNode.types.index(typ)\n except ValueError:\n raise ValueError(\"The given type %s could not be found in available types: %\" % (typ, JB_ReftrackNode.types))\n cmds.setAttr(\"%s.type\" % refobj, enum)",
"def pack... | [
"0.6159773",
"0.5961745",
"0.59081626",
"0.5753152",
"0.5753152",
"0.5753152",
"0.5730525",
"0.541535",
"0.5396919",
"0.5396919",
"0.5396919",
"0.5396919",
"0.5396919",
"0.5396919",
"0.5373088",
"0.5369171",
"0.53629214",
"0.53623974",
"0.5353288",
"0.53107536",
"0.5273596",
... | 0.8858585 | 0 |
Raise OrderError if no package or no file defined. Raise CardinalityError if more than one comment set. Raise SPDXValueError if text is not free form text. | def set_file_comment(self, doc, text):
if self.has_package(doc) and self.has_file(doc):
if not self.file_comment_set:
self.file_comment_set = True
if validations.validate_file_comment(text):
self.file(doc).comment = str_from_text(text)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_license_comment(self, doc, text):\n if self.has_package(doc) and self.has_file(doc):\n if not self.file_license_comment_set:\n self.file_license_comment_set = True\n if validations.validate_file_lics_comment(text):\n self.file(doc).lic... | [
"0.5914955",
"0.5854182",
"0.5657133",
"0.5595194",
"0.54339826",
"0.5308573",
"0.53011435",
"0.52610093",
"0.52270424",
"0.5199544",
"0.51780844",
"0.5151495",
"0.5097012",
"0.50774825",
"0.50482154",
"0.5039999",
"0.50381523",
"0.49722335",
"0.49688828",
"0.49667266",
"0.49... | 0.6025616 | 0 |
Raise OrderError if no package or file defined. Raise SPDXValueError if malformed value. | def set_file_license_in_file(self, doc, lic):
if self.has_package(doc) and self.has_file(doc):
if validations.validate_file_lics_in_file(lic):
self.file(doc).add_lics(lic)
return True
else:
raise SPDXValueError('File::LicenseInFile')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_product_line_raises_value_error(self):\n def parse_invalid_product_line():\n rec = SeqIO.read(path.join('GenBank', 'invalid_product.gb'),\n 'genbank')\n self.assertRaises(ValueError, parse_invalid_product_line)",
"def test_old_data_format_erro... | [
"0.6375005",
"0.5561006",
"0.5520461",
"0.5514166",
"0.5473529",
"0.5455603",
"0.54430103",
"0.5272656",
"0.5271739",
"0.52384794",
"0.52159655",
"0.52074456",
"0.5205557",
"0.5191385",
"0.51765156",
"0.5176459",
"0.5158093",
"0.51476985",
"0.5129917",
"0.5111158",
"0.5107678... | 0.0 | -1 |
Raise OrderError if no package or file defined. Raise SPDXValueError if not free form text or NONE or NO_ASSERT. Raise CardinalityError if more than one. | def set_file_copyright(self, doc, text):
if self.has_package(doc) and self.has_file(doc):
if not self.file_copytext_set:
self.file_copytext_set = True
if validations.validate_file_cpyright(text):
if isinstance(text, string_types):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self):\n errors = []\n if self.package_format:\n if not re.match('^[1-9][0-9]*$', str(self.package_format)):\n errors.append(\"The 'format' attribute of the package must \"\n 'contain a positive integer if present')\n\n if not... | [
"0.607976",
"0.5926898",
"0.5802946",
"0.57141036",
"0.56801033",
"0.5672274",
"0.5562405",
"0.5484936",
"0.5468498",
"0.5464596",
"0.5463877",
"0.5458504",
"0.54176563",
"0.54176",
"0.53858477",
"0.5385328",
"0.53670776",
"0.53328896",
"0.53297424",
"0.53270954",
"0.5305994"... | 0.0 | -1 |
Add a new extracted license to the document. Raise SPDXValueError if data format is incorrect. | def set_lic_id(self, doc, lic_id):
# FIXME: this state does not make sense
self.reset_extr_lics()
if validations.validate_extracted_lic_id(lic_id):
doc.add_extr_lic(document.ExtractedLicense(lic_id))
return True
else:
raise SPDXValueError('ExtractedLic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fusion_api_add_license(self, key=None, license_type='LicenseV500', api=None, headers=None):\n return self.license.add(key, license_type, api, headers)",
"def set_pkg_license_from_file(self, doc, lic):\n self.assert_package_exists()\n if validations.validate_lics_from_file(lic):\n ... | [
"0.6575696",
"0.6275083",
"0.62596345",
"0.62420154",
"0.608776",
"0.60109174",
"0.5892227",
"0.5848414",
"0.5827891",
"0.57654315",
"0.57419956",
"0.573979",
"0.56407845",
"0.5620761",
"0.55235535",
"0.55036247",
"0.55033106",
"0.5497293",
"0.5382184",
"0.53481",
"0.5313563"... | 0.5882061 | 7 |
Set license name. Raise SPDXValueError if name is not str or utils.NoAssert Raise OrderError if no license id defined. | def set_lic_name(self, doc, name):
if self.has_extr_lic(doc):
if not self.extr_lic_name_set:
self.extr_lic_name_set = True
if validations.validate_extr_lic_name(name):
self.extr_lic(doc).full_name = name
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_lic_name(self, doc, name):\n if self.has_extr_lic(doc):\n if not self.extr_lic_name_set:\n self.extr_lic_name_set = True\n if validations.validate_extr_lic_name(name, True):\n self.extr_lic(doc).full_name = name\n return ... | [
"0.73220515",
"0.6396575",
"0.61972296",
"0.61965394",
"0.6186129",
"0.6170389",
"0.6169439",
"0.6168958",
"0.6168958",
"0.61683965",
"0.61169314",
"0.6085125",
"0.6078903",
"0.60736537",
"0.60736537",
"0.60736537",
"0.60736537",
"0.6058857",
"0.6058857",
"0.604263",
"0.60353... | 0.733175 | 0 |
Set license comment. Raise SPDXValueError if comment is not free form text. Raise OrderError if no license ID defined. | def set_lic_comment(self, doc, comment):
if self.has_extr_lic(doc):
if not self.extr_lic_comment_set:
self.extr_lic_comment_set = True
if validations.validate_is_free_form_text(comment):
self.extr_lic(doc).comment = str_from_text(comment)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_file_license_comment(self, doc, text):\n if self.has_package(doc) and self.has_file(doc):\n if not self.file_license_comment_set:\n self.file_license_comment_set = True\n if validations.validate_file_lics_comment(text):\n self.file(doc).lic... | [
"0.81745994",
"0.80319244",
"0.7535927",
"0.7421154",
"0.720437",
"0.68231684",
"0.66864914",
"0.65178484",
"0.6270932",
"0.62492037",
"0.6227365",
"0.6204164",
"0.619954",
"0.6194712",
"0.6188058",
"0.6104291",
"0.60890913",
"0.6059739",
"0.6056942",
"0.6056942",
"0.604826",... | 0.7980674 | 2 |
Add a license cross reference. Raise OrderError if no License ID defined. | def add_lic_xref(self, doc, ref):
if self.has_extr_lic(doc):
self.extr_lic(doc).add_xref(ref)
return True
else:
raise OrderError('ExtractedLicense::CrossRef') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_license(self, contents):\n buf_size = len(contents)\n buf = (ctypes.c_char * (buf_size + 1))(*contents.encode())\n\n res = self._dll.JLINK_EMU_AddLicense(buf)\n\n if res == -1:\n raise errors.JLinkException('Unspecified error.')\n elif res == -2:\n r... | [
"0.64722526",
"0.62111443",
"0.58033043",
"0.55013335",
"0.5416698",
"0.5373802",
"0.5205612",
"0.5191666",
"0.516612",
"0.51602787",
"0.5124441",
"0.51213676",
"0.5106808",
"0.50696963",
"0.49839833",
"0.49669445",
"0.4956937",
"0.49544975",
"0.49243644",
"0.4923189",
"0.491... | 0.7074869 | 0 |
Set name of the snippet. Raise OrderError if no snippet previously defined. Raise CardinalityError if the name is already set. | def set_snippet_name(self, doc, name):
self.assert_snippet_exists()
if not self.snippet_name_set:
self.snippet_name_set = True
doc.snippet[-1].name = name
return True
else:
raise CardinalityError('SnippetName') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n\t\tself.name_ = name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def setName(self, name):\n self._name ... | [
"0.6959192",
"0.694765",
"0.694765",
"0.69101614",
"0.69101614",
"0.69011956",
"0.68903756",
"0.68870795",
"0.68870795",
"0.68870795",
"0.68870795",
"0.68870795",
"0.6861245",
"0.6838443",
"0.68335605",
"0.6824499",
"0.6813794",
"0.68067247",
"0.68067247",
"0.68067247",
"0.68... | 0.8357078 | 0 |
Set the snippet's copyright text. Raise OrderError if no snippet previously defined. Raise CardinalityError if already set. Raise SPDXValueError if text is not one of [None, NOASSERT, TEXT]. | def set_snippet_copyright(self, doc, text):
self.assert_snippet_exists()
if not self.snippet_copyright_set:
self.snippet_copyright_set = True
if validations.validate_snippet_copyright(text):
if isinstance(text, string_types):
doc.snippet[-1].co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pkg_cr_text(self, doc, text):\n self.assert_package_exists()\n if not self.package_cr_text_set:\n self.package_cr_text_set = True\n if validations.validate_pkg_cr_text(text):\n if isinstance(text, string_types):\n doc.package.cr_text = s... | [
"0.7483664",
"0.70696807",
"0.7054515",
"0.70457447",
"0.6823482",
"0.6540734",
"0.6536564",
"0.6187854",
"0.6187854",
"0.591872",
"0.58079594",
"0.5701383",
"0.56818897",
"0.5601822",
"0.5402159",
"0.53800815",
"0.5378974",
"0.5361824",
"0.5358519",
"0.5357413",
"0.5355048",... | 0.845006 | 0 |
Raise OrderError if no snippet previously defined. Raise CardinalityError if already set. Raise SPDXValueError if the data is a malformed value. | def set_snip_concluded_license(self, doc, conc_lics):
self.assert_snippet_exists()
if not self.snippet_conc_lics_set:
self.snippet_conc_lics_set = True
if validations.validate_lics_conc(conc_lics):
doc.snippet[-1].conc_lics = conc_lics
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_old_data_format_error(self):\n assert_raises(ValueError, get_data, self.testv1)",
"def test_invalid_product_line_raises_value_error(self):\n def parse_invalid_product_line():\n rec = SeqIO.read(path.join('GenBank', 'invalid_product.gb'),\n 'genbank')\... | [
"0.56103104",
"0.52182895",
"0.505197",
"0.50294346",
"0.50227314",
"0.5020306",
"0.4983532",
"0.4959386",
"0.48906904",
"0.48852557",
"0.4831082",
"0.4828166",
"0.48145762",
"0.48132923",
"0.47971845",
"0.47803226",
"0.47758704",
"0.47683132",
"0.47562045",
"0.4753423",
"0.4... | 0.0 | -1 |
Raise OrderError if no snippet previously defined. Raise SPDXValueError if the data is a malformed value. | def set_snippet_lics_info(self, doc, lics_info):
self.assert_snippet_exists()
if validations.validate_snip_lics_info(lics_info):
doc.snippet[-1].add_lics(lics_info)
return True
else:
raise SPDXValueError('Snippet::LicenseInfoInSnippet') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_old_data_format_error(self):\n assert_raises(ValueError, get_data, self.testv1)",
"def test_invalid_product_line_raises_value_error(self):\n def parse_invalid_product_line():\n rec = SeqIO.read(path.join('GenBank', 'invalid_product.gb'),\n 'genbank')\... | [
"0.5954434",
"0.57209384",
"0.54280454",
"0.52760863",
"0.521301",
"0.517692",
"0.5175308",
"0.51731735",
"0.5092197",
"0.50920516",
"0.50573885",
"0.50407416",
"0.50012136",
"0.49823266",
"0.49694544",
"0.49480554",
"0.4933678",
"0.49084908",
"0.4904503",
"0.4898814",
"0.488... | 0.0 | -1 |
Takes square matrices as input and constructs a block diagonal matrix in order of their appearance as input arguments. | def blockDiag(matrixList):
# Check if all input matrices are square matrices
dimension = 0
for block in matrixList:
if block.shape[0] != block.shape[1]:
raise Error("Non-square input matrix.")
dimension += block.shape[0]
# Construct diagonal block matrix
index =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _block_diagonal(factor_matrices):\n shapes_dict = {}\n for i, matrix_i in enumerate(factor_matrices):\n for j, matrix_j in enumerate(factor_matrices):\n shapes_dict[(i, j)] = matrix_i.shape[:-1] + matrix_j.shape[-1:]\n rows = []\n # concacatenate along axis = -2\n for i, matrix... | [
"0.78770435",
"0.772451",
"0.77153736",
"0.6895055",
"0.6756513",
"0.667681",
"0.6323695",
"0.6099601",
"0.60986227",
"0.6035383",
"0.6021418",
"0.5928099",
"0.5925762",
"0.5907038",
"0.5885221",
"0.58050233",
"0.5793896",
"0.5793547",
"0.5750941",
"0.5739432",
"0.5709976",
... | 0.75373685 | 3 |
lcm(a, b) > number Returns least common multiple of two integers a and b using the gcd function. | def lcm(a, b):
return a * b / gcd(a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_lcm(a, b):\n return a * b / calculate_gcd(a, b)",
"def lcm(a, b):\n return abs(a*b) / gcd(a, b) if a and b else 0",
"def lcm(a, b):\n\n\treturn (a * b)/gcd(a, b)",
"def lcm(a, b):\r\n return a * b // gcd(a, b)",
"def lcm(a, b):\n return a * b // gcd(a, b)",
"def lcm(a, b):\n... | [
"0.8980369",
"0.88264817",
"0.8714298",
"0.8696795",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.8688295",
"0.86474174",
"0.86374545",
"0.86374545",
"0.8627074",
"0.86215067",
"0.86196643",
"0.86183",
"0.8604869",... | 0.86542946 | 15 |
modExp(a, b, n) > number modExp calculates ab mod n | def modExp(a, b, n):
c = 0
d = 1
for bi in bin(b)[2:]:
c = 2 * c
d = (d * d) % n
if bi == '1':
c += 1
d = (d * a) % n
return d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp_mod( a, b, n):\n r = int(1)\n while(b):\n if(b&1):\n r=(r*a)%n\n a=(a*a)%n\n b>>=1 # b = b>>1\n \n return r",
"def mod_exp(a, b, n):\n result = 1\n while True:\n if b % 2 == 1:\n result = (a * result) % n\n\n b = b / 2\n\n ... | [
"0.8597584",
"0.84851956",
"0.81083775",
"0.80882597",
"0.76773614",
"0.7662332",
"0.7503698",
"0.7457951",
"0.74132854",
"0.7327739",
"0.73141307",
"0.7280034",
"0.726227",
"0.7226039",
"0.7189068",
"0.71342766",
"0.71265507",
"0.712637",
"0.71223575",
"0.7113074",
"0.710953... | 0.85754675 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.