query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Context processor to access all products from user wishlist | def user_wishlist(request):
if request.user.is_authenticated:
wishlist = get_object_or_404(Wishlist, user=request.user)
# Pagination show 12 products per page
paginator = Paginator(wishlist.products.all().order_by('id'), 12)
page = request.GET.get('page')
try:
a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wishlist(request):\n items = []\n user = get_object_or_404(UserProfile, user=request.user)\n wishlist = Wishlist.objects.get_or_create(user=user)\n wishlist_user = wishlist[0]\n existingWishlist = WishlistItem.objects.filter(\n wishlist=wishlist_user).exists()\n\n if existingWishlist:\... | [
"0.68520015",
"0.64964706",
"0.64570814",
"0.64333427",
"0.6225109",
"0.62219924",
"0.6135836",
"0.59208906",
"0.586585",
"0.5846289",
"0.58390373",
"0.58213365",
"0.57715636",
"0.5741449",
"0.56791115",
"0.5651308",
"0.5636304",
"0.5611469",
"0.5594619",
"0.55830675",
"0.554... | 0.6923329 | 0 |
unquantize weight before update weight, avoid training turbulence. | def unquant_weight(m):
global _QUANT_HANDLE
try:
m.weight.data = m.weight_origin
except AttributeError:
pass
except TypeError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def normalize_weight(self, Z):\n self.weight /= Z",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self):\n\n self.weights -= self.loss_grads\n sel... | [
"0.69327414",
"0.69287616",
"0.6750582",
"0.66629714",
"0.6540235",
"0.64524895",
"0.63917345",
"0.63575107",
"0.6343039",
"0.63287055",
"0.6307151",
"0.63064945",
"0.62739104",
"0.6245761",
"0.6244238",
"0.61442715",
"0.61392426",
"0.60856277",
"0.6049837",
"0.6031831",
"0.6... | 0.7209583 | 0 |
r""" Test GFPG library QuantAndDeQuantGPU. | def test():
quant_handle = QuantAndDeQuantGPU()
import torch
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
tensor = torch.Tensor(np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])).cuda()
logging.info("Origin Data: ")
logging.info(tensor)
start_time = datetime.datetime.now()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_qc_quantize_op_gpu(self):\n graph = tf.Graph()\n config = tf.compat.v1.ConfigProto(log_device_placement=False)\n sess = tf.compat.v1.Session(graph=graph, config=config)\n bitwidth = 8\n use_symm_encoding = False\n with graph.as_default():\n\n inp = tf.c... | [
"0.6797666",
"0.6711396",
"0.6471242",
"0.63600224",
"0.6304373",
"0.62627554",
"0.61734736",
"0.61478865",
"0.61421573",
"0.6140544",
"0.6102282",
"0.6074853",
"0.5933609",
"0.59066427",
"0.58761114",
"0.58625305",
"0.58616734",
"0.583168",
"0.5812284",
"0.57926136",
"0.5761... | 0.75784075 | 0 |
Check that the 'FUN' and 'BBQ' variable values are unique with respect to each other. | def check_fun_bbq_not_unique(fun, bbq):
fun_set = set(str(fun))
bbq_set = set(str(bbq))
if len(fun_set.union(bbq_set)) != 5:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_summer_not_unique(fun, bbq, summer):\n fun_set = set(str(fun))\n bbq_set = set(str(bbq))\n summer_set = set(str(summer))\n\n summer_fun_union = fun_set.union(summer_set)\n summer_bbq_union = bbq_set.union(summer_set)\n\n if len(summer_fun_union) != 7 or len(summer_bbq_union) != 7 or len... | [
"0.73765635",
"0.6097503",
"0.6023298",
"0.58524156",
"0.56967366",
"0.56548667",
"0.55882883",
"0.558621",
"0.55075127",
"0.5472332",
"0.5461498",
"0.5419203",
"0.5411763",
"0.5389069",
"0.53699887",
"0.53594816",
"0.5310973",
"0.5302523",
"0.5223545",
"0.5216425",
"0.520791... | 0.83220375 | 0 |
Check that 'SUMMER' variable values are almost unique to 'FUN' (excluding the 'U' variable) and completely unique to 'BBQ'. Also check that the 'SUMMER' variable values are unique to each other. | def check_summer_not_unique(fun, bbq, summer):
fun_set = set(str(fun))
bbq_set = set(str(bbq))
summer_set = set(str(summer))
summer_fun_union = fun_set.union(summer_set)
summer_bbq_union = bbq_set.union(summer_set)
if len(summer_fun_union) != 7 or len(summer_bbq_union) != 7 or len(summer_set) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_fun_bbq_not_unique(fun, bbq):\n fun_set = set(str(fun))\n bbq_set = set(str(bbq))\n\n if len(fun_set.union(bbq_set)) != 5:\n return True\n else:\n return False",
"def _valid_sbu_combination(self, incidence, sbu_set):\n if incidence is None:\n return len([i fo... | [
"0.73538435",
"0.5752358",
"0.56996167",
"0.54556",
"0.5418842",
"0.54076654",
"0.537638",
"0.53074366",
"0.52388746",
"0.5164242",
"0.51392543",
"0.5134561",
"0.5127542",
"0.51243865",
"0.5114154",
"0.5074979",
"0.50513005",
"0.5024604",
"0.4982424",
"0.49569768",
"0.4951057... | 0.7588708 | 0 |
download_data downloads the training data from the specified remote path via fsspec and places it in the tmpdir unextracted. | def download_data(remote_path: str, tmpdir: str) -> str:
tar_path = os.path.join(tmpdir, "data.tar.gz")
print(f"downloading dataset from {remote_path} to {tar_path}...")
fs, _, rpaths = fsspec.get_fs_token_paths(remote_path)
assert len(rpaths) == 1, "must have single path"
fs.get(rpaths[0], tar_path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe_download_and_extract():\n dest_directory = FLAGS.data_dir\n if not os.path.exists(dest_directory):\n os.makedirs(dest_directory)\n filename = DATA_URL.split('/')[-1]\n filepath = os.path.join(dest_directory, filename)\n if not os.path.exists(filepath):\n r = requests.Session().get(DATA_URL)\n ... | [
"0.6259458",
"0.62141436",
"0.61821884",
"0.61650014",
"0.61649317",
"0.61506605",
"0.6042444",
"0.6038",
"0.59566534",
"0.5953423",
"0.5948335",
"0.5939772",
"0.5936615",
"0.59077805",
"0.58687586",
"0.5842238",
"0.5826728",
"0.5821514",
"0.57949364",
"0.5789982",
"0.5730511... | 0.6341184 | 0 |
Fills the given path with randomly generated 64x64 images. This can be used for quick testing of the workflow of the model. Does NOT pack the files into a tar, but does preprocess them. | def create_random_data(output_path: str, num_images: int = 5) -> None:
train_path = os.path.join(output_path, "train")
class1_train_path = os.path.join(train_path, "class1")
class2_train_path = os.path.join(train_path, "class2")
val_path = os.path.join(output_path, "val")
class1_val_path = os.path.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_raw_data(tmp_dir, raw_dim=1024, num_channels=3, num_images=1):\n\n tf.gfile.MakeDirs(tmp_dir)\n\n for image_id in range(num_images):\n\n raw_image_path = os.path.join(tmp_dir, \"%s.jpg\" % image_id)\n\n mock_raw_image(x_dim=raw_dim, y_dim=raw_dim,\n num_channels=num_channels,\n ... | [
"0.60784703",
"0.59843904",
"0.5849876",
"0.5831968",
"0.5792602",
"0.57504994",
"0.56419593",
"0.5597036",
"0.5579867",
"0.5567797",
"0.5550139",
"0.55407375",
"0.5509547",
"0.5507798",
"0.5497652",
"0.5475824",
"0.54651845",
"0.5463205",
"0.5461314",
"0.5449749",
"0.5435942... | 0.60208035 | 1 |
Return a tuple of types for a field, or `default` if there is no type information and a default is specified. All fields will return a singleelement tuple, unless it was configured with a `UnionKind`, in which case all types in the union will be returned. If `unwrap` is True, then the tuple of types will be specified. ... | def field_type(f, default=MISSING, *, unwrap=True) -> Union[tuple, Any]:
return _field_type(f, TYPE, default, unwrap=unwrap) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _or_types(field):\n return '|'.join(field.get('type', {}).get('names', []))",
"def field_subtype(f, default=MISSING, *, unwrap=True):\n return _field_type(f, SUBTYPE, default, unwrap=unwrap)",
"def build_defaults(self, fields, defaults):\n # assert '__iter__' in dir(defaults), iterReq('default... | [
"0.5224334",
"0.52030015",
"0.4946775",
"0.4809755",
"0.47901797",
"0.47571266",
"0.4754597",
"0.4746675",
"0.47141576",
"0.4618402",
"0.46020648",
"0.45992017",
"0.44853425",
"0.44204098",
"0.44177788",
"0.4409449",
"0.44036892",
"0.4402199",
"0.43875858",
"0.4387374",
"0.43... | 0.71920294 | 0 |
For a given seed and shot, generate a config file based on a template config file that is used for training/evaluation. You can extend/modify this function to fit your usecase. | def get_config(seed, shot):
if args.coco:
# COCO
assert args.two_stage, 'Only supports novel weights for COCO now'
if args.novel_finetune:
# Fine-tune novel classifier
ITERS = {
1: (10000, 500),
2: (10000, 1500),
3: (10... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_config_and_makefile(_config):\n experiment_dir = Path(_config['trainer']['storage_dir'])\n makefile_path = Path(experiment_dir) / \"Makefile\"\n\n if not makefile_path.exists():\n from padertorch.contrib.examples.source_separation.tasnet.templates import \\\n MAKEFILE_TEMPLATE_T... | [
"0.6447288",
"0.6440364",
"0.6314993",
"0.63084924",
"0.62926704",
"0.61100346",
"0.6052603",
"0.6044389",
"0.59434706",
"0.59244305",
"0.59235203",
"0.59207696",
"0.5917525",
"0.5906047",
"0.58772135",
"0.58684087",
"0.5858659",
"0.5848748",
"0.58348626",
"0.58281535",
"0.58... | 0.7042954 | 0 |
Redirect nonwww requests to www. | def redirect_nonwww():
urlparts = urlparse(request.url)
if urlparts.netloc != 'www.mealscount.com':
return redirect('https://www.mealscount.com/', code=301) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_www(hostname: str) -> str:\n if hostname.startswith(\"www.\"):\n return hostname[4:]\n return hostname",
"def ssl_redirect():\n if request.get_header('X-Forwarded-Proto', 'http') != 'https':\n redirect(request.url.replace('http://', 'https://', 1), code=301)",
"def fir... | [
"0.6378573",
"0.62721723",
"0.5859779",
"0.5771819",
"0.5680137",
"0.56411994",
"0.54752874",
"0.5462076",
"0.5380044",
"0.5353241",
"0.5254475",
"0.5163623",
"0.51251495",
"0.50596863",
"0.501662",
"0.4976819",
"0.49192634",
"0.4908197",
"0.48885605",
"0.4851343",
"0.4846871... | 0.8099394 | 0 |
returns a list of neighbors returns a list of position objects with their directiontomoveto set to the direction that the empty square moved. | def neighbors(self):
# find 0 - blank square
x0 = None
y0 = None
for i in range(4):
for j in range(4):
if self.get_tile(i,j) == 0:
y0 = i
x0 = j
if x0 == None or y0 == None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_neighbors(self):\n return list(map(self.game.square, [self.position - self.game.rules[\"row_len\"], self.position + 1, self.position + self.game.rules[\"row_len\"], self.position - 1]))",
"def empty_spots(self):\n\t\tret = []\n\t\tfor i in range(0, self.size):\n\t\t\tfor j in range(0, self.size):\... | [
"0.7583234",
"0.73333657",
"0.72945344",
"0.7293684",
"0.725854",
"0.72296697",
"0.72086686",
"0.71733797",
"0.71366847",
"0.71238005",
"0.707542",
"0.7062021",
"0.7032389",
"0.70102596",
"0.6965794",
"0.6941387",
"0.6917996",
"0.6900293",
"0.6844919",
"0.6826912",
"0.6825766... | 0.8379654 | 0 |
Add a league which doesn't exist in the DB to it. | def add_league(inp_to_add, type_to_add, con, host, root, password):
with con.cursor() as cur:
if type_to_add == "url":
league_soup = BeautifulSoup(requests.get(inp_to_add).text, 'html.parser')
league_site = inp_to_add
elif type_to_add == "country":
midterm_u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_game():\n\n if (request.json or \"teams\") not in request.json:\n abort(400)\n game = {\n \"id\": games[-1][\"id\"] + 1,\n \"teams\": request.json[\"teams\"],\n \"score\": request.json.get(\"score\", \"\"),\n \"city\": request.json.get(\"city\", \"\"),\n \"da... | [
"0.61241",
"0.5901289",
"0.58466893",
"0.5826113",
"0.5742285",
"0.5730009",
"0.5710978",
"0.5699382",
"0.5605475",
"0.5599539",
"0.5587349",
"0.55752534",
"0.55563235",
"0.554479",
"0.5541232",
"0.55322415",
"0.54096913",
"0.538382",
"0.5365119",
"0.53349566",
"0.5314468",
... | 0.6966496 | 0 |
Get the HTML of the first relevant result in soccerway.com | def get_first_search_result(searching_site, player=None):
search_soup = BeautifulSoup(requests.get(searching_site).text, 'html.parser')
first_result = None
result_soup = None
result_site = None
if player:
search_result = search_soup.find('table', class_="playerstats table")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html(self, first_date = \"\"):\n\n link = \"https://en.wikipedia.org/w/index.php?title=\" + self.title + \"&offset=\" + first_date + \"&limit=500&action=history\"\n return bs(requests.get(link).text, 'lxml')",
"def get_html(query, search_type):\n params = {\n '_nkw': query,\n ... | [
"0.6606933",
"0.63835824",
"0.63004875",
"0.626508",
"0.61528665",
"0.6132819",
"0.6128713",
"0.61236644",
"0.6098358",
"0.60884625",
"0.6087206",
"0.60443574",
"0.60235274",
"0.59097105",
"0.5905273",
"0.58991724",
"0.58679825",
"0.5866748",
"0.5862152",
"0.5857842",
"0.5853... | 0.6680494 | 0 |
Get the countries that exist in soccerway.com and the midterm URL to their first leagues | def get_countries_dict():
competitions_page_soup = BeautifulSoup(requests.get(
SOCCER_URL + "/competitions/").text, 'html.parser')
competitions_page_soup = competitions_page_soup.find('ul', class_='areas')
countries_soup = competitions_page_soup.find_all('div', class_="row")
countries_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leagues_and_countries(source=utils.get_native_source):\n if not isinstance(source, games.models.Source):\n # If I used source=native_source() or if native_source was a global variable then\n # during db initialization (running command initialize) you would get an error since\n # it ... | [
"0.70956886",
"0.6197914",
"0.607584",
"0.59360814",
"0.5923666",
"0.58099824",
"0.5723477",
"0.57135236",
"0.5656138",
"0.56534845",
"0.5647318",
"0.5647285",
"0.56464356",
"0.56439775",
"0.5614668",
"0.5614668",
"0.55881184",
"0.55697626",
"0.5568917",
"0.5506007",
"0.54929... | 0.6228564 | 1 |
Add all teams in a league which doesn't exist in the DB to it. | def add_league_teams(league_diction, team_count, host, root, password):
teams_diction = scrape_teams(league_diction, team_count)
create_teams(host, root, password, dict_to_read=teams_diction)
return teams_diction | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_teams(self, data):\n for k, v in data.items():\n try:\n self._db_cur.execute(\"insert or ignore into team_data \\\n (team_id, team_name) values (?, ?)\", (v, k))\n self._db_conn.commit()\n except sqlite3.Error as er:\n ... | [
"0.6818083",
"0.6252091",
"0.6219382",
"0.589217",
"0.58345926",
"0.58333796",
"0.58290184",
"0.5785899",
"0.57341504",
"0.57333916",
"0.5699606",
"0.56956434",
"0.56849265",
"0.5651164",
"0.5634886",
"0.56297773",
"0.5575925",
"0.55408275",
"0.55124295",
"0.5452181",
"0.5450... | 0.64764833 | 1 |
Initialize a dictionary that will contain the metadata. | def init_meta():
meta = {}
meta["title"] = None
meta["authors"] = []
meta["date"] = None
meta["abstract"] = None
meta["notes"] = []
return meta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metadata(self):\n return {}",
"def initMetadata(self):\n\n if not 'flags' in self.metadata:\n\n self.metadata['flags'] = {}\n\n if not 'uidvalidity' in self.metadata:\n\n\n self.metadata['uidvalidity'] = random.randint(1000000, 9999999)\n\n if not 'uids' ... | [
"0.75047845",
"0.7474656",
"0.7414356",
"0.7339264",
"0.7337838",
"0.73160756",
"0.7288747",
"0.71932274",
"0.7176863",
"0.715695",
"0.71429217",
"0.7088457",
"0.7064578",
"0.7053004",
"0.6986673",
"0.6980293",
"0.6911412",
"0.6873568",
"0.6837764",
"0.682899",
"0.671761",
... | 0.7806081 | 0 |
Match URL against known URL formats for this repository of papers (e.g. URL for papers and/or landing pages). Return match object. | def match_url(self, url):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _match_url(self, _url):\n\n regex = re.compile(\n r'^(?:http|ftp)s?://' # http:// or https://\n r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|' # domain\n r'localhost|' # localhost\n r'\\d{1,3}\\.\\d{1... | [
"0.6157265",
"0.594759",
"0.5917867",
"0.58787566",
"0.58424425",
"0.5786022",
"0.56746024",
"0.56278706",
"0.5603191",
"0.5554448",
"0.5544937",
"0.5531292",
"0.54624885",
"0.5449005",
"0.5389851",
"0.5389752",
"0.53753614",
"0.5351463",
"0.5350919",
"0.53164864",
"0.5315264... | 0.6763665 | 0 |
Return normalized URL, assuming it matches a known URL format for this repository of papers. Return normalized URL. | def normalize_url(self, url):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalized_url(url):\r\n scheme, netloc, path, params, query, fragment = urlparse(url)\r\n\r\n # Exclude default port numbers.\r\n if scheme == 'http' and netloc[-3:] == ':80':\r\n netloc = netloc[:-3]\r\n elif scheme == 'https' and netloc[-4:] == ':443':\r\n ... | [
"0.6855667",
"0.68432397",
"0.6735049",
"0.66331047",
"0.6608784",
"0.6575851",
"0.65584445",
"0.6552749",
"0.6549481",
"0.6537265",
"0.64769214",
"0.6430751",
"0.63981295",
"0.6336849",
"0.63184595",
"0.62799007",
"0.62568545",
"0.6245693",
"0.6244802",
"0.6235218",
"0.62338... | 0.7057887 | 0 |
Entry point for starting an HTTP git server. | def main(config=None):
init = InitRepoPath(config)
listen_address, port = init.get_listen_address()
backend = DictBackend(init.get_backends())
app = make_wsgi_chain(backend)
server = make_server(listen_address, port, app,
handler_class=WSGIRequestHandlerLogger,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n host = ''\n port = 8088\n HTTPServer((host, port), HandleRequests).serve_forever()",
"def git_server():\n log('Instalando git', yellow)\n sudo('apt-get -y install git')",
"def main():\r\n LOG.info('Starting server build.')\r\n web.run_app(init_app(),\r\n host=o... | [
"0.7091706",
"0.70480895",
"0.66758436",
"0.66428643",
"0.65184426",
"0.65044636",
"0.64539856",
"0.64152414",
"0.631969",
"0.6310795",
"0.6310067",
"0.6309897",
"0.6301403",
"0.6270714",
"0.61036736",
"0.608633",
"0.60519946",
"0.60306233",
"0.60127413",
"0.59982204",
"0.599... | 0.75933325 | 0 |
The main point is find a good threshold that is the optimal split label. A good threshold is the threshold that minimize misclassification error. | def _find_threshold(self, feature, y_train, num_class):
assert len(num_class) == 2, "This function only assumes work with binary classification."
best_threshold = 0.0
max_exact_classification = 0.0
is_positive_negative = False
sorted_feature = sorted(np.unique(feature))
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_metric_threshold(self):\n logger.info(\"compute metric threshold\")\n\n ### Beaucoup trop lent quand on a beaucoup de models ###\n\n df_results_not_aggregated = self.result_reader.load_all_results(aggregate=False)\n\n if len(df_results_not_aggregated) == 0:\n logger.... | [
"0.67801523",
"0.6688665",
"0.6677787",
"0.65061504",
"0.645018",
"0.64142174",
"0.6409299",
"0.6338233",
"0.63270754",
"0.6305354",
"0.6278283",
"0.62284493",
"0.6212606",
"0.6212504",
"0.6205091",
"0.61867553",
"0.6158211",
"0.6140681",
"0.6089691",
"0.6088866",
"0.6082587"... | 0.68700206 | 0 |
Compute entropy each partition of specific feature in a given node. | def _entropy(self, feature, node):
entropy = 0
categories = np.unique(feature)
num_point = len(feature)
for category in categories:
# for each category in that feature
num_category = len(feature[feature == category])
for c in self.num_class:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entropy_feature(self, feature, df=None):\n if df is None:\n df = self.df\n target = self.target\n\n target_variables = df[target].unique()\n variables = df[feature].unique()\n entropy = 0\n\n # Aggregate entropy for each unique value in 'feature' feature... | [
"0.6836324",
"0.6772727",
"0.6772727",
"0.66967833",
"0.6569912",
"0.6569912",
"0.65580887",
"0.6530346",
"0.6457403",
"0.6431625",
"0.6368553",
"0.63630193",
"0.6301875",
"0.6297013",
"0.62775517",
"0.62715507",
"0.62592775",
"0.62461853",
"0.6226261",
"0.6225333",
"0.618254... | 0.78461814 | 0 |
Compute information gain between a node with that feature. | def _information_gain(self, feature, node):
return node.entropy() - self._entropy(feature, node) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy_gain(node,attribute):\n data_subset1 = filter_data(node.data,node.ancestors)\n data_counts = list(Counter(data_subset1['Class']).values())\n base_entropy = entropy(data_counts,base=2)\n num_values = len(data_subset1)\n entropy_sum = 0\n \n for value in [0,1]:\n data_subset2 ... | [
"0.6878586",
"0.6690411",
"0.65747595",
"0.65485966",
"0.64689696",
"0.6455205",
"0.6325612",
"0.62913805",
"0.62239647",
"0.61959743",
"0.61940885",
"0.61387944",
"0.6121174",
"0.61054665",
"0.60826224",
"0.6063609",
"0.5996675",
"0.59405375",
"0.59325457",
"0.59104127",
"0.... | 0.84394205 | 0 |
get mean, std and major frequency for a single time series | def get_time_series_stats(time_series):
return pd.Series([np.mean(time_series), np.std(time_series), get_frequency(time_series)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_analyze_time_series_std():\n\n statistics = analyze_time_series(np.ones(10))\n\n assert statistics.n_total_points == 10\n assert statistics.n_uncorrelated_points == 1\n assert np.isclose(statistics.statistical_inefficiency, 10.0)\n assert statistics.equilibration_index == 0",
"def Series... | [
"0.63931805",
"0.6212582",
"0.61890626",
"0.61378825",
"0.612101",
"0.60711044",
"0.6019158",
"0.58699524",
"0.58329415",
"0.58328384",
"0.58283913",
"0.58263576",
"0.58220524",
"0.58168924",
"0.58132654",
"0.5803837",
"0.5793796",
"0.5787034",
"0.57626736",
"0.5731403",
"0.5... | 0.72206175 | 0 |
break up time series into chunks and get time series stats for each | def break_and_get_stats(full_series, breaks):
n = len(breaks)
return pd.concat([get_time_series_stats(full_series[breaks[i]:breaks[i+1]]) for i in range(n-1)], axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_chunk_stats(self, args):\n iStart = args[0]\n iEnd = args[1]\n [start_date, end_date] = parse_start_end_date(None, None)\n print('Chunk %d - %d' %(iStart, iEnd)) # FIXME: TEST ONLY\n chunk_stats = self.components[iStart:iEnd]\n sym_list = self.components[iStart:iE... | [
"0.62124497",
"0.62107456",
"0.6032165",
"0.6029467",
"0.60025483",
"0.5973273",
"0.58360463",
"0.5779444",
"0.573043",
"0.56823605",
"0.5632646",
"0.5631443",
"0.56259614",
"0.56224453",
"0.5608115",
"0.5569298",
"0.55545145",
"0.55337185",
"0.5533596",
"0.5523319",
"0.54202... | 0.6821645 | 0 |
break up time series into chunks and get mean for each | def break_and_get_mean(full_series, breaks):
n = len(breaks)
return pd.Series([np.mean(full_series[breaks[i]:breaks[i+1]]) for i in range(n-1)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_means(arr, n):\n means = []\n for i in range(0, len(arr), n):\n means.append(np.mean(arr[i : i + n]))\n return means",
"def mean(series):\n return fsum(series) / len(series)",
"def daymean(x):\n return nstepf(x, 24, func='mean')",
"def split_by_interval(array, interval: int):\... | [
"0.6471262",
"0.62352437",
"0.6152543",
"0.6098485",
"0.6035611",
"0.59925014",
"0.5950393",
"0.59090394",
"0.5896033",
"0.5873036",
"0.58688504",
"0.5853194",
"0.5843164",
"0.58135355",
"0.5811944",
"0.5798107",
"0.5787635",
"0.5768644",
"0.57661927",
"0.5737312",
"0.5733862... | 0.6760139 | 0 |
Scales outputs to be from action min to action max | def scale_actions(self, actions): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_action(self, action: np.ndarray) -> np.ndarray:\n low, high = self.action_space.low, self.action_space.high\n return 2.0 * ((action - low) / (high - low)) - 1.0",
"def scale(self, state, action):\n control_action = action[..., : self._true_dim_action[0]]\n scale = super().sc... | [
"0.73590297",
"0.72091806",
"0.71684563",
"0.7003353",
"0.6765136",
"0.6575955",
"0.65628123",
"0.6436179",
"0.6347377",
"0.6303791",
"0.6247077",
"0.62256503",
"0.61939955",
"0.6152221",
"0.6135645",
"0.6094537",
"0.6066447",
"0.60465604",
"0.6009634",
"0.60020316",
"0.59917... | 0.75005263 | 0 |
Takes in a series of means and variances for the logged data of the state space Need this so the different states can be normalized to unit normal before passing into net | def set_statespace_normal(self, means, variances):
if means == [] and variances == []:
print("loading data distribution from the dynamics model")
self.state_means = self.dynam_model.scalarX_tensors_mean
self.state_vars = self.dynam_model.scalarX_tensors_var
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateMeanAndVar(X, log_gamma, varianceFloor=5.0):",
"def reparameterize(self, mean, logvar):\n if self.training:\n std = torch.exp(0.5 * logvar)\n # std = torch.zeros_like(mean) + 0.25\n eps = torch.randn_like(std)\n return mean + std * eps\n else:\n... | [
"0.633177",
"0.6291005",
"0.61961645",
"0.61756563",
"0.6090529",
"0.6065415",
"0.6040498",
"0.59970474",
"0.5996735",
"0.5990036",
"0.59628403",
"0.5940341",
"0.5930685",
"0.5929473",
"0.58963656",
"0.58864814",
"0.5882486",
"0.5876815",
"0.5867442",
"0.58599293",
"0.5850962... | 0.758573 | 0 |
merge git and bit repos and extract count information | def getMergedObj(self, git_team, git_repos, bit_repos):
code = 200
err = ""
merged = {}
languages = {}
public_count = git_team.get('public_repos', 0)
followers_count = git_team.get('followers', 0)
fork_count = 0
git_keys = ['fork', 'forks_count', 'watchers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gitStatistics(self):\n self.vcs.gitStatistics(self.project.getProjectPath())",
"def get_git_commiter_count(path):\n process = subprocess.Popen(['git', 'shortlog', '-sn'], cwd=path, stdout=subprocess.PIPE)\n stdout, _ = process.communicate()\n committers = stdout.decode(\"ISO-8859-1\")\n ... | [
"0.62743694",
"0.59985805",
"0.5849858",
"0.5814272",
"0.5812936",
"0.57753754",
"0.5728794",
"0.5617592",
"0.5600996",
"0.55920964",
"0.5562345",
"0.54946303",
"0.5492678",
"0.5465922",
"0.54608595",
"0.5435852",
"0.5432932",
"0.5418635",
"0.5418293",
"0.53994155",
"0.539421... | 0.66621345 | 0 |
fetch team information from bitbucket and git | def getMergedTeam(self):
response_obj = dict(
data="",
err="",
code=200
)
git_repos_data = []
bit_repos_data = []
GIT_TEAM_URI = config.GITHUB_API_ENDPOINT + "/orgs/{team_name}".format(team_name=self.team_name)
git_team_info = self._jso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_commits(): # pragma: no cover\n global commit_data\n all_commits = 0\n team = {\n 'stevex196x': 0,\n 'TheSchaft': 0,\n 'melxtru': 0,\n 'aylish19': 0,\n 'connormlewis': 0,\n 'tsukkisuki': 0\n }\n while all_commits == 0:\n url = 'https://api.gi... | [
"0.6490177",
"0.62863183",
"0.6233867",
"0.6118521",
"0.6044377",
"0.5923517",
"0.5899961",
"0.5893558",
"0.58813363",
"0.5877972",
"0.5859925",
"0.58368886",
"0.5832686",
"0.5759416",
"0.5752883",
"0.5711394",
"0.56964076",
"0.5665525",
"0.566056",
"0.56461406",
"0.56074584"... | 0.719228 | 0 |
This is a higher level function that send(). It sends a Msg to the specified user. If no address is specified, then the user's last used address (user.current_address) is used. | async def send_to_user(self, user: User, msg: Msg, address: str = None):
if address is None:
address = user.current_address
await self.send(msg, address) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_as_user(self, command, msg, user=None):\n user = self if user is None else user\n self._write(f':{user.ident} {command} {msg}')",
"def do_send_touser(self,customer_id,currency,amount):\n \"\"\"usage: send_touser customerID currency amount\"\"\"\n try:\n bitstamp.se... | [
"0.6948198",
"0.6436093",
"0.63397884",
"0.6205436",
"0.6199159",
"0.61925495",
"0.6088808",
"0.6087555",
"0.6080063",
"0.6040955",
"0.5998877",
"0.5942789",
"0.59125847",
"0.5907251",
"0.58854675",
"0.5878623",
"0.58739597",
"0.58509094",
"0.58420265",
"0.58088267",
"0.58082... | 0.86238986 | 0 |
Given a previous message old_msg, this function replies to it with the text in the text argument. | async def reply(self, old_msg: Msg, text: str):
if old_msg.direction == azurabot.msg.TO_BOT:
direction = azurabot.msg.FROM_BOT
else:
direction = azurabot.msg.TO_BOT
reply_msg = Msg(direction=direction,
user=old_msg.user,
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_something(incoming_msg):\n return \"i did what you said - {}\".format(incoming_msg.text)",
"def text_reply(msg):\n if msg['Type'] != TEXT:\n # sanitize the text field so that we can assume it always contains string.\n # and this is also to avoid infinite loop during serialization in th... | [
"0.6766925",
"0.6720746",
"0.63862306",
"0.6342622",
"0.61958545",
"0.6135881",
"0.611654",
"0.6096974",
"0.6047219",
"0.6044003",
"0.6026358",
"0.60032403",
"0.60032403",
"0.60032403",
"0.5950733",
"0.5946362",
"0.59281623",
"0.59240496",
"0.5913224",
"0.58990586",
"0.589404... | 0.789176 | 0 |
generate a translator function that will map from a 1hot repr of chord to a classical chord signature | def get_onehot2chordnotes_transcoder():
chord_id2sign = np.load('csv/chord-1hot-signatures-rev.npy')
def f(chord):
"""
Translate from 1-hot array of dim {DIM} back to superimposed repr of dim=12
:param chord: 1-hot representation of chords in (M, T, Dim)
:return: chord si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_onehot2weighted_chords_transcoder():\r\n chord_id2sign = np.load('csv/chord-1hot-signatures-rev.npy')\r\n\r\n def f(chord):\r\n \"\"\"\r\n Translate from 1-hot array of dim {DIM} back to superimposed repr of dim=12\r\n :param chord: 1-hot representation of chords in (M, T, Dim)\r... | [
"0.6614671",
"0.5769357",
"0.5698559",
"0.56645834",
"0.56529045",
"0.55155694",
"0.55034935",
"0.54679215",
"0.5425101",
"0.54120916",
"0.54120916",
"0.53971213",
"0.538774",
"0.5374609",
"0.5356483",
"0.53515774",
"0.53292423",
"0.5324584",
"0.5315523",
"0.52981585",
"0.526... | 0.6836312 | 0 |
generate a translator function that will map from a 1hot repr of chord to a classical chord signature | def get_onehot2weighted_chords_transcoder():
chord_id2sign = np.load('csv/chord-1hot-signatures-rev.npy')
def f(chord):
"""
Translate from 1-hot array of dim {DIM} back to superimposed repr of dim=12
:param chord: 1-hot representation of chords in (M, T, Dim)
:return: cho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_onehot2chordnotes_transcoder():\r\n chord_id2sign = np.load('csv/chord-1hot-signatures-rev.npy')\r\n\r\n def f(chord):\r\n \"\"\"\r\n Translate from 1-hot array of dim {DIM} back to superimposed repr of dim=12\r\n :param chord: 1-hot representation of chords in (M, T, Dim)\r\n ... | [
"0.68381053",
"0.57690674",
"0.5698061",
"0.56648403",
"0.56513613",
"0.5516458",
"0.5503976",
"0.546884",
"0.5425767",
"0.5412974",
"0.5412974",
"0.5397893",
"0.5389627",
"0.5374363",
"0.5356093",
"0.5352136",
"0.53298694",
"0.53236294",
"0.5316585",
"0.5300051",
"0.5264589"... | 0.66158575 | 1 |
Drop all dummy posts used during tests. | def tearDownClass(cls):
for post in cls.session.wp_post_objects:
cls.session.connection.call(DeletePost(post.id))
# Test cleanup() method to assert that all dummy test posts
# have been trashed and are dropped from database.
cls.session.cleanup()
# Assert that no it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n\n Post.query.delete()",
"def tearDown(self):\n db.drop_all()",
"def tearDown(self):\n db.drop_all()",
"def tearDown(self):\n\n User.query.delete()\n Blog.query.delete()",
"def tearDown(self):\n User.objects.all().delete()\n Project.objects... | [
"0.6742712",
"0.63928",
"0.63928",
"0.63647366",
"0.63469243",
"0.62678415",
"0.6257659",
"0.6196355",
"0.6166326",
"0.61662084",
"0.6144767",
"0.6108191",
"0.6105125",
"0.6013753",
"0.6013753",
"0.6013753",
"0.6013753",
"0.6013753",
"0.6013753",
"0.6013753",
"0.6013753",
"... | 0.6716512 | 1 |
The function rotate render the bitmap within the full image canvas and rotate the whole canvas with a given rotator (ImageRotator class object contain size of image and angle to rotate) | def rotate(self, rotator):
full_img_data = np.zeros(rotator.src_imsize + self.data.shape[2:], dtype=self.data.dtype)
full_img_data[
self.origin.row:(self.origin.row + self.data.shape[0]),
self.origin.col:(self.origin.col + self.data.shape[1]), ...] = self.data[:, :, ...]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(self, image, angle):\n tmpImage = pygame.transform.rotate(image ,angle)\n imageCentreX = tmpImage.get_rect()[0] + tmpImage.get_rect()[2]/2\n imageCentreY = tmpImage.get_rect()[1] + tmpImage.get_rect()[3]/2\n\n targetWidth = tmpImage.get_rect()[2]\n targetHeight = tmpIm... | [
"0.7114526",
"0.6855607",
"0.685048",
"0.6798645",
"0.67613417",
"0.6659643",
"0.66030043",
"0.6512459",
"0.64869493",
"0.64115447",
"0.6395608",
"0.63924265",
"0.63760424",
"0.63394535",
"0.6326849",
"0.63236195",
"0.63056964",
"0.6284121",
"0.62591845",
"0.6254835",
"0.6252... | 0.7153731 | 0 |
Crop the current MultichannelBitmap object with a given rectangle | def crop(self, rect):
maybe_cropped_area = self.to_bbox().crop(rect)
if len(maybe_cropped_area) == 0:
return []
else:
[cropped_area] = maybe_cropped_area
cropped_origin = PointLocation(row=cropped_area.top, col=cropped_area.left)
cropped_area_in_da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_rect(self, rect: 'pygame.Rect') -> 'BaseImage':\n self._surface = self.get_crop_rect(rect)\n return self",
"def crop(\n self,\n x: NumberType,\n y: NumberType,\n width: NumberType,\n height: NumberType\n ) -> 'BaseImage':\n self._surface = self.... | [
"0.70140654",
"0.69734436",
"0.6824329",
"0.6681341",
"0.6640309",
"0.6611977",
"0.656057",
"0.6558125",
"0.64772123",
"0.64610535",
"0.64189845",
"0.64062244",
"0.63840437",
"0.63834655",
"0.63748735",
"0.6367454",
"0.63590825",
"0.6340213",
"0.6340213",
"0.6328262",
"0.6312... | 0.7179569 | 0 |
Resize the current MultichannelBitmap to match a certain size | def resize(self, in_size, out_size):
scaled_origin, scaled_data = resize_origin_and_bitmap(self._origin, self._data, in_size, out_size)
return MultichannelBitmap(data=scaled_data, origin=scaled_origin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Rescale(self):\r\n picWidth,picHeight = self.oldSize = self.GetSizeTuple()\r\n bitmap = self.scaled = self.bitmap\r\n if not bitmap: return\r\n imgWidth,imgHeight = bitmap.GetWidth(),bitmap.GetHeight()\r\n if self.scaling == 2 or (self.scaling == 1 and (imgWidth > picWidth or... | [
"0.6741827",
"0.62626356",
"0.60623795",
"0.60617864",
"0.6012608",
"0.59815633",
"0.5941668",
"0.59120166",
"0.5884829",
"0.58750904",
"0.5854437",
"0.5848284",
"0.5848173",
"0.5843797",
"0.5824694",
"0.5809576",
"0.58015764",
"0.5798132",
"0.5786924",
"0.57853585",
"0.57687... | 0.73829323 | 0 |
The function base64_2_data convert base64 encoded string to numpy | def base64_2_data(s: str) -> np.ndarray:
saved_bytes = io.BytesIO(zlib.decompress(base64.b64decode(s)))
return np.load(saved_bytes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_base64(x):\n\treturn numpy.fromstring(\n\t\tbinascii.a2b_base64(x),\n\t\tdtype=numpy.uint8\n\t)",
"def base64_decode_array(inStr, dtype):\n return np.frombuffer(base64.decodestring(inStr), dtype=dtype)",
"def base64_to_numpy_image(b64: str) -> np.ndarray:\n image = np.array(Image.open(BytesIO(ba... | [
"0.8184459",
"0.79700077",
"0.7619043",
"0.754169",
"0.7244293",
"0.71252644",
"0.6947376",
"0.659718",
"0.6586803",
"0.65722215",
"0.65642273",
"0.6504433",
"0.64950395",
"0.6386613",
"0.63705456",
"0.63646716",
"0.63078606",
"0.62903976",
"0.62824816",
"0.62819695",
"0.6281... | 0.88050646 | 0 |
he function data_2_base64 convert numpy array to base64 encoded string | def data_2_base64(data: np.ndarray) -> str:
bytes_io = io.BytesIO()
np.save(bytes_io, data, allow_pickle=False)
return base64.b64encode(zlib.compress(bytes_io.getvalue())).decode('utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base64_encode_array(inArray):\n return base64.b64encode(inArray)",
"def _encode_base64(data: str) -> str:\n ebytes = base64.b64encode(data.encode(\"utf-8\"))\n estring = str(ebytes, \"utf-8\")\n return estring",
"def _encodeArray(self, array):\n\n # Actually, we want dtype,naxis,axNlen,b... | [
"0.7588745",
"0.7516981",
"0.7438014",
"0.7362127",
"0.7350758",
"0.7344294",
"0.7296927",
"0.72549736",
"0.7129535",
"0.7069589",
"0.70046437",
"0.6933189",
"0.689586",
"0.6836253",
"0.68321025",
"0.6796364",
"0.67913944",
"0.67715025",
"0.67699975",
"0.67620367",
"0.6727047... | 0.87411064 | 0 |
Returns a REST API source of ``Player`` data. It is assumed the REST API returns player data in the expected JSON format. | def get_rest_data_source(uri):
def players_from_rest():
response = requests.get(uri)
response.raise_for_status()
return parse_players_json(response.text)
return players_from_rest | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_info(player_name):\r\n\r\n api_url = api_url_base + player_name\r\n\r\n response = requests.get(api_url, headers=headers)\r\n\r\n if response.status_code >= 500:\r\n print('[!] [{0}] Server Error'.format(response.status_code))\r\n return None\r\n elif response.status_code =... | [
"0.6757945",
"0.6371991",
"0.6367396",
"0.6248512",
"0.6150757",
"0.6095749",
"0.60823464",
"0.6076938",
"0.6022456",
"0.6011816",
"0.60081345",
"0.5968988",
"0.59689283",
"0.5915473",
"0.59142816",
"0.5868256",
"0.5868256",
"0.5829394",
"0.57885414",
"0.5780477",
"0.5779154"... | 0.7371019 | 0 |
Returns a file source of ``Player`` data. It is assumed the file contains player data in the expected JSON format. | def get_file_data_source(filename):
def players_from_file():
with open(filename, 'r') as f:
json_str = '\n'.join(f.readlines())
return parse_players_json(json_str)
return players_from_file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_player_data(self, player_file):\n\n #read a single players file\n with open(self.player_path + player_file, 'r') as f:\n data = json.load(f)\n f.close()\n return(data)",
"def get_file(file):\n with open(file) as data_file:\n return json.load(data_file... | [
"0.7611685",
"0.615944",
"0.6125585",
"0.60973024",
"0.6078081",
"0.59851694",
"0.58206",
"0.5683008",
"0.5597726",
"0.55805624",
"0.5526197",
"0.55232203",
"0.552299",
"0.5507355",
"0.5463816",
"0.54605025",
"0.54236525",
"0.53874636",
"0.5384293",
"0.5369403",
"0.53625804",... | 0.8262929 | 0 |
Returns a generated source of ``Player`` data. Each generated player is assigned a random skill rating for skating, shooting, and checking between ``min_rating`` and ``max_rating``. | def get_generated_data_source(num_players, min_rating=DEFAULT_MIN_RATING, max_rating=DEFAULT_MAX_RATING):
return lambda: generate_players(num_players, min_rating, max_rating) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_player_data():\n names = [\"Gunther O'Brian\",\n 'Workman Gloom',\n 'Esme Ramsey',\n 'Cornelius Games',\n 'Kline Greenlemon',\n 'Hotbox Sato',\n 'Famous Owens',\n 'Jenkins Good']\n nums = [77, 31, 37, 6, 14, 53, 7, ... | [
"0.5868942",
"0.5538956",
"0.52820337",
"0.5259538",
"0.5210891",
"0.51927793",
"0.51602036",
"0.5145461",
"0.51008767",
"0.5097428",
"0.5094346",
"0.5041324",
"0.50287414",
"0.50021684",
"0.5001608",
"0.50004065",
"0.49834913",
"0.49777955",
"0.49602842",
"0.49199477",
"0.48... | 0.7219732 | 0 |
Return all of the links between two nodes in a topology | def getlinks2(topology, node1, node2):
allLinks = topology.loadResources({"resourceType":"Link"})
links = []
for l in allLinks:
(dstNode,dstPort) = linkednode2(l,node1)
if (dstNode,dstPort) == (None, None):
continue
(dstNode,dstPort) = linkednode2(l,node2)
if (dst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_links(self, node): # pragma: no cover\n\t\traise NotImplementedError",
"def get_links(node_tree, socket):\n return tuple(link for link in node_tree.links\n if (link.from_socket == socket or\n link.to_socket == socket))",
"def get_links(self) -> list:\n resu... | [
"0.68479264",
"0.67361224",
"0.66511023",
"0.6613033",
"0.6471993",
"0.6390997",
"0.63857716",
"0.6317723",
"0.6274998",
"0.6270319",
"0.62160325",
"0.6210695",
"0.6173468",
"0.61675924",
"0.6159017",
"0.61007774",
"0.60911804",
"0.6051444",
"0.60479224",
"0.59839463",
"0.598... | 0.80981374 | 0 |
In the following logical topology , the OSCARS circuits ends onto the port on the core router connected to the HwSwitch. This function returns the port on the HwSwitch that is connected to the the core router when the OSCARS circuit terminates. | def getgriport(topology,hwswitch,core,griport):
hwswitchname = hwswitch.resourceName
corename = core.resourceName
links = getlinks2(topology, corename, hwswitchname)
if links == None or len(links) == 0:
print "No links from",corename,"to",hwswitchname
return False
corelink = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_switch(self,host):\n switch_list = self.__graph_dict[host]\n switch_num = switch_list[0]\n return switch_num",
"def swconnect(localpop, remotepop, mac, vc, meter):\n core = Container.fromAnchor(localpop.properties['CoreRouter'])\n corename = core.resourceName\n (corename,cor... | [
"0.6056018",
"0.5864472",
"0.5744896",
"0.569074",
"0.5611226",
"0.5543881",
"0.55240554",
"0.54477835",
"0.5420691",
"0.5382262",
"0.5346929",
"0.5321753",
"0.528606",
"0.5251105",
"0.52226937",
"0.5214782",
"0.5148469",
"0.51428545",
"0.51317555",
"0.5099614",
"0.509746",
... | 0.6257958 | 0 |
Create entries on the local hardware switch that pass broadcast traffic to and from the connected host | def connecthostbroadcast(localpop,
hwport_tosite,
sitevlan,
meter=3,
broadcast_rewritemac = None):
hwswitch = Container.fromAnchor(localpop.properties['HwSwitch'])
hwswitchname = hwswitch.resourceName
swswit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hh_assign_ports():\n print('******* Assigning ports')\n for device in ci_addrs.switches_hh1:\n print ('******* Connecting to ', device.get('ip'))\n net_connect = ConnectHandler(**device)\n output_vlan_cp = net_connect.send_config_set(cp_hh1_config_commands)\n print (output... | [
"0.59532166",
"0.5937295",
"0.5799532",
"0.5706568",
"0.56275046",
"0.5578826",
"0.55391914",
"0.5535615",
"0.5502016",
"0.5501313",
"0.5489316",
"0.5470721",
"0.54283583",
"0.5427892",
"0.5426942",
"0.5419042",
"0.5402045",
"0.5376207",
"0.53679425",
"0.53496623",
"0.5347597... | 0.6400162 | 0 |
Create fanout entry on source POP's software switch | def connectentryfanoutmac(localpop,
hostmac,
hostvlan,
forwards,
meter,
mac):
hwswitch = Container.fromAnchor(localpop.properties['HwSwitch'])
hwswitchname = hwswitch.resourceName
swswitch = Co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connectexitfanout(localpop,\n corevlan,\n forwards,\n meter,\n mac):\n\n hwswitch = Container.fromAnchor(localpop.properties['HwSwitch'])\n hwswitchname = hwswitch.resourceName\n swswitch = Container.fromAnchor(loc... | [
"0.5853953",
"0.56127334",
"0.5453903",
"0.53140277",
"0.5251082",
"0.52267796",
"0.5201543",
"0.51840484",
"0.5074265",
"0.5068683",
"0.50396186",
"0.5023897",
"0.5015812",
"0.49987084",
"0.49089834",
"0.49046764",
"0.48974884",
"0.48914778",
"0.48834187",
"0.48745808",
"0.4... | 0.6274215 | 0 |
Create exit fanout flow on software switch of a destination POP. This handles broadcast traffic before it exits the network | def connectexitfanout(localpop,
corevlan,
forwards,
meter,
mac):
hwswitch = Container.fromAnchor(localpop.properties['HwSwitch'])
hwswitchname = hwswitch.resourceName
swswitch = Container.fromAnchor(localpop.propert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_inner_dp_join(self, dp):\n ofp = dp.ofproto\n parser = dp.ofproto_parser\n\n #Deletion of already existing OF flows\n LOG.debug('TOPO MNGR: Deleting flow table configuration of newly added forwarder ID: ' + str(dp.id) )\n dp.send_msg(parser.OFPFlowMod(datapath=dp, command=... | [
"0.5967594",
"0.5906457",
"0.56219417",
"0.5474351",
"0.5386218",
"0.53010625",
"0.52660906",
"0.52272975",
"0.5142328",
"0.5108621",
"0.50874406",
"0.5077897",
"0.506066",
"0.49685788",
"0.4954655",
"0.49296337",
"0.4854221",
"0.48277456",
"0.48222342",
"0.47977006",
"0.4785... | 0.67179614 | 0 |
Make a Java array of bytes from unsigned bytes in Python. Note that Java bytes are signed, whereas in Python they may be either signed or unsigned. | def javaByteArray(a):
b = jarray.zeros(len(a), 'b')
for i in range(len(a)):
b[i] = struct.unpack('b', struct.pack('B', a[i]))[0]
return b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def javaByteArray2(s):\n a = array.array('B', binascii.unhexlify(s))\n return javaByteArray(a)",
"def decode_u8_array(as_bytes: typing.List[int]) -> typing.List[int]:\n raise NotImplementedError()",
"def decode_byte_array(as_bytes: typing.List[int]) -> bytes:\n return bytes(as_bytes)",
"def bytif... | [
"0.7003046",
"0.6871421",
"0.6711044",
"0.6243507",
"0.61276656",
"0.61108124",
"0.6078007",
"0.60172135",
"0.5982723",
"0.59610796",
"0.5933144",
"0.59135413",
"0.5878097",
"0.583533",
"0.57353103",
"0.5725388",
"0.5707536",
"0.5652822",
"0.56485355",
"0.56485355",
"0.561504... | 0.7075934 | 0 |
Starting the robot in new thread | def _worker(self, robot_id):
robot = Robot(self, rid=robot_id, scroll_times=3)
self.robots.update({robot_id: robot})
d('Starting ROBO_%s' % str(robot_id))
robot.start()
d('End of robot_thread %s ' % str(robot_id))
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n self.thread.start()",
"def start(self):\n self._setup_thread()\n self.thread.start()",
"def runRobot():",
"def start(self):\n self._thread.start()",
"def __init__(self):\n Thread.__init__(self)\n self.start()",
"def __init__(self):\n Thr... | [
"0.72708154",
"0.71561426",
"0.7082271",
"0.70204693",
"0.6998391",
"0.6998391",
"0.69400173",
"0.6863858",
"0.68171334",
"0.6799912",
"0.67390585",
"0.6717737",
"0.66612923",
"0.663221",
"0.6610315",
"0.6556348",
"0.654235",
"0.6528905",
"0.646403",
"0.64595586",
"0.6442346"... | 0.7174281 | 1 |
checks status of query job, and returns result id if successfull | def _poll_for_new_result(session, job):
while job['status'] not in (3, 4):
response = session.get('{}/api/jobs/{}'.format(REDASH_HOST, job['id']))
job = response.json()['job']
time.sleep(POLL_INTERVAL)
if job['status'] == 3:
return job['query_result_id']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_result(job_id):\n result = _database_operations.get_results(job_id, Session())\n if result is None:\n flask.abort(404)\n else:\n return result",
"def _check_job_status(self) -> str:\n self._assert_job_created()\n\n r = requests.post(\n f'https://{cc.ROU... | [
"0.65486574",
"0.6471142",
"0.6466445",
"0.6453059",
"0.6433005",
"0.6426885",
"0.63764495",
"0.6318302",
"0.62912136",
"0.62787354",
"0.6262894",
"0.62122035",
"0.6210269",
"0.6176431",
"0.61736745",
"0.6141012",
"0.6130964",
"0.6082434",
"0.6055645",
"0.6053044",
"0.6048456... | 0.7408653 | 0 |
Check for endpoint relative position and overlap. Used in scan_P__(). | def comp_edge(_P, P): # Used in scan_P_().
_x0 = _P['x0']
_xn = _x0 + _P['L']
x0 = P['x0']
xn = x0 + P['L']
if _xn < xn: # End-point relative position.
return True, x0 < _xn # Overlap.
else:
return False, _x0 < xn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _in_bounds(self, x, y):\r\n return 0 <= x < 8 and 0 <= y < 8",
"def is_valid_overlap_xy(dir_id, p1, p2, pattern_catalog, pattern_width, adjacency_directions):\n #dir_corrected = (0 - adjacency_directions[dir_id].x, 0 - adjacency_directions[dir_id].y)\n dir_corrected = (0 + adjacency_directions[d... | [
"0.6494828",
"0.61780626",
"0.61478144",
"0.61463255",
"0.61320376",
"0.6116703",
"0.61136043",
"0.6108635",
"0.60967755",
"0.606722",
"0.60669786",
"0.6033708",
"0.6022681",
"0.60138786",
"0.6001213",
"0.5966237",
"0.59654135",
"0.59575963",
"0.59564316",
"0.5953769",
"0.592... | 0.6398601 | 1 |
Cluster P vertically, stop at the end of segment | def cluster_vertical(P): # Used in form_segment_().
if len(P['down_fork_']) == 1 and len(P['down_fork_'][0]['up_fork_']) == 1:
down_fork = P.pop('down_fork_')[0] # Only 1 down_fork.
down_fork.pop('up_fork_') # Only 1 up_fork.
down_fork.pop('y')
down_fork.pop('sign')
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_clusters(self, p: float):\n pass",
"def compute_clusters(self, p: float):\n w = self.w\n h = self.h\n self.p = p\n self.sample = self._get_sample(p)\n self.cluster = np.zeros((w + 1, h + 1), dtype=int)\n visited = np.full((w + 1, h + 1), False)\n ... | [
"0.64368105",
"0.6374936",
"0.634104",
"0.60059184",
"0.58162886",
"0.5787876",
"0.57370514",
"0.5631855",
"0.5605895",
"0.55195105",
"0.5509005",
"0.54823226",
"0.54415303",
"0.54227644",
"0.54128027",
"0.5396293",
"0.53785056",
"0.536136",
"0.5358855",
"0.5355567",
"0.53385... | 0.7829764 | 0 |
Form blobs from given list of segments. Each blob is formed from a number of connected segments. | def form_blob_(seg_, root_fork):
# Determine params type:
if 'M' not in seg_[0]: # No M.
Dert_keys = (*aDERT_PARAMS[:2], *aDERT_PARAMS[3:], "S", "Ly")
else:
Dert_keys = (*aDERT_PARAMS, "S", "Ly") if nI != 1 \
else (*gDERT_PARAMS, "S", "Ly")
# Form blob:
blob_ = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_segments(self):\n for strand in self.strand_list:\n strand.construct_segment()",
"def create_from_segments(self, segment, origin=0):\r\n n = origin\r\n if segment[origin]['T'] != 'soma': # if it's a soma, only one compartment\r\n while (len(segment[n]['chi... | [
"0.6240448",
"0.573545",
"0.5672107",
"0.56235355",
"0.55338395",
"0.5473892",
"0.54547447",
"0.5373943",
"0.5372714",
"0.52542466",
"0.5249314",
"0.52047896",
"0.51399314",
"0.51182914",
"0.51067835",
"0.50957716",
"0.5091512",
"0.5088217",
"0.5078772",
"0.50569415",
"0.5052... | 0.58002687 | 1 |
Sets the upgrade_time of this NextUpgradeInfo. | def upgrade_time(self, upgrade_time):
self._upgrade_time = upgrade_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upgrade_time_epoch(self, upgrade_time_epoch):\n\n self._upgrade_time_epoch = upgrade_time_epoch",
"def update_time(self, update_time):\n\n self._update_time = update_time",
"def mod_time(self, mod_time):\n\n self._mod_time = mod_time",
"def mod_time(self, mod_time):\n\n self._... | [
"0.6725681",
"0.62003857",
"0.5695385",
"0.5695385",
"0.55752087",
"0.55294573",
"0.54945123",
"0.5405532",
"0.5399842",
"0.5302209",
"0.52906084",
"0.52381265",
"0.5231574",
"0.5231574",
"0.5231574",
"0.5231574",
"0.5231574",
"0.52093667",
"0.5196944",
"0.51616",
"0.50660056... | 0.8613101 | 0 |
Sets the stable of this NextUpgradeInfo. | def stable(self, stable):
self._stable = stable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stable():\n env.branch = 'stable'",
"def get_stable(self: _R) -> _R:\n return self._replace(\n BaseVersion(\n epoch=0,\n release=(self.major, self.minor, self.micro),\n pre=None,\n post=None,\n dev=None,\n ... | [
"0.62132746",
"0.574145",
"0.5200357",
"0.5139811",
"0.51368827",
"0.50893146",
"0.48866063",
"0.48249158",
"0.46558702",
"0.46255958",
"0.46187514",
"0.46168604",
"0.46053055",
"0.4556065",
"0.45172706",
"0.45138413",
"0.4506797",
"0.45026952",
"0.4471989",
"0.4469258",
"0.4... | 0.7988852 | 0 |
Sets the major_version of this NextUpgradeInfo. | def major_version(self, major_version):
self._major_version = major_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _major_version(self):\n version_tuple = StrictVersion(self.plugin.version).version\n major = '.'.join(map(str, version_tuple[:2]))\n\n return major",
"def minor_version(self, minor_version):\n\n self._minor_version = minor_version",
"def minor_version(self, minor_version):\n\n ... | [
"0.6609667",
"0.64588195",
"0.64588195",
"0.6412141",
"0.64004534",
"0.6383321",
"0.63680845",
"0.62749135",
"0.62064695",
"0.617141",
"0.6109517",
"0.60880303",
"0.6085801",
"0.60802436",
"0.6033241",
"0.5941284",
"0.5857889",
"0.57498246",
"0.5686118",
"0.56828374",
"0.5679... | 0.826978 | 0 |
Sets the minor_version of this NextUpgradeInfo. | def minor_version(self, minor_version):
self._minor_version = minor_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operatingsystem_version_minor(self, operatingsystem_version_minor):\n # type: (string_types) -> None\n\n if operatingsystem_version_minor is not None:\n if not isinstance(operatingsystem_version_minor, string_types):\n raise TypeError(\"Invalid type for `operatingsystem_... | [
"0.6780061",
"0.6694908",
"0.6519205",
"0.6498734",
"0.6280392",
"0.62734467",
"0.6271302",
"0.59974277",
"0.58754146",
"0.5872266",
"0.5872266",
"0.5766906",
"0.57591933",
"0.57591933",
"0.57591933",
"0.57591933",
"0.5721738",
"0.5721738",
"0.5715131",
"0.5521791",
"0.547740... | 0.8593409 | 0 |
Sets the mandatory of this NextUpgradeInfo. | def mandatory(self, mandatory):
self._mandatory = mandatory | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required(self, required):\n\n self._required = required",
"def required(self, required):\n\n self._required = required",
"def required(self, required):\n\n self._required = required",
"def required(self, required):\n\n self._required = required",
"def explicitly_required(sel... | [
"0.6098085",
"0.6098085",
"0.6098085",
"0.6098085",
"0.5943629",
"0.5823603",
"0.5807848",
"0.57494354",
"0.5626224",
"0.55867773",
"0.54788595",
"0.53794473",
"0.53619933",
"0.5344923",
"0.53359044",
"0.52371824",
"0.5211088",
"0.51647735",
"0.5157812",
"0.51299804",
"0.5129... | 0.72124577 | 0 |
Sets the upgrade_time_epoch of this NextUpgradeInfo. | def upgrade_time_epoch(self, upgrade_time_epoch):
self._upgrade_time_epoch = upgrade_time_epoch | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upgrade_time(self, upgrade_time):\n\n self._upgrade_time = upgrade_time",
"def set_epoch(self, epoch=None):\n params = {'epoch': epoch if epoch is not None else int(time.time())}\n return self._jadeRpc('set_epoch', params)",
"def set_epoch(self, epoch):\n self.epoch = epoch",
... | [
"0.71056724",
"0.58541226",
"0.58303434",
"0.56607425",
"0.5544668",
"0.55109674",
"0.5417715",
"0.5276821",
"0.5267726",
"0.5082459",
"0.5068214",
"0.5068214",
"0.50546193",
"0.50347763",
"0.5013292",
"0.4975316",
"0.49132764",
"0.49092776",
"0.48097897",
"0.47805026",
"0.47... | 0.85634923 | 0 |
Given a node (as an input or as a neuron), a dictionary mapping input names to their values, and a dictionary mapping neuron names to their outputs returns the output value of the node. This function does NOT do any computation; it simply looks up values in the provided dictionaries. | def node_value(node, input_values, neuron_outputs): # PROVIDED BY THE STAFF
if isinstance(node, str):
# A string node (either an input or a neuron)
if node in input_values:
return input_values[node]
if node in neuron_outputs:
return neuron_outputs[node]
raise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_output_and_node(cls, onnx_model: onnx.ModelProto):\n output2node = dict()\n for node in onnx_model.graph.node:\n for output_name in node.output:\n output2node[output_name] = node\n return output2node",
"def _lookup_input(nodes, name, value, definition):\n ... | [
"0.63742995",
"0.5989175",
"0.587564",
"0.5840289",
"0.58103305",
"0.5776675",
"0.5659506",
"0.5615959",
"0.559921",
"0.556679",
"0.5563925",
"0.55307496",
"0.54789686",
"0.54659796",
"0.54319817",
"0.5390829",
"0.53307354",
"0.5327316",
"0.5283891",
"0.52830815",
"0.52765304... | 0.7839648 | 0 |
Given a neural net and dictionary of input values, performs forward propagation with the given threshold function to compute binary output. | def forward_prop(net, input_values, threshold_fn=stairstep):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(inputs,weights,function=sigmoid,step=-1):\n if step == 0:\n return inputs\n elif step == -1:\n step = len(weights) #go to output layer \n output = np.append(1, inputs)\n for i in range(step):\n output = np.append(1, function(np.dot(weights[i], output))) #calculating ac... | [
"0.6250236",
"0.60710454",
"0.5927202",
"0.589811",
"0.58545476",
"0.57951117",
"0.5756987",
"0.57506436",
"0.5733161",
"0.57154197",
"0.57070035",
"0.57040226",
"0.5698928",
"0.5695584",
"0.5671023",
"0.5650407",
"0.5640358",
"0.5620086",
"0.56128013",
"0.560631",
"0.5605319... | 0.76103055 | 0 |
Given an unknown function of three variables and a list of three values representing the current inputs into the function, increments each variable by +/ step_size or 0, with the goal of maximizing the function output. | def gradient_ascent_step(func, inputs, step_size):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step_4(f: Callable[..., float], x: float, y: np.array, params: Tuple,\\\n h: float, k3: np.array) -> np.array:\n\n # Initialize the output vector.\n n = len(y)\n y_int = np.zeros(n)\n\n # Find dym/dx using the given function, then use it to compute dym-1/dx.\n y_int[0] = f(x + h, y + k3, *par... | [
"0.5863381",
"0.5583114",
"0.5476102",
"0.54370964",
"0.53885406",
"0.53238237",
"0.5317676",
"0.5294501",
"0.5279447",
"0.5264133",
"0.52436185",
"0.5241336",
"0.52220637",
"0.5213319",
"0.5204717",
"0.5185854",
"0.5183404",
"0.5178885",
"0.51723236",
"0.5156619",
"0.5156295... | 0.5839692 | 1 |
Retruns repository url from Cekit config files repositories section | def _get_repo_url(self, descriptor):
configured_repositories = config.get('repositories')
# We need to remove the custom "__name__" element before we can show
# which repository keys are defined in the configuration
configured_repository_names = configured_repositories.keys()
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo_url(self):\n return self._repo_url",
"def _get_config(repository, config):\n confp = ConfigParser()\n for config_path in CONF_LOCATIONS:\n confp.read(config_path / 'config.ini')\n\n local_config = Path(repository) / 'cricic/config.ini'\n confp.read(local_config)\n confp.read... | [
"0.68390673",
"0.6761129",
"0.6745644",
"0.67428726",
"0.6676351",
"0.6610542",
"0.6607609",
"0.65621877",
"0.6534249",
"0.6315402",
"0.6299453",
"0.6285862",
"0.62839335",
"0.62542546",
"0.6166379",
"0.61340797",
"0.61335737",
"0.6127935",
"0.611482",
"0.61136746",
"0.611214... | 0.749481 | 0 |
Solver for 1D diffusion equations with constant diffusion coefficent and | def diffusion_solver(I, alpha=1, L=1, Nx=11, T=1, F=0.5, udim='1D'):
assert alpha > 0, f'Diffusion coefficient alpha must be greater than 0'
assert F <= 0.5, \
f'Stability criterion F=alpha*dt/dx**2 <= 0.5 not satisfied with F={F}'
x = np.linspace(0, L, Nx + 1) # mesh points in space
dx =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_ufl_equations_diff(self):\n\n # Derivatives of velocity integration equation.\n if self.f1 != 0:\n self.df1_du = dlf.derivative(self.f1, self.displacement, self.trial_vector)\n self.df1_dv = dlf.derivative(self.f1, self.velocity, self.trial_vector)\n else:\n ... | [
"0.6330036",
"0.6144398",
"0.60684615",
"0.6064849",
"0.6052447",
"0.6048306",
"0.6007914",
"0.59658027",
"0.59391546",
"0.5922955",
"0.58881867",
"0.58848006",
"0.58755314",
"0.5860544",
"0.585488",
"0.585488",
"0.5840503",
"0.5813928",
"0.58136034",
"0.58136034",
"0.5794688... | 0.67087233 | 0 |
Return a Euca2ool Object | def __init_euca(self):
if self.euca:
return
self.euca = Euca2ool() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createCasaTool(mytool):\n if (type(casac.Quantity) != type): # casa 4.x\n myt = mytool()\n else: # casa 3.x\n myt = mytool.create()\n return(myt)",
"def exo2():",
"def Au():\n return load_material(miepy.__path__[0] + \"/materials/au.dat\")",
"def __init__(self):\n self.... | [
"0.5496832",
"0.5192484",
"0.51200885",
"0.50912255",
"0.5090922",
"0.50232905",
"0.500518",
"0.4990415",
"0.49752933",
"0.49743345",
"0.4944218",
"0.49384177",
"0.49251083",
"0.49192965",
"0.48852822",
"0.48561084",
"0.48528242",
"0.48424453",
"0.48358312",
"0.4827221",
"0.4... | 0.7435938 | 0 |
Validate one or more instance ids | def __validate_instance_id(self, instance_ids):
try:
if instance_ids:
for id in instance_ids:
self.euca.validate_instance_id(id)
except InstanceValidationError:
sys.exit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_instance_bundles(instance_bundles, mode):\n for bundle in instance_bundles:\n if mode in ['ssh', 'sftp']:\n if not INSTANCE_ID_RE.match(bundle['instance_id']):\n raise AssertionError('Missing instance_id')",
"def check_validity_of_ids(self, user_inputs, db_ids, m... | [
"0.66104805",
"0.63021135",
"0.6231086",
"0.6120488",
"0.608665",
"0.6085082",
"0.5961724",
"0.5956122",
"0.5913075",
"0.58599216",
"0.5846487",
"0.584379",
"0.58395326",
"0.5822834",
"0.5817616",
"0.57512295",
"0.5728121",
"0.57224673",
"0.57157797",
"0.56912893",
"0.566695"... | 0.83329064 | 0 |
Validate instance_ids and get reservations deployed | def __get_reservations(self, instance_ids=None):
if instance_ids:
self.__validate_instance_id(instance_ids)
euca_conn = self.__make_connection()
try:
return euca_conn.get_all_instances(instance_ids)
except:
euca.display_error_and_exit('%s' % ex)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_multi_instances(self, reservations, instance_ids=None, policies=None):\n check_instance_ids = False\n if ( instance_ids and len(instance_ids) > 0 ):\n check_instance_ids = True\n instances = [] \n for reservation in reservations:\n if check_instanc... | [
"0.688962",
"0.67898965",
"0.64505816",
"0.6446688",
"0.6443735",
"0.6300012",
"0.6249685",
"0.62233186",
"0.61486757",
"0.6136195",
"0.6116925",
"0.60838884",
"0.60401386",
"0.6009709",
"0.6004771",
"0.5986708",
"0.59733444",
"0.59473145",
"0.5845798",
"0.5832438",
"0.581583... | 0.7164238 | 0 |
Get Reservations ids deployed | def get_reservations_ids(self, instance_ids=None):
reservations = self.__get_reservations(instance_ids)
reservations_ids = []
for reservation in reservations:
reservations_ids.append(reservation.id.encode("latin-1"))
return reservations_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instances_ids(self):\n reservations = self.__get_reservations()\n instances_ids = []\n instances,_ = self.__get_multi_instances(reservations)\n for instance in instances:\n instances_ids.append(instance.id.encode(\"latin-1\"))\n return instances_ids",
"def ge... | [
"0.6664405",
"0.6625137",
"0.6480203",
"0.60759157",
"0.5999064",
"0.5983193",
"0.59796596",
"0.5953766",
"0.5928444",
"0.5895583",
"0.585223",
"0.57362765",
"0.57356167",
"0.5665165",
"0.56505793",
"0.5645751",
"0.5641092",
"0.56102735",
"0.55491316",
"0.55278045",
"0.552573... | 0.6637255 | 1 |
Compare and return if exist one instance equal some policies (cpu, ram, disk) | def __compare_types_instances(self, policies, instance_type):
zones = availabilityZones()
types_ins = zones.get_typevm_zones()
if ( types_ins[instance_type]['cpu'] == policies['cpu'] and
types_ins[instance_type]['ram'] == policies['ram'] and
types_ins[instance_type]['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_adaptive_instance(self, policies, instance_type):\n zones = availabilityZones()\n typevms = zones.get_typevm_zones()\n if ( typevms[instance_type]['cpu'] >= policies['cpu_min'] and typevms[instance_type]['cpu'] <= policies['cpu_max'] and\n typevms[instance_type]['... | [
"0.66594005",
"0.5957029",
"0.58745104",
"0.5764576",
"0.57531226",
"0.55842274",
"0.5541506",
"0.5485973",
"0.53717875",
"0.5304936",
"0.5302708",
"0.5281764",
"0.5257215",
"0.522992",
"0.51905346",
"0.51892805",
"0.5180331",
"0.5180251",
"0.5165421",
"0.51497835",
"0.512592... | 0.7060165 | 0 |
Return true if is possible adapt the instance_type for the policies | def __is_adaptive_instance(self, policies, instance_type):
zones = availabilityZones()
typevms = zones.get_typevm_zones()
if ( typevms[instance_type]['cpu'] >= policies['cpu_min'] and typevms[instance_type]['cpu'] <= policies['cpu_max'] and
typevms[instance_type]['ram'] >=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __compare_types_instances(self, policies, instance_type):\n zones = availabilityZones()\n types_ins = zones.get_typevm_zones()\n\n if ( types_ins[instance_type]['cpu'] == policies['cpu'] and\n types_ins[instance_type]['ram'] == policies['ram'] and\n types_ins[insta... | [
"0.66462946",
"0.6631519",
"0.6285129",
"0.61954254",
"0.61424285",
"0.61359036",
"0.600172",
"0.5945884",
"0.5918538",
"0.59132266",
"0.5857154",
"0.5843552",
"0.58333933",
"0.56642264",
"0.56641996",
"0.56546956",
"0.56274027",
"0.56115484",
"0.56003535",
"0.55908203",
"0.5... | 0.7656916 | 0 |
Find and return true and the instance_type true according policies | def __find_adaptive_image(self, policies):
instances_types = INSTANCE_TYPES;
if policies['level'] == 1:
for instance_type in instances_types:
if self.__compare_types_instances( policies, instance_type ):
return True, instance_type
elif policies['le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __compare_types_instances(self, policies, instance_type):\n zones = availabilityZones()\n types_ins = zones.get_typevm_zones()\n\n if ( types_ins[instance_type]['cpu'] == policies['cpu'] and\n types_ins[instance_type]['ram'] == policies['ram'] and\n types_ins[insta... | [
"0.6889342",
"0.6853335",
"0.6505152",
"0.59607524",
"0.59246886",
"0.5916552",
"0.57527685",
"0.57044965",
"0.5672798",
"0.56674916",
"0.5656137",
"0.5563012",
"0.5509639",
"0.5452389",
"0.540743",
"0.5406744",
"0.54066825",
"0.54032224",
"0.5387874",
"0.53858787",
"0.536427... | 0.71402055 | 0 |
Return all instances ids | def get_instances_ids(self):
reservations = self.__get_reservations()
instances_ids = []
instances,_ = self.__get_multi_instances(reservations)
for instance in instances:
instances_ids.append(instance.id.encode("latin-1"))
return instances_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_instance_ids(instances):\n instance_ids = []\n for instance in instances:\n instance_ids.append(instance.id)\n return instance_ids",
"def get_ids(self, instances):\n instance_ids = []\n for instance in instances:\n instance_ids.append(instance.id)\n return instance_... | [
"0.8507518",
"0.83568853",
"0.7767982",
"0.7608295",
"0.74277884",
"0.7245206",
"0.7245206",
"0.71949583",
"0.7122765",
"0.7118952",
"0.707014",
"0.70677406",
"0.7018259",
"0.6999699",
"0.6988456",
"0.6983812",
"0.69503725",
"0.6898317",
"0.68574446",
"0.676398",
"0.67505455"... | 0.8676883 | 0 |
Return the total number of instances | def get_num_instances(self):
return len( self.get_instances_ids() ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_count(self) -> int:\n return pulumi.get(self, \"instance_count\")",
"def total_size(instance):\n return sum(i.size for i in instance.iter_instances())",
"def instance_count(self) -> pulumi.Output[Optional[int]]:\n return pulumi.get(self, \"instance_count\")",
"def retrieve_num_i... | [
"0.85416496",
"0.8332706",
"0.80736727",
"0.7749521",
"0.76511467",
"0.76511467",
"0.75533694",
"0.75408304",
"0.7379059",
"0.7302489",
"0.72858953",
"0.7279924",
"0.7279924",
"0.7279924",
"0.7279924",
"0.7277189",
"0.7227607",
"0.7180085",
"0.7153769",
"0.7115572",
"0.711445... | 0.84645474 | 1 |
Get one image id | def __get_image_id(self):
return self.__get_multi_images_ids(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"image_id\")",
"def image_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"image_id\")",
"def get_image_id(filename):\n del filename\n global GLOBAL_IMG_ID\n GLOBAL_IMG_ID += 1\n return GLOBAL_IMG_ID",
"... | [
"0.78510964",
"0.78510964",
"0.78145814",
"0.77161556",
"0.7650705",
"0.7650705",
"0.7648366",
"0.7648366",
"0.7603875",
"0.7390626",
"0.73811406",
"0.73773754",
"0.7275588",
"0.72276074",
"0.71651524",
"0.7130926",
"0.7123816",
"0.7108411",
"0.7017009",
"0.7016007",
"0.70152... | 0.814898 | 0 |
Return true if the image_id is registered | def __is_image_id( self, image_id ):
images_ids = self.__get_multi_images_ids()
for id in images_ids:
if image_id == id:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_image(self, tag):\n image_name = self.build_image_name(tag)\n try:\n self.client.images.get_registry_data(image_name)\n return True\n except Exception as ex:\n print('Image {} does not exist: '.format(image_name), str(ex))\n return False",
... | [
"0.72950876",
"0.71553874",
"0.69728947",
"0.6842381",
"0.67704",
"0.6737884",
"0.67175126",
"0.67107576",
"0.6646041",
"0.64513296",
"0.6427297",
"0.64015955",
"0.6368361",
"0.63507783",
"0.63206196",
"0.6298749",
"0.628413",
"0.62777007",
"0.6260048",
"0.6255963",
"0.617897... | 0.7375224 | 0 |
Return true if the instace type exist | def __is_type_instance( self, instance_type ):
for index, instance in enumerate(INSTANCE_TYPES):
if instance == instance_type:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_unique_instance(type_):\n return type_ in unique_instance_types",
"def is_registered(self, type):\n attr = self._type_to_attr(type)\n return getattr(self, attr, None) is not None",
"def _isinstancetype(an_obj):\n if an_obj is None: return False\n if not PY3K:\n return is... | [
"0.7270652",
"0.71896994",
"0.702901",
"0.68987685",
"0.6777073",
"0.67513824",
"0.6712662",
"0.66715205",
"0.66715205",
"0.6631957",
"0.66299903",
"0.6596198",
"0.6541169",
"0.6444942",
"0.64414465",
"0.6440417",
"0.64149344",
"0.63910496",
"0.6367319",
"0.6320373",
"0.63114... | 0.7339385 | 0 |
Get one Image Id, Type of Instance and State according some policies(requirements) | def __verify_policies( self, policies ):
image_id = ''
instance_type=''
if type(policies) == type(str()):
if self.__is_type_instance( policies ):
instance_type = policies
state = True
elif self.__is_image_id( policies ):
ima... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __find_adaptive_image(self, policies):\n instances_types = INSTANCE_TYPES;\n if policies['level'] == 1:\n for instance_type in instances_types:\n if self.__compare_types_instances( policies, instance_type ):\n return True, instance_type\n elif p... | [
"0.6219611",
"0.57743716",
"0.5763096",
"0.57555014",
"0.5749443",
"0.56019837",
"0.55169725",
"0.54476464",
"0.54437417",
"0.5438611",
"0.54333144",
"0.54257226",
"0.5425297",
"0.54199284",
"0.538957",
"0.5378725",
"0.53651994",
"0.535963",
"0.5358915",
"0.5342345",
"0.53194... | 0.68623555 | 0 |
Return ids from instances | def get_ids(self, instances):
instance_ids = []
for instance in instances:
instance_ids.append(instance.id)
return instance_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_instance_ids(instances):\n instance_ids = []\n for instance in instances:\n instance_ids.append(instance.id)\n return instance_ids",
"def get_instances_ids(self):\n reservations = self.__get_reservations()\n instances_ids = []\n instances,_ = self.__get_multi_instances(reserva... | [
"0.85830265",
"0.8202876",
"0.77256346",
"0.7455178",
"0.7383215",
"0.73242325",
"0.70874155",
"0.70678616",
"0.70521647",
"0.7050327",
"0.70132405",
"0.69588256",
"0.69588256",
"0.69324195",
"0.6916249",
"0.68825996",
"0.67803013",
"0.6776181",
"0.6759419",
"0.67552614",
"0.... | 0.8575143 | 1 |
Return ips from instances | def get_ips(self, instances):
public_ips = []
for instance in instances:
public_ips.append(instance.public_dns_name)
return public_ips | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instances(self):\n for server in self.cs.servers.list():\n match = self.cluster_re.match(server.name)\n if match:\n for ip in server.networks['public']:\n if ip.count('.'):\n v4ip = ip\n yield (match.group(... | [
"0.76113784",
"0.730542",
"0.72717494",
"0.7170812",
"0.7075248",
"0.7043355",
"0.70000243",
"0.68474054",
"0.6840684",
"0.68234193",
"0.6718438",
"0.6659494",
"0.66257316",
"0.6606317",
"0.6606317",
"0.659874",
"0.6588869",
"0.6585919",
"0.6579781",
"0.6567652",
"0.6516815",... | 0.82241243 | 0 |
Oktaspecific application info retrieved from the URL. | def _app_info(self):
redirect_url = parse.urlparse(self._redirect_url())
if re.search("okta", redirect_url.hostname):
app_info = re.match(
r"^\/app\/(\w+)\/(\w+)\/sso/saml$",
redirect_url.path
)
return app_info.groups(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_app_info(self):\n pass",
"def _fetch_app_info(app_id):\n try:\n assert len(app_id), \"Empty string\"\n lookup_url = \"https://itunes.apple.com/lookup?id=\"\n target_url = lookup_url + app_id\n if sys.version_info < (3, 5):\n res... | [
"0.691974",
"0.6761501",
"0.66218877",
"0.6582538",
"0.65025103",
"0.6377309",
"0.6356972",
"0.63516927",
"0.6295055",
"0.6275283",
"0.6253936",
"0.61869735",
"0.61593604",
"0.61483043",
"0.6089754",
"0.6008549",
"0.60042727",
"0.60020375",
"0.59736496",
"0.5971184",
"0.59040... | 0.7358192 | 0 |
Check if MFA is supported. | def _mfa_supported(self):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_mfa(self) -> None:\n try:\n mfa_form = self._driver.find_element(By.CSS_SELECTOR, \"form[name=form]\", timeout=5)\n self._driver.find_element(By.CSS_SELECTOR, \"input[name=otc]\", timeout=5)\n self._halo.stop()\n mfacode = self._csc.prompt_for(\"MFA Code... | [
"0.6456988",
"0.64207107",
"0.6161599",
"0.6030697",
"0.57195747",
"0.5707503",
"0.5667593",
"0.5590575",
"0.54633266",
"0.54578304",
"0.5440032",
"0.53827685",
"0.53774214",
"0.5354453",
"0.5353557",
"0.53513414",
"0.53478837",
"0.5345963",
"0.53414917",
"0.5340764",
"0.5339... | 0.8236154 | 0 |
return the mirror of the given string | def mirror_string(the_string):
return the_string + reverse_string(the_string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mirror(s):\n mir_str = s\n for i in range(1, len(s) + 1):\n mir_str += s[-i]\n return mir_str",
"def string_mirror(text):\n rev_text = text[::-1]\n mirror_text = text + rev_text\n return mirror_text",
"def reverse(string):\n return string[::-1]",
"def reverse_string(s):\n s... | [
"0.78554",
"0.7797941",
"0.64188313",
"0.6326632",
"0.627955",
"0.6224376",
"0.62028164",
"0.61798996",
"0.6115949",
"0.609675",
"0.60859007",
"0.6011427",
"0.6008479",
"0.59972316",
"0.595555",
"0.5951928",
"0.59278554",
"0.59032947",
"0.58988315",
"0.5854072",
"0.58286273",... | 0.82076615 | 0 |
define a function called sum_evens, which receives one argument, a list of numbers. your function should return the sum of all the even numbers in the list | def sum_evens(the_nums):
my_sum = 0
for num in the_nums:
if num % 2 == 0:
my_sum += num
return my_sum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_evens( n ):\n result = 0\n num = 0\n while num < n + 1:\n result += num\n num += 2\n return result",
"def sum_of_even(numbers):\r\n\r\n\tsum = 0\r\n\tfor i in numbers:\r\n\t\tif (i%2 == 0):\r\n\t\t\tsum += i\r\n\r\n\treturn sum",
"def get_all_evens(nums):\n\n even_nums = []... | [
"0.7681991",
"0.75866824",
"0.747706",
"0.7456841",
"0.7318411",
"0.7282693",
"0.7232526",
"0.7115733",
"0.6844247",
"0.6804674",
"0.6795843",
"0.6716187",
"0.67088974",
"0.66193366",
"0.650387",
"0.64708626",
"0.6333387",
"0.63076717",
"0.62996763",
"0.62290937",
"0.6212629"... | 0.83778375 | 0 |
Execute a shell script. Setting prefix will add the environment variable COLCON_BUNDLE_INSTALL_PFREFIX equal to the passed in value | def _execute(script, prefix=None, path=None):
path = tempfile.gettempdir() if path is None else path
result = 1
try:
fh = tempfile.NamedTemporaryFile('w', delete=False)
fh.write(script)
fh.close()
print('Executing script below with cwd=%s\n{{{\n%s\n}}}\n' %
(pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process(self, prefix):\n options = self.options\n script = options.get(prefix, '').strip()\n if script:\n env = _env(options.get(prefix+'-env') or options.get('env') or '')\n shell = (options.get(prefix+'-shell')\n or options.get('shell') or ... | [
"0.6353147",
"0.60257393",
"0.56810886",
"0.55134755",
"0.54582494",
"0.5435877",
"0.5353717",
"0.52477705",
"0.51856023",
"0.51831543",
"0.5131652",
"0.50362307",
"0.5002932",
"0.49729705",
"0.49688485",
"0.49680483",
"0.4939706",
"0.49229112",
"0.49186707",
"0.490497",
"0.4... | 0.6236007 | 1 |
Instrument a method with the given Test. | def instrumentMethod(test, method_name, c=TestRunner):
unadorned = getattr(c, method_name)
import new
method = new.instancemethod(test.wrap(unadorned), None, c)
setattr(c, method_name, method) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instrumentMethod(test, method_name, c=TestRunner):\r\n unadorned = getattr(c, method_name)\r\n import new\r\n method = new.instancemethod(test.wrap(unadorned), None, c)\r\n setattr(c, method_name, method)",
"def add_test_method(cls, queue_name_fragment, hdrs, props, send_shim, receive_shim, timeo... | [
"0.8075311",
"0.5744945",
"0.57412565",
"0.57279474",
"0.57251406",
"0.56970775",
"0.5630941",
"0.5606898",
"0.55533004",
"0.5506733",
"0.54564655",
"0.5387677",
"0.5387677",
"0.53375614",
"0.521765",
"0.521765",
"0.51903296",
"0.51803833",
"0.5178082",
"0.51614606",
"0.51176... | 0.8082962 | 0 |
Prepares to execute the task that this module is design to do. Preparations include loading and running the NLP model, retrieving the information needed from the NLP output and the user to execute the task. | def prepare(self, nlp_model_names, text, sender):
if self.nlp_model is None:
# Replace "NLP_MODEL" with the name of the NLP models which this module should use.
self.nlp_model = spacy.load(nlp_model_names["NLP_MODEL"])
to, when, body = self.nlp(text)
self.description = No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _preparation_workflow(self):\n self._validate_environment()\n self._validate_parameters()\n self._update_verbosity()",
"def setup(self) -> None:\n self.logger.info(\"ML Train task: setup method called.\")",
"def launch(self, force_prep=False):\n #TODO process upploaded cs... | [
"0.66875076",
"0.6421311",
"0.6281637",
"0.62222123",
"0.6220328",
"0.6153359",
"0.5987517",
"0.595677",
"0.5844441",
"0.5797753",
"0.5791133",
"0.5779024",
"0.57548994",
"0.5751336",
"0.5750355",
"0.5739375",
"0.57367283",
"0.5709741",
"0.57093525",
"0.57036644",
"0.5699484"... | 0.6535937 | 1 |
Run the NLP module on the input. Group and return the NLP labels and entities. | def nlp(self, text):
# Runs the NLP model on the input.
doc = self.nlp_model(text)
to = []
when = []
body = []
# Group the labels into variables.
for token in doc:
if token.dep_ == "TO":
to.append(token.text)
elif token.de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_text(model_name: str, text: str) -> spacy.tokens.Doc:\r\n nlp = load_model(model_name)\r\n return nlp(text)",
"def main(model=None, output_dir=None, n_iter=20):\n if model is not None:\n nlp = spacy.load(model) # load existing spaCy model\n print(\"Loaded model '%s'\" % model)... | [
"0.6044815",
"0.60106623",
"0.5951502",
"0.59280443",
"0.58727735",
"0.582777",
"0.5826666",
"0.57033956",
"0.56903803",
"0.5683299",
"0.56206745",
"0.56038415",
"0.56035453",
"0.55429745",
"0.55383086",
"0.553127",
"0.55225134",
"0.5516551",
"0.5504731",
"0.5500881",
"0.5488... | 0.66848516 | 0 |
Returns an array of all pixels' rgb values in a surface | def get_pixels(surface):
pixels = []
for y in range(surface.get_height()):
for x in range(surface.get_width()):
pixels.append(surface.get_at((x,y))[:3])
return pixels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rgb(self):\n return [self.__r, self.__g, self.__b]",
"def getPixels(self):\n\t\treturn self.strip.ledsColorBuffer",
"def get_rgb_light():\n return list(light.rgb())",
"def _colored_img_to_arr(image, verbose=False):\n height, width = image.size\n arr = np.array(image.getdata())\n ar... | [
"0.70980895",
"0.66557866",
"0.66320956",
"0.6622494",
"0.6541926",
"0.65298855",
"0.6529636",
"0.6522719",
"0.6466939",
"0.64495635",
"0.6425906",
"0.63456154",
"0.63314754",
"0.6304527",
"0.62431765",
"0.6228581",
"0.61598295",
"0.610881",
"0.61073124",
"0.60987216",
"0.604... | 0.7694175 | 0 |
image_location is a file path to the image. First we load the surface, turn it to a small 8x8 greyscale copy get the average rgb from that and create our hash from the average rgbs | def image_hash(image_location):
image = pygame.image.load(image_location)
grey = greyscale(image)
avg = average_image_value(grey)
bitstring = ''
for pixels in get_pixels(grey):
if pixels[0] < avg:
bitstring += '1'
else: bitstring += '0'
hash = int(bitstring, 2).__for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_hash(image_path):\n\n return imagehash.average_hash(Image.open(image_path))",
"def _calc_hash(self) -> None:\n self.image = Image.open(self.path)\n self.image = self.image.convert(\"L\")\n self.image = self.image.resize((self.width, self.height), Image.ANTIALIAS)\n ... | [
"0.6444688",
"0.6177515",
"0.5947265",
"0.5923501",
"0.583346",
"0.56014127",
"0.55459803",
"0.5524121",
"0.5515747",
"0.5444249",
"0.54428154",
"0.54388857",
"0.5426759",
"0.5384609",
"0.5372793",
"0.5368804",
"0.53539616",
"0.5330574",
"0.53144616",
"0.5249488",
"0.5230912"... | 0.7241937 | 0 |
Download songs from YouTube, for use in our database | def download_songs(playlist_url):
command_string = 'youtube-dl -x --audio-format wav --postprocessor-args "-ar 44100 -ac 1" --output "Songs/%(' \
'title)s_%(id)s.%(ext)s" ' + \
playlist_url
args = shlex.split(command_string)
subprocess.call(args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def download(self, ctx, *, song):\n try:\n with youtube_dl.YoutubeDL(ytdl_download_format_options) as ydl:\n if \"https://www.youtube.com/\" in song:\n download = ydl.extract_info(song, True)\n else:\n infosearched = ydl.ex... | [
"0.72204304",
"0.70007014",
"0.69705606",
"0.6968855",
"0.6955529",
"0.6739802",
"0.6696157",
"0.66440094",
"0.66403437",
"0.6592989",
"0.6551917",
"0.65344065",
"0.6519165",
"0.65043634",
"0.6503763",
"0.6496321",
"0.647971",
"0.64418465",
"0.64357823",
"0.6430905",
"0.64211... | 0.74034494 | 0 |
Prunes dictionary containing the words in the message to the most interesting 15 tokens based on the size of their deviation from the "Neutral" value of 0.5 To perform this function, it first assigns spam probability to each words by referencing a established dataset of words and their spam probability. If word not fou... | def find_interesting_tokens(test_corpus_words, word_spam_chance_dict):
# Assign probabilities to words in the test corpus based on established dataset of words and spam probabilities.
test_corpus_word_probability_dict = {}
for each_word in test_corpus_words:
# If dataset contains that word, assign... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def individual_word_spam_chance(spam_words_dict, non_spam_words_dict, threshold):\n\n # Combine unique spam and non-spam words into one dictionary with their associated combined occurrences.\n combined_spam_nonspam_word_occurrences = {}\n\n for key, value in spam_words_dict.items():\n if key not in... | [
"0.6841508",
"0.6254475",
"0.59997356",
"0.58946764",
"0.58677113",
"0.5823959",
"0.58210856",
"0.5756859",
"0.566003",
"0.56481004",
"0.5628697",
"0.56022924",
"0.55878425",
"0.55792934",
"0.5560454",
"0.5552837",
"0.55461967",
"0.55404204",
"0.5540015",
"0.55317634",
"0.551... | 0.6931594 | 0 |
Determines the final probability of the message being spam. | def message_spam_chance(word_probabilities_dict):
# Remove the keys from the dictionary and store only the associated values.
word_probability_values = sorted(word_probabilities_dict.values())
print("\nword spam probability values only, keys removed: " + str(word_probability_values))
# Calculate the p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_probability(self, unseen_mail):\n unseen_mail = self.__handle_unseen_mail_unknown_words(unseen_mail)\n \n start_token = ' '.join([NGramModel.START_SENTENCE_TOKEN]*(self.__n-1));\n sentences = unseen_mail.replace(NGramModel.START_SENTENCE_TOKEN, start_token).split(NGramMode... | [
"0.6856276",
"0.66305524",
"0.63954985",
"0.6126914",
"0.59960806",
"0.59381163",
"0.592768",
"0.58817714",
"0.5818623",
"0.5792749",
"0.575886",
"0.5748488",
"0.5743481",
"0.5741628",
"0.5736055",
"0.572044",
"0.57093024",
"0.57084846",
"0.56884634",
"0.56721234",
"0.5664108... | 0.6654423 | 1 |
Create sorted savings list and matrix with distance and savings | def Savings(self,geolocations):
self.savings = [] #List to store savings
size = len(geolocations)
for from_node in xrange(1,size):
for to_node in xrange(from_node+1,size):
save = self.Distance(0,from_node) + self.Dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_savings_matrix(self):\n mat_dim = self._problem.number_of_patients()\n savings_matrix = np.zeros((mat_dim, mat_dim))\n cost_matrix = self._problem.costs_matrix\n for i in range(mat_dim):\n for j in range(mat_dim):\n if i != j:\n ... | [
"0.59517455",
"0.57231927",
"0.5445455",
"0.52918875",
"0.5289238",
"0.5222936",
"0.5219054",
"0.5216862",
"0.520472",
"0.51936656",
"0.51906747",
"0.51685256",
"0.5164179",
"0.5163071",
"0.5157834",
"0.5112156",
"0.51111937",
"0.51060206",
"0.51024145",
"0.50942177",
"0.5075... | 0.67217356 | 0 |
total_venues(filename) returns an integer that tells you how many different unique values there are in the csv timetable file. To use total_venues, enter the filename in the function. The function should return an integer. | def total_venues(filename):
#reading the file
f = open(filename,"r")
#incsv is a short form of 'input csv file'
incsv = f.readlines()
#removing affixes
incsv[:] = [i.rstrip('\n') for i in incsv]
#lines into lists
#tempstr and templist are temporary variables to split the strings in incsv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_venues(filename,start,end,day):\n #open file\n f = open(filename,\"r\")\n incsv = f.readlines()\n #removing affixes\n incsv[:] = [i.rstrip('\\n') for i in incsv]\n #lines into lists\n tempstr = \"\"\n templist = []\n for j in range(len(incsv)):\n #enters each line in... | [
"0.61805046",
"0.6054929",
"0.57702976",
"0.5745972",
"0.5560655",
"0.5547302",
"0.5427406",
"0.5402603",
"0.5343917",
"0.5309098",
"0.5299042",
"0.5273285",
"0.5256531",
"0.5246932",
"0.5193131",
"0.51890045",
"0.51861143",
"0.5183398",
"0.5170527",
"0.51524687",
"0.510676",... | 0.68946314 | 0 |
available_venues(filename,start,end,day) returns a list of venues that are not occupied in a certain time range in a certain day. To use available_venues, enter the filename as the first argument, followed by the start time, end time and an integer end code. The function should return a list with all available venues. | def available_venues(filename,start,end,day):
#open file
f = open(filename,"r")
incsv = f.readlines()
#removing affixes
incsv[:] = [i.rstrip('\n') for i in incsv]
#lines into lists
tempstr = ""
templist = []
for j in range(len(incsv)):
#enters each line into temporary string ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_timing(filename,day,venue):\n #reading the file\n f = open(filename,\"r\")\n incsv = f.readlines()\n #removing affixes\n incsv[:] = [i.rstrip('\\n') for i in incsv]\n #lines into lists\n tempstr = \"\"\n templist = []\n for j in range(len(incsv)):\n #enters each line... | [
"0.61132663",
"0.60554844",
"0.5829282",
"0.5526698",
"0.54212916",
"0.5218367",
"0.52058125",
"0.51949495",
"0.5194945",
"0.51915556",
"0.5039286",
"0.502326",
"0.50132734",
"0.49665505",
"0.49555328",
"0.49053603",
"0.486853",
"0.48457333",
"0.48428378",
"0.48234007",
"0.48... | 0.7609462 | 0 |
venue_occupancy(filename) returns the value of the average venue occupancy for all the venues. To use venue_occupancy, enter the filename in between the parentheses. The function should return a number that tells you the average venue occupancy in the timetable file. | def venue_occupancy(filename):
#open file
f = open(filename,"r")
incsv = f.readlines()
#removing affixes
incsv[:] = [i.rstrip('\n') for i in incsv]
#lines into lists
tempstr = ""
templist = []
for j in range(len(incsv)):
#enters each line into temporary string variable
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n \n file = open(\"profit.txt\",\"r\")\n profits = file.readlines()\n file = open(\"revenue.txt\",\"r\")\n revenues = file.readlines()\n file.close()\n \n totalProfits = 0\n for i in range(len(profits)):\n totalProfits += float(profits[i])\n \n print \"Total Fort... | [
"0.527116",
"0.514293",
"0.512036",
"0.5116814",
"0.50583875",
"0.504117",
"0.5030007",
"0.5024472",
"0.5019992",
"0.5010778",
"0.5010778",
"0.4986395",
"0.49747267",
"0.49149644",
"0.4880314",
"0.4873189",
"0.48650548",
"0.48556772",
"0.4847156",
"0.48384276",
"0.48384276",
... | 0.6115728 | 0 |
available_timing(filename,day,venue) returns a list of available timings for a certain venue in a certain day. To use available_timing, enter the filename as the first argument, followed by an integer day code and finally the venue. The function should return a list with a range of available timings in round brackets. | def available_timing(filename,day,venue):
#reading the file
f = open(filename,"r")
incsv = f.readlines()
#removing affixes
incsv[:] = [i.rstrip('\n') for i in incsv]
#lines into lists
tempstr = ""
templist = []
for j in range(len(incsv)):
#enters each line into temporary stri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_venues(filename,start,end,day):\n #open file\n f = open(filename,\"r\")\n incsv = f.readlines()\n #removing affixes\n incsv[:] = [i.rstrip('\\n') for i in incsv]\n #lines into lists\n tempstr = \"\"\n templist = []\n for j in range(len(incsv)):\n #enters each line in... | [
"0.59195966",
"0.57383525",
"0.5540875",
"0.5463237",
"0.53547984",
"0.51768637",
"0.50629467",
"0.49165255",
"0.4908699",
"0.48233223",
"0.47792912",
"0.4748623",
"0.47469702",
"0.47431985",
"0.46946442",
"0.46777627",
"0.46385124",
"0.46170804",
"0.45761064",
"0.45463902",
... | 0.7180395 | 0 |
ttint(timelist,venue) takes a timelist list from pp_schedule and draws in python turtle graphics as a readable table. Venue is the string to be printed at the bottom of the screen denoting the venue that is concerned. | def ttint(timelist,venue):
#setup
showturtle()
#make python turtle graphics window 1260 pixels wide and 800 pixels tall
setup(width = 1260, height = 800, startx = None, starty = None)
reset()
#text at top
pen(pencolor="black")
pu()
setpos(0,380)
write("Welcome to your schedule. U... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pp_schedule(filename,venue):\n #reading the file\n f = open(filename,\"r\")\n incsv = f.readlines()\n #removing affixes\n incsv[:] = [i.rstrip('\\n') for i in incsv]\n #lines into lists\n tempstr = \"\"\n templist = []\n for j in range(len(incsv)):\n #enters each line into tem... | [
"0.7735832",
"0.62591535",
"0.53490853",
"0.52944165",
"0.5200095",
"0.5179349",
"0.5171907",
"0.5160587",
"0.5143638",
"0.51262563",
"0.51205915",
"0.5059147",
"0.4967323",
"0.49631694",
"0.49489382",
"0.49449074",
"0.49370623",
"0.4925877",
"0.4924541",
"0.48869017",
"0.485... | 0.76725847 | 1 |
commanding quit() quits from python turtle graphics. | def quit():
#quits from python turtle graphics screen
bye() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quit():\n return 'quit'",
"def quit():\n\tsys.exit()",
"def cmd_quit(args):",
"def quit(self):\n pass",
"def do_quit(self, args):\n quit()",
"def quit(self):\n\t\tpass",
"def quit(self, *args, **kwargs):\n pass",
"def do_quit(self,line):\n self.quit()",
"d... | [
"0.70075387",
"0.69214535",
"0.68864304",
"0.6808114",
"0.6739777",
"0.669683",
"0.66821736",
"0.66361433",
"0.6610632",
"0.6570589",
"0.6564331",
"0.65494555",
"0.65493435",
"0.6515216",
"0.64835155",
"0.64770013",
"0.64566535",
"0.6432395",
"0.64222944",
"0.63981736",
"0.63... | 0.89436555 | 0 |
pp_schedule(filename,venue) opens up a python turtle graphics window which shows what times of each of the seven days of the week is occupied by which module in which venue. To use pp_schedule, enter a filename as the first element and a venue as the second element. pp_schedule commands ttint(timelist,venue) to create ... | def pp_schedule(filename,venue):
#reading the file
f = open(filename,"r")
incsv = f.readlines()
#removing affixes
incsv[:] = [i.rstrip('\n') for i in incsv]
#lines into lists
tempstr = ""
templist = []
for j in range(len(incsv)):
#enters each line into temporary string variab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ttint(timelist,venue):\n #setup\n showturtle()\n #make python turtle graphics window 1260 pixels wide and 800 pixels tall\n setup(width = 1260, height = 800, startx = None, starty = None)\n reset()\n #text at top\n pen(pencolor=\"black\")\n pu()\n setpos(0,380)\n write(\"Welcome t... | [
"0.79792595",
"0.6396415",
"0.6337348",
"0.63255966",
"0.6231173",
"0.60653955",
"0.6034211",
"0.5956495",
"0.5881271",
"0.5827585",
"0.58147764",
"0.5813226",
"0.57874453",
"0.5776859",
"0.57415116",
"0.5731401",
"0.56468225",
"0.56463355",
"0.56160754",
"0.5590078",
"0.5586... | 0.8151101 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.