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 |
|---|---|---|---|---|---|---|
Extract event and time relations | def event_time_relations(self):
caption = 'event-time relations in %s' % self.partition
for xmi_path in tqdm(self.xmi_paths, desc=caption):
# does this xmi belong to the sought partition?
xmi_file_name = xmi_path.split('/')[-1]
id = int(xmi_file_name.split('_')[0][-3:])
if id % 8 not i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events_info(request):\n \n global input\n \n if request == 'event-based':\n client_neries = Client_neries()\n \n events = client_neries.getEvents(min_datetime=input['min_date'], \\\n max_datetime=input['max_date'], min_magnitude=input['min_mag'], \\\n max_... | [
"0.5974341",
"0.5903659",
"0.5766911",
"0.5751432",
"0.5742652",
"0.5725592",
"0.57211006",
"0.5718718",
"0.56873685",
"0.56518936",
"0.5628234",
"0.5574481",
"0.55294824",
"0.548288",
"0.5463423",
"0.54617137",
"0.54422045",
"0.5438251",
"0.54358226",
"0.54207003",
"0.541385... | 0.6729224 | 0 |
Load VEGA spectrum once here to be used later. | def test_load_vspec():
global _vspec
_vspec = SourceSpectrum.from_vega() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def t4_loadFile(self):\n print \"subspectrumFile\"\n filename = tkFileDialog.askopenfilename()\n filename = \"SubSpectrumData/\" + self.filenameparser(filename)\n self.t4_filename = filename",
"def t9_loadFile(self):\n print \"subspectrumFile\"\n filename = tkFileDialog.... | [
"0.6096043",
"0.60425687",
"0.6037046",
"0.59479153",
"0.59037733",
"0.58304983",
"0.57549256",
"0.574654",
"0.5744462",
"0.57042634",
"0.56860816",
"0.5640132",
"0.5632671",
"0.5624204",
"0.5614218",
"0.56010455",
"0.54256785",
"0.5398315",
"0.53687054",
"0.5361466",
"0.5359... | 0.7026588 | 0 |
Powerlaw in one flux unit might not be powerlaw anymore in another, so we cannot convert flux unit of analytical integration easily. | def test_integrate_wontfix(self):
ans_flam = 8.8608168e-09 * (u.erg / (u.cm * u.cm * u.s))
assert_quantity_allclose(
self.sp.integrate(wavelengths=self.w, flux_unit='flam',
integration_type='analytical'), ans_flam) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powerlaw(self, wavelength, AKs):\n # If input entry is a single float, turn it into an array\n try:\n len(wavelength)\n except:\n wavelength = [wavelength]\n\n # Return error if any wavelength is beyond interpolation range of\n # extinction law\n ... | [
"0.63392043",
"0.614425",
"0.61436033",
"0.61247146",
"0.6035892",
"0.60239434",
"0.59861016",
"0.59202015",
"0.5908754",
"0.58964163",
"0.5887878",
"0.58834094",
"0.58605194",
"0.5755435",
"0.57531023",
"0.57396954",
"0.5715524",
"0.5712901",
"0.57078284",
"0.5689281",
"0.56... | 0.6213279 | 1 |
Test redshift behavior that conserves flux. | def test_conserve_flux_redshift(self):
sp = SourceSpectrum(self.sp_z0.model, z=1.3, z_type='conserve_flux')
fac = 1 / (1 + sp.z)
wave = [5000, 11500]
assert_quantity_allclose(sp(wave), self.sp(wave) * fac)
assert_quantity_allclose(sp.integrate(), self.sp_z0.integrate()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reactor(self):\n self.assertIdentical(self.tx_client._reactor, self.reactor)",
"def test_fluxes(self):\n\n t, x_n, x_p, r_n, r_p = (\n self.t,\n self.x_n,\n self.x_p,\n self.r_n_edge,\n self.r_p_edge,\n )\n if self.model.... | [
"0.6371813",
"0.60547906",
"0.5955846",
"0.5887768",
"0.5706954",
"0.57004935",
"0.5678911",
"0.5677099",
"0.56690884",
"0.55426234",
"0.54605067",
"0.54446536",
"0.5421223",
"0.5383447",
"0.5358234",
"0.5356049",
"0.53522944",
"0.5349485",
"0.5343459",
"0.53269",
"0.53144664... | 0.66344607 | 0 |
Create a panel of plots (bare spectra, bare wavefunctions, dressed spectrum, nphoton qubit transitions, chi). | def plot_explorer_panels(self, param_val, photonnumber, initial_index, final_index, qbt_index, osc_index):
def fig_ax(index):
return fig, axes_list_flattened[index]
param_index = np.searchsorted(self.param_vals, param_val)
param_val = self.param_vals[param_index]
initial_ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plots():\n out = interactive_output(generate_plots, {'gsize':gridSlider, 'ra':RABox, 'ra':RASlider, 'dec':DECBox, 'dec':DECSlider, 'ang':radBox, 'ang':radSlider, 'style':hexDrop})\n return display(widgrid, out)",
"def plot(self):\n\t\tself.plotOfSpect()",
"def plot(self):\n\t\tself.plotOfSpect().plot... | [
"0.68754035",
"0.6722656",
"0.6549479",
"0.6468496",
"0.6340719",
"0.6307666",
"0.62612665",
"0.6232706",
"0.6226473",
"0.6196949",
"0.6196443",
"0.61874056",
"0.61871344",
"0.6176061",
"0.6137373",
"0.6113347",
"0.60863554",
"0.60843045",
"0.6075881",
"0.60385644",
"0.603653... | 0.72008353 | 0 |
Writes a dict representation of the user_map to a database | def write_user_map_to_db(user_map):
print("writing user_map to db")
try:
for user in user_map:
put_user_in_table(user_map[user].to_dict())
user_map[user].set_is_new_user(False)
except IOError:
print("Error writing to DB.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_user_map_from_db():\n user_map = {}\n\n try:\n users = get_users_from_table()\n for user in users:\n user_dict = {\n \"user_id\" : user[0],\n \"username\" : user[1],\n \"id_last_message_sent\" : user[2],\n \"id_last... | [
"0.66149426",
"0.65620214",
"0.6410111",
"0.61584723",
"0.6056155",
"0.6032432",
"0.59367055",
"0.5933605",
"0.5921467",
"0.58698714",
"0.58241343",
"0.5788991",
"0.56693506",
"0.5662842",
"0.5640421",
"0.563223",
"0.5573533",
"0.55562806",
"0.5514045",
"0.5466411",
"0.546562... | 0.84273005 | 0 |
Loads database users into the bot's user_map | def load_user_map_from_db():
user_map = {}
try:
users = get_users_from_table()
for user in users:
user_dict = {
"user_id" : user[0],
"username" : user[1],
"id_last_message_sent" : user[2],
"id_last_message_stickered" : ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_users(self):\n self.__users = {}\n\n conn = sqlite3.connect(self.__DB)\n cursor = conn.cursor()\n\n cursor.execute('''\n SELECT * FROM users;\n ''')\n\n for row in cursor.fetchall():\n self.__users[row[0]] = User(row[1], row[2], row[3], row[4])\n... | [
"0.7575431",
"0.75312525",
"0.7430518",
"0.7358216",
"0.73493826",
"0.73340756",
"0.73147094",
"0.72647876",
"0.71816975",
"0.71670586",
"0.70162374",
"0.69401765",
"0.68738306",
"0.6801875",
"0.6755816",
"0.6709565",
"0.67047334",
"0.6703773",
"0.66817784",
"0.6583641",
"0.6... | 0.7773803 | 0 |
Calculates the number of days since 111900 (the Excel Epoch) | def get_current_days_excel_epoch():
f_date = datetime.date(1900, 1, 1)
l_date = datetime.datetime.today().date()
delta = l_date - f_date
return delta.days | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_days_since_epoch(day, month, year):\r\n d = datetime(int(year), int(month), int(day))\r\n epoch = datetime.utcfromtimestamp(0)\r\n return (d - epoch).days",
"def calculate_days(time):\n return int(time / 86400)",
"def epoch_seconds(date):\r\n td = date - epoch\r\n return td.days *... | [
"0.7083012",
"0.70454645",
"0.6994901",
"0.6972299",
"0.6954758",
"0.6954758",
"0.69342244",
"0.6863395",
"0.67731464",
"0.670872",
"0.6632939",
"0.6544763",
"0.6531819",
"0.6528415",
"0.65174526",
"0.6493381",
"0.64617276",
"0.6439297",
"0.63977396",
"0.63881654",
"0.635627"... | 0.8354966 | 0 |
>>> string_chopped_to_float('hello75494758test', 'hello', 'test') 75494758.0 >>> string_chopped_to_float('hello1test', 'hello', 'test') 1.0 | def string_chopped_to_float(input_string, chop_up, chop_low):
input_string = str(input_string)
return float(string_chop_up(string_chop_low(input_string, chop_up), chop_low)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ffloat(string):\n try:\n return float(string.strip())\n except:\n return 0",
"def floatify(string):\n temporary_string = \"0.\" + string[:-1]\n return float(temporary_string)",
"def _to_float(self, s: str) -> float:\n return int(s[:-1]) / 1e9 if s.endswith('n') else float(s... | [
"0.76202214",
"0.7513479",
"0.73897016",
"0.7269182",
"0.7262404",
"0.71777946",
"0.715664",
"0.7013713",
"0.69565153",
"0.6954011",
"0.6907948",
"0.68754464",
"0.6867221",
"0.6840515",
"0.68281454",
"0.6768567",
"0.6767471",
"0.6719723",
"0.67103374",
"0.6662983",
"0.6615891... | 0.8501997 | 0 |
>>> string_chop_low('hello my name is test', 'hello') ' my name is test' >>> string_chop_low('tests are the worst', 'tests') ' are the worst' >>> string_chop_low('tests are the worst', 'tests ') 'are the worst' >>> string_chop_low('tests are the worst', 'hello ') 'failed to find chop value in input; tests are the worst... | def string_chop_up(input_string, chop_up):
if type(input_string and chop_up) is str:
if chop_up in input_string:
return input_string[:input_string.find(chop_up)]
else:
return 'failed to find chop value in input; ' + input_string + ' ' + chop_up
else:
return 'inco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_chop_low(input_string, chop_low):\n\n if type(input_string and chop_low) is str:\n if chop_low in input_string:\n return input_string[input_string.find(chop_low) + len(chop_low):]\n else:\n return 'failed to find chop value in input; ' + input_string + ' ' + chop_l... | [
"0.84307736",
"0.6584799",
"0.6184809",
"0.6057745",
"0.586353",
"0.586353",
"0.586353",
"0.586353",
"0.58208066",
"0.5773311",
"0.56332487",
"0.55489016",
"0.55271244",
"0.5511366",
"0.5504316",
"0.55003667",
"0.5394182",
"0.53500986",
"0.5341113",
"0.53355",
"0.53089803",
... | 0.7435827 | 1 |
>>> string_chop_up('hello my name is test', 'test') 'hello my name is ' >>> string_chop_up('hello my name is test', 'hello') '' >>> string_chop_up('tests are the worst', 'hello') 'failed to find chop value in input; tests are the worst hello' | def string_chop_low(input_string, chop_low):
if type(input_string and chop_low) is str:
if chop_low in input_string:
return input_string[input_string.find(chop_low) + len(chop_low):]
else:
return 'failed to find chop value in input; ' + input_string + ' ' + chop_low
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_chop_up(input_string, chop_up):\n\n if type(input_string and chop_up) is str:\n if chop_up in input_string:\n return input_string[:input_string.find(chop_up)]\n else:\n return 'failed to find chop value in input; ' + input_string + ' ' + chop_up\n else:\n ... | [
"0.8285419",
"0.63285214",
"0.60643446",
"0.6053091",
"0.6015441",
"0.5907004",
"0.58838874",
"0.58760774",
"0.58760774",
"0.58760774",
"0.58760774",
"0.57705975",
"0.5706846",
"0.5702618",
"0.5614449",
"0.5596575",
"0.55737156",
"0.5562196",
"0.552415",
"0.55043644",
"0.5472... | 0.703384 | 1 |
>>> r1, r2 = netvals() >>> isinstance(r1, float) True >>> isinstance(r2, float) True | def netvals():
net = psutil.net_io_counters()
values1 = string_chopped_to_float(net, 'ts_sent=', ', packets_recv=')
values2 = string_chopped_to_float(net, 'ts_recv=', ', errin=')
if type(values1 or values2) is str:
return 0.0, 0.0
else:
return values1, values2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isFloat(val):\n\tvalFloat = True\n\ttry:\n\t\ttVal = float(val)\n\texcept ValueError:\n\t\tvalFloat = False\n\ttVal = None\n\tr = (valFloat, tVal)\n\treturn r",
"def __type_of_elements_incorrect_float_in_Numpy_vector(self):\n strTestName = 'Float elements in a Numpy vector (incorrect)'\n RxCSOb... | [
"0.5736689",
"0.5489035",
"0.54506356",
"0.54265505",
"0.5361754",
"0.53063047",
"0.5261343",
"0.52446413",
"0.52359414",
"0.52216905",
"0.5195725",
"0.51760864",
"0.515261",
"0.5142327",
"0.5130434",
"0.51203215",
"0.5120054",
"0.5115277",
"0.51066065",
"0.5103527",
"0.51007... | 0.6207648 | 0 |
>>> doc = get_cpuvals() >>> type(doc) >>> type(doc.get('CPUCore1')) >>> type(doc.get('CPUCore2')) >>> type(doc.get('CPUCore3')) >>> type(doc.get('CPUCore4')) >>> type(doc.get('CPU')) | def get_cpuvals(inteval = 1):
cpu_array = psutil.cpu_percent(inteval, percpu=True)
return {
'CPUCore1': cpu_array[0],
'CPUCore2': cpu_array[1],
'CPUCore3': cpu_array[2],
'CPUCore4': cpu_array[3],
'CPU': sum(cpu_array)/4
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cpu(self):\n pass",
"def cpuinfo(self):\n \n command = 'cat /proc/cpuinfo'\n\tpipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n stdout, stderr = pipe.communicate()\n\tinfo = stdout.strip()\n cpu_type = None\n\tn_proc = 0\n\tfor... | [
"0.61431915",
"0.6141705",
"0.6017399",
"0.59705234",
"0.5904287",
"0.58928514",
"0.5870974",
"0.583177",
"0.5802893",
"0.578462",
"0.57783324",
"0.577111",
"0.5750272",
"0.5723958",
"0.5707999",
"0.5707999",
"0.569427",
"0.5682598",
"0.56772864",
"0.56761044",
"0.5675952",
... | 0.6525174 | 0 |
>>> doc = get_hdd() >>> type(doc) >>> type(doc.get('HDD')) | def get_hdd():
return {
'HDD': string_chopped_to_float(psutil.disk_usage('/'), 'percent=', ')'),
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_disk_type(vm_):\n return config.get_cloud_config_value(\n \"disk_type\", vm_, __opts__, default=\"HDD\", search_global=False\n )",
"def get_type(self):\n\t\treturn call_sdk_function('PrlSrvCfgHddPart_GetType', self.handle)",
"def drive_type():",
"def get_type_from_doc(doc):\n try:\n ... | [
"0.57787406",
"0.56320417",
"0.54935527",
"0.5410566",
"0.5407092",
"0.53723776",
"0.53289616",
"0.526137",
"0.52491623",
"0.52209634",
"0.52188796",
"0.51643825",
"0.5126635",
"0.51211774",
"0.51054615",
"0.50980705",
"0.50856817",
"0.50843906",
"0.50716096",
"0.50542814",
"... | 0.61445147 | 0 |
>>> doc = get_net(155.0,155.0,150.0,150.0) >>> type(doc) >>> type(doc.get('NETPKTSNT')) >>> type(doc.get('NETPKTRCV')) >>> doc.get('NETPKTSNT') 5.0 >>> doc.get('NETPKTRCV') 5.0 | def get_net(netsnt, netrcv, tempsnt, temprcv):
return {
'NET-PKT-SNT': (netsnt - tempsnt),
'NET-PKT-RCV': (netrcv - temprcv),
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_net(con):\n try:\n return con.virtual_network_read(fq_name=conf.get('default_net', 'UNEXPECTED_VALUE'))\n except NoIdError:\n log.debug('Unable to find net.')\n return None",
"def retrieve_wordnet():\n try:\n from nltk.corpus import wordnet\n except:\n impor... | [
"0.5998551",
"0.54016143",
"0.52674556",
"0.51855856",
"0.5174027",
"0.5115852",
"0.50885844",
"0.5085922",
"0.5083989",
"0.506498",
"0.50474215",
"0.50177103",
"0.4994038",
"0.4992014",
"0.49484563",
"0.49484563",
"0.4944003",
"0.49173918",
"0.48750484",
"0.48706457",
"0.485... | 0.6270284 | 0 |
Test the Jinja2 library by generating text from a template. | def test_jinja2(device_inventory):
test_template = """
interface Ethernet{{ intf_id }}
ip address {{ intf_ip }}
"""
test_result = """
interface Ethernet1
ip address 1.2.3.4/24
"""
template = Template(test_template)
result = template.render(intf_id=1, intf_ip="1.2.3.4/24")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_template(project):\n project.add_mock_file(\"templates\", \"test.tmpl\", \"{{ value }}\")\n project.compile(\"\"\"import unittest\nvalue = \"1234\"\nstd::print(std::template(\"unittest/test.tmpl\"))\n \"\"\")\n\n assert project.get_stdout() == \"1234\\n\"",
"def jinja():\n template_path =... | [
"0.75394106",
"0.7256456",
"0.6912083",
"0.69060135",
"0.68854314",
"0.6817552",
"0.67234933",
"0.6688544",
"0.6668396",
"0.66600764",
"0.6600059",
"0.65813076",
"0.65677065",
"0.654897",
"0.6504566",
"0.64888847",
"0.6438241",
"0.6436712",
"0.6336467",
"0.62927145",
"0.62797... | 0.74415267 | 1 |
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output. | def run_migrations_offline():
# pylint:disable=E1101
context.configure(url=db_url,
target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
# pylint:enable=E1101 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_migrations_offline():\n url = get_url()\n context.configure(\n url=url,\n target_metadata=target_metadata,\n literal_binds=True,\n compare_type=True,\n version_table_schema=POSTGRES_SCHEMA,\n )\n\n with context.begin_transaction():\n context.run_migrati... | [
"0.80303395",
"0.8029356",
"0.78208125",
"0.78090495",
"0.78090495",
"0.78090495",
"0.7806276",
"0.7806276",
"0.7799458",
"0.77574885",
"0.7739294",
"0.7663957",
"0.75618684",
"0.72405314",
"0.683358",
"0.6712527",
"0.6489763",
"0.64791274",
"0.64538157",
"0.6449191",
"0.6415... | 0.80295223 | 1 |
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. | def run_migrations_online():
# specify here how the engine is acquired
engine = create_engine(db_url)
if isinstance(engine, Engine):
connection = engine.connect()
else:
raise Exception(
'Expected engine instance got %s instead' % type(engine)
)
# pylint:disable=E1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_migrations_online():\n\n # this callback is used to prevent an auto-migration from being generated\n # when there are no changes to the schema\n # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html\n def process_revision_directives(context, revision, directives):\n if get... | [
"0.80878067",
"0.8022579",
"0.7953097",
"0.78431326",
"0.78431326",
"0.78360605",
"0.7816961",
"0.7794103",
"0.77602583",
"0.77448124",
"0.772743",
"0.7680166",
"0.75318956",
"0.74468094",
"0.7395117",
"0.7278825",
"0.7206148",
"0.7206148",
"0.7206148",
"0.71949494",
"0.71104... | 0.83305466 | 0 |
This function uses the readability library for feature engineering. It includes textual statistics, readability scales and metric, and some pos stats | def readability_measurements(passage: str):
results = readability.getmeasures(passage, lang='en')
chars_per_word = results['sentence info']['characters_per_word']
syll_per_word = results['sentence info']['syll_per_word']
words_per_sent = results['sentence info']['words_per_sentence']
kinca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readability(target_text):\n\n nb1 = total_words(target_text)\n nb2 = total_phrases(target_text)\n nb3 = total_syllables(target_text)\n k1 = 206.835\n k2 = 1.015\n k3 = 84.6\n score = round((k1 - k2 * (nb1 / nb2) - k3 * (nb3 / nb1)), 2)\n\n print_text = \"Reading level of\"\n if score... | [
"0.70964235",
"0.700147",
"0.6474971",
"0.6031555",
"0.59483445",
"0.5798763",
"0.57125306",
"0.5708922",
"0.5620137",
"0.5572969",
"0.5520066",
"0.55136657",
"0.5461339",
"0.54419374",
"0.54236954",
"0.5397866",
"0.5397591",
"0.53626674",
"0.5309625",
"0.53059995",
"0.529496... | 0.7091168 | 1 |
Constructor vcs reference to the Mercurial vcs object Hg | def __init__(self, vcs):
super(Histedit, self).__init__(vcs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, vcs, parent=None):\n super(HgDiffGenerator, self).__init__(parent)\n \n self.vcs = vcs\n \n self.__hgClient = self.vcs.getClient()",
"def __init__(self, vcsObject, projectObject, parent=None, name=None):\n VcsProjectHelper.__init__(self, vcsObject, pro... | [
"0.72592425",
"0.6153009",
"0.5937477",
"0.5793642",
"0.5717146",
"0.5704376",
"0.5618294",
"0.561336",
"0.559752",
"0.5589518",
"0.55828726",
"0.5570476",
"0.554911",
"0.55144864",
"0.55056185",
"0.55014986",
"0.5490154",
"0.5488235",
"0.5460426",
"0.54231936",
"0.541986",
... | 0.6204929 | 1 |
Public method to start a histedit session. name file/directory name str rev revision to start histedit at str flag indicating that the project should be reread bool | def hgHisteditStart(self, name, rev=""):
# find the root of the repo
repodir = self.vcs.splitPath(name)[0]
while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
repodir = os.path.dirname(repodir)
if os.path.splitdrive(repodir)[1] == os.sep:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hgHisteditContinue(self, name):\n # find the root of the repo\n repodir = self.vcs.splitPath(name)[0]\n while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):\n repodir = os.path.dirname(repodir)\n if os.path.splitdrive(repodir)[1] == os.sep:\n ... | [
"0.66567546",
"0.6401503",
"0.5962742",
"0.5858265",
"0.58273435",
"0.572169",
"0.57191056",
"0.55681163",
"0.55275154",
"0.5489793",
"0.5481485",
"0.54750323",
"0.54496247",
"0.53956324",
"0.5375326",
"0.5370722",
"0.5364145",
"0.535253",
"0.53496885",
"0.53409106",
"0.53092... | 0.7639411 | 0 |
Public method to continue an interrupted histedit session. name file/directory name str flag indicating that the project should be reread bool | def hgHisteditContinue(self, name):
# find the root of the repo
repodir = self.vcs.splitPath(name)[0]
while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
repodir = os.path.dirname(repodir)
if os.path.splitdrive(repodir)[1] == os.sep:
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hgHisteditAbort(self, name):\n # find the root of the repo\n repodir = self.vcs.splitPath(name)[0]\n while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):\n repodir = os.path.dirname(repodir)\n if os.path.splitdrive(repodir)[1] == os.sep:\n ... | [
"0.6027129",
"0.5696851",
"0.56891614",
"0.56332964",
"0.55927086",
"0.55381435",
"0.5467123",
"0.5454806",
"0.545194",
"0.5426058",
"0.5423759",
"0.5419736",
"0.5403304",
"0.53328574",
"0.5300164",
"0.52785355",
"0.5268785",
"0.5258025",
"0.522451",
"0.5215203",
"0.518834",
... | 0.6637892 | 0 |
Public method to abort an interrupted histedit session. name file/directory name str flag indicating that the project should be reread bool | def hgHisteditAbort(self, name):
# find the root of the repo
repodir = self.vcs.splitPath(name)[0]
while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
repodir = os.path.dirname(repodir)
if os.path.splitdrive(repodir)[1] == os.sep:
return Fal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aborting(self):\n \n pass",
"def abort(self):\n print(\"abort\")",
"def set_abort_flag(self):\r\n self.abort_flag = True",
"def set_abort_flag(self):\r\n self.abort_flag = True",
"def interrupted(self):\n print(\"Macro interrupted!\")",
"def abort(self):\n ... | [
"0.6545505",
"0.636072",
"0.61627394",
"0.61627394",
"0.6134689",
"0.59427524",
"0.587195",
"0.58490455",
"0.58361816",
"0.5763654",
"0.57473016",
"0.57127345",
"0.56520957",
"0.563169",
"0.56248873",
"0.5618058",
"0.5608859",
"0.5598004",
"0.55777436",
"0.5575246",
"0.557429... | 0.7164713 | 0 |
Print out prune rate for each layer and the whole network | def prune_rate(model, verbose=True):
total_nb_param = 0
nb_zero_param = 0
layer_id = 0
for parameter in model.parameters():
param_this_layer = 1
for dim in parameter.data.size():
param_this_layer *= dim
total_nb_param += param_this_layer
# only pruning lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune():\n with tf.Graph().as_default() as g:\n # Input evaluation data\n images, labels = rn.inputs(eval_data=True)\n\n # inference model.\n logits = rn.inference(images, 15)\n\n # Calculate predictions.\n top_k_op = tf.nn.in_top_k(logits, labels, 1)\n\n # C... | [
"0.64732736",
"0.634886",
"0.6300416",
"0.62022644",
"0.61382544",
"0.60211",
"0.6006544",
"0.5990342",
"0.597919",
"0.59374833",
"0.5764295",
"0.56720144",
"0.5667925",
"0.5640819",
"0.5632508",
"0.5617337",
"0.5603527",
"0.55663127",
"0.55620337",
"0.5540223",
"0.5536165",
... | 0.6647221 | 0 |
nonzero argmin of a nonnegative array | def arg_nonzero_min(a):
if not a:
return
min_ix, min_v = None, None
# find the starting value (should be nonzero)
for i, e in enumerate(a):
if e != 0:
min_ix = i
min_v = e
if not min_ix:
print('Warning: all zero')
return np.inf, np.inf
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argmin(self, array):\n minvalue = inf\n minindex = None\n for i in range(len(array)):\n if array[i] < minvalue:\n minvalue = array[i]\n minindex = i\n return minvalue, minindex",
"def nanargmin(a, axis=None):\n y = array(a, subok=True)\n... | [
"0.7431452",
"0.73155326",
"0.7293049",
"0.7244737",
"0.7145072",
"0.69662106",
"0.6898724",
"0.6882872",
"0.6814072",
"0.66423774",
"0.6625572",
"0.65994143",
"0.65701747",
"0.65519756",
"0.65190005",
"0.65178686",
"0.64915746",
"0.64562446",
"0.63749224",
"0.6362779",
"0.63... | 0.78794104 | 0 |
prints menu guide for headless | def printMenu():
# tWelc = PrettyTable(['Welcome to the CLI-of the repository classifier'])
print('Welcome to the CLI of the repository classifier')
print(strStopper1)
t = PrettyTable(['Action', ' Shortcut '])
t.add_row(['Show Menu', '- m -'])
t.add_row([' Predict repositories form txt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_menu_for_testing():\n print(PROMPT_TEXT)",
"def help_menu():\n print('\\n##################################################')\n print('################ Help Menu ###############') \n print('##################################################')\n print(' Type move or examine for ea... | [
"0.6749462",
"0.6589138",
"0.656004",
"0.65471476",
"0.6537451",
"0.6534654",
"0.6447573",
"0.6425884",
"0.6336168",
"0.6328453",
"0.6319378",
"0.6289573",
"0.62706345",
"0.6265602",
"0.6191971",
"0.6189462",
"0.6185392",
"0.6173904",
"0.6134442",
"0.61315536",
"0.61285436",
... | 0.7151886 | 0 |
Computes the shortest path for each agent to its target and the action to be taken to do so. The paths are derived from a `DistanceMap`. If there is no path (rail disconnected), the path is given as None. The agent state (moving or not) and its speed are not taken into account | def get_shortest_paths(distance_map: DistanceMap, agent_pos, agent_dir, max_depth: Optional[int] = None, agent_handle: Optional[int] = None) \
-> Dict[int, Optional[List[Waypoint]]]:
shortest_paths = dict()
def _shortest_path_for_agent(agent,agent_pos,agent_dir):
if agent_pos is None :
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_path(source, target):\n #although lecture checks for goal when a node is popped off the frontier, efficiency of search can be improved\n #by checking for a goal as nodes are ADDED. If goal detected, don't add it to frontier, just return the solution\n #immediately\n\n #create start point\n... | [
"0.64891803",
"0.6126406",
"0.61130154",
"0.61024654",
"0.6021146",
"0.6011218",
"0.600556",
"0.5974616",
"0.5965403",
"0.59535706",
"0.5902704",
"0.58986044",
"0.58868396",
"0.5840881",
"0.58329207",
"0.582555",
"0.5794891",
"0.5792446",
"0.5790476",
"0.5788205",
"0.5780904"... | 0.7431506 | 0 |
Estimate the weighted logprobabilities, log P(X | Z) + log weights. | def _estimate_weighted_log_prob(self, X, precision_cholesky):
return self._estimate_log_prob(X, precision_cholesky) + self._estimate_log_weights(X.location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_log_prob(self,params: ndarray) -> float:\n return self.compute_log_prior(params) + self.compute_log_likelihood(params)",
"def __log_likelihood(self, params, *args):\n\t\tX, y, feature_set, lambda_reg, empirical_weights, verbose, sign = args\n\n\t\tno_example = len(X)\n\t\ttotal_logZ = 0\n\t\tt... | [
"0.74555504",
"0.72333777",
"0.7085037",
"0.69240975",
"0.6921773",
"0.6889137",
"0.6864954",
"0.67947763",
"0.6763284",
"0.6763284",
"0.673634",
"0.6713014",
"0.670383",
"0.6699093",
"0.66656667",
"0.6645787",
"0.66439337",
"0.66428185",
"0.6572697",
"0.6556301",
"0.6547387"... | 0.76370335 | 0 |
guess the indent and block sequence indent of yaml stream/string returns round_trip_loaded stream, indent level, block sequence indent block sequence indent is the number of spaces before a dash relative to previous indent if there are no block sequences, indent is taken from nested mappings, block sequence indent is u... | def load_yaml_guess_indent(stream, **kw):
# type: (StreamTextType, Any) -> Any
from .main import round_trip_load
# load a YAML document, guess the indentation, if you use TABs you're on your own
def leading_spaces(line):
# type: (Any) -> int
idx = 0
while idx < len(line) and lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _open_yaml(stream, original_file=None, substitutions_dict={}):\n try:\n yaml_contents = yaml.load(stream, Loader=yaml_SafeLoader)\n\n return _get_yaml_contents_without_documentation_complete(yaml_contents, substitutions_dict)\n except DocumentationNotComplete as e:\n raise e\n exc... | [
"0.578162",
"0.57497257",
"0.5425795",
"0.5360043",
"0.5172861",
"0.5130717",
"0.5103146",
"0.51013577",
"0.5100713",
"0.50921977",
"0.50826526",
"0.5068082",
"0.5051855",
"0.49383286",
"0.47772184",
"0.47223315",
"0.47201133",
"0.47092918",
"0.47074708",
"0.47030818",
"0.466... | 0.8381411 | 0 |
walks over a ConfigObj (INI file with comments) generating corresponding YAML output (including comments | def configobj_walker(cfg):
# type: (Any) -> Any
from configobj import ConfigObj # type: ignore
assert isinstance(cfg, ConfigObj)
for c in cfg.initial_comment:
if c.strip():
yield c
for s in _walk_section(cfg):
if s.strip():
yield s
for c in cfg.final_com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_config(self_config, indict):\n for key in self_config:\n if isinstance(self_config[key], Section) \\\n and key in indict and isinstance(indict[key], Section):\n self_config[key].parent = self_config\n self_config[key].main = self_config.main\n sel... | [
"0.6239781",
"0.6015929",
"0.59799016",
"0.58748394",
"0.5775479",
"0.566098",
"0.5645587",
"0.55956334",
"0.55764544",
"0.556279",
"0.5462302",
"0.545196",
"0.53988105",
"0.5348956",
"0.5340353",
"0.53137195",
"0.52974904",
"0.5287517",
"0.52514",
"0.5246019",
"0.5230226",
... | 0.71770924 | 0 |
updates curis with crawlinfo in bulk. not implemented noop. this is too slow anyways. | def update_crawlinfo(self, curis):
pass
# tasks = [(self._set_crawlinfo, (curi,))
# for curi in curis if 'a' not in curi]
# if tasks:
# b = TaskBucket(tasks)
# b.execute_wait(executor, 4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_cid(cid):\n st = time.time()\n count = 0\n for i, g in enumerate(query_to_tuples(\"select distinct group_id from hits_mv where crawl_id = %s\", cid)):\n g = g[0]\n if i == 0:\n log.info(\"processing %s, %s %s\", i, cid, g)\n\n updatehitgroup(g, cid)\n cou... | [
"0.5782717",
"0.5608955",
"0.52848727",
"0.5265156",
"0.5140733",
"0.5116181",
"0.511579",
"0.5113692",
"0.50977015",
"0.50872344",
"0.5059017",
"0.5058618",
"0.50420874",
"0.50329894",
"0.50203854",
"0.5001459",
"0.4997908",
"0.49683064",
"0.4879333",
"0.48768982",
"0.486750... | 0.73055416 | 0 |
Reads a query string in from a file | def load_query(query_filename):
with open(query_filename) as f:
return f.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(filepath: str, query_params: dict) -> list:\r\n\r\n # Get start and end line #'s from query_params (if they exist)\r\n if 'startln' in query_params:\r\n startln = query_params['startln']\r\n else:\r\n startln = 0 # Default to line 0 (index 0)\r\n if 'endln' in query_params:... | [
"0.6686722",
"0.6092512",
"0.58761114",
"0.583466",
"0.5680918",
"0.5669449",
"0.5634066",
"0.5563954",
"0.5549494",
"0.55478275",
"0.5527858",
"0.5523341",
"0.5503141",
"0.5480167",
"0.5479446",
"0.54216677",
"0.54202884",
"0.5412485",
"0.5387319",
"0.53809255",
"0.5365935",... | 0.6663521 | 1 |
transforms the db cursor into a list of records, where the first item is the header | def construct_list(cursor):
header = [h[0] for h in cursor.description]
data = cursor.fetchall()
return header, data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __toListOfDict(self, cursor):\n lst = []\n for row in cursor.fetchall():\n # first convert row to a dictionary\n rowdict={}\n for idx, col in enumerate(cursor.description):\n rowdict[col[0]] = row[idx]\n lst.append(rowdict)\n retur... | [
"0.66654354",
"0.62916434",
"0.61054385",
"0.60755",
"0.60545087",
"0.603872",
"0.6024499",
"0.6024499",
"0.59340316",
"0.58559614",
"0.58446676",
"0.58311486",
"0.58311486",
"0.5826768",
"0.58213234",
"0.58213234",
"0.58130705",
"0.5800854",
"0.5800144",
"0.5795948",
"0.5770... | 0.7417043 | 0 |
transforms the db cursor rows into a csv file string | def construct_csv(cursor):
header, data = construct_list(cursor)
# python 2 and 3 handle writing files differently
if sys.version_info[0] <= 2:
output = io.BytesIO()
else:
output = io.StringIO()
writer = csv.writer(output)
writer.writerow(header)
for row in data:
wri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbtocsv():\n connection = sqlite3.connect(\"sensordata.db\")\n cursor = connection.cursor()\n cursor.execute(\"Select * from sensordata\")\n roadstationdata = cursor.fetchall()\n\n with open('roadstationdata.csv', 'w') as f:\n writer = csv.writer(f)\n wr... | [
"0.7352472",
"0.71596783",
"0.7136416",
"0.71115726",
"0.66507584",
"0.659347",
"0.65784544",
"0.65673685",
"0.65560377",
"0.6527843",
"0.6523417",
"0.6518057",
"0.6511207",
"0.64884603",
"0.6487957",
"0.64878666",
"0.64728415",
"0.64676136",
"0.6412606",
"0.6377043",
"0.6366... | 0.76759154 | 0 |
Loads the original data and the cluster assignments from the given handles. | def load_data(original_input_handle, cluster_input_handle):
info('Loading original data from {}'.format(original_input_handle.name))
original_data = pd.read_csv(original_input_handle, index_col=0)
info('Loaded a table with shape {}'.format(original_data.shape))
clusters = None
if cluster_input_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_cluster(self):",
"def update_plot_clusters(cluster_handles, data_points, cluster_ids):\n for handle, cluster_id in zip(cluster_handles, np.unique(cluster_ids)):\n loc = cluster_id == cluster_ids\n handle.set_data(data_points[loc, 0], data_points[loc, 1])",
"def load_data(path=\"data/... | [
"0.5732979",
"0.5528183",
"0.53812313",
"0.53248346",
"0.5263107",
"0.5128452",
"0.51189303",
"0.51144075",
"0.5102167",
"0.510216",
"0.5052296",
"0.50336933",
"0.49960402",
"0.49948552",
"0.49863207",
"0.4969336",
"0.49581128",
"0.49332035",
"0.49203888",
"0.49171543",
"0.48... | 0.6863571 | 0 |
Splits the given data by the given cluster assignments. | def split_data(df_data, clusters):
if clusters is None:
return {0: df_data}
return {
k: df_data.loc[clusters.index[clusters == k]]
for k in clusters.unique()
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partitionData(data, labels, partition):\n\treturn [s[partition] for s in data], labels[partition]",
"def partition(self, data, labels):\n\t\treturn self.kfold.split(labels)",
"def partition(self, data, labels):\n\t\traise Exception(\"Not implmented\")",
"def dataset_splits(self):\n # 10% evaluatio... | [
"0.5998715",
"0.58617157",
"0.5804616",
"0.5778629",
"0.5770824",
"0.57205516",
"0.5692267",
"0.5632453",
"0.5593713",
"0.5591811",
"0.5513163",
"0.5492773",
"0.5449953",
"0.54481894",
"0.54481894",
"0.541212",
"0.53947717",
"0.5391424",
"0.53894734",
"0.53755146",
"0.5373107... | 0.62756664 | 0 |
Helper to extract a version number for the sgjirabridge module. This will attenmpt to extract the version number from git if installed from a cloned repo. If a version is unable to be determined, or the process fails for any reason, we return "dev" | def get_sg_jira_bridge_version():
# Note: if you install from a cloned git repository
# (e.g. pip install ./tk-core), the version number
# will be picked up from the most recently added tag.
try:
version_git = subprocess.check_output(
["git", "describe", "--abbrev=0"]
).rstri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version():\n return '%d.%d.%d' % version_info",
"def get_version():\n git_root = find_git_root(dirname(__file__))\n\n if git_root is not None:\n # Get the version using \"git describe\".\n cmd = \"git describe --tags --match [0-9]*\".split()\n try:\n version = sub... | [
"0.72106606",
"0.7164096",
"0.71361184",
"0.7040402",
"0.69997597",
"0.69977856",
"0.69790304",
"0.69710505",
"0.69553876",
"0.6948242",
"0.68848306",
"0.67506284",
"0.6745226",
"0.67318237",
"0.67231417",
"0.6697725",
"0.66623807",
"0.6662004",
"0.6661547",
"0.6650725",
"0.6... | 0.83579165 | 0 |
Return the list of sync settings this server handles. | def sync_settings_names(self):
return self._sg_jira.sync_settings_names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_setting_keys(self):\n return self.do_rpc(\"get_setting_keys\")",
"def get_common_settings(self):\n # TODO: Assuming first server is good - need to make fallback logic\n return self.session.get_any(\"{base}{request_url}\".format(base=self.servers[0],\n ... | [
"0.6777745",
"0.6726385",
"0.6686099",
"0.64769393",
"0.6183471",
"0.6172553",
"0.61415565",
"0.60690784",
"0.60242116",
"0.6009671",
"0.60060817",
"0.5956607",
"0.5917273",
"0.5917273",
"0.58822757",
"0.5875323",
"0.5793291",
"0.57896274",
"0.57802707",
"0.5755891",
"0.57484... | 0.7506215 | 0 |
Handle a request to sync between ShotGrid and Jira in either direction. At this point, only the action (the first path_part) from the request path has been validated. The rest of the path_parts still need to be validated before we proceed. We expect the path to for this request to | def _handle_sync_request(self, path_parts, parameters):
entity_type = None
entity_key = None
if len(path_parts) == 4:
direction, settings_name, entity_type, entity_key = path_parts
elif len(path_parts) == 2:
direction, settings_name = path_parts
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_POST(self):\n # /sg2jira/default[/Task/123]\n # /jira2sg/default/Issue/KEY-123\n # /admin/reset\n try:\n parsed = parse.urlparse(self.path)\n # Extract additional query parameters.\n # What they could be is still TBD, may be things like `dry_run=1... | [
"0.6277269",
"0.56263167",
"0.5389302",
"0.52111244",
"0.52075213",
"0.5120015",
"0.50959146",
"0.50387746",
"0.50253576",
"0.49855313",
"0.49503982",
"0.48730215",
"0.4871536",
"0.48006532",
"0.47819403",
"0.4768859",
"0.4757492",
"0.4751778",
"0.47499153",
"0.47415203",
"0.... | 0.7156784 | 0 |
Handle admin request to the server. Currently handles a single action, ``reset`` which resets the Bridge in order to clear out the ShotGrid schema cache. At this point, only the action (the first path_part) from the request path has been validated. The rest of the path_parts still need to be validated before we proceed... | def _handle_admin_request(self, path_parts, parameters):
# The only function we respond to now is reset
if len(path_parts) != 2 or path_parts[1] != "reset":
raise SgJiraBridgeBadRequestError(
"Invalid admin path '%s'. Action is not set or unsupported." % self.path
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self) :\n self.redirect('/admin')",
"def handleAction(self, action):\n\n if action.deviceAction == indigo.kUniversalAction.EnergyReset:\n # Reset energy consumed and returned\n self.resetEnergy()\n\n # \"Reset\" the ui value\n self.device.updateS... | [
"0.54518783",
"0.52910465",
"0.5178191",
"0.51725644",
"0.5136174",
"0.5127565",
"0.50896084",
"0.5067153",
"0.50648755",
"0.50648755",
"0.5060515",
"0.5003707",
"0.49719203",
"0.49688086",
"0.49603596",
"0.4890772",
"0.48744968",
"0.48420691",
"0.48357865",
"0.48271266",
"0.... | 0.78643763 | 0 |
Returns an ordinal of a number, e.g. 'st' in 1st or 'th' in 5th | def ordinal(num):
if num > 9:
secondToLastDigit = str(num)[-2]
if secondToLastDigit == '1':
return 'th'
lastDigit = num % 10
if (lastDigit == 1):
return 'st'
elif (lastDigit == 2):
return 'nd'
elif (lastDigit == 3):
return 'rd'
else:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordinal(n):\n ord_dict = {1: \"st\", 2: \"nd\", 3: \"rd\"}\n return str(n + 1) + ord_dict.get((n + 1) if (n + 1) < 20 else (n + 1) % 10, \"th\")",
"def ordinal(value):\r\n try:\r\n value = int(value)\r\n except (TypeError, ValueError):\r\n return value\r\n t = (P_('0', 'th'),\r\n... | [
"0.8400007",
"0.8286457",
"0.8247375",
"0.80570805",
"0.80227697",
"0.80137414",
"0.8002642",
"0.7400951",
"0.72943175",
"0.72184294",
"0.7113696",
"0.70945907",
"0.70449984",
"0.6995809",
"0.695234",
"0.68502814",
"0.67553157",
"0.66592044",
"0.66592044",
"0.63282025",
"0.62... | 0.8333732 | 1 |
Add the number to an internal data structure. | def add(self, number):
self.num[number] = self.num.get(number, 0) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, number):\n self.arr.append(number)",
"def add(self, number: int) -> None:\n self._nums.append(number)",
"def add(self, number):\n self.dict.setdefault(number,0)\n self.dict[number]+=1",
"def addNumber(self,num):\n self.vec.append(num)",
"def add(self, number... | [
"0.7958194",
"0.7897046",
"0.7746004",
"0.77175236",
"0.77086926",
"0.762551",
"0.7606187",
"0.72695446",
"0.7232493",
"0.72108144",
"0.71716285",
"0.7018763",
"0.6935516",
"0.6820895",
"0.68135285",
"0.67898583",
"0.6761962",
"0.67507046",
"0.667893",
"0.66093165",
"0.660666... | 0.8017899 | 1 |
Verify that the cli import command for barred list is working properly. | def test_cli_barred_list_importer(postgres, db_conn, tmpdir, mocked_config, logger):
here = path.abspath(path.dirname(__file__))
data_dir = path.join(here, 'unittest_data/barred_tac_list')
valid_data_file_name = 'sample_barred_tac_list.csv'
valid_data_file = path.join(data_dir, valid_data_file_name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_simple_import(barred_tac_list_importer, logger, db_conn):\n expect_success(barred_tac_list_importer, 6, db_conn, logger)",
"def test_importtleCommandExists(self):\n self.assertIn('importtle', get_commands())",
"def test_command(self):\n out = io.StringIO()\n management.call_com... | [
"0.7015476",
"0.67361224",
"0.6451141",
"0.6186179",
"0.5987224",
"0.59660673",
"0.58773834",
"0.57910436",
"0.578258",
"0.57626116",
"0.57529277",
"0.5704016",
"0.57028526",
"0.5652167",
"0.5650002",
"0.5644594",
"0.5639698",
"0.5625188",
"0.55891484",
"0.5563083",
"0.555084... | 0.73132885 | 0 |
Verify that the barred list data is not imported if a header column is missing. | def test_missing_header(barred_tac_list_importer, logger, db_conn):
expect_failure(barred_tac_list_importer, exc_message='Metadata header, cannot find the column headers - tac, '
'10000110') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_header_missing_fields(self):\r\n\r\n # Default header, should not generate any errors/warnings\r\n header = ['AAA', 'XXX', 'YYY',\r\n 'ZZZ']\r\n errors = []\r\n warnings = []\r\n\r\n errors, warnings = check_header(header,\r\n ... | [
"0.7067991",
"0.69137025",
"0.6793218",
"0.66770756",
"0.655948",
"0.6491118",
"0.644131",
"0.64299643",
"0.6377049",
"0.6375862",
"0.63706404",
"0.6356679",
"0.6330546",
"0.6281854",
"0.6254557",
"0.6231428",
"0.61882013",
"0.6186738",
"0.6186536",
"0.6136432",
"0.6100023",
... | 0.7986043 | 0 |
Verify that barred list import fails historical check. | def test_historical_check_percent_fails(barred_tac_list_importer, logger, mocked_statsd, db_conn, mocked_config,
metadata_db_conn, tmpdir):
expect_success(barred_tac_list_importer, 20, db_conn, logger)
with get_importer(BarredTacListImporter,
db_conn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_historical_check_empty(barred_tac_list_importer, logger, mocked_statsd, db_conn, metadata_db_conn,\n mocked_config, tmpdir):\n expect_success(barred_tac_list_importer, 20, db_conn, logger)\n with get_importer(BarredTacListImporter,\n db_conn,\n ... | [
"0.71457416",
"0.60553885",
"0.5974987",
"0.5966817",
"0.59611845",
"0.59369254",
"0.5923301",
"0.58791023",
"0.58728397",
"0.58074075",
"0.58041584",
"0.57973963",
"0.5775518",
"0.57660973",
"0.57592916",
"0.5721072",
"0.56882304",
"0.56514066",
"0.562057",
"0.56134725",
"0.... | 0.74854404 | 0 |
Verify that Barred List data is not imported if the filename format is invalid. | def test_invalid_file_type(barred_tac_list_importer):
expect_failure(barred_tac_list_importer, exc_message='Wrong suffix') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_schema_invalid_format(self):\n bad_schema = [int, int, float, float, str]\n with self.assertRaisesRegexp(Exception, \"more than one char\"):\n self.context.frame.import_csv(self.dataset, bad_schema)",
"def test_readbadformat(self):\n\n self.assertRaises(ParseError, self.h... | [
"0.6773873",
"0.6557811",
"0.6552536",
"0.6541129",
"0.6514669",
"0.6513529",
"0.6511712",
"0.6507632",
"0.6490889",
"0.64167464",
"0.6416206",
"0.6412278",
"0.6411024",
"0.6403559",
"0.6390128",
"0.63897705",
"0.63036674",
"0.6293136",
"0.6235364",
"0.6232673",
"0.62258214",... | 0.72804755 | 0 |
Check that the models agree with the different surface forms | def test_compare_outputs_surface_form(self):
# load models
options = [
{"surface form": cap} for cap in ["false", "differential", "algebraic"]
]
model_combos = [
([pybamm.lead_acid.LOQS(opt) for opt in options]),
([pybamm.lead_acid.Full(opt) for opt in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verifyModels(self):\r\n\r\n #\r\n # now check that all models have the same poly data in the\r\n # model node as in the display node\r\n #\r\n polyDataInScene = []\r\n fileNamesInScene = []\r\n success = True\r\n numModels = slicer.mrmlScene.GetNumberOfNodesByClass( \"vtkMRMLModelNode\"... | [
"0.7056126",
"0.6636524",
"0.6374058",
"0.62989813",
"0.62264",
"0.62234527",
"0.6196559",
"0.6173605",
"0.61693895",
"0.6148875",
"0.6129384",
"0.61152375",
"0.6094649",
"0.6082957",
"0.60760045",
"0.6044832",
"0.6029263",
"0.6016909",
"0.6001543",
"0.59900147",
"0.59876186"... | 0.7274881 | 0 |
Creates json files for all csv origin files in the translations directory. | def build():
for root, dirs, files in os.walk(IN_PATH):
for filename in files:
if filename.endswith('.csv'):
with open(os.path.join(IN_PATH, filename), encoding='utf-8') as f:
reader = csv.reader(f)
next(reader)
data = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n for db_csv_export in current_dir.glob(\"template*.csv\"):\n data_projects = load_projects(db_csv_export)\n json_path = db_csv_export.with_suffix(\".json\")\n with open(json_path, \"w\") as fh:\n json.dump(data_projects, fh, indent=2)",
"def translation_folder() ->... | [
"0.72169816",
"0.6239214",
"0.5965321",
"0.5960024",
"0.5880255",
"0.5826347",
"0.5801222",
"0.57782835",
"0.5725814",
"0.5641025",
"0.5562766",
"0.5547573",
"0.55085456",
"0.5504383",
"0.54943895",
"0.54807526",
"0.547371",
"0.54257804",
"0.54095495",
"0.53896224",
"0.538548... | 0.66954327 | 1 |
Loads a locale from json file. FileNotFound exception if locale does not exist or is not built. | def load(locale):
if not locale:
locale = 'en_US'
filepath = os.path.join(OUT_PATH, locale + '.json')
with open(filepath, encoding='utf-8') as f:
return json.load(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __load_locale(self, locale_path: str) -> dict:\n return FileManager.read_json(locale_path)",
"def get_translation_dict_from_file(path, lang, app):\n\tjson_content = {}\n\tif os.path.exists(path):\n\t\twith open(path, 'r') as f:\n\t\t\tjson_content = json.loads(f.read())\n\n\treturn json_content",
"d... | [
"0.7947998",
"0.6503637",
"0.64720017",
"0.6461613",
"0.6374977",
"0.6359497",
"0.6317788",
"0.6287273",
"0.62427133",
"0.6233056",
"0.62286323",
"0.62209904",
"0.6220625",
"0.6211775",
"0.61991024",
"0.61654764",
"0.61560154",
"0.61465466",
"0.61421305",
"0.6131117",
"0.6108... | 0.78440344 | 1 |
Report the memory usage of the tensor.storage in pytorch Both on CPUs and GPUs are reported if print_all is True, print size and shape info for each tensor | def mem_report(print_all: bool = False) -> None:
def _mem_report(tensors: Iterable, mem_type: str) -> None:
"""Print the selected tensors of type
There are two major storage types in our major concern:
- GPU: tensors transferred to CUDA devices
- CPU: tensors remaining on t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mem_report(tensors: Iterable, mem_type: str) -> None:\n print(f\"Storage on {mem_type}\")\n print(\"-\" * LEN)\n total_numel = 0\n total_mem = 0\n visited_data: List[Any] = []\n for tensor in tensors:\n if tensor.is_sparse:\n continue\n ... | [
"0.76286286",
"0.76208466",
"0.75848514",
"0.6062649",
"0.60435545",
"0.59913194",
"0.5908436",
"0.58341956",
"0.5819237",
"0.58095634",
"0.57732356",
"0.5746633",
"0.56530523",
"0.5649426",
"0.5599731",
"0.54681385",
"0.543996",
"0.5432778",
"0.5427471",
"0.5343541",
"0.5335... | 0.82132757 | 0 |
Copies the model parameters of one net to another. | def copy_model_parameters(sess, net1, net2):
copy_scope_parameters(sess, net1.scope, net2.scope) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_update(source_net, target_net):\n for target_param, param in zip(target_net.parameters(), source_net.parameters()):\n target_param.data.copy_(param.data)",
"def copy_para(from_model, to_model):\n for i, j in zip(from_model.trainable_weights, to_model.trainable_weights):\n ... | [
"0.7798005",
"0.71947426",
"0.6970523",
"0.6810422",
"0.6723942",
"0.6572565",
"0.65657896",
"0.652187",
"0.6497664",
"0.63801336",
"0.63801336",
"0.63792497",
"0.63616174",
"0.6232208",
"0.6214631",
"0.62068164",
"0.61581165",
"0.61567116",
"0.61458546",
"0.61458546",
"0.614... | 0.8102487 | 0 |
Inverse of integral funcition. | def inverseintegrate(x, power):
if power == -1:
return exp(x)
else:
return pow(x*(power+1.), 1./(power+1.)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_inc(self, inc):\n return (inc - self.inc_min) / self.inc_range",
"def inverse(self, x, y):",
"def inverse (x_ij):\n\n Hij = xyzrph2matrix (x_ij)\n Rji = Hij[0:3, 0:3]\n tij = Hij[0:3,3]\n Rij = Rji.transpose ()\n tji = -Rij.dot (tij)\n Hji = numpy.zeros ((4,4))\n Hji[0:3... | [
"0.69220066",
"0.66979194",
"0.66966254",
"0.66640913",
"0.66048366",
"0.65923154",
"0.65687484",
"0.65617555",
"0.64913154",
"0.64834225",
"0.64825004",
"0.6481306",
"0.6476842",
"0.64719844",
"0.6456946",
"0.64499253",
"0.64258504",
"0.64149606",
"0.6412622",
"0.64105195",
... | 0.7399638 | 0 |
Given xmin and xmean, calculate xmax. | def _calc_xmax(self, xmin, xmean):
self.xmin = xmin
self.xmax = xmean+.01
for i in itertools.count():
self.norm = self._integrate(self.xmax)-self._integrate(self.xmin)
newmean = self.mean()
delta = xmean - newmean
#print self.xmin, newmean, self.xm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calc_xmin(self, xmax, xmean):\n self.xmin = xmean-.01\n self.xmax = xmax\n for i in itertools.count():\n self.norm = self._integrate(self.xmax)-self._integrate(self.xmin)\n newmean = self.mean()\n delta = - newmean + xmean\n #print self.xmin, ne... | [
"0.7159941",
"0.6644928",
"0.6595465",
"0.6282393",
"0.6058324",
"0.6008358",
"0.598642",
"0.5981668",
"0.59622645",
"0.59518296",
"0.589675",
"0.5775744",
"0.5768364",
"0.573387",
"0.5666532",
"0.56613404",
"0.5658492",
"0.55588865",
"0.5554085",
"0.5546216",
"0.55198145",
... | 0.7543527 | 0 |
Given xmax and xmean, calculate xmin. | def _calc_xmin(self, xmax, xmean):
self.xmin = xmean-.01
self.xmax = xmax
for i in itertools.count():
self.norm = self._integrate(self.xmax)-self._integrate(self.xmin)
newmean = self.mean()
delta = - newmean + xmean
#print self.xmin, newmean, self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_xmin(self):\n return self.__xmin",
"def minimum ( self ,\n xmin = None , xmax = None ,\n ymin = None , ymax = None , x0 = () ) :\n \n if xmin is None : xmin = self.xminmax()[0]\n if xmax is None : xmax = self.xminmax()[1]\n if self.xmin... | [
"0.65930706",
"0.6441789",
"0.6427979",
"0.6360444",
"0.6352979",
"0.634569",
"0.6193621",
"0.61772054",
"0.6101645",
"0.6027506",
"0.60104257",
"0.58738685",
"0.5823002",
"0.5815513",
"0.57013637",
"0.5684938",
"0.56506073",
"0.56309605",
"0.5604591",
"0.5601875",
"0.5589556... | 0.793842 | 0 |
Runs the IOLoop until stop is called or timeout has passed. In the event of a timeout, an exception will be thrown. If condition is not None, the IOLoop will be restarted after stop() until condition() returns true. | def execute(self, condition=None, timeout=90):
if not self.stopped:
if timeout:
def timeout_func():
try:
raise Exception('Async operation timed out after {} seconds'.format(timeout))
except:
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for(self, condition, timeout_message='', time_for_stop=None):\n\n if self._loaded:\n time_for_stop = time_for_stop or self.operate_timeout\n else:\n time_for_stop = time_for_stop or self.loading_timeout\n\n started_at = time.time()\n while not condition():... | [
"0.612119",
"0.61086583",
"0.5870289",
"0.56086886",
"0.5497519",
"0.5474042",
"0.5418685",
"0.5394804",
"0.53819144",
"0.5278656",
"0.5167572",
"0.5094579",
"0.50806487",
"0.5072892",
"0.50411636",
"0.5006859",
"0.4991152",
"0.4987409",
"0.49852386",
"0.498472",
"0.49841267"... | 0.6562266 | 0 |
Decodes the access token | def decodeAccesshTokenForRefreshToken( accessToken):
try:
payload = jwt.decode(accessToken, ApiJWTAuthentication.secretKey_access)
return {"message": "success","refresh_token": payload['refresh_token']}
except jwt.ExpiredSignatureError:
return {"message": "Expired Acc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode(encoded_token):\n return jwt.decode(encoded_token, key=settings.JWT_AUTH['JWT_SECRET_KEY'])",
"def decode_token(token):\n\n return jwt.decode(\n token, settings.JWT_SECRET, algorithms=[settings.JWT_ALGO])",
"def decode_token(token):\n decoded_token = jwt.decode(token, secret_... | [
"0.71385145",
"0.6923402",
"0.68968344",
"0.6808708",
"0.67496204",
"0.6623631",
"0.65789926",
"0.65712416",
"0.65472937",
"0.6485703",
"0.6442308",
"0.642451",
"0.64098173",
"0.6402688",
"0.63797253",
"0.63750285",
"0.6345176",
"0.633867",
"0.63199043",
"0.63098365",
"0.6309... | 0.69587624 | 1 |
Helper to complete the current task. Uses the current date for the completion date. | def complete(self):
self.completed = peewee.datetime.date.today()
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete_task(self, user_id, task_id, completed=datetime.now()):\n\n sql = \"select complete_task(%s, %s, %s)\"\n data = (user_id, task_id, completed)\n self._query_insert(sql, data)",
"def complete_task(self, tid):\n self.task_controller.complete_task(tid)",
"def task_finished(... | [
"0.6669351",
"0.6491872",
"0.6246007",
"0.60987025",
"0.60895264",
"0.6069248",
"0.6016118",
"0.5858474",
"0.5845539",
"0.57785606",
"0.5765019",
"0.57643634",
"0.56999147",
"0.566027",
"0.5653691",
"0.5622749",
"0.55803406",
"0.557997",
"0.55447817",
"0.5539159",
"0.55381876... | 0.6539347 | 1 |
Returns the URL for marking this task as completed. | def complete_url(self):
return url_for('complete',id=self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(self):\n endpoint = 'taskinfo?taskID=%d' % self.id\n return posixpath.join(self.connection.weburl, endpoint)",
"def task_url(self, obj):\n request = self.context.get(\"request\")\n return reverse(\"task-detail\", args=[obj.id], request=request)",
"def get_finished_url(self):... | [
"0.67253566",
"0.6233988",
"0.59180653",
"0.5902739",
"0.58974993",
"0.5888213",
"0.58599114",
"0.58551264",
"0.5851763",
"0.58509356",
"0.58509356",
"0.5793037",
"0.57874066",
"0.57840174",
"0.57840174",
"0.5769833",
"0.576545",
"0.5763912",
"0.57438934",
"0.5731111",
"0.573... | 0.73656243 | 0 |
Get primary key properties for a SQLAlchemy model. | def get_primary_keys(model):
mapper = model.__mapper__
return [mapper.get_property_by_column(column) for column in mapper.primary_key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _primary_key_columns(cls):\n return [col for col in cls._columns() if getattr(cls, col).primary_key]",
"def primary_key(cls):\n\n if cls.__from_class__:\n cls = cls.__from_class__\n return cls.__table__.primary_key.columns.values()[0].name",
"def _get_model_pks(model) -> 'Tu... | [
"0.7160862",
"0.7128666",
"0.7097386",
"0.70444226",
"0.7013771",
"0.6962156",
"0.69374174",
"0.69265515",
"0.69011205",
"0.68751216",
"0.6821622",
"0.6797018",
"0.6795012",
"0.66927487",
"0.6628391",
"0.6505348",
"0.6425742",
"0.639433",
"0.6361701",
"0.61770916",
"0.6156272... | 0.84452593 | 0 |
Deserialize a serialized value to a model instance. If the parent schema is transient, create a new (transient) instance. Otherwise, attempt to find an existing instance in the database. | def _deserialize(self, value, *args, **kwargs):
if not isinstance(value, dict):
if len(self.related_keys) != 1:
keys = [prop.key for prop in self.related_keys]
raise self.make_error("invalid", value=value, keys=keys)
value = {self.related_keys[0].key: valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deserialize(self, value, **kwargs):\n kwargs.update({'trusted': kwargs.get('trusted', False)})\n if self.deserializer is not None:\n return self.deserializer(value, **kwargs)\n if value is None:\n return None\n if issubclass(self.instance_class, HasProperties):... | [
"0.66955453",
"0.66205436",
"0.6339031",
"0.6127864",
"0.5938254",
"0.58837366",
"0.58773464",
"0.58529365",
"0.57516885",
"0.56784666",
"0.5618999",
"0.5596128",
"0.55882066",
"0.5542467",
"0.5535758",
"0.5521772",
"0.5444111",
"0.5418266",
"0.54116184",
"0.54016405",
"0.539... | 0.68193334 | 0 |
Here I will use two dictionary to find the judge. The judge has two requirement. 1. He trust nobody 2. He is trusted by everyone So the judge will not appear in the trust dictionary and The judge in the trusted dictionary will be n1 | def findJudge(self, N, trust):
if trust == []:
return 1
trust_dict = {}
trusted_dict = {}
for i in range(len(trust)):
trust_dict[trust[i][0]] = trust_dict.get(trust[i][0], 0) + 1
for i in range(len(trust)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_judge1(_str1):\n\tglobal final_output\n\tif _str1==\"\":\n\t\treturn 'Finished.'\n\t_list0=dict_check34(_str1)\n\t#Judge1: Longest\n\t_list=[]\n\t_list1=[]\n\tfor i in range(len(_list0)):\n\t\tn=0\n\t\tfor j in range(3):\n\t\t\tn+=len(_list0[i][j])\n\t\t_list.append(n)\n\n\t_max=max(_list)\n\tfor i in ran... | [
"0.6606831",
"0.5874298",
"0.5797658",
"0.5700648",
"0.56681466",
"0.56661856",
"0.56576616",
"0.5616665",
"0.5603664",
"0.5586277",
"0.5550964",
"0.55097014",
"0.5485889",
"0.547874",
"0.547864",
"0.54734164",
"0.5467415",
"0.5467028",
"0.5458769",
"0.54495853",
"0.5448698",... | 0.6127626 | 1 |
Undoes the last cooldown counter for usererror cases. | def revert_cooldown_counter(command: commands.Command, message: Message) -> None:
if command._buckets.valid:
bucket = command._buckets.get_bucket(message)
bucket._tokens = min(bucket.rate, bucket._tokens + 1)
logger.debug(
"Cooldown counter reverted as the com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_fedcm_cooldown(self):\n pass",
"async def _reset_cooldowns(self, ctx):\n if await self.casino_is_global():\n for player in await self.db.all_users():\n try:\n user = await ctx.bot.fetch_user(player)\n except AttributeError:\n ... | [
"0.6446497",
"0.63339865",
"0.5929738",
"0.5898447",
"0.58259195",
"0.56469464",
"0.5618133",
"0.55638516",
"0.55638516",
"0.55428493",
"0.55135626",
"0.5491918",
"0.5457377",
"0.5438237",
"0.54345345",
"0.5428591",
"0.54179364",
"0.54025924",
"0.5400194",
"0.53919417",
"0.53... | 0.67223144 | 0 |
Build a basic embed with red colour and either a random error title or a title provided. | def error_embed(message: str, title: Optional[str] = None) -> Embed:
title = title or random.choice(ERROR_REPLIES)
embed = Embed(colour=Colours.soft_red, title=title)
embed.description = message
return embed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _error_embed_helper(title: str, description: str) -> discord.Embed:\n return discord.Embed(title=title, description=description, colour=discord.Colour.red())",
"def error_embed(self, message: str):\n embed = discord.Embed(color=discord.Color.red())\n embed.title = \"\"\n embed.descrip... | [
"0.7961499",
"0.7644481",
"0.745184",
"0.7408599",
"0.66280687",
"0.6610442",
"0.61613584",
"0.6114265",
"0.6081033",
"0.5978314",
"0.59047866",
"0.58742785",
"0.571194",
"0.57114404",
"0.56518126",
"0.56516266",
"0.5614344",
"0.5605068",
"0.5581944",
"0.55571604",
"0.5534191... | 0.80812234 | 0 |
Score is precision @ k Relevance is binary (nonzero is relevant). | def precision_at_k(r, k):
assert k >= 1
r = np.asarray(r)[:k] != 0
if r.size != k:
raise ValueError('Relevance score length < k')
return np.mean(r) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ranking_precision_score(y_true, y_score, k=10):\n unique_y = np.unique(y_true)\n\n if len(unique_y) > 2:\n raise ValueError(\"Only supported for two relevance levels.\")\n\n n_relevant = 0\n n_pos = 0\n for relevance_score in y_true:\n if relevance_score == 1:\n n_pos +=... | [
"0.75731516",
"0.7522145",
"0.73962903",
"0.7273532",
"0.7057773",
"0.68080103",
"0.6795387",
"0.67633754",
"0.6720216",
"0.66712075",
"0.6666154",
"0.6661671",
"0.6647038",
"0.6594839",
"0.6591126",
"0.65699756",
"0.65699756",
"0.65699756",
"0.656782",
"0.65359664",
"0.64968... | 0.7581125 | 0 |
Find duplicate number in nums. Given a list of nums with, at most, one duplicate, return the duplicate. If there is no duplicate, return None >>> find_the_duplicate([1, 2, 1, 4, 3, 12]) 1 >>> find_the_duplicate([6, 1, 9, 5, 3, 4, 9]) 9 >>> find_the_duplicate([2, 1, 3, 4]) is None True | def find_the_duplicate(nums):
# frequency = {}
# for num in nums:
# frequency[num] = frequency.get(num, 0) + 1
# for num in frequency:
# if frequency[num] == 2:
# return num
##########
# nums_dict = list(enumerate(sorted(nums)))
# for i, num in nums_dict:
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def single_number(self, nums: List[int]) -> int:\n if not nums:\n return False\n if len(nums) == 1:\n return nums[0]\n\n visited = set()\n\n for i in nums:\n if i not in visited:\n visited.add(i)\n else:\n visited... | [
"0.72007155",
"0.71849084",
"0.7120184",
"0.6819626",
"0.67981535",
"0.6700376",
"0.6495514",
"0.64611137",
"0.6423958",
"0.6412791",
"0.64043427",
"0.6378339",
"0.6245624",
"0.6185543",
"0.60564303",
"0.602177",
"0.59826195",
"0.5961004",
"0.5892497",
"0.5873059",
"0.5866645... | 0.8059625 | 0 |
Adds a single or a list of variables to the table. If a list is added, a common nD halton sequence is generated and the variables are transformed according to their distribution. | def add(self, variables):
if not isinstance(variables, (list, tuple)):
variables = [variables]
for v in variables:
if isinstance(v, Variable):
self.list.append(v)
elif isinstance(v, dict):
self.list.append(Variable.create(**v))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_variables(self, variables):\n for variable in variables:\n self.variables.append(variable)",
"def add_variables(self, variables, cardinality, inhibitor_probability):\n if len(variables) == 1:\n if not isinstance(inhibitor_probability[0], (list, tuple)):\n ... | [
"0.6779108",
"0.5884022",
"0.58515257",
"0.57882535",
"0.5754274",
"0.5742688",
"0.570694",
"0.57024676",
"0.5680752",
"0.5630975",
"0.55475026",
"0.5504034",
"0.53752697",
"0.5362309",
"0.5345792",
"0.53398895",
"0.5313651",
"0.52873653",
"0.5265503",
"0.5260763",
"0.5256366... | 0.65194196 | 1 |
Deletes one or more variables from the table. | def delete_variable(self, columns):
if not isinstance(columns, (list, tuple)):
columns = [columns]
for col in columns:
if isinstance(col, str):
col = [i for i, v in enumerate(self.list) if v.name == col][0]
self.list.pop(col) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_variables(self, variables):\n variables = [variables] if isinstance(variables, str) else set(variables)\n indices = [\n index\n for index, variable in enumerate(self.variables)\n if variable in variables\n ]\n self.variables = np.delete(self.vari... | [
"0.6981609",
"0.6801651",
"0.6574825",
"0.6357187",
"0.6268128",
"0.6219467",
"0.6161024",
"0.6139154",
"0.61092824",
"0.6058168",
"0.6037691",
"0.60095805",
"0.5996754",
"0.5977992",
"0.59129065",
"0.5885939",
"0.5858878",
"0.5821576",
"0.58151644",
"0.579565",
"0.57837343",... | 0.6951394 | 1 |
Generates a common halton sequence for all variables where this is possible and transforms them according to their distribution. | def generate_from_halton(self):
halton_variables = [
v for v in self.list if v.kind.lower() not in EXCLUDE_FROM_HALTON
]
if halton_variables:
nd_halton_seq = halton((self.samples, len(halton_variables)))
for idx, v in enumerate(halton_variables):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halton_sequence(values, feature, parent):\r\n \r\n index = values[0]\r\n base = values[1]\r\n return halton(index, base)",
"def chao1_var_no_doubletons(singles, chao1):\n s = float(singles)\n return s*(s-1)/2 + s*(2*s-1)**2/4 - s**4/(4*chao1)",
"def gen_samp_halton(self, dim, N, vectorize... | [
"0.62650365",
"0.55580455",
"0.5470865",
"0.53370374",
"0.528174",
"0.5237821",
"0.52284503",
"0.5134325",
"0.50632566",
"0.50232273",
"0.50070465",
"0.49988118",
"0.49939665",
"0.4990304",
"0.49660513",
"0.49465144",
"0.49359086",
"0.48992848",
"0.48754936",
"0.4871042",
"0.... | 0.7201351 | 0 |
Creates a Variable instance from a string. E.g. 'Uniform(3.4, 7.8)' | def create_from_str(cls, name, size, v_str):
from re import split
def try_parse(s):
funcs = [int, float]
for f in funcs:
try:
return f(s)
except ValueError:
pass
return s
if isinstance(t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_str(cls, string):",
"def fromString(self, s):\n vars = s.replace(',', '').split()\n self.position = [int(vars[0]), int(vars[1])]\n print(self.position)\n self.K = np.array([[int(vars[2]), int(vars[3])], \n [int(vars[4]), int(vars[5])]])",
"def __in... | [
"0.6127289",
"0.6087292",
"0.6058823",
"0.60111624",
"0.5989084",
"0.5988206",
"0.59134144",
"0.5904956",
"0.5896577",
"0.5887973",
"0.5801908",
"0.57761246",
"0.57336295",
"0.5733064",
"0.57015896",
"0.5686449",
"0.5683663",
"0.5681443",
"0.56389797",
"0.5605651",
"0.5581987... | 0.67324436 | 0 |
pads the string on the left side by adding the add string to the left as many times as necessary such that the output is "[add,]string" | def pad_str_left(string, length: int, add: str) -> str:
out_string = string
while len(out_string) < length:
out_string = add + out_string
return out_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padder(str_list, extra=0):\n length = max(len(str(s)) for s in str_list) + extra\n\n def pad(string):\n string = str(string)\n padding = max(0, length - len(string))\n return string + (padding * \" \")\n\n return pad",
"def _pad_shorter(sequence: str) -> str:\n return seq... | [
"0.67100894",
"0.6707976",
"0.6621261",
"0.6557144",
"0.64166796",
"0.6376291",
"0.63675404",
"0.63523495",
"0.6338037",
"0.6326726",
"0.62968856",
"0.62506044",
"0.6153734",
"0.6096829",
"0.60582674",
"0.6022688",
"0.6016048",
"0.6015064",
"0.60114783",
"0.5928853",
"0.58942... | 0.75408876 | 0 |
extract words from the text with the filters given above. | def extract_words_from_text_with_filters(text: str, char_filters: Union[str, List[str]]) -> List[str]:
translate_dict = dict((c, " ") for c in char_filters)
new_text = Str.get_string_from_translate_dict(text.lower(), translate_dict)
return [word for word in new_text.split(" ") if len(word) > 0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def words(self, text):\n return re.findall(r'\\w+', text)",
"def extract_words(self):\n str = self.text.lower()\n words = re.sub(r'[?|—|:|\"|,|\\.\\n|\\.|\\s|\\n|\\t|\\v|\\f|\\r]+', \"*\", str)\n self.word_list = words.split(\"*\")",
"def process_text(self, text):\n\n flags =... | [
"0.71811485",
"0.7146654",
"0.7123673",
"0.7050718",
"0.7026393",
"0.6935126",
"0.68902266",
"0.68653965",
"0.68196225",
"0.67737347",
"0.6772545",
"0.6758144",
"0.66683286",
"0.6657706",
"0.66109127",
"0.66083884",
"0.65960807",
"0.6518513",
"0.6510654",
"0.6507925",
"0.6492... | 0.7547689 | 0 |
remove the characters chars from the string | def remove_chars_from_string(string: str, chars: str) -> str:
translate_dict = dict((c, "") for c in chars)
return Str.get_string_from_translate_dict(string, translate_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_chars(old_str, chars):\n new_string = old_str\n for char in chars:\n new_string = new_string.replace(char, '')\n \n return new_string",
"def removeChars(inStr, chars):\n newStr = inStr\n for char in chars:\n newStr = newStr.replace(char, \"\")\n return newStr",
"de... | [
"0.80567366",
"0.78707707",
"0.75965416",
"0.7534202",
"0.74423885",
"0.7400966",
"0.73769957",
"0.732449",
"0.7247478",
"0.72136223",
"0.71792966",
"0.71769863",
"0.71769863",
"0.7173774",
"0.7155353",
"0.7151169",
"0.71502686",
"0.7126166",
"0.7124986",
"0.7114123",
"0.7109... | 0.79013807 | 1 |
checks whether the date is before the target date | def is_date_is_before(date: str, target_date: str) -> bool:
year, month, day = [int(v) for v in get_year_month_day_from_date(date)]
t_year, t_month, t_day = [int(v) for v in get_year_month_day_from_date(target_date)]
return datetime.date(year, month, day) < datetime.date(t_year, t_month, t_day) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_before(self,other_date):",
"def isBefore(self, d2):\n if self.year < d2.year:\n return True\n elif self.year == d2.year and self.month < d2.month:\n return True\n elif self.year == d2.year and self.month == d2.month and self.day < d2.day:\n return True\n else:\n return Fals... | [
"0.7974179",
"0.7136264",
"0.7086439",
"0.70032203",
"0.6943512",
"0.691709",
"0.68937576",
"0.68937576",
"0.68851334",
"0.6731868",
"0.6680624",
"0.63977677",
"0.6367512",
"0.6367512",
"0.6366988",
"0.63058424",
"0.62624735",
"0.6255914",
"0.6251922",
"0.62442446",
"0.622947... | 0.7974098 | 1 |
Give a list of dates from the start date until the until date | def get_dates_from(start_date: str, until_date: str) -> list:
date_start_date = extract_date_from_date_time(start_date)
assert is_date_is_before(date_start_date, until_date), "start_date must come before until_date"
dates = [date_start_date]
current_date = date_start_date
while True:
if curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dates(self):\n dates = []\n d = self.date_a\n while d < self.date_b:\n dates.append(d)\n d += datetime.timedelta(1)\n\n return dates",
"def _get_dates_list(date_from, date_to):\n d_from, d_to = _validate_dates(date_from, date_to)\n return [(d_from + dat... | [
"0.79282206",
"0.7813958",
"0.7752638",
"0.77034736",
"0.77034736",
"0.74981916",
"0.7465518",
"0.7401069",
"0.7371189",
"0.72273517",
"0.7195485",
"0.71697414",
"0.7110415",
"0.70919085",
"0.706751",
"0.70579195",
"0.70442706",
"0.7034021",
"0.70304114",
"0.70287514",
"0.699... | 0.84404135 | 0 |
normalization function; x is the array with the performances and y is the normalization method. For vector input 'v' and for linear 'l' | def norm(x, y):
if y == 'v':
k = array(cumsum(x**2, 0))
z = array([[round(x[i, j] / sqrt(k[x.shape[0] - 1,
j]), 3) for j in range(x.shape[1])]
for i in range(x.shape[0])])
return z
else:
yy = []
for i in range(x.shape[1]):
yy.append(ama... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_l2(x):\n return x / (npla.norm(x))",
"def normalize(v):\n return v / np.linalg.norm(v)",
"def normalisation_l2(x):\n res = np.zeros(x.shape)\n print(x.shape)\n for i in range(x.shape[0]):\n res[i] = x[i]/(np.linalg.norm(x[i],2)+1e-5)\n std = res.std()\n mean = res.mean... | [
"0.6730058",
"0.6626219",
"0.6596552",
"0.654943",
"0.6383801",
"0.63267845",
"0.6323685",
"0.6296565",
"0.629236",
"0.6283104",
"0.62742805",
"0.6272496",
"0.62530035",
"0.6211536",
"0.61133325",
"0.61099577",
"0.60958254",
"0.60511935",
"0.6014799",
"0.60141456",
"0.6008235... | 0.6896728 | 0 |
multiplication of each evaluation by the associate weight; r stands for the weights matrix and t for the normalized matrix resulting from norm() | def mul_w(r, t):
z = array([[round(t[i, j] * r[j], 3)
for j in range(t.shape[1])]
for i in range(t.shape[0])])
return z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _eval(self, v):\n return super(weighted_sum_squares, self)._eval(self.weight * v)",
"def spectral_norm_parallel(self):\n weights = {}\n for l in self.all_conv_layers:\n weight = l.weight_normalized\n weight_mat = weight.view(weight.size(0), -1)\n if weigh... | [
"0.6129544",
"0.6117957",
"0.60585874",
"0.58965945",
"0.5833318",
"0.58202934",
"0.58175045",
"0.5808738",
"0.5746646",
"0.57379395",
"0.5711738",
"0.5680558",
"0.5667962",
"0.5665953",
"0.5665172",
"0.56397617",
"0.5603127",
"0.5603127",
"0.5602767",
"0.5597688",
"0.5575965... | 0.6385531 | 0 |
matrix is the initial decision matrix, weight is the weights matrix, norm_m is the normalization method, id_sol is the action used, and pl is 'y' for plotting the results or any other string for not | def topsis(matrix, weight, norm_m, id_sol):
z = mul_w(weight, norm(matrix, norm_m))
s, f = zenith_nadir(z, id_sol)
p, n = distance(z, s, f)
final_s = array([n[i] / (p[i] + n[i])
for i in range(p.shape[0])])
if pl == 'y':
q = [i + 1 for i in range(matrix.shape[0])]
return final_s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_plot_matrix(self):\n tx = self.i_border[0]+self.o_wh[1]*self.i_origin[0]/self.i_axis[0]*self._scaling[0]\n ty = -self.i_border[1]-(self.o_wh[1]-self.o_wh[1]*self.i_origin[1]/self.i_axis[1])*self._scaling[1]\n\n sx = (self.o_wh[0])*self._scaling[0]/self.i_axis[0]\n sy = (sel... | [
"0.53575367",
"0.52575105",
"0.5047736",
"0.50258255",
"0.5019314",
"0.5014307",
"0.49873912",
"0.4984877",
"0.49825478",
"0.49677086",
"0.49216104",
"0.48880774",
"0.48840985",
"0.4865971",
"0.4859036",
"0.4854754",
"0.48357424",
"0.47992447",
"0.4792262",
"0.47912467",
"0.4... | 0.5631413 | 0 |
connect to BBG Desktop API streaming service | def connect(self, service='//blp/mktdata', host='localhost', port=8194):
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(host)
sessionOptions.setServerPort(port)
# Create a Session
session = blpapi.Session(sessionOptions)
# start the session
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def connect(self):\n\n self.rtm = await api_call('rtm.start') # Start the connection\n assert self.rtm['ok'], self.rtm['error']\n\n with aiohttp.ClientSession() as client:\n async with client.ws_connect(self.rtm[\"url\"]) as ws:\n async for msg in ws:\n ... | [
"0.61455",
"0.6107906",
"0.59628505",
"0.58750725",
"0.5872142",
"0.5823631",
"0.5823631",
"0.57745796",
"0.5737923",
"0.57350636",
"0.5722567",
"0.5695313",
"0.5695165",
"0.5688673",
"0.56867665",
"0.56855273",
"0.5664964",
"0.5631598",
"0.5603763",
"0.5578657",
"0.5571712",... | 0.63837266 | 0 |
Takes a generator, and returns the elements, with the previous element. The first element only appears as previous. (and the last neveras) | def with_prev(gen):
prev = next(gen)
for el in gen:
yield prev, el
prev = el | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_previous(iterable, *, fillvalue=None):\n previous = fillvalue\n for item in iterable:\n yield previous, item\n previous = item",
"def previous_current_next(iterable):\n iterable = iter(iterable)\n prv = None\n cur = iterable.__next__()\n try:\n while True:\n ... | [
"0.7380492",
"0.7278611",
"0.6838151",
"0.64239144",
"0.63389957",
"0.62083423",
"0.619124",
"0.6190989",
"0.6165338",
"0.6127255",
"0.6122218",
"0.60787714",
"0.60787714",
"0.60787714",
"0.59519506",
"0.59518856",
"0.59163994",
"0.5854666",
"0.5818591",
"0.5799487",
"0.57877... | 0.79789877 | 0 |
thread function which parses through data dictionary of datetimevalue pairs and uploads values to Google Sheets | def upload_protocol(sheet_no, data_struct):
global num_uploads
client = gspread.authorize(creds)
sheet = client.open('Fridge Data Testing').get_worksheet(sheet_no)
print('uploading...')
for key, val in data_struct.items():
time.sleep(7)
d = key.strftime('%m/%d/%Y ')
t = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_process():\n global localtime\n global value_dict\n sensor_types = sEtting.sensor_types\n sensor_values = []\n msg = None\n value_dict = collections.OrderedDict.fromkeys(sEtting.payload_header)\n value_dict[\"ver_format\"] = sEtting.ver_format\n value_dict[\"FAKE_GPS\"] = sEtting.f... | [
"0.61692804",
"0.60276407",
"0.56456286",
"0.5621793",
"0.56024337",
"0.557042",
"0.5544886",
"0.55163705",
"0.5486351",
"0.5377748",
"0.53730744",
"0.53604203",
"0.52800494",
"0.52580196",
"0.5248529",
"0.5245868",
"0.5236083",
"0.5233625",
"0.52309823",
"0.5220883",
"0.5189... | 0.6345834 | 0 |
EX_PLOT_SOLVER_WEIGHTS Example showing how to plot the first layer weights in a solver object | def ex_plot_solver_weights(ax, fname, title=None):
if title is None:
title = "Layer 1 weights"
solv = solver.Solver(None, None)
solv.load_checkpoint(fname)
vis_solver.plot_model_first_layer(ax, solv.model, cname)
ax.set_title(title) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_weights(self,):\n \n weights_evolution = pd.DataFrame(self.predict[\"weights\"].values.tolist(), columns=[*self.models.keys()])\n\n plt.figure(figsize=(8, 5))\n\n for name in weights_evolution.columns:\n plt.plot(weights_evolution[name], label=name)\n\n plt.ti... | [
"0.6385945",
"0.6170082",
"0.5981295",
"0.5815622",
"0.5803023",
"0.5791579",
"0.57450867",
"0.56806463",
"0.55871564",
"0.55849475",
"0.55763376",
"0.5517764",
"0.55028695",
"0.550259",
"0.5473033",
"0.5391613",
"0.5383743",
"0.5383329",
"0.53756016",
"0.5358619",
"0.5335213... | 0.7461885 | 0 |
EX_PLOT_SEQUENCE Example wrapper for vis_solver.plot_model_first_layer showing a possible inner loop for a weight visualization animation | def ex_plot_sequence(ax, path, fname, num_checkpoints, prefix=None, step=1, pause_time=0.01):
if type(num_checkpoints) is tuple:
if len(num_checkpoints) > 2:
raise ValueError("Cannot accept more than 2 limits for num_checkpoints")
if num_checkpoints[0] == 0:
n_min = 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_figure1(model, S, Z, A, lmbdas, figdir='.'):\n N_used = len(model.used_states)\n A = A[:N_used, :N_used]\n lmbdas = lmbdas[:N_used, :]\n T,C = S.shape\n fig = create_figure((5,3.5))\n\n # S = S[:1000]\n # Z = Z[:1000]\n\n # Plot the spike train\n ax = create_axis_at_location(fig... | [
"0.5870648",
"0.58663654",
"0.58504975",
"0.57887715",
"0.5779638",
"0.57354945",
"0.5731308",
"0.5727329",
"0.5711856",
"0.56892616",
"0.5594663",
"0.5558167",
"0.5547996",
"0.5537942",
"0.553181",
"0.5518179",
"0.55143106",
"0.5478215",
"0.5464771",
"0.5453829",
"0.5453513"... | 0.5876752 | 0 |
Function to move all of the bricks when they're in the process of getting hit | def moveBricks(questionBricks, interactBricks, breakingBrick):
BRICKVY, IDLE, TYPE = 4, 5, 6
# Moving all question blocks that are hit
for brick in questionBricks: # Going through each question block
if brick[BRICKVY] != 3.5 and brick[IDLE] == 1: # Checking if the block is back at its original pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __move_ball(self):\n while not self.__game_is_over():\n self.__ball.move(self.__dx, self.__dy)\n self.__handle_wall_collision()\n if self.__num_lives == 0:\n self.__game_over_picture()\n break\n elif self.__bricks_total == 0:\n ... | [
"0.72056586",
"0.7097705",
"0.6833168",
"0.67692256",
"0.66816014",
"0.666886",
"0.66138154",
"0.65899867",
"0.6583445",
"0.65507984",
"0.65507984",
"0.65214247",
"0.6517555",
"0.6495065",
"0.6485477",
"0.64805573",
"0.64264655",
"0.64043504",
"0.6400978",
"0.6386226",
"0.638... | 0.72406894 | 0 |
Function to allow coins and points to float up | def floatObjects(moveCoins, points):
X, Y, COINVY = 0, 1, 4
PTSCOUNT, PTSNUM = 2, 3
for coin in range(len(moveCoins) - 1, -1, -1): # Going through each moving coin
if moveCoins[coin][COINVY] != 5: # Checking if the animation is still going by checking VY
moveCoins[coin][COINVY] += 0.5 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_coins():\r\n print(\"Please insert coins.\")\r\n quarters = int(input(\"How many quarters?:\"))\r\n dimes = int(input(\"How many dimes?:\"))\r\n nickels = int(input(\"How many nickels?:\"))\r\n pennies = int(input(\"How many pennies?:\"))\r\n total_amount = (quarters * 0.25) + (dimes ... | [
"0.6244508",
"0.6085001",
"0.60503703",
"0.5918569",
"0.5901316",
"0.5879677",
"0.58134323",
"0.5808035",
"0.5800907",
"0.57918227",
"0.57757616",
"0.57389444",
"0.5732006",
"0.57240874",
"0.5693288",
"0.5692767",
"0.5681823",
"0.5678981",
"0.56784904",
"0.5616299",
"0.561256... | 0.6254845 | 0 |
Function to draw Mario's stats on screen (Points, coins, level number, and time left) | def drawStats(mario, marioInfo, points, coins, startTime, level, fastMode, timesUp, coinPic, spriteCount, forceTime = None):
ONGROUND, JUMPFRAMES, INGROUND, ISCROUCH, ONPLATFORM, ISFALLING, ISANIMATING, INVULFRAMES = 0, 1, 2, 3, 4, 5, 6, 7
X, Y, VX, VY, DIR, STATE = 0, 1, 2, 3, 4, 5
currentTime = 200 - int(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_info(self) -> None:\n\n icon_size = INFO_HEIGHT - 6\n\n for i in range(self.lives):\n life_icon = pg.image.load(\n path.join(image_dir, f\"pengo_left.png\")\n ).convert_alpha()\n life_icon = pg.transform.scale(life_icon, (icon_size, icon_size))... | [
"0.73251015",
"0.7254068",
"0.70598423",
"0.7003535",
"0.6832389",
"0.672869",
"0.6585104",
"0.6375345",
"0.63422054",
"0.6308433",
"0.6288771",
"0.6238304",
"0.6168731",
"0.6111721",
"0.61045563",
"0.6101927",
"0.6101008",
"0.60984254",
"0.60963476",
"0.6092666",
"0.6050358"... | 0.7563521 | 0 |
Function to draw the pause screen on top of the surface | def drawPause():
alphaSurface = Surface((800, 600)) # Making a surface
alphaSurface.set_alpha(128) # Giving it alpha functionality
alphaSurface.fill((0, 0, 0)) # Fill the surface with a black background
screen.blit(alphaSurface, (0, 0)) # Blit it into the actual screen
# Blitting pause screen te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, p):\r\n self.active = True\r\n surface = pygame.surfarray.make_surface(p)\r\n self.screen.blit(surface, (0, 0))\r\n pygame.display.flip()\r\n return",
"def draw(self, draw_surface):\n draw_surface.blit(self.background_frame, (0, 120))",
"def draw(self, s... | [
"0.7404573",
"0.7204721",
"0.7189807",
"0.717696",
"0.71732324",
"0.70616364",
"0.69439983",
"0.6924246",
"0.6879588",
"0.6837976",
"0.6712683",
"0.6705588",
"0.6689974",
"0.6661779",
"0.6656619",
"0.66292024",
"0.66060925",
"0.65907043",
"0.6577849",
"0.65681565",
"0.6560610... | 0.8452994 | 0 |
Function for the pole grabbing animation | def movePole(mario, marioStats, marioScore, frame, flagInfo, unisprite, isDone, forceTime):
PTS, COIN, LIVES = 0, 1, 2
X, Y, VX, VY, DIR, STATE = 0, 1, 2, 3, 4, 5
ONGROUND, JUMPFRAMES, INGROUND, ISCROUCH, ONPLATFORM, ISFALLING, ISANIMATING, INVULFRAMES = 0, 1, 2, 3, 4, 5, 6, 7
# Declaring flag pole Rect... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spinAround(self):",
"def draw(self, DISPLAYSURF, frame:int):\r\n\r\n #Pac-Man gets drawn\r\n pg.draw.circle(DISPLAYSURF, Colors.colors['YELLOW'], (self.pos[0] + self.grid_size // 2, self.pos[1] + self.grid_size // 2), self.radius)\r\n\r\n\r\n #The rest of the function has to do with Pacm... | [
"0.6497629",
"0.60039103",
"0.5968689",
"0.5912195",
"0.58834237",
"0.57261246",
"0.57001954",
"0.5674496",
"0.56446874",
"0.56046677",
"0.5601234",
"0.5589281",
"0.55861264",
"0.55768484",
"0.55692846",
"0.5567347",
"0.5559935",
"0.5557085",
"0.55568796",
"0.55568796",
"0.55... | 0.61660314 | 1 |
Function to apply commands to all mixer channels | def globalSound(command):
for id in range(mixer.get_num_channels()): # Going through each mixer channel
if command == "stop":
mixer.Channel(id).stop() # Stopping all playback on the channel
elif command == "pause":
mixer.Channel(id).pause() # Pausing playback on the channe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def func(self):\n from evennia.comms.models import ChannelDB\n\n caller = self.caller\n if self.args not in (\"on\", \"off\"):\n return super(CmdArxAllCom, self).func()\n if self.args == \"on\":\n # get names of all channels available to listen to\n # an... | [
"0.67937",
"0.6212347",
"0.6127568",
"0.60401815",
"0.57887614",
"0.5695176",
"0.5614732",
"0.5486767",
"0.54710484",
"0.5466062",
"0.5415141",
"0.5412691",
"0.5399915",
"0.535831",
"0.5321624",
"0.52504086",
"0.52504086",
"0.52504086",
"0.52504086",
"0.5235799",
"0.52335495"... | 0.6670069 | 1 |
Function to progress the universal sprite counter | def spriteCounter(counter):
counter += 0.2 # Adding to the counter
if counter > 10: # Checking if the counter hits the limit and resetting it
counter = 0
return counter # Returning the new counter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tick(self):\n self.current_count += 1\n self.progress(self.current_count)",
"def increment_counter(self) -> None:",
"def tick():\n global counter\n counter += 1",
"def counter(self) -> int:",
"def counter(self) -> int:",
"def increment(self):\n self.pos += 1\n if sel... | [
"0.67599034",
"0.6682511",
"0.6467532",
"0.6404736",
"0.6404736",
"0.62559193",
"0.62494326",
"0.6231774",
"0.62207705",
"0.6155689",
"0.6126023",
"0.6084964",
"0.6029701",
"0.59845203",
"0.596666",
"0.59613025",
"0.59318554",
"0.58982337",
"0.58488274",
"0.5845167",
"0.58451... | 0.7577976 | 0 |
Changing ownership, permission of resolv.conf and named.conf files. This is required to so that enum server runs properly | def changeOwn():
os.system('sudo chown -R test:users /etc/resolv.conf')
os.system('sudo chown -R test:named /etc/named.conf') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ownership(self):\n\n os.chmod(os.path.join(\"%s\" % NetworkManager_conf_dir, self.connection._id), 0600)",
"def setup_permissions():\n sudo('chown %s:%s -R %s' % (env.apache_user, env.apache_user, env.whole_path_symlinked))",
"def _fix_r_res(res, o, g, p):\n print green(\"Setting remote re... | [
"0.6728234",
"0.63324696",
"0.6216844",
"0.6043002",
"0.5902963",
"0.5706212",
"0.569801",
"0.5665244",
"0.56556827",
"0.56550056",
"0.5617268",
"0.5592188",
"0.5543758",
"0.55316424",
"0.5518632",
"0.54966915",
"0.5488969",
"0.53970206",
"0.5382431",
"0.5380776",
"0.5254363"... | 0.77114516 | 0 |
Copy "e164.zone" file from /var/opt/nextest/tdb/production_components.qms/enum.qms to /var/lib/named. Modify the file so that it will contain the actual ip addresses. | def zone(enum_path):
lip = socket.gethostbyname('mygen')
sipb = socket.gethostbyname('prv_rsa')
sip1 = socket.gethostbyname('public8')
#34101 Modified realmIP to endpoint IP so that SETUP/INVITE message will go through enum_realm
h323b = socket.gethostbyname('private8')
h323c = socket.gethostbyn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modifyNamed():\n try:\n nconfile = open('/etc/named.conf',\"r\")\n nconf=nconfile.readlines()\n nconfile.close()\n if (nconf.__contains__('zone \"e164.com\" in {\\n') == False):\n # Back up the original file on local host\n if (os.path.isfile('/etc/named.con... | [
"0.60475475",
"0.5712828",
"0.5401735",
"0.5373833",
"0.5278509",
"0.5231044",
"0.51390064",
"0.49758998",
"0.49488488",
"0.4879243",
"0.48639935",
"0.47958717",
"0.47264674",
"0.46990132",
"0.4642579",
"0.46327728",
"0.46313915",
"0.45631486",
"0.45495316",
"0.45407936",
"0.... | 0.67915636 | 0 |
Modify named.conf file on host machine This function will add the following lines before line include "/etc/named.conf.include"; in the /etc/named.conf file zone "e164.com" in { type master; file "e164.zone"; }; | def modifyNamed():
try:
nconfile = open('/etc/named.conf',"r")
nconf=nconfile.readlines()
nconfile.close()
if (nconf.__contains__('zone "e164.com" in {\n') == False):
# Back up the original file on local host
if (os.path.isfile('/etc/named.conf.bkup') == False... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modifyNamed_mdns():\n try:\n nconfile = open('/etc/named.conf',\"r\")\n nconf=nconfile.readlines()\n nconfile.close()\n if (nconf.__contains__('zone \"abc.com\" in {\\n') == False):\n # Back up the original file on local host\n if (os.path.isfile('/etc/named... | [
"0.7575135",
"0.59046865",
"0.5903014",
"0.57330203",
"0.5728442",
"0.5668565",
"0.5576049",
"0.53493255",
"0.53486425",
"0.5292934",
"0.5266158",
"0.5208066",
"0.5167433",
"0.5164074",
"0.51579875",
"0.51520425",
"0.511993",
"0.5108533",
"0.50947",
"0.5090036",
"0.5053315",
... | 0.8367045 | 0 |
Modify named.conf file on host machine This function will add the following lines before line include "/etc/named.conf.include"; in the /etc/named.conf file zone "abc.com" in { type master; file "abc.zone"; }; | def modifyNamed_mdns():
try:
nconfile = open('/etc/named.conf',"r")
nconf=nconfile.readlines()
nconfile.close()
if (nconf.__contains__('zone "abc.com" in {\n') == False):
# Back up the original file on local host
if (os.path.isfile('/etc/named.conf.bkup') == F... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modifyNamed():\n try:\n nconfile = open('/etc/named.conf',\"r\")\n nconf=nconfile.readlines()\n nconfile.close()\n if (nconf.__contains__('zone \"e164.com\" in {\\n') == False):\n # Back up the original file on local host\n if (os.path.isfile('/etc/named.con... | [
"0.77619606",
"0.63265705",
"0.6181848",
"0.6033994",
"0.56227785",
"0.5607145",
"0.5587523",
"0.5564659",
"0.55436414",
"0.54945743",
"0.5427236",
"0.53943163",
"0.5346534",
"0.53115493",
"0.53009063",
"0.52916235",
"0.5268169",
"0.52624804",
"0.52428997",
"0.5229057",
"0.52... | 0.79277194 | 0 |
Modify "/etc/resolv.conf" file on host machine to configure the host machine as DNS server and e164.com as the domain On the MSX machine for as per MDN feature the resolve.conf should have the loopback ip as the nameserver | def modifyResolve_6_0(msw):
hostip = socket.gethostbyname('mygen')
name = 'nameserver ' + hostip+'\n'
name1 = 'search e164.com'+'\n'
newFileContents = [name,name1]
name_msw='nameserver 127.0.0.1\n'
try:
# Back up the original file on local host
if (os.path.isfile('/etc/resolv.co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ip_dns(resolv, nameservers, rdatatype, server, responsetype):\n for ns in nameservers:\n try:\n answer = resolv.query(ns, rdatatype)\n nameserver = answer[0].to_text()\n except Exception as e:\n print(e)\n continue\n resolve_public_ip(n... | [
"0.66663253",
"0.65197766",
"0.6454977",
"0.62498075",
"0.6179379",
"0.61113495",
"0.6102947",
"0.60348105",
"0.6027049",
"0.600597",
"0.59050775",
"0.5875488",
"0.5875488",
"0.58731216",
"0.5846704",
"0.5843882",
"0.5840513",
"0.5787853",
"0.57816136",
"0.5773999",
"0.575628... | 0.67207164 | 0 |
Modify "/etc/resolv.conf" file on host machine and on iserver to configure the host machine as DNS server and e164.com as the domain | def modifyResolve(msw):
hostip = socket.gethostbyname('mygen')
name = 'nameserver ' + hostip+'\n'
name1 = 'search e164.com'+'\n'
newFileContents = [name,name1]
try:
# Back up the original file on local host
if (os.path.isfile('/etc/resolv.conf.bkup') == False):
os.system... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modifyResolve_6_0(msw):\n hostip = socket.gethostbyname('mygen')\n name = 'nameserver ' + hostip+'\\n'\n name1 = 'search e164.com'+'\\n'\n newFileContents = [name,name1]\n name_msw='nameserver 127.0.0.1\\n'\n\n try:\n # Back up the original file on local host\n if (os.path.isfil... | [
"0.66512424",
"0.63267154",
"0.60071784",
"0.5803594",
"0.58030224",
"0.57954264",
"0.57864046",
"0.574424",
"0.57165027",
"0.56893486",
"0.5684942",
"0.5670558",
"0.56101656",
"0.5576847",
"0.5547269",
"0.5527023",
"0.54528004",
"0.5452761",
"0.5439995",
"0.543432",
"0.54310... | 0.6592895 | 1 |
Modify server.cfg to configure enum policy This function will add the following line before maxhunt policy enumdomain "e164.com" mswName Name of the MSW | def modifyIserver(mswName):
serverpath = "/usr/local/nextone/bin/server.cfg"
try:
bkupFile = '/tmp/server.cfg.%s.bkup' %mswName
# Copy the server.cfg file from MSW to the local host
if (os.path.isfile(bkupFile) == False):
os.system("scp -q root@" + mswName + "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_hyperflex_ucsm_config_policy(self):\n pass",
"def test_update_hyperflex_ucsm_config_policy(self):\n pass",
"def gotConfig(self, mode, buddylist, permit, deny):\n global screename\n\n # add someone to our deny list?\n self.add_deny([])\n\n # add ourself ... | [
"0.5155949",
"0.50969183",
"0.5087618",
"0.50697464",
"0.49049747",
"0.4853016",
"0.48166493",
"0.48111272",
"0.47832248",
"0.4758035",
"0.475463",
"0.47444928",
"0.47056305",
"0.47035003",
"0.4684181",
"0.46461055",
"0.4607421",
"0.4605782",
"0.4543735",
"0.4535835",
"0.4529... | 0.61365265 | 0 |
This function restarts named on the MSX machine | def remoteNamedRestart(msw):
try:
msw.assertCommand('/etc/init.d/named restart')
time.sleep(20)
namedStatus = msw.filter("pgrep -x named")
namedStatus = namedStatus.strip('|')
if not namedStatus:
print "Named not running on MSX"
log.error("Named not r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart(name):\n ret = \"restart False\"\n if stop(name) and start(name):\n ret = \"restart True\"\n return ret",
"def restart():\n stop()\n start()",
"def restart():\n log.info('restart')\n samuraix.restarting = True\n samuraix.app.stop()",
"def restart(self) -> None:",
... | [
"0.7395235",
"0.71174425",
"0.70991457",
"0.7040018",
"0.698922",
"0.69879663",
"0.6952697",
"0.6909831",
"0.6879459",
"0.68594456",
"0.68499994",
"0.6841836",
"0.68356466",
"0.68333083",
"0.67938286",
"0.6699267",
"0.66945845",
"0.66886044",
"0.66683984",
"0.6666926",
"0.663... | 0.76644677 | 0 |
Turns an array into a tuple. | def arr_to_tup(a):
return tuple(a.reshape(1, -1)[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def totuple(self, arr):\n\n\t\ttry:\n\t\t return tuple(self.totuple(i) for i in arr)\n\t\texcept TypeError:\n\t\t return arr",
"def tuple_from_sequence(*args):\n return tuple(args)",
"def from_val_array(val_array: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:\n values = np.zeros(val_array.shape)\n ... | [
"0.740222",
"0.7205401",
"0.7028237",
"0.68840843",
"0.6856533",
"0.66772735",
"0.6635185",
"0.6635185",
"0.6626691",
"0.6501668",
"0.6481281",
"0.6428507",
"0.6392776",
"0.6385211",
"0.6264097",
"0.6256837",
"0.6186616",
"0.6184272",
"0.61623657",
"0.61484647",
"0.61317927",... | 0.8194976 | 0 |
Finds the fit range for a single Lorentzian. | def find_single_fit_range(lorentz_params):
f0 = lorentz_params[1]
FWHM = lorentz_params[2]
return (f0 - 4 * FWHM, f0 - 2 * FWHM, f0 + 2 * FWHM, f0 + 4 * FWHM) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_full_fit_range(lorentz_params_array):\n (f_low_stop_list, f_low_list, f_high_list,\n f_high_stop_list) = find_all_fit_ranges(lorentz_params_array)\n f_low_stop = min(f_low_stop_list)\n f_low = min(f_low_list)\n f_high = max(f_high_list)\n f_high_stop = max(f_high_stop_list)\n return ... | [
"0.63660175",
"0.60472846",
"0.5928239",
"0.58382803",
"0.56657225",
"0.5663349",
"0.56379336",
"0.5610311",
"0.556652",
"0.55410683",
"0.55410683",
"0.55334866",
"0.55225533",
"0.55187094",
"0.54082763",
"0.5396919",
"0.53620934",
"0.5283245",
"0.52774984",
"0.525325",
"0.52... | 0.7493216 | 0 |
Finds a single fit range given an array defining a group of Lorentzians. | def find_full_fit_range(lorentz_params_array):
(f_low_stop_list, f_low_list, f_high_list,
f_high_stop_list) = find_all_fit_ranges(lorentz_params_array)
f_low_stop = min(f_low_stop_list)
f_low = min(f_low_list)
f_high = max(f_high_list)
f_high_stop = max(f_high_stop_list)
return (f_low_stop,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_fit_ranges(lorentz_params_array):\n f_low_stop_list = []\n f_low_list = []\n f_high_list = []\n f_high_stop_list = []\n for i in range(0, lorentz_params_array.shape[0]):\n fit_range = find_single_fit_range(lorentz_params_array[i])\n f_low_stop_list.append(fit_range[0])\n ... | [
"0.701321",
"0.6875592",
"0.6510563",
"0.5838932",
"0.5786284",
"0.5705617",
"0.5551643",
"0.5543331",
"0.5527045",
"0.54780036",
"0.54772216",
"0.54156286",
"0.54079676",
"0.5383618",
"0.5334958",
"0.5326469",
"0.5324271",
"0.5259432",
"0.5258009",
"0.5256806",
"0.5252409",
... | 0.74654967 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.