query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
An instructor should be able to initiate a jitsi live. | def test_api_video_instructor_initiate_jitsi_live(self):
video = factories.VideoFactory(
id="27a23f52-3379-46a2-94fa-697b59cfe3c7",
playlist__title="foo bar",
playlist__lti_id="course-v1:ufr+mathematics+00001",
)
jwt_token = AccessToken()
jwt_token.pay... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_instructor_start_non_idle_live(self):\n video = factories.VideoFactory(\n id=\"27a23f52-3379-46a2-94fa-697b59cfe3c7\",\n upload_state=PENDING,\n live_state=random.choice([s[0] for s in LIVE_CHOICES if s[0] != \"idle\"]),\n live_type=RAW,\n )\n ... | [
"0.60261226",
"0.6015295",
"0.59643716",
"0.59009105",
"0.58533597",
"0.58318335",
"0.58318335",
"0.58318335",
"0.58318335",
"0.58011377",
"0.5790651",
"0.57562137",
"0.5751726",
"0.56952894",
"0.56641877",
"0.56325126",
"0.56325126",
"0.56237036",
"0.56237036",
"0.5600287",
... | 0.69384843 | 0 |
Anonymous users are not allowed to start a live. | def test_api_video_start_live_anonymous_user(self):
video = factories.VideoFactory()
response = self.client.post(f"/api/videos/{video.id}/start-live/")
self.assertEqual(response.status_code, 401)
content = json.loads(response.content)
self.assertEqual(
content, {"de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anonymous():\n return False",
"def test_api_video_initiate_live_anonymous_user(self):\n video = factories.VideoFactory()\n\n response = self.client.post(f\"/api/videos/{video.id}/initiate-live/\")\n\n self.assertEqual(response.status_code, 401)\n content = json.loads(res... | [
"0.6592946",
"0.6494612",
"0.6479494",
"0.64649665",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
"0.63279337",
... | 0.6924362 | 0 |
An instructor with read_only set to true should not be able to start a live. | def test_api_video_instructor_start_live_in_read_only(self):
video = factories.VideoFactory()
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
jwt_token.payload["roles"] = [random.choice(["instructor", "administrator"])]
jwt_token.payload["permissions"] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_instructor_initiate_live_in_read_only(self):\n video = factories.VideoFactory()\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"])]\n jwt_token.pa... | [
"0.72525626",
"0.6742537",
"0.6489153",
"0.6489153",
"0.6405917",
"0.6348487",
"0.63340545",
"0.62907255",
"0.6168628",
"0.6149776",
"0.6135148",
"0.6042868",
"0.6026938",
"0.5999581",
"0.5999581",
"0.5999581",
"0.5999581",
"0.599148",
"0.5984983",
"0.5965824",
"0.5955471",
... | 0.7389538 | 0 |
A student should not be able to start a live. | def test_api_video_student_start_live(self):
video = factories.VideoFactory()
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
jwt_token.payload["roles"] = ["student"]
response = self.client.post(
f"/api/videos/{video.id}/start-live/",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_careers_invalid_student(self):\n student_id = '1234567890'\n result = self.ucuenca.schedule(student_id)\n self.assertFalse(result)",
"def test_api_video_student_initiate_live(self):\n video = factories.VideoFactory()\n jwt_token = AccessToken()\n jwt_token.paylo... | [
"0.64666325",
"0.6193658",
"0.61624396",
"0.6158128",
"0.6136004",
"0.6102498",
"0.60907173",
"0.6051432",
"0.6016664",
"0.5931232",
"0.5912021",
"0.5900177",
"0.5882163",
"0.5858718",
"0.5842952",
"0.58379006",
"0.57815033",
"0.5769379",
"0.5767614",
"0.57554597",
"0.5740034... | 0.6614195 | 0 |
An instructor should not start a video when not in live mode. | def test_api_instructor_start_non_live_video(self):
video = factories.VideoFactory(
id="27a23f52-3379-46a2-94fa-697b59cfe3c7",
upload_state=random.choice([s[0] for s in STATE_CHOICES]),
)
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_instructor_start_non_idle_live(self):\n video = factories.VideoFactory(\n id=\"27a23f52-3379-46a2-94fa-697b59cfe3c7\",\n upload_state=PENDING,\n live_state=random.choice([s[0] for s in LIVE_CHOICES if s[0] != \"idle\"]),\n live_type=RAW,\n )\n ... | [
"0.7412882",
"0.7358776",
"0.7240957",
"0.7188807",
"0.7049525",
"0.68243253",
"0.67984855",
"0.67984855",
"0.67984855",
"0.67984855",
"0.6778227",
"0.67452276",
"0.67433876",
"0.66061795",
"0.65485644",
"0.6529168",
"0.6495579",
"0.6489755",
"0.648626",
"0.648626",
"0.644844... | 0.7704749 | 0 |
An instructor should not start a video when not in live mode. | def test_api_instructor_start_non_idle_live(self):
video = factories.VideoFactory(
id="27a23f52-3379-46a2-94fa-697b59cfe3c7",
upload_state=PENDING,
live_state=random.choice([s[0] for s in LIVE_CHOICES if s[0] != "idle"]),
live_type=RAW,
)
jwt_token... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_instructor_start_non_live_video(self):\n video = factories.VideoFactory(\n id=\"27a23f52-3379-46a2-94fa-697b59cfe3c7\",\n upload_state=random.choice([s[0] for s in STATE_CHOICES]),\n )\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = ... | [
"0.7703713",
"0.7358513",
"0.7240945",
"0.7188635",
"0.7049232",
"0.68231356",
"0.67985535",
"0.67985535",
"0.67985535",
"0.67985535",
"0.67787534",
"0.6745583",
"0.67433345",
"0.6606759",
"0.65474766",
"0.6529702",
"0.649597",
"0.6488909",
"0.64857394",
"0.64857394",
"0.6448... | 0.74117947 | 1 |
Anonymous users are not allowed to stop a live. | def test_api_video_stop_live_anonymous_user(self):
video = factories.VideoFactory()
response = self.client.post(f"/api/videos/{video.id}/stop-live/")
self.assertEqual(response.status_code, 401)
content = json.loads(response.content)
self.assertEqual(
content, {"deta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disallow_handler(update, _):\n global TEMPORARILY_ALLOWED\n user_id = update.message.chat.id\n if user_id == ADMIN_ID:\n TEMPORARILY_ALLOWED = False\n update.message.reply_text(\"Temprarily allowed disabled!\")",
"def test_api_video_instructor_stop_live_in_read_only(self):\n vid... | [
"0.65399635",
"0.64476043",
"0.6439552",
"0.63720864",
"0.6289802",
"0.6223873",
"0.62178606",
"0.61278325",
"0.607359",
"0.60633457",
"0.6044045",
"0.597465",
"0.59742105",
"0.59253925",
"0.59094024",
"0.5898963",
"0.5882345",
"0.5861994",
"0.58303726",
"0.58122665",
"0.5783... | 0.7234297 | 0 |
An instructor with read_only set to true should not be able to stop a live. | def test_api_video_instructor_stop_live_in_read_only(self):
video = factories.VideoFactory()
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
jwt_token.payload["roles"] = [random.choice(["instructor", "administrator"])]
jwt_token.payload["permissions"] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_instructor_start_live_in_read_only(self):\n video = factories.VideoFactory()\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"])]\n jwt_token.paylo... | [
"0.7276562",
"0.7149556",
"0.6529597",
"0.64743584",
"0.64743584",
"0.6461077",
"0.63935566",
"0.63030887",
"0.6153621",
"0.61088896",
"0.5998145",
"0.59547323",
"0.59547323",
"0.59547323",
"0.59547323",
"0.5901826",
"0.5891755",
"0.5890304",
"0.58862036",
"0.5877192",
"0.584... | 0.7423588 | 0 |
A student should not be able to stop a live. | def test_api_video_student_stop_live(self):
video = factories.VideoFactory()
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
jwt_token.payload["roles"] = ["student"]
response = self.client.post(
f"/api/videos/{video.id}/stop-live/",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_instructor_stop_live_in_read_only(self):\n video = factories.VideoFactory()\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = str(video.id)\n jwt_token.payload[\"roles\"] = [random.choice([\"instructor\", \"administrator\"])]\n jwt_token.payloa... | [
"0.665526",
"0.66009367",
"0.6460251",
"0.63614786",
"0.63535726",
"0.6301615",
"0.60067385",
"0.6005226",
"0.59533995",
"0.59468013",
"0.59030604",
"0.58920294",
"0.5869129",
"0.5864219",
"0.58633035",
"0.58615416",
"0.58441806",
"0.5843927",
"0.5821259",
"0.58041114",
"0.57... | 0.697601 | 0 |
An instructor should not stop a video when not in live mode. | def test_api_instructor_stop_non_live_video(self):
video = factories.VideoFactory(
id="27a23f52-3379-46a2-94fa-697b59cfe3c7",
upload_state=random.choice([s[0] for s in STATE_CHOICES]),
)
jwt_token = AccessToken()
jwt_token.payload["resource_id"] = str(video.id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_instructor_stop_non_running_live(self):\n video = factories.VideoFactory(\n id=\"27a23f52-3379-46a2-94fa-697b59cfe3c7\",\n upload_state=PENDING,\n live_state=random.choice([s[0] for s in LIVE_CHOICES if s[0] != \"running\"]),\n live_type=RAW,\n ... | [
"0.7796268",
"0.7427205",
"0.72466075",
"0.71685565",
"0.7167635",
"0.7152092",
"0.70547813",
"0.70006377",
"0.6970477",
"0.6923031",
"0.69106203",
"0.6893699",
"0.6771923",
"0.6740988",
"0.66896695",
"0.6677808",
"0.65654933",
"0.6487636",
"0.6487632",
"0.6487632",
"0.646642... | 0.7894922 | 0 |
An instructor should not stop a video when not in live state. | def test_api_instructor_stop_non_running_live(self):
video = factories.VideoFactory(
id="27a23f52-3379-46a2-94fa-697b59cfe3c7",
upload_state=PENDING,
live_state=random.choice([s[0] for s in LIVE_CHOICES if s[0] != "running"]),
live_type=RAW,
)
jwt_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_instructor_stop_non_live_video(self):\n video = factories.VideoFactory(\n id=\"27a23f52-3379-46a2-94fa-697b59cfe3c7\",\n upload_state=random.choice([s[0] for s in STATE_CHOICES]),\n )\n jwt_token = AccessToken()\n jwt_token.payload[\"resource_id\"] = s... | [
"0.7944129",
"0.7291849",
"0.72207254",
"0.719873",
"0.7040603",
"0.7018957",
"0.69474876",
"0.6940812",
"0.6808219",
"0.67891145",
"0.67476165",
"0.6694016",
"0.6679444",
"0.66699386",
"0.6599011",
"0.6586042",
"0.65245074",
"0.64716214",
"0.6442532",
"0.6427986",
"0.6426531... | 0.7828574 | 1 |
Confirm update video live state. | def test_api_video_update_live_state(self):
video = factories.VideoFactory(
id="a1a21411-bf2f-4926-b97f-3c48a124d528",
upload_state=PENDING,
live_state=IDLE,
live_info={},
live_type=RAW,
)
data = {
"logGroupName": "/aws/lamb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_update_live_state_idle(self):\n video = factories.VideoFactory(\n id=\"a1a21411-bf2f-4926-b97f-3c48a124d528\",\n upload_state=PENDING,\n live_state=CREATING,\n live_info={},\n live_type=RAW,\n )\n data = {\n \... | [
"0.669423",
"0.66067946",
"0.6488981",
"0.63831115",
"0.6315425",
"0.6314889",
"0.6285026",
"0.6158163",
"0.6078076",
"0.59171903",
"0.5905363",
"0.5857383",
"0.58428895",
"0.5838473",
"0.5838473",
"0.5814329",
"0.579707",
"0.57459235",
"0.5738861",
"0.5720667",
"0.5709396",
... | 0.66788983 | 1 |
Updating state to stopped should set video to DELETED if manifest is missing. | def test_api_video_update_live_state_stopped_missing_manifest(self):
video = factories.VideoFactory(
id="a1a21411-bf2f-4926-b97f-3c48a124d528",
upload_state=PENDING,
live_state=STOPPING,
live_info={"mediapackage": {"channel": {"id": "channel1"}}},
live... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_update_live_state_unknown_video(self):\n data = {\n \"logGroupName\": \"/aws/lambda/dev-test-marsha-medialive\",\n \"state\": \"running\",\n }\n signature = generate_hash(\"shared secret\", json.dumps(data).encode(\"utf-8\"))\n response = self.cl... | [
"0.61517084",
"0.6147886",
"0.6037828",
"0.6032262",
"0.6032262",
"0.5964834",
"0.5944277",
"0.5937539",
"0.58444035",
"0.58058584",
"0.57293636",
"0.5729041",
"0.5718966",
"0.5702582",
"0.5674354",
"0.566203",
"0.5659448",
"0.5617334",
"0.55615175",
"0.554622",
"0.5542855",
... | 0.6312514 | 0 |
Live state update with an invalid signature should fails. | def test_api_video_update_live_state_invalid_signature(self):
video = factories.VideoFactory(
id="a1a21411-bf2f-4926-b97f-3c48a124d528",
upload_state=PENDING,
live_state=IDLE,
live_type=RAW,
)
data = {
"logGroupName": "/aws/lambda/dev-t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_update_live_state_unknown_video(self):\n data = {\n \"logGroupName\": \"/aws/lambda/dev-test-marsha-medialive\",\n \"state\": \"running\",\n }\n signature = generate_hash(\"shared secret\", json.dumps(data).encode(\"utf-8\"))\n response = self.cl... | [
"0.7028745",
"0.70109797",
"0.6085967",
"0.6063225",
"0.6047554",
"0.5965111",
"0.59549403",
"0.59207034",
"0.59040105",
"0.58996487",
"0.58742315",
"0.5871743",
"0.58040553",
"0.57979226",
"0.5776625",
"0.5771004",
"0.5761674",
"0.5754233",
"0.57024837",
"0.5696791",
"0.5632... | 0.79467356 | 0 |
Live state update with an invalid state should fails. | def test_api_video_update_live_state_invalid_state(self):
video = factories.VideoFactory(
id="a1a21411-bf2f-4926-b97f-3c48a124d528",
upload_state=PENDING,
live_state=IDLE,
live_type=RAW,
)
invalid_state = random.choice(
[s[0] for s in L... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid(self, state):\n log(\"current state '{0}' cannot process event '{1}'\".format(state.name, self.name))",
"def test_update_node_state_smartfail(self):\n pass",
"def test_state_after_failure(self):\n pass",
"def state_failsafe_validate(cfg, app, win, events):",
"def test_block... | [
"0.6867225",
"0.6746515",
"0.670642",
"0.6673287",
"0.66131973",
"0.65411866",
"0.6478215",
"0.6466603",
"0.64601433",
"0.64423186",
"0.64142185",
"0.6396009",
"0.6346287",
"0.6346287",
"0.63296247",
"0.63008726",
"0.6247246",
"0.62421614",
"0.62149596",
"0.6208199",
"0.61872... | 0.75381476 | 0 |
Live state update with an unknown video should fails. | def test_api_video_update_live_state_unknown_video(self):
data = {
"logGroupName": "/aws/lambda/dev-test-marsha-medialive",
"state": "running",
}
signature = generate_hash("shared secret", json.dumps(data).encode("utf-8"))
response = self.client.patch(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_video_update_live_state_invalid_state(self):\n video = factories.VideoFactory(\n id=\"a1a21411-bf2f-4926-b97f-3c48a124d528\",\n upload_state=PENDING,\n live_state=IDLE,\n live_type=RAW,\n )\n invalid_state = random.choice(\n [... | [
"0.7784363",
"0.72019297",
"0.7105363",
"0.7011971",
"0.68896437",
"0.65897465",
"0.6572008",
"0.643296",
"0.6379981",
"0.6292681",
"0.6288871",
"0.6288871",
"0.627914",
"0.6160698",
"0.61350566",
"0.61238045",
"0.59614325",
"0.58788806",
"0.58284414",
"0.5731805",
"0.5718009... | 0.80395156 | 0 |
Computes the min edit distance from source to target | def min_edit_distance(source, target):
source_words = source.split()
target_words = target.split()
m = len(source_words)
n = len(target_words)
distance = [[0 for i in range(n+1)] for j in range(m+1)]
for i in range(1, m+1):
distance[i][0] = distance[i-1][0] + 1
for j in range(1, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_edit_distance_pro(\n source: str,\n target: str,\n del_cost=1,\n ins_cost=1,\n sub_cost=2,\n):\n # Use three tables for up, left and northwest or,\n # Uses one tables and represents up,\n # left and northwest as 1, 3, 5 respectivly?\n # 1: up, 3: left, 5: northwest, 4: up + left\... | [
"0.7693602",
"0.75446385",
"0.72816",
"0.6812453",
"0.67283833",
"0.671338",
"0.6683665",
"0.6606871",
"0.6497808",
"0.6490708",
"0.6487655",
"0.6399363",
"0.6332539",
"0.6325396",
"0.6324086",
"0.62027526",
"0.6196767",
"0.6151955",
"0.61486185",
"0.61167824",
"0.6116629",
... | 0.764925 | 1 |
Computes the word error rate between output and ideal word error rate = minimum edit distance/no of words in ideal sentence | def word_error_rate(output, ideal):
return min_edit_distance(output, ideal)/len(ideal.split()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_error_rate(hypotheses, references):\n\n scores = 0\n words = 0\n len_diff = len(references) - len(hypotheses)\n if len_diff > 0:\n raise ValueError(\"Uneqal number of hypthoses and references: \"\n \"{0} and {1}\".format(len(hypotheses), len(references)))\n el... | [
"0.70479745",
"0.6861282",
"0.6712708",
"0.6672853",
"0.6627787",
"0.65970993",
"0.6548495",
"0.6483904",
"0.6389047",
"0.6382813",
"0.6372524",
"0.6365916",
"0.63445747",
"0.6335466",
"0.63145435",
"0.62640274",
"0.62636125",
"0.62576604",
"0.6257261",
"0.621895",
"0.6209494... | 0.8901293 | 0 |
Collects the output shape(s) of a list of Keras tensors. Arguments | def _collect_input_shape(input_tensors):
input_tensors = to_list(input_tensors)
shapes = []
for x in input_tensors:
try:
shapes.append(K.int_shape(x))
except TypeError:
shapes.append(None)
return unpack_singleton(shapes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ExtractInputShapes(inputs):\n if context.executing_eagerly():\n return array_ops.shape_n(inputs)\n sizes = []\n fully_known = True\n for x in inputs:\n input_shape = array_ops.shape(x)\n if not isinstance(input_shape,\n tensor.Tensor) or input_shape.op.type !=... | [
"0.735498",
"0.70147294",
"0.70147294",
"0.70147294",
"0.70022446",
"0.69870424",
"0.69419247",
"0.6935082",
"0.6802348",
"0.67808133",
"0.6715975",
"0.6681929",
"0.66333735",
"0.65937126",
"0.65777856",
"0.656046",
"0.654464",
"0.65077263",
"0.65072185",
"0.6503165",
"0.6503... | 0.7279559 | 1 |
Try to import all C extensions. | def test_c_extensions_import():
import storm_analysis.dbscan.dbscan_c
import storm_analysis.fista.fista_fft_c
import storm_analysis.frc.frc_c
import storm_analysis.L1H.homotopy_imagea_c
import storm_analysis.rolling_ball_bgr.rolling_ball_lib_c
import storm_analysis.sa_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detectExtensions(builder):\n print (\"Checking if C extensions can be compiled, don't be alarmed if \"\n \"a few compile errors are printed.\")\n\n if not builder._compile_helper(\"#define X 1\\n\"):\n print \"Compiler not found, skipping C extensions.\"\n return []\n\n # Exten... | [
"0.6752059",
"0.6606153",
"0.6383072",
"0.63468283",
"0.6211412",
"0.6153936",
"0.6096747",
"0.60393804",
"0.597067",
"0.5909593",
"0.5909499",
"0.59058255",
"0.58827597",
"0.58437383",
"0.5838516",
"0.58294934",
"0.581349",
"0.57937706",
"0.5778554",
"0.5777526",
"0.5745322"... | 0.6875448 | 0 |
Finds all allowed value in the set of possible arrays This is done with binary OR. Values that are always 1 or 2 will never change. If either, they will become a 3 If they remain 0 > there is no solution | def find_allowed(possible_arrays):
allowed = [0] * len(possible_arrays[0])
for array in possible_arrays:
allowed = [x | y for x, y in zip(allowed, array)]
return allowed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self, i, j):\n possible=np.ones((10), np.int)\n for k in range(0, 9):\n if k==j: continue\n possible[self.a[i][k]]=0\n\n for k in range(0, 9):\n if k==i: continue\n possible[self.a[k][j]]=0\n for a1 in range(0, 3):\n for b1 in range(0, 3):\n if (i//3)*3+a1==i a... | [
"0.6063571",
"0.5989684",
"0.58360726",
"0.5805874",
"0.57882935",
"0.5782648",
"0.572063",
"0.5671718",
"0.56716937",
"0.5633513",
"0.56065935",
"0.5559587",
"0.55376446",
"0.55248064",
"0.5514542",
"0.5503843",
"0.5489493",
"0.54865366",
"0.54118717",
"0.5406459",
"0.538802... | 0.730627 | 0 |
Deprecated, use make_xml instead | def prepare(*args, **kwargs):
LOGGER.warning(
"readalongs.api.prepare() is deprecated. Please use make_xml() instead."
)
return make_xml(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_xml(self, root_name):\n\n self.tree = ET.ElementTree(ET.fromstring('<?xml version=\"1.0\" encoding=\"UTF-8\"?><%s></%s>'%(\n root_name, root_name)))\n return self.tree.getroot()",
"def from_xml(cls, xml_data, system, id_gene... | [
"0.6673175",
"0.6491031",
"0.6446211",
"0.637155",
"0.6355076",
"0.63387907",
"0.6337277",
"0.62541366",
"0.6239761",
"0.619156",
"0.6185545",
"0.61794513",
"0.61569715",
"0.61033696",
"0.609219",
"0.6091051",
"0.60459286",
"0.60458064",
"0.6006322",
"0.59886265",
"0.59737456... | 0.73191714 | 0 |
Verifies that isotropicDistance refuses non binary input images | def testIsotropicDistanceDepthAcceptance(self):
self.assertRaises(MambaError, isotropicDistance, self.im8_1, self.im8_2)
self.assertRaises(MambaError, isotropicDistance, self.im32_1, self.im8_2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testIsotropicDistance(self):\n (w,h) = self.im1_1.getSize()\n \n self.im1_1.reset()\n drawSquare(self.im1_1, (w//2-1, h//2-1, w//2+1, h//2+1), 1)\n \n self.im8_3.reset()\n drawSquare(self.im8_3, (w//2-1, h//2-1, w//2+1, h//2+1), 1)\n self.im8_3.setPixel(2... | [
"0.72642386",
"0.619694",
"0.6139344",
"0.6065631",
"0.6022535",
"0.60154855",
"0.5971038",
"0.59305257",
"0.5920673",
"0.59090304",
"0.59090304",
"0.589726",
"0.58919555",
"0.5806894",
"0.57667726",
"0.57252896",
"0.5722722",
"0.5716484",
"0.5700085",
"0.5682196",
"0.5666687... | 0.69661176 | 1 |
Tests the computation of an isotropic distance | def testIsotropicDistance(self):
(w,h) = self.im1_1.getSize()
self.im1_1.reset()
drawSquare(self.im1_1, (w//2-1, h//2-1, w//2+1, h//2+1), 1)
self.im8_3.reset()
drawSquare(self.im8_3, (w//2-1, h//2-1, w//2+1, h//2+1), 1)
self.im8_3.setPixel(2, (w//2, h//2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_calculate_distance():\n\n r1 = np.array([0, 0, 0])\n r2 = np.array([0, 1, 0])\n\n expected_distance = 1\n\n calculated_distance = molecool.calculate_distance(r1, r2)\n\n assert expected_distance == calculated_distance",
"def test_distance(self):\n self.assertTrue(np.allclose(self.v... | [
"0.7066497",
"0.6987544",
"0.65998495",
"0.65983224",
"0.6521844",
"0.6477065",
"0.645209",
"0.6424145",
"0.63212407",
"0.6281343",
"0.62577516",
"0.62530804",
"0.6249498",
"0.6235426",
"0.61601436",
"0.61583465",
"0.61443377",
"0.6097818",
"0.6092339",
"0.6088725",
"0.608457... | 0.7764714 | 0 |
Verifies that the edge is correctly drawn | def testDrawEdge(self):
(w,h) = self.im8_1.getSize()
for thick in range(10):
self.im8_1.reset()
drawEdge(self.im8_1, thick)
self.im8_3.fill(255)
drawSquare(self.im8_3, (thick, thick, w-1-thick, h-1-thick), 0)
(x,y) = compare(self.im8_1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_edges(self):\n if self.rect.right >= self.screen_rect.right or self.rect.left <= 0:\n return True",
"def is_edge(self):\n if self._row == 0 or self._row == 9 or self._column == 0 or self._column == 9:\n # check that the edge is not actually a corner square\n ... | [
"0.697433",
"0.68805933",
"0.6687636",
"0.6635503",
"0.66265905",
"0.65967",
"0.6589389",
"0.6577165",
"0.65077263",
"0.64738965",
"0.6442234",
"0.64329076",
"0.64071053",
"0.636453",
"0.635672",
"0.6261035",
"0.6224357",
"0.6167584",
"0.608596",
"0.6079706",
"0.60442454",
... | 0.76946634 | 0 |
Verifies the saturated (ceiling) addition for 32bit images | def testCeilingAdd(self):
(w,h) = self.im32_1.getSize()
self.im32_1.fill(0xffffff80)
for i in range(256):
self.im32_3.fill(i)
ceilingAdd(self.im32_1, self.im32_3, self.im32_2)
vol = computeVolume(self.im32_2)//(w*h)
value = min(0xffffff80+... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCeilingAddConst(self):\n (w,h) = self.im32_1.getSize()\n \n self.im32_1.fill(0xffffff80)\n for i in range(256):\n ceilingAddConst(self.im32_1, i, self.im32_2)\n vol = computeVolume(self.im32_2)//(w*h)\n value = min(0xffffff80+i, 0xffffffff)\n ... | [
"0.6719554",
"0.58146805",
"0.56908935",
"0.5687286",
"0.5670073",
"0.5638138",
"0.5523233",
"0.5491617",
"0.5490418",
"0.5481001",
"0.5478708",
"0.5466016",
"0.5438659",
"0.54138035",
"0.5375235",
"0.5356348",
"0.5356348",
"0.5345921",
"0.5326352",
"0.53262323",
"0.53206027"... | 0.70995 | 0 |
Verifies the saturated (ceiling) constant addition for 32bit images | def testCeilingAddConst(self):
(w,h) = self.im32_1.getSize()
self.im32_1.fill(0xffffff80)
for i in range(256):
ceilingAddConst(self.im32_1, i, self.im32_2)
vol = computeVolume(self.im32_2)//(w*h)
value = min(0xffffff80+i, 0xffffffff)
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCeilingAdd(self):\n (w,h) = self.im32_1.getSize()\n \n self.im32_1.fill(0xffffff80)\n for i in range(256):\n self.im32_3.fill(i)\n ceilingAdd(self.im32_1, self.im32_3, self.im32_2)\n vol = computeVolume(self.im32_2)//(w*h)\n value = mi... | [
"0.7092009",
"0.60995674",
"0.5991026",
"0.57602704",
"0.575369",
"0.57189256",
"0.5710188",
"0.5662257",
"0.5640272",
"0.5598037",
"0.5539307",
"0.55210054",
"0.54802877",
"0.54787415",
"0.54771805",
"0.54771805",
"0.54765064",
"0.54759747",
"0.54268837",
"0.5373671",
"0.535... | 0.7191471 | 0 |
Verifies the saturated (floor) subtraction for 32bit images | def testFloorSub(self):
(w,h) = self.im32_1.getSize()
self.im32_1.fill(0x80)
for i in range(256):
self.im32_3.fill(i)
floorSub(self.im32_1, self.im32_3, self.im32_2)
vol = computeVolume(self.im32_2)//(w*h)
value = max(0x80-i, 0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFloorSubConst(self):\n (w,h) = self.im32_1.getSize()\n \n self.im32_1.fill(0x80)\n for i in range(256):\n floorSubConst(self.im32_1, i, self.im32_2)\n vol = computeVolume(self.im32_2)//(w*h)\n value = max(0x80-i, 0)\n self.assertTrue(v... | [
"0.6624845",
"0.6108797",
"0.5919725",
"0.5898519",
"0.5795399",
"0.5761699",
"0.5750941",
"0.5718273",
"0.57015765",
"0.5672458",
"0.55940855",
"0.5587078",
"0.55136657",
"0.5511485",
"0.5511485",
"0.5492086",
"0.545562",
"0.54514277",
"0.54314",
"0.54248077",
"0.5393601",
... | 0.6482305 | 1 |
Verifies the saturated (floor) constant subtraction for 32bit images | def testFloorSubConst(self):
(w,h) = self.im32_1.getSize()
self.im32_1.fill(0x80)
for i in range(256):
floorSubConst(self.im32_1, i, self.im32_2)
vol = computeVolume(self.im32_2)//(w*h)
value = max(0x80-i, 0)
self.assertTrue(vol==value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_bit_exactness(input_raw_file):\n (t1, f1) = interpolate(input_raw_file, 'cpu_nn_lena.dat', 'cpu', 1, 'nn', 8000, 4000)\n (t2, f2) = interpolate(input_raw_file, 'gpu_nn_lena.dat', 'gpu', 1, 'nn', 8000, 4000)\n (t3, f3) = interpolate(input_raw_file, 'cpu_bl_lena.dat', 'cpu', 1, 'bl', 8000, 4000)\n... | [
"0.6310723",
"0.62938845",
"0.62113756",
"0.5969369",
"0.59030825",
"0.5886565",
"0.58667827",
"0.58567953",
"0.5739565",
"0.57389843",
"0.57019556",
"0.5626554",
"0.55466545",
"0.55359733",
"0.5475242",
"0.54310983",
"0.5407184",
"0.54054695",
"0.53816265",
"0.53612334",
"0.... | 0.6950812 | 0 |
Verifies that mulRealConst refuses binary input images | def testMulRealConstDepthAcceptance(self):
self.assertRaises(MambaError, mulRealConst, self.im1_1, 1.0, self.im8_2)
self.assertRaises(MambaError, mulRealConst, self.im32_1, 1.0, self.im1_2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_on_merlin_image_binary(self):\n im = diffread(TEST_MIB)\n self.assertEqual(im.shape, (256, 256))\n self.assertEqual(im.dtype, np.dtype(\">u2\"))",
"def testMulRealConst(self):\n self.im8_1.fill(1)\n \n self.im8_3.fill(1)\n mulRealConst(self.im8_1, 1.6, se... | [
"0.65523493",
"0.6411468",
"0.6128225",
"0.5862283",
"0.5744814",
"0.55602735",
"0.55312604",
"0.54814464",
"0.546288",
"0.54556775",
"0.54417485",
"0.54311913",
"0.54021156",
"0.53700346",
"0.53652495",
"0.53612983",
"0.5352316",
"0.53403133",
"0.53360397",
"0.53285086",
"0.... | 0.6963398 | 0 |
DEVELOPMENT ONLY Saves a screenshot of the captcha (out/captcha.png) and reads from file (out/captcha) the captcha text to input. | def handle_captcha(self):
self.webdriver.save_screenshot('./out/captcha.png')
sleep(20)
with open('./out/captcha', 'r') as f:
try:
self.webdriver.find_element_by_xpath("//input[@aria-label='Type the text you hear or see']").send_keys(f.read())
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_captcha_manual(gid):\n image = auth.get_captcha_image(gid)\n # FIXME: Use Python's temp file interface.\n image.save(\"./test.png\")\n webbrowser.open_new_tab(\"./test.png\")\n text = input('solve_captcha --->')\n return text",
"def gen_captcha(**kwargs):\n from PIL import ImageFil... | [
"0.71884316",
"0.6698693",
"0.65424967",
"0.6215375",
"0.61891127",
"0.6079916",
"0.60580266",
"0.5914424",
"0.5824995",
"0.5824887",
"0.58242536",
"0.57925165",
"0.5688282",
"0.5589822",
"0.5572178",
"0.55524635",
"0.5550549",
"0.529425",
"0.52441746",
"0.5242615",
"0.522713... | 0.7391811 | 0 |
Shows info related the dataframes wrangled in this pipeline. | def _show_info(self):
dataframe = self._cache.get_source(config.DATAFRAME_ARTISTS)
dataframe.printSchema() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_frame_info(self):\r\n print(self.dataframe_name)\r\n print(self.data_frame.info())",
"def show(dfs):\n\n for df in dfs:\n print('{} -> {}'.format(df[0], df[1]))",
"def show_hdf(self):\n self._walk()",
"def display_df_info(df, df_name, max_rows=None, max_columns=None):\... | [
"0.68191516",
"0.65245867",
"0.6203311",
"0.61643773",
"0.6033394",
"0.59863055",
"0.5783366",
"0.57670814",
"0.5765709",
"0.5762325",
"0.5701758",
"0.5682693",
"0.5662552",
"0.56528604",
"0.56318945",
"0.5623627",
"0.56216586",
"0.5618758",
"0.56068605",
"0.55752116",
"0.556... | 0.739165 | 0 |
parse the table containing personal info | def get_personal_info(self, table):
json_result = {}
row_list = table.xpath('./tr[position() > 1]')
for row in row_list:
row_key = row.xpath('./td[1]/b/text()')
if row_key:
row_key = row_key[0]
else:
raise ProfileException("Fail... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseRow(self, row):\n\n data = {}\n for i in self.index:\n data[self.headers[i].value] = row[i].value\n # initialize parser\n username = re.findall('(\\w+)\\s(\\w+)', self.request.POST['user'])[0]\n self.user = User.objects.get(first_name=username[0], \n ... | [
"0.59491",
"0.5947452",
"0.58929724",
"0.5722304",
"0.5655687",
"0.5653452",
"0.5643614",
"0.56298906",
"0.5590057",
"0.5525687",
"0.55215514",
"0.5480727",
"0.5425067",
"0.5399843",
"0.53760237",
"0.5370106",
"0.5361874",
"0.53501594",
"0.53389573",
"0.5324406",
"0.5318426",... | 0.68037164 | 0 |
parse the table containing the course table | def get_course_table(self, table):
json_result = {}
row_list = table.xpath('.//table[@id = "s_course"]/tr[position() > 1]')
for row in row_list:
session = row.xpath('./td[1]/text()')
course_full_code_list = row.xpath('.//a[starts-with(@href, "javascript:course_popup")]/te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self):\r\n hdr = {'User-Agent': 'Mozilla/5.0'}\r\n url = CostOfLiving.URL.format(self.city)\r\n req = Request(url, headers=hdr)\r\n page = urlopen(req)\r\n soup = BeautifulSoup(page, \"html.parser\")\r\n self.table = soup.find(\"table\", attrs={\"class\": \"data_... | [
"0.59884536",
"0.5907242",
"0.5891754",
"0.5856169",
"0.58113074",
"0.57813877",
"0.57237667",
"0.56541145",
"0.56348234",
"0.5606098",
"0.56006235",
"0.55713445",
"0.55658233",
"0.55501825",
"0.5547375",
"0.55394775",
"0.55043435",
"0.54974276",
"0.54566413",
"0.5454764",
"0... | 0.67425555 | 0 |
Get a selection of integers for syscalls, by using the C preprocessor. This relies on the system headers defining the numbers as macros. | def get_syscall_numbers(fns):
import subprocess
p = subprocess.Popen(["cc", "-E", "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
p.stdin.write("#include <sys/syscall.h>\n".encode())
for fn in fns:
p.stdin.write(("SYS_%s\n" % fn).encode())
p.stdin.close()
lns = list(p.stdout)
ns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_arch_cc():\n\n k = cc_macros()\n\n matchup = {\n '__x86_64__' : 'x64',\n '__i386__' : 'ia32',\n '__arm__' : 'arm',\n }\n\n rtn = 'ia32' # default\n\n for i in matchup:\n if i in k and k[i] != '0':\n rtn = matchup[i]\n break\n\n return rtn",
"def host_arch_cc():\n\n ... | [
"0.50889546",
"0.49972665",
"0.4936319",
"0.49223414",
"0.4902251",
"0.4890649",
"0.4839331",
"0.48086706",
"0.47911236",
"0.47417554",
"0.47330827",
"0.46965626",
"0.46034023",
"0.46000037",
"0.45939147",
"0.4557752",
"0.45424187",
"0.45383772",
"0.45346913",
"0.4531515",
"0... | 0.70829827 | 0 |
Returns a a digest of a secret you want to store in memory | def hash_secret(secret):
hashed = hashlib.sha256(secret.encode('UTF-8')).hexdigest()
return hashed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_shared_secret():\n\n randint = random.SystemRandom().randint\n bits = load_config(\"instavpn.json\")[\"shared_secret_bits\"]\n return urlsafe_b64encode(\"\".join(chr(randint(0, 255)) for _ in xrange(bits/8)))",
"def get_secret(self):\n return Buffer.from_mpz(self._secret_key)",
"def... | [
"0.7134875",
"0.6946913",
"0.6946709",
"0.68133456",
"0.67842025",
"0.6751108",
"0.6749412",
"0.67133594",
"0.66987425",
"0.6670669",
"0.6663457",
"0.66460395",
"0.66460395",
"0.66328174",
"0.660878",
"0.6516705",
"0.65102446",
"0.64714366",
"0.6459151",
"0.6428858",
"0.64238... | 0.70165616 | 1 |
Verifies that a value in the current config (hashed) corresponds to the value passed as parameter (unhashed) | def verify_secret(prop_name, value):
hashed = hashlib.sha256(value.encode('UTF-8')).hexdigest()
has_must_be = RUN_CONFIG.get(prop_name)
return hashed == has_must_be | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self, user_specific_config: Any, factor: str) -> bool:",
"def check(secret: bytes, b64str: str, values: Dict[str, Any]) -> bool:\n return check_with_reason(secret, b64str, values)[0]",
"def verify_config_params(attack_config):\n _check_config(attack_config, _VALID_CONFIG_CHECKLIST)",
"def ... | [
"0.61623335",
"0.6038576",
"0.6019497",
"0.5998033",
"0.59090203",
"0.5885619",
"0.58353555",
"0.5834025",
"0.58322227",
"0.58322227",
"0.58189595",
"0.5798566",
"0.57869095",
"0.5744254",
"0.5738265",
"0.5719662",
"0.5696878",
"0.56657153",
"0.56617755",
"0.5657235",
"0.5611... | 0.74857116 | 0 |
Returns the index of the rotation point >>> find_rotation(['play', 'xebra', 'bat', 'cat', 'dog']) 2 | def find_rotation(arr):
# edge case: already sorted
if arr[0] < arr[-1]:
return 0
for idx, item in enumerate(arr):
# if the first letter of next item is 'lower' than first letter of item,
# rotation point is index of next item
if arr[idx+1][0] < item[0]:
return i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_rotation_point( word_list ):",
"def test_finds_rotation_point_in_long_list(self):\n result = find_rotation_point(long_words_list)\n self.assertEqual(result, 6)",
"def find_rotation_efficient(arr):\n # edge case: already sorted\n if arr[0] < arr[-1]:\n return 0\n\n low = 0... | [
"0.70094186",
"0.6499037",
"0.6390685",
"0.63771015",
"0.60722977",
"0.5954184",
"0.5886457",
"0.57360756",
"0.57325774",
"0.5722924",
"0.5688037",
"0.568782",
"0.5638405",
"0.5631212",
"0.56212085",
"0.55536884",
"0.5515408",
"0.55049914",
"0.55042875",
"0.54950285",
"0.5465... | 0.6721891 | 1 |
Test flipflop conditions. Signal propagation only at the rising edge | def test_dflipflop(self):
circ = DFlipFlop(size=2)
circ.clk.pulse()
self.assertSigEq(circ.q, 0)
circ.d = 3
self.assertSigEq(circ.q, 0)
circ.clk.set()
self.assertSigEq(circ.q, 3)
circ.d = 2
self.assertSigEq(circ.q, 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_flipflop(self):\n circ = FlipFlop(size=2)\n #test basic flip flop functionality\n circ.d = 3\n self.assertSigEq(circ.q, 0)\n circ.clk.pulse()\n self.assertSigEq(circ.q, 3)\n #test reset circuit\n circ.r.set()\n circ.clk.pulse()\n self.a... | [
"0.7181312",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.5667709",
"0.56069386",
"0.55510265",
"0.55361986",
"0.5455058",
... | 0.65154636 | 1 |
Test ELR flip flop | def test_flipflop(self):
circ = FlipFlop(size=2)
#test basic flip flop functionality
circ.d = 3
self.assertSigEq(circ.q, 0)
circ.clk.pulse()
self.assertSigEq(circ.q, 3)
#test reset circuit
circ.r.set()
circ.clk.pulse()
self.assertSigEq(circ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_flip():\n\n # Function: should_flip(bag_state, has_red, has_blue, has_green)\n\n # Test state and serial number:\n test_state = {\n 'suspicion level': 0,\n 'indicators': {},\n }\n test_state['serial number'] = 'JQXX7e3652'\n test_state['indicators']['check engine'] =... | [
"0.6335177",
"0.6155589",
"0.5920715",
"0.5845766",
"0.5824236",
"0.57557905",
"0.56701374",
"0.56628877",
"0.5648033",
"0.56269133",
"0.5609399",
"0.559891",
"0.55862045",
"0.5580663",
"0.5524137",
"0.550997",
"0.55030376",
"0.54818213",
"0.5480717",
"0.5453894",
"0.54397684... | 0.6759984 | 0 |
Return a nicelyformatted sourcelike function signature. | def signature(function: model.Function) -> str:
return str(function.signature) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_method_signature(self, locals, code):\n\n res = \"\"\n is_args = code.co_flags & 4\n is_kwargs = code.co_flags & 8\n total_args = code.co_argcount\n if is_args:\n total_args += 1\n if is_kwargs:\n total_args += 1\n for i in xrange(to... | [
"0.6755815",
"0.6658284",
"0.6619437",
"0.63633657",
"0.63358295",
"0.61643356",
"0.6092141",
"0.60560864",
"0.6055912",
"0.60539556",
"0.6053157",
"0.600914",
"0.60030514",
"0.5999202",
"0.59839904",
"0.5970945",
"0.5919851",
"0.5903308",
"0.5886662",
"0.5876354",
"0.5852387... | 0.73504645 | 0 |
Set up 3D cube with percentiles of height | def set_up_percentiles_cube():
test_data = np.full((5, 4, 4), -1, dtype=float)
for i in range(5):
test_data[i].fill(100*i + 200)
percentiles = DimCoord(np.linspace(0, 100, 5), long_name="percentiles",
units="%")
grid_x = DimCoord(np.arange(4), standard_name="projecti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_up_threshold_cube():\n test_data = 50*np.arange(16).reshape(4, 4)\n grid_x = DimCoord(np.arange(4), standard_name=\"projection_x_coordinate\",\n units=\"km\")\n grid_y = DimCoord(np.arange(4), standard_name=\"projection_y_coordinate\",\n units=\"km\")\n ... | [
"0.6401066",
"0.6047249",
"0.5978683",
"0.5975754",
"0.5891019",
"0.57748264",
"0.5761081",
"0.5691293",
"0.56676495",
"0.5665823",
"0.5639302",
"0.56036085",
"0.55903935",
"0.5572805",
"0.5559912",
"0.5519475",
"0.5457179",
"0.5456965",
"0.54461634",
"0.54381275",
"0.5431166... | 0.7220225 | 0 |
Set up 2D cube with "orography" data on which to threshold percentiles | def set_up_threshold_cube():
test_data = 50*np.arange(16).reshape(4, 4)
grid_x = DimCoord(np.arange(4), standard_name="projection_x_coordinate",
units="km")
grid_y = DimCoord(np.arange(4), standard_name="projection_y_coordinate",
units="km")
test_cube = iris.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_up_percentiles_cube():\n\n test_data = np.full((5, 4, 4), -1, dtype=float)\n for i in range(5):\n test_data[i].fill(100*i + 200)\n\n percentiles = DimCoord(np.linspace(0, 100, 5), long_name=\"percentiles\",\n units=\"%\")\n grid_x = DimCoord(np.arange(4), standa... | [
"0.6977779",
"0.6504011",
"0.64642787",
"0.62994087",
"0.6236152",
"0.6200467",
"0.6112209",
"0.6097758",
"0.6073408",
"0.5821836",
"0.57702947",
"0.57655525",
"0.5731981",
"0.56486183",
"0.56143403",
"0.561078",
"0.55911934",
"0.55821806",
"0.5579705",
"0.55728793",
"0.55644... | 0.68136084 | 1 |
Test setting of inverse_order flag using percentiles_cube. In this case the flag should be false as the values associated with the percentiles increase in the same direction as the percentiles. | def test_inverse_order_false(self):
plugin_instance = ProbabilitiesFromPercentiles2D(
self.test_cube, 'new_name')
self.assertFalse(plugin_instance.inverse_ordering) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inverse_order_true(self):\n percentiles_cube = self.test_cube.copy(\n data=np.flipud(self.test_cube.data))\n plugin_instance = ProbabilitiesFromPercentiles2D(\n percentiles_cube, 'new_name')\n self.assertTrue(plugin_instance.inverse_ordering)",
"def test_equal_... | [
"0.79300445",
"0.71616274",
"0.7156937",
"0.6335259",
"0.57806724",
"0.5717485",
"0.55411136",
"0.5492557",
"0.5461046",
"0.5437405",
"0.53619474",
"0.53439605",
"0.53260297",
"0.5306396",
"0.52882934",
"0.5254635",
"0.5213377",
"0.5212515",
"0.5176069",
"0.5159069",
"0.51506... | 0.75066394 | 1 |
Test setting of inverse_order flag using percentiles_cube. In this case the flag should be true as the values associated with the percentiles increase in the opposite direction to the percentiles. | def test_inverse_order_true(self):
percentiles_cube = self.test_cube.copy(
data=np.flipud(self.test_cube.data))
plugin_instance = ProbabilitiesFromPercentiles2D(
percentiles_cube, 'new_name')
self.assertTrue(plugin_instance.inverse_ordering) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_inverse_order_false(self):\n plugin_instance = ProbabilitiesFromPercentiles2D(\n self.test_cube, 'new_name')\n self.assertFalse(plugin_instance.inverse_ordering)",
"def test_equal_percentiles_inverse_ordering(self):\n self.percentiles_cube.data[0, :, :].fill(300.)\n ... | [
"0.7347653",
"0.7248827",
"0.7198209",
"0.6305554",
"0.57931304",
"0.5644359",
"0.56396455",
"0.5557479",
"0.5472661",
"0.54367006",
"0.54120636",
"0.538846",
"0.53692895",
"0.534631",
"0.52895766",
"0.52163696",
"0.5215714",
"0.5201024",
"0.5148742",
"0.51197976",
"0.5103274... | 0.7871805 | 0 |
Test relative_to_threshold attribute is suitable for the inverse_ordering case, when it should be 'above'. | def test_attributes_inverse_ordering(self):
self.percentiles_cube.data = np.flipud(self.percentiles_cube.data)
plugin_instance = ProbabilitiesFromPercentiles2D(self.percentiles_cube,
self.new_name)
result = plugin_instance.create_probabili... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_less_than(self):\n utils.compare_tracing_methods(\n SimpleCompareOpsModule(\"lessThan\"),\n torch.randn(3, 4, 5),\n torch.randn(3, 4, 5),\n fusible_ops={\"aten::lt\"},\n )",
"def test_unknown_thresholding(self):\n self.cube.coord(var_name=... | [
"0.62599236",
"0.62535155",
"0.6050937",
"0.6029088",
"0.602097",
"0.59990096",
"0.59913033",
"0.59730476",
"0.5952634",
"0.59435964",
"0.5829159",
"0.5757781",
"0.5755329",
"0.5735106",
"0.57177514",
"0.57121515",
"0.5703613",
"0.56988364",
"0.5690524",
"0.5688124",
"0.56856... | 0.6903596 | 0 |
Test that interpolated probabilities at given topography heights are sensible when we use the inverse_ordering set to True. This is for situations in which the values associated with the percentiles increase in the opposite direction, e.g. 0 % = 100m, 20% = 50m, etc. In this situation we expect the lowest points to hav... | def test_values_inverse_ordering(self):
# Invert the values associated with the percentiles.
self.percentiles_cube.data = np.flipud(self.percentiles_cube.data)
expected = set_reference_probabilities()
expected = 1.0 - expected
probability_cube = ProbabilitiesFromPercentiles2D(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equal_percentiles_inverse_ordering(self):\n self.percentiles_cube.data[0, :, :].fill(300.)\n # Invert the values associated with the percentiles.\n self.percentiles_cube.data = np.flipud(self.percentiles_cube.data)\n expected = set_reference_probabilities()\n expected[np... | [
"0.6936694",
"0.6612405",
"0.6557043",
"0.6536174",
"0.5836456",
"0.55769354",
"0.535456",
"0.5231798",
"0.52008826",
"0.5179406",
"0.5144554",
"0.508962",
"0.50874543",
"0.5033925",
"0.49582127",
"0.49430206",
"0.4935415",
"0.49341342",
"0.49052998",
"0.48981342",
"0.4893713... | 0.6670819 | 1 |
Test for sensible behaviour when some percentile levels are equal. | def test_equal_percentiles(self):
self.percentiles_cube.data[0, :, :].fill(300.)
expected = set_reference_probabilities()
expected[np.where(expected < 0.25)] = 0.
probability_cube = ProbabilitiesFromPercentiles2D(
self.percentiles_cube, 'new_name').percentile_interpolation(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_all_equal_percentiles(self):\n self.percentiles_cube.data[:, :, 0:2].fill(300.)\n expected = set_reference_probabilities()\n expected[0:2, 0:2] = 0\n expected[2:, 0:2] = 1\n probability_cube = ProbabilitiesFromPercentiles2D(\n self.percentiles_cube, 'new_name'... | [
"0.73339146",
"0.72588104",
"0.7193721",
"0.7059122",
"0.70239633",
"0.70094275",
"0.69339293",
"0.6898088",
"0.6817949",
"0.6797381",
"0.66857415",
"0.66115236",
"0.65848815",
"0.6558533",
"0.655689",
"0.6524207",
"0.651964",
"0.64494",
"0.6404538",
"0.6392922",
"0.6383709",... | 0.74234265 | 0 |
Test for sensible behaviour when all percentile levels are equal at some points. | def test_all_equal_percentiles(self):
self.percentiles_cube.data[:, :, 0:2].fill(300.)
expected = set_reference_probabilities()
expected[0:2, 0:2] = 0
expected[2:, 0:2] = 1
probability_cube = ProbabilitiesFromPercentiles2D(
self.percentiles_cube, 'new_name').percentil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_equal_percentiles(self):\n self.percentiles_cube.data[0, :, :].fill(300.)\n expected = set_reference_probabilities()\n expected[np.where(expected < 0.25)] = 0.\n probability_cube = ProbabilitiesFromPercentiles2D(\n self.percentiles_cube, 'new_name').percentile_interp... | [
"0.7465344",
"0.73089546",
"0.72304213",
"0.7225448",
"0.70770556",
"0.7074356",
"0.7005688",
"0.6945462",
"0.67612404",
"0.67586714",
"0.6628192",
"0.6621422",
"0.6559432",
"0.65530586",
"0.6547619",
"0.65411127",
"0.65288323",
"0.64875853",
"0.644483",
"0.6342356",
"0.63316... | 0.75860626 | 0 |
Test for sensible behaviour when some percentile levels are equal in the case of inverse ordering (as described above). | def test_equal_percentiles_inverse_ordering(self):
self.percentiles_cube.data[0, :, :].fill(300.)
# Invert the values associated with the percentiles.
self.percentiles_cube.data = np.flipud(self.percentiles_cube.data)
expected = set_reference_probabilities()
expected[np.where(exp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_values_inverse_ordering(self):\n # Invert the values associated with the percentiles.\n self.percentiles_cube.data = np.flipud(self.percentiles_cube.data)\n expected = set_reference_probabilities()\n expected = 1.0 - expected\n\n probability_cube = ProbabilitiesFromPerce... | [
"0.6926413",
"0.687153",
"0.6708092",
"0.66441315",
"0.6613673",
"0.6609807",
"0.65475774",
"0.654371",
"0.64967823",
"0.64276195",
"0.639919",
"0.6376965",
"0.6329518",
"0.6276094",
"0.6139106",
"0.61351883",
"0.6096647",
"0.60896903",
"0.60634524",
"0.60582614",
"0.60257256... | 0.77178353 | 0 |
Test the "process" function returns a single cube whose shape matches that of the input threshold (orography) field. | def test_basic(self):
probability_cube = self.plugin_instance.process(self.orography_cube)
self.assertIsInstance(probability_cube, iris.cube.Cube)
self.assertSequenceEqual(probability_cube.shape,
self.reference_cube.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_up_threshold_cube():\n test_data = 50*np.arange(16).reshape(4, 4)\n grid_x = DimCoord(np.arange(4), standard_name=\"projection_x_coordinate\",\n units=\"km\")\n grid_y = DimCoord(np.arange(4), standard_name=\"projection_y_coordinate\",\n units=\"km\")\n ... | [
"0.6223342",
"0.581257",
"0.5645637",
"0.5620068",
"0.55189896",
"0.5439803",
"0.54124796",
"0.54022574",
"0.5321581",
"0.525051",
"0.5183953",
"0.5169333",
"0.5150942",
"0.5149574",
"0.5130358",
"0.5119568",
"0.50816226",
"0.5041569",
"0.5040525",
"0.5014353",
"0.50084394",
... | 0.6590361 | 0 |
Test the "process" function converts units appropriately if possible when the input cubes are in different units. | def test_unit_conversion_compatible(self):
self.orography_cube.convert_units('ft')
probability_cube = self.plugin_instance.process(self.orography_cube)
self.assertIsInstance(probability_cube, iris.cube.Cube)
self.assertSequenceEqual(probability_cube.shape,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unit_conversion_incompatible(self):\n self.orography_cube.units = 'K'\n msg = \"Unable to convert from\"\n with self.assertRaisesRegex(ValueError, msg):\n self.plugin_instance.process(self.orography_cube)",
"def test_convert_same_unit():\n assert pressure_util.convert(... | [
"0.6625997",
"0.6437879",
"0.6160189",
"0.58628625",
"0.5836225",
"0.5800775",
"0.57642335",
"0.5732402",
"0.56941307",
"0.56460065",
"0.5623775",
"0.5611578",
"0.5577296",
"0.555354",
"0.55409086",
"0.55349946",
"0.55279815",
"0.55069077",
"0.5484457",
"0.5435416",
"0.538233... | 0.74237454 | 0 |
Test the "process" function raises an error when trying to convert the units of cubes that have incompatible units. | def test_unit_conversion_incompatible(self):
self.orography_cube.units = 'K'
msg = "Unable to convert from"
with self.assertRaisesRegex(ValueError, msg):
self.plugin_instance.process(self.orography_cube) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_too_many_cubes(self):\n temp = self.temperature\n humid = self.relative_humidity\n pressure = self.pressure\n msg = \"Expected 3\"\n with self.assertRaisesRegex(ValueError, msg):\n WetBulbTemperature().process(CubeList([temp, humid, pressure, temp]))",
"def ... | [
"0.6727947",
"0.6689959",
"0.6644148",
"0.66011065",
"0.6515232",
"0.6496085",
"0.6222151",
"0.61650944",
"0.6138874",
"0.6074079",
"0.60311204",
"0.5983569",
"0.59056264",
"0.5855763",
"0.5833101",
"0.58096343",
"0.57705975",
"0.5756942",
"0.57507277",
"0.56909555",
"0.56720... | 0.7596227 | 0 |
Test that if the pecentiles_cube has other dimension coordinates over which slicing is performed, that these dimensions are properly restored in the resulting probability cube. | def test_preservation_of_dimensions(self):
percentiles_cube = set_up_percentiles_cube()
test_data = np.array([percentiles_cube.data, percentiles_cube.data])
percentiles = percentiles_cube.coord('percentiles')
grid_x = percentiles_cube.coord('projection_x_coordinate')
grid_y = per... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_preservation_of_single_valued_dimension(self):\n percentiles_cube = set_up_percentiles_cube()\n new_model_coord = build_coordinate([0],\n long_name='leading_coord',\n coord_type=DimCoord,\n ... | [
"0.6573338",
"0.65155584",
"0.6331512",
"0.6296247",
"0.6127816",
"0.61163586",
"0.602921",
"0.59533024",
"0.59429663",
"0.58905756",
"0.58462465",
"0.5840607",
"0.5825418",
"0.58206326",
"0.5819811",
"0.5686703",
"0.5670416",
"0.5668486",
"0.5650249",
"0.5611526",
"0.5593675... | 0.7481589 | 0 |
Test that if the pecentiles_cube has a single value dimension coordinate over which slicing is performed, that this coordinate is restored as a dimension coordinate in the resulting probability cube. | def test_preservation_of_single_valued_dimension(self):
percentiles_cube = set_up_percentiles_cube()
new_model_coord = build_coordinate([0],
long_name='leading_coord',
coord_type=DimCoord,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_preservation_of_dimensions(self):\n percentiles_cube = set_up_percentiles_cube()\n test_data = np.array([percentiles_cube.data, percentiles_cube.data])\n percentiles = percentiles_cube.coord('percentiles')\n grid_x = percentiles_cube.coord('projection_x_coordinate')\n gr... | [
"0.7051559",
"0.68129355",
"0.6192699",
"0.59999096",
"0.59750366",
"0.5854034",
"0.5833827",
"0.5687848",
"0.5681342",
"0.56353337",
"0.5614267",
"0.5514567",
"0.5513307",
"0.5488463",
"0.5487292",
"0.54499996",
"0.5447126",
"0.5413848",
"0.53965026",
"0.53933626",
"0.534820... | 0.71103495 | 0 |
Creates a Gateway Load Balancer and resturns response and ARN | def create_gwlb(gwlb_name, subnet_id_list):
logging.info(f"Creating gateway load balancer: {gwlb_name}")
waiter = elbv2.get_waiter('load_balancer_available')
try:
response = elbv2.create_load_balancer(
Name=gwlb_name,
Subnets=subnet_id_list,
Tags=[{'Key': 'Name', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_balancer(self):\n app_env = self.get_current_env()\n balancer_name = self.get_balancer_name()\n subnet_ids = self.get_subnet_ids()\n\n response = self.client.create_load_balancer(\n Name=balancer_name,\n Subnets=subnet_ids,\n SecurityGroups=[s... | [
"0.7186875",
"0.7094904",
"0.70398855",
"0.6917474",
"0.68913764",
"0.6481388",
"0.6477398",
"0.636849",
"0.61646646",
"0.6153201",
"0.6110362",
"0.6108698",
"0.6096575",
"0.59728664",
"0.5910449",
"0.59034276",
"0.585251",
"0.5678679",
"0.56646043",
"0.56287825",
"0.56194615... | 0.7172102 | 1 |
Creates a listener for the specified GWLB. | def create_fwd_listener(gwlb_arn, tg_arn):
try:
response = elbv2.create_listener(
LoadBalancerArn=gwlb_arn,
DefaultActions=[
{
'Type': 'forward',
'TargetGroupArn': tg_arn,
}
]
)
listen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_listener(self, context, listener):\n LOG.info(\"Received request 'Create Listener' for LB:%(lb)s \",\n {'lb': listener['loadbalancer_id']})\n arg_dict = {'context': context,\n lb_const.LISTENER: listener,\n }\n self._send_event(l... | [
"0.680093",
"0.6062638",
"0.5872074",
"0.568026",
"0.562014",
"0.55364203",
"0.5465429",
"0.54544973",
"0.5450853",
"0.5429485",
"0.53733176",
"0.5358816",
"0.5357443",
"0.53148276",
"0.53111404",
"0.5308438",
"0.52377367",
"0.5230723",
"0.5210393",
"0.51991904",
"0.5175915",... | 0.65823334 | 1 |
Creates Appliance Gateway (GWLB) and associated Target Group (TG) and Listener and registers target(s) | def main():
parser = argparse.ArgumentParser()
parser.add_argument('--tg_name', required=True,
help='specify target group name', type=str)
parser.add_argument('--gwlb_name', required=True,
help='specify gateway load balancer name', type=str)
parser.add_arg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_gwlb(gwlb_name, subnet_id_list):\n logging.info(f\"Creating gateway load balancer: {gwlb_name}\")\n waiter = elbv2.get_waiter('load_balancer_available')\n try:\n response = elbv2.create_load_balancer(\n Name=gwlb_name,\n Subnets=subnet_id_list,\n Tags=[{'... | [
"0.62968814",
"0.61144644",
"0.55747527",
"0.5550602",
"0.5515989",
"0.55029714",
"0.54040945",
"0.53575385",
"0.5312576",
"0.52309376",
"0.52106285",
"0.52051246",
"0.5162079",
"0.5135037",
"0.5105967",
"0.5101289",
"0.50615025",
"0.50615025",
"0.5044468",
"0.5033211",
"0.50... | 0.6617608 | 0 |
Read a bufr file and convert to a Pandas DataFrame Variables used inside the DataFrame are already CDM compliant | def bufr_to_dataframe(file=''):
if debug:
print("Running bufr_to_dataframe for: ", file)
check_read_file (file = file, read= False)
f = open(file)
#source_file = [l for l in file.split('/') if '.bfr' in l][0]
read_data = []
""" Name of the columns as they will appear ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_swc(file_name):\n\n df = pd.read_csv(file_name, delimiter=' ', header=None, comment='#',\n names=['sample', 'identifier', 'x', 'y', 'z', 'r', 'parent'],\n skipinitialspace=True).astype({'sample':int,'identifier':int,'x':float,'y':float,'z':float,'r':float,'parent... | [
"0.6760399",
"0.66910934",
"0.66843355",
"0.6596809",
"0.65731204",
"0.64530325",
"0.6444564",
"0.64268804",
"0.64126265",
"0.6340299",
"0.6340299",
"0.6340299",
"0.6326406",
"0.63134426",
"0.6298015",
"0.6291843",
"0.628385",
"0.62818545",
"0.6272516",
"0.6217461",
"0.621523... | 0.7691618 | 0 |
Read an uadb stationfile in ASCII format and convert to a Pandas DataFrame. | def uadb_ascii_to_dataframe(file=''):
if debug:
print("Running uadb_ascii_to_dataframe for: ", file)
data = check_read_file(file=file, read=True) # TODO
#source_file = [l for l in file.split('/') if '.txt' in l][0]
nmiss = 0
search_h = False
read_data = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uadb_ascii_to_dataframe(filename, **kwargs):\n import datetime\n import zipfile\n import gzip\n import os\n import io\n import numpy as np\n import pandas as pd\n from . import support as sp\n\n if not os.path.isfile(filename):\n raise IOError(\"File not Found! %s\" % filename... | [
"0.7591771",
"0.685794",
"0.6593989",
"0.62999815",
"0.6292323",
"0.6279624",
"0.6228682",
"0.6220584",
"0.61573863",
"0.61280155",
"0.611027",
"0.6012557",
"0.5959872",
"0.5870615",
"0.5867335",
"0.5846116",
"0.5834367",
"0.58262587",
"0.58182746",
"0.581537",
"0.57865024",
... | 0.70143044 | 1 |
Read an igra2 stationfile in ASCII format and convert to a Pandas DataFrame. | def igra2_ascii_to_dataframe(file=''):
if debug:
print("Running igra2_ascii_to_dataframe for: ", file)
data = check_read_file(file=file, read=True)
#source_file = [l for l in file.split('/') if '.txt' in l][0]
read_data = [] # Lists containing the raw data from the ascii file, and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uadb_ascii_to_dataframe(filename, **kwargs):\n import datetime\n import zipfile\n import gzip\n import os\n import io\n import numpy as np\n import pandas as pd\n from . import support as sp\n\n if not os.path.isfile(filename):\n raise IOError(\"File not Found! %s\" % filename... | [
"0.6976135",
"0.6776106",
"0.6681584",
"0.6436349",
"0.6297956",
"0.6267564",
"0.6266623",
"0.62274367",
"0.6124879",
"0.61233276",
"0.60146654",
"0.60051876",
"0.59578943",
"0.5896764",
"0.5883741",
"0.58122426",
"0.5811471",
"0.5803112",
"0.5794453",
"0.5778825",
"0.574811"... | 0.72274184 | 0 |
build a sonde release time ex 2019 02 20 00 2349 ex 2019 01 10 00 0011 They round the release time to the closest hour. It can be the same day or the following !!! date_time = date_time pytohn object, date, time, release = original strings | def make_release_time(date_time, hour, release):
release_h = int(release[:2])
release_m = int(release[2:4])
if release_h == 99:
return 0 #largest integer number int 64
else:
if release_m == 99:
release_m = 0
releas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_time(date_time):\n\n time_hour = int(date_time.strftime('%H'))\n\n quotient = int(time_hour / 4)\n\n if quotient == 5:\n date_time = datetime.combine(date_time.date()+timedelta(1), time(0,0))\n else:\n date_time = datetime.combine(date_time.date(), time((quotient+1)*4,0))\n ... | [
"0.72464585",
"0.60484743",
"0.59548783",
"0.5717549",
"0.5513829",
"0.5408672",
"0.53816426",
"0.5347346",
"0.53351736",
"0.53103334",
"0.5297417",
"0.52803713",
"0.5220621",
"0.5219593",
"0.5197299",
"0.51796794",
"0.51562935",
"0.5153432",
"0.5144711",
"0.5126217",
"0.5102... | 0.79936635 | 0 |
Create the header from the odb file, if not found in the 'headers/' directory. Headers contain the columsn names and their respective variable types. Only for ODB files. | def make_odb_header(odbfile, dataset):
header = 'headers/' + dataset + '_header.dat'
if not os.path.isfile ( header ):
print(' Creating the header file for the dataset: ', dataset )
if dataset in ('era5_1','era5_2'):
odbfile = odbfile.replace('.gz','')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_header(filename, data, lima):\n\tfrom utilities import file_type\n\tfrom EMAN2db import db_open_dict\n\n\tftp = file_type(filename)\n\tif ftp == \"bdb\":\n\t\tDB = db_open_dict(filename)\n\t\tDB.set_header(lima, data)\n\telif ftp == \"hdf\":\n\t\tdata.write_image(filename, lima, EMUtil.ImageType.IMAGE_HD... | [
"0.6557311",
"0.6183077",
"0.6180994",
"0.6173603",
"0.61628336",
"0.6050184",
"0.6024849",
"0.5993984",
"0.5971808",
"0.59469956",
"0.5938618",
"0.59086764",
"0.59044254",
"0.59018356",
"0.58778733",
"0.58743674",
"0.58452106",
"0.5840796",
"0.58389056",
"0.58276016",
"0.582... | 0.80710715 | 0 |
Writes each separate variable from the observation or feedback tables inot netcdf using h5py. f is a pandas dataframe with one column, one for each variable k is either 'era5fb' or 'observations_table' | def write_dict_h5(dfile, f, k, fbencodings, var_selection=[], mode='a', attrs={}):
#attrs= {'date_time':('units','seconds since 1900-01-01 00:00:00')}
#attrs = {'observation_id': ('description', 'unique ID for observation'), 'report_id': ('description', 'Link to header information') , 'date_time':('units','se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_dict_h6(dfile, f, k, fbencodings, var_selection=[], mode='a', attrs={}):\n\n #attrs= {'date_time':('units','seconds since 1900-01-01 00:00:00')}\n #attrs = {'observation_id': ('description', 'unique ID for observation'), 'report_id': ('description', 'Link to header information') , 'date_time':('un... | [
"0.67543757",
"0.6443923",
"0.6092056",
"0.5962444",
"0.59045845",
"0.58782977",
"0.58390933",
"0.58258235",
"0.57865006",
"0.57606965",
"0.57498914",
"0.56900674",
"0.5640461",
"0.5636864",
"0.5624655",
"0.5609386",
"0.55957025",
"0.5575014",
"0.5549395",
"0.55375063",
"0.55... | 0.6696595 | 1 |
Writes each separate variable from the observation or feedback tables inot netcdf using h5py. f is a pandas dataframe with one column, one for each variable k is either 'era5fb' or 'observations_table' | def write_dict_h6(dfile, f, k, fbencodings, var_selection=[], mode='a', attrs={}):
#attrs= {'date_time':('units','seconds since 1900-01-01 00:00:00')}
#attrs = {'observation_id': ('description', 'unique ID for observation'), 'report_id': ('description', 'Link to header information') , 'date_time':('units','se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_dict_h5(dfile, f, k, fbencodings, var_selection=[], mode='a', attrs={}):\n\n #attrs= {'date_time':('units','seconds since 1900-01-01 00:00:00')}\n #attrs = {'observation_id': ('description', 'unique ID for observation'), 'report_id': ('description', 'Link to header information') , 'date_time':('un... | [
"0.6696969",
"0.64458895",
"0.6092665",
"0.5964444",
"0.5906239",
"0.5880411",
"0.5839755",
"0.5827213",
"0.5787817",
"0.57605267",
"0.5750614",
"0.5691835",
"0.56416214",
"0.5637448",
"0.56259525",
"0.56092304",
"0.5597023",
"0.55758166",
"0.55513054",
"0.5536801",
"0.551205... | 0.6754596 | 0 |
Converts the variable type of the input DataFrame (igra2,ncar,bufr) | def convert_variable_type_n(df):
# available columns
"""
'source_file', 'source_id', 'report_id', 'observation_id',
'record_timestamp', 'iday', 'station_id', 'lat@hdr', 'lon@hdr',
'vertco_reference_1@body', 'obsvalue@body', 'varno@body', 'units',
'number_of_pressure_levels'
"""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_type(data):\n# Categorical features\n columns = ['Browser', 'OperatingSystems', 'Region', 'TrafficType']\n for col in columns:\n data[col] = data[col].apply(lambda x: str(x))\n return data",
"def convert_types(df):\n \n # Iterate through each column\n for c in df:\n ... | [
"0.698135",
"0.6574161",
"0.6371382",
"0.6348573",
"0.6335147",
"0.61783874",
"0.60554516",
"0.60521567",
"0.603357",
"0.6014633",
"0.5996646",
"0.59819514",
"0.59644175",
"0.59415495",
"0.58963",
"0.58877915",
"0.588751",
"0.58810073",
"0.5805037",
"0.579967",
"0.5769489",
... | 0.7458724 | 0 |
Load the cdm tables into Panda DataFrames, reading the tables from the cdm GitHub page FF To do Uncomment to get the list of all the .csv files present at the url specified | def load_cdm_tables():
tpath = os.getcwd() + '/../data'
cdmpath='https://raw.githubusercontent.com/glamod/common_data_model/master/tables/' # cdm tables
""" Selecting the list of table definitions. Some of the entires do not have the corresponding implemented tables """
cdmtabledeflist=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_datasets_csv(url):\n # dataset = pd.read_csv(url, sep='\\t')\n dataset = pd.read_csv(url, sep=\",\")\n dataset.columns = dataset.columns.str.replace(\" \", \"_\")\n return dataset",
"def get_data():\n \n \"\"\" Prepare variables\"\"\"\n urls = {\"cases\": \"https://github.com/CS... | [
"0.71734565",
"0.67320985",
"0.6669976",
"0.6588941",
"0.65831953",
"0.64777106",
"0.64169997",
"0.63222474",
"0.63173807",
"0.6298204",
"0.62980694",
"0.62220365",
"0.6213207",
"0.6168551",
"0.61399347",
"0.61185586",
"0.60854256",
"0.6081547",
"0.6046216",
"0.6012291",
"0.5... | 0.7079996 | 1 |
Return a list of csv files, as fond in the url on the cdm GitHub | def csvListFromUrls(url=''):
urlpath = urlopen(url)
string = urlpath.read().decode('utf-8')
split = string.split(' ')
csv_files_list = [m.replace('"','') for m in [n.split('title="')[1] for n in split if '.csv' in n and "title" in n] ]
return csv_files_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_csv_files():\n # See README.txt Ref#2.\n return [filename for filename in glob.glob(\"*.csv\")]",
"def clowder_dataset_filelist(session, url, dataset):\n try:\n ret = session.get(posixpath.join(url, \"api/datasets\", dataset, \"listFiles\"))\n except session.exceptions.RequestExceptio... | [
"0.71335447",
"0.6901352",
"0.6822499",
"0.67910224",
"0.6789945",
"0.6654213",
"0.66047746",
"0.65839416",
"0.6547043",
"0.64927316",
"0.6466528",
"0.64494634",
"0.6361783",
"0.63590306",
"0.6329721",
"0.63262",
"0.63022965",
"0.6283138",
"0.6280837",
"0.62568825",
"0.625632... | 0.74914557 | 0 |
Replace wrong characters from the station configuration tables | def clean_station_configuration(cdm_tab ):
subs={'o':[240,242,243,244,245,246,248],'O':[210,211,212,213,214,216],
'a':[224,225,226,227,228,229,230],'A':[192,193,194,195,196,197,198],
'u':[249,250,251,252,253],'U':[217,218,219,220],
'i':[236,237,238,239],'I':[204,205,206,207,304],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _strip_invalid_characters(self: object) -> None:\n for current_invalid_character in Episode._invalid_characters:\n self.episode_broadcast = self.episode_broadcast.replace(current_invalid_character, \" \").strip()\n self.episode_inspectors = self.episode_inspectors.replace(current_i... | [
"0.57187146",
"0.5708669",
"0.55323374",
"0.5492229",
"0.5476717",
"0.54078436",
"0.53837335",
"0.53668267",
"0.5350255",
"0.5330315",
"0.5287106",
"0.5197462",
"0.5163849",
"0.51432276",
"0.5143008",
"0.51317203",
"0.51091266",
"0.5106305",
"0.5104198",
"0.5097012",
"0.50901... | 0.7234293 | 0 |
Return the 2D center position of `pos + shift` | def _center(pos: ArrayLike, shift: ArrayLike) -> Tuple[float, float]:
x = np.concatenate((pos[0], pos[0] + shift[0]))
y = np.concatenate((pos[1], pos[1] + shift[1]))
return (x.max() + x.min()) / 2, (y.max() + y.min()) / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _center(pos, shift):\n x = np.concatenate((pos[0], pos[0] + shift[0]))\n y = np.concatenate((pos[1], pos[1] + shift[1]))\n return (x.max() + x.min()) / 2, (y.max() + y.min()) / 2",
"def center(self):\n return self.pos + self.axis / 2.0",
"def crop_center(im, ps):\n if not type(ps) == int... | [
"0.87730724",
"0.6642049",
"0.65281355",
"0.64186084",
"0.6198713",
"0.6174678",
"0.6117257",
"0.6109757",
"0.60876495",
"0.6070367",
"0.60687387",
"0.6055401",
"0.6047456",
"0.60136634",
"0.6009561",
"0.59890777",
"0.59838825",
"0.5973223",
"0.59308547",
"0.5927332",
"0.5923... | 0.83657295 | 1 |
Plot the sites, hoppings and periodic boundaries of the lead | def plot(self, lead_length: int = 6, ax: Optional[plt.Axes] = None, **kwargs) -> None:
if ax is None:
ax = plt.gca()
pos = self.system.positions
sub = self.system.sublattices
inner_hoppings = self.system.hoppings.tocoo()
boundary = self.system.boundaries[0]
ou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_bond_lattice(lattice, worm, observables):\n # create bond grid for plotting\n line_range = np.linspace(0, lattice.L, lattice.L+1)\n x_grid, y_grid = np.meshgrid(line_range, line_range)\n\n\n # initialize figure.\n fig = plt.figure(figsize=(9, 9))\n ax = plt.axes(xlim=(0, lattice.L), ylim... | [
"0.6571925",
"0.6494316",
"0.6387066",
"0.6355867",
"0.6060526",
"0.60148257",
"0.59904087",
"0.5880127",
"0.5846436",
"0.5815426",
"0.5802742",
"0.574608",
"0.5697785",
"0.56814563",
"0.56812817",
"0.5646751",
"0.5629472",
"0.5623733",
"0.5613848",
"0.5612298",
"0.56044704",... | 0.65872544 | 0 |
Plot the band structure of an infinite lead | def plot_bands(self, start: float = -pi, end: float = pi, step: float = 0.05, **kwargs) -> None:
bands = self.calc_bands(start, end, step)
bands.plot(**kwargs)
plt.title("lead {}".format(self.index)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def band_plot(N=400,a=1.0):\n foot_step=2*np.pi/N\n x=np.arange(0.0,2*np.pi/a,foot_step)\n y=band_energy(x)\n plt.plot(x,y)",
"def DrawBands(self, count):\n value = self.little[0]\n mobile_average = float(sum([float(self.little[i])\n for i in range(len(self.little))])) / floa... | [
"0.66511804",
"0.64478564",
"0.61882246",
"0.60987866",
"0.6028533",
"0.59789073",
"0.5939781",
"0.5918501",
"0.5852052",
"0.58147776",
"0.5804578",
"0.5693301",
"0.5680562",
"0.5675579",
"0.567436",
"0.56429476",
"0.5581434",
"0.5549642",
"0.5546036",
"0.5541444",
"0.5512552... | 0.67208236 | 0 |
Save response and redirect to next question or thanks when done | def handle_answer():
choice = request.form['answer']
text = request.form.get("text", "")
# add this response to the list in the session
responses = session[RESPONSES_KEY]
responses.append({"choice": choice, "text": text})
# add this response to the session
session[RESPONSES_KEY] = response... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_question():\n # responses variable will go on to store all of the user's answers to the questions\n session[ANSWERS_KEY] = []\n return redirect(f\"/questions/{len(session[ANSWERS_KEY])}\")",
"def handle_answer():\n \n extracted_answer = request.form.get('answers')\n responses.ap... | [
"0.7377074",
"0.7321153",
"0.72295934",
"0.72033834",
"0.69435203",
"0.6750071",
"0.6735021",
"0.67152864",
"0.658852",
"0.6523324",
"0.6363237",
"0.6334974",
"0.6329038",
"0.6250559",
"0.62394965",
"0.6238538",
"0.6195629",
"0.6136314",
"0.612431",
"0.60994416",
"0.6094137",... | 0.7651496 | 0 |
Return True if the interval [start, end] does not overlap with any region in the skip list. | def isValid(self, start, end):
for s in self.skip:
if start <= s[0] <= end or start <= s[1] <= end:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def does_overlap(self, start, stop):\n\n ranges = [list(range(key, self.map[key] + 1)) for key in self.map]\n all_coords = [item for sublist in ranges for item in sublist]\n # removing all_coords implementation until we write some tests\n for i in range(start, stop + 1):\n if... | [
"0.7434765",
"0.7223908",
"0.69054854",
"0.68777937",
"0.6707784",
"0.66524976",
"0.64958876",
"0.64859533",
"0.64682317",
"0.63680816",
"0.6349625",
"0.63234466",
"0.6302115",
"0.62551606",
"0.62365174",
"0.62196153",
"0.62146914",
"0.6151166",
"0.6150224",
"0.61310005",
"0.... | 0.75347215 | 0 |
Returns a tuple containing the start positions of two mates in a read pair. The positions are produced by selecting a start position at random, and adding to it a random insert size, having mean insertSize and standard deviation insertStdev. | def genInsertPosition(self):
insize = np.random.normal(self.insertSize, self.insertStdev)
while True:
start = random.randint(self.fpstart, self.fpend)
end = start + insize
if end < self.fpend and self.isValid(start, end):
return (start, end - self.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRandomCoordinates( self, size ):\n if not self.mIsLoaded: self.__loadIndex()\n\n token = random.choice( self.mIndex.keys() ) \n strand = random.choice( (\"+\", \"-\") )\n pos_id, pos_seq, lcontig = self.mIndex[token][:3]\n rpos = random.randint( 0, lcontig )\n ... | [
"0.5988597",
"0.59602445",
"0.5950955",
"0.5834952",
"0.5787519",
"0.57752746",
"0.57375985",
"0.5677156",
"0.5668214",
"0.5666423",
"0.56609106",
"0.56546366",
"0.5638042",
"0.56298256",
"0.56073266",
"0.56041735",
"0.5542233",
"0.55215186",
"0.5492197",
"0.5475261",
"0.5467... | 0.67196673 | 0 |
Return a read starting at `pos' with the length contained in the `readlen' attribute, with the base qualities specified in `probs'. If the read would overlap a header line, return False. | def getOneRead(self, pos, probs):
if not self.isValid(pos, pos + self.readlen):
return False
bases = []
f = self.stream
f.seek(pos)
n = 0
while True:
b = f.read(1)
if b == '>':
return False
if b not in "ACGTN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeOneRead(self, pos, probs, out):\n if not self.isValid(pos, pos + self.readlen):\n return False\n f = self.stream\n f.seek(pos)\n n = 0\n while True:\n b = f.read(1)\n if b not in \"ACGTNXacgtnx\":\n continue\n if... | [
"0.57073915",
"0.55153537",
"0.5060607",
"0.4848363",
"0.48103166",
"0.47505322",
"0.4749512",
"0.47271252",
"0.46359605",
"0.46293926",
"0.4597865",
"0.4596303",
"0.45541385",
"0.4539164",
"0.45315552",
"0.45100403",
"0.45100108",
"0.44856367",
"0.448304",
"0.44561794",
"0.4... | 0.6515178 | 0 |
Like getOneRead, but writes the sequence to stream `out' instead of returning it. If the read would overlap a header line, return False without writing anything. | def writeOneRead(self, pos, probs, out):
if not self.isValid(pos, pos + self.readlen):
return False
f = self.stream
f.seek(pos)
n = 0
while True:
b = f.read(1)
if b not in "ACGTNXacgtnx":
continue
if random.random() ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_single_end(self, reads):\n if len([read for read in reads if read.get(\"IsIndexedRead\",\"N\") == \"N\"]) == 1:\n return True\n return False",
"def is_first_read(flag):\n IS_FIRST_SEGMENT = 0x40\n return (int(flag) & IS_FIRST_SEGMENT) != 0",
"def lookup_sync(self, flag=0)... | [
"0.54492384",
"0.5370275",
"0.5135002",
"0.5129447",
"0.5108733",
"0.5068222",
"0.5045536",
"0.5004825",
"0.49932212",
"0.4987386",
"0.49309695",
"0.48679584",
"0.48513126",
"0.48447204",
"0.4844478",
"0.48289055",
"0.4799689",
"0.47929904",
"0.47920433",
"0.47609288",
"0.475... | 0.62499744 | 0 |
Return the sequence of a read starting at position `s' using quality scores `q' from stream `f'. | def getOneRead(self, f, q, s):
probs = np.power(10, q / -10)
bases = []
f.seek(s)
n = 0
while True:
b = f.read(1)
if b == "\n":
continue
if random.random() < probs[n]:
b = random.choice('ACGT')
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readfq(fp): # this is a generator function\n last = None # this is a buffer keeping the last unprocessed line\n while True: # mimic closure; is it a bad idea?\n if not last: # the first record or a record following a fastq\n for l in fp: # search for the start of the next record\n ... | [
"0.6454674",
"0.63423574",
"0.6075785",
"0.5916024",
"0.5780577",
"0.5768713",
"0.5536341",
"0.5424657",
"0.53865683",
"0.538002",
"0.5313396",
"0.53032666",
"0.5296372",
"0.52853894",
"0.5264895",
"0.5221116",
"0.52116334",
"0.51880556",
"0.5100524",
"0.5074263",
"0.50645083... | 0.64760786 | 0 |
Returns a list of quality values sampling from the qavgs and qstdevs distribution. | def genQuality(self):
return np.clip(np.random.normal(self.qavgs, self.qstdevs), 0, 40) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def samples(self):\n if self._samples:\n return self._samples\n if SAMPLE_DF_KEY not in self or self[SAMPLE_DF_KEY] is None:\n _LOGGER.debug(\"No samples are defined\")\n return []",
"def get_parameters_affecting_quality(self, quality: str) -> List[str]:\n re... | [
"0.5885404",
"0.580384",
"0.56202406",
"0.5590326",
"0.5522683",
"0.5520481",
"0.55016017",
"0.5484402",
"0.5439344",
"0.5426934",
"0.540806",
"0.540806",
"0.54041284",
"0.54027855",
"0.5381106",
"0.5370229",
"0.5364764",
"0.53576636",
"0.53525275",
"0.5342002",
"0.53403366",... | 0.6887802 | 0 |
Hook in to application startup and start background NmapPingTask. | def postStartup(self):
daemon = component.getUtility(interfaces.ICollector)
task = NmapPingTask(
"NmapPingTask", "NmapPingTask", taskConfig=daemon._prefs
)
# introduce a small delay to can have a chance to load some config
task.startDelay = 5
daemon._scheduler... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_start(self):\n self.run_in_background(self.__run_client)",
"def start(self):\n self._logger.debug(\"%s: request to start pinger\",\n self.ping_address)\n self.stop()\n self._task = asyncio.ensure_future(self._pinger(), loop=self._loop)",
"def on_star... | [
"0.63465035",
"0.6073031",
"0.60578746",
"0.59798384",
"0.5913347",
"0.5913347",
"0.5913347",
"0.5913347",
"0.5913347",
"0.5913347",
"0.5913347",
"0.5913347",
"0.59071606",
"0.5884065",
"0.58758944",
"0.5852766",
"0.58509463",
"0.58503497",
"0.5830008",
"0.5796353",
"0.577830... | 0.8040481 | 0 |
Detect whether the Ping Cycle Time is too short. | def _detectCycleInterval(self):
cycleInterval = self._daemon._prefs.pingCycleInterval
minCycleInterval = MIN_PING_TIMEOUT + MAX_NMAP_OVERHEAD
newValue = cycleInterval >= minCycleInterval
if self._cycleIntervalReasonable != newValue:
self._cycleIntervalReasonable = newValue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _exceeds_hop_latency(self,ping_time):\n # remote ' ms' from ping time\n ping_as_float = float(ping_time.replace(\" ms\",\"\"))\n\tprint \"Compare {0} to {1}\".format(ping_as_float, self.LATENCY_THRESHOLD)\n\n return ping_as_float >= self.LATENCY_THRESHOLD",
"def check_time():\n times ... | [
"0.7162169",
"0.6673382",
"0.65730745",
"0.6475383",
"0.64306843",
"0.6398188",
"0.6313421",
"0.6286024",
"0.62831277",
"0.61869854",
"0.6170411",
"0.6166333",
"0.60736674",
"0.6058907",
"0.60438025",
"0.6022601",
"0.60170096",
"0.60063773",
"0.60038066",
"0.60017705",
"0.599... | 0.6818477 | 1 |
Send/Clear event to show that ping cycle time is short/fine. | def _sendShortCycleInterval(self, cycleInterval):
if self._cycleIntervalReasonable:
msg = "ping cycle time (%.1f seconds) is fine" % cycleInterval
severity = _CLEAR
else:
minimum = MIN_PING_TIMEOUT + MAX_NMAP_OVERHEAD
msg = (
"ping cycle ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def ping(self, ctx):\n start = time.time()\n msg = await ctx.send(embed=\n discord.Embed(\n title=\"**Pong!**\",\n colour=discord.Color.green(),\n description=\"Pinging...\"\n ... | [
"0.6756339",
"0.6682347",
"0.66572905",
"0.6634368",
"0.6632559",
"0.662904",
"0.6613886",
"0.6611981",
"0.6609368",
"0.6565207",
"0.65384394",
"0.648648",
"0.6478771",
"0.64708966",
"0.6428788",
"0.64074665",
"0.6401151",
"0.6391863",
"0.6389115",
"0.636785",
"0.6364683",
... | 0.7109918 | 0 |
Send/Clear event to show that correlation is executed properly. | def _correlationExecution(self, ex=None):
if ex is None:
msg = "correlation executed correctly"
severity = _CLEAR
else:
msg = "correlation did not execute correctly: %s" % ex
severity = _CRITICAL
evt = dict(
device=self.collectorName,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acknowledged(self):\n ...",
"def on_response(self, ch, method, props, body):\n if self.corr_id == props.correlation_id:\n self.response = body",
"def corr(self):\n pass",
"def _set_correlations(self) -> None:\n pass",
"def __timer_event(self, event):\n self... | [
"0.61915857",
"0.6143062",
"0.61174214",
"0.6090135",
"0.5885771",
"0.5878563",
"0.5741486",
"0.56712615",
"0.5606218",
"0.5476562",
"0.54708314",
"0.5470178",
"0.54279435",
"0.5422348",
"0.5422348",
"0.5417193",
"0.53912276",
"0.5373222",
"0.53426033",
"0.5299313",
"0.528487... | 0.71676165 | 0 |
Send/Clear event to show that nmap is executed properly. | def _nmapExecution(self, ex=None):
if ex is None:
msg = "nmap executed correctly"
severity = _CLEAR
else:
msg = "nmap did not execute correctly: %s" % ex
severity = _CRITICAL
evt = dict(
device=self.collectorName,
eventClass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_cb(self, msg):\n self.map = Map(msg, dilate=5)\n if VERBOSE:\n rospy.loginfo(\"Map received! Origin: \" + str(msg.info.origin))",
"def do_nmap__Auxilary(self, param):\n if self.which(\"nmap\"):\n self.do_shell(\"nmap \" + param)",
"def address_mapped_event(sel... | [
"0.6076413",
"0.60371435",
"0.5883904",
"0.58613986",
"0.5440963",
"0.54270107",
"0.54088324",
"0.5406641",
"0.53981125",
"0.5395532",
"0.53375036",
"0.53336084",
"0.5309096",
"0.5281287",
"0.5242296",
"0.52364504",
"0.52032447",
"0.5127933",
"0.5124582",
"0.51173687",
"0.509... | 0.7199875 | 0 |
Iterate the daemons task list and find PingTask tasks that are IPV4. | def _getPingTasks(self):
tasks = self._daemon._scheduler._tasks
pingTasks = {}
for configName, task in tasks.iteritems():
if isinstance(task.task, PingTask):
if task.task.config.ipVersion == 4:
pingTasks[configName] = task.task
return pingT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_hosts():\n task_run(\"/bin/hostname -f\",RING_1_dev__allnodes)",
"def pingMany(self, ipList):\n results = yield executeNmapForIps(sorted(ipList))\n self.log.info(\"Found %s addresses\", len(results))\n if self.log.isEnabledFor(logging.DEBUG):\n self.log.debug(\n ... | [
"0.6179824",
"0.6031999",
"0.5868787",
"0.58304566",
"0.5507003",
"0.5498833",
"0.545695",
"0.5452734",
"0.5425952",
"0.54163104",
"0.5371902",
"0.5334249",
"0.5294592",
"0.52945757",
"0.52848583",
"0.5277899",
"0.5275892",
"0.526688",
"0.52499354",
"0.5246008",
"0.52358633",... | 0.68449944 | 0 |
Clear out old down counts so process memory utilization doesn't grow. | def _cleanupDownCounts(self):
now = datetime.now()
timeout = timedelta(minutes=DOWN_COUNT_TIMEOUT_MINUTES)
for taskName, (down_count, last_time) in self._down_counts.iteritems():
if now - last_time > timeout:
del self._down_counts[taskName] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()",
"def stats_reset(self):\n self.stats.reset()",
"def stats_reset(self):\n self.stats.reset()",
"def resetCounters(self):\n self.chain.zero_counters()\n counters = self.s... | [
"0.66692394",
"0.6468958",
"0.6468958",
"0.64442396",
"0.64247274",
"0.6397391",
"0.6387521",
"0.63292354",
"0.6271622",
"0.62635636",
"0.625734",
"0.62529767",
"0.62223554",
"0.6208025",
"0.62053263",
"0.62046486",
"0.62046486",
"0.62046486",
"0.6183287",
"0.6166497",
"0.615... | 0.703562 | 0 |
The currentlyrunning event loop, if one exists. | def current_event_loop(self):
loop = current_loop.get()
if loop is None:
loop = super().get_event_loop()
return loop | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_event_loop():\n try:\n return asyncio.get_running_loop()\n except RuntimeError:\n return asyncio.new_event_loop()",
"def getLoop():\n return asyncio.get_event_loop_policy().get_event_loop()",
"def get_event_loop(self):\n try:\n task = trio.lowlevel.current_task(... | [
"0.7723177",
"0.75770026",
"0.7485644",
"0.70032215",
"0.68456113",
"0.67435944",
"0.6675096",
"0.64809227",
"0.6377319",
"0.6373083",
"0.63486046",
"0.6326653",
"0.62989074",
"0.6260146",
"0.6214039",
"0.61226684",
"0.60561204",
"0.6007589",
"0.5903972",
"0.5897526",
"0.5889... | 0.8508764 | 0 |
Set the current event loop. | def set_event_loop(self, loop):
if _in_trio_context():
current_loop.set(loop)
elif _faked_policy.policy is not None:
_faked_policy.policy.set_event_loop(loop)
else:
super().set_event_loop(loop) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_event_loop(self):\n loop = current_loop.get()\n if loop is None:\n loop = super().get_event_loop()\n return loop",
"def __init__(self, loop=None):\n object.__setattr__(self, '_loop', loop or get_event_loop())",
"def event_loop(self):\n logging.warning('loop... | [
"0.66105914",
"0.6508577",
"0.6366844",
"0.63097066",
"0.628712",
"0.6116527",
"0.6116527",
"0.6116527",
"0.6116527",
"0.6111462",
"0.59851605",
"0.59842205",
"0.5894794",
"0.5893572",
"0.57664776",
"0.5733221",
"0.57316995",
"0.57202154",
"0.56887686",
"0.5618949",
"0.555068... | 0.7112107 | 0 |
Add a callback to run when a child process terminates. | def add_child_handler(self, pid, callback, *args):
h = self._loop.trio_as_future(self._waitpid, pid, callback, *args)
self._callbacks[pid] = h | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_close(self, callback):\n self._close_callback = callback",
"def shutdown_callback():\n pass",
"def set_close_callback( callback ):",
"def set_exit_callback(self: Self, func: Callable[[Self], None]) -> None:\n # XXX should this be a property instead?\n assert not inspect.iscorou... | [
"0.6766719",
"0.66032535",
"0.65404296",
"0.6505321",
"0.6328872",
"0.624823",
"0.6140321",
"0.60114604",
"0.60114604",
"0.60041755",
"0.5905687",
"0.58477104",
"0.58365023",
"0.5831817",
"0.58230436",
"0.58230436",
"0.58206904",
"0.58144957",
"0.580842",
"0.5779761",
"0.5763... | 0.6618512 | 1 |
Return number of threads for a running PID | def get_pid_threads_count(pid):
process = psutil.Process(pid)
assert process.is_running(), 'PID %d is not running' % pid
threads_count = process.num_threads()
return threads_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getThreads():\r\n return multiprocessing.cpu_count()",
"def getThreads():\n if sys.platform == 'win32':\n return int(os.environ['NUMBER_OF_PROCESSORS'])\n else:\n return int(os.popen('grep -c cores /proc/cpuinfo').read())",
"def getNumThreads(cls) -> int:\n return cls.NUMTHREA... | [
"0.7690271",
"0.76181304",
"0.7551392",
"0.73519766",
"0.7266163",
"0.7219404",
"0.7217407",
"0.71540976",
"0.71363544",
"0.7090084",
"0.7077626",
"0.7074354",
"0.70573896",
"0.7002955",
"0.7001179",
"0.6996043",
"0.6958745",
"0.69556826",
"0.69513303",
"0.69494325",
"0.69449... | 0.807942 | 0 |
Assert that we can determine whether a dict does not contain a key. | def testDictDoesNotContain(self):
self.Check("""
d1 = {"x": 42}
if "x" not in d1:
print d1["nonsense"] # Dead code
else:
print d1["x"]
d2 = {}
if "x" not in d2:
pass
else:
print d2["nonsense"] # Dead code
d3 = {__any_object__: __any_objec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dictionary_should_not_contain_key(self,dictionary,key,msg=None):\r\n default = \"Dictionary contains key '%s'\" %key\r\n _verify_condition(not dictionary.has_key(key),default,msg)",
"def test_remove_key_not_found(self):\n\n expected = {\n \"Hello\": \"world\",\n \"W... | [
"0.81113243",
"0.7270285",
"0.7054258",
"0.7022218",
"0.6932946",
"0.69100094",
"0.6858473",
"0.6853848",
"0.67975736",
"0.6752067",
"0.67427343",
"0.6726948",
"0.67186964",
"0.6715598",
"0.65655386",
"0.6539576",
"0.653925",
"0.65203315",
"0.64888024",
"0.6468318",
"0.633836... | 0.767277 | 1 |
Decorator that clears context values when objects or attributes are modified. | def objects_attributes_change(f):
def _f(*args):
clear_cxt_vars(args[0])
f(*args)
return _f | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalidate(self, context):\n self.dictionary = None",
"def clean(_context):",
"def keep_attributes(context, *attributes):\n attr_to_value = preserve_attributes(context, attributes)\n yield\n restore_attributes(context, attr_to_value)",
"def keep_request_data(context):\n attr_to_value =... | [
"0.659579",
"0.6377247",
"0.63353455",
"0.6282862",
"0.6166172",
"0.60900927",
"0.60400164",
"0.6011574",
"0.6009515",
"0.59849083",
"0.5958491",
"0.58819735",
"0.58578616",
"0.5849856",
"0.5849856",
"0.5849856",
"0.5849856",
"0.576469",
"0.573563",
"0.57189983",
"0.5696667",... | 0.70711803 | 0 |
Create a context from cross table and list of objects, list of attributes cross_table the list of bool lists objects the list of objects attributes the list of attributes | def __init__(self, cross_table=None, objects=None, attributes=None):
# if not (isinstance(cross_table, list) and
# all(isinstance(i, list) for i in cross_table)):
# try:
# cross_table = [list(i) for i in cross_table]
# except:
# raise NotTa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transpose(self):\n new_objects = self.attributes[:]\n new_attributes = self.objects[:]\n new_cross_table = []\n for j in range(len(self.attributes)):\n line = []\n for i in range(len(self.objects)):\n line.append(self.table[i][j])\n ne... | [
"0.6420432",
"0.62756455",
"0.58896726",
"0.57891214",
"0.55413866",
"0.5389268",
"0.53224635",
"0.5273347",
"0.5262823",
"0.49912634",
"0.49382988",
"0.49220228",
"0.4912022",
"0.49018574",
"0.4884419",
"0.4881911",
"0.48671058",
"0.48665777",
"0.47704384",
"0.47696188",
"0.... | 0.65482605 | 0 |
Return a set of corresponding attributes for row with index i. | def get_object_intent_by_index(self, i):
obj_row = self.np_table[i, :]
att_inds = obj_row.nonzero()[0]
atts = [self.attributes[j] for j in att_inds]
return set(atts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr(self, index):\n return self.row[0, index]",
"def iter_attributes(self):\n return iteritems(self.schema)",
"def get_attribute_extent_by_index(self, j):\n att_col = self.np_table[:, j]\n obj_inds = att_col.nonzero()[0]\n objs = [self.objects[j] for j in obj_inds]\n ... | [
"0.62024844",
"0.5906992",
"0.58736366",
"0.57972324",
"0.5740616",
"0.573088",
"0.5686372",
"0.5554735",
"0.55490464",
"0.5513947",
"0.5484823",
"0.5460635",
"0.5427901",
"0.5394885",
"0.5335074",
"0.5317278",
"0.5288471",
"0.52869004",
"0.52812207",
"0.5275876",
"0.5255269"... | 0.7309502 | 0 |
Compute the set of all attributes shared by given objects. Objects are specified by indices. | def oprime_inds(self, obj_inds):
if type(obj_inds) == set:
obj_inds = list(obj_inds)
try:
common_intent = self.np_table[obj_inds[0], :].copy()
except IndexError:
return set(range(len(self.attributes)))
else:
for obj_ind in obj_inds[1:]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object_intent_by_index(self, i):\n obj_row = self.np_table[i, :]\n att_inds = obj_row.nonzero()[0]\n atts = [self.attributes[j] for j in att_inds]\n return set(atts)",
"def partial_align(*objects, **kwargs):\n join = kwargs.pop('join', 'inner')\n copy = kwargs.pop('copy'... | [
"0.588733",
"0.55038106",
"0.5487051",
"0.53599745",
"0.53599745",
"0.53055453",
"0.5282523",
"0.52661836",
"0.5225572",
"0.5225572",
"0.5223952",
"0.5203928",
"0.51347214",
"0.5112523",
"0.50871557",
"0.50589556",
"0.50493234",
"0.50442564",
"0.5041548",
"0.50312746",
"0.502... | 0.61166066 | 0 |
Return new context with transposed crosstable | def transpose(self):
new_objects = self.attributes[:]
new_attributes = self.objects[:]
new_cross_table = []
for j in range(len(self.attributes)):
line = []
for i in range(len(self.objects)):
line.append(self.table[i][j])
new_cross_table... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crosstab(self, x, y=[], w=None, f=None, ci='counts', base='auto', stats=False,\n sig_level=None, rules=False, decimals=1, xtotal=False,\n painted=True, text_key=None):\n def _rounding(x, dec):\n try:\n return np.round(x, decimals=dec)\n ... | [
"0.55264497",
"0.54790974",
"0.53508955",
"0.5332192",
"0.53310543",
"0.5275063",
"0.5258353",
"0.5240064",
"0.52142644",
"0.51650935",
"0.507828",
"0.49838346",
"0.4972646",
"0.4959765",
"0.4957016",
"0.494776",
"0.49308422",
"0.49294916",
"0.49254048",
"0.49244452",
"0.4910... | 0.7405647 | 0 |
Create a subcontext with such objects that have given attributes | def extract_subcontext_filtered_by_attributes(self, attributes_names,
mode="and"):
values = dict( [(attribute, True) for attribute in attributes_names] )
object_names, subtable = \
self._extract_subtable_by_attribute_values(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_subcontext(self, attribute_names):\n return Context(self._extract_subtable(attribute_names),\n self.objects,\n attribute_names)",
"def _createContext(instance, args, kwargs, settings):\n context = kwargs.copy()\n args = list(args)\n context.... | [
"0.6639891",
"0.61329204",
"0.60786223",
"0.5814791",
"0.5736604",
"0.5519445",
"0.5488261",
"0.5481172",
"0.5458826",
"0.5431118",
"0.54173887",
"0.54173887",
"0.54173887",
"0.54173887",
"0.54173887",
"0.54173887",
"0.54009163",
"0.53864425",
"0.53735554",
"0.53639424",
"0.5... | 0.6591381 | 1 |
Create a subcontext with only indicated attributes | def extract_subcontext(self, attribute_names):
return Context(self._extract_subtable(attribute_names),
self.objects,
attribute_names) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_subcontext_filtered_by_attributes(self, attributes_names,\n mode=\"and\"):\n values = dict( [(attribute, True) for attribute in attributes_names] )\n object_names, subtable = \\\n self._extract_subtable_by_attri... | [
"0.6352824",
"0.61252177",
"0.59263754",
"0.59086",
"0.5668162",
"0.5635775",
"0.5630362",
"0.5616696",
"0.559728",
"0.5584677",
"0.55576473",
"0.55489206",
"0.5496291",
"0.5392509",
"0.53736514",
"0.53543055",
"0.5328164",
"0.5325613",
"0.52986324",
"0.5296754",
"0.5292805",... | 0.65030646 | 0 |
Extract a subtable containing only rows that satisfy the condition. Return a list of object names and a subtable. | def _extract_subtable_by_condition(self, condition):
indices = [i for i in range(len(self)) if condition(i)]
return ([self.objects[i] for i in indices],
[self.table[i] for i in indices]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtable(self):\n return self._subtable",
"def _extract_subtable_by_attribute_values(self, values, \n mode=\"and\"):\n self._check_attribute_names(list(values.keys()))\n if mode == \"and\":\n indices = [i for i in range(len(self))... | [
"0.6559272",
"0.6510114",
"0.5544194",
"0.5477949",
"0.53826314",
"0.52908766",
"0.5278037",
"0.52699465",
"0.52350736",
"0.52335566",
"0.5231618",
"0.52294695",
"0.5219934",
"0.52114856",
"0.5207663",
"0.5198288",
"0.51861113",
"0.517153",
"0.51542264",
"0.5143596",
"0.51411... | 0.82139236 | 0 |
Extract a subtable containing only rows with certain column values. Return a list of object names and a subtable. | def _extract_subtable_by_attribute_values(self, values,
mode="and"):
self._check_attribute_names(list(values.keys()))
if mode == "and":
indices = [i for i in range(len(self)) if self._has_values(i, values)]
elif mode == "or":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_subtable_by_condition(self, condition):\n indices = [i for i in range(len(self)) if condition(i)]\n return ([self.objects[i] for i in indices],\n [self.table[i] for i in indices])",
"def subtable(self):\n return self._subtable",
"def get_subtable(df, col, val) -> pd... | [
"0.69696",
"0.62196416",
"0.6045123",
"0.57857233",
"0.5705896",
"0.5616721",
"0.5520197",
"0.54634094",
"0.5274531",
"0.522673",
"0.5220967",
"0.52097815",
"0.5191158",
"0.5120592",
"0.5120265",
"0.5107816",
"0.50978726",
"0.5091551",
"0.5087479",
"0.50757533",
"0.5070154",
... | 0.6358995 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.