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 |
|---|---|---|---|---|---|---|
Supply a stock Unpacker component configuration. | def config():
return {
"CLEAN_OUTBOX": "TRUE",
"COMPONENT_NAME": "testing-unpacker",
"DEST_SITE": "WIPAC",
"FILE_CATALOG_REST_TOKEN": "fake-file-catalog-token",
"FILE_CATALOG_REST_URL": "http://kVj74wBA1AMTDV8zccn67pGuWJqHZzD7iJQHrUJKA.com/",
"HEARTBEAT_PATCH_RETRIES"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _configure(self):\n Component._configure(self)\n self.dataDim = self.inventory.dataDim\n self.reader = self.inventory.reader\n self.coordsys = self.inventory.coordsys\n return",
"def component_configuration():\n return ProtocolConfig(\"a_protocol\", \"an_author\", \"0.1.0\")",
"def __init... | [
"0.60491806",
"0.60181206",
"0.5820223",
"0.5703235",
"0.56558824",
"0.5650569",
"0.56040895",
"0.5548784",
"0.5548784",
"0.5532857",
"0.550845",
"0.5503605",
"0.5503605",
"0.54902905",
"0.54895806",
"0.54834265",
"0.547269",
"0.54592365",
"0.54548174",
"0.5436214",
"0.541266... | 0.6135341 | 0 |
Test that a Unpacker can be constructed with a configuration object and a logging object. | def test_constructor_config(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
assert p.heartbeat_sleep_duration_seconds == 60
assert p.lta_rest_url == "http://RmMNHdPhHpH2ZxfaFAC9d2jiIbf5pZiHDqy43rFLQiM.com/"
assert p.name == "testing-unpacker"
as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_constructor_missing_logging():\n with pytest.raises(TypeError):\n config = {\n \"PAN_GALACTIC_GARGLE_BLASTER\": \"Yummy\"\n }\n Unpacker(config)",
"def test_constructor_missing_config():\n with pytest.raises(TypeError):\n Unpacker()",
"def test_constructor_... | [
"0.7700672",
"0.7513467",
"0.7095627",
"0.70245063",
"0.6740902",
"0.66885704",
"0.640876",
"0.63840824",
"0.6075561",
"0.60365963",
"0.6021522",
"0.5991082",
"0.59532076",
"0.5941087",
"0.58921325",
"0.58667576",
"0.58344215",
"0.5830553",
"0.5816027",
"0.57797635",
"0.57350... | 0.7794762 | 0 |
Verify that the Unpacker has a reasonable state when it is first constructed. | def test_constructor_state(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
assert p.last_work_begin_timestamp is p.last_work_end_timestamp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanity_check(self):\n pass",
"def _check_initialized(self):\n self.assertEquals(0, self._error_count)\n self.assertEquals(0, len(self._error_messages))",
"def check_state(self):\n pass",
"def test_constructor_missing_config():\n with pytest.raises(TypeError):\n Unpac... | [
"0.6263604",
"0.62551486",
"0.6254808",
"0.6216785",
"0.61777383",
"0.61777383",
"0.6158712",
"0.61534536",
"0.61313677",
"0.61311907",
"0.611405",
"0.5982184",
"0.5978936",
"0.5948849",
"0.5830854",
"0.58068204",
"0.57835066",
"0.57656497",
"0.57650167",
"0.5762708",
"0.5758... | 0.6736872 | 0 |
Test the Unpacker does the work the unpacker should do. | async def test_unpacker_run(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
p._do_work = AsyncMock()
await p.run()
p._do_work.assert_called() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_unpacker_do_work_yes_results(config, mocker, path_map_mock):\n BUNDLE_OBJ = {\n \"uuid\": \"f74db80e-9661-40cc-9f01-8d087af23f56\"\n }\n logger_mock = mocker.MagicMock()\n lta_rc_mock = mocker.patch(\"rest_tools.client.RestClient.request\", new_callable=AsyncMock)\n lta_rc_mock... | [
"0.7026921",
"0.6917229",
"0.6718217",
"0.66345006",
"0.66317636",
"0.6522449",
"0.6346672",
"0.6327242",
"0.6220994",
"0.621743",
"0.6194161",
"0.61879057",
"0.6159423",
"0.6151889",
"0.6040789",
"0.60328835",
"0.5927252",
"0.5900667",
"0.5900305",
"0.58887774",
"0.5873927",... | 0.7175864 | 0 |
Test that _do_work raises when the RestClient can't pop. | async def test_unpacker_do_work_pop_exception(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
lta_rc_mock = mocker.patch("rest_tools.client.RestClient.request", new_callable=AsyncMock)
lta_rc_mock.side_effect = HTTPError(500, "LTA DB on fire. Again.")
p = Unpacker(config, logger_mock)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_deleter_do_work_pop_exception(config, mocker):\n logger_mock = mocker.MagicMock()\n lta_rc_mock = mocker.patch(\"rest_tools.client.RestClient.request\", new_callable=AsyncMock)\n lta_rc_mock.side_effect = HTTPError(500, \"LTA DB on fire. Again.\")\n p = Deleter(config, logger_mock)\n ... | [
"0.6955301",
"0.60720605",
"0.6056252",
"0.60504097",
"0.6034629",
"0.5921771",
"0.5903964",
"0.59034634",
"0.58731407",
"0.5835031",
"0.5810943",
"0.5788028",
"0.5776666",
"0.5761587",
"0.5745618",
"0.5732667",
"0.5707057",
"0.57010514",
"0.5690324",
"0.56870055",
"0.568692"... | 0.661107 | 1 |
Test that _update_bundle_in_lta_db updates the status of the bundle in the LTA DB. | async def test_unpacker_update_bundle_in_lta_db(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
lta_rc_mock = mocker.patch("rest_tools.client.RestClient", new_callable=AsyncMock)
p = Unpacker(config, logger_mock)
assert await p._update_bundle_in_lta_db(lta_rc_mock, {"uuid": "c4b345e4-23... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_bundle_2(self):\n self.bndl.ticket = None\n import_genome.check_bundle(self.bndl,\n ticket_ref=\"ticket\",\n file_ref=\"flat_file\",\n retrieve_ref=\"phagesdb\",\n ... | [
"0.6499748",
"0.6375098",
"0.63195056",
"0.62923455",
"0.62595326",
"0.61508405",
"0.61508405",
"0.61508405",
"0.6130336",
"0.6129345",
"0.60776377",
"0.60384524",
"0.6009847",
"0.6008804",
"0.59955597",
"0.5994568",
"0.59913254",
"0.59864956",
"0.5981181",
"0.593282",
"0.589... | 0.71887296 | 0 |
Test that _add_location_to_file_catalog adds a location in the File Catalog. | async def test_unpacker_add_location_to_file_catalog(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
fc_rc_mock = mocker.patch("rest_tools.client.RestClient.request", new_callable=AsyncMock)
p = Unpacker(config, logger_mock)
bundle_file = {
"checksum": {
"sha512": "0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_azr_location(self):\n pass",
"def addLocation(self, locationString):\r\n self.location = locationString\r\n self.addFiles(locationString)\r\n return",
"def test_path_to_location(self):\r\n\r\n print \"Starting import\"\r\n modulestore = XMLModuleStore(DATA... | [
"0.66326916",
"0.65633965",
"0.640427",
"0.6389609",
"0.6195534",
"0.60576284",
"0.6021749",
"0.58707",
"0.5849283",
"0.5849283",
"0.5849283",
"0.5849283",
"0.5849283",
"0.5849283",
"0.5849283",
"0.58483905",
"0.57948303",
"0.56947505",
"0.56699157",
"0.5669271",
"0.5654221",... | 0.70740956 | 0 |
Test that _delete_manifest_metadata will delete metadata of either version. | def test_unpacker_delete_manifest_metadata_v3(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_os_remove = mocker.patch("os.remove")
mock_os_remove.side_effect = [NameError, None]
p._delete_manifest_metadata("0869ea50-e437-443f-8cdb-31a350f88e57... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_delete_manifest_metadata_unknown(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_os_remove = mocker.patch(\"os.remove\")\n mock_os_remove.side_effect = [NameError, NameError]\n with pytest.raises(NameError):\n p._... | [
"0.68494916",
"0.6320009",
"0.6316312",
"0.62980163",
"0.6202315",
"0.5990099",
"0.59865844",
"0.59578156",
"0.5951433",
"0.594975",
"0.5945878",
"0.5921927",
"0.5902222",
"0.58407366",
"0.5838764",
"0.583026",
"0.58298224",
"0.58037287",
"0.5794836",
"0.57929486",
"0.579052"... | 0.74787045 | 0 |
Test that _delete_manifest_metadata will throw on an unknown version. | def test_unpacker_delete_manifest_metadata_unknown(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_os_remove = mocker.patch("os.remove")
mock_os_remove.side_effect = [NameError, NameError]
with pytest.raises(NameError):
p._delete_manife... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_delete_manifest_metadata_v3(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_os_remove = mocker.patch(\"os.remove\")\n mock_os_remove.side_effect = [NameError, None]\n p._delete_manifest_metadata(\"0869ea50-e437-443f-8cdb... | [
"0.7372555",
"0.6441587",
"0.62728256",
"0.6213908",
"0.6173617",
"0.61352557",
"0.6132365",
"0.6121432",
"0.6107993",
"0.61024123",
"0.6098416",
"0.6049859",
"0.60365367",
"0.6020899",
"0.5971693",
"0.59376717",
"0.5902457",
"0.5899617",
"0.589082",
"0.5890105",
"0.58641493"... | 0.7510625 | 0 |
Test that _read_manifest_metadata will read v3 metadata. | def test_unpacker_read_manifest_metadata_for_v3(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_v2 = mocker.patch("lta.unpacker.Unpacker._read_manifest_metadata_v2")
mock_v2.side_effect = [None]
mock_v3 = mocker.patch("lta.unpacker.Unpacker._re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index_manifest_additional_metadata(gen3_index, gen3_auth):\n with patch(\n \"gen3.tools.indexing.index_manifest.Gen3Metadata.create\", MagicMock()\n ) as mock_mds_create:\n index_object_manifest(\n manifest_file=CURRENT_DIR + \"/test_data/manifest_additional_metadata.tsv\",\... | [
"0.73140496",
"0.70539397",
"0.68020827",
"0.6727229",
"0.65726835",
"0.6526684",
"0.648349",
"0.6460334",
"0.6441329",
"0.64323914",
"0.63309455",
"0.63134676",
"0.6311856",
"0.62913156",
"0.6285495",
"0.60795236",
"0.6078326",
"0.6056551",
"0.5991489",
"0.593395",
"0.593275... | 0.7606809 | 0 |
Test that _read_manifest_metadata will throw on an unknown version. | def test_unpacker_read_manifest_metadata_unknown(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
mock_v2 = mocker.patch("lta.unpacker.Unpacker._read_manifest_metadata_v2")
mock_v2.side_effect = [None]
mock_v3 = mocker.patch("lta.unpacker.Unpacker._r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_v3_no_throw(file_open_mock, config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n file_open_mock.side_effect = NameError\n p = Unpacker(config, logger_mock)\n assert not p._read_manifest_metadata_v3(\"0869ea50-e437-443f-8cdb-31a350f88e57\")",
"d... | [
"0.7169583",
"0.7081144",
"0.6739161",
"0.6642735",
"0.64975154",
"0.6303252",
"0.6300239",
"0.6251104",
"0.62317026",
"0.61887234",
"0.61170816",
"0.61137027",
"0.6109315",
"0.6099843",
"0.60819846",
"0.60760486",
"0.6066707",
"0.6066453",
"0.6053334",
"0.6042419",
"0.604208... | 0.73456854 | 0 |
Test that _read_manifest_metadata_v2 will try to read metadata. | def test_unpacker_read_manifest_metadata_v2(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
p = Unpacker(config, logger_mock)
with patch("builtins.open", mock_open(read_data='{"some": "object"}')) as metadata_mock:
assert p._read_manifest_metadata_v2("0869ea50-e437-443f-8cdb-31a350f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_unknown(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_v2 = mocker.patch(\"lta.unpacker.Unpacker._read_manifest_metadata_v2\")\n mock_v2.side_effect = [None]\n mock_v3 = mocker.patch(\"lta.unpacke... | [
"0.71277475",
"0.71106714",
"0.7096303",
"0.6979915",
"0.6931832",
"0.67869776",
"0.66541153",
"0.6563625",
"0.64848506",
"0.6481526",
"0.63658917",
"0.6347141",
"0.6292325",
"0.6262598",
"0.6238003",
"0.62081164",
"0.6181404",
"0.60355276",
"0.60354185",
"0.6022765",
"0.5986... | 0.7187784 | 0 |
Test that _read_manifest_metadata_v2 will not throw when unable to read metadata. | def test_unpacker_read_manifest_metadata_v2_no_throw(file_open_mock, config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
file_open_mock.side_effect = NameError
p = Unpacker(config, logger_mock)
assert not p._read_manifest_metadata_v2("0869ea50-e437-443f-8cdb-31a350f88e57") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_v3_no_throw(file_open_mock, config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n file_open_mock.side_effect = NameError\n p = Unpacker(config, logger_mock)\n assert not p._read_manifest_metadata_v3(\"0869ea50-e437-443f-8cdb-31a350f88e57\")",
"d... | [
"0.73747724",
"0.723688",
"0.66781574",
"0.6594511",
"0.62752706",
"0.62732124",
"0.6246404",
"0.6190824",
"0.61308306",
"0.6048068",
"0.60363334",
"0.6034072",
"0.6007644",
"0.59953654",
"0.59303254",
"0.59267104",
"0.59176725",
"0.5915127",
"0.5906802",
"0.590577",
"0.59012... | 0.74949676 | 0 |
Test that _read_manifest_metadata_v3 will not throw when unable to read metadata. | def test_unpacker_read_manifest_metadata_v3_no_throw(file_open_mock, config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
file_open_mock.side_effect = NameError
p = Unpacker(config, logger_mock)
assert not p._read_manifest_metadata_v3("0869ea50-e437-443f-8cdb-31a350f88e57") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_read_manifest_metadata_for_v3(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n p = Unpacker(config, logger_mock)\n mock_v2 = mocker.patch(\"lta.unpacker.Unpacker._read_manifest_metadata_v2\")\n mock_v2.side_effect = [None]\n mock_v3 = mocker.patch(\"lta.unpacker... | [
"0.6892553",
"0.6883256",
"0.6865995",
"0.65582126",
"0.65180963",
"0.63612777",
"0.6188923",
"0.6170187",
"0.60026217",
"0.59894437",
"0.59743226",
"0.5963816",
"0.59482044",
"0.58974534",
"0.5895962",
"0.5818921",
"0.58149624",
"0.58108026",
"0.5777837",
"0.5769291",
"0.576... | 0.75113803 | 0 |
Test that _clean_outbox_directory will bail when configured not to clean. | def test_unpacker_clean_outbox_directory_bail_early(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
config["CLEAN_OUTBOX"] = "FALSE"
mock_os_scandir = mocker.patch("os.scandir")
p = Unpacker(config, logger_mock)
p._clean_outbox_directory()
mock_os_scandir.assert_not_called() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_clean_outbox_directory_empty(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n mock_os_scandir = mocker.patch(\"os.scandir\")\n mock_os_scandir.return_value.__enter__.return_value = []\n mock_os_remove = mocker.patch(\"os.remove\")\n mock_shutil_rmtree = mocker.p... | [
"0.7589741",
"0.7286968",
"0.71165204",
"0.7106962",
"0.6762901",
"0.65971464",
"0.6574729",
"0.65095353",
"0.64370966",
"0.6377741",
"0.6369253",
"0.6360255",
"0.6349552",
"0.6328343",
"0.6313261",
"0.6300792",
"0.6299647",
"0.62972945",
"0.6236254",
"0.62355155",
"0.6221481... | 0.7928514 | 0 |
Test that _clean_outbox_directory will bail when configured not to clean. | def test_unpacker_clean_outbox_directory_empty(config, mocker, path_map_mock):
logger_mock = mocker.MagicMock()
mock_os_scandir = mocker.patch("os.scandir")
mock_os_scandir.return_value.__enter__.return_value = []
mock_os_remove = mocker.patch("os.remove")
mock_shutil_rmtree = mocker.patch("shutil.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpacker_clean_outbox_directory_bail_early(config, mocker, path_map_mock):\n logger_mock = mocker.MagicMock()\n config[\"CLEAN_OUTBOX\"] = \"FALSE\"\n mock_os_scandir = mocker.patch(\"os.scandir\")\n p = Unpacker(config, logger_mock)\n p._clean_outbox_directory()\n mock_os_scandir.assert... | [
"0.79289985",
"0.72874457",
"0.71171397",
"0.7107507",
"0.6762995",
"0.6597322",
"0.6574195",
"0.65085953",
"0.64376104",
"0.63765323",
"0.6369071",
"0.63603437",
"0.6349144",
"0.6328027",
"0.6311919",
"0.6299938",
"0.62991375",
"0.62963414",
"0.6236318",
"0.62355804",
"0.621... | 0.7590166 | 1 |
Converts a packed float RGB format to an RGB list | def float_to_rgb(self, float_rgb):
s = struct.pack('>f', float_rgb)
i = struct.unpack('>l', s)[0]
pack = ctypes.c_uint32(i).value
r = (pack & 0x00FF0000) >> 16
g = (pack & 0x0000FF00) >> 8
b = (pack & 0x000000FF)
color = [r, g, b]
return color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_color(raw_color) -> list[float]:\n if isinstance(raw_color, str):\n return list(to_rgba(raw_color))\n return list(raw_color)",
"def RGB255(RGB):\r\n return [round((RGB[0]*255), 2),\r\n round((RGB[1]*255), 2),\r\n round((RGB[2]*255), 2)]",
"def int2color(x):\n ... | [
"0.67312515",
"0.66181636",
"0.6467763",
"0.63019437",
"0.62769794",
"0.61972845",
"0.616402",
"0.6141077",
"0.6086466",
"0.6074755",
"0.6063334",
"0.6045226",
"0.60361975",
"0.60147935",
"0.59682196",
"0.5953603",
"0.595135",
"0.5947158",
"0.59371084",
"0.59325135",
"0.58769... | 0.75988054 | 0 |
Categorize the email accounts. | def email_category(x):
MAP = {'msn':'msn',
'yahoo':'yahoo',
'gmail':'gmail',
'hotmail':'hotmail',
'live.com':'hotmail',
'.edu':'education',
'comcast':'comcast_aol_att',
'aol.com':'comcast_aol_att',
'att.net':'comcast_aol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, email, application_category):",
"def accounts():",
"def categories(self):\n pass",
"def get_accounts_for_emails(cls, emails):\n return cls.get_by_key_name(['<%s>' % email for email in emails])",
"def get_multiple_accounts_by_email(cls, emails):\n results = {}\n keys = []\n ... | [
"0.54823273",
"0.5180047",
"0.51556504",
"0.50444186",
"0.48520416",
"0.48209494",
"0.47935078",
"0.47873983",
"0.47819233",
"0.4690984",
"0.46311715",
"0.4622466",
"0.45883647",
"0.4582181",
"0.4575058",
"0.45619455",
"0.45484143",
"0.4541372",
"0.45172882",
"0.4490564",
"0.... | 0.60974425 | 0 |
Prepare and return carbon socket. | def __get_carbon_socket(self):
if not self.__carbon_socket:
self.__carbon_socket = socket.socket()
self.__carbon_socket.connect((self.server, self.carbon_port))
return self.__carbon_socket | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _carbon(host, port):\n carbon_sock = None\n\n try:\n carbon_sock = socket.socket(\n socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP\n )\n\n carbon_sock.connect((host, port))\n except OSError as err:\n log.error(\"Error connecting to %s:%s, %s\", host, port... | [
"0.6502791",
"0.623138",
"0.60780895",
"0.589238",
"0.5681348",
"0.56679773",
"0.5598785",
"0.5590324",
"0.5542243",
"0.5535573",
"0.549113",
"0.5473068",
"0.54670733",
"0.5453171",
"0.5452635",
"0.5439816",
"0.5439225",
"0.53962433",
"0.534416",
"0.53342634",
"0.53285605",
... | 0.73319286 | 0 |
Load list of available metrics from Grafana. | def list_metrics(self, filters=""):
metrics = urllib.request.urlopen( \
"http://%s:%s/api/datasources/proxy/1/metrics/index.json" % \
(self.server, self.grafana_port)).read()
metrics = json.loads(metrics)
metrics = filter_metrics_list(metrics, filters)
return metr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_metrics(self):\n pass",
"def loadFeeds(self):\n\n metrics = self.config['metrics']\n for metric in metrics:\n metricConf = self.config['metrics'][metric]\n metricConf['name'] = metric\n source = metricConf['source']['driver']\n if 'metrics... | [
"0.6842371",
"0.64784294",
"0.6404118",
"0.63857615",
"0.6282738",
"0.6261602",
"0.6179737",
"0.6140208",
"0.61263037",
"0.6082021",
"0.59748083",
"0.58999896",
"0.5897629",
"0.5883824",
"0.5880064",
"0.58514386",
"0.5797277",
"0.57547307",
"0.57453907",
"0.5734091",
"0.57322... | 0.6743832 | 1 |
Generate and push metrics based on cfg. | def generate_metrics(self, cfg):
# filter available metrics based on cfg"[filter"]
for metric in self.list_metrics(cfg["filter"]):
LOGGER.info("Generating metrics for: %s", metric)
dg = usmqe_cmdg.data_generators.DataGenerators(metric, cfg["since"], cfg["until"])
# it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_metrics(config):\n metrics = []\n if config.get(\"data.output.label.choice\") == \"segmentation\":\n metrics = [\n ext_sm.metrics.IOUScore(),\n ext_sm.metrics.FScore(beta=0.5),\n ext_sm.metrics.FScore(beta=2),\n ]\n metrics = []\n elif confi... | [
"0.631445",
"0.5999573",
"0.59453815",
"0.59003264",
"0.58321077",
"0.58117884",
"0.56931746",
"0.56553",
"0.56425506",
"0.5638092",
"0.5601853",
"0.5535858",
"0.55330646",
"0.55151415",
"0.5507236",
"0.5408201",
"0.5405444",
"0.53615457",
"0.5357003",
"0.5342007",
"0.5326961... | 0.77454835 | 0 |
Handle message events from Discord. Presently, handles two separate functionalities; one manages !rbot commands and the other simply parses appropriate string productions into subreddit | async def on_message(message):
if message.author.name == client.user.name:
return
text = message.content
pattern = re.compile(r'(?<!/)\br/([A-Z]|[a-z]|[0-9])+([A-Z]|[a-z]|[0-9]|_)*')
match = pattern.search(text)
subreddit = ''
if match is None:
print('No subreddit pattern provided in message text: {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_command(command, channel):\n default_response = \"Not sure what you mean. Try *{}*.\".format(EXAMPLE_COMMAND)\n\n response = None\n\n if command.startswith(EXAMPLE_COMMAND):\n response = \"Sure...write some code then I can do that!\"\n elif command.startswith(\"date\"):\n respo... | [
"0.6607252",
"0.6544112",
"0.65416676",
"0.653821",
"0.6518347",
"0.6487856",
"0.6439922",
"0.6429166",
"0.6425389",
"0.64215636",
"0.6379654",
"0.6372129",
"0.6368443",
"0.6333835",
"0.63122857",
"0.6290473",
"0.6281352",
"0.6254567",
"0.6245724",
"0.6226384",
"0.6221189",
... | 0.79917675 | 0 |
Find tags that point to this commit ref_dict maps tag names ('refs/tags/...') to sha's | def find_tags(self, commit, repo):
ref_dict = repo.repo.refs.as_dict()
tags = []
for tag, tag_id in [(t, ref_dict[t]) for t in repo.tags]:
obj, obj_id = repo.repo[tag_id], None
if isinstance(obj, Tag):
_, obj_id = obj.object
if isinstance(obj, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tags(self):\n return self.get_url_data(self.api_url + 'refs/tags')",
"def refs_to(cls, sha1, repo):\n matching = []\n for refname in repo.listall_references():\n symref = repo.lookup_reference(refname)\n dref = symref.resolve()\n oid = dref.target\n ... | [
"0.62403345",
"0.6116644",
"0.6014842",
"0.58929694",
"0.5848022",
"0.5842315",
"0.5691861",
"0.56649595",
"0.55364084",
"0.55348146",
"0.5497391",
"0.5489217",
"0.5463652",
"0.5425813",
"0.5411417",
"0.5398828",
"0.53734875",
"0.53405094",
"0.5331109",
"0.5315611",
"0.528969... | 0.7510693 | 0 |
Find branches that point to this commit ref_dict maps tag names ('refs/tags/...') to sha's | def find_branches(self, commit, repo):
ref_dict = repo.repo.refs.as_dict()
branches = []
for branch, branch_id in [(b, ref_dict[b]) for b in repo.branches]:
obj = repo.repo[branch_id]
if commit.id == obj.id:
branches.append((branch, obj))
return br... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_tags(self, commit, repo):\n ref_dict = repo.repo.refs.as_dict()\n tags = []\n for tag, tag_id in [(t, ref_dict[t]) for t in repo.tags]:\n obj, obj_id = repo.repo[tag_id], None\n if isinstance(obj, Tag):\n _, obj_id = obj.object\n if isin... | [
"0.6522685",
"0.6117245",
"0.6058106",
"0.6013241",
"0.59181464",
"0.5894208",
"0.5810088",
"0.5795151",
"0.5756926",
"0.5742759",
"0.5655489",
"0.5582779",
"0.55563235",
"0.5528173",
"0.5512294",
"0.5504516",
"0.5493247",
"0.54874253",
"0.5472698",
"0.54704016",
"0.54211396"... | 0.7307467 | 0 |
Sets up ACLs on a directory for sandbox support. Noop of the ACLs are already set. | def SetupSandboxAcls(self, directory):
# Import here instead of at the top of the file to prevent issues with
# Telemetry unittests not properly including all dependencies for stuff
# it's testing.
# //chrome/browser/vr/test/
import_dir = os.path.join(
os.path.dirname(__file__), '..', '..', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_dir(self):\n for directory in ['', CERT_DIR_NAME, CRL_DIR_NAME, NEWCERT_DIR_NAME,\n PRIVATE_DIR_NAME]:\n mode = 0o755 if directory != PRIVATE_DIR_NAME else 0o700\n os.mkdir(self.ca_dir + directory, mode=mode)",
"def test_set_get_acls_recursive(self)... | [
"0.6196306",
"0.5923529",
"0.5842131",
"0.5663468",
"0.5636822",
"0.5475791",
"0.53177273",
"0.5316718",
"0.5280822",
"0.5274384",
"0.5231724",
"0.5190451",
"0.517361",
"0.51203406",
"0.5103013",
"0.5068319",
"0.5063383",
"0.50551945",
"0.50448084",
"0.50445795",
"0.5035752",... | 0.61628777 | 1 |
Asks user to enter guess and returns a guess within defined min and max guess range | def check_input(min_guess_range, max_guess_range):
while True:
try:
playerGuess = int(input('enter your guess: '))
assert min_guess_range <= playerGuess <= max_guess_range
except AssertionError:
print('guess should be between {0} - {1}!'.format(min_guess_range, max_guess_range))
except ValueError:
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guess_number(min_guess_range, max_guess_range):\n\tprint(f'guess the number between {min_guess_range} and {max_guess_range}!')\n\treturn check_input(min_guess_range, max_guess_range)",
"def get_guess_from_user(self):\n self.guess_number = input(f\"please guess a number between 1 to {self.difficulty}: ... | [
"0.82719445",
"0.69029313",
"0.6884909",
"0.6877467",
"0.67984104",
"0.6675037",
"0.65230066",
"0.6514835",
"0.64944184",
"0.64870876",
"0.647735",
"0.64380676",
"0.64101094",
"0.6392033",
"0.6388613",
"0.6379732",
"0.63135016",
"0.6312778",
"0.62930226",
"0.62755316",
"0.626... | 0.73224753 | 1 |
Returns a guess that is within defined min and max guess range | def guess_number(min_guess_range, max_guess_range):
print(f'guess the number between {min_guess_range} and {max_guess_range}!')
return check_input(min_guess_range, max_guess_range) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_guess_value(min_guess_range=1, max_guess_range=10):\n\treturn random.randrange(min_guess_range, max_guess_range), min_guess_range, max_guess_range",
"def get_guess(current_low, current_high):\n guess = (current_low + current_high) // 2\n return guess",
"def check_input(min_guess_range, max_g... | [
"0.7134362",
"0.6692091",
"0.6492073",
"0.63647914",
"0.6293252",
"0.6205491",
"0.61944205",
"0.6039712",
"0.59171355",
"0.59032553",
"0.5901379",
"0.5886149",
"0.5885227",
"0.58848464",
"0.58821833",
"0.5871746",
"0.58637625",
"0.58529526",
"0.583199",
"0.58230156",
"0.57949... | 0.74645835 | 0 |
Returns a random number to guess between a defined min and max range. Min and Max range can be custom. Default values are 1 10 | def generate_guess_value(min_guess_range=1, max_guess_range=10):
return random.randrange(min_guess_range, max_guess_range), min_guess_range, max_guess_range | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand_int(min=0, max=100):\n\n num = random.random() * (max - min) + min\n return round(num)",
"def GetRandomNumberFromLimits():\n smaller = int(input(\"Enter the smaller number: \"))\n larger = int(input(\"Enter a larger number: \"))\n return random.randint(smaller, larger)",
"def random_... | [
"0.76161236",
"0.75509644",
"0.7517967",
"0.740434",
"0.73546493",
"0.7202086",
"0.7185706",
"0.70262927",
"0.7018812",
"0.7011188",
"0.6972874",
"0.6880558",
"0.6832716",
"0.68269193",
"0.681806",
"0.68124956",
"0.6784969",
"0.67752266",
"0.67384106",
"0.6733601",
"0.673004"... | 0.82935673 | 0 |
Starts running the blink animation. This command is a noop if the animation is already started. | def start_animation(self, initial_delay=True):
if self._run_animation:
# Animation already scheduled.
return
self._run_animation = True
self._animation_task = self._scheduler.schedule(
self._toggle_blink, delay_ms=self._update_interval_ms) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_animation(self):\n\t\ttime.sleep(1)\n\t\tself.fishbowl.animate_balls()",
"def do_animations(self):\n self.animate_bloop(700, 160, 50)",
"def start(self):\n\t\tif self._start is not None:\n\t\t\traise RuntimeError('Animations can only be run once')\n\t\tself._start = 1\t\n\t\t# start time\n\t\t... | [
"0.6864446",
"0.6314133",
"0.6162421",
"0.61600614",
"0.609783",
"0.60687596",
"0.59246624",
"0.5884644",
"0.58791906",
"0.56971717",
"0.5668077",
"0.56629616",
"0.5560703",
"0.5531899",
"0.54622275",
"0.54411113",
"0.54126674",
"0.5389357",
"0.538864",
"0.53759867",
"0.53715... | 0.7371076 | 0 |
Manually step blink the animation. | def step_animation(self):
self._light.toggle() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blink(self):\n self.n_blinks += 1\n if self.n_blinks > self.max_blinks:\n self.active = False",
"def blink(self):\n\n # Dict hack since nonlocal doesn't exist in py2.7\n blinks = {'': 3}\n period = 150\n\n def _red_callback():\n self.window.stat... | [
"0.70736086",
"0.687366",
"0.6829606",
"0.68264735",
"0.68243945",
"0.68216884",
"0.6816459",
"0.6707035",
"0.66966826",
"0.66900396",
"0.64363587",
"0.6371583",
"0.634869",
"0.6344733",
"0.63048106",
"0.62374896",
"0.6218782",
"0.6192973",
"0.6192289",
"0.61368537",
"0.61199... | 0.758761 | 0 |
Returns True if the blink animation is scheduled/running. | def is_animation_running(self):
return self._run_animation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blinking (self):\n\t\treturn self.__blink_timeout != None",
"def is_running(self):\n return self.style['position'][0] == 'running()'",
"def blink_interval (self):\n\t\tif self.blinking():\n\t\t\t#print \"BLINK\"\n\t\t\tself.__blink_phase += 0.1\n\t\t\tif self.__blink_phase > 0.7:\n\t\t\t\tself.__bli... | [
"0.7852205",
"0.72244287",
"0.7162112",
"0.7001169",
"0.68594503",
"0.658761",
"0.64561003",
"0.64360917",
"0.6402631",
"0.6400231",
"0.63969755",
"0.6367294",
"0.6350837",
"0.6329001",
"0.62703735",
"0.6263845",
"0.621835",
"0.6201981",
"0.6176478",
"0.61657846",
"0.6162432"... | 0.74028075 | 1 |
Create a participant and join task in pycloudmessenger. | def create_worker_join_task(self, id, user_password='Tester', user_org='Musketeer'):
created = False
while not created:
try:
self.task_name = self.get_current_task_name()
print(self.task_name)
config = 'cloud'
version... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_worker_and_join_task(self, user_name, user_password, task_name, display, logger, user_org='TREE', verbose=False):\r\n config = 'cloud'\r\n created = False\r\n while not created:\r\n try:\r\n # Create context for the cloud communications\r\n f... | [
"0.6704113",
"0.6407724",
"0.6189387",
"0.60461444",
"0.60051984",
"0.58677226",
"0.58455616",
"0.5721235",
"0.5690737",
"0.566567",
"0.5633558",
"0.56189233",
"0.55986845",
"0.5585254",
"0.5573334",
"0.55259395",
"0.5523978",
"0.54599917",
"0.54470474",
"0.5394258",
"0.53731... | 0.64877224 | 1 |
Create a participant and join task in pycloudmessenger. Used for POMs 1, 2 and 3. | def create_worker_and_join_task(self, user_name, user_password, task_name, display, logger, user_org='TREE', verbose=False):
config = 'cloud'
created = False
while not created:
try:
# Create context for the cloud communications
ffl.Factory.regist... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_participant(name='Not Brian', email='test@email.com') ->\\\n Participant:\n participant = Participant(name=name, email=email)\n return participant",
"def create_worker_join_task(self, id, user_password='Tester', user_org='Musketeer'):\r\n created = False\r\n while not create... | [
"0.61137635",
"0.6025689",
"0.5766859",
"0.56972104",
"0.56946117",
"0.5640265",
"0.5479885",
"0.54327685",
"0.5423514",
"0.54106396",
"0.53965014",
"0.5339241",
"0.53114873",
"0.53066635",
"0.53044194",
"0.5256036",
"0.5247076",
"0.52256536",
"0.5213109",
"0.5203414",
"0.516... | 0.6277691 | 0 |
Wait for all the workers to join a given task. | def wait_for_workers(self):
stop = False
workers = self.aggregator.get_participants()
while not stop:
try:
with self.aggregator:
resp = self.aggregator.receive(1)
participant = resp.notification['participant']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join(self, timeout=None):\n self.all_tasks_done.acquire()\n try:\n while self.unfinished_tasks:\n self.all_tasks_done.wait(timeout) # changed here\n finally:\n self.all_tasks_done.release()",
"def wait_completion(self):\r\n self.tasks.join()",... | [
"0.71965927",
"0.69442743",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.6935114",
"0.68235236",
"0.6484635",
"0.6447578",
"0.64142144",
"0.64057785",
"0.6359411",
"0.62274563",
"0.621065",
"0.62009966",
"0.619399"... | 0.71357846 | 1 |
Enumerates the list of items corresponding to the given `list_id` found in the World Bank's wds API. | def get_wb_curated_list(list_id):
r = requests.get('https://search.worldbank.org/api/v2/wds')
b = BeautifulSoup(r.content, 'html.parser')
item_list = b.find('select', id=list_id).find_all('option')
g = {re.sub(r'[^a-z]+', '_', o.text.lower()).strip('_'): o.text for o in item_list}
for k, v in g.it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_list(list_id):\n\n to_do_list = ToDoList.query.get(list_id)\n\n shared_lists = SharedUsersLists.query.filter(SharedUsersLists.shared_list_id==to_do_list.list_id)\n num_users = len({shared_list.shared_user_id for shared_list in shared_lists})\n\n return render_template(\"items.html\", \n ... | [
"0.5704703",
"0.55885726",
"0.55359554",
"0.5458047",
"0.5392294",
"0.53841865",
"0.5340373",
"0.53304833",
"0.52451247",
"0.51591915",
"0.51591915",
"0.51591915",
"0.51396877",
"0.5107217",
"0.5081919",
"0.507648",
"0.50747544",
"0.5066142",
"0.5056513",
"0.5032338",
"0.5027... | 0.6896623 | 0 |
Yield all template style names. | def _styles(self):
for filename in os.listdir(self.dirpath):
name, ext = os.path.splitext(filename.lower())
if ext in self.EXTENSIONS and name != self.DEFAULT:
yield name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_styles(formatter: HtmlFormatter, *, prefix: str) -> Iterator[str]:\n for line in formatter.get_linenos_style_defs():\n yield f\"{prefix} {line}\"\n yield from formatter.get_background_style_defs(prefix)\n yield from formatter.get_token_style_defs(prefix)",
"def style_lines(self):\n ... | [
"0.6425035",
"0.6199566",
"0.58800036",
"0.57705873",
"0.56939477",
"0.544067",
"0.53518593",
"0.53190124",
"0.5242418",
"0.521749",
"0.5196322",
"0.51627713",
"0.51461536",
"0.51005906",
"0.50973916",
"0.5086407",
"0.5075316",
"0.5064818",
"0.50534266",
"0.50510406",
"0.5021... | 0.69882464 | 0 |
Get htmlfile names in 'html'directory | def get_html_filenames():
filenames = []
file_folder = os.getcwd() + "\\htmls"
for file in os.listdir(file_folder):
if file.endswith(".html"):
filenames.append('htmls\\' + file)
return filenames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHTMLFileNames(self):\n HTMLFiles = []\n for _file in os.listdir(self.dir):\n if _file.lower().endswith(\".html\"):\n HTMLFiles.append(_file)\n elif _file.lower().endswith(\".htm\"):\n HTMLFiles.append(_file)\n HTMLFiles.append(\"statis... | [
"0.84493315",
"0.78294855",
"0.76450336",
"0.70340323",
"0.7033795",
"0.6888103",
"0.6686301",
"0.6508017",
"0.6462853",
"0.636859",
"0.6324661",
"0.6323666",
"0.6221088",
"0.6218619",
"0.6204112",
"0.61443794",
"0.60680825",
"0.6054292",
"0.5941045",
"0.5941045",
"0.5918693"... | 0.8740226 | 0 |
create a new body of text using random keys and values from the trigrams_dict (tris) | def trigrams_to_new_text(tris):
new_text_list = []
target_length = 50
current_key = random.choice(list(tris.keys()))
new_text_list.extend(current_key)
while len(new_text_list) < target_length:
list_of_candidates = tris[current_key]
third_word = random.choice(list_of_candidates)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_trigrams(texts,trigram_mod,bigram_mod):\n return [trigram_mod[bigram_mod[doc]] for doc in texts]",
"def make_story(pre_trigrms):\n # print(pre_trigrms)\n word_index = {}\n for counter, word in enumerate(pre_trigrms):\n # print(\"=======counter, word==========\",counter, word)\n ... | [
"0.6745469",
"0.63461035",
"0.6230079",
"0.6214213",
"0.620982",
"0.6110247",
"0.6067855",
"0.6000509",
"0.59491956",
"0.5935895",
"0.5924606",
"0.5901294",
"0.5884166",
"0.588225",
"0.58709216",
"0.586009",
"0.58476764",
"0.5813717",
"0.58109707",
"0.57962215",
"0.57910293",... | 0.7578781 | 0 |
Second moment of area for an anglesection beam a and b are the webbing lengths, i.e. the side lengths of the enclosing rectangle. t is the thickness of the webs Returns I in m^4 | def IAngle(a, b, t):
# http://www.engineersedge.com/material_science/moment-inertia-gyration-7.htm
d = b - t
y = b - (t*(2*d + a) + d**2)/(2*(d+a))
I = 1/3 * (t*y**3 + a*(b-y)**3 - (a-t)*(b-y-t)**3)
return I | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trapezoid_area(lower, leg , upper):\n area = (((upper+lower)/2)*leg)\n return area",
"def triArea(base,height):\n return base * height /2",
"def areaTriangulo(base,altura):\n\treturn (base*altura)/2",
"def area_rectangulo(b,h):\n area = b*h\n print \"El area es: \",area",
"def ar... | [
"0.63339615",
"0.6290283",
"0.6066879",
"0.60653067",
"0.6055789",
"0.5919855",
"0.58179396",
"0.57800967",
"0.57517064",
"0.572945",
"0.56946796",
"0.56218886",
"0.5619065",
"0.56045985",
"0.5568028",
"0.5538325",
"0.5513849",
"0.5508183",
"0.5497758",
"0.54812294",
"0.54713... | 0.64586306 | 0 |
Second moment of area for a round crosssection beam. d is the diameter. Returns I in m^4 | def IRound(d):
# http://en.wikipedia.org/wiki/List_of_area_moments_of_inertia
return np.pi / 4 * (d/2)**4 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(diam):\n radius = diam / 2\n return(pi * radius * radius)",
"def computeA(diameter):\n radius = diameter / 2.0\n return np.pi * (radius**2)",
"def get_diameter(self) -> float:\r\n \r\n return (self.box[3] - self.box[1] + self.box[2] - self.box[0]) / 2",
"def calc_area(diam... | [
"0.6174425",
"0.59519684",
"0.59201103",
"0.5866587",
"0.5842287",
"0.58228916",
"0.5814309",
"0.5725709",
"0.5683347",
"0.5649071",
"0.56077075",
"0.56077075",
"0.5581033",
"0.5566853",
"0.5545892",
"0.5534966",
"0.553202",
"0.5506168",
"0.5490202",
"0.54631525",
"0.54440457... | 0.64716536 | 0 |
Returns the Young Modulus of a material in N/m^2 | def YoungModulus(material):
if material == "mild":
return 200e9
else:
if material == "al":
return 69e9
else:
raise ValueError("Invalid material `"+material+"'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_young_modulus(dataset: np.ndarray) -> YoungModulus:\n segment_x_length: int = len(dataset) // 10\n max_derivative_index = np.argmax([\n dataset[i + segment_x_length][1] - dataset[i][1]\n for i in range(len(dataset) - segment_x_length)\n ])\n first_point = dataset[max_derivative_... | [
"0.67148286",
"0.61187845",
"0.58572924",
"0.5819239",
"0.579422",
"0.5661844",
"0.559946",
"0.5591879",
"0.55850786",
"0.5577663",
"0.5567218",
"0.55623007",
"0.5491746",
"0.5478498",
"0.5471267",
"0.5455068",
"0.54468375",
"0.54108715",
"0.54105854",
"0.5386188",
"0.5383324... | 0.8423878 | 0 |
Returns the density of a material in kg/m^3 | def Density(material):
if material == "mild":
return 7850.0
else:
if material == "al":
return 2700.0
else:
raise ValueError("Invalid material `"+material+"'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return (1e-3*self.molar_mass) * self.pressure / (gas_constant * self.temperature) # kg/m^3",
"def density_kg_m3(self):\n return self._density_kg_m3",
"def density_g_cm3(self):\n return self._density_kg_m3 / 1000.0",
"def electron_density_per_m3(self):\n return... | [
"0.78450173",
"0.7577004",
"0.75337845",
"0.75139385",
"0.68572533",
"0.67514986",
"0.6707994",
"0.67074585",
"0.66710615",
"0.6592827",
"0.6582313",
"0.6472921",
"0.6445674",
"0.6445674",
"0.6445674",
"0.6412132",
"0.633474",
"0.63141286",
"0.6308918",
"0.6267133",
"0.623077... | 0.7671926 | 1 |
Returns the Euler buckling force of a beam. I is the second moment of area E is the Young Modulus L is the uncorrected beam length It is assumed that the beam will be setup as a vertical cantilever. | def EulerBucklingForce(I, E, L):
# http://en.wikipedia.org/wiki/Buckling
K = 2.0 # for a vertical cantilever
F = np.pi**2 * E*I / (K*L)**2
return F | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_force(self):\n displ = self.get_displ()\n equil = displ / np.linalg.norm(displ) * self.L0\n return self.k * (displ - equil)",
"def main_beam_eff(beam=1, ZA=0, frequency=1400.): # apply the frequency at 1400\n D = 300 # m\n n_R = 1.0\n lam = 299792458./(1e6*frequency)\n th... | [
"0.5730016",
"0.5696926",
"0.5672615",
"0.56207347",
"0.5585775",
"0.5474149",
"0.54311466",
"0.54287106",
"0.5424067",
"0.53959465",
"0.53862375",
"0.5383065",
"0.5340565",
"0.53288513",
"0.5264461",
"0.5257924",
"0.5251172",
"0.52255565",
"0.5214405",
"0.5213214",
"0.520564... | 0.773737 | 0 |
Return the maximum height of a freestanding column made from this material. | def MaxColumn(I, E, d, ro):
# http://en.wikipedia.org/wiki/Buckling
B = 1.86635
g = 9.81
h = (9 * B**2 * E*I / (4*ro*g*np.pi * (d/2)**2))**(1/3)
return h | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n yy = self.yy\n return max(yy) - min(yy)",
"def max_height(self) -> int:\n return UIMetric.parse(self.props.max_height).to_pixels(self.parent.height)",
"def get_height(self) -> int:\n return int(self._surface.get_height())",
"def max_col(self):\n return s... | [
"0.67684513",
"0.67097926",
"0.6672111",
"0.6611079",
"0.6606086",
"0.655056",
"0.64820045",
"0.64599043",
"0.6417942",
"0.6411152",
"0.6397831",
"0.6371955",
"0.6367346",
"0.63524234",
"0.63524234",
"0.63520205",
"0.6351878",
"0.6351878",
"0.6343721",
"0.6335481",
"0.6333378... | 0.68725646 | 0 |
Returns the deflection of a horizontal cantilever of length L made from the material described by I and E, under a distributed uniform load q. | def BeamDeflection(I, E, L, q):
w = q * L**4 / (8*E*I)
return w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def EulerBucklingForce(I, E, L):\n # http://en.wikipedia.org/wiki/Buckling\n K = 2.0 # for a vertical cantilever\n F = np.pi**2 * E*I / (K*L)**2\n return F",
"def uelbeam2DU(coord, I, Emod):\r\n vec = coord[1, :] - coord[0, :]\r\n nx = vec[0]/np.linalg.norm(vec)\r\n ny = vec[1]/np.linalg.no... | [
"0.55021435",
"0.53189874",
"0.52113706",
"0.5087749",
"0.50627816",
"0.5025136",
"0.4990624",
"0.4911095",
"0.4907491",
"0.481666",
"0.48159784",
"0.47943085",
"0.47663116",
"0.47565433",
"0.47562125",
"0.4755256",
"0.4752054",
"0.46714708",
"0.46163446",
"0.4614189",
"0.461... | 0.6460688 | 0 |
Returns a dictionary containing a `PIL` image object for every number in the specified font image `font_name`.jpg, callable in dictionary format. | def create_font(font_name, fit = True):
font = {}
try:
numbers = Image.open(fonts_path + font_name + ".jpg")
if fit:
numbers = images.fit_to_display(numbers, True)
width, height = numbers.size
font["d"] = Image.open(fonts_path + "degree.jpg")
font["d"] = image... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_font_dict(*a, **kw):\n return get_font_dict(*a, **kw)",
"def get_font_dict(f):\n return tk_font.Font(font=f).actual()",
"def get_fonts():\n\n fontpath = \"/usr/share/fonts/truetype/freefont/\"\n font1 = \"FreeSansBold.ttf\"\n pfont = {}\n pfont['big'] = ImageFo... | [
"0.60353744",
"0.5992",
"0.5921621",
"0.58782345",
"0.5625733",
"0.55315936",
"0.53956556",
"0.5386595",
"0.5384754",
"0.53655636",
"0.52947056",
"0.52919567",
"0.5260362",
"0.52113074",
"0.517837",
"0.5178138",
"0.5172966",
"0.51706356",
"0.5159321",
"0.51376754",
"0.5136626... | 0.7058921 | 0 |
Checks if guessed answer is correct | def check_if_correct(self, guess):
answer = MCQAnswer.objects.get(id=guess)
if answer.correct is True:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleGuess(self, guess):\n res = self.checkAnswer(guess)\n if res is True:\n print (\"Correct!\")\n return True\n print (\"Bulls: %s, Cows: %s\" % res)\n return False",
"def check(self, answer):\n return self.answer == answer",
"def check_answer... | [
"0.76002586",
"0.7309093",
"0.724927",
"0.72046506",
"0.7164317",
"0.7019194",
"0.70176375",
"0.6989743",
"0.6985875",
"0.69786674",
"0.6902333",
"0.68926233",
"0.6872335",
"0.68639845",
"0.6859119",
"0.68505853",
"0.68262213",
"0.6813424",
"0.68111575",
"0.6780529",
"0.67449... | 0.736174 | 1 |
Orders the options of each question as specified. | def order_answers(self, queryset):
if self.answer_order == 'content':
return queryset.order_by('content')
if self.answer_order == 'random':
return queryset.order_by('?')
if self.answer_order == 'none':
return queryset.order_by('None') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortChoices(self):\n self.formatList.sort()",
"def sorted_options(options):\n return sorted(options, key=lambda _o: _o.number)",
"def get_ordering_options(self):\n raise NotImplementedError()",
"def sort(self):\n for section, section_items in self.items():\n if sorted(s... | [
"0.71150845",
"0.6452089",
"0.64219284",
"0.6252214",
"0.6112026",
"0.59948385",
"0.5988947",
"0.5984478",
"0.5867033",
"0.5771361",
"0.5764251",
"0.573852",
"0.5600011",
"0.5583496",
"0.5576887",
"0.5572281",
"0.5550145",
"0.5514063",
"0.54813755",
"0.5480601",
"0.5462634",
... | 0.6749732 | 1 |
checks type of question and increments score | def add_to_score(self, mcq, question):
if mcq:
question_obj = MCQQuestion.objects.get(id=question)
else:
question_obj = QuestionOne.objects.get(id=question)
self.score += int(question_obj.marks)
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quiz():\n\n global score\n\n questions = [question1,question2,question3,question4,question5,question6,question7,question8,question9,question10]\n\n for question in questions:\n if question() == 1:\n score += 1\n results()",
"def administer(self):\n\n score = 0.0\n ... | [
"0.71389204",
"0.6525334",
"0.64161056",
"0.6413131",
"0.6407072",
"0.63878745",
"0.63627917",
"0.63142234",
"0.63098717",
"0.6262972",
"0.625054",
"0.624885",
"0.6153965",
"0.6131386",
"0.6047595",
"0.6041027",
"0.60368663",
"0.60297614",
"0.6017702",
"0.6006743",
"0.5952434... | 0.6753305 | 1 |
Marks quiz as completed to prevent further attempts. | def mark_quiz_complete(self):
self.end = now()
self.complete=True
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed(self, completed):\n\n self._completed = completed",
"def completed(self, completed):\n\n self._completed = completed",
"def completed(self, completed):\n\n self._completed = completed",
"def mark_as_done(self):\n self.status = \"DONE\"",
"def mark_as_done(self):\n ... | [
"0.666438",
"0.666438",
"0.666438",
"0.6601487",
"0.633473",
"0.62769043",
"0.61434376",
"0.6136244",
"0.60896957",
"0.6046479",
"0.6035201",
"0.6013619",
"0.601079",
"0.60057056",
"0.59889686",
"0.59837306",
"0.5968197",
"0.59507734",
"0.59377795",
"0.5916138",
"0.58859855",... | 0.7973157 | 0 |
Adds answer submitted by user to the useranser model | def add_user_answer(self, question, guess, correct):
user_answer = UserAnswer()
user_answer.user = self.user
user_answer.quiz = self.quiz
user_answer.question = question
user_answer.answer = guess
user_answer.correct = correct
user_answer.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_answer(self):\n # Create users\n user = self.create_user(self.user)\n other_user = self.create_user(self.other_user)\n\n # Create question\n question = self.create_question(self.question, other_user.id)\n\n # Add answers\n answer = self.create_answer(self.an... | [
"0.691368",
"0.6903137",
"0.6866147",
"0.6613287",
"0.6463317",
"0.6436483",
"0.64179677",
"0.63023746",
"0.6301039",
"0.6299443",
"0.62993157",
"0.6293704",
"0.61399835",
"0.61233646",
"0.6122987",
"0.61187315",
"0.6116005",
"0.61153954",
"0.6089595",
"0.60716236",
"0.606884... | 0.75195974 | 0 |
Wrap a file descriptor's read with a partial function which schedules after each read. This can prevent eventlet thread starvation. | def cooperative_read(fd):
def readfn(*args):
result = fd.read(*args)
sleep(0)
return result
return readfn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stay(read_func, *args, **kwargs):\n def wrapper(mm, *args, **kwargs):\n idx = mm.tell()\n ret = read_func(mm, *args, **kwargs)\n mm.seek(idx)\n return ret\n return wrapper",
"def read(fd, name, *args, version=None, **kwargs):\n\treturn access('read', fd, name, *args, version=version, **kwargs)"... | [
"0.5972302",
"0.58320224",
"0.5788182",
"0.5618918",
"0.5511519",
"0.54880667",
"0.548475",
"0.54720575",
"0.54264635",
"0.54044545",
"0.5366987",
"0.52953213",
"0.5147776",
"0.51402205",
"0.51109",
"0.5103628",
"0.5075668",
"0.5069435",
"0.50356865",
"0.50146556",
"0.4996181... | 0.7639875 | 0 |
The library.txt file is generated with that method | def makeLibrary(self):
#------------------------------------------ Instance for the output file
outputFile = open("%s/%s" % (self.sceneryPath,self.libTxtFileName),"w")
#------------------------------------------------------ write the header
for line in self.header:
outputFile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, filename=None):\n\n if not filename:\n filename = self.name+\".lib\"\n\n to_write = []\n\n to_write += \"EESchema-LIBRARY Version 2.3\\n#encoding utf-8\\n\"\n\n to_write += self.output()\n\n to_write += \"#\\n#End Library\\n\"\n\n library_file = o... | [
"0.64733523",
"0.62905824",
"0.62651056",
"0.6057636",
"0.6057636",
"0.5972573",
"0.59236306",
"0.5857377",
"0.5805822",
"0.5670919",
"0.5644121",
"0.562789",
"0.5592982",
"0.5586372",
"0.5536091",
"0.5527501",
"0.5527252",
"0.5517965",
"0.55090505",
"0.5487517",
"0.546953",
... | 0.66664284 | 0 |
A function to parse PMID from a given Pubmed Article tree | def parse_pmid(pubmed_article):
medline = pubmed_article.find("MedlineCitation")
if medline.find("PMID") is not None:
pmid = medline.find("PMID").text
return pmid
else:
article_ids = pubmed_article.find("PubmedData/ArticleIdList")
if article_ids is not None:
pmid ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_pmid(pmid):\n try:\n article = Article.parse_pmid(pmid)\n print(json.dumps(article.to_dict(), indent=4))\n except Exception as e:\n logger.error('cannot parse %s', pmid)\n logger.exception(e)\n return 0",
"def get_pubmed(pmid: str) -> Mapping[str, Any]:\n\n doc =... | [
"0.73570246",
"0.65713143",
"0.6387604",
"0.63388264",
"0.6312597",
"0.6289863",
"0.6120879",
"0.60785246",
"0.6000593",
"0.58370835",
"0.58011854",
"0.58005863",
"0.5763148",
"0.57299227",
"0.5724621",
"0.57101184",
"0.5699428",
"0.5697061",
"0.5671142",
"0.56413275",
"0.563... | 0.796262 | 0 |
A function to parse DOI from a given Pubmed Article tree | def parse_doi(pubmed_article):
medline = pubmed_article.find("MedlineCitation")
article = medline.find("Article")
elocation_ids = article.findall("ELocationID")
if len(elocation_ids) > 0:
for e in elocation_ids:
doi = e.text.strip() or "" if e.attrib.get("EIdType", "") == "doi" else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_pubmed_web_tree(tree):\r\n\r\n if tree.xpath('//articletitle') is not None:\r\n title = ' '.join([title.text for title in tree.xpath('//articletitle')])\r\n else:\r\n title = ''\r\n\r\n abstract_tree = tree.xpath('//abstract/abstracttext')\r\n abstract = ' '.join([stringify_chil... | [
"0.6976802",
"0.69305915",
"0.67692757",
"0.65734845",
"0.6276886",
"0.6271696",
"0.62616444",
"0.6156599",
"0.6017145",
"0.59787565",
"0.59582615",
"0.58830047",
"0.57565635",
"0.56651783",
"0.5654048",
"0.5514932",
"0.5514562",
"0.5445093",
"0.54172665",
"0.5397747",
"0.536... | 0.7192857 | 0 |
A function to parse MESH terms from article | def parse_mesh_terms(medline, parse_subs=False):
if parse_subs:
return parse_mesh_terms_with_subs(medline)
if medline.find("MeshHeadingList") is not None:
mesh = medline.find("MeshHeadingList")
mesh_terms_list = [
m.find("DescriptorName").attrib.get("UI", "")
+ ":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseTerms(cmds):\n if len(cmds) != 0:\n print(\"Term\")\n delimit = \"[*|/|%]+\"\n factors = re.split(delimit, cmds[0])\n parseFactors(cmds[0])\n parseTerms(cmds[1:])",
"def parse_mesh_terms_with_subs(medline):\n if medline... | [
"0.64881164",
"0.62840873",
"0.6254708",
"0.60422814",
"0.5957006",
"0.5776982",
"0.5763243",
"0.57585305",
"0.5738282",
"0.57337797",
"0.5732574",
"0.5683419",
"0.56544065",
"0.5641391",
"0.5622923",
"0.56216896",
"0.55864245",
"0.5585782",
"0.55767405",
"0.5551935",
"0.5521... | 0.6414588 | 1 |
A function to parse MESH terms and subterms from article | def parse_mesh_terms_with_subs(medline):
if medline.find("MeshHeadingList") is not None:
mesh = medline.find("MeshHeadingList")
mesh_terms_list = []
for m in mesh.getchildren():
term = m.find("DescriptorName").attrib.get("UI", "") + ":" + \
m.find("DescriptorNa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_mesh_terms(medline, parse_subs=False):\n if parse_subs:\n return parse_mesh_terms_with_subs(medline)\n if medline.find(\"MeshHeadingList\") is not None:\n mesh = medline.find(\"MeshHeadingList\")\n mesh_terms_list = [\n m.find(\"DescriptorName\").attrib.get(\"UI\", \... | [
"0.64122605",
"0.64025384",
"0.6103752",
"0.6023651",
"0.5986627",
"0.59803843",
"0.5936909",
"0.5649527",
"0.5616139",
"0.5603024",
"0.55506754",
"0.5529224",
"0.54751176",
"0.5464779",
"0.54593426",
"0.5452379",
"0.54316574",
"0.5428042",
"0.54266185",
"0.5419184",
"0.54105... | 0.6434661 | 0 |
String split a string from parse_mesh_terms_with_subs() | def split_mesh(mesh):
mesh_list = []
for term in mesh.split("; "):
subs = []
for subterm in term.split(" / "):
ui, descriptor = subterm.split(":")
subs.append((ui, descriptor))
mesh_list.append(subs)
return mesh_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_mesh_terms_with_subs(medline):\n if medline.find(\"MeshHeadingList\") is not None:\n mesh = medline.find(\"MeshHeadingList\")\n mesh_terms_list = []\n for m in mesh.getchildren():\n term = m.find(\"DescriptorName\").attrib.get(\"UI\", \"\") + \":\" + \\\n ... | [
"0.6812198",
"0.65854865",
"0.6580678",
"0.5933108",
"0.58779895",
"0.5688747",
"0.56473017",
"0.5642285",
"0.5628331",
"0.55601037",
"0.554537",
"0.5483551",
"0.5476565",
"0.5472029",
"0.5440364",
"0.54225814",
"0.5419035",
"0.53959453",
"0.53847015",
"0.53758883",
"0.533511... | 0.68090683 | 1 |
Parse Publication types from article | def parse_publication_types(medline):
publication_types = []
publication_type_list = medline.find("Article/PublicationTypeList")
if publication_type_list is not None:
publication_type_list = publication_type_list.findall("PublicationType")
for publication_type in publication_type_list:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_article(el):\n assert len(el) == 1 # We only expect one article record\n el = el[0]\n\n all_tags = [c.tag for c in el.getchildren()]\n title = el.xpath('ArticleTitle')[0].text\n publication_types = [\n pt.text for pt in el.xpath('PublicationTypeList/PublicationType')]\n if al... | [
"0.7313803",
"0.63218784",
"0.60573584",
"0.5765831",
"0.5694005",
"0.56654435",
"0.56604934",
"0.5598379",
"0.55924803",
"0.5574206",
"0.5510022",
"0.54975927",
"0.5441196",
"0.5376045",
"0.5345155",
"0.53228986",
"0.53020364",
"0.52925515",
"0.5289019",
"0.5281766",
"0.5269... | 0.7494804 | 0 |
Parse keywords from article, separated by ; | def parse_keywords(medline):
keyword_list = medline.find("KeywordList")
keywords = list()
if keyword_list is not None:
for k in keyword_list.findall("Keyword"):
if k.text is not None:
keywords.append(k.text)
keywords = "; ".join(keywords)
else:
keyword... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_meta_keywords(self, article):\r\n return self.get_meta_content(article.doc, \"meta[name=keywords]\")",
"def get_article_keywords(article,\n keywords,\n preprocess_type=PreprocessWordType.LEMMATIZE):\n matches = set()\n for word in article.words... | [
"0.66058993",
"0.6597431",
"0.6553142",
"0.65223294",
"0.6405868",
"0.62722445",
"0.62233555",
"0.61550903",
"0.6069308",
"0.6068769",
"0.5960745",
"0.5947075",
"0.59435534",
"0.587642",
"0.58033395",
"0.5772144",
"0.5771494",
"0.5770108",
"0.57658756",
"0.5741952",
"0.573905... | 0.7547382 | 0 |
Parse chemical list from article | def parse_chemical_list(medline):
chemical_list = []
chemicals = medline.find("ChemicalList")
if chemicals is not None:
for chemical in chemicals.findall("Chemical"):
substance_name = chemical.find("NameOfSubstance")
chemical_list.append(
substance_name.attrib... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_article_info(\n pubmed_article, year_info_only, nlm_category, author_list, reference_list, parse_subs=False\n):\n medline = pubmed_article.find(\"MedlineCitation\")\n article = medline.find(\"Article\")\n\n if article.find(\"ArticleTitle\") is not None:\n title = stringify_children(art... | [
"0.6222195",
"0.6024133",
"0.59882087",
"0.59565526",
"0.5684856",
"0.5663086",
"0.56559575",
"0.5621398",
"0.554181",
"0.55378926",
"0.5532693",
"0.5523771",
"0.551324",
"0.54923326",
"0.5442949",
"0.539521",
"0.5378039",
"0.5360074",
"0.5342916",
"0.533946",
"0.53320855",
... | 0.6976527 | 0 |
Parse OtherID from article, each separated by ; | def parse_other_id(medline):
pmc = ""
other_id = list()
oids = medline.findall("OtherID")
if oids is not None:
for oid in oids:
if "PMC" in oid.text:
pmc = oid.text
else:
other_id.append(oid.text)
other_id = "; ".join(other_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_id_to(self):\r\n return self._tokens[3]",
"def test_other_identifier(self):\n other_id_field = \\\n self.record.find('field[@name=\\'other_identifier\\']')\n self.assertEqual(other_id_field.text, 'HOSNUM0000',\n 'other Identifier incorrect')",
... | [
"0.5491049",
"0.537238",
"0.5308199",
"0.52775127",
"0.5275325",
"0.5216522",
"0.5202616",
"0.51684475",
"0.5155948",
"0.51537657",
"0.5152694",
"0.5126574",
"0.51157016",
"0.511525",
"0.5095941",
"0.5084444",
"0.5007452",
"0.5006633",
"0.49894956",
"0.49892694",
"0.49116343"... | 0.7156614 | 0 |
Parse MEDLINE journal information | def parse_journal_info(medline):
journal_info = medline.find("MedlineJournalInfo")
if journal_info is not None:
if journal_info.find("MedlineTA") is not None:
medline_ta = (
journal_info.find("MedlineTA").text or ""
) # equivalent to Journal name
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_journal_article_record(root) -> dict:\n\n # print(\"Root\", root)\n # pmid = root.find(\"PMID\").text\n # print(\"PMID\", pmid)\n # quit()\n\n doc = {\n \"abstract\": \"\",\n \"pmid\": \"\",\n \"title\": \"\",\n \"authors\": [],\n \"pub_date\": \"\",\n ... | [
"0.69463015",
"0.6893685",
"0.67740494",
"0.6446217",
"0.62134707",
"0.6076948",
"0.5894794",
"0.5874047",
"0.58277744",
"0.581124",
"0.57633674",
"0.57528937",
"0.57173485",
"0.5708581",
"0.56820804",
"0.56179523",
"0.55583566",
"0.5532855",
"0.54864424",
"0.5475486",
"0.546... | 0.78397477 | 0 |
Parse Grant ID and related information from a given MEDLINE tree | def parse_grant_id(pubmed_article):
medline = pubmed_article.find("MedlineCitation")
article = medline.find("Article")
grants = article.find("GrantList")
grant_list = list()
if grants is not None:
grants_list = grants.getchildren()
for grant in grants_list:
grant_country... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_other_id(medline):\n pmc = \"\"\n other_id = list()\n oids = medline.findall(\"OtherID\")\n if oids is not None:\n for oid in oids:\n if \"PMC\" in oid.text:\n pmc = oid.text\n else:\n other_id.append(oid.text)\n other_id = \";... | [
"0.566869",
"0.5166036",
"0.5147205",
"0.5087932",
"0.49221995",
"0.48322293",
"0.4799802",
"0.47679526",
"0.47477022",
"0.47342318",
"0.47338164",
"0.47008723",
"0.4680658",
"0.46730265",
"0.46682873",
"0.46682873",
"0.4637865",
"0.46293026",
"0.46226257",
"0.461459",
"0.460... | 0.6662491 | 0 |
Parse MEDLINE authors and their corresponding affiliations | def parse_author_affiliation(medline):
authors = []
article = medline.find("Article")
if article is not None:
author_list = article.find("AuthorList")
if author_list is not None:
authors_list = author_list.findall("Author")
for author in authors_list:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_authors(article):\n author_names = article.find(\"sourcedesc\").findAll(\"persname\")\n authors = []\n for author in author_names:\n firstname = author.find(\"forename\", {\"type\": \"first\"})\n firstname = firstname.text.strip() if firstname is not None else \"\"\n middlen... | [
"0.7243341",
"0.6763486",
"0.65745157",
"0.64651096",
"0.6329514",
"0.62551844",
"0.6240139",
"0.61946684",
"0.615733",
"0.6112369",
"0.61013514",
"0.60567135",
"0.60114396",
"0.59951836",
"0.59820884",
"0.5947064",
"0.5936139",
"0.59209085",
"0.5912814",
"0.59069955",
"0.587... | 0.84362084 | 0 |
Parse references from Pubmed Article Parameter | def parse_references(pubmed_article, reference_list):
references = []
reference_list_data = pubmed_article.find("PubmedData/ReferenceList")
if reference_list_data is not None:
for ref in reference_list_data.findall("Reference"):
citation = ref.find("Citation")
if citation is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_references(article):\n reference_list = []\n references = article.find(\"text\").find(\"div\", attrs={\"type\": \"references\"})\n references = references.find_all(\"biblstruct\") if references is not None else []\n reference_list = []\n for reference in references:\n title = refere... | [
"0.6714518",
"0.60441375",
"0.5868587",
"0.57981247",
"0.5795672",
"0.54941785",
"0.54921067",
"0.5484585",
"0.54596186",
"0.5406544",
"0.53896403",
"0.5357162",
"0.53375167",
"0.52936333",
"0.5255138",
"0.52079666",
"0.518769",
"0.5183244",
"0.51541054",
"0.51126474",
"0.510... | 0.68856055 | 0 |
Parse article nodes from Medline dataset | def parse_article_info(
pubmed_article, year_info_only, nlm_category, author_list, reference_list, parse_subs=False
):
medline = pubmed_article.find("MedlineCitation")
article = medline.find("Article")
if article.find("ArticleTitle") is not None:
title = stringify_children(article.find("Article... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_articles(self, parsed_xml):\n\n # Iterates over every item (article) in xml\n for item in parsed_xml.xpath(\"//item\"):\n\n article = {}\n\n\n article['title'] = self.get_text_or_attr(item, 'title')\n\n\n # The article's categories must be always a list, e... | [
"0.6311608",
"0.63048667",
"0.6302403",
"0.62022054",
"0.60416377",
"0.6017985",
"0.5983129",
"0.5938324",
"0.590473",
"0.58516335",
"0.5845498",
"0.5797115",
"0.57790345",
"0.5755098",
"0.56837875",
"0.567583",
"0.56423163",
"0.56315774",
"0.5606992",
"0.5590542",
"0.5577601... | 0.6315034 | 0 |
Parse XML file from Medline XML format available at | def parse_medline_xml(
path,
year_info_only=True,
nlm_category=False,
author_list=False,
reference_list=False,
parse_downto_mesh_subterms=False
):
with gzip.open(path, "rb") as f:
for event, element in etree.iterparse(f, events=("end",)):
if element.tag == "PubmedArticle"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_medline_xml_file(medline_xml):\n parser = etree.XMLParser(encoding='utf-8')\n tree = etree.parse(medline_xml, parser=parser)\n for citation in tree.iter(tag='MedlineCitation'):\n all_tags = [c.tag for c in citation.getchildren()]\n\n # Article identifiers\n pmc = citation.xp... | [
"0.7497664",
"0.6295463",
"0.6232681",
"0.6040854",
"0.5897063",
"0.5878532",
"0.5848969",
"0.5844884",
"0.57083094",
"0.570209",
"0.5663509",
"0.56471807",
"0.56383073",
"0.5588667",
"0.5586866",
"0.5583017",
"0.55522674",
"0.5533509",
"0.5531271",
"0.55312276",
"0.54943436"... | 0.63142884 | 1 |
Replace clipboard code with parsed version. If to_end is True, open the terminal output file to get the full last shell session, treating bpython and vanilla python the same. | def copy(to_end=False):
# Find a way to generalize this for different systems
if to_end:
with open('/Users/john/Terminal Saved Output', 'r') as f:
output = f.read().replace('bpython', 'Python')
code = output.split('\nPython')[-1]
else:
code = pyperclip.paste()
pyp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(self):\n _, tmp = tempfile.mkstemp()\n with open(tmp, 'w') as f:\n f.write(\"\".join([x + self.newline for x in self.buffer]))\n cledit = os.getenv('EDITOR') or 'vi'\n p = subprocess.Popen([cledit, tmp])\n p.wait()\n buffer = editor.contents(tmp)\n ... | [
"0.5498853",
"0.5077291",
"0.5049165",
"0.49515352",
"0.48975712",
"0.48876852",
"0.48280418",
"0.46903878",
"0.46874332",
"0.468168",
"0.46521688",
"0.46332717",
"0.4594648",
"0.45710236",
"0.45462614",
"0.4519466",
"0.45044506",
"0.45042783",
"0.45006523",
"0.4475485",
"0.4... | 0.7554083 | 0 |
Method thread function that gathers each of Prep's functionality Threading is implemented in the main method below with exception handling | def thread_function():
while True:
try:
s.sanitization()
try:
t.yeast_temp()
try:
w.read_weight_grains()
try:
w.read_weight_hops()
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prep_main():\n time.sleep(sleep_time * 2)\n thread_list = []\n # to create up to 5 Threads\n for x in range(5):\n # status_log = \"{\\\"batch_id\\\":\\\"1\\\", \\\"brew_batch_stage\\\":\\\"Preparation\\\", \\\"log\\\":\\\"Starting Preparation Process\\\"}\"\n # ServiceNowLog.ServiceNo... | [
"0.68166006",
"0.6532869",
"0.62666047",
"0.62606984",
"0.60895264",
"0.6061789",
"0.60539746",
"0.60021615",
"0.5888999",
"0.5862415",
"0.58380425",
"0.58310854",
"0.57812005",
"0.5776536",
"0.5760595",
"0.5725798",
"0.5638094",
"0.5627613",
"0.56204855",
"0.55964607",
"0.55... | 0.6687923 | 1 |
Fix tree when XML conversion is not conducted | def _fix_tree(self, output: str):
tag_ptn = "[A-Z][A-Z_]*"
output = re.sub("\s", "", output)
xml = re.sub(f"<({tag_ptn})>", r"[\1 ", output)
xml = re.sub(f"</{tag_ptn}>", r"] ", xml)
def _convert_to_xml(text):
for _ in range(max(text.count("["), text.count("]"))):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean():\n new_tree = None",
"def _fix_treetags(self, tree):\n for element in tree:\n element.tag = element.tag.split('}')[1]\n if len(element.getchildren()) > 0:\n self._fix_treetags(element)\n return tree",
"def cleanup(self):\n for element in ... | [
"0.6874046",
"0.6827174",
"0.64162207",
"0.6379204",
"0.6374269",
"0.6312029",
"0.62933517",
"0.62933517",
"0.61917543",
"0.6075247",
"0.6043416",
"0.6030928",
"0.5990299",
"0.59791905",
"0.5904357",
"0.588181",
"0.5846464",
"0.58095354",
"0.57301277",
"0.56948686",
"0.568893... | 0.7249811 | 0 |
a function to demonstrate how to create and save a bitmap image | def testImage():
width = 200
height = 200
image = BitMap( width, height )
# create a loop in order to draw some pixels
for col in range(width):
if col % 10 == 0: print 'col is', col
for row in range(height):
if col % 10 == 0 or row % 10 == 0:
image.plo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_image(x, y, out, data):\n img = Image.new('RGB', (x, y))\n img.putdata(data)\n img.save(out)",
"def testBinaryImage():\n ALIEN = \"0\"*8 + \"11011011\"*2 + \"0\"*8 + \"00001000\" + \\\n \"01000010\" + \"01111110\" + \"0\"*8\n # this function is imported from cs5png.py\n NUM_R... | [
"0.69351363",
"0.682433",
"0.67990786",
"0.6749489",
"0.64395714",
"0.6397731",
"0.6397731",
"0.6393648",
"0.6389351",
"0.63833565",
"0.6365215",
"0.63567644",
"0.6347056",
"0.6344134",
"0.6335865",
"0.6284737",
"0.62719446",
"0.62664825",
"0.62484896",
"0.6243408",
"0.623951... | 0.6932726 | 1 |
replace self.mesh_points based on current slider positions. Called continuously by a timer because this only sample code. | def update_points(self, *args):
points = [Window.width / 2, Window.height / 2, .5, .5]
i = 0
while i < 2 * pi:
i += 0.01 * pi
points.extend([
Window.width / 2 + cos(i) * (self.radius + self.sin_wobble *
sin(i * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n # Find only unmasked data :\n xyz, sData, sColor, _ = self._select_unmasked()\n # xyz, sData, sColor = self.xyz, self.sData, self.sColor\n\n # Render as cloud points :\n if xyz.size:\n self.mesh.visible = True\n self.mesh.set_data(xyz, ed... | [
"0.66854626",
"0.639376",
"0.6371708",
"0.6223976",
"0.61168814",
"0.6005774",
"0.59393",
"0.5877151",
"0.58306324",
"0.57560045",
"0.57472366",
"0.5731076",
"0.57036614",
"0.56943214",
"0.5670122",
"0.5670015",
"0.5664288",
"0.56522924",
"0.5632418",
"0.557543",
"0.556765",
... | 0.6852548 | 0 |
test EDO with a random signal | def test_edo_random():
# if (__name__ == '__main__'):
DBplot = True
x = np.random.randn(102)
x_e = gen_edo(x)
# -------------------------------------------------------------------
# plot
# -------------------------------------------------------------------
if DBplot:
plt.figure... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSignalModelExponential(data):\n print \"Creating model\"\n switchpoint = DiscreteUniform('switchpoint', lower=0, upper=len(data))\n \n noise_sigma = HalfNormal('noise_sigma', tau=sigToTau(.01))\n exp_sigma = HalfNormal('exp_sigma', tau=sigToTau(.05))\n \n #Modeling these parameters this way is why... | [
"0.61609674",
"0.60894215",
"0.5962885",
"0.57883495",
"0.5772621",
"0.57705086",
"0.57659596",
"0.57525915",
"0.5747032",
"0.5729385",
"0.5698475",
"0.56755584",
"0.56755584",
"0.5665003",
"0.560398",
"0.5595107",
"0.55848503",
"0.55599123",
"0.5559279",
"0.5554062",
"0.5550... | 0.68250364 | 0 |
raise panel by name. | def raise_panel(name):
# type: (Text,) -> None
from wulifang.vendor.Qt import QtWidgets
for i in QtWidgets.QApplication.topLevelWidgets():
panel = i.findChild(QtWidgets.QWidget, cast_str(name))
if not panel:
continue
parent = panel.parentWidget()
if not isinsta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raiseframe(self, name):\n\n self.mainframe.forget()\n frame = self.frames[name]\n frame.pack(expand=True, fill='both', padx=10)\n frame.update()\n frame.event_generate('<<ShowFrame>>')",
"def show_frame(self, page_name):\n frame = self.frames[page_name]\n fram... | [
"0.6125437",
"0.5957808",
"0.5957808",
"0.579883",
"0.5664773",
"0.55497974",
"0.55288047",
"0.549094",
"0.5383739",
"0.5350418",
"0.5324708",
"0.529769",
"0.5283791",
"0.5272809",
"0.52644736",
"0.5052339",
"0.50425017",
"0.5033997",
"0.5029124",
"0.50085276",
"0.49862525",
... | 0.8056387 | 0 |
read stdin until !(chars) | def until_not_multi(chars) -> str:
import sys
chars = list(chars)
y = ""
sys.stdout.flush()
while True:
i = read_single_keypress()
_ = sys.stdout.write(i)
sys.stdout.flush()
if i not in chars:
break
y += i
return y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stdin():\n\n while sys.stdin in select.select([sys.stdin], [], [], 0)[0]:\n\n line = sys.stdin.readline()\n\n if not line:\n yield from []\n break\n\n line = line.strip()\n yield line",
"def clear_in():\r\n c = sys.stdin.read(1)\r\n while(c!='\\n'):\... | [
"0.6532257",
"0.65098697",
"0.614524",
"0.6142632",
"0.6028982",
"0.60227627",
"0.60067415",
"0.6006633",
"0.5940817",
"0.5909145",
"0.58938634",
"0.588086",
"0.5839184",
"0.5832333",
"0.5795176",
"0.5778326",
"0.57482076",
"0.5713066",
"0.56246036",
"0.5590361",
"0.5582918",... | 0.6704463 | 0 |
Gets the path of macchanger, ip, and iwlink (required to gather interface info and change settings) | def pathGet():
macchanger = subprocess.check_output("which macchanger", shell=True)[:-1].decode("utf-8")
ip = subprocess.check_output("which ip", shell=True)[:-1].decode("utf-8")
iwconfig = subprocess.check_output("which iwconfig", shell=True)[:-1].decode("utf-8")
if macchanger == '':
return(1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intGet(): \n macchanger, ip, iwconfig = pathGet()\n interfaces = []\n a = str(subprocess.check_output(\"{} link show\".format(ip), shell=True))\n ints = a.split(': ')\n for i in range(len(ints)):\n if len(ints[i].split()) == 1:\n if ints[i] not in [\"1\", \"lo\", \"b'1\"]:\n ... | [
"0.6666703",
"0.629355",
"0.6035245",
"0.6004075",
"0.58747464",
"0.58303535",
"0.5665434",
"0.5665434",
"0.5629629",
"0.56242174",
"0.56165075",
"0.5611102",
"0.5600619",
"0.5600619",
"0.55945617",
"0.55720687",
"0.5570015",
"0.55602115",
"0.5460957",
"0.5432823",
"0.5398993... | 0.7431996 | 0 |
Genes1 and Genes2 should be dictionaries for GM and glimmer genes Here tring to first put all starts in a list, then compare them | def compare_gene_predictors(GM_genes, Glim_genes):
GM_starts = []
Glim_starts = []
GM_only = []
Glim_only = []
shared_starts = []
# GM_stops = []
# Glim_stops = []
Glim_unique = 0
GM_unique = 0
for i in range(1,GM_genes["total genes"]+1):
GM_starts.append(GM_genes["gene" +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gk_one_2_One(file1, file2):\r\n gk1 = gene_types(file1)\r\n gk2 = gene_types(file2)\r\n\r\n one_to_one = 0\r\n for row in gk1.itertuples():\r\n if row.gene_type == \"One_2_One\":\r\n Q_gene = row.Q_gene\r\n S_gene = row.S_gene\r\n idx = gk2[gk2.Q_gene.isin([S... | [
"0.5966085",
"0.59100145",
"0.589792",
"0.58363974",
"0.5791867",
"0.5788298",
"0.5785222",
"0.5742638",
"0.57316375",
"0.5621621",
"0.5608842",
"0.55541587",
"0.55262613",
"0.55256605",
"0.5476937",
"0.54571533",
"0.54315186",
"0.5416846",
"0.5404828",
"0.54037124",
"0.53944... | 0.7355956 | 0 |
Check flow abort when an entry already exist. | async def test_abort_if_existing_entry(hass: HomeAssistant):
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_key_raises_integrity_error(self):\n return exclusions.closed()",
"def check(self, name, entry):\n return None",
"def check_duplicate(self, state):\n pass",
"def add_existing_key_fail(self, data):\n message = 'exists'\n rv = self.add_success(data)\n asse... | [
"0.5934224",
"0.5926686",
"0.58534783",
"0.58445776",
"0.5736494",
"0.5687313",
"0.5652692",
"0.5648461",
"0.56250834",
"0.5606766",
"0.560445",
"0.5590957",
"0.5588486",
"0.5567927",
"0.55167276",
"0.54570234",
"0.5455502",
"0.54489535",
"0.54350406",
"0.53876656",
"0.538471... | 0.6654196 | 0 |
Find library contents. This function is a bit messy now as it is supporting two different response types. Can be cleaned up once all users are migrated to the new responses. | def get_library_contents(response, renderer):
section = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST, True)
contents = None
if section is None: # empty library
contents = nav(response, SINGLE_COLUMN + TAB_1_CONTENT + SECTION_LIST_ITEM + renderer,
True)
else:
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_library_content(self):\n raise NotImplementedError",
"def searchDiscover(self, query, limit=30, libtype=None):\n libtypes = {'movie': 'movies', 'show': 'tv'}\n libtype = libtypes.get(libtype, 'movies,tv')\n\n headers = {\n 'Accept': 'application/json'\n }\n ... | [
"0.60223347",
"0.57441866",
"0.5743922",
"0.56372076",
"0.5541128",
"0.5533635",
"0.54462445",
"0.5396952",
"0.5394179",
"0.5373028",
"0.53606236",
"0.53260654",
"0.53219444",
"0.5308331",
"0.52921003",
"0.52768916",
"0.5273805",
"0.526523",
"0.52570826",
"0.52460384",
"0.523... | 0.5921575 | 1 |
Adds the specified quantity to inventory at the given location. | def add_to_inventory(item, location, quantity, user=None):
try:
inventory = Inventory.objects.get(item=item, location=location)
inventory.quantity += quantity
inventory.save()
except ObjectDoesNotExist:
inventory = Inventory.objects.create(item=item, loca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_inventory(self, item_name: str, quantity: int) -> None:\n raise_if_false(quantity >= 0, f\"Quantity [{quantity}] can't be negative\")\n\n # If the item is already in inventory, just increment the quantity\n if item_name in self._player_data.inventory:\n self._player_data.... | [
"0.7737908",
"0.7397885",
"0.6875861",
"0.68697864",
"0.674013",
"0.6647282",
"0.6617832",
"0.6587421",
"0.65782684",
"0.6570471",
"0.65323216",
"0.65319645",
"0.6529759",
"0.65023",
"0.64655864",
"0.6448974",
"0.6442592",
"0.6419441",
"0.6415442",
"0.6403914",
"0.63631666",
... | 0.82828355 | 0 |
Removes the specified quantity from inventory at the given location. | def remove_from_inventory(item, location, quantity, user=None):
quantity = -quantity
return InventoryTransaction.add_to_inventory(item=item, location=location, quantity=quantity, user=user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_inventory(self, item_name: str, quantity: Optional[int] = None) -> None:\n raise_if_false(quantity >= 0, f\"Quantity [{quantity}] can't be negative\")\n\n # Item was never in inventory, return true since the end goal is satisfied\n if item_name not in self._player_data.inventor... | [
"0.74648863",
"0.6791366",
"0.6711227",
"0.6568045",
"0.65039015",
"0.6488564",
"0.64439595",
"0.62665594",
"0.62647074",
"0.6259461",
"0.62533015",
"0.624555",
"0.6214717",
"0.6093642",
"0.60210323",
"0.60030895",
"0.5990286",
"0.5962018",
"0.5962018",
"0.5962018",
"0.596201... | 0.836732 | 0 |
Handle the second armed state arm the second copter | def arm_second():
global c1, c2
global a1, a2
global BUF_SIZE
global state
msg1 = c1.recv(BUF_SIZE) # wait for the arrival message from first copter
print a1, ' >> ', msg1
if msg1 != 'Arrived':
error(msg1)
state = 9 # exit failure
else:
new_msg = 'ARM'
c2.send(new_msg)
state += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_event(self, event):\r\n global modrive\r\n if (event == \"disconnected odrive\"):\r\n return DisconnectedState()\r\n\r\n elif (event == \"arm cmd\"):\r\n modrive.arm()\r\n return ArmedState()\r\n\r\n elif (event == \"calibrating cmd\"):\r\n ... | [
"0.608657",
"0.6059883",
"0.58599967",
"0.58487993",
"0.5845047",
"0.5814345",
"0.58009404",
"0.5778152",
"0.57577664",
"0.573761",
"0.57078487",
"0.5669589",
"0.56129026",
"0.56129026",
"0.5597435",
"0.5589522",
"0.5582152",
"0.55679625",
"0.5561526",
"0.55465364",
"0.552742... | 0.64434195 | 0 |
Handle the goto second state. | def goto_second():
global c2
global a2
global BUF_SIZE
global state
msg = c2.recv(BUF_SIZE) # wait for the taken off message
print a2, ' >> ', msg
if msg != 'Taken Off':
error(msg)
state = 9 # exit failure
else:
new_msg = {}
new_msg['msg'] = 'GOTO'
new_msg['arg1'] = init2
c2.send(json.dumps(new_msg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_first():\n\tglobal c1\n\tglobal a1\n\tglobal BUF_SIZE\n\tglobal state\n\n\tmsg = c1.recv(BUF_SIZE) # wait for taken off message\n\tprint a1, ' >> ', msg\n\tif msg != 'Taken Off':\n\t\terror(msg)\n\t\tstate = 9 # exit failure\n\telse:\n\t\tnew_msg = {}\n\t\tnew_msg['msg'] = 'GOTO'\n\t\tnew_msg['arg1'] = in... | [
"0.63395256",
"0.6190942",
"0.59144545",
"0.591076",
"0.57834107",
"0.56880254",
"0.5673944",
"0.56446236",
"0.5622095",
"0.5580994",
"0.5521544",
"0.54864967",
"0.54773515",
"0.54529846",
"0.5430759",
"0.5396616",
"0.53932726",
"0.53924805",
"0.5367373",
"0.53670466",
"0.526... | 0.771308 | 0 |
Handle the exit success state. | def exit_success():
global state
print "EXIT SUCCESS"
state += 2 # increment state to 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit(self) -> None:\n\n self.result = self.handle_success('finished-task')",
"def _exit_with_return(self) -> int:\n self.should_exit = True\n return 0",
"def do_exit(self,*args):\r\n return True",
"def state_finish_exit(cfg, app, win):",
"def _success(self, msg=\"\"):\n ... | [
"0.76312023",
"0.6938733",
"0.69310325",
"0.68238515",
"0.68094873",
"0.6772633",
"0.6713087",
"0.67009234",
"0.6685954",
"0.6679004",
"0.66336673",
"0.66165906",
"0.66164505",
"0.66099507",
"0.6596699",
"0.6574345",
"0.65473217",
"0.65340966",
"0.6455953",
"0.6447668",
"0.64... | 0.8107691 | 0 |
Handle the exit failure state. | def exit_failure():
global state
global c1, c2
global a1, a2
# Tell clients to close connections
c1.send("CLOSE")
c2.send("CLOSE")
print "EXIT FAILURE"
state += 1 # increment state to 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_failsafe_exit(cfg, app, win):",
"def bail_out(exit_code=ErrorCode.NO_ERROR):\n sys.exit(exit_code.value)",
"def screen_exit(self, error=0):\n sys.exit(error)",
"def exit_handler():\n logger.debug(\"Application exit caught.\")\n save_state()",
"def state_finish_exit(cfg, app, w... | [
"0.768074",
"0.7043717",
"0.70283407",
"0.70210654",
"0.69956344",
"0.6991612",
"0.6988683",
"0.6945064",
"0.69296736",
"0.6920645",
"0.6906545",
"0.68730116",
"0.6869069",
"0.6866513",
"0.6862982",
"0.6808353",
"0.68037564",
"0.67895186",
"0.6671454",
"0.6663841",
"0.6652742... | 0.7370716 | 1 |
r"""Test for physical limits on DHI using the QCRad criteria. Test is applied to each DHI value. A DHI value passes if value > lower bound and value < upper bound. Lower bounds are constant for all tests. Upper bounds are calculated as | def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits=None):
if not limits:
limits = QCRAD_LIMITS
dhi_ub = _qcrad_ub(dni_extra, solar_zenith, limits['dhi_ub'])
dhi_limit_flag = quality.util.check_limits(dhi, limits['dhi_lb'], dhi_ub)
return dhi_limit_flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits=None):\n if not limits:\n limits = QCRAD_LIMITS\n ghi_ub = _qcrad_ub(dni_extra, solar_zenith, limits['ghi_ub'])\n\n ghi_limit_flag = quality.util.check_limits(ghi, limits['ghi_lb'], ghi_ub)\n\n return ghi_limit_flag",
"def check(s... | [
"0.58753437",
"0.5838555",
"0.57582146",
"0.5723153",
"0.56529295",
"0.5624598",
"0.56038237",
"0.55892324",
"0.5566748",
"0.556427",
"0.5554553",
"0.5432854",
"0.5424298",
"0.54139566",
"0.5390203",
"0.53861904",
"0.5373518",
"0.53721553",
"0.53694445",
"0.5363957",
"0.53633... | 0.6253911 | 0 |
r"""Test for physical limits on DNI using the QCRad criteria. Test is applied to each DNI value. A DNI value passes if value > lower bound and value < upper bound. Lower bounds are constant for all tests. Upper bounds are calculated as | def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits=None):
if not limits:
limits = QCRAD_LIMITS
dni_ub = _qcrad_ub(dni_extra, solar_zenith, limits['dni_ub'])
dni_limit_flag = quality.util.check_limits(dni, limits['dni_lb'], dni_ub)
return dni_limit_flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self):\n self.lower_bound(5e-4)\n self.upper_bound(5e2)",
"def RestrictionRangeBound(self, compsIdList, lowerBound, upperBound):\n for i in range(len(compsIdList)): compsIdList[i] -= 1\n if self.solverTypeOptimize:\n self.solver.add(sum([self.a[compId * self.nrVM ... | [
"0.61664826",
"0.61184645",
"0.60738164",
"0.5996084",
"0.5923358",
"0.58196723",
"0.5774115",
"0.5754019",
"0.5748481",
"0.5728973",
"0.5722339",
"0.57165563",
"0.5708725",
"0.5686485",
"0.5640013",
"0.56243104",
"0.56219226",
"0.5612017",
"0.5596693",
"0.5576909",
"0.557066... | 0.61573493 | 1 |
Check consistency of GHI, DHI and DNI using QCRad criteria. Uses criteria given in [1]_ to validate the ratio of irradiance components. | def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni,
param=None):
if not param:
param = QCRAD_CONSISTENCY
# sum of components
component_sum = dni * cosd(solar_zenith) + dhi
ghi_ratio = ghi / component_sum
dhi_ratio = dhi / ghi
bound... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_irradiance_limits_qcrad(solar_zenith, dni_extra, ghi=None, dhi=None,\n dni=None, limits=None):\n if not limits:\n limits = QCRAD_LIMITS\n\n if ghi is not None:\n ghi_limit_flag = check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra,\n ... | [
"0.6210632",
"0.6152089",
"0.6070339",
"0.59262955",
"0.56886464",
"0.5459015",
"0.54097587",
"0.53839093",
"0.53646404",
"0.5345585",
"0.529793",
"0.5257886",
"0.520315",
"0.52029836",
"0.519754",
"0.51677847",
"0.51555806",
"0.515244",
"0.51515347",
"0.51415277",
"0.5138743... | 0.7200766 | 0 |
Identify irradiance values which do not exceed clearsky values. | def clearsky_limits(measured, clearsky, csi_max=1.1):
csi = pvlib.irradiance.clearsky_index(
measured,
clearsky,
max_clearsky_index=np.Inf
)
return quality.util.check_limits(
csi, upper_bound=csi_max, inclusive_upper=True
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def irradiance(self) -> float:\n\n if self.declination > 0:\n return self._irradiance\n return 0",
"def filter(self, intensities):\n return np.array(intensities) > self.min_ms1_intensity",
"def test_uniformity_values(self):\n for key, exp_val in self.unif_values.items():\... | [
"0.5850449",
"0.5804829",
"0.57967424",
"0.5752119",
"0.5733003",
"0.5726604",
"0.5652637",
"0.56453276",
"0.55786926",
"0.5570144",
"0.5563917",
"0.55392665",
"0.5531552",
"0.5518706",
"0.5486282",
"0.5436702",
"0.5436546",
"0.543401",
"0.54253584",
"0.54106593",
"0.54039323... | 0.62086505 | 0 |
Check that daily insolation lies between minimum and maximum values. Irradiance measurements and clearsky irradiance on each day are integrated with the trapezoid rule to calculate daily insolation. | def daily_insolation_limits(irrad, clearsky, daily_min=0.4, daily_max=1.25):
daily_irradiance = _daily_total(irrad)
daily_clearsky = _daily_total(clearsky)
good_days = quality.util.check_limits(
daily_irradiance/daily_clearsky,
upper_bound=daily_max,
lower_bound=daily_min
)
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rise_timeseries_with_expert_model_for_correct_max_and_min():\n hot_day_index = 6\n cold_day_index = 12\n temperature_timeseries = average_temperature_timeseries_with_1_cold_and_1_hot_day(cold_day_index, hot_day_index)\n\n summer_explanation, winter_explanation = dianna.explain_timeseries(run_e... | [
"0.6369793",
"0.57336044",
"0.5600145",
"0.54392594",
"0.5422642",
"0.54211634",
"0.53994054",
"0.5373662",
"0.5365661",
"0.5364505",
"0.5302732",
"0.5247371",
"0.52443624",
"0.5232224",
"0.5231941",
"0.5231065",
"0.5219841",
"0.5216216",
"0.52012587",
"0.51931906",
"0.519267... | 0.7507311 | 0 |
Determine whether the provided `number` is an Armstrong number. | def is_armstrong_number(number: int) -> bool:
str_number = f"{number}"
return sum(pow(int(x), len(str_number)) for x in str_number) == number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_armstrong_number(number: int) -> bool:\n return get_armstrong_value(number) == number",
"def is_armstrong_number(number: int) -> bool:\n result = 0\n num_str = str(number)\n for i in num_str:\n result += int(i) ** len(num_str)\n return result == number",
"def check_if_armstrong_num... | [
"0.8565779",
"0.8001075",
"0.79122883",
"0.7537187",
"0.70546013",
"0.7017828",
"0.6724216",
"0.6066517",
"0.5715955",
"0.5636005",
"0.55235034",
"0.5445059",
"0.54095477",
"0.53725064",
"0.5329689",
"0.5204038",
"0.51953304",
"0.5185787",
"0.515538",
"0.51431876",
"0.5141505... | 0.81648034 | 1 |
Use preset data set in ./ImageSets/Main contains [train.txt, val.txt] | def InitDataset(self):
train_txt = 'ImageSets/Main/train.txt'
val_txt = 'ImageSets/Main/val.txt'
annotations = "Annotations"
jpegimages = "JPEGImages"
images_path = train_txt if (self.is_train) else val_txt
images_path = readTxt(os.path.join(self.path, images_path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(self):\n sets = ['train', 'val']\n images = []\n labels = []\n self.labels_dic = {}\n file = open(self.path + 'wnids.txt')\n train_labels = file.read().split()\n if self.train:\n for fn in range(self.num_classes):\n f = train_... | [
"0.71798444",
"0.68717134",
"0.66940504",
"0.66788894",
"0.66568184",
"0.66535676",
"0.6600728",
"0.65291554",
"0.648733",
"0.64652747",
"0.64606804",
"0.64323556",
"0.6352032",
"0.63371366",
"0.6327431",
"0.6314092",
"0.63104546",
"0.62998956",
"0.62800175",
"0.62764573",
"0... | 0.70900375 | 1 |
Takes in the prediction dictionary from get_top_down_bottom_up_model_predictions and calculates various statistics for each of the predicted vectors | def get_top_down_bottom_up_model_stats(pred_dict):
td_bu_summary_stats = {}
years = pred_dict.viewkeys()
for year in years:
logging.info("Year {0}: Getting stats".format(year))
td_bu_summary_stats[year] = {}
hosts = pred_dict[year].viewkeys()
for host in hosts:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postprocess_model_outputs(self, predictions, expected):\n\n predictions = {k: t.numpy() for k, t in predictions.items()}\n\n return predictions, expected",
"def walk_forward_prediction(self):\r\n for output_name in self.output_names:\r\n print('\\t\\t\\t|--Prediction type: {}'... | [
"0.6227865",
"0.62160873",
"0.61403304",
"0.6077898",
"0.6015517",
"0.5987928",
"0.5970293",
"0.5914843",
"0.5838905",
"0.58210194",
"0.58132994",
"0.58083683",
"0.58071494",
"0.5797783",
"0.57888037",
"0.57819533",
"0.5746168",
"0.57369685",
"0.57255536",
"0.5722879",
"0.571... | 0.68800414 | 0 |
Receive a reply from a switch to a description statistics request | def desc_stats_reply_handler(self, ev):
body = ev.msg.body
datapath = ev.msg.datapath
dpid = datapath.id
self.logger.info('event=DescStats Switch dpid=%s is mfr_desc="%s" '
'hw_desc="%s" sw_desc="%s" serial_num="%s" dp_desc="%s"',
dpid, body.mf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_switch_desc(self):\n parser = self.datapath.ofproto_parser\n req = parser.OFPDescStatsRequest(self.datapath, 0)\n self.logger.debug(\"Sending description request to dpid=%s\",\n self.datapath.id)\n self.datapath.send_msg(req)",
"def port_desc_sta... | [
"0.7459488",
"0.5846796",
"0.5744121",
"0.5670133",
"0.56123596",
"0.55629295",
"0.5553321",
"0.5522781",
"0.55148125",
"0.53258",
"0.53202474",
"0.53104687",
"0.53003013",
"0.5296296",
"0.5258403",
"0.52489954",
"0.52228546",
"0.52206576",
"0.5208435",
"0.5188448",
"0.518631... | 0.7425097 | 1 |
A switch has sent an event to us because it has removed a flow from a flow table | def flow_removed_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofp = datapath.ofproto
if msg.reason == ofp.OFPRR_IDLE_TIMEOUT:
reason = 'IDLE TIMEOUT'
elif msg.reason == ofp.OFPRR_HARD_TIMEOUT:
reason = 'HARD TIMEOUT'
elif msg.reason == o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch_features_handler(self, ev):\n datapath = ev.msg.datapath\n [self.remove_flows(datapath, n) for n in [0, 1]]",
"def handle_migration(self, message):\n if self.migrating:\n if (messages.get_message_type(message) == \"OFPT_FLOW_REMOVED\"\n and message.cookie... | [
"0.6532196",
"0.6117751",
"0.592321",
"0.59198344",
"0.5906881",
"0.5887209",
"0.5814587",
"0.57975984",
"0.57966393",
"0.5745297",
"0.573445",
"0.5728125",
"0.5693756",
"0.5686685",
"0.5685901",
"0.56696266",
"0.5652708",
"0.5652708",
"0.565259",
"0.5628637",
"0.5628637",
... | 0.65345526 | 0 |
Switch Port Status event | def _port_status_handler(self, ev):
msg = ev.msg
reason = msg.reason
port = msg.desc.port_no
ofproto = msg.datapath.ofproto
if reason == ofproto.OFPPR_ADD:
self.logger.info("port added port=%s", port)
elif reason == ofproto.OFPPR_DELETE:
self.logg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _port_status_handler(self, ev):\n msg = ev.msg\n reason = msg.reason\n port_no = msg.desc.port_no\n dpid = msg.datapath.id\n ofproto = msg.datapath.ofproto\n\n reason_dict = {ofproto.OFPPR_ADD: \"added\",\n ofproto.OFPPR_DELETE: \"deleted\",\n ... | [
"0.76439655",
"0.6579206",
"0.64653075",
"0.64174473",
"0.6343006",
"0.6236042",
"0.6193415",
"0.6116067",
"0.60152215",
"0.598462",
"0.5976042",
"0.59319746",
"0.5909777",
"0.5905015",
"0.59019053",
"0.5863298",
"0.58506155",
"0.5816463",
"0.581492",
"0.57929504",
"0.5767336... | 0.7141782 | 1 |
A DPAE may have sent us a join discovery packet (Phase 2) Check the packet payload to see if it is valid | def dpae_join(self, pkt, datapath, in_port):
_payload = str(pkt.protocols[-1])
self.logger.info("Phase 2 DPAE discovery packet received from dpid=%s "
"port=%s payload=%s",
datapath.id, in_port, _payload)
#*** Try decode of payload ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pes_packet_check_formedness(payload):\n b1 = ord(payload[0])\n b2 = ord(payload[1])\n b3 = ord(payload[2])\n\n b4 = ord(payload[3])\n if b1 != 0 or b2 != 0 or b3 != 1:\n return False\n return True",
"def _packet_in(self, ev):\n\n dp = ev.msg.datapath\n ofp = dp.ofproto\n ... | [
"0.66729975",
"0.61234146",
"0.6103079",
"0.60170406",
"0.59049493",
"0.58593595",
"0.57960343",
"0.5756518",
"0.57057464",
"0.56915927",
"0.5690995",
"0.559017",
"0.55846393",
"0.5511162",
"0.55064785",
"0.54756075",
"0.5443688",
"0.54418343",
"0.5393763",
"0.5385802",
"0.53... | 0.6756374 | 0 |
Downloads the Imagenet classes index file and loads it to self.classes. The file is downloaded only if it not already in the cache. | def get_classes():
file_name = 'imagenet_class_index.json'
file_origin = os.path.join(FILE_PATH, file_name)
file_path = get_file(file_name, file_origin, cache_subdir='models')
with open(file_path) as f:
class_dict = json.load(f)
return [class_dict[str(i)][1] for i in range(len(class_dict))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_class_index(filename_class_index):\n class_dictionary = np.load(filename_class_index).item()\n return class_dictionary",
"def getIndex(self):\n # Create Cache path if it does not exist.\n if not os.path.exists(self.cache_dir):\n os.mkdir(self.cache_dir)\n if... | [
"0.63446873",
"0.61518574",
"0.61288095",
"0.61214083",
"0.5795006",
"0.57744956",
"0.55965006",
"0.54753643",
"0.5459999",
"0.54408014",
"0.5435864",
"0.54010755",
"0.5370532",
"0.53377366",
"0.532477",
"0.5316305",
"0.5288684",
"0.5274166",
"0.5252574",
"0.5239661",
"0.5214... | 0.6425914 | 0 |
Import a manager from a python path. | def import_manager(path: str) -> Donald:
manager: Donald = import_obj(path)
return manager | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_module(path: os.PathLike):\n path = Path(path)\n pwd = Path(os.getcwd())\n os.chdir(path.parent)\n try:\n mod = import_module(path.stem)\n except ModuleNotFoundError as err:\n raise err\n finally:\n os.chdir(pwd)\n return mod",
"def import_module_from_module_pat... | [
"0.58093685",
"0.57530785",
"0.5680276",
"0.5554292",
"0.55145615",
"0.5513528",
"0.54977083",
"0.54819685",
"0.54715574",
"0.5445949",
"0.5443499",
"0.5379156",
"0.53738177",
"0.53627676",
"0.53493345",
"0.53493345",
"0.53493345",
"0.53491825",
"0.534369",
"0.53353643",
"0.5... | 0.77317756 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.