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 |
|---|---|---|---|---|---|---|
Combine graphs for each host, each VM, and each type of graph. The function gets generated graphs from ds object, and combine them for each host, each VM, and each type of graph. | def combine_graphs(cls, ds, gr):
topdir, file_prefix, outfiles = ds.get_allinone_outfiles()
# For each host, combine all its graphs
_, _, host_outfiles = ds.get_host_outfiles()
for node in ds.get_hosts():
logging.info("Combining graphs for %s" % node)
graphs = [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def graph_create(host, host_path):\n graphs = list()\n for name in dash_profile['graphs']:\n log.info(\" Graph: %s\" % name)\n graph = list()\n # Skip undefined graphs\n if name not in graphdef.keys():\n log.error(\"%s not found in graphdef.yml\" % name)\n c... | [
"0.6458627",
"0.6350494",
"0.6022526",
"0.5996724",
"0.5935758",
"0.58955854",
"0.5857132",
"0.57133496",
"0.56948525",
"0.5680493",
"0.5671144",
"0.5665709",
"0.56493074",
"0.56467503",
"0.5636302",
"0.5604065",
"0.5592455",
"0.5575804",
"0.5561434",
"0.5543002",
"0.5527179"... | 0.8009694 | 0 |
Set transparency to a color The function returns a new color code in RRGGBBAA format. | def alpha(cls, rgb_color, transparency):
if transparency > 1:
transparency = 1
elif transparency < 0:
transparency = 0
return rgb_color + str(hex(int(254 * transparency)))[2:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_transparent_color(color: Color, transparency: float):\r\n return color[0], color[1], color[2], transparency",
"def alpha(c, alpha):\n c = mpl.colors.to_rgb(c) + (alpha,)\n return mpl.colors.to_hex(c, keep_alpha=True)",
"def _set_transparency(self, transparency, elm):\n a = str(100 - tr... | [
"0.78209764",
"0.73038715",
"0.7302642",
"0.7206615",
"0.6976027",
"0.68748236",
"0.6650054",
"0.64086324",
"0.64055395",
"0.63803023",
"0.6362796",
"0.6257481",
"0.62436134",
"0.62134147",
"0.621271",
"0.6188674",
"0.6172513",
"0.6168444",
"0.6161709",
"0.61255264",
"0.61204... | 0.82165104 | 0 |
Load config file and instantiate UnitGroup, Metric and Graph objects. | def initialize(config_file):
config = Config(config_file)
# Instantiate UnitGroup objects, based on definition in config file.
ugregistry = {}
for ugname, ugcfg in config["unit_groups"].items():
ugobj = UnitGroup(ugname)
for unit, value in ugcfg.items():
ugobj.add(unit, val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, unit_system: Literal[\"metric\", \"imperial\"], vertical_axis: Literal[\"Y\", \"Z\"] = 'Y'):\n self.settings = Settings(unit_system, vertical_axis)\n self.nodes = Nodes()\n self.members = Members()\n self.plates = Plates()\n self.meshed_plates = MeshedPlates()\... | [
"0.6170909",
"0.615522",
"0.61503947",
"0.6127943",
"0.60802895",
"0.59707385",
"0.5952361",
"0.5900908",
"0.58998567",
"0.5868946",
"0.5859573",
"0.5854684",
"0.5832521",
"0.5830994",
"0.5809213",
"0.5793956",
"0.57823586",
"0.5777671",
"0.5761102",
"0.574937",
"0.5740909",
... | 0.7923505 | 0 |
This function checks if the username being entered exists in the text file. While taken usernames are being entered, the user is prompted for a new one. Only details with unique username are added to the text file. | def check_registration_details(username, password):
contents = read_file()
while ((username + '\n') in contents):
print("Sorry! This username is taken..")
username = get_username()
password = get_password()
add_details(username, password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_find(file):\n username1 = input(\"Enter your username: \")\n username = username1.lower()\n for row in file:\n if row[0] == username:\n print(\"\\n username found \" + username +\"\\n\")\n user_found = [row[0],row[1]]\n pass_check(user_found)\n g... | [
"0.7662307",
"0.6793095",
"0.66563344",
"0.6564982",
"0.6513607",
"0.6472383",
"0.644965",
"0.6377841",
"0.63619727",
"0.63443094",
"0.6267576",
"0.6248461",
"0.6202253",
"0.61871177",
"0.60983133",
"0.60960597",
"0.6069588",
"0.60584617",
"0.60576737",
"0.6053954",
"0.605265... | 0.7357108 | 1 |
Get the WoS ID and MAG ID from a paperinfo json file | def get_wos_id(path_to_json):
data = json.loads(path_to_json.read_text())
return (data.get('wos_id'), data.get('mag_id')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mp_info(mp_id):\r\n # pulling the json object from file\r\n j = get_mp_json_from_file(mp_id)\r\n\r\n votes = {}\r\n\r\n for item in j:\r\n if item.startswith('public_whip_dreammp'):\r\n\r\n key = item.replace('public_whip_dreammp', '')\r\n vote_id = re.findall(r'\\d+', ... | [
"0.5925384",
"0.57665193",
"0.57649213",
"0.5484075",
"0.53541416",
"0.5328685",
"0.5327472",
"0.531801",
"0.52699614",
"0.5245115",
"0.52148813",
"0.5208454",
"0.5204211",
"0.5177082",
"0.5166915",
"0.5150425",
"0.5139891",
"0.513928",
"0.5125608",
"0.51210254",
"0.5119743",... | 0.6920304 | 0 |
get Genre element with list attr | def get_genres(type_: str, value_: str, page: int, step: int):
genre = factory.get_elem_list(Genre, type_, value_, page, step)
return genre | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GetAttributeList(node, attr_list=None):\n attr_list = attr_list or []\n if isinstance(node, jinja2.nodes.Getattr):\n attr_list.insert(0, node.attr)\n _GetAttributeList(node.node, attr_list)\n elif isinstance(node, jinja2.nodes.Name):\n attr_list.insert(0, node.name)\n return attr_list",
"def ge... | [
"0.6062535",
"0.5831022",
"0.57182366",
"0.5705885",
"0.5572966",
"0.54356104",
"0.5361206",
"0.53488874",
"0.5309927",
"0.5309927",
"0.5309927",
"0.52968377",
"0.5273998",
"0.5273998",
"0.5234556",
"0.518929",
"0.5172812",
"0.51493555",
"0.51339674",
"0.5126402",
"0.51024354... | 0.65601164 | 0 |
get Genre element with attrs | def get_genre(id_genre):
genre = factory.get_elem_solo(Genre, id_genre)
return genre | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_attributes(self, element):",
"def get_genres(type_: str, value_: str, page: int, step: int):\n genre = factory.get_elem_list(Genre, type_, value_, page, step)\n return genre",
"def __getitem__(self, name):\n return self.gattrs[name]",
"def find_genres(genre_dom, dom):\n # take t... | [
"0.5788714",
"0.57737064",
"0.5725627",
"0.5615253",
"0.56053334",
"0.5594965",
"0.55769396",
"0.55683476",
"0.5526234",
"0.5526234",
"0.55093855",
"0.54989445",
"0.54989445",
"0.5477207",
"0.54172635",
"0.53392744",
"0.5312361",
"0.5303174",
"0.5301365",
"0.5274901",
"0.5265... | 0.5910385 | 0 |
get count genres by type and value | def count_genres(type_: str, value_=''):
count = factory.get_elem_count(Genre, type_, value_)
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_count_genomic_types(self):\n \n result, bed_result = parse_AS_STRUCTURE_dict(\"test\", clipper.test_dir())\n result = count_genomic_types(result)\n \n self.assertDictEqual(result, {\"CE:\" : 14})",
"def subtype_counts(node_set, G, log=False):\n subtypes = Counter()\... | [
"0.6092542",
"0.6083161",
"0.6023084",
"0.594775",
"0.5827863",
"0.5791389",
"0.5737511",
"0.5697055",
"0.5689171",
"0.55484855",
"0.5522721",
"0.54647654",
"0.5452232",
"0.54305583",
"0.5412545",
"0.54052013",
"0.53957707",
"0.5388194",
"0.5383729",
"0.5371988",
"0.5360215",... | 0.8488953 | 0 |
Extracts and anaylzes the altitude from a raw telemetry string | def process_telemetry_string(telem, nichrome):
telemFields = telem.split(",")
try:
# Check to make sure the string is actually the telemetry data.
# This will have to be changed based on what you name your payload
if re.match("\$\$\w{1,10}", telemFields[0]) != None:
# The 6t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_altitude(self):\n self.degrees = self.altitude_encoder.get_degrees()\n self.tele_altitude = self.Calculations.convert_degrees( self.degrees)\n return self.tele_altitude",
"def altitude(press, altimeter=29.92126):\n AS = altimeter*inHg2PA\n print(AS, press**(L*R/g/M))\n h = -... | [
"0.6720805",
"0.65445393",
"0.65247965",
"0.6507956",
"0.64723134",
"0.62712276",
"0.61412066",
"0.61412066",
"0.60638577",
"0.57889676",
"0.5782594",
"0.5751737",
"0.5751737",
"0.5707257",
"0.56867486",
"0.56180745",
"0.5610211",
"0.5567454",
"0.5563814",
"0.54588395",
"0.54... | 0.6671002 | 1 |
Sleeps forever, periodically forcing nichrome to stay low (deactivated) | def keepNichromeLow(nichrome):
while True:
loginfo("Deactivating nichrome again...")
nichrome.deactivate()
time.sleep(2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lightleep(time_ms: int = None) -> None:",
"def fuzz():\n if FUZZ:\n time.sleep(random.random())",
"def wait_forever(self):\r\n while True:\r\n time.sleep(0.5)",
"def wait(self):\n time.sleep(0.010)",
"def _sleep(self):\n while 1:\n diff = (time.time()-self.las... | [
"0.62966967",
"0.6132644",
"0.60721",
"0.5918225",
"0.59004706",
"0.58737785",
"0.58737785",
"0.58737785",
"0.5843681",
"0.5841695",
"0.58400065",
"0.58346456",
"0.58301884",
"0.5810509",
"0.5802237",
"0.5758035",
"0.57551044",
"0.5752673",
"0.5744132",
"0.5725491",
"0.572158... | 0.7663598 | 0 |
Creates the telemetry file if it isn't there | def create_telemetry_file():
loginfo("Creating telem file if it doesn't exist...")
with open(HAB_TELEM_FILE, "w"):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_telemetry(self, telemetry):\n\n _id = telemetry['id']\n _type = telemetry['type']\n\n # If there is no log open for the current ID check to see if there is an existing (closed) log file, and open it.\n if _id not in self.open_logs:\n _search_string = os.path.join(se... | [
"0.6439721",
"0.607161",
"0.6014355",
"0.6009945",
"0.59758687",
"0.5965215",
"0.58997035",
"0.5889219",
"0.5861597",
"0.5857285",
"0.5794037",
"0.57913977",
"0.57815826",
"0.57186556",
"0.57160866",
"0.5698505",
"0.5695984",
"0.5652613",
"0.56342226",
"0.56266046",
"0.561926... | 0.8411467 | 0 |
Test wrapper function doify() | def test_doify():
def genfun(tymth, tock=0.0, **opts):
tyme = yield(tock)
assert inspect.isgeneratorfunction(genfun)
gf0 = doing.doify(genfun, name='gf0', tock=0.25)
gf1 = doing.doify(genfun, name='gf1', tock=0.125)
assert inspect.isgeneratorfunction(gf0)
assert inspect.isgeneratorfun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_a():\n foo_do(4)\n foo_do(\"hello\")\n bar_do([1,2,3])",
"def test_do_return():\n\n @do\n def f():\n yield do_return(\"hello\")\n\n with warns(DeprecationWarning):\n assert perf(f()) == \"hello\"",
"def test_wraps():\n print('func')",
"def unitary_test():",
"def t... | [
"0.59483993",
"0.5807372",
"0.5771744",
"0.57428163",
"0.5708095",
"0.5708095",
"0.5673134",
"0.5553789",
"0.5506994",
"0.550334",
"0.55026174",
"0.55026174",
"0.548085",
"0.5474856",
"0.5474856",
"0.5474856",
"0.5474856",
"0.5474856",
"0.5422439",
"0.541525",
"0.541525",
"... | 0.66281915 | 0 |
Test DoDoer class with tryDoer and always | def test_dodoer_always():
# create some TryDoers for doers
doer0 = TryDoer(stop=1)
doer1 = TryDoer(stop=2)
doer2 = TryDoer(stop=3)
doers = [doer0, doer1, doer2]
tock = 1.0
dodoer = doing.DoDoer(tock=tock, doers=list(doers))
assert dodoer.tock == tock == 1.0
assert dodoer.doers == do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_deleter_do_work_no_results(config, mocker):\n logger_mock = mocker.MagicMock()\n dwc_mock = mocker.patch(\"lta.deleter.Deleter._do_work_claim\", new_callable=AsyncMock)\n dwc_mock.return_value = False\n p = Deleter(config, logger_mock)\n await p._do_work()\n dwc_mock.assert_called(... | [
"0.6120738",
"0.59847236",
"0.59634715",
"0.58789694",
"0.5862914",
"0.58382034",
"0.5809949",
"0.5742558",
"0.57110935",
"0.56508386",
"0.5597733",
"0.5591101",
"0.55195457",
"0.5505833",
"0.5505833",
"0.5505833",
"0.54548043",
"0.5433832",
"0.54265547",
"0.5421805",
"0.5415... | 0.7301341 | 0 |
Test exDo generator function nonclass based | def test_exDo():
doizeExDo = doing.doizeExDo
assert inspect.isgeneratorfunction(doizeExDo)
assert hasattr(doizeExDo, "tock")
assert hasattr(doizeExDo, "opts")
assert "states" in doizeExDo.opts
assert doizeExDo.opts["states"] == None
doizeExDo.opts["states"] = []
tymist = tyming.Tymist(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testGeneratorType(self):",
"def test_func_generator():\n def test_odd(v):\n assert v % 2\n for i in range(0, 4):\n yield test_odd, i",
"def test_generator_inline(self):\n def test_odd(v):\n assert v % 2\n for i in range(0, 4):\n ... | [
"0.69425654",
"0.67788553",
"0.66770464",
"0.6559386",
"0.6521904",
"0.64930636",
"0.6480948",
"0.6477324",
"0.64332664",
"0.6391887",
"0.6362238",
"0.63430214",
"0.63208383",
"0.6199608",
"0.6186559",
"0.6182152",
"0.6155177",
"0.6155177",
"0.6155177",
"0.6155177",
"0.615517... | 0.6953838 | 0 |
Test trydo testing function example with break to normal exit | def test_trydo_break():
assert inspect.isgeneratorfunction(tryDo)
assert hasattr(tryDo, "tock")
assert hasattr(tryDo, "opts")
tymist = tyming.Tymist(tock=0.125)
assert tymist.tyme == 0.0
states = []
do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25)
assert inspect.isgenerator(d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_run_loop_success(self):\n found = False\n pyint = Interpreter(limit=15)\n try:\n pyint.run(code=BF_CODE_LOOP_TWICE)\n except SystemExit: \n found = True\n self.assertFalse(found)",
"def test_retry_run(self):\n pass",
"def test_main(mock_t... | [
"0.63869816",
"0.63265485",
"0.63147306",
"0.62900674",
"0.6242783",
"0.61911696",
"0.6141206",
"0.6111745",
"0.60973704",
"0.59276676",
"0.58884645",
"0.5870281",
"0.58558637",
"0.5848308",
"0.5836646",
"0.58318436",
"0.5809373",
"0.5804813",
"0.5803023",
"0.5759391",
"0.575... | 0.6423723 | 0 |
Test trydo testing function example with close to force exit | def test_trydo_close():
tymist = tyming.Tymist(tock=0.125)
assert tymist.tyme == 0.0
states = []
do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25)
assert inspect.isgenerator(do)
result = do.send(None)
assert result == 0
assert states == [State(tyme=0.0, context='enter', feed='D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_terminate_run(self):\n pass",
"def test_close():\n while True:\n yield",
"def test_main(mock_timesleep,mock_network,mock_machine_pin):\n with pytest.raises(InterruptedError):\n AppSwitch.main()",
"def test_trydoer_close():\n tymist = tyming.Tymist(tock=0.125)\n doer ... | [
"0.6395225",
"0.619183",
"0.6189198",
"0.6176477",
"0.6169383",
"0.60915303",
"0.5879608",
"0.5844186",
"0.58387417",
"0.58095753",
"0.5774369",
"0.57531786",
"0.5726396",
"0.5708866",
"0.5701388",
"0.56967646",
"0.56804425",
"0.5680095",
"0.5647397",
"0.56312543",
"0.5620959... | 0.66664875 | 0 |
Test trydo testing function example with throw to force exit | def test_trydo_throw():
tymist = tyming.Tymist(tock=0.125)
assert tymist.tyme == 0.0
states = []
do = tryDo(tymth=tymist.tymen(), states=states, tock=0.25)
assert inspect.isgenerator(do)
result = do.send(None)
assert result == 0
assert states == [State(tyme=0.0, context='enter', feed='D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retry_run(self):\n pass",
"def test_trydo_break():\n assert inspect.isgeneratorfunction(tryDo)\n assert hasattr(tryDo, \"tock\")\n assert hasattr(tryDo, \"opts\")\n\n tymist = tyming.Tymist(tock=0.125)\n assert tymist.tyme == 0.0\n states = []\n\n do = tryDo(tymth=tymist.tyme... | [
"0.6433851",
"0.63803047",
"0.6284302",
"0.62418973",
"0.62312156",
"0.6203113",
"0.6190655",
"0.61465496",
"0.6130344",
"0.6108381",
"0.61045945",
"0.6095485",
"0.60884714",
"0.60814196",
"0.6035478",
"0.60191983",
"0.5978732",
"0.5939394",
"0.5919296",
"0.59102464",
"0.5907... | 0.6895369 | 0 |
Test ServerDoer ClientDoer classes | def test_server_client():
tock = 0.03125
ticks = 16
limit = ticks * tock
doist = doing.Doist(tock=tock, real=True, limit=limit)
assert doist.tyme == 0.0 # on next cycle
assert doist.tock == tock == 0.03125
assert doist.real == True
assert doist.limit == limit == 0.5
assert doist.do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_for_client():",
"def test_create_client(self):\n pass",
"def test_get_client(self):\n pass",
"def test_delete_client(self):\n pass",
"def test_echo_server_client():\n tock = 0.03125\n ticks = 16\n limit = ticks * tock\n doist = doing.Doist(tock=tock, real=True, li... | [
"0.7513112",
"0.69929147",
"0.68744075",
"0.67281103",
"0.66821295",
"0.66807735",
"0.6652283",
"0.65622354",
"0.6543381",
"0.6526167",
"0.64628434",
"0.64329016",
"0.64329016",
"0.64329016",
"0.64329016",
"0.63859886",
"0.63597393",
"0.6336899",
"0.629655",
"0.6293273",
"0.6... | 0.7207533 | 1 |
Test EchoServerDoer ClientDoer classes | def test_echo_server_client():
tock = 0.03125
ticks = 16
limit = ticks * tock
doist = doing.Doist(tock=tock, real=True, limit=limit)
assert doist.tyme == 0.0 # on next cycle
assert doist.tock == tock == 0.03125
assert doist.real == True
assert doist.limit == limit == 0.5
assert doi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_for_client():",
"def test_server_client():\n tock = 0.03125\n ticks = 16\n limit = ticks * tock\n doist = doing.Doist(tock=tock, real=True, limit=limit)\n assert doist.tyme == 0.0 # on next cycle\n assert doist.tock == tock == 0.03125\n assert doist.real == True\n assert doist.... | [
"0.72575915",
"0.7249093",
"0.66610587",
"0.6635919",
"0.6635122",
"0.65471476",
"0.65235204",
"0.65007335",
"0.64428306",
"0.6440027",
"0.6419176",
"0.64183944",
"0.64183944",
"0.63425195",
"0.6333824",
"0.6316979",
"0.6309964",
"0.63007313",
"0.6276703",
"0.6199192",
"0.619... | 0.77605975 | 0 |
Test EchoConsoleDoer class Must run in WindIDE with Debug I/O configured as external console | def test_echo_console():
port = os.ctermid() # default to console
try: # check to see if running in external console
fd = os.open(port, os.O_NONBLOCK | os.O_RDWR | os.O_NOCTTY)
except OSError as ex:
# maybe complain here
return # not in external console
else:
os.close... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def console():\n start_console()",
"def get_console(self):\n\t\treturn None",
"def start_console(self):\n return",
"def test_console_driver(duthost):\n out = duthost.shell('ls /dev/ttyUSB*', module_ignore_errors=True)['stdout']\n ttys = set(out.split())\n pytest_assert(len(ttys) > 0, \"No ... | [
"0.6557113",
"0.6358973",
"0.6357349",
"0.6250034",
"0.62377596",
"0.62299806",
"0.6129152",
"0.612263",
"0.60406756",
"0.5996627",
"0.59710854",
"0.59572494",
"0.59531933",
"0.5940231",
"0.5929235",
"0.589979",
"0.5892514",
"0.5865835",
"0.58611655",
"0.5860659",
"0.585572",... | 0.74439275 | 0 |
Defines the null and alternative hypothesis. | def define_hypothesis(df, statistic, alternative, paired, alpha):
paired_text = f"the {statistic} difference" if paired else f"difference in {statistic}"
hypothesis = {
'two-sided_H0': f"{paired_text} equal to zero",
'two-sided_H1': f"{paired_text} not equal to zero",
'grea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_alternative(df, hypothesis, alternative='two-sided', alpha=0.05):\n df['H0'] = hypothesis[alternative + '_H0']\n df['H1'] = hypothesis[alternative + '_H1']\n formatted_alpha = round(alpha*100, 2)\n conclusion = 'There is no evidence' if df['p-val'][0] > alpha else 'There is evi... | [
"0.6455733",
"0.61753273",
"0.61616707",
"0.58870167",
"0.58759326",
"0.58596665",
"0.5715439",
"0.5703288",
"0.5663849",
"0.56625116",
"0.56293815",
"0.5621157",
"0.56145686",
"0.5562165",
"0.5533882",
"0.5483456",
"0.54680246",
"0.5450762",
"0.539382",
"0.5374309",
"0.53743... | 0.6396941 | 1 |
Tests the hypothesis using the pvalue and adds the conclusion to the results DataFrame. | def test_alternative(df, hypothesis, alternative='two-sided', alpha=0.05):
df['H0'] = hypothesis[alternative + '_H0']
df['H1'] = hypothesis[alternative + '_H1']
formatted_alpha = round(alpha*100, 2)
conclusion = 'There is no evidence' if df['p-val'][0] > alpha else 'There is evidence'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_hypothesis(df, statistic, alternative, paired, alpha):\n paired_text = f\"the {statistic} difference\" if paired else f\"difference in {statistic}\"\n hypothesis = {\n 'two-sided_H0': f\"{paired_text} equal to zero\",\n 'two-sided_H1': f\"{paired_text} not equal to zero\"... | [
"0.6139014",
"0.59191096",
"0.56186587",
"0.55141944",
"0.55031806",
"0.53873",
"0.53590375",
"0.5266749",
"0.5259233",
"0.5245075",
"0.5224029",
"0.52130735",
"0.520389",
"0.51930904",
"0.51885474",
"0.51866484",
"0.5186087",
"0.51756436",
"0.5168725",
"0.51264113",
"0.51248... | 0.640209 | 0 |
Called from the definition file with the definition of a condition. Receives the name of the condition and it's expression. | def AddCondition(self, name, expression):
self.conditions[name] = expression | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condition(self) -> global___Expression:",
"def condition(self) -> global___Expression:",
"def eval_definition(exp, env):\n define_variable(definition_variable(exp), m_eval(definition_value(exp), env), env)\n return quote(\"ok\")",
"def condition(self, condition):\n\n self._condition = condit... | [
"0.60299903",
"0.60299903",
"0.58058965",
"0.57567054",
"0.5676619",
"0.5661788",
"0.5585156",
"0.55506593",
"0.5536422",
"0.54914516",
"0.54885614",
"0.5461103",
"0.54198915",
"0.54021317",
"0.53634095",
"0.5359292",
"0.53558147",
"0.5352741",
"0.5310563",
"0.53045696",
"0.5... | 0.73426414 | 0 |
Load the state machine definition file. In the definition file, which is based on the python syntax, the following variables and functions are defined. | def Load(self, filename):
self.sm['state'] = self.AddState
self.sm['condition'] = self.AddCondition
exec(open(filename).read(), self.sm)
self.name = self.sm['name']
if not self.name.isalnum():
raise Exception("State machine name must consist of only alphanumeric"
"charac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_state_machine_definitions(\n def_file: str) -> Tuple[str, YamlInputFile, MachineDefinition]:\n # Determine the data directory ad build the config file's absolute path\n model_definition_path = get_data_dir()\n model_definition_filename = os.path.sep.join(\n [model_definition_path, ... | [
"0.65411615",
"0.6423537",
"0.60361713",
"0.59719336",
"0.59658307",
"0.58369714",
"0.5749073",
"0.570999",
"0.5671639",
"0.5663093",
"0.56431085",
"0.56079596",
"0.558816",
"0.5572879",
"0.5572879",
"0.55678475",
"0.55635643",
"0.55422217",
"0.5507806",
"0.5505211",
"0.55027... | 0.76456934 | 0 |
Used to get next row of either list of dicts or cursor | def get_next_row(table, names):
if isinstance(table, list):
if not table:
return None, True
else:
return table.pop(0), False
else:
row = table.fetchone()
if row is None:
return None, True
else:
return dict(zip(names, row)),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __next__(self) :\n\n data = self.cur.fetchone()\n if not data :\n raise StopIteration\n return RowReference(self.desc, data[1:])",
"def next(self, num_rows=10):\n\n start = self._cursor\n stop = start + num_rows\n self._cursor += num_rows\n return s... | [
"0.6931901",
"0.64631486",
"0.64456135",
"0.63371646",
"0.6249426",
"0.6236442",
"0.6208837",
"0.6197598",
"0.618017",
"0.6168919",
"0.61328393",
"0.6082178",
"0.60636836",
"0.6054832",
"0.6017265",
"0.59916645",
"0.59916645",
"0.598793",
"0.5943697",
"0.59400916",
"0.5934102... | 0.67075896 | 1 |
Used to find all rows in one table but not in another, not treating rows as distinct. | def unsorted_not_distinct(table1, table2, subset=False):
only_in_table1 = []
if subset:
# When subset, a row in table1 is not subset,
# if its contains more instances of a row than table2
for row in table1:
count1 = table1.count(row)
count2 = table2.count(row)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDifference(self, table2):\n results = set([])\n for rec in self.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n results.add(rec_tuple)\n for rec in table2.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n if rec_tuple... | [
"0.68144566",
"0.671206",
"0.65324634",
"0.649911",
"0.6377828",
"0.6274883",
"0.6272812",
"0.6096138",
"0.60055655",
"0.5998634",
"0.59853375",
"0.5975118",
"0.59444433",
"0.59095633",
"0.5894284",
"0.58582914",
"0.58507025",
"0.5822497",
"0.5753021",
"0.5674006",
"0.5666055... | 0.67386425 | 1 |
Used to find all rows in one table but not in another. | def tab_unsorted(table1, table2, where_conditions, dw_rep):
sql = \
" SELECT * " + \
" FROM " + table1 + \
" AS table1 " + \
" WHERE NOT EXISTS" \
" ( " + \
" SELECT NULL " + \
" FROM " + table2 + \
" AS table2 " + \
" WHERE " + " AND ".join(w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDifference(self, table2):\n results = set([])\n for rec in self.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n results.add(rec_tuple)\n for rec in table2.records:\n rec_tuple = tuple([v for (k, v) in rec.items()])\n if rec_tuple... | [
"0.6672395",
"0.6617561",
"0.65095437",
"0.6373357",
"0.6184577",
"0.6165197",
"0.59691566",
"0.5948662",
"0.5894413",
"0.58872354",
"0.5830431",
"0.58233774",
"0.5791073",
"0.5774153",
"0.5673653",
"0.56427497",
"0.5573534",
"0.5549403",
"0.55481064",
"0.55452496",
"0.552260... | 0.683357 | 0 |
Does a subset comparison of two sorted tables | def subset_sorted_compare(actual, expected):
# Get names of attributes
names = [t[0] for t in actual.description]
e_row, expected_empty = get_next_row(expected, names)
if not expected_empty:
result = None not in e_row.values()
else:
result = False
actual_empty = False
# Ru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_tables(t1, t2):\n assert type(t1)==type(t2)\n assert isinstance(t1,(np.ndarray,DataTable,pd.DataFrame))\n assert np.shape(t1)==np.shape(t2)\n if isinstance(t1,DataTable):\n assert all([np.all(t1.c[i]==t2.c[i]) for i in range(np.shape(t1)[1])])\n else:\n assert np.all(t1==t2... | [
"0.6723325",
"0.6639622",
"0.6540761",
"0.64077485",
"0.63627774",
"0.6208932",
"0.6208834",
"0.6191564",
"0.6189009",
"0.61446047",
"0.6110602",
"0.60610974",
"0.5989919",
"0.59587985",
"0.59558547",
"0.58967036",
"0.5894383",
"0.58753526",
"0.5857242",
"0.5827912",
"0.58035... | 0.685202 | 0 |
Generate path, including query and fragment (aka anchor), for ``request`` using positional arguments ``args`` and keyword arguments ``kwargs``. Refer to corresponding router plugin for specific signature for positional and keyword arguments. Returns urlpath string. This does not include SCRIPT_NAME, netlocation and sch... | def urlpath( request, *args, **kwargs ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self, **kwargs):\n\n return build(\n self._request.path,\n self._request.GET,\n self._meta.prefix,\n **kwargs )",
"def pathfor( request, *args, **kwargs ):",
"def url(self, request_path=\"\"):\n return f\"{self.scheme}://{self.host}/{request... | [
"0.64753556",
"0.628129",
"0.62777704",
"0.62373245",
"0.6221489",
"0.62195736",
"0.6203761",
"0.61327916",
"0.6034436",
"0.6002653",
"0.5988426",
"0.5972479",
"0.5961196",
"0.59514344",
"0.59143126",
"0.5896229",
"0.5896229",
"0.58924574",
"0.5859545",
"0.5827251",
"0.580974... | 0.68177366 | 0 |
When the router finds that a resource (typically indicated by the requestURL) has multiple representations, where each representation is called a variant, it has to pick the best representation negotiated by the client. Negotiation is handled through attributes like mediatype, language, charset and contentencoding. ``r... | def negotiate( request, variants ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_negotiation(self, request, environ, mtype_list):\n alist = request.sys_query_options.get(core.SystemQueryOption.format,\n None)\n if alist is None:\n if \"HTTP_ACCEPT\" in environ:\n try:\n alist = m... | [
"0.6388638",
"0.58420646",
"0.572146",
"0.56802297",
"0.56731945",
"0.56254303",
"0.56223434",
"0.56139547",
"0.55455554",
"0.551041",
"0.5460923",
"0.54406977",
"0.5377689",
"0.5287527",
"0.52641153",
"0.5233765",
"0.5164498",
"0.51348597",
"0.5087331",
"0.50804424",
"0.5079... | 0.6252837 | 1 |
Use HTTP `headers` dictionary, to parse cookie name/value pairs, along with its metainformation, into Cookie Morsels. Get the cookie string from ``headers`` like, | def parse_cookies( headers ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __extractCookies(self, cookieString):\n parts = cookieString.split(\"; \")\n \n data = {}\n \n for cookie in parts:\n keyValues = cookie.split(\"=\")\n data[keyValues[0]] = keyValues[1]\n \n return data\n #print resultHeadersKv\n... | [
"0.66611415",
"0.64269054",
"0.6329864",
"0.6290737",
"0.6235485",
"0.6235485",
"0.6199424",
"0.61779773",
"0.61479324",
"0.60945964",
"0.60757387",
"0.59653485",
"0.59545845",
"0.5939655",
"0.5897959",
"0.58464956",
"0.5736396",
"0.56966174",
"0.5693424",
"0.56601405",
"0.56... | 0.80582446 | 0 |
Update ``cookies`` dictionary with cookie ``name`` and its ``morsel``. Optional Keyword arguments, typically, contain ``domain``, ``expires_days``, ``expires``, ``path``, which are set on the Cookie.Morsel directly. ``cookies``, Dictionary like object mapping cookie name and its morsel. It is updated inplace and return... | def set_cookie( cookies, name, morsel, **kwargs ) : | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cookie(\n self,\n name: str,\n value: str,\n *,\n expires: Optional[str] = None,\n domain: Optional[str] = None,\n max_age: Optional[Union[int, str]] = None,\n path: str = \"/\",\n secure: Optional[bool] = None,\n httponly: Optional[bool... | [
"0.6560919",
"0.6371054",
"0.61873186",
"0.59360474",
"0.5889485",
"0.58349055",
"0.5782738",
"0.57371664",
"0.5694596",
"0.56428206",
"0.5622598",
"0.55732596",
"0.557322",
"0.5484455",
"0.54833525",
"0.54718137",
"0.54183614",
"0.53668654",
"0.5339797",
"0.5316583",
"0.5278... | 0.7567295 | 0 |
Returns True if this request supports HTTP/1.1 semantics | def supports_http_1_1(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_server_should_be_http_1_1(httpbin):\n resp = get_raw_http_response(httpbin.host, httpbin.port, \"/get\")\n assert resp.startswith(b\"HTTP/1.1\")",
"def is_supported(self) -> bool:\n\n # TODO logging ?\n # TODO ICMP error if ttl is zero\n return self._version == 4 and self._ihl... | [
"0.63006914",
"0.6202393",
"0.61148703",
"0.61043656",
"0.5947065",
"0.59074837",
"0.5852643",
"0.5731418",
"0.56117535",
"0.5606208",
"0.5559672",
"0.5547659",
"0.55382115",
"0.55035686",
"0.5499543",
"0.5495566",
"0.5454329",
"0.54527396",
"0.54498947",
"0.5448252",
"0.5395... | 0.80598897 | 0 |
Returns a signed cookie if it validates, or None. Call to this | def get_secure_cookie( name, value=None ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cookie(self, provided_cookie, decrypt=True):\n\n if 'HTTP_COOKIE' in self.environ:\n grab_cookie = cookies.SimpleCookie(self.environ['HTTP_COOKIE'])\n \n if provided_cookie in grab_cookie:\n if decrypt:\n try:\n ... | [
"0.67511994",
"0.64220226",
"0.61643136",
"0.6157462",
"0.6149605",
"0.5972794",
"0.5919926",
"0.5899736",
"0.5893973",
"0.5885634",
"0.5859752",
"0.5823456",
"0.5812559",
"0.5812559",
"0.5784276",
"0.57393366",
"0.5726692",
"0.5698617",
"0.5693313",
"0.5668825",
"0.56523204"... | 0.6572365 | 1 |
Return True if this request is considered finished, which is, when | def has_finished(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished(self):\n return self._state == FINISHED_STATE",
"def isFinish(self):\n return self.finish",
"def isFinished(self):\n return self.isTimedOut()",
"def done(self):\n return self._status != Future.STATUS_STARTED",
"def isFinished():",
"def isFinished():",
"def isFin... | [
"0.7893599",
"0.785629",
"0.7801624",
"0.7791034",
"0.77553874",
"0.77553874",
"0.77553874",
"0.7745339",
"0.7745339",
"0.7745339",
"0.7722582",
"0.7720691",
"0.7706907",
"0.76873726",
"0.7687296",
"0.76775944",
"0.7634663",
"0.76284164",
"0.7626273",
"0.75619394",
"0.7538805... | 0.7938837 | 0 |
Returns True if this request is received using `chunked` TransferEncoding. | def ischunked() : | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_chunked(self):\r\n cl = 0\r\n data = StringIO.StringIO()\r\n while True:\r\n line = self.rfile.readline().strip().split(\";\", 1)\r\n chunk_size = int(line.pop(0), 16)\r\n if chunk_size <= 0:\r\n break\r\n cl += chunk_size\r... | [
"0.59374046",
"0.5720478",
"0.5649413",
"0.5643323",
"0.553375",
"0.55225235",
"0.5521607",
"0.54682434",
"0.5453274",
"0.53548074",
"0.5349224",
"0.52951217",
"0.5291799",
"0.52821094",
"0.52617615",
"0.5254956",
"0.52493757",
"0.5239688",
"0.5227221",
"0.5220763",
"0.521872... | 0.7465098 | 0 |
Generate url for a different webapplication identified by ``instkey``. Typically uses webapp.appurl(). ``instkey``, A tuple of ``(appsec, netpath, configini)`` indexes into platform's `webapps` attribute | def appurl( instkey, name, **matchdict ) : | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])",
"def build_url(app, request):\n return '%s%s' % (app.url_root, request.path[1:])",
"def api_url(self, url_key):\n dic = self.api_endpoints()\n return dic.get(url_key)",
"def url(self):\n if not self._... | [
"0.58576363",
"0.58576363",
"0.5623256",
"0.56221247",
"0.55988806",
"0.5585243",
"0.5538256",
"0.5424072",
"0.53234696",
"0.53213304",
"0.5307345",
"0.5305116",
"0.52884024",
"0.52879715",
"0.5249623",
"0.5244203",
"0.5239846",
"0.5239406",
"0.52258646",
"0.5224644",
"0.5202... | 0.72840726 | 0 |
Set a response status code. By default it will be 200. | def set_status( code ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setResponseCode(code, message=None):",
"def setResponseCode(self, code, message=None):\n assert not self.written, \"Response code cannot be set after data has been written: %s.\" % \"@@@@\".join(self.written)\n self.responseCode = code\n self.responseMessage = message",
"def status_cod... | [
"0.80714124",
"0.7299864",
"0.7288931",
"0.7265546",
"0.7265546",
"0.72009724",
"0.7186744",
"0.7174475",
"0.7165363",
"0.7111467",
"0.70771134",
"0.70771134",
"0.7026749",
"0.69407403",
"0.6925514",
"0.6722728",
"0.6721266",
"0.6686304",
"0.668352",
"0.6621333",
"0.6604315",... | 0.78074044 | 1 |
Set cookie `name`/`value` with optional ``kwargs``. Keyword arguments typically contains, ``domain``, ``expires_days``, ``expires``, ``path``. Additional keyword arguments are set on the Cookie.Morsel directly. By calling this method cookies attribute will be updated inplace. See | def set_cookie( name, value, **kwargs ) : | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cookie( cookies, name, morsel, **kwargs ) :",
"def set_cookie(\n self,\n name: str,\n value: str,\n *,\n expires: Optional[str] = None,\n domain: Optional[str] = None,\n max_age: Optional[Union[int, str]] = None,\n path: str = \"/\",\n secure... | [
"0.8420435",
"0.79221094",
"0.7444182",
"0.74370587",
"0.7345756",
"0.7201238",
"0.71946406",
"0.7171358",
"0.71276164",
"0.66001695",
"0.6599659",
"0.6423538",
"0.631609",
"0.6207204",
"0.61627495",
"0.6073698",
"0.5977196",
"0.5935828",
"0.5813138",
"0.58102167",
"0.5718615... | 0.8409126 | 1 |
Similar to set_cookie() method, additionally signs and timestamps a cookie value so it cannot be forged. Uses | def set_secure_cookie( name, value, **kwargs ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cookie( name, value, **kwargs ) :",
"def set(self, name, value, timestamp=None, expires_days=30, **kwargs):\n \n timestamp = timestamp and timestamp or str(int(time.time()))\n value = base64.b64encode(value)\n args = (name, value, timestamp)\n signature = _generate_cook... | [
"0.74688053",
"0.7455388",
"0.72751254",
"0.72063357",
"0.70475024",
"0.6851211",
"0.6815025",
"0.68128604",
"0.66326326",
"0.6592273",
"0.6509545",
"0.6509545",
"0.64895",
"0.6470476",
"0.64571637",
"0.6434016",
"0.64097345",
"0.6322631",
"0.63069767",
"0.6275352",
"0.625296... | 0.7734208 | 0 |
Deletes all the cookies the user sent with this request. | def clear_all_cookies(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_cookies(self):\n self.base_driver.delete_all_cookies()",
"def logout():\n _cookies = ['user', 'pass', 'hash']\n for cookie in _cookies:\n util.web.delete_cookie(cookie)",
"def clear_cookies(response):\n for cookie_name in list(flask.request.cookies.keys()):\n ... | [
"0.8314878",
"0.79060113",
"0.7764054",
"0.75879586",
"0.74467",
"0.73246366",
"0.72249746",
"0.7155583",
"0.7140678",
"0.7131695",
"0.7051185",
"0.69263476",
"0.6845432",
"0.6812562",
"0.6739007",
"0.670739",
"0.66826046",
"0.66742474",
"0.6650126",
"0.6621511",
"0.6612393",... | 0.81525165 | 1 |
Subscribe a ``callback`` function, to be called when this response is finished. | def set_finish_callback( callback ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_response(self, callback):\n\n self.log.info(\"Received callback for subscription %s\", self.service_id)\n self.log.info(callback)\n\n # handle callbacks\n self.handle_callbacks()",
"def subscribe(self, callback: Callable) -> None:\n self.callbacks.add(callback)",
"... | [
"0.7337261",
"0.72173417",
"0.6887395",
"0.6764623",
"0.6744843",
"0.6545311",
"0.65448177",
"0.65093887",
"0.65067255",
"0.64918005",
"0.6415015",
"0.6398242",
"0.6356268",
"0.6323706",
"0.62204206",
"0.6189996",
"0.61888844",
"0.6179687",
"0.61578566",
"0.61118984",
"0.6095... | 0.7379709 | 0 |
Returns True if this response is transferred using `chunked` TransferEncoding. | def ischunked() : | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_chunked(self):\r\n cl = 0\r\n data = StringIO.StringIO()\r\n while True:\r\n line = self.rfile.readline().strip().split(\";\", 1)\r\n chunk_size = int(line.pop(0), 16)\r\n if chunk_size <= 0:\r\n break\r\n cl += chunk_size\r... | [
"0.57229114",
"0.5549699",
"0.5535076",
"0.5498817",
"0.5495948",
"0.54413956",
"0.5428297",
"0.5392888",
"0.53799695",
"0.53299",
"0.53035134",
"0.5299927",
"0.5269785",
"0.525448",
"0.52073103",
"0.5202222",
"0.5174824",
"0.5155284",
"0.5124991",
"0.5083998",
"0.50101703",
... | 0.72753114 | 0 |
Flushes the responseheader (if not written already) to the socket connection. Then flushes the writebuffer to the socket connection. ``finishing``, If True, signifies that data written since the last flush() on this response instance is the last chunk. It will also flush the trailers at the end of the chunked response.... | def flush( finishing=False, callback=None ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, chunk, callback=None, read_until_delimiter=CRLF):\n if not self.stream.closed():\n if callback is None:\n callback = functools.partial(self.stream.read_until,\n utf8(read_until_delimiter),\n ... | [
"0.5697157",
"0.5237605",
"0.52154744",
"0.51464176",
"0.5056116",
"0.5045713",
"0.50180554",
"0.5014987",
"0.49502966",
"0.49502966",
"0.4899851",
"0.4892243",
"0.48771352",
"0.4832465",
"0.48308593",
"0.47830316",
"0.46727931",
"0.4668935",
"0.46423793",
"0.4630665",
"0.462... | 0.6894146 | 0 |
Return a generator, which, for every iteration will call the ``callback`` function with ``request`` and ``c`` arguments, which are preserved till the iteration is over. The call back should return a a tuple representing a chunk, ``(chunk_size, chunk_ext, chunk_data)`` this will formatted into a response chunk and sent ... | def chunk_generator( callback, request, c ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _request_generator(request, data_handler):\n # First, the request header.\n yield data_handler.request_to_bytes(request)\n\n # Then, for the body. The body can be bytes or an iterator, but that's it.\n # The iterator is the more general case, so let's transform the bytes into\n # an iterator via... | [
"0.62096155",
"0.61808133",
"0.6032896",
"0.5845108",
"0.575135",
"0.57170826",
"0.5671511",
"0.5627092",
"0.56268936",
"0.545666",
"0.54119474",
"0.54040426",
"0.5395256",
"0.53291893",
"0.53276765",
"0.5250885",
"0.5200447",
"0.5184646",
"0.51722205",
"0.51582944",
"0.51517... | 0.8492581 | 0 |
Instantiate plugin with `viewname` and `view` attributes. | def __init__( viewname, view ): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_plugin(self, **kwargs):\n return self.plugin_class(**kwargs)",
"def initialize(self, view, request, *args, **kwargs):\n view.request = request\n view.args = args\n view.kwargs = kwargs\n return view",
"def setup_view(view, request=None, *args, **kwargs):\n view.... | [
"0.6548358",
"0.6006528",
"0.5945799",
"0.5894253",
"0.58324546",
"0.5823484",
"0.5800297",
"0.57579005",
"0.57316625",
"0.56788945",
"0.5655144",
"0.5637644",
"0.56267685",
"0.5609166",
"0.56016356",
"0.55474275",
"0.5512851",
"0.549349",
"0.5422086",
"0.5387782",
"0.535329"... | 0.6774538 | 0 |
Endpoint for API requests given book isbn | def api(isbn):
# Ensure valid isbn-10 format provided
if len(isbn) != 10:
response = make_response(
jsonify("Please provide a valid ISBN-10"), 404)
response.headers['X-Error'] = "Please provide a valid ISBN-10"
return response
# Ensure requested book is in our database
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_book(isbn):\n isbn = Markup.escape(isbn)\n # check if book exist in database\n book_db = db.execute(\n \"SELECT * FROM books WHERE isbn LIKE :isbn\", {\"isbn\": isbn}\n ).fetchone()\n if book_db == None:\n return jsonify({\"error\": \"Invalid isbn or not in our database\"}), 40... | [
"0.7609882",
"0.74613976",
"0.74272406",
"0.7041582",
"0.68572766",
"0.67950946",
"0.67200625",
"0.6669115",
"0.6622111",
"0.6500195",
"0.6484592",
"0.64041054",
"0.6352689",
"0.63392377",
"0.62087476",
"0.61840034",
"0.61652505",
"0.6151179",
"0.61272323",
"0.6125678",
"0.61... | 0.77853644 | 0 |
This funtion is used to read the training data with over sampling. I tried the performance of this method and because of the negative result I do not use it in the final model. | def loadtrainData_oversampling():
pre_x = []
pre_y = []
fileIn = open(PATH + 'traindata_Subtask4.txt')
for line in fileIn.readlines():
lineArr = line.strip().split()
pre_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)])
pre_y.append(int(lineArr[-1]))
ros = Random... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadtrainData_undersampling():\n train = []\n fileIn = open(PATH + 'traindata_Subtask4.txt')\n for line in fileIn.readlines():\n lineArr = line.strip().split()\n train.append([float(lineArr[i]) for i in range(len(lineArr))])\n\n pos = []\n neg = []\n for i in train:\n if ... | [
"0.74855584",
"0.6844487",
"0.67235553",
"0.6635843",
"0.65714896",
"0.655013",
"0.65257406",
"0.65041095",
"0.64458853",
"0.6431045",
"0.6288388",
"0.6259542",
"0.6254891",
"0.6248755",
"0.62383735",
"0.62307274",
"0.62214607",
"0.6210643",
"0.6210329",
"0.62057644",
"0.6185... | 0.7424427 | 1 |
This funtion is used to read the training data with under sampling. In my training set, it including 153 positive samples and 3201 negative samples. By using this function, we can get all the positive samples and the same number of negative samples. | def loadtrainData_undersampling():
train = []
fileIn = open(PATH + 'traindata_Subtask4.txt')
for line in fileIn.readlines():
lineArr = line.strip().split()
train.append([float(lineArr[i]) for i in range(len(lineArr))])
pos = []
neg = []
for i in train:
if i[-1] == 1.0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadtrainData_oversampling():\n pre_x = []\n pre_y = []\n fileIn = open(PATH + 'traindata_Subtask4.txt')\n for line in fileIn.readlines():\n lineArr = line.strip().split()\n pre_x.append([float(lineArr[i]) for i in range(len(lineArr) - 1)])\n pre_y.append(int(lineArr[-1]))\n ... | [
"0.7016822",
"0.6664856",
"0.645917",
"0.64384604",
"0.64043915",
"0.63820744",
"0.6264231",
"0.625226",
"0.62346333",
"0.620052",
"0.6194809",
"0.6153491",
"0.61352617",
"0.61151683",
"0.6104559",
"0.6074965",
"0.6066834",
"0.6033847",
"0.60328984",
"0.6000171",
"0.5999229",... | 0.7961876 | 0 |
This function is the logistic regresion model with stochastic gradient descent. The input is the train_x, the label 'train_y' and the smooth method. I tried two different method in the model. The output is the weights that using for prediction. I also print the train loss and training time to analyse the effect of lear... | def trainLogRegres(train_x, train_y, opts):
startTime = time.time() # calculate training time
numSamples, numFeatures = np.shape(train_x)
alpha = opts['alpha']
maxIter = opts['maxIter']
weights = np.ones((numFeatures, 1))
for k in range(maxIter):
if opts['optimizeType'] == 'stocGradDe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient_descent(self, x, y):\n # Initialize weights vector\n self.weights = np.zeros(len(x[0]))\n\n # Storing number of training example in a variable \n n = len(x)\n\n # Initiate variables to keep track of the current and smallest loss recorded\n lowest_loss = sys.fl... | [
"0.70313853",
"0.69511914",
"0.6924913",
"0.6899533",
"0.6819347",
"0.6808069",
"0.6797615",
"0.6790879",
"0.67861557",
"0.6707913",
"0.66786504",
"0.6632093",
"0.65839654",
"0.65689814",
"0.65687764",
"0.6554728",
"0.65536284",
"0.6550399",
"0.6531903",
"0.6528379",
"0.65280... | 0.7041955 | 0 |
This function is used to predict the data by the logistice model. The input is the weights of logistics model, the dev_x and the label 'dev_y'. The output is the prediction result. | def testLogRegres(weights, dev_x, dev_y):
predict_y = []
numSamples, numFeatures = np.shape(dev_x)
for i in range(numSamples):
if sigmoid(dev_x[i, :] * weights) > 0.5:
label = 1
else:
label = 0
predict_y.append(label)
print('Congratulations, testing comple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logistic_predict(weights, data):\n\n # TODO: Finish this function\n\n return y",
"def logistic_predict(self, x: np.array) -> np.array:\r\n if self.LogisticModel is None:\r\n print('Logistic Model not trained, please run logistic_fit first!')\r\n return None\r\n else:... | [
"0.69716686",
"0.67710924",
"0.6762844",
"0.6762844",
"0.6759554",
"0.6738379",
"0.67310774",
"0.67310774",
"0.67310774",
"0.6683879",
"0.66406286",
"0.658558",
"0.6546615",
"0.6540146",
"0.6515744",
"0.6444978",
"0.6444978",
"0.6444978",
"0.64326894",
"0.64309853",
"0.640947... | 0.72072643 | 0 |
Get targets from either the sample or the net's output. | def get_targets(self, sample, net_output):
return sample["target"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_targets(self):\n\t\treturn self.prDoc['inputs']['data'][0]['targets']",
"def output_targets(self, input_targets):\n return input_targets",
"def output_targets(self) -> Set[str]:\n return {\n out.target\n for out in\n self.outputs\n }",
"def output... | [
"0.7546623",
"0.71686465",
"0.6932078",
"0.6811666",
"0.6767465",
"0.67216605",
"0.6592436",
"0.65119016",
"0.65086675",
"0.6496015",
"0.6452853",
"0.64246523",
"0.6375694",
"0.63572305",
"0.632819",
"0.62846535",
"0.6282436",
"0.6256334",
"0.622767",
"0.62171936",
"0.6214964... | 0.883374 | 0 |
Get normalized probabilities (or log probs) from a net's output. | def get_normalized_probs(
self,
net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]],
log_probs: bool,
sample: Optional[Dict[str, Tensor]] = None,
):
return self.get_normalized_probs_scriptable(net_output, log_probs, sample) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalized_probs(self, net_output, log_probs, sample=None):\n encoder_out = net_output[\"encoder_out\"]\n if torch.is_tensor(encoder_out):\n logits = encoder_out.float()\n if log_probs:\n return F.log_softmax(logits, dim=-1)\n else:\n ... | [
"0.7654916",
"0.762612",
"0.7447698",
"0.7434408",
"0.7308484",
"0.72212243",
"0.65518427",
"0.61370546",
"0.61370546",
"0.6102418",
"0.6070036",
"0.60151446",
"0.59467596",
"0.5924957",
"0.58652586",
"0.58567977",
"0.57644725",
"0.5761727",
"0.5735097",
"0.57293767",
"0.5727... | 0.78670233 | 1 |
Run the forward pass for an encoderdecoder model. First feed a batch of source tokens through the encoder. Then, feed the encoder output and previous decoder outputs (i.e., teacher forcing) to | def forward(self, src_tokens, src_lengths, prev_output_tokens, **kwargs):
encoder_out = self.encoder(src_tokens, src_lengths=src_lengths, **kwargs)
decoder_out = self.decoder(
prev_output_tokens, encoder_out=encoder_out, **kwargs
)
return decoder_out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, inputs_encoder, inputs_decoder):\n states_encoder = self.encoder(inputs_encoder)\n outputs_decoder, states_decoder = self.decoder(inputs_decoder, states_encoder)\n return outputs_decoder, states_decoder",
"def forward(self, input_token, target_token, timestep, *inputs):\n ... | [
"0.701429",
"0.69124043",
"0.6851775",
"0.67677385",
"0.6747971",
"0.66699445",
"0.6630951",
"0.66303766",
"0.66230434",
"0.6597526",
"0.6532557",
"0.64746654",
"0.6471793",
"0.64453846",
"0.6425172",
"0.6398952",
"0.63581455",
"0.63262665",
"0.6285209",
"0.62551093",
"0.6229... | 0.72772044 | 0 |
Helper function to build shared embeddings for a set of languages after checking that all dicts corresponding to those languages are equivalent. | def build_shared_embeddings(
dicts: Dict[str, Dictionary],
langs: List[str],
embed_dim: int,
build_embedding: callable,
pretrained_embed_path: Optional[str] = None,
):
shared_dict = dicts[langs[0]]
if any(dicts[lang] != shared_dict for lang in langs):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def common_languages(programmers: dict):\n lang_sets = [set(languages) for languages in programmers.values()]\n return set.intersection(*lang_sets)",
"def build_embeddings(opt, word_dict, for_encoder='src'):\n if for_encoder=='src':\n embedding_dim = opt.src_word_vec_size #512\n elif for_encoder=='t... | [
"0.61849177",
"0.60261357",
"0.58251303",
"0.58241105",
"0.5754996",
"0.5612742",
"0.55997604",
"0.55655533",
"0.5560588",
"0.55467874",
"0.5529211",
"0.55203277",
"0.53863925",
"0.53837025",
"0.53825444",
"0.535034",
"0.5340224",
"0.530569",
"0.5258829",
"0.5242967",
"0.5226... | 0.7487093 | 0 |
Run the forward pass for a decoderonly model. Feeds a batch of tokens through the decoder to predict the next tokens. | def forward(self, src_tokens, **kwargs):
return self.decoder(src_tokens, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, input_token, target_token, timestep, *inputs):\n log_probs_per_model = []\n state_outputs = []\n next_state_input = len(self.models)\n vocab_reduction_module = self.models[0].decoder.vocab_reduction_module\n if vocab_reduction_module is not None:\n po... | [
"0.6603129",
"0.6492484",
"0.63717306",
"0.63408744",
"0.6279637",
"0.6271893",
"0.6234917",
"0.6129099",
"0.611657",
"0.6088647",
"0.6083846",
"0.6076934",
"0.60715055",
"0.6046105",
"0.60413575",
"0.6034035",
"0.6028133",
"0.6008129",
"0.6004112",
"0.6004112",
"0.59878695",... | 0.66097987 | 0 |
append questions to meetups | def questions_meetups(cls):
for meetup in MEETUPS_LIST:
for question in QUESTIONS_LIST:
if meetup["meetup_id"] == question["meetup"]:
meetups = MEETUPS_LIST.append(question)
return meetups | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_questions(self, questions):\n for question in questions:\n self.questions.append(question)",
"def addQuestion(self):\n self.questions.append(Question(self))",
"def test_ask_question_meetup(self):\n res = self.client().post(\n '/api/v2/auth/login',\n ... | [
"0.6729881",
"0.58960307",
"0.58123344",
"0.5767761",
"0.56640637",
"0.56520694",
"0.5624104",
"0.56080323",
"0.558679",
"0.5563679",
"0.54919684",
"0.54856396",
"0.5463428",
"0.54592943",
"0.54343736",
"0.5408007",
"0.5386879",
"0.5353735",
"0.5335016",
"0.53313965",
"0.5325... | 0.6592625 | 1 |
Sort given items by splitting list into two approximately equal halves, sorting each with an iterative sorting algorithm, and merging results into a list in sorted order. | def split_sort_merge(items):
# TODO: Split items list into approximately equal halves
pivot = len(items) // 2
# TODO: Sort each half using any other sorting algorithm
# sort first half in-place (insertion sort)
left = insertion_sort(items[:pivot])
right = insertion_sort(items[pivot:])
# TOD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_sort(items):\r\n # TODO: Check if list is so small it's already sorted (base case)\r\n # TODO: Split items list into approximately equal halves\r\n # TODO: Sort each half by recursively calling merge sort\r\n # TODO: Merge sorted halves into one list in sorted order\r",
"def split_sort_merg... | [
"0.8726051",
"0.81528765",
"0.80984515",
"0.8059322",
"0.7023216",
"0.70154995",
"0.6990501",
"0.6860262",
"0.68393856",
"0.6779179",
"0.67722803",
"0.676385",
"0.67394567",
"0.6680889",
"0.66504735",
"0.66409963",
"0.66250134",
"0.6570565",
"0.65390325",
"0.65087175",
"0.649... | 0.8257935 | 1 |
Test case for retrieve_iso20022_account_statement | def test_retrieve_iso20022_account_statement(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_iso20022_account_statement_ids(self):\n pass",
"def test_client_bank_account_retrieve(self):\n pass",
"def test_lookup_account(self):\n pass",
"def test_duo_account_get(self):\n pass",
"def test_get_account(self):\n account = Account(self.client, \"suppo... | [
"0.7644585",
"0.7231425",
"0.6812529",
"0.67593855",
"0.6592105",
"0.6502707",
"0.6176865",
"0.6147158",
"0.61404335",
"0.60323703",
"0.59900594",
"0.5960902",
"0.5945615",
"0.5922146",
"0.59219354",
"0.5869125",
"0.58601254",
"0.5782012",
"0.5768315",
"0.5767688",
"0.5763573... | 0.9354298 | 0 |
Test case for retrieve_iso20022_account_statement_ids | def test_retrieve_iso20022_account_statement_ids(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_iso20022_account_statement(self):\n pass",
"def get_account_ids(response):\n return [account['Id'] for account in response[0]]",
"def _get_account_ids_for_payment(cls, batch_type) -> List[int]:\n # CREDIT : Distribution code against fee schedule\n # DEBIT : Distributio... | [
"0.6812683",
"0.62837356",
"0.58088756",
"0.54739934",
"0.54076695",
"0.54023266",
"0.5306752",
"0.5292501",
"0.5267886",
"0.519998",
"0.5199648",
"0.51961565",
"0.5137261",
"0.5128088",
"0.5126967",
"0.5121954",
"0.51077014",
"0.5105441",
"0.5099286",
"0.50584334",
"0.502265... | 0.9331227 | 0 |
Test case for retrieve_iso20022_payment_instruction | def test_retrieve_iso20022_payment_instruction(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_iso20022_payment_instruction_status_report(self):\n pass",
"def test_submit_iso20022_payment_instruction(self):\n pass",
"def test_get_pay_in_details(self):\n pass",
"def test_retrieve_iso20022_account_statement(self):\n pass",
"def test_get_nveto_pmt_item(self... | [
"0.7929505",
"0.77909356",
"0.675292",
"0.6300968",
"0.5816299",
"0.5814966",
"0.5679115",
"0.5636617",
"0.5615561",
"0.5567673",
"0.5559224",
"0.54956764",
"0.5464819",
"0.5416394",
"0.53895956",
"0.53485143",
"0.5336239",
"0.53228277",
"0.5236428",
"0.5206498",
"0.5196977",... | 0.9272758 | 0 |
Test case for retrieve_iso20022_payment_instruction_status_report | def test_retrieve_iso20022_payment_instruction_status_report(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_iso20022_payment_instruction(self):\n pass",
"def test_submit_iso20022_payment_instruction(self):\n pass",
"def test_get_pay_in_details(self):\n pass",
"def payment_info_and_status(report):\n\n order_data = open(report)\n for line in order_data:\n order = l... | [
"0.7529059",
"0.62428045",
"0.6210108",
"0.61702275",
"0.59611535",
"0.59611535",
"0.5566417",
"0.5521743",
"0.54387635",
"0.5430647",
"0.5417798",
"0.5384927",
"0.53397685",
"0.53175116",
"0.5312262",
"0.52929735",
"0.5252589",
"0.51756126",
"0.5153839",
"0.51465034",
"0.514... | 0.94082433 | 0 |
Test case for submit_iso20022_payment_instruction | def test_submit_iso20022_payment_instruction(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_iso20022_payment_instruction(self):\n pass",
"def test_retrieve_iso20022_payment_instruction_status_report(self):\n pass",
"def awaiting_payment(self):",
"def test_authorize_pending_payment(self):\n pass",
"def test_cancel_pending_payment(self):\n pass",
"def... | [
"0.80150306",
"0.69385153",
"0.6408621",
"0.6376836",
"0.6285447",
"0.62363833",
"0.62204283",
"0.6191187",
"0.6069737",
"0.6022646",
"0.599725",
"0.5964021",
"0.59160477",
"0.5867808",
"0.5816957",
"0.5812033",
"0.57907003",
"0.5760644",
"0.574709",
"0.57147986",
"0.56779367... | 0.93557435 | 0 |
Load the federalist papers as a tokenized list of strings, one for each eassay | def load_federalist_corpus(filename):
with open(filename, "rt") as f:
data = f.read()
papers = data.split("FEDERALIST")
# all start with "To the people of the State of New York:" (sometimes . instead of :)
# all end with PUBLIUS (or no end at all)
locations = [(i, [-1] + [m.end() + 1 for m ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_primers(tsv_filename):\n answer = []\n with open(tsv_filename) as handle:\n for line in handle:\n if line.startswith(\"#\"):\n continue\n parts = line.rstrip(\"\\n\").split(\"\\t\")\n if len(parts) == 2:\n left, right = parts\n ... | [
"0.58227915",
"0.5724984",
"0.56780964",
"0.56092507",
"0.5532302",
"0.5484157",
"0.53883326",
"0.5370804",
"0.53507763",
"0.5328658",
"0.5301289",
"0.5288816",
"0.52872497",
"0.5275812",
"0.52693164",
"0.5240785",
"0.5199876",
"0.5166234",
"0.5156385",
"0.51557773",
"0.51299... | 0.6521002 | 0 |
Create TFIDF matrix. This function creates a TFIDF matrix from the docs input. | def tfidf(docs):
vocab = {}
df = {}
regex = re.compile("\s+")
count = 0
for doc in docs:
terms = re.split(regex, doc)
for term in set(terms):
if len(term) > 0:
if term not in vocab:
vocab[term] = count # (index, df)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tfidf(self):\n matrix = numpy.zeros(self.shape)\n # the number of words in a document\n words_per_doc = numpy.asarray(self.sum(axis=1), dtype=float)\n # the number of documents in which a word is attested.\n word_frequencies = numpy.asarray(numpy.sum(self > 0, axis=0), dtype=... | [
"0.6873089",
"0.66823035",
"0.6493619",
"0.6493619",
"0.6493619",
"0.64821815",
"0.64000684",
"0.6270314",
"0.6241418",
"0.6232862",
"0.6105327",
"0.6093112",
"0.6044048",
"0.6034128",
"0.5971325",
"0.5963278",
"0.59623235",
"0.5951346",
"0.5939513",
"0.5932343",
"0.59086144"... | 0.6719997 | 1 |
Return a matrix of cosine similarities. | def cosine_similarity(X):
matrix = X.dot(X.transpose()).todense()
mat_len = len(matrix)
norms = [0] * mat_len
for i in range(0, mat_len):
norms[i] = 1.0 / np.sqrt(matrix.item((i, i)))
norm_mat = np.matrix(norms)
return np.multiply(norm_mat.transpose().dot(norm_mat), matrix) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cosineDistanceMatrix():\n\n\tmatrix = movieMatrix()\n\tsimilarity = np.dot(matrix, matrix.T)\n\tsquareMag = np.diag(similarity)\n\tinvSquareMag = 1/squareMag\n\tinvSquareMag[np.isinf(invSquareMag)]=0\n\tinvMag = np.sqrt(invSquareMag)\n\tcosine = similarity * invMag\n\tcosine = cosine.T * invMag\n\treturn cosin... | [
"0.8285621",
"0.78920585",
"0.7579562",
"0.74811274",
"0.743485",
"0.7388749",
"0.73220444",
"0.71874624",
"0.71846974",
"0.7142988",
"0.70933944",
"0.7079397",
"0.7016768",
"0.69719607",
"0.69497156",
"0.69476235",
"0.6929229",
"0.69159657",
"0.6877522",
"0.68710095",
"0.684... | 0.8017912 | 1 |
Generate a random sample of k words. | def sample(self, k):
result = ""
current = self.gen_beginning()
for i in range(0, k):
result += current[0] + " "
t = tuple(current)
if t in self.dict:
c_sum = self.dict[t][self.sum_index]
rand = random.randint(0, c_sum)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(words, n=10) -> str:\n return [random.choice(words) for _ in range(n)]",
"def generate(self, words=5):\n seed()\n return sorted(self.keywords, key=lambda *args: random())[0:words]",
"def initialize_k_mediods(data, k):\n return random.sample(range(len(data)), k)",
"def sample(da... | [
"0.72455376",
"0.70879835",
"0.693704",
"0.6925264",
"0.6848805",
"0.6814129",
"0.67589587",
"0.6738232",
"0.6705459",
"0.6673047",
"0.65499115",
"0.6505917",
"0.64209366",
"0.64151245",
"0.641502",
"0.6339997",
"0.6326541",
"0.62663114",
"0.6211554",
"0.62094414",
"0.6188869... | 0.7714014 | 0 |
Shift the colours to associate a value standing anywhere in the new cmap (relatively to the two extremes start & stop or min & max) with whichever value / colour of the input cmap (by default the midpoint). If the input cmap is divergent, this will be white by default. The locpoint value cannot be the min or max (start... | def shift_cmap(cmap, start=0., locpoint=0.5, stop=1.0, name='centered'):
# declare a colour + transparency dictionary
cdict={'red':[], 'green':[], 'blue':[], 'alpha':[]}
# regular index to compute the colors
RegInd = np.linspace(start, stop, cmap.N)
# shifted index to match what the data ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name=\"shiftedcmap\"):\n cdict = {\"red\": [], \"green\": [], \"blue\": [], \"alpha\": []}\n\n # regular index to compute the colors\n reg_index = np.linspace(start, stop, 257)\n\n # shifted index to match the data\n shift_index = np.hstack(... | [
"0.7426894",
"0.71807843",
"0.6564476",
"0.6303851",
"0.6023876",
"0.59686595",
"0.59551555",
"0.58223695",
"0.5817288",
"0.5612482",
"0.5571391",
"0.55472046",
"0.5510123",
"0.5468494",
"0.5433831",
"0.541819",
"0.5417777",
"0.536488",
"0.532748",
"0.5306837",
"0.53066117",
... | 0.78395176 | 0 |
use the approximated eigenvector returned by Power Iteration method to compute the largest eigenvalue of the matrix A | def compute_largest_eigenvalue(A, num_simulations):
b_k = power_iteration(A, num_simulations)
return b_k.dot(A).dot(b_k) / (b_k.dot(b_k)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(mat, otp):\n prd = mat*otp\n eigval = prd[0]/otp[0]\n print 'computed eigenvalue :' , eigval\n [eigs, vecs] = np.linalg.eig(mat)\n abseigs = list(abs(eigs))\n ind = abseigs.index(max(abseigs))\n print ' largest eigenvalue :', eigs[ind]",
"def calculate_biggest_eigenvalue(cls, covar... | [
"0.7686338",
"0.75658166",
"0.7420887",
"0.7406523",
"0.7244843",
"0.6996089",
"0.6981068",
"0.6972226",
"0.6875169",
"0.68482476",
"0.6837701",
"0.68196994",
"0.68079334",
"0.6799966",
"0.6798281",
"0.67714775",
"0.6687908",
"0.6684467",
"0.66705984",
"0.6626259",
"0.6624495... | 0.7842253 | 0 |
Load from SAM formatted tag. | def from_sam(column):
tag = Tag.__new__(Tag)
header = TagHeader()
tag._header = header
header.tag, value_type, tag._buffer = column.split(b':', 2)
header.value_type = int(value_type)
return tag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _readtag(self):\n tag = Tag()\n tag.tag = self.reader.readint(1)\n tag.len = self.reader.readint(2)\n\n if tag.len > 0:\n tag.data = self.reader.read(tag.len)\n return tag",
"def loads(cls, raw: bytes) -> 'Tag':\n meta = json.loads(raw.decode('utf-8'))\n ... | [
"0.5769399",
"0.57009256",
"0.54815173",
"0.541181",
"0.52811766",
"0.5242441",
"0.5222803",
"0.5183103",
"0.5168342",
"0.51363677",
"0.5094421",
"0.50843364",
"0.50767493",
"0.5076378",
"0.50727826",
"0.50671816",
"0.50626606",
"0.5058337",
"0.5029517",
"0.5023263",
"0.50008... | 0.59755653 | 0 |
Duplicate the tag instance and underlying buffer. | def copy(self):
new = Tag.__new__(Tag)
new._header = TagHeader.from_buffer_copy(self._header)
new._buffer = bytearray(self._buffer)
return new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\r\n cp = self.__class__(self.type, self.data, self.name)\r\n cp.tag = copy(self.tag)\r\n return cp",
"def clone(self):\r\n #return copy(self)\r\n cp = self.__class__(self.type, None, None, self.name)\r\n cp.tag = copy(self.tag)\r\n return cp",
"... | [
"0.7311448",
"0.71100277",
"0.6665762",
"0.6128848",
"0.60210073",
"0.59999156",
"0.59991366",
"0.5981431",
"0.59087753",
"0.5877438",
"0.58530945",
"0.5850476",
"0.58475935",
"0.584531",
"0.58307993",
"0.58307993",
"0.58307993",
"0.58262277",
"0.58262277",
"0.58262277",
"0.5... | 0.79683113 | 0 |
Return True if VM has already been registered. | def is_registered(self, thevm):
return self.is_registered_vm_ref(thevm.get_id()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_registered(self):\n return self._is_registered",
"def is_registered(self) -> bool:\n from arkouda.util import is_registered\n\n if self.registered_name is None:\n return False\n return is_registered(self.registered_name)",
"def is_registered(self):\n if self... | [
"0.69196904",
"0.68907464",
"0.6320427",
"0.628127",
"0.622022",
"0.61987096",
"0.6179819",
"0.61126006",
"0.60980445",
"0.6064852",
"0.6058638",
"0.60367787",
"0.60367787",
"0.59639454",
"0.59211785",
"0.5887907",
"0.5887252",
"0.58583194",
"0.58470297",
"0.5841361",
"0.5797... | 0.8016748 | 0 |
This function is for processing a vmrecord and determining the course of action that should be taken. | def process_vmrecord(self, vmref, vmrecord):
is_monitored = self.is_registered_vm_ref(vmref)
should_monitor = self._should_monitor(vmrecord)
if not is_monitored and should_monitor:
self.start_monitoring(vmref)
elif is_monitored and not should_monitor:
self.stop_mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_record(self, record):\n raise NotImplementedError('Process record needs to be customized')",
"def step(self):\n\n #make a dictionary of rules and which are active\n binary = self.int_to_8_bit_binary(self.rule_nbr)\n binary_str = ''.join(binary)\n\n active_rules = di... | [
"0.5164569",
"0.49395716",
"0.4700608",
"0.46963623",
"0.4691204",
"0.46837854",
"0.46780255",
"0.46223032",
"0.4606696",
"0.45727763",
"0.44958025",
"0.44768083",
"0.4473273",
"0.44693777",
"0.44464642",
"0.44464642",
"0.44457793",
"0.44338378",
"0.44290945",
"0.44153652",
"... | 0.5090451 | 1 |
Tidy TLS secrets after vmdestroy | def process_vm_del(self, vm_ref):
if vm_ref in self.tls_secret_cache:
for key in tls_secret.XSCONTAINER_TLS_KEYS:
if key in self.tls_secret_cache[vm_ref]:
secret_uuid = self.tls_secret_cache[vm_ref][key]
session = self.host.get_session()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clear_secret_token_map():\n global _secret_token_map\n _secret_token_map = None",
"def terraform_destroy():\n return subprocess.call([\n \"terraform\",\n \"destroy\",\n \"-var-file=terraform/aws/security.tfvars\",\n \"terraform/aws\"\n ])",
"def prepare_secrets(c, r... | [
"0.5807785",
"0.5727637",
"0.5725778",
"0.55358976",
"0.5488105",
"0.5402988",
"0.5384859",
"0.52961004",
"0.5294215",
"0.5262412",
"0.5256724",
"0.5233984",
"0.51561475",
"0.50737864",
"0.5048128",
"0.5044511",
"0.5015237",
"0.5011312",
"0.5009923",
"0.497746",
"0.49721035",... | 0.63315004 | 0 |
Returns a string representation of the given Bouquet. | def bouquet_to_string(bouquet: Bouquet) -> str:
flowers = sorted(bouquet.flowers.items())
flower_quantities = (f"{count}{flower.species}" for flower, count in flowers)
return "".join(chain(bouquet.name, bouquet.size, flower_quantities)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n tag = []\n for key in self.tags:\n if key == 'label':\n self.type = self.tags[key]\n else:\n try:\n tag.append(\"%s=%0.3f\" % (str(key), self.tags[key]))\n except TypeError:\n ... | [
"0.6125326",
"0.6092544",
"0.60388684",
"0.6008322",
"0.6004144",
"0.5972039",
"0.5931697",
"0.5896468",
"0.5836418",
"0.5798204",
"0.5778516",
"0.5772454",
"0.57675993",
"0.57460415",
"0.57389605",
"0.5727558",
"0.5709913",
"0.5687112",
"0.567919",
"0.56786853",
"0.56669056"... | 0.8395375 | 0 |
Returns an approximation of the design's complexity to create. | def design_complexity(design: Design) -> int:
diversity = 3 * len(design.required)
abundance = 2 * sum(design.required.values())
return diversity + abundance + design.additional | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complexity(self):\n raise NotImplementedError()",
"def complexity(self) -> str:\n return pulumi.get(self, \"complexity\")",
"def time_complexities():\n return \"Best Case: O(n), Average Case: O(n), Worst Case: O(n)\"",
"def _calculate_complexity(workflow):\n complexity = estimate_comp... | [
"0.8077096",
"0.6961893",
"0.6919179",
"0.6726002",
"0.6631515",
"0.66048616",
"0.6532741",
"0.64464813",
"0.6343992",
"0.63089466",
"0.62893844",
"0.61888796",
"0.6182711",
"0.61719126",
"0.6056263",
"0.60038203",
"0.59974915",
"0.5947808",
"0.5912837",
"0.5826208",
"0.57910... | 0.7889661 | 1 |
Returns a dict of flowers and amount required across all designs. | def flower_demand(designs: Iterable[Design]) -> FlowerCounter:
elements = (design.required.elements() for design in designs)
return Counter(chain.from_iterable(elements)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _evaluate(self, design: Design) -> Dict[str, float]:\n state_dict = dict()\n for i, key in enumerate(self.params_vec.keys()):\n state_dict[key] = self.params_vec[key][design[i]]\n results = dict()\n for netlist_name, netlist_module in self.netlist_module_dict.items():\n ... | [
"0.5650389",
"0.55767566",
"0.55356234",
"0.5211133",
"0.5200495",
"0.51428133",
"0.51294917",
"0.5111226",
"0.50917345",
"0.50691676",
"0.5068217",
"0.5063549",
"0.5061189",
"0.50606686",
"0.5054326",
"0.5049696",
"0.50316507",
"0.5015505",
"0.50010157",
"0.4985385",
"0.4977... | 0.67191625 | 0 |
Parse position packet to extract x,y,z coordinates. | def handle_position(data: bytes) -> Tuple[bytes, str]:
x, y, z = struct.unpack('fff', data[0:3 * 4])
return data[20:], f'Current Position (x,y,z): {x} {y} {z}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xyz_points(packet):\n if not isinstance(packet, tuple):\n packet = unpack(packet)\n\n x = []\n y = []\n z = []\n\n for b in range(AZIMUTH_BLOCK_COUNT):\n block = azimuth_block(b, packet)\n\n if not azimuth_valid(block):\n continue\n\n for c in range(CHANNEL... | [
"0.69323254",
"0.69320357",
"0.69288343",
"0.6922433",
"0.6886289",
"0.67812216",
"0.63687855",
"0.6320784",
"0.62680185",
"0.61316466",
"0.61238545",
"0.6087155",
"0.6069988",
"0.6061023",
"0.60496056",
"0.59711367",
"0.59693176",
"0.5949054",
"0.5853009",
"0.58473074",
"0.5... | 0.7093595 | 0 |
Parse jump packet to determine whether character is jumping. | def handle_jump(data: bytes) -> Tuple[bytes, str]:
jumping = struct.unpack('?', data[:1])[0]
return data[1:], 'Jumping' if jumping else 'Falling' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isJump(self) -> bool:\n ...",
"def parseJump(cmds):\n if (len(cmds) != 0):\n parseExpr(cmds[0])\n parseJump(cmds[1:])",
"def jump(self):\n if self.commandType() is C_COMMAND and SEMIC in self.currentCommand:\n return self.currentCommand.split(SE... | [
"0.615037",
"0.6014653",
"0.5796932",
"0.5575382",
"0.5509545",
"0.53331184",
"0.52808654",
"0.5249864",
"0.515087",
"0.5149437",
"0.512318",
"0.50901484",
"0.508259",
"0.5030159",
"0.5023107",
"0.50212574",
"0.5014617",
"0.49220034",
"0.48980102",
"0.48829585",
"0.48466754",... | 0.6712948 | 0 |
Parse sneak packet to determine whether character is sneaking. | def handle_sneak(data: bytes) -> Tuple[bytes, str]:
sneaking = not(struct.unpack('?', data[:1])[0])
return data[1:], 'Sneaking' if sneaking else 'Done sneaking' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spoof_packet(packet):",
"def is_valid_ssdp_packet(data: bytes) -> bool:\n return (\n bool(data)\n and b\"\\n\" in data\n and (\n data.startswith(b\"NOTIFY * HTTP/1.1\")\n or data.startswith(b\"M-SEARCH * HTTP/1.1\")\n or data.startswith(b\"HTTP/1.1 200... | [
"0.60442406",
"0.5914778",
"0.55621016",
"0.5559887",
"0.5418556",
"0.5331959",
"0.5268514",
"0.517216",
"0.5141348",
"0.5118424",
"0.5115155",
"0.5101938",
"0.5091775",
"0.50372213",
"0.5020283",
"0.50183654",
"0.4982059",
"0.4971184",
"0.4962405",
"0.495",
"0.49458483",
"... | 0.67788094 | 0 |
Parse slot packet to get new selected slot. | def handle_slot_select(data: bytes) -> Tuple[bytes, str]:
new_slot = struct.unpack('B', data[:1])[0]
return data[1:], f'New slot: {new_slot}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ParseSlot(self, G, node):\n slot = BLNlpClipsSlotMap()\n slot.Name = node\n return slot",
"def slot(self):\n if self.__slot in ApexAP1000.SLOTS:\n return self.__slot\n else:\n raise ValueError('Bad slot number !')",
"def get_slot(self, c):\n i... | [
"0.6871716",
"0.6167444",
"0.6067937",
"0.5867668",
"0.582912",
"0.56749433",
"0.5670136",
"0.5644674",
"0.55893064",
"0.55682135",
"0.5525981",
"0.54996186",
"0.5356382",
"0.53551406",
"0.5354744",
"0.535286",
"0.53276724",
"0.5315347",
"0.5280438",
"0.5268219",
"0.5253302",... | 0.74431324 | 0 |
Parse shoot packet to get name and direction of weapon shot. | def handle_shoot(data: bytes) -> Tuple[bytes, str]:
length = struct.unpack('H', data[:2])[0]
name = data[2:length+2]
direction = struct.unpack('fff', data[length+2:length+2+12])
return data[2+length:], f'Shot {name.decode()} in direction: {direction}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shoot(self, direction):\n self.type = self.boss.get_bullet_type()\n if self.type == 'shotgun':\n try:\n dx = abs(Laser.List[-1].x - self.x)\n dy = abs(Laser.List[-1].y - self.y)\n if dx < 50 and dy < 50 and self.type == 'shotgun':\n ... | [
"0.5890974",
"0.5887054",
"0.53437346",
"0.5336487",
"0.53323966",
"0.52839124",
"0.5244903",
"0.51474124",
"0.5147154",
"0.51261395",
"0.5072278",
"0.5041751",
"0.5030743",
"0.50281894",
"0.50211716",
"0.49417537",
"0.49294055",
"0.49110854",
"0.48818228",
"0.48443696",
"0.4... | 0.6662206 | 0 |
Parse actor drop packet to get actor information. Message displays actor name and drop position. If the actor is a "Drop" object, send loot packet to server to automatically pick it up. | def handle_actor_drop(data: bytes) -> Tuple[bytes, str]:
# TODO: reverse first 9 bytes
item_id = struct.unpack('I', data[:4])[0]
unknown = struct.unpack('I', data[4:8])[0] # noqa: F841
unknown2 = data[9] # noqa: F841
item_name_length = struct.unpack('H', data[9:11])[0]
item_name = data[11:11+i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_drop(self, arg):\r\n\r\n # put this value in a more suitably named variable\r\n itemToDrop = arg.lower()\r\n\r\n # get a list of all \"description words\" for each item in the inventory\r\n invDescWords = getAllDescWords(inventory)\r\n\r\n # find out if the player doesn't ... | [
"0.56872076",
"0.55682516",
"0.54184365",
"0.5319463",
"0.51151735",
"0.50281775",
"0.49502423",
"0.494522",
"0.49405202",
"0.48522088",
"0.47940865",
"0.47803688",
"0.47510865",
"0.47133994",
"0.4665043",
"0.46581176",
"0.46517873",
"0.46223408",
"0.46195015",
"0.45776522",
... | 0.72898984 | 0 |
Parse regionchange packet to get region name. Drop positions of initial actors, like GoldenEggs, is also revealed. | def handle_region_change(data: bytes) -> Tuple[bytes, str]:
region_name_length = struct.unpack('H', data[:2])[0]
region_name = data[2:2+region_name_length]
return (data[2+region_name_length:],
f'Changing to region: {region_name.decode().upper()}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_region_name(self, i):\n for region in self.regions:\n if region['id'] == i:\n return region['name']\n return 'Unknown Matchmaking Region'",
"def region_name(self):\n return self.random_element(self._regions)[1]",
"def parse(spec: str):\n parts = spe... | [
"0.59673536",
"0.57557505",
"0.5583435",
"0.5512079",
"0.5460583",
"0.5374759",
"0.53120506",
"0.5214128",
"0.51646787",
"0.5143317",
"0.51233065",
"0.503153",
"0.5028622",
"0.49404567",
"0.49021447",
"0.4894185",
"0.4893214",
"0.48763806",
"0.48636374",
"0.48617592",
"0.4861... | 0.7242775 | 0 |
Parse itemacquire packet to get information about item. For example, indicate the type and amount of ammo received by a Drop. | def handle_item_acquire(data: bytes) -> Tuple[bytes, str]:
item_name_length = struct.unpack('H', data[:2])[0]
item_name = data[2:2+item_name_length].decode(helpers.ENCODING)
amount = struct.unpack('I',
data[2+item_name_length:2+item_name_length+4])[0]
return data[2+item_name_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_item(raw_item: str) -> Item:\n name, cost, damage, armor = raw_item.split()\n\n return Item(name, int(cost), int(damage), int(armor))",
"def purchase(self, item_type):",
"def test_acquire(self):\n cmd = Acquire(10, Discriminator(name='test_disc', params={'test_params': 1.0}),\n ... | [
"0.5597219",
"0.5188092",
"0.5177499",
"0.5073031",
"0.5053507",
"0.47726688",
"0.47510383",
"0.47276434",
"0.46652564",
"0.46515086",
"0.46486056",
"0.4630913",
"0.46084592",
"0.4608282",
"0.45737928",
"0.4572363",
"0.45675558",
"0.4482317",
"0.44680476",
"0.44588447",
"0.44... | 0.76179355 | 0 |
Parse itempickup packet to get ID of item picked up. This packet can be used to implement autolooting. | def handle_item_pickup(data: bytes) -> Tuple[bytes, str]:
item_id = struct.unpack('I', data[:4])[0]
return data[4:], f'Picked up item with ID {item_id}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_id(self):\n return self._item_id",
"def get_itemId(self):\n return self.metadata['itemId']",
"def item2id(self):\n if self._item2id is None:\n self._item2id = dict(zip(self.item_unique_vals, range(self.n_items)))\n return self._item2id",
"def GetId(self,item):\... | [
"0.5675741",
"0.5595556",
"0.55021983",
"0.5498978",
"0.5446714",
"0.53615916",
"0.5318583",
"0.5302795",
"0.52846485",
"0.52069044",
"0.52050513",
"0.5146597",
"0.51271284",
"0.5093275",
"0.50868964",
"0.50801",
"0.50474125",
"0.50447243",
"0.5043063",
"0.5026166",
"0.497911... | 0.6605895 | 0 |
Parse reload packet to get weapon reloaded and type and amount of ammo. This packet can also be used to implement autoreloading. | def handle_reload(data: bytes) -> Tuple[bytes, str]:
try:
weapon_name_length = struct.unpack('H', data[:2])[0]
weapon_name = data[2:2+weapon_name_length].decode(helpers.ENCODING)
ammo_name_length = struct.unpack('H',
data[2+weapon_name_length:2+weapon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_loaded_ammo(data: bytes) -> Tuple[bytes, str]:\n weapon_name_length = struct.unpack('H', data[:2])[0]\n weapon_name = data[2:2+weapon_name_length].decode(helpers.ENCODING)\n loaded_ammo = struct.unpack('I',\n data[2+weapon_name_length:2+weapon_name_length+4])[0] ... | [
"0.66666114",
"0.55387217",
"0.5414622",
"0.5111501",
"0.50200164",
"0.48626655",
"0.4839229",
"0.47635645",
"0.47579595",
"0.47329336",
"0.47281036",
"0.4692487",
"0.46864903",
"0.46703836",
"0.46219566",
"0.46208167",
"0.46134442",
"0.46068662",
"0.4582399",
"0.45680597",
"... | 0.7670467 | 0 |
Parse health packet to get amount of HP for actors. | def handle_health(data: bytes) -> Tuple[bytes, str]:
actor_id, hp = struct.unpack('Ih', data[:6])
return data[6:], f'Actor {actor_id} has {hp} HP' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hp():\n\n return character['HP']",
"def get_character_health(character: dict):\r\n print(\"Your health is: %d\" % character['HP'])",
"def health(self) -> Union[int, float]:\n return self.proto.health",
"def health(self) -> Union[int, float]:\n return self.proto.health",
"def get... | [
"0.61138475",
"0.58834904",
"0.58287996",
"0.58287996",
"0.57303226",
"0.56599045",
"0.557464",
"0.55465996",
"0.55047244",
"0.54503375",
"0.54475665",
"0.54012614",
"0.53854513",
"0.5374126",
"0.5319295",
"0.53045714",
"0.52863604",
"0.52635986",
"0.526149",
"0.526149",
"0.5... | 0.72335124 | 0 |
Parse mana packet to get amount of mana player has. | def handle_mana(data: bytes) -> Tuple[bytes, str]:
mana = struct.unpack('H', data[:2])[0]
return data[2:], f'Player has {mana} mana' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_card_generic_mana(card_face: CardFace) -> int:\n if not card_face.mana_cost:\n return 0\n\n generic_mana = RE_GENERIC_MANA.search(card_face.mana_cost)\n if generic_mana:\n return int(generic_mana.group(1))\n return 0",
"async def mana():\n acc = Account(\"travelfeed\")\n m... | [
"0.57014525",
"0.56480294",
"0.51965064",
"0.5002724",
"0.49907732",
"0.4978547",
"0.49368247",
"0.4921005",
"0.49195775",
"0.48984864",
"0.48687136",
"0.4837379",
"0.48320034",
"0.4801529",
"0.4791798",
"0.4788704",
"0.4764654",
"0.467033",
"0.464986",
"0.46493697",
"0.46481... | 0.7122957 | 0 |
Parse actor state packet to get state of actors. | def handle_state(data: bytes) -> Tuple[bytes, str]:
actor_id, state_length = struct.unpack('IH', data[:6])
state = data[6:6+state_length].decode(helpers.ENCODING)
return data[6+state_length:], f'Actor {actor_id} in {state} state' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_state(self, state: str):\r\n state = state.strip()\r\n state = state.split(';')\r\n\r\n if len(state) < 2:\r\n print(state)\r\n return\r\n\r\n for field in state:\r\n split = field.split(':')\r\n if len(split) < 2:\r\n ... | [
"0.64426273",
"0.58384633",
"0.5417954",
"0.54048204",
"0.53565496",
"0.5319129",
"0.53103405",
"0.530963",
"0.52439404",
"0.5221096",
"0.515227",
"0.5113325",
"0.5079505",
"0.5075995",
"0.5031213",
"0.5030043",
"0.50287706",
"0.502478",
"0.50243676",
"0.5004235",
"0.49950925... | 0.6912247 | 0 |
Parse attack packet to get actor that attacked a victim and the attack. | def handle_attack(data: bytes) -> Tuple[bytes, str]:
attacker_id, attack_length = struct.unpack('IH', data[:6])
attack = data[6:6+attack_length].decode(helpers.ENCODING)
victim_id = struct.unpack('I', data[6+attack_length:6+attack_length+4])[0]
return (data[6+attack_length+4:],
f'Actor {atta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_attack(self, name_index, bonus_index, damage_index, sheet=None):\n if self.character_data is None: raise Exception('You must call get_character() first.')\n\n wksht = sheet or self.character_data\n\n name = wksht.value(name_index)\n damage = wksht.value(damage_index)\n ... | [
"0.57115144",
"0.5400416",
"0.528136",
"0.51143986",
"0.5100148",
"0.50714874",
"0.49574938",
"0.4811062",
"0.48007146",
"0.47944915",
"0.4706924",
"0.47052175",
"0.46990165",
"0.46683258",
"0.46647388",
"0.46605876",
"0.4658123",
"0.46417665",
"0.46375567",
"0.46187025",
"0.... | 0.71671 | 0 |
Parse loaded ammo packet after firing weapon to get amount left. Implements autoreloading by sending an empty reload packet once the loaded ammo is 0. | def handle_loaded_ammo(data: bytes) -> Tuple[bytes, str]:
weapon_name_length = struct.unpack('H', data[:2])[0]
weapon_name = data[2:2+weapon_name_length].decode(helpers.ENCODING)
loaded_ammo = struct.unpack('I',
data[2+weapon_name_length:2+weapon_name_length+4])[0] # noqa: E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_reload(data: bytes) -> Tuple[bytes, str]:\n try:\n weapon_name_length = struct.unpack('H', data[:2])[0]\n weapon_name = data[2:2+weapon_name_length].decode(helpers.ENCODING)\n ammo_name_length = struct.unpack('H',\n data[2+weapon_name_lengt... | [
"0.6259794",
"0.58762985",
"0.55822694",
"0.5278703",
"0.507096",
"0.49732047",
"0.4869085",
"0.48412865",
"0.48208162",
"0.48206604",
"0.47543898",
"0.47513166",
"0.47376245",
"0.4736578",
"0.47344047",
"0.47061676",
"0.4654247",
"0.46230495",
"0.4613993",
"0.4606527",
"0.45... | 0.780836 | 0 |
Tests that get_connection calls psftp.Connection with the correct values | def test_get_connection_settings(self, connection_mock): # pylint: disable=no-self-use
connection = get_connection()
connection_mock.assert_called_once_with(
host=EXAMS_SFTP_HOST,
port=int(EXAMS_SFTP_PORT),
username=EXAMS_SFTP_USERNAME,
password=EXAMS_SFT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_connection_established(self):\n module = MagicMock()\n connection = slxos.get_connection(module)\n self.assertEqual(connection, module.slxos_connection)",
"def test_get_connection_new(self, connection):\n socket_path = \"little red riding hood\"\n module = MagicMoc... | [
"0.72463953",
"0.69269234",
"0.6732456",
"0.6695619",
"0.6427103",
"0.63837254",
"0.6339699",
"0.63005483",
"0.62540317",
"0.62194014",
"0.62133",
"0.6174514",
"0.616663",
"0.6124214",
"0.61124814",
"0.6091434",
"0.6076851",
"0.60266703",
"0.6018473",
"0.60139763",
"0.6008917... | 0.7967671 | 0 |
Tests that get_connection ImproperlyConfigured if settings.{0} is not set | def test_get_connection_missing_settings(self, settings_key, connection_mock):
kwargs = {settings_key: None}
with self.settings(**kwargs):
with self.assertRaises(ImproperlyConfigured) as cm:
get_connection()
connection_mock.assert_not_called()
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_settings(self):\n if not self.app.config['SIMPLE_DOMAINS']:\n raise ConfigurationError('You must specify at least one SimpleDB domain to use.')\n\n if not (self.app.config['AWS_ACCESS_KEY_ID'] and self.app.config['AWS_SECRET_ACCESS_KEY']):\n raise ConfigurationError('Y... | [
"0.649657",
"0.6454777",
"0.6415557",
"0.64093715",
"0.6342447",
"0.6325495",
"0.63240635",
"0.6275803",
"0.6271064",
"0.62406033",
"0.62391704",
"0.6227631",
"0.6218934",
"0.61725026",
"0.6149161",
"0.6049156",
"0.6045454",
"0.60177803",
"0.6005816",
"0.5928027",
"0.5928027"... | 0.76731056 | 0 |
Smoothing should be a number, bbox_x = [minx, maxx] | def get_res(smoothing, bbox_x, bbox_y):
def res(bbox, sm):
return int((bbox_x[1] - bbox_x[0])/sm)
return [res(bbox_x, smoothing), res(bbox_y, smoothing)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def smooth(y, box_pts):\r\n box = np.ones(box_pts)/box_pts\r\n y_smooth = np.convolve(y, box, mode='same')\r\n return y_smooth",
"def smooth(y, box_pts):\n box = np.ones(box_pts) / box_pts\n y_smooth = np.convolve(y, box, mode='same')\n return y_smooth",
"def smooth(y, box_pts):\n box = np... | [
"0.57198817",
"0.56598175",
"0.56598175",
"0.56491804",
"0.5611589",
"0.54865634",
"0.5460925",
"0.5432702",
"0.536268",
"0.53520083",
"0.5329537",
"0.5329224",
"0.5327849",
"0.5318262",
"0.5299387",
"0.52045935",
"0.51921636",
"0.51901954",
"0.51788276",
"0.5169787",
"0.5165... | 0.6321506 | 0 |
DG is the datagrid, and sound is a callable function that returns the sound speed (see toomre.py). res_elem gives the size of the resolution element in simulation units (used to convert the mass in a pixel to surface density) It automatically masks regions where there are no particles, which can be used through cmap.se... | def get_toomre_Q(DG, sound, res_elem):
area = res_elem**2
gas_sd = DG.gas_data['masses']/area
star_sd = DG.star_data['masses']/area
gas_v = DG.gas_data['velocities'] # note this is actually v/r
gas_d = DG.gas_data['densities']
# Surface density reasoning see 1503.07873v1
gas_q = toom.Q_g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toomre_Q_r(DG, sound, res_elem, max_radius):\n # Yes, this is very slow.\n radii = np.arange(res_elem, max_radius, res_elem)\n toomre_Q = []\n\n for rad in radii:\n toomre_Q.append(fid.toomre_Q_gas(DG, rad, res_elem, sound))\n\n return toomre_Q",
"def simulated_dph(grbdir,typ,t_src,alph... | [
"0.52552176",
"0.5182895",
"0.51682216",
"0.5144233",
"0.50311786",
"0.49805695",
"0.49099684",
"0.4887669",
"0.48485103",
"0.4843213",
"0.48011786",
"0.47985935",
"0.47597227",
"0.4748434",
"0.47479472",
"0.46964255",
"0.4680623",
"0.46685237",
"0.46675152",
"0.46445018",
"0... | 0.61697304 | 0 |
Finds the number of particles within the bin radii, useful for seeing how the disk stabalises (does it transport mass into the centre?) | def n_particles_bins(DG, bins=[0, 0.5, 3, 10, 100]):
radii = fid.rss(DG.gas['Coordinates'][()])
hist, bin_edges = np.histogram(radii, bins)
return hist, bin_edges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computation_gr(particles,p_types,dist,i,j,nbins, rmax):\n i=np.where(p_types == i)[0][0]\n j=np.where(p_types == j)[0][0]\n\n\n if len(p_types)>1:\n #indexes to delete if there is more than one type of particles\n i_axis0=[]\n i_axis1=[]\n for k in range(len(p_types)):\n ... | [
"0.7237319",
"0.7176436",
"0.63535374",
"0.6320189",
"0.6278159",
"0.61981356",
"0.6194995",
"0.6141035",
"0.61394185",
"0.61316097",
"0.61302745",
"0.6105756",
"0.6071953",
"0.6067629",
"0.6005089",
"0.5995811",
"0.59784985",
"0.59109277",
"0.59025335",
"0.58659625",
"0.5864... | 0.74232644 | 0 |
Checks that fetch_inventory_and_error adds entries to database_inv_sig and that the execution time is smaller when fetching an already existing entry | def test_fecth_inventory_and_error():
# build
for key in divHretention.database_inv_sig:
# ensuring an empty database
del divHretention.database_inv_sig[key]
# test
test_time = 1e3
start_time = time.time()
inv, sig = divHretention.fetch_inventory_and_error(test_time)
long_ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_inventory_and_error(time):\n if time in database_inv_sig.keys(): # fetch in database\n inv_T_c_local = database_inv_sig[time][\"inv\"]\n sig_inv_local = database_inv_sig[time][\"sig\"]\n else: # if time is not in the database\n GP = estimate_inventory_with_gp_regression(time=... | [
"0.6221308",
"0.5411542",
"0.53102636",
"0.5308235",
"0.5300307",
"0.5236339",
"0.52021307",
"0.51916313",
"0.5173078",
"0.5142627",
"0.5137326",
"0.5120869",
"0.5109939",
"0.50971144",
"0.5077694",
"0.5074573",
"0.5023493",
"0.49574175",
"0.49436677",
"0.49277782",
"0.492769... | 0.7170764 | 0 |
Checks that compute_inventory runs correctly | def test_compute_inventory():
T = [1000]
c_max = [1e20]
time = 1e3
inv, sig = divHretention.compute_inventory(T, c_max, time)
assert len(inv) == len(sig)
assert len(inv) == len(T) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_inventory(self):\n pass",
"def test_get_dealer_active_inventory(self):\n pass",
"def test_fecth_inventory_and_error():\n # build\n for key in divHretention.database_inv_sig:\n # ensuring an empty database\n del divHretention.database_inv_sig[key]\n\n # test\... | [
"0.6818076",
"0.63204855",
"0.6264373",
"0.61825716",
"0.61619246",
"0.61434335",
"0.6123214",
"0.60767823",
"0.5987047",
"0.59677404",
"0.59621096",
"0.59617424",
"0.5866379",
"0.5864086",
"0.5852474",
"0.5762252",
"0.57233906",
"0.5713749",
"0.56915",
"0.5668413",
"0.564253... | 0.6829671 | 0 |
Checks that compute_inventory raises a TypeError when a float is given | def test_compute_inventory_float():
T = 1000
c_max = 1e20
time = 1e3
with pytest.raises(TypeError):
inv, sig = divHretention.compute_inventory(T, c_max, time) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_float(check):",
"def test_float(self):\n self.assertFalse(validate_measure_input('0.0', self.measures))\n self.assertFalse(validate_measure_input('1.0', self.measures))\n self.assertFalse(validate_measure_input('1.1', self.measures))",
"def test_float_type(self):\n\n i... | [
"0.6769449",
"0.6288506",
"0.6269468",
"0.61832154",
"0.6129997",
"0.61288977",
"0.60953104",
"0.60848355",
"0.60641825",
"0.6039481",
"0.60373956",
"0.6024941",
"0.6017565",
"0.60068446",
"0.5970356",
"0.5923205",
"0.58845717",
"0.5883388",
"0.5840277",
"0.5804445",
"0.57976... | 0.7702364 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.