query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
test get all accessible by hash as superuser returns global template | def test_get_all_accessible_by_hash_as_superuser_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash(
self.fixture.global_template.hash, request=mock_request
)
self.assertTr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n ... | [
"0.7841484",
"0.779551",
"0.7761922",
"0.76789105",
"0.7675325",
"0.75503117",
"0.75284576",
"0.75161767",
"0.7387159",
"0.73823154",
"0.73564553",
"0.73227084",
"0.72829455",
"0.716237",
"0.7129225",
"0.7032054",
"0.69710624",
"0.6944363",
"0.68697715",
"0.68558455",
"0.6848... | 0.80500853 | 0 |
test get all accessible by hash list as anonymous with access right does not return user template | def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_does_not_return_user_template(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n se... | [
"0.82188314",
"0.81064343",
"0.80074686",
"0.7999916",
"0.7974573",
"0.794547",
"0.7922802",
"0.7900087",
"0.7856008",
"0.7839907",
"0.7780824",
"0.77454853",
"0.7712532",
"0.76505816",
"0.76493615",
"0.76412743",
"0.75517875",
"0.7539482",
"0.7521282",
"0.7480579",
"0.743073... | 0.81870437 | 1 |
test get all accessible by hash list as anonymous does not return global | def test_get_all_accessible_by_hash_list_as_anonymous_does_not_return_global(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_requ... | [
"0.72003764",
"0.6906085",
"0.682766",
"0.6713539",
"0.6642761",
"0.6638915",
"0.6523141",
"0.6474281",
"0.6390187",
"0.6310114",
"0.6268782",
"0.6232631",
"0.6226728",
"0.6178704",
"0.6056042",
"0.60132897",
"0.6012866",
"0.5999089",
"0.5983888",
"0.59816855",
"0.5979013",
... | 0.70168906 | 1 |
test get all accessible by hash list as anonymous with access right returns global | def test_get_all_accessible_by_hash_list_as_anonymous_with_access_right_returns_global(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_as_anonymous_with_access_right_returns_global(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n templates = template_api.get_all_accessible_by_hash(\n self.fixture.global_template.hash, request=mock_request\n ... | [
"0.72204554",
"0.6992188",
"0.69133",
"0.67211556",
"0.6717264",
"0.66367173",
"0.6608304",
"0.6528222",
"0.6494193",
"0.6466781",
"0.63778913",
"0.634835",
"0.6266997",
"0.6256954",
"0.6207588",
"0.6187965",
"0.6110008",
"0.6073582",
"0.6053851",
"0.60277724",
"0.5977818",
... | 0.7492252 | 0 |
test get all accessible by hash list as user returns user template | def test_get_all_accessible_by_hash_list_as_user_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.assertTru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n... | [
"0.8133613",
"0.8025096",
"0.79555947",
"0.7924744",
"0.77753305",
"0.77026737",
"0.75754946",
"0.7567176",
"0.7559033",
"0.75048995",
"0.7476242",
"0.7378073",
"0.73105985",
"0.73017",
"0.72951525",
"0.72721916",
"0.7231697",
"0.7122126",
"0.70607495",
"0.7040041",
"0.702032... | 0.8334091 | 0 |
test get all accessible by hash list as user returns global template | def test_get_all_accessible_by_hash_list_as_user_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self.assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n ... | [
"0.7817108",
"0.7674833",
"0.76448846",
"0.7635715",
"0.76171523",
"0.7548915",
"0.7494546",
"0.74614096",
"0.7423985",
"0.7415341",
"0.7338782",
"0.7198786",
"0.7194994",
"0.7095257",
"0.7054384",
"0.7039704",
"0.70117605",
"0.6924233",
"0.69152415",
"0.68132144",
"0.6760775... | 0.792674 | 0 |
test get all accessible by hash list as staff returns user template | def test_get_all_accessible_by_hash_list_as_staff_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n se... | [
"0.81351954",
"0.8133138",
"0.8092263",
"0.78858453",
"0.7810828",
"0.7779971",
"0.7641144",
"0.7626335",
"0.7617192",
"0.76108444",
"0.74905986",
"0.74905354",
"0.747804",
"0.7434959",
"0.7407873",
"0.732234",
"0.7317942",
"0.7250191",
"0.71803576",
"0.7138569",
"0.70978194"... | 0.83508813 | 0 |
test get all accessible by hash list as staff returns global template | def test_get_all_accessible_by_hash_list_as_staff_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.superuser1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n ... | [
"0.7654985",
"0.7619861",
"0.7532686",
"0.75176096",
"0.7428983",
"0.7404091",
"0.7361139",
"0.7338509",
"0.7328727",
"0.7255129",
"0.72190326",
"0.71115243",
"0.69764596",
"0.69752246",
"0.6954954",
"0.69451195",
"0.6886439",
"0.68627393",
"0.6745489",
"0.67304397",
"0.66975... | 0.78305656 | 0 |
test get all accessible by hash list as superuser returns user template | def test_get_all_accessible_by_hash_list_as_superuser_returns_user_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.user1_template.hash], request=mock_request
)
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_user_returns_user_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.user1_template.hash], request=mock_request\n )\n se... | [
"0.8227565",
"0.8194535",
"0.8007385",
"0.7911953",
"0.78929853",
"0.78840536",
"0.7775287",
"0.7738975",
"0.7630923",
"0.76105887",
"0.758177",
"0.75368434",
"0.7483725",
"0.7452379",
"0.7292541",
"0.72641546",
"0.7235065",
"0.7176262",
"0.71578574",
"0.71336734",
"0.7131445... | 0.84037524 | 0 |
test get all accessible by hash list as superuser returns global template | def test_get_all_accessible_by_hash_list_as_superuser_returns_global_template(
self,
):
mock_request = create_mock_request(user=self.superuser1)
templates = template_api.get_all_accessible_by_hash_list(
[self.fixture.global_template.hash], request=mock_request
)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_accessible_by_hash_list_as_user_returns_global_template(\n self,\n ):\n mock_request = create_mock_request(user=self.user1)\n templates = template_api.get_all_accessible_by_hash_list(\n [self.fixture.global_template.hash], request=mock_request\n )\n ... | [
"0.79852265",
"0.79441637",
"0.79198414",
"0.7865991",
"0.77729464",
"0.77234817",
"0.7679411",
"0.76214916",
"0.7617738",
"0.7583023",
"0.754689",
"0.7470992",
"0.7443684",
"0.72886294",
"0.7275211",
"0.72666967",
"0.7181501",
"0.7174229",
"0.7105018",
"0.6970292",
"0.694222... | 0.81317466 | 0 |
test get all as anonymous with access right returns global templates | def test_get_all_as_anonymous_with_access_right_returns_global_templates(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 1)
self.assertTrue((template.user is None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def T(request):\n\treturn all_templates[request.param]",
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTr... | [
"0.71963495",
"0.69589484",
"0.695767",
"0.6738414",
"0.6680882",
"0.6666209",
"0.6632277",
"0.66269696",
"0.6591374",
"0.65500444",
"0.65330005",
"0.64813143",
"0.6450166",
"0.6417387",
"0.6408952",
"0.64055634",
"0.63884926",
"0.6387879",
"0.6307593",
"0.62807924",
"0.62755... | 0.7641047 | 0 |
test get all as user returns accessible templates | def test_get_all_as_user_returns_accessible_templates(self):
mock_request = create_mock_request(user=self.user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 2)
self.assertTrue(self.fixture.user1_template in list(templates))
self.asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_as_superuser_returns_all_templates(self):\n mock_request = create_mock_request(user=self.superuser)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 3)\n self.assertTrue(self.fixture.user1_template in list(templates))\n ... | [
"0.7973463",
"0.7884634",
"0.75864184",
"0.73863786",
"0.7368473",
"0.73545754",
"0.73322153",
"0.73156446",
"0.7303613",
"0.7301676",
"0.71165544",
"0.70814574",
"0.7071253",
"0.7070465",
"0.7058631",
"0.69952977",
"0.6969601",
"0.6948563",
"0.6939556",
"0.6878665",
"0.68417... | 0.8490938 | 0 |
test get all as staff returns accessible templates | def test_get_all_as_staff_returns_accessible_templates(self):
mock_request = create_mock_request(user=self.staff_user)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 2)
self.assertTrue(self.fixture.user2_template in list(templates))
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n ... | [
"0.77078307",
"0.76111203",
"0.7382082",
"0.7332171",
"0.7315884",
"0.73020625",
"0.7169267",
"0.709241",
"0.69971323",
"0.69874364",
"0.69600505",
"0.6950572",
"0.6810104",
"0.6807266",
"0.67712927",
"0.6756902",
"0.6676017",
"0.66577077",
"0.66072726",
"0.65592235",
"0.6539... | 0.8453167 | 0 |
test get all as superuser returns all templates | def test_get_all_as_superuser_returns_all_templates(self):
mock_request = create_mock_request(user=self.superuser)
templates = template_api.get_all(request=mock_request)
self.assertEqual(templates.count(), 3)
self.assertTrue(self.fixture.user1_template in list(templates))
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_as_user_returns_accessible_templates(self):\n mock_request = create_mock_request(user=self.user)\n templates = template_api.get_all(request=mock_request)\n self.assertEqual(templates.count(), 2)\n self.assertTrue(self.fixture.user1_template in list(templates))\n ... | [
"0.80813885",
"0.7807613",
"0.73119265",
"0.7304258",
"0.7133047",
"0.7106707",
"0.7028065",
"0.70258",
"0.6983149",
"0.69324434",
"0.6922331",
"0.69057953",
"0.687215",
"0.6858583",
"0.683814",
"0.6838046",
"0.6819967",
"0.6750605",
"0.67349994",
"0.6714064",
"0.6704779",
... | 0.84164745 | 0 |
test delete user template as anonymous raises access control error | def test_delete_user_template_as_anonymous_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user1_template, request=mock_request
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template,... | [
"0.8109796",
"0.7890928",
"0.785249",
"0.78486097",
"0.7497058",
"0.7439203",
"0.7439203",
"0.7338107",
"0.73019093",
"0.72081596",
"0.71589935",
"0.7156079",
"0.7141743",
"0.71223885",
"0.70870435",
"0.70845276",
"0.70736223",
"0.70583034",
"0.7051745",
"0.7028054",
"0.69838... | 0.8186267 | 0 |
test delete user template as anonymous with access right raises access control error | def test_delete_user_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user1_template, request=mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_user_template_as_anonymous_raises_access_control_error(\n self,\n ):\n mock_request = create_mock_request(user=self.anonymous_user)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.user1_template, request=mock_requ... | [
"0.8130148",
"0.8038917",
"0.7928053",
"0.7784703",
"0.7748895",
"0.7658275",
"0.7418729",
"0.7418729",
"0.7411724",
"0.73322123",
"0.72632694",
"0.72585547",
"0.72350216",
"0.71767664",
"0.714434",
"0.7127663",
"0.7013489",
"0.7002689",
"0.6998825",
"0.6979983",
"0.69761485"... | 0.82500076 | 0 |
test delete global template as anonymous with access right raises access control error | def test_delete_global_template_as_anonymous_with_access_right_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.anonymous_user)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.global_template, request... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_user_raises_access_control_error(self):\n mock_request = create_mock_request(user=self.user1)\n with self.assertRaises(AccessControlError):\n template_api.delete(\n self.fixture.... | [
"0.7957372",
"0.78233325",
"0.7783485",
"0.7648756",
"0.73494995",
"0.724509",
"0.7238044",
"0.7229371",
"0.7146958",
"0.70505244",
"0.694791",
"0.6860597",
"0.6852993",
"0.67819417",
"0.66837376",
"0.66768485",
"0.6628545",
"0.6627234",
"0.6593351",
"0.65602285",
"0.6522194"... | 0.78978837 | 1 |
test delete own template as user saves | def test_delete_own_template_as_user_saves(self):
mock_request = create_mock_request(user=self.user1)
template_api.delete(self.fixture.user1_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.staf... | [
"0.8405559",
"0.7938252",
"0.78544295",
"0.7835479",
"0.76984704",
"0.75773",
"0.75123143",
"0.7462032",
"0.73763233",
"0.7366287",
"0.7339748",
"0.72637725",
"0.72637725",
"0.7095875",
"0.70382494",
"0.6969727",
"0.6962131",
"0.6931763",
"0.6909945",
"0.68845177",
"0.6865710... | 0.8729449 | 0 |
test delete other users template as user raises access control error | def test_delete_other_users_template_as_user_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user2_template, request=mock_request
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(us... | [
"0.8105018",
"0.8104827",
"0.8100035",
"0.8017625",
"0.80126005",
"0.7705949",
"0.7705949",
"0.7640928",
"0.7617843",
"0.7548961",
"0.75398606",
"0.7430284",
"0.73903745",
"0.72945106",
"0.7280149",
"0.72691876",
"0.723362",
"0.720127",
"0.7198595",
"0.71942717",
"0.7187567",... | 0.81878215 | 0 |
test delete global template as user raises access control error | def test_delete_global_template_as_user_raises_access_control_error(self):
mock_request = create_mock_request(user=self.user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.global_template, request=mock_request
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_namespaced_template(self):\n pass",
"def test_delete_global_template_as_anonymou... | [
"0.8058154",
"0.78446215",
"0.7595148",
"0.75532234",
"0.75362784",
"0.753489",
"0.74993956",
"0.7437848",
"0.72980475",
"0.7283631",
"0.726282",
"0.7225051",
"0.7123989",
"0.711558",
"0.7096376",
"0.7071216",
"0.70578927",
"0.70301336",
"0.70142186",
"0.69239014",
"0.6853447... | 0.8217039 | 0 |
test delete own template as staff saves | def test_delete_own_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.delete(self.fixture.user1_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1... | [
"0.8108582",
"0.80523485",
"0.80356413",
"0.7905152",
"0.76571864",
"0.76172143",
"0.7565759",
"0.7552634",
"0.74682933",
"0.74544466",
"0.73570675",
"0.7341402",
"0.7218155",
"0.7113023",
"0.7024291",
"0.7003252",
"0.69519466",
"0.6912048",
"0.69030714",
"0.6814051",
"0.6802... | 0.8403106 | 0 |
test delete other users template as staff raises access control error | def test_delete_other_users_template_as_staff_raises_access_control_error(
self,
):
mock_request = create_mock_request(user=self.staff_user1)
with self.assertRaises(AccessControlError):
template_api.delete(
self.fixture.user2_template, request=mock_request
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_other_users_template_as_superuser_saves(self):\n mock_request = create_mock_request(us... | [
"0.808326",
"0.802726",
"0.7965073",
"0.79332936",
"0.7800406",
"0.7799253",
"0.76195556",
"0.75638926",
"0.75588703",
"0.7483941",
"0.7483941",
"0.73990446",
"0.73645484",
"0.7327109",
"0.72690487",
"0.71860415",
"0.7184741",
"0.7150509",
"0.70893085",
"0.7082953",
"0.706137... | 0.8265562 | 0 |
test delete global template as staff saves | def test_delete_global_template_as_staff_saves(self):
mock_request = create_mock_request(user=self.staff_user1)
template_api.delete(self.fixture.global_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.global_template, request=mock_request)",
"def test_delete_own_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.... | [
"0.8153071",
"0.7786319",
"0.7784371",
"0.7716912",
"0.75208735",
"0.7489113",
"0.7379321",
"0.73716503",
"0.72625434",
"0.72461313",
"0.71758413",
"0.71681505",
"0.71080875",
"0.709806",
"0.7042556",
"0.6959074",
"0.6730459",
"0.67151546",
"0.66676325",
"0.66467226",
"0.6606... | 0.84990233 | 0 |
test delete own template as superuser saves | def test_delete_own_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.user1_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superus... | [
"0.8280397",
"0.8224194",
"0.8060117",
"0.78996503",
"0.75895417",
"0.7520532",
"0.7519773",
"0.75025415",
"0.73786604",
"0.73680294",
"0.721002",
"0.70879525",
"0.702414",
"0.70129967",
"0.7012797",
"0.7012797",
"0.6967623",
"0.6949611",
"0.68701947",
"0.68661785",
"0.679306... | 0.8697194 | 0 |
test delete other users template as superuser saves | def test_delete_other_users_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.user2_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_own_template_as_user_saves(self):\n mock_request = create_mock_request(user=self.user1... | [
"0.8817737",
"0.85475934",
"0.8236777",
"0.7992185",
"0.7491608",
"0.7396679",
"0.7396679",
"0.7336298",
"0.725919",
"0.72099054",
"0.7088548",
"0.7082489",
"0.7050118",
"0.70074046",
"0.69393295",
"0.6897725",
"0.688309",
"0.6881316",
"0.687922",
"0.68716925",
"0.68648237",
... | 0.86611134 | 1 |
test delete global template as superuser saves | def test_delete_global_template_as_superuser_saves(self):
mock_request = create_mock_request(user=self.superuser1)
template_api.delete(self.fixture.global_template, request=mock_request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_own_template_as_superuser_saves(self):\n mock_request = create_mock_request(user=self.superuser1)\n template_api.delete(self.fixture.user1_template, request=mock_request)",
"def test_delete_global_template_as_staff_saves(self):\n mock_request = create_mock_request(user=self.s... | [
"0.8211604",
"0.8005223",
"0.7721632",
"0.771418",
"0.756075",
"0.73948276",
"0.7389841",
"0.7346052",
"0.7268417",
"0.72225857",
"0.7203136",
"0.7147506",
"0.70092875",
"0.69376206",
"0.68497753",
"0.68214715",
"0.670203",
"0.66734916",
"0.66634125",
"0.66634125",
"0.6585964... | 0.8784708 | 0 |
Creates a breakpoint, which is a renamed deep copy of the QuantumCircuit, and creates and appends an AssertUniform instruction to its end. If the statistical test passes, the assertion passes; if the test fails, the assertion fails. | def get_breakpoint_uniform(self, qubit, cbit, pcrit=0.05):
clone = self.copy(Asserts._new_breakpoint_name())
assertion = AssertUniform(qubit, cbit, pcrit, False)
clone.append(assertion, [assertion._qubit], [assertion._cbit])
return clone | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_breakpoint_not_uniform(self, qubit, cbit, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertUniform(qubit, cbit, pcrit, True)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_product(self, qubit0, cbit0, q... | [
"0.615157",
"0.5664515",
"0.5564676",
"0.51173455",
"0.5042951",
"0.49747887",
"0.49527636",
"0.4948408",
"0.48849374",
"0.48534235",
"0.48316854",
"0.48037466",
"0.4722693",
"0.47221145",
"0.4704494",
"0.47041127",
"0.46748686",
"0.4669761",
"0.46511495",
"0.4641877",
"0.463... | 0.6336997 | 0 |
Creates a breakpoint, which is a renamed deep copy of the QuantumCircuit, and creates and appends an AssertUniform instruction to its end. If the statistical test passes, the assertion fails; if the test fails, the assertion passes. | def get_breakpoint_not_uniform(self, qubit, cbit, pcrit=0.05):
clone = self.copy(Asserts._new_breakpoint_name())
assertion = AssertUniform(qubit, cbit, pcrit, True)
clone.append(assertion, [assertion._qubit], [assertion._cbit])
return clone | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_breakpoint_uniform(self, qubit, cbit, pcrit=0.05):\n clone = self.copy(Asserts._new_breakpoint_name())\n assertion = AssertUniform(qubit, cbit, pcrit, False)\n clone.append(assertion, [assertion._qubit], [assertion._cbit])\n return clone",
"def get_breakpoint_product(self, qubit0, cbit0, qubi... | [
"0.6328285",
"0.5668417",
"0.5596492",
"0.5110465",
"0.50538695",
"0.5012597",
"0.49447802",
"0.49177045",
"0.49040687",
"0.48579818",
"0.48148197",
"0.481229",
"0.47325182",
"0.47238013",
"0.47059774",
"0.46966594",
"0.46892297",
"0.46688747",
"0.46467826",
"0.4646354",
"0.4... | 0.6174962 | 1 |
Geotransform the original map and create an inverse geotransform for the raster. | def _get_inv_gt(self):
# Geotransform the original map
self.in_gt = self.in_ds.GetGeoTransform()
# Create an inverse geotransform for the raster.
# This converts real-world coordinates to pixel offsets.
self.inv_gt = gdal.InvGeoTransform(self.in_gt)
if gdal.VersionI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geo_transform(self):\n pass",
"def geotransform(self):\n return self._geotransform",
"def __affine_geo_transformation(x, y, gtr):\n\n # https://gdal.org/user/raster_data_model.html#affine-geotransform\n # Affine transformation rewritten for rasterio:\n gtr_x = gtr[2] + (x... | [
"0.7338185",
"0.65408427",
"0.6371385",
"0.63351965",
"0.63224435",
"0.62674654",
"0.62644494",
"0.62108505",
"0.6176385",
"0.61081815",
"0.6096801",
"0.6054763",
"0.604431",
"0.5978923",
"0.59416425",
"0.5915392",
"0.5910879",
"0.58931345",
"0.58687687",
"0.58653194",
"0.581... | 0.67420596 | 1 |
get clip location in array. | def _get_clip_loc_in_array(self):
# coordinates of upperleft and lowerright points of binding box
box_ulx, box_uly, box_lrx, box_lry = self.clip_box[0][0], self.clip_box[0][1], \
self.clip_box[1][0], self.clip_box[1][1]
# Get the offsets that ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip(self):\r\n\t\treturn self._clip",
"def get_marker_absolute_pos(marker_position, clip):\n marker_x = (marker_position[\"x\"] * clip.w) - marker_image.w / 2\n marker_y = (marker_position[\"y\"] * clip.h) - marker_image.h / 2\n return marker_x, marker_y",
"def location_of(self, index):\n ... | [
"0.62954205",
"0.61157066",
"0.5843126",
"0.5814552",
"0.57981294",
"0.5748439",
"0.5678269",
"0.5570744",
"0.55497",
"0.5545587",
"0.55285585",
"0.55121255",
"0.5457112",
"0.544028",
"0.5431783",
"0.5430645",
"0.54257566",
"0.5412553",
"0.54099363",
"0.5408648",
"0.5408648",... | 0.755718 | 0 |
Unique class is stored as self.unique_class. Total number of classes is stored as self.total_classes_number. Total number of each class is stored in self.class_number_dict. Total number of unique words is stored as self.unique_word_number. Total number of a word in a class is stored in self.class_word_number_dict. otal... | def __init__(self):
self.unique_classes = []
self.total_classes_number = 0
self.class_number_dict = {}
self.unique_word_number = 0
self.class_word_number_dict = {}
self.class_total_words_dict = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classes(self):\n if not hasattr(self, '_unique_classes'):\n # build when we don't have\n self._unique_classes = self.data['label'].unique()\n self._unique_classes.sort()\n\n ret = self._unique_classes\n return ret",
"def calc_class_weights(self):\n ... | [
"0.7139616",
"0.6484298",
"0.645103",
"0.6282322",
"0.6265374",
"0.62360275",
"0.6218017",
"0.61864156",
"0.6164485",
"0.6155118",
"0.6132282",
"0.6087209",
"0.6073724",
"0.6055184",
"0.6008472",
"0.59811527",
"0.59720916",
"0.59651655",
"0.5958494",
"0.59583336",
"0.59582025... | 0.85412234 | 0 |
Updates a testing scenario. | def put(self, id):
data = request.json
update_scenario(id, data)
return None, 204 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_scenario(self):\n pass",
"def test_update(self):\n payload = {\n 'name': 'Pecho inclinado',\n 'description': \"New description\",\n 'muscle_group': \"pecho\"\n }\n response = self.client.put(\n '/exercises/{}/'.format(sel... | [
"0.71119636",
"0.63907033",
"0.6312588",
"0.6248452",
"0.6179395",
"0.61243194",
"0.610072",
"0.60918045",
"0.60918045",
"0.60918045",
"0.60252446",
"0.5980113",
"0.59608054",
"0.5916117",
"0.5899539",
"0.5895658",
"0.58752656",
"0.5818258",
"0.5801083",
"0.57950765",
"0.5793... | 0.66489846 | 1 |
Mix an image by a constant base color. The base color should be a 1by3 arraylike object representing an RGB color in [0, 255]^3 space. For example, to mix with orange, the transformation RGBTransform().mix_with((255, 127, 0)) might be used. The factor controls the strength of the color to be added. If the factor is 1.0... | def mix_with(self, base_color, factor=1.0):
base_color = _to_rgb(base_color, "base_color")
operation = _embed44((1 - factor) * np.eye(3))
operation[:3, 3] = factor * base_color
return self._then(operation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mix(\n self,\n color: ColorInput,\n percent: float = util.DEF_MIX,\n *,\n in_place: bool = False,\n **interpolate_args: Any\n ) -> 'Color':\n\n # Mix really needs to be between 0 and 1 or steps will break\n domain = interpolate_args.get('domain')\n ... | [
"0.63442767",
"0.5894581",
"0.5830767",
"0.5649231",
"0.5571899",
"0.5529526",
"0.5451907",
"0.536669",
"0.53180206",
"0.5242517",
"0.51597506",
"0.5142259",
"0.5101442",
"0.5004268",
"0.49906832",
"0.49472693",
"0.48828548",
"0.4848855",
"0.48302355",
"0.4824658",
"0.4820808... | 0.80262935 | 0 |
Apply this transformation to a copy of the given RGB image. The image should be a PIL image with at least three channels. Specifically, the RGB and RGBA modes are both supported, but L is not. Any channels past the first three will pass through unchanged. The original image will not be modified; a new image of the same... | def applied_to(self, image):
# PIL.Image.convert wants the matrix as a flattened 12-tuple.
# (The docs claim that they want a 16-tuple, but this is wrong;
# cf. _imaging.c:767 in the PIL 1.1.7 source.)
matrix = tuple(self.get_matrix().flatten())
channel_names = image.getbands()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enhance_image(self, img):\n\n blue = self.g.clahe.apply(img[:,:,0])\n green = self.g.clahe.apply(img[:,:,1])\n red = self.g.clahe.apply(img[:,:,2])\n img[:,:,0] = blue\n img[:,:,1] = green\n img[:,:,2] = red\n return img",
"def colorize(image, newColor):\n ... | [
"0.61241204",
"0.59882116",
"0.59521466",
"0.5738032",
"0.5636173",
"0.56255084",
"0.5623958",
"0.559346",
"0.5581521",
"0.5567112",
"0.5559615",
"0.5529105",
"0.55037665",
"0.5473657",
"0.54565656",
"0.54229414",
"0.5404122",
"0.53800154",
"0.5358894",
"0.5328545",
"0.530646... | 0.6715946 | 0 |
Embed a 4by4 or smaller matrix in the upperleft of I_4. | def _embed44(matrix):
result = np.eye(4)
r, c = matrix.shape
result[:r, :c] = matrix
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_augmented_matrix(self):\r\n for row in range(self.SIZE):\r\n self.matrix[row].append(self.result[row])",
"def matrix_3d_to_4x4(matrix: np.matrix) -> np.matrix:\n return np.matrix([\n [matrix.item(0, 0), matrix.item(0, 1), matrix.item(0, 2), 0],\n [matrix.item(1, 0), m... | [
"0.56006694",
"0.553187",
"0.5439319",
"0.54256284",
"0.5364134",
"0.5332387",
"0.53140825",
"0.5310225",
"0.53080255",
"0.52915466",
"0.5281834",
"0.52639854",
"0.52455604",
"0.5245288",
"0.51908726",
"0.5160496",
"0.5122607",
"0.5120262",
"0.5118664",
"0.51174915",
"0.51112... | 0.67249334 | 0 |
This will first try to load the specified module from the pyrominfo package using the current module search path. If it can't be found, then the parent directory is added to the module search path and the import attempt is repeated. | def loadModule(mod):
try:
# from pyrominfo import gameboy, etc
pyrominfo = __import__("pyrominfo", globals(), locals(), [mod])
except ImportError:
import os
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.sys.path.insert(0, parentdir)
py... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_module(self, name, path, parent=None):\n\n if parent is not None:\n # assert path is not None\n fullname = parent.identifier + '.' + name\n else:\n fullname = name\n\n node = self.findNode(fullname)\n if node is not None:\n self.msg(... | [
"0.6502171",
"0.6038095",
"0.5900002",
"0.58177245",
"0.57946616",
"0.57328486",
"0.5724542",
"0.57179606",
"0.5698969",
"0.5637101",
"0.5621891",
"0.5580989",
"0.5569779",
"0.55592674",
"0.55570364",
"0.5522914",
"0.5515631",
"0.5507379",
"0.5486642",
"0.54800147",
"0.547965... | 0.7147778 | 0 |
Attach disk to VM by reconfiguration. | def attach_disk_to_vm(self, vm_ref, instance_name,
adapter_type, disk_type, vmdk_path=None,
disk_size=None, linked_clone=False,
controller_key=None, unit_number=None,
device_name=None):
client_factory = self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AttachDisk(self, disk: 'AZComputeDisk') -> None:\n vm = self.compute_client.virtual_machines.get(\n self.resource_group_name, self.name)\n data_disks = vm.storage_profile.data_disks\n # ID to assign to the data disk to attach\n lun = 0 if len(data_disks) == 0 else len(data_disks) + 1\n\n ... | [
"0.73531574",
"0.68157685",
"0.67563796",
"0.66293067",
"0.64325035",
"0.6426697",
"0.63882655",
"0.6334873",
"0.623497",
"0.6223832",
"0.62092334",
"0.6202001",
"0.6195019",
"0.61449945",
"0.6086266",
"0.6073298",
"0.6072383",
"0.6067116",
"0.6057906",
"0.59617317",
"0.58979... | 0.7390084 | 0 |
Detach disk from VM by reconfiguration. | def detach_disk_from_vm(self, vm_ref, instance_name, device):
client_factory = self._session._get_vim().client.factory
vmdk_detach_config_spec = vm_util.get_vmdk_detach_config_spec(
client_factory, device)
disk_key = device.key
LOG.debug(_("Reconfiguri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disk_detach(vmdk_path, vm):\n\n device = findDeviceByPath(vmdk_path, vm)\n\n if not device:\n # Could happen if the disk attached to a different VM - attach fails\n # and docker will insist to sending \"unmount/detach\" which also fails.\n msg = \"*** Detach failed: disk={0} not foun... | [
"0.765152",
"0.71042055",
"0.710292",
"0.7051662",
"0.6706635",
"0.66381764",
"0.65310085",
"0.63526535",
"0.62885463",
"0.62843525",
"0.6217464",
"0.62058824",
"0.6176701",
"0.61576825",
"0.6140649",
"0.6140027",
"0.6105745",
"0.6038374",
"0.6036814",
"0.5985441",
"0.5894797... | 0.74518675 | 1 |
Return volume connector information. | def get_volume_connector(self, instance):
iqn = volume_util.get_host_iqn(self._session, self._cluster)
return {
'ip': CONF.vmwareapi_host_ip,
'initiator': iqn,
'host': CONF.vmwareapi_host_ip
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_connection(self, volume, connector):\n export = '%s/%s' % (volume['provider_location'], volume['name'])\n data = {'export': export, 'name': 'volume'}\n if volume['provider_location'] in self.shares:\n data['options'] = self.shares[volume['provider_location']]\n ... | [
"0.6858231",
"0.6418148",
"0.62130344",
"0.60607785",
"0.6042523",
"0.58188075",
"0.5792801",
"0.5697431",
"0.55846596",
"0.55579096",
"0.5506042",
"0.5469819",
"0.5426191",
"0.5425665",
"0.54218316",
"0.5421626",
"0.54012877",
"0.53762865",
"0.53762865",
"0.5360571",
"0.5350... | 0.7179875 | 0 |
check that columns_lst is tbset of self.df.columns.names | def validate_col_lst(self, df, columns_lst):
if columns_lst == []:
raise ValueError("column_lst is empty")
col_set = set(columns_lst)
df_col_set = set(list(df))
if col_set - df_col_set != set():
msg = "col_lst has columns name that does not exists in the DataFrame... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_columns_in_dataframe(df, columns):\n\n if not isinstance(columns, list):\n columns = [columns]\n return set(columns).issubset(df.columns)",
"def _check_columns(df: pd.DataFrame, names: typing.Sequence[str]) -> None:\n for expected in names:\n if expected not in df.columns:\n ... | [
"0.7229939",
"0.69595104",
"0.6792466",
"0.6648041",
"0.66035503",
"0.65919405",
"0.65672946",
"0.6438893",
"0.64331186",
"0.6377156",
"0.6362247",
"0.63079476",
"0.62102634",
"0.61988276",
"0.6196506",
"0.61454993",
"0.61221856",
"0.61137414",
"0.61022323",
"0.6095521",
"0.6... | 0.83148104 | 0 |
given an OU, find all the OUs within that OU... | def get_child_ous(logger, org_client, org_unit):
logger.debug("Getting OUs for: %s", org_unit)
result = [org_unit]
# for this OU, get all the children...
args = dict(ParentId=org_unit["Id"])
children = utils.generic_paginator(logger, org_client.list_organizational_units_for_parent,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_accounts_for_ou(logger, options, org_client, path):\n logger.debug(\"Getting accounts for OU: %s\", path)\n org_unit = get_ou_from_path(logger, org_client, path)\n ous = []\n if options.no_recursive:\n ous.append(org_unit)\n else:\n ous.extend(get_child_ous(logger, org_client, ... | [
"0.6812674",
"0.67796934",
"0.61813617",
"0.5930881",
"0.58512056",
"0.54681545",
"0.54233587",
"0.53596294",
"0.52998245",
"0.52364296",
"0.51616734",
"0.51128006",
"0.50904953",
"0.50900835",
"0.5064042",
"0.50519156",
"0.50236064",
"0.5009377",
"0.4984651",
"0.49781162",
"... | 0.6912658 | 0 |
given a path, traverse Organizations OUs to locate the required OU... | def get_ou_from_path(logger, org_client, path):
logger.debug("Getting OU from path: %s", path)
current_ou = org_client.list_roots()["Roots"][0]["Id"]
if path == "/":
return {"Id":current_ou, "Path":path}
for dir_name in path.split("/")[1:]:
logger.debug("Getting OU from path: %s, looki... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_accounts_for_ou(logger, options, org_client, path):\n logger.debug(\"Getting accounts for OU: %s\", path)\n org_unit = get_ou_from_path(logger, org_client, path)\n ous = []\n if options.no_recursive:\n ous.append(org_unit)\n else:\n ous.extend(get_child_ous(logger, org_client, ... | [
"0.5943409",
"0.5662944",
"0.5541912",
"0.5307396",
"0.52833915",
"0.52833915",
"0.51416296",
"0.51335",
"0.5058733",
"0.5023612",
"0.50106674",
"0.4983386",
"0.49637613",
"0.49609458",
"0.49326625",
"0.49166146",
"0.49147454",
"0.49008152",
"0.4848601",
"0.48095214",
"0.4798... | 0.7749507 | 0 |
given a path, get all the AWS accounts within that part of an Organization... | def get_accounts_for_ou(logger, options, org_client, path):
logger.debug("Getting accounts for OU: %s", path)
org_unit = get_ou_from_path(logger, org_client, path)
ous = []
if options.no_recursive:
ous.append(org_unit)
else:
ous.extend(get_child_ous(logger, org_client, org_unit))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organizations(self):\n return self.get('{}/orgs'.format(ApiVersion.A1.value))",
"def ls():\n return dynamodb.ls(OrganizationModel)",
"async def get_organizations(request: Request):\n redis = request.app.state.redis\n organizations_obj = orjson.loads(await redis.get_key(\"influxdb_organizations\... | [
"0.5892514",
"0.5680063",
"0.5646794",
"0.5550604",
"0.5464335",
"0.5430682",
"0.5372216",
"0.5369034",
"0.53668135",
"0.53542835",
"0.5335564",
"0.5326624",
"0.53066283",
"0.5276022",
"0.5273535",
"0.52497715",
"0.5233608",
"0.5233608",
"0.5214551",
"0.5214118",
"0.52107763"... | 0.63345224 | 0 |
Checks globals() and builtins for the existence of the object name (used for StuWareSoftSystems' bootstrap) | def checkObjectInNameSpace(objectName):
if objectName is None or not isinstance(objectName, basestring) or objectName == u"": return False
if objectName in globals(): return True
return objectName in dir(builtins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isbuiltin(object):\n if inspect.isbuiltin(object):\n return True\n\n return getattr(object, '__module__', None) == 'builtins'",
"def is_builtin_name(name):\r\n if name.startswith('__') and name.endswith('__'):\r\n return ALL_LOWER_CASE_RE.match(name[2:-2]) is not None\r\n return False",
"... | [
"0.6845686",
"0.64684844",
"0.64186686",
"0.63405824",
"0.6296543",
"0.6213715",
"0.60902375",
"0.60629964",
"0.60133064",
"0.5856874",
"0.5762603",
"0.57043445",
"0.56223327",
"0.56172764",
"0.55805594",
"0.5576068",
"0.5568513",
"0.5556084",
"0.55383843",
"0.5527319",
"0.55... | 0.7423229 | 0 |
Pass a string in the format 'x.x.x'. Will check that this MacOSX version is at least that version. The 3rd micro number is optional | def isOSXVersionAtLeast(compareVersion):
# type: (basestring) -> bool
try:
if not Platform.isOSX(): return False
def convertVersion(convertString):
_os_major = _os_minor = _os_micro = 0
_versionNumbers = []
for versionPart in Str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_from_version(version: str) -> str:\n version_int = [int(v) for v in version.split(\".\")]\n if version_int[0] not in PipetteModelMajorVersion:\n raise ValueError(f\"Major version {version_int[0]} is not supported.\")\n if version_int[1] not in PipetteModelMinorVersion:\n raise Valu... | [
"0.6574004",
"0.6253473",
"0.6247122",
"0.6238033",
"0.6165214",
"0.6156912",
"0.612077",
"0.60846204",
"0.60516804",
"0.6008613",
"0.5996625",
"0.5967177",
"0.59521145",
"0.59322596",
"0.5885311",
"0.5882469",
"0.58820486",
"0.5845207",
"0.5835244",
"0.5812287",
"0.580141",
... | 0.62811625 | 1 |
Detect Intel x86 32bit system | def isIntelX86_32bit():
return String(System.getProperty("os.arch", "null").strip()).toLowerCase(Locale.ROOT) == "x86" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_32bit(self):\n return self.machine in ['i386', 'i586', 'i686']",
"def osarch_is_32_bit():\n return osarch_match(\"32-bit\")",
"def osarch_is_ia32():\n return osarch_match(\"ia32\")",
"def host_arch_win():\n\n arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')\n\n matchup = {\n 'AMD64... | [
"0.81732696",
"0.80353045",
"0.7400126",
"0.6873196",
"0.6867948",
"0.6770266",
"0.6644437",
"0.6488959",
"0.6488959",
"0.6432496",
"0.6342804",
"0.63230413",
"0.6291553",
"0.62735385",
"0.6245272",
"0.615874",
"0.6148934",
"0.6148358",
"0.613531",
"0.5986601",
"0.5973497",
... | 0.8507626 | 0 |
Grabs the MD defaultText font, reduces default size down to below 18, sets UIManager defaults (if runtime extension, will probably error, so I catch and skip) | def setDefaultFonts():
if MD_REF_UI is None: return
# If a runtime extension, then this may fail, depending on timing... Just ignore and return...
try:
myFont = MD_REF.getUI().getFonts().defaultText
except:
myPrint("B","ERROR trying to call .getUI().getFonts().de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_default_font(cls):\n if platform.system() == \"Linux\":\n for family in (\"DejaVu Sans\", \"Noto Sans\", \"Nimbus Sans\"):\n if family in tk.font.families():\n logger.debug(\"Setting default font to: '%s'\", family)\n tk.font.nametofon... | [
"0.68280387",
"0.6737032",
"0.6695929",
"0.6610507",
"0.64827216",
"0.6389932",
"0.6196747",
"0.6126894",
"0.60420203",
"0.60152656",
"0.59716773",
"0.596298",
"0.593417",
"0.5910025",
"0.5883346",
"0.58664095",
"0.58539915",
"0.5838941",
"0.58219564",
"0.58039767",
"0.578717... | 0.829493 | 0 |
sets up Client Properties for JFileChooser() to behave as required >> Mac only | def setJFileChooserParameters(_jf, lReportOnly=False, lDefaults=False, lPackagesT=None, lApplicationsT=None, lOptionsButton=None, lNewFolderButton=None):
myPrint("D", "In ", inspect.currentframe().f_code.co_name, "()")
if not Platform.isOSX(): return
if not isinstance(_jf, JFileChooser): retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setFileDialogParameters(lReportOnly=False, lDefaults=False, lSelectDirectories=None, lPackagesT=None):\n\n myPrint(\"D\", \"In \", inspect.currentframe().f_code.co_name, \"()\")\n\n if not Platform.isOSX(): return\n\n _TRUE = \"true\"\n _FALSE = \"false\"\n\n _DIRS_FD = \"app... | [
"0.59659076",
"0.52273905",
"0.52243555",
"0.5196339",
"0.51798254",
"0.51786554",
"0.51282394",
"0.5127446",
"0.51222116",
"0.51085234",
"0.5083295",
"0.50667393",
"0.5033301",
"0.5033301",
"0.5033301",
"0.5008447",
"0.5006361",
"0.4993501",
"0.49912578",
"0.49555835",
"0.49... | 0.60916245 | 0 |
sets up System Properties for FileDialog() to behave as required >> Mac only | def setFileDialogParameters(lReportOnly=False, lDefaults=False, lSelectDirectories=None, lPackagesT=None):
myPrint("D", "In ", inspect.currentframe().f_code.co_name, "()")
if not Platform.isOSX(): return
_TRUE = "true"
_FALSE = "false"
_DIRS_FD = "apple.awt.fileDialogForDirec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _startup_system(self):\n\n self._config_path.set(filedialog.asksaveasfilename())\n self._system = System(self._config_path.get())\n\n self._start_frame.pack_forget()\n self._main_frame.pack()",
"def pkg_app_file_chooser(self):\n filename = tk.filedialog.askopenfilename()\n ... | [
"0.6109975",
"0.5899527",
"0.5769735",
"0.55686957",
"0.55619633",
"0.5373799",
"0.5356747",
"0.5335496",
"0.53288305",
"0.5298387",
"0.5294953",
"0.52298236",
"0.5206536",
"0.51610196",
"0.514091",
"0.50889593",
"0.5086334",
"0.5081264",
"0.5057602",
"0.50511295",
"0.5033079... | 0.61366576 | 0 |
This triggers MD to firePreferencesUpdated().... Hopefully refreshing Home Screen Views too | def fireMDPreferencesUpdated():
myPrint("DB", "In ", inspect.currentframe().f_code.co_name, "()" )
class FPSRunnable(Runnable):
def __init__(self): pass
def run(self):
myPrint("DB",".. Inside FPSRunnable() - calling firePreferencesUpdated()...")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_screen(self):",
"def preferencesChanged(self):\n # do nothing\n pass",
"def on_refresh(self):\n pass",
"def updateSettingsUI(self):\n\n pass",
"def applyPrefs (self):\r\n self.storyPanel.eachWidget(lambda w: w.applyPrefs())\r\n self.storyPanel.Refresh()... | [
"0.70166314",
"0.67420226",
"0.67126137",
"0.6558181",
"0.6547368",
"0.6456297",
"0.62285334",
"0.61892396",
"0.6178164",
"0.6083877",
"0.59968984",
"0.59863025",
"0.5978254",
"0.5940049",
"0.5935096",
"0.5920283",
"0.59084743",
"0.58467805",
"0.58467805",
"0.58374125",
"0.58... | 0.7383542 | 0 |
Will detect and then run the codeblock on the EDT | def genericSwingEDTRunner(ifOffEDTThenRunNowAndWait, ifOnEDTThenRunNowAndWait, codeblock, *args):
isOnEDT = SwingUtilities.isEventDispatchThread()
# myPrint("DB", "** In .genericSwingEDTRunner(), ifOffEDTThenRunNowAndWait: '%s', ifOnEDTThenRunNowAndWait: '%s', codeblock: '%s', args: '%s'" %(ifOffEDTThe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self.window.mainloop()",
"def takeControl(self):\n mainloop()",
"def takeControl(self):\n mainloop()",
"def exec(self):\n if self._root.master is None:\n self._root.mainloop()",
"def run(self):\n self.ident = threading.current_thread().ident\n ... | [
"0.6536498",
"0.64465624",
"0.64465624",
"0.6426398",
"0.63144535",
"0.61656505",
"0.61306715",
"0.60988885",
"0.6066413",
"0.6066413",
"0.6001287",
"0.59971917",
"0.59842736",
"0.5967664",
"0.59582716",
"0.5954346",
"0.5944975",
"0.59409404",
"0.5900608",
"0.58864576",
"0.58... | 0.6598361 | 0 |
Implement your canvas drawing logic here, returning False will stop the rendering, returning True will continue it | def draw(self, canvas) -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw (self, screen):\n drew = bool(self.draw_fn(self, screen, self.dirty))\n self.dirty = False\n return drew",
"def on_draw(self, widget, cr):\n #print \"starting to draw\"\n if self.double_buffer is not None:\n self.draw_tiles()\n cr.set_source_surfa... | [
"0.7068976",
"0.70053196",
"0.6794968",
"0.67545444",
"0.66375184",
"0.66362685",
"0.65746",
"0.6460818",
"0.6460818",
"0.6460818",
"0.6460818",
"0.64464664",
"0.64366764",
"0.6423051",
"0.63904214",
"0.6366687",
"0.6364581",
"0.63468754",
"0.63468754",
"0.63468754",
"0.62978... | 0.8466848 | 0 |
Implement your canvas animation drawing logic here, returning False will stop the rendering, returning True will continue it | def draw_animation(self, canvas, animation_tick) -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, canvas) -> bool:\n return False",
"def draw(self):\r\n if not self.stopped:\r\n super().draw()\r\n self.next_frame()",
"def on_draw(self, widget, cr):\n #print \"starting to draw\"\n if self.double_buffer is not None:\n self.draw_tiles... | [
"0.78179634",
"0.68488324",
"0.6405945",
"0.6315539",
"0.6288791",
"0.6209565",
"0.6140665",
"0.6124815",
"0.6104606",
"0.60049677",
"0.5990784",
"0.59893525",
"0.5976392",
"0.5976392",
"0.5976392",
"0.5976392",
"0.59686214",
"0.5960046",
"0.5932858",
"0.5920046",
"0.59116364... | 0.8034474 | 0 |
Respond to theme load ins here | def load_theme_values(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_load_theme (self):\n\n\t\tif self.has_started:\n\t\t\tself.init_buffers()\n\t\t\tself.redraw_background()\n\t\t\tself.redraw_foreground()",
"def on_load(self):\n pass",
"def on_load(self):\n pass",
"def onStartup(event):\n\n plugins = getPlugins()\n\n for themeDirectory in iterDire... | [
"0.68556285",
"0.66520184",
"0.66520184",
"0.6610389",
"0.64057696",
"0.62862283",
"0.61794144",
"0.6151126",
"0.6137831",
"0.59524107",
"0.59130126",
"0.59130126",
"0.5907942",
"0.58921796",
"0.58286834",
"0.58206403",
"0.57867295",
"0.5769557",
"0.576859",
"0.5764957",
"0.5... | 0.6718465 | 1 |
Starts a setup mode that is used for moving, resizing and other various changes that the user might setup | def start_setup(self, setup_type):
# Persist the user preferences when we end our setup
if (self.setup_type != "" and not setup_type):
self.setup_type = setup_type
rect = self.canvas.get_rect()
self.x = int(rect.x)
self.y = int(rect.y)
self.wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\n setFormat()\n setFilename()\n setScreenMode()",
"def setup_mode():\n status_label.color = WHITE\n status_label.text = \"-SET-\"\n\n ave_label.color = BLACK # Turn off average label and value display\n ave_value.color = BLACK\n\n max_value.text = str(MAX_RANGE_F) # Display... | [
"0.6800144",
"0.6734263",
"0.66898155",
"0.66412646",
"0.6498546",
"0.633072",
"0.62841946",
"0.6278032",
"0.6212285",
"0.6206775",
"0.62048006",
"0.6197723",
"0.61908454",
"0.6190276",
"0.6158729",
"0.6156555",
"0.61511356",
"0.6121974",
"0.6118286",
"0.6098591",
"0.6072834"... | 0.7203417 | 0 |
Extract bbox info from file name. | def get_bbox(fname):
fname = fname.split('_') # fname -> list
i = fname.index('bbox')
return map(float, fname[i+1:i+5]) # m
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bbox(fname):\r\n fname = fname.split('_') # fname -> list\r\n i = fname.index('bbox')\r\n return list(map(float, fname[i+1:i+5])) # m\r",
"def get_bbox(fname):\r\n\r\n fname = fname.split('_') # fname -> list\r\n i = fname.index('bbox')\r\n return list(map(float, fname[i+1:i+5])) # ... | [
"0.7414556",
"0.73649496",
"0.71413463",
"0.6696102",
"0.62867755",
"0.6165321",
"0.6104715",
"0.59432495",
"0.59432495",
"0.59264004",
"0.59072345",
"0.59054977",
"0.5792332",
"0.5791462",
"0.577605",
"0.56787",
"0.5672523",
"0.5659785",
"0.5647485",
"0.56438744",
"0.5634939... | 0.7516535 | 0 |
Extract EPSG number from file name. | def get_proj(fname):
fname = fname.split('_') # fname -> list
i = fname.index('epsg')
return fname[i+1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_proj(fname):\r\n\r\n fname = fname.split('_') # fname -> list\r\n i = fname.index('epsg')\r\n return fname[i+1]",
"def _epsg(self):\n info = self._info['coordinateSystem']['wkt'].rsplit('\"EPSG\",', 1)[-1]\n return int(re.findall(r\"\\d+\", info)[0])",
"def get_version_filename(... | [
"0.63735604",
"0.62062746",
"0.6061637",
"0.58868164",
"0.5818382",
"0.5740342",
"0.5669474",
"0.5658069",
"0.5641101",
"0.5620341",
"0.5620254",
"0.56191593",
"0.56164837",
"0.56108224",
"0.5606117",
"0.55956405",
"0.5589816",
"0.558568",
"0.557769",
"0.5521931",
"0.55009794... | 0.6381265 | 1 |
Return all 2d '/variable' names in the HDF5. | def get_grid_names(fname):
with h5py.File(fname, 'r') as f:
vnames = [k for k in f.keys() if f[k].ndim == 2]
return vnames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_variable_names(self):\n data_names = []\n mesh = self.mesh_names()\n prefix = mesh[0]+'_'\n for vname in self.nc.variables.keys():\n if vname.startswith(prefix):\n if self.nc.dimensions.has_key(vname):\n continue\n if ... | [
"0.6690074",
"0.62676114",
"0.61328524",
"0.60728717",
"0.6032376",
"0.5962701",
"0.5961076",
"0.5934028",
"0.5920969",
"0.5817062",
"0.57885367",
"0.57675433",
"0.57535744",
"0.5749644",
"0.5723075",
"0.57072866",
"0.56532377",
"0.56390136",
"0.5622561",
"0.56167597",
"0.558... | 0.6843741 | 0 |
Test that initializing a Matern1/2 kernel with 0 lengthscale raises an exception | def test_matern_zero_lengthscale(matern):
with pytest.raises(ValueError) as exp:
matern(lengthscale=0.0, variance=1.0, output_dim=1)
assert exp.value.args[0].find("lengthscale must be positive.") >= 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testZeroInput(self):\n nb.rescale_length(2.0)\n nb.rescale_length(0)\n self.assertEqual(2.0, nb.rscale)",
"def testZeroInput(self):\n self.assertRaises(TypeError, nb.rscale,)",
"def testKernelsNotSpecified(self):\n with self.assertRaisesRegexp(ValueError, \"`kernel_shape` can... | [
"0.6572343",
"0.6536193",
"0.63661206",
"0.6360225",
"0.6295031",
"0.6194598",
"0.6051746",
"0.5993452",
"0.59858924",
"0.59765357",
"0.59129274",
"0.5900474",
"0.5889973",
"0.58620816",
"0.5820467",
"0.58139074",
"0.5799146",
"0.5781969",
"0.57249826",
"0.57009274",
"0.56885... | 0.6592899 | 0 |
Test that initializing a Matern1/2 kernel with 0 variance raises an exception | def test_matern12_zero_variance(matern):
with pytest.raises(ValueError) as exp:
matern(lengthscale=1.0, variance=0.0, output_dim=1)
assert exp.value.args[0].find("variance must be positive.") >= 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gauss_kernel():\n\n gauss = gauss_kernel(2, 5)\n\n assert gauss.shape == (5, 5)\n assert gauss[2, 2] == 0.039788735772973836",
"def test_nonpositive_nu_raises_exception(nu):\n with pytest.raises(ValueError):\n kernels.Matern(input_dim=1, nu=nu)",
"def testKernelsNotSpecified(self):\... | [
"0.64694107",
"0.64663404",
"0.63284683",
"0.6302467",
"0.60142285",
"0.59726274",
"0.5947721",
"0.589947",
"0.5893144",
"0.589087",
"0.5890487",
"0.581995",
"0.5760517",
"0.57496685",
"0.57280266",
"0.5705864",
"0.56650275",
"0.5636754",
"0.56325996",
"0.56217444",
"0.560097... | 0.6615188 | 0 |
Test that the assertion fires for a negative delta time | def test_to_delta_time_positive_difference(with_tf_random_seed, np_time_points):
time_points = tf.constant(np_time_points, dtype=default_float())
with pytest.raises(InvalidArgumentError) as exp:
to_delta_time(time_points)
assert exp.value.message.find("Condition x >= y") >= 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_timeout_elapsed_no_exception(self):\n deadline = Deadline(-MS)\n timeout = deadline.timeout(raise_if_elapsed=False)\n self.assertGreater(timeout, -2 * MS)\n self.assertLess(timeout, -MS)",
"def test_negative_timedelta(self):\n @converters.wrap\n def inner_test(p... | [
"0.7007831",
"0.6637345",
"0.6576894",
"0.6474647",
"0.64391077",
"0.6374031",
"0.6313927",
"0.6297262",
"0.62733597",
"0.6259941",
"0.62490773",
"0.62064755",
"0.62022203",
"0.6191",
"0.6171475",
"0.61501443",
"0.610897",
"0.6103212",
"0.6097491",
"0.609512",
"0.6081113",
... | 0.6970346 | 1 |
Compute the derivative of the logpdf with respect to the parameters. | def log_pdf_derivative(x):
return gs.autodiff.jacobian(log_pdf_at_x(x))(base_point) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_pdf_derivative_squared(x):\n dlog = log_pdf_derivative(x)\n return gs.einsum(\"...i, ...j -> ...ij\", dlog, dlog)",
"def logpdf(self, x):\n if self.transform is not None:\n x = self.transform(x) \n return (-self.alpha-1)*np.log(x) - (self.beta/float(x)... | [
"0.77660567",
"0.70519257",
"0.6876588",
"0.6850686",
"0.67922556",
"0.677512",
"0.67627126",
"0.67627126",
"0.6756322",
"0.67217326",
"0.67073756",
"0.65952337",
"0.6584878",
"0.6568949",
"0.65437335",
"0.6536892",
"0.65261656",
"0.65239733",
"0.651334",
"0.6512677",
"0.6508... | 0.82203406 | 0 |
r"""Compute the derivative of the innerproduct matrix. Compute the derivative of the innerproduct matrix of the Fisher information metric at the tangent space at base point. | def inner_product_derivative_matrix(self, base_point):
def pdf(x):
"""Compute pdf at a fixed point on the support.
Parameters
----------
x : float, shape (,)
Point on the support of the distribution
"""
return lambda point... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integrability_tensor_derivative(\n self,\n horizontal_vec_x,\n horizontal_vec_y,\n nabla_x_y,\n tangent_vec_e,\n nabla_x_e,\n base_point,\n ):\n raise NotImplementedError",
"def derivatives(x_p, y_p):\r\n # set up the matrix equation\r\n n = x_... | [
"0.65636075",
"0.6383123",
"0.6320185",
"0.6274132",
"0.62254035",
"0.6178101",
"0.6175668",
"0.6127627",
"0.61223304",
"0.61122054",
"0.61108375",
"0.60562176",
"0.60325277",
"0.6020855",
"0.6019261",
"0.6014277",
"0.60129786",
"0.60129786",
"0.5989726",
"0.59852016",
"0.598... | 0.6529994 | 1 |
Compute the cost function given a set of features / values, and the values for our thetas. | def compute_cost(features, values, theta):
# your code here
error = (values - features.dot(theta))
cost = error.dot(error)
return cost | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_cost(features, values, theta):\r\n m = len(values)\r\n sum_of_square_errors = numpy.square(numpy.dot(features, theta) - values).sum()\r\n cost = sum_of_square_errors / (2*m)\r\n\r\n return cost",
"def compute_cost(features, values, theta):\n m = len(values)\n sum_of_square_errors = ... | [
"0.72324276",
"0.7181755",
"0.71723294",
"0.69701",
"0.69247854",
"0.6471834",
"0.6227543",
"0.6182345",
"0.617613",
"0.6167203",
"0.6144014",
"0.6132684",
"0.61300564",
"0.6123157",
"0.6107986",
"0.6094501",
"0.60778195",
"0.6051131",
"0.60425967",
"0.60174876",
"0.60173744"... | 0.74634284 | 0 |
Calculate yj = rj + gamma argmaxQ or yj = rj (terminating state) This is the target value used to train the neural network and it uses the target network to make predictions | def get_target(self, batch):
# initialise array to store yj values
target = np.zeros((len(batch[0]), self.num_actions))
# loop over samples in the minibatch
for j in range(len(batch[0])):
a0_i = self.action_str2idx(batch[1][j])
r0 = batch[2][j]
done ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Q_net(self, state):\n\t\tif not self._prediction_made: \n\t\t\tQ = tf.matmul(tf.nn.relu( tf.matmul(state, self.weights_hidden) + self.bias_hidden ), self.weights_out) + self.bias_out \n\t\t\tself._Qval = Q\t\n\t\t\tself._prediction_made = True\n\t\treturn self._Qval",
"def final_result(self, board):\n ... | [
"0.6133086",
"0.59240603",
"0.59210104",
"0.58679605",
"0.586299",
"0.5832981",
"0.58184266",
"0.58139116",
"0.58036226",
"0.5798045",
"0.5787385",
"0.5786582",
"0.5784244",
"0.57797366",
"0.5778133",
"0.57767266",
"0.57760173",
"0.5755751",
"0.57456607",
"0.5729801",
"0.5724... | 0.59281206 | 1 |
Small function to build the correct argtypes for the LibXC computers | def _build_comute_argtype(num_nd, num_nd_write):
ret = [_xc_func_p, ctypes.c_size_t]
ret += [_ndptr] * num_nd
ret += [_ndptr_w] * num_nd_write
return tuple(ret) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_type(args):",
"def _cast_types(args):\n\targs.x_val = None if args.x_val == 'None' else int(args.x_val)\n\targs.test_size = float(args.test_size)\n\targs.alpha = float(args.alpha)\n\targs.fit_prior = (args.fit_prior in ['True', \"True\", 'true', \"true\"])\n\n\t# class_prior - array like type (problem to... | [
"0.6376518",
"0.58763367",
"0.58502054",
"0.5712465",
"0.5642069",
"0.5633545",
"0.56088585",
"0.5531215",
"0.5515016",
"0.550904",
"0.5504691",
"0.5500384",
"0.54895383",
"0.5458106",
"0.5442237",
"0.53984636",
"0.5386691",
"0.5374875",
"0.53544724",
"0.5347694",
"0.5341656"... | 0.6243665 | 1 |
Returns the LibXCFunctional family. | def get_family(self):
return self._family | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_01_GetFamily(self):\n self.m_device_obj.DeviceFamily = TESTING_FAMILY_NAME_1\n l_family = FamUtil.get_family(self.m_device_obj)\n # print(PrettyFormatAny.form(l_family, 'B3-01-A - Family'))\n self.assertEqual(l_family, TESTING_FAMILY_NAME_1)",
"def test_02_GetFamily(self):\n ... | [
"0.6671878",
"0.66315264",
"0.6380709",
"0.6380162",
"0.62706983",
"0.62706983",
"0.62412816",
"0.62412816",
"0.62412816",
"0.6231695",
"0.6231695",
"0.6231695",
"0.6102895",
"0.6017814",
"0.5974126",
"0.5966167",
"0.58548194",
"0.57114094",
"0.5633405",
"0.5601125",
"0.55779... | 0.68424135 | 0 |
Returns the VV10 (b, C) coefficients | def get_vv10_coef(self):
if self._nlc_b is False:
raise ValueError("get_vv10_coeff can only be called on -V functionals.")
return (self._nlc_b, self._nlc_C) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coefficients(self):\r\n return self.coef_['x']",
"def coefficients(self) :\n raise NotImplementedError",
"def b_coefficients(x1,x2,x3,y1,y2,y3,CCoefficients,DCoefficients):\n\tBCoefficients = np.array([\t((y2-y1)/(x2-x1)-CCoefficients[0]*(x2-x1) - DCoefficients[0]*((x2-x1)**2)), \\\n\t\t\t\t... | [
"0.65958256",
"0.65501094",
"0.6504454",
"0.6486117",
"0.6194975",
"0.61420995",
"0.60554177",
"0.60554177",
"0.60174334",
"0.5979773",
"0.59653145",
"0.59653145",
"0.59482545",
"0.59466475",
"0.5945674",
"0.59176135",
"0.59019333",
"0.58690476",
"0.58312464",
"0.582763",
"0.... | 0.83470845 | 0 |
Gets the names of all external parameters | def get_ext_param_names(self):
num_param = core.xc_func_info_get_n_ext_params(self.xc_func_info)
ret = []
for p in range(num_param):
tmp = core.xc_func_info_get_ext_params_name(self.xc_func_info, p)
ret.append(tmp.decode("UTF-8"))
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameter_names(self) -> List[str]:",
"def get_param_names(self):\n return list(self.params.keys())",
"def parameter_names(self) -> list:\n parameters = []\n parameters.extend(self.properties.parameter_names)\n return parameters",
"def parameters_names(cls):\n return cl... | [
"0.77504754",
"0.7389947",
"0.72158164",
"0.71607",
"0.71043503",
"0.7083737",
"0.7037365",
"0.70315456",
"0.7013595",
"0.70036983",
"0.698914",
"0.687916",
"0.6841593",
"0.6833137",
"0.68269855",
"0.6797805",
"0.6785064",
"0.6723883",
"0.6707179",
"0.6698673",
"0.6685417",
... | 0.7800671 | 0 |
Gets the descriptions of all external parameters | def get_ext_param_descriptions(self):
num_param = core.xc_func_info_get_n_ext_params(self.xc_func_info)
ret = []
for p in range(num_param):
tmp = core.xc_func_info_get_ext_params_description(self.xc_func_info, p)
ret.append(tmp.decode("UTF-8"))
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _external_params():\n list_ext_params = []\n list_ext_params.append(\n (hoomd.md.external.field.Periodic, \"params\",\n list([dict(A=1.5, i=1, w=3.5, p=5),\n dict(A=10, i=0, w=3.4, p=2)]), _evaluate_periodic))\n list_ext_params.append(\n (hoomd.md.external.field.Ele... | [
"0.7344136",
"0.66554403",
"0.6622951",
"0.6612917",
"0.6590222",
"0.65895045",
"0.65495247",
"0.6545839",
"0.64892864",
"0.6436556",
"0.6409071",
"0.6368646",
"0.6351103",
"0.6338677",
"0.6323158",
"0.63069546",
"0.628588",
"0.628588",
"0.6284201",
"0.6275635",
"0.62606674",... | 0.7465921 | 0 |
Gets the default values of all external parameters. | def get_ext_param_default_values(self):
num_param = core.xc_func_info_get_n_ext_params(self.xc_func_info)
ret = []
for p in range(num_param):
tmp = core.xc_func_info_get_ext_params_default_value(self.xc_func_info, p)
ret.append(tmp)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters_default(cls):\n return cls._Parameters.__new__.__defaults__",
"def default_parameters(self) -> List[Parameter]:\n return self.settings.job_default_parameters",
"def initDefaults(self):\n return _libsbml.Parameter_initDefaults(self)",
"def parameters(self):\n return ... | [
"0.7586267",
"0.75206536",
"0.7345313",
"0.7338341",
"0.7124671",
"0.708384",
"0.7017844",
"0.68795174",
"0.68700486",
"0.6861506",
"0.68081266",
"0.6789644",
"0.672888",
"0.670684",
"0.670621",
"0.6609515",
"0.6601124",
"0.6569071",
"0.6553868",
"0.6518829",
"0.6501356",
"... | 0.80710435 | 0 |
Sets the density threshold below which the functional will not be evaluated. | def set_dens_threshold(self, dens_threshold):
if dens_threshold < 0:
raise ValueError("The density threshold cannot be smaller than 0.")
core.xc_func_set_dens_threshold(self.xc_func, ctypes.c_double(dens_threshold)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setThreshold(self, threshold): # real signature unknown; restored from __doc__\n pass",
"def clear_density(self):\n self._density = None",
"def set_threshold(self, threshold):\n self._threshold = check_value_positive('threshold', threshold)",
"def threshold(self,thresholdValue):\n ... | [
"0.63226175",
"0.61955786",
"0.6171416",
"0.61262935",
"0.59644085",
"0.58235157",
"0.58235157",
"0.58235157",
"0.58235157",
"0.58235157",
"0.57770663",
"0.5771117",
"0.5760468",
"0.5694355",
"0.5690046",
"0.56802684",
"0.5664838",
"0.56599784",
"0.56505716",
"0.5615393",
"0.... | 0.7752366 | 0 |
Calculate the number of columns and rows required to divide an image into ``n`` parts. Return a tuple of integers in the format (num_columns, num_rows) | def calc_columns_rows(n):
num_columns = int(ceil(sqrt(n)))
num_rows = int(ceil(n / float(num_columns)))
return (num_columns, num_rows) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_rows_columns(num_wells):\n a = math.sqrt(num_wells / 6)\n n_rows = int(round(2 * a))\n n_columns = int(round(3 * a))\n return n_rows, n_columns",
"def compute_nrows_ncolumns(nplots):\n n_rows = int(np.sqrt(nplots)) + (np.sqrt(nplots) != int(np.sqrt(nplots))) * 1\n n_columns = int(np... | [
"0.73097175",
"0.7159921",
"0.6962047",
"0.69273585",
"0.6925103",
"0.6749133",
"0.66736543",
"0.6470178",
"0.64632785",
"0.63872576",
"0.6368298",
"0.62814194",
"0.6258692",
"0.6197939",
"0.61734897",
"0.6155329",
"0.6155302",
"0.61514986",
"0.61438143",
"0.6133328",
"0.6131... | 0.79326427 | 0 |
Calculate combined size of tiles. | def get_combined_size(tiles):
# TODO: Refactor calculating layout to avoid repetition.
columns, rows = calc_columns_rows(len(tiles))
tile_size = tiles[0].image.size
return (tile_size[0] * columns, tile_size[1] * rows) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tile_size_2d(self):\n return 32.0, 32.0",
"def get_num_tiles(rows, cols, row_tile_size, col_tile_size):\n num_row_tiles = math.ceil(rows / row_tile_size)\n num_col_tiles = math.ceil(cols / col_tile_size)\n return num_row_tiles, num_col_tiles",
"def get_tilesize(self, sampling):\n xsize = {... | [
"0.6917832",
"0.6854386",
"0.66924536",
"0.66773844",
"0.6626963",
"0.6563682",
"0.6505493",
"0.6481431",
"0.64496267",
"0.641139",
"0.63941205",
"0.631634",
"0.6312036",
"0.627973",
"0.62632513",
"0.625943",
"0.6246556",
"0.621888",
"0.6217926",
"0.62107056",
"0.61723995",
... | 0.8319171 | 0 |
``tiles`` Tuple of ``Image`` instances. ``width`` Optional, width of combined image. ``height`` Optional, height of combined image. ``Image`` instance. | def join(tiles, width=0, height=0):
# Don't calculate size if width and height are provided
# this allows an application that knows what the
# combined size should be to construct an image when
# pieces are missing.
if width > 0 and height > 0:
im = Image.new("RGBA", (width, height), None)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tile_images(imgs, tile_shape, concatenated_image, margin_color=None):\n x_num, y_num = tile_shape\n one_width = imgs[0].shape[1]\n one_height = imgs[0].shape[0]\n if concatenated_image is None:\n concatenated_image = np.zeros((one_height * y_num, one_width * x_num, 3),\n ... | [
"0.6996957",
"0.6695184",
"0.63886476",
"0.62590015",
"0.6253077",
"0.6211737",
"0.62029433",
"0.60706353",
"0.6000102",
"0.596734",
"0.5926167",
"0.5918759",
"0.5894937",
"0.5867754",
"0.5861465",
"0.5857397",
"0.5848029",
"0.5744577",
"0.5702461",
"0.5656095",
"0.56503665",... | 0.7703681 | 0 |
Determine column and row position for filename. | def get_image_column_row(filename):
row, column = os.path.splitext(filename)[0][-5:].split("_")
return (int(column) - 1, int(row) - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_position(self): # maybe encoded in filepath at some point\n result = (self.iter * self.row_step)% self.row_size, self.iter // (self.row_size * self.row_step)* self.col_step\n self.iter += 1\n return result",
"def ind(self, pos):\n row = int(pos[1:]) - 1\n column = self... | [
"0.6791335",
"0.66289556",
"0.66289556",
"0.66289556",
"0.6522248",
"0.6411789",
"0.63911855",
"0.63667697",
"0.6281292",
"0.62766576",
"0.6266177",
"0.6249092",
"0.6142638",
"0.61390686",
"0.6129921",
"0.60795605",
"0.60582995",
"0.60221326",
"0.6021388",
"0.60078406",
"0.59... | 0.75118536 | 0 |
Open all images in a directory. Return tuple of Tile instances. | def open_images_in(directory):
files = [
filename
for filename in os.listdir(directory)
if "_" in filename and not filename.startswith("joined")
]
tiles = []
if len(files) > 0:
i = 0
for file in files:
pos = get_image_column_row(file)
im =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pic_in_directory(directory):\n return [Image.open(os.path.join(directory, img)) for img in os.listdir(directory)]",
"def get_images(directory=None): #import from mask.py\n \n if directory == None:\n directory = os.getcwd() # Use working directory if unspecified\n \n image_list ... | [
"0.67336595",
"0.6599813",
"0.6416653",
"0.63725936",
"0.61642754",
"0.6014441",
"0.5978408",
"0.59570676",
"0.5940081",
"0.5896447",
"0.58877945",
"0.5837525",
"0.5792128",
"0.5787893",
"0.5751572",
"0.57426775",
"0.5739392",
"0.57090163",
"0.57005966",
"0.56994253",
"0.5688... | 0.81790555 | 0 |
If a resource has a title, it should be included in the string representation. | def test_str_with_title(media_resource_factory):
resource = media_resource_factory(title="Test Resource")
assert str(resource) == f"{resource.id} ({resource.title})" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_link_title(self):\n return self.request.POST.get(\"resource_link_title\", self.resource_link_id)",
"def get_resource_details (self):\n return (f\"[Title:\\\"{self.get_title()}\\\"] [Author:{self.get_author()}] [Publisher:{self.get_publisher()}] [Year:{self.get_year()}]\")",
"def res_... | [
"0.68804574",
"0.6865952",
"0.6629121",
"0.6599802",
"0.6590698",
"0.6551943",
"0.6400065",
"0.6386993",
"0.6346398",
"0.632626",
"0.63220584",
"0.63117653",
"0.6293808",
"0.62767816",
"0.6276447",
"0.62574726",
"0.6230404",
"0.61885935",
"0.6185459",
"0.61847913",
"0.6184791... | 0.7142992 | 0 |
Media resources should be ordered by creation time, ascending. | def test_ordering(media_resource_factory):
m1 = media_resource_factory()
m2 = media_resource_factory()
assert list(models.MediaResource.objects.all()) == [m1, m2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sorted_img_list():\n dirPath=settings.BASE_DIR\n imgdir=\"/pttWeb/static/topicmodel\"\n fileID=glob.glob(dirPath+imgdir+\"/*.png\")\n fileID=[i.replace('/home/stream/Documents/minimum_django/pttWeb/static/','') for i in fileID]\n fileID=[Week_Image(i) for i in fileID]\n fileID.sort(key=la... | [
"0.61875653",
"0.60358816",
"0.59814835",
"0.5946629",
"0.5863695",
"0.57058465",
"0.5681557",
"0.5633815",
"0.55823237",
"0.5550474",
"0.5542779",
"0.5542779",
"0.5542779",
"0.5542779",
"0.5485966",
"0.54624945",
"0.544271",
"0.5394488",
"0.5365429",
"0.5348334",
"0.5256054"... | 0.65957546 | 0 |
If a media resource has both an image and YouTube video ID specified then cleaning it should throw an error. | def test_clean_both_image_and_youtube_id(image):
resource = models.MediaResource(image=image, youtube_id="dQw4w9WgXcQ")
with pytest.raises(ValidationError):
resource.clean() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_no_image_or_youtube_id():\n resource = models.MediaResource()\n\n with pytest.raises(ValidationError):\n resource.clean()",
"def test_clean_only_youtube_id():\n resource = models.MediaResource(youtube_id=\"dQw4w9WgXcQ\")\n\n resource.clean()",
"def test_clean_only_image(image)... | [
"0.7774484",
"0.7352817",
"0.6742315",
"0.6415747",
"0.59018755",
"0.5872863",
"0.58247",
"0.57007104",
"0.55338883",
"0.5439113",
"0.54177034",
"0.53636616",
"0.5305156",
"0.53002834",
"0.52959025",
"0.51120865",
"0.51028275",
"0.50996584",
"0.5081952",
"0.5054293",
"0.50387... | 0.78584284 | 0 |
If a media resource does not encapsulate any media, cleaning it should throw an error. | def test_clean_no_image_or_youtube_id():
resource = models.MediaResource()
with pytest.raises(ValidationError):
resource.clean() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_removed_media(self):\r\n if self.has_media():\r\n try:\r\n image = str(self.image)\r\n os.remove(image)\r\n except OSError:\r\n raise('Failure trying to remove image from filesystem.')\r\n return True",
"def test_clean_o... | [
"0.69884086",
"0.6832411",
"0.6076411",
"0.5952054",
"0.5877735",
"0.586007",
"0.574167",
"0.5715479",
"0.56592447",
"0.56336623",
"0.5573302",
"0.55011815",
"0.5439052",
"0.54167026",
"0.5395553",
"0.5383151",
"0.53797346",
"0.532659",
"0.52952904",
"0.5293007",
"0.5271096",... | 0.70109206 | 0 |
Cleaning a media resource that only has an image should do nothing. | def test_clean_only_image(image):
resource = models.MediaResource(image=image)
resource.clean() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_removed_media(self):\r\n if self.has_media():\r\n try:\r\n image = str(self.image)\r\n os.remove(image)\r\n except OSError:\r\n raise('Failure trying to remove image from filesystem.')\r\n return True",
"def clean_before... | [
"0.698834",
"0.67045337",
"0.6504589",
"0.6436783",
"0.6413871",
"0.637336",
"0.6318583",
"0.61001015",
"0.60031515",
"0.59312874",
"0.59246147",
"0.5909386",
"0.58954066",
"0.5854419",
"0.58376265",
"0.58252335",
"0.5816791",
"0.5799392",
"0.5791953",
"0.5740084",
"0.5719948... | 0.7978231 | 0 |
Cleaning a media resource that only has a YouTube video ID should do nothing. | def test_clean_only_youtube_id():
resource = models.MediaResource(youtube_id="dQw4w9WgXcQ")
resource.clean() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_no_image_or_youtube_id():\n resource = models.MediaResource()\n\n with pytest.raises(ValidationError):\n resource.clean()",
"def test_clean_both_image_and_youtube_id(image):\n resource = models.MediaResource(image=image, youtube_id=\"dQw4w9WgXcQ\")\n\n with pytest.raises(Validat... | [
"0.7022397",
"0.66042817",
"0.61575353",
"0.5879848",
"0.56859034",
"0.56468034",
"0.5629039",
"0.5511188",
"0.5497184",
"0.54881966",
"0.54724157",
"0.5448994",
"0.5418817",
"0.541001",
"0.54045886",
"0.53989905",
"0.5339894",
"0.5189437",
"0.51847184",
"0.51762545",
"0.5173... | 0.8092883 | 0 |
If a media resource has an image, its type property should indicate it's an image. | def test_type_image(image):
resource = models.MediaResource(image=image)
assert resource.type == models.MediaResource.TYPE_IMAGE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_image(content_type):\n return content_type == \"image/jpeg\" or content_type == \"image/png\"",
"def is_image(self):\r\n # we can only get this if we have headers\r\n LOG.debug('content type')\r\n LOG.debug(self.content_type)\r\n if (self.content_type is not None and\r\n ... | [
"0.71367157",
"0.6835922",
"0.6663885",
"0.6654667",
"0.6619548",
"0.648332",
"0.6373138",
"0.6143732",
"0.6071515",
"0.59954345",
"0.5967518",
"0.596137",
"0.59485954",
"0.5918796",
"0.5918796",
"0.5918796",
"0.5918796",
"0.5918796",
"0.5918796",
"0.5918796",
"0.5918796",
... | 0.7742908 | 0 |
If a media resource has a YouTube video ID, its type property should indicate it's a YouTube video. | def test_type_youtube():
resource = models.MediaResource(youtube_id="dQw4w9WgXcQ")
assert resource.type == models.MediaResource.TYPE_YOUTUBE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_youtube(self, media_id):\n pass",
"def isYouTube(self):\n if 'youtube' in self.link.split('.'):\n return True\n return None",
"def play_youtube(self, media_id):\n raise NotImplementedError()",
"def on_play(self, event, type=\"yt\", content=None):\n urls ... | [
"0.6823963",
"0.6766844",
"0.6746436",
"0.6112856",
"0.60233295",
"0.59815586",
"0.5897715",
"0.58677566",
"0.5842102",
"0.58315057",
"0.580741",
"0.580741",
"0.580741",
"0.580741",
"0.58059746",
"0.579559",
"0.579133",
"0.5763148",
"0.57312804",
"0.57054985",
"0.56609565",
... | 0.78130394 | 0 |
Extract text and other things from the raw_html for this document. | def extract(self, doc, raw_html):
super(KenyaTodayCrawler, self).extract(doc, raw_html)
soup = BeautifulSoup(raw_html)
# gather title
doc.title = soup.find(attrs={"property":"og:title"})['content']
#gather publish date
date = self.extract_plaintext(soup.select("main.co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_all_text(self, url, html_doc):\n self.title_text = self.get_title_words(html_doc)\n self.meta_text = self.get_meta_words(html_doc)\n self.url_text = self.get_url_words(url)\n self.heading_text = self.get_heading_words(html_doc)\n self.body_text = self.get_body_words(h... | [
"0.6755422",
"0.6671859",
"0.6553396",
"0.64243054",
"0.6272383",
"0.623531",
"0.623531",
"0.6228035",
"0.61742455",
"0.61664754",
"0.61556983",
"0.6104006",
"0.6092044",
"0.60168433",
"0.59852856",
"0.59402233",
"0.5923603",
"0.59181535",
"0.59116304",
"0.58720744",
"0.58008... | 0.73629075 | 0 |
phase5 requires a 4edge combo where none of the edges are in the zplane. phase4 will put a 4edge combo into that state. There are 12!/(4!8!) or 495 different 4edge combinations. Try them all and see which one has the lowest phase4 cost. | def find_first_four_edges_to_pair(self):
original_state = self.state[:]
original_solution = self.solution[:]
original_solution_len = len(self.solution)
results = []
for wing_str_index, wing_str_combo in enumerate(itertools.combinations(wing_strs_all, 4)):
wing_str_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phase_5(self):\n test_board_1 = board(5, 5, [1, 1], [0, 0])\n render = Render_engine('terminal', test_board_1)\n\n render.render_terminal(test_board_1)",
"def cost_function_SO4(params: list):\n cost = 0\n SO4 = SO4_circuit(params[0], params[1], params[2], params[3], params[4], para... | [
"0.56203735",
"0.5353156",
"0.5339077",
"0.53312033",
"0.52918285",
"0.52905166",
"0.5248838",
"0.52097756",
"0.5169619",
"0.51692957",
"0.51207316",
"0.50766826",
"0.5064046",
"0.5053413",
"0.50450885",
"0.50349313",
"0.503351",
"0.49939486",
"0.49711737",
"0.49670827",
"0.4... | 0.58114266 | 0 |
phase1 stages the centers on sides L and R phase2 stages the centers on sides F and B and put the LR centers in one of 495 states that can be solved without L L' R R'...this is prep work for phase 3 TODO this needs more work BLBFRUFRDDFBUULBRLBRRLDLDLFURFLUBUDRRRDDFDFBBLUFRUFFBBFBLLLDBDFBDBLFDUUFRFBLDUDDURFDRBBDFUUFUBF... | def group_centers_phase1_and_2(self) -> None:
self.rotate_U_to_U()
self.rotate_F_to_F()
if self.centers_staged():
return
original_state = self.state[:]
original_solution = self.solution[:]
tmp_solution_len = len(self.solution)
# find multiple phase1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain_corrections():\n \n #read the files\n sample_4m=read_sample(map_files('sample_4m'))\n empty_cell_4m=read_sample(map_files('empty_cell_4m'))\n empty_4m=read_sample(map_files('empty_4m'))\n transmission_sample_cell_4m=read_sample(map_files('trans_sample_4m'))\n transmission_empty_cell_... | [
"0.5802384",
"0.5704981",
"0.553651",
"0.55297977",
"0.55000675",
"0.5490818",
"0.53914285",
"0.5377671",
"0.5346241",
"0.53404874",
"0.5332665",
"0.52918446",
"0.52571434",
"0.52550757",
"0.52523685",
"0.5244776",
"0.5243008",
"0.5238628",
"0.5237757",
"0.52282685",
"0.51770... | 0.7835292 | 0 |
Convert a column number into a column letter (3 > 'C') Right shift the column col_idx by 26 to find column letters in reverse order. These numbers are 1based, and can be converted to ASCII ordinals by adding 64. | def _get_column_letter(col_idx):
# these indicies corrospond to A -> ZZZ and include all allowed
# columns
if not 1 <= col_idx <= 18278:
raise ValueError("Invalid column index {0}".format(col_idx))
letters = []
while col_idx > 0:
col_idx, remainder = divmod(col_idx, 26)
# che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _index_to_column(i, column=''):\n\n # A dictionary of numbers to letters starting at 0, e.g.\n # {0: 'A', 1: 'B' ...}\n num_to_alpha = {k:v for k, v in enumerate(string.ascii_uppercase, 0)}\n # If our index is divisble by 26, we need to get recursive and add\n # additional letters.\n div = i ... | [
"0.7620537",
"0.74437094",
"0.7439917",
"0.7273949",
"0.68757963",
"0.6614841",
"0.65894353",
"0.6583816",
"0.6494394",
"0.64713115",
"0.64713115",
"0.6470613",
"0.6470613",
"0.6470613",
"0.64606607",
"0.6388831",
"0.6317523",
"0.6244326",
"0.61555386",
"0.60580075",
"0.59901... | 0.7847133 | 0 |
Given a head of LinkedList, delete from that linkedList index j and skip index i iterative | def skip_i_delete_j(head, i, j):
if i == 0:
return None
if head is None or j < 0 or i < 0:
return head
current = head
previous = None
while current:
# skip (i - 1) nodes
for _ in range(i - 1):
if current is None:
return head
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, index):\n if index == 0 and self.head is not None:\n self.head = self.head.next\n return\n\n current_index = 0\n current = self.head\n previous = None\n\n while current:\n if current_index == index:\n previous.next = current.next\n\n previous = current\n ... | [
"0.7670848",
"0.7561153",
"0.73862875",
"0.7377517",
"0.73646194",
"0.73238605",
"0.7250336",
"0.72010875",
"0.71746737",
"0.71504664",
"0.713762",
"0.71322805",
"0.7128258",
"0.7071973",
"0.70681566",
"0.7032534",
"0.69234806",
"0.6903745",
"0.6830704",
"0.6819169",
"0.68181... | 0.81535465 | 0 |
Perform a context visibility test. Creates a (fake) image with the specified owner and is_public attributes, then creates a context with the given keyword arguments and expects exp_res as the result of an is_image_visible() call on the context. | def do_visible(self, exp_res, img_owner, img_public, **kwargs):
img = FakeImage(img_owner, img_public)
ctx = context.RequestContext(**kwargs)
self.assertEqual(ctx.is_image_visible(img), exp_res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_sharable(self, exp_res, img_owner, membership=None, **kwargs):\n\n img = FakeImage(img_owner, True)\n ctx = context.RequestContext(**kwargs)\n\n sharable_args = {}\n if membership is not None:\n sharable_args['membership'] = membership\n\n self.assertEqual(ctx.i... | [
"0.55633384",
"0.54331094",
"0.5389461",
"0.5342315",
"0.5338732",
"0.53361624",
"0.5331995",
"0.53111786",
"0.5263905",
"0.519634",
"0.5192311",
"0.5132145",
"0.51142937",
"0.5112023",
"0.50558454",
"0.49886537",
"0.49874082",
"0.49178144",
"0.47592",
"0.4705346",
"0.4691575... | 0.7743895 | 0 |
Perform a context sharability test. Creates a (fake) image with the specified owner and is_public attributes, then creates a context with the given keyword arguments and expects exp_res as the result of an is_image_sharable() call on the context. If membership is not None, its value will be passed in as the 'membership... | def do_sharable(self, exp_res, img_owner, membership=None, **kwargs):
img = FakeImage(img_owner, True)
ctx = context.RequestContext(**kwargs)
sharable_args = {}
if membership is not None:
sharable_args['membership'] = membership
self.assertEqual(ctx.is_image_sharab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_auth_sharable_can_share(self):\n self.do_sharable(True, 'pattieblack', FakeMembership(True),\n tenant='froggy')",
"def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwar... | [
"0.54896724",
"0.54389876",
"0.52578163",
"0.5243541",
"0.5127175",
"0.50320935",
"0.49899673",
"0.49097702",
"0.4775629",
"0.47158346",
"0.47047496",
"0.4655331",
"0.4621686",
"0.46000612",
"0.45601118",
"0.45558378",
"0.45160365",
"0.4514471",
"0.45083925",
"0.45038795",
"0... | 0.8215476 | 0 |
Tests that an empty context (with is_admin set to True) can access an owned image with is_public set to True. | def test_empty_public_owned(self):
self.do_visible(True, 'pattieblack', True, is_admin=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_private_owned(self):\n self.do_visible(True, 'pattieblack', False, is_admin=True)",
"def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')",
"def test_should_render_for_owner_unpublished(self) -> None:\n self.assertTrue(self.action... | [
"0.68287414",
"0.68124455",
"0.6661694",
"0.65978193",
"0.6575297",
"0.6509962",
"0.6473352",
"0.64539516",
"0.6439792",
"0.63888246",
"0.63792306",
"0.6371669",
"0.6366299",
"0.6361131",
"0.63585526",
"0.62366015",
"0.6124907",
"0.6047954",
"0.6000606",
"0.5996451",
"0.59751... | 0.7047812 | 0 |
Tests that an empty context (with is_admin set to True) can access an owned image with is_public set to False. | def test_empty_private_owned(self):
self.do_visible(True, 'pattieblack', False, is_admin=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_public_owned(self):\n self.do_visible(True, 'pattieblack', True, is_admin=True)",
"def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')",
"def test_should_render_for_owner_unpublished(self) -> None:\n self.assertTrue(self.action.s... | [
"0.70528495",
"0.6893526",
"0.67592186",
"0.6630321",
"0.65318274",
"0.65298545",
"0.6517861",
"0.65116936",
"0.6454932",
"0.6407351",
"0.63348746",
"0.63260263",
"0.63152415",
"0.6308235",
"0.62680256",
"0.62383586",
"0.6053724",
"0.59971654",
"0.5979315",
"0.59685737",
"0.5... | 0.6911272 | 1 |
Tests that an authenticated context (with is_admin set to False) cannot share an image it does not own even if it is shared with it, but with can_share = False. | def test_auth_sharable_cannot_share(self):
self.do_sharable(False, 'pattieblack', FakeMembership(False),
tenant='froggy') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_share(self, context, share, share_server=None):\n pass",
"def ensure_share(self, context, share, share_server=None):\r\n LOG.debug(\"Ensure share.\")",
"def cant_share_photo(request, ttl=None,*args, **kwargs):\n\tif ttl:\n\t\ttry:\n\t\t\tttl = int(ttl)\n\t\texcept ValueError:\n\t\t\ttt... | [
"0.6938848",
"0.6857029",
"0.68210304",
"0.67752564",
"0.6616296",
"0.63722545",
"0.6287799",
"0.6185038",
"0.61454177",
"0.6070145",
"0.6063103",
"0.6063056",
"0.59651726",
"0.5954177",
"0.5950448",
"0.58537835",
"0.5789933",
"0.57651097",
"0.5743968",
"0.57354796",
"0.57342... | 0.74366206 | 0 |
loads file FILTER, returns filter matrix | def load_filter():
if not os.path.isfile(FILTER):
print('no filter found, creating square grid')
return []
with open(FILTER, 'r') as ff:
reader = csv.reader(ff)
l = list(reader)
ar = numpy.asarray(l)
# ar = numpy.transpose(ar, (0, 1))
# ar = numpy.flip(ar,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_filter_file(self, file_path): \n self._pop_all_self()\n self.filter_list = []\n self.file_path = file_path \n \n with codecs.open(self.file_path, 'r', encoding='cp1252') as fid: \n for k, line in enumerate(fid):\n line = line.lstrip('\\n\\r ')\n... | [
"0.66520554",
"0.657589",
"0.65067047",
"0.64896256",
"0.63868827",
"0.6371127",
"0.626495",
"0.5997112",
"0.59562635",
"0.5929189",
"0.59240067",
"0.5835717",
"0.58037555",
"0.5700353",
"0.56678426",
"0.5623952",
"0.5620478",
"0.55956954",
"0.5576885",
"0.55100983",
"0.55041... | 0.7438268 | 0 |
returns boolean, whether xy is occupied in filter matrix | def filtered(filter, xy):
try:
x, y = xy
return bool(filter[x][y])
except IndexError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xy_occupied(xy, board):\n return True if board[xy[0]][xy[1]] else False",
"def occupiedNeighbor(self, xi, yi):\n\n xmax = self.mapData.og.info.width\n ymax = self.mapData.og.info.height\n\n if self.mapData.sampled:\n # Fails on an occupied cell\n assert self.mapD... | [
"0.6924757",
"0.6860181",
"0.6504782",
"0.6499604",
"0.6476733",
"0.6406629",
"0.6393374",
"0.63787687",
"0.6288766",
"0.6284607",
"0.6230571",
"0.62087417",
"0.6196269",
"0.61808234",
"0.6141441",
"0.612595",
"0.61152285",
"0.61060596",
"0.60959953",
"0.60850585",
"0.6084111... | 0.71220756 | 0 |
Write the matrix to a csv table | def write_out(matrix, filename):
with open(filename, 'w') as csvfile:
writer = csv.writer(csvfile)
for r in matrix:
writer.writerow(r)
print(filename + ' writen!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_csv(table, header):\n with open(\"%s.csv\" % header, \"w\") as csvfile:\n for i in range(len(table)):\n for j in range(len(table[i])):\n if j != len(table[i])-1:\n tmp = table[i][j] + \",\"\n else:\n tmp = table[i... | [
"0.75623345",
"0.7330622",
"0.71900606",
"0.71231455",
"0.71107894",
"0.7031687",
"0.7024952",
"0.70113516",
"0.697658",
"0.69399834",
"0.6934993",
"0.69087684",
"0.69058",
"0.6873836",
"0.6852782",
"0.6852024",
"0.6777883",
"0.676096",
"0.6755106",
"0.67167455",
"0.6708375",... | 0.76784086 | 0 |
Construct a DCEL from the output of matplotlib.delaunay.delaunay. | def from_delaunay_triangulation(cls, xl, yl, triangles, circumcentres):
def add_containing_face_to_dcel():
containing_face_edges = [edge for edge in dcel.edges if not edge.nxt]
edge = containing_face_edges.pop()
face = Face(outer_component=None, inner_components=[edge])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mesh(self):\n from scipy.spatial import Delaunay\n points = self.cluster.get_positions()\n delaunay = Delaunay(points)\n simplices = self._filter_max_dist_in_element(delaunay.simplices)\n delaunay.simplices = simplices\n return delaunay",
"def __plot_delaunay(self, ... | [
"0.553893",
"0.5346823",
"0.52831537",
"0.50846463",
"0.49604708",
"0.48745608",
"0.48555076",
"0.485055",
"0.4848358",
"0.4832407",
"0.47853115",
"0.47777563",
"0.47689658",
"0.47675616",
"0.47572455",
"0.474961",
"0.4736425",
"0.47201127",
"0.4714435",
"0.47010985",
"0.4685... | 0.5686502 | 0 |
Add an edge to DCEL if it doesn't already exists, otherwise return the existing edge. | def add_edge(self, edge):
try:
edge_idx = self.edges.index(edge)
return self.edges[edge_idx]
except Exception:
self.edges.append(edge)
return edge | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n\n add_egde = True\n for edge_this in self.edges:\n if edge_this == edge:\n add_egde = False\n\n if add_egde:\n self.edges.append(edge)\n\n return self",
"def add_edge(self, edge):\n edge = set(edge)\n (vert... | [
"0.7570172",
"0.7543887",
"0.7385329",
"0.731582",
"0.7228451",
"0.72140056",
"0.7205442",
"0.7191608",
"0.7144214",
"0.712575",
"0.7108078",
"0.7094593",
"0.7083264",
"0.6992474",
"0.6966737",
"0.6870384",
"0.6825222",
"0.6818147",
"0.67740756",
"0.67177004",
"0.6700951",
... | 0.81017184 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.