query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
This test ensures that `pafy` and `youtubedl` do not raise any exceptions when getting the url of the audio stream. | def test_get_audio_stream_does_not_raise(self):
youtube_url = "https://www.youtube.com/watch?v=jIxas0a-KgM"
_ = utils.get_audio_stream(youtube_url)
assert True # No error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_audio_stream_uses_pafy(self, monkeypatch):\n pafy_mock = MagicMock()\n youtube_video_mock = MagicMock()\n audio_stream_mock = MagicMock()\n audio_stream_mock.url = \"some-url\"\n pafy_mock.new.return_value = youtube_video_mock\n youtube_video_mock.getbestaudio... | [
"0.73855877",
"0.68620956",
"0.6554057",
"0.649739",
"0.6350189",
"0.6266915",
"0.624502",
"0.6188693",
"0.6179482",
"0.60891366",
"0.6061445",
"0.60325617",
"0.5985034",
"0.5915826",
"0.591404",
"0.5903476",
"0.58943635",
"0.5894254",
"0.5858184",
"0.5857649",
"0.5840587",
... | 0.8195822 | 0 |
If a directory is specified at the MusicGroup level and not the TrackList level, return the MusicGroup directory (even if there is a default directory specified). | def test_get_track_list_root_directory_returns_group_directory(self, example_group):
example_group.directory = "group/dir"
example_track_list = example_group.track_lists[0]
example_track_list.directory = None
directory = utils.get_track_list_root_directory(
group=example_grou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_track_list_root_directory_returns_default_directory(self, example_group):\n example_group.directory = None\n example_track_list = example_group.track_lists[0]\n example_track_list.directory = None\n directory = utils.get_track_list_root_directory(\n group=example... | [
"0.7300617",
"0.7005289",
"0.6776891",
"0.6530413",
"0.62937003",
"0.5796358",
"0.5730125",
"0.570387",
"0.55898523",
"0.5577252",
"0.5570405",
"0.556296",
"0.5501124",
"0.5476069",
"0.5476069",
"0.5476069",
"0.5476069",
"0.54219604",
"0.54202604",
"0.5416887",
"0.54064286",
... | 0.73076063 | 0 |
If a directory is specified at the TrackList, return it (even if there is a default directory and a MusicGroup directory specified). | def test_get_track_list_root_directory_returns_track_list_directory(self, example_group):
example_group.directory = "group/dir"
example_track_list = example_group.track_lists[0]
example_track_list.directory = "track/list/dir"
directory = utils.get_track_list_root_directory(
g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_track_list_root_directory_returns_default_directory(self, example_group):\n example_group.directory = None\n example_track_list = example_group.track_lists[0]\n example_track_list.directory = None\n directory = utils.get_track_list_root_directory(\n group=example... | [
"0.6984249",
"0.68418986",
"0.67935693",
"0.64016855",
"0.627342",
"0.57656026",
"0.5544318",
"0.55125946",
"0.5497522",
"0.54900193",
"0.545574",
"0.5420547",
"0.54195446",
"0.5405093",
"0.53324926",
"0.5311299",
"0.53054774",
"0.5269432",
"0.5255914",
"0.5251969",
"0.523074... | 0.7165096 | 0 |
If no directory is specified at all (neither the default, MusicGroup or TrackList level), then raise a ValueError. | def test_get_track_list_root_directory_raises_value_error_if_no_directory_on_any_level(self, example_group):
example_group.directory = None
example_track_list = example_group.track_lists[0]
example_track_list.directory = None
with pytest.raises(ValueError):
utils.get_track_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_track_path_raises_value_error_if_root_directory_unknown(self, example_group):\n example_group.directory = None\n track_list = example_group.track_lists[0]\n track_list.directory = None\n track = track_list.tracks[0]\n track.file = \"file.mp3\"\n with pytest.ra... | [
"0.6666906",
"0.65186435",
"0.64348835",
"0.62780577",
"0.6051036",
"0.6036086",
"0.60046846",
"0.6001214",
"0.59972245",
"0.5941083",
"0.58764106",
"0.5864775",
"0.57750106",
"0.57120746",
"0.5710117",
"0.5679481",
"0.5677798",
"0.5676402",
"0.5645783",
"0.56189084",
"0.5614... | 0.6675426 | 0 |
If the `file` attribute of a `Track` is the link to a YouTube video, return the url of its audio stream. | def test_get_track_path_returns_audio_url_if_track_is_youtube_link(self, example_group, monkeypatch):
track_list = example_group.track_lists[0]
track = track_list.tracks[0]
track.file = "https://www.youtube.com/watch?v=jIxas0a-KgM"
get_audio_stream_mock = MagicMock(return_value="some-url... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_track_url(self) -> Optional[str]:\n return self.track_url",
"def getYouTubeLink(self):\n \n return self.link.replace('watch?v=', 'v/')",
"async def video_url(cls, url, ytdl, *, loop=None, stream=False):\n loop = loop or asyncio.get_event_loop()\n data = await loop.run... | [
"0.6517977",
"0.6222144",
"0.61775047",
"0.613382",
"0.6090457",
"0.60868955",
"0.6059591",
"0.5979248",
"0.5948752",
"0.59048",
"0.58944744",
"0.5857499",
"0.5803926",
"0.57988226",
"0.57923424",
"0.5771793",
"0.57668257",
"0.57618827",
"0.5743584",
"0.57390773",
"0.5733271"... | 0.6292326 | 1 |
If the `file` attribute of a `Track` is not the link to a YouTube video, return the file path. The file path consists of the root directory combined with the filename. If there is no root directory, raise a `ValueError`. | def test_get_track_path_raises_value_error_if_root_directory_unknown(self, example_group):
example_group.directory = None
track_list = example_group.track_lists[0]
track_list.directory = None
track = track_list.tracks[0]
track.file = "file.mp3"
with pytest.raises(ValueErr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_path(self):\n return os.path.splitext(self.file_path)[0]",
"def video_path(self):\n return self.file_path",
"def video_path(self):\n return self.file_path",
"def file_path(self, request, response=None, info=None):\n url = request.url\n media_guid = hashlib.sha1(to... | [
"0.64809597",
"0.59345466",
"0.59345466",
"0.57224315",
"0.5699178",
"0.56898814",
"0.5637941",
"0.56020266",
"0.55251944",
"0.55185705",
"0.5516615",
"0.55107254",
"0.55096567",
"0.54277694",
"0.5409555",
"0.5409178",
"0.539645",
"0.53792495",
"0.53523844",
"0.5350454",
"0.5... | 0.62986904 | 1 |
Recursively build a list of all possible interlocked words based on t and s | def recursive_build_list(w, t, s):
if len(t) == 0 and len(s) == 0:
return [w]
elif len(t) > 0 and len(s) > 0:
return recursive_build_list(w+s[0], t, s[1:]) + recursive_build_list(w+t[0], t[1:], s)
elif len(t) == 0:
return recursive_build_list(w+s[0], t, s[1:])
else:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nlp_tree(self, t, s=0):\n if t is not []:\n for word in t:\n # Ignore symbols & punctuation\n if word.pos_ != 'PUNCT' and word.pos_ != 'SYM':\n yield word.lemma_, s\n yield from self.nlp_tree(word.children, s + 1)",
"def mutate... | [
"0.6322268",
"0.58114284",
"0.5630272",
"0.55674845",
"0.5529122",
"0.55001175",
"0.5493375",
"0.5480591",
"0.5470335",
"0.5420374",
"0.541383",
"0.54046464",
"0.53999716",
"0.53935856",
"0.5380236",
"0.534647",
"0.5331949",
"0.53291",
"0.53234106",
"0.53050655",
"0.52850217"... | 0.7121028 | 0 |
Build a list of words interlocked based on w and z | def merge_words(w, z):
list_w = list(w)
list_z = list(z)
return recursive_build_list("", list_w, list_z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parallel_word_dict(w_list, st, end):\n import spacy\n w_list = w_list[st:end]\n nlp, out_dict, count = spacy.load('en_core_web_lg'), {}, 0\n for word in w_list:\n word_obj = nlp(word)\n if word_obj.has_vector:\n out_dict[word] = word_obj.vector\n count += 1\n retu... | [
"0.5804452",
"0.57623976",
"0.574421",
"0.5729602",
"0.5720258",
"0.5679107",
"0.5663034",
"0.5638631",
"0.563784",
"0.5582289",
"0.5581782",
"0.55727065",
"0.5570792",
"0.5566986",
"0.5512288",
"0.54632133",
"0.5462469",
"0.54015785",
"0.5399697",
"0.5390555",
"0.5371636",
... | 0.68757725 | 0 |
Returns a list of labels from the tasks. | def get_unique_label_list(self) -> List[str]:
return self.tasks.get_label_list() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_labels(self):\n return set([t.label for t in self.tasks])",
"def get_label_lists(datasets, tasks):\n label_lists = []\n for task in tasks:\n is_regression = task == \"stsb\"\n if is_regression:\n label_lists.append([None])\n else:\n label_lists.app... | [
"0.81855375",
"0.80007124",
"0.7931263",
"0.7458139",
"0.7309054",
"0.73071444",
"0.727765",
"0.72751105",
"0.7092487",
"0.70907557",
"0.7078556",
"0.7015346",
"0.6968778",
"0.69611603",
"0.6945055",
"0.691256",
"0.691256",
"0.6898451",
"0.6897616",
"0.68881816",
"0.6854316",... | 0.8328031 | 0 |
Returns list of project names from the tasks. | def get_unique_project_list(self) -> List[str]:
return self.tasks.get_project_list() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects():\n data = sql.list_projects()\n names = [(d['id'], d['name']) for d in data]\n return names",
"def getProjectNames(self):\n con = self.getMetadataDatabaseConnection()\n result = con.cursor()\n con.cursor().callproc('get_project_names', [result])\n projnames... | [
"0.74907464",
"0.7306409",
"0.7227985",
"0.70803934",
"0.70278406",
"0.68793106",
"0.6849616",
"0.6809694",
"0.675445",
"0.6740595",
"0.6733592",
"0.6697811",
"0.6686038",
"0.66624755",
"0.6633826",
"0.66166234",
"0.66079336",
"0.6595606",
"0.65875524",
"0.6575735",
"0.656158... | 0.8331013 | 0 |
Returns list of due_date strings from the tasks. | def __get_unique_due_date_list(self) -> List[str]:
return self.tasks.get_due_date_list() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, due_date):\n try:\n tasks = tasks_by_due_date(get_db(), date.fromisoformat(due_date))\n return list(map(task_to_dict, tasks))\n except ValueError:\n api.abort(422, \"Invalid Date\")",
"def get(self):\n try:\n tasks = tasks_overdue(get... | [
"0.71177363",
"0.6910078",
"0.6393227",
"0.62248355",
"0.6204708",
"0.613299",
"0.6092391",
"0.60636747",
"0.58547604",
"0.58399415",
"0.58160484",
"0.5789354",
"0.5771243",
"0.5749997",
"0.5652659",
"0.5627289",
"0.56259596",
"0.5615194",
"0.5611514",
"0.56003356",
"0.558806... | 0.84577 | 0 |
Test basic Treant init | def test_init(self, treant, tmpdir):
assert treant.name == self.treantname
assert treant.location == tmpdir.strpath
assert treant.treanttype == self.treanttype
assert treant.abspath == (os.path.join(tmpdir.strpath,
self.treantname) + os.sep)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n\r\n self.tree = DndParser(StringIO(TEST_TREE), constructor=PhyloNode)",
"def test_init(self):\r\n p = TreeBuilder({})\r\n self.assertEqual(p.Name, 'TreeBuilder')\r\n self.assertEqual(p.Params, {})",
"def test_T0():",
"def test_init(self):\n xtal_model_d... | [
"0.6599072",
"0.6426812",
"0.6373637",
"0.6294346",
"0.6243723",
"0.6226852",
"0.6184305",
"0.6119979",
"0.61037016",
"0.61037016",
"0.60974133",
"0.6073882",
"0.607233",
"0.6069253",
"0.6066963",
"0.60555035",
"0.60550135",
"0.60500324",
"0.6049526",
"0.6046453",
"0.60438067... | 0.79635894 | 0 |
Test the variety of ways we can generate a new Treant 1. ``Treant('treant')``, where 'treant' is not an existing file or directory path 2. ``Treant('treant')``, where 'treant' is an existing directory without Treant state files inside 3. ``Treant('/somedir/treant')``, where 'treant' is not an existing file or directory... | def test_gen_methods(self, tmpdir, treantclass):
with tmpdir.as_cwd():
# 1
t1 = treantclass('newone')
assert os.path.exists(t1.filepath)
# 2
os.mkdir('another')
t2 = treantclass('another')
assert os.path.exists(t2.filepath)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_noregen(self, tmpdir, treantclass):\n with tmpdir.as_cwd():\n # 1\n t1 = treantclass('newone')\n t2 = treantclass('newone', new=True)\n assert t1.uuid != t2.uuid\n\n with pytest.raises(dtr.treants.MultipleTreantsError):\n t3 = tr... | [
"0.72016335",
"0.6978772",
"0.6545394",
"0.5855711",
"0.5795792",
"0.5741578",
"0.5717387",
"0.5712861",
"0.5698848",
"0.55889666",
"0.5584871",
"0.5394674",
"0.5370587",
"0.5350077",
"0.5317703",
"0.52627647",
"0.520542",
"0.51556545",
"0.5151814",
"0.51469076",
"0.50805426"... | 0.743853 | 0 |
Test a variety of ways that generation of a new Treant should fail. 1. `Treant('somedir/treant')` should raise `MultipleTreantsError` if more than one state file is in the given directory | def test_noregen(self, tmpdir, treantclass):
with tmpdir.as_cwd():
# 1
t1 = treantclass('newone')
t2 = treantclass('newone', new=True)
assert t1.uuid != t2.uuid
with pytest.raises(dtr.treants.MultipleTreantsError):
t3 = treantclass('ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init(self, treant, tmpdir):\n assert treant.name == self.treantname\n assert treant.location == tmpdir.strpath\n assert treant.treanttype == self.treanttype\n assert treant.abspath == (os.path.join(tmpdir.strpath,\n self.treantname)... | [
"0.60381055",
"0.599281",
"0.5979761",
"0.5929113",
"0.5919436",
"0.58588606",
"0.58527654",
"0.58287495",
"0.57682323",
"0.5753016",
"0.57425493",
"0.56523967",
"0.56501704",
"0.5647308",
"0.56395644",
"0.5619321",
"0.55897903",
"0.55862457",
"0.5579676",
"0.557584",
"0.5571... | 0.7305239 | 0 |
Test the comparison of Treants when sorting | def test_cmp(self, tmpdir, treantclass):
with tmpdir.as_cwd():
c1 = treantclass('a')
c2 = treantclass('b')
c3 = treantclass('c')
assert sorted([c3, c2, c1]) == [c1, c2, c3]
assert c1 <= c2 < c3
assert c3 >= c2 > c1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testSorting(self):\n if self.sorting in tools.SORTINGS:\n self.assertEqual(\n self.sorting,\n self.config.sorting\n )\n else:\n self.assertNotEqual(\n self.sorting,\n self.config.sorting\n )\n ... | [
"0.64171344",
"0.64019907",
"0.63461435",
"0.6286553",
"0.6282336",
"0.6196637",
"0.6167226",
"0.6084763",
"0.60635316",
"0.605794",
"0.6034905",
"0.6029929",
"0.6017265",
"0.6001104",
"0.5999717",
"0.59973514",
"0.5987992",
"0.59710693",
"0.59631217",
"0.59438115",
"0.592403... | 0.69490385 | 0 |
Setting a category to ``None`` should not change the value. | def test_None_no_change(self, treant):
treant.categories['bark'] = 'smooth'
treant.categories['bark'] = None
assert treant.categories['bark'] == 'smooth'
treant.categories.add(bark=None)
assert treant.categories['bark'] == 'smooth' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_default_value(self):\n categories = {\"asdfa\": 0.1, 2: 0.2, 3: 0.3, \"lalala\": 0.4}\n dim = Categorical(\"yolo\", categories)\n assert dim.default_value is None",
"def _set_None(self):\n\n self.description = None\n self.func = None",
"def test_get_none(self):\n ... | [
"0.64149475",
"0.6200565",
"0.59799516",
"0.59799516",
"0.59398645",
"0.5913836",
"0.5879109",
"0.5812705",
"0.56973296",
"0.5644126",
"0.56387496",
"0.55984664",
"0.55858207",
"0.55858207",
"0.55858207",
"0.55858207",
"0.55858207",
"0.5580078",
"0.55675083",
"0.5545346",
"0.... | 0.7339946 | 0 |
Test that a readonly Treant can be accessed, but not written to. | def test_treant_read_only(self, treant):
c = dtr.treants.Treant(treant.filepath)
assert '72' in c.tags
with pytest.raises(OSError):
c.tags.add('yet another') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_read_only():\n t = Tree(None)\n with pytest.raises(AttributeError):\n t.data = 0",
"def test_get_node_state_readonly(self):\n pass",
"def test_update_node_state_readonly(self):\n pass",
"def IsReadOnly(self) -> bool:",
"def isReadOnly(self) -> bool:\n ...",
... | [
"0.7563677",
"0.7381614",
"0.7153244",
"0.64748025",
"0.64352864",
"0.64352864",
"0.64264363",
"0.6400511",
"0.62610245",
"0.61271405",
"0.6115995",
"0.60951144",
"0.6023646",
"0.5964316",
"0.59242225",
"0.59242225",
"0.585599",
"0.585599",
"0.58400774",
"0.5836763",
"0.58246... | 0.74954784 | 1 |
Test that Group can access members when the Group is readonly. | def test_group_member_access(self, group):
assert len(group.members) == 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_access_levels(self):\n resource_id = 'protected-data'\n arn_prefix = \"arn:dcp:fus:us-east-1:dev:\"\n user = 'user_test_access_levels'\n group = 'group_test_access_levels'\n\n # create the resource to control\n resp = self.app.post(\n f'/v1/resource/{se... | [
"0.68453103",
"0.67862797",
"0.6601197",
"0.65803045",
"0.65372676",
"0.64127195",
"0.63970155",
"0.63799375",
"0.63446563",
"0.6307491",
"0.6302089",
"0.6301567",
"0.6300017",
"0.6294212",
"0.62863517",
"0.62780446",
"0.62339777",
"0.6223893",
"0.6200065",
"0.6097351",
"0.60... | 0.7663207 | 0 |
Reads file and adds users from info found therein. | def add_users_from_file(args):
with open(args.users_from_file) as file:
for line in file:
name, email_address = line.split(',')
add_user(name, email_address.strip().lower()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_all():\n with open(User.get_users_path(), encoding='utf8') as file:\n for line in file:\n username, pw_hash, email, name, level = line.strip().split(';')\n level = int(level)\n user = User.from_file(username)\n# userfile = User.... | [
"0.7879125",
"0.7133883",
"0.70680463",
"0.697859",
"0.68746567",
"0.6759337",
"0.6704905",
"0.66616327",
"0.66397035",
"0.6615441",
"0.64673185",
"0.6450946",
"0.6375819",
"0.6334819",
"0.6320263",
"0.6309807",
"0.6224747",
"0.6217894",
"0.6202408",
"0.6191679",
"0.61768013"... | 0.7916668 | 0 |
returns the family id | def get_family_id(self):
return self._family_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def family_id(self):\n\n return self._family_id",
"def get_family_id(self):\n # Implemented from template for osid.resource.ResourceLookupSession.get_bin_id\n return self._catalog_id",
"def get_family_id(self):\n # Implemented from template for osid.resource.ResourceLookupSession.ge... | [
"0.8668898",
"0.76729614",
"0.76729614",
"0.76729614",
"0.7451965",
"0.70795184",
"0.70795184",
"0.70795184",
"0.69636923",
"0.69379437",
"0.6931943",
"0.6931943",
"0.6929808",
"0.69207877",
"0.6893346",
"0.6843812",
"0.67588395",
"0.67588395",
"0.66772735",
"0.6542837",
"0.6... | 0.8803874 | 0 |
add a single child id | def add_child(self, child_id):
self._children.append(child_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_child(self, child):\n name = child.name\n self._children[name] = child\n self._name_dict[name.split('-')[0]] += 1",
"def insert(self, parent, name):\n pid = self.db.insert_returning_id('simple', dict(parent=parent, name=name))\n return pid",
"def add_child(self, pid):... | [
"0.67771375",
"0.67239463",
"0.6646781",
"0.66223174",
"0.65858465",
"0.64711475",
"0.64099675",
"0.63824654",
"0.634989",
"0.6345633",
"0.63180256",
"0.62917775",
"0.627123",
"0.6227966",
"0.6157923",
"0.6157923",
"0.612921",
"0.6119924",
"0.6099184",
"0.6093017",
"0.6090446... | 0.68644553 | 0 |
Create and return a listening TLS socket on a given address. | def create_listening_ssl_socket(address, certfile, keyfile):
# check if 2 files exist. If not, raise exceptions
if os.path.isfile(certfile) and os.path.isfile(keyfile):
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.options |= (
ssl.OP_NO_TLSv1 | s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_socket(host, port):\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n s.settimeout(300)\n while True:\n try:\n s.connect( (host, int(port)) )\n except:\n s.shutdown(socket.SHUT_RDWR)\n s.close()\n time.sleep(1)\n else:\n ... | [
"0.701491",
"0.6868728",
"0.68399423",
"0.6784247",
"0.6681144",
"0.66220903",
"0.6562696",
"0.63992184",
"0.6391871",
"0.63498175",
"0.6340781",
"0.6259616",
"0.6205906",
"0.6203364",
"0.62015766",
"0.6196381",
"0.61861056",
"0.615563",
"0.61325216",
"0.6089246",
"0.6080461"... | 0.69605416 | 1 |
Returns the loss weights for the given mode. The weights are normalized to sum to one. | def get_loss_weights(n: int, mode: Optional[str]) -> np.ndarray:
# Construct the weights
if mode is None or not isinstance(mode, str):
weights = np.ones(shape=(n, ))
elif mode.lower() == 'linear':
weights = np.linspace(start=1, stop=n, num=n, endpoint=True)
elif mode.lower() == 'quadrati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_weights(self):\n return None",
"def _get_loss_weight(self) -> torch.Tensor:\n n_pos: torch.Tensor = 0.0\n n_neg: torch.Tensor = 0.0\n\n for _, ground_truth in self.train_loader:\n n_poss_curr = ground_truth.sum()\n n_pos += n_poss_curr\n n_neg... | [
"0.7242148",
"0.67020047",
"0.63229626",
"0.6176248",
"0.61701304",
"0.61701304",
"0.61701304",
"0.61701304",
"0.6167755",
"0.6166871",
"0.6135705",
"0.6089235",
"0.6068443",
"0.6065923",
"0.6065923",
"0.6064304",
"0.6064304",
"0.6064304",
"0.60554934",
"0.6049718",
"0.603735... | 0.7819412 | 0 |
The username gets added to the requestContext when the authorizer runs. | def get_username(request: Request) -> str:
return request.scope["aws.event"]["requestContext"]["authorizer"]["username"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_username(self, request):\r\n try:\r\n return request.user.username\r\n except AttributeError:\r\n return ''",
"def auth_username(self, auth_username):\n\n self._auth_username = auth_username",
"def get_username(self):\r\n return self.username",
"def u... | [
"0.70503217",
"0.6913045",
"0.66467226",
"0.66452754",
"0.6557163",
"0.6557163",
"0.6557163",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.6538145",
"0.65086454",
"0.6503406",
"0.6492756",
"0.6451262",
"0.64256054"... | 0.72729677 | 0 |
Decorator that validates incoming requests using the provided swagger spec | def swagger_validate(f):
@wraps(f)
def swagger_validated_function(*args, **kwargs):
converted_uri = request.path
# convert /pet/mypetsid to /pet/{petId}
for key, value in request.view_args.items():
target = '{{{0}}}'.format(key)
converted_uri = converted_uri.repla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_validation(schema):\n def decorator(function):\n @wraps(function)\n def wrapper(*args, **kwargs):\n data = {}\n if request.method in ['POST', 'PATCH', 'PUT']:\n data = request.get_json(force=True)\n elif request.method in ['GET', 'DELETE']... | [
"0.6865928",
"0.6810045",
"0.6759758",
"0.6698567",
"0.66800046",
"0.66577315",
"0.6459967",
"0.62118506",
"0.62097496",
"0.6128788",
"0.60941267",
"0.6089975",
"0.6072779",
"0.6016448",
"0.5995236",
"0.59504074",
"0.59334654",
"0.59204024",
"0.587783",
"0.58687794",
"0.57752... | 0.82377815 | 0 |
A version of the standard mock_open that only mocks when filepattern matches the given pattern. | def fp_mock_open(filepattern='.*', **kwargs):
mo_obj = mock_open(**kwargs)
filepattern = filepattern.rstrip("$") + '$'
# capture open() in a closure now before any patching can happen
real_open = open
def new_call(filename, *args, **kwargs):
if not re.match(filepattern, filename):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_open_f(fname, **_):\n # Return the mocked file on full match\n if fname in files_dict:\n logger.debug(\"patch_yaml_files match %s\", fname)\n res = StringIO(files_dict[fname])\n setattr(res, \"name\", fname)\n return res\n\n # Match using en... | [
"0.7159996",
"0.65915257",
"0.5888818",
"0.5843505",
"0.5794006",
"0.5781652",
"0.57481414",
"0.56930566",
"0.56635827",
"0.56248444",
"0.5619262",
"0.5548096",
"0.5541527",
"0.55311066",
"0.5518296",
"0.5473773",
"0.5458357",
"0.54063696",
"0.5370915",
"0.53583825",
"0.53429... | 0.85847664 | 0 |
Twolayer NPTN as described in the paper. out_channels and num_transforms refer to the first layer only. | def two_layer_nptn(x, num_classes=10, out_channels=48, num_transforms=1):
with tf.variable_scope('nptn_1'):
x = nptn_layer(x, 3, 3, out_channels, num_transforms)
x = tf.layers.batch_normalization(x)
x = parametric_relu(x)
x = tf.layers.max_pooling2d(x, (2, 2), 2)
with tf.variabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nptn_layer(input, kernel_size, in_channels, out_channels, num_transforms):\n assert len(input.shape) == 4\n\n filter_shape = (kernel_size, kernel_size, in_channels,\n out_channels * num_transforms)\n filter = tf.get_variable('weights', filter_shape, dtype=input.dtype)\n bias = tf... | [
"0.67367357",
"0.57352144",
"0.56979936",
"0.56967825",
"0.5668742",
"0.5588165",
"0.55659705",
"0.5548545",
"0.5547123",
"0.55060697",
"0.5501692",
"0.5468197",
"0.5446166",
"0.5425245",
"0.5420839",
"0.5418289",
"0.5409266",
"0.5403939",
"0.5401453",
"0.5381876",
"0.5373465... | 0.7447827 | 0 |
The ShuffleBag constructor accepts an arbitrary number of parameters. Initialize the ShuffleBag by providing tuples of itemscount's. Each itemcount tuple represents an item we want to | def __init__(self, *args):
self.bag = []
# Each item in 'args' is a tuple, we can assign each item in
# the tuple directly to a variable name in our loop. Here we
# assign the first item in each tuple to the variable named
# 'item' and we assign the second item in each tuple to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def baskets(items, count):\n _baskets = [[] for _ in range(count)]\n for i, item in enumerate(items):\n _baskets[i % count].append(item)\n return list(filter(None, _baskets))",
"def generatesack(nmbrofitems):\n while nmbrofitems != 0:\n newitem = Sackitem(random.randint(1,10),random.ran... | [
"0.60249996",
"0.58913267",
"0.58240587",
"0.56716937",
"0.5632874",
"0.5559852",
"0.55549103",
"0.54421496",
"0.54417074",
"0.5407714",
"0.5406237",
"0.53914803",
"0.53490365",
"0.5340191",
"0.53170216",
"0.5316131",
"0.53105706",
"0.5278412",
"0.52594",
"0.52425754",
"0.523... | 0.7325171 | 0 |
Get the next random item from our bag Automatically reshuffles once all previously randomized items have been selected from. | def next(self):
# The contents of self.bag have already been randomized so the
# next item is always the item at our current position.
next_item = self.bag[self.pos]
# Each time an item is selected we decrement our position
# until we finally arrive back at the beginning of the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Choose(self):\n lst = [x for x in self.bag.keys()]\n choice = random.choices(lst, k=1)[0]\n self.bag.update({choice : self.bag.get(choice) - 1})\n return(choice)",
"def next_item(self):\n self.recent_box = np.random.multinomial(1, self.dist_boxes).argmax()\n \n ... | [
"0.742434",
"0.70814496",
"0.68981713",
"0.6854162",
"0.6783028",
"0.67663664",
"0.6713778",
"0.66755927",
"0.6669434",
"0.6626496",
"0.66090435",
"0.6597135",
"0.6521952",
"0.6510127",
"0.6467735",
"0.63979405",
"0.6392224",
"0.63809824",
"0.63791627",
"0.6349567",
"0.633880... | 0.77953297 | 0 |
Delete a route in csv file | def deleteroute(self, new_route):
route_key = new_route.replace('-', ',')
error, exists, message, code, lines = self.selectroute(route_key)
if error or not exists:
return False, message, code
else:
error, message, code = self.commandroute('Delete', lines, route_ke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_delete_emp():\n\twhile True:\n\t\ttry:\n\t\t\tfile_path = input(\"Enter the path of your file or enter 'quit' to go back to menu.\\n File Path: \")\n\t\texcept FileNotFoundError:\n\t\t\tprint(\"File Not Found Error.\")\n\t\t\tcontinue\n\t\tif file_path == \"quit\":\n\t\t\treturn\n\t\telif not os.path.exis... | [
"0.63496786",
"0.6288668",
"0.6283921",
"0.623299",
"0.621573",
"0.6144322",
"0.6065442",
"0.6021136",
"0.601586",
"0.59728646",
"0.5969066",
"0.5941977",
"0.58966523",
"0.58565456",
"0.5852467",
"0.5792653",
"0.5791504",
"0.5704627",
"0.56954354",
"0.56462485",
"0.562099",
... | 0.65340215 | 0 |
A utility method for parsing token keyword arguments. | def token_kwargs(bits, parser, support_legacy=False):
if not bits:
return {}
match = kwarg_re.match(bits[0])
kwarg_format = match and match.group(1)
if not kwarg_format:
if not support_legacy:
return {}
if len(bits) < 3 or bits[1] != 'as':
return {}
k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_kwargs(bits, parser):\r\n if not bits:\r\n return {}\r\n kwargs = SortedDict()\r\n while bits:\r\n match = kwarg_re.match(bits[0])\r\n if not match or not match.group(1):\r\n return kwargs\r\n key, value = match.groups()\r\n del bits[:1]\r\n k... | [
"0.6858736",
"0.65743685",
"0.65157807",
"0.6488571",
"0.6254719",
"0.623518",
"0.60444295",
"0.59977835",
"0.5971349",
"0.5943965",
"0.59420085",
"0.5881135",
"0.58578956",
"0.5810159",
"0.5787497",
"0.5712456",
"0.5669264",
"0.5660733",
"0.56607217",
"0.5653276",
"0.5648537... | 0.66773784 | 1 |
Parses bits for template tag helpers (simple_tag, include_tag and assignment_tag), in particular by detecting syntax errors and by extracting positional and keyword arguments. | def parse_bits(parser, bits, params, varargs, varkw, defaults,
takes_context, name):
if takes_context:
if params[0] == 'context':
params = params[1:]
else:
raise TemplateSyntaxError(
"'%s' is decorated with takes_context=True so it must "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_tags_for_model(parser, token):\r\n bits = token.contents.split()\r\n len_bits = len(bits)\r\n if len_bits not in (4, 6):\r\n raise TemplateSyntaxError(_('%s tag requires either three or five arguments') % bits[0])\r\n if bits[2] != 'as':\r\n raise TemplateSyntaxError(_(\"second arg... | [
"0.57488596",
"0.5737454",
"0.5638623",
"0.55657476",
"0.5519191",
"0.53449297",
"0.53199315",
"0.53199315",
"0.5303536",
"0.5292785",
"0.52452683",
"0.5226292",
"0.52253306",
"0.5222468",
"0.52098155",
"0.52042407",
"0.51535916",
"0.5143653",
"0.5140168",
"0.51205957",
"0.51... | 0.59634084 | 0 |
Request package lists from the storage service. Package lists will contain details of the AIPs that we want to download. | def package_lists_request(self, apiUrl, timestamp, packages_directory):
META = "meta"
NEXT = "next"
LIMIT = "limit"
COUNT = "total_count"
IN_PROGRESS = "IN PROGRESS"
(
base_url,
request_url_without_api_key,
request_url,
) = format_api_url_with_limit_offset(apiUrl)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPackages(self):\n cat = getToolByName(self.context, 'portal_catalog')\n ideeSejour = getattr(self.context, 'idee-sejour')\n url = '/'.join(ideeSejour.getPhysicalPath())\n contentFilter = {}\n path = {}\n path['query'] = url\n path['depth'] = 1\n conten... | [
"0.6325941",
"0.61709034",
"0.6110309",
"0.6110068",
"0.6019527",
"0.59549713",
"0.59013885",
"0.5772765",
"0.5744429",
"0.57390606",
"0.57223964",
"0.57007676",
"0.56096125",
"0.5591694",
"0.55876523",
"0.5547729",
"0.5532049",
"0.5525446",
"0.5517884",
"0.54909605",
"0.5458... | 0.62853605 | 1 |
Request METS XML file from the storage service and parse. Download a METS file from an AIP that is stored in the storage service and then parse the results into the AIPscan database. This function relies on being able to use metsreaderwriter which is the primary object we will be passing about. | def get_mets(
package_uuid,
relative_path_to_mets,
api_url,
timestamp_str,
package_list_no,
storage_service_id,
storage_location_id,
origin_pipeline_id,
fetch_job_id,
):
download_file = download_mets(
api_url, package_uuid, relative_path_to_mets, timestamp_str, package_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_mets_with_metsrw(mets_file):\n try:\n mets = metsrw.METSDocument.fromfile(mets_file)\n except AttributeError as err:\n # See archivematica/issues#1129 where METSRW expects a certain\n # METS structure but Archivematica has written it incorrectly.\n err = \"{}: {}\".forma... | [
"0.58833987",
"0.5729579",
"0.52889115",
"0.5267423",
"0.5027156",
"0.49360585",
"0.49152625",
"0.48964554",
"0.48772672",
"0.48520353",
"0.48085588",
"0.47513145",
"0.4742343",
"0.4729083",
"0.47278604",
"0.46892235",
"0.46876562",
"0.46588516",
"0.46445543",
"0.45911303",
"... | 0.63453954 | 0 |
Extract a set of ngrams from a list of integers. | def create_ngram_set(input_list, ngram_value=2):
return set(zip(*[input_list[i:] for i in range(ngram_value)])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_ngram_set(input_list, ngram_value=2):\n return set(zip(*[input_list[i:] for i in range(ngram_value)]))",
"def find_ngrams(input_list, n=3):\n return zip(*[input_list[i:] for i in range(n)])",
"def create_ngram_set(self, input_list, ngram_value=2):\n return set(zip(*[input_list[i:] f... | [
"0.76989484",
"0.7478928",
"0.74681896",
"0.7228818",
"0.71772516",
"0.7038002",
"0.6977662",
"0.6938288",
"0.6829033",
"0.6759564",
"0.6719",
"0.66278785",
"0.66258675",
"0.65890974",
"0.6534543",
"0.65252674",
"0.64583546",
"0.6402734",
"0.63953984",
"0.6389275",
"0.6377588... | 0.7822425 | 0 |
Augment the input list of list (sequences) by appending ngrams values. | def add_ngram(sequences, token_indice, ngram_range=2):
new_sequences = []
for input_list in sequences:
new_list = input_list[:]
for ngram_value in range(2, ngram_range + 1):
for i in range(len(new_list) - ngram_value + 1):
ngram = tuple(new_list[i:i + ngram_value])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_ngram(sequences, token_indice, ngram_range=2):\n new_sequences = []\n for input_list in sequences:\n new_list = input_list[:]\n for ngram_value in range(2, ngram_range + 1):\n for i in range(len(new_list) - ngram_value + 1):\n ngram = tu... | [
"0.7456609",
"0.740691",
"0.7316882",
"0.63946664",
"0.6229141",
"0.62036645",
"0.6144797",
"0.59809494",
"0.5973278",
"0.5964258",
"0.5932551",
"0.5929449",
"0.58704007",
"0.58352613",
"0.58208406",
"0.58001685",
"0.57981306",
"0.5784745",
"0.57427156",
"0.5742448",
"0.57222... | 0.7426375 | 1 |
Default curvature is convex. | def func_curvature(self):
return u.Curvature.CONVEX | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def curvature(self):\n return self.circle().curvature(self.o, self.r, p = self.a)",
"def set_curvature(self, f_convex=0):\n self.F_CONVEX = f_convex",
"def convex(self, *args, **kwargs) -> Any:\n pass",
"def curvature(self):\n if self.x[0] == self.x[-1] and self.y[0] == self.y[-1]... | [
"0.74688697",
"0.7462474",
"0.72098196",
"0.7006293",
"0.6957008",
"0.6773553",
"0.67535996",
"0.6722736",
"0.67056644",
"0.66013193",
"0.65752554",
"0.65729827",
"0.63231677",
"0.62764686",
"0.62578213",
"0.6220555",
"0.61711574",
"0.6158542",
"0.61263645",
"0.6113366",
"0.6... | 0.82958746 | 0 |
Set the sensitivity of the AddButton depends on the AccountConfig. | def _on_account_config_changed(self, _, state: bool):
if state:
self.add_button.grab_default()
self.add_button.set_sensitive(state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable(self): \n self.feed_button.config(state=\"normal\")\n self.eat_button.config(state=\"normal\") \n for t in range(self.player.game.trait_limit): \n self.add_trait_buttons[t].config(state=\"normal\") \n self.add_population_button.config(s... | [
"0.54773664",
"0.53105736",
"0.51178366",
"0.50574803",
"0.5017042",
"0.49711785",
"0.49711785",
"0.49711785",
"0.49711785",
"0.4931563",
"0.4914064",
"0.49018964",
"0.4901295",
"0.4885883",
"0.4840759",
"0.4840654",
"0.48240182",
"0.48174897",
"0.48004106",
"0.47915936",
"0.... | 0.6999704 | 0 |
Get all recipe names for a given recipe_type | def get_recipes_by_type(self, recipe_type):
if (recipe_type in self.recipe_list):
for item in self.recipe_list[recipe_type]:
print(item.name + " ", end='')
print() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_recipes_by_types(self, recipe_type):\n if recipe_type not in self.recipe_list.keys():\n sys.stderr.write(UKN_TYP.format(recipe_type))\n raise KeyError\n return [r.name for r in self.recipe_list[recipe_type]]",
"def get_recipes_by_types(self, recipe_type): \n\t\tfor key... | [
"0.87046784",
"0.78575134",
"0.60613257",
"0.5926502",
"0.5911596",
"0.5784762",
"0.57654727",
"0.5693117",
"0.5665932",
"0.561807",
"0.55705935",
"0.5569196",
"0.5518742",
"0.54930437",
"0.54705566",
"0.5408921",
"0.5384791",
"0.5370821",
"0.53666055",
"0.5360897",
"0.532331... | 0.81245553 | 1 |
Add a recipe to the book and update last_update | def add_recipe(self, recipe):
self.recipe_list[recipe.recipe_type].append(recipe)
self.last_update = datetime.now | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_recipe(self, recipe):\n if not isinstance(recipe, Recipe):\n raise TypeError(\"Object {0} is not a recipe.\".format(type(recipe)))\n else:\n self.last_update = datetime.now()\n self.recipe_list[recipe.recipe_type].append(recipe)",
"def set_recipe(self, recip... | [
"0.68380475",
"0.6759233",
"0.65852773",
"0.59952736",
"0.5942158",
"0.5918344",
"0.5897957",
"0.58793384",
"0.5851835",
"0.58261883",
"0.58108413",
"0.57993954",
"0.578886",
"0.57745844",
"0.57408506",
"0.56967485",
"0.56599766",
"0.5641641",
"0.56262285",
"0.56114924",
"0.5... | 0.7315263 | 0 |
computes the synapse loss of a projection | def projectionwise_synapse_loss(self, proj, marocco):
orig_weights = proj.getWeights(format='array')
mapped_weights = marocco.stats.getWeights(proj)
syns = np.where(~np.isnan(orig_weights))
realized_syns = np.where(~np.isnan(mapped_weights))
orig = len(syns[0])
realized =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_reprojection_loss(self, pred, target):\n \n abs_diff = torch.abs(target - pred)\n l1_loss = abs_diff.mean(1, True)\n\n ssim_loss = self.ssim(pred, target).mean(1, True)\n \n# photometric error function pe\n \n reprojection_loss = 0.85 * ssim_loss + 0.15 ... | [
"0.68540245",
"0.67980486",
"0.6720597",
"0.6630273",
"0.6628562",
"0.66196245",
"0.6613643",
"0.6494649",
"0.6427868",
"0.6420529",
"0.63347983",
"0.6318105",
"0.6311914",
"0.6251796",
"0.6184851",
"0.6157289",
"0.61205316",
"0.6109993",
"0.6086552",
"0.60584813",
"0.6058459... | 0.7359748 | 0 |
Search for a vertex in the 2nd position of List(int, str) and return index. | def search_vertex(ls, vertex):
for idx in range(len(ls)):
if ls[idx][1] == vertex:
return idx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_vertices(vertexlist, graph):\n return_list = list()\n for vertex in vertexlist:\n return_list.append(graph.vs.find(name=vertex).index)\n return return_list",
"def find_vertex_index(graph, uri_str, brackets=False):\n\tif brackets:\n\t\turi_str = '<'+uri_str+'>'\n\n\ttry:\n\t\treturn grap... | [
"0.6945676",
"0.67291117",
"0.63841534",
"0.6382502",
"0.63806105",
"0.6175287",
"0.609422",
"0.6090202",
"0.6087574",
"0.6026152",
"0.6013369",
"0.6009101",
"0.60074645",
"0.60070634",
"0.59980595",
"0.5997357",
"0.59782416",
"0.59773296",
"0.5972704",
"0.5972371",
"0.596567... | 0.82055616 | 0 |
Implementation of Dijkstra's single source shortest path using the Heap data structure. Reduced time complexity from O(mn), where n is the number of vertices and m is the number of edges; to O((m+n) logn) | def dijkstra_heap(graph, source_vertex):
x = set()
heap = []
shortest_key = {source_vertex: 0}
heapq.heappush(heap, (0, source_vertex))
for v in graph.keys():
if v != source_vertex:
shortest_key[v] = float('inf')
heapq.heappush(heap, (float('inf'), v))
while hea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dijkstra(self, src):\n unvisited = MinHeap() \n visited = set()\n dist = []\n for v_id in range(0, self.v):\n if v_id != src:\n dist.append(sys.maxsize)\n unvisited.insert((sys.maxsize, v_id))\n else:\n unvisi... | [
"0.7673448",
"0.764781",
"0.7550312",
"0.7496649",
"0.74511784",
"0.7408023",
"0.73920304",
"0.7297488",
"0.71974826",
"0.7112031",
"0.70883447",
"0.70692307",
"0.7026926",
"0.69953686",
"0.6986602",
"0.69828784",
"0.69611603",
"0.6925294",
"0.69137615",
"0.68880713",
"0.6884... | 0.7708882 | 0 |
As different modalities are not oriented in the same space when converted and as fslorient2std affects only the sform and not the qform. 1) apply fslorient2std 2) set translational part to zero 3) use nibabel to set the sform as the qform | def orient2std(pfi_in, pfi_out, keep_translation=True):
# assert os.path.exists(pfi_in)
# pfi_intermediate = os.path.join(os.path.dirname(pfi_out), 'zz_tmp_' + os.path.basename(pfi_in))
# # 1 --
# cmd0 = 'fslreorient2std {0} {1}'.format(pfi_in, pfi_intermediate)
# print_and_run(cmd0)
# # 2 --
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rectify_header_sform_qform(img_nii):\n d = img_nii.header[\"dim\"][0]\n pixdim = np.asarray(img_nii.header.get_zooms())[:d]\n sform, qform = img_nii.get_sform(), img_nii.get_qform()\n norm_sform = affine_to_spacing(sform, r=d)\n norm_qform = affine_to_spacing(qform, r=d)\n sform_mismatch = no... | [
"0.56340766",
"0.5552576",
"0.5393118",
"0.53499824",
"0.5334968",
"0.5317745",
"0.5317373",
"0.5241254",
"0.5147726",
"0.51464725",
"0.5137515",
"0.5123962",
"0.50710905",
"0.5070234",
"0.50646394",
"0.5026007",
"0.50017285",
"0.4991581",
"0.49753067",
"0.49660143",
"0.49614... | 0.6171053 | 0 |
Retrieve the depth for the given pair. Returns a tuple (asks, bids); each of these is a list of (price, volume) tuples. | def getDepth(session=None):
depth = get_data('depth', requests_session=session).json()
if not isinstance(depth, dict):
raise TypeError("The response is not a dict.")
if not isinstance(depth.get('sell'), list):
raise TypeError("The response does not contain an asks list.")
if not isinsta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_level(self, typ, price):\r\n lst = {\"ask\": self.asks, \"bid\": self.bids}[typ]\r\n comp = {\"ask\": lambda x, y: x < y, \"bid\": lambda x, y: x > y}[typ]\r\n low = 0\r\n high = len(lst)\r\n\r\n # binary search\r\n while low < high:\r\n mid = (low + h... | [
"0.5834912",
"0.56560266",
"0.5556811",
"0.55232126",
"0.54120165",
"0.537693",
"0.51835144",
"0.51666456",
"0.5100785",
"0.50309825",
"0.49039283",
"0.4863811",
"0.482422",
"0.48202473",
"0.48064035",
"0.4802574",
"0.47942957",
"0.47936392",
"0.47814223",
"0.4779255",
"0.477... | 0.64202404 | 0 |
create RiskSLIM MIP object | def create_risk_slim(input):
assert 'coef_set' in input, 'input is missing coef_set'
P = len(input['coef_set'])
# setup printing and loading
function_print_flag = input['print_flag'] if 'print_flag' in input else False
print_from_function = lambda msg: print_log(msg) if function_print_flag else la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: VpcIpamPoolArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def createRotoNodeMI():\n return gs()",
"def __init__(__self__, *,\n cidr: pulumi.Input[str],\n ... | [
"0.57169443",
"0.54935175",
"0.5459325",
"0.54075986",
"0.5400031",
"0.53792804",
"0.5355474",
"0.5321274",
"0.5289824",
"0.5282277",
"0.5275696",
"0.52704775",
"0.5260886",
"0.5239818",
"0.5238467",
"0.52272254",
"0.51834756",
"0.5177146",
"0.5176517",
"0.5174048",
"0.516651... | 0.65285146 | 0 |
Convert coefficient vector 'rho' into a solution for RiskSLIM CPLEX MIP | def convert_to_risk_slim_cplex_solution(rho, indices, loss=None, objval=None):
solution_idx = range(0, indices['n_variables'])
solution_val = np.zeros(indices['n_variables'])
# rho
solution_val[indices['rho']] = rho
# alpha
alpha = np.zeros(len(indices['alpha']))
alpha[np.flatnonzero(rho[i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __rho2v(self, vm, beta, rhoc, w, rho):\n if rho < 0:\n return float(vm)\n elif rho <= rhoc:\n return float(vm - vm * rho / beta)\n else:\n rhom = rhoc - (vm * rhoc - vm * (rhoc ** 2) / beta) / w\n # print('rho {0}; rhoc {1}'.format(rho, rhoc))\n ... | [
"0.6425455",
"0.6136281",
"0.6075107",
"0.5987988",
"0.5921063",
"0.58948505",
"0.58340585",
"0.5815005",
"0.5806702",
"0.57607275",
"0.573623",
"0.573623",
"0.57223886",
"0.56066144",
"0.5581213",
"0.5568523",
"0.55072504",
"0.5494078",
"0.5487261",
"0.54860395",
"0.54662186... | 0.74424803 | 0 |
Helper function to set CPLEX parameters of CPLEX MIP object | def set_cplex_mip_parameters(mip, cplex_parameters, display_cplex_progress=False):
problem_type = mip.problem_type[mip.get_problem_type()]
mip.parameters.randomseed.set(cplex_parameters['randomseed'])
mip.parameters.threads.set(cplex_parameters['n_cores'])
mip.parameters.output.clonelog.set(0)
mip.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_cplex_problem(model, num_threads=1, lpmethod=0, adv=2):\n # type: (compass.models.MetabolicModel)\n\n # Create the Problem first\n # Easier to modify existing problem and re-solve\n problem = cplex.Cplex()\n problem.set_log_stream(None) # Suppress output\n problem.set_error_stream... | [
"0.6164122",
"0.5768742",
"0.5652481",
"0.55380464",
"0.5534128",
"0.5511752",
"0.5465898",
"0.54354465",
"0.54134136",
"0.5363561",
"0.5363474",
"0.53579825",
"0.5353175",
"0.53517497",
"0.53419966",
"0.53327173",
"0.53242403",
"0.53236616",
"0.5305246",
"0.52744114",
"0.526... | 0.7699031 | 0 |
given a initial feasible solution, rho, produces an improved solution that is 1OPT (i.e. the objective value does not decrease by moving in any single dimension) at each iteration, the algorithm moves in the dimension that yields the greatest decrease in objective value the best step size is each dimension is computed ... | def discrete_descent(rho, Z, C_0, rho_ub, rho_lb, descent_dimensions=None, print_flag=False):
#print_flag = False
# initialize key variables
MAX_ITERATIONS = 500
MIN_IMPROVEMENT_PER_STEP = float(1e-10)
n_iterations = 0
P = rho.shape[0]
rho = np.require(np.require(rho, dtype=np.int_), dtype=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_descent(rho, Z, C_0, rho_ub, rho_lb, get_L0_penalty, compute_loss_from_scores, descent_dimensions = None, active_set_flag = True):\n \"\"\"\n \n \"\"\"\n assert callable(compute_loss_from_scores)\n assert callable(get_L0_penalty)\n\n # initialize key variables\n MAX_ITERATIONS = 5... | [
"0.6743748",
"0.6657099",
"0.6160385",
"0.6001702",
"0.59684205",
"0.5896244",
"0.5857873",
"0.5857873",
"0.5825519",
"0.58243793",
"0.5822577",
"0.5766945",
"0.5732598",
"0.5726821",
"0.56536394",
"0.5649663",
"0.55963314",
"0.5584035",
"0.5580361",
"0.55653274",
"0.55501056... | 0.68277067 | 0 |
finds the value of rho[j] in feasible_coef_values that minimizes log_loss(rho) + C_0j | def compute_objvals_at_dim(dim_index,
feasible_coef_values,
base_rho,
base_scores,
base_loss,
C_0):
# copy stuff because ctypes
scores = np.copy(base_scores)
# initialize ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def P_bol(j,rhoA):\n\n rho_j = rhoA[j]\n return rho_j * c0**2 * np.sqrt( 1 + (rho_j/rho0)**(4/3) )",
"def convert_to_risk_slim_cplex_solution(rho, indices, loss=None, objval=None):\n solution_idx = range(0, indices['n_variables'])\n solution_val = np.zeros(indices['n_variables'])\n\n # rho\n ... | [
"0.65310234",
"0.62829095",
"0.6058815",
"0.5960956",
"0.5918176",
"0.5790462",
"0.57894534",
"0.5714317",
"0.5696645",
"0.5694927",
"0.56927633",
"0.56864077",
"0.5677211",
"0.56683356",
"0.56644833",
"0.56557816",
"0.56422967",
"0.5613286",
"0.5590972",
"0.5574816",
"0.5569... | 0.63221544 | 1 |
runs DCD polishing for all solutions in the a solution pool can be stopped early using max_runtime or max_solutions | def discrete_descent_solution_pool(pool,
Z,
C_0,
constraints,
max_runtime=float('inf'),
max_solutions=float('inf')):
# quick return
if l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ccg_algo(dir:str, tol: float, gamma: int, pv_min: np.array, pv_max: np.array, engagement: np.array, solver_param: dict, day:str, log:bool=False, printconsole:bool=False, warm_start:bool=False, M_neg:float=None):\n\n # Compute the maximal deviation between the max and min PV uncertainty set bounds\n max_d... | [
"0.6022789",
"0.58565557",
"0.5757754",
"0.5713914",
"0.56298095",
"0.5623495",
"0.5618828",
"0.56145066",
"0.5593574",
"0.55354154",
"0.55244654",
"0.55019087",
"0.5490933",
"0.5488504",
"0.54834783",
"0.54765904",
"0.5462353",
"0.5445008",
"0.5390179",
"0.5381186",
"0.53692... | 0.6562362 | 0 |
Data dependent initialization for eager execution | def _data_dep_init(self, inputs):
from tensorflow.python.ops.nn import moments
from tensorflow.python.ops.math_ops import sqrt
with variable_scope.variable_scope('data_dep_init'):
# Generate data dependent init values
activation = self.layer.activation
self.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.args = self._prepare_args(locals())\n self.requires_full_dataset_in_memory = False",
"def __init__(self, lazy = False, **args):\n self.initialized = False\n if not lazy:\n self.set_up(**args)",
"def initialize(self):\n \n #initiali... | [
"0.6272557",
"0.62491",
"0.62490684",
"0.61200494",
"0.6107404",
"0.60481584",
"0.59271073",
"0.59137136",
"0.59105057",
"0.5900862",
"0.5886543",
"0.5868641",
"0.5862043",
"0.5859246",
"0.58126813",
"0.5809382",
"0.5809382",
"0.58025134",
"0.5795178",
"0.5786986",
"0.5785482... | 0.6455311 | 0 |
Removes a file or a directory even if they don't exist | def remove(path):
if os.path.isfile(path):
try:
os.remove(path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
elif os.path.isdir(path):
try:
shutil.rmtree(path)
except FileNotFoundError:
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(file_or_dirname: str):\n if osp.exists(file_or_dirname):\n if osp.isdir(file_or_dirname):\n shutil.rmtree(file_or_dirname, ignore_errors=True)\n if osp.isfile(file_or_dirname):\n os.remove(file_or_dirname)",
"def _unlink(path):\n if os.path.isdir(path):\n ... | [
"0.7852434",
"0.7728063",
"0.77252376",
"0.7716022",
"0.7715892",
"0.7609601",
"0.7609601",
"0.7605511",
"0.75752413",
"0.75660896",
"0.75422573",
"0.75422573",
"0.753782",
"0.7519136",
"0.7492162",
"0.74389076",
"0.7433981",
"0.7362199",
"0.73330706",
"0.73083794",
"0.730377... | 0.7783918 | 1 |
Represent this collection as a list of `asdf.ExternalArrayReference` objects. | def external_array_references(self):
return self._to_ears(self.fileuris) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def references(self) -> \"IterableList[Reference]\":\n return Reference.list_items(self)",
"def references_list( self, theWeaver ):\n return [ (c.name, c.seq) \n for c in theWeaver.reference_style.chunkReferencedBy( self ) ]",
"def ref_pt(self):\n return self._ref_pt.flatten().t... | [
"0.6874796",
"0.62250584",
"0.61639774",
"0.6046303",
"0.6020999",
"0.596683",
"0.5948374",
"0.58768654",
"0.58759147",
"0.58529055",
"0.5837051",
"0.583503",
"0.5829926",
"0.58188266",
"0.5809035",
"0.5797621",
"0.57649285",
"0.5753792",
"0.5740601",
"0.5718886",
"0.57052696... | 0.7180862 | 0 |
Return a list of file names referenced by this Array Container. | def filenames(self):
names = []
for furi in np.asarray(self.fileuris).flat:
names.append(furi)
return names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filenames(self):\n return self._filenames",
"def get_filenames(self):\n return self.filenames",
"def filenames(self):\n return self._files.keys()",
"def filenames(self):\n return self._files.keys()",
"def GetFileNames(self):\n return self.files",
"def filenames(self):\n... | [
"0.7770755",
"0.7642094",
"0.7562831",
"0.7562831",
"0.7495348",
"0.74486923",
"0.7356338",
"0.73090744",
"0.7258218",
"0.7248668",
"0.72052234",
"0.7086959",
"0.7085161",
"0.70490724",
"0.6978835",
"0.69501644",
"0.6931754",
"0.69258267",
"0.69189584",
"0.69062644",
"0.68721... | 0.8045425 | 0 |
Stack a loader array along each of its dimensions. This results in a dask array with the correct chunks and dimensions. | def stack_loader_array(loader_array):
if len(loader_array.shape) == 1:
return da.stack(loader_to_dask(loader_array))
stacks = []
for i in range(loader_array.shape[0]):
stacks.append(stack_loader_array(loader_array[i]))
return da.stack(stacks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array(self):\n return stack_loader_array(self.loader_array).reshape(self.output_shape)",
"def load_chunks(self):\n for key, array in self.chunks.items():\n loaded_array = np.asarray(array)\n self.chunks[key] = loaded_array",
"def stack(arrays, axis=0):\n raise Not... | [
"0.6740181",
"0.62578696",
"0.6237837",
"0.61975235",
"0.59589636",
"0.59500736",
"0.5881783",
"0.5869132",
"0.5701136",
"0.5689394",
"0.56675667",
"0.5660353",
"0.56292516",
"0.55963564",
"0.5542171",
"0.5517344",
"0.55140144",
"0.5411399",
"0.5389828",
"0.5389679",
"0.53683... | 0.8333696 | 0 |
Map a call to `dask.array.from_array` onto all the elements in ``loader_array``. This is done so that an explicit ``meta=`` argument can be provided to prevent loading data from disk. | def loader_to_dask(loader_array):
if len(loader_array.shape) != 1:
raise ValueError("Can only be used on one dimensional arrays")
# The meta argument to from array is used to determine properties of the
# array, such as dtype. We explicitly specify it here to prevent dask
# trying to auto calc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stack_loader_array(loader_array):\n if len(loader_array.shape) == 1:\n return da.stack(loader_to_dask(loader_array))\n stacks = []\n for i in range(loader_array.shape[0]):\n stacks.append(stack_loader_array(loader_array[i]))\n return da.stack(stacks)",
"def array(self):\n aa ... | [
"0.6512419",
"0.60990465",
"0.58843625",
"0.58693886",
"0.55165154",
"0.5438049",
"0.5366238",
"0.5358712",
"0.5263945",
"0.52227837",
"0.52216196",
"0.52055085",
"0.51365423",
"0.51171994",
"0.51155996",
"0.50952417",
"0.5079183",
"0.5017124",
"0.5017124",
"0.50152904",
"0.5... | 0.7210299 | 0 |
Read the bot's token from disk. | def read_discord_token():
token_file = Path("./token")
if token_file.exists():
with open("token", "r") as f:
return "".join(f.readlines()).strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token():\n if os.path.exists(AUTH_TOKEN_PATH):\n with open(str(AUTH_TOKEN_PATH), 'r') as TokenObj:\n try:\n data = TokenObj.read()\n except (OSError, IOError) as e:\n echo(e)\n data = json.loads(data)\n token = data[\"token\"]\n ... | [
"0.73423564",
"0.705419",
"0.7009817",
"0.67909896",
"0.6624552",
"0.6541929",
"0.6472037",
"0.6438901",
"0.6341169",
"0.6292705",
"0.6263115",
"0.6248997",
"0.6187486",
"0.6166654",
"0.61150044",
"0.6094345",
"0.6046179",
"0.5934022",
"0.5882249",
"0.5851091",
"0.58380544",
... | 0.8046541 | 0 |
sort the months in chronological order and return them | def sort_the_months(inp_arr):
if inp_arr != '':
inp_list = []
for i in inp_arr.split():
inp_list.append(int(i.strip()))
in_months = [rev_lookup_months.get(i,0) for i in inp_list] # picking up the month names using reverse lookup
return sorted(in_months,key=months.get)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_months(self):\n m = []\n for post in self:\n d = \"-\".join(post.Date.split(\"-\")[:2])\n m.append(d)\n return list(sorted(set(m), reverse=True))",
"def _get_months(self, cr, uid, context):\n months=[(str(n),str(n)) for n in range(1,13)]\n return mon... | [
"0.728279",
"0.6666359",
"0.6597574",
"0.6544042",
"0.6487118",
"0.6324376",
"0.6284505",
"0.62394524",
"0.6108125",
"0.60979056",
"0.60320026",
"0.6023549",
"0.5952423",
"0.5939564",
"0.59168625",
"0.5911988",
"0.59090114",
"0.5899776",
"0.58295673",
"0.5827182",
"0.5788694"... | 0.74024427 | 0 |
Finds the closest next Determination Date for a given CLO | def next_determination_date(ddates,clo_idx):
dd = ddates.loc[ddates['Fund']==clo_idx,'Determination Date']
next_ddate = min(dd.loc[dd>pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))
return next_ddate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_payment_date(ddates,clo_idx):\n dd = ddates.loc[ddates['Fund']==clo_idx,'Payment Date'].dropna()\n next_date = min(dd.loc[dd>pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))\n return next_date",
"def prior_determination_date(ddates,clo_idx):\n dd = ddates.loc[ddates['Fund']==cl... | [
"0.70815456",
"0.6885164",
"0.62852925",
"0.62490076",
"0.6035495",
"0.59736896",
"0.5913274",
"0.5899726",
"0.58242583",
"0.57373506",
"0.57354647",
"0.572037",
"0.56322455",
"0.56102186",
"0.55837506",
"0.55447114",
"0.5503305",
"0.54535663",
"0.54417944",
"0.5431457",
"0.5... | 0.76319665 | 0 |
Finds the closest previous Determination Date for a given CLO | def prior_determination_date(ddates,clo_idx):
dd = ddates.loc[ddates['Fund']==clo_idx,'Determination Date']
prior_ddate = max(dd.loc[dd<pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))
return prior_ddate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_determination_date(ddates,clo_idx):\n dd = ddates.loc[ddates['Fund']==clo_idx,'Determination Date']\n next_ddate = min(dd.loc[dd>pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))\n return next_ddate",
"def prev(self):\n return self.from_date(self.date_a - datetime.timedelta(... | [
"0.6685649",
"0.62003607",
"0.6038706",
"0.60027647",
"0.5706821",
"0.5627713",
"0.56235075",
"0.5614483",
"0.55525076",
"0.5481342",
"0.54760635",
"0.5463021",
"0.5436332",
"0.54109854",
"0.5400086",
"0.5367436",
"0.5364868",
"0.5345662",
"0.5303397",
"0.5301976",
"0.5294986... | 0.7292106 | 0 |
Finds the closest next Determination Date for a given CLO | def next_payment_date(ddates,clo_idx):
dd = ddates.loc[ddates['Fund']==clo_idx,'Payment Date'].dropna()
next_date = min(dd.loc[dd>pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))
return next_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_determination_date(ddates,clo_idx):\n dd = ddates.loc[ddates['Fund']==clo_idx,'Determination Date']\n next_ddate = min(dd.loc[dd>pd.Timestamp.today()], key=lambda s: (s-pd.Timestamp.today()))\n return next_ddate",
"def prior_determination_date(ddates,clo_idx):\n dd = ddates.loc[ddates['Fund'... | [
"0.76311296",
"0.68860203",
"0.62814987",
"0.62474966",
"0.60339886",
"0.5972924",
"0.59115094",
"0.58981055",
"0.5821018",
"0.57357585",
"0.5732491",
"0.5717424",
"0.56315535",
"0.5611521",
"0.55821496",
"0.5543604",
"0.5502113",
"0.54530454",
"0.5440974",
"0.54317224",
"0.5... | 0.70796466 | 1 |
This function creates the new Moody's Ratings Factor based on the old Moody's rating. !!! This needs to have the old WARF logic added, just a place holder ATM !!! | def moodys_adjusted_warf_old(df):
# moodys_score: dataframe with alphanumeric rating to numeric map (1 to 1 map; linear)
moodys_score = pd.DataFrame([[ 'Aaa',1],['Aa1',2],['Aa2',3],['Aa3',4],
['A1',5],['A2',6],['A3',7],['Baa1',8],['Baa2',9],
['Baa3',10],['Ba1',11],['Ba2',12],['B... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moodys_adjusted_warf(df):\n \n # moodys_score: dataframe with alphanumeric rating to numeric map (1 to 1 map; linear)\n moodys_score = pd.DataFrame([[ 'Aaa',1],['Aa1',2],['Aa2',3],['Aa3',4],\n ['A1',5],['A2',6],['A3',7],['Baa1',8],['Baa2',9],\n ['Baa3',10],['Ba1',11],['Ba2',1... | [
"0.5758869",
"0.5558767",
"0.55134934",
"0.5373286",
"0.5344737",
"0.53218704",
"0.5310128",
"0.5293716",
"0.52666426",
"0.5231981",
"0.5197451",
"0.51960105",
"0.5166237",
"0.5158851",
"0.515657",
"0.51444876",
"0.513253",
"0.51257116",
"0.5106219",
"0.5086788",
"0.5084834",... | 0.6010136 | 0 |
This function get the S&P recovery rate as a percent. If it doesn't exist in the master field, it will look up in the appropriate first and second lien tables, if not, will look up the bond table. | def sp_recovery_rate(model_df):
new_rr_map = {'1+(100)': 0.75,
'1(95%)': 0.70,
'1(90%)': 0.65,
'2(85%)': 0.625,
'2(80%)': 0.60,
'2(75%)': 0.55,
'2(70%)': 0.5,
'3(65%)': 0.45,
'3(60%)': 0.4... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRPSA(ChargeSA):\n temp=0.0\n for i in ChargeSA:\n temp=temp+i[2]\n if temp == 0.0:\n return 0.0\n return getPSA(ChargeSA)/temp",
"def get_real_percent(self):\n if not (self.votes and self.score):\n return 0\n return 100 * (self.get_real_rating() / self.fi... | [
"0.5657199",
"0.56126875",
"0.56044537",
"0.5579284",
"0.5579284",
"0.5570814",
"0.5545265",
"0.55394834",
"0.5506119",
"0.548141",
"0.5445264",
"0.54104847",
"0.5407307",
"0.5405687",
"0.53885186",
"0.53699744",
"0.53552747",
"0.53388464",
"0.5332455",
"0.53295994",
"0.53268... | 0.58117896 | 0 |
Per the Virtus Compliance Reports, the Indenture and the CheatsheetSpreadsheet the WAS is based on the 'Effective Spread' which is neither the Floating Spread, nor the AllinRate in the files, but rather derived from the Floating Spread and the Floor vis a vis LIBOR. It is possible that this needs further refinement, bu... | def Weighted_Average_Spread(clo_df,col,libor=.002):
clo_df = Specified_Assets(clo_df,col) # This should be a view, not a copy: sub CCC excluded
#mask = (clo_df['Asset Type']!='Bond') & (clo_df[col] > 0) & (~clo_df['Spread'].isna()) # Bonds are excluded too
mask = (clo_df[col] > 0) & (~clo_df['Spread... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Effective_Spread(df,libor=0.0020):\n \n def Libor_floor(df,libor = 0.0020):\n df['Libor Floor'] = df['Floor']-libor\n df.loc[df['Libor Floor']<0,'Libor Floor'] = 0\n return df\n\n df['Effective Spread'] = df['Spread'] + Libor_floor(df,libor = 0.0020)['Libor Floor']\n\n \n re... | [
"0.58219266",
"0.56519014",
"0.56018376",
"0.5536604",
"0.55187523",
"0.54828113",
"0.54223007",
"0.5414408",
"0.53947794",
"0.5382458",
"0.5377251",
"0.535083",
"0.53318816",
"0.531121",
"0.52665097",
"0.5265197",
"0.5258741",
"0.5256482",
"0.52473676",
"0.5227359",
"0.52126... | 0.620789 | 0 |
Wait for the container to emit logs satisfying the predicate. | def wait_for_logs(container, predicate, timeout=None, interval=1):
if isinstance(predicate, str):
predicate = re.compile(predicate, re.MULTILINE).search
start = time.time()
while True:
duration = time.time() - start
stdout = container.get_logs()[0].decode()
stderr = container... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_log(self, hub, success_criteria):\n timeMax = time() + BrowserConstants().CONTAINER_TIMEOUT\n line = 'error'\n while line not in BrowserConstants().CONTAINER_SUCCESS or time() < timeMax:\n for line in hub.logs().decode().split('\\n'):\n if success_criteri... | [
"0.65812457",
"0.6081031",
"0.59423965",
"0.5692668",
"0.5603141",
"0.55391514",
"0.53351426",
"0.52783597",
"0.5271061",
"0.5259022",
"0.5256617",
"0.5196948",
"0.51935583",
"0.5154671",
"0.5153015",
"0.51157707",
"0.51076037",
"0.51065934",
"0.5106501",
"0.5091136",
"0.5081... | 0.74227065 | 0 |
Numerically calculate the energy of a wave function generated by `h_static`. For n=1, we'd like to see if we can backcalculate E = 1/2. | def calc_energy(n: int) -> float:
E = -2 / (n + 1) ** 2
x, ψ = h_static(E)
# Calculate potential between the e- field and the nucleus point by integrating.
# todo: Let's do this manually first, then try to apply a scipy.integrate approach.
dx = 1
result = 0
ψ2 = np.conj(ψ) * ψ
sampl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy(n):\n return (n * pi * hbar / (2 * a)) ** 2 / (2 * m)",
"def heterodyner_signal(self, n=1):\n omega = self.fvec*2*np.pi*n\n phvec = np.cumsum(omega)\n return np.exp(1j*phvec)",
"def E(n):\n\n h = 2 * np.pi\n E = h ** 2/(8 * np.pi) * np.sum(n ** 2)\n\n return E",
"d... | [
"0.75971985",
"0.71659374",
"0.71083647",
"0.701199",
"0.68858737",
"0.6817904",
"0.6749287",
"0.6681984",
"0.66303617",
"0.6575992",
"0.6444103",
"0.6439027",
"0.64366823",
"0.6436469",
"0.64302945",
"0.6401461",
"0.63511914",
"0.63426185",
"0.6292362",
"0.6289546",
"0.62835... | 0.79739964 | 0 |
Given a distance, calculate the potential energy between 2 n=1 S orbital hydrogen atoms | def h2_potential(dist: float) -> float:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def h2_potential(x: float) -> float:\n\n # Start with the perspectic of one atom. Calculate the interaction between\n # its nucleus and the other atom's nucleus, and electron.\n\n # Our convention will be attraction is positive potential.\n n = 1\n E = -2 / (n + 1) ** 2\n H = Hydrogen3d([0, 1])\n... | [
"0.6384631",
"0.6381651",
"0.6319062",
"0.6148947",
"0.61302406",
"0.6101907",
"0.6079007",
"0.6075828",
"0.6062157",
"0.6049209",
"0.6048194",
"0.60463667",
"0.60135514",
"0.5892047",
"0.58688706",
"0.5856186",
"0.580126",
"0.57910675",
"0.5746363",
"0.5741646",
"0.57313496"... | 0.6454436 | 0 |
Calcualte the electric potential between 2 hydrogen atoms | def h2_potential(x: float) -> float:
# Start with the perspectic of one atom. Calculate the interaction between
# its nucleus and the other atom's nucleus, and electron.
# Our convention will be attraction is positive potential.
n = 1
E = -2 / (n + 1) ** 2
H = Hydrogen3d([0, 1])
nuc_nuc_V... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_hydration_energies(molecules, parameters):\n\n energies = dict() # energies[index] is the computed solvation energy of molecules[index]\n\n platform = openmm.Platform.getPlatformByName(\"Reference\")\n\n for molecule in molecules:\n # Create OpenMM System.\n system = openmm.Syste... | [
"0.61824036",
"0.6110711",
"0.60990095",
"0.60944664",
"0.6037802",
"0.6018047",
"0.5987008",
"0.59685355",
"0.59524834",
"0.59218556",
"0.5917058",
"0.59143436",
"0.59092486",
"0.590086",
"0.5874456",
"0.5870467",
"0.5863061",
"0.5863061",
"0.58585525",
"0.5823801",
"0.58128... | 0.6720945 | 0 |
Calcualte the electric potential between 2 hydrogen atoms. In this function, we view things from the perspective of the proton of one of the atoms, and calculate everything else relative to it. | def h2_force_pov(x: float) -> float:
# Start with the perspectic of one atom. Calculate the interaction between
# its nucleus and the other atom's nucleus, and electron.
# Our convention will be that towards our POV nucleus is positive;
# repulusion from it is negative.
H = Hydrogen3d([0, 1])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def h2_potential(x: float) -> float:\n\n # Start with the perspectic of one atom. Calculate the interaction between\n # its nucleus and the other atom's nucleus, and electron.\n\n # Our convention will be attraction is positive potential.\n n = 1\n E = -2 / (n + 1) ** 2\n H = Hydrogen3d([0, 1])\n... | [
"0.68302417",
"0.5985139",
"0.5985137",
"0.5957728",
"0.59014904",
"0.58173996",
"0.5814926",
"0.5801584",
"0.57900685",
"0.5789176",
"0.5782294",
"0.57763743",
"0.5774872",
"0.57664514",
"0.57297873",
"0.57273495",
"0.5719949",
"0.57191896",
"0.57191026",
"0.57181704",
"0.57... | 0.6243541 | 1 |
MediaDirectorBridge should be configured per each viewport to properly translate director geometry to viewport geometry and provide separation and service granularity. | def __init__(self, adhoc_media_pool_publisher, viewport_name, media_type='video'):
self.viewport_name = viewport_name
self.adhoc_media_pool_publisher = adhoc_media_pool_publisher
self.media_type = media_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_viewport(self):\n self.add_uniform('viewport', vartype=\"float\", ndim=2, data=(1., 1.))\n self.add_uniform('window_size', vartype=\"float\", ndim=2)#, data=(600., 600.))\n if self.constrain_ratio:\n self.add_vertex_main(\"gl_Position.xy = gl_Position.xy / viewport;\"... | [
"0.5597454",
"0.5359893",
"0.52549493",
"0.52383494",
"0.51137745",
"0.5068526",
"0.49693277",
"0.49679467",
"0.49444598",
"0.4940298",
"0.4934702",
"0.49214214",
"0.49126577",
"0.49018493",
"0.48633575",
"0.48633575",
"0.48526138",
"0.48286793",
"0.4820388",
"0.48173475",
"0... | 0.58055717 | 0 |
Translates director messages to AdhocMedias message. | def translate_director(self, data):
adhoc_medias = self._extract_adhoc_media(data)
logger.info("Publishing AdhocMedias: %s" % adhoc_medias)
self.adhoc_media_pool_publisher.publish(adhoc_medias) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_adhoc_media(self, data):\n # first get assets\n medias = extract_first_asset_from_director_message(data, self.media_type, self.viewport_name)\n logger.info(\"Got assets for %s based media player %s\" % (self.media_type, medias))\n # and wrap them inside AdhocMedia\n ... | [
"0.5756828",
"0.4951096",
"0.4926124",
"0.48583293",
"0.4834989",
"0.4828096",
"0.48003724",
"0.47539556",
"0.47286603",
"0.46866736",
"0.4644532",
"0.45892704",
"0.45611614",
"0.4559201",
"0.4549347",
"0.45020056",
"0.44780415",
"0.44762057",
"0.44577742",
"0.44485086",
"0.4... | 0.75116444 | 0 |
Returns a list containing AdhocMedia objects extracted from director message for specified viewport specific to adhoc_media that this instance of bridge is configured for. | def _extract_adhoc_media(self, data):
# first get assets
medias = extract_first_asset_from_director_message(data, self.media_type, self.viewport_name)
logger.info("Got assets for %s based media player %s" % (self.media_type, medias))
# and wrap them inside AdhocMedia
adhoc_medias... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_adhoc_medias(self, media_list, media_type):\n adhoc_medias = []\n media_id = 0\n for media in media_list:\n media_name = 'adhoc_media_' + media_type + '_' + self.viewport_name + '_' + str(media_id)\n adhoc_media = AdhocMedia()\n adhoc_media.id = medi... | [
"0.66840446",
"0.55954885",
"0.52748317",
"0.5094191",
"0.50603825",
"0.50256515",
"0.4926079",
"0.48892766",
"0.4857374",
"0.48434255",
"0.4839673",
"0.4718286",
"0.47109455",
"0.47022042",
"0.4665178",
"0.46371213",
"0.4633954",
"0.4617935",
"0.46088228",
"0.45785013",
"0.4... | 0.70781124 | 0 |
Accepts json medias list and converts them into AdhocMedias per any media type. | def _build_adhoc_medias(self, media_list, media_type):
adhoc_medias = []
media_id = 0
for media in media_list:
media_name = 'adhoc_media_' + media_type + '_' + self.viewport_name + '_' + str(media_id)
adhoc_media = AdhocMedia()
adhoc_media.id = media_name
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_adhoc_media(self, data):\n # first get assets\n medias = extract_first_asset_from_director_message(data, self.media_type, self.viewport_name)\n logger.info(\"Got assets for %s based media player %s\" % (self.media_type, medias))\n # and wrap them inside AdhocMedia\n ... | [
"0.68942547",
"0.6524161",
"0.6331878",
"0.6318265",
"0.58122784",
"0.57880604",
"0.5740853",
"0.57387435",
"0.5732245",
"0.5609309",
"0.559163",
"0.5577246",
"0.55280346",
"0.5499376",
"0.5481778",
"0.54332197",
"0.54049844",
"0.5360534",
"0.5360534",
"0.5360119",
"0.5306492... | 0.75830823 | 0 |
Syncs the local documents via hg. | def sync_hg(store, path):
storedir, _ = os.path.split(path)
# get or update the storage
if os.path.isdir(os.path.join(storedir, ".hg")):
client = hglib.open(storedir)
client.pull(update=True, force=True)
else:
# Strip off three characters for hg+
client = hglib.clone(stor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def syncfolder():",
"def sync(local_dir, remote_dir):\n\n rsync_project(local_dir=local_dir, remote_dir=remote_dir, delete=True, exclude=['*.pyc', '*.log', '__pycache__', '.idea', '.DS_Store'])",
"def sync(ui, repo, **opts):\n\tif not opts[\"local\"]:\n\t\tui.status = sync_note\n\t\tui.note = sync_note\n\t\... | [
"0.6492948",
"0.61293757",
"0.604978",
"0.60311264",
"0.59857196",
"0.5960997",
"0.5887606",
"0.579694",
"0.57847375",
"0.57500553",
"0.5673247",
"0.5657278",
"0.5640286",
"0.5639766",
"0.5566123",
"0.5528083",
"0.5503859",
"0.55021006",
"0.54978347",
"0.5489572",
"0.54768646... | 0.6388193 | 1 |
Returns all the dn behaviors in doing where eid is the target. | def active_target_of(doing, eid):
if eid is None: return
for dn in doing.values():
tgt_eid = dn.behavior_target_id()
if tgt_eid == eid:
yield dn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_targets():\n # Use a list comp because querying MODM with Guid.find(Q('referent', 'eq', None))\n # only catches the first case.\n return [each for each in Guid.find() if each.referent is None]",
"def current_involvement(doing, eid):\n if eid in doing: return True\n for dn in active_target_... | [
"0.5325171",
"0.5301176",
"0.49029928",
"0.48773405",
"0.48725855",
"0.47625184",
"0.47498816",
"0.47458115",
"0.47372842",
"0.47043437",
"0.46119994",
"0.4577156",
"0.4522979",
"0.4511572",
"0.44878668",
"0.4487514",
"0.44793487",
"0.447785",
"0.4444392",
"0.4444392",
"0.444... | 0.7487286 | 0 |
Lookup or add generic token for entity. | def token(self, ent):
if ent.eid in self.lookup: return self.lookup[ent.eid]
if ent.tid == data.AGENT_TYPE_ID: prefix = 'A'
elif ent.tid in data.combatants: prefix = 'C'
elif ent.tid in data.gatherable: prefix = 'G'
ct = self.counts[prefix]
self.counts[prefix] += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_entity(self, entity):\n entity_type = str(type(entity)).lower()\n if 'acl' in entity_type:\n entity_ref = entity.submit()\n entity_type = 'acl'\n elif 'secret' in entity_type:\n entity_ref = entity.store()\n entity_type = 'secret'\n el... | [
"0.5997961",
"0.58515966",
"0.5842707",
"0.5810176",
"0.5767588",
"0.567083",
"0.53393847",
"0.53307647",
"0.5289455",
"0.5287018",
"0.52758694",
"0.52589107",
"0.5254871",
"0.5253613",
"0.524903",
"0.5211251",
"0.5210907",
"0.5208914",
"0.51905626",
"0.51624143",
"0.516092",... | 0.6373288 | 0 |
All the cases for a given node are in the transitions to that node. | def all_case_groups(self, node_tag):
for tag in self.reverse_edges[node_tag]:
for from_grp,to_grp in self.nodes[tag].transitions[node_tag]:
yield to_grp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transition(self):\n for node in self.net.nodes():\n if node not in self.evidence:\n self.update_node(node)",
"def get_successors(self, node):\n succs = []\n parent_state = self.node_to_state(node)\n for it in self.children:\n child_node = (node[0] + it[0], node[1] + it[1])\n ... | [
"0.5792827",
"0.5410251",
"0.53993726",
"0.5290269",
"0.52816916",
"0.5278971",
"0.5252477",
"0.5199749",
"0.5178954",
"0.5143815",
"0.51037747",
"0.50952506",
"0.50904924",
"0.5067474",
"0.50654083",
"0.50454456",
"0.50382626",
"0.50260895",
"0.49898145",
"0.49791223",
"0.49... | 0.6066631 | 0 |
Print Pandas dataframes side by side in python notebook | def display_side_by_side(*args):
html_string = ''
for df in args:
html_string += df.to_html(index=False, header=True)
display_html(html_string.replace('table',
'table style="display:inline"'), raw=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_side_by_side(*args:\"pandas.DataFrame, pandas.Series\", drop_index:\"bool\"=False)-> \"None\":\n from IPython.display import display_html\n \n strHtml = ''\n for df in args:\n \n if isinstance(df, pandas.Series):\n df = df.to_frame()\n if drop_index:\n ... | [
"0.753792",
"0.711955",
"0.6847479",
"0.6823474",
"0.6737545",
"0.6716674",
"0.66545683",
"0.6632838",
"0.6581293",
"0.6578611",
"0.6498583",
"0.6446919",
"0.6442522",
"0.64392906",
"0.6338867",
"0.6290526",
"0.6267287",
"0.6198592",
"0.60689056",
"0.6055208",
"0.60430104",
... | 0.7244116 | 1 |
Join all the tables in dataframe | def merge_tables():
# get sql connection
conn = get_sql_conn()
# get all info from materials table
query_mat = 'Select * from material_procurement'
df_mat = pd.read_sql_query(query_mat, con=conn)
df_mat = df_mat.drop(['uid'], axis=1)
df_mat = df_mat.pivot(index='ball_milling_uid',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_tables(self) -> DataFrame:\n if not self.source_tables:\n raise ValueError(f\"No source tables were provided to GlueTransformer: {self}\")\n\n if len(self.source_tables) == 1:\n # extract the first value from the dictionary\n source_table = list(self.source_t... | [
"0.7395973",
"0.647935",
"0.6452989",
"0.640315",
"0.61098063",
"0.598186",
"0.59498644",
"0.59199065",
"0.5916071",
"0.5857313",
"0.5837995",
"0.582548",
"0.5813223",
"0.5760614",
"0.57454985",
"0.5742425",
"0.57407284",
"0.57362974",
"0.5732524",
"0.57144666",
"0.57009363",... | 0.6695207 | 1 |
Read log files and create a dict of zip files processed | def getAllEntries(self):
log_entries_dict = collections.defaultdict(list)
for logfile in os.listdir(self.log_folder):
log = os.path.join(self.log_folder, logfile)
with open(log, 'rb') as l:
logCSVreader = csv.reader(l, delimiter="|")
logCS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_logs():\n logging.info('Archive start...')\n\n for log_dir in filter(dir_filter, os.listdir('logs')):\n path = 'logs/{}'.format(log_dir)\n archive_files = filter(lambda x: '.log.' in x, os.listdir(path))\n zip_file_name = '{}/{}.zip'.format(\n path,\n st... | [
"0.6630395",
"0.6468884",
"0.63585454",
"0.6214697",
"0.6129166",
"0.60579395",
"0.60567033",
"0.6022194",
"0.6007949",
"0.5996118",
"0.5982326",
"0.5951958",
"0.589989",
"0.58540064",
"0.5835107",
"0.57785535",
"0.5763304",
"0.5752816",
"0.5747817",
"0.5742977",
"0.57037747"... | 0.7312646 | 0 |
Process all the labels that occur in tex This works by scanning for commands and environments that alter numbering as well as any LaTeX labelling commands. | def process_labels(ctx, tex, chapter):
headings = ['chapter'] + ['sub'*i + 'section' for i in range(4)]
reh = r'(' + '|'.join(headings) + r'){(.+?)}'
environments = ['thm', 'lem', 'exc', 'figure', 'equation']
ree = r'begin{(' + '|'.join(environments) + r')}'
rel = r'(\w+)label{(.+?)}'
rel2 = r'l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _FindLabels(self):\n texs = \" \".join(glob.glob(\"*.tex\"))\n cat_process = subprocess.Popen(shlex.split(\"cat %s\" % texs),\n stdout=subprocess.PIPE)\n grep_process = subprocess.Popen(shlex.split(r\"grep \\\\\\\\label\"),\n ... | [
"0.6509359",
"0.60091585",
"0.6000219",
"0.580651",
"0.57997483",
"0.56963754",
"0.5682401",
"0.56652904",
"0.56348157",
"0.5611503",
"0.5588299",
"0.5568256",
"0.5554805",
"0.5524883",
"0.55227274",
"0.55060005",
"0.55027604",
"0.54896235",
"0.54572046",
"0.5443968",
"0.5385... | 0.73234004 | 0 |
Get the next command in tex that occurs at or after pos | def next_command(tex, pos):
rx = re.compile(r'\\([a-zA-Z0-9]+\*?)')
m = rx.search(tex, pos)
if m:
optargs, args, t, j = chomp_args(tex, m.end())
cmd = command(m.group(1), optargs, args, m.start(), j)
return cmd
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_position(self):",
"def GetCurrentToken(tokens, pos):\n i = 0\n while i < len(tokens):\n if pos > tokens[i].start and pos < tokens[i].end:\n return tokens[i]\n if pos < tokens[i].start:\n return tokens[i-1] if i > 0 else None\n i += 1\n\n return tokens[len(tokens)-1] if tokens e... | [
"0.664574",
"0.64717907",
"0.6439655",
"0.62922895",
"0.6165806",
"0.615074",
"0.6132748",
"0.61289316",
"0.6057875",
"0.59959984",
"0.59621286",
"0.5910657",
"0.5876916",
"0.5819534",
"0.58171415",
"0.58050245",
"0.5793795",
"0.57711893",
"0.5754559",
"0.57465935",
"0.573182... | 0.7707845 | 0 |
These command break out of math mode | def process_mathbreaker_cmd(ctx, text, cmd, mode):
if mode & MATH:
return process_cmd_passthru(ctx, text, cmd, mode | MATHBREAK)
return process_cmd_strip(ctx, text, cmd, mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_calculation():",
"def is_equation(self): \n return False",
"def test01_math_operators(self):\n\n import _cppyy\n number = _cppyy.gbl.number\n\n assert (number(20) + number(10)) == number(30)\n assert (number(20) + 10 ) == number(30)\n assert (numb... | [
"0.6146702",
"0.5816061",
"0.5774647",
"0.5557019",
"0.55432904",
"0.553412",
"0.5533933",
"0.55278563",
"0.5495544",
"0.5481049",
"0.5470436",
"0.5417471",
"0.5400012",
"0.53921664",
"0.53921664",
"0.5354398",
"0.5347526",
"0.53421474",
"0.5260497",
"0.5259039",
"0.52540535"... | 0.724486 | 0 |
Get an environment that is started by begincmd. | def get_environment(tex, begincmd):
name = begincmd.args[0]
pos = begincmd.end
optargs, args, t, pos0 = chomp_args(tex, pos)
pos = pos0
d = 1
regex = r'\\(begin|end){{{}}}'.format(re.escape(name))
rx = re.compile(regex)
while d > 0:
m = rx.search(tex, pos)
if not m:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environment(self):\r\n return self.mcas[0].get_environment()",
"def get_env(self, *args):\n m = module(*args)\n return m.env",
"def getEnvironment(self):\n pass",
"def get_environment(self):\n return self._environment",
"def get_environ():\n # Manually set environm... | [
"0.75646055",
"0.70212203",
"0.6972797",
"0.68663144",
"0.68611",
"0.67535865",
"0.6707893",
"0.6703011",
"0.66816056",
"0.6542364",
"0.6465277",
"0.6460655",
"0.6457151",
"0.64376605",
"0.64262396",
"0.6336297",
"0.6335392",
"0.63349175",
"0.63046724",
"0.6293944",
"0.628789... | 0.79574853 | 0 |
detect intrusion between 2 packets per time intervals | def detect_intrusion(packet1, packet2, ips, malicious_ips):
for i in range(len(packet2.packets)):
packet_per_time1 = packet1.packets[i]
packet_per_time2 = packet2.packets[i]
for ip, tup in packet_per_time1.packets_map:
sent, received = tup | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_packets_in_interval(packet, packets_list, inspection_interval):\n packets_url_list = []\n final_packet_list = []\n\n for elem in packets_list:\n if elem.url_domain == packet.url_domain:\n packets_url_list.append(elem)\n\n for i in range(0, len(packets_url_list)):\n elem... | [
"0.5653804",
"0.5615221",
"0.56144255",
"0.56138706",
"0.5556069",
"0.5537869",
"0.5529584",
"0.5424415",
"0.54096365",
"0.53902227",
"0.5384274",
"0.5381208",
"0.53760254",
"0.5374839",
"0.5334448",
"0.5321723",
"0.53090703",
"0.5306684",
"0.5299968",
"0.5286531",
"0.5282496... | 0.7192617 | 0 |
Multiplies two quaternions according to Hamilton's convention q3 = q1 q2 | def quatMultiply(q1, q2):
q1 = q1.flatten()
q2 = q2.flatten()
q3 = np.zeros(4)
q3[0] = q1[0] * q2[0] - np.dot(q1[1:], q2[1:])
q3[1:] = (q1[0] * q2[1:] + q2[0] * q1[1:] + np.cross(q1[1:], q2[1:]))
return (q3 / np.linalg.norm(q3)).reshape(-1, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiply_quaternions(quats1,quats2):\n w1 = quats1[:,0]\n x1 = quats1[:,1]\n y1 = quats1[:,2]\n z1 = quats1[:,3]\n\n w2 = quats2[:,0]\n x2 = quats2[:,1]\n y2 = quats2[:,2]\n z2 = quats2[:,3]\n\n res = np.zeros((quats1.shape[0],4))\n \n res[:,0] = w1 * w2 - x1 * x2 - y1 * y2 - z... | [
"0.82009214",
"0.7777479",
"0.771397",
"0.77088773",
"0.7682568",
"0.75567377",
"0.75304407",
"0.73233193",
"0.7194208",
"0.69519967",
"0.6885308",
"0.6885308",
"0.6860672",
"0.6852312",
"0.68511367",
"0.68075776",
"0.67176276",
"0.661498",
"0.65372235",
"0.64440626",
"0.6401... | 0.78207225 | 1 |
Transforms a vector, v into a different frame with the transformation represented as a quaternion | def quatPassiveRot(q, v):
v_q = np.zeros((4, 1))
v_q[1:] = v
v_qnew = quatLeftMat(q).T @ quatRightMat(q) @ v_q
return v_qnew[1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quatActiveRot(q, v):\n\tv_q = np.zeros((4, 1))\n\tv_q[1:] = v\n\tv_qnew = quatLeftMat(q) @ quatRightMat(q).T @ v_q\n\treturn v_qnew[1:]",
"def qrot(q, v):\n assert q.shape[-1] == 4\n assert v.shape[-1] == 3\n assert q.shape[:-1] == v.shape[:-1]\n\n qvec = q[..., 1:]\n uv = torch.cross(qvec.dou... | [
"0.74617785",
"0.737833",
"0.7371231",
"0.7002721",
"0.6993505",
"0.698818",
"0.67339283",
"0.6691262",
"0.6470421",
"0.64028096",
"0.6344371",
"0.62991285",
"0.6294629",
"0.62905675",
"0.61926275",
"0.6156036",
"0.61080223",
"0.6072867",
"0.6021131",
"0.6021041",
"0.60159594... | 0.77789176 | 0 |
Transforms an active quaternion, q into a DCM | def quat2DCM(q):
DCM = quatLeftMat(q) @ quatRightMat(q).T
DCM = DCM[1:, 1:]
return DCM | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quat2dcm(q):\n q0q0 = q[0] * q[0]\n q0q1 = q[0] * q[1]\n q0q2 = q[0] * q[2]\n q0q3 = q[0] * q[3]\n q1q1 = q[1] * q[1]\n q1q2 = q[1] * q[2]\n q1q3 = q[1] * q[3]\n q2q2 = q[2] * q[2]\n q2q3 = q[2] * q[3]\n q3q3 = q[3] * q[3]\n dcm = np.zeros((3, 3))\n dcm[0, 0] = q0q0 + q1q1 -... | [
"0.7942583",
"0.7284102",
"0.6947959",
"0.6947452",
"0.6690092",
"0.66138154",
"0.6482744",
"0.64237666",
"0.6322584",
"0.6315125",
"0.626222",
"0.6257847",
"0.6131777",
"0.6131777",
"0.6085944",
"0.6059335",
"0.60456383",
"0.59921414",
"0.5973512",
"0.5939934",
"0.59363055",... | 0.7980867 | 0 |
Store data to config file. | def save(self):
try:
with open(self._filename, 'w') as conf_file:
conf_file.write(json.dumps(self._data))
except OSError:
_LOGGER.exception("Can't store config in %s", self._filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_config(self, fname, data):\n with open(fname, 'w') as fhandle:\n fhandle.write(data)",
"def save_data(self):\n # Validate\n try:\n self._data = self._schema(self._data)\n except vol.Invalid as ex:\n _LOGGER.error(\"Can't parse data: %s\",\n ... | [
"0.7645778",
"0.7546113",
"0.7486713",
"0.7441288",
"0.7431161",
"0.73804575",
"0.7378107",
"0.72353476",
"0.72058284",
"0.7117145",
"0.7084985",
"0.7070956",
"0.7070956",
"0.7070956",
"0.7070956",
"0.7070956",
"0.7070956",
"0.7059753",
"0.7048014",
"0.6990008",
"0.6945066",
... | 0.79483265 | 0 |
Return config path extern for docker. | def path_config_docker(self):
return HOMEASSISTANT_CONFIG.format(HASSIO_SHARE_EXT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_file_location():\n\n return './' + CONFIG_FILE_NAME",
"def get_config_path(config):\n section = config.sections()[0]\n return Path(config.get(section, \"path\")).expanduser().absolute()",
"def get_config_path():\n\n root = os.path.dirname(os.path.abspath(__file__))[:-5]\n config_p... | [
"0.74192953",
"0.72808295",
"0.7199606",
"0.71740204",
"0.71022815",
"0.7070487",
"0.7018677",
"0.6993428",
"0.6987514",
"0.6987457",
"0.69760936",
"0.6965125",
"0.69459623",
"0.69216627",
"0.6906117",
"0.6885735",
"0.685167",
"0.68265676",
"0.6822401",
"0.6778158",
"0.668739... | 0.81461096 | 0 |
Return SSL path extern for docker. | def path_ssl_docker(self):
return HOMEASSISTANT_SSL.format(HASSIO_SHARE_EXT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_ssl(self):\n return HOMEASSISTANT_SSL.format(HASSIO_SHARE_INT)",
"def path_ssl(self) -> Path:\n return self.path_supervisor / HASSIO_SSL",
"def path_extern_ssl(self) -> PurePath:\n return PurePath(self.path_extern_supervisor, HASSIO_SSL)",
"def _get_path(client):\n if client ... | [
"0.6822689",
"0.6708025",
"0.66049916",
"0.6426582",
"0.6254691",
"0.60204744",
"0.5989687",
"0.59779346",
"0.59149474",
"0.58805597",
"0.58476746",
"0.57965374",
"0.57806724",
"0.57640135",
"0.5754668",
"0.5754668",
"0.57436466",
"0.57014",
"0.5634066",
"0.5619365",
"0.55528... | 0.8433545 | 0 |
Signup user with missing fields | def signup_user_with_missing_fields(self):
response = self.client.post(
self.signup_url, self.invalid_user_with_missing_fields, format='json')
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signup_user_with_empty_fields(self):\n response = self.client.post(\n self.signup_url, self.invalid_user_with_empty_fields, format='json')\n\n return response",
"def signup():",
"def signup(**kwargs):\n\n pass",
"def signup(self, request, user):\n pass",
"def proc... | [
"0.78258413",
"0.7724598",
"0.7622048",
"0.7553007",
"0.7168377",
"0.7110705",
"0.71080893",
"0.7070942",
"0.7047038",
"0.7044982",
"0.7033845",
"0.7023482",
"0.7016647",
"0.701621",
"0.7001904",
"0.700088",
"0.6998123",
"0.697008",
"0.69637936",
"0.6958926",
"0.68998307",
... | 0.78752875 | 0 |
Signup user with empty fields | def signup_user_with_empty_fields(self):
response = self.client.post(
self.signup_url, self.invalid_user_with_empty_fields, format='json')
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signup_user_with_missing_fields(self):\n response = self.client.post(\n self.signup_url, self.invalid_user_with_missing_fields, format='json')\n\n return response",
"def signup():",
"def signup(**kwargs):\n\n pass",
"def signup(self, request, user):\n pass",
"def ... | [
"0.75136113",
"0.7452351",
"0.72739697",
"0.7222121",
"0.7047973",
"0.6911724",
"0.6904559",
"0.6894035",
"0.6893144",
"0.68879724",
"0.68854135",
"0.6878987",
"0.68164825",
"0.6813771",
"0.67976874",
"0.6785147",
"0.6780374",
"0.6780209",
"0.6780088",
"0.67720515",
"0.676552... | 0.82857573 | 0 |
Send sampled subgraph (Nodeflow) to remote trainer. | def _send_subgraph(sender, nodeflow):
graph_handle = nodeflow._graph._handle
node_mapping = nodeflow._node_mapping.todgltensor()
edge_mapping = nodeflow._edge_mapping.todgltensor()
# Can we convert NDArray to tensor directly, instead of using toindex()?
layers_offsets = utils.toindex(nodeflow._layer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsample_graph(graph, max_degree,\n rng):\n edges = sampler.get_adjacency_lists(graph)\n edges = sampler.sample_adjacency_lists(edges, graph.train_nodes, max_degree,\n rng)\n senders = []\n receivers = []\n for u in edges:\n for v in edges[u]:... | [
"0.59181595",
"0.55878484",
"0.5443911",
"0.54433334",
"0.5167351",
"0.5132645",
"0.511138",
"0.51074356",
"0.5107281",
"0.50582814",
"0.50561494",
"0.5037428",
"0.49844283",
"0.49630538",
"0.49382666",
"0.49320403",
"0.48904377",
"0.4868248",
"0.48680243",
"0.483973",
"0.481... | 0.69966424 | 0 |
Receive sampled subgraph (NodeFlow) from remote sampler. | def _recv_subgraph(receiver, graph):
# hdl is a list of ptr
hdl = unwrap_to_ptr_list(_CAPI_ReceiverRecvSubgraph(receiver))
return NodeFlow(graph, hdl[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsample_graph(graph, max_degree,\n rng):\n edges = sampler.get_adjacency_lists(graph)\n edges = sampler.sample_adjacency_lists(edges, graph.train_nodes, max_degree,\n rng)\n senders = []\n receivers = []\n for u in edges:\n for v in edges[u]:... | [
"0.6293176",
"0.5980139",
"0.58321863",
"0.5762111",
"0.56033033",
"0.54630053",
"0.5437144",
"0.54267013",
"0.5269671",
"0.5268855",
"0.5232244",
"0.52186954",
"0.52127975",
"0.5190399",
"0.51345867",
"0.5117507",
"0.5110123",
"0.5088535",
"0.5028839",
"0.49922106",
"0.49705... | 0.6772197 | 0 |
If `tree` is the common ancestor, `_CommonAncestorFound(tree)` is raised. If `node1`/`node2` is in this subtree, return True, otherwise return False. | def recursive(tree):
if tree == None:
return False
if tree == node1 or tree == node2:
# Only need to find another node in the left or right subtree.
if recursive(tree.left_child) or recursive(tree.right_child):
raise _CommonAncestorFound(tree)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isancestor(s2,tree):\n if tree is s2: return True\n if tree is None: return False\n else:\n return isancestor(s2, tree.left) or isancestor(s2, tree.right)",
"def is_subtree(t1, t2):\r\n if t2.root is None:\r\n # Empty tree always a subtree.\r\n return True\r\n elif t1.root... | [
"0.7154758",
"0.7103896",
"0.7099606",
"0.6927285",
"0.6887851",
"0.6735549",
"0.65954554",
"0.65434515",
"0.65420276",
"0.6436624",
"0.63037133",
"0.626203",
"0.60956085",
"0.6092718",
"0.60760075",
"0.59891075",
"0.598102",
"0.5936786",
"0.58779895",
"0.587709",
"0.58655816... | 0.8833482 | 0 |
increases house size by 1 multiplies money value by 2 maximum limit size 3 | def upgrade(self):
if self._size == 3:
return
self._size += 1
self._money *= 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_price(self):\n price = self.price\n action = self.action\n mortage = 5 # here set mortage multiplier \n\n if action == 'RESIDENTIAL_SALE':\n return price * 12 * mortage\n\n\n if price >= 10000:\n return price * 0.7\n elif price < 10000 & pric... | [
"0.6034786",
"0.5827989",
"0.57220954",
"0.57160413",
"0.5705812",
"0.56746256",
"0.5661567",
"0.56573707",
"0.5635523",
"0.5630269",
"0.5583196",
"0.5558698",
"0.55280656",
"0.55250853",
"0.5505951",
"0.5505012",
"0.5502733",
"0.5488841",
"0.5422625",
"0.5405125",
"0.5337693... | 0.6464554 | 0 |
Is this term describing a power of ten? | def power_of_ten(term):
if term is None:
return True
_, factor = term
return round_to_ten(factor) == factor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(num, exponent):\n return num ** exponent",
"def power(base, exponent):\n return base ** exponent",
"def power(a, b):\n \n return a**b",
"def power(num, exponent):\n power = num ** exponent\n return power",
"def __pow__( self, power ):\r\n\t\tif ( power > 0 ):\r\n\t\t\treturn frac... | [
"0.62583596",
"0.6207931",
"0.6175461",
"0.6132473",
"0.6064472",
"0.6038002",
"0.6032997",
"0.6016182",
"0.60135865",
"0.6011028",
"0.6011028",
"0.5985615",
"0.5969478",
"0.5964911",
"0.59611195",
"0.59195787",
"0.5917505",
"0.5917162",
"0.58533084",
"0.5839585",
"0.5830735"... | 0.81160843 | 0 |
This method creates storage if it exists | def prepare_storage(self):
self.logger.info("Preparing storage for your data...")
try:
self.dir.mkdir(exist_ok=True)
self.full_path_to_file.touch(exist_ok=True)
except PermissionError:
logging.error(
"Conversion cannot be performed. Permission ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storage_create(context, values):\n if not values.get('id'):\n values['id'] = uuidutils.generate_uuid()\n\n storage_ref = models.Storage()\n storage_ref.update(values)\n\n session = get_session()\n with session.begin():\n session.add(storage_ref)\n\n return _storage_get(context,\... | [
"0.7400515",
"0.66225326",
"0.6451715",
"0.637169",
"0.636824",
"0.6327173",
"0.6287005",
"0.62570935",
"0.6238478",
"0.62244916",
"0.6187873",
"0.61840564",
"0.6179413",
"0.61558247",
"0.6145781",
"0.6141107",
"0.61387914",
"0.60816854",
"0.60043514",
"0.59725773",
"0.592477... | 0.68925494 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.