query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Test that read_mapping_file can read more than one molecule. | def test_read_mapping_file_multiple(reference_multi):
content, reference = reference_multi
from_names = list(reference.keys())
to_names = []
block_names = []
for k in reference:
to_names.extend(reference[k].keys())
for to in reference[k]:
block_names.extend(reference[k][... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_mapping_file(case):\n reference = collections.defaultdict(lambda: collections.defaultdict(dict))\n for from_ff, to_ff in itertools.product(case.from_ff, case.to_ff):\n reference[from_ff][to_ff][case.name] = (\n case.mapping, case.weights, case.extra\n )\n\n ffs = cas... | [
"0.67420113",
"0.6703428",
"0.6658432",
"0.6653267",
"0.6620562",
"0.6576531",
"0.65403",
"0.6393296",
"0.6315044",
"0.6295086",
"0.6235337",
"0.6168162",
"0.61647826",
"0.61638695",
"0.6154931",
"0.6074728",
"0.6069374",
"0.60642123",
"0.605357",
"0.5964693",
"0.59500426",
... | 0.7212817 | 0 |
Build a file tree with mapping files. | def ref_mapping_directory(tmpdir_factory):
basedir = tmpdir_factory.mktemp('data')
mapdir = basedir.mkdir('mappings')
template = textwrap.dedent("""
[ molecule ]
dummy_{0}
[ from ]
{1}
[ to ]
{2}
[ atoms ]
0 X1{0} A{0} B{0}
1 X2{0} ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_file_tree(self):\n # Build file tree with packmode and weigth info (# of file in the packmode)\n root = {\"packmode\": None, \"weight\": None, \"children\": {}}\n for filepath, packmode in self.override_packmode_map.items():\n node = root\n for part in filepath... | [
"0.7007131",
"0.6332988",
"0.6162577",
"0.606019",
"0.6058516",
"0.60204667",
"0.59296227",
"0.5903134",
"0.5871665",
"0.5856109",
"0.5854468",
"0.5800572",
"0.57764846",
"0.57486165",
"0.5710741",
"0.57098264",
"0.5703374",
"0.5689811",
"0.5654435",
"0.56431305",
"0.5602831"... | 0.6665727 | 1 |
Test that mapping files from a directory are propely found and read. | def test_read_mapping_directory(ref_mapping_directory):
dirpath, ref_mappings = ref_mapping_directory
from_names = list(ref_mappings.keys())
to_names = []
block_names = []
mapping = {}
weights = {}
for k in ref_mappings:
to_names.extend(ref_mappings[k].keys())
for to in ref... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_map(self, audio_store_and_expected_files):\n audio_store = audio_store_and_expected_files[0]\n expected_files = audio_store_and_expected_files[1]\n\n # Check number of files.\n assert len(audio_store.file_map) == expected_files\n\n # Ensure the keys are as expected.\n ... | [
"0.6989255",
"0.67256457",
"0.6499422",
"0.64963084",
"0.64944816",
"0.64576644",
"0.63912785",
"0.62879676",
"0.62493104",
"0.6245174",
"0.62226516",
"0.61930525",
"0.6185058",
"0.60630137",
"0.6058861",
"0.6024957",
"0.5999067",
"0.59754974",
"0.5968207",
"0.596742",
"0.595... | 0.7653856 | 0 |
Sets text of a Plone document if it exists and reindex the document The text is coming from a browser view template tag | def setPageText(portal, page, viewName):
if page is None:
return
request = getattr(portal, 'REQUEST', None)
if request is not None:
view = queryMultiAdapter((portal, request), name=viewName)
if view is not None:
text = bodyfinder(view.index()).strip()
page.set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_text(self, text):\n self.response['text'] = text",
"def edit_document():",
"def SetText(self, text):\n self.Clear()\n self.__context.builder.DocumentInsert(self._blip_data.wave_id,\n self._blip_data.wavelet_id,\n ... | [
"0.66143626",
"0.66091734",
"0.6442834",
"0.63463277",
"0.63095236",
"0.6092229",
"0.6057413",
"0.6057413",
"0.6057413",
"0.6057413",
"0.6057413",
"0.6057413",
"0.60565853",
"0.60544866",
"0.60536844",
"0.6018306",
"0.59941316",
"0.5978407",
"0.59762806",
"0.5954543",
"0.5917... | 0.7150492 | 0 |
Add a MaildropHost if Products.MaildropHost is available... If MaildropHost exist, PloneGazette will use it to send mails. This will avoid duplicate emails send as reported by | def addMaildropHost(self):
portal = getToolByName(self, 'portal_url').getPortalObject()
if not hasattr(portal, "MaildropHost"):
try:
portal.manage_addProduct['MaildropHost'].manage_addMaildropHost('MaildropHost', title='MaildropHost')
except AttributeError:
# if MaildropH... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_addMailServer( self, id='MailServer', title='', host=None, port=None, REQUEST=None ):\n self._setObject( id, MailServer( id, title, host, port ) )\n\n if REQUEST is not None:\n REQUEST.RESPONSE.redirect( REQUEST.URL1 )",
"def manage_addMailSender( self, id='MailHost', title='', host=None,... | [
"0.57076377",
"0.5688542",
"0.54326963",
"0.5342844",
"0.522222",
"0.5184435",
"0.5170344",
"0.5141721",
"0.51176596",
"0.5113623",
"0.5091956",
"0.5051609",
"0.5037057",
"0.5037057",
"0.50238883",
"0.49762768",
"0.49572164",
"0.49479112",
"0.48867533",
"0.48693794",
"0.48661... | 0.7845082 | 0 |
Method to add our wanted indexes to the portal_catalog. | def addCatalogIndexes(portal):
catalog = getToolByName(portal, 'portal_catalog')
indexes = catalog.indexes()
wanted = (('standardTags', 'KeywordIndex'),
('iamTags', 'KeywordIndex'),
('isearchTags', 'KeywordIndex'),
('hiddenTags', 'KeywordIndex'))
indexables = []... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_catalog_indexes(context, logger):\n if logger is None:\n logger = logging.getLogger('bungenicms.membershipdirectory')\n \n # Run the catalog.xml step as that may have defined new metadata columns. \n # We could instead add <depends name=\"catalog\"/> to the registration of our \n ... | [
"0.819925",
"0.6714551",
"0.66770244",
"0.6349882",
"0.6222696",
"0.6083812",
"0.6036434",
"0.6023171",
"0.60225964",
"0.60145235",
"0.60141164",
"0.6001239",
"0.59967524",
"0.5949453",
"0.5890639",
"0.5824087",
"0.57495576",
"0.5746176",
"0.5742815",
"0.57316446",
"0.5660347... | 0.8188832 | 1 |
Extracts and parses data from a sqlite3.Cursor object | def cursor_data(c):
# pull column description
d = []
for i in range(len(c.description)):
d.append(c.description[i][0])
# fetch column entries
c = c.fetchall()
# compile list
info = []
for i in range(len(c)):
# compile dictionary entry
entry = {}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_list(cursor):\n header = [h[0] for h in cursor.description]\n data = cursor.fetchall()\n return header, data",
"def get_text_data(db, table, col):\n con = lite.connect(db)\n with con:\n cur = con.cursor()\n cur.execute(\"SELECT \" + col + \" FROM \" + table)\n te... | [
"0.64374334",
"0.62329024",
"0.6100417",
"0.5942611",
"0.5928529",
"0.59160304",
"0.59160304",
"0.58683413",
"0.58111495",
"0.5792052",
"0.5788436",
"0.577716",
"0.577716",
"0.5717413",
"0.56549394",
"0.56148547",
"0.5608014",
"0.5591911",
"0.5588732",
"0.55835444",
"0.557283... | 0.7030328 | 0 |
Retrieves and parses current time stamp from the 'datetime' module. | def get_time():
dt = datetime.datetime.now()
dt_parsed = dt.strftime("%Y-%m-%d %H:%M:%S")
return dt_parsed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime(self):\r\n if 'observation_time_rfc822' in self.data \\\r\n and self.data['observation_time_rfc822']:\r\n tstr = self.data['observation_time_rfc822']\r\n tstr = ' '.join(tstr.split(' ')[:-2])\r\n return datetime.strptime(tstr, '%a, %d %b %Y %H:%M:%S')\... | [
"0.69299984",
"0.6702524",
"0.63582027",
"0.63440084",
"0.63380075",
"0.63115704",
"0.6280957",
"0.6251938",
"0.62222415",
"0.61944693",
"0.61944693",
"0.61590403",
"0.6087337",
"0.60751706",
"0.60636747",
"0.6060406",
"0.6042445",
"0.6027001",
"0.6009286",
"0.59921634",
"0.5... | 0.6883768 | 1 |
Fetches the ten most recent news articles from an RSS feed. | def get_news(url):
# parse RSS feed into list of dictionaries
feed = feedparser.parse(url)
# no RSS feed articles for url
if len(feed['entries']) == 0:
return []
# get first ten articles from the RSS feed
news = []
i = 0
while True:
if i == len(fee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_articles(update=False):\n # use caching to avoid running unnecessary DB queries at each page load\n key = 'top_ten'\n articles = memcache.get(key)\n\n logging.warn('MEMCACHE | Wiki articles %s' % str(articles))\n\n if (articles is None) or (len(articles) == 0) or update:\n # neces... | [
"0.721724",
"0.6942011",
"0.6921786",
"0.68017155",
"0.680133",
"0.67669815",
"0.6721919",
"0.66387874",
"0.6592782",
"0.65631974",
"0.64701366",
"0.63726705",
"0.6331431",
"0.6329042",
"0.6328483",
"0.63121986",
"0.6246357",
"0.6245741",
"0.6224736",
"0.6222687",
"0.6214443"... | 0.7554712 | 0 |
Calls the new_transformations.sql script on a date by date basis | def run_sql_transformations(self):
conn = pg2.connect(user='postgres', dbname='penny', host='localhost', port='5432', password='password')
for d in self.get_list_of_dates():
print(d)
df = pd.read_sql("Select count(*) as acount from auctions where auctiontime < '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_new_sql(self):\n\n pass",
"def upgrade_db():\n import publicprize.db_upgrade\n\n backup_db()\n for field, date in (\n (\"submission_start\", \"6/16/2017 12:0:0\"),\n (\"submission_end\", \"9/7/2017 12:0:0\"),\n (\"public_voting_start\", \"9/8/2017 12:0:0\"),\n ... | [
"0.63391304",
"0.55349416",
"0.5524126",
"0.5391393",
"0.5282291",
"0.5150908",
"0.51406926",
"0.5104045",
"0.5097644",
"0.5060103",
"0.50325495",
"0.50310206",
"0.5027701",
"0.49788183",
"0.4962675",
"0.4934943",
"0.49243897",
"0.490533",
"0.48683342",
"0.4866766",
"0.486197... | 0.6584904 | 0 |
Players may join a game of Pig | def test_join(self):
pig = game.pig.Pig('PlayerA', 'PlayerB', 'PlayerC')
self.assertEqual(pig.get_players(), ('PlayerA', 'PlayerB', 'PlayerC')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enough_players():\n return True",
"def gameOver():\n if len(p1)==0 and len(p1winnings)==0:\n return True\n elif len(p2)==0 and len(p2winnings)==0:\n return True\n return False",
"async def join(ctx):\n if ctx.message.channel.name.lower() not in tod_channels:... | [
"0.69568753",
"0.6629181",
"0.6586598",
"0.6556356",
"0.6515452",
"0.64138293",
"0.6406495",
"0.63846964",
"0.63828003",
"0.6336657",
"0.6336657",
"0.62983274",
"0.62676483",
"0.6216054",
"0.6119754",
"0.6101144",
"0.6100801",
"0.6068492",
"0.6054281",
"0.60209066",
"0.600347... | 0.7154914 | 0 |
db cursor as a "self closing" context manager | def cursor(cls) -> Iterator[sqlite3.Cursor]:
with closing(cls.db.cursor()) as cur:
yield cur | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cursor(self):\n with self.connection() as conn:\n cursor = conn.cursor(prepared=True)\n try:\n yield cursor\n finally:\n cursor.close()",
"def cursor():\n dbh = handle()\n return dbh.cursor()",
"def cursor(self):\n with self... | [
"0.7609911",
"0.7451035",
"0.73391515",
"0.73391515",
"0.7098719",
"0.70769083",
"0.7069774",
"0.70652825",
"0.70240337",
"0.69698375",
"0.6927731",
"0.69276625",
"0.6879431",
"0.6833794",
"0.6830395",
"0.6811575",
"0.6784924",
"0.6755978",
"0.67383385",
"0.6733037",
"0.67103... | 0.77426666 | 0 |
Get the available pollutants per country from the summary. | def pollutants_per_country(cls) -> dict[str, dict[str, int]]:
with cls.cursor() as cur:
cur.execute(
"SELECT country_code, pollutant, pollutant_id FROM summary"
)
output: dict[str, dict[str, int]] = defaultdict(dict)
for country_code, pollutant, p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_top_country(self):\n tabular_format_countries_list = [['Canada', 66, '20'], ['United States', 33, '10']]\n\n result = InstallationStatistics.get_statistics_top_country(tabular_format_countries_list)\n\n self.assertEqual('Canada', result)",
"def get_countries():\n call = build_cal... | [
"0.58904153",
"0.56610507",
"0.5657063",
"0.54212266",
"0.54170454",
"0.53987294",
"0.53270453",
"0.5311308",
"0.52836245",
"0.5188203",
"0.51842904",
"0.51799196",
"0.5174705",
"0.516637",
"0.51484",
"0.5143588",
"0.5081845",
"0.5025447",
"0.50168353",
"0.49986464",
"0.49953... | 0.6624939 | 0 |
Darkens the given color by multiplying luminosity by the given amount. Input can be matplotlib color string, hex string, or RGB tuple. | def darken_color(color, amount=0.5):
import matplotlib.colors as mc
import colorsys
try:
c = mc.cnames[color]
except:
c = color
c = colorsys.rgb_to_hls(*mc.to_rgb(c))
return colorsys.hls_to_rgb(c[0], amount * c[1], c[2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_lightness(color, amount=0.5):\n import matplotlib.colors as mc\n import colorsys\n try:\n c = mc.cnames[color]\n except:\n c = color\n c = colorsys.rgb_to_hls(*mc.to_rgb(c))\n return colorsys.hls_to_rgb(c[0], max(0, min(1, amount * c[1])), c[2])",
"def _lighten_color(co... | [
"0.725701",
"0.70771843",
"0.7057821",
"0.7057821",
"0.7057821",
"0.7057821",
"0.7057821",
"0.7057821",
"0.6648363",
"0.6628755",
"0.65275615",
"0.6517876",
"0.65105426",
"0.62327015",
"0.61098164",
"0.6095843",
"0.6092338",
"0.60866326",
"0.6059547",
"0.6035964",
"0.6009311"... | 0.81315416 | 0 |
Function needed for backwards compatibility with the old "col" argument in plt functions. It returns the default color 'C0' if both arguments are None. If 'color' is not None, it always uses that. If 'color' is None and 'col' is an integer, it returns the corresponding 'CN' color. If 'col' is neither None nor integer, ... | def get_color(col, color):
if color is None and col is None:
return 'C0'
if col is None:
return color
if not isinstance(col, int):
raise ValueError("`col` must be an integer. Consider using `color` instead.")
return 'C{}'.format(col) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _color_for_labels(label_color, default_color, seq_index):\n if label_color is None:\n if hasattr(default_color, '__getitem__'):\n c = default_color[seq_index]\n else:\n c = default_color\n else:\n c = label_color\n\n return c or 'black'",
"def getColor(col=... | [
"0.69194543",
"0.65208554",
"0.61030096",
"0.58912325",
"0.5869798",
"0.58372813",
"0.5826115",
"0.58039564",
"0.57599896",
"0.57347935",
"0.5713629",
"0.56824017",
"0.5678672",
"0.5661202",
"0.5658636",
"0.56532097",
"0.5652371",
"0.5651904",
"0.56345254",
"0.5624993",
"0.56... | 0.8174092 | 0 |
Render suborganizations like it is originally made in collective.contact.core. | def render_original_suborgs(self):
original_suborgs_view = self.context.restrictedTraverse('@@original-suborganizations')
return original_suborgs_view() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organizations(self):\n self.elements('organizations')",
"def sub_organization(self) -> object:\n return self._sub_organization",
"def organization(request, id):\n org = get_object_or_404(Organization, pk=id)\n context = {\n 'org': org,\n 'cover': modify_image_url(str(org.c... | [
"0.6251725",
"0.6150702",
"0.594913",
"0.5577881",
"0.5523968",
"0.55234843",
"0.5503316",
"0.54320455",
"0.53701484",
"0.5356018",
"0.53543377",
"0.53503627",
"0.52751493",
"0.52619004",
"0.5256815",
"0.5246703",
"0.52364534",
"0.51886845",
"0.5175095",
"0.5121588",
"0.51048... | 0.71478117 | 0 |
Return group title. If self.short, turn "My config (My suffix)" into "My suffix". | def group_title(self, group):
group_title = group.getProperty('title')
if self.short:
splitted = group_title.split('(')
if len(splitted) > 1:
group_title = group_title.split('(')[-1][:-1]
return html.escape(group_title) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return f\"{self._group.friendly_name} {GROUP_SUFFIX}\"",
"def abbreviate_title(s):\n if u'Group ' in s:\n return s.replace(u'Group ', u'')\n else:\n parts = s.split(None, 1)\n if len(parts) < 2:\n return s\n genus, rest = s.split(None, 1)\n ... | [
"0.6838066",
"0.6740804",
"0.6598238",
"0.6544966",
"0.64837915",
"0.6482191",
"0.6465803",
"0.6433619",
"0.6433619",
"0.6433619",
"0.6433619",
"0.6433619",
"0.6433619",
"0.6433619",
"0.6433619",
"0.63969857",
"0.6358775",
"0.6357756",
"0.6357756",
"0.6346445",
"0.633116",
... | 0.75570285 | 0 |
Returns a list of top 10 video IDs in the descending order of view count from the VIDEOS table. | def get_most_viewed(self): # WORKS
self.cur.execute("SELECT video_ID FROM videos ORDER BY CAST(view_count as decimal) DESC LIMIT 10")
most_viewed_video_IDs = []
for ID in self.cur.fetchall():
most_viewed_video_IDs.append(ID[0])
return most_viewed_video_IDs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def popular():\r\n d = data_loader.vid_patient_tuples_dict\r\n most_popular_videos = []\r\n for k in sorted(d, key=lambda k: len(d[k]), reverse=True):\r\n most_popular_videos.append(k)\r\n return most_popular_videos",
"def get_most_popular_talks_by_views(videos):\r\n return sorted(videos, k... | [
"0.7012187",
"0.6970375",
"0.69525117",
"0.64749527",
"0.6374998",
"0.6189566",
"0.6091879",
"0.59435105",
"0.58874273",
"0.58376026",
"0.5828731",
"0.5826369",
"0.58129585",
"0.57645524",
"0.57359713",
"0.57298183",
"0.5721471",
"0.5713073",
"0.57077444",
"0.56908333",
"0.56... | 0.80609137 | 0 |
Checks if the entered username and password corresponds to a valid user in the USERS and ADMINS table. | def is_valid_user(self, username, password): # WORKS
done1 = self.cur.execute("SELECT password FROM users WHERE username=\"{}\"".format(username))
done2 = self.cur.execute("SELECT username FROM admins WHERE username=\"{}\"".format(username))
if done1 == 0 and done2 == 0: # If both queries are un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_user(self):\n try:\n if (self.get_user()[0][0] == self.username) and (self.check_password(self.password)):\n return True\n else:\n return False\n except:\n return False",
"def validate(self) -> bool:\n if not super().va... | [
"0.73799044",
"0.73681056",
"0.7302386",
"0.7233658",
"0.7211134",
"0.71928614",
"0.7071615",
"0.7062441",
"0.70173335",
"0.698397",
"0.6976572",
"0.6945523",
"0.6932524",
"0.6915142",
"0.68958944",
"0.6830708",
"0.6821252",
"0.6783548",
"0.67477894",
"0.6739477",
"0.6738232"... | 0.79998374 | 0 |
Updates the password of the user in the USERS table. | def update_password(self, username, password): #WORKS
password_hash = generate_password_hash(password)
try:
self.cur.execute("UPDATE users SET password = \"{}\" WHERE username = \"{}\"".format(password_hash, username))
self.db.commit()
except:
self.db.rollback... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_password(self, user, password):\n user.password = hashers.make_password(password)",
"def update_user_password(self, username):\n parser_password.add_argument('password',\n type=validate_password, required=True,\n nul... | [
"0.8231751",
"0.78945357",
"0.7791965",
"0.77891487",
"0.7711647",
"0.76875335",
"0.76627403",
"0.7620926",
"0.7619506",
"0.7600196",
"0.7599043",
"0.7467108",
"0.7440784",
"0.7408987",
"0.7402097",
"0.73598385",
"0.7357057",
"0.73238444",
"0.7320691",
"0.7301765",
"0.7280018... | 0.83124804 | 0 |
Updates VIDEOS table with video ID, uploader username and video title in the VIDEOS table. | def upload_video(self, video_ID, username, title): #WORKS
try:
view_count = 0
self.cur.execute("INSERT INTO videos VALUES(\"{}\", \"{}\", \"{}\", {}, NULL)".format(video_ID, title, username, view_count))
self.db.commit()
except:
self.db.rollback() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_watched(self, username, video_ID): #WORKS\n try:\n done = self.cur.execute(\"SELECT * FROM watched WHERE username = \\\"{}\\\" AND video_ID = \\\"{}\\\"\".format(username, video_ID))\n if done == 1: # If the query was successful, one row exists\n self.cur.exec... | [
"0.6349348",
"0.6306322",
"0.61023533",
"0.6064381",
"0.596619",
"0.58223826",
"0.580957",
"0.57428473",
"0.5715386",
"0.5588825",
"0.558088",
"0.55619055",
"0.5524529",
"0.5521689",
"0.5521673",
"0.5514653",
"0.549211",
"0.54767346",
"0.540602",
"0.53847206",
"0.53525865",
... | 0.7231752 | 0 |
Returns the title of the video with the corresponding video ID from the VIDEOS table. | def get_video_title(self, video_ID): #WORKS
try:
self.cur.execute("SELECT video_title FROM videos WHERE video_ID = \"{}\"".format(video_ID))
title = self.cur.fetchone()[0]
return title
except:
return "Error getting title" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video_title(self):\n # type: () -> string_types\n return self._video_title",
"def fetch_title(self, movie_id):\n movie = tmdbsimple.Movies(movie_id)\n request = movie.info()\n\n return movie.title",
"def get_video_title(self, response):\n return response.css(\".wat... | [
"0.73725605",
"0.73459566",
"0.68171036",
"0.6612213",
"0.6597776",
"0.6552867",
"0.6513855",
"0.6465385",
"0.64621156",
"0.6405156",
"0.63849044",
"0.6364947",
"0.63489693",
"0.63430095",
"0.6326501",
"0.63252646",
"0.6307263",
"0.6270719",
"0.6268202",
"0.62612736",
"0.6237... | 0.870934 | 0 |
Updates the view count for the corresponding video ID in the VIDEOS table. | def update_view_count(self, video_ID): #WORKS
try:
self.cur.execute("UPDATE videos SET view_count = view_count + 1 WHERE video_ID = \"{}\"".format(video_ID)) # Adds 1 to the existing value.
self.db.commit()
except:
self.db.rollback() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_view(self):\n self.count_views += 1\n self.save(update_fields=['count_views'])",
"def viewedVideo(videoId):\n\n if videoId in movieViewCounts:\n movieViewCounts['videoId'] += 1\n rearrangeMovieArray()\n else:\n movieViewCounts[videoId] = movieViewCounts.get(vide... | [
"0.7064346",
"0.6721617",
"0.6701861",
"0.66842705",
"0.6578619",
"0.6062659",
"0.60547465",
"0.5957374",
"0.570349",
"0.55510974",
"0.55167",
"0.5509747",
"0.55055314",
"0.54816747",
"0.54619527",
"0.54047817",
"0.53531873",
"0.53466165",
"0.5299417",
"0.52944577",
"0.523298... | 0.85083866 | 0 |
Adds the username and video ID to the WATCHED table. | def update_watched(self, username, video_ID): #WORKS
try:
done = self.cur.execute("SELECT * FROM watched WHERE username = \"{}\" AND video_ID = \"{}\"".format(username, video_ID))
if done == 1: # If the query was successful, one row exists
self.cur.execute("UPDATE watched... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_video(self, video_ID, username, title): #WORKS\n try:\n view_count = 0\n self.cur.execute(\"INSERT INTO videos VALUES(\\\"{}\\\", \\\"{}\\\", \\\"{}\\\", {}, NULL)\".format(video_ID, title, username, view_count))\n self.db.commit()\n except:\n se... | [
"0.6086152",
"0.57009065",
"0.56358945",
"0.53841454",
"0.5195449",
"0.5182404",
"0.5076552",
"0.50528973",
"0.5050366",
"0.50346893",
"0.4994848",
"0.4992545",
"0.4992251",
"0.49108446",
"0.49001947",
"0.48948443",
"0.48926342",
"0.4877786",
"0.4862681",
"0.48542246",
"0.485... | 0.6312015 | 0 |
Returns the username of the user that uploaded the video with the corresponding video ID. | def get_video_uploader(self, video_ID): #WORKS
try:
done = self.cur.execute("SELECT uploader FROM videos WHERE video_ID = \"{}\"".format(video_ID))
uploader = self.cur.fetchone()[0]
return uploader
except:
return "Error getting username" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_username(self):\n \n if self.livestream_user:\n return self.livestream_user\n \n if not self.original_url:\n return ''\n \n p = urlparse.urlparse(self.original_url)\n path_term = p.path.split('/')\n \n if len(path_term) == 3:\n if path_ter... | [
"0.641162",
"0.6297686",
"0.62112385",
"0.6183648",
"0.61202574",
"0.6118284",
"0.6118284",
"0.60755575",
"0.60589427",
"0.6056746",
"0.6052009",
"0.60495865",
"0.60349935",
"0.60280395",
"0.60260934",
"0.59834033",
"0.59371436",
"0.592973",
"0.5911973",
"0.5911973",
"0.59119... | 0.7299416 | 0 |
Returns the date when the video was uploaded from VIDEOS table. | def get_upload_date(self, video_ID):
self.cur.execute("SELECT upload_date FROM videos WHERE video_ID = \"{}\"".format(video_ID))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creation_date_video(path_to_file):\n print(\"Last modified: %s\" % time.ctime(os.path.getmtime(path_to_file)))\n print(\"Created: %s\" % time.ctime(os.path.getctime(path_to_file)))\n # return os.path.getctime(path_to_file)",
"def get_video_publishing_date(self, response):\n return response.cs... | [
"0.67232716",
"0.664657",
"0.6525809",
"0.6451199",
"0.60254365",
"0.5908486",
"0.5774346",
"0.577208",
"0.5711206",
"0.56496966",
"0.56353307",
"0.56186765",
"0.5566246",
"0.5565173",
"0.55505514",
"0.55357367",
"0.5500961",
"0.5481637",
"0.5464294",
"0.545051",
"0.5447081",... | 0.8272224 | 0 |
Returns a random video ID from the VIDEOS table. | def get_random_ID(self): # WORKS
self.cur.execute("SELECT video_ID FROM videos ORDER BY RAND() LIMIT 1") # Selects video_ID from 1 random row.
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_random_video(self):\n if self.video_id != None:\n print(f\"Stopping video: {self.video_id}\")\n video_info = self._video_library.get_all_videos()\n a_list = []\n for i in video_info:\n a_list.append(video_info.title)\n a = random.randint(0, len(a_li... | [
"0.71237874",
"0.6802794",
"0.66620547",
"0.6631764",
"0.65763164",
"0.652057",
"0.6504283",
"0.6471329",
"0.6438538",
"0.64067775",
"0.6335452",
"0.62914747",
"0.6240138",
"0.622437",
"0.6203106",
"0.6133006",
"0.6125536",
"0.61106116",
"0.61035943",
"0.6083071",
"0.60749495... | 0.8383894 | 0 |
Returns a list of video IDs watched by the user from the WATCHED table. | def get_watched(self, username): # WORKS
self.cur.execute("SELECT video_ID FROM watched WHERE username = \"{}\"".format(username))
watched_video_IDs = []
for ID in self.cur.fetchall():
watched_video_IDs.append(ID[0])
return watched_video_IDs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_watchlists(user_id):\n # user = User.query.get(user_id)\n\n watchlists = Watchlist.query.filter(Watchlist.user_id == user_id).all()\n\n return watchlists",
"def view_watched_movies(username: str) -> list[tuple]:\n with connection:\n return connection.execute(VIEW_WATCHED_MOVIES, (usern... | [
"0.67549974",
"0.65549356",
"0.6315282",
"0.6313528",
"0.6200434",
"0.59684265",
"0.58552593",
"0.582406",
"0.5795294",
"0.57791805",
"0.5738125",
"0.5682407",
"0.5559121",
"0.5552698",
"0.5543253",
"0.548902",
"0.5432729",
"0.53820366",
"0.5381979",
"0.5370005",
"0.53598285"... | 0.7925406 | 0 |
Returns the view count of the video with the corresponding video_ID. | def get_views(self, video_ID): # WORKS
self.cur.execute("SELECT view_count FROM videos WHERE video_ID = \"{}\"".format(video_ID))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_video_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM videos\")\n return done",
"def get_total_view_count(self):\n done = self.cur.execute(\"SELECT CAST(SUM(view_count) AS DECIMAL(10, 0)) FROM videos\")\n count = self.cur.fetchone()[0]\n return count",
"... | [
"0.761071",
"0.75590754",
"0.69225156",
"0.6922456",
"0.6912246",
"0.67060393",
"0.66868937",
"0.6662882",
"0.66086495",
"0.6460109",
"0.6458782",
"0.6238349",
"0.61823505",
"0.6116544",
"0.6043676",
"0.5959066",
"0.59584385",
"0.5930518",
"0.5929406",
"0.59067196",
"0.589002... | 0.86707634 | 0 |
Deletes the video from the database. | def delete_video(self, video_ID): # WORKS
try:
self.cur.execute("DELETE FROM videos WHERE video_ID = \"{}\"".format(video_ID))
self.db.commit()
os.remove('static/videos/' + str(video_ID) + '.mp4')
os.remove('static/images/' + str(video_ID) + '.jpg')
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, video_id):\n\n query = \"\"\"\n DELETE\n FROM videos\n WHERE id = ?\n \"\"\"\n\n result = Model.execute(query, (video_id,))\n\n return True if result.rowcount == 1 else False",
"def delete_video(event_id, video_id):... | [
"0.73853815",
"0.7320137",
"0.7140269",
"0.7012943",
"0.68155694",
"0.68002707",
"0.6758645",
"0.673845",
"0.66331697",
"0.6509932",
"0.64298964",
"0.6426344",
"0.64150596",
"0.6369963",
"0.63509244",
"0.6335846",
"0.6276657",
"0.6246866",
"0.62201995",
"0.61679363",
"0.61584... | 0.80854136 | 0 |
Returns a list of all videos uploaded by the user with the corresponding username. | def get_uploaded(self, username): # WORKS
self.cur.execute("SELECT video_ID FROM videos WHERE uploader = \"{}\"".format(username))
uploaded_video_IDs = []
for ID in self.cur.fetchall():
uploaded_video_IDs.append(ID[0])
return uploaded_video_IDs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_videos(self, user):\n raise NotImplementedError",
"def get_videos(self, user):\n youtube = self.get_service(user)\n # Gather a list of all IDs of the channels that the user is subscribed to.\n\n request = youtube.subscriptions().list(part='snippet', mine=True, maxResults=50)\n... | [
"0.7457652",
"0.70110625",
"0.6914144",
"0.67175204",
"0.66885626",
"0.66715485",
"0.65637517",
"0.650081",
"0.63107467",
"0.6185674",
"0.6175587",
"0.6173313",
"0.6156263",
"0.61157864",
"0.61140674",
"0.61111623",
"0.610035",
"0.6082998",
"0.6081753",
"0.6064207",
"0.606155... | 0.76592815 | 0 |
Returns True if the username is present in the USERS table. | def is_user_present(self, username): # WORKS
done = self.cur.execute("SELECT username FROM users WHERE username = \"{}\"".format(username))
if done == 1:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_user(self, username):\n return username in self.user_table",
"def exists_in_db(self) -> bool:\n query = \"\"\"SELECT * \n FROM Users \n WHERE Username=?;\"\"\"\n return len(self.db.fetchall(query, values=(self.username,))) > 0",
"def userExists(s... | [
"0.87660056",
"0.8282255",
"0.8261474",
"0.8222565",
"0.8204488",
"0.82031626",
"0.80208254",
"0.8006336",
"0.7955199",
"0.7936963",
"0.79178756",
"0.7800615",
"0.7787375",
"0.7707385",
"0.7649575",
"0.7648491",
"0.76411563",
"0.7584512",
"0.7551436",
"0.75165737",
"0.7509721... | 0.84399956 | 1 |
Returns a maximum of 5 random video IDS from the VIDEOS table. | def get_five_random_IDs(self):
self.cur.execute("SELECT video_ID FROM videos ORDER BY RAND() LIMIT 5")
IDs = []
for ID in self.cur.fetchall():
IDs.append(ID[0])
return IDs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_ID(self): # WORKS\n self.cur.execute(\"SELECT video_ID FROM videos ORDER BY RAND() LIMIT 1\") # Selects video_ID from 1 random row.\n return self.cur.fetchone()[0]",
"def play_random_video(self):\n #[ expression for item in list if conditional ]\n unflagged_videos = [vi... | [
"0.6715515",
"0.64491177",
"0.6400545",
"0.62863255",
"0.6253465",
"0.6194111",
"0.60011953",
"0.5903442",
"0.58871764",
"0.5860959",
"0.5722055",
"0.56515723",
"0.5600675",
"0.55765074",
"0.55703866",
"0.5550376",
"0.554172",
"0.5523666",
"0.55215514",
"0.5498145",
"0.547405... | 0.8638253 | 0 |
Adds the video ID to the FLAGS table. | def flag_ID(self, username, video_ID):
done = self.cur.execute("SELECT video_ID from flags WHERE video_ID = \"{}\"".format(video_ID))
if done == 0: # Not yet flagged by any user.
try:
self.cur.execute("INSERT INTO flags VALUES(\"{}\", \"{}\")".format(video_ID, username))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flag_video(self, video_id, flag_reason=\"\"):\n print(\"flag_video needs implementation\")",
"def flag_video(self, video_id, flag_reason=\"\"):\n print(\"flag_video needs implementation\")",
"def flag_video(self, video_id, flag_reason=\"Not supplied\"):\n if self._video_library.get_vid... | [
"0.61697054",
"0.61697054",
"0.59331304",
"0.5890974",
"0.5873597",
"0.5819396",
"0.58043575",
"0.56625754",
"0.56442875",
"0.5636927",
"0.5559719",
"0.5406017",
"0.5353216",
"0.5332353",
"0.53097856",
"0.53097856",
"0.53097856",
"0.53097856",
"0.52876383",
"0.5258258",
"0.52... | 0.7335359 | 0 |
Returns username of flagger of the video ID. | def get_flagger(self, video_ID):
self.cur.execute("SELECT username FROM flags WHERE video_ID = \"{}\"".format(video_ID))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username(self) -> str:",
"def username(self) -> str:",
"def get_username(self):\n \n if self.livestream_user:\n return self.livestream_user\n \n if not self.original_url:\n return ''\n \n p = urlparse.urlparse(self.original_url)\n path_term = p.path.split('... | [
"0.66205794",
"0.66205794",
"0.654406",
"0.6508635",
"0.64972645",
"0.649588",
"0.649588",
"0.649588",
"0.64898527",
"0.6474817",
"0.6413524",
"0.64029515",
"0.6389556",
"0.6362839",
"0.63601893",
"0.633342",
"0.63329804",
"0.6328341",
"0.6322044",
"0.6317198",
"0.6309156",
... | 0.7351368 | 0 |
Returns a list of flagged videos from FLAGS table. | def get_flagged(self):
self.cur.execute("SELECT video_ID FROM flags")
flagged_IDs = []
for ID in self.cur.fetchall():
flagged_IDs.append(ID[0])
return flagged_IDs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flag_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM flags\")\n return done",
"def video_list(self) -> list:\n return self._video_list",
"def flags(self):\n flags = self.Flags\n return [x for x in self.FLAGS_VALUES if flags & x]",
"def flag_video(self,... | [
"0.59645563",
"0.5873178",
"0.568918",
"0.56486547",
"0.5638592",
"0.5637153",
"0.5600878",
"0.5555618",
"0.5444726",
"0.54408675",
"0.5410056",
"0.54091847",
"0.54091847",
"0.53483254",
"0.53305584",
"0.5321235",
"0.53046703",
"0.5302004",
"0.5291554",
"0.52836734",
"0.52633... | 0.7468905 | 0 |
Returns number of videos of user flagged by other users. | def get_flagged_num(self, username):
done = self.cur.execute("SELECT flags.video_ID FROM videos,flags WHERE videos.video_ID = flags.video_ID AND videos.uploader = \"{}\"".format(username))
return done | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_video_count(self, username):\n done = self.cur.execute(\"SELECT video_ID FROM videos WHERE uploader = \\\"{}\\\"\".format(username))\n return done",
"def get_videos_count(khoros_object, user_settings=None, user_id=None, login=None, email=None):\n user_settings = _process_settings_an... | [
"0.7523925",
"0.6733229",
"0.63746536",
"0.6260079",
"0.6234799",
"0.6202073",
"0.6138974",
"0.60228616",
"0.59842056",
"0.59239006",
"0.58508843",
"0.57385385",
"0.56081533",
"0.5598427",
"0.55598706",
"0.55529207",
"0.5511205",
"0.5501292",
"0.5490401",
"0.5456478",
"0.5449... | 0.7559999 | 0 |
Returns number of videos in the VIDEOS table. | def get_video_count(self):
done = self.cur.execute("SELECT video_ID FROM videos")
return done | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_videos(self):\n return len(self.videos)",
"def get_views(self, video_ID): # WORKS\n self.cur.execute(\"SELECT view_count FROM videos WHERE video_ID = \\\"{}\\\"\".format(video_ID))\n return self.cur.fetchone()[0]",
"def count_video_meta(self):\n metas = YoutubeVideoMeta.qu... | [
"0.82683337",
"0.7324633",
"0.7128083",
"0.705069",
"0.69343895",
"0.6885626",
"0.67733824",
"0.6640411",
"0.6491014",
"0.6469322",
"0.646399",
"0.6452515",
"0.6443329",
"0.6419106",
"0.6393201",
"0.6381259",
"0.63574064",
"0.6304938",
"0.6295545",
"0.6275196",
"0.6236569",
... | 0.8443735 | 0 |
Returns number of flagged videos in the VIDEOS table. | def get_flag_count(self):
done = self.cur.execute("SELECT video_ID FROM flags")
return done | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_video_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM videos\")\n return done",
"def count_videos(self):\n return len(self.videos)",
"def get_flagged_num(self, username):\n done = self.cur.execute(\"SELECT flags.video_ID FROM videos,flags WHERE videos.video_ID ... | [
"0.77415645",
"0.7383914",
"0.7020163",
"0.6678284",
"0.665664",
"0.65775",
"0.6527008",
"0.6088112",
"0.6027986",
"0.5998238",
"0.59302866",
"0.5903157",
"0.5892386",
"0.5889689",
"0.5801771",
"0.57928395",
"0.57669586",
"0.5756323",
"0.57086295",
"0.57069635",
"0.55990773",... | 0.78880155 | 0 |
Returns number of videos uploaded by the user from VIDEOS table. | def get_user_video_count(self, username):
done = self.cur.execute("SELECT video_ID FROM videos WHERE uploader = \"{}\"".format(username))
return done | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_video_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM videos\")\n return done",
"def count_videos(self):\n return len(self.videos)",
"def get_videos_count(khoros_object, user_settings=None, user_id=None, login=None, email=None):\n user_settings = _process_settings_... | [
"0.78139544",
"0.75539935",
"0.7544837",
"0.7432486",
"0.7323483",
"0.7125673",
"0.67732424",
"0.65567315",
"0.6395767",
"0.6310928",
"0.617212",
"0.6141789",
"0.61221516",
"0.6081953",
"0.6072957",
"0.6031323",
"0.6020064",
"0.59904104",
"0.59509546",
"0.5947412",
"0.5942394... | 0.8299071 | 0 |
Returns number of views on all videos uploaded by the user from VIDEOS table. | def get_user_view_count(self, username):
self.cur.execute("SELECT CAST(SUM(view_count) AS DECIMAL(10, 0)) FROM videos WHERE uploader = \"{}\"".format(username))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_views(self, video_ID): # WORKS\n self.cur.execute(\"SELECT view_count FROM videos WHERE video_ID = \\\"{}\\\"\".format(video_ID))\n return self.cur.fetchone()[0]",
"def get_user_video_count(self, username):\n done = self.cur.execute(\"SELECT video_ID FROM videos WHERE uploader = \\\"... | [
"0.78535324",
"0.73414063",
"0.7268572",
"0.7242948",
"0.7227357",
"0.7038107",
"0.6769094",
"0.6495603",
"0.61842996",
"0.6127641",
"0.6106806",
"0.6050462",
"0.5961984",
"0.5937592",
"0.5896913",
"0.58555007",
"0.58042014",
"0.5800134",
"0.57887244",
"0.57736903",
"0.575693... | 0.77311456 | 1 |
Returns the video ID of the video uploaded by the user with most views. | def get_best_video_ID(self, username):
self.cur.execute("SELECT video_ID FROM videos WHERE uploader = \"{}\" ORDER BY view_count DESC".format(username))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_most_viewed(self): # WORKS\n self.cur.execute(\"SELECT video_ID FROM videos ORDER BY CAST(view_count as decimal) DESC LIMIT 10\")\n most_viewed_video_IDs = []\n for ID in self.cur.fetchall():\n most_viewed_video_IDs.append(ID[0])\n return most_viewed_video_IDs",
"de... | [
"0.73119",
"0.6968702",
"0.6827411",
"0.6747587",
"0.6502863",
"0.63282526",
"0.61964494",
"0.6152308",
"0.60951626",
"0.60849375",
"0.60268444",
"0.5864287",
"0.5831303",
"0.57951087",
"0.5778345",
"0.57708985",
"0.5739955",
"0.5739642",
"0.5708817",
"0.5672575",
"0.5642984"... | 0.79390967 | 0 |
Returns the video ID of the user's favourite video. | def get_fav_video_ID(self, username):
self.cur.execute("SELECT video_ID FROM watched WHERE username = \"{}\" ORDER BY CAST(count as decimal) DESC".format(username))
return self.cur.fetchone()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_favourites(self, username):\n self.cur.execute(\"SELECT video_ID FROM favourites WHERE username = \\\"{}\\\"\".format(username))\n favourites = []\n for ID in self.cur.fetchall():\n favourites.append(ID[0])\n return favourites",
"def get_video_id(self):\n \n ... | [
"0.65228593",
"0.63321614",
"0.62774026",
"0.6269768",
"0.6204911",
"0.6177124",
"0.61610436",
"0.6155687",
"0.6141831",
"0.6064822",
"0.60217404",
"0.59948564",
"0.5968167",
"0.59483504",
"0.59404963",
"0.5832371",
"0.57427824",
"0.55508655",
"0.55254495",
"0.5523709",
"0.55... | 0.7914319 | 0 |
Returns list of videos favourited by the user from FAVOURITES table. | def get_favourites(self, username):
self.cur.execute("SELECT video_ID FROM favourites WHERE username = \"{}\"".format(username))
favourites = []
for ID in self.cur.fetchall():
favourites.append(ID[0])
return favourites | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorites(self):\n path = self._get_path('favorites')\n \n response = self._GET(path)\n self._set_attrs_to_values(response)\n return self._clean_return(response)",
"def get_favorites(self, user_id=None):\n if not user_id:\n user_id = self.user_id\n\n ... | [
"0.6658978",
"0.65604013",
"0.63298076",
"0.6320051",
"0.6193292",
"0.61421627",
"0.6124463",
"0.6117669",
"0.61098194",
"0.60715187",
"0.6000728",
"0.59898365",
"0.5935978",
"0.59210503",
"0.5835391",
"0.5789033",
"0.57097423",
"0.5699663",
"0.5696433",
"0.56601214",
"0.5636... | 0.77204025 | 0 |
Deletes the video from FLAGS table. | def delete_flag(self, video_ID):
try:
self.cur.execute("DELETE FROM flags WHERE video_ID = \"{}\"".format(video_ID))
self.db.commit()
except:
self.db.rollback() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_video(self, video_ID): # WORKS\n try:\n self.cur.execute(\"DELETE FROM videos WHERE video_ID = \\\"{}\\\"\".format(video_ID))\n self.db.commit()\n os.remove('static/videos/' + str(video_ID) + '.mp4')\n os.remove('static/images/' + str(video_ID) + '.jpg'... | [
"0.63553846",
"0.62756777",
"0.59260094",
"0.5923239",
"0.56933457",
"0.5685907",
"0.5635672",
"0.5605303",
"0.55901444",
"0.5575058",
"0.5559596",
"0.555788",
"0.55328196",
"0.5488664",
"0.54750097",
"0.5451727",
"0.5449797",
"0.5439663",
"0.543637",
"0.5435362",
"0.5417179"... | 0.7183327 | 0 |
Returns a dictionary of video IDs, title and a list of video titles. For Fuzzy Search. | def video_dict(self):
self.cur.execute("SELECT video_ID, video_title FROM videos")
videos = {}
video_titles = []
for video in self.cur.fetchall():
video_titles.append(video[1])
videos.update({video[0] : video[1]})
return videos, video_titles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_for_title(session, search_term):\n try:\n s_result = session.search_movie(search_term)\n shows = {}\n\n # made the keys of the namedtuple a digit for ease of selecting the correct one later\n for count, result in enumerate(s_result):\n show_id = count\n ... | [
"0.63464946",
"0.63003737",
"0.62933",
"0.6200125",
"0.6154921",
"0.5969483",
"0.59387124",
"0.58837193",
"0.58710206",
"0.58641505",
"0.58581513",
"0.58392906",
"0.58041734",
"0.57863104",
"0.5770734",
"0.57627165",
"0.5736344",
"0.5699794",
"0.56986773",
"0.5690014",
"0.568... | 0.7131889 | 0 |
Drop any existing tables and create the SBML classes schema. URI is a string interpreted as an rfc1738 compatible database URI. | def init(db_uri, drop):
engine = create_engine(db_uri)
if drop.lower().startswith("y"):
Base.metadata.drop_all(bind=engine)
Base.metadata.create_all(bind=engine) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tear_down():\n db.flush()\n for table in metadata.tables.values():\n db.execute(table.delete())",
"def teardown_db():\n engine = config['tg.app_globals'].sa_engine\n connection = engine.connect()\n\n # INFO - D.A. - 2014-12-04\n # Recipe taken from bitbucket:\n # https... | [
"0.634737",
"0.6157549",
"0.61463475",
"0.6144049",
"0.6128537",
"0.61086684",
"0.60474813",
"0.60012245",
"0.59740967",
"0.5970951",
"0.59620595",
"0.5883204",
"0.58639604",
"0.5856733",
"0.5855191",
"0.5840111",
"0.5809529",
"0.5783441",
"0.57696843",
"0.5762156",
"0.574712... | 0.65057254 | 0 |
switch from hostview to services view and viceversa | def _controller_switch(self, widget, test, newpage):
if newpage == 0:
# switch to host view
self.on_services_view = False
try:
self.main.workspace.remove(self.services_view.notebook)
except:
# empty workspace
self.main.workspace.remove(self.main.welcome_note)
try:
self.main.works... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __handle_view_adversary(self, gamestate_component):",
"def _handler_control_view(self,event):\n self._mgr.LoadPerspective(\n\t\t\tself._perspectives['control_view'])",
"def on_action_set_view(self, content):\n self._view = content['view']\n self.refresh_traits_widget()",
"def view_sy... | [
"0.5940524",
"0.5927022",
"0.5788933",
"0.57363355",
"0.56955576",
"0.56856203",
"0.5660334",
"0.56177056",
"0.5548212",
"0.5532452",
"0.5528236",
"0.54758364",
"0.54498",
"0.54244065",
"0.5414866",
"0.5408288",
"0.53973764",
"0.53850013",
"0.5373715",
"0.53456396",
"0.534563... | 0.6726968 | 0 |
add / remove host scope | def _scope(self, widget, add, targets):
for host_obj in targets:
self.engine.database.switch_scope(add, host_obj)
self._sync() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_or_remove_host(self, event):\n try:\n host = self.caller.search(self.lhs).Dominion\n except AttributeError:\n return\n if event:\n if host == event.main_host:\n raise self.CalCmdError(\"The main host cannot be removed.\")\n if ... | [
"0.5854914",
"0.5846827",
"0.5810849",
"0.5483697",
"0.54318076",
"0.5403112",
"0.52607644",
"0.52530056",
"0.5238579",
"0.517643",
"0.51754916",
"0.5110414",
"0.50496083",
"0.50493914",
"0.50262",
"0.5015864",
"0.49888277",
"0.4976647",
"0.49699435",
"0.49688184",
"0.4946202... | 0.6768299 | 0 |
show / hide outofscope targets | def _showhide_scope(self, widget):
self.host_list.toggle_scope()
self.services_list.toggle_scope()
self._sync() #reset=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_visible(self, target: bool) -> None:\n hidden = not target\n for ent in self.child_ents():\n ent.vis_shown = target\n ent.hidden = hidden\n for solid in ent.solids:\n solid.vis_shown = target\n solid.hidden = hidden\n\n for... | [
"0.6622147",
"0.6241229",
"0.61932164",
"0.60345656",
"0.56592095",
"0.56346786",
"0.56018",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.5549058",
"0.55428123",
"0.54548293",
"0.54544175"... | 0.6492323 | 1 |
show / hide logs notebook | def _showhide_logs(self, widget):
if self.main.view_logs.get_active():
self.logger.notebook.show()
else:
self.logger.notebook.hide() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_messages(self):\n self.masterlog.revealme()",
"def viewLog(self, event):\n logcontent = \"\"\n if Config.GetOption(\"ActLog\") == True:\n\n logFrame = wx.Frame(None, -1, \"View Log\", size=(500, 500))\n panel5 = wx.Panel(logFrame)\n data = wx.richtext.... | [
"0.6446135",
"0.62465423",
"0.6045043",
"0.57627416",
"0.5757946",
"0.5732056",
"0.5711249",
"0.5697132",
"0.56432843",
"0.56414294",
"0.5610665",
"0.56100166",
"0.56040424",
"0.5602165",
"0.55740595",
"0.55740595",
"0.553568",
"0.5534145",
"0.5527125",
"0.543908",
"0.5409417... | 0.8210805 | 0 |
serviceslist service click event this will generate the scene in the scenes dictionary | def services_row(self, listbox, cell, listboxrow):
self._clear_workspace()
if str(cell) in self.scenes["services_view"]:
# check if the scene was already loaded
self.services_view = self.scenes["services_view"][str(cell)]
else:
# get selected port
(model, pathlist) = self.services_list.servicestr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_select_scene(self, scene):\n pass",
"def mouse_click(self, tv, event, alltargets=False):\n\t\t\n\t\tif event.button == 3:\n\n\t\t\t# create the menu and submenu objects\n\t\t\trightclickmenu = Gtk.Menu()\n\t\t\t\n\t\t\ttargets = []\n\t\t\tgeneric = []\n\n\t\t\t# check\n\t\t\tif self.on_ser... | [
"0.5816325",
"0.56552047",
"0.5570884",
"0.54380053",
"0.5428393",
"0.5369113",
"0.5291489",
"0.5280148",
"0.52580625",
"0.5250973",
"0.52037925",
"0.51483935",
"0.5143417",
"0.51365715",
"0.5135276",
"0.511065",
"0.50677156",
"0.50518566",
"0.5048181",
"0.5044973",
"0.504153... | 0.64644957 | 0 |
Specifies the type of threshold criteria Expected value is 'DynamicThresholdCriterion'. | def criterion_type(self) -> str:
return pulumi.get(self, "criterion_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n criterion_type: str,\n metric_name: str,\n name: str,\n operator: str,\n threshold: float,\n time_aggregation: str,\n dimensions: Optional[Sequence['outputs.MetricDimensionRes... | [
"0.64736396",
"0.6007544",
"0.5649433",
"0.560247",
"0.549276",
"0.5436013",
"0.53366566",
"0.5287433",
"0.5287433",
"0.5266749",
"0.5145749",
"0.5077199",
"0.5077199",
"0.5077199",
"0.5077199",
"0.5077199",
"0.5073182",
"0.49863455",
"0.49803627",
"0.4960917",
"0.4954998",
... | 0.62579083 | 1 |
Name of the metric. | def metric_name(self) -> str:
return pulumi.get(self, "metric_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metric_name(self) -> str:\n return self._metric_name",
"def metric_name(self) -> str:\n return self._values.get('metric_name')",
"def metric_name(self) -> str:\n return self._values.get('metric_name')",
"def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"m... | [
"0.9080742",
"0.89493376",
"0.89493376",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.85680395",
"0.8507669",
"0.8280574",
"0.8280574",
"0.8276878",
"0.8003284",
"0.7678508",
"0.7518795",
"0.74013215",
"0.7... | 0.9079402 | 1 |
the criteria time aggregation types. | def time_aggregation(self) -> str:
return pulumi.get(self, "time_aggregation") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __timeRestriction():\n restriction = {\"M\": [\"7:00\", \"9:30\"],\n \"A\": [\"16:00\", \"19:30\"]}\n return restriction",
"def get_group_types(self):\r\n pass",
"def durations_per_type(self):\n pass",
"def get_report_event_types():\n post_data = reque... | [
"0.57325155",
"0.56621933",
"0.5633908",
"0.5444428",
"0.5374539",
"0.5365551",
"0.5315507",
"0.53074354",
"0.5227702",
"0.521846",
"0.5201579",
"0.5184422",
"0.5163588",
"0.51626277",
"0.5159124",
"0.5154171",
"0.5151809",
"0.51419383",
"0.51266676",
"0.5125911",
"0.5125398"... | 0.5837583 | 0 |
Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | def skip_metric_validation(self) -> Optional[bool]:
return pulumi.get(self, "skip_metric_validation") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_metric(self) -> 'LossMetric':\n raise NotImplementedError()",
"def test_error_on_invalid_metric(self):\n self.ocp_data.get(\"rates\", [])[0][\"metric\"][\"name\"] = \"invalid_metric\"\n with tenant_context(self.tenant):\n serializer = CostModelSerializer(data=self.ocp_d... | [
"0.53630054",
"0.53394985",
"0.5327985",
"0.53265405",
"0.5294704",
"0.52564716",
"0.5245898",
"0.52369255",
"0.51835185",
"0.5125754",
"0.51243144",
"0.5101995",
"0.5097013",
"0.50950426",
"0.5072278",
"0.50347114",
"0.50080895",
"0.49950373",
"0.49888673",
"0.49649054",
"0.... | 0.5530519 | 0 |
the id of the action group to use. | def action_group_id(self) -> Optional[str]:
return pulumi.get(self, "action_group_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self):\n return self._group",
"def group_id(self):\n return self._id",
"def getId(self):\n return _libsbml.Group_getId(self)",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")"... | [
"0.77482456",
"0.7099057",
"0.70216775",
"0.69734263",
"0.69734263",
"0.6817101",
"0.6817101",
"0.6817101",
"0.6800052",
"0.6768275",
"0.6752699",
"0.6614591",
"0.66105044",
"0.6609539",
"0.66095287",
"0.65748924",
"0.6553389",
"0.6553389",
"0.6553389",
"0.6470345",
"0.644829... | 0.84645164 | 0 |
Specifies the metric alert criteria for multiple resource that has multiple metric criteria. | def __init__(__self__, *,
odata_type: str,
all_of: Optional[Sequence[Any]] = None):
pulumi.set(__self__, "odata_type", 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria')
if all_of is not None:
pulumi.set(__self__, "all_of", all_of) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n odata_type: str,\n all_of: Optional[Sequence['outputs.MetricCriteriaResponse']] = None):\n pulumi.set(__self__, \"odata_type\", 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria')\n if all_of is not None:\n pulumi.set(... | [
"0.6026406",
"0.51808137",
"0.50900877",
"0.48364025",
"0.48048016",
"0.47682977",
"0.47614202",
"0.47585002",
"0.47174513",
"0.4685663",
"0.46267575",
"0.45938715",
"0.45914057",
"0.45757943",
"0.4562624",
"0.45517758",
"0.4543452",
"0.44907033",
"0.4478374",
"0.44422543",
"... | 0.6174168 | 0 |
Specifies the metric alert criteria for a single resource that has multiple metric criteria. | def __init__(__self__, *,
odata_type: str,
all_of: Optional[Sequence['outputs.MetricCriteriaResponse']] = None):
pulumi.set(__self__, "odata_type", 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria')
if all_of is not None:
pulumi.set(__self__, "a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n odata_type: str,\n all_of: Optional[Sequence[Any]] = None):\n pulumi.set(__self__, \"odata_type\", 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria')\n if all_of is not None:\n pulumi.set(__self__, \"all_of\", all_o... | [
"0.58963656",
"0.5050068",
"0.50446075",
"0.5041433",
"0.4687035",
"0.46119368",
"0.46008843",
"0.45889822",
"0.4584769",
"0.45769805",
"0.45517832",
"0.45421895",
"0.453245",
"0.45204303",
"0.45196065",
"0.4497745",
"0.44730958",
"0.44707868",
"0.44672188",
"0.4449448",
"0.4... | 0.58667475 | 1 |
The list of metric criteria for this 'all of' operation. | def all_of(self) -> Optional[Sequence['outputs.MetricCriteriaResponse']]:
return pulumi.get(self, "all_of") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_criteria(self):\r\n c = []\r\n if self.minmax_criteria is not None:\r\n c.extend(self.minmax_criteria.values())\r\n\r\n return c",
"def _get_criteria(self):\n for molecule in self.values():\n molecule.get_criterion()",
"def criteria(self) -> google.proto... | [
"0.67560923",
"0.6633179",
"0.6580229",
"0.63893026",
"0.63158923",
"0.622334",
"0.6153101",
"0.6063113",
"0.6005794",
"0.6004159",
"0.5937065",
"0.5884718",
"0.58846277",
"0.58748585",
"0.58309233",
"0.57818455",
"0.5748338",
"0.5677755",
"0.564924",
"0.563005",
"0.56039816"... | 0.76627076 | 0 |
the criteria threshold value that activates the alert. | def threshold(self) -> float:
return pulumi.get(self, "threshold") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threshold(self,thresholdValue):\n # TO DO\n pass",
"def threshold(self):\n return self._threshold",
"def threshold(self):\n return self._threshold",
"def threshold(self) -> pulumi.Input[float]:\n return pulumi.get(self, \"threshold\")",
"def threshold(self) -> pulumi.... | [
"0.73743016",
"0.70379454",
"0.70379454",
"0.68876785",
"0.68876785",
"0.68876785",
"0.68876785",
"0.68876785",
"0.68192774",
"0.680575",
"0.6726792",
"0.6726792",
"0.6726792",
"0.6714316",
"0.6673342",
"0.6624437",
"0.66214246",
"0.6594564",
"0.6541047",
"0.6528297",
"0.6473... | 0.720796 | 1 |
the criteria time aggregation types. | def time_aggregation(self) -> str:
return pulumi.get(self, "time_aggregation") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __timeRestriction():\n restriction = {\"M\": [\"7:00\", \"9:30\"],\n \"A\": [\"16:00\", \"19:30\"]}\n return restriction",
"def get_group_types(self):\r\n pass",
"def durations_per_type(self):\n pass",
"def get_report_event_types():\n post_data = reque... | [
"0.57344794",
"0.56620973",
"0.56332326",
"0.54430324",
"0.537375",
"0.53651655",
"0.5316518",
"0.5306705",
"0.522799",
"0.52185",
"0.5201779",
"0.51849824",
"0.5163754",
"0.5163674",
"0.51582074",
"0.5154635",
"0.5152362",
"0.51422703",
"0.5126015",
"0.5125766",
"0.51251775"... | 0.5836969 | 1 |
Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. | def skip_metric_validation(self) -> Optional[bool]:
return pulumi.get(self, "skip_metric_validation") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_metric(self) -> 'LossMetric':\n raise NotImplementedError()",
"def test_error_on_invalid_metric(self):\n self.ocp_data.get(\"rates\", [])[0][\"metric\"][\"name\"] = \"invalid_metric\"\n with tenant_context(self.tenant):\n serializer = CostModelSerializer(data=self.ocp_d... | [
"0.53630054",
"0.53394985",
"0.5327985",
"0.53265405",
"0.5294704",
"0.52564716",
"0.5245898",
"0.52369255",
"0.51835185",
"0.5125754",
"0.51243144",
"0.5101995",
"0.5097013",
"0.50950426",
"0.5072278",
"0.50347114",
"0.50080895",
"0.49950373",
"0.49888673",
"0.49649054",
"0.... | 0.5530519 | 1 |
The number of failed locations. | def failed_location_count(self) -> float:
return pulumi.get(self, "failed_location_count") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_locations(self):\n return len(self.locations)",
"def error_count(self):\n return len(self.errors)",
"def get_location_count(self):\n return len(self.matrix)",
"def getNumFailures(self):\n return _libsbml.SBMLValidator_getNumFailures(self)",
"def counter(self) -> int:\n ... | [
"0.7635072",
"0.731395",
"0.7201066",
"0.7142528",
"0.7035365",
"0.7015711",
"0.7007765",
"0.69258225",
"0.68146944",
"0.67784536",
"0.6741547",
"0.6715071",
"0.6687685",
"0.66636074",
"0.6612101",
"0.66006345",
"0.6583765",
"0.657363",
"0.65356445",
"0.64715993",
"0.64708614... | 0.88088346 | 0 |
The Application Insights web test Id. | def web_test_id(self) -> str:
return pulumi.get(self, "web_test_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def application_insights_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"application_insights_id\")",
"def web_id(self):\n return self._web_id",
"def application_insights_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"application_insights_id\")",
"def unique_id(se... | [
"0.66186976",
"0.65677965",
"0.63514495",
"0.6283445",
"0.62499297",
"0.62100387",
"0.620081",
"0.6128248",
"0.61215425",
"0.61211663",
"0.61199594",
"0.6118256",
"0.60975343",
"0.608105",
"0.6077543",
"0.6069551",
"0.60655457",
"0.6046929",
"0.6040767",
"0.6037821",
"0.59609... | 0.8475513 | 0 |
Pass in an index_name to be deleted. Raises an IndexNotFound exception if the index is missing on the node. | def delete_index(index_name):
try:
ES.indices.delete(index=[index_name])
except NotFoundError:
raise IndexNotFound(index_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_index(self, index_name):\n return AlgoliaUtils_request(self.headers, self.write_hosts, \"DELETE\", \"/1/indexes/%s\" % quote(index_name.encode('utf8'), safe=''), self.timeout)",
"def delete_index(client, index_name):\n\n client.conn.indices.delete(index=index_name)",
"def delete_index(inde... | [
"0.8237238",
"0.7881001",
"0.7858925",
"0.7437211",
"0.7330589",
"0.7315321",
"0.7273739",
"0.71558714",
"0.6878204",
"0.678057",
"0.6732007",
"0.6623749",
"0.65878093",
"0.641981",
"0.6412163",
"0.63936096",
"0.63936096",
"0.63688356",
"0.6324927",
"0.63195837",
"0.62910414"... | 0.7987658 | 1 |
Create a document based on instance of a model. Returns None if successful and an error string if it's not. | def create_document(obj):
index = obj.get_index_name()
doc_type = obj.get_document_type()
body = obj.get_document_body()
exists = ES.exists(index=index, doc_type=doc_type, id=obj.pk)
if not exists:
ES.create(index=index, doc_type=doc_type, body=body, id=obj.pk)
return None
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createDocument(self, document):\n data = self.createDocumentAll([document])\n try:\n return data[0]\n except: pass",
"def _create(self, model_obj: Any):\n conn = self.provider.get_connection()\n\n try:\n model_obj.save(\n refresh=True,\n ... | [
"0.6608516",
"0.64796597",
"0.64517796",
"0.61958444",
"0.6173862",
"0.61243945",
"0.61194986",
"0.60412973",
"0.6032219",
"0.6027759",
"0.5958546",
"0.59557694",
"0.59135765",
"0.5911795",
"0.58485466",
"0.5826208",
"0.581102",
"0.5803531",
"0.5795227",
"0.5792533",
"0.57392... | 0.70802784 | 0 |
Get a document based on the instance. Raises a DocumentNotFound exception if the document is not found on the index. | def get_document(obj):
try:
return ES.get(
index=obj.get_index_name(), doc_type=obj.get_document_type(), id=obj.pk)
except NotFoundError:
raise DocumentNotFound(obj.get_index_name(), obj.pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_document(self, url: str) -> Optional[Document]:\n return self._index.get(url, None)",
"def get_document(self, *args, **kwargs):\n return self._documents_manager.get_document(*args, **kwargs)",
"def fetch_search_document(self, index):\n assert self.pk, \"Object must have a primary k... | [
"0.7509461",
"0.7387173",
"0.73165256",
"0.7186353",
"0.7047284",
"0.691709",
"0.67920256",
"0.6776412",
"0.6762755",
"0.6755989",
"0.6754873",
"0.6712459",
"0.6660555",
"0.6659591",
"0.6637856",
"0.6628112",
"0.6611464",
"0.66052437",
"0.6423677",
"0.6407396",
"0.63751054",
... | 0.8279071 | 0 |
Updates the document from the index. This should be called via a signal whenever the obj gets saved. | def update_document(obj):
index = obj.get_index_name()
doc_type = obj.get_document_type()
body = dict(doc=obj.get_document_body())
try:
ES.update(index=index, doc_type=doc_type, body=body, id=obj.pk)
except NotFoundError:
raise DocumentNotFound(obj.get_index_name(), obj.pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_document(self):\n pass",
"def update_index(self, document):\n\t\tix = self.get_index()\n\n\t\twith ix.searcher():\n\t\t\twriter = AsyncWriter(ix)\n\t\t\twriter.delete_by_term(self.id, document[self.id])\n\t\t\twriter.add_document(**document)\n\t\t\twriter.commit(optimize=True)",
"def update(s... | [
"0.7923124",
"0.7285815",
"0.6899564",
"0.674032",
"0.6725462",
"0.6640049",
"0.660014",
"0.6572434",
"0.6434228",
"0.6432489",
"0.6420817",
"0.64181536",
"0.6382638",
"0.6373966",
"0.63086164",
"0.6277604",
"0.6238722",
"0.6227302",
"0.62181604",
"0.620456",
"0.6190446",
"... | 0.7662434 | 1 |
Delete a document from the index. This should be called via a signal when the obj gets deleted. | def delete_document(obj):
index = obj.get_index_name()
doc_type = obj.get_document_type()
try:
ES.delete(index=index, doc_type=doc_type, id=obj.pk)
except NotFoundError:
raise DocumentNotFound(obj.get_index_name(), obj.pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_document(self, index: str, doc_id: str):\n self.__client__.delete(index=index, id=doc_id, refresh=True)",
"def delete_document(self):\n pass",
"def document_delete(index_name, doc_type, doc_id):\n resp = es.delete(index=index_name, doc_type=doc_type, id=doc_id)\n print(resp)",
... | [
"0.7964796",
"0.78938943",
"0.73939353",
"0.7126827",
"0.7060756",
"0.70206016",
"0.69494325",
"0.68832034",
"0.6852863",
"0.6832469",
"0.6787975",
"0.6762144",
"0.6753757",
"0.67328316",
"0.6688438",
"0.6654373",
"0.66286594",
"0.66176105",
"0.6594214",
"0.6585247",
"0.65852... | 0.82214576 | 0 |
Initialize all models with statistics about cases. It can either receive an explicit data frame with cases/deaths statistics, a callable object that receives a model and return the desired cases. If none of these are passed, it assumes that the cases should be initialized from the region. | def init_cases(self: T, data=None, regions=None, raises=True, **kwargs) -> T:
kwargs["regions"] = {} if regions is None else regions
kwargs.setdefault("real", True)
for i, report in enumerate(self._reports):
print(i, report.model.region.id, report.model.region.name)
call... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_case_metrics(self) -> None:\n for case in self.cases:\n graph_distance, time_distance = extract_case_distances(self.process_model_graph, case)\n case.graph_distance = graph_distance\n case.time_distance = time_distance",
"def setUp(self):\n self.df_ca... | [
"0.6291318",
"0.5654613",
"0.54874974",
"0.54647356",
"0.5348363",
"0.5319384",
"0.52680993",
"0.5202522",
"0.5159842",
"0.5042738",
"0.5006515",
"0.49600613",
"0.49330205",
"0.4911519",
"0.48664477",
"0.4865999",
"0.4861922",
"0.48572075",
"0.4801666",
"0.4765036",
"0.474230... | 0.6120037 | 1 |
Initialize R0 from cases data. | def init_R0(self: T, *args, raises=False, **kwargs) -> T:
for report in self._reports:
call_safe_if(raises, report, report.init_R0, *args, **kwargs)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_from_data(self, data):\n self.data = data\n self.norm_data()",
"def _initialize_data(self):\n self.reset_count = 0\n self._idn_no_firmware = \"KEPCO,BOP 50-20,E1234,\"\n self._firmware = 2.6\n self._init_data()",
"def __init__(self, RA, DEC, AST, I_data, Q_dat... | [
"0.59208477",
"0.56282413",
"0.55791855",
"0.55220836",
"0.5463353",
"0.5461818",
"0.54125756",
"0.54075485",
"0.54050404",
"0.5377448",
"0.5374158",
"0.5368257",
"0.53553694",
"0.53524685",
"0.5322364",
"0.53080964",
"0.53036493",
"0.5297168",
"0.5273072",
"0.5272792",
"0.52... | 0.5742876 | 1 |
Create a data frame from simulations by extracting all columns in the given list at the selected times. | def report_time_columns_data(
self, columns, times=(7, 15, 30, 60), info=None, dtype=None
) -> pd.DataFrame:
locs = [t - self._niter - 1 for t in times]
col_names = [*map(col_name, columns)]
columns = [*map(to_column, columns)]
rows = []
n_times = len(times)
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_results_frames(results_df, times):\n # coherence check:\n for t in times:\n assert results_df['t'].iloc[0] <= t <= results_df['t'].iloc[-1], \\\n 'time={} is outside the results_df range'.format(t)\n\n frames = pd.DataFrame(columns=results_df.columns)\n ... | [
"0.6223679",
"0.5822695",
"0.54896504",
"0.5359699",
"0.5312869",
"0.52989984",
"0.52454346",
"0.52427393",
"0.52333844",
"0.52250195",
"0.521591",
"0.51858145",
"0.516235",
"0.51598847",
"0.51354957",
"0.51323926",
"0.5114523",
"0.50899047",
"0.50888115",
"0.50779295",
"0.50... | 0.60906285 | 1 |
Convert column identifier into a function with signature ``(model, dates) > data`` used to retrieve data from models. | def to_column(col):
if callable(col):
return col
def fn(model, dates):
return model[col + ":dates"].loc[dates]
return fn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _column_picker(attr, objects):\n getter = attr\n if not isinstance(getter, collections.Callable):\n getter = functools.partial(_getter, attr=attr)\n data = list(map(getter, objects))\n return data",
"def column_expression(self, col):\n return getattr(func, self.impl.as_binary)(\n ... | [
"0.5211079",
"0.5170846",
"0.5079418",
"0.50410134",
"0.49328077",
"0.4853944",
"0.47984892",
"0.4774336",
"0.47474742",
"0.47217572",
"0.47154763",
"0.46920162",
"0.4674512",
"0.4672522",
"0.46535575",
"0.46521583",
"0.46270508",
"0.46200037",
"0.46099943",
"0.45872426",
"0.... | 0.7271065 | 0 |
Return a column name from its representation. | def col_name(col):
if isinstance(col, str):
return col
return col.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getColName(self, col):\n try:\n return chr(ord('a') + col)\n except:\n return col",
"def getColName(self, col):\n try:\n return chr(ord('a') + col)\n except:\n return col",
"def column_name(name):\n # Only needs exceptions to standa... | [
"0.6985993",
"0.6985993",
"0.6697623",
"0.6697423",
"0.66891664",
"0.6680047",
"0.6680047",
"0.65051776",
"0.6443857",
"0.6407808",
"0.64052784",
"0.63633984",
"0.6293007",
"0.62478954",
"0.6172242",
"0.61684376",
"0.6145761",
"0.6128707",
"0.6106663",
"0.6092888",
"0.6059596... | 0.7314486 | 0 |
Safely call function that involves a report. If function raises an error, log the error with report.log_error() method. | def call_safe(*args, **kwargs):
report, func, *args = args
if not callable(func):
func = getattr(report, func)
try:
return func(*args, **kwargs)
except Exception as ex:
msg = f"{type(ex).__name__}: {ex}"
report.log_error(msg, code=ex)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report(self) -> computation_base.Computation:\n return self._report_fn",
"def report():\n pass",
"def ReportError(text):\n raise IOError(text)",
"def safe_run(self, function: Callable) -> Callable:\n\n def wrapper(*args, **kwargs) -> Any:\n result = None\n try:\n... | [
"0.5956291",
"0.59040755",
"0.5768061",
"0.56814855",
"0.5658449",
"0.5552167",
"0.55508804",
"0.5523072",
"0.54855865",
"0.5481154",
"0.5434947",
"0.54322094",
"0.54240316",
"0.5408172",
"0.5373893",
"0.5319612",
"0.5294064",
"0.52918303",
"0.52637404",
"0.5253317",
"0.52443... | 0.70517135 | 0 |
Load calibrations into the database | def load(db):
r = db.truncate_table('calibrations')
print "Truncated calibrations table"
# Allowed columns
columns = ['class','asset_uid','start_date','serial','name','value','notes']
# Read in calibration data
file_mask = "repos/asset-management/calibration/*"
directory_list = glob.glob(file_mask)
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_calibrations(self):\r\n try:\r\n self.calibrations = load_calibrations(os.path.join(os.path.dirname(__file__),\r\n \"..\",\r\n \"calibrations\"))\r\n for... | [
"0.66712004",
"0.60240537",
"0.5914236",
"0.5840371",
"0.58154255",
"0.576945",
"0.5760715",
"0.57121146",
"0.5657287",
"0.54794174",
"0.5456236",
"0.5436734",
"0.5418373",
"0.5412157",
"0.54064906",
"0.5387298",
"0.53832376",
"0.53711975",
"0.53692985",
"0.5359947",
"0.53554... | 0.7634288 | 0 |
Initialize blockchain + open transfers data from a file | def load_data(self):
try:
with open("blockchain.txt", mode="r") as f:
file_content = f.readlines()
blockchain = json.loads(file_content[0][:-1])
# OrderedDict
updated_blockchain = []
for block in blockchain:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, node_id: str, ledger: Ledger):\n self.ledger = ledger\n self.node_id = node_id\n filename = '../files/blockchain' + node_id\n self.file_path = filename + '.txt'\n self.pickle_path = filename + '.pickle'\n self.blockchain = []\n self.saved_blocks =... | [
"0.6819916",
"0.67035604",
"0.66686094",
"0.63645846",
"0.6158963",
"0.60149735",
"0.6014652",
"0.5977203",
"0.59086215",
"0.5895487",
"0.5874486",
"0.5856579",
"0.5804675",
"0.5782293",
"0.57734174",
"0.5761372",
"0.575894",
"0.5711983",
"0.5692812",
"0.5642049",
"0.56329024... | 0.74270946 | 0 |
Save blockchain + open transactions snapshot to a file | def save_data(self):
try:
with open("blockchain.txt", mode="w") as f:
dict_chain = []
for block in self.__chain:
temp = Block(
block.index,
block.previous_hash,
[tx.__dict__ fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_data(self):\n try:\n with open('blockchain-{}.txt'.format(self.node_id), mode='w') as f:\n # save the block object like a dictionary\n saveable_chain = [block.__dict__ for block in \n [Block(block_el.index, block_el.previous_hash, [tx.__dict__... | [
"0.7076406",
"0.69661385",
"0.69495887",
"0.6570535",
"0.6515428",
"0.6430769",
"0.6341623",
"0.61975217",
"0.61354846",
"0.5901512",
"0.5844782",
"0.57685465",
"0.5766446",
"0.5762449",
"0.5744786",
"0.559941",
"0.55762947",
"0.5561207",
"0.5560014",
"0.5559062",
"0.5533427"... | 0.71053904 | 0 |
Generate a proof of work for the open transfers, the hash of the previous block and a random number (which is guessed until it fits). | def proof_of_work(self):
last_block = self.__chain[-1]
last_hash = hash_block(last_block)
proof = 0
# Try different PoW numbers and return the first valid one
while not Verification.valid_proof(self.__open_transfers, last_hash, proof):
proof += 1
print(proof)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proof_of_work(self):\n last_block = self.__chain[-1]\n last_hash = hash_block(last_block)\n proof = 0\n # Try different PoW numbers and return the first valid one\n while not Verification.valid_proof(self.__open_transactions, self.__open_chipsactions, self.__open_messsactions... | [
"0.6767066",
"0.66403455",
"0.65471375",
"0.64007163",
"0.6309153",
"0.63058364",
"0.62753505",
"0.6238329",
"0.62287176",
"0.587455",
"0.58743477",
"0.58078885",
"0.5754991",
"0.57458746",
"0.5647915",
"0.55475503",
"0.55412304",
"0.5443019",
"0.5433007",
"0.54295146",
"0.54... | 0.7421745 | 0 |
Credit points to user. No checks required | def credit_points(self, user, signature, amount=0.0):
if self.hosting_node == None:
return False
transfer = Transfer(user, signature, amount)
if not Wallet.verify_transfer(transfer):
return False
self.__open_transfers.append(transfer)
# participants.add(us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def credit(ctx, *args):\n users_mentioned = ctx.message.mentions\n user_mention = ctx.author.mention\n credit = 0\n for arg in args:\n try:\n credit = float(arg)\n await ctx.message.channel.send(user_mention+\", ... | [
"0.67803556",
"0.6295979",
"0.6186931",
"0.613697",
"0.6093839",
"0.60716486",
"0.60704947",
"0.6043647",
"0.6004744",
"0.59940994",
"0.5894286",
"0.578384",
"0.57367456",
"0.57338923",
"0.57108366",
"0.56967866",
"0.5689059",
"0.5688745",
"0.5649226",
"0.5633477",
"0.5628388... | 0.6380664 | 1 |
Debit points from user. Need to verify sufficient points. | def debit_points(self, user, signature, amount=0.0):
if self.hosting_node == None:
return False
transfer = Transfer(user, signature, amount)
if Verification.verify_single_transfer(transfer, self.get_balance):
self.__open_transfers.append(transfer)
# participan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def debit(ctx, *args):\n users_mentioned = ctx.message.mentions\n user_mention = ctx.author.mention\n debit = 0\n for arg in args:\n try:\n debit = float(arg)\n await ctx.message.channel.send(user_mention+\", we ... | [
"0.7162027",
"0.6481338",
"0.62580574",
"0.6227215",
"0.62052536",
"0.62043357",
"0.61842215",
"0.6171607",
"0.60994",
"0.6087336",
"0.5968105",
"0.59115344",
"0.58873826",
"0.58712614",
"0.5836311",
"0.57992375",
"0.5780527",
"0.5765384",
"0.57358664",
"0.56935155",
"0.56838... | 0.6702249 | 1 |
Return a list of all connected peer nodes. | def get_peer_nodes(self):
return list(self.__peer_nodes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peer_list_all(self):\n return self.client.call('GET', self.name + 'peer-list/all')",
"def peer_list_reachable(self):\n return self.client.call('GET', self.name + 'peer-list/reachable')",
"def list_nodes(self):\n return self.ironic_client.node.list()",
"def get_all_nodes(self):\n ... | [
"0.7392017",
"0.7002911",
"0.69784385",
"0.69227666",
"0.6882579",
"0.6802107",
"0.6790903",
"0.67703485",
"0.6725873",
"0.6651802",
"0.66069186",
"0.6584915",
"0.6584334",
"0.6553957",
"0.6539939",
"0.6539486",
"0.6532221",
"0.65297973",
"0.6525269",
"0.6498614",
"0.6494739"... | 0.849466 | 1 |
PWM signal generator with direction signal for DC motors. The generated PWM frequency is approximately 25 KHz (25 MHz / 1024). The duty cycle can be fully controlled via a 11bit speed input. pwm Output PWM signal dir Output direction signal en_n Active low output enable signal clk25 25 MHz clock input speed 11bit signe... | def MotorDriver(pwm, dir, en_n, clk25, speed, rst_n, optocoupled):
assert speed.min >= -2**10 and speed.max <= 2**10, 'wrong speed constraints'
# account for optocouplers
LOW_OPTO = LOW if not optocoupled else HIGH
HIGH_OPTO = HIGH if not optocoupled else LOW
CNT_MAX = 2**10 - 1;
@instance
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DriveMotor():\n\n # cnt overflows at 25KHz (approximately)\n cnt = intbv(0, min = 0, max = CNT_MAX + 1)\n\n # 10-bit duty cycle\n duty_cycle = intbv(0)[10:]\n\n while True:\n yield clk25.posedge, rst_n.negedge\n if rst_n == LOW:\n cnt[:] =... | [
"0.72991186",
"0.59104633",
"0.59067416",
"0.5808709",
"0.57710034",
"0.55783296",
"0.5572987",
"0.556341",
"0.55390674",
"0.5538115",
"0.55178213",
"0.54046714",
"0.53235024",
"0.52748865",
"0.5251518",
"0.5233242",
"0.52320105",
"0.5143564",
"0.5135276",
"0.51250744",
"0.51... | 0.67168146 | 1 |
Generate PWM, dir and brake signals for motor | def DriveMotor():
# cnt overflows at 25KHz (approximately)
cnt = intbv(0, min = 0, max = CNT_MAX + 1)
# 10-bit duty cycle
duty_cycle = intbv(0)[10:]
while True:
yield clk25.posedge, rst_n.negedge
if rst_n == LOW:
cnt[:] = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pinForward, pinBackward, pinControlStraight,pinLeft, pinRight, pinControlSteering):\n\n self.pinForward = pinForward\n self.pinBackward = pinBackward\n self.pinControlStraight = pinControlStraight\n self.pinLeft = pinLeft\n self.pinRight = pinRight\n sel... | [
"0.68529385",
"0.668605",
"0.66161764",
"0.65924245",
"0.6577437",
"0.6463951",
"0.64577734",
"0.6276354",
"0.6200667",
"0.6139953",
"0.6101437",
"0.60730547",
"0.60481185",
"0.5986419",
"0.5972765",
"0.59718496",
"0.5970813",
"0.5956315",
"0.59275526",
"0.5881428",
"0.587313... | 0.71569127 | 0 |
List the train files of the `fold` | def train_files(self, fold: int) -> List[str]:
all_files = []
for fold_id, inputs in enumerate(self.folds):
if fold_id != fold:
all_files += inputs
return all_files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_files(self, fold: int) -> List[str]:\n for fold_id, inputs in enumerate(self.folds):\n if fold_id == fold:\n return inputs\n\n return []",
"def get_filenames(is_training, data_dir):\n\n return [ os.path.join(data_dir, 'train_'+str(shard_id)+'.tfrecord') for sha... | [
"0.7803892",
"0.7056508",
"0.685751",
"0.6802941",
"0.6719647",
"0.6520368",
"0.6367892",
"0.630924",
"0.6265436",
"0.6264137",
"0.6258419",
"0.6230313",
"0.6188211",
"0.6176572",
"0.613282",
"0.61127913",
"0.61011595",
"0.6052456",
"0.6017384",
"0.6011248",
"0.60108817",
"... | 0.85289615 | 0 |
List the test files of the `fold` | def test_files(self, fold: int) -> List[str]:
for fold_id, inputs in enumerate(self.folds):
if fold_id == fold:
return inputs
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_files(self, fold: int) -> List[str]:\n all_files = []\n for fold_id, inputs in enumerate(self.folds):\n if fold_id != fold:\n all_files += inputs\n\n return all_files",
"def get_test_files():\n test_files = os.listdir('./test')\n return [\n cr... | [
"0.72677034",
"0.6791726",
"0.6743439",
"0.66508114",
"0.6589474",
"0.6483487",
"0.64777064",
"0.64353925",
"0.63842374",
"0.63672245",
"0.63392895",
"0.6315878",
"0.628178",
"0.6266603",
"0.6184447",
"0.61463225",
"0.61328787",
"0.6130215",
"0.6115048",
"0.60493886",
"0.6045... | 0.84272116 | 0 |
Write the fold split to the `filepath` as json. | def write_folds_to_json(self, filepath: str):
with open(filepath, "w") as f:
json.dump(
{
"isH5": self.is_h5_dataset,
"folds": self.folds,
},
f,
indent=4,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, filepath):\n with open(filepath, 'w') as f:\n json.dump(self, f, indent=2)",
"def to_json_file(self, path):\n with open(path, 'w') as f:\n f.write(self.to_json())",
"def write(self, _filepath=None):\n _json_txt = json.dumps(self.json_dict, indent=2)\n ... | [
"0.6139056",
"0.6109978",
"0.605159",
"0.60373914",
"0.5996056",
"0.59922796",
"0.5931721",
"0.58890903",
"0.58890903",
"0.58382756",
"0.583775",
"0.58370245",
"0.5836411",
"0.5768725",
"0.5767711",
"0.57568604",
"0.5755295",
"0.57466227",
"0.57201326",
"0.5704674",
"0.567035... | 0.8364435 | 0 |
Return environment variables starting with prefix | def env_vars(prefix):
return {k: v for k, v in os.environ.items() if k.startswith(prefix)} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _preload_existing_vars(prefix: str) -> Store:\n if not prefix:\n # If prefix is empty just return all the env variables.\n return environ\n\n prefixed = {}\n\n # Prefix is not empty, do the search and replacement:\n for env_name, env_value in environ.items():\n if not env_name.... | [
"0.72910964",
"0.67468673",
"0.6712868",
"0.65505886",
"0.6517432",
"0.63044226",
"0.6295789",
"0.62780964",
"0.6245079",
"0.62119097",
"0.62084186",
"0.6165885",
"0.6108197",
"0.6107439",
"0.60423785",
"0.60150474",
"0.5988261",
"0.59737426",
"0.59527063",
"0.5928965",
"0.59... | 0.8657359 | 0 |
Get an object from cache, return `None` if not found. | def cache_get(item: str) -> object:
item = str(item)
cache = cache_find(item)
# cache_find() will return none if the cache does not exist
# the returned location is guaranteed to exist, so no point checking again.
if cache is not None:
try:
cached = pickle.load(open(cache, "rb"))
except EOFError as ex:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key):\n if key:\n return self.cache_data.get(key)\n else:\n return None",
"def cache_get(self, key: str) -> Optional[bytes]:\n if self.cache is not None:\n return self.cache.get(key)\n return None",
"def get(self, key):\n if key ... | [
"0.7674477",
"0.76137364",
"0.75440174",
"0.75440174",
"0.75393486",
"0.7432243",
"0.73063606",
"0.72476906",
"0.72312814",
"0.72097397",
"0.7185365",
"0.71732783",
"0.71528417",
"0.713144",
"0.7064178",
"0.70147896",
"0.6986404",
"0.697731",
"0.69466746",
"0.6875618",
"0.687... | 0.82087857 | 0 |
Save an item to cache, using a hashed ID. | def cache_save_hashed(item: str, obj: object) -> None:
cache_save(md5(item), obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_save(item: str, obj: object) -> None:\n\titem = str(item)\n\tcache = \"Cached/\" + item\n\n\tcache_create()\n\n\tpickle.dump(obj, open(cache, \"wb\"))\n\tuux.show_debug(\"Cached object to \" + cache)",
"def put(self, key, item):\n if key and item:\n self.cache_data[key] = item",
"de... | [
"0.6912247",
"0.6871242",
"0.6871242",
"0.68123543",
"0.672946",
"0.6583027",
"0.65691537",
"0.65477073",
"0.6547111",
"0.65152246",
"0.6514978",
"0.64275014",
"0.631806",
"0.6274006",
"0.6242404",
"0.6202362",
"0.618209",
"0.6162696",
"0.61198336",
"0.6114743",
"0.60722595",... | 0.76418275 | 0 |
Delete an item from the cache, using a hashed ID. | def cache_remove_hashed(item: str) -> None:
cache_remove(md5(item)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, cache_key):\r\n pass",
"def delete(self, item):\r\n self.fetch()\r\n t = self.make_item_tuple(item)\r\n changed = False\r\n while t in self.data:\r\n self.data.remove(t)\r\n changed = True\r\n \r\n if changed:\r\n ... | [
"0.73074245",
"0.7108162",
"0.7069796",
"0.6890898",
"0.6881778",
"0.68032175",
"0.6778153",
"0.66678333",
"0.65715957",
"0.65388805",
"0.65362626",
"0.6529011",
"0.6476025",
"0.6450751",
"0.6441844",
"0.6438636",
"0.6429002",
"0.6412903",
"0.6373064",
"0.6361154",
"0.6356138... | 0.75325364 | 0 |
Download the file from the provided url to the location. Uses the cache. | def download_file_cached(file_url: str, location: str) -> None:
item = os.path.basename(location)
local = cache_find(item)
if local is None:
# Cached item doesn't exist
cache_create()
download_file(file_url, "Cached/" + item)
copy_file("Cached/" + item, location)
return
# Copy file from cache to locati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download_from_url(self, url):\n target_file_name = self.dir + \"/\" + url.split('/')[-1].split('?')[0]\n urllib.urlretrieve (url, target_file_name)",
"def get_file(url, file_name=None):\n cache_dir = os.path.join(os.path.expanduser(\"~\"), \".jhML\")\n\n if file_name is None:\n fi... | [
"0.77907306",
"0.769478",
"0.7670883",
"0.7608222",
"0.76022357",
"0.75971365",
"0.7591167",
"0.7481028",
"0.7422788",
"0.73972017",
"0.73849773",
"0.7383973",
"0.73804367",
"0.73578197",
"0.7338381",
"0.7335585",
"0.73251",
"0.73097956",
"0.7306151",
"0.7297983",
"0.7275222"... | 0.79674214 | 0 |
Return true if a folder at the provided path exists. | def folder_exists(path: str) -> bool:
return os.path.isdir(path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_exists(self, path):\n\t\tos_path = self._get_os_path(path=path)\n\t\treturn is_folder(self.bucket, os_path)",
"def is_dir(self, path):\n return self.dir_exists(path)",
"def check_if_dir_exists(path):\n\n # From http://stackoverflow.com/questions/8933237/how-to-find-if-directory-exists-in-pyt... | [
"0.8179201",
"0.79332864",
"0.79051244",
"0.79029113",
"0.7897626",
"0.7854854",
"0.7750175",
"0.76297736",
"0.762717",
"0.7530441",
"0.74888587",
"0.7445432",
"0.7384682",
"0.7375725",
"0.7344606",
"0.73166764",
"0.7307144",
"0.7302061",
"0.72769064",
"0.72708213",
"0.726542... | 0.88796943 | 0 |
Relabel array with consecutive values. | def relabel_consecutive(lab, start_from=0):
new_lab = np.empty_like(lab)
new_lab[:] = np.unique(lab, return_inverse=True)[1]
new_lab += start_from
return new_lab | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _relabel(self, a):\n\n labels = list(np.unique(a))\n if 0 in labels:\n labels.remove(0)\n\n if len(labels) == 0:\n return a.copy()\n old_values = np.asarray(labels)\n new_values = np.arange(1, len(labels) + 1, dtype=old_values.dtype)\n\n try:\n ... | [
"0.69688505",
"0.64422935",
"0.6288373",
"0.61246604",
"0.60274583",
"0.59455514",
"0.5938729",
"0.57887626",
"0.5761393",
"0.5696665",
"0.56867516",
"0.56867516",
"0.56587917",
"0.562061",
"0.561991",
"0.560544",
"0.5561162",
"0.5536896",
"0.5529303",
"0.5529303",
"0.5501358... | 0.72478616 | 0 |
Relabel according to overlap with reference. | def relabel_by_overlap(lab, ref_lab):
u1 = np.unique(lab)
u2 = np.unique(ref_lab)
if u1.size > u2.size:
thresh = lab.max() + 1
lab_shifted = lab + thresh
lab_corr = find_label_correspondence(lab_shifted, ref_lab)
lab_shifted = relabel(lab_shifted, new_labels=lab_corr)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_labels(mask1, mask2):\n # Find the object in mask2 that has maximum overlap with an object in max1,\n # (as a fraction of the objects pixels in mask1)\n def get_max_overlap(mask1, mask2, label1):\n # Count overlapping pixels.\n labels, counts = np.unique(mask2[mask1 == label1], re... | [
"0.6455704",
"0.6364087",
"0.6258506",
"0.6226747",
"0.60531056",
"0.60333496",
"0.60238916",
"0.59531003",
"0.5953097",
"0.5881179",
"0.5791674",
"0.57539934",
"0.57377",
"0.56943",
"0.56618845",
"0.5648628",
"0.5617306",
"0.5584542",
"0.55834746",
"0.5574411",
"0.55666256",... | 0.8048359 | 0 |
Map data in source to target according to their labels. Target labels are sorted in ascending order, such that the smallest label indexes the value at position 0 in `source_val`. If `source_lab` is specified, any label in `target_lab` must be in `source_lab`. | def map_to_labels(source_val, target_lab, mask=None, fill=0, axis=0,
source_lab=None):
if mask is not None:
if not isinstance(mask, np.ndarray):
mask = target_lab != mask
target_lab = target_lab[mask]
mapped = map_to_labels(source_val, target_lab, axis=axis,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_remap_values(labels: np.ndarray, label_map: Dict[int, int]) -> np.ndarray:\n for l1, l2 in label_map.items():\n labels[labels == l1] = l2",
"def convert_label(in_volume, label_convert_source, label_convert_target):\n mask_volume = np.zeros_like(in_volume)\n convert_volume = np.zeros_lik... | [
"0.56942385",
"0.56030554",
"0.56030554",
"0.54778296",
"0.5465966",
"0.52517056",
"0.52104473",
"0.5193827",
"0.51464367",
"0.5123239",
"0.51058954",
"0.5102379",
"0.50587285",
"0.50403357",
"0.5035835",
"0.50214636",
"0.50138366",
"0.50128025",
"0.5004057",
"0.49926925",
"0... | 0.80103874 | 0 |
return a string of verify statement. | def gen_v_stmt(q1n, q2n):
return "verify {} {};\n".format(q1n, q2n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(self):\n\n # tekstlig testing om koden fungerer\n text = self.klar_tekst_start + \" ble sendt til mottaker som krypteringen \" + \\\n self.crypto + \".\\nMottaker dekrypterte dette til \" + self.klar_tekst_slutt\n\n return text",
"def format_verification(verification: O... | [
"0.6132083",
"0.6103445",
"0.6096352",
"0.57968384",
"0.5759049",
"0.57580143",
"0.5546414",
"0.5314555",
"0.53042316",
"0.53004193",
"0.5224447",
"0.51929504",
"0.51896125",
"0.518826",
"0.5155716",
"0.51303595",
"0.512667",
"0.5108908",
"0.50595164",
"0.505352",
"0.50520885... | 0.6741842 | 0 |
Prints text to the screen, using the currently active alignment. | def msg(text):
for line in text.splitlines():
if JS.alignment == "left":
print(demarkup(line))
elif JS.alignment == "center":
print(demarkup(line).center(get_terminal_size()[0] - 1))
else:
print(demarkup(line).rjust(get_terminal_size()[0] - 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PrintAt(self,x=0,y=0,text=''):\n self.SetCursor(x,y)\n self.Print(text)",
"def print_text_line():\n print_indentation()\n print(STYLES[parameters[\"Style\"]][\"Vertical line\"], end=\"\")\n for _ in range(parameters[\"Surrounding spaces\"]):\n print(parameters[\"Fill char\"], en... | [
"0.70358264",
"0.6626184",
"0.64501715",
"0.6403515",
"0.63804656",
"0.63767767",
"0.63763213",
"0.63579285",
"0.6340895",
"0.63053125",
"0.62978816",
"0.62961745",
"0.62925726",
"0.6286042",
"0.6282825",
"0.62492776",
"0.62384284",
"0.6171509",
"0.61666787",
"0.614422",
"0.6... | 0.68693316 | 1 |
Convert Tags to Entities | def get_entities(tags):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bio_tag_to_entity_mentions(bio_tags):\n within_entity_mention = False\n mentions = []\n for i, tag in enumerate(bio_tags):\n if not within_entity_mention:\n # start of entity mention\n if 'B-' in tag:\n start = i\n within_entity_mention = True... | [
"0.62833726",
"0.61343277",
"0.60737306",
"0.5947258",
"0.5923205",
"0.58831906",
"0.58670056",
"0.5811215",
"0.58097756",
"0.57908505",
"0.5778241",
"0.57619965",
"0.575832",
"0.5747811",
"0.5735009",
"0.5708459",
"0.5707962",
"0.5704061",
"0.5694413",
"0.56721485",
"0.56528... | 0.7193571 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.