query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Load the data and calculate heights.
def _initialise_data(self): data_graph = self._load_data() data_graph.calculate_max_heights() return data_graph
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getHeights(self):\n if self.heights: return self.heights\n reader = self.getReader()\n subData = reader.findSubRecord('VHGT','LAND')\n if not subData: return None\n height0 = struct.unpack('f',subData[:4])[0]\n import array\n deltas = array.array('b',subData[4:4...
[ "0.64111936", "0.6029936", "0.5960766", "0.59529585", "0.5880706", "0.5839389", "0.5756515", "0.5741466", "0.5675853", "0.5659828", "0.5659828", "0.5659828", "0.563116", "0.563116", "0.56030744", "0.5593001", "0.55927116", "0.5567349", "0.5567349", "0.552846", "0.5522765", ...
0.6433362
1
Create a list of pairs (input edge count, node) that is sorted from highest count.
def _select_sources(self, nodes): node_sources = [] for node in nodes: if len(node.edges_in) == 0: node_sources.append(node) node_sources.sort(reverse=True, key=lambda n: (len(n.edges_out), n.height, n.name)) return node_sources
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def walk_sort(edges):\n g = nx.Graph()\n g.add_edges_from(edges)\n connected = set()\n degree = nx.degree(g)\n ordering = []\n while degree:\n next = max_degree_node(g, degree, connected)\n if next is not None:\n ordering.append(next)\n else:\n break\n ...
[ "0.64853567", "0.6266425", "0.6056536", "0.59029275", "0.5899401", "0.5843856", "0.5779872", "0.57611424", "0.5738577", "0.5725267", "0.57128936", "0.57043004", "0.5701572", "0.5685223", "0.56579274", "0.5656229", "0.5655609", "0.5655609", "0.56483656", "0.5597191", "0.558169...
0.0
-1
Post a question and wait for the user's response.
def _post_question(self, question): self.messages_sent.append(question) if self.user_input: return input(question) else: ans = self.lines.pop(0) print(question + ans) return ans
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_question(self):\n self.post_meetup()\n return self.client.post(\"api/v2/questions\", headers={\"Authorization\": \"{}\".format(self.token())}, data=json.dumps(self.question), content_type='application/json')", "def Wait(p_question: str):\n input(p_question)\n return", "def _post_qu...
[ "0.6669837", "0.6633832", "0.66121936", "0.6588372", "0.64548445", "0.6415149", "0.640862", "0.63962865", "0.63914204", "0.63729346", "0.63199115", "0.63199115", "0.6252762", "0.62428695", "0.61925095", "0.60855335", "0.6048211", "0.60243255", "0.60222024", "0.5988716", "0.59...
0.6390715
9
Post an answer to the user and save it for analysis.
def _post_answer(self, answer): print(answer) self.messages_received.append(answer)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_answer():\n try:\n answer = request.args.get('answer')\n poll_id = request.args.get('poll_id')\n user_name = request.args.get('user_name')\n if user_service.check_user(user_name):\n service.insert_answer(answer, poll_id, user_name)\n ...
[ "0.70205164", "0.6791866", "0.67722994", "0.6704242", "0.6661546", "0.65924793", "0.65407985", "0.6536091", "0.65116584", "0.65081704", "0.64944977", "0.64931846", "0.6489533", "0.64617085", "0.634831", "0.6341989", "0.63410234", "0.63369197", "0.63127434", "0.630318", "0.628...
0.6829947
2
Tell the user why I'm asking him this question.
def _why(self, current_data): if len(self.answered_true) > 0: print("*Uživatel odpověděl pravdivě na následující otázky: ") for i in self.answered_true: print("---", i.name) if len(self.implied_true) > 0: print("*Z nich vyplývá, že: ") for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def asking(self):\n return 'Sure.'", "async def nwhy(self, ctx):\n question = nekos.why()\n await ctx.send(question)", "def hey(self, msg):\n if issilence(msg):\n return \"Fine. Be that way.\"\n elif isshouting(msg):\n return \"Woah, chill out!\"\n ...
[ "0.6908813", "0.6718016", "0.6626582", "0.6435212", "0.6357683", "0.63420093", "0.6309488", "0.6275732", "0.6197925", "0.607799", "0.5996539", "0.5977487", "0.59511226", "0.5944695", "0.58894676", "0.5879362", "0.58693576", "0.5799273", "0.5794895", "0.5786102", "0.5763241", ...
0.0
-1
Explain how i got to the current solution.
def _explain(self, solution): # Get the whole data whole_graph = ChatBot() # all nodes that were marked as true either by user or implied all_true = self.implied_true.union(self.answered_true).union(self.current_subgraph) # get the nodes that were not used unused = all_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_solution():\n pass", "def explain(self):", "def _explain(self, solution):\n all_true = self.implied_true.union(self.answered_true).union(self.current_subgraph)\n\n # recalculate all data\n self.data_graph = self._initialise_data()\n\n # get the nodes that were not used\...
[ "0.7156278", "0.7037696", "0.70189935", "0.6772505", "0.66031325", "0.6583985", "0.655581", "0.655581", "0.6534624", "0.6422485", "0.63931155", "0.63874745", "0.63836277", "0.6379449", "0.6364412", "0.6364363", "0.61915267", "0.6169752", "0.61190975", "0.6086019", "0.60786486...
0.62415946
16
On step of the knowledge bot. Ask the user and then parse the answer
def ask(self): # update the sources if len(self.current_subgraph) == 0: current_data = self._select_sources(self.data_graph.nodes) else: current_data = self._select_sources(self.current_subgraph) # ask for the node with the highest priority .. sorted by (height, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def next_step(\n self, step_context: WaterfallStepContext\n ) -> DialogTurnResult:\n step_context.values[\"input\"] = step_context.result\n user_input = step_context.values[\"input\"]\n\n # TODO: remove this notification, it is for demo purposes only.\n await step_contex...
[ "0.6661836", "0.6623523", "0.6185823", "0.6169001", "0.6127652", "0.61216295", "0.60287195", "0.5947787", "0.59054744", "0.5882209", "0.5847624", "0.5803464", "0.575814", "0.57570684", "0.5730973", "0.5725769", "0.57204896", "0.56983685", "0.5662998", "0.56618017", "0.5654815...
0.0
-1
Test for foreign key constraints that don't have a corresponding index.
def test_missing_foreign_key_indices(db_session): from sqlalchemy_utils.functions import non_indexed_foreign_keys from kotti import metadata assert non_indexed_foreign_keys(metadata) == {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_indexed_foreign_key(constraint):\n for index in constraint.table.indexes:\n index_column_names = set([\n column.name for column in index.columns\n ])\n if index_column_names == set(constraint.columns):\n return True\n return False", "def collect_drop_fk(sel...
[ "0.748976", "0.704024", "0.68740153", "0.6803409", "0.6442127", "0.63733286", "0.6137904", "0.6083083", "0.6067429", "0.59864193", "0.5934889", "0.57362586", "0.56498003", "0.56025785", "0.5596647", "0.5577209", "0.5565569", "0.5537458", "0.552599", "0.5427226", "0.5406838", ...
0.7493482
0
Syntactic sugar for synchronously grabbing an item by id, description id or name.
def __getitem__(self, key: Union[int, str]): loop = asyncio.get_event_loop() future = loop.create_future() async def getitem(): if isinstance(key, int): # Most desc_ids are 9 digits but there are 14 that aren't. # At time of writing this is good for 1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_item(\n request: Request,\n response: Response,\n item_id: int,\n db: SAConnection = Depends(get_postgresql_connection)\n):\n cached_item = await request.app.extra['cache'].get_cache_item(item_id=item_id)\n if cached_item:\n return cached_item\n if db is No...
[ "0.6691297", "0.6671622", "0.66482127", "0.66345274", "0.6607628", "0.6532821", "0.65211505", "0.6369041", "0.6343377", "0.632963", "0.6251882", "0.62229437", "0.6185694", "0.61646783", "0.60775787", "0.60709995", "0.60169435", "0.5998554", "0.5959487", "0.59420747", "0.59297...
0.66012645
5
Discover this item using its id or description id. The description id is preferred as it provides more information, so if only an id is provided, libkol will first determine the desc_id. Note that this Returns an Item object but it is not automatically committed to the database. It is not sufficient to run `await item....
async def discover(cls, id: int = None, desc_id: int = None): if id is not None: desc_id = (await request.item_information(cls.kol, id).parse()).descid if desc_id is None: raise ItemNotFoundError( "Cannot discover an item without either an id or a desc_id" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_item_detail(item_id):\n pass", "def get_item_description(item_slug):\n return session.query(\n Items.description).filter_by(\n slug=item_slug).first()[0]", "def get_item(self, item_id): # pragma: no cover\n raise NotImplementedError", "def get_item(item_id):\n return It...
[ "0.5958962", "0.5945608", "0.58951426", "0.5857073", "0.5793325", "0.5768699", "0.57304674", "0.5702956", "0.5690138", "0.5687487", "0.56168866", "0.5571609", "0.5569454", "0.55473393", "0.5527266", "0.5521872", "0.54873824", "0.54755473", "0.541963", "0.54195684", "0.5334919...
0.80740875
0
Get the lowest price for this item in the mall
async def get_mall_price(self, limited: bool = False) -> int: prices = await request.mall_price(self.kol, self).parse() if limited: return prices.limited[0].price return prices.unlimited[0].price
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lowest_price_item_id(table):\n\n prices = [(line[ID], line[TITLE], int(line[PRICE])) for line in table]\n min_price = min(prices, key=common.get_item(2))[2]\n min_price_items = [(item[ID], item[TITLE], item[PRICE]) for item in prices if item[2] == min_price]\n\n return common.srt(min_price_item...
[ "0.7255369", "0.7116045", "0.7108892", "0.6947185", "0.6841582", "0.675164", "0.6612951", "0.66056067", "0.6539328", "0.6539328", "0.64958763", "0.6480108", "0.64767087", "0.6460087", "0.6364029", "0.6355585", "0.63383627", "0.6330016", "0.62961346", "0.6272824", "0.6271888",...
0.62092066
24
Table print repeat info
def cli(context, repeats_file): repeat_information = {} with open(repeats_file, 'r') as file_handle: repeat_information = parse_repeat_file(file_handle, repeats_file_type='json') if not repeat_information: LOG.warning("Could not find any repeat info") context.abort() header = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_table(self):\n print(\"%-12s%-12s%-12s%-12s%-12s\" % (\"index\",\"balance\",\"payment\",\"interest\",\"amortization\"))\n print(\"-------------------------------------------------------------\")\n for i in self.table[\"index\"]:\n print(\"%-12i%-12i%-12i%-12i%-12i\" % (sel...
[ "0.7371803", "0.71344876", "0.6969507", "0.6963204", "0.692555", "0.6835418", "0.67638135", "0.6760846", "0.6750816", "0.66937345", "0.6680997", "0.6655735", "0.6651745", "0.6644229", "0.6636536", "0.6633744", "0.6621832", "0.6618156", "0.6618156", "0.66038305", "0.6592382", ...
0.0
-1
Factory function to create a new currency from its ISO code
def create_currency_from_ISO(isocode): from .commodity import Commodity # if self.get_session().query(Commodity).filter_by(isocode=isocode).first(): # raise GncCommodityError("Currency '{}' already exists".format(isocode)) from .currency_ISO import ISO_currencies cur = ISO_currencies.get(isoc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCurrencyIsoCode(id=None):", "def fromisoformat(cls, *args, **kwargs): # real signature unknown\r\n pass", "def from_code_and_minor(cls, currency_code, value):\n from .currency import currencies\n try:\n return cls(currencies[currency_code.upper()], value)\n except ...
[ "0.66242546", "0.63548607", "0.62624526", "0.6172577", "0.6047738", "0.5967506", "0.594702", "0.59417343", "0.5927033", "0.5797854", "0.5797854", "0.57801336", "0.5746309", "0.57142186", "0.56475854", "0.5633694", "0.563085", "0.56046224", "0.56037885", "0.5591195", "0.557395...
0.7708666
0
Factory function to create a new stock from its symbol. The ISO code of the quoted currency of the stock is stored in the slot "quoted_currency".
def create_stock_from_symbol(symbol, book=None): from .commodity import Commodity share = get_latest_quote(symbol) stock = Commodity( mnemonic=symbol, fullname=share.name, fraction=10000, namespace=share.exchange, quote_flag=1, quote_source="yahoo", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_symbol(symbol):\n st = Stock(symbol)\n return st.get_quote()", "def FromYfinance(symbol):\n stock = Stock(symbol)\n stock.Update()\n return stock", "def create(symbol, number_of_shares, purchase_price):\n stock = Stock(symbol, number_of_shares, purchase_price)\n databas...
[ "0.658607", "0.655007", "0.64967674", "0.6324575", "0.61781764", "0.61781764", "0.61742914", "0.61241645", "0.6066685", "0.6028303", "0.5916321", "0.58823574", "0.5855334", "0.58455604", "0.5823851", "0.58002996", "0.5796427", "0.5793406", "0.575277", "0.57361037", "0.5734318...
0.7477825
0
Creates a new textmessage SpamFilter trained on the given text messages and their associated labels. Performs any necessary preprocessing before training the SpamFilter's Naive Bayes Classifier. As part of this process, trains and stores the CountVectorizer used in the feature extraction process.
def __init__(self, text_train, labels_train): self.vectorizer = CountVectorizer(stop_words='english') self.features = self.vectorizer.fit_transform(text_train) self.nbc = MultinomialNB().fit(self.features, labels_train)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_model(self, text, labels):\n clf = svm.SVR()\n count_vect = CountVectorizer()\n tfidf_transformer = TfidfTransformer()\n counts = count_vect.fit_transform(text)\n tfidf = tfidf_transformer.fit_transform(counts)\n clf.fit(tfidf, labels)\n\n return clf, coun...
[ "0.59928596", "0.5991479", "0.58972853", "0.5896386", "0.5881257", "0.58270174", "0.5791569", "0.57531697", "0.56607693", "0.5642098", "0.56038517", "0.55683374", "0.5556388", "0.5550796", "0.5503383", "0.54590356", "0.53853714", "0.53828907", "0.5378921", "0.5342874", "0.534...
0.624333
0
Takes as input a list of raw textmessages, uses the SpamFilter's vectorizer to convert these into the known bag of words, and then returns a list of classifications, one for each input text
def classify (self, text_test): test_features = self.vectorizer.transform(text_test) return self.nbc.predict(test_features)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vectorize_text(text):\n\n def remove_punctuation(text):\n \"\"\"Removes special characters from text.\"\"\"\n return re.sub('[,.?\";:\\-!@#$%^&*()]', '', text)\n\n def remove_common_words(text_vector):\n \"\"\"Removes 50 most common words in the uk english.\n\n source: http://...
[ "0.6773912", "0.6709329", "0.66575223", "0.66177416", "0.65822107", "0.6579251", "0.64948726", "0.64688814", "0.6454887", "0.6437127", "0.64282006", "0.6301154", "0.6277714", "0.6274535", "0.6252408", "0.62520164", "0.6225644", "0.61832404", "0.6182126", "0.61709464", "0.6170...
0.0
-1
Takes the testset as input (2 DataFrames consisting of test texts and their associated labels), classifies each text, and then prints the classification_report on the expected vs. given labels.
def test_model (self, text_test, labels_test): print(classification_report(labels_test, self.classify(text_test)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_classification_report(y_train,y_test,y_train_preds,y_test_preds): \n try:\n for i in range(y_train.shape[-1]):\n test = (y_test.iloc[:,i].values, y_test_preds[:,i])\n train = (y_train.iloc[:,i].values, y_train_preds[:,i])\n print(f\"---------------{y_train.co...
[ "0.70495254", "0.6905331", "0.68044335", "0.67821795", "0.67230874", "0.6670411", "0.6623034", "0.6588332", "0.6568425", "0.652718", "0.64948666", "0.6488643", "0.6487697", "0.64806813", "0.64704436", "0.6383303", "0.6340591", "0.63397235", "0.6333492", "0.63176745", "0.63121...
0.75366956
0
Takes a path to the raw data file (a csv spreadsheet) and creates a new Pandas DataFrame from it with only the message texts and labels as the remaining columns.
def load_and_sanitize (data_file): data = pd.read_csv(data_file, encoding="latin-1") data = data.drop(columns=['Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4']) data = data.rename(columns={"v1": "class", "v2": "text"}) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(txt_path: str = RAW_TXT) -> pd.DataFrame:\n df = pd.read_csv(txt_path)[INDICES]\n return df", "def load_raw_data(path: str) -> pd.DataFrame:\n data = []\n with open(path) as file:\n for line in file:\n data.append(line)\n data_df = pd.DataFrame(data, columns = {'twe...
[ "0.71791464", "0.70036703", "0.69079787", "0.66350573", "0.6587034", "0.6573408", "0.65146476", "0.6495639", "0.649103", "0.6491012", "0.6479905", "0.6461631", "0.6417438", "0.63850695", "0.63770866", "0.6361787", "0.6361787", "0.6361787", "0.63617593", "0.6361643", "0.630978...
0.5878654
76
method parses csv file and loads images into structure Image
def parse_data(filename, data_path, ground_truths_path): with open(filename) as f: content = f.readlines() content = [x.strip() for x in content] data = [] for i, item in enumerate(content): if i == 0: continue parametres = item.split(',') image = cv2.imrea...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_or_new(cls, csv_path, image_files):\n if os.path.exists(csv_path):\n return cls.from_csv(csv_path)\n else:\n return cls.graphical(image_files)", "def _read_labels_csv_file(self, csv_file_path, image_file_paths):\n\n self.__logger.debug('[Get Labels]')\n ...
[ "0.71182513", "0.70285696", "0.69939166", "0.6939744", "0.67621666", "0.6727584", "0.6722772", "0.66315526", "0.6631409", "0.6559266", "0.6529502", "0.6486764", "0.64602864", "0.6403504", "0.63981724", "0.63912535", "0.63322", "0.63251", "0.6303752", "0.62977785", "0.6280485"...
0.0
-1
function returns TP, FP, TN, FN metrics score
def perf_measure(y_actual, y_hat): TP = 0 FP = 0 TN = 0 FN = 0 for i in range(len(y_hat)): if y_actual[i]==y_hat[i]==1: TP += 1 if y_hat[i]==1 and y_actual[i]!=y_hat[i]: FP += 1 if y_actual[i]==y_hat[i]==0: TN += 1 if y_hat[i]==0 and...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_metrics(self):\n sensitivity = TP + FN\n sensitivity = TP / sensitivity\n\n specificity = TN + FP\n specificity = TN / specificity\n\n accuracy = TP + FP + TN + FN\n divisor = TP + TN\n accuracy = divisor / accuracy\n\n positive_predictive = TP ...
[ "0.7501237", "0.6926722", "0.6862839", "0.6861548", "0.68331003", "0.68244755", "0.68199164", "0.681663", "0.6799322", "0.67838806", "0.67769575", "0.6709428", "0.67028385", "0.66891694", "0.668129", "0.6674142", "0.66389775", "0.66237277", "0.6617541", "0.66001135", "0.65845...
0.6616394
19
Convert (year,month,day) to day of the year (out of 366) January 1 = 0
def find_day_of_year(year, month, day): leap_flag = year % 4 == 0 feb_days = np.where(leap_flag, 29, 28) days_per_month = np.array([31, feb_days, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) return np.sum(days_per_month[0:month-1]) + day - 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def day_of_year(month, day):\n try:\n # 2003 is an arbitrary non-leap year.\n return date(2003, month, day).timetuple().tm_yday\n except ValueError:\n if month == 2 and day == 29:\n return 60\n else:\n raise", "def date_to_day_of_year(year, month, day):\n ...
[ "0.74115866", "0.7353909", "0.718122", "0.71607465", "0.7069977", "0.7047048", "0.68796897", "0.68069255", "0.673768", "0.67354643", "0.6649406", "0.65735936", "0.6567866", "0.65617204", "0.6547489", "0.653711", "0.65096027", "0.6506358", "0.6505979", "0.64983153", "0.6476086...
0.7057415
5
Calculate the unconditional mean vector of a multivariate normal DAG. This function calculates the mean vector of a multivariate normal DAG. It only calculates the vector and stores the values in the dag. Use the function 'mean_vector' to get to the vector.
def to_dagauss(G): V = list(networkx.topological_sort(G)) """ Populates a directed graph G with attributes. """ for node in G.nodes: G.nodes[node]["beta"] = sp.Symbol("beta_" + node, real = True ) G.nodes[node]["sigma"] = sp.Symbol("sigma_" + node, positive = True) for edge in G.edges: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vector_mean(vectors: List[Vector]) -> Vector:\n n = len(vectors)\n return scalar_multiply(1/n, vector_sum(vectors))", "def vector_mean(vectors: List[Vector]) -> Vector:\n n = len(vectors)\n return scalar_multiply(1/n, vector_sum(vectors))", "def vector_mean(vectors: List[Vector]) -> Vector:\n ...
[ "0.65818983", "0.65818983", "0.65590894", "0.65404785", "0.65404785", "0.65404785", "0.6522068", "0.6522068", "0.62767", "0.6115197", "0.6051941", "0.5798251", "0.5677843", "0.56523216", "0.5638601", "0.55734503", "0.55333024", "0.5528915", "0.5496608", "0.54678524", "0.54666...
0.0
-1
Calculate the conditional mean vector and covariance matrix
def parameters(G, variables = [], conditionants = []): if(not variables): variables = get_order(G, conditionants) H = G.graph["dependency_graph"] order = get_order(G) mean_ = sp.Matrix([H.nodes[value]["mu"] for value in order]) cov = sp.zeros(len(order), len(order)) for (i, j) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate(self):\n\n gt_n = np.count_nonzero(self.ground_truth)\n gt_indices = np.flip(np.where(self.ground_truth == 1), axis=0)\n gt_mean = gt_indices.mean(axis=1)\n gt_cov = np.cov(gt_indices)\n\n seg_n = np.count_nonzero(self.segmentation)\n seg_indices = np.flip(np...
[ "0.64783967", "0.64311194", "0.6394623", "0.636508", "0.63498867", "0.6311388", "0.6303238", "0.6297135", "0.6278319", "0.62237257", "0.62198985", "0.62144303", "0.61656857", "0.6094996", "0.60383916", "0.6037372", "0.6010727", "0.5990731", "0.59747386", "0.59711796", "0.5951...
0.0
-1
Calculate the conditional mean vector
def mean(G, variables = [], conditionants = []): return parameters(G, variables = variables, conditionants = conditionants)["mean"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditional_mean(self, F):\n raise NotImplementedError", "def conditional_mean(self, gp):\n raise NotImplementedError", "def mean(self):\n return self.cond_proba.mean", "def _get_mean(self):\n mu = self._get_conditional_negative_energy()\n return sigmoid(mu)", "def co...
[ "0.75884086", "0.7420518", "0.7326542", "0.72048956", "0.7168534", "0.696724", "0.69614416", "0.68689317", "0.68494517", "0.6848806", "0.6841679", "0.6841358", "0.68342346", "0.68115646", "0.68115646", "0.68115646", "0.6789283", "0.6777226", "0.6777226", "0.6732227", "0.67221...
0.61112547
90
Calculate the conditional covariance matrix
def covariance(G, variables = [], conditionants = []): return parameters(G, variables = variables, conditionants = conditionants )["cov"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditional_component_covs(self):\n return np.array([d.conditional_cov() for d in self.conditionalMVNs])", "def covariance(data_matrix):\n return np.asmatrix(np.cov(data_matrix, rowvar=0))", "def covariance_matrix(self):\n\n self._order_observations()\n self.cov_matrix = self._compu...
[ "0.73899573", "0.7329456", "0.7226545", "0.70018446", "0.69857293", "0.69405174", "0.68893206", "0.681819", "0.67607033", "0.67339945", "0.6721007", "0.66540647", "0.6635569", "0.66328156", "0.6599933", "0.659521", "0.6584683", "0.6575936", "0.6550229", "0.65470797", "0.65456...
0.6713619
11
Calculate the conditional covariance matrix
def variance(G, variables = [], conditionants = []): cov = covariance(G, variables = variables, conditionants = conditionants) if len(variables) == 1: return cov[0] else: return cov
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditional_component_covs(self):\n return np.array([d.conditional_cov() for d in self.conditionalMVNs])", "def covariance(data_matrix):\n return np.asmatrix(np.cov(data_matrix, rowvar=0))", "def covariance_matrix(self):\n\n self._order_observations()\n self.cov_matrix = self._compu...
[ "0.73899573", "0.7329456", "0.7226545", "0.70018446", "0.69857293", "0.69405174", "0.68893206", "0.681819", "0.67607033", "0.67339945", "0.6721007", "0.6713619", "0.66540647", "0.6635569", "0.66328156", "0.6599933", "0.659521", "0.6584683", "0.6575936", "0.6550229", "0.654707...
0.0
-1
Calculate the theoretical beta coefficient of a regression
def beta(G, responses = [], covariates = [], conditionants = []): variables = covariates + conditionants means = mean(G, responses, variables) def collect(index): return sp.collect(expr = sp.expand(means[index]), syms = variables) collections = [...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def beta_coef_(self):\n return pcr_beta_coef(self.regression, self.prcomp)", "def beta(self):\n eTheta = self.eTheta()\n cosOmg = np.cos(self.omega())\n return self.a1()/c.c*(1-eTheta**2)**0.5*cosOmg", "def _beta(self):\n return _handle_ab(self.solution, self.use_const)[1]", ...
[ "0.7797716", "0.7335511", "0.7307658", "0.7068588", "0.69392455", "0.68964314", "0.6882692", "0.6854041", "0.6854041", "0.68456256", "0.68385607", "0.6826287", "0.681263", "0.681263", "0.6769854", "0.6761017", "0.67435676", "0.6736225", "0.66807735", "0.6674472", "0.66708785"...
0.59473324
92
Calculates the theoretical R squared. This function calculates R squared, also known as the coefficient of determination.
def rsquared(G, responses, covariates, conditionants = [], norm = "trace"): betas = beta(G, responses = responses, covariates = covariates, conditionants = conditionants) cov_covariates = variance(G, variables = covariates, conditionan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rsq(self):\n return self._ss_reg / self._ss_tot", "def R_squared(self):\n return 1 - ((self.y - self.y_hat(self.x))**2).sum() / ((self.y - self.y.mean())**2).sum()", "def R_square(self,parameterValues=None):\n sst = self.SST(parameterValues)\n cost = self.Cost(parameterValues)\...
[ "0.7470857", "0.7435628", "0.6879839", "0.6857282", "0.6828465", "0.6814315", "0.6789556", "0.66813314", "0.65971434", "0.6531645", "0.64626896", "0.64340127", "0.64333946", "0.64192575", "0.6368554", "0.6368314", "0.63613373", "0.6360666", "0.6342186", "0.6327854", "0.624074...
0.59219635
44
Calculates the conditional correlation.
def correlation(G, variables = [], conditionants = []): cov = covariance(G, variables = variables, conditionants = conditionants) k = cov.shape[0] sds = sp.Matrix([1/sp.sqrt(cov[i, i]) for i in range(0, k)]*k).reshape(k, k) cor = cov.multiply_e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mp_corr(self):\n a, c, d, b = self.to_ccw()\n p1, q1 = a + b, c + d\n p2, q2 = a + c, b + d\n n = p1 + q1\n\n if n == 0:\n return np.nan\n elif a == n or d == n:\n # only one (diagonal) cell is non-zero\n return 0.5\n elif b == n...
[ "0.6608739", "0.6533732", "0.6441438", "0.63805926", "0.62961954", "0.6242456", "0.62402856", "0.6196539", "0.61814976", "0.6175767", "0.6171645", "0.6156763", "0.6144202", "0.61440504", "0.6108581", "0.6100552", "0.6100552", "0.60683787", "0.6066992", "0.60644835", "0.602987...
0.63287646
4
thin the edges and delete the values below the low threshold so that it doesn't need to happen in hysteresis anymore (or don't delete the low ones, doesn't really matter when it happens)
def thin_edges(magnitude, angle, low): # define footprints for the angle cases (1, 2, 3 and 4) t1 = time.time() f1 = np.array([[1, 0, 1]]) f2 = np.array([[1, 0, 0], [0, 0, 0], [0, 0, 1]]) # hier had ik f4 verwacht, ma de hoeken kloppen niet f3 = np.array([[1], [0], [1]]) f4 = np.array([[0, 0, 1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_straight_lines(self):\r\n\r\n # Creates a vertical 1x5 kernel and applies binary closing based on that kernel\r\n vertical_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, 5))\r\n self.thresh_invert = cv2.morphologyEx(self.thresh_invert, cv2.MORPH_CLOSE, vertical_kernel, iteratio...
[ "0.6336831", "0.6080223", "0.6076756", "0.6074127", "0.6065923", "0.60143733", "0.59788924", "0.590821", "0.58946663", "0.5881717", "0.58767915", "0.58761054", "0.58173144", "0.5753505", "0.5737722", "0.5726844", "0.57266", "0.5726238", "0.5722348", "0.5721435", "0.56907165",...
0.58781993
10
Parses the Gaussian log file for the QM energy. Returns
def ReadGaussian(): # LICHEM calculates this as the optimization energy - self energy. # Self energy of the charges = {f} a.u. self_line = " Self energy of the charges" # SCF Done: E({s}) = {f} A.U. after {d} cycles SCF_line = " SCF Done:" with open('LICHM_GaussEnergy_0.log') as f: for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_fermi_energy_from_log(log_file):\n with open(log_file, \"r\") as f:\n content = f.readlines()\n ferimiValues = EFermi_Pattern.findall(\"\".join(content))\n return list([float(item.split()[1]) for item in ferimiValues])", "def read_data_test_MLOG(self):\n self.na.set_query_timeout(...
[ "0.60903597", "0.575791", "0.5489557", "0.54672337", "0.5395261", "0.5361491", "0.5357795", "0.53484565", "0.53275615", "0.5284829", "0.5283435", "0.52671564", "0.5243411", "0.5235176", "0.5217604", "0.5205431", "0.51733214", "0.5166768", "0.515823", "0.51553243", "0.5126141"...
0.6854024
0
Parses the TINKER log file for the MM energy. Currently does not support AMOEBA polarization terms! Returns
def ReadTinker(): # Total Potential Energy : {f} Kcal/mole total_line = " Total Potential Energy :" with open('LICHM_TINKEREnergy_0.log') as f: for line in f: if line.startswith(total_line): # print(line) TinkE = re.findall(r'\-\d+\.*\d*', line) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_lammps_log(logfile):\n keys = None\n data = []\n read = False\n with open(logfile) as infile:\n for lines in infile:\n if lines.startswith('Step'):\n if data:\n yield keys, data\n keys = [i.lower() for i in lines.strip().split(...
[ "0.6170222", "0.6100037", "0.5945984", "0.59330875", "0.583597", "0.58223265", "0.573726", "0.5724382", "0.57241416", "0.5691281", "0.5658535", "0.55970955", "0.55613095", "0.5531624", "0.55298966", "0.5528802", "0.55086756", "0.5499865", "0.54951453", "0.54804593", "0.547738...
0.70619804
0
Sums the QM and MM energy. Returns
def GetSum(GaussE, TinkE): sumE = GaussE + TinkE return sumE
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def energy(self):\n sum_energy = 0.0\n for i in range(0,self.natoms-1):\n for j in range(i+1,self.natoms):\n rij = (self.atoms[i].xyz - self.atoms[j].xyz)\n rij = rij - self.pbc_correction(rij)\n mag_rij = la.norm(rij)\n ...
[ "0.6841351", "0.6395822", "0.62988883", "0.6194192", "0.6180285", "0.60826874", "0.60562325", "0.60547197", "0.6052184", "0.6049038", "0.6040721", "0.60101056", "0.5994954", "0.5935547", "0.59211665", "0.5914214", "0.5909242", "0.5854844", "0.58482", "0.5826296", "0.5823644",...
0.0
-1
Prints out the energy breakdown as requested. Formats them to 10 decimal places.
def PrintDetailedE(GaussE, TinkE, sumE, result_format): ## Force to lowercase for search result_format = [each_form.lower() for each_form in result_format] if 'all' in result_format: print("\n") print(f"Gaussian Energy (au): {GaussE/har2ev:.10f} +") print(f"Tinker Energy (au): {Tin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printenergy(a=atoms): # store a reference to atoms in the definition.\n epot = a.get_potential_energy() / len(a)\n ekin = a.get_kinetic_energy() / len(a)\n print('Energy per atom: Epot = %.3feV Ekin = %.3feV (T=%3.0fK) '\n 'Etot = %.3feV' % (epot, ekin, ekin / (1.5 * units.kB), epot + ekin...
[ "0.6651297", "0.66041625", "0.64915216", "0.6394182", "0.63865393", "0.6292253", "0.6252328", "0.61997074", "0.61993366", "0.61913204", "0.61803615", "0.6095283", "0.6078317", "0.60224664", "0.59334", "0.5921052", "0.5904255", "0.5897822", "0.582768", "0.57853764", "0.5727542...
0.62866193
6
Choose a behavior class, based on the behaviorClass JSON attribute.
def get_behavior_class_from_dict(data): # TODO: Replace with a behavior package. class_map = { "PlayAnim": BehaviorPlayAnim, "PlayArbitraryAnim": BehaviorPlayArbitraryAnim, "ReactToCliff": BehaviorReactToCliff, "DriveOffCharger": BehaviorDriveOffCharger, } cls = class_map...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def behavior_for_attributes(self, attributes):\n for behavior, criteria in self.registered_behaviors:\n if criteria.evaluate(attributes):\n return behavior\n return self.event.default_behavior", "def getBehaviorNature(self, behavior):\n if not self.proxy:\n ...
[ "0.58255094", "0.5570628", "0.51562303", "0.5121632", "0.51032513", "0.5080963", "0.5079439", "0.5076947", "0.50172156", "0.5009232", "0.50005877", "0.49934128", "0.493821", "0.49222156", "0.49222156", "0.48718593", "0.4865874", "0.4862071", "0.4836569", "0.48241413", "0.4805...
0.72726583
0
Collect urls of images by keyword using splash api
def collect_urls_by_keyword(keyword: str, page_num: int, n_max: int, scenery: bool = False): if scenery: keyword += '-scenery' r = requests.get(f'https://api.unsplash.com/search/collections?query={keyword}&page={page_num}&per_page={n_max}&client_id=1H5zbugfvk1UOnX60y2yiMyjNMrE-vdpThxGkP1y9_E') data ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keyword_to_images(keywords):\n searchTerm = ' '.join(keywords)\n searchTerm = searchTerm.replace(' ', '%20')\n\n # Start FancyURLopener with defined version\n # myopener = MyOpener()\n\n # Notice that the start changes for each iteration in order\n # to request a new set of images for each lo...
[ "0.67936283", "0.662286", "0.66023016", "0.65941745", "0.65375906", "0.65149903", "0.64483434", "0.6410244", "0.6386181", "0.6354036", "0.6343934", "0.63412344", "0.6332881", "0.6311104", "0.6299738", "0.62983704", "0.62725866", "0.62346876", "0.62243366", "0.61484414", "0.61...
0.7433807
0
Batch gradient descent for maximumlikelihood estimation
def fit(self, X, Y, lrate=0.01, training_steps=100, coeff_reg=0.1):#, batch_size=1): num_instances = len(X) num_features = len(X[0]) x = T.matrix("x") y = T.vector("y") w = theano.shared(np.random.random((num_features,)), name="w") b = theano.shared(0., name="b") #p = 1 / (1 + T.exp(-(T.do...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batchGradientDescent(x,y,theta,alpha):\n m,n = np.shape(x)\n xTran = x.transpose()\n convergence = 0.000000001\n lastCost = 0\n cost = -1 \n recurseCount = 0\n while abs(lastCost - cost) > convergence: # rcurse until converge\n lastCost = cost\n hypothesis = np.dot(x,theta...
[ "0.72205806", "0.7206563", "0.71251976", "0.6894467", "0.68875915", "0.67967856", "0.6775867", "0.6730671", "0.67216426", "0.6704044", "0.6699318", "0.66864246", "0.6653493", "0.663533", "0.6630918", "0.6626834", "0.66227376", "0.66114336", "0.6599626", "0.6587141", "0.657541...
0.0
-1
Create database VIEWS from files.
def add_views(apps, schema_editor): connection = schema_editor.connection with connection.cursor() as cur: for view in reversed(OCP_ALL_VIEWS): LOG.info(f"""Dropping materialized view "{view}" with cascade""") cur.execute(f"""DROP MATERIALIZED VIEW "{view}" CASCADE;""") for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export_sqlite_views(self):\r\n # Gather the names of report views in the db\r\n SQL_TRAN.execute(\"SELECT name FROM sqlite_master WHERE type='view'\")\r\n view_names = SQL_TRAN.fetchall()\r\n\r\n # Export report views to tsv files\r\n for i in view_names:\r\n\r\n q...
[ "0.6438778", "0.6305463", "0.6267813", "0.61501664", "0.57469606", "0.57229686", "0.5681535", "0.56686246", "0.56341827", "0.5624621", "0.5580693", "0.55182123", "0.5498059", "0.5480512", "0.54795283", "0.54676986", "0.5459569", "0.54512936", "0.5437881", "0.54340816", "0.541...
0.5971611
4
Convert a caffe parameter name to a tensorflow parameter name as defined in the above model
def name_conversion(caffe_layer_name, prefix=''): # beginning & end mapping NAME_MAP = { 'bn_conv1/beta': 'conv0/BatchNorm/beta:0', 'bn_conv1/gamma': 'conv0/BatchNorm/gamma:0', 'bn_conv1/mean/EMA': 'conv0/BatchNorm/moving_mean:0', 'bn_conv1/variance/EMA': 'conv0/BatchNorm/moving_variance:0',...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eff_param():\n return r.TF1('photon_eff_param', eff_param_string(), 0, 7)", "def _get_param_to_param_name(\n model: torch.nn.Module,\n) -> Dict[torch.nn.Parameter, str]:\n param_to_param_names = _get_param_to_unflat_param_names(model)\n for param_names in param_to_param_names.values():\n a...
[ "0.59476686", "0.58388007", "0.5772405", "0.5701666", "0.5692458", "0.5617242", "0.55691546", "0.54260504", "0.53634006", "0.5344747", "0.53117526", "0.5303694", "0.5301256", "0.5296789", "0.5279293", "0.5278879", "0.52710485", "0.5232698", "0.5229766", "0.5218155", "0.520569...
0.6089701
1
Add missing padding to string and return the decoded base64 string.
def base64_decode(s): log = logging.getLogger() s = str(s).strip() try: return base64.b64decode(s) except TypeError: padding = len(s) % 4 if padding == 1: log.error("Invalid base64 string: {}".format(s)) return '' elif padding == 2: s +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad_base64_str(str):\n missing_padding = len(str) % 4\n if missing_padding != 0:\n str += '=' * (4 - missing_padding)\n return str", "def decode_base64(data):\n missing_padding = 4 - len(data) % 4\n if missing_padding:\n data += b'='* missing_padding\n return base64.decodestri...
[ "0.806213", "0.8022017", "0.78917044", "0.78661764", "0.72686636", "0.7100269", "0.71000576", "0.6996135", "0.693596", "0.6920945", "0.6920945", "0.6904011", "0.68946016", "0.68341017", "0.6829386", "0.6726214", "0.6700636", "0.6659003", "0.66499424", "0.65814054", "0.6541725...
0.7816081
4
Called by self._format_as(space), to check whether self and space have compatible sizes. Throws a ValueError if they don't.
def _check_sizes(self, space): my_dimension = self.get_total_dimension() other_dimension = space.get_total_dimension() if my_dimension != other_dimension: if isinstance(space, Conv2DSpace): if my_dimension * space.shape[0] !=\ other_dimension: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_size(self):\n if self.type == 'grid':\n if not self.size:\n raise ChartError(\n \"Layout size must be set \"\n \"if layout type is 'grid'\")\n\n if len(self.size) != 2:\n raise ChartError('Layout size leng...
[ "0.6610175", "0.6451334", "0.6441938", "0.640975", "0.61760485", "0.61393535", "0.61014336", "0.60155046", "0.5922366", "0.58863646", "0.58730096", "0.58581656", "0.5849174", "0.58366275", "0.58356285", "0.5833874", "0.5824362", "0.5816935", "0.5773754", "0.5703666", "0.57024...
0.76109046
0
CLI to collect random commits and analyze maintainability.
def tool(security_dataset, regular_dataset): df = pd.read_csv(security_dataset) add_random_regular_commits(df, regular_dataset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n print(\"Hello World!!!\")\n print(\"Commit to DLNA\")\n print(\"Another commit\")\n print(\"Commit after PR merge\")", "def main():\n# logging.basicConfig(level=logging.DEBUG)\n try:\n user = sys.ARGV[1]\n except:\n user = 'hmm01i'\n repos = getRepos(user)\n ...
[ "0.618323", "0.60287666", "0.5585191", "0.55699843", "0.5559813", "0.5543677", "0.5541772", "0.5530489", "0.5476184", "0.5458055", "0.54341", "0.5431736", "0.5429843", "0.53909594", "0.5388294", "0.5387541", "0.5365055", "0.5360595", "0.5360282", "0.5360282", "0.5341381", "...
0.6278088
0
Add refactoring commits in the dataset.
def add_random_regular_commits(rows, regular_dataset): log.info(f"Will analyze {len(rows)} commits.") for i, row in rows[~pd.notnull(rows['sha-reg'])][::-1].iterrows(): if 'random_commit' not in row.keys(): user = row['owner'] project = row['project'] with ghu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stage_changes(c):\n c.run(f\"git add -u\")", "def tool(security_dataset, regular_dataset):\n df = pd.read_csv(security_dataset)\n add_random_regular_commits(df, regular_dataset)", "def add_commit( self\n , cl\n , mark_number\n , parent_commit_list...
[ "0.6127678", "0.5976285", "0.56654656", "0.553326", "0.55086493", "0.54893506", "0.5359894", "0.5359894", "0.5341617", "0.5340379", "0.53341734", "0.5282182", "0.521549", "0.5194299", "0.51693976", "0.51512754", "0.5129469", "0.5128068", "0.5128068", "0.5128068", "0.5128068",...
0.5277058
12
This is a utility function to obtain a bytefile from storage and load it into memory.
def get_pickle_file(file_name): # change directory os.chdir("../") os.chdir("data") # pickle activities f = open(file_name, "rb") python_data = pickle.load(f) f.close() # change directory # change directory os.chdir("../") os.chdir("pathfinder") return python_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cached_load(filepath: str) -> io.BytesIO:\n with open(filepath, 'rb') as f:\n return io.BytesIO(f.read())", "def bz2_file_bytes_reader(path):\n return bz2.open(path, 'rb')", "def read_as_bytes(filename):\n try:\n with open(filename, \"rb\") as file:\n bytes = a...
[ "0.68174493", "0.6185826", "0.6098357", "0.6079456", "0.6040377", "0.6038012", "0.6038012", "0.60342246", "0.59672946", "0.59166515", "0.5906796", "0.58646876", "0.5849056", "0.58230805", "0.5773357", "0.5756768", "0.5738463", "0.57284206", "0.57050073", "0.5650204", "0.56099...
0.0
-1
Return boxes with a confidence >= `min_score`
def filter_boxes(min_score, boxes, scores, classes): n = len(classes) idxs = [] for i in range(n): if scores[i] >= min_score: idxs.append(i) filtered_boxes = boxes[idxs, ...] filtered_scores = scores[idxs, ...] filtered_classes = classes[idxs, ...] return filtered_bo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_boxes(self, min_score, boxes, scores, classes):\n n = len(classes)\n idxs = []\n for i in range(n):\n if scores[i] >= min_score:\n idxs.append(i)\n \n filtered_boxes = boxes[idxs, ...]\n filtered_scores = scores[idxs, ...]\n filt...
[ "0.7317321", "0.72855526", "0.72492224", "0.72279024", "0.6647105", "0.6314491", "0.63112724", "0.61915874", "0.6165219", "0.61569124", "0.6156313", "0.61135215", "0.6062302", "0.5995685", "0.59620845", "0.5960607", "0.5950879", "0.59485", "0.5940718", "0.5940718", "0.5936835...
0.72886777
1
The original box coordinate output is normalized, i.e [0, 1]. This converts it back to the original coordinate based on the image size.
def to_image_coords(boxes, height, width): box_coords = np.zeros_like(boxes) box_coords[:, 0] = boxes[:, 0] * height box_coords[:, 1] = boxes[:, 1] * width box_coords[:, 2] = boxes[:, 2] * height box_coords[:, 3] = boxes[:, 3] * width return box_coords
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __normalizeBox(self):\n self.currentBox = normalizeBox(self.currentBox)", "def normalizeBox(box):\n x, y, w, h = box\n if w < 0:\n x += (w+1)\n w *= -1\n if h < 0:\n y += (h+1)\n h *= -1\n return (x, y, w, h)", "def _normalize(self, x):\n # TODO: imagen...
[ "0.7233279", "0.69938886", "0.6768024", "0.67188823", "0.6718466", "0.66769713", "0.6532776", "0.6505893", "0.6494021", "0.63477725", "0.6327291", "0.62319106", "0.6229367", "0.62115335", "0.6191667", "0.6175719", "0.6174944", "0.61304796", "0.6116588", "0.6073716", "0.607182...
0.0
-1
Draw bounding boxes on the image
def draw_boxes(image, boxes, classes, thickness=4): draw = ImageDraw.Draw(image) for i in range(len(boxes)): bot, left, top, right = boxes[i, ...] class_id = int(classes[i]) color = 'blueviolet' draw.line([(left, top), (left, bot), (right, bot), (right, top), (left, top)], width=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_bounding_boxes(self, image_path):\n img = cv.imread(image_path, cv.IMREAD_ANYDEPTH)\n bboxes = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)\n unique, counts = np.unique(img, return_counts=True)\n for uni in unique:\n if uni == 0:\n continu...
[ "0.80207103", "0.7730494", "0.7663894", "0.75815976", "0.75812364", "0.7569874", "0.7564505", "0.7560773", "0.74707085", "0.74676245", "0.7462541", "0.7429634", "0.7386207", "0.73359627", "0.73075604", "0.73066705", "0.73026776", "0.72940755", "0.7275691", "0.72722554", "0.72...
0.0
-1
Loads a frozen inference graph
def load_graph(graph_file): graph = tf.Graph() with graph.as_default(): od_graph_def = tf.compat.v1.GraphDef() with tf.io.gfile.GFile(graph_file, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_frozen_graph(frozen_graph_path, graph=None, session=None):\n from diplomacy_research.utils.tensorflow import tf, tf_logging\n\n # Making sure the path exists\n if not os.path.exists(frozen_graph_path):\n LOGGER.error('The frozen graph %s does not exist.', frozen_graph_path)\n raise ...
[ "0.7145618", "0.71300054", "0.6952633", "0.64996564", "0.6480352", "0.64554673", "0.6437847", "0.6419772", "0.6419772", "0.63925844", "0.638914", "0.63779676", "0.6364601", "0.6306616", "0.6300151", "0.627973", "0.6269959", "0.6266776", "0.6258529", "0.62003803", "0.6152927",...
0.60229445
30
Read through a ped/samples file and get the names of the cases and controls.
def getCaseAndControlListsFromPedFile(pedFilePath): CASE = "2" CONTROL = "1" statusIndex = 5 nameIndex = 1 names = defaultdict(list) with open(pedFilePath, "r") as samples: for sample in samples: names[sample.split("\t")[statusIndex]].append(sample.split("\t")[nameIndex]) # The second spot is the ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def samples():\n f = open(config['samples'], \"r\")\n samp=[]\n for line in f:\n samp.append(line.strip().split()[0])\n return samp", "def read_file(testing_file):\n samples = []\n with open(testing_file, 'r') as in_file:\n for line in in_file:\n info = line.strip('\\n'...
[ "0.63636255", "0.6313014", "0.61136013", "0.59631413", "0.56838787", "0.56684047", "0.56344813", "0.5632566", "0.5621312", "0.5583971", "0.55766374", "0.55750257", "0.55492824", "0.55484843", "0.55387455", "0.5510029", "0.5475519", "0.5473172", "0.5460236", "0.5412151", "0.54...
0.6725174
0
Read through the first two lines of a _genotypes file and calculate how many total cases and controls were in the initial ATAV job. (If a sample does not have a variant, they won't show up in the file, so this total needs to be calculated separately.)
def getTotalCaseAndControlCounts(genotypesFilename): comphetSuffix = "" if "comphet" in genotypesFilename: comphetSuffix = " (#1)" # We read through the whole file. Might take a while, but easier than dealing with all edge cases. maxCoveredCasePercentage = 0 maxCoveredControlPercentage = 0 reader = c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_total(self):\n total = 0\n rpk_total = 0.0\n with open(self.filename, 'rU') as my_htseq:\n for line in my_htseq:\n if '_' not in line:\n line = line.rstrip('\\n').split('\\t')\n ensg_id = line[0]\n gen...
[ "0.62967587", "0.6293312", "0.6029363", "0.6015871", "0.5913728", "0.58160174", "0.5763021", "0.5732417", "0.57178193", "0.56836647", "0.56249833", "0.5541682", "0.5532769", "0.5515604", "0.55022156", "0.5498849", "0.5483801", "0.54305834", "0.5416177", "0.5402783", "0.538538...
0.7090837
0
Read through a genotypes file and get the number of QVs per sample.
def getQVcounts(genotypesFilename, caseNames, controlNames): if "genotypes" in genotypesFilename: caseCounts, controlCounts = getQVcountsForDominantModel(genotypesFilename, caseNames, controlNames) elif "comphet" in genotypesFilename: caseCounts, controlCounts = getQVsForComphetModel(genotypesFilename, case...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def n(self):\n return len(self.genotypes)", "def countgenes():\n directory = openfile('db_directory.txt')\n no_genes_file = directory+'GENES_IN_HPO.txt'\n GENES_IN_HPO = openfile(no_genes_file)\n #GENES_IN_HPO = openfile(numbergenes_file)\n return int(GENES_IN_HPO)", "def populate(infile,...
[ "0.6377052", "0.61921424", "0.6050802", "0.5921395", "0.57854915", "0.5723797", "0.5702904", "0.56815153", "0.5647343", "0.5629553", "0.55353963", "0.55299056", "0.54956543", "0.548101", "0.5472195", "0.5413845", "0.54131746", "0.53874993", "0.5385036", "0.53508884", "0.53467...
0.62267786
1
Read through a _genotypes file and get the variant counts for all samples, broken down into cases and controls.
def getQVcountsForDominantModel(genotypesFilename, caseNames, controlNames): # If we have a sample file, then we have everyone's names: if len(caseNames) != 0 or len(controlNames) != 0: caseCounts = {name: 0 for name in caseNames} controlCounts = {name: 0 for name in controlNames} counts = {"case": cas...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_genotypes(self, samples, records, switch):\n\n variant = np.zeros(len(samples))\n for idx, sample in enumerate(samples):\n try:\n gt = records.genotype(sample)['GT']\n except IndexError:\n print(\"something went wrong with:\")\n ...
[ "0.67506015", "0.6729951", "0.64543974", "0.6217519", "0.5930664", "0.5902287", "0.58747613", "0.5775546", "0.5687666", "0.5658399", "0.55744815", "0.55508137", "0.5545412", "0.5542533", "0.5530825", "0.5470585", "0.54633224", "0.5454796", "0.54509187", "0.5425045", "0.539496...
0.6443562
3
Read through a _comphet file and get the variant counts for all samples, broken down into cases and controls. If a sample has 2 variants in one gene, they'll be printed to the same line as "Variant (1)" and "Variant (2)".
def getQVsForComphetModel(comphetVariantsFilename, caseNames, controlNames): # If we have a sample file, then we have everyone's names: if len(caseNames) != 0 or len(controlNames) != 0: caseCounts = {name: set() for name in caseNames} controlCounts = {name: set() for name in controlNames} variantIDs ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTotalCaseAndControlCounts(genotypesFilename):\r\n\r\n\tcomphetSuffix = \"\"\r\n\tif \"comphet\" in genotypesFilename:\r\n\t\tcomphetSuffix = \" (#1)\"\r\n\r\n\t# We read through the whole file. Might take a while, but easier than dealing with all edge cases.\r\n\tmaxCoveredCasePercentage = 0\r\n\tmaxCovered...
[ "0.6928196", "0.625293", "0.58950937", "0.58474743", "0.5823805", "0.56312484", "0.5608807", "0.5597664", "0.5558391", "0.55020434", "0.54880935", "0.5404076", "0.53877914", "0.53493875", "0.53344697", "0.52961344", "0.5296094", "0.5268602", "0.5253312", "0.52310175", "0.5185...
0.6625952
1
Our general logger function.
def writeToLog(logName, message, writeOrAppend): with open(logName, writeOrAppend) as out: out.write(message)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_logger(self):", "def logger(self):\n pass", "def log(self, message):", "def log(self, level, msg, *args, **kwargs):\n pass", "def build_logger(self):\n pass", "def log(self, message: str):", "def _log(self, message):\n pass", "def _log_some_info(self):\n loggin...
[ "0.76633245", "0.7640444", "0.73370457", "0.7284354", "0.72126675", "0.7195057", "0.71616554", "0.71473765", "0.7031027", "0.6963027", "0.6950897", "0.69403726", "0.6933146", "0.68858904", "0.68542427", "0.6837671", "0.6836879", "0.6833609", "0.6813234", "0.6787216", "0.67616...
0.0
-1
Write out the sample name and the number of QVs they have to a log.
def writeOutQVcounts(qvCountsLogName, casesToTheirQVcounts, controlsToTheirQVcounts, missingCases, missingControls): log = "" if missingCases > 0 or missingControls > 0: log += "### A sample file may have not been submitted, and so there are some samples that do not have\n" log += "### any QVs, but we don't...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _print_log(self, step, data=None):\n \n # Set mode to append to log file\n mode = 'a'\n\n if self.logfile is None:\n # Increment log counter for the class. Each instance of the class generates a new log.\n self.__class__.log_no += 1\n\n # Create a lo...
[ "0.60270923", "0.5782031", "0.57312113", "0.5726678", "0.57149386", "0.557019", "0.55264795", "0.5509941", "0.54832083", "0.5469556", "0.54433197", "0.5429885", "0.5374645", "0.5369299", "0.53379154", "0.5330904", "0.5304008", "0.5279867", "0.52705723", "0.52650094", "0.52610...
0.6655646
0
Run Mann Whitney and write out the results.
def runMannWhitney(mannWhitneyLogName, qvsPerCase, qvsPerControl): log = "" log += "Checking amounts of found variants for cases vs. controls. Date: {}.\n".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) log += "Cases (n = {}): Median: {}; mean: {}.\n".format(len(qvsPerCase), np.median(qvsPerCase), n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _mann_whitney(_sample_a, _sample_b):\n res = stats.mannwhitneyu(_sample_a, _sample_b, use_continuity=True)\n print('Mann-Whitney rank test\\nU-statistic: {}\\np-value: {}'.format(res[0], res[1]))\n print('-' * 10)", "def mann_whitney_plus_means(turnstile_weather):\n with_rain = turnst...
[ "0.6443433", "0.62065065", "0.6126351", "0.60448587", "0.58548564", "0.55368865", "0.552356", "0.52770686", "0.5268584", "0.5214635", "0.5069704", "0.5024073", "0.49422473", "0.49388117", "0.49314013", "0.4907475", "0.4886257", "0.48828724", "0.4872175", "0.48712775", "0.4866...
0.6721948
0
Create and plot a histogram of variant counts, broken into cases and controls.
def graphQVcounts(caseCounts, controlCounts, outputName): plt.figure(1) caseCounter = Counter(caseCounts) controlCounter = Counter(controlCounts) totalCases = float(len(caseCounts)) totalControls = float(len(controlCounts)) plt.bar(caseCounter.keys(), np.array(caseCounter.values())/totalCases, facec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hist_qual(self, fontsize=16, bins=100):\n self.rewind()\n data = [x.QUAL for x in self._vcf_reader]\n pylab.hist(data, bins=bins)\n pylab.grid(True)\n pylab.xlabel(\"Variant quality\", fontsize=fontsize)", "def generate_counthist(counts, label, view_lim=[1e-6,1e0,1e0,1e5]):...
[ "0.639714", "0.6303354", "0.6291766", "0.61522007", "0.6151823", "0.61423516", "0.6139937", "0.60908663", "0.6076454", "0.6051278", "0.6031893", "0.595742", "0.5954826", "0.5929051", "0.5881224", "0.5870992", "0.5846922", "0.58407176", "0.5829935", "0.5828306", "0.5822304", ...
0.65548986
0
Parses the arguments of the program
def parse_user_arguments(*args, **kwds): parser = argparse.ArgumentParser( description = "Predict if a pair of drugs is a drug combination", epilog = "@oliva's lab 2017") parser.add_argument('-d1','--drug_name1',dest='drug_name1',action = 'store', help = """ Name of...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def parseArguments(self):\n iterator = iter(sys.argv[1:]) # Skip file name\n for argument in iterator:\n if len(argument) < 2 or argument[:2] != '--':\n self.error('syntax error \"{}\"'.format(argument))\n else:\n de...
[ "0.82726073", "0.75477016", "0.75268954", "0.74781555", "0.74548787", "0.73958445", "0.7384183", "0.7330172", "0.7327063", "0.72733825", "0.7226752", "0.72222376", "0.7221101", "0.7219167", "0.72155046", "0.718937", "0.7186559", "0.7163097", "0.7151462", "0.7149633", "0.71457...
0.0
-1
Predicts if a pair of drugs is a drug combination
def predict(options): # Start marker for time measure start = time.time() print("\n\t\t------------------------------------------------------------------------------------------------------\n") print("\t\tStarting Drug Interactions ANAlysis (DIANA), a program created by @OLIVA'S LAB. Third part: Predi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coxen_multi_drug_gene_selection(\n source_data,\n target_data,\n drug_response_data,\n drug_response_col,\n tumor_col,\n drug_col,\n prediction_power_measure=\"lm\",\n num_predictive_gene=100,\n generalization_power_measure=\"ccc\",\n num_generalizable_gene=50,\n union_of_singl...
[ "0.5656811", "0.53940845", "0.53094256", "0.5222329", "0.51587594", "0.5060356", "0.5006437", "0.4997518", "0.4978938", "0.49725336", "0.49702358", "0.49521005", "0.49268988", "0.4919356", "0.49191993", "0.49191785", "0.49171874", "0.49169835", "0.49162063", "0.4881673", "0.4...
0.48015535
32
Starts a watchfolder in the user's iCloud directory
def do_start_icloud(self, args): args = self.parse_arguments(args) plat = get_local_platform_routines() user = LocalUserRoutines(plat) home_dir = user.get_home_dir() icloud_dir = os.path.join(home_dir, "iCloudDrive", "fiepipe_watch") if not os.path.exists(icloud_dir...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start(self):\n try:\n self.getEverything()\n self._watchFolder()\n except Unauthorized, e:\n self.authorize()\n self.start()\n \n #TODO: make this work\n #self._setPeriodicSync()\n \n print 'stopped'", "def _watchFol...
[ "0.6660409", "0.63080263", "0.60288143", "0.587695", "0.57806844", "0.577429", "0.56855834", "0.5651817", "0.546844", "0.54465985", "0.54192054", "0.5416022", "0.5339537", "0.5321164", "0.52857655", "0.5200085", "0.51923317", "0.5147048", "0.50987595", "0.50855106", "0.507541...
0.669887
0
Starts a watchfolder in the user's Documents directory
def do_start_documents(self, args): args = self.parse_arguments(args) plat = get_local_platform_routines() user = LocalUserRoutines(plat) home_dir = user.get_home_dir() docs_dir = os.path.join(home_dir, "Documents", "fiepipe_watch") if not os.path.exists(docs_dir): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _watchFolder(self):\n wm = pyinotify.WatchManager()\n wm.add_watch(self.gdocs_folder, pyinotify.IN_MODIFY, rec=True)\n \n handler = EventHandler(self)\n notifier = pyinotify.Notifier(wm, handler)\n \n print 'waiting for changes . . .'\n notifier.loop()", ...
[ "0.71423084", "0.6504502", "0.6461225", "0.62531656", "0.62520504", "0.59916514", "0.5971321", "0.5947779", "0.58603346", "0.57456636", "0.5725944", "0.5721107", "0.56487375", "0.55851334", "0.5476341", "0.54706573", "0.54611844", "0.5439405", "0.53978366", "0.5392165", "0.53...
0.66735244
1
Starts a named watchfolder in a given directory
def do_start(self, args): args = self.parse_arguments(args) if len(args) < 1: self.perror("No name given.") return if len(args) < 2: self.perror("No path given.") return name = args[0] path = args[1] if name in self._wat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(dir_to_watch):\n event_handler = AudioCreatedHandler()\n observer = Observer()\n observer.schedule(event_handler, dir_to_watch, recursive=True)\n observer.start()\n try:\n while True:\n time.sleep(1) \n except KeyboardInterrupt:\n print \"Stopping...\"\n ...
[ "0.6714537", "0.66689855", "0.6548735", "0.6480822", "0.63712686", "0.6312195", "0.6257685", "0.6201636", "0.61205935", "0.611318", "0.6073615", "0.6034104", "0.5983241", "0.5969944", "0.5909975", "0.58480537", "0.57867706", "0.5744905", "0.569635", "0.56687886", "0.56275433"...
0.6300915
6
Runs R correlation calculations and pvalue corrections on the given dataframe.
def run_r_corr(df, corr_type='spearman', p_correction='BH'): num_cols = len(df.columns.values) r_dataframe = pandas2ri.py2ri(df) r_as = r['as.matrix'] rcorr = r['rcorr'] r_p_adjust = r['p.adjust'] result = rcorr(r_as(r_dataframe), type=corr_type) rho = result[0] n = result[1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def df_corr(df, method=\"pearson\", min_periods=1):\n op = DataFrameCorr(method=method, min_periods=min_periods)\n return op(df)", "def df_corrwith(df, other, axis=0, drop=False, method=\"pearson\"):\n axis = validate_axis(axis, df)\n if drop:\n # TODO implement with df.align(method='inner')\n...
[ "0.67682356", "0.6436532", "0.6363697", "0.625707", "0.6251887", "0.61984104", "0.6184104", "0.61419874", "0.61195624", "0.6110142", "0.61037296", "0.61014676", "0.60986847", "0.6088977", "0.60165393", "0.6007464", "0.59634864", "0.5930247", "0.5885391", "0.5870298", "0.58694...
0.8098069
0
returns the matplotlib plt object for the specified correlations.
def build_corr_mat(corrs, p_vals, labels, title, alpha): plt.rcParams["figure.figsize"] = [20,12] plt.imshow(corrs) for i in range(len(labels)): for j in range(len(labels)): text = "{0:.2f}".format(r_corrs[i, j]) p = p_vals[i,j] if p < alpha / len(labels): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_corr_plot():\r\n fig = plt.figure(figsize=(12, 12))\r\n ax = fig.add_subplot", "def correlations(self, data,label, **kwds):\n corrmat = data.corr(**kwds)\n\n fig, ax1 = plt.subplots(ncols=1, figsize=(6,5))\n\n opts = {'cmap': plt.get_cmap(\"RdBu\"),\n 'vmin': -...
[ "0.68624145", "0.6416293", "0.630825", "0.62502193", "0.62021136", "0.6112833", "0.6112833", "0.6105096", "0.61047894", "0.60861915", "0.6000319", "0.5963655", "0.5898949", "0.58250797", "0.58071315", "0.57193774", "0.571394", "0.5691973", "0.5680117", "0.565944", "0.56465924...
0.53622854
49
Returns dataframe of features significantly correlated with the target variable.
def get_sig_features(cols, target, corrs, p_vals, exclude_cols=[], alpha=0.05): idx = np.where(cols == target) sel_corrs = corrs[idx] sel_p_vals = p_vals[idx] sel_stats = np.transpose(np.vstack((sel_corrs, sel_p_vals))) sel_df = pd.DataFrame(sel_stats, index=cols, columns=['corr', 'p']) si...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_feature_corr(self):\n \n return self.train_data.astype(float).corr(method='kendall')", "def calculate_correlation(df, vars_to_corr, target_var) :\n\n\n mean = df[target_var].mean()\n sigma = df[target_var].std()\n\n correlation = []\n error = []\n\n for j in vars_to_cor...
[ "0.65806085", "0.6303217", "0.5886798", "0.5873877", "0.5863441", "0.5858851", "0.5834802", "0.5786022", "0.5741659", "0.56739926", "0.5565418", "0.5546522", "0.5505434", "0.55022067", "0.54964596", "0.54573977", "0.5441468", "0.54347897", "0.54161024", "0.5409365", "0.539591...
0.5719083
9
Generate yaml test cases from the yaml files in the given directory
def generate_yaml_tests(directory): for yml_file in directory.glob("*/*.yml"): data = yaml.safe_load(yml_file.read_text()) assert "cases" in data, "A fixture needs cases to be used in testing" # Strip the parts of the directory to only get a name without # extension and resolver dir...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_yaml_tests(directory):\n for yml_file in directory.glob(\"*.yml\"):\n data = yaml.safe_load(yml_file.read_text())\n assert \"cases\" in data, \"A fixture needs cases to be used in testing\"\n\n # Strip the parts of the directory to only get a name without\n # extension a...
[ "0.81488127", "0.7012131", "0.6698927", "0.66773045", "0.6447837", "0.63057554", "0.627959", "0.6240237", "0.6215887", "0.6164365", "0.609653", "0.60548806", "0.6040794", "0.6032984", "0.5965803", "0.59477776", "0.5941153", "0.5919988", "0.5910295", "0.5891571", "0.58607346",...
0.8186191
0
Give a nice parameter name to the generated function parameters
def id_func(param): if isinstance(param, dict) and ":name:" in param: return param[":name:"] retval = str(param) if len(retval) > 25: retval = retval[:20] + "..." + retval[-2:] return retval
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def function_name(parameters):", "def _name_from_args(func, _, params):\n return \"{}_{}\".format(func.__name__, \"_\".join(str(arg) for arg in params.args))", "def _formal_params(self, doclet):\n name, paren, params = self.arguments[0].partition('(')\n return ('(%s' % params) if param...
[ "0.75918895", "0.7188827", "0.70072734", "0.6688677", "0.6679166", "0.66557956", "0.6603848", "0.6521158", "0.6502662", "0.6339839", "0.6331608", "0.6301998", "0.62911433", "0.62872463", "0.6281126", "0.6255605", "0.62299716", "0.6222758", "0.62045634", "0.61936885", "0.61494...
0.6672928
5
Creates directory if not exists
def mkdir(dirName): raw = 'mockaroo_data/raw/' + dirName cln = 'mockaroo_data/cln/' + dirName call(['mkdir', raw]) call(['mkdir', cln]) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_dir(self):\n if not os.path.exists(self.d):\n try:\n os.mkdir(self.d)\n except OSError, e:\n if e.errno != 17:\n raise\n pass", "def create_dir(path):\n if not os.path.exists(path):\n os.makedirs(path)...
[ "0.83656484", "0.834942", "0.82707036", "0.82707036", "0.82600933", "0.8223895", "0.82130796", "0.82078326", "0.82049537", "0.8204173", "0.8199202", "0.8157144", "0.8146599", "0.81431687", "0.81396705", "0.8137432", "0.8130188", "0.8127501", "0.8105457", "0.80995184", "0.8095...
0.0
-1
Creates an inline LOAD_ATTR call, using a validator.
def attr(self, attr: _PyteAugmentedValidator): # Use the __override_opcode param and __override_list_restriction return _AttrLoader(self, attr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_Attribute(self, node):\n self.generic_visit(node)\n if isinstance(node.ctx, ast.Load):\n args = [ node.value, ast.Str(node.attr) ]\n return to_call(to_name('getattr'), args)\n return node", "def loader_for_attribute(self, attribute):\n return lambda x: ...
[ "0.5518646", "0.53865415", "0.53345865", "0.528758", "0.51410544", "0.50560033", "0.5017652", "0.4997242", "0.4987636", "0.4981382", "0.48947912", "0.48831546", "0.48165223", "0.47417164", "0.4713835", "0.4696541", "0.4672414", "0.46377176", "0.46348855", "0.4614697", "0.4609...
0.6687772
0
Add an attribute to the chain of attributes to load.
def attr(self, item: _PyteAugmentedValidator): self._attrs.append(item) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_attribute(self, attr):\n self.attrs.add_attribute(attr)", "def add_attribute(self, attr):\n self.add(attr)", "def add_attribute(self, attr):\n self.attrs.add(attr)", "def add_attribute(self, attr: ResourceAttributeDescriptor) -> None:\n self._attributes[assert_not_none(att...
[ "0.7693865", "0.76586586", "0.75456613", "0.7126628", "0.70298725", "0.6939387", "0.6719474", "0.67137754", "0.6698703", "0.66245776", "0.65580535", "0.6553192", "0.6553192", "0.6553192", "0.6502369", "0.65008056", "0.6477134", "0.6433667", "0.6418253", "0.6397711", "0.637903...
0.5912731
46
A method running a allreduce operation in a data parallel group.
def handle_gradient(self): self._optimizer.sync_grad()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce_run():", "def ol_mpi_allreduce(data, operator: Union[int, str, None] = None):\n import numba_mpi\n\n if operator is None or isinstance(operator, nb.types.NoneType):\n op_id = -1 # value will not be used\n elif isinstance(operator, nb.types.misc.StringLiteral):\n op_id = Operato...
[ "0.6912629", "0.67692804", "0.66038615", "0.60643405", "0.5996911", "0.59751207", "0.59230024", "0.5809717", "0.5766782", "0.5738034", "0.5723741", "0.56574804", "0.5656459", "0.5588614", "0.55475324", "0.553867", "0.55309284", "0.55309284", "0.55309284", "0.55309284", "0.553...
0.0
-1
Parse rule about what child bags a parent bag can contain
def parse_rule(line): parent, children_str = line.strip().split(" bags contain ") children = {} for child in children_str.split(", "): match = re.match(r"(?P<quantity>\d+) (?P<color>.+?) bag", child) if match: children[match.group("color")] = int(match.group("quantity")) retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__findChildBags(self):\n file = \"\"\"\n shiny gold bags contain 2 dark red bags.\n dark red bags contain 2 dark orange bags.\n dark orange bags contain 2 dark yellow bags.\n dark yellow bags contain 2 dark green bags.\n dark green bags contain 2 dark blue bags.\n dark blue bags contai...
[ "0.6878267", "0.6853976", "0.6154937", "0.61455214", "0.5890407", "0.5784656", "0.5481967", "0.5432812", "0.53975284", "0.53018963", "0.528658", "0.517007", "0.51429975", "0.51294297", "0.51093775", "0.51039433", "0.4958595", "0.49047592", "0.48926118", "0.4822519", "0.480323...
0.6862749
1
Gets lists of lists of SubContour objects from a watershed array using ImageContour
def GetSubContoursByFrame(watershed, allValsByFrame): scListByFrame = [] for frame in range(len(watershed)): scList = [] for v in allValsByFrame[frame]: boundingRect = ImageContour.GetBoundingRect(watershed[frame], v) # No longer needed: #contour,turns,vals = ImageContour...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_contours(self):\r\n (contours, _) = cv2.findContours(self.image.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)\r\n return [DbugContour(cv_contour=contour) for contour in contours]", "def contour_ice(dataarray):\n contours = dataarray.plot.contourf(vmin=0, vmax=100, levels=5)\n ...
[ "0.6358348", "0.62865835", "0.61682415", "0.61467576", "0.6096353", "0.60877997", "0.6076599", "0.60685176", "0.6063275", "0.6045179", "0.6035992", "0.6009514", "0.59757787", "0.5924858", "0.5912952", "0.5906821", "0.5885125", "0.5875746", "0.5873737", "0.5834278", "0.5828782...
0.6689849
0
Gets lists of lists of CVLS's from a watershed array use GetSubContoursByFrame instead!
def GetContourValuesLengthsAndSubContoursByFrame(watershed, allValsByFrame): return [ [sc.cVLS() for sc in scList] for scList in GetSubContoursByFrame(watershed, allValsByFrame) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetSubContoursByFrame(watershed, allValsByFrame):\n scListByFrame = []\n for frame in range(len(watershed)):\n scList = []\n for v in allValsByFrame[frame]:\n boundingRect = ImageContour.GetBoundingRect(watershed[frame], v)\n # No longer needed: #contour,turns,vals = I...
[ "0.75937665", "0.6507299", "0.6484516", "0.6458244", "0.6308807", "0.62851155", "0.6266374", "0.62063503", "0.60648507", "0.59767586", "0.5921466", "0.5914407", "0.5904614", "0.58996433", "0.58695424", "0.58617276", "0.5860281", "0.584063", "0.577641", "0.5762255", "0.5724690...
0.6806032
1
Identify every contour in the watershed segmentation for each frame as defined by each pair of cell IDs (vals). Also, return the order of contours that is needed to reconstruct the border surrounding each cell.
def GetSubContoursAndOrderingByFrame(watershed, allValsByFrame): cellNetworkList = GetCellNetworksByFrame(watershed, allValsByFrame) scListByFrame = [cellNetworkList[i].subContours for i in range(len(watershed))] orderOfSCsByValueByFrame = [ cellNetworkList[i].orderOfSubContoursDict for i in range(l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetSubContoursByFrame(watershed, allValsByFrame):\n scListByFrame = []\n for frame in range(len(watershed)):\n scList = []\n for v in allValsByFrame[frame]:\n boundingRect = ImageContour.GetBoundingRect(watershed[frame], v)\n # No longer needed: #contour,turns,vals = I...
[ "0.682303", "0.62864244", "0.6280185", "0.60297304", "0.59573025", "0.5944612", "0.58334446", "0.57923675", "0.5783148", "0.5739409", "0.56378686", "0.55968744", "0.5590528", "0.55639815", "0.5518648", "0.54740554", "0.5468312", "0.5427046", "0.5407643", "0.5381385", "0.53796...
0.6968971
0
Identify every contour in the watershed segmentation for each frame as defined by each pair of cell IDs (vals). Also, return the order of contours that is needed to reconstruct the border surrounding each cell. DEPRECATED, use GetSubContoursAndOrderingByFrame instead!
def GetContourValuesLengthsAndSubContoursAndOrderOfSubContoursByFrame( watershed, allValsByFrame ): scListByFrame, orderOfSCsByValueByFrame = GetSubContoursAndOrderingByFrame( watershed, allValsByFrame ) cVLSByFrame = [[sc.cVLS() for sc in scList] for scList in scListByFrame] return cVLSByFr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetSubContoursAndOrderingByFrame(watershed, allValsByFrame):\n cellNetworkList = GetCellNetworksByFrame(watershed, allValsByFrame)\n scListByFrame = [cellNetworkList[i].subContours for i in range(len(watershed))]\n orderOfSCsByValueByFrame = [\n cellNetworkList[i].orderOfSubContoursDict for i i...
[ "0.7544308", "0.72690433", "0.6326455", "0.6134341", "0.6090655", "0.60881174", "0.60103273", "0.59323454", "0.589878", "0.5895224", "0.5728049", "0.5722162", "0.5446987", "0.54307616", "0.53550386", "0.5353401", "0.5350056", "0.53280115", "0.53188914", "0.5309465", "0.529283...
0.6577085
2
Turn a cVLS into a list of points (xyList) and a dictionary of index lists (into xyList) with cellID keys (polyList) polyList basically contains the information that reconstructs each individual contour from points Appends the first point to the end of each list to close the loop and makes plotting cleaner, but be caut...
def GetXYListAndPolyListFromCVLS(cVLS, allValsByFrame, orderOfSCsByValueByFrame): numFrames = len(cVLS) xyList = [ sorted(list(set(tuple(pt) for c in cvlsByVal for pt in c[2]))) for cvlsByVal in cVLS ] polyList = [] for t in range(numFrames): polyList.append({}) for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def individual_plot(z, cf_lvls, cl_lvls, cline_label_format=cline_label_format_default, log_scale=False ,\n extend=\"neither\"):\n map_plot.drawcoastlines(linewidth=.4)\n\n if log_scale:\n norm = colors.LogNorm(vmin=cf_lvls[0], vmax=cf_lvls[-1])\n else:\n norm = None\n\n ...
[ "0.57014245", "0.5649377", "0.56392044", "0.55886257", "0.5495664", "0.54937655", "0.5468166", "0.54670477", "0.54585874", "0.5396782", "0.5394453", "0.5374216", "0.53528965", "0.5322514", "0.53171647", "0.5304197", "0.5300245", "0.52861774", "0.52711666", "0.526915", "0.5230...
0.6929526
0
Operates INPLACE, so use cautiously...
def LimitPointsBetweenSubContourNodes(scList, numInteriorPointsDict, interpolate=True): limIntPtsFunc = ( limitInteriorPointsInterpolating if interpolate else limitInteriorPoints ) for sc in scList: sc.points = limIntPtsFunc(sc.points, numInteriorPointsDict[tuple(sc.values)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mod_inplace(a, b):", "def add_inplace(a, b):", "def psi_inplace(a):", "def second_inplace(a):", "def mul_inplace(a, b):", "def le_inplace(a,b):", "def sub_inplace(a, b):", "def or__inplace(a,b):", "def inv_inplace(a):", "def sgn_inplace(a):", "def exp_inplace(a):", "def ge_inplace(a,b):",...
[ "0.6320513", "0.63055974", "0.6295562", "0.6247203", "0.6221748", "0.61597484", "0.6049256", "0.60334474", "0.6032077", "0.5932389", "0.5925243", "0.5923073", "0.5862695", "0.58618164", "0.58565295", "0.5828316", "0.5803157", "0.5762689", "0.5715238", "0.56960684", "0.5693837...
0.0
-1
Return a copy of the cVLS, but trim some points between triple junctions using one of several approaches.
def GetCVLSWithLimitedPointsBetweenNodes( cVLS, allValsByFrame, splitLength=1, fixedNumInteriorPoints=None, interpolate=True ): allValues = list(set(tuple(flatten(allValsByFrame)))) allPairs = sorted( list(set([tuple(c[0]) for cVLSByFrame in cVLS for c in cVLSByFrame])) ) # Value pairs... ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decomposing_line_cut_by_splicing(P, v, w):\n\n\n\tv_Point = Point(v)\n\tw_Point = Point(w)\n\n\tchain = LineString(P[0]+[P[0][0]])\n\n\tdistance_to_v = chain.project(v_Point)\n\tdistance_to_w = chain.project(w_Point)\n\n\tif not chain.intersects(v_Point):\n\t\tprint(\"decomposing_cut_as_line: V not on chain\")...
[ "0.6545068", "0.6061567", "0.56634015", "0.55024093", "0.5485883", "0.5218839", "0.51911056", "0.51615465", "0.50686365", "0.50194067", "0.50190455", "0.4984925", "0.49776727", "0.49476588", "0.49237248", "0.49079263", "0.48954168", "0.48850134", "0.48548362", "0.483178", "0....
0.45522165
67
Get an list of points and a connection network from a cVLS and orderOfSCsByValueByFrame; limit points between triple junctions (Applies GetCVLSWithLimitedPointsBetweenNodes and then GetXYListAndPolyListFromCVLS)
def GetXYListAndPolyListWithLimitedPointsBetweenNodes_CVLS( cVLS, allValsByFrame, orderOfSCsByValueByFrame, splitLength=1, fixedNumInteriorPoints=None, interpolate=True, ): cVLS2 = GetCVLSWithLimitedPointsBetweenNodes( cVLS, allValsByFrame, splitLength, fixedN...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetCVLSWithLimitedPointsBetweenNodes(\n cVLS, allValsByFrame, splitLength=1, fixedNumInteriorPoints=None, interpolate=True\n):\n allValues = list(set(tuple(flatten(allValsByFrame))))\n allPairs = sorted(\n list(set([tuple(c[0]) for cVLSByFrame in cVLS for c in cVLSByFrame]))\n ) # Value pai...
[ "0.6758528", "0.65826356", "0.5632501", "0.55175966", "0.54169285", "0.5379928", "0.5346093", "0.5311847", "0.53098977", "0.52789253", "0.52344453", "0.52038324", "0.5167569", "0.51378644", "0.51114464", "0.50953865", "0.5084913", "0.5053021", "0.5044931", "0.5041024", "0.501...
0.71487695
0
Make 2 simplified subcontour networks, one for scListRef and another for scList with a 1to1 mapping to the first
def GetMatchedSubContourLists( scListRef, scList, allValsByFrame, orderOfSCsByValue, splitLength=1, fixedNumInteriorPoints=None, ): ## NOT DONE! MERGE LATER?? return simplifiedSCListRef, simplifiedSCList
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetMatchedSubContourListsCollapsing(scListA, scListB):\n\n if (\n scListA == scListB\n ): # if we got the same object for some reason, just return 2 shallow clones\n return scListA, scListB\n\n scsMatchedInB = [] # This keeps us from looping over both lists\n\n scsMatchedInB, remove...
[ "0.6174592", "0.5594567", "0.5401644", "0.53908986", "0.5365256", "0.5335248", "0.5255532", "0.5243055", "0.5222066", "0.5215828", "0.5205438", "0.5200392", "0.5197557", "0.51619846", "0.51185894", "0.5075667", "0.5075613", "0.5074813", "0.5073621", "0.50514334", "0.50234973"...
0.6822347
0
Check all the subcontours in A to see if they have a match in B and return them Also check for flipped matches; in the event of a flip, both sc's are flagged for removal
def FindMatchesAndRemovals(scListA, scListB, searchInds=None): scsMatchedInB = [] removeFromA = [] removeFromB = [] if searchInds is None: searchInds = list(range(len(scListA))) for ind in searchInds: sca = scListA[ind] # Look for each sc from A in B: matchTuples = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetMatchedSubContourListsCollapsing(scListA, scListB):\n\n if (\n scListA == scListB\n ): # if we got the same object for some reason, just return 2 shallow clones\n return scListA, scListB\n\n scsMatchedInB = [] # This keeps us from looping over both lists\n\n scsMatchedInB, remove...
[ "0.67644656", "0.5664181", "0.55579877", "0.5505676", "0.5449042", "0.5422501", "0.53664684", "0.535521", "0.5319952", "0.53025115", "0.5284908", "0.5258869", "0.52418005", "0.52386093", "0.52161735", "0.5211302", "0.51943326", "0.5173569", "0.51730245", "0.51399046", "0.5133...
0.64999247
1
Make 2 simplified subcontour networks, making sure that there is a 1to1 mapping between all points; this function collapses pairs of subcontours that do not match but are in between the same 4 cells
def GetMatchedSubContourListsCollapsing(scListA, scListB): if ( scListA == scListB ): # if we got the same object for some reason, just return 2 shallow clones return scListA, scListB scsMatchedInB = [] # This keeps us from looping over both lists scsMatchedInB, removeFromA, removeF...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiple_intersections():\n levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3,\n 754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7,\n 534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276.,\n ...
[ "0.5663014", "0.55421275", "0.5500052", "0.54700613", "0.54657197", "0.5435926", "0.54106635", "0.540982", "0.5407893", "0.54021794", "0.5359405", "0.5358323", "0.5355261", "0.53323746", "0.5324935", "0.5305605", "0.53029805", "0.5296254", "0.5277591", "0.5276798", "0.5273874...
0.6103664
0
Go all the way from raw 2d+t array to an pointList,indexes format
def MakePolygonNetworkFromWaterSeg( waterArr, minSplit=30, allValsByFrame=None, cVLS=None ): if allValsByFrame is None: allValsByFrame = [list(set(w.flat)) for w in waterArr] if cVLS is None: cVLS = GetContourValuesLengthsAndSubContoursByFrame(waterArr, allValsByFrame) allPtsList = [] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _point_array(self, objects, unique_id):\n points = []\n ids = []\n for idx, row in tqdm(objects.iterrows(), total=objects.shape[0]):\n if row[\"geometry\"].type in [\"Polygon\", \"MultiPolygon\"]:\n poly_ext = row[\"geometry\"].boundary\n else:\n ...
[ "0.62952024", "0.6216155", "0.6199011", "0.60683894", "0.6059465", "0.6004489", "0.5989433", "0.5935704", "0.5931404", "0.59047157", "0.5871109", "0.58357066", "0.58297163", "0.5827456", "0.58271873", "0.582091", "0.57979715", "0.57417595", "0.5718235", "0.57016736", "0.57009...
0.0
-1
Tests whether ``limit_string_length`` works as intended.
def test__limit_string_length(string, max_length): return limit_string_length(string, max_length)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_string_max_length(self, value):\n if self.max_length is not None:\n return len(str(value)) <= self.max_length\n else:\n return True", "def _str_len_check(text, min_len, max_len):\n if not isinstance(text, str):\n raise ValueError(\"expected string type\...
[ "0.7828164", "0.74206644", "0.7354528", "0.73487365", "0.730151", "0.7263644", "0.721242", "0.7049977", "0.7049977", "0.696591", "0.69547063", "0.6921804", "0.68282324", "0.68267554", "0.6825206", "0.6779123", "0.67705727", "0.66442156", "0.66199005", "0.65304154", "0.6527428...
0.87113315
0
Makes sure that an element is only once in a set
def making_sets(lists): empty_set = [] lists =lists.split() for elements in lists: if elements == " ": next else: if elements not in empty_set: empty_set.append(elements) return empty_set
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_duplicates_set(L):\r\n return len(L) != len(set(L))", "def is_unique(x):\n return len(set(x)) == len(x)", "def contains_duplicate_fast_set(self, nums: List[int]) -> bool:\n visited = set()\n for i in nums:\n if i in visited:\n return True\n visit...
[ "0.7018525", "0.69216627", "0.6786688", "0.67724", "0.65951574", "0.6533579", "0.6502767", "0.6317338", "0.62912786", "0.6264362", "0.6228308", "0.62009895", "0.61905575", "0.61454374", "0.6141629", "0.6129668", "0.61090344", "0.6108465", "0.6100084", "0.6098274", "0.6094932"...
0.0
-1
Creates the intersection for both sets
def intersection(A,B): set_A = A set_B = B sorted_intersection = [] for elements in set_A: if elements in set_B: sorted_intersection.append(elements) return sorted_intersection
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_intersection(set_a, set_b):\n \n intersection = set_b & set_a\n \n return intersection", "def intersection(self, *other):\n new_ordered_set = OrderedSet()\n\n for element in self:\n for obj in other:\n if element not in obj:\n break\n ...
[ "0.8064488", "0.759755", "0.7544426", "0.75385064", "0.7532488", "0.751954", "0.7467276", "0.7437161", "0.7419048", "0.74105626", "0.7405655", "0.7400201", "0.7389499", "0.7355031", "0.7274344", "0.7242505", "0.7151147", "0.7141193", "0.7128307", "0.71257377", "0.7113491", ...
0.71919143
16
Creates the union for both sets
def union(A,B): set_A = A set_B = B sorted_union = [] for elements in set_A: if elements not in sorted_union: sorted_union.append(elements) for elements in set_B: if elements not in sorted_union: sorted_union.append(elements) return sorted_union
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def union(set1, set2):", "def union(self, other):\n # initialize new Set from the elements in the first Set\n union_set = Set(self.get_elements())\n\n # add every element in the second Set to a new Set and return it\n for element in other.get_elements():\n union_set.add(ele...
[ "0.91032857", "0.8199574", "0.81561077", "0.8112362", "0.8112362", "0.8079239", "0.7954901", "0.78030175", "0.7769405", "0.7736159", "0.7602489", "0.7571999", "0.75703096", "0.75657684", "0.7470459", "0.7423027", "0.7389487", "0.7339673", "0.7271273", "0.72401893", "0.7232426...
0.78106946
7
Merge thing classes to one class. In PanopticFPN, the background labels will be reset from `0` to `self.num_stuff_classes1`, the foreground labels will be merged to `self.num_stuff_classes`th channel.
def _set_things_to_void(self, gt_semantic_seg): gt_semantic_seg = gt_semantic_seg.int() fg_mask = gt_semantic_seg < self.num_things_classes bg_mask = (gt_semantic_seg >= self.num_things_classes) * ( gt_semantic_seg < self.num_things_classes + self.num_stuff_classes) new_gt_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_class_labels(classes,group):\n classes=np.asarray(classes)\n if (classes.dtype != int) and (classes.dtype != 'int64') and (classes.dtype != 'int32'):\n classes_merged=np.zeros(classes.shape,dtype=object)\n for subgroup in group:\n subgroup_label='+'.join(subgroup)\n ...
[ "0.5646296", "0.5563238", "0.55517465", "0.524863", "0.5160917", "0.5154303", "0.51411086", "0.5111963", "0.5110147", "0.50583875", "0.50512093", "0.50234336", "0.50105685", "0.50064385", "0.5000355", "0.49941373", "0.49783427", "0.4972571", "0.49269307", "0.49222225", "0.491...
0.0
-1
The loss of PanopticFPN head. Things classes will be merged to one class in PanopticFPN.
def loss(self, seg_preds, gt_semantic_seg): gt_semantic_seg = self._set_things_to_void(gt_semantic_seg) return super().loss(seg_preds, gt_semantic_seg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_loss(self):\n raise NotImplementedError", "def get_loss(self):\n raise NotImplementedError", "def compute_loss(self):", "def loss(self):\n return self._loss", "def loss(self) -> KernelLoss:\n return self._loss", "def loss(self):\n return self._get(\"loss\")", ...
[ "0.70618695", "0.69945925", "0.6858851", "0.67771924", "0.6720419", "0.67067975", "0.6667089", "0.66429305", "0.6599716", "0.65971327", "0.65931565", "0.6573648", "0.65692914", "0.65643126", "0.649664", "0.6443536", "0.6420886", "0.64154387", "0.64138764", "0.6337381", "0.628...
0.0
-1
Split A at q and merge together in order.
def merge(A, p, q, r): n_1 = q-p+1 n_2 = r-q L = [] R = [] for i in range(n_1): L.append(A[p+i]) for j in range(n_2): R.append(A[q+j+1]) L.append(math.inf) R.append(math.inf) i = 0 j = 0 for k in range(p, r+1): if L[i] <= R[j]: A[k] = L[i] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(A, p, q, r):\n\n # Split A[p..r] into L = A[p..q] and R = A[q+1..r]\n n1 = q - p + 1 # will hold A[p..q]\n n2 = r - q # will hold A[q+1..r]\n\n L = [0] * (n1 + 1)\n R = [0] * (n2 + 1)\n \n for i in range(n1):\n L[i] = A[p+i]\n for j in range(n2):\n R[j] = A[q+j...
[ "0.61172956", "0.5973977", "0.5877295", "0.5761929", "0.556019", "0.52428263", "0.5225745", "0.51877797", "0.5173802", "0.513103", "0.5128278", "0.5124813", "0.511389", "0.5050456", "0.50198215", "0.4964687", "0.4958875", "0.49537897", "0.49401355", "0.48680025", "0.48670024"...
0.58953327
2
Split A at q and merge together in order.
def merge_in_place(A, p, q, r): n_1 = q - p + 1 n_2 = r - q L = 0 R = 0 for k in range(p, r+1): if A[p] <= A[q + 1]: A.insert(r+1, A[p]) del A[p] L += 1 q -= 1 else: A.insert(r+1, A[q+1]) del A[q+1] R...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(A, p, q, r):\n\n # Split A[p..r] into L = A[p..q] and R = A[q+1..r]\n n1 = q - p + 1 # will hold A[p..q]\n n2 = r - q # will hold A[q+1..r]\n\n L = [0] * (n1 + 1)\n R = [0] * (n2 + 1)\n \n for i in range(n1):\n L[i] = A[p+i]\n for j in range(n2):\n R[j] = A[q+j...
[ "0.6118815", "0.58961606", "0.5878436", "0.57619405", "0.5558039", "0.5241369", "0.5224264", "0.5186988", "0.5172165", "0.51325655", "0.5128098", "0.51249146", "0.51147157", "0.5049574", "0.5020555", "0.49630874", "0.49623552", "0.49531335", "0.49419618", "0.48679426", "0.486...
0.5974006
1
Sort array elements in A between p and r using mergesort.
def mergesort(A, p, r): if p < r: q = (p+r)//2 mergesort(A, p, q) mergesort(A, q + 1, r) merge(A, p, q, r)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort(self, A, index, p, r, rc_arr):\n\n if p < r:\n q = (p + r) // 2\n\n self.sort(A, index, p, q, rc_arr)\n self.sort(A, index, q + 1, r, rc_arr)\n self.merge(A, index, p, q, r, rc_arr)", "def mergesort_ip(A, p, r):\n if p < r:\n q = (p+r)//2\n ...
[ "0.83909804", "0.82299715", "0.7800592", "0.752118", "0.74472076", "0.74064726", "0.7010142", "0.69270617", "0.6911257", "0.6762529", "0.6758566", "0.67509073", "0.6742108", "0.6702788", "0.66815907", "0.6673625", "0.6635363", "0.656472", "0.65487516", "0.6545953", "0.6545235...
0.86928904
0
Sort array elements in A between p and r using mergesort inplace.
def mergesort_ip(A, p, r): if p < r: q = (p+r)//2 mergesort(A, p, q) mergesort(A, q + 1, r) merge_in_place(A, p, q, r)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mergesort(A, p, r):\n if p < r:\n q = (p+r)//2\n mergesort(A, p, q)\n mergesort(A, q + 1, r)\n merge(A, p, q, r)", "def sort(self, A, index, p, r, rc_arr):\n\n if p < r:\n q = (p + r) // 2\n\n self.sort(A, index, p, q, rc_arr)\n self.sort...
[ "0.84125704", "0.83105433", "0.7512306", "0.7361288", "0.73299336", "0.7286003", "0.6971325", "0.69071525", "0.689582", "0.6885693", "0.68768835", "0.6779977", "0.66591114", "0.662605", "0.6586384", "0.65090984", "0.6479134", "0.64221436", "0.64146775", "0.64103496", "0.63233...
0.83402205
1
Store an object's key.
def save(self, object_id, object_key, unique_type=None): self.storage.save("", object_id, { "object_key": object_key, "unique_type": unique_type }) self.key_object[object_key] = object_id if unique_type: if unique_type not in self.unique_objects: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(self, key, obj):\n attrs = self.load_attrs()\n attrs[key] = obj\n self.store_attrs(attrs)", "def store(self, key, value):\n pass", "def setKey(self, key):\n if hasattr(key, '__class__') and issubclass(key.__class__, ObjectKey):\n key = key.getKey()\n\n ...
[ "0.7458511", "0.71172404", "0.6803623", "0.6750187", "0.6709677", "0.66902435", "0.6667568", "0.6667568", "0.6667472", "0.66614276", "0.6657352", "0.6639487", "0.66291237", "0.66127026", "0.65728253", "0.65728253", "0.6540316", "0.6503544", "0.649624", "0.64704573", "0.645637...
0.68876964
2
Get an object's element key.
def get_key(self, object_id): try: info = self.storage.load("", object_id) return info["object_key"] except KeyError: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def object_key(self) -> str:\n return self._values.get('object_key')", "def get_key(self, item):\r\n return item[0]", "def key(self):\n raise NotImplementedError(\"'key' not implemented for Element subclass\")", "def obj_key(objname):\n return OBJ_PREFIX + objname", "def get_key(sel...
[ "0.7112568", "0.705819", "0.6947471", "0.6844022", "0.6839712", "0.67814183", "0.67632306", "0.67580813", "0.6720763", "0.6639502", "0.6636918", "0.66335106", "0.6631516", "0.6629096", "0.6537854", "0.6537854", "0.6499949", "0.6489818", "0.64673126", "0.6444907", "0.6434619",...
0.7098794
1
Get an object by its element key.
def get_object_id(self, key): try: return self.key_object[key] except KeyError: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, key):\n return self()[key]", "def __getitem__(self, key):\n if self.containsKey(key):\n return self.get(key)\n else:\n raise IndexError()", "def __getitem__(self, key):\n return self._[key]", "def _single_getitem(self, key):\n ret...
[ "0.6758728", "0.6676352", "0.6675846", "0.6639574", "0.66102517", "0.6604584", "0.6603278", "0.6603278", "0.6603278", "0.6601982", "0.6601982", "0.66018176", "0.66018176", "0.66018176", "0.66018176", "0.65997744", "0.6594028", "0.65724087", "0.6571191", "0.656945", "0.6553533...
0.0
-1
Get an object by its element key.
def get_unique_objects(self, unique_type): try: return self.unique_objects[unique_type] except KeyError: return {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, key):\n return self()[key]", "def __getitem__(self, key):\n if self.containsKey(key):\n return self.get(key)\n else:\n raise IndexError()", "def __getitem__(self, key):\n return self._[key]", "def _single_getitem(self, key):\n ret...
[ "0.6758728", "0.6676352", "0.6675846", "0.6639574", "0.66102517", "0.6604584", "0.6603278", "0.6603278", "0.6603278", "0.6601982", "0.6601982", "0.66018176", "0.66018176", "0.66018176", "0.66018176", "0.65997744", "0.6594028", "0.65724087", "0.6571191", "0.656945", "0.6553533...
0.0
-1
Setup of creation of shared libraries in 2 Steps.
def _shared_library_in_2steps(env): if not config.shared_library_1st in env['BUILDERS']: # The 1st builder shlinkcom_name = config.shared_library_1st + "COM" env[shlinkcom_name] = "${TEMPFILE('$AR /DEF $ARFLAGS /OUT:$TARGET $SOURCES')}" ar_action = SCons.Action.Action("$" + shlinkcom_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_lib(CLIB):\n # {{ SETUP_LIB }}", "def setup_module():\n common_setup_module()", "def initialize_library():\n # return the handle to the shared object\n if os.name == \"nt\":\n pass\n # libc = load_windows_dll()\n else:\n libc = load_linux_so()\n return libc", ...
[ "0.69693637", "0.6318507", "0.62593526", "0.61885273", "0.6175638", "0.61054045", "0.6081299", "0.60247236", "0.6005774", "0.59742194", "0.59631056", "0.59508246", "0.59508246", "0.59334606", "0.5921951", "0.5921951", "0.5921951", "0.5921951", "0.5921951", "0.5915148", "0.590...
0.761938
0
Convert `url` into a hashed filename in a repeatable way. If `etag` is specified, append its hash to the url's, delimited by a period.
def url_to_filename(url, etag=None): url_bytes = url.encode("utf-8") url_hash = sha256(url_bytes) filename = url_hash.hexdigest() if etag: etag_bytes = etag.encode("utf-8") etag_hash = sha256(etag_bytes) filename += "." + etag_hash.hexdigest() return filename
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_to_filename(url, etag=None):\n\turl_bytes = url.encode ('utf-8')\n\turl_hash = sha256 (url_bytes)\n\tfilename = url_hash.hexdigest ()\n\n\tif etag:\n\t\tetag_bytes = etag.encode ('utf-8')\n\t\tetag_hash = sha256 (etag_bytes)\n\t\tfilename += '.' + etag_hash.hexdigest ()\n\n\treturn filename", "def url_to...
[ "0.84432817", "0.84120035", "0.672716", "0.64712", "0.62056106", "0.61464995", "0.6029297", "0.59602135", "0.59466934", "0.59007996", "0.58756745", "0.5849285", "0.57746124", "0.57643247", "0.57582027", "0.57522213", "0.574183", "0.5723955", "0.5720462", "0.57145333", "0.5713...
0.8393963
2