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 |
|---|---|---|---|---|---|---|
Displays the status, the owner, the project name and the number of cart items. | def __str__(self):
return _(
"cart (status: %(status)s, owner: %(owner)s, project name: "
"%(project_name)s, number of cart items: %(nb_cart_items)d, "
"total amount: %(total_amount)d)"
) % {
'status': self.CART_STATUSES[self.status][1],
'owner... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display(auth_context):\n\n cart = carts.get_cart(auth_context.get('uid'))\n for item in cart:\n product = product_catalog.get_product(item.item_id)\n item.info = product\n\n return render_template('cart.html',\n cart=cart,\n auth_contex... | [
"0.65103585",
"0.60823727",
"0.59575856",
"0.5933486",
"0.5839279",
"0.5830037",
"0.5798492",
"0.57583416",
"0.57334095",
"0.5703823",
"0.5699384",
"0.5692979",
"0.56647104",
"0.56580704",
"0.56565565",
"0.56434786",
"0.563236",
"0.5614772",
"0.5598291",
"0.5586921",
"0.55683... | 0.7057877 | 0 |
Retrieves all cart items for a given cart. | def get_cart_items(self):
return CartItem.objects.filter(cart=self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cart_items(request):\n return CartItem.objects.filter(cart_id=_cart_id(request))",
"def get_cart_items(request):\n return CartItem.objects.filter(cart_id=_cart_id(request))",
"def get_cart_items(request):\n return CartItem.objects.filter(cart_id = get_cart_id_session(request))",
"def get_ite... | [
"0.7381225",
"0.7381225",
"0.72456187",
"0.69202214",
"0.6845669",
"0.66992563",
"0.65180063",
"0.6440269",
"0.6359296",
"0.6044959",
"0.6000852",
"0.59828556",
"0.5950014",
"0.5811841",
"0.5804673",
"0.573022",
"0.5728143",
"0.568424",
"0.56840277",
"0.5662042",
"0.5657203",... | 0.7630341 | 0 |
Retrieves the number of distinct cart items for a given cart. | def nb_cart_items(self):
return CartItem.objects.filter(cart=self).count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cart_distinct_item_count(request):\n return get_cart_items(request).count()",
"def get_cart_counter(request):\n return len(get_cart_items(request))",
"def num_carts(self):\n return self._num_carts",
"def __len__(self):\n return sum(item['qty'] for item in self.cart.values())",
"def ... | [
"0.83708996",
"0.7122882",
"0.66277915",
"0.64961153",
"0.6374639",
"0.63468164",
"0.5831994",
"0.5810013",
"0.578669",
"0.5636934",
"0.5636934",
"0.56178385",
"0.56098634",
"0.5601126",
"0.55407643",
"0.54967433",
"0.5454864",
"0.54540205",
"0.54383975",
"0.5436613",
"0.5397... | 0.73278224 | 1 |
Retrieves the total amount of cart items for a given cart. | def total_amount(self):
total_amount = 0
for cart_item in self.get_cart_items():
total_amount += cart_item.total_price
return total_amount | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_of_cart(session_id):\n cart_items = CartItem.objects.filter(cart_id=session_id)\n cart_total_list = [cart_item.total() for cart_item in cart_items]\n return sum(cart_total_list)",
"def cart_subtotal(request):\n cart_total = decimal.Decimal('0.00')\n cart_products = get_ca... | [
"0.78944373",
"0.7428659",
"0.74166524",
"0.7226727",
"0.6956555",
"0.66739833",
"0.6626357",
"0.6577171",
"0.65215605",
"0.6469818",
"0.64654446",
"0.644342",
"0.6432942",
"0.6390239",
"0.6378628",
"0.62492317",
"0.6200687",
"0.6190806",
"0.61329013",
"0.6089602",
"0.6088345... | 0.7810109 | 1 |
Test if this cart is empty. | def is_empty(self):
return self.id is None or self.nb_cart_items == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_shopping_cart_is_empty(self):\n response = self.client.get(self.SHOP_CART_URL)\n self.assertEqual(response.status_code, 200)\n self.assertContains(response, \"Your shopping cart is empty.\")\n self.assertQuerysetEqual(response.context['contents'], [])",
"def test_shopping_car... | [
"0.8263173",
"0.7682502",
"0.76717985",
"0.7634377",
"0.7626435",
"0.7626435",
"0.76094395",
"0.7590669",
"0.7586988",
"0.75739545",
"0.75577635",
"0.75392646",
"0.7537761",
"0.7518471",
"0.74757564",
"0.74757564",
"0.74580145",
"0.7455165",
"0.7455165",
"0.7435698",
"0.74259... | 0.8744867 | 0 |
Runs experiment using DP, QL or both. Creates new directory automatically Save result summary to summary file | def run_Experiment(DP = None, QL = None):
# Path information
output_path, exp_num = create_new_dir() #dirs Exp/1, Exp/2, ...
DP_path = join(output_path,'DP') #dirs Exp/1/DP
QL_path = join(output_path,'QL') #dirs Exp/1/QL
print("************ Exp ", exp_num, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_test(self):\n\n # populate *_ps sets\n self.enter_project_file()\n\n # populate *_dir sets\n self.enter_directories()\n\n # The files in the directories makes up the largest possible set of files\n self.result_files = self.result_files_dir\n self.design_file... | [
"0.6303137",
"0.5954984",
"0.5947202",
"0.5942798",
"0.5933814",
"0.5922406",
"0.58769554",
"0.58608824",
"0.58519894",
"0.5840858",
"0.5767799",
"0.5748718",
"0.5712309",
"0.5707479",
"0.5706759",
"0.56962764",
"0.56911665",
"0.56899905",
"0.56842196",
"0.567968",
"0.5671062... | 0.76796246 | 0 |
start point of scraping use urls, pass soup tag to Unvs return a list of 100 unvs(university) object | def scrape():
url_base='https://www.usnews.com/best-colleges/rankings/national-universities'
unvss=[]
for page in range(N_PAGE):
url=url_base+'?_page={}'.format(page+1)
soup=get_soup(url)
unvs_tags=soup.find_all('li',id=re.compile(r'^view-.*'),class_='block-normal block-loose-for-lar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_national_university_data(univ_url):\n f_name = 'national_university_html.json'\n base_url = 'https://www.usnews.com'\n html_cache = load_cache(f_name)\n\n if univ_url not in html_cache:\n resp = requests.get(base_url + univ_url, headers=agent)\n html_cache[univ_url] = resp.text\n ... | [
"0.6813396",
"0.6677755",
"0.6292874",
"0.6277937",
"0.62407184",
"0.6227392",
"0.6170943",
"0.60358685",
"0.6008686",
"0.5971656",
"0.5971656",
"0.5909",
"0.5846324",
"0.5824053",
"0.5823654",
"0.5777535",
"0.57656276",
"0.5758727",
"0.5701715",
"0.57001144",
"0.5692121",
... | 0.8051392 | 0 |
use the url to scrape detailed info | def scrape_detail(self,url):
soup=get_soup(url)
self.zip=soup.find('p',class_='block-normal hide-for-small-only text-small hero-ranking-data-contact').stripped_strings.__next__()[-5::1]
if self.zip in zips:
#print('DUPLICATE!')
zips.append(self.zip)
info_tags=soup.fin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info_of_url(url):\n pass",
"def get_details(self):\n # For every URL in our list of links that we got from the parser's\n # 'lookup()' method we get the data from that URL, set it in our\n # parser's buffer, and then let the parser do the rest of the work.\n #\n for ... | [
"0.70981526",
"0.6877993",
"0.6745803",
"0.67396754",
"0.66712624",
"0.66406703",
"0.6620889",
"0.6527329",
"0.65011233",
"0.64701736",
"0.6441623",
"0.6421658",
"0.6386159",
"0.63498217",
"0.6328521",
"0.6304512",
"0.62901115",
"0.625672",
"0.6245974",
"0.62436974",
"0.62268... | 0.7324095 | 0 |
Swap the byteordering in a packet with N=4 bytes per word | def byteswap(data, word_size=4):
return reduce(lambda x,y: x+''.join(reversed(y)), chunks(data, word_size), '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def byte_swap(data, word_size):\n \n bs_data = [0]*len(data)\n for ii in range(0, len(data), word_size):\n bs_data[ii:ii+word_size] = data[ii:ii+4][::-1]\n return(bytes(bs_data))",
"def swapNibbles(inputByte):\n return (inputByte << 4 | inputByte >> 4) & 0xff",
"def swap_bytes(word_val):\... | [
"0.6286982",
"0.6104455",
"0.57370377",
"0.5551212",
"0.5419383",
"0.541504",
"0.5307678",
"0.524828",
"0.5197568",
"0.51582634",
"0.5000781",
"0.49925607",
"0.49657536",
"0.49612567",
"0.49490094",
"0.49409774",
"0.49387702",
"0.48654178",
"0.48503458",
"0.48486102",
"0.4845... | 0.62880516 | 0 |
returns true if response is HTML | def is_good_response(self, resp):
content_type = resp.headers['Content-Type'].lower()
return (resp.status_code == 200 and content_type is not None and content_type.find('html') > -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_good_response(self, resp):\r\n\t\tcontent_type = resp.headers['Content-Type'].lower()\r\n\t\treturn (resp.status_code == 200 and content_type is not None and content_type.find('html') > -1)",
"def is_html(self):\r\n return self.__content_type == html_ctype",
"def is_html(self):\n return se... | [
"0.7978629",
"0.7896287",
"0.7848669",
"0.7823706",
"0.78176934",
"0.77728",
"0.7765719",
"0.77475446",
"0.7746658",
"0.77149415",
"0.76882756",
"0.76882756",
"0.76882756",
"0.76882756",
"0.7683412",
"0.7676108",
"0.7676108",
"0.7676108",
"0.7676108",
"0.7676108",
"0.7676108"... | 0.80010843 | 0 |
Returns the Guide data used by the Rig Component to define the layout of the final rig. | def getRigBuildData(self):
data = super(SimpleControlComponentGuide, self).getRigBuildData()
data["ctrlSize"] = self.ctrlSizeInputAttr.getValue()
data["ctrlXfo"] = self.mainCtrl.xfo
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveData(self):\n data = super(SimpleControlComponentGuide, self).saveData()\n\n data[\"ctrlSize\"] = self.ctrlSizeInputAttr.getValue()\n data[\"ctrlXfo\"] = self.mainCtrl.xfo\n\n return data",
"def saveData(self):\n\n data = super(OSSMouthGuide, self).saveData()\n\n ... | [
"0.60837376",
"0.57267016",
"0.5652258",
"0.55439556",
"0.55439556",
"0.5307513",
"0.5296474",
"0.52579033",
"0.52306396",
"0.5197011",
"0.51202613",
"0.5104202",
"0.50606996",
"0.50557256",
"0.5048612",
"0.5043005",
"0.5043005",
"0.50353324",
"0.50348055",
"0.50302404",
"0.5... | 0.6716383 | 0 |
Enables introspection of the class prior to construction to determine if it is a guide component. | def getComponentType(cls):
return 'Guide' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abstract(self):\n return self._cls and not self._tool",
"def get_guide_type(guide):\n # Maintained by naming convention in the Blender files. Sub-optimal.\n try:\n return guide.name[guide.name.rindex(\".\") + 1:]\n except:\n return None",
"def setup_class(cls):\n cls.be... | [
"0.57170075",
"0.5539905",
"0.5513718",
"0.5417464",
"0.53752244",
"0.5361038",
"0.53488845",
"0.5335014",
"0.5306125",
"0.5271901",
"0.5271901",
"0.5254923",
"0.5219103",
"0.5219103",
"0.5090291",
"0.5090291",
"0.5021101",
"0.5020824",
"0.49868792",
"0.49730074",
"0.49605048... | 0.6441624 | 1 |
Returns the corresponding rig component class for this guide component class | def getRigComponentClass(cls):
return SimpleControlComponentRig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getComponentType(cls):\n\n return 'Guide'",
"def getComponentType(cls):\n\n return 'Guide'",
"def getRigComponentClass(cls):\n\n return OSSMouthRig",
"def get_class(self):\n\t\treturn self.CLASS",
"def component(self):\n return self._component",
"def component(self):\n ... | [
"0.72734654",
"0.72734654",
"0.6762508",
"0.6674559",
"0.61377406",
"0.61377406",
"0.61340904",
"0.6081116",
"0.6031022",
"0.59476155",
"0.59440464",
"0.5913267",
"0.59066844",
"0.586445",
"0.583399",
"0.5800438",
"0.5774759",
"0.5768571",
"0.57600415",
"0.5756991",
"0.575684... | 0.74637115 | 0 |
Load csv file to database. Add `year` column | def from_csv_to_database():
for year, path in FileNamePath.items():
# load csv files
with open(path, encoding='cp1251') as dataset:
print(f"Download {year} data")
get_curr_data(dataset, year) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_catalog(self):\n self.catalog = pd.read_csv(self.catalog_path, \n index_col=0, parse_dates=True)\n self.unique_years = self.catalog.index.year.unique()\n return",
"def load_data(path):\n\n columns = ['Item Year', 'Original Value', 'Standard Value', 'Original Currency',... | [
"0.6482594",
"0.6402999",
"0.6367218",
"0.6283168",
"0.62296",
"0.6219771",
"0.6213001",
"0.6185162",
"0.6111619",
"0.6011145",
"0.60105246",
"0.5978613",
"0.597643",
"0.5974852",
"0.5945671",
"0.59363544",
"0.593171",
"0.5929072",
"0.5925405",
"0.5903456",
"0.5902019",
"0.... | 0.6820516 | 0 |
Save csv file with given header and rows into output folder | def to_csv(header, rows):
with open('result.csv', 'w') as result:
result_writer = csv.writer(result, delimiter=';')
result_writer.writerow(header)
result_writer.writerows(rows) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_csv(self, out_file_name, header):\n\n with open(out_file_name, 'wb') as outf:\n writer = csv.writer(outf, quoting=csv.QUOTE_ALL)\n writer.writerow(header)\n writer.writerows(self.records)",
"def write_csv(header_row, data_rows, filename, course_id):\n shared.e... | [
"0.73305476",
"0.7274633",
"0.7113233",
"0.69982344",
"0.68883383",
"0.6880275",
"0.68772936",
"0.6867271",
"0.6855233",
"0.68267447",
"0.67927784",
"0.6781188",
"0.67231953",
"0.67214197",
"0.666982",
"0.6666694",
"0.663893",
"0.6626239",
"0.6602342",
"0.65913993",
"0.657377... | 0.74616706 | 0 |
Return age and the averages of size and intensity. | def calculate(data, data_top):
size, intensity, age = np.array([data["Size"]]), np.array([data["Intensity"]]), data_top.iat[1,0]
size_avg, intensity_avg = np.average(size), np.average(intensity)
return size_avg, intensity_avg, age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_age(self):\n return np.mean([agent.age for agent in self.agents])",
"def average_age():\n df = pd.read_csv(config.META_FQN, sep=\"\\t\")\n ages = []\n for _, row in df.iterrows():\n if row[\"asr_test\"]:\n age = row[\"Age_ses1\"]\n if not math.isnan(ag... | [
"0.69467896",
"0.6716017",
"0.64098644",
"0.6313252",
"0.62349457",
"0.60789764",
"0.603415",
"0.5983959",
"0.5971684",
"0.5971354",
"0.596329",
"0.5948338",
"0.59151775",
"0.59151775",
"0.5871947",
"0.5868544",
"0.58433545",
"0.57856715",
"0.5773423",
"0.57728165",
"0.576568... | 0.74258214 | 0 |
Locates the flags in the resource Calls the LineFinder class in order | def getting_flags_locations(self):
print(self.flags)
self.line_finder.find_line(self.html) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _linesearch(self):\n pass",
"def setup_flags(self):\n self.io_args.color = self.io_args.color_full\n self.io_args.rig_in = self.io_args.rig\n self.io_args.matches = os.path.join(self.io_args.output_root, \"matches.json\")\n self.io_args.rig_out = os.path.join(self.io_args.o... | [
"0.6099659",
"0.573128",
"0.5506411",
"0.54494226",
"0.52455074",
"0.52231914",
"0.5129431",
"0.51100206",
"0.5072955",
"0.5024129",
"0.5009258",
"0.4999141",
"0.49835676",
"0.4975226",
"0.49732998",
"0.49641412",
"0.49461514",
"0.4915233",
"0.49087882",
"0.48647398",
"0.4846... | 0.76073164 | 0 |
Add url domain field to each tweet in each user data object. Url domain field contains list of domains corresponding to list of urls. | def modify_user_data(user_d_list):
for user in user_d_list:
for tweet in user['tweets']:
domains = [get_domain_of_url(url) for url in tweet['urls']]
tweet['domains'] = domains
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_domain():\n\n for e in Expr.search() + User.search(): e.set_tld(config.server_name)",
"def fixURLS():\n url_re = re.compile(r'http t co \\S+')\n tweets = Tweet.objects.all()\n for tweet in tweets:\n tweet.text = url_re.sub(' ', tweet.text)\n tweet.text = ' '.join(tweet.text.s... | [
"0.5635619",
"0.55407476",
"0.5532279",
"0.5374472",
"0.537326",
"0.53537875",
"0.53423244",
"0.53104246",
"0.5303713",
"0.5294134",
"0.52771896",
"0.527685",
"0.52617246",
"0.524754",
"0.52349997",
"0.52061516",
"0.5133119",
"0.5130348",
"0.5129113",
"0.5128528",
"0.5121948"... | 0.8328926 | 0 |
This function takes in all paths that are represented as lists of consecutive nodes [node1, node2,...,nodeN] and converted to paths represented as lists of consecutive relations [rel1, rel2,...,relM] if self.include_entity is false, or as lists of nodes and relations [node1, rel1, node2, rel2,...,relM, nodeN] if self.i... | def expand_paths_by_nodes(self, paths):
paths_formatted = set()
# Expand each path
for path in paths:
if len(path) < 2:
continue
expanded_paths = set()
if self.include_entity:
relations_for_each_step = [[path[0]]]
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_paths(self):\n # convert to node sequences, dropping s'\n self.nodeseq_paths = []\n for path in self.paths:\n node_seq = [] # don't include s'\n for arc in path:\n node_seq.append(self.arc_info[arc]['destin'])\n self.nodeseq_paths.ap... | [
"0.6200332",
"0.5851866",
"0.571507",
"0.56179786",
"0.5481076",
"0.5464558",
"0.5461847",
"0.5296667",
"0.5288939",
"0.5283457",
"0.5277893",
"0.5269692",
"0.52677166",
"0.52636945",
"0.5238955",
"0.5237788",
"0.5216618",
"0.52149516",
"0.5190407",
"0.51791054",
"0.5176276",... | 0.6647005 | 0 |
This function is used to write all paths between any two entities that are connected by the input relation to a file. Because this function will go through all paths node by node, this function will also used to filter paths to save computation. | def write_and_filter_paths(self, source, target, relation, label, paths):
file_dir = os.path.join(self.save_dir, relation + "_" + str(self.maximum_length) + "_" + str(self.remaining_percentage) + "_" + str(self.random_seed) + ".txt")
with open(file_dir, "a") as fh:
fh.write(str(label) + "\t"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writePathways( self ):\n\n self.logger.info( 'writePathways: START' )\n\n # Generate inserts for meabolic pathways.\n self.importerPathway.writePathways()\n\n self.logger.info( 'writePathways: DONE' )",
"def filter_paths(self, paths):\n formatted_paths = set()\n for ... | [
"0.6408844",
"0.6286845",
"0.62742597",
"0.619009",
"0.6096018",
"0.5878812",
"0.5735827",
"0.5685394",
"0.56852794",
"0.5661119",
"0.5632934",
"0.5616579",
"0.5599253",
"0.55716807",
"0.556647",
"0.5563934",
"0.5434351",
"0.54200315",
"0.537365",
"0.5366517",
"0.53606457",
... | 0.74876946 | 0 |
This function is used to filter all paths and change paths represented by relation index and entity index to paths represented by relation name and entity name | def filter_paths(self, paths):
formatted_paths = set()
for path in paths:
formatted_path = []
if self.include_entity:
if len(path) == 3:
continue
formatted_path.append(self.idx_to_node[path[0]].get_name())
for rd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_and_filter_paths(self, source, target, relation, label, paths):\n file_dir = os.path.join(self.save_dir, relation + \"_\" + str(self.maximum_length) + \"_\" + str(self.remaining_percentage) + \"_\" + str(self.random_seed) + \".txt\")\n with open(file_dir, \"a\") as fh:\n fh.write... | [
"0.58268344",
"0.52432096",
"0.5228353",
"0.51687616",
"0.5044035",
"0.5042572",
"0.4956355",
"0.49512407",
"0.4946628",
"0.4930969",
"0.49182546",
"0.49161366",
"0.4869944",
"0.48368976",
"0.4831286",
"0.48303708",
"0.48242262",
"0.48204356",
"0.48135132",
"0.48054898",
"0.4... | 0.6383274 | 0 |
Convert single line in Instruction instance. | def process_line(line: str) -> Instruction:
register, op, value, _, base, check, limit = line.split()
return Instruction(register, op, int(value), base, check, int(limit)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trans_line(line: str, progname):\r\n splitline = line.split()\r\n command = splitline[0]\r\n if command == 'push':\r\n segment = splitline[1]\r\n index = splitline[2]\r\n out = mem.push(segment, index, progname)\r\n elif command == 'pop':\r\n segment = splitline[1]\r\n ... | [
"0.6149348",
"0.60882974",
"0.60344046",
"0.59739935",
"0.5775252",
"0.5676443",
"0.56726754",
"0.56274086",
"0.5606504",
"0.5577222",
"0.55470794",
"0.5473916",
"0.5454122",
"0.54540783",
"0.54350394",
"0.5411006",
"0.5390487",
"0.5379209",
"0.53752047",
"0.53626865",
"0.535... | 0.6650071 | 0 |
Convert raw data in the easytouse list of Instruction instances. | def process_data(data: str) -> list[Instruction]:
instructions = []
for line in data.strip().split("\n"):
instruction = process_line(line)
instructions.append(instruction)
return instructions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract(input_data: str) -> list:\n instructions = list()\n for instruction in input_data.split('\\n'):\n op, arg = instruction.split(' ')\n arg = int(arg)\n assert op in ('acc', 'jmp', 'nop')\n instructions.append(Instruction(op, arg))\n return instructions",
"def _perfo... | [
"0.5894083",
"0.580195",
"0.56562746",
"0.5608601",
"0.55650634",
"0.55505216",
"0.55473304",
"0.5376276",
"0.53636885",
"0.5328439",
"0.5309102",
"0.52925634",
"0.52925086",
"0.5272285",
"0.5267069",
"0.5258318",
"0.5257359",
"0.5243541",
"0.5228365",
"0.5214779",
"0.5211774... | 0.63322127 | 0 |
Apply all instructions and return registers + the biggest value seen. | def perform_instructions(
instructions: list[Instruction],
) -> tuple[DefaultDict[str, int], int]:
registers: DefaultDict[str, int] = defaultdict(int)
biggest = 0
for instruction in instructions:
update = OPERATORS[instruction.op]
check = OPERATORS[instruction.check]
register = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_most_valuable(self):\n return self.most_valuable",
"def computeActionFromValues(self, state):\n \"*** YOUR CODE HERE ***\"\n maxvalue = -100000000\n bestaction = None\n for action in self.mdp.getPossibleActions(state):\n valueforthisaction = self.getQValue(stat... | [
"0.5996123",
"0.5894548",
"0.5865219",
"0.5787033",
"0.5779433",
"0.57666355",
"0.56985855",
"0.56887287",
"0.56882644",
"0.5670334",
"0.56451887",
"0.56444883",
"0.5636384",
"0.56336486",
"0.56252307",
"0.55974555",
"0.55864197",
"0.5554566",
"0.55422884",
"0.5532165",
"0.55... | 0.65974396 | 0 |
Convert a URL to IDN notation | def _convert_to_idn(url):
# this function should only be called with a unicode string
# strategy: if the host cannot be encoded in ascii, then
# it'll be necessary to encode it in idn form
parts = list(urllib.parse.urlsplit(url))
try:
parts[1].encode('ascii')
except UnicodeEncodeError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_to_doi(url):\n return url[url.index(prefix):].rstrip(url_suffix).rstrip(INT_URL_SUFFIX)",
"def iri2uri(uri): \r\n if isinstance(uri ,unicode):\r\n (scheme, authority, path, query, fragment) = urlparse.urlsplit(uri)\r\n authority = authority.encode('idna')\r\n # For each charact... | [
"0.7021145",
"0.65356356",
"0.6437324",
"0.6412383",
"0.6395479",
"0.6311997",
"0.61961514",
"0.6158848",
"0.61555415",
"0.6119481",
"0.6110008",
"0.61025923",
"0.60946435",
"0.6066466",
"0.6030167",
"0.6021279",
"0.6020139",
"0.6007491",
"0.60052556",
"0.5983566",
"0.5945938... | 0.8388875 | 0 |
One epoch is a single tournament here | def one_epoch(self, tournament_id: int, epoch=0):
# TODO: tournament pre-fetcher
tournament = Tournament(tournament_id, cache=self.cache)
# Measure correlation before to see whether gradient update took effect
correlation_before = self.get_prediction_correlation(tournament)
cor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tournament(self):\n pass",
"def train_one_epoch(self):\n raise NotImplementedError",
"def train_epoch(self) -> None:\n ct = self.config.training\n total_games = self._get_total_games()\n print(f\"Total Games: {total_games}\")\n train_size = int(0.9 * total_games)\n... | [
"0.6938331",
"0.6872798",
"0.6221495",
"0.61553615",
"0.6041733",
"0.5884427",
"0.58615357",
"0.5858718",
"0.58503413",
"0.584667",
"0.58107626",
"0.5793915",
"0.57814837",
"0.5771732",
"0.57555825",
"0.57402873",
"0.5730085",
"0.5728672",
"0.57039595",
"0.57039595",
"0.57039... | 0.7137898 | 0 |
Get scores for all the teams | def get_scores(self, tournament: Tournament):
self.model.eval()
# collate_fn = lambda x: collate_teams(x, tournament.max_members)
dl_rank = DataLoader(tournament.ranking, num_workers=self.jobs, batch_size=self.bs, shuffle=False)
iterator = tqdm(dl_rank, position=0, desc=f'{tournament.tou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_team_scores(self):\n scores = defaultdict(lambda: {\n \"scored_xg\": [],\n \"conceded_xg\": [],\n \"home_adv\": 0,\n \"expected_points\": 0\n })\n\n for g in self.games:\n scores[g.HomeTeam][\"scored_xg\"].append(g.FTHG)\n ... | [
"0.77148676",
"0.6926027",
"0.6908442",
"0.6832203",
"0.68074715",
"0.67282873",
"0.67100906",
"0.6675928",
"0.66030395",
"0.6575878",
"0.6529839",
"0.647783",
"0.63599753",
"0.63421893",
"0.6304855",
"0.63044083",
"0.62909013",
"0.6269161",
"0.62505054",
"0.62181664",
"0.620... | 0.7616093 | 1 |
suit and value should be integers | def __init__(self, value, suit) -> None:
self.value = value
self.suit = suit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, value, suit):\n self.value = value # A,2,3,4,5,6,7,8,9,10,J,Q, or K\n self.suit = suit # hearts, diamonds, clubs, spades",
"def test_is_suit_integer(self):\n self.assertIsInstance(cardutils.Card(10,1).suit, int)",
"def suit(self):\r\n\t\tsuit = self.n // 13\r... | [
"0.7262717",
"0.7030172",
"0.67238253",
"0.66163784",
"0.65954757",
"0.65391135",
"0.6420939",
"0.6411027",
"0.6410355",
"0.6391943",
"0.6384562",
"0.63782066",
"0.63565224",
"0.63530475",
"0.6339618",
"0.63249195",
"0.62757915",
"0.62429863",
"0.6201983",
"0.61999196",
"0.61... | 0.7071617 | 1 |
Return comments tree by entity or root comment | async def get_comments_tree(request):
comment_id = request.match_info.get('comment_id')
if comment_id:
# valitation was in route (\d+)
comment_id = int(comment_id)
tree = CommentsTreeDAO.create_by_parent(comment_id)
else:
entity_type = request.match_info.get('entity_type')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_by_entity(entity_type, entity_id, only_roots=False):\n\n return CommentsTreeDAO(entity_type=entity_type, entity_id=entity_id,\n only_roots=only_roots)",
"async def fetch(self, conn, page=None, fdt=None, tdt=None):\n\n sql = \"\"\"SELECT\n ... | [
"0.65842324",
"0.63664144",
"0.63229674",
"0.6065913",
"0.6050549",
"0.6045573",
"0.60114443",
"0.5975179",
"0.5946544",
"0.58939505",
"0.587878",
"0.58299065",
"0.58249295",
"0.5780401",
"0.57469136",
"0.5738545",
"0.57361287",
"0.57340264",
"0.5731925",
"0.5722351",
"0.5712... | 0.7140785 | 0 |
checks to see if word is in dictionary, then checks if homophones | def word_check(word):
word1 = word[1:]
if word1 not in word_dict: return False
if not homophones (word, word1): return False
word2 = word[0] + word[2:]
if word2 not in word_dict: return False
if not homophones(word, word2): return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homophone_words(word_one, word_two, pron_dict):\n if word_one not in pron_dict or word_two not in pron_dict:\n return False\n return pron_dict[word_one] == pron_dict[word_two]",
"def homophones():\n pron = pronounce.read_dictionary('c06d')\n words = mkwrddct('words.txt')\n\n for word in... | [
"0.7909334",
"0.7649232",
"0.7379768",
"0.70193833",
"0.66508675",
"0.6501066",
"0.64329946",
"0.64270467",
"0.63939303",
"0.63705605",
"0.6364078",
"0.63594246",
"0.6337399",
"0.63142025",
"0.625433",
"0.62256026",
"0.6210163",
"0.6180701",
"0.6136245",
"0.6133826",
"0.61200... | 0.80829525 | 0 |
Generate the positions from trace | def posns_from_trace(trace):
posns = []
for i in range((len(trace.variables)-1)//2):
var_x = trace.variables[2*i]
var_y = trace.variables[2*i+1]
car_i = int(var_x.name.split('_')[2])
xy = (var_x.value.item(), var_y.value.item())
if len(posns) <= car_i:
pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positions(self, tileID, numSamples):",
"def BeamPosition():\n \n XPOS, YPOS = [], []\n\n x=0\n for j in range(0,6,1):\n x += 0.1\n y=0\n for k in range(0,6,1):\n y += 0.2\n XPOS.append(x)\n YPOS.append(y)\n\n return XPOS, YPOS",
"def gene... | [
"0.6406588",
"0.62758404",
"0.62750536",
"0.61463076",
"0.611264",
"0.6014426",
"0.6004055",
"0.5968917",
"0.5884226",
"0.5875474",
"0.5816131",
"0.5784888",
"0.5737535",
"0.5731324",
"0.5729159",
"0.5626728",
"0.56128687",
"0.5607636",
"0.5580684",
"0.5576681",
"0.5570371",
... | 0.706652 | 0 |
Parts should call draw on its child parts. It should determine if a change has been made, and if so, make the change and call update. If a part has pasted outside its region, it should return True Parts should not make changes to the display until draw has been called! This is because the order parts are drawn is impor... | def draw(self, force=False):
self.display.draw(force) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, force = False):\n\t\tpass",
"def _onPaint(self, evt):\n if not self._isRealized:\n self.realize()\n if self._drawn < 2:\n self.draw(repaint = False)\n self._drawn += 1\n self.gui_repaint(drawDC=wx.PaintDC(self))",
"def draw(self, force=False)... | [
"0.6380005",
"0.593526",
"0.5855134",
"0.572638",
"0.56879467",
"0.564566",
"0.56153196",
"0.5614835",
"0.5576688",
"0.55423486",
"0.5540616",
"0.55378747",
"0.55355537",
"0.5513865",
"0.55125195",
"0.54864395",
"0.5464399",
"0.5464399",
"0.54607123",
"0.5451927",
"0.5438394"... | 0.5939307 | 1 |
Returns True if the coord is in Part or any of its children. May be a better idea to call the get_part_containing function instead though, which returns the lowest level Part that contains the coord (none of its children contain the coord, but the Part does) | def contains(self, coord):
# print(coord, self.position, self.size)
return (0 <= coord[0] - self.position[0] < self.size[0] and
0 <= coord[1] - self.position[1] < self.size[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_part_containing(self, coord):\n # print('in', self)\n for k, child in self.children.items():\n # print('try', k, child)\n if child.ignore:\n # print('ignore', k, child)\n continue\n if child.contains(coord):\n # pri... | [
"0.75447255",
"0.6645123",
"0.66114485",
"0.6500257",
"0.6442654",
"0.64163774",
"0.6345653",
"0.63166255",
"0.61932963",
"0.6176176",
"0.6176057",
"0.61623186",
"0.61566186",
"0.6145891",
"0.6117253",
"0.60773057",
"0.60773057",
"0.6069949",
"0.6057143",
"0.6003461",
"0.5990... | 0.7134822 | 1 |
Returns the lowest Part that contains the coord (a part that contains the coord where none of its children contain the coord) Assumes that self already contains coord! Please check this if you are not sure! | def get_part_containing(self, coord):
# print('in', self)
for k, child in self.children.items():
# print('try', k, child)
if child.ignore:
# print('ignore', k, child)
continue
if child.contains(coord):
# print('contained... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findMin(self):\n curr = self\n while curr.hasLeftChild():\n curr = curr.leftChild\n return curr",
"def get_parent_by_coord(x, y, w, h, states: [State]) -> State:\n parents = [state for state in states if is_state_a_child_by_coord(x, y, w, h, state)]\n if not parents:\n ... | [
"0.65753007",
"0.64252496",
"0.6329845",
"0.6284443",
"0.6221933",
"0.6202329",
"0.61960083",
"0.61666095",
"0.6122884",
"0.60579133",
"0.601533",
"0.59646225",
"0.59528434",
"0.5939711",
"0.58846384",
"0.5878549",
"0.5874045",
"0.5835615",
"0.58301",
"0.5770619",
"0.5761702"... | 0.7808834 | 0 |
splink score histogram diagnostic plot public API function Compute a histogram using the provided buckets and plot the result. | def splink_score_histogram(
df_e: DataFrame,
spark: SparkSession,
buckets=None,
score_colname=None,
symmetric=True,
):
rows = _calc_probability_density(
df_e,
spark=spark,
buckets=buckets,
score_colname=score_colname,
symmetric=symmetric,
)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeHistogram(values, numBins, xLabel, yLabel, title=None):",
"def plot_hitstogram_graph(data_values, title,\r\n number_of_keys,\r\n max_val,\r\n file_in):\r\n\r\n # bins = max(data_values)\r\n # pylab.hist(data_values, facecolo... | [
"0.65873337",
"0.65499824",
"0.6416419",
"0.6398828",
"0.6303546",
"0.6264724",
"0.6263202",
"0.6211154",
"0.6202789",
"0.61877424",
"0.6169316",
"0.6159507",
"0.61091715",
"0.6084146",
"0.60816425",
"0.6069394",
"0.6049768",
"0.603087",
"0.60236806",
"0.6020201",
"0.6001724"... | 0.6923532 | 0 |
Convert an ascii format PSD to XML. | def _convert_psd(self, ascii_format, ifo):
command = ["convert_psd_ascii2xml",
"--fname-psd-ascii", f"{ascii_format}",
"--conventional-postfix",
"--ifo", f"{ifo}"]
pipe = subprocess.Popen(command,
std... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exportXml ( w, xml ):\n assert str ( type ( xml ) ) == \"<type 'str'>\"\n rawText = xml\n pattern = re.compile (r'[^\\S ]+')\n text = re.sub ( pattern, \"\", rawText )\n reparsed = MD.parseString ( text )\n w.write ( reparsed.toprettyxml ( indent = \"\\t\", encoding = \"UTF-8\" ) )",
"def t... | [
"0.55738395",
"0.54602534",
"0.54489726",
"0.53523225",
"0.52660984",
"0.52540344",
"0.5241616",
"0.5230467",
"0.5184351",
"0.51782966",
"0.5153558",
"0.51349664",
"0.50608534",
"0.5040427",
"0.50386435",
"0.5021166",
"0.5018161",
"0.49920428",
"0.49768257",
"0.49715346",
"0.... | 0.6901742 | 0 |
Construct a DAG file in order to submit a production to the condor scheduler using util_RIFT_pseudo_pipe.py | def build_dag(self, user=None):
cwd = os.getcwd()
#os.chdir(self.production.event.meta['working directory'])
#os.chdir(os.path.join(self.production.event.repository.directory,
# self.category))
if self.production.event.repository:
gps_file = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(\n metadata: ProjectMetadata, pipeline_name, env, target_path\n): # pylint: disable=too-many-locals\n loader = jinja2.FileSystemLoader(str(Path(__file__).parent))\n jinja_env = jinja2.Environment(autoescape=True, loader=loader, lstrip_blocks=True)\n jinja_env.filters[\"slugify\"] = slugify\... | [
"0.6791086",
"0.66254175",
"0.6543903",
"0.6439742",
"0.62908417",
"0.6201106",
"0.5974608",
"0.5915672",
"0.58422476",
"0.57603854",
"0.56926197",
"0.5625026",
"0.5587469",
"0.556881",
"0.55680734",
"0.5542769",
"0.54487556",
"0.5446099",
"0.54422826",
"0.5420124",
"0.540782... | 0.67467165 | 1 |
Submit a DAG file to the condor cluster (using the RIFT dag name). This is an overwrite of the near identical parent function submit_dag() | def submit_dag(self):
os.chdir(self.production.rundir)
os.system("cat *_local.cache > local.cache")
for psdfile in self.production.get_psds("xml"):
ifo = psdfile.split("/")[-1].split("_")[1].split(".")[0]
os.system(f"cp {psdfile} {ifo}-psd.xml.gz")
self.before_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit_dag(config, dag_file):\n with SUBMIT_LOCK:\n try:\n condor_dag_cmd = osp.join(get_condor_bin_dir(config),\n CONDOR_COMMAND['dag'])\n\n pipe = subprocess.Popen(args=(condor_dag_cmd, '-force', dag_file),\n ... | [
"0.7314224",
"0.709528",
"0.63085747",
"0.6191946",
"0.60718346",
"0.5973721",
"0.59433025",
"0.5939774",
"0.5474602",
"0.5430673",
"0.53907543",
"0.53773415",
"0.5344598",
"0.52862775",
"0.52801114",
"0.52279294",
"0.5198155",
"0.5184064",
"0.5162414",
"0.5139023",
"0.512411... | 0.7345251 | 0 |
Collect all of the log files which have been produced by this production and return their contents as a dictionary. | def collect_logs(self):
logs = glob.glob(f"{self.production.rundir}/*.err") #+ glob.glob(f"{self.production.rundir}/*/logs/*")
logs += glob.glob(f"{self.production.rundir}/*.out")
messages = {}
for log in logs:
with open(log, "r") as log_f:
message = log_f.rea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllEntries(self):\n \n log_entries_dict = collections.defaultdict(list)\n for logfile in os.listdir(self.log_folder):\n log = os.path.join(self.log_folder, logfile)\n with open(log, 'rb') as l:\n logCSVreader = csv.reader(l, delimiter=\"|\")\n ... | [
"0.7099511",
"0.685938",
"0.6689108",
"0.65805835",
"0.654927",
"0.65117294",
"0.6469987",
"0.6433183",
"0.6433183",
"0.63312954",
"0.63312954",
"0.6329445",
"0.626463",
"0.6235582",
"0.6214215",
"0.61539227",
"0.61492366",
"0.6038331",
"0.60342073",
"0.6025179",
"0.5985445",... | 0.8644327 | 0 |
Builds the sbatch file in order to combine genomics.vcf samples contained in current_batch in a single one. | def build_GenotypeGVCFs_sbatch(working_dir, combined_gvcf_files, scratch=False, interval=None):
name_batch1 = os.path.basename([item for item in combined_gvcf_files if "batch1" in item][0])
interval_name = ""
#there must be at least one batch so look for it, not elegant but works
if name_batch1.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GenotypeGVCFs():\n #creates sbatch files to merge batches of batch_size genomics vcf\n cwd = os.getcwd()\n sbatch_files = []\n if not os.path.isdir(os.path.join(cwd, \"01_CombineGVCFs\")):\n sys.exit(\"Directory 01_CombineGVCFs does not exits exists, something went wrong here.\")\n if os.... | [
"0.672763",
"0.58610225",
"0.5566432",
"0.5434747",
"0.5414289",
"0.5365546",
"0.53649545",
"0.5345907",
"0.5329101",
"0.52768123",
"0.52546614",
"0.5217361",
"0.5212177",
"0.5211676",
"0.5201498",
"0.5170869",
"0.5153864",
"0.5102112",
"0.5095486",
"0.509299",
"0.5088659",
... | 0.7443647 | 0 |
Runs GenotypeGVCFs on all combined files produced previosuly (assumes folder structure) | def GenotypeGVCFs():
#creates sbatch files to merge batches of batch_size genomics vcf
cwd = os.getcwd()
sbatch_files = []
if not os.path.isdir(os.path.join(cwd, "01_CombineGVCFs")):
sys.exit("Directory 01_CombineGVCFs does not exits exists, something went wrong here.")
if os.path.isdir(os.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genotype_gvcfs(gatk, xmx, cores,\n inputs, output,\n reference, bed_file=None):\n commands = []\n command = GENOTYPEGVCFS_TEMPLATE.format(xmx, gatk, reference, output)\n command = command + ' --variant ' + ' --variant '.join(inputs)\n if bed_file is not None:\n command = comma... | [
"0.6848684",
"0.6842689",
"0.66581684",
"0.65295035",
"0.6394109",
"0.6241394",
"0.62080246",
"0.6191771",
"0.6087738",
"0.60208416",
"0.5983195",
"0.59366655",
"0.5929118",
"0.5920719",
"0.5885988",
"0.58807164",
"0.5872283",
"0.5867078",
"0.5824099",
"0.5782577",
"0.5766673... | 0.77105707 | 0 |
Returns a duplicate of the profile instance. | def duplicate(self):
duplicate = Profile()
for i in self.__dict__:
if type(getattr(self, i)) is dict:
setattr(duplicate, i, getattr(self, i).copy())
else:
setattr(duplicate, i, getattr(self, i))
return duplicate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return Population(self)",
"def copy(self):\n return self.__class__(dict(self))",
"def copy(self):\n return self.__class__(self)",
"def copy(self):\n return self.__class__(self)",
"def strip_copy(self):\n return strip_profiles_copy(self)",
"def get_full... | [
"0.65038234",
"0.6457992",
"0.6320341",
"0.6320341",
"0.6286995",
"0.62803096",
"0.6278374",
"0.62589824",
"0.6257265",
"0.62398297",
"0.62353045",
"0.6209959",
"0.6207495",
"0.61983556",
"0.61954135",
"0.61781174",
"0.61590487",
"0.6154005",
"0.6154005",
"0.6154005",
"0.6138... | 0.81918967 | 0 |
To save this profile intance to xml file using a XmlWriter. xwriter>should be a XmlWriter instance. | def save_to_xml(self, xwriter):
xwriter.WriteStartElement("Profile")
xwriter.WriteAttributeString("Name", self.Name)
xwriter.WriteStartAttribute("Version")
xwriter.WriteValue(self.Version)
xwriter.WriteEndAttribute()
for var_name in self.__dict__:
v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_profile(file_path, profile):\r\n try:\r\n xSettings = XmlWriterSettings()\r\n xSettings.Indent = True\r\n with XmlWriter.Create(file_path, xSettings) as writer:\r\n profile.save_to_xml(writer)\r\n except Exception, ex:\r\n MessageBox.Show(\"An error occured wri... | [
"0.75539035",
"0.66137195",
"0.6487311",
"0.64123094",
"0.61329263",
"0.6101124",
"0.60908806",
"0.60279024",
"0.60243684",
"0.59840643",
"0.59765226",
"0.58507067",
"0.585065",
"0.58390087",
"0.58205575",
"0.58169997",
"0.5809403",
"0.58001035",
"0.56534475",
"0.5646809",
"0... | 0.7909768 | 0 |
Writes a dictionary to an xml file in the form of etc. attribute_name>The name of the dictonary attribute to write. xmlwriter>The xml writer to write with. write_empty>A bool of whether to write empty values to the xml file. Default is don't write them. | def write_dict_to_xml(self, attribute_name, xmlwriter, write_empty=False):
if attribute_name in ("IllegalCharacters", "Months"):
write_empty = True
dictionary = getattr(self, attribute_name)
xmlwriter.WriteStartElement(attribute_name)
for key in dictionary:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeDictToXMLFile(outfile, target, dict):\n targetStr = \"\\t\\t<Target>%s</Target>\\n\" % (escape(target),)\n for key in dict.keys():\n outfile.write('\\t<AVU>\\n')\n outfile.write(targetStr)\n outfile.write(\"\\t\\t<Attribute>%s</Attribute>\\n\" % (escape(key),) )\n outfile... | [
"0.6729531",
"0.65415585",
"0.6262941",
"0.6016264",
"0.5983849",
"0.5939113",
"0.58700234",
"0.58539236",
"0.5813194",
"0.5684836",
"0.56377923",
"0.56335074",
"0.5623472",
"0.56098765",
"0.55822074",
"0.5524061",
"0.5433924",
"0.5403624",
"0.5400973",
"0.53912425",
"0.53563... | 0.80239266 | 0 |
Writes a list to an xml file in the form of value value etc. attribute_name>The name of the list attribute to write. xmlwriter>The xml writer to write with. write_empty>A bool of whether to write empty values to the xml file. Default is don't write them. | def write_list_to_xml(self, attribute_name, xmlwriter, write_empty=False):
attribute_list = getattr(self, attribute_name)
xmlwriter.WriteStartElement(attribute_name)
for item in attribute_list:
if item or write_empty:
xmlwriter.WriteElementString("Item", item)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(lst):\n # TODO",
"def write(self, data, filename):\n id_ = 1\n weightlist_el = Element('weight-list')\n for dataset in data:\n weight_el = SubElement(weightlist_el, 'weight')\n id_el = SubElement(weight_el, 'id')\n id_el.text = str(id_)\n ... | [
"0.6497926",
"0.6048247",
"0.60110986",
"0.5987103",
"0.59648246",
"0.5957363",
"0.5939886",
"0.57804435",
"0.5734696",
"0.57158196",
"0.5674186",
"0.5656518",
"0.56491786",
"0.55900544",
"0.55637085",
"0.55263245",
"0.546913",
"0.54400545",
"0.54337585",
"0.54084957",
"0.539... | 0.8491795 | 0 |
Writes a string to an xml file in the form of string attribute_name>The name of the string attribute to write. xmlwriter>The xml writer to write with. write_empty>A bool of whether to write empty strings to the xml file. Default is write empty strings. | def write_string_to_xml(self, attribute_name, xmlwriter, write_empty=True):
string = getattr(self, attribute_name)
if string or write_empty:
xmlwriter.WriteElementString(attribute_name, string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_write_string():\n buf = make_buffer()\n writer = XmlWriter(buf)\n writer.write_element('value', 'myvalue')\n writer.flush()\n assert_equals(decode_buffer(buf), '<value>myvalue</value>')",
"def write_dict_to_xml(self, attribute_name, xmlwriter, write_empty=False):\r\n if attribute_n... | [
"0.6247003",
"0.58558315",
"0.5849161",
"0.57865465",
"0.5765893",
"0.5722448",
"0.5617337",
"0.5580295",
"0.55794567",
"0.554683",
"0.55136317",
"0.55108947",
"0.54859346",
"0.54719436",
"0.5470503",
"0.54250485",
"0.53961504",
"0.5380822",
"0.5374993",
"0.53526664",
"0.5339... | 0.8222901 | 0 |
Writes a boolean to an xml file in the form of true/false attribute_name>The name of the attribute to write. xmlwriter>The xml writer to write with. | def write_bool_to_xml(self, attribute_name, xmlwriter):
xmlwriter.WriteStartElement(attribute_name)
xmlwriter.WriteValue(getattr(self, attribute_name))
xmlwriter.WriteEndElement() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeAttribute(self, *args):\n if type(args[1]) == type(True): return _libsbml.XMLOutputStream_writeAttributeBool(self, *args)\n\n\n return _libsbml.XMLOutputStream_writeAttribute(self, *args)",
"def writeAttributeBool(self, *args):\n return _libsbml.XMLOutputStream_writeAttributeBool(se... | [
"0.74465925",
"0.73603874",
"0.7117586",
"0.67680955",
"0.66733044",
"0.63848156",
"0.62347335",
"0.59897983",
"0.591663",
"0.5848001",
"0.57468945",
"0.564458",
"0.5640521",
"0.5636943",
"0.561803",
"0.5609525",
"0.5577795",
"0.557284",
"0.55520767",
"0.5486341",
"0.54855955... | 0.8478797 | 0 |
Load profiles from a xml file. If no profiles are found it creates a blank profile. file_path>The absolute path to the profile file Returns a dict of the found profiles and a list of the lastused profile(s) | def load_profiles(file_path):
profiles, lastused = load_profiles_from_file(file_path)
if len(profiles) == 0:
#Just in case
profiles["Default"] = Profile()
profiles["Default"].Name = "Default"
#Some default templates
profiles["Default"].FileTemplate = "{<series>}{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_profiles_from_file(file_path):\r\n profiles = {}\r\n\r\n lastused = \"\"\r\n\r\n if File.Exists(file_path):\r\n try:\r\n with StreamReader(file_path) as xmlfile:\r\n xmldoc = XmlDocument()\r\n xmldoc.Load(xmlfile)\r\n\r\n if xmldoc.Docume... | [
"0.81233364",
"0.77697146",
"0.67844415",
"0.6566505",
"0.636305",
"0.62747896",
"0.6168049",
"0.6128615",
"0.61190236",
"0.6096743",
"0.5969697",
"0.5946075",
"0.59331304",
"0.5897405",
"0.58071595",
"0.57577217",
"0.5669829",
"0.564856",
"0.55757815",
"0.5557105",
"0.553909... | 0.7774989 | 1 |
Loads profiles from a file. file_path>The absolute path the xml file Returns a dict of the profiles | def load_profiles_from_file(file_path):
profiles = {}
lastused = ""
if File.Exists(file_path):
try:
with StreamReader(file_path) as xmlfile:
xmldoc = XmlDocument()
xmldoc.Load(xmlfile)
if xmldoc.DocumentElement.Name == "Profiles":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_profiles(file_path):\r\n profiles, lastused = load_profiles_from_file(file_path)\r\n\r\n return profiles",
"def load_profiles(file_path):\r\n profiles, lastused = load_profiles_from_file(file_path)\r\n\r\n if len(profiles) == 0:\r\n #Just in case\r\n profiles[\"Default\"] = P... | [
"0.7816373",
"0.7494791",
"0.69231015",
"0.68052244",
"0.669596",
"0.6337234",
"0.6331917",
"0.60487854",
"0.6018389",
"0.59737855",
"0.59296596",
"0.59177107",
"0.57330143",
"0.57177866",
"0.5666612",
"0.5610871",
"0.56013894",
"0.5478734",
"0.54241526",
"0.5402424",
"0.5382... | 0.755472 | 1 |
Load profiles from a xml file. If no profiles are found it returns an empty dict. file_path>The absolute path to the profile file Returns a dict of the found profiles. | def import_profiles(file_path):
profiles, lastused = load_profiles_from_file(file_path)
return profiles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_profiles_from_file(file_path):\r\n profiles = {}\r\n\r\n lastused = \"\"\r\n\r\n if File.Exists(file_path):\r\n try:\r\n with StreamReader(file_path) as xmlfile:\r\n xmldoc = XmlDocument()\r\n xmldoc.Load(xmlfile)\r\n\r\n if xmldoc.Docume... | [
"0.7626121",
"0.73465997",
"0.66420317",
"0.64548403",
"0.6422596",
"0.61153334",
"0.60498744",
"0.59523565",
"0.5855331",
"0.57868946",
"0.5670626",
"0.56380814",
"0.5517114",
"0.5462929",
"0.54440254",
"0.54290825",
"0.5421971",
"0.5367816",
"0.53443223",
"0.53429097",
"0.5... | 0.74111307 | 1 |
Saves the profiles to an xml file. | def save_profiles(file_path, profiles, lastused=""):
try:
xSettings = XmlWriterSettings()
xSettings.Indent = True
with XmlWriter.Create(file_path, xSettings) as writer:
writer.WriteStartElement("Profiles")
if lastused:
writer.WriteAttributeStrin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_profile(file_path, profile):\r\n try:\r\n xSettings = XmlWriterSettings()\r\n xSettings.Indent = True\r\n with XmlWriter.Create(file_path, xSettings) as writer:\r\n profile.save_to_xml(writer)\r\n except Exception, ex:\r\n MessageBox.Show(\"An error occured wri... | [
"0.77402055",
"0.7153504",
"0.68901503",
"0.65989304",
"0.6585187",
"0.6567334",
"0.65197617",
"0.64477056",
"0.6292227",
"0.62706214",
"0.62006843",
"0.61452764",
"0.6128959",
"0.610915",
"0.6092176",
"0.6072949",
"0.60326505",
"0.60216737",
"0.5989765",
"0.5988323",
"0.5958... | 0.76685476 | 1 |
Saves a single profile to an xml file. | def save_profile(file_path, profile):
try:
xSettings = XmlWriterSettings()
xSettings.Indent = True
with XmlWriter.Create(file_path, xSettings) as writer:
profile.save_to_xml(writer)
except Exception, ex:
MessageBox.Show("An error occured writing the settings fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_profile(self):\n self.save()",
"def save_profiles(file_path, profiles, lastused=\"\"):\r\n try:\r\n xSettings = XmlWriterSettings()\r\n xSettings.Indent = True\r\n with XmlWriter.Create(file_path, xSettings) as writer:\r\n writer.WriteStartElement(\"Profiles\")\... | [
"0.720293",
"0.71852773",
"0.6845692",
"0.6742488",
"0.6558711",
"0.6505063",
"0.645329",
"0.64384377",
"0.6373711",
"0.63664985",
"0.6296266",
"0.6280068",
"0.62594324",
"0.6223609",
"0.6212394",
"0.6104943",
"0.60820746",
"0.60820746",
"0.6042483",
"0.60255325",
"0.60242546... | 0.8002179 | 0 |
This function returns the softmax derivative value for the given input | def softmax_derivative(x):
der = derivative(softmax,x,dx=1e-9)
return der | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax_derivative(Z):\n\treturn None",
"def softmax(x):\n e_x = np.exp(x - np.max(x))\n return e_x / e_x.sum(axis=0) # only difference",
"def softmax(x):\r\n e_x = np.exp(x - np.max(x))\r\n return e_x / e_x.sum(axis=0) # only difference\r",
"def softmax(x):\r\n e_x = np.exp(x - np... | [
"0.78823423",
"0.7861486",
"0.7818649",
"0.78063107",
"0.7801125",
"0.7801125",
"0.7801125",
"0.7801125",
"0.77747434",
"0.7771414",
"0.7755482",
"0.7754241",
"0.76962405",
"0.7687193",
"0.7682934",
"0.76776224",
"0.76399696",
"0.7632133",
"0.7632133",
"0.76276577",
"0.762613... | 0.8873611 | 0 |
AppendRows(numRows=1) > bool Append additional rows at the end of the table. | def AppendRows(self, numRows=1): # real signature unknown; restored from __doc__
return (self.GetNumberRows() + numRows) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AppendRows(self, numRows = 1):\n for i in range(numRows):\n self.data = numpy.vstack((self.data,\n numpy.array([''] * self.data.shape[1], dtype = numpy.object),\n ))\n self.rowmask = numpy.append(self.rowmask, nu... | [
"0.82234913",
"0.7680864",
"0.7680864",
"0.67422974",
"0.66286564",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.65267634",
"0.62137854",
"0.60128397",
"0.60119236",
"0.5857733",
"0.5790014",
"0.5778878",
"... | 0.7819538 | 1 |
DeleteRows(pos=0, numRows=1) > bool Delete rows from the table. | def DeleteRows(self, pos=0, numRows=1): # real signature unknown; restored from __doc__
if self.data is None or len(self.data) == 0:
return False
for rowNum in range(0,numRows):
self.data.remove(self.data[numRows-1-pos-rowNum])
gridView=self.GetView()
gridView.Be... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteRows(self, pos=0, numRows=1): # real signature unknown; restored from __doc__\n if self.data is None or len(self.data) == 0:\n return False\n for rowNum in range(0, numRows):\n self.data.remove(self.data[numRows - 1 - pos - rowNum])\n gridView = self.GetView()\... | [
"0.8509247",
"0.8509247",
"0.7138309",
"0.6614276",
"0.6614276",
"0.6300265",
"0.6087969",
"0.59195846",
"0.59115934",
"0.5869983",
"0.58482474",
"0.57762325",
"0.57336473",
"0.570933",
"0.56701875",
"0.56412894",
"0.56196254",
"0.5617777",
"0.56165785",
"0.56080425",
"0.5603... | 0.85211456 | 0 |
DeleteRows(pos=0, numRows=1) > bool Delete rows from the table. | def DeleteRows(self, pos=0, numRows=1): # real signature unknown; restored from __doc__
if self.data is None or len(self.data) == 0:
return False
for rowNum in range(0,numRows):
self.data.remove(self.data[numRows-1-pos-rowNum])
gridView=self.GetView()
gridView.Be... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteRows(self, pos=0, numRows=1): # real signature unknown; restored from __doc__\n if self.data is None or len(self.data) == 0:\n return False\n for rowNum in range(0, numRows):\n self.data.remove(self.data[numRows - 1 - pos - rowNum])\n gridView = self.GetView()\... | [
"0.8509247",
"0.8509247",
"0.7138309",
"0.6614276",
"0.6614276",
"0.6300265",
"0.6087969",
"0.59195846",
"0.59115934",
"0.5869983",
"0.58482474",
"0.57762325",
"0.57336473",
"0.570933",
"0.56701875",
"0.56412894",
"0.56196254",
"0.5617777",
"0.56165785",
"0.56080425",
"0.5603... | 0.85211456 | 1 |
AppendCols(numCols=1) > bool Exactly the same as AppendRows() but for columns. | def AppendCols(self, numCols=1): # real signature unknown; restored from __doc__
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_cols(cat, prefix=\"\", floatcols=None, boolcols=None):\n\t\n\tif floatcols != None:\n\t\tfor col in floatcols:\n\t\t\tcat.add_column(astropy.table.MaskedColumn(name=prefix+col, dtype=float, length=len(cat)))\n\t\t\tcat[prefix+col].mask = [True] * len(cat)\n\tif boolcols != None:\n\t\tfor col in boolcol... | [
"0.6017477",
"0.5631939",
"0.55924374",
"0.5548952",
"0.5529502",
"0.5455568",
"0.5444327",
"0.54101974",
"0.53786486",
"0.53754896",
"0.53557205",
"0.5345275",
"0.53391767",
"0.53190124",
"0.5316484",
"0.5307784",
"0.528852",
"0.5280459",
"0.5254802",
"0.525032",
"0.5224798"... | 0.89480335 | 0 |
AppendCols(numCols=1) > bool Exactly the same as AppendRows() but for columns. | def AppendCols(self, numCols=1): # real signature unknown; restored from __doc__
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_cols(cat, prefix=\"\", floatcols=None, boolcols=None):\n\t\n\tif floatcols != None:\n\t\tfor col in floatcols:\n\t\t\tcat.add_column(astropy.table.MaskedColumn(name=prefix+col, dtype=float, length=len(cat)))\n\t\t\tcat[prefix+col].mask = [True] * len(cat)\n\tif boolcols != None:\n\t\tfor col in boolcol... | [
"0.6017477",
"0.5631939",
"0.55924374",
"0.5548952",
"0.5529502",
"0.5455568",
"0.5444327",
"0.54101974",
"0.53786486",
"0.53754896",
"0.53557205",
"0.5345275",
"0.53391767",
"0.53190124",
"0.5316484",
"0.5307784",
"0.528852",
"0.5280459",
"0.5254802",
"0.525032",
"0.5224798"... | 0.89480335 | 1 |
Reset all noisy layers. | def reset_noise(self):
self.advantage_hidden_layer.reset_noise()
self.advantage_layer.reset_noise()
self.value_hidden_layer.reset_noise()
self.value_layer.reset_noise() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n for layer in self.network:\n layer.clean()",
"def reset_layers(self, rov_id): # Clear hidden layers and output layers\n for i in range(self.n_nodes):\n self.hid_layer[rov_id, i] = 0.0\n\n for j in range(self.n_outputs):\n self.out_layer[ro... | [
"0.75135684",
"0.7388977",
"0.7320769",
"0.7070128",
"0.6976212",
"0.69198513",
"0.69061995",
"0.6805137",
"0.67520696",
"0.67174494",
"0.6668943",
"0.6648948",
"0.6637794",
"0.66241336",
"0.6584105",
"0.65818655",
"0.6574278",
"0.65249395",
"0.6519634",
"0.6511302",
"0.64818... | 0.8044907 | 0 |
Given an undefined output folder path, we return the blank string | def test_make_output_folder_undefined_path(self):
test_object = Maic()
expected_result = ""
self.assertEqual(expected_result,
test_object.make_output_folder(output_folder=None),
"Should get back an empty string for an undefined "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_output_folder_blank_path(self):\n test_object = Maic()\n expected_result = \"\"\n self.assertEqual(expected_result,\n test_object.make_output_folder(output_folder=\"\"),\n \"Should get back an empty string for an output \"\n ... | [
"0.76985216",
"0.70029175",
"0.69376665",
"0.6890628",
"0.68563265",
"0.6776184",
"0.6774517",
"0.6737329",
"0.6688305",
"0.6654316",
"0.66089475",
"0.6563189",
"0.6542934",
"0.6504976",
"0.64609385",
"0.63817656",
"0.6361122",
"0.6351268",
"0.63438004",
"0.63324255",
"0.6330... | 0.78773004 | 0 |
Given an empty output folder path, we return the blank string | def test_make_output_folder_blank_path(self):
test_object = Maic()
expected_result = ""
self.assertEqual(expected_result,
test_object.make_output_folder(output_folder=""),
"Should get back an empty string for an output "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_output_folder_undefined_path(self):\n test_object = Maic()\n expected_result = \"\"\n self.assertEqual(expected_result,\n test_object.make_output_folder(output_folder=None),\n \"Should get back an empty string for an undefined \"\n ... | [
"0.7781955",
"0.6907767",
"0.66690165",
"0.6645506",
"0.6641241",
"0.66131055",
"0.65263367",
"0.63996685",
"0.6386103",
"0.6343422",
"0.6288943",
"0.62462056",
"0.6244957",
"0.61959714",
"0.6165891",
"0.61632746",
"0.6150932",
"0.61507374",
"0.60942763",
"0.6087422",
"0.6048... | 0.78897774 | 0 |
Given a complex folder path with multiple embedded slashes, check that the code tries to make the folder and returns the path with a single trailing '/' appended only if required | def test_make_output_folder_path_with_multi_slashes(self, mock_makedirs):
mock_makedirs.return_value = True
test_object = Maic()
path = '/c/o/m/p/l/e/x_p/a/t/h/'
expected_result = path
self.assertEqual(expected_result,
test_object.make_output_folder(outpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_folder_path(folder_path):\n if folder_path[-1] != '/':\n folder_path += '/'\n\n return folder_path",
"def test_fix_path(self):\n\n expected = \"hello\" + PyFunceble.directory_separator + \"world\" + PyFunceble.directory_separator # pylint: disable=line-too-long\n actual = D... | [
"0.7249269",
"0.6797798",
"0.6691372",
"0.6648862",
"0.6491748",
"0.6453401",
"0.6421338",
"0.63004524",
"0.62997335",
"0.6285595",
"0.62594306",
"0.6247562",
"0.62401736",
"0.62397146",
"0.6239207",
"0.6219014",
"0.62041944",
"0.61918926",
"0.6191478",
"0.61791414",
"0.61717... | 0.6893744 | 1 |
Check that an output folder path that exists but does not end with something that looks like a timestamp gets a timestamp added | def test_make_output_folder_exists_no_timestamp(self, mock_makedirs,
mock_logger):
mock_makedirs.side_effect = [OSError, True]
test_object = Maic()
path = "my_path"
sep = os.sep
if os.sep == '\\':
# we've got a backs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_output_folder_exists_with_timestamp_fails(self,\n mock_makedirs):\n mock_makedirs.side_effect = [OSError]\n test_object = Maic()\n path = \"my_path-1960-04-04--15-00\"\n try:\n test_object.make_output_fo... | [
"0.65769327",
"0.6254106",
"0.62120444",
"0.61580235",
"0.60756755",
"0.602552",
"0.60144717",
"0.6014027",
"0.6002626",
"0.59853584",
"0.5975292",
"0.5899892",
"0.58989424",
"0.5844146",
"0.5834909",
"0.5810283",
"0.5796441",
"0.5729634",
"0.5713246",
"0.57086563",
"0.567258... | 0.6856277 | 0 |
Check that an output folder path that exists and does end with something that looks like a timestamp raises an exception | def test_make_output_folder_exists_with_timestamp_fails(self,
mock_makedirs):
mock_makedirs.side_effect = [OSError]
test_object = Maic()
path = "my_path-1960-04-04--15-00"
try:
test_object.make_output_folder(output_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_output_folder_exists_no_timestamp(self, mock_makedirs,\n mock_logger):\n mock_makedirs.side_effect = [OSError, True]\n test_object = Maic()\n path = \"my_path\"\n sep = os.sep\n if os.sep == '\\\\':\n # w... | [
"0.66987944",
"0.63590485",
"0.6132183",
"0.60929406",
"0.604455",
"0.6034466",
"0.60191363",
"0.60158616",
"0.59803444",
"0.59565026",
"0.59523237",
"0.5931433",
"0.5840402",
"0.57827204",
"0.5757492",
"0.5711939",
"0.5690312",
"0.5685456",
"0.5668919",
"0.566759",
"0.565680... | 0.68613607 | 0 |
Function to remove the line numbers from the debug output of gyp and thus reduce the extreme fragility of the stdout comparison tests. | def remove_debug_line_numbers(contents):
lines = contents.splitlines()
# split each line on ":"
lines = [l.split(":", 3) for l in lines]
# join each line back together while ignoring the
# 3rd column which is the line number
lines = [len(l) > 3 and ":".join(l[3:]) or l for l in lines]
return "\n".join(lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_curl_debug_lines(text: str) -> str:\n lines = text.split(\"\\n\")\n lines = [line for line in lines if not line.startswith(\"**\")]\n return \"\\n\".join(lines)",
"def lines_without_stdlib(self):\n prev_line = None\n current_module_path = inspect.getabsfile(inspect.currentframe(... | [
"0.6622459",
"0.59901255",
"0.59256816",
"0.58421296",
"0.581115",
"0.57030994",
"0.5660609",
"0.55992305",
"0.55508304",
"0.5550596",
"0.552097",
"0.55145377",
"0.54679954",
"0.5458479",
"0.5454181",
"0.54463637",
"0.54463637",
"0.53545886",
"0.53511184",
"0.5350658",
"0.534... | 0.7173805 | 0 |
File contents matcher that ignores line numbers. | def match_modulo_line_numbers(contents_a, contents_b):
contents_a = remove_debug_line_numbers(contents_a)
contents_b = remove_debug_line_numbers(contents_b)
return TestCommon.match_exact(contents_a, contents_b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_line_count(self):\n self.assertEqual(analyze_text(self.filename)[0], 11)",
"def test_line_count(self):\n self.assertEqual(analyze_text(self.filename)[0], 4)",
"def test_line_count(self):\n self.assertEqual(analyze_text(self.filename)[0], 4)",
"def _MatchPatternLines(self, in_str... | [
"0.6075021",
"0.6011866",
"0.6011866",
"0.5980236",
"0.58842176",
"0.5875963",
"0.5659142",
"0.5647999",
"0.5642151",
"0.5629507",
"0.5616189",
"0.560516",
"0.55971444",
"0.55460477",
"0.5533876",
"0.55265915",
"0.5506669",
"0.5466076",
"0.54504406",
"0.54157746",
"0.5407447"... | 0.6234986 | 0 |
Fails the test if the specified built file name does not exist. | def built_file_must_exist(self, name, type=None, **kw):
return self.must_exist(self.built_file_path(name, type, **kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def built_file_must_not_exist(self, name, type=None, **kw):\n return self.must_not_exist(self.built_file_path(name, type, **kw))",
"def check_build_exists(self):\n path = self.base_dir + \"/\" + self.app_name + \"/\" + \"build\"\n from django_swagger_utils.core.utils.check_path_exists import che... | [
"0.7556298",
"0.68302405",
"0.6742456",
"0.6706596",
"0.66908234",
"0.65641314",
"0.651123",
"0.6510022",
"0.6502727",
"0.64891094",
"0.64801955",
"0.64408535",
"0.6430225",
"0.6354745",
"0.6318534",
"0.6268824",
"0.62088376",
"0.6206341",
"0.6198592",
"0.61985487",
"0.617418... | 0.7726593 | 0 |
Fails the test if the specified built file name exists. | def built_file_must_not_exist(self, name, type=None, **kw):
return self.must_not_exist(self.built_file_path(name, type, **kw)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def built_file_must_exist(self, name, type=None, **kw):\n return self.must_exist(self.built_file_path(name, type, **kw))",
"def check_build_exists(self):\n path = self.base_dir + \"/\" + self.app_name + \"/\" + \"build\"\n from django_swagger_utils.core.utils.check_path_exists import check_path_... | [
"0.7764489",
"0.6900003",
"0.6773992",
"0.67330974",
"0.67238265",
"0.6665234",
"0.6645847",
"0.6642983",
"0.6570576",
"0.65533084",
"0.65091807",
"0.6487374",
"0.6403167",
"0.6386307",
"0.63263017",
"0.632228",
"0.62877107",
"0.6276694",
"0.62678105",
"0.6252823",
"0.6243601... | 0.75279915 | 1 |
Fails the test if the contents of the specified built file name do not match the specified contents. | def built_file_must_match(self, name, contents, **kw):
return self.must_match(self.built_file_path(name, **kw), contents) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def built_file_must_not_match(self, name, contents, **kw):\n return self.must_not_match(self.built_file_path(name, **kw), contents)",
"def built_file_must_not_contain(self, name, contents, **kw):\n return self.must_not_contain(self.built_file_path(name, **kw), contents)",
"def test_buildings_file_path(se... | [
"0.7865123",
"0.725757",
"0.6427956",
"0.6343546",
"0.61661303",
"0.6108487",
"0.6048125",
"0.6037537",
"0.60135037",
"0.59942937",
"0.5991819",
"0.59909046",
"0.5990231",
"0.5943843",
"0.5930705",
"0.5888282",
"0.5878586",
"0.58620876",
"0.5855489",
"0.5848895",
"0.58476365"... | 0.8206071 | 0 |
Fails the test if the contents of the specified built file name match the specified contents. | def built_file_must_not_match(self, name, contents, **kw):
return self.must_not_match(self.built_file_path(name, **kw), contents) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def built_file_must_match(self, name, contents, **kw):\n return self.must_match(self.built_file_path(name, **kw), contents)",
"def built_file_must_not_contain(self, name, contents, **kw):\n return self.must_not_contain(self.built_file_path(name, **kw), contents)",
"def built_file_must_exist(self, name, t... | [
"0.85351104",
"0.7359012",
"0.62920475",
"0.6136921",
"0.60466075",
"0.60382736",
"0.59580076",
"0.59560263",
"0.5939516",
"0.58847064",
"0.5883172",
"0.58079237",
"0.57745993",
"0.57733077",
"0.57392937",
"0.5728668",
"0.5728633",
"0.56980926",
"0.5695948",
"0.56950855",
"0.... | 0.79406774 | 1 |
Copies the test configuration from the specified source_dir (the directory in which the test script lives) to the specified dest_dir (a temporary working directory). This ignores all files and directories that begin with the string 'gyptest', and all '.svn' subdirectories. | def copy_test_configuration(self, source_dir, dest_dir):
for root, dirs, files in os.walk(source_dir):
if '.svn' in dirs:
dirs.remove('.svn')
dirs = [ d for d in dirs if not d.startswith('gyptest') ]
files = [ f for f in files if not f.startswith('gyptest') ]
for dirname in dirs:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_dir(source, dest, vars, verbosity=1, simulate=False, indent=0,\n sub_vars=True, interactive=False, overwrite=True,\n template_renderer=None, out_=sys.stdout):\n def out(msg):\n out_.write(msg)\n out_.write('\\n')\n out_.flush()\n # This allows you to ... | [
"0.5968082",
"0.5623668",
"0.55685383",
"0.5543154",
"0.54757017",
"0.53514683",
"0.5298348",
"0.5297488",
"0.5291825",
"0.5271045",
"0.5267549",
"0.52317536",
"0.51011693",
"0.5092042",
"0.5072532",
"0.5053451",
"0.50515586",
"0.5050869",
"0.50469726",
"0.5045372",
"0.501263... | 0.86488324 | 0 |
Initializes the .build_tool attribute. Searches the .build_tool_list for an executable name on the user's $PATH. The first tool on the list is used asis if nothing is found on the current $PATH. | def initialize_build_tool(self):
for build_tool in self.build_tool_list:
if not build_tool:
continue
if os.path.isabs(build_tool):
self.build_tool = build_tool
return
build_tool = self.where_is(build_tool)
if build_tool:
self.build_tool = build_tool
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_tool_path(self):",
"def __find_tool_path(self):\n tool_path = Path(os.path.dirname(os.path.realpath(__file__)))\n # We asume the installion path is relative to our installation path\n tool_path = tool_path / '../../../bin'\n if os.name == 'posix':\n ret = tool_pat... | [
"0.6117797",
"0.59801966",
"0.57670516",
"0.5763969",
"0.57467836",
"0.5693948",
"0.5670825",
"0.5632699",
"0.55697215",
"0.5522049",
"0.5520909",
"0.5454913",
"0.5439451",
"0.54242945",
"0.54215056",
"0.5409395",
"0.5408753",
"0.5398145",
"0.53854394",
"0.53382486",
"0.53367... | 0.84088266 | 0 |
Renames (relocates) the specified source (usually a directory) to the specified destination, creating the destination directory first if necessary. | def relocate(self, source, destination):
destination_dir = os.path.dirname(destination)
if not os.path.exists(destination_dir):
self.subdir(destination_dir)
os.rename(source, destination) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def os_rename(self, source, destination):\n cmd = ['/bin/mv', source, destination]\n process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\n returncode = subprocess.Popen.wait(process)\n return returncode",
"def hmove(src_path, res_path):\n os.rename... | [
"0.7349947",
"0.68736243",
"0.6767133",
"0.6640591",
"0.65091836",
"0.6415128",
"0.6383818",
"0.63748705",
"0.6370775",
"0.63415533",
"0.6336806",
"0.63208145",
"0.63091844",
"0.62984276",
"0.61878335",
"0.6184522",
"0.6032903",
"0.60203373",
"0.6016925",
"0.59881675",
"0.598... | 0.83426297 | 0 |
Reports that a build is not uptodate. This provides common reporting for formats that have complicated conditions for checking whether a build is uptodate. Formats that expect exact output from the command (make) can just set stdout= when they call the run_build() method. | def report_not_up_to_date(self):
print "Build is not up-to-date:"
print self.banner('STDOUT ')
print self.stdout()
stderr = self.stderr()
if stderr:
print self.banner('STDERR ')
print stderr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_build_log(mysettings, out=None):\n\tlogfile = mysettings.get(\"PORTAGE_LOG_FILE\")\n\tif logfile is None:\n\t\treturn\n\ttry:\n\t\tf = open(_unicode_encode(logfile, encoding=_encodings['fs'],\n\t\t\terrors='strict'), mode='rb')\n\texcept EnvironmentError:\n\t\treturn\n\n\tf_real = None\n\tif logfile.end... | [
"0.6245686",
"0.61322933",
"0.5972909",
"0.5953914",
"0.5951226",
"0.5934385",
"0.56919557",
"0.55922455",
"0.5552093",
"0.54457146",
"0.54384977",
"0.5403101",
"0.53969556",
"0.5394229",
"0.5389238",
"0.5372847",
"0.53642845",
"0.5359401",
"0.5345811",
"0.5342945",
"0.533501... | 0.7970113 | 0 |
Runs gyp against the specified gyp_file with the specified args. | def run_gyp(self, gyp_file, *args, **kw):
# When running gyp, and comparing its output we use a comparitor
# that ignores the line numbers that gyp logs in its debug output.
if kw.pop('ignore_line_numbers', False):
kw.setdefault('match', match_modulo_line_numbers)
# TODO: --depth=. works around... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TestGyp(*args, **kw):\n format = kw.pop('format', os.environ.get('TESTGYP_FORMAT'))\n if format != 'ninja':\n raise Exception(\"unknown format %r\" % format)\n return TestGypNinja(*args, **kw)",
"def build(self, gyp_file, target=None, **kw):\n raise NotImplementedError",
"def run_python_file(pytho... | [
"0.65655947",
"0.64958555",
"0.5667241",
"0.56293947",
"0.56070536",
"0.54797554",
"0.5434344",
"0.5331075",
"0.52507114",
"0.5226264",
"0.5204586",
"0.51571316",
"0.5147136",
"0.5133636",
"0.51022816",
"0.5073251",
"0.5073251",
"0.5066566",
"0.50257397",
"0.5001088",
"0.4970... | 0.673332 | 0 |
Runs a build of the specified target against the configuration generated from the specified gyp_file. A 'target' argument of None or the special value TestGyp.DEFAULT specifies the default argument for the underlying build tool. A 'target' argument of TestGyp.ALL specifies the 'all' target (if any) of the underlying bu... | def build(self, gyp_file, target=None, **kw):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_gyp(self, gyp_file, *args, **kw):\n\n # When running gyp, and comparing its output we use a comparitor\n # that ignores the line numbers that gyp logs in its debug output.\n if kw.pop('ignore_line_numbers', False):\n kw.setdefault('match', match_modulo_line_numbers)\n\n # TODO: --depth=. ... | [
"0.6142762",
"0.5641256",
"0.55775917",
"0.5569497",
"0.53769106",
"0.5277803",
"0.52763253",
"0.5215424",
"0.5061313",
"0.505405",
"0.5053484",
"0.49617815",
"0.49577522",
"0.49448642",
"0.49349135",
"0.4898354",
"0.489373",
"0.48929888",
"0.48899007",
"0.48863566",
"0.48392... | 0.76094955 | 0 |
Returns the base name of the specified file name, of the specified type. A bare=True keyword argument specifies that prefixes and suffixes shouldn't be applied. | def built_file_basename(self, name, type=None, **kw):
if not kw.get('bare'):
if type == self.EXECUTABLE:
name = name + self._exe
elif type == self.STATIC_LIB:
name = self.lib_ + name + self._lib
elif type == self.SHARED_LIB:
name = self.dll_ + name + self._dll
return na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_fullname(basename, _type=None):\n return '{}.{}'.format(basename, extensions.get(_type, None))",
"def base_name(self):\n return \".\".join(posixpath.basename(self.file_name).split(\".\")[:-1])",
"def basefname(fname):\n return os.path.splitext(fname.split(\"\\\\\")[-1])[0]",
"def base_n... | [
"0.7135192",
"0.6425883",
"0.63058126",
"0.62789595",
"0.61583006",
"0.615667",
"0.61490166",
"0.60626936",
"0.59788233",
"0.59788233",
"0.59788233",
"0.59684837",
"0.5965139",
"0.59572744",
"0.5927984",
"0.59277415",
"0.5919521",
"0.59044087",
"0.5902169",
"0.5895096",
"0.58... | 0.76263374 | 0 |
Runs an executable program built from a gypgenerated configuration. The specified name should be independent of any particular generator. Subclasses should find the output executable in the appropriate output build directory, tack on any necessary executable suffix, etc. | def run_built_executable(self, name, *args, **kw):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(self, progname):\n self.run_programm(self.COMPILED[self.progtype][0], \"%s %s %s\" %\\\n (progname, self.COMPILED[self.progtype][1], COMPILED_FILENAME ))\n\n compiled_progname=COMPILED_FILENAME\n return compiled_progname",
"def exe(self, name):\n\n return ... | [
"0.6624041",
"0.6600797",
"0.64478886",
"0.6147318",
"0.61315423",
"0.6088417",
"0.5887231",
"0.5876601",
"0.5817391",
"0.57601607",
"0.57026327",
"0.5663314",
"0.56571984",
"0.5645205",
"0.5624931",
"0.56230867",
"0.5593044",
"0.553381",
"0.5533443",
"0.553212",
"0.5465984",... | 0.7209196 | 0 |
Convert to cygwin path if we are using cygwin. | def ConvertToCygpath(path):
if sys.platform == 'cygwin':
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cygpath(filename):\n if sys.platform == 'cygwin':\n proc = Popen(['cygpath', '-am', filename], stdout=PIPE)\n return proc.communicate()[0].strip()\n else:\n return filename",
"def conditional_abspath (filename):\n if sys.platform.find('cygwin') != -1:\n return filename\n else:... | [
"0.8049506",
"0.73739505",
"0.7203524",
"0.7143538",
"0.67795306",
"0.6647246",
"0.6647246",
"0.65076965",
"0.6450253",
"0.6416357",
"0.61581916",
"0.6095484",
"0.60797286",
"0.607077",
"0.6055507",
"0.59301335",
"0.5853573",
"0.5805152",
"0.5760639",
"0.5707755",
"0.5666738"... | 0.82450604 | 0 |
Returns path to MSBuild for msvs_version or latest available. Looks in the registry to find install location of MSBuild. MSBuild before v4.0 will not build c++ projects, so only use newer versions. | def FindMSBuildInstallation(msvs_version = 'auto'):
import TestWin
registry = TestWin.Registry()
msvs_to_msbuild = {
'2013': r'12.0',
'2012': r'4.0', # Really v4.0.30319 which comes with .NET 4.5.
'2010': r'4.0'}
msbuild_basekey = r'HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions'
if not re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindVisualStudioInstallation():\n possible_roots = ['%s:\\\\Program Files%s' % (chr(drive), suffix)\n for drive in range(ord('C'), ord('Z') + 1)\n for suffix in ['', ' (x86)']]\n possible_paths = {\n '2013': r'Microsoft Visual Studio 12.0\\Common7\\IDE\\devenv.com',... | [
"0.74490994",
"0.61283606",
"0.60080606",
"0.5867908",
"0.5809241",
"0.5623859",
"0.55386347",
"0.55197555",
"0.55090356",
"0.5305542",
"0.5296578",
"0.5279354",
"0.5249882",
"0.5218957",
"0.5179512",
"0.5171492",
"0.51507473",
"0.5116992",
"0.5103813",
"0.509796",
"0.5077102... | 0.8086731 | 0 |
Returns appropriate values for .build_tool and .uses_msbuild fields of TestGypBase for Visual Studio. We use the value specified by GYP_MSVS_VERSION. If not specified, we search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable. Failing that, we search for likely deployment paths. | def FindVisualStudioInstallation():
possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix)
for drive in range(ord('C'), ord('Z') + 1)
for suffix in ['', ' (x86)']]
possible_paths = {
'2013': r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com',
'2012': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindMSBuildInstallation(msvs_version = 'auto'):\n import TestWin\n registry = TestWin.Registry()\n\n msvs_to_msbuild = {\n '2013': r'12.0',\n '2012': r'4.0', # Really v4.0.30319 which comes with .NET 4.5.\n '2010': r'4.0'}\n\n msbuild_basekey = r'HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVer... | [
"0.69029933",
"0.61118186",
"0.58593863",
"0.5823036",
"0.5704268",
"0.569332",
"0.5633969",
"0.5570575",
"0.5372743",
"0.5309162",
"0.52959627",
"0.5287438",
"0.5257357",
"0.5171771",
"0.5165725",
"0.5161343",
"0.51455754",
"0.5138159",
"0.51229465",
"0.5083195",
"0.5071728"... | 0.8004529 | 0 |
Run the dumpbin tool with the specified arguments, and capturing and returning stdout. | def run_dumpbin(self, *dumpbin_args):
assert sys.platform in ('win32', 'cygwin')
cmd = os.environ.get('COMSPEC', 'cmd.exe')
arguments = [cmd, '/c', self.vsvars_path, '&&', 'dumpbin']
arguments.extend(dumpbin_args)
proc = subprocess.Popen(arguments, stdout=subprocess.PIPE)
output = proc.communica... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_and_capture(*argv):\n print(*argv, file=sys.stderr)\n return subprocess.check_output(argv)",
"def dump(args):\n if args.dump_command == \"trace\":\n _dump_trace(args)\n elif args.dump_command == \"checkpoint\":\n _dump_checkpoint(args)\n elif args.dump_command == \"config\":\... | [
"0.6620855",
"0.64421326",
"0.6403631",
"0.6061605",
"0.60324913",
"0.599794",
"0.599789",
"0.59293294",
"0.59045",
"0.5888841",
"0.5851133",
"0.57390636",
"0.57296616",
"0.5724511",
"0.5675946",
"0.56678206",
"0.5652054",
"0.5632921",
"0.5618824",
"0.5589044",
"0.5553226",
... | 0.7729673 | 0 |
Returns an appropriate TestGyp instance for a specified GYP format. | def TestGyp(*args, **kw):
format = kw.pop('format', os.environ.get('TESTGYP_FORMAT'))
if format != 'ninja':
raise Exception("unknown format %r" % format)
return TestGypNinja(*args, **kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_driver(browser_name):\n if browser_name == BaseConstants.CHROME:\n options = webdriver.ChromeOptions()\n options.add_argument('headless')\n if BaseConstants.HEADLESS_MODE:\n return webdriver.Chrome(options=options)\n else:\n return webdriver.Chrome()\... | [
"0.48283198",
"0.4679778",
"0.46405205",
"0.46262017",
"0.4596164",
"0.4575837",
"0.45242107",
"0.45190325",
"0.449273",
"0.44799712",
"0.44797117",
"0.44374356",
"0.4432995",
"0.43943155",
"0.4385032",
"0.43449232",
"0.43261662",
"0.43182468",
"0.43172392",
"0.4313307",
"0.4... | 0.7641839 | 0 |
Read data from file, and return RDD data | def read_data(file_path, sparkContext):
data_rdd = sparkContext \
.textFile(file_path) \
.map(eval) \
.map(lambda x: (x[0], x[1]))
return data_rdd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file(file_name):\r\n f = open(file_name)\r\n\r\n tids = f.readlines()\r\n \r\n dataset = [(int(tid), get_from_id(int(tid))) for tid in tids]\r\n\r\n f.close()\r\n return dataset",
"def open_file(path):\n input_file = os.path.join(path)\n with open(input_file) as f:\n dataset... | [
"0.64890283",
"0.64516765",
"0.6394799",
"0.6333202",
"0.6283155",
"0.6235973",
"0.6203842",
"0.61601675",
"0.615744",
"0.6122503",
"0.6106315",
"0.60988206",
"0.60945296",
"0.6094214",
"0.6093703",
"0.6081706",
"0.60803366",
"0.60783815",
"0.6070833",
"0.60573804",
"0.605545... | 0.8014558 | 0 |
Swap the elements of a pair tuple. | def swap((u, v)):
return (v, u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap(t, i, j):\n t[i], t[j] = t[j], t[i]",
"def swap(arr, first, second):\n arr[first], arr[second] = arr[second], arr[first]",
"def __fix_tuple(self, xy_tup):\n if self.__swapxy:\n return xy_tup[::-1]\n return xy_tup",
"def swap(array, x, y):\n array[x], array[y] = arra... | [
"0.710742",
"0.6921995",
"0.67650807",
"0.6753853",
"0.67195106",
"0.6608336",
"0.6608336",
"0.65285224",
"0.65226775",
"0.64976215",
"0.6457704",
"0.64406437",
"0.6424713",
"0.64173776",
"0.64168835",
"0.6398433",
"0.6393677",
"0.6344615",
"0.6300766",
"0.6300416",
"0.629629... | 0.7532806 | 0 |
Calculate the degree for each node in the graph, return the degree result RDD | def calc_degree(graph_rdd):
all_degree = graph_rdd \
.map(swap) \
.union(graph_rdd) \
.map(lambda (x, y): (x, 1)) \
.reduceByKey(add, numPartitions=40)
return all_degree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_node_degrees(self):\n mes = []\n args = []\n for metaedge, matrix in self.adj_matrices.items():\n mes.append(metaedge)\n args.append(matrix)\n res = parallel_process(array=args, function=mt.calculate_degrees, n_jobs=self.n_jobs, front_num=0)\n f... | [
"0.73189455",
"0.6666675",
"0.66346604",
"0.6527249",
"0.6472764",
"0.64700943",
"0.6447332",
"0.6439064",
"0.6412134",
"0.63582855",
"0.635775",
"0.6351265",
"0.6337845",
"0.63136494",
"0.62561065",
"0.62335783",
"0.6209105",
"0.6083658",
"0.6079586",
"0.6071218",
"0.6063278... | 0.82944816 | 0 |
Returns the requested Detail Placement view in full detail. | def GetDetailPlacementView(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details_view(self):\n return_url = get_redirect_target() or self.get_url('.index_view')\n\n if not self.can_view_details:\n return redirect(return_url)\n\n id = get_mdict_item_or_list(request.args, 'id')\n if id is None:\n return redirect(return_url)\n\n ... | [
"0.62962556",
"0.6222012",
"0.60413206",
"0.60247207",
"0.599701",
"0.59846437",
"0.59270996",
"0.59270996",
"0.59270996",
"0.5781382",
"0.5744504",
"0.57360107",
"0.5722859",
"0.56349206",
"0.56211096",
"0.5606024",
"0.5596012",
"0.55128306",
"0.5510236",
"0.5470296",
"0.543... | 0.67889655 | 0 |
Returns a list of all available netloaders | def getNets(self):
return NetLoader.listNetworks() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLoaders(self):\n return self.__loaders;",
"def list_all_sys_net_if():\n sys_net_path = glob.glob('/sys/class/net/*')\n # Now remove the /sys/class/net prefix, keep only the interface name\n p = re.compile('^/sys/class/net/')\n result = [ p.sub('', s) for s in sys_net_path ]\n \n r... | [
"0.66725755",
"0.6490495",
"0.63215595",
"0.62439114",
"0.60754764",
"0.60590166",
"0.6027253",
"0.600712",
"0.6005559",
"0.6004541",
"0.5944526",
"0.5937115",
"0.5898024",
"0.5864237",
"0.5839915",
"0.58086324",
"0.5807643",
"0.5779557",
"0.5754953",
"0.56995124",
"0.5694432... | 0.6645465 | 1 |
Sets the type of the net | def setType(self, type):
if not self.Loaded:
self.type = type
self.loader = NetLoader.getNetwork(type)
self.isTypeSet = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_network_type(self, nNetworkType):\n\t\tcall_sdk_function('PrlVirtNet_SetNetworkType', self.handle, nNetworkType)",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self._type = type",
"def set_type(self... | [
"0.7971514",
"0.71984947",
"0.71984947",
"0.6919849",
"0.6910896",
"0.6831771",
"0.673096",
"0.6675191",
"0.6675191",
"0.6673063",
"0.66369283",
"0.6631227",
"0.6560186",
"0.6550808",
"0.6550808",
"0.6550808",
"0.6550808",
"0.6550808",
"0.6550808",
"0.6550808",
"0.6550808",
... | 0.8372814 | 0 |
Sets the config of the net | def setConfig(self, cfg):
if not self.Loaded:
self.cfg = cfg
if (cfg != ""):
self.isCfgSet = NetLoader.loadConfig(self.type,cfg)
else:
self.isCfgSet = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config(self):\n self._resource_manager = self._api._ixnetwork.ResourceManager\n self._ixn_vport = self._api._vport\n self._delete_vports()\n self._create_vports()\n self._create_capture()\n self._set_location()\n self._set_layer1()",
"def set_config(config_nam... | [
"0.7222632",
"0.6988482",
"0.698327",
"0.69201595",
"0.6917988",
"0.6894919",
"0.6846105",
"0.6840916",
"0.68287504",
"0.6813093",
"0.68010086",
"0.6800059",
"0.6800059",
"0.67930377",
"0.66927445",
"0.66901636",
"0.6685445",
"0.6637061",
"0.65850174",
"0.655442",
"0.6551127"... | 0.72783136 | 0 |
Provides direct access to the netloader | def getNet(self):
return self.loader | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_network(self):\t\t\r\n\t\tself.dqn.load_network(self.path)",
"def setup_net(self):\n pass",
"def loader(self):\r\n return self._endpoint.loader",
"def load_device():",
"def loader(self):\n return self._loader",
"def _load_disk(self):\r\n pass",
"def getInstance():\n ... | [
"0.645929",
"0.6270606",
"0.61700976",
"0.61311126",
"0.612642",
"0.5924534",
"0.58821017",
"0.58444583",
"0.5807952",
"0.57599235",
"0.57308453",
"0.57299966",
"0.57299966",
"0.57212603",
"0.5716569",
"0.5710826",
"0.5686609",
"0.56737906",
"0.56279176",
"0.5610941",
"0.5587... | 0.7985111 | 0 |
Returns the number of neurons in the net | def getNeuronCount(self):
return self.loader.getNeuronCount() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size_in(self):\n if isinstance(self.ensemble.neuron_type, Direct):\n # This will prevent users from connecting/probing Direct neurons\n # (since there aren't actually any neurons being simulated).\n return 0\n return self.ensemble.n_neurons",
"def numNodes(self)... | [
"0.8014516",
"0.7718805",
"0.7711043",
"0.7549032",
"0.7513461",
"0.7375314",
"0.73752713",
"0.736108",
"0.73195183",
"0.7298478",
"0.7297693",
"0.72939956",
"0.72719425",
"0.7255253",
"0.72395927",
"0.7193449",
"0.7181116",
"0.71256834",
"0.71191174",
"0.71191174",
"0.711391... | 0.8422572 | 0 |
Returns a single neuron from the net | def getNeuron(self, index):
return self.loader.getNeuron(index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_neuron(self, position):\n return self.neurons[position]",
"def get_neuron_number(self):\n return self.neuronNumber",
"def _get_network(name):\n\n if name not in _NAME_TO_NETS:\n raise ValueError('Network name [%s] not recognized.' % name)\n return _NAME_TO_NETS[name].model",
"def g... | [
"0.76190454",
"0.67833936",
"0.61882776",
"0.60611504",
"0.60453904",
"0.60128474",
"0.5981504",
"0.59493107",
"0.5938629",
"0.5838178",
"0.5739871",
"0.56908137",
"0.56752616",
"0.5671026",
"0.5622484",
"0.5606323",
"0.55538636",
"0.555125",
"0.555125",
"0.555125",
"0.554771... | 0.81398237 | 0 |
Recursively partition the graph G using the the algorithm defined by partition function depth times. | def recursive_partition(G,
partition_function,
depth,
dendogram=False,
**kwargs):
C = [set(G)]
if dendogram:
D = nx.Graph()
for _ in range(depth):
C_next = []
for c in C:
C_nex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, g, n_partitions):\n\n def _iterative_cutting(g, p):\n \"\"\"helper function (iterative version)\"\"\"\n\n to_be_processed = [g]\n K = math.ceil(len(g.nodes()) / p)\n\n res = []\n while len(to_be_processed) > 0:\n\n g = ... | [
"0.6947835",
"0.6692274",
"0.6523319",
"0.64699167",
"0.61639374",
"0.61390674",
"0.6134492",
"0.5891478",
"0.5791794",
"0.57705605",
"0.5603623",
"0.5438325",
"0.54188836",
"0.53874147",
"0.5370432",
"0.5352181",
"0.534992",
"0.5345076",
"0.53345937",
"0.53251743",
"0.529117... | 0.8169132 | 0 |
Tests the creation of LASCOMap using FITS. | def test_fitstoLASCO(lasco):
assert isinstance(lasco, LASCOMap) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialized() -> None:\n MapieClassifier()",
"def test_initialized() -> None:\n MapieRegressor()",
"def test_make_ec_map():\n pass",
"def test_on_map_of_constants(synthetic_checkerboard):\n img = synthetic_checkerboard['img']\n di = synthetic_checkerboard['cdi']\n\n cpp_vorimg = te... | [
"0.642239",
"0.6291131",
"0.61287856",
"0.58283335",
"0.5784628",
"0.5760995",
"0.5741576",
"0.5735342",
"0.56763834",
"0.56645465",
"0.5649165",
"0.56062466",
"0.5596278",
"0.5567189",
"0.55620426",
"0.55452317",
"0.55275035",
"0.5512195",
"0.5509079",
"0.5508",
"0.55052185"... | 0.6583202 | 0 |
Test the is_datasource_for method of LASCOMap. Note that header data to be provided as an argument can be a MetaDict object. | def test_is_datasource_for(lasco):
assert lasco.is_datasource_for(lasco.data, lasco.meta) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_datasource_for(eit_map):\n assert eit_map.is_datasource_for(eit_map.data, eit_map.meta)",
"def is_datasource_for(cls, **kwargs):\n if 'source' in kwargs.keys():\n if kwargs.get('source', ''):\n return kwargs.get('source', '').lower().startswith(cls._source)\n ... | [
"0.74529046",
"0.6727229",
"0.57659274",
"0.57537",
"0.5483662",
"0.5415242",
"0.5341589",
"0.52654755",
"0.5249164",
"0.522096",
"0.5166681",
"0.5155394",
"0.5150383",
"0.5117535",
"0.5107733",
"0.50836915",
"0.50509775",
"0.50261915",
"0.5001209",
"0.49781814",
"0.495897",
... | 0.762238 | 0 |
Tests the measurement property of the LASCOMap object. | def test_measurement(lasco):
assert lasco.measurement == "white-light" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_measurement(eit_map):\n assert eit_map.measurement.value in [195, 171]",
"def test_unit_of_measurement(self):\n for name in self.sensor_dict:\n sensor = self.sensor_dict[name][\"sensor\"]\n assert self.sensor_dict[name][\"units\"] == sensor.unit_of_measurement",
"def te... | [
"0.7147487",
"0.70588326",
"0.6354547",
"0.6340808",
"0.62565184",
"0.622547",
"0.62038094",
"0.614342",
"0.6091599",
"0.5935994",
"0.5892707",
"0.58639777",
"0.5852712",
"0.58456856",
"0.57708514",
"0.57647926",
"0.5735114",
"0.5731323",
"0.57311",
"0.5704018",
"0.5696798",
... | 0.70623285 | 1 |
Tests the observatory property of the LASCOMap object. | def test_observatory(lasco):
assert lasco.observatory == "SOHO" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_observatory(eit_map):\n assert eit_map.observatory == \"SOHO\"",
"def check_observatory(self):\n assert self.observatory in ALL_OBSERVATORIES, \\\n \"Invalid observatory \" + repr(self.observatory) + \" in \" + repr(self.filename)",
"def observatories():\n\n obs_db = {}\n\n ... | [
"0.70502925",
"0.5905423",
"0.5631481",
"0.55709904",
"0.53638643",
"0.53604794",
"0.535205",
"0.53501725",
"0.53381866",
"0.53307277",
"0.5307905",
"0.5280215",
"0.52539486",
"0.5241711",
"0.51865333",
"0.5175831",
"0.51357836",
"0.5132824",
"0.51225543",
"0.50932837",
"0.50... | 0.62336797 | 1 |
get value from query dict by key | def get_value(self, query_dict, k):
if k in query_dict:
return query_dict[k]
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, key):\n return self.query(key)",
"def find(cls, key):\r\n return cls.query().get(key)",
"def getSpecific(self, keyword, key):",
"def __getitem__(self, key):\n return self.keyvaluepair_set.get(key=key).value",
"def __getitem__(self, key):\n return self.param... | [
"0.7332471",
"0.7147431",
"0.7024943",
"0.68989784",
"0.6870327",
"0.6814481",
"0.6814481",
"0.68065345",
"0.67460203",
"0.67460203",
"0.67460203",
"0.67460203",
"0.673437",
"0.67057145",
"0.6673087",
"0.6667873",
"0.66438895",
"0.66222626",
"0.6579917",
"0.6568693",
"0.65685... | 0.8017572 | 0 |
Sort the contents of a directory by last modified date. | def _sorted_ls(path):
def _get_modified_time(f):
return os.stat(os.path.join(path, f)).st_mtime
return list(sorted(os.listdir(path), key=_get_modified_time)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_files_list(dirname, date_order, rdate_order):\n file_list = os.listdir(dirname)\n file_mtimes = dict.fromkeys(file_list)\n for f in file_list:\n if f[0] == '.':\n print \"Skipping file: \", f\n del file_mtimes[f]\n continue\n if date_order or rdate_or... | [
"0.6985285",
"0.64413553",
"0.62352586",
"0.62184626",
"0.62138826",
"0.62063205",
"0.6144919",
"0.6113929",
"0.6106303",
"0.6105642",
"0.60882264",
"0.5959481",
"0.5916365",
"0.58824",
"0.5865776",
"0.58552366",
"0.582905",
"0.57945603",
"0.57103086",
"0.5698084",
"0.567522"... | 0.7565834 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.