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 |
|---|---|---|---|---|---|---|
This function adds ZIPCODE and ZIPCODE_AGI columns to the dataFrame. | def merge_zipcode_agi(df_turnstiles):
# define URLs for MTA Station data & IRS Income Info
mta_url = "http://web.mta.info/developers/data/nyct/subway/Stations.csv"
irs_url = "https://www.irs.gov/pub/irs-soi/18zpallagi.csv"
# collect & clean MTA station info
mta_station_info = p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_loc_cols(df):\r\n\r\n\tdf['STATE'] = [int(i[1:3]) for i in df.gisjoin]\r\n\tdf['COUNTY'] = [int(i[4:7]) for i in df.gisjoin]\r\n\tdf['TRACT'] = [int(i[7:-4]) for i in df.gisjoin]\r\n\tdf['BLOCK'] = [int(i[-4:]) for i in df.gisjoin]\r\n\r\n\tif df.STATE[0] > 9:\r\n\t\traise Exception(\"Warning! Code might b... | [
"0.6326425",
"0.58691585",
"0.58307797",
"0.5718286",
"0.56968427",
"0.5463691",
"0.5426602",
"0.5325125",
"0.5292596",
"0.518979",
"0.5161211",
"0.51520586",
"0.51448625",
"0.51438683",
"0.5116092",
"0.5104685",
"0.50368077",
"0.5005452",
"0.49896863",
"0.49113354",
"0.48995... | 0.59902793 | 1 |
Clean entries and exits column. Returns a dataFrame grouped by individual turnstile and AM/PM. Entries & exit columns converted from cumulative > change from previous value | def fixup_entries_exits(df_turnstiles):
# group data by AMPM, taking the maximum entries/exits for each date
ampm_station_group = df_turnstiles.groupby(
["C/A", "UNIT", "SCP", "STATION", "DATE", "AMPM", "DAY_NAME",],
as_index=False,
)
df_ampm = ampm_station_group... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_data(df_turnstiles):\n\n # sort values in a such a way that the duplicate values sit directly below the originals, so they will be removed.\n df_turnstiles.sort_values(\n [\"C/A\", \"UNIT\", \"SCP\", \"STATION\", \"DATE_TIME\"],\n inplace=True,\n ascending=F... | [
"0.6312388",
"0.57322955",
"0.55727816",
"0.5407285",
"0.53056943",
"0.5223147",
"0.5200911",
"0.51957583",
"0.5163521",
"0.5142505",
"0.51417726",
"0.51290923",
"0.51139414",
"0.5108265",
"0.50709075",
"0.5058216",
"0.5057824",
"0.50575924",
"0.50515586",
"0.50307417",
"0.50... | 0.66307956 | 0 |
Proxy function for the tracking pts logger service. Used to start and stop logging. | def tracking_pts_logger_proxy(namespace,cmd,filename):
srv = '{0}/logging_cmd'.format(namespace)
proxy = rospy.ServiceProxy(srv,LoggingCmd)
try:
resp = proxy(cmd,filename)
flag = resp.flag
except rospy.ServiceException, e:
flag = False
return flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_start(self):\r\n self.log()",
"def _start_logging(self):\n raise NotImplementedException()",
"def start():\n log(\"=========== hook: start ===========\")",
"def setup_logger():\n logger = logging.getLogger('tracking_log')\n logger.setLevel(logging.INFO)\n #Where to Store need... | [
"0.6483767",
"0.6436041",
"0.62074864",
"0.60591334",
"0.6058873",
"0.5985169",
"0.5953372",
"0.594782",
"0.5884326",
"0.5873426",
"0.58346224",
"0.58311236",
"0.5822701",
"0.58113503",
"0.580145",
"0.5779789",
"0.5722892",
"0.56905645",
"0.5668255",
"0.56460786",
"0.56447643... | 0.73594636 | 0 |
Path to the small test database. | def db_small_path():
return os.path.join(_here, 'fixtures/databases/db-small/database') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_database_path() -> str:\n test_suite_dir = os.path.abspath(os.path.dirname(__file__))\n return os.path.join(test_suite_dir, \"testDb.sqlite\")",
"def db_path_with_improper_files():\n return os.path.join(_here, 'fixtures/databases/db-improper/database')",
"def db_python_only():\n return... | [
"0.7880446",
"0.7255324",
"0.71025",
"0.7018129",
"0.6852007",
"0.6844908",
"0.6765523",
"0.6755608",
"0.661674",
"0.66091156",
"0.6603943",
"0.6476906",
"0.6379316",
"0.63708115",
"0.63703257",
"0.6369142",
"0.63338923",
"0.6288185",
"0.6270612",
"0.6251157",
"0.6239606",
... | 0.8609781 | 0 |
Path to the test database with improper files. | def db_path_with_improper_files():
return os.path.join(_here, 'fixtures/databases/db-improper/database') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_python_only():\n return os.path.join(_here, 'fixtures/databases/db-python-only/database')",
"def get_test_database_path() -> str:\n test_suite_dir = os.path.abspath(os.path.dirname(__file__))\n return os.path.join(test_suite_dir, \"testDb.sqlite\")",
"def db_small_path():\n return os.path.jo... | [
"0.75037533",
"0.7484556",
"0.7308964",
"0.72868377",
"0.7141627",
"0.70591956",
"0.68684435",
"0.68129104",
"0.65792465",
"0.65683746",
"0.6477624",
"0.64596736",
"0.64382106",
"0.6410621",
"0.63923675",
"0.63674766",
"0.63598526",
"0.635115",
"0.63402563",
"0.63394076",
"0.... | 0.8216641 | 0 |
Path to the pythononly test database. | def db_python_only():
return os.path.join(_here, 'fixtures/databases/db-python-only/database') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_database_path() -> str:\n test_suite_dir = os.path.abspath(os.path.dirname(__file__))\n return os.path.join(test_suite_dir, \"testDb.sqlite\")",
"def db_path_with_improper_files():\n return os.path.join(_here, 'fixtures/databases/db-improper/database')",
"def get_db_path():\n return os... | [
"0.83466035",
"0.7774428",
"0.7629329",
"0.761447",
"0.75845534",
"0.7301873",
"0.7227108",
"0.7013593",
"0.69737864",
"0.69364893",
"0.6922749",
"0.6880376",
"0.6847117",
"0.68102425",
"0.67964154",
"0.667084",
"0.66114485",
"0.65440637",
"0.65155536",
"0.6482962",
"0.648188... | 0.87227327 | 0 |
Path to the Java CVE record. | def java_record_path():
return os.path.join(_here, 'fixtures/records/java-2018-10237.yaml') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eve_path():\n return '{}\\\\CCP\\\\EVE'.format(get_appdata())",
"def python_record_path():\n return os.path.join(_here, 'fixtures/records/python-2016-10516.yaml')",
"def filenameAsPath(self, app):\n return app.recordingsPath.child(self.filename).path",
"def _filepath(self, filename):\n ... | [
"0.62098986",
"0.5912817",
"0.5730348",
"0.55741614",
"0.54508793",
"0.5395311",
"0.5369696",
"0.5326624",
"0.5291892",
"0.52387875",
"0.5238363",
"0.51714534",
"0.5161415",
"0.5160295",
"0.5158992",
"0.5158992",
"0.51548153",
"0.51473683",
"0.5144279",
"0.51361686",
"0.51209... | 0.67759377 | 0 |
Path to the Python CVE record. | def python_record_path():
return os.path.join(_here, 'fixtures/records/python-2016-10516.yaml') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def java_record_path():\n return os.path.join(_here, 'fixtures/records/java-2018-10237.yaml')",
"def get_eve_path():\n return '{}\\\\CCP\\\\EVE'.format(get_appdata())",
"def filenameAsPath(self, app):\n return app.recordingsPath.child(self.filename).path",
"def _filepath(self, filename):\n ... | [
"0.64519113",
"0.6400784",
"0.5669879",
"0.56179076",
"0.55499196",
"0.5471142",
"0.5426507",
"0.5385525",
"0.53746593",
"0.5369389",
"0.5369389",
"0.5369389",
"0.536584",
"0.53491783",
"0.5332675",
"0.5330011",
"0.5306925",
"0.53048134",
"0.5290578",
"0.5289849",
"0.5289849"... | 0.6816917 | 0 |
Path to the invalid CVE record. | def invalid_record_path():
return os.path.join(_here, 'fixtures/records/invalid.yaml') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errpath(self):\n return None",
"def get_eve_path():\n return '{}\\\\CCP\\\\EVE'.format(get_appdata())",
"def path_emergency(self) -> Path:\n return self.path_supervisor / EMERGENCY_DATA",
"def keyfunc(invalid: utils.TraceTuple) -> Path:\n traces_path = invalid.traces_path\n ... | [
"0.66394675",
"0.5727181",
"0.5622843",
"0.5510485",
"0.54649556",
"0.545422",
"0.54506046",
"0.5437321",
"0.5424419",
"0.53868675",
"0.53067327",
"0.5286599",
"0.5256299",
"0.524939",
"0.51857644",
"0.5179442",
"0.5176023",
"0.5119216",
"0.50469637",
"0.5045826",
"0.5044293"... | 0.68413717 | 0 |
Path to the unparseable CVE record. | def unparseable_record_path():
return os.path.join(_here, 'fixtures/records/unparseable.yaml') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eve_path():\n return '{}\\\\CCP\\\\EVE'.format(get_appdata())",
"def invalid_record_path():\n return os.path.join(_here, 'fixtures/records/invalid.yaml')",
"def get_vernissagecmd_path():\n return vernissagecmd_path",
"def filenameAsPath(self, app):\n return app.recordingsPath.child(se... | [
"0.6018208",
"0.5807608",
"0.55535054",
"0.55206513",
"0.54571867",
"0.5447501",
"0.54112256",
"0.54112256",
"0.5389032",
"0.5367391",
"0.52851504",
"0.5257984",
"0.52340305",
"0.52340305",
"0.52340305",
"0.52340305",
"0.52340305",
"0.52340305",
"0.52340305",
"0.52340305",
"0... | 0.6446508 | 0 |
GIT URL with YAML data. | def git_url():
return "https://github.com/tisnik/victimsdb-sample-data.git" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_url(self):\n\n url = 'https://api.{}/repos/{}/{}/git/'.format(HOST_GITHUB, \\\n self.repo, self.product)\n return url",
"def format_url(self, data):\n git_url = urlparse(data[\"git_url\"])\n\n url = \"oauth2:{0}@{1}\".format(data[\"token\"], git_url.netloc... | [
"0.6493995",
"0.6401901",
"0.63599044",
"0.6350393",
"0.623588",
"0.6124202",
"0.5908427",
"0.5831547",
"0.5816461",
"0.57776284",
"0.5769506",
"0.57230633",
"0.5700079",
"0.56966275",
"0.5680488",
"0.5672194",
"0.5633531",
"0.5631661",
"0.56257445",
"0.56098515",
"0.5595114"... | 0.7103082 | 0 |
Mock hue entry setup. | def hue_setup_fixture():
with patch("homeassistant.components.hue.async_setup_entry", return_value=True):
yield | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_colormap_single_hue():\n with TestingCanvas(size=size, bgcolor='w') as c:\n idata = np.linspace(255, 0, size[0]*size[1]).astype(np.ubyte)\n data = idata.reshape((size[0], size[1]))\n image = Image(cmap=get_colormap('single_hue', 255),\n clim='auto', parent=c.sc... | [
"0.6190617",
"0.59994584",
"0.5958978",
"0.59334356",
"0.585053",
"0.585053",
"0.5840002",
"0.57558155",
"0.57501155",
"0.5749036",
"0.57405436",
"0.57301694",
"0.57248044",
"0.56999147",
"0.5684357",
"0.5675351",
"0.56750894",
"0.5665969",
"0.5647237",
"0.56080663",
"0.55635... | 0.70570976 | 0 |
Return a mocked Discovered Bridge. | def get_discovered_bridge(bridge_id="aabbccddeeff", host="1.2.3.4", supports_v2=False):
return Mock(host=host, id=bridge_id, supports_v2=supports_v2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_bridge(hass):\n return create_mock_bridge()",
"def create_mock_bridge():\n bridge = Mock(\n available=True,\n allow_unreachable=False,\n allow_groups=False,\n api=Mock(),\n spec=hue.HueBridge\n )\n bridge.mock_requests = []\n # We're using a deque so we ... | [
"0.7372151",
"0.73244363",
"0.6197295",
"0.6095032",
"0.57564074",
"0.56794703",
"0.56739575",
"0.5600137",
"0.5596264",
"0.5588057",
"0.54905665",
"0.54791147",
"0.5407656",
"0.5389388",
"0.53728324",
"0.5369918",
"0.5355989",
"0.5288491",
"0.5288298",
"0.5277364",
"0.527159... | 0.78755337 | 0 |
Test config flow discovers two bridges. | async def test_flow_two_bridges_discovered_one_new(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
create_mock_api_discovery(aioclient_mock, [("1.2.3.4", "bla"), ("5.6.7.8", "beer")])
MockConfigEntry(
domain="hue", unique_id="bla", data={"host": "1.2.3.4"}
).add_to_hass(hass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_flow_discovered_bridges(opp, aioclient_mock):\n aioclient_mock.get(\n pydeconz.utils.URL_DISCOVER,\n json=[\n {\"id\": BRIDGEID, \"internalipaddress\": \"1.2.3.4\", \"internalport\": 80},\n {\"id\": \"1234E567890A\", \"internalipaddress\": \"5.6.7.8\", \"intern... | [
"0.7181192",
"0.657215",
"0.6402847",
"0.6280944",
"0.6279817",
"0.5987878",
"0.59858084",
"0.59460175",
"0.59324795",
"0.5932003",
"0.5878794",
"0.5875763",
"0.5835963",
"0.58070344",
"0.5779187",
"0.5733481",
"0.57093203",
"0.5626492",
"0.56254184",
"0.5592134",
"0.5588778"... | 0.672303 | 1 |
Test if a unknown error happened during the linking processes. | async def test_flow_link_unknown_error(hass: HomeAssistant) -> None:
disc_bridge = get_discovered_bridge()
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value=[disc_bridge],
):
result = await hass.config_entries.flow.async_init(
const.DOMAI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _errcheck_link(value, func, args): # pylint: disable=W0613\n # The windows api returns nonzero if the call was successful\n if value != 0:\n return\n\n last_error = ctypes.windll.kernel32.GetLastError()\n # Somehow CreateSymbolicLinkW and CreateHardLinkW retuns zero\n # and the last erro... | [
"0.6474779",
"0.64479744",
"0.6337244",
"0.62498707",
"0.6116203",
"0.61068827",
"0.60577756",
"0.60174847",
"0.5844965",
"0.5829207",
"0.5748955",
"0.5735846",
"0.5717332",
"0.5702572",
"0.5702572",
"0.56888384",
"0.56444484",
"0.56255955",
"0.5616288",
"0.5600202",
"0.55956... | 0.6570556 | 0 |
Test that we clean up entries for same host and bridge. An IP can only hold a single bridge and a single bridge can only be accessible via a single IP. So when we create a new entry, we'll remove all existing entries that either have same IP or same bridge_id. | async def test_creating_entry_removes_entries_for_same_host_or_bridge(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
create_mock_api_discovery(aioclient_mock, [("2.2.2.2", "id-1234")])
orig_entry = MockConfigEntry(
domain="hue",
data={"host": "0.0.0.0", "api_key": "1234... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_collection_host_subnet(self):\n pass",
"async def test_remove_orphaned_entries_service(\n hass: HomeAssistant, aioclient_mock: AiohttpClientMocker\n) -> None:\n data = {\n \"lights\": {\n \"1\": {\n \"name\": \"Light 1 name\",\n \"state... | [
"0.58510834",
"0.5813717",
"0.57812136",
"0.5701259",
"0.5596435",
"0.55728924",
"0.55418134",
"0.55372703",
"0.5518171",
"0.54749167",
"0.5468669",
"0.5466749",
"0.5457224",
"0.54543275",
"0.54192454",
"0.53716856",
"0.5364132",
"0.5360512",
"0.5357036",
"0.53381026",
"0.533... | 0.58459246 | 1 |
Test a bridge being discovered via HomeKit. | async def test_bridge_homekit(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
create_mock_api_discovery(aioclient_mock, [("0.0.0.0", "bla")])
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": config_entries.SOURCE_HOMEKIT},
dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_home_bridge(mock_pre_serv):\n bridge = HomeBridge('TestBridge', 'test.bridge', b'123-45-678')\n\n assert bridge.display_name == 'TestBridge'\n assert bridge.pincode == b'123-45-678'\n assert len(bridge.services) == 2\n\n assert bridge.services[0].display_name == SERV_ACCESSORY_INFO\n ass... | [
"0.75312334",
"0.6870456",
"0.68665636",
"0.6690778",
"0.6649442",
"0.6622296",
"0.6615364",
"0.6443438",
"0.6431749",
"0.6419735",
"0.64003897",
"0.63273555",
"0.6083087",
"0.6046865",
"0.60348",
"0.59840834",
"0.59795445",
"0.5970852",
"0.5957151",
"0.5952589",
"0.59462017"... | 0.70850176 | 1 |
Test if a HomeKit discovered bridge has already been configured. | async def test_bridge_homekit_already_configured(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
create_mock_api_discovery(aioclient_mock, [("0.0.0.0", "aabbccddeeff")])
MockConfigEntry(
domain="hue", unique_id="aabbccddeeff", data={"host": "0.0.0.0"}
).add_to_hass(hass)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_connected(cls, device_config):\n if \"console_port_name\" in device_config[\"persistent\"]:\n address = device_config[\"persistent\"][\"console_port_name\"]\n else:\n address = device_config[\"persistent\"][\"hub_port_name\"]\n return os.path.exists(address)",
"async def is_configured(h... | [
"0.6457371",
"0.61604476",
"0.6104228",
"0.6002925",
"0.5971744",
"0.59514815",
"0.5920931",
"0.59096086",
"0.5874031",
"0.58673847",
"0.5864205",
"0.5858051",
"0.58545786",
"0.58428514",
"0.58357936",
"0.58042425",
"0.5801472",
"0.5788955",
"0.57613575",
"0.5750078",
"0.5734... | 0.67370534 | 0 |
Test options config flow for a V1 bridge. | async def test_options_flow_v1(hass: HomeAssistant) -> None:
entry = MockConfigEntry(
domain="hue",
unique_id="aabbccddeeff",
data={"host": "0.0.0.0"},
)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_option_flow(opp, aioclient_mock):\n config_entry = await setup_deconz_integration(opp, aioclient_mock)\n\n result = await opp.config_entries.options.async_init(config_entry.entry_id)\n\n assert result[\"type\"] == RESULT_TYPE_FORM\n assert result[\"step_id\"] == \"deconz_devices\"\n\n ... | [
"0.6737381",
"0.65399843",
"0.6378295",
"0.6286918",
"0.61853635",
"0.6151957",
"0.614278",
"0.6120484",
"0.5999094",
"0.5926487",
"0.58837944",
"0.58702725",
"0.5867645",
"0.5861611",
"0.576889",
"0.5757",
"0.57449085",
"0.5726978",
"0.56929123",
"0.5679204",
"0.5670719",
... | 0.66397613 | 1 |
Test options config flow for a V2 bridge. | async def test_options_flow_v2(hass: HomeAssistant) -> None:
entry = MockConfigEntry(
domain="hue",
unique_id="aabbccddeeff",
data={"host": "0.0.0.0", "api_version": 2},
)
entry.add_to_hass(hass)
dev_reg = dr.async_get(hass)
mock_dev_id = "aabbccddee"
dev_reg.async_get_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_option_flow(opp, aioclient_mock):\n config_entry = await setup_deconz_integration(opp, aioclient_mock)\n\n result = await opp.config_entries.options.async_init(config_entry.entry_id)\n\n assert result[\"type\"] == RESULT_TYPE_FORM\n assert result[\"step_id\"] == \"deconz_devices\"\n\n ... | [
"0.67560863",
"0.6373548",
"0.6286991",
"0.6278226",
"0.62578523",
"0.6233213",
"0.61113554",
"0.60163224",
"0.59915006",
"0.59855986",
"0.5981519",
"0.595006",
"0.58520335",
"0.5813534",
"0.58015335",
"0.5766455",
"0.57646006",
"0.57201713",
"0.5719225",
"0.57179165",
"0.571... | 0.7129589 | 0 |
Test a bridge being discovered by zeroconf already exists. | async def test_bridge_zeroconf_already_exists(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
create_mock_api_discovery(
aioclient_mock, [("0.0.0.0", "ecb5faabcabc"), ("192.168.1.217", "ecb5faabcabc")]
)
entry = MockConfigEntry(
domain="hue",
source=config_en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_bridge_homekit_already_configured(\n hass: HomeAssistant, aioclient_mock: AiohttpClientMocker\n) -> None:\n create_mock_api_discovery(aioclient_mock, [(\"0.0.0.0\", \"aabbccddeeff\")])\n MockConfigEntry(\n domain=\"hue\", unique_id=\"aabbccddeeff\", data={\"host\": \"0.0.0.0\"}\n ... | [
"0.65536493",
"0.6400834",
"0.63210285",
"0.6163109",
"0.6107604",
"0.59410834",
"0.58979404",
"0.5866441",
"0.58326805",
"0.5749012",
"0.56838477",
"0.56618524",
"0.565966",
"0.5654871",
"0.5614883",
"0.5600673",
"0.5578344",
"0.5554906",
"0.55545014",
"0.5549597",
"0.554934... | 0.71763957 | 0 |
Test a bridge being discovered by zeroconf and ipv6 address. | async def test_bridge_zeroconf_ipv6(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": config_entries.SOURCE_ZEROCONF},
data=zeroconf.ZeroconfServiceInfo(
host="fd00::eeb5:faff:fe84:b17d",
addresses=["fd0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SupportsIPv6(self) -> bool:",
"def test_ipv6_in_net(self):\n test_ip = ip_address.IPAddress(\"2001:0db8:85a3:08d3:1319:8a2e:0370:7344/24\")\n assert test_ip.in_network(\"2001:0d00::/24\")\n assert test_ip.in_network(\"2001:0d00::/29\")",
"def bridge_network_check(ip, bridge_ip, bridge_... | [
"0.69296867",
"0.6873178",
"0.6855335",
"0.68408835",
"0.67723507",
"0.6649084",
"0.65144736",
"0.6484365",
"0.6461369",
"0.63507825",
"0.6304988",
"0.6245266",
"0.6233388",
"0.6186134",
"0.61457056",
"0.6034072",
"0.6014273",
"0.6006413",
"0.5968635",
"0.59401035",
"0.593909... | 0.80193996 | 0 |
Return an error for given Y and T. Differs for classification and multiclass. | def _error(self, Y, T):
err = np.mean((Y - T)**2)
return err | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errors(self, y):\r\n\r\n # check if y has same dimension of y_pred\r\n if y.ndim != self.y_pred.ndim:\r\n raise TypeError('y should have the same shape as self.y_pred',\r\n ('y', target.type, 'y_pred', self.y_pred.type))\r\n # check if y is of the correct datatype... | [
"0.705394",
"0.705394",
"0.70179045",
"0.7015995",
"0.70074224",
"0.69555795",
"0.6893458",
"0.68518806",
"0.6773689",
"0.6564925",
"0.653388",
"0.64286697",
"0.63042307",
"0.6298643",
"0.6283704",
"0.6282769",
"0.6233783",
"0.6225041",
"0.6223552",
"0.61783606",
"0.61619973"... | 0.7826117 | 0 |
Leave only neurons with the given indexes. | def _prune(self, idx):
idx = list(idx)
neurons = []
for nold in self.neurons:
k = nold[1] # number of neurons
ix1 = [i for i in idx if i < k] # index for current neuron type
idx = [i-k for i in idx if i >= k]
func = nold[0]
number = l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_indexes(self, indexes):\n # Create a set of the rows (as int) to delete\n selected_rows = set()\n for index in indexes:\n selected_rows.add(index.row())\n\n # Delete all of them one by one (easy but maybe not the best performance-wise)\n for index, row in en... | [
"0.63015276",
"0.5982674",
"0.558918",
"0.54869",
"0.54803425",
"0.5414516",
"0.5411668",
"0.5348167",
"0.5242817",
"0.52350545",
"0.5226981",
"0.5212443",
"0.5177332",
"0.5151017",
"0.51317",
"0.5111102",
"0.5095578",
"0.50760925",
"0.5072626",
"0.50687325",
"0.5067967",
"... | 0.6700615 | 0 |
Function to transform dataframe to array | def df_to_array(datasample):
return np.array(datasample) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataframe_to_array(df: pd.DataFrame) -> np.ndarray:\n\n if isinstance(df, pd.Series):\n x_array = df\n elif isinstance(df, pd.DataFrame):\n nb_vars = df.shape[1]\n varlist = df.columns\n x_array = df[varlist[0]]\n if nb_vars > 1:\n for k in range(1, nb_vars):... | [
"0.76691246",
"0.7365685",
"0.70576155",
"0.7006761",
"0.6754656",
"0.6746705",
"0.67400545",
"0.6668439",
"0.6607527",
"0.65974987",
"0.65742385",
"0.6560906",
"0.65563977",
"0.644972",
"0.6419316",
"0.6397516",
"0.638746",
"0.63369447",
"0.6327966",
"0.6318903",
"0.6294463"... | 0.79419214 | 0 |
Generate the full PDS path for a given HRSC data file | def generatePdsPath(filePrefix):
# File prefix looks like this: hHXXX_DDDD_SSS
fileType = '.img'
# Extract the run number --> HXXX
runNum = filePrefix[1:5]
filename = filePrefix + fileType
baseUrl = "http://pds-geosciences.wustl.edu/mex/mex-m-hrsc-5-refdr-mapprojected-v2/me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def get_path(data_path):\n\treturn os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path",
"def pathFromCompetition(competition):\n config = Config()\n ret = Path... | [
"0.6609946",
"0.6476409",
"0.6458018",
"0.6431442",
"0.6423816",
"0.6364348",
"0.63640827",
"0.6339666",
"0.632974",
"0.62803036",
"0.6274267",
"0.62587535",
"0.6227221",
"0.61917484",
"0.6113514",
"0.60960364",
"0.60952705",
"0.6090089",
"0.6077048",
"0.607591",
"0.60563326"... | 0.71917576 | 0 |
Numpy version of vplane_2_vparam | def np_vplane_2_vparam(vplane):
vparam = np.cross(
vplane,
np.stack([-vplane[...,1], vplane[...,0], np.zeros_like(vplane[...,0])], axis=-1),
axis=-1)
return vparam[..., :2] / vparam[..., [2]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def np_vparam_2_vplane(vparam):\n d = np.linalg.norm(vparam, ord=2, axis=-1, keepdims=True)\n a = vparam[..., [0]] / d\n b = vparam[..., [1]] / d\n neg_sign = (a < 0)\n a[neg_sign] = -a[neg_sign]\n b[neg_sign] = -b[neg_sign]\n c = -(a * vparam[..., [0]] + b * vparam[..., [1]])\n vplane = np... | [
"0.8257363",
"0.63768786",
"0.59504795",
"0.5945344",
"0.5901103",
"0.58194584",
"0.57758623",
"0.5767143",
"0.57617015",
"0.5703245",
"0.56223404",
"0.5606822",
"0.5601651",
"0.5597385",
"0.5542641",
"0.55421805",
"0.55402094",
"0.5523554",
"0.5511729",
"0.55012995",
"0.5484... | 0.8056421 | 1 |
Numpy version of vparam_2_vplane | def np_vparam_2_vplane(vparam):
d = np.linalg.norm(vparam, ord=2, axis=-1, keepdims=True)
a = vparam[..., [0]] / d
b = vparam[..., [1]] / d
neg_sign = (a < 0)
a[neg_sign] = -a[neg_sign]
b[neg_sign] = -b[neg_sign]
c = -(a * vparam[..., [0]] + b * vparam[..., [1]])
vplane = np.concatenate(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def np_vplane_2_vparam(vplane):\n vparam = np.cross(\n vplane,\n np.stack([-vplane[...,1], vplane[...,0], np.zeros_like(vplane[...,0])], axis=-1),\n axis=-1)\n return vparam[..., :2] / vparam[..., [2]]",
"def plane_point_side_v3(p: np.ndarray, v: np.ndarray) -> Any:\n return p[:3].d... | [
"0.81128526",
"0.63427055",
"0.58030635",
"0.57959634",
"0.5778007",
"0.5763449",
"0.5689331",
"0.56818783",
"0.56719047",
"0.56514084",
"0.56460345",
"0.5639332",
"0.5572977",
"0.5532811",
"0.5504314",
"0.5495645",
"0.54833466",
"0.54692966",
"0.54263157",
"0.5412707",
"0.53... | 0.8370257 | 0 |
Binary Lovasz hinge loss (negative positive invert version) | def neg_lovasz_hinge(logits, labels):
# Positive negative convert
logits = -logits
labels = 1 - labels.float()
# Compute lovasz hinge as usual
signs = 2 * labels - 1
errors = (1 - signs * logits)
errors_sorted, perm = torch.sort(errors, dim=0, descending=True)
perm = perm.data
gt_so... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hinge_loss_backward():\n from your_code import HingeLoss\n X = np.array([[-1, 2, 1], [-3, 4, 1]])\n w = np.array([1, 2, 3])\n y = np.array([1, -1])\n\n loss = HingeLoss(regularization=None)\n\n _true = np.array([-1.5, 2, 0.5])\n _est = loss.backward(X, w, y)\n print(_est)",
"def ... | [
"0.7503922",
"0.6930668",
"0.6631124",
"0.6568263",
"0.65180033",
"0.64716583",
"0.6459475",
"0.6447354",
"0.64316416",
"0.64218694",
"0.6414487",
"0.63204765",
"0.6296678",
"0.62932754",
"0.62772226",
"0.61665654",
"0.6147692",
"0.61436665",
"0.6130597",
"0.6096201",
"0.6085... | 0.73268783 | 1 |
Override private function that sets all the links for the contents to download on FOMC website from from_year (=min(2015, from_year)) to the current most recent year | def _get_links(self, from_year):
self.links = []
self.titles = []
self.speakers = []
self.dates = []
r = requests.get(self.calendar_url)
soup = BeautifulSoup(r.text, "html.parser")
if self.verbose:
print("Getting links for press conference scripts...... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download_backwards(self, date_str):\n self.url = f\"http://example.com/new/url/{date_str}\"\n self.html = self._download()",
"def get_year_with_links():\n response = get_response(MAIN_PAGE)\n if response.ok:\n soup = BeautifulSoup(response.text, 'html.parser')\n years_li = ... | [
"0.62690467",
"0.5965184",
"0.58395374",
"0.5766525",
"0.56891763",
"0.5681498",
"0.5655357",
"0.5437689",
"0.5355802",
"0.53454053",
"0.53197294",
"0.531165",
"0.531165",
"0.5307396",
"0.525201",
"0.52506924",
"0.52495944",
"0.5240057",
"0.52300364",
"0.5228289",
"0.52204984... | 0.6953851 | 0 |
Check if the folder contain the expected number of episodes and if they are complete. | def check_folder(env_name, number_episodes):
path = os.path.join(os.environ["SRL_DATASET_PATH"], 'sample_benchmark2', env_name)
# List number of folders check if match expected
environments_count = 0
for filename in os.listdir(path):
try:
int_filename = int(filename)
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def objectsReady(self, n):\n return len(self.files) >= n",
"def in_folder(self):\n return len(os.path.split(self.file_path)) > 1",
"def is_done(self):\n return_val = False\n for name in os.listdir(self.results_dir_path):\n if name.startswith('top_genes_per_phenotype'):\n ... | [
"0.612574",
"0.6075443",
"0.60746336",
"0.60218",
"0.60132325",
"0.6002474",
"0.59599173",
"0.5942792",
"0.59202325",
"0.59194344",
"0.58748317",
"0.5805734",
"0.5788102",
"0.576801",
"0.5702322",
"0.56581885",
"0.56397027",
"0.5637409",
"0.5630495",
"0.56222147",
"0.5608263"... | 0.7175833 | 0 |
Perform all useful analysis and direct the output via the Analysis'formatter. It analyses the scratch memory usage in DM1, DM2 and none, per priority and per task. [in] self Pointer to the current object | def run_all(self):
self.formatter.section_start('Scratch Memory Info')
self.formatter.section_start('Per priority')
self.analyse_per_priority()
self.formatter.section_end()
self.formatter.section_start('Per task')
self.analyse_per_task()
self.formatter.section_end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyse_per_priority(self):\n dm1_total = 0\n dm2_total = 0\n none_total = 0\n dm1_size = []\n dm2_size = []\n none_size = []\n users = []\n pdd = self.chipdata.get_var_strict('$_per_prio_data')\n num_entries = len(pdd.members)\n\n for curre... | [
"0.6257934",
"0.53452003",
"0.5278709",
"0.5274121",
"0.52575785",
"0.5248487",
"0.5191664",
"0.5152627",
"0.5093256",
"0.50777346",
"0.5058658",
"0.5053167",
"0.5052041",
"0.50365144",
"0.5028099",
"0.50278026",
"0.49993584",
"0.49851224",
"0.49738514",
"0.49705818",
"0.4949... | 0.66813105 | 0 |
analyse_per_priority() displays the total scratch memory allocations in DM1, DM2 and none and their values per each priority level. Furthermore, it also displays the total number of users per each priority level. The function reads and stores the allocations info from per_prio_data in the first for loop in order to dis... | def analyse_per_priority(self):
dm1_total = 0
dm2_total = 0
none_total = 0
dm1_size = []
dm2_size = []
none_size = []
users = []
pdd = self.chipdata.get_var_strict('$_per_prio_data')
num_entries = len(pdd.members)
for current in range(0, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_all(self):\n self.formatter.section_start('Scratch Memory Info')\n self.formatter.section_start('Per priority')\n self.analyse_per_priority()\n self.formatter.section_end()\n self.formatter.section_start('Per task')\n self.analyse_per_task()\n self.formatter... | [
"0.53971434",
"0.5170996",
"0.5162139",
"0.5098022",
"0.50932366",
"0.5056469",
"0.5031619",
"0.49695593",
"0.4948778",
"0.48987287",
"0.48891315",
"0.4879162",
"0.486115",
"0.4814659",
"0.47854146",
"0.47718522",
"0.47487068",
"0.47278893",
"0.47230425",
"0.4713487",
"0.4710... | 0.8804243 | 0 |
analyse_per_task() displays the scratch memory info per task. It can take one parameter that represents the task id and it will display the info for it. The function goes through the linked list and if no value is passed to it, it displays the complete list. Otherwise, it displays the info for the task with the id inpu... | def analyse_per_task(self, task_id=None):
per_task = self.chipdata.cast(
self.chipdata.get_var_strict('$_first_scratch_mem').address,
'scratch_per_task_data'
)
matching_id = False
for sc_table in self.parse_linked_list(per_task.address, 'next'):
if (ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _show_task(task, depth=0):\n indent = \" \"*depth\n # get people associated with this task\n people = query_with_results(\"select person.name from (person inner join task_person_pair on person.id = task_person_pair.person) where task_person_pair.task = ?\", [task[0]])\n people_string = \", \".join(map(lam... | [
"0.5747738",
"0.5657995",
"0.5638674",
"0.53487",
"0.533303",
"0.52720445",
"0.5245136",
"0.5212383",
"0.5205075",
"0.51718265",
"0.5147321",
"0.5135097",
"0.5119915",
"0.5110738",
"0.5069854",
"0.5043964",
"0.5008171",
"0.49889505",
"0.49718043",
"0.49696076",
"0.49006426",
... | 0.78272986 | 0 |
Creates confusion matrix with true labels along rows and predicted labels along columns. Assumes df contains columns "label"=>True labels and "classification"=>Predicted labels | def confusion_matrix(df):
rows, true_counts = np.unique(df["label"].values, return_counts=True)
cols, predicted_counts = np.unique(df["label"].values, return_counts=True)
matrix = np.ndarray(shape=(len(rows), len(cols)), dtype=float)
for ri, row in enumerate(rows):
for ci, col in enumerate(cols... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Confusion_Matrix(predicted_labels: list, actual_labels: list):\n labels = set(actual_labels)\n\n predicted_labels = list(map(custom_round, predicted_labels))\n\n matrix = pd.DataFrame(index=labels, columns=labels)\n\n matrix = matrix.fillna(0)\n\n for i in range(len(actual_labels)):\n mat... | [
"0.7578771",
"0.757619",
"0.7365501",
"0.7315624",
"0.7218451",
"0.7216669",
"0.7189216",
"0.71862596",
"0.71079034",
"0.71034706",
"0.7092456",
"0.7072218",
"0.7069952",
"0.70334834",
"0.70166075",
"0.70071",
"0.6982015",
"0.6978647",
"0.69725907",
"0.6929406",
"0.6928698",
... | 0.8234337 | 0 |
Check whether the current process already has a CUDA context created. Returns ``False`` if current process has no CUDA context created, otherwise returns the index of the device for which there's a CUDA context. | def has_cuda_context():
init_once()
if not nvmlInitialized:
return False
for index in range(device_get_count()):
handle = pynvml.nvmlDeviceGetHandleByIndex(index)
if hasattr(pynvml, "nvmlDeviceGetComputeRunningProcesses_v2"):
running_processes = pynvml.nvmlDeviceGetComput... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cuda(self):\n return self.share.is_cuda",
"def is_cuda(self):\n return self._tensor.is_cuda",
"def is_cuda(self):\n return next(self.parameters()).is_cuda",
"def is_cuda(self):\n return next(self.parameters()).is_cuda",
"def is_cuda(self):\n return next(self.parame... | [
"0.6835757",
"0.6608968",
"0.6581112",
"0.6581112",
"0.6581112",
"0.6581112",
"0.6325496",
"0.6288792",
"0.6280778",
"0.6250953",
"0.6104318",
"0.60323524",
"0.5995625",
"0.59909964",
"0.5980723",
"0.59791404",
"0.59286463",
"0.58897775",
"0.5851873",
"0.5831781",
"0.5828129"... | 0.84578913 | 0 |
Tests that NewickTokenizer without arg raises ValueError. | def test_no_arg(self):
self.assertRaises(ValueError, NewickTokenizer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_start_open_parens(self):\n self.assertRaises(ValueError, NewickTokenizer, newick='hi')",
"def test_unclosed(self):\n nt = NewickTokenizer(newick='(a,(b,c)')\n self.assertRaises(ValueError, nt.tokens)",
"def test_label(self):\n nt = NewickTokenizer(newick=\"(a\\n'b',(b,c)... | [
"0.80845463",
"0.8068447",
"0.79711384",
"0.7760871",
"0.77430147",
"0.7444971",
"0.7422035",
"0.73452514",
"0.70215565",
"0.6891094",
"0.6746495",
"0.668125",
"0.6609283",
"0.64874065",
"0.6484285",
"0.63872623",
"0.6362746",
"0.6270539",
"0.62485063",
"0.62016183",
"0.61146... | 0.9196363 | 0 |
Tests Newick with extra close parens generate errors. | def test_extra_closed(self):
nt = NewickTokenizer(newick='(a,(b,c)));')
self.assertRaises(ValueError, nt.tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_parens(self):\r\n with self.assertRaisesRegexp(Exception, 'Unknown parenthesis'):\r\n preview.LatexRendered('x^2', parens='not parens')",
"def test_no_start_open_parens(self):\n self.assertRaises(ValueError, NewickTokenizer, newick='hi')",
"def test_parse_newick(self):\r\n... | [
"0.73407525",
"0.6944178",
"0.68909293",
"0.6720148",
"0.6655094",
"0.65632147",
"0.65201473",
"0.6426458",
"0.63206464",
"0.62966466",
"0.6227613",
"0.62115365",
"0.6188436",
"0.6125099",
"0.60763067",
"0.6053083",
"0.6040547",
"0.6035202",
"0.6031782",
"0.6004939",
"0.59827... | 0.6950155 | 1 |
Tests behavior of peek when there are no more tokens. | def test_peek_none(self):
nt = NewickTokenizer(newick='(a,(b,c));')
nt.tokens()
self.assertIsNone(nt._peek()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _peek(self):\n return self.token_list[self._current]",
"def test_cant_peek_empty(empty_deque):\n assert empty_deque.peek() is None",
"def peek(self):\n pass",
"def peek(self):\n pass",
"def test_peek_returns_value(full_deque):\n assert full_deque.peek() == 1",
"def ... | [
"0.6841655",
"0.67698705",
"0.67421055",
"0.67218506",
"0.6719078",
"0.6685085",
"0.6640774",
"0.6601139",
"0.65826523",
"0.6487924",
"0.6462702",
"0.6457941",
"0.6455371",
"0.6413746",
"0.6394823",
"0.6385544",
"0.6372492",
"0.6347741",
"0.6288089",
"0.6286338",
"0.6266971",... | 0.772483 | 0 |
Tests that unclosed [] comments generate errors. | def test_unclosed_comment(self):
nt = NewickTokenizer(newick='(a,(b,c),[(d,e));')
self.assertRaises(ValueError, nt.tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unicode_comments(self):\n self._do_test(\n ['Hi there!', 'This is an element in a list of strings.'],\n ensure_binary(dedent(u\"\"\"\n [\n 'Hi there!',\n # This is a comment with ‘sneaky‘ unicode characters.\n 'This is an element in a list of strings.',\n # Th... | [
"0.68163717",
"0.6574816",
"0.650323",
"0.62634087",
"0.62355363",
"0.6234494",
"0.6229091",
"0.6162364",
"0.6082871",
"0.6055238",
"0.60307336",
"0.6022331",
"0.5991022",
"0.59871715",
"0.5957869",
"0.59467596",
"0.59367037",
"0.5929556",
"0.59011656",
"0.58821195",
"0.58664... | 0.7163699 | 0 |
Test that terminating ; is not preceded by ,. | def test_comma_bef_semicolon(self):
nt = NewickTokenizer(newick='(a,(b,c),(d,e)),;')
self.assertRaises(ValueError, nt.tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_semicolon_else_skip(self, symbol):\n if symbol.type == self.scanner.SEMICOLON:\n pass\n else:\n self._display_syntax_error(\"semicolon\")\n # Skip to semicolon at end of line\n self._semicolon_skipper()",
"def test_missing_delim(self):",
"def... | [
"0.67393607",
"0.66642225",
"0.65089947",
"0.6488513",
"0.6395795",
"0.63606805",
"0.63165295",
"0.6296124",
"0.62489814",
"0.6237657",
"0.62362576",
"0.61840713",
"0.60308063",
"0.6019244",
"0.59941745",
"0.5912011",
"0.5773467",
"0.5769748",
"0.57470113",
"0.5730535",
"0.57... | 0.699548 | 0 |
Test that unquoted labels with newline character generate errors. | def test_label(self):
nt = NewickTokenizer(newick="(a\n'b',(b,c),(d,e));")
self.assertRaises(ValueError, nt.tokens) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CheckLabel(Line): \n for i in Line:\n if i == '\\t': #can't detect leading tabs, stops at the first \\ \n raise InputError(Line,\"malformed input\") \n elif i != ' ':\n break",
"def test_parse_simple_quote_with_newline(self):\n with self.assertRaisesReg... | [
"0.664799",
"0.6574299",
"0.6504542",
"0.65013915",
"0.6482029",
"0.6461377",
"0.64312947",
"0.64140993",
"0.63935316",
"0.63755876",
"0.6157155",
"0.61145914",
"0.61092746",
"0.6062495",
"0.6057764",
"0.6028911",
"0.59751755",
"0.596203",
"0.58908796",
"0.5872407",
"0.582574... | 0.7631913 | 0 |
Test that quoting edge info generates no error and string edge length. | def test_quoted_edge_info(self):
exp = ['(', 'a', ',', '(', 'b', ',', 'c', ')', ':', '4', ',',
'(', 'd', ',', 'e', ')', ')', ';']
self._do_test("(a,(b,c):'4',(d,e));", exp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_info_whitespace():\n pytest.raises(SaltInvocationError, mac_group.info, \"white space\")",
"def test_general_subset_invalid_space():\n pass",
"def test_handles_empty_string(self):\n result = encode_run_length(\"\")\n self.assertEqual(result, \"\")",
"def test_should_raise_error_i... | [
"0.5995964",
"0.59914005",
"0.586099",
"0.5849451",
"0.58113915",
"0.5799296",
"0.57758814",
"0.5663836",
"0.5662087",
"0.56569314",
"0.5623805",
"0.5614479",
"0.56139755",
"0.5608006",
"0.5597547",
"0.5584426",
"0.5580746",
"0.55754036",
"0.55740744",
"0.5573375",
"0.5562653... | 0.7028773 | 0 |
Part of the testing harness. Writes `content`, the parses and compares to `expected`. | def _do_test(self, content, expected):
self.assertEqual(list(NewickTokenizer(StringIO(content))), expected)
self.assertEqual(list(NewickTokenizer(newick=content)), expected)
fp = path_map.next_unique_scratch_filepath('tok_test')
try:
write_to_filepath(content, fp)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_content():\n # PREPARE\n expected_f = open(\n 'tests/pages/expected/stepanenkoartem-github-io.html',\n 'rb',\n )\n expected_dom = BeautifulSoup(\n expected_f.read(),\n 'html.parser',\n )\n\n actual_f = open(\n os.path.join(TEMP_DIR, path.for_page(URL)),... | [
"0.64601886",
"0.61881155",
"0.6004434",
"0.59650457",
"0.5940238",
"0.5898892",
"0.5894748",
"0.58445835",
"0.581732",
"0.57843995",
"0.5749043",
"0.5675368",
"0.565861",
"0.5657756",
"0.5625757",
"0.5623709",
"0.5619837",
"0.5596385",
"0.55919063",
"0.5585478",
"0.5575018",... | 0.68610203 | 0 |
Tests that NewickEventFactory without arg raises ValueError. | def test_no_arg(self):
self.assertRaises(ValueError, NewickEventFactory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_event_model_missing_creator(self):\n with self.assertRaises(ValidationError):\n e = Event(title=self.TITLE)\n e.save()",
"def test_atevent_disabled(self):\n from plone.api.exc import InvalidParameterError\n with self.assertRaises(InvalidParameterError):\... | [
"0.6419645",
"0.6396346",
"0.6311455",
"0.6303136",
"0.628506",
"0.6277325",
"0.61772805",
"0.6125845",
"0.61118144",
"0.6111505",
"0.6089412",
"0.6066073",
"0.6054844",
"0.60529006",
"0.60401094",
"0.60319936",
"0.60121155",
"0.60074675",
"0.5997193",
"0.5990431",
"0.5982735... | 0.929328 | 0 |
Find positions that are contained within segments | def find_overlapping_segments(pos, seg, columns):
seg = seg.sort_values(['start', 'end'])
if seg.duplicated(['start', 'end']).any():
raise ValueError('duplicate columns')
start_idx = np.searchsorted(seg['start'].values, pos['coord'].values) - 1
end_idx = np.searchsorted(seg['end'].values, pos[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains ( self, pos ):\n \n inds = in_hull(pos[:2,:].T, array(self.edges).reshape(-1,2), \\\n border = self.include_border ,tol = self.abs_tol)\n \n # if none inside, take nearest\n if ~inds.any() and self.default_nearest:\n dr2 = array(s... | [
"0.6588952",
"0.6547448",
"0.6513691",
"0.646229",
"0.6430361",
"0.64195794",
"0.6334076",
"0.62850267",
"0.62444854",
"0.6213392",
"0.61859167",
"0.61407787",
"0.6118163",
"0.6112225",
"0.6081516",
"0.60803694",
"0.606772",
"0.6065855",
"0.60600376",
"0.6054242",
"0.6050661"... | 0.6627635 | 0 |
Simple hierarhical clustering figure for SNVs | def snv_hierarchical_clustering_figure(snv_data, clusters):
snv_matrix = snv_data.merge(clusters)
snv_matrix = (
snv_matrix.groupby(
['chrom', 'coord', 'ref', 'alt', 'cluster_id'],
as_index=True, observed=True)[['alt_counts', 'ref_counts']]
.sum().unstack().fillna(0).ast... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clustering_and_visulization(self):\n centroids, _ = kmeans(self.data_mat, self.k)\n idx, _ = vq(self.data_mat, centroids)\n for i in range(self.k):\n\n self.plot_list.append(self.data_mat[idx == i, 0])\n self.plot_list1.append(self.data_mat[idx == i, 1])\n\n fo... | [
"0.6763111",
"0.6744619",
"0.6698987",
"0.66339046",
"0.6591178",
"0.65695626",
"0.65430254",
"0.64374816",
"0.6399827",
"0.6366124",
"0.6343846",
"0.6322008",
"0.628119",
"0.62615293",
"0.62459433",
"0.6195688",
"0.61666834",
"0.61042285",
"0.60836965",
"0.608267",
"0.604885... | 0.77539515 | 0 |
Compute the ML tree under the dollo model of SNV evolution | def compute_dollo_ml_tree(snv_log_likelihoods, leaf_name_groups=None):
trees = dollo.tasks.create_trees(
snv_log_likelihoods,
sample_col='cluster_id',
leaf_name_groups=leaf_name_groups,
)
results_table = dollo.tasks.compute_tree_log_likelihoods_mp(
snv_log_likelihoods, trees... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_tree(self, tree):\n g_list_val, g_list_h = self._build_graph(tree) # return theano variable of each node\n list_val = self._traversal_tree(tree) #\n f = theano.function(g_list_val, g_list_h, allow_input_downcast=True)\n result = f(*list_val)\n return result",
"def s... | [
"0.59042037",
"0.58983594",
"0.5885023",
"0.5865591",
"0.58178765",
"0.5806134",
"0.5788585",
"0.578253",
"0.5766343",
"0.5740447",
"0.5739229",
"0.5704725",
"0.56913364",
"0.5689851",
"0.56591946",
"0.5614322",
"0.56094",
"0.55793583",
"0.5578998",
"0.5564107",
"0.556346",
... | 0.6712835 | 0 |
Plot a tree with branchlengths as snv origin counts | def plot_dollo_ml_tree(tree, nodes):
leaf_order = []
for leaf in tree.leaves:
leaf.plot_id = leaf.name
leaf_order.append(leaf.name)
origin_counts = nodes.groupby('node')['ml_origin'].sum()
for node in tree.nodes:
node.origin_count = origin_counts[node.label]
loss_counts = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_tree(tree, min_x, max_x, min_y, max_y, prev_node, branch, depth=0):\r\n \r\n cur_node = tree.location # current tree's node\r\n left_branch = tree.left_child # its left branch\r\n right_branch = tree.right_child # its right branch\r\n \r\n # set line's width depending on tree's dep... | [
"0.6562327",
"0.6287754",
"0.6251616",
"0.6110724",
"0.60776746",
"0.6010152",
"0.59485954",
"0.5894037",
"0.58730257",
"0.5862622",
"0.581848",
"0.581848",
"0.5794135",
"0.57915914",
"0.5767268",
"0.57500875",
"0.57399803",
"0.5731056",
"0.56966746",
"0.56453246",
"0.5613726... | 0.6549905 | 1 |
Run the SNV phylogenetic analysis. | def run_snv_phylogenetics(snv_count_data, allele_cn, clusters, results_prefix):
snv_log_likelihoods = scgenome.snvphylo.compute_snv_log_likelihoods(
snv_count_data, allele_cn, clusters)
ml_tree, tree_annotations = scgenome.snvphylo.compute_dollo_ml_tree(
snv_log_likelihoods)
return ml_tree... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, verbose=0):\n self.verbose = verbose\n self._preproc()\n self._lda()\n self._evaluate()",
"def main():\n args = parameter_parser()\n tab_printer(args)\n trainer = GPNTrainer(args)\n # trainer.fit()\n \"\"\"\n Scoring on the prediction and learning ability.\n \"\"\"\... | [
"0.5969365",
"0.5918953",
"0.5864023",
"0.58417416",
"0.58233285",
"0.57631445",
"0.5671599",
"0.561224",
"0.5609736",
"0.5591403",
"0.55810434",
"0.557726",
"0.55602694",
"0.5552123",
"0.54858965",
"0.54581356",
"0.5456001",
"0.5453447",
"0.54224575",
"0.54124206",
"0.540098... | 0.68774 | 0 |
The function is used to extract faces from face coordinates | def extract_faces(self, img, list_face_coord):
#from the img array extract the facees
list_faces = []
#Go through each face coordinates and store the array
#or clip face region in the list
for i, coord in enumerate(list_face_coord):
left, top, right, bottom = coord
list_faces.append(img[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_faces(image):\n return (image.crop(face) for face in image.faces)",
"def detect_faces(image):\n\n face_locations = face_recognition.face_locations(image)\n return face_locations",
"def detect_face(self, img):\n # Fetch face location from the frame with 128 encoding of face landmarks\n ... | [
"0.7587838",
"0.7559992",
"0.71235484",
"0.70463777",
"0.703729",
"0.6998884",
"0.6969824",
"0.69670296",
"0.6928266",
"0.6918168",
"0.69046986",
"0.690407",
"0.69037646",
"0.6871529",
"0.68654686",
"0.6846667",
"0.68419194",
"0.68375146",
"0.68206996",
"0.67943585",
"0.67732... | 0.78909254 | 0 |
Takes in an Image object. Resizes to terminal window size, maps pixel darkness to characters, and matches pixel colors to closest colors available to xterm. Returns CursesFrame. | def render_frame(self, image):
arr = np.array(image.resize(self.curses_shape))
characters = self.character_transformer.map_pixels_to_characters(arr)
colors = self.color_transformer.nearest_neighbors(arr)
return CursesFrame(characters, colors) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertDepthFrame(self):\n try:\n \"\"\" \n Convert Depth frame to rudimentary colormap\n \"\"\"\n self.DepthHSV[...,0] = self.currentDepthFrame\n self.DepthHSV[...,1] = 0x9F\n self.DepthHSV[...,2] = 0xFF\n self.DepthCM = cv2.c... | [
"0.546428",
"0.5435573",
"0.535255",
"0.53075343",
"0.51861966",
"0.5182019",
"0.50476694",
"0.50233334",
"0.5015882",
"0.49961483",
"0.4940678",
"0.49397632",
"0.49355415",
"0.4922061",
"0.48910037",
"0.48616993",
"0.48419634",
"0.48383147",
"0.48173562",
"0.47996178",
"0.47... | 0.667852 | 0 |
Use black text in our curses colorpairs | def use_black_text(self):
black_foreground = 0
for color in range(curses.COLORS):
curses.init_pair(color, black_foreground, color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_black(c):\n c.run(\"black .\")",
"def prBlueBG(text):\n print(\"\\033[44m{}\\033[0m\".format(text), sep=\"\")",
"def paint(self):\r\n self.win.bkgd(\" \", COLOR_PAIR[\"con_text\"])",
"def charcolor(message):\n try:\n print(c.clear)\n while True:\n print_col... | [
"0.68883044",
"0.65288943",
"0.6435637",
"0.64223605",
"0.6409496",
"0.64047366",
"0.637912",
"0.63355744",
"0.63222665",
"0.6212109",
"0.6198274",
"0.6194393",
"0.618123",
"0.6157293",
"0.6144373",
"0.6131209",
"0.61289185",
"0.6126858",
"0.6119503",
"0.61139125",
"0.6083473... | 0.8621288 | 0 |
Takes in a CursesFrame, draws to terminal window | def draw(self, curses_frame):
nrows, ncols = self.shape[1], self.shape[0]
for row in range(nrows):
for col in range(ncols):
self.screen.addch(row, col,
curses_frame.characters[row][col],
curses.color_pair(curses_frame.colors[row][col]))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, win):\n self.rect.draw(win)\n self.text.draw(win)",
"def draw(self, screen):",
"def draw(text: list):\n\n curses.wrapper(wrapper, text)",
"def draw():",
"def draw_window(win, bird, pipes, score):\n\twin.blit(bg, (0,0))\n\n\tfor pipe in pipes:\n\t\tpipe.draw(win)\n\n\tbird.dr... | [
"0.6687068",
"0.65805525",
"0.6468488",
"0.6441222",
"0.64168227",
"0.6387608",
"0.63720363",
"0.63700324",
"0.632748",
"0.63065773",
"0.6263605",
"0.61770093",
"0.61756444",
"0.61599934",
"0.61589754",
"0.6118374",
"0.60708827",
"0.6054496",
"0.60516113",
"0.6051077",
"0.600... | 0.78547007 | 0 |
Run 'git up' w/o remotes | def test_no_remotes():
os.chdir(master_path)
from PyGitUp.gitup import GitUp
with pytest.raises(GitError):
GitUp(testing=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush_repo():\n server = get_server()\n run(\"rm -rf %(project_name)s\" % env)\n git.clone()\n server.setup()",
"def update():\n call('git -C ~/norminette+ pull', shell=True)",
"def test_out_of_tree():\n os.chdir(work_tree)\n\n from PyGitUp.gitup import GitUp\n gitup = GitUp(testing... | [
"0.65749276",
"0.631371",
"0.60905033",
"0.60868317",
"0.6072795",
"0.6063428",
"0.6059339",
"0.60275495",
"0.60171896",
"0.59809583",
"0.59625286",
"0.594102",
"0.5918649",
"0.59147465",
"0.5892201",
"0.5878971",
"0.58600026",
"0.58579963",
"0.58295166",
"0.5828949",
"0.5806... | 0.696725 | 0 |
Python function wrapping c++ dcpagerank function. Computes the pagerank on the double cover of a graph. | def dcpagerank_weighted_cpp(n, ai, aj, a, alpha, eps, seedids, maxsteps, simplify=True, xlength=10**7):
# Find the appropriate types and the function to call
float_type, vtype, itype, ctypes_vtype, ctypes_itype, fun = _get_dcpagerank_weighted_cpp_types_fun(ai, aj)
# Set up the parameters for the function c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pagerank(matrix, bias, d=0.85):\n n = matrix.shape[0]\n rank = 0\n new_rank = np.array([1.0 / n] * n)\n for i in range(0,200):\n print \"iteration: \"+str(i)\n rank = new_rank\n new_rank = np.array([(1.0-d)/n] * n) + d * np.dot(matrix, rank)\n# new_rank = (1.0-d) * bias ... | [
"0.6244098",
"0.6042641",
"0.59871113",
"0.58468974",
"0.5497095",
"0.545267",
"0.53842545",
"0.53722274",
"0.5371284",
"0.5293458",
"0.5290599",
"0.52026564",
"0.5152519",
"0.51313794",
"0.5127473",
"0.50595695",
"0.5054545",
"0.502223",
"0.50221354",
"0.50027007",
"0.492262... | 0.7260255 | 0 |
Returns the root node. | def root(self) -> Node:
return self._root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root_node(self):\n return self.root",
"def root_node(self):\n return self.process_tree",
"def get_root(self):\n return self.root",
"def get_root(self):\n return self._root",
"def get_root(self):\n return self.__root",
"def get_root(self):\n return self.__... | [
"0.910351",
"0.8290668",
"0.8217083",
"0.8173495",
"0.8160994",
"0.8160994",
"0.8012295",
"0.79397935",
"0.7906321",
"0.7891344",
"0.7891344",
"0.7891344",
"0.78236896",
"0.78236896",
"0.778467",
"0.76256216",
"0.74740446",
"0.74515945",
"0.74515945",
"0.74515945",
"0.7451594... | 0.8593523 | 1 |
Returns whether a given node is the root of the tree. | def is_root(self, node: Node) -> bool:
return node == self._root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_root(self, node: object) -> bool:\n if node == self.root:\n return True\n else:\n return False",
"def is_root(self, node):\n self._validate_node(node)\n return node._index == 0",
"def is_root(self):\n return (self.__type & NODE_ROOT) == NODE_ROOT"... | [
"0.87300867",
"0.86150634",
"0.8057707",
"0.773191",
"0.76230824",
"0.76225185",
"0.75887793",
"0.75870013",
"0.7549237",
"0.75374883",
"0.7516718",
"0.7516718",
"0.7516718",
"0.75107855",
"0.7507924",
"0.7507924",
"0.7460199",
"0.74530596",
"0.7420673",
"0.7382724",
"0.73562... | 0.87255406 | 1 |
Loads the SNLI dataset Returns the train, dev and test sets in a dictionary, each as a tuple of containing the trees and the labels. | def load_snli(path, terminals_only=True, binary=False):
splits = {}
for split in ["train", "dev", "test"]:
data = list(
read_snli(split, path, terminals_only=terminals_only)
)
premises = [premise for premise, _, _ in data]
hypotheses = [hypothesis for _, hypothesis, _... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_datasets(snli_path):\n print('extract data from snli directory..')\n train = dict(); dev = dict(); test = dict()\n gold_labels = {'entailment': 0, 'neutral': 1, 'contradiction': 2}\n\n for file_type in ['train', 'dev', 'test']:\n path = os.path.join(snli_path, 'snli_1.0_{}.jsonl'.form... | [
"0.7550551",
"0.69392824",
"0.6362481",
"0.62841177",
"0.6205859",
"0.6195043",
"0.61733544",
"0.6165103",
"0.6156814",
"0.61507016",
"0.6137038",
"0.61166465",
"0.60398614",
"0.60327417",
"0.602376",
"0.59936607",
"0.59875435",
"0.5966797",
"0.5961108",
"0.5958861",
"0.59320... | 0.70486546 | 1 |
a naive implementation of numerical gradient of f at x f shoule be a function that takes a single argument x is the point (numpy array) to evaluate the gradient at | def eval_numerical_gradient(f,x):
grad = np.zeros(x.shape)
h = 0.0001
# iterate over all indexes in x
it = np.nditer(x, flag = ['multi_index'], op_flags = ['readwrite'])
while not it.finished:
ix = it.multi_index
old_value = x[ix]
x[ix] = old_value + h
fxh_left = f(x)
x[ix] = old_value - h
fxh_rig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numerical_gradient(f, x: np.ndarray):\n h = 1e-4\n grad = np.zeros_like(x)\n for i in range(x.size):\n tmp_val = x.flat[i]\n x.flat[i] = tmp_val + h\n fxh1 = f(x)\n\n x.flat[i] = tmp_val - h\n fxh2 = f(x)\n grad.flat[i] = (fxh1 - fxh2) / (2 * h)\n x.fla... | [
"0.84269315",
"0.81413966",
"0.80848795",
"0.79042566",
"0.78174055",
"0.7724996",
"0.77106667",
"0.7672559",
"0.7582516",
"0.75697535",
"0.7540686",
"0.75193363",
"0.7438803",
"0.7428454",
"0.73855096",
"0.72808963",
"0.7259516",
"0.7252474",
"0.7248751",
"0.7218508",
"0.718... | 0.8318079 | 1 |
Checks that all the user inputs were valid | def check_all_user_inputs_valid(self):
self.check_RNN_layers_valid()
self.check_activations_valid()
self.check_embedding_dimensions_valid()
self.check_initialiser_valid()
self.check_y_range_values_valid()
self.check_return_final_seq_only_valid() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self):\n return (self.check_input_digits_count()\n and self.check_if_input_is_int()\n and self.check_if_input_digits_are_unique())",
"def validate_inputs(self, extra_inputs=[]):\n pass",
"def _check_inputs(self):\n\n self._check_resident_prefs()\n ... | [
"0.7220598",
"0.7108561",
"0.70876473",
"0.70693684",
"0.70338637",
"0.70334446",
"0.70019114",
"0.6869092",
"0.68278015",
"0.682422",
"0.6806817",
"0.67754287",
"0.6775213",
"0.67563385",
"0.67295283",
"0.672505",
"0.66668016",
"0.6663835",
"0.6622917",
"0.66160303",
"0.6612... | 0.8166545 | 0 |
Checks that layers provided by user are valid | def check_RNN_layers_valid(self):
error_msg_layer_type = "First element in a layer specification must be one of {}".format(self.valid_RNN_hidden_layer_types)
error_msg_layer_form = "Layer must be of form [layer_name, hidden_units]"
error_msg_layer_list = "Layers must be provided as a list"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_layers(self, layer_param, params, permitted_layers, mandatory):\n exception = None\n\n requested_layers = params.get(layer_param)\n if requested_layers:\n requested_layers = requested_layers.split(',')\n for layer in requested_layers:\n # allow on... | [
"0.755296",
"0.6597595",
"0.64689934",
"0.6319897",
"0.6265187",
"0.62488556",
"0.6099883",
"0.6094844",
"0.6083564",
"0.60594773",
"0.6057919",
"0.6048783",
"0.60151726",
"0.5988586",
"0.59779537",
"0.59748954",
"0.5968838",
"0.59571236",
"0.59380984",
"0.5897566",
"0.585814... | 0.6611211 | 1 |
Puts relevant data through embedding layers and then concatenates the result with the rest of the data ready to then be put through the hidden layers | def incorporate_embeddings(self, x):
all_embedded_data = []
for embedding_layer_ix, embedding_var in enumerate(self.columns_of_data_to_be_embedded):
data = x[:, :, embedding_var]
embedded_data = self.embedding_layers[embedding_layer_ix](data)
all_embedded_data.append(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_data(opt, model, data_loader, log_step=10, logging=print, contextual_model=True):\n batch_time = AverageMeter()\n val_logger = LogCollector()\n\n # switch to evaluate mode\n model.val_start(opt)\n\n end = time.time()\n\n # numpy array to keep all the embeddings\n clip_embs, cap_embs = [], []\n v... | [
"0.6751634",
"0.66188323",
"0.6565778",
"0.6504802",
"0.6489491",
"0.6482955",
"0.64141357",
"0.64005345",
"0.63975483",
"0.6358861",
"0.6324988",
"0.6312998",
"0.6306232",
"0.62920576",
"0.6267797",
"0.62240666",
"0.6208343",
"0.61861455",
"0.6166707",
"0.6162105",
"0.610380... | 0.6679302 | 1 |
Method to create a dictionary of state block representing stream states. This takes a dict with stream name keys and stream values. | def stream_states_dict(streams, time_point=0):
stream_dict = OrderedDict()
def _stream_dict_add(sb, n, i=None):
"""add a line to the stream table"""
if i is None:
key = n
else:
key = "{}[{}]".format(n, i)
stream_dict[key] = sb
for n in streams.keys()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, owner, stateNumber):\n self.streamInfoDict = {}\n self.stateNumber = stateNumber\n self.owner = owner",
"def make_state_dict(self):\r\n state_dict = {c.TRANSITION_IN: self.transition_in,\r\n c.TRANSITION_OUT: self.transition_out,\r\n ... | [
"0.6171527",
"0.6134761",
"0.6117695",
"0.6105486",
"0.5810494",
"0.5645507",
"0.56314987",
"0.5620535",
"0.5580415",
"0.55707365",
"0.5560745",
"0.5542073",
"0.55274445",
"0.5510747",
"0.5489986",
"0.54460365",
"0.5440837",
"0.5429758",
"0.5429758",
"0.54054964",
"0.5401729"... | 0.75801265 | 0 |
Method to create a stream table in the form of a pandas dataframe. Method takes a dict with name keys and stream values. Use an OrderedDict to list the streams in a specific order, otherwise the dataframe can be sorted later. | def create_stream_table_dataframe(
streams, true_state=False, time_point=0, orient="columns"
):
stream_attributes = OrderedDict()
stream_states = stream_states_dict(streams=streams, time_point=time_point)
full_keys = [] # List of all rows in dataframe to fill in missing data
stream_attributes["Un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_stream_table_ui(\n streams, true_state=False, time_point=0, orient=\"columns\", precision=5\n):\n\n # Variable Types:\n class VariableTypes:\n UNFIXED = \"unfixed\"\n FIXED = \"fixed\"\n PARAMETER = \"parameter\"\n EXPRESSION = \"expression\"\n\n stream_attributes... | [
"0.7057761",
"0.627377",
"0.611543",
"0.5960522",
"0.58987206",
"0.5864669",
"0.57906604",
"0.5757231",
"0.5680212",
"0.56271696",
"0.56033725",
"0.5602798",
"0.5569012",
"0.555265",
"0.5547795",
"0.5495419",
"0.54677314",
"0.54455346",
"0.54358",
"0.5394573",
"0.53550637",
... | 0.7505053 | 0 |
Method to create a stream table in the form of a pandas dataframe. Method takes a dict with name keys and stream values. Use an OrderedDict to list the streams in a specific order, otherwise the dataframe can be sorted | def create_stream_table_ui(
streams, true_state=False, time_point=0, orient="columns", precision=5
):
# Variable Types:
class VariableTypes:
UNFIXED = "unfixed"
FIXED = "fixed"
PARAMETER = "parameter"
EXPRESSION = "expression"
stream_attributes = OrderedDict()
strea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_stream_table_dataframe(\n streams, true_state=False, time_point=0, orient=\"columns\"\n):\n\n stream_attributes = OrderedDict()\n stream_states = stream_states_dict(streams=streams, time_point=time_point)\n full_keys = [] # List of all rows in dataframe to fill in missing data\n\n stream... | [
"0.7518011",
"0.62724274",
"0.6179858",
"0.588675",
"0.5853962",
"0.58128667",
"0.57937926",
"0.5699301",
"0.56680727",
"0.5644031",
"0.5609429",
"0.55866784",
"0.55698466",
"0.5561937",
"0.55287117",
"0.5496556",
"0.545095",
"0.5440981",
"0.5406918",
"0.5390033",
"0.5360076"... | 0.71313876 | 1 |
Method to print a stream table from a dataframe. Method takes any argument understood by DataFrame.to_string | def stream_table_dataframe_to_string(stream_table, **kwargs):
# Set some default values for keyword arguments
na_rep = kwargs.pop("na_rep", "-")
justify = kwargs.pop("justify", "center")
float_format = kwargs.pop("float_format", lambda x: "{:#.5g}".format(x))
# Print stream table
return stream_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_dataframe_content(dataframe):\n\n dataframe_len = len(dataframe.columns)\n dataframe_columns_index = list(range(0, dataframe_len))\n dataframe_column_index_len = len(dataframe_columns_index)\n\n if dataframe.empty:\n print('Empty dataframe.')\n else:\n should_continue_process... | [
"0.71346676",
"0.70650566",
"0.67613006",
"0.6756046",
"0.66866994",
"0.6665646",
"0.6648919",
"0.6601342",
"0.6567974",
"0.6533634",
"0.647307",
"0.6460402",
"0.63788",
"0.63754827",
"0.6371477",
"0.6357922",
"0.6357922",
"0.63577956",
"0.6285462",
"0.6260336",
"0.6228227",
... | 0.7853061 | 0 |
Attempt to find a StateBlocklike object connected to a Port. If the object is indexed both in space and time, assume that the time index comes first. If no components are assigned to the Port, raise a ValueError. If the first component's parent block has no index, raise an AttributeError. If different variables on the ... | def _get_state_from_port(port, time_point):
vlist = list(port.iter_vars())
states = [v.parent_block().parent_component() for v in vlist]
if len(vlist) == 0:
raise ValueError(
f"No block could be retrieved from Port {port.name} "
f"because it contains no components."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(self,port):\n\tif self.portlist == []:\n\t\treturn -1\n\tif isinstance(port,Port):\n\t\tport = (int(port.GetPortNbr()), port.GetPortWay())\n\tmatch = ( (int(self.portlist[0].GetPortNbr()), self.portlist[0].GetPortWay()) == port )\n\ti = 0\n\twhile ( not match and i<len(self.portlist)-1 ):\n\t\ti += 1\n\t\... | [
"0.5097411",
"0.49286756",
"0.49020544",
"0.4896261",
"0.48728776",
"0.4848658",
"0.48388606",
"0.48070934",
"0.47842085",
"0.4696942",
"0.46295482",
"0.46090135",
"0.4582102",
"0.4582032",
"0.4542554",
"0.45188886",
"0.45160478",
"0.45076382",
"0.45029464",
"0.45028275",
"0.... | 0.7329799 | 0 |
Create a Pandas DataFrame that contains a list of userdefined attributes from a set of Blocks. | def generate_table(blocks, attributes, heading=None, exception=True):
if heading is None:
heading = attributes
st = DataFrame(columns=heading)
row = [None] * len(attributes) # not a big deal but save time on realloc
for key, s in blocks.items():
for i, a in enumerate(attributes):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_dataframe(block_zones, block_guid, block_name, block_pt, block_layer):\n # make an empty list to populate with block objects\n blocks = []\n # connect gh wires to python block classes\n for i, z in enumerate(block_zones):\n b = Block()\n b.guid = block_guid[i]\n b.name = ... | [
"0.6213763",
"0.60232276",
"0.5933897",
"0.58126754",
"0.57580143",
"0.5599309",
"0.5351924",
"0.5347785",
"0.53098786",
"0.52822083",
"0.52670205",
"0.5263557",
"0.52503467",
"0.52472496",
"0.52292097",
"0.52067655",
"0.51953876",
"0.518646",
"0.51731384",
"0.5167735",
"0.51... | 0.68994987 | 0 |
Imports jammer info from [jammers.csv] it will perform classification and picture (url) fetching returns a list of Jammer objects with propagated fields. Hardcoded reasoner that thinks the jammer has a ticket, if it comes from the jammers.csv file. | def import_jammers(csvfile, fieldnames=None):
parsed_jammers = []
if fieldnames is None:
# Read fieldnames from first line of csvfile.
jammers = csv.DictReader(csvfile)
else:
# Fieldnames provided
# Skip header line/fieldnames line
jammers = csv.DictReader(csvfile, fieldnames)
next(jammers)
for jammer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_registered_jammers(filename=\"jammerskillz.csv\"):\n\tfrom utils import gf_fieldnames\n\treturn import_jammers(filename, fieldnames=gf_fieldnames())",
"def import_from_file(jamsite, source='jammers.csv', fieldnames=None):\n\t# import jammers.csv\n\twith open(source) as csvfile:\n\t\tjamsite.mergeinser... | [
"0.6269612",
"0.5713424",
"0.545809",
"0.5050449",
"0.50021917",
"0.49669176",
"0.49323994",
"0.4921784",
"0.48439816",
"0.48355928",
"0.48049712",
"0.47829503",
"0.4769548",
"0.4752347",
"0.47450462",
"0.47308967",
"0.4725612",
"0.46987265",
"0.4671122",
"0.4665979",
"0.4655... | 0.6562913 | 0 |
Fetches the gforms results page as csv from a published csv link. imports it to the jamsite.jammers | def import_from_url(jamsite, url, fieldnames=None):
# import csv, from the webz.
csvfile = fetch_csv_from_url(url)
jamsite.mergeinsert( import_jammers(csvfile, fieldnames=fieldnames) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_report():\n entities = get_names()\n save_csv(entities)",
"def get_csv(request, cur_course_user, assessment_id):\n assessment = shortcuts.get_object_or_404(models.Assessment, pk=assessment_id)\n\n # Create the HttpResponse object with the appropriate CSV header.\n response = http.HttpRespon... | [
"0.6201149",
"0.607644",
"0.6065895",
"0.6027334",
"0.6022655",
"0.6019954",
"0.5921036",
"0.58984226",
"0.58627075",
"0.58585614",
"0.5844853",
"0.5842384",
"0.58340067",
"0.5828979",
"0.57914275",
"0.57760054",
"0.57621425",
"0.57086945",
"0.5707585",
"0.5690205",
"0.567674... | 0.6346724 | 0 |
Imports from jammers.csv and mergeinserts into jamsite.jammers. | def import_from_file(jamsite, source='jammers.csv', fieldnames=None):
# import jammers.csv
with open(source) as csvfile:
jamsite.mergeinsert( import_jammers(csvfile, fieldnames=fieldnames) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_registered_jammers(filename=\"jammerskillz.csv\"):\n\tfrom utils import gf_fieldnames\n\treturn import_jammers(filename, fieldnames=gf_fieldnames())",
"def import_jammers(csvfile, fieldnames=None):\n\tparsed_jammers = []\n\tif fieldnames is None:\n\t\t# Read fieldnames from first line of csvfile.\n\t\... | [
"0.65137184",
"0.643069",
"0.60201544",
"0.5691",
"0.56182426",
"0.5514427",
"0.55112034",
"0.54825675",
"0.5477282",
"0.5451876",
"0.53347766",
"0.5326418",
"0.53094995",
"0.5309341",
"0.5289789",
"0.5280948",
"0.52332306",
"0.5228012",
"0.5208589",
"0.52083606",
"0.5201785"... | 0.77328527 | 0 |
Input a google form mapped fieldnames file, | def gf_fieldnames(fn="forms-fields.txt"):
if fn is None:
return None
with open(fn) as f:
fieldnames = [fieldname.split(":")[0] for fieldname in f]
return fieldnames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_PDF_with_field_names(csv_file_name, pdf_file_name):\n field_mapping = get_field_list(csv_file_name)\n print \"UPDATING FORM VALUES\"\n update_form_values(pdf_file_name, 'out-' + pdf_file_name) # enumerate & fill the fields with their own names\n update_form_values(pdf_file_name, 'output-'... | [
"0.61632854",
"0.548621",
"0.5437756",
"0.54099333",
"0.538648",
"0.51360255",
"0.5062522",
"0.50576115",
"0.5052346",
"0.5046612",
"0.50351626",
"0.5026276",
"0.50158596",
"0.5007784",
"0.49943054",
"0.4981942",
"0.4961241",
"0.49573717",
"0.4890512",
"0.48849797",
"0.487376... | 0.6461564 | 0 |
Remove all files from list of files not mentioned in a changes file. | def remove_cruft_files(cls, files):
valid_files = []
for changes_file in files:
if cls.is_changes(changes_file):
LOG.debug("Checking: {c}".format(c=changes_file))
try:
with mini_buildd.misc.open_utf8(changes_file) as cf:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_files(self, files: Set[str]) -> None:\n for f in files:\n src = os.path.join(self.get_directory(), f)\n os.remove(src)",
"def remove_files(files):\n for file_name in files:\n os.remove(file_name)",
"def decide_files_to_delete(files: list) -> Set:\n files_to_... | [
"0.73587847",
"0.7211431",
"0.7047009",
"0.6971956",
"0.6960391",
"0.69041646",
"0.6855135",
"0.6853807",
"0.684943",
"0.6742613",
"0.67363465",
"0.6628714",
"0.66005105",
"0.6550325",
"0.65438914",
"0.65044606",
"0.64617664",
"0.64221704",
"0.6410761",
"0.63926953",
"0.63668... | 0.7371116 | 0 |
Remove cruft files from incoming. | def remove_cruft(cls):
cls.remove_cruft_files(["{p}/{f}".format(p=mini_buildd.config.INCOMING_DIR, f=f) for f in os.listdir(mini_buildd.config.INCOMING_DIR)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_cruft_files(cls, files):\n valid_files = []\n for changes_file in files:\n if cls.is_changes(changes_file):\n LOG.debug(\"Checking: {c}\".format(c=changes_file))\n try:\n with mini_buildd.misc.open_utf8(changes_file) as cf:\n ... | [
"0.7069261",
"0.65022355",
"0.6483339",
"0.6470212",
"0.63693684",
"0.63030815",
"0.62388057",
"0.6237357",
"0.61482847",
"0.61369854",
"0.6103959",
"0.6088915",
"0.60184264",
"0.5994813",
"0.5988947",
"0.5985742",
"0.59550464",
"0.593584",
"0.5918022",
"0.5881333",
"0.586764... | 0.7153117 | 0 |
Requeue all existing changes in incoming. We must feed the the user uploads first, so the daemon does not get any yetunknown build results (hence the sorting). | def requeue_changes(cls, queue):
for c in sorted(cls.get_changes(), key=lambda c: 1 if fnmatch.fnmatch(c, "*mini-buildd-build*") else 0):
LOG.info("Incoming: Re-queuing: {c}".format(c=c))
queue.put(c) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queueStatusAll():",
"def _process_incoming_queue_messages(self):\n while self._queue.qsize():\n msg = self._queue.get()\n if msg == MAP_UPDATE:\n self._clear_measurement_progress_label()\n self._presenter.update_map(self.chosen_value.get())",
"def ... | [
"0.63072103",
"0.59501857",
"0.5914015",
"0.58714503",
"0.58414",
"0.582209",
"0.5728848",
"0.57213223",
"0.56732166",
"0.5665568",
"0.56222856",
"0.56147325",
"0.5610322",
"0.5587205",
"0.558216",
"0.55685467",
"0.55618864",
"0.5524419",
"0.5512161",
"0.5472448",
"0.54688776... | 0.7815794 | 0 |
Check if the testbed is dualtor. | def is_dualtor(tbinfo):
return "dualtor" in tbinfo["topo"]["name"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_dualtor(tbinfo):\n pytest_require(\"dualtor\" not in tbinfo[\"topo\"][\"name\"], \"Skip 'test_tagged_arp' over dualtor.\")",
"def test_case(self) -> bool:\n return pulumi.get(self, \"test_case\")",
"def spec(self) -> bool:\n\t\treturn True",
"def in_test_mode(mode: str) -> bool:\n retur... | [
"0.6514536",
"0.60643315",
"0.60052663",
"0.592934",
"0.5915355",
"0.5871197",
"0.5859092",
"0.5826975",
"0.5814629",
"0.5802817",
"0.5687041",
"0.5671905",
"0.5647522",
"0.56311524",
"0.563024",
"0.562746",
"0.5623227",
"0.56203735",
"0.55674803",
"0.55630165",
"0.5551409",
... | 0.6489944 | 1 |
Given a timedelta object, returns a float representing milliseconds | def ms_from_timedelta(td):
return (td.seconds * 1000) + (td.microseconds / 1000.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __timedelta_millis(td):\n return int(round(td.total_seconds(), 3) * 1000)",
"def timedeltaToFloat(self,time_d):\n time_d_min = time_d / timedelta(minutes=1)\n time_d_s = time_d / timedelta(seconds=1)\n time_d_ms = time_d / timedelta(milliseconds=1)\n\n return (time_d_min * 60 +... | [
"0.79984653",
"0.7154051",
"0.69038457",
"0.68848103",
"0.67910194",
"0.6784229",
"0.6774616",
"0.67619616",
"0.6695946",
"0.6629579",
"0.6577556",
"0.65353703",
"0.6470385",
"0.6467742",
"0.6434467",
"0.6433005",
"0.6432159",
"0.6419568",
"0.63950807",
"0.638573",
"0.6364025... | 0.8328362 | 0 |
Couchdbkit < 0.6.0 changes feed listener | def old_changes(self):
from couchdbkit import Consumer
c = Consumer(self.couch_db, backend='gevent')
while True:
try:
c.wait(self.parsing_processor, since=self.since, filter=self.couch_filter,
heartbeat=WAIT_HEARTBEAT, feed='continuous', timeou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MyDataChangedCallback(self, inRefcon):\r\n pass",
"def new_changes(self):\n with ChangesStream(self.couch_db, feed='continuous', heartbeat=True, since=self.since,\n filter=self.couch_filter, **self.extra_args) as st:\n for c in st:\n self.proc... | [
"0.62532365",
"0.6226378",
"0.61087376",
"0.59061956",
"0.580392",
"0.5717122",
"0.5684762",
"0.5652663",
"0.5625966",
"0.55350727",
"0.5533221",
"0.54960304",
"0.5480702",
"0.5476974",
"0.546286",
"0.5462046",
"0.5432287",
"0.5430175",
"0.5393917",
"0.5377997",
"0.5354258",
... | 0.6658043 | 0 |
Processor that also parses the change to json only for pre 0.6.0 couchdbkit, as the change is passed as a string | def parsing_processor(self, change):
self.processor(simplejson.loads(change)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changeFromMessage(message):\n retval = message['payload']['change']\n retval['revision'] = retval['rev']\n retval['properties'] = dict((k,v) for (k,v,s) in retval['properties'])\n retval['files'] = [f['name'] for f in retval['files']]\n if not retval['files']:\n retval['files'] = ['dummy'... | [
"0.5822516",
"0.5435952",
"0.540422",
"0.52699476",
"0.52576315",
"0.5242274",
"0.52018917",
"0.5112058",
"0.5104661",
"0.5075216",
"0.506897",
"0.50613344",
"0.5037064",
"0.50290513",
"0.5022374",
"0.5008275",
"0.5005664",
"0.49938402",
"0.49938402",
"0.49796298",
"0.4958498... | 0.70396775 | 0 |
Set a more optimized setting setup for fast reindexing | def set_index_reindex_settings(self):
return self.update_settings(INDEX_REINDEX_SETTINGS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSpellerCacheSize(self, value):\n self.setIntegerOption(17, value)",
"def cacheOptionsForBuild(self):",
"def test_change_default_throttling_settings_http_with_overwrite_throttled():",
"def test_change_default_throttling_settings_http_with_overwrite_not_throttled():",
"def _optimise(self):\n ... | [
"0.57740206",
"0.569045",
"0.56603867",
"0.564941",
"0.5621489",
"0.55744123",
"0.5519884",
"0.54922324",
"0.54647976",
"0.53976315",
"0.5357913",
"0.5357913",
"0.5356065",
"0.5311139",
"0.5212538",
"0.5199254",
"0.51861364",
"0.51667863",
"0.5117706",
"0.5116156",
"0.5114999... | 0.65560335 | 0 |
Using the HEAD 404/200 result API for document existence Returns True if 200(exists) | def doc_exists(self, doc_id):
es = self.get_es()
doc_path = self.get_doc_path(doc_id)
head_result = es.head(doc_path)
return head_result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists(path):\n r = requests.head(path)\n # print(r.status_code)\n return r.status_code == requests.codes.ok",
"def doc_exists(self, doc_dict):\n es = self.get_es()\n head_result = es.head(self.get_doc_path_typed(doc_dict))\n return head_result",
"def is_exist(self, status_cod... | [
"0.7441819",
"0.6859171",
"0.67155325",
"0.66828007",
"0.6660155",
"0.64963514",
"0.6493887",
"0.64617324",
"0.63922584",
"0.6353348",
"0.63439393",
"0.63398975",
"0.63322216",
"0.6331907",
"0.6277079",
"0.6238249",
"0.6191304",
"0.6183627",
"0.61783135",
"0.6140467",
"0.6092... | 0.70652413 | 1 |
Generator function for bulk changes note each individual change item goes through the pillowtop pathway individually when loading the bulk item, and short of change_transport, it's identical. It would be slightly more efficient if the couch load could be done in bulk for the actual documents, but it's not quite possibl... | def bulk_builder(self, changes):
for change in changes:
try:
t = self.change_trigger(change)
if t is not None:
tr = self.change_transform(t)
if tr is not None:
self.change_transport(tr)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step070() -> None:\n logger.logMessage('Begin: elasticsearch bulk update')\n client = es.Elasticsearch(hostlist)\n\n def generate():\n with open(renumFile,'r') as f:\n line = f.readline().rstrip()\n while line != '':\n fields = line.split(';')\n ... | [
"0.5816827",
"0.5687157",
"0.56473476",
"0.5625761",
"0.5434474",
"0.53927106",
"0.5390141",
"0.53204507",
"0.5286606",
"0.52333415",
"0.51879084",
"0.5183084",
"0.51375544",
"0.51019603",
"0.5101592",
"0.50638294",
"0.5050282",
"0.50388134",
"0.49663755",
"0.49251467",
"0.48... | 0.6802877 | 0 |
Naive means to verify the alias of the current pillow iteration is matched. If we go fancier with routing and multiindex aliases due to index splitting, this will need to be revisited. | def check_alias(self):
es = self.get_es()
aliased_indexes = es[self.es_alias].get('_aliases')
return aliased_indexes.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alias_exists(self, alias):\n req = requests.head(\n urljoin(self.base_url, '_alias/{0}'.format(alias)),\n verify=self.verify_certs)\n return req.status_code == 200",
"def is_aliasable(self, *args):\n return _ida_hexrays.vdloc_t_is_aliasable(self, *args)",
"def alt... | [
"0.6139494",
"0.5927287",
"0.58235115",
"0.580604",
"0.580179",
"0.5758179",
"0.5729632",
"0.56602716",
"0.5649573",
"0.5600212",
"0.5569809",
"0.5567751",
"0.5552736",
"0.5540553",
"0.55247414",
"0.54951197",
"0.5476063",
"0.54035634",
"0.5327102",
"0.5275424",
"0.52657884",... | 0.6047442 | 1 |
For this instance, have the index that represents this index receive the alias itself. This presents a management issue later if we route out additional indexes/aliases that we automate this carefully. But for now, 1 alias to 1 index. Routing will need a refactor anyway | def assume_alias(self):
es = self.get_es()
if es.head(self.es_alias):
#remove all existing aliases - this is destructive and could be harmful, but for current
#uses, it is legal - in a more delicate routing arrangement, a configuration file of
# some sort should be i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_alias(self, alias, index):\n if index >= len(self._datasets):\n raise DataInvalidIndex('A dataset with index {} does not exist'.format(index))\n self._aliases[alias] = index",
"def get_indexes_from_alias(self, alias):\n return requests.get(\n urljoin(self.base_u... | [
"0.6676081",
"0.66249245",
"0.6387008",
"0.62786865",
"0.62055886",
"0.61112547",
"0.60653275",
"0.6054649",
"0.60334975",
"0.60334975",
"0.59681004",
"0.5964024",
"0.5911201",
"0.5893658",
"0.5892665",
"0.58747756",
"0.58730376",
"0.5786041",
"0.5774079",
"0.5764505",
"0.575... | 0.7307731 | 0 |
Verify whether the server has indexed this type We can assume at startup that the mapping from the server is loaded, so in memory will be up to date. | def type_exists(self, doc_dict, server=False):
es = self.get_es()
type_string = self.get_type_string(doc_dict)
if server and self.online:
type_path = "%(index)s/%(type_string)s" % (
{
'index': self.es_index,
'type_string': type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_index(self):\n return self.index is not None",
"def check_type(self):\n pass\n\n indice = client.IndicesClient(self.es)\n print(self.es_main_index)\n if indice.exists_type(index=self.es_main_index,\n doc_type=self.es_main_type):\n ... | [
"0.63144267",
"0.6157267",
"0.60441124",
"0.6003592",
"0.59744084",
"0.58695626",
"0.5794515",
"0.57553786",
"0.5698403",
"0.5676481",
"0.56584233",
"0.5648552",
"0.56066954",
"0.560276",
"0.55641127",
"0.55522156",
"0.5533276",
"0.55121136",
"0.55082977",
"0.5486367",
"0.546... | 0.67840266 | 0 |
performs a DNS lookup an ip or hostname. | def handle_dns(bot, ievent):
if not ievent.args:
ievent.missing('<host | ip>')
else:
is_a = None
result = None
# If we support IPv6 ...
if socket.has_ipv6:
# ... then check if this is an IPv6 ip
try:
socket.inet_pton(socket.AF_INE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nslookup(name, dnsserver='', prevent_unqualified_dns=True):\n # if it looks like an IP address, don't try to resolve it\n if digitsAndDots.match(name):\n return (0, \"OK\")\n if name != \"localhost\" and prevent_unqualified_dns:\n name = name + \".\" # prevent unqualified DNS lookups\n\n # TODO: we r... | [
"0.758345",
"0.72457",
"0.69946975",
"0.6803022",
"0.6664075",
"0.6664075",
"0.6659345",
"0.6629895",
"0.66242015",
"0.6593789",
"0.6536833",
"0.65359706",
"0.6534513",
"0.65007156",
"0.64688385",
"0.6463831",
"0.64384496",
"0.6414392",
"0.63627326",
"0.6354092",
"0.6319608",... | 0.73357594 | 1 |
Discovers the resource structure and attributes. | def get_inventory(self, context):
# See below some example code demonstrating how to return the resource structure
# and attributes. In real life, of course, if the actual values are not static,
# this code would be preceded by some SNMP/other calls to get the actual resource information
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_resource_metadata(self):\n self.rmeta_path = os.path.join(self.bag_content_path, self.res_meta_path)\n if not os.path.exists(self.rmeta_path):\n raise GenericResourceMeta.ResourceMetaException(\n \"Resource metadata {0} does not exist\".format(self.rmeta_path))\n ... | [
"0.5671755",
"0.5449949",
"0.53734154",
"0.5339723",
"0.5314795",
"0.529846",
"0.5258291",
"0.5246755",
"0.52241033",
"0.5214886",
"0.5209261",
"0.51976424",
"0.51858026",
"0.5176893",
"0.51756376",
"0.51583856",
"0.51576287",
"0.5146784",
"0.51284975",
"0.5121302",
"0.511320... | 0.58067125 | 0 |
Write decorated test log for all levels | def log_all_levels_decorated(logger_instance):
for log_level in list(new_loglevel_dict.keys()) + list(standard_loglevel_dict.keys()):
getattr(logger_instance, log_level.lower())('test ' + log_level, decorated=True)
getattr(logger_instance, "info")("", decorated=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_default():\n logger = logging.getLogger(__name__)\n log_all_levels(logger)\n log_all_levels_decorated(logger)\n log_all_levels_loop(logger)\n return logger",
"def testLoggerLevels(self):\n logging = Logger()\n for level in range(len(logging.LEVELS)):\n testString ... | [
"0.7253009",
"0.70702046",
"0.68437916",
"0.68053335",
"0.6804448",
"0.6685715",
"0.66668046",
"0.6588776",
"0.6572676",
"0.65395325",
"0.6526354",
"0.6512286",
"0.650486",
"0.6426932",
"0.640954",
"0.6406446",
"0.64059454",
"0.6372152",
"0.6348167",
"0.63254714",
"0.63050705... | 0.7710551 | 0 |
Write test log for loops on all levels | def log_all_levels_loop(logger_instance):
for log_level in list(new_loglevel_dict.keys()) + list(standard_loglevel_dict.keys()):
for i in range(3):
logger_instance.loop_counter("test", i, getattr(logging, log_level.upper()))
getattr(logger_instance, log_level.lower())("\n\n") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTest(self):\n import logging\n lg_name = expector.logger_name\n lg = logging.getLogger(lg_name)\n start_level = logging.getLevelName('DEBUG_9')\n end_level = logging.getLevelName('CRITICAL_0')\n for lvl in range(start_... | [
"0.7322604",
"0.7109084",
"0.694877",
"0.6849797",
"0.67564356",
"0.6494106",
"0.64357036",
"0.63690066",
"0.63465595",
"0.6284087",
"0.62071955",
"0.61847913",
"0.6177005",
"0.6165315",
"0.6150953",
"0.6119336",
"0.6119231",
"0.61017275",
"0.607864",
"0.6051501",
"0.5957064"... | 0.7543858 | 0 |
Load a subset of the floorplan dataset. | def load_floorplan(self, dataset_dir, subset):
# Set class set based on provided config default classes
class_set = self.config.CLASSES
# Add Classes to inner collection
for idx, c in enumerate(class_set):
self.add_class("floorplan", idx + 1, c)
# Train or validati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(subset: str):\n df_train = pd.read_csv(f\"{DATA_PATH}/train_durations_per_speaker.csv\")\n df_test = pd.read_csv(f\"{DATA_PATH}/val_durations_per_speaker.csv\")\n df_global = pd.read_csv(f\"{DATA_PATH}/global_durations_per_speaker.csv\")\n if (subset == \"train\"):\n df = df_train\... | [
"0.661039",
"0.62231714",
"0.6147798",
"0.583328",
"0.5583259",
"0.5560036",
"0.54643214",
"0.540946",
"0.5382919",
"0.5382749",
"0.5364376",
"0.53627944",
"0.5359254",
"0.5358604",
"0.534547",
"0.53237855",
"0.53235096",
"0.531234",
"0.5311516",
"0.5301634",
"0.53001165",
... | 0.71230924 | 0 |
Generate instance masks for shapes of the given image ID. | def load_mask(self, image_id):
info = self.image_info[image_id]
mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
dtype=np.uint8)
shapes = info['polygons']
for i, p in enumerate(info['polygons']):
shape = p['shape_attributes']['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_mask(self, image_id):\n\n image_info = self.image_info[image_id]\n if image_info[\"source\"] != \"pcb\":\n return super(self.__class__, self).load_mask(image_id)\n\n # convert polygons to a bitmap mask of shape\n # [height, width, instance_count]\n info = self... | [
"0.7636923",
"0.742737",
"0.7384672",
"0.7339207",
"0.72988886",
"0.7290323",
"0.71908504",
"0.713616",
"0.713167",
"0.7113493",
"0.70892924",
"0.70513177",
"0.7007302",
"0.7003303",
"0.70003724",
"0.69821656",
"0.68691427",
"0.6793878",
"0.6793428",
"0.6769815",
"0.6765007",... | 0.7464017 | 1 |
Route to redirect /v to /version permanently (301). | def redirect_version():
return redirect(url_for("base_blueprint.version"), code=301) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redir_index():\n return redirect(url_for(\"index\"), code=301)",
"def redirect_source():\n return redirect(url_for(\"base_blueprint.source\"), code=301)",
"def redirect_old_featured(page):\r\n return redirect(url_for('.index', page=page), 301)",
"def redirect_view(request):\n path = request.G... | [
"0.60801035",
"0.56187874",
"0.5600564",
"0.5590633",
"0.5558089",
"0.55440605",
"0.5326738",
"0.529449",
"0.5254541",
"0.52042747",
"0.51776284",
"0.5129523",
"0.51130855",
"0.51113045",
"0.5070587",
"0.5069953",
"0.50527155",
"0.5035664",
"0.500536",
"0.49580628",
"0.492803... | 0.7418174 | 0 |
Route to return the current version of the application. | def version():
from app import get_version
return render_template("version.html", version=get_version()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_application_version(self):\n return self.connector.request('GET', '/app/version')",
"def GetVersion(self):\n return self._SendRequest(HTTP_GET, \"/version\", None, None)",
"def redirect_version():\n return redirect(url_for(\"base_blueprint.version\"), code=301)",
"def dispatch(self, req,... | [
"0.7166603",
"0.6996313",
"0.6883298",
"0.6768739",
"0.67376894",
"0.6720483",
"0.66486543",
"0.6620883",
"0.6592513",
"0.65706766",
"0.655283",
"0.65500826",
"0.6521532",
"0.65004563",
"0.6468458",
"0.64239985",
"0.6387191",
"0.6363297",
"0.6339282",
"0.63187337",
"0.6308470... | 0.774868 | 0 |
Redirects /s to /source permanently (301). | def redirect_source():
return redirect(url_for("base_blueprint.source"), code=301) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_301(self, new_url):\n try:\n self.send_response(301)\n self.send_header('Location', new_url)\n self.send_header('Content-type', 'text/html')\n self.end_headers()\n except UnicodeEncodeError:\n self._send_internal_server_error()",
"def... | [
"0.61149055",
"0.5877363",
"0.58217674",
"0.574811",
"0.5609715",
"0.55710393",
"0.55684286",
"0.556559",
"0.55389315",
"0.54649377",
"0.5393228",
"0.52729505",
"0.5256892",
"0.5242376",
"0.523995",
"0.52105653",
"0.5163181",
"0.51342165",
"0.5124434",
"0.5098271",
"0.5082799... | 0.7261589 | 0 |
Redirects to the last menus' url. | def source():
return redirect(get_last_menus_url()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_redirect():\r\n return redirect(url_for(\"display_top\"))",
"def get_redirect_url(self):\n return reverse('accounts:home')",
"def redirect(url):",
"def get(self, request):\n return redirect('start:home')",
"def get(self, request):\n return redirect('start:home')",
"def ge... | [
"0.6405678",
"0.63813686",
"0.6303314",
"0.6293801",
"0.6293801",
"0.6293801",
"0.62527364",
"0.62424713",
"0.61899626",
"0.6161606",
"0.615013",
"0.61412543",
"0.60826886",
"0.60195106",
"0.6013808",
"0.6008119",
"0.598344",
"0.598344",
"0.5967124",
"0.5961747",
"0.5948852",... | 0.77138567 | 0 |
finds all MP3s below the path given and returns a list of all the file paths | def findMP3s(path=None):
if not path:
lib_path = r'.\songs'
else:
lib_path = path
all_songs = []
#folder from os.walk is: root, dirnames, filenames
for rt, dirs, files in os.walk(lib_path):
for fp in files:
if fnmatch.fnmatch(fp, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mp3_files(path):\n for dirname, dirnames, filenames in sorted(os.walk(path)):\n for filename in filenames:\n filepath = os.path.join(dirname, filename)\n if is_mp3_file(filepath):\n yield filepath",
"def list_directory(path):\n files = []\n for f in li... | [
"0.7776858",
"0.7220829",
"0.72117263",
"0.68320405",
"0.678996",
"0.67430526",
"0.671247",
"0.664901",
"0.66283673",
"0.65808403",
"0.6493454",
"0.6273654",
"0.617928",
"0.61612785",
"0.61595064",
"0.61321527",
"0.60744894",
"0.60734063",
"0.60670584",
"0.60611314",
"0.60567... | 0.86981595 | 0 |
Extract metadata from options and populate a post node. | def _update_post_node(node, options, arguments):
node["date"] = arguments[0] if arguments else None
node["tags"] = options.get("tags", [])
node["author"] = options.get("author", [])
node["category"] = options.get("category", [])
node["location"] = options.get("location", [])
node["language"] = o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_meta(self, post, *args, **kwargs):\n\t\tsuper(Command, self).add_meta(post, *args, **kwargs)\n\t\tpost.gen_description = False\n\t\tpost.description = description_from_content(post)\n\t\tpost.save()",
"def post(self):\n args = parser.parse_args()",
"def handle_post(self, node):\n\t\tattr = node.... | [
"0.59166276",
"0.5812724",
"0.56457675",
"0.56069916",
"0.526757",
"0.52343196",
"0.52183485",
"0.5210904",
"0.5157758",
"0.51434153",
"0.50863826",
"0.5043521",
"0.50420105",
"0.50243163",
"0.5016184",
"0.5016184",
"0.5013102",
"0.4995355",
"0.49839917",
"0.49028623",
"0.489... | 0.68622595 | 0 |
Return section title as text. | def _get_section_title(section):
for title in section.findall(nodes.title):
return title.astext()
raise Exception("Missing title")
# A problem with the following is that title may contain pending
# references, e.g. :ref:`tag-tips` | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(self):\n return self.header",
"def get_section_title(\n header_element: lxml.html.Html.Element,\n anchor_characters: str | None = None,\n) -> str:\n return clean_title_text(header_element.text_content())",
"def get_title():",
"def get_title(self) -> str:\n pass",
"def titl... | [
"0.72328174",
"0.7200083",
"0.7151541",
"0.7150657",
"0.70747584",
"0.70035803",
"0.70035803",
"0.70035803",
"0.6951649",
"0.6951533",
"0.6945576",
"0.6945576",
"0.6945576",
"0.6924524",
"0.69163346",
"0.6911535",
"0.6908612",
"0.6906137",
"0.6904355",
"0.6904355",
"0.6900102... | 0.7722091 | 0 |
Return list of dates of updates found section. | def _get_update_dates(section, docname, post_date_format):
update_nodes = list(section.findall(UpdateNode))
update_dates = []
for update_node in update_nodes:
try:
update = datetime.strptime(update_node["date"], post_date_format)
except ValueError:
if date_parser:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_last_update_dates(self, feed):\n parsed_feed = parse_feed(feed)\n\n if not parsed_feed:\n return []\n\n dates = [\n (publication.metadata.identifier, publication.metadata.modified)\n for publication in self._get_publications(parsed_feed)\n ... | [
"0.67136776",
"0.6575803",
"0.5979425",
"0.5853244",
"0.5843556",
"0.58385",
"0.5817554",
"0.5813687",
"0.5786492",
"0.5741242",
"0.57165074",
"0.5714437",
"0.5712907",
"0.5687153",
"0.5668193",
"0.5646013",
"0.5619637",
"0.56141734",
"0.5610867",
"0.5599167",
"0.5577074",
... | 0.7661961 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.