query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Method has to check if any of `modules` contains `callable` object with name `method_name` and return list of such objects | def methods_importer(
method_name: str, modules: List[Union[str, ModuleType]]
) -> List[Callable]:
result = []
for module in modules:
try:
if isinstance(module, ModuleType):
mod = module
elif isinstance(module, str):
mod = importlib.import_modu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_function_list_from_modlist(self):\n function_list = []\n function_name_list = []\n for module in self.module_list:\n for name, obj in inspect.getmembers(module, inspect.isfunction):\n if inspect.getmodule(obj) == module:\n function_list.appe... | [
"0.6745168",
"0.6412298",
"0.6275962",
"0.61267555",
"0.6027407",
"0.5975847",
"0.5927226",
"0.58631086",
"0.5823784",
"0.58145356",
"0.58093834",
"0.5742289",
"0.57135206",
"0.56821996",
"0.565382",
"0.5643577",
"0.56351846",
"0.5629629",
"0.56272805",
"0.5621702",
"0.554427... | 0.72288847 | 0 |
Method has to check if any of `modules` contains `callable` object with name `method_name` and return list of such objects | def search_import(
method: str, modules: List[Union[str, ModuleType]]
) -> Optional[object]:
for module in modules:
try:
if isinstance(module, ModuleType):
mod = module
elif isinstance(module, str):
# get module by string name
mod ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods_importer(\n method_name: str, modules: List[Union[str, ModuleType]]\n) -> List[Callable]:\n result = []\n for module in modules:\n try:\n if isinstance(module, ModuleType):\n mod = module\n elif isinstance(module, str):\n mod = importl... | [
"0.7228631",
"0.6745489",
"0.64123005",
"0.6276553",
"0.6126318",
"0.6027167",
"0.5976674",
"0.59269667",
"0.58626205",
"0.5824591",
"0.58095425",
"0.57424253",
"0.57137376",
"0.5682728",
"0.56539214",
"0.56437916",
"0.56349504",
"0.5628067",
"0.56268847",
"0.56217253",
"0.55... | 0.58134925 | 10 |
Start the survey, Increment in started survey field but if set the max_response_limit of survey then check the current user how many times start this survey. if current user max_response_limit is reach then this user can not start this survey(Raise Exception). | def action_next(self, cr, uid, ids, context=None):
survey_obj = self.pool.get('survey')
search_obj = self.pool.get('ir.ui.view')
if context is None: context = {}
this = self.browse(cr, uid, ids, context=context)[0]
survey_id = this.survey_id.id
context.update({'survey_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_survey(self, survey_id):\n self.logger.info(\"Adapter: Start survey : %s\" % survey_id)\n survey = self.service.getSurvey(survey_id)\n if survey is None:\n raise Exception(\"Survey Not found\")\n\n self._current_survey = survey\n\n # Pre format the payload\n ... | [
"0.63824034",
"0.59922814",
"0.5904111",
"0.5882263",
"0.5702201",
"0.56299543",
"0.54538417",
"0.52832985",
"0.5170122",
"0.51636046",
"0.49692428",
"0.48387736",
"0.4832471",
"0.48114467",
"0.47959805",
"0.47895217",
"0.47582608",
"0.4741108",
"0.47408897",
"0.47143224",
"0... | 0.521931 | 8 |
on change event of survey_id field, if note is available in selected survey then display this note in note fields. | def on_change_survey(self, cr, uid, ids, survey_id, context=None):
if not survey_id:
return {}
notes = self.pool.get('survey').read(cr, uid, survey_id, ['note'])['note']
return {'value': {'note': notes}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _on_clip_notes_changed(self):\n if liveobj_valid(self._sequencer_clip) and self._can_edit():\n time_start, time_length = self._get_clip_notes_time_range()\n self._clip_notes = self._get_notes_handler(self._sequencer_clip, time_start, self._pitches, time_length)\n else:\n ... | [
"0.54103535",
"0.5384617",
"0.5342676",
"0.531327",
"0.52878267",
"0.52672136",
"0.5042082",
"0.49997288",
"0.49391526",
"0.49161386",
"0.49144882",
"0.49064714",
"0.48971125",
"0.4877697",
"0.48331854",
"0.47828805",
"0.4776097",
"0.47532988",
"0.47387284",
"0.46859652",
"0.... | 0.7571935 | 0 |
Parses the given string in infix notation. | def parse_infix(input: str) -> Node:
parsed = ParsedString(input).tokenize()
ans = parse_e(parsed)
return ans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_infix(string):\n return postfix(infix_to_postfix(string))",
"def calculate_infix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate infix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n\t\ttry:\n\t\t\tfor e in elements:\n\t\t\t\tif not e.isdigit() an... | [
"0.7397211",
"0.6478074",
"0.6168341",
"0.61475885",
"0.6107287",
"0.60420674",
"0.60419923",
"0.6025316",
"0.60142255",
"0.5998835",
"0.5970454",
"0.5955664",
"0.5921972",
"0.5825912",
"0.5818483",
"0.576102",
"0.5759942",
"0.57156307",
"0.56969327",
"0.56241494",
"0.5590105... | 0.81860536 | 0 |
Parse command line arguments. | def parse_args(args: List[str]) -> Optional[argparse.Namespace]:
root = argparse.ArgumentParser(description=inspect.cleandoc('''
Small cross-platform Python app that can create and update PlatformIO projects from STM32CubeMX .ioc files. It
uses STM32CubeMX to generate a HAL-framework-based code and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_arguments(args):",
"def parse_command_line(self, argv):\n from optparse import OptionParser\n usage = \"usage: %prog [options]\"\n parser = OptionParser(usage)\n\n (options, args) = parser.parse_args(argv)",
"def parseArguments(self):\n iterator = iter(sys.argv[1:])... | [
"0.807208",
"0.74767",
"0.73985106",
"0.73932225",
"0.73173845",
"0.72599804",
"0.7232453",
"0.7222555",
"0.713585",
"0.7102058",
"0.71020466",
"0.7096281",
"0.7093058",
"0.70890576",
"0.7080071",
"0.70745754",
"0.70641047",
"0.70633066",
"0.70568484",
"0.7051162",
"0.7048470... | 0.0 | -1 |
Prepare a logging setup suitable for a CLI application. Keep in mind, though, that Python ``logging`` module, in general, mutates some internal global state, so be careful not to invoke this procedure twice in a single "session" to avoid any unwanted interfering and possible slowdowns. | def setup_logging(verbose: int = 1, dummy: bool = False) -> logging.Logger:
if dummy:
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
else:
logger = logging.getLogger('stm32pio')
logger.setLevel(logging.DEBUG if verbose == 2 else logging.INFO)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setupLogging():\n global enabled, dummyInstance\n from pyemma.util.config import conf_values\n args = conf_values['Logging']\n\n if args.enabled:\n if args.tofile and args.file:\n filename = args.file\n else:\n filename = None\n try:\n logging.b... | [
"0.7403228",
"0.7374052",
"0.73629564",
"0.7305064",
"0.72769016",
"0.72717994",
"0.72512513",
"0.70789415",
"0.7068529",
"0.70679766",
"0.705025",
"0.7044205",
"0.70441914",
"0.7042654",
"0.70334554",
"0.70323396",
"0.70148087",
"0.69615436",
"0.69575274",
"0.6947882",
"0.69... | 0.0 | -1 |
Entry point to the CLI edition of application. Since this is a highestorder wrapper, it can be used to | def main(sys_argv: List[str] = None, should_setup_logging: bool = True) -> int:
if sys_argv is None:
sys_argv = sys.argv[1:]
args = parse_args(sys_argv)
if args is not None and args.command == 'gui':
gui_args = [arg for arg in sys_argv if arg != 'gui']
import stm32pio.gui.app as g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n CLI_APP.run()",
"def main_cli():\n pass",
"def main():\n\tcli = Cli()\n\tcli.run()",
"def cli():\n pass",
"def cli():\r\n pass",
"def cli():\n config, auth, execute_now = read_command_line_arguments()\n main(config, auth, execute_now)",
"def cli():\n return",
"d... | [
"0.8524258",
"0.8464578",
"0.8092409",
"0.80703413",
"0.8055468",
"0.79824275",
"0.7956653",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"0.79459286",
"... | 0.0 | -1 |
Turn a formatted time back into a datetime. | def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT):
return datetime.datetime.strptime(timestr, fmt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_time(cls, time_str):\n if cls.date_ignore_pattern:\n time_str = re.sub(cls.date_ignore_pattern, '', time_str)\n return datetime.strptime(time_str, cls.date_format)",
"def convert_datetime(date, time):\n return datetime.datetime.strptime(date + \" \" + time, '%Y-%m-%d %H:%M... | [
"0.73640734",
"0.71984607",
"0.71712947",
"0.71472126",
"0.7088561",
"0.70292485",
"0.6919432",
"0.69148016",
"0.6899537",
"0.68993694",
"0.68652415",
"0.67638415",
"0.6718928",
"0.67043966",
"0.67007536",
"0.66780806",
"0.6667434",
"0.66511416",
"0.6628394",
"0.6583426",
"0.... | 0.65230465 | 22 |
Normalize time in arbitrary timezone to UTC naive object. | def normalize_time(timestamp):
offset = timestamp.utcoffset()
if offset is None:
return timestamp
return timestamp.replace(tzinfo=None) - offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_to_utc(date, timezone):\n local_tz = pytz.timezone(timezone)\n new_date = date.replace(tzinfo = local_tz)\n utc_tz = pytz.timezone('UTC')\n new_date = new_date.astimezone(utc_tz)\n return new_date",
"def normalize_time(timestamp):\r\n offset = timestamp.utcoffset()\r\n if offse... | [
"0.7121004",
"0.70751613",
"0.68719333",
"0.6638765",
"0.6492223",
"0.6492223",
"0.64689595",
"0.6383807",
"0.63305354",
"0.6259214",
"0.6201917",
"0.61943454",
"0.6189186",
"0.61438674",
"0.6071864",
"0.6052293",
"0.6044807",
"0.6037905",
"0.60008335",
"0.60007656",
"0.59903... | 0.7118167 | 1 |
Overridable version of utils.utcnow. | def utcnow():
if utcnow.override_time:
try:
return utcnow.override_time.pop(0)
except AttributeError:
return utcnow.override_time
return datetime.datetime.utcnow() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _utcnow(self):\n return datetime.datetime.utcnow()",
"def datetime_utcnow() -> datetime:\n return datetime.now(tz=pytz.timezone('UTC'))",
"def now():\n return datetime.datetime.utcnow()",
"def utcnow():\r\n if utcnow.override_time:\r\n try:\r\n return utcnow.override_tim... | [
"0.8539415",
"0.8027824",
"0.7782708",
"0.77643603",
"0.7735758",
"0.77322936",
"0.77046347",
"0.76547515",
"0.7576246",
"0.7486357",
"0.74273384",
"0.73486847",
"0.730371",
"0.72524977",
"0.7243433",
"0.7233085",
"0.71630627",
"0.71119446",
"0.70993876",
"0.7030391",
"0.6953... | 0.77223676 | 6 |
Return the difference between two timing objects. | def delta_seconds(before, after):
delta = after - before
return total_seconds(delta) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duration(self):\r\n return self.t2 - self.t1",
"def _subtract_times(self, a, b):\n td = a - b\n return td.days * 24 * 60 + td.seconds // 60",
"def time_diff(dt1, dt2):\n return abs(int((dt2 - dt1).total_seconds()))",
"def elapsed(t1, t2):\n # Use the timedelta's standard formatting... | [
"0.7564027",
"0.73061734",
"0.7275471",
"0.7021707",
"0.6927145",
"0.6924693",
"0.69082826",
"0.6850764",
"0.6742648",
"0.6573544",
"0.6448123",
"0.6372256",
"0.6367635",
"0.6340591",
"0.62391603",
"0.6200217",
"0.61754555",
"0.61506987",
"0.61456347",
"0.6129372",
"0.6069111... | 0.0 | -1 |
Return the total seconds of datetime.timedelta object. | def total_seconds(delta):
try:
return delta.total_seconds()
except AttributeError:
return ((delta.days * 24 * 3600) + delta.seconds +
float(delta.microseconds) / (10 ** 6)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_seconds(td):\n return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6",
"def total_seconds(self):\n return (\n (self.days * 86400 + self.seconds) * 10**6 + self.microseconds\n ) / 10**6",
"def get_total_seconds(td):\n return (td.microseconds + (td... | [
"0.7660376",
"0.76501614",
"0.7579259",
"0.74830866",
"0.7447662",
"0.7263316",
"0.72183",
"0.71539515",
"0.70629454",
"0.70629454",
"0.7046123",
"0.70381135",
"0.6981377",
"0.6980456",
"0.6966398",
"0.6944039",
"0.68772465",
"0.682706",
"0.6801305",
"0.67495024",
"0.674575",... | 0.75388104 | 3 |
Determines if time is going to happen in the next window seconds. | def is_soon(dt, window):
soon = (utcnow() + datetime.timedelta(seconds=window))
return normalize_time(dt) <= soon | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_soon(dt, window):\r\n soon = (utcnow() + datetime.timedelta(seconds=window))\r\n return normalize_time(dt) <= soon",
"def is_time(self) -> bool:\n return self.times > 1",
"def check_timer(self, wanted_time):\n if time.time() - self.start_time >= wanted_time:\n return True\... | [
"0.6944493",
"0.6809295",
"0.6770309",
"0.66791123",
"0.6604746",
"0.6575241",
"0.65720016",
"0.6527601",
"0.64802086",
"0.6467284",
"0.6399745",
"0.63648057",
"0.6287537",
"0.62048924",
"0.6202289",
"0.61881906",
"0.6164102",
"0.6113024",
"0.6048458",
"0.60255253",
"0.599680... | 0.6890391 | 1 |
Connect to Google Docs spreadsheet and return the first worksheet. | def login_open_sheet(oauth_key_file, spreadsheet):
try:
json_key = json.load(open(oauth_key_file))
credentials = SignedJwtAssertionCredentials(json_key['client_email'],
json_key['private_key'],
['https://spreadsheets.google.com/feeds'])
gc = gspread.authorize(credentials)
worksheet = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def google_sheets_connector():\n print(\"Connecting to Google Sheets\")\n scope = ['https://www.googleapis.com/auth/drive']\n credentials = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)\n client = gspread.authorize(credentials)\n sheet = client.open('backend').sheet1\n retur... | [
"0.76090544",
"0.75515413",
"0.70657873",
"0.6737377",
"0.67137086",
"0.66439945",
"0.65799826",
"0.65298957",
"0.65184474",
"0.6441897",
"0.64368963",
"0.6434696",
"0.6430115",
"0.64215475",
"0.6263627",
"0.6231455",
"0.6227264",
"0.6202866",
"0.6169387",
"0.6113986",
"0.610... | 0.62673867 | 14 |
Train and Evaluate a estimator (defined as input parameter) on the given labeled data using accuracy. | def train_and_evaluate_classifier(X, yt, estimator, grid):
# Cross validation
cv = ShuffleSplit(n_splits=5, test_size=0.2, random_state=0)
classifier = GridSearchCV(estimator=estimator, cv=cv, param_grid=grid, error_score=0.0, n_jobs = -1, verbose = 5, scoring='f1')
# Train the model over and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self):\n y_list = []\n y_hat_list = []\n for ex_dict in ut.EXAMPLES_LIST:\n y_list.append(ex_dict[1])\n y_hat_list.append(self.predict(ex_dict[0]))\n\n acc = ut.compute_accuracy(y_hat_list, y_list)\n return acc",
"def evaluate(model, eval_data, n... | [
"0.7146936",
"0.6996435",
"0.6894942",
"0.6876865",
"0.6867176",
"0.6788031",
"0.6736972",
"0.67225075",
"0.6721627",
"0.66882557",
"0.6671993",
"0.66699123",
"0.6663194",
"0.66536176",
"0.665214",
"0.66422933",
"0.66421616",
"0.66099846",
"0.6607928",
"0.660663",
"0.6601722"... | 0.69482434 | 2 |
sent message to line when BTC price change | def line_sent(price):
now = datetime.datetime.now()
LINE_ACCESS_TOKEN = " " # Line Token
url = "https://notify-api.line.me/api/notify"
print("[%02i:%02i:%02i] Price Change : Send Message" % (now.hour, now.minute, now.second))
message = "[%02i:%02i:%02i] Now BTC Price : %s" % (now.hour, now.minute, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def m_ts_OrderUpdated(self, sender, e):\r\n print(\"Order was updated with price of {0}.\".format(e.NewOrder.LimitPrice))",
"def price(temp):\n now = datetime.datetime.now()\n r = requests.get(\"https://bitcoin.co.th/\")\n soup = BeautifulSoup(r.content, \"html.parser\")\n data = soup.find_all... | [
"0.6816411",
"0.6801577",
"0.65582",
"0.6458763",
"0.640456",
"0.63957596",
"0.63561404",
"0.6308241",
"0.6267959",
"0.60562086",
"0.6038898",
"0.6030322",
"0.6026573",
"0.6005116",
"0.5988077",
"0.5987116",
"0.59702915",
"0.5927759",
"0.5876349",
"0.5855136",
"0.5835843",
... | 0.72373915 | 0 |
pull BTC price from bitcoin.co.th and display auto refresh 30 second | def price(temp):
now = datetime.datetime.now()
r = requests.get("https://bitcoin.co.th/")
soup = BeautifulSoup(r.content, "html.parser")
data = soup.find_all("div", {"class": "price"})
print("[%02i:%02i:%02i] Now BTC Price : " % (now.hour, now.minute, now.second), end="")
for i in range(len(data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_price():\n\n url = \"https://www.bitstamp.net/api/ticker/\"\n\n response = json.load(urllib2.urlopen(url))\n\n return {\"buy\": response['ask'], \"sell\": response['bid']}",
"def one_second_update(self):\n\n val[\"timeRunning\"] += 1\n total_btc_value = self.calc_total_btc()\n\n ... | [
"0.70592564",
"0.693128",
"0.68808323",
"0.6876423",
"0.6630507",
"0.65967596",
"0.65728116",
"0.65671337",
"0.6530796",
"0.64484495",
"0.64475566",
"0.64403254",
"0.64142734",
"0.63919145",
"0.63195646",
"0.62791777",
"0.62609833",
"0.6260832",
"0.62537676",
"0.62360334",
"0... | 0.68963987 | 2 |
Check if vocab file doesn't exist, create from corpus file | def check_vocab(vocab_file, out_dir, check_special_token=True, sos=None,
eos=None, unk=None):
if tf.gfile.Exists(vocab_file):
utils.print_out("# Vocab file %s exist"%(vocab_file))
vocab, vocab_size = load_vocab(vocab_file)
if check_special_token:
if not u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_vocab(targets, fname):\n\n\tpath = os.path.join(\"data\", fname)\n\tif not os.path.isfile(path):\n\t\tworddict, wordcount = vocab.build_dictionary(targets)\n\t\tvocab.save_dictionary(worddict, wordcount, path)\n\n\treturn path",
"def create_vocab(data_files, vocab_fname):\n chars = set()\n for data... | [
"0.6977475",
"0.6754829",
"0.67372584",
"0.6708775",
"0.66447884",
"0.65663725",
"0.6565397",
"0.65651417",
"0.64246404",
"0.63713026",
"0.6286252",
"0.62843806",
"0.62478554",
"0.6221544",
"0.6218052",
"0.62025714",
"0.6173772",
"0.6173772",
"0.6156694",
"0.61282647",
"0.610... | 0.61879635 | 16 |
Creates vocab tables for src_vocab_file and tgt_vocab_file | def create_vocab_tables(src_vocab_file, tgt_vocab_file, share_vocab):
src_vocab_table = lookup_ops.index_table_from_file(
src_vocab_file, default_value=UNK_ID)
if share_vocab:
tgt_vocab_table = src_vocab_table
else:
tgt_vocab_table = lookup_ops.index_table_from_file(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vocab_tables(source_file, tags_file):\n pass",
"def create_vocab_tables(vocab_file):\n vocab_table = lookup_ops.index_table_from_file(\n vocab_file, default_value=0)\n return vocab_table",
"def create_vocab(data_files, vocab_fname):\n chars = set()\n for data_fname in data_files:\n w... | [
"0.7955603",
"0.7308529",
"0.7184133",
"0.68010455",
"0.6748521",
"0.6647768",
"0.64361453",
"0.64343816",
"0.642107",
"0.637317",
"0.63398",
"0.62193406",
"0.60044277",
"0.59781426",
"0.58856463",
"0.5873985",
"0.5845134",
"0.58191055",
"0.5818881",
"0.58034873",
"0.5802334"... | 0.8489429 | 0 |
Load embed text into python dictionary | def load_embed_text(embed_file):
emb_dict = dict()
emb_size = None
with codecs.getreader("utf-8")(tf.gfile.GFile(embed_file, "rb")) as f:
for line in f:
tokens = line.strip().split(" ")
word = tokens[0]
vec = list(map(float, tokens[1:]))
emb_dict[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_embedding_file(self):\n if self.language == 'en':\n embed_file_dir = self.embedding_path\n wv = KeyedVectors.load_word2vec_format(embed_file_dir, binary=True)\n self.pretrained_embedding = {}\n for word in wv.vocab.keys():\n normalized_word... | [
"0.6251451",
"0.59665245",
"0.5931526",
"0.5864249",
"0.5857385",
"0.585637",
"0.5768584",
"0.56255275",
"0.55851597",
"0.5561361",
"0.55584276",
"0.55403835",
"0.5534576",
"0.551691",
"0.5507314",
"0.5474913",
"0.5453954",
"0.5416933",
"0.5389678",
"0.5383825",
"0.53736913",... | 0.7389193 | 0 |
Add arguments and `func` to `p`. | def parseargs(p):
p.set_defaults(func=func)
p.description = "Print machine architecture."
return p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pfunc(self, func):\n if (self.operator in _cst.list_FIELD_OPERATORS) or (len(self.func_arguments) == 0) :\n from .utils import function\n self.pfunc = function(func, space=self.space)\n else:\n raise(\"Not used anymore. Dead code\")",
"def append_partial(sel... | [
"0.637058",
"0.6234944",
"0.6016136",
"0.58248454",
"0.5707327",
"0.5671719",
"0.55735564",
"0.55435956",
"0.55145085",
"0.5508382",
"0.55024254",
"0.54566646",
"0.5382222",
"0.5367993",
"0.5364236",
"0.53506577",
"0.5320255",
"0.5305345",
"0.52700186",
"0.5244459",
"0.523765... | 0.0 | -1 |
Test Jacobi symbol function. Test data by clux .com Copyright (c) 2015 Eirik Albrigtsen. | def test_jacobi_symbol():
assert jacobi_symbol.jacobi_symbol(-1, 5) == 1
assert jacobi_symbol.jacobi_symbol(-1, 13) == 1
assert jacobi_symbol.jacobi_symbol(-1, 3) == -1
assert jacobi_symbol.jacobi_symbol(-1, 7) == -1
assert jacobi_symbol.jacobi_symbol(2, 3) == -1
assert jacobi_symbol.jacob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_jacobian(self):\n\n gT1 = Pose2(1, 2, np.pi/2)\n gT2 = Pose2(-1, 4, np.pi)\n\n expected = Pose2(2, 2, np.pi/2)\n\n def error_func(this: CustomFactor, v: gtsam.Values, H: List[np.ndarray]):\n # print(f\"{this = },\\n{v = },\\n{len(H) = }\")\n\n key0 = this.... | [
"0.6263861",
"0.60016906",
"0.5993425",
"0.59792936",
"0.59679013",
"0.5947442",
"0.58563167",
"0.5767559",
"0.57407844",
"0.56984955",
"0.5689885",
"0.56845725",
"0.5673471",
"0.56505066",
"0.56440735",
"0.5604703",
"0.5593576",
"0.55914634",
"0.5581195",
"0.557651",
"0.5572... | 0.82948303 | 0 |
set up some polynomials | def setUp(self):
self.f1 = uniutil.polynomial(enumerate([3, 6, 81, 1]), Z)
self.f2 = uniutil.polynomial(enumerate([1, 81, 6, 3]), Z)
self.f3 = uniutil.polynomial(enumerate([37, 6, 18, 1]), Z)
self.f4 = uniutil.polynomial(enumerate([91, 7, 14, 1]), Z)
# f5 = (x - 6)(x - 5)...x(x +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test():\n assert str(Polynomial(0, 1, 0, -1, 4, -2, 0, 1, 3, 0)) == \"3x^8 + x^7 - 2x^5 + 4x^4 - x^3 + x\"\n assert str(Polynomial([-5, 1, 0, -1, 4, -2, 0, 1, 3, 0])) == \"3x^8 + x^7 - 2x^5 + 4x^4 - x^3 + x - 5\"\n assert str(Polynomial(x7=1, x4=4, x8=3, x9=0, x0=0, x5=-2, x3=-1, x1=1)) == \"3x^8 + x^... | [
"0.678141",
"0.67440933",
"0.6514138",
"0.65139806",
"0.64966166",
"0.6434011",
"0.62719",
"0.6235043",
"0.62243843",
"0.62179774",
"0.6173415",
"0.61612695",
"0.60989493",
"0.6082673",
"0.60799944",
"0.6079461",
"0.6062244",
"0.60604817",
"0.6048867",
"0.60426575",
"0.603064... | 0.70385593 | 0 |
test by Dumas's method | def testDumas(self):
self.assertTrue(irreducible.dumas(self.f1, 3))
self.assertTrue(irreducible.dumas(self.f2, 3))
self.assertEqual(None, irreducible.dumas(self.f2, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def test():",
"def test():",
"def test(self):\n pass",
"def test_T01():",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def tes... | [
"0.7360619",
"0.7360619",
"0.7360619",
"0.7360619",
"0.7360619",
"0.710369",
"0.710369",
"0.7014247",
"0.7008825",
"0.69486576",
"0.69486576",
"0.69486576",
"0.6938057",
"0.6914093",
"0.6914093",
"0.6908473",
"0.6908473",
"0.68305767",
"0.6827298",
"0.6766351",
"0.6744857",
... | 0.61407936 | 88 |
test by Perron's method | def testPerron(self):
self.assertTrue(irreducible.perron(self.f1))
self.assertEqual(None, irreducible.perron(self.f2), "non-monic") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def test():",
"def test():",
"def test(self):\n pass",
"def test_T01():",
"def che... | [
"0.73669046",
"0.73669046",
"0.73669046",
"0.73669046",
"0.73669046",
"0.71796256",
"0.71796256",
"0.71796256",
"0.7061055",
"0.7061055",
"0.70045656",
"0.68833125",
"0.687679",
"0.68614805",
"0.6823308",
"0.67640966",
"0.67640966",
"0.67107856",
"0.67107856",
"0.6668276",
"0... | 0.6174891 | 71 |
test by Osada's method | def testOsada(self):
self.assertEqual(None, irreducible.osada(self.f1), "constant is small")
self.assertEqual(None, irreducible.osada(self.f2), "non-monic")
self.assertTrue(irreducible.osada(self.f3))
self.assertEqual(None, irreducible.osada(self.f4), "composite constant") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def test():",
"def test():",
"def test(self):",
"def tes... | [
"0.7649156",
"0.7649156",
"0.7649156",
"0.7649156",
"0.7649156",
"0.7348239",
"0.7283287",
"0.7283287",
"0.7283287",
"0.721375",
"0.721375",
"0.72019917",
"0.72019917",
"0.7032876",
"0.70248324",
"0.7023114",
"0.7022478",
"0.69966865",
"0.6954297",
"0.6939279",
"0.6934356",
... | 0.0 | -1 |
test by Osada's method | def testPolya(self):
self.assertTrue(irreducible.polya(self.f5))
self.assertEqual(False, irreducible.polya(self.f5 + 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def _test(self):",
"def test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def _test(self):\n pass",
"def test():",
"def test():",
"def test(self):",
"def tes... | [
"0.7649156",
"0.7649156",
"0.7649156",
"0.7649156",
"0.7649156",
"0.7348239",
"0.7283287",
"0.7283287",
"0.7283287",
"0.721375",
"0.721375",
"0.72019917",
"0.72019917",
"0.7032876",
"0.70248324",
"0.7023114",
"0.7022478",
"0.69966865",
"0.6954297",
"0.6939279",
"0.6934356",
... | 0.0 | -1 |
Return the document as a string. | def __call__( self, *args, **kwargs ):
return self.__str__( ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_string(self):\n return json.dumps(self.document, indent=4)",
"def raw_doc(self):\n try:\n return str(self.definition.docstr)\n except AttributeError:\n return ''",
"def to_string(self) -> str:\n return f\"<Document, #sentences: {len(self.sentences)}>\""... | [
"0.7829644",
"0.7579167",
"0.7380491",
"0.73097616",
"0.69618034",
"0.69533587",
"0.6720976",
"0.6694182",
"0.66199726",
"0.65835214",
"0.6501972",
"0.64754546",
"0.64682484",
"0.64594126",
"0.64469343",
"0.6424059",
"0.6416956",
"0.64057046",
"0.63234025",
"0.63051337",
"0.6... | 0.0 | -1 |
This method return if the path of a boundary end up in a segmented part, take into account that a segmented part of a picture is set to 1 | def has_been_segmented(input, loc, clockwise):
height = np.shape(input)[0]
width = np.shape(input)[1]
if clockwise:
if loc[0] == 0 and loc[2] + 1 < width:
if input[int(loc[1]), int(loc[2]) + 1] < 0:
return True
elif loc[0] == 1 and loc[2] - 1 >= 0:
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_fix_intersection(self, segment):\n\n points = segment.points\n points = [points[1], points[2], points[3], points[2], points[1], points[0]]\n path = create_path(points)\n layer = GSLayer()\n layer.paths.append(path)\n\n if layer.paths[0].insertNodeWithPathTime_(2.5)... | [
"0.6368944",
"0.63270986",
"0.62400246",
"0.62330496",
"0.61352235",
"0.6133332",
"0.6041779",
"0.6016519",
"0.6001525",
"0.592066",
"0.5908251",
"0.5867232",
"0.5827352",
"0.5784938",
"0.5769791",
"0.57347274",
"0.5710265",
"0.5690472",
"0.56710804",
"0.56612056",
"0.5648762... | 0.5582 | 31 |
return the size and line number of all the files end with file_format in file_path | def get_files_size_and_line_number(file_path, file_format):
logging.info("[get_file_size_and_line_number] file_path: %s, file_format: %s", file_path, file_format)
size = 0
lines = 0
for root, dirs, files in os.walk(file_path):
for file in files:
for one_format in file_format:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(path):",
"def file_stat(self, file_path):",
"def get_file_size(file_path):\n with open(file_path, 'rb') as infile:\n infile.seek(0, 2)\n return infile.tell()",
"def fileLineCount(fPath):\n\twith open(fPath) as f:\n\t\tfor i, li in enumerate(f):\n\t\t\tpass\n\treturn (i + 1)",
"def read_file... | [
"0.63892037",
"0.6363271",
"0.60669774",
"0.60568386",
"0.60216236",
"0.59628934",
"0.5924917",
"0.5862097",
"0.5836959",
"0.581429",
"0.5798193",
"0.5783594",
"0.57677364",
"0.5739231",
"0.57310176",
"0.572738",
"0.57239795",
"0.57239795",
"0.57225364",
"0.5717134",
"0.57096... | 0.8117311 | 0 |
Get number of lines of the file | def get_file_lines(filename):
if not os.path.isfile(filename):
logging.error("[get_file_lines] %s not found", filename)
return -1
if not os.access(filename, os.R_OK):
logging.error("[get_file_lines] %s cannot be read", filename)
return -1
i = -1
with open(filename) as f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_of_lines():\n number_of_lines = len(open(FILE_NAME).readlines())\n return number_of_lines",
"def number_of_lines(filename=\"\"):\n c = 0\n with open(filename) as f:\n for r in f:\n c += 1\n return(c)",
"def line_count(fname):\n return int(call(['wc', '-l', fname])... | [
"0.86255336",
"0.8530903",
"0.8486514",
"0.8486119",
"0.84292805",
"0.84233004",
"0.84030133",
"0.83998626",
"0.83932936",
"0.8383373",
"0.8358024",
"0.8348638",
"0.8348638",
"0.8336576",
"0.8333743",
"0.8329848",
"0.8317158",
"0.8295557",
"0.8279558",
"0.8258976",
"0.8251855... | 0.7358279 | 45 |
return the checksum for the given file | def checksum_of(filepath):
bfsz = 10240000 # 10 MB buffer
sum = hashlib.sha256()
with open(filepath) as fd:
while True:
buf = fd.read(bfsz)
if not buf: break
sum.update(buf)
return sum.hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksum(file):\n\n cksm = hashlib.sha256()\n f = open(file, 'rb')\n try:\n cksm.update(f.read())\n finally:\n f.close()\n return cksm.hexdigest()",
"def get_file_checksum(file_path):\n with open(file_path) as f:\n content = f.read()\n return md5(content.encode()).he... | [
"0.808862",
"0.80663633",
"0.79676646",
"0.7905982",
"0.78999996",
"0.7685831",
"0.75917816",
"0.75259084",
"0.74437404",
"0.7386972",
"0.73729914",
"0.7323392",
"0.7219426",
"0.71757",
"0.71747947",
"0.7154105",
"0.70644516",
"0.69933987",
"0.69731617",
"0.6952713",
"0.69175... | 0.76318544 | 6 |
get hit num, HR the k is determined by the size of pred | def get_hit_num(pred, y_truth):
hit_num = 0
for i in range(len(y_truth)):
for value in y_truth[i]:
hit_num += np.sum(pred[i] == value)
return hit_num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall(gt, pred, k):\n k = min(len(pred), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / len(gt)",
"def ap(gt, pred, k):\n if len(pred) > k:\n pred = pred[:k]\n\n score = 0.0\n num_hits = 0.0\n\n for i, p in enumerate(pred):\n if p in... | [
"0.70658284",
"0.6934945",
"0.67937434",
"0.6567325",
"0.6456124",
"0.6448051",
"0.6417109",
"0.6206844",
"0.61633265",
"0.61516654",
"0.60036904",
"0.59555906",
"0.5910098",
"0.58566326",
"0.58453375",
"0.58057845",
"0.5799665",
"0.5799421",
"0.576527",
"0.5762945",
"0.57606... | 0.67658854 | 3 |
get MRR value, MRR the k is determined by the size of pred | def get_rr(pred, y_truth):
rr = 0.
for i in range(len(y_truth)):
for value in y_truth[i]:
hit_indexes = np.where(pred[i] == value)[0]
for hit_index in hit_indexes:
rr += 1 / (hit_index + 1)
return rr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metric_mrr_at_k(pred: list, echt: list, k: int):\n echt_keys = [key for key, _ in echt[:k]]\n pred_keys = [key for key, _ in pred]\n return sum([1.0 / (pred_keys.index(key) + 1.0) for key in echt_keys if key in pred_keys]) / float(k)",
"def mrr_at(prediction, target, k=10):\n rank_target = (predi... | [
"0.69672316",
"0.6372463",
"0.60298693",
"0.5954082",
"0.576194",
"0.5751144",
"0.57502794",
"0.5746234",
"0.5731656",
"0.5685121",
"0.5675345",
"0.56536746",
"0.5646447",
"0.5644542",
"0.56380415",
"0.56108654",
"0.55345213",
"0.55289006",
"0.5492717",
"0.54816496",
"0.54705... | 0.5518691 | 18 |
get DCG value, the k is determined by the size of pred | def get_dcg(pred, y_truth):
y_pred_score = np.zeros_like(pred)
for i in range(len(y_truth)):
for j, y_pred in enumerate(pred[i]):
if y_pred == y_truth[i][0]:
y_pred_score[i][j] = 1
gain = 2 ** y_pred_score - 1 # DCG Numerator
discounts = np.tile(np.log2(np.arange(pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndcg(self, gt, pred, k):\n k = min(k, len(pred))\n idcg = self.idcg(k)\n dcg_k = sum([int(pred[i] in gt) / math.log(i + 2, 2) for i in range(k)])\n return dcg_k / idcg",
"def dcg_at_k(cls, r, k):\n assert k >= 1\n r = np.asfarray(r)[:k]\n if r.size:\n ... | [
"0.7696004",
"0.69793993",
"0.6977624",
"0.6374677",
"0.6331683",
"0.6331683",
"0.6266526",
"0.6234941",
"0.62250835",
"0.62250835",
"0.62250835",
"0.6221169",
"0.6187577",
"0.61738646",
"0.61722773",
"0.61650544",
"0.61531126",
"0.61244565",
"0.61213666",
"0.610128",
"0.6099... | 0.6230466 | 8 |
get NDCG value,NDCG the k is determined by the size of pred | def get_ndcg(pred, y_truth):
dcg = get_dcg(pred, y_truth)
idcg = get_dcg(np.concatenate((y_truth, np.zeros_like(pred)[:, :-1] - 1), axis=1), y_truth)
ndcg = np.sum(dcg / idcg)
return ndcg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ndcg(self, gt, pred, k):\n k = min(k, len(pred))\n idcg = self.idcg(k)\n dcg_k = sum([int(pred[i] in gt) / math.log(i + 2, 2) for i in range(k)])\n return dcg_k / idcg",
"def nDCG_at(prediction, target, k=10):\n pass",
"def ndcg(preds, labels):\n \n #find positions wher... | [
"0.79625756",
"0.75401056",
"0.65493155",
"0.6547638",
"0.65072984",
"0.65072984",
"0.6429389",
"0.63246894",
"0.6285959",
"0.62397695",
"0.619581",
"0.612648",
"0.61192584",
"0.60718626",
"0.60313153",
"0.6029979",
"0.60148996",
"0.59617794",
"0.59408885",
"0.5915773",
"0.59... | 0.6809565 | 2 |
Converts a database entity to a formal object. | def _from_db_object(user, db_user):
foreign_key = ['project']
for field in user.fields:
if field not in foreign_key:
user[field] = db_user[field]
elif field == 'project' and db_user.project:
user['project'] = db_user.project.name
user.obj_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_entity(cls, model_obj: \"SqlalchemyModel\"):\n item_dict = {}\n for field_name in attributes(cls.meta_.entity_cls):\n item_dict[field_name] = getattr(model_obj, field_name, None)\n return cls.meta_.entity_cls(item_dict)",
"def from_entity(cls, e):\n kwargs = {name: e... | [
"0.6669113",
"0.624897",
"0.6070841",
"0.6052395",
"0.5927984",
"0.58920175",
"0.5879707",
"0.5838379",
"0.58042955",
"0.57850313",
"0.5752309",
"0.5725446",
"0.56776404",
"0.56579125",
"0.5648718",
"0.5647884",
"0.56169814",
"0.56110656",
"0.55401975",
"0.54984033",
"0.54784... | 0.5234766 | 32 |
Converts a list of database entities to a list of formal objects. | def _from_db_object_list(db_objects, cls, context):
return [User._from_db_object(cls(context), obj)
for obj in db_objects] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_field_list(entities: List[Entity], features: List[Feature]) -> List[Field]:\n fields: List[Field] = []\n\n for entity in entities:\n if isinstance(entity, Field):\n fields.append(entity)\n\n for feature in features:\n if isinstance(feature, Field):\n fields.... | [
"0.6553517",
"0.6404906",
"0.609518",
"0.5947816",
"0.5911902",
"0.5895528",
"0.57278997",
"0.5614274",
"0.55199146",
"0.5477894",
"0.54750085",
"0.54574007",
"0.5452225",
"0.5449309",
"0.5444442",
"0.54305166",
"0.5390607",
"0.5357768",
"0.534359",
"0.5310096",
"0.5309579",
... | 0.6059527 | 3 |
Return a list of User objects. | def list(cls, context, filters=None, limit=3000, marker=1,
sort_key='id', sort_dir='asc'):
#import pdb; pdb.set_trace()
db_users = cls.dbapi.get_user_list(
context, limit=limit, marker=marker, sort_key=sort_key,
sort_dir=sort_dir, filters=filters)
total = db... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_list():\n\tudb = UserPageDB()\n\ttry:\n\t\tusers = udb.user_list()\n\t\treturn UserList([_transform_user(u) for u in users])\n\tfinally:\n\t\tudb.close()",
"def get_users():\n coll = data_access.get_user_collection()\n users = [User(**u) for u in coll.find()]\n return users",
"def get_use... | [
"0.8223808",
"0.81874853",
"0.81304026",
"0.80897486",
"0.80895907",
"0.7997258",
"0.79471356",
"0.79443645",
"0.79324484",
"0.7883471",
"0.7877116",
"0.7825088",
"0.7817362",
"0.77952695",
"0.77803516",
"0.77659327",
"0.7758774",
"0.77310413",
"0.771211",
"0.7697829",
"0.767... | 0.7617105 | 25 |
Save updates to this user. Updates will be made column by column based on the result of self.what_changed(). | def save(self, context=None):
updates = self.obj_get_changes()
self.dbapi.update_user(context, self.id, updates)
self.obj_reset_changes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_to_users(self):\n Data.add_data(self.user_data())",
"def update(self):\n db.session.commit()",
"def update(self):\n db.session.commit()",
"def save(self):\n self.__db.commit()",
"def save(self):\n self.db.commit()",
"def save(self):\n db.session.commit()... | [
"0.6838319",
"0.6649925",
"0.6649925",
"0.66234463",
"0.65625477",
"0.64974636",
"0.6454244",
"0.63921773",
"0.63921773",
"0.63760066",
"0.63760066",
"0.63760066",
"0.63760066",
"0.63760066",
"0.63760066",
"0.63760066",
"0.63760066",
"0.6369375",
"0.6336045",
"0.63228583",
"0... | 0.6958138 | 0 |
Add the Wiser Smart System Switch entities | async def async_setup_entry(hass, config_entry, async_add_entities):
data = hass.data[DOMAIN]
# Add appliances (if any)
if data.wiserSmart.getWiserAppliances() is not None:
wiserSmart_appliances = [
WiserSmartAppliance(data, appliance.get("applianceName"), "WiserSmart - Plug - {}".forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_entity(device: SmartPlug, async_add_entities):\n # Attempt to get the sysinfo. If it fails, it will raise an\n # exception that is caught by async_add_entities_retry which\n # will try again later.\n device.get_sysinfo()\n\n async_add_entities([SmartPlugSwitch(device)], update_before_add=Tru... | [
"0.67680925",
"0.6515442",
"0.63500303",
"0.61388206",
"0.6016288",
"0.58496785",
"0.5820558",
"0.5798155",
"0.5768528",
"0.57529867",
"0.5746875",
"0.5705419",
"0.56905735",
"0.567721",
"0.56609863",
"0.5627506",
"0.5608422",
"0.5595277",
"0.55840945",
"0.5580214",
"0.554294... | 0.54446214 | 39 |
Return device specific attributes. | def device_info(self):
model = self.data.wiserSmart.getWiserDeviceInfo(self.appliance_id).get("modelId")
return {
"name": self.appliance_name,
"identifiers": {(DOMAIN, self.unique_id)},
"manufacturer": MANUFACTURER,
"model": model,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes(self, device_id=0):\n\t\t\treturn cuda.Device(device_id).get_attributes()",
"def device_info(self) -> Optional[Dict[str, Any]]:\n return {ATTR_NAME: self.name, \"identifiers\": {(DOMAIN, self._device.device_id)}}",
"def device_state_attributes(self):\n attrs = {\n ATTR_A... | [
"0.80724686",
"0.7450437",
"0.742771",
"0.7409806",
"0.7293218",
"0.72523683",
"0.72523683",
"0.719905",
"0.7175151",
"0.7155777",
"0.7155777",
"0.71476424",
"0.7145971",
"0.71375567",
"0.7095317",
"0.7051197",
"0.703671",
"0.7035435",
"0.7017325",
"0.7013673",
"0.70050514",
... | 0.66067904 | 77 |
Return the name of the appliance | def name(self):
return self.appliance_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storage_appliance_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"storage_appliance_name\")",
"def getApplicationName(self) -> unicode:\n ...",
"def get_name(self, name):\n return self.apps[name]['name']",
"def name(self):\n return self.application_tree[... | [
"0.728623",
"0.670762",
"0.6638334",
"0.66285485",
"0.6624678",
"0.6546256",
"0.6457588",
"0.6457588",
"0.64034915",
"0.6325202",
"0.62845224",
"0.6272063",
"0.62540203",
"0.62129927",
"0.6174521",
"0.61575866",
"0.6152049",
"0.610121",
"0.6100212",
"0.6099339",
"0.60911846",... | 0.90326834 | 0 |
Return the polling state. | def should_poll(self):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\r\n alarm = self._alarm()\r\n return alarm.state",
"def _get_state(self):\n # gst's get_state function returns a 3-tuple; we just want the\n # status flag in position 1.\n return self.pipeline.get_state(Gst.CLOCK_TIME_NONE)[1]",
"def state(self):\n ... | [
"0.70800793",
"0.69442177",
"0.6918493",
"0.6845751",
"0.68327427",
"0.67729336",
"0.67729336",
"0.6728276",
"0.6668334",
"0.6641413",
"0.6641413",
"0.6641413",
"0.6641413",
"0.6641413",
"0.66395515",
"0.66395515",
"0.66395515",
"0.66395515",
"0.66395515",
"0.66395515",
"0.66... | 0.0 | -1 |
Return true if device is on. | def is_on(self):
self._is_on = self.data.wiserSmart.getWiserApplianceInfo(self.appliance_id).get("state")
_LOGGER.debug(
"Appliance {} is currently {}".format(self.appliance_id, self._is_on)
)
return self._is_on | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on(self) -> bool:\n return self._device.is_on",
"def is_on(self):\n return self._device.is_on",
"def is_on(self):\n return self._device.is_on",
"def is_on(self):\n return self._device.is_on",
"def is_on(self):\n return self._device.state",
"def is_on(self) -> boo... | [
"0.87892145",
"0.86683935",
"0.86683935",
"0.86683935",
"0.83668846",
"0.8228278",
"0.80222344",
"0.7944196",
"0.7889458",
"0.7790521",
"0.7790521",
"0.76525116",
"0.7474403",
"0.7448818",
"0.74451506",
"0.74371916",
"0.73949003",
"0.7393098",
"0.7387312",
"0.7380527",
"0.736... | 0.0 | -1 |
Turn the device on. | async def async_turn_on(self, **kwargs):
await self.data.set_appliance_state(self.appliance_id, True)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_on(self, **kwargs):\n self._state = True\n if(self._device['type'] == '_DT-PLUG' or self._device['type'] == '_THIMR'):\n self._send_cmd(self._device,'cmd=ctrl&devices={[' + self._device[\"sid\"] + ']}&op={\"cmd\":5,\"op\":1 }', 5)\n if(self._device['type'] == '_REALY2' or s... | [
"0.8281669",
"0.7963511",
"0.7818252",
"0.7757262",
"0.7712496",
"0.7595535",
"0.7588195",
"0.7578901",
"0.751521",
"0.7514764",
"0.7510081",
"0.75018376",
"0.74641955",
"0.74501693",
"0.7437987",
"0.7409389",
"0.7357094",
"0.73516375",
"0.73505986",
"0.73295283",
"0.7277296"... | 0.66248816 | 68 |
Turn the device off. | async def async_turn_off(self, **kwargs):
await self.data.set_appliance_state(self.appliance_id, False)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n self._state = False\n if(self._device['type'] == '_DT-PLUG' or self._device['type'] == '_THIMR'):\n self._send_cmd(self._device, 'cmd=ctrl&devices={[' + self._device[\"sid\"] + ']}&op={\"cmd\":5,\"op\":0 }', 5)\n if(self._device['type'] == '_REALY2' or self._de... | [
"0.8548868",
"0.8254268",
"0.8161882",
"0.8142198",
"0.8119367",
"0.807117",
"0.7936932",
"0.7904594",
"0.7890579",
"0.78688365",
"0.7838398",
"0.7834393",
"0.78312963",
"0.77885693",
"0.77876323",
"0.7755004",
"0.77309066",
"0.77295303",
"0.7704694",
"0.76726454",
"0.7648420... | 0.0 | -1 |
Subscribe for update from the Controller | async def async_added_to_hass(self):
async def async_update_state():
"""Update sensor state."""
await self.async_update_ha_state(False)
async_dispatcher_connect(self.hass, "WiserSmartUpdateMessage", async_update_state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_controller(self):",
"def Update(self, controller):\n pass",
"def _notify_update(self, cuds_object):",
"def on_update(self, **kwargs):\n self.get_client()\n self.update(self, kwargs['sender'], kwargs['instance'])",
"def notifyObservers(self):",
"def subscribe(observer):",
... | [
"0.74831104",
"0.7353053",
"0.67304915",
"0.6597416",
"0.65423954",
"0.6507029",
"0.6507029",
"0.64969844",
"0.634441",
"0.6310208",
"0.62986887",
"0.62847424",
"0.62847424",
"0.62847424",
"0.6230553",
"0.621529",
"0.62080646",
"0.6202387",
"0.61830443",
"0.61828065",
"0.6169... | 0.0 | -1 |
Inject an extend method in obj that will used append method. | def define_extend_as_seq_of_appends(obj):
assert hasattr(
obj, 'append'
), f'Your object needs to have an append method! Object was: {obj}'
def extend(self, items):
for item in items:
self.append(item)
if isinstance(obj, type):
obj = type(obj.__name__, (obj,), {})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend(self, *args, **kwargs): # real signature unknown\n pass",
"def extend(self, x) -> None:\n pass",
"def append(self, obj):\r\n raise NotImplementedError",
"def extend(self, other):\n # YOUR CODE HERE\n raise NotImplementedError()",
"def append(self, *args, **kwargs):... | [
"0.7326428",
"0.6949307",
"0.6912196",
"0.6708326",
"0.6557307",
"0.6522524",
"0.6451939",
"0.64439166",
"0.63893723",
"0.6349176",
"0.62845767",
"0.60959977",
"0.60721445",
"0.60629874",
"0.5988625",
"0.5980781",
"0.5946136",
"0.5893937",
"0.58636904",
"0.5830696",
"0.582557... | 0.72547257 | 1 |
Make item2kv from a item2key function (the value will be the item itself). | def item_to_key(item2key):
def item2kv(item):
return item2key(item), item
return item2kv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_key_params_and_val(item_to_key_params_and_val, key_str_format):\n\n def item2kv(item):\n key_params, val = item_to_key_params_and_val(item)\n if isinstance(key_params, dict):\n return key_str_format.format(**key_params), val\n else:\n ... | [
"0.718581",
"0.5973326",
"0.59086525",
"0.59082144",
"0.5864925",
"0.5777844",
"0.5666772",
"0.56512356",
"0.5644327",
"0.56334215",
"0.5619753",
"0.54938334",
"0.54744387",
"0.54451644",
"0.53108513",
"0.5293976",
"0.52673554",
"0.522438",
"0.519466",
"0.5186249",
"0.5139293... | 0.8628558 | 0 |
item2kv that uses a specific key of a (mapping) item as the key | def field(field, keep_field_in_value=True, dflt_if_missing=NotSpecified):
if dflt_if_missing is NotSpecified:
if keep_field_in_value:
def item2kv(item):
return item[field], item
else:
def item2kv(item):
return ite... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_key(item2key):\n\n def item2kv(item):\n return item2key(item), item\n\n return item2kv",
"def item_to_key_params_and_val(item_to_key_params_and_val, key_str_format):\n\n def item2kv(item):\n key_params, val = item_to_key_params_and_val(item)\n if ... | [
"0.778238",
"0.674136",
"0.65468377",
"0.6250673",
"0.60905874",
"0.60205346",
"0.60039794",
"0.5975666",
"0.58866817",
"0.5851954",
"0.5782743",
"0.577586",
"0.57081103",
"0.5664182",
"0.56369895",
"0.56318825",
"0.5582396",
"0.55586785",
"0.5549029",
"0.5524534",
"0.5497107... | 0.0 | -1 |
Make an item2kv function that uses the current time as the key, and the unchanged item as a value. The offset_s, which is added to the output key, can be used, for example, to align to another system's clock, or to get a more accurate timestamp of an event. | def utc_key(offset_s=0.0):
if offset_s == 0.0: # splitting for extra speed (important in real time apps)
def item2kv(item):
return time.time(), item
else:
def item2kv(item):
return time.time() + offset_s, item
return item2kv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_key(item2key):\n\n def item2kv(item):\n return item2key(item), item\n\n return item2kv",
"def item_to_key_params_and_val(item_to_key_params_and_val, key_str_format):\n\n def item2kv(item):\n key_params, val = item_to_key_params_and_val(item)\n if ... | [
"0.599946",
"0.57572216",
"0.5707284",
"0.56803143",
"0.5570548",
"0.5564531",
"0.54696536",
"0.5291604",
"0.5251823",
"0.52447885",
"0.5214924",
"0.51746917",
"0.51510656",
"0.51070833",
"0.5074654",
"0.5035714",
"0.5030335",
"0.50250804",
"0.5017685",
"0.5007017",
"0.495430... | 0.7907506 | 0 |
Make item2kv from a function that produces key_params and val, and a key_template that will produce a string key from the key_params | def item_to_key_params_and_val(item_to_key_params_and_val, key_str_format):
def item2kv(item):
key_params, val = item_to_key_params_and_val(item)
if isinstance(key_params, dict):
return key_str_format.format(**key_params), val
else:
return key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_key(item2key):\n\n def item2kv(item):\n return item2key(item), item\n\n return item2kv",
"def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:\n my_tuple = (k, v*v)\n\n return my_tuple",
"def to_kv(k: str, v: typing.Union[int, float]) -> typing.Tuple[str, flo... | [
"0.6950581",
"0.60080147",
"0.59396696",
"0.5878557",
"0.58238006",
"0.58238006",
"0.57599187",
"0.5747728",
"0.57112104",
"0.5701399",
"0.56740856",
"0.5659779",
"0.56510776",
"0.5546873",
"0.54509264",
"0.53719",
"0.5371222",
"0.5350639",
"0.5309715",
"0.52902204",
"0.52765... | 0.77231133 | 0 |
Make item2kv from specific fields of a Mapping (i.e. dictlike object) item. | def fields(fields, keep_field_in_value=False, key_as_tuple=False):
if isinstance(fields, str):
fields_set = {fields}
fields = (fields,)
else:
fields_set = set(fields)
def item2kv(item):
if keep_field_in_value:
key = dict()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_to_dict(dict_item):\n info = {}\n item_info = None\n\n for k, v in dict_item.items():\n if k == 'ItemType':\n info[k] = api.item_dict_inv[dict_item['ItemType']]\n elif k == 'Item':\n item_info = colectica.parse_xml(v, api.item_dict_inv[dict_item['ItemType']])\n... | [
"0.638681",
"0.5986349",
"0.5864333",
"0.5854016",
"0.58341384",
"0.58299994",
"0.5811925",
"0.5781122",
"0.5701328",
"0.56673425",
"0.55486465",
"0.5536015",
"0.55340225",
"0.55320275",
"0.5532019",
"0.55023867",
"0.5484489",
"0.54644644",
"0.5459894",
"0.5418803",
"0.541620... | 0.56652045 | 10 |
Makes a new class with append (and consequential extend) methods | def appendable(
store_cls=None, *, item2kv,
):
def append(self, item):
k, v = item2kv(item)
self[k] = v
def extend(self, items):
for item in items:
self.append(item)
return type(
'Appendable' + store_cls.__name__,
(store_cls,),
{'append': ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_extend_as_seq_of_appends(obj):\n assert hasattr(\n obj, 'append'\n ), f'Your object needs to have an append method! Object was: {obj}'\n\n def extend(self, items):\n for item in items:\n self.append(item)\n\n if isinstance(obj, type):\n obj = type(obj.__name__... | [
"0.6761683",
"0.6586482",
"0.64911306",
"0.647231",
"0.6393636",
"0.6302089",
"0.6301802",
"0.62075347",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.61674505",
"0.... | 0.0 | -1 |
the function print a data from dict 'new_dict' according to the number(picked_n) the user choosed. | def pickedFromDict(picked_num, new_dict):
#1-printing mariah's last name
#2-printing mariah's birth date
#3-printing mariah's hobbies
#4-printing mariah's last hobbie
#5-adds "coocking" to mariah's hobbies and printing mariah's updated hobbies
#6-printing mariah's birth date into tuple of ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_five_gram_dict(n_gram_dict):\n n_gram = dict()\n\n for line_idx, line_val in enumerate(n_gram_dict):\n if n_gram.get(line_val[0], None) == None:\n n_gram[line_val[0]] = [line_val[1]+\" \"+line_val[2], int(line_val[3])]\n\n if DEBUGGING_MODE:\n print(\"\\n========== check ... | [
"0.62824196",
"0.6082546",
"0.5780949",
"0.5698525",
"0.5650637",
"0.5601323",
"0.55702174",
"0.5543086",
"0.5519851",
"0.5518044",
"0.5468941",
"0.54135096",
"0.53970253",
"0.53740084",
"0.53520656",
"0.5302337",
"0.52912074",
"0.52847147",
"0.5274072",
"0.52664304",
"0.5217... | 0.74096864 | 0 |
Iterator for page links | def iter_page_links(self) -> Iterable[str]:
base_url = 'https://www.med.navy.mil'
r = requests.get(self.starting_url, verify=CERTIFICATE_DIR + '/cat3.pem')
soup = bs4.BeautifulSoup(r.content, features="html.parser")
# get target column of list items
issuance_list = soup.find('di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_links(self):",
"def iter_page_links(self) -> Iterable[str]:\n base_url = 'https://health.mil/About-MHS/OASDHA/Defense-Health-Agency/Resources-and-Management/DHA-Publications'\n yield base_url",
"def links(cls, page):\r\n for match in cls.HREF_RE.finditer(page):\r\n yield cls.href... | [
"0.80651504",
"0.750158",
"0.7370286",
"0.73280376",
"0.69186187",
"0.69141686",
"0.6908116",
"0.6793799",
"0.67863417",
"0.6741017",
"0.66748494",
"0.6670355",
"0.66565365",
"0.6593838",
"0.65873545",
"0.65807104",
"0.6502916",
"0.6478992",
"0.64505965",
"0.64059603",
"0.639... | 0.75957644 | 1 |
Parse document objects from page of text | def parse_docs_from_page(self, page_url: str, page_text: str) -> Iterable[Document]:
# parse html response
url = "https://www.med.navy.mil/directives/Pages/Publications.aspx"
base_url = 'https://www.med.navy.mil'
parsed_docs = []
doc_name_list = []
if (page_url.find("Publ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_docs_from_page(self, page_url: str, page_text: str) -> Iterable[Document]:\n # get the data\n data = requests.get(page_url)\n\n # load data into bs4\n soup = BeautifulSoup(data.text, 'html.parser')\n # links = []\n pdf_dis = []\n dates = []\n table ... | [
"0.71913856",
"0.69207364",
"0.6807848",
"0.6564104",
"0.6440653",
"0.6434585",
"0.6419085",
"0.6406201",
"0.63876253",
"0.6367041",
"0.6246994",
"0.62138414",
"0.6203199",
"0.6178067",
"0.6176524",
"0.61475307",
"0.6122435",
"0.6108919",
"0.60970265",
"0.6094376",
"0.6085055... | 0.6943239 | 1 |
Handle the simple domain testing. | def domain(self):
# We run the preset specific to this method.
self.preset.simple_domain()
# We print the header if it was not done yet.
PyFunceble.CLICore.print_header()
if self.subject:
if PyFunceble.CONFIGURATION["syntax"]:
# The syntax mode is ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_domain(self, dm):\n request = create_request(\"domain\", \"other\")\n result = await dm.apply_handler(request, create_responder(request))\n assert result.dialogue_state == \"domain\"",
"def domain(self, domain):",
"def test_domain(self):\n self.assertEqual(self.gmail_... | [
"0.69996405",
"0.65742457",
"0.64918303",
"0.64027655",
"0.6280388",
"0.6163927",
"0.6068581",
"0.5992819",
"0.5953436",
"0.59357256",
"0.5913644",
"0.5860243",
"0.58194214",
"0.5796987",
"0.578456",
"0.5782908",
"0.57691324",
"0.57577944",
"0.5725612",
"0.5719665",
"0.571478... | 0.6193609 | 5 |
Handle the simple URL testing. | def url(self):
# We run the preset specific to this method.
self.preset.simple_url()
# We print the header if it was not done yet.
PyFunceble.CLICore.print_header()
if self.subject:
if PyFunceble.CONFIGURATION["syntax"]:
# The syntax mode is activate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_good_get_url(self):\n result = self._search('Love Story', just_results=True)\n get_url = result[0]['get_url']\n resp = self.app.get(get_url)\n self.assertEqual(resp.status_code, 200)\n self.assertIn('url', resp.data)\n self.assertIn('/d?', resp.data)",
"def test... | [
"0.72681403",
"0.71391606",
"0.70289594",
"0.6968646",
"0.6947732",
"0.69267225",
"0.6905998",
"0.68799067",
"0.6875748",
"0.6863834",
"0.6787024",
"0.67587733",
"0.67512286",
"0.6680818",
"0.66688335",
"0.66518843",
"0.6651252",
"0.6636319",
"0.6613866",
"0.6590681",
"0.6582... | 0.0 | -1 |
Applies the update rule (1alpha) old weights + alpha new weights to the target network | def _soft_update_target_network(self):
# Update the target network
for target_param, param in zip(self.actor_target_network.parameters(), self.actor_network.parameters()):
target_param.data.copy_((1-self.args.tau) * target_param.data + self.args.tau * param.data)
# Update the criti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n activation, activation_p = self.feedforward()\n # initialize delta_weights\n delta_w = np.zeros(2)\n # simultaneous calculate delta_weights\n for i, element in enumerate(self.y):\n delta_w += (activation[i]-element)*(activation_p[i])*self.X[... | [
"0.7455495",
"0.7379926",
"0.73600084",
"0.73110175",
"0.72854525",
"0.72537595",
"0.7178255",
"0.71139073",
"0.69609594",
"0.69375557",
"0.6933966",
"0.6921262",
"0.6915784",
"0.6860178",
"0.6826528",
"0.6823616",
"0.67989314",
"0.67899925",
"0.6783151",
"0.6774147",
"0.6753... | 0.640386 | 50 |
Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits . It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The "answer" return value is one of "yes" or "no". | def query_yes_no(question, default="yes"):
valid = {"yes":True, "y":True, "ye":True,
"no":False, "n":False}
if default == None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_yes_no(question, default=\"yes\"):\n valid = {\"yes\":\"yes\", \"y\":\"yes\", \"ye\":\"yes\",\n \"no\":\"no\", \"n\":\"no\"}\n if default == None:\n prompt = \" [y/n] \"\n elif default == \"yes\":\n prompt = \" [Y/n] \"\n elif default == \"no\":\n promp... | [
"0.8572186",
"0.85713255",
"0.8545572",
"0.853924",
"0.85147977",
"0.8507389",
"0.8505385",
"0.85048777",
"0.85032177",
"0.85032177",
"0.85032177",
"0.85032177",
"0.85032177",
"0.85032177",
"0.85032177",
"0.85032177",
"0.8501381",
"0.8499923",
"0.84977955",
"0.849599",
"0.849... | 0.8504754 | 12 |
Provide an API call to Pushover for mobile notifications of events in the script. "message" is a string that will display on the Pushover notification. "app_token" is a string for the app token provided by Pushover. | def pushover(message, app_token):
import urllib, httplib
conn = httplib.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": app_token,
"user": "uU95W9hYqeW3b24uyPaT1skT1SG35N",
"message": message,
}), { "Content-type": "application/x-www... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tell_sophie(message):\n \n d = {'token': cf.get('pushover', 'apikey'),\n 'user': cf.get('pushover', 'userkey'),\n 'message': message }\n requests.post('https://api.pushover.net/1/messages.json', json=d)",
"def send_push(message: Dict[Any, Any]) -> None:\n notification_url = settin... | [
"0.6193292",
"0.6061524",
"0.5765204",
"0.5674728",
"0.54582673",
"0.5439559",
"0.5439116",
"0.5438104",
"0.54364663",
"0.5409798",
"0.5393484",
"0.53734607",
"0.5351594",
"0.5273738",
"0.5259695",
"0.5203758",
"0.51804733",
"0.51779073",
"0.51729697",
"0.51518786",
"0.508690... | 0.79063237 | 0 |
Creates a compressed ZIP file. ZIP64 is enabled, which will allow for files larger then 4GB. | def make_zipfile(output_filename, source_dir):
import zipfile, zlib
relroot = os.path.abspath(os.path.join(source_dir, os.pardir))
with zipfile.ZipFile(output_filename, "w", zipfile.ZIP_DEFLATED, allowZip64) as zip:
for root, dirs, files in os.walk(source_dir):
# add directory (needed fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_zip_file():\n shutil.make_archive(os.path.join(DIST_DIR, \"build\"), \"zip\", BUILD_DIR)",
"def make_zip(self):\n shutil.make_archive(self.name, 'zip', self.name)",
"def create_zip(file_dir):\n curr_path = os.getcwd()\n os.chdir(file_dir)\n zip_name = 'files_archive_{}.zip'.fo... | [
"0.6925083",
"0.67105824",
"0.6490892",
"0.6436635",
"0.6400512",
"0.6301467",
"0.6213911",
"0.6209122",
"0.617005",
"0.611945",
"0.6118456",
"0.6095087",
"0.6064599",
"0.60629886",
"0.605085",
"0.6048859",
"0.603617",
"0.59521216",
"0.59409684",
"0.59262395",
"0.5903568",
... | 0.6547043 | 2 |
Setup our command line options | def init_parser():
parser = OptionParser()
parser.add_option("-n", "--interactive", action="store_true", help="run in interactive (non-daemon) mode")
parser.add_option("-r", "--run", action="store_true", help="starts process identified by -app parameter")
parser.add_option("-k", "--kill", action="store_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self, optparser):\n\t\tpass",
"def setupOptions(self):\n add = command_line.CommandLineParser.add_option\n add(\"-S\", \"--startup\", action=\"store\", type=\"str\", default=None,\n dest=\"dotVistrails\",\n help=\"Set startup file (default is ~/.vistrails/startup.py)... | [
"0.78367716",
"0.7731022",
"0.75332916",
"0.73882174",
"0.734645",
"0.7200229",
"0.7177633",
"0.71584034",
"0.7153046",
"0.71506524",
"0.71472234",
"0.7069307",
"0.70598435",
"0.7003351",
"0.69833183",
"0.69774586",
"0.69264084",
"0.6907073",
"0.68903387",
"0.68735695",
"0.68... | 0.0 | -1 |
Determine the path to the virtualenv python | def get_python():
if sys.platform == 'win32':
python = path.join(VE_ROOT, 'Scripts', 'python.exe')
else:
python = path.join(VE_ROOT, 'bin', 'python')
return python | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtualenv_pypath():\n virtual_env = os.environ.get('VIRTUAL_ENV')\n if not virtual_env:\n return\n\n interpreter = \"python%s\" % sys.version[:3]\n\n site_packages = os.path.join(virtual_env, \"lib\", interpreter,\n \"site-packages\")\n\n return site_packa... | [
"0.7656868",
"0.7537979",
"0.7274006",
"0.72609043",
"0.69453156",
"0.69351953",
"0.6896114",
"0.6774373",
"0.6663893",
"0.6648732",
"0.6585911",
"0.6559061",
"0.652245",
"0.65128434",
"0.6482724",
"0.6455669",
"0.64529234",
"0.6367414",
"0.62886614",
"0.6280892",
"0.62603056... | 0.729334 | 2 |
Rerun this script within the virtualenv with same args | def go_to_ve():
# two options are possible
if not path.abspath(sys.prefix) == VE_ROOT:
# Option A: we are in the parental process that was called from command line like
# $> ./launch.py --run -app NAME
# in this case sys.prefix points to Global Interpreter
python = get_python()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch():\n if launched():\n check_version()\n os.chdir(ROOT)\n return\n\n if not os.path.exists(BIN_LORE):\n missing = ' %s virtualenv is missing.' % APP\n if '--launched' in sys.argv:\n sys.exit(ansi.error() + missing + ' Please check for errors during:\\n ... | [
"0.6228062",
"0.616016",
"0.6155152",
"0.6054533",
"0.603145",
"0.59831095",
"0.5941501",
"0.58203095",
"0.5775378",
"0.5753949",
"0.5752812",
"0.57347965",
"0.57167816",
"0.5708028",
"0.5705326",
"0.5691063",
"0.5664881",
"0.56143963",
"0.5597662",
"0.55923563",
"0.5588306",... | 0.5524607 | 26 |
Install our virtual environment; removing the old one if it exists | def install_environment(root):
sys.stdout.write('Installing virtualenv into %s \n' % root)
try:
import virtualenv
except ImportError:
sys.stdout.write('Installing virtualenv into global interpreter \n')
subprocess.call([VE_GLOBAL_SCRIPT, PROJECT_ROOT])
import virtualenv
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_virtualenv(ctx):\n if not path.isfile(\"./pyenv/bin/pip\"):\n ctx.run(\"virtualenv --no-site-packages --python=/usr/bin/python2.7 pyenv\")\n ctx.run(\"PIP_DOWNLOAD_CACHE=/var/tmp/ ./pyenv/bin/pip install -r requirements.txt\")\n print(\"\"\"\n Installation completed. Please check any er... | [
"0.70328605",
"0.66779727",
"0.66118217",
"0.656353",
"0.65248436",
"0.65089977",
"0.6502636",
"0.6473916",
"0.6418527",
"0.6363957",
"0.63546306",
"0.63459617",
"0.63441616",
"0.62826",
"0.62428427",
"0.6232576",
"0.6230184",
"0.6230184",
"0.62095016",
"0.62049896",
"0.61960... | 0.692725 | 1 |
Installs, switches, or bails | def install_or_switch_to_virtualenv(options):
if options.install_ve:
install_environment(VE_ROOT)
elif path.exists(VE_ROOT):
go_to_ve()
else:
sys.stdout.write('No virtualenv detected, please run ./launch.py --install_ve \n')
sys.exit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _install(self):\n\n pass",
"def install():\n deploy()\n configure()",
"def install():\n PackCommandExecutor().pack()\n InstallCommandExecutor().install()",
"def do(self):\r\n parameters = ParametersParserStr(self.args_parameters).get()\r\n self.core.install(self.product_n... | [
"0.70007586",
"0.69492835",
"0.68649054",
"0.6785551",
"0.65928584",
"0.65834975",
"0.6547626",
"0.65337116",
"0.6506436",
"0.6504917",
"0.65019196",
"0.6499389",
"0.6488611",
"0.6479118",
"0.6479118",
"0.64570904",
"0.64477783",
"0.6431348",
"0.6423871",
"0.6401179",
"0.6356... | 0.0 | -1 |
Decorator validates if the app parameter is registered in the process_context | def valid_process_name(function):
def _wrapper(options, *args, **kwargs):
from synergy.conf.process_context import ProcessContext
if options.app not in ProcessContext.CONTEXT:
msg = 'Aborting: application <%r> defined by --app option is unknown. \n' % options.app
sys.stdout.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_context(f):\n @wraps(f)\n def wrapper(*args, **kwargs):\n if not is_admin_context(args[0]) and not is_user_context(args[0]):\n raise exception.NotAuthorized()\n return f(*args, **kwargs)\n return wrapper",
"def __call__(self, app: App, **kwargs: Any) -> bool:\n ... | [
"0.60219806",
"0.5993461",
"0.58701164",
"0.5856209",
"0.5856209",
"0.58344436",
"0.58344436",
"0.5770378",
"0.568177",
"0.568177",
"0.5681647",
"0.56343865",
"0.56343865",
"0.5310002",
"0.5292798",
"0.52796423",
"0.5245052",
"0.52111816",
"0.520173",
"0.5142669",
"0.512641",... | 0.647955 | 0 |
Start up specific daemon | def start_process(options, args):
import psutil
import process_starter
from synergy.system import process_helper
try:
pid = process_helper.get_process_pid(options.app)
if pid is not None:
if psutil.pid_exists(pid):
message = 'ERROR: Process %r is already runn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_daemon(self, *args, **kwargs):\n pass",
"def daemon(self):\n obj = self.subparsers.add_parser(\"daemon\", help=\"Daemon scripts\")\n obj.add_argument(\n \"daemon_type\",\n # default=\"all\",\n # const=\"all\",\n nargs=1,\n choi... | [
"0.7956209",
"0.75054634",
"0.7067929",
"0.6814917",
"0.67252594",
"0.6712481",
"0.656734",
"0.6528579",
"0.6513064",
"0.65108347",
"0.6503128",
"0.64801586",
"0.6427501",
"0.6425095",
"0.6422609",
"0.6417206",
"0.63690954",
"0.6340095",
"0.63130045",
"0.63100076",
"0.6272269... | 0.0 | -1 |
Run IPython in the virtualenv | def run_shell(options):
from IPython import embed
embed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interactive():\n IPython.start_ipython(argv=[])",
"def runWithIpythonKernel(self) -> None:\n try:\n from leo.core import leoIPython\n g.app.ipk = leoIPython.InternalIPKernel()\n g.app.ipk.run()\n except Exception:\n g.es_exception()\n pr... | [
"0.7166777",
"0.7158425",
"0.6624234",
"0.6447659",
"0.63694334",
"0.6131091",
"0.6131091",
"0.6092883",
"0.60665303",
"0.60531026",
"0.6051143",
"0.600603",
"0.59939516",
"0.5958773",
"0.59398896",
"0.59178424",
"0.57795167",
"0.57483995",
"0.56020933",
"0.5594966",
"0.55824... | 0.56023276 | 18 |
Runs the main function, including running the algorithm | def run_louvain(fn, algorithm):
df = read_exprs_as_df(fn)
k = get_k(df)
print("building graph...")
indices, adj_matrix = get_sparse_knn_graph(df, k, algorithm)
igraph = convert_sparse_to_igraph(indices, adj_matrix)
print("running louvainCluster find partition...")
part = louvain.find_partiti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n run_program()",
"def main():\n parser = argparse.ArgumentParser(description=MAIN_DESCRIPTION)\n parser.add_argument('-a', '--algorithm', help=ALGORITHM_DESCRIPTION)\n parser.add_argument('-n', '--number', type=int, help=NUMBER_DESCRIPTION)\n parser.add_argument('-o', '--order', help=... | [
"0.7703787",
"0.75213575",
"0.75199765",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",
"0.73887837",... | 0.0 | -1 |
Convert an adjacency graph in scipy sparse matrix format into an iGraph format. | def convert_sparse_to_igraph(indices, matrix):
# sources, targets = matrix.nonzero()
# weights = matrix[sources, targets]
# weights = np.array(weights)[0]
# print(dir(louvain))
# ig = igraph.Graph(zip(sources, targets), directed=True,
# edge_attrs={'weight': weights})
# return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_nxgraph(G):\n return nx.to_scipy_sparse_matrix(G).astype('float32')",
"def create_adjacency_matrix(graph):\n index_1 = [edge[0] for edge in graph.edges()]\n index_2 = [edge[1] for edge in graph.edges()]\n values = [1 for edge in graph.edges()]\n node_count = max(max(index_1)+1,max(index_2... | [
"0.7428788",
"0.698894",
"0.6937286",
"0.6890723",
"0.6840507",
"0.6761767",
"0.6671198",
"0.6508733",
"0.64971626",
"0.6486387",
"0.64698505",
"0.6466938",
"0.6412773",
"0.6366936",
"0.6302056",
"0.61876756",
"0.615492",
"0.6137109",
"0.61366796",
"0.60860234",
"0.6081462",
... | 0.79616356 | 0 |
Given a gene expression matrix, find the k nearest neighbors | def get_sparse_knn_graph(df, k, algorithm):
print("df shape", df.shape)
X = np.array(df)
nbrs = NearestNeighbors(n_neighbors=k, algorithm=algorithm).fit(X)
distances, indices = nbrs.kneighbors(X)
knn_graph = nbrs.kneighbors_graph(X).toarray()
print("indices, graph", len(indices), knn_graph.shape... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_nearest_neighbors_idx(X, x, k):\n ## homework:start\n result = \n ## homework:end\n return result",
"def _find_nearest_neighbors(self, k=15):\n # this isn't running as expected\n # if self.pca_matrix.any():\n # sys.exit(\"Please run reduce matrix dimensions for popul... | [
"0.6991374",
"0.6955085",
"0.68214",
"0.6793339",
"0.67343223",
"0.6649099",
"0.6557108",
"0.65438896",
"0.6536014",
"0.6518725",
"0.65002185",
"0.64913833",
"0.6414896",
"0.6372991",
"0.63632715",
"0.63308126",
"0.62902194",
"0.62772727",
"0.6258799",
"0.6254702",
"0.6214376... | 0.6276555 | 18 |
Reads in a file as a dataframe, expects genes as rownames, cells as colnames | def read_exprs_as_df(fn):
df = pd.read_table(fn, index_col=0).T
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_data(fname, cols):\n df = (pd.read_csv(fname, header=None, sep=r\"\\s+\", comment=\"#\",\n names=cols, dtype=np.float64)\n .iloc[1:]) # First line is the total number of trees\n # Could reset_index, but we don't shuffle the DataFrame\n return df",
"def _read_gff... | [
"0.68378675",
"0.6703915",
"0.65640306",
"0.64664686",
"0.6444617",
"0.6426337",
"0.64188665",
"0.6380153",
"0.6320563",
"0.63187337",
"0.6276507",
"0.62567705",
"0.62567705",
"0.62567705",
"0.6245474",
"0.62407905",
"0.62309635",
"0.62281895",
"0.61989623",
"0.61345327",
"0.... | 0.0 | -1 |
Returns a value K which scales logarithmically to the number of cells in a sample. | def get_k(df):
return int(np.log(len(df.columns))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_kl(self, lvl):\n kl = [] # kernal length\n for n in range(lvl):\n fct = self.scaling**n # up-sampling factor\n kl.append(fct*(self.nfreq-1)+1)\n kl.append(kl[-1]) # repeat the value of the coarsest scale for the approximation coefficient\n return kl... | [
"0.62024623",
"0.6159338",
"0.6130816",
"0.60664135",
"0.6045936",
"0.6011657",
"0.5971239",
"0.59182364",
"0.58902717",
"0.5853251",
"0.5848989",
"0.58119035",
"0.58073115",
"0.5798724",
"0.5790387",
"0.5779547",
"0.5767433",
"0.5755783",
"0.575504",
"0.57255423",
"0.5699927... | 0.70775306 | 0 |
Authorize with Spotify API and fetch bearer token. | def authorize(self):
try:
auth_url = 'https://accounts.spotify.com/api/token'
headers={}
data={}
data_string = f"{self.client_id}:{self.client_secret}"
data_bytes = data_string.encode("ascii")
base_bytes = base64.b64encode(data_bytes)
base_message = base_bytes.decode("ascii")
headers['Autho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize():\n encoded_auth = base64.b64encode(\n (os.environ[\"SPOTIFY_CLIENT_ID\"] + ':' + os.environ[\"SPOTIFY_CLIENT_SECRET\"]).encode())\n headers = {\n 'Authorization': 'Basic {}'.format(encoded_auth.decode(\"utf-8\"))\n }\n\n response = requests.post(os.environ['SPOTIFY_AUTH_UR... | [
"0.7426291",
"0.71426195",
"0.71205246",
"0.70915276",
"0.7082394",
"0.69950104",
"0.6989322",
"0.69705796",
"0.67263836",
"0.67155063",
"0.6676822",
"0.6665931",
"0.66071135",
"0.656264",
"0.65159553",
"0.65093845",
"0.6490198",
"0.6468989",
"0.64642835",
"0.6463644",
"0.645... | 0.81158495 | 0 |
Fetch song meta data from Spotify API | def fetch_song_data(self, song_ids):
tracks_base_url = "https://api.spotify.com/v1/tracks"
headers = {}
track_ids = ','.join(song_ids)
query_params = "/?ids="+track_ids
tracks_url = tracks_base_url + query_params
tracks={}
headers['Authorization'] = f"Bearer {self.token}"
try:
req = request.Request(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSongsSpotify(song_name,access_token):\n song_name = song_name.strip()\n query = \"https://api.spotify.com/v1/search?q={}&type=track&limit=20&offset=0\".format(song_name)\n response = requests.get(\n query,\n headers={\n \"Content-Type\": \"application/json\",\n \... | [
"0.74497265",
"0.7296947",
"0.71008754",
"0.6712899",
"0.66537416",
"0.6643649",
"0.6556194",
"0.6546541",
"0.65292156",
"0.6465178",
"0.64304024",
"0.6372433",
"0.6330061",
"0.6325236",
"0.63066703",
"0.62279993",
"0.61934066",
"0.61768615",
"0.617526",
"0.6166159",
"0.61555... | 0.66748154 | 4 |
Set the topic and topic class | def __init__(self, topic):
self._topic = topic
# Because this is Music-specific, the server is
# built-in to the API class, stored as the transport.
# Thus, unlike oslo.messaging, there is no server
# specified for a target. There also isn't an
# exchange, namespace, or ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, topic):\n self.topic = topic",
"def topic(self, topic):\n self.connection.topic(str(self), topic)",
"def __init__(self, topic):\n super().__init__(topic)",
"def __init__(self, topics=None):\n self.topics = topics or []",
"def __init__(self):\n self.topi... | [
"0.73967177",
"0.6828095",
"0.67778134",
"0.65736896",
"0.63798666",
"0.63574094",
"0.62670046",
"0.6237963",
"0.6213709",
"0.61785144",
"0.61389863",
"0.6136595",
"0.5996025",
"0.59714216",
"0.59703076",
"0.59272283",
"0.58732325",
"0.58732325",
"0.587296",
"0.5817917",
"0.5... | 0.64841026 | 4 |
Set the transport and target | def __init__(self, conf, transport, target):
self.conf = conf
self.transport = transport
self.target = target
self.RPC = self.target.topic_class
# introduced as a quick means to cache messages
# with the aim of preventing unnecessary communication
# across conduc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transport(self, transport):\n\n self._transport = transport",
"def set_target(self, host, port):\r\n pass",
"def target(self, target) :\n\t\ttry :\n\t\t\tself._target = target\n\t\texcept Exception as e:\n\t\t\traise e",
"def target(self, target) :\n\t\ttry :\n\t\t\tself._target = target\n\t\t... | [
"0.74800366",
"0.72744805",
"0.674761",
"0.674761",
"0.6387341",
"0.6313637",
"0.6256866",
"0.6238963",
"0.6235229",
"0.6182711",
"0.6158008",
"0.6034109",
"0.6004867",
"0.5946721",
"0.5941989",
"0.5934719",
"0.59205323",
"0.589888",
"0.582428",
"0.5814501",
"0.5808628",
"0... | 0.5737295 | 25 |
Check status for a given message id | def __check_rpc_status(self, rpc_id, rpc_method):
# Wait check_interval seconds before proceeding
check_interval = self.conf.messaging_server.check_interval
time.sleep(check_interval)
if self.conf.messaging_server.debug:
LOG.debug("Checking status for message {} method {} on ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_status(self, message_id):\n\n values = {'token': self._token, 'reference': message_id}\n return self._request(self.CHECK_STATUS_URL, values)",
"def check_status(self, id):\n raise NotImplementedError()",
"def check_status(bot, chat_id, query):\n\n remain = remain_time(chat_id)... | [
"0.79201895",
"0.74367034",
"0.6907959",
"0.6788956",
"0.65535843",
"0.65016764",
"0.64323986",
"0.64196557",
"0.638342",
"0.638342",
"0.6196043",
"0.6139166",
"0.613727",
"0.6111337",
"0.6080665",
"0.60454464",
"0.6041567",
"0.5996191",
"0.5978278",
"0.5949077",
"0.5930252",... | 0.6058128 | 15 |
Prepare to process requests | def _init(self, conf, **kwargs):
self.conf = conf
self.rpc_listener = None
self.transport = kwargs.pop('transport')
self.target = kwargs.pop('target')
self.endpoints = kwargs.pop('endpoints')
self.flush = kwargs.pop('flush')
self.kwargs = kwargs
self.RPC =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare(self, request):\n pass",
"def prepare(self):\n\t\treturn self.api.prepare_request(self)",
"def _process_request(self, request, response):\n ...",
"def process_request_starts(self, request):\n pass",
"def _prepare(self, url):\n pass",
"def _handle_first_request(self... | [
"0.8036205",
"0.7537117",
"0.7419324",
"0.7191366",
"0.7068381",
"0.6870673",
"0.68116856",
"0.68116856",
"0.6584572",
"0.6576559",
"0.65727884",
"0.65616536",
"0.65616536",
"0.65616536",
"0.655626",
"0.65227324",
"0.6508558",
"0.6505727",
"0.65009254",
"0.64425266",
"0.64372... | 0.0 | -1 |
Flush all messages with an enqueued status. Use this only when the parent service is not running concurrently. | def _flush_enqueued(self):
msgs = self.RPC.query.all()
for msg in msgs:
if msg.enqueued:
if 'plan_name' in list(msg.ctxt.keys()): # Python 3 Conversion -- dict object to list object
LOG.info('Plan name: {}'.format(msg.ctxt['plan_name']))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush(self):\n size = self.queue.qsize()\n self.queue.join()\n logger.debug(f'[Analytics Client] Forcefully flushed {size} events')",
"def flush(self):\n self._pending_flush = False\n\n if self.handler is None or not self.handler.active or not self.send_queue:\n ... | [
"0.71293557",
"0.69559765",
"0.68641376",
"0.6769518",
"0.6711332",
"0.6666974",
"0.66550875",
"0.66449267",
"0.662717",
"0.649321",
"0.6464931",
"0.62884754",
"0.6249862",
"0.6178131",
"0.6155402",
"0.614081",
"0.61334896",
"0.60976636",
"0.6079396",
"0.6021548",
"0.5977156"... | 0.6660184 | 6 |
Current time in milliseconds. | def current_time_seconds(self):
return int(round(time.time())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_milli_time(self):\n return int(round(time.time() * 1000))",
"def __current_milli_time(self):\n\n return int(round(time.time() * 1000))",
"def current_time_millis():\n return int(round(time.time() * 1000))",
"def current_time(cls) -> float:",
"def current_millis():\n return i... | [
"0.87762415",
"0.87733865",
"0.85277",
"0.84228027",
"0.82104343",
"0.81799555",
"0.81684387",
"0.8135206",
"0.8096484",
"0.806833",
"0.80171204",
"0.79878896",
"0.79878896",
"0.7956128",
"0.7915534",
"0.78929555",
"0.7819905",
"0.7805699",
"0.7805138",
"0.7788874",
"0.778834... | 0.7686609 | 27 |
Convert milliseconds to seconds | def millisec_to_sec(self, millisec):
return millisec / 1000 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MillisToSec(self):\n self.Millis = [item / 1000 for item in self.Millis]\n return self.Millis",
"def _ms_to_time(self, milliseconds):\n \n ms = milliseconds\n \n # Get the last 3 digits of the milliseconds\n trunc_ms = ms % 1000\n seconds = (ms / 1000)\n minutes = (seconds ... | [
"0.76566106",
"0.7349378",
"0.7331618",
"0.7264953",
"0.7230861",
"0.7129717",
"0.7029283",
"0.6987922",
"0.69484216",
"0.68863964",
"0.68600786",
"0.6857339",
"0.68361413",
"0.6827519",
"0.68191534",
"0.6809082",
"0.67981195",
"0.6795517",
"0.6790688",
"0.6744001",
"0.672427... | 0.7594132 | 1 |
Wait for the polling interval, then do the real message check. | def __check_for_messages(self):
# Wait for at least poll_interval sec
polling_interval = self.conf.messaging_server.polling_interval
time.sleep(polling_interval)
if self.conf.messaging_server.debug:
LOG.debug("Topic {}: Checking for new messages".format(
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poll(self):\n self.poll_function(self.connection)",
"def poll(self):\n while self.running and reactor._started and not reactor._stopped:\n self.check_response_queue()\n sleep(0.5)",
"async def check():\r\n while True:\r\n if rss.check_new():\r\n item... | [
"0.6918109",
"0.6909268",
"0.66404",
"0.6634429",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6591415",
"0.6586251",
"0.650955",
"0.6... | 0.74402225 | 0 |
Look for a new RPC call and serve it | def _do(self):
# Get all the messages in queue
msgs = self.RPC.query.all()
for msg in msgs:
# Find the first msg marked as enqueued.
if msg.working and \
(self.current_time_seconds() - self.millisec_to_sec(msg.updated)) \
> self.co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpc(self) -> global___Rpc:",
"def send_rpc_probe(url, rpc_call):\n headers = {\n \"Content-Type\" : CONTENT_TYPE,\n \"X-GWT-Permutation\": GWT_PERMUTATION,\n \"X-GWT-Module-Base\": BASE_URL,\n }\n try:\n response = requests.post(\n url, data=rpc_call.replace(\"... | [
"0.65703666",
"0.6462032",
"0.6368787",
"0.63659775",
"0.62542856",
"0.6202504",
"0.6071764",
"0.6068642",
"0.6013697",
"0.6013697",
"0.5960758",
"0.5955402",
"0.59375614",
"0.58991414",
"0.58947885",
"0.58872646",
"0.5857087",
"0.5847803",
"0.58385795",
"0.58327603",
"0.5828... | 0.0 | -1 |
Gracefully stop working on things | def _gracefully_stop(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_check(self):\n pass",
"def aborting(self):\n \n pass",
"def stopclean(self):\n raise Exception(\"Not implemented\")",
"def stop() -> None:",
"def force_stop(self):\n #cancel any current request:\n self._cancel_current_request()",
"def _prepare_to_stop(self):\n ... | [
"0.74943763",
"0.7360043",
"0.7337609",
"0.72221744",
"0.7203809",
"0.7203615",
"0.7172144",
"0.7161631",
"0.7161631",
"0.7149348",
"0.7134612",
"0.713363",
"0.70896405",
"0.7084329",
"0.7068823",
"0.7068823",
"0.7068823",
"0.7068823",
"0.7068823",
"0.7068823",
"0.7068823",
... | 0.81977755 | 0 |
Prepare to restart the RPC Server | def _restart(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _RestartServer( self ):\n with self._gocode_lock:\n self._StopServer()\n self._StartServer()",
"def restart(self):",
"def restart(self) -> None:",
"def restart(self):\n pass",
"def request_shutdown(self, restart=False):",
"def restart(self):\r\n pass",
"def restart(self):... | [
"0.7340876",
"0.7222521",
"0.7215268",
"0.7143786",
"0.7116937",
"0.70833296",
"0.6916681",
"0.6875465",
"0.67941314",
"0.6769875",
"0.67550653",
"0.6754594",
"0.67220056",
"0.6678545",
"0.6672805",
"0.66473347",
"0.66432434",
"0.66391295",
"0.66269875",
"0.6593943",
"0.65930... | 0.77630264 | 0 |
Sets environment variables for a nox session object. | def set_environment_variables(env_dict, session):
for key, value in env_dict.items():
session.env[key] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_env_var(self):\n\n list_env_vars = self.config.items('environment_variables')\n for env_var in list_env_vars:\n os.environ[env_var[0].upper()] = env_var[1]",
"def set_envvars(self):\n # self.logger.trace(\"update os.environ with %s\", self.environ)\n for key in os.e... | [
"0.7283772",
"0.7195755",
"0.7000887",
"0.6998755",
"0.6786736",
"0.6786736",
"0.6722491",
"0.6713368",
"0.67089427",
"0.66470826",
"0.65927714",
"0.6552898",
"0.6529187",
"0.6479471",
"0.64337885",
"0.6416746",
"0.64166296",
"0.64166296",
"0.6415311",
"0.64110196",
"0.635323... | 0.7486853 | 0 |
Run the coverage tests and generate an XML report. | def run_coverage(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.run_always("pip", "install", "coverage")
session.run_always("pip", "install", "-e", ".[all]")
if sys.platform != "win32":
session.run_always("pip", "install", "-e", ".[odes]")
session.run_always("pi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coverage(ctx):\n ctx.run(\"coverage run --source {PROJECT_NAME} -m pytest\".format(PROJECT_NAME=PROJECT_NAME))\n ctx.run(\"coverage report -m\")\n ctx.run(\"coverage html\")",
"def generate_report():\n if os.path.isdir(\"build/coverage\"):\n shutil.rmtree(\"build/coverage\")\n commands ... | [
"0.75908047",
"0.73616856",
"0.73454845",
"0.7307842",
"0.72947073",
"0.7161443",
"0.71462065",
"0.71100754",
"0.7049113",
"0.7043015",
"0.70139116",
"0.7010246",
"0.7000596",
"0.69439244",
"0.6935107",
"0.6927644",
"0.6852005",
"0.66157794",
"0.6567534",
"0.65229076",
"0.649... | 0.6916893 | 16 |
Run the integration tests. | def run_integration(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.run_always("pip", "install", "-e", ".[all]")
if sys.platform == "linux":
session.run_always("pip", "install", "-e", ".[odes]")
session.run("python", "run-tests.py", "--integration") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTests(self):\n \n pass",
"def run_integration_tests():\n run_pytest('integration')\n return redirect(url_for('main.test_reports', report='integration'))",
"def _run_ci_integration_test():\n _run_install(False)\n _run_integration_tests_on_github(False)",
"def main():\n run_test... | [
"0.7858921",
"0.745134",
"0.74206007",
"0.728913",
"0.7250753",
"0.719681",
"0.7154184",
"0.70862395",
"0.70747304",
"0.7033606",
"0.697288",
"0.6942197",
"0.6851933",
"0.68370897",
"0.6828814",
"0.67902005",
"0.6787784",
"0.67841387",
"0.6778627",
"0.67776775",
"0.67760456",... | 0.6656401 | 58 |
Run the doctests and generate the output(s) in the docs/build/ directory. | def run_doctests(session):
session.run_always("pip", "install", "-e", ".[all,docs]")
session.run("python", "run-tests.py", "--doctest") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n build_no_documentation()\n build_sphinx_build()\n #build_sphinx_pdf()\n build_graphviz_files()",
"def docs():\n sh('sphinx-build -W -b html docs docs/_build/html')",
"def generate_documentation(self):\n self.generate_api_docs()\n build.main([\n self.SOURCE_D... | [
"0.7855625",
"0.7585224",
"0.75764483",
"0.7446974",
"0.72906613",
"0.72729623",
"0.72696984",
"0.72601384",
"0.7141866",
"0.7027311",
"0.69379294",
"0.6924913",
"0.6908724",
"0.6836512",
"0.6835656",
"0.68237054",
"0.6773623",
"0.67538667",
"0.6654604",
"0.66332316",
"0.6603... | 0.70405626 | 9 |
Run the unit tests. | def run_unit(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.run_always("pip", "install", "-e", ".[all]")
if sys.platform == "linux":
session.run_always("pip", "install", "-e", ".[odes]")
session.run_always("pip", "install", "-e", ".[jax]")
session.run("python", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTests(self):\n \n pass",
"def test():\n import unittest\n\n tests = unittest.TestLoader().discover(\"tests\")\n unittest.TextTestRunner(verbosity=2).run(tests)",
"def main():\n run_test_all()",
"def test():\n import unittest\n tests = unittest.TestLoader().dis... | [
"0.85183024",
"0.82517105",
"0.81414855",
"0.8076668",
"0.8069847",
"0.80517304",
"0.8050559",
"0.801922",
"0.7989364",
"0.7988354",
"0.79849315",
"0.7968269",
"0.7955071",
"0.7955071",
"0.7952072",
"0.7952072",
"0.7952072",
"0.7952072",
"0.7952072",
"0.7952072",
"0.7952072",... | 0.0 | -1 |
Run the examples tests for Jupyter notebooks and Python scripts. | def run_examples(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.run_always("pip", "install", "-e", ".[all]")
session.run("python", "run-tests.py", "--examples") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTest(self):\n self.setUp()\n self.test_JupyterNotebooks1()",
"def test_notebook():\n jupyter_notebooks = os.getenv('PYNQ_JUPYTER_NOTEBOOKS')\n\n # Try and find the notebook\n if os.path.isdir(f\"{jupyter_notebooks}/pynq-helloworld\"):\n if os.path.isfile(f\"{jupyter_notebooks}/pynq-h... | [
"0.79467314",
"0.76150626",
"0.7434167",
"0.7361855",
"0.717332",
"0.70440155",
"0.6929046",
"0.68701357",
"0.67449963",
"0.6597527",
"0.64612055",
"0.64561605",
"0.64463365",
"0.6435978",
"0.64315826",
"0.6427751",
"0.6382553",
"0.6372939",
"0.6356606",
"0.6331874",
"0.63151... | 0.72583026 | 4 |
Install PyBaMM in editable mode. | def set_dev(session):
set_environment_variables(PYBAMM_ENV, session=session)
envbindir = session.bin
session.install("-e", ".[all]")
session.install("cmake")
if sys.platform == "linux" or sys.platform == "darwin":
session.run(
"echo",
"export",
f"LD_LIBRAR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install(repo, package, python, editable):\n if repo.install(package, python, editable):\n click.echo('Done.')",
"def install():\n PackCommandExecutor().pack()\n InstallCommandExecutor().install()",
"def _set_editable_mode(self):\n dist = self.distribution\n build = dist.get_co... | [
"0.59621525",
"0.53993165",
"0.5379407",
"0.5375676",
"0.53683895",
"0.532562",
"0.5300663",
"0.5280318",
"0.5231794",
"0.5220922",
"0.52193946",
"0.51740074",
"0.51698244",
"0.51618624",
"0.5161461",
"0.51592284",
"0.51584935",
"0.51584935",
"0.5135395",
"0.51260597",
"0.508... | 0.51834434 | 11 |
Run the unit tests and integration tests sequentially. | def run_tests(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.run_always("pip", "install", "-e", ".[all]")
if sys.platform == "linux" or sys.platform == "darwin":
session.run_always("pip", "install", "-e", ".[odes]")
session.run_always("pip", "install", "-e", ".[jax]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTests(self):\n \n pass",
"def run_all_tests():\n remove_dbs()\n run_training_tests()\n run_custom_training_tests()\n run_training_save_tests()\n run_validation_tests()\n run_feature_extraction_tests()",
"def execute(self):\n for test in self.tests:\n test.ex... | [
"0.7365431",
"0.71568394",
"0.7119937",
"0.71017414",
"0.709754",
"0.6999044",
"0.69906926",
"0.6960894",
"0.69312894",
"0.6909163",
"0.6904695",
"0.6868181",
"0.6816456",
"0.6806892",
"0.679433",
"0.6739883",
"0.6709385",
"0.66809094",
"0.66681534",
"0.66680676",
"0.6650314"... | 0.0 | -1 |
Build the documentation and load it in a browser tab, rebuilding on changes. | def build_docs(session):
envbindir = session.bin
session.install("-e", ".[all,docs]")
with session.chdir("docs/"):
session.run(
"sphinx-autobuild",
"-j",
"auto",
"--open-browser",
"-qT",
".",
f"{envbindir}/../tmp/htm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_doc(self, widget, data=None):\n\t\twebbrowser.open('file://'+os.path.abspath(\"./doc/build/html/index.html\"))",
"def _docs():\n url = \"https://vanheeringen-lab.github.io/seq2science\"\n if not webbrowser.open(url):\n print(url)",
"def open_manual() -> None:\n\n path = os.path.abspath... | [
"0.7079853",
"0.70295894",
"0.69541997",
"0.6773426",
"0.66701597",
"0.66432005",
"0.6626478",
"0.66244996",
"0.65749663",
"0.6532104",
"0.64479727",
"0.6441878",
"0.642467",
"0.63460654",
"0.63347214",
"0.6310532",
"0.6291252",
"0.6214101",
"0.6180255",
"0.6161738",
"0.61294... | 0.644983 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.