query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Lift a sampling function to one that draws multiple iid samples.
def iid_sample(sample_fn, sample_shape): sample_shape = distribution_util.expand_to_vector( ps.cast(sample_shape, np.int32), tensor_name='sample_shape') n = ps.cast(ps.reduce_prod(sample_shape), dtype=np.int32) static_n = tf.get_static_value(tf.convert_to_tensor(n)) def unflatten(x): sample_dims = 0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iid_sample_fn(*args, **kwargs):\n\n with tf.name_scope('iid_sample_fn'):\n\n seed = kwargs.pop('seed', None)\n if samplers.is_stateful_seed(seed):\n kwargs = dict(kwargs, seed=SeedStream(seed, salt='iid_sample')())\n def pfor_loop_body(_):\n with tf.name_scope('iid_sample_fn...
[ "0.6780334", "0.6380335", "0.5978483", "0.59762675", "0.5962528", "0.5962528", "0.59488493", "0.58723915", "0.5839884", "0.5820229", "0.5768919", "0.5750288", "0.5728591", "0.57276875", "0.5725391", "0.57026887", "0.5686771", "0.5677376", "0.56756586", "0.5674957", "0.5672077...
0.6582716
1
Draws iid samples from `fn`.
def iid_sample_fn(*args, **kwargs): with tf.name_scope('iid_sample_fn'): seed = kwargs.pop('seed', None) if samplers.is_stateful_seed(seed): kwargs = dict(kwargs, seed=SeedStream(seed, salt='iid_sample')()) def pfor_loop_body(_): with tf.name_scope('iid_sample_fn_stateful_bod...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iid_sample(sample_fn, sample_shape):\n sample_shape = distribution_util.expand_to_vector(\n ps.cast(sample_shape, np.int32), tensor_name='sample_shape')\n n = ps.cast(ps.reduce_prod(sample_shape), dtype=np.int32)\n static_n = tf.get_static_value(tf.convert_to_tensor(n))\n\n def unflatten(x):\n samp...
[ "0.64719844", "0.5108194", "0.5058195", "0.5022143", "0.5005775", "0.49909416", "0.49430317", "0.4896238", "0.48929828", "0.4841593", "0.48388526", "0.48310915", "0.48164558", "0.481505", "0.48034382", "0.47747755", "0.4774165", "0.47662959", "0.47544459", "0.474792", "0.4742...
0.6562505
0
Returns full text extracted from cdm compound object pages.
def extract_text(self, record): # type: (Element) -> str cdm_struc = Fields.cdm_structural_elements structure_el = record.find(cdm_struc['compound_object_container']) pages_el = structure_el.iterfind('.//' + cdm_struc['compound_object_page']) fulltext = '' for page in pag...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_text(self):\n\t\t\n\t\t #eliminating more headers\n\t\traw_text = re.sub(r\".*OPERATIONS O[PF].*\",r\"\",self.doc)\n\t\traw_text = re.sub(r\"Page \\d+\",r\"\",raw_text)\n\t\traw_text = re.sub(r\".*B[lL]OCK.*\",r\"\",raw_text)\n\t\traw_text = re.sub(r\".*WEST GULF.*\",r\"\",raw_text)\n\t\traw_text = re.sub(...
[ "0.6273365", "0.62023115", "0.6014343", "0.59526193", "0.5892059", "0.5881646", "0.5855388", "0.58526736", "0.58320683", "0.58169097", "0.5788491", "0.5753858", "0.57474256", "0.5684555", "0.56561995", "0.5646933", "0.5620174", "0.5598048", "0.55893654", "0.5587107", "0.55830...
0.7681376
0
Get the list of chromosome names from a fasta file
def _chrom_names(fasta_file): from pysam import FastaFile with FastaFile(fasta_file) as fa: chroms = list(fa.references) return chroms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readFasta(self, fastaFile):\t\n\t\tname, seq = None, []\n\t\tfor line in fastaFile:\n\t\t\tline = line.rstrip()\n\t\t\tif (line.startswith(\">\")):\n\t\t\t\tif name: yield (name, ''.join(seq))\n\t\t\t\tname, seq = line, []\n\t\t\telse:\n\t\t\t\tseq.append(line)\n\t\tif name: yield (name, ''.join(seq))", "def...
[ "0.6546648", "0.64621747", "0.63865525", "0.63529944", "0.63245755", "0.63238037", "0.6276679", "0.6252582", "0.62015104", "0.6200787", "0.6186508", "0.6152302", "0.6124569", "0.60324305", "0.60317713", "0.60203993", "0.60121757", "0.6001881", "0.60012823", "0.59866214", "0.5...
0.79199076
0
Get the chromosome sizes for a fasta file
def _chrom_sizes(fasta_file): from pysam import FastaFile fa = FastaFile(fasta_file) chrom_lens = OrderedDict([(name, l) for name, l in zip(fa.references, fa.lengths)]) if len(chrom_lens) == 0: raise ValueError(f"no chromosomes found in fasta file: {fasta_file}. " "Make ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expected_readlen(bedfile, bedHeader, annoList):\n\n #chromosomes from project bed\n with open(bedfile, 'r') as f:\n if bedHeader=='yes':\n chroms = [key for key in dict(Counter([line.split('\\t')[0] for il, line in enumerate(f) if il>0])).keys()]\n else:\n chroms = [ke...
[ "0.6612106", "0.65703803", "0.6373489", "0.6340387", "0.629946", "0.62345374", "0.6110134", "0.60759944", "0.6062779", "0.6048343", "0.60378957", "0.60344946", "0.6015284", "0.59918827", "0.59908766", "0.59731734", "0.5965608", "0.5897269", "0.58564174", "0.58517754", "0.5796...
0.7949907
0
Potts3D class used for getting information about the lattice and cells Potts3D class used for getting information about the lattice and cells
def __init__(self, *args): this = _CompuCell.new_Potts3D(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Tol3d(self, *args):\n return _Adaptor3d.Adaptor3d_TopolTool_Tol3d(self, *args)", "def __init__(self, u1=(1,0,0), u2=(0,1,0), u3=(0,0,1)):\n u1 = vec3(u1)\n u2 = vec3(u2)\n u3 = vec3(u3)\n\n if triple_scalar_product(u1, u2, u3) != 1:\n print >> sys.stderr, \"!! In...
[ "0.64591336", "0.628939", "0.60183465", "0.59724873", "0.594738", "0.5926596", "0.5878722", "0.5874803", "0.5872248", "0.5800448", "0.5789005", "0.5752864", "0.5690429", "0.56581295", "0.56511575", "0.5619621", "0.55708784", "0.5568822", "0.5567117", "0.55142593", "0.54944754...
0.64276975
1
Function to set output frequency of debug statements
def setDebugOutputFrequency(self, *args): return _CompuCell.Potts3D_setDebugOutputFrequency(self, *args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def debug_counter(name, every=1):\r\n setattr(debug_counter, name, getattr(debug_counter, name, 0) + 1)\r\n n = getattr(debug_counter, name)\r\n if n % every == 0:\r\n print >>sys.stderr, \"debug_counter [%s]: %s\" % (name, n)", "def set_debug(self):\n self.logger.setLevel(5)\n if s...
[ "0.6158451", "0.59726447", "0.58677197", "0.58550537", "0.57988405", "0.5754504", "0.57102424", "0.57102424", "0.57052463", "0.5704786", "0.5639605", "0.56269664", "0.5622346", "0.5621204", "0.5620845", "0.56105494", "0.5537305", "0.55235225", "0.5522253", "0.5500236", "0.550...
0.75071925
0
Obtain a list of all the features in the list sorted by partial similarity to the question
def feature_list_by_ratio(processed_question, feature_list): ratio_ordered = [] length_question = len(processed_question.text) for feature in feature_list: length_feature = len(feature) if length_feature > length_question: ratio_ordered.append((feature, 0, -1)) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_features(self) -> List[Tuple[str, float]]:\n return [(key, self.features[key]) for key in sorted(self.features, key=self.features.get, reverse=True)]", "def _get_frequent_features(self):\n feature_terms = [sub_items for items in self.data['noun_and_np'].values for sub_items in items]\n...
[ "0.678645", "0.62636334", "0.60991806", "0.597559", "0.5955568", "0.59549016", "0.58404565", "0.58069927", "0.5797778", "0.57971066", "0.578736", "0.5771025", "0.5766309", "0.5766309", "0.5759463", "0.5758711", "0.57309", "0.57095194", "0.5690606", "0.56742805", "0.5673589", ...
0.6981241
0
distance is distance from light, in m returns probability that driver can make the light assumes driver going 100 km/h (250 / 9 m/s)
def make_light_prob(distance): if distance <= 1250 / 9: return 1 return .99 * make_light_prob(distance - 250 / 9)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distmeter(self):\n return self._distance.to(\"m\").value", "def manhatam_distance(self) -> int:\n raise NotImplementedError", "def test_rand_distance(self):\n\t\t\n\t\tdetails= self.watcher.analyze(layers=[self.fc2_layer], randomize=True)\n\t\tactual = details.rand_distance[0]\n\t\texpected =...
[ "0.66249526", "0.65129966", "0.65120053", "0.6509538", "0.6479013", "0.6472196", "0.63685584", "0.634336", "0.6341657", "0.63386166", "0.6302642", "0.6301768", "0.62938505", "0.6221564", "0.61828953", "0.61725366", "0.61725366", "0.61725366", "0.61725366", "0.61725366", "0.61...
0.7146622
0
Returns the 4 dataframes (trip_link_df, itinerary_df, legs_df, segments_df) initialized as defined in init_data_struct.py with each itinerary/leg/segment assigned a unique IDs (uuid4() converted to string)
def initialize_all_df(itinerary_nodes): # Build nested bundles and assign IDs # (itinerary_ID, itinerary_node) itin_nodes = [(str(uuid.uuid4()), itin) for itin in itinerary_nodes] # (itinerary_ID, leg_ID, leg_node, numbering) leg_nodes = [(itin[0], str(uuid.uuid4()), leg, i) for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_frame_creator(self):\n sequence_folder = [\n '/SEQ1', '/SEQ2', '/SEQ3', '/SEQ4', '/SEQ5', '/SEQ6'\n ]\n rgb_folder = ['/RGBLeft/', '/RGBRight/']\n depth_folder = ['/DepthLeft/', '/DepthRight/']\n segmentation_folder = ['/GTLeft/', '/GTright/']\n rgb_dir...
[ "0.6310724", "0.617593", "0.61627376", "0.5935321", "0.5896558", "0.5864568", "0.5827048", "0.5805143", "0.57813084", "0.57492137", "0.5713851", "0.57109815", "0.55745304", "0.55693126", "0.55637246", "0.55569404", "0.55528224", "0.553132", "0.5521182", "0.5518123", "0.551747...
0.7354393
0
Fetches a block from IOTA with an address. Since IOTA does not support exactly blocks, what is fetched is all the transactions of an address which are then sorted based on their timestamps and then concatenated in one block.
def fetch(self, address: str, log: Logger) -> Block: def get_transactions(address: str) -> Iterable['Transaction']: adapter = self._iota_api.adapter return find_transaction_objects(adapter, addresses=[address]) def get_signature_string(t: 'Transaction') -> str: retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fetch(self, address: str, latest: bool = False) -> None:\n try:\n # Fetch block from the ledger\n self._address_index[address] = self._connector.fetch(address,\n self._logger)\n # Add block to the registry\...
[ "0.63075423", "0.6130317", "0.60563076", "0.59326637", "0.5903281", "0.590054", "0.5893151", "0.5886603", "0.58753556", "0.5863715", "0.57891095", "0.57841134", "0.57321405", "0.57314", "0.5723248", "0.5698044", "0.56945467", "0.56176645", "0.55606705", "0.5559356", "0.550265...
0.7177153
0
Fetch a block from the ledger and update the state of the stream.
def _fetch(self, address: str, latest: bool = False) -> None: try: # Fetch block from the ledger self._address_index[address] = self._connector.fetch(address, self._logger) # Add block to the registry ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_block(self, blnum):\n MogamiLog.debug(\"** read %d block\" % (blnum))\n MogamiLog.debug(\"request to data server %d block\" % (blnum))\n self.p_channel.read_req(self.datafd, blnum)\n\n # change status of the block (to requiring)\n with self.r_buflock:\n sel...
[ "0.6299564", "0.5995834", "0.59561527", "0.5936668", "0.58768857", "0.5831979", "0.5819885", "0.5817211", "0.58122575", "0.5758775", "0.575114", "0.5735385", "0.5709176", "0.56670076", "0.5592112", "0.5553803", "0.5553803", "0.55014235", "0.54505074", "0.54420453", "0.5390549...
0.7019611
0
Obtain the Qvalue for performing the specified action given the observation
def Q(self, observation, action): return self[observation, action]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qval(self, observation, action):\n obs_variable = Variable(torch.from_numpy(observation),\n volatile=True).type(torch.FloatTensor)\n\n # obs_variable sets volatile to True, thus, we do not set\n # it here\n action_variable = Variable(torch.from_numpy(action)).type(\n ...
[ "0.81143", "0.7915187", "0.7891677", "0.7835517", "0.7801762", "0.77660453", "0.76960266", "0.76921123", "0.7663453", "0.7615161", "0.7614706", "0.75210184", "0.74891776", "0.7462017", "0.7462017", "0.7462017", "0.7462017", "0.7454296", "0.74501723", "0.74501723", "0.74158025...
0.80301124
1
Obtain all Qvalues for multiple possible actions given the observation
def Qs(self, observation, actions): return {a: self[observation, a] for a in actions}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_action_Qvalues(Qvalues,actions):\n\n batch_i = T.arange(Qvalues.shape[0])[:,None]\n time_i = T.arange(Qvalues.shape[1])[None,:]\n action_Qvalues_predicted= Qvalues[batch_i,time_i, actions]\n return action_Qvalues_predicted", "def computeQValueFromValues(self, state, action):\n \"*** YO...
[ "0.71025026", "0.70802724", "0.6990872", "0.6927177", "0.68964356", "0.685025", "0.6729977", "0.67239213", "0.67226744", "0.6694636", "0.66370744", "0.6608392", "0.6598005", "0.6568247", "0.6557059", "0.65552235", "0.6547387", "0.65166014", "0.6490783", "0.64322513", "0.64144...
0.7254307
0
Create a Q Table with the environment's observation and action spaces
def for_env(env: DiscreteEnvironment): return QTable(env.observation_space, env.action_space)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_Qtable_line(self, state):\n # 4. Create qtable with current state\n # Our qtable should be a two level dict,\n # Qtable[state] ={'u':xx, 'd':xx, ...}\n # If Qtable[state] already exits, then do\n # not change it.\n if state not in self.Qtable.keys():\n ...
[ "0.6255378", "0.62204945", "0.6166513", "0.60615325", "0.6026363", "0.5958345", "0.5860154", "0.5855717", "0.5805799", "0.580382", "0.5777994", "0.57499313", "0.57398605", "0.5693433", "0.56837535", "0.56642014", "0.5643528", "0.5640943", "0.5637645", "0.5579142", "0.5579053"...
0.8406137
0
splits msg up in chunks of 160 characters with numbers at the start of the chunk to ensure that the order can be retained in the case of the messages not arriving at the same time, which will most definitely happen.
def chunkify(msg): return ["%s %s" % (i, msg[i*158 : (i+1)*158]) for i in range(len(msg)/158 + 1)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_message(message, max_length):\n ms = []\n while len(message) > max_length:\n ms.append(message[:max_length])\n message = message[max_length:]\n ms.append(message)\n return ms", "def chunk_split(cls, text):\n parts = []\n current = []\n for line in text.spl...
[ "0.65123254", "0.6352726", "0.5945958", "0.5764811", "0.5745976", "0.57398397", "0.56032455", "0.5584404", "0.55716544", "0.5547637", "0.5528964", "0.5514335", "0.5504813", "0.5485734", "0.54836977", "0.54310673", "0.5405054", "0.5393326", "0.53833044", "0.53765863", "0.53716...
0.7787634
0
Save an image to H5 file.
def save_image_to_h5(image, h5_path, *args, **kwargs): # TODO: Implement the method f = h5.File(h5_path, "w") grp = f.create_group("data") grp.create_dataset("image", data=image)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_as_hdf5(self, filename):", "def save_image(img: Image, filename: str) -> None:\r\n img.save(filename)", "def save_img(img: np.ndarray, path: str) -> None:\n\n img_obj = Image.fromarray(img)\n img_obj.save(path)", "def save_image(img, path):\n cv2.imwrite(path, img)", "def save_image(se...
[ "0.7164401", "0.6891454", "0.68416053", "0.6818399", "0.6801005", "0.6790581", "0.6781218", "0.6770538", "0.6723622", "0.66964334", "0.6677857", "0.66489947", "0.65959775", "0.6587879", "0.65265673", "0.6482147", "0.64585376", "0.6458208", "0.6433483", "0.6411232", "0.640583"...
0.8219461
0
Find the difference of two Gaussian blurs from an image.
def find_difference_of_gaussian_blur(image, k1, k2, *args, **kwargs): # TODO: Implement the method res1 = snf.gaussian_filter(image, k1) res2 = snf.gaussian_filter(image, k2) res = res2 - res1 minn = num.amin(res) maxx = num.amax(res) if(minn - maxx != 0): res = (res-minn)/(maxx...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def differenceOfGausssians(image,sigma0, sigma1,window_size, roi, out = None):\n return (vigra.filters.gaussianSmoothing(image,sigma0,window_size=window_size,roi = roi)-vigra.filters.gaussianSmoothing(image,sigma1,window_size=window_size,roi = roi))", "def img_compare(A, B):\r\n A = cv2.GaussianBlur(A, (5,...
[ "0.6985116", "0.67345124", "0.650252", "0.6417384", "0.6318204", "0.6304162", "0.6298801", "0.6222766", "0.6212655", "0.61555135", "0.606799", "0.60050595", "0.59965354", "0.5986602", "0.59817517", "0.5940041", "0.59379756", "0.5924522", "0.5862609", "0.5854046", "0.5843962",...
0.77067065
0
return a directory path to a module
def get_module_path(module): return pathlib.Path(os.path.dirname(os.path.abspath(inspect.getfile(module))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def module_directory(file_path):\n return os.path.dirname(os.path.realpath(file_path))", "def module_path():\n return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( )))", "def modulePath(self, name):\n return os.path.join(self.modulesDir, name)", "def _get_module_path():\n\n return ...
[ "0.81944263", "0.8096354", "0.80722326", "0.7936179", "0.76663285", "0.7579195", "0.7564892", "0.74413705", "0.74383605", "0.743328", "0.7392733", "0.7389454", "0.73743325", "0.7297176", "0.7270132", "0.72672725", "0.7237529", "0.72215545", "0.72154826", "0.7209719", "0.71698...
0.8276851
0
Return the given string converted to a string that can be used for a clean filename. Remove leading and trailing spaces; convert other spaces to underscores; and remove anything that is not an alphanumeric, dash, underscore, or dot. >>> get_valid_filename("john's portrait in 2004.jpg") 'johns_portrait_in_2004.jpg'
def get_valid_filename(s): s = str(s).strip().replace(" ", "_") return re.sub(r"(?u)[^-\w.]", "", s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_valid_filename(s):\n s = str(s).strip().replace(' ', '_')\n return re.sub(r'(?u)[^-\\w.]', '', s)", "def get_valid_filename(s):\n assert(s is not \"\" or s is not None)\n s = str(s).strip().replace(' ', '_')\n return re.sub(r'(?u)[^-\\w.]', '', s)", "def get_valid_filename(s):\n retur...
[ "0.86586744", "0.8547645", "0.8149609", "0.80513585", "0.79863226", "0.7839607", "0.77740246", "0.77427137", "0.7719834", "0.76964754", "0.76964754", "0.76964754", "0.76510334", "0.75894004", "0.75845075", "0.74965084", "0.7492183", "0.7492183", "0.74786764", "0.73877007", "0...
0.8631907
1
Print top words for a topic.
def print_top_words(components, feature_names, n_top_words: int = 10): for topic_idx, topic in enumerate(components): message = "Topic #%d: " % topic_idx message += " ".join( [feature_names[i] for i in topic.argsort()[: -n_top_words - 1 : -1]] ) print(message) print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_topic(self, series, top=10):\n series.sort(ascending=False)\n t = [u'{} ({:.4f})'.format(word, p)\n for word, p in series[0:top].iteritems()]\n return u' - '.join(t)", "def display_topics(model, feature_names, no_top_words, topic_names=None):\n for ix, topic in enume...
[ "0.7723348", "0.76109993", "0.75774586", "0.7472223", "0.7343527", "0.7328319", "0.7318414", "0.72321844", "0.71997887", "0.7157243", "0.7114651", "0.70796895", "0.6947733", "0.69452626", "0.6838635", "0.6817538", "0.68120825", "0.6801275", "0.6722403", "0.67175907", "0.67012...
0.78302485
0
Copy the current plot to the clipboard
def on_copy(self): path = os.path.dirname(os.path.realpath(__file__)) path = os.path.join(path, 'test.png') self.fig.savefig(path) img = QtGui.QImage(path) QtGui.QApplication.clipboard().setImage(img)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toClipboard(self):\n buf = io.BytesIO()\n self.fig.savefig(buf, dpi=300, facecolor='w', format='png',\n transparent=True)\n QtGui.QApplication.clipboard().setImage(\n QtGui.QImage.fromData(buf.getvalue()))\n buf.close()", "def __editCopy(self):\n...
[ "0.7606093", "0.67240316", "0.6549864", "0.635706", "0.63442725", "0.63283503", "0.63100284", "0.6305897", "0.62985206", "0.62625074", "0.6260492", "0.6237598", "0.6230931", "0.62308145", "0.6198418", "0.6189235", "0.61865187", "0.61849517", "0.6175345", "0.6145666", "0.61348...
0.74077797
1
Some win32 COM magic to interact with powerpoint
def on_to_ppt(self): try: import win32com.client except ImportError: print('ERROR: The win32com library needs to be installed') return # First, copy to the clipboard self.on_copy() # Connect to an open PowerPoint application app = win...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UsePresentation(self, event):\n pass", "def comdlg32_PrintDlgEx(jitter, get_str, set_str):\n ret_ad, args = jitter.func_args_stdcall([\"lppd\"])\n raise RuntimeError('API not implemented')\n jitter.func_ret_stdcall(ret_ad, ret_value)", "def connect():\n Rhino = win32com.client.Dispatch(\"R...
[ "0.52668995", "0.51922184", "0.509907", "0.50320804", "0.4994227", "0.49861234", "0.4938685", "0.49147597", "0.48995832", "0.48588198", "0.48588198", "0.4839947", "0.48387888", "0.48261172", "0.48254737", "0.47565627", "0.4731225", "0.47279295", "0.47279295", "0.4720214", "0....
0.58805686
0
Initialise EnsembleHull from a cursor, with other keywords following QueryConvexHull.
def __init__( self, cursor, data_key, energy_key="enthalpy_per_atom", chempot_energy_key=None, num_samples=None, parameter_key=None, species=None, voltage=False, verbosity=None, **kwargs, ): # sometimes the first hull ne...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convex_hull(self):\n nodes = self._datacontroller.get_data('nodes')\n scale = self._datacontroller.get_data('scale')\n hull = tsputil.convex_hull_helper(nodes)\n if hull:\n result = construct_step(hull, 'Most Top Left Node', 'Clockwise', nodes, scale)\n self._d...
[ "0.56471527", "0.5645025", "0.560803", "0.55001235", "0.5461656", "0.5383847", "0.52694416", "0.5206169", "0.5176081", "0.5166029", "0.51593155", "0.5150027", "0.5116916", "0.5103227", "0.5053244", "0.50198245", "0.49959636", "0.4989708", "0.49692374", "0.49644575", "0.493446...
0.571932
0
This function generates a voronoi centroid point list from arrays of latitude and longitude
def _get_voronoi_centroid_array(lsm_lat_array, lsm_lon_array, extent): YMin = extent[2] YMax = extent[3] XMin = extent[0] XMax = extent[1] ptList = [] if (lsm_lat_array.ndim == 2) and (lsm_lon_array.ndim == 2): # generate point list with 2D lat lon lists if extent: #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pointsToVoronoiGridArray(lat, lon, extent=None):\n voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent)\n # find nodes surrounding polygon centroid\n # sort nodes in counterclockwise order\n # create polygon perimeter through nodes\n log(\"Building Voronoi polygons...\")\n # comp...
[ "0.65372", "0.6385518", "0.6369866", "0.6352986", "0.63227725", "0.6310845", "0.6269614", "0.62459695", "0.62092495", "0.6206954", "0.6184177", "0.6160597", "0.61529094", "0.61167246", "0.6113499", "0.6096009", "0.6049528", "0.60330814", "0.60061824", "0.6005695", "0.5998281"...
0.7456306
0
This function returns the corner points for a polygon from scipy voronoi information
def _get_voronoi_poly_points(vert_index_list, voronoi_vertices, voronoi_centroid): voronoi_poly_points = [] if -1 not in vert_index_list and len(vert_index_list) > 3: voronoi_poly_points = voronoi_vertices[vert_index_list] elif vert_index_list.size > 0: # ASSUME ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def voronoi_polygons(self, voronoi, radius=None):\n\n if voronoi.points.shape[1] != 2:\n raise ValueError(\"Requires 2D input\")\n\n new_regions = []\n new_vertices = voronoi.vertices.tolist()\n\n center = voronoi.points.mean(axis=0)\n if radius is None:\n r...
[ "0.68197215", "0.670755", "0.67009354", "0.6434472", "0.62601817", "0.6184525", "0.6176979", "0.61670077", "0.61580414", "0.6120427", "0.60982144", "0.6064844", "0.60642666", "0.6035292", "0.6015687", "0.60129887", "0.60129887", "0.600831", "0.5997366", "0.59831345", "0.59699...
0.78336376
0
Converts points to shapefile grid via voronoi
def pointsToVoronoiGridShapefile(lat, lon, vor_shp_path, extent=None): voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # set-up output polygon shp log("Creating output polygon shp {0}" .format(os.path.basename(vor_shp_path))) if os.path.exists(vor_shp_path): os.remove(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def voronoi(points, buffer_percent=100):\n # Remove duplicate xy points bc that would make delauney fail, and must remember z (if any) for retrieving originals from index results\n seen = set() \n uniqpoints = [ p for p in points if str( p[:2] ) not in seen and not seen.add( str( p[:2] ) )]\n classpoin...
[ "0.73642546", "0.6624605", "0.6493146", "0.64552146", "0.64445776", "0.6433658", "0.6414309", "0.64070576", "0.62853026", "0.62327176", "0.6230993", "0.6223746", "0.6214373", "0.6130584", "0.6109224", "0.6064484", "0.60588217", "0.60203505", "0.6009164", "0.5995349", "0.59607...
0.77111614
0
Converts points to grid array via voronoi
def pointsToVoronoiGridArray(lat, lon, extent=None): voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # find nodes surrounding polygon centroid # sort nodes in counterclockwise order # create polygon perimeter through nodes log("Building Voronoi polygons...") # compute voronoi ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def voronoi(points, buffer_percent=100):\n # Remove duplicate xy points bc that would make delauney fail, and must remember z (if any) for retrieving originals from index results\n seen = set() \n uniqpoints = [ p for p in points if str( p[:2] ) not in seen and not seen.add( str( p[:2] ) )]\n classpoin...
[ "0.7390621", "0.6877065", "0.67941904", "0.66441345", "0.66243017", "0.65572363", "0.65515393", "0.65475076", "0.6483277", "0.6442599", "0.6416807", "0.6381285", "0.6378487", "0.63503474", "0.634898", "0.62505853", "0.6236391", "0.61788255", "0.61699975", "0.6052225", "0.6026...
0.7085668
1
Instantiates and returns the list of permissions that this view requires.
def get_permissions(self): if self.action == 'list': permission_classes = [IsAuthenticated] else: permission_classes = [IsAdminUser] return [permission() for permission in permission_classes]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_permissions(self):\n if self.action in ['list', 'retrieve']:\n permission_classes = [IsAuthenticated]\n else:\n permission_classes = [IsAdminUser]\n return [permission() for permission in permission_classes]", "def get_permissions(self):\n if self.action ...
[ "0.7738158", "0.76905394", "0.7635271", "0.7618894", "0.7523193", "0.7523193", "0.7523193", "0.7497525", "0.74957764", "0.74865115", "0.7463958", "0.7431705", "0.7412355", "0.7407442", "0.7388661", "0.73826563", "0.73599124", "0.73599124", "0.7338907", "0.73276186", "0.73226"...
0.77929497
0
Check if original word matches encoded word.
def _does_words_matches(original_word: str, encoded_word: str) -> bool: return( len(original_word) == len(encoded_word) and original_word[0] == encoded_word[0] and original_word[-1] == encoded_word[-1] and sorted(original_word[1:-1]) == sorted(encoded_word[1:-1]) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(self, word):\n length = len(word)\n if length == 1:\n for letter in string.ascii_lowercase:\n key = \"{}/{}\".format(1, letter)\n if key in self.origin and letter != word:\n return True\n return False\n\n key = \...
[ "0.6823817", "0.6497194", "0.64674133", "0.6466808", "0.6456004", "0.6433033", "0.6371502", "0.6352263", "0.63260645", "0.62544364", "0.6197851", "0.61972284", "0.6180082", "0.609289", "0.6079167", "0.60727626", "0.6068379", "0.60665554", "0.6060675", "0.6059112", "0.6057214"...
0.8261765
0
Extract the variable and wrap it in a stream.
def extracted(self, variable, timestep): try: process = cmd_run(cmd_make(variable, self.uda, timestep)) except subprocess.CalledProcessError: print("The timestep {timestep} was not found in {uda}" " and was therefore ignored.".format(timestep=timestep, uda=self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_variable_value(variable):\n def pipeline_from_info(variableinfo):\n controller = variableinfo._controller\n version = controller.vistrail.get_version_number(\n 'dat-var-%s' % variable.name)\n return controller.vistrail.getPipeline(version), version\n\n def pipeline_fro...
[ "0.5547266", "0.53885806", "0.53768164", "0.5351466", "0.5347634", "0.53024673", "0.5286729", "0.52457756", "0.52190644", "0.51141566", "0.50830096", "0.5061464", "0.49422723", "0.49422723", "0.4932786", "0.4878473", "0.48528296", "0.48392415", "0.48339707", "0.4821986", "0.4...
0.5781148
0
Generate a list of timestep indices. If a list of timesteps is provided, return the index of the bestfitting timestep. If instead the caller wants every nth timestep, the list of timesteps is generated from the frequency. If the caller wants a total of N samples, the list of timesteps returned contains N + 1 timesteps,...
def get_timesteps(self, timesteps=None, every=None, samples=None): timedict = self.generate_timedict() if samples is not None: stride = len(timedict) // samples return [str(i) for i in range(0, len(timedict), stride)] elif every is not None: max_time_index = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_steps_by_times(times,chosen_times):\n\n time_steps = []\n chosen_index = 0\n for i in range(len(times)):\n if times[i] >= chosen_times[chosen_index]:\n time_steps.append(i)\n chosen_index += 1\n if chosen_index == len(chosen_times): #We're done\n return time_steps\n if chosen_i...
[ "0.62273204", "0.61630476", "0.5811249", "0.56252664", "0.54821074", "0.54376155", "0.5382979", "0.5318907", "0.5290574", "0.5282313", "0.5265857", "0.5237639", "0.5224652", "0.52216583", "0.5208017", "0.5204625", "0.51511866", "0.5112422", "0.51089954", "0.51061344", "0.5036...
0.6946111
0
Parse isbn from url querystring
def parse_isbn_url(url): parts = urlparse.urlparse(url) query = urlparse.parse_qs(parts.query) if ISBN_QS_KEY in query and len(query[ISBN_QS_KEY]): return query[ISBN_QS_KEY][0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isbn_lookup(isbn):\n base = \"https://www.googleapis.com/books/v1/volumes?q=isbn=\"\n# Unfortunately we can't use the superior \"with spam as eggs\" syntax here...\n search = urlopen(base + isbn + \"&prettyprint=false\")\n lines = search.read()\n search.close()\n for bool_pair in [(\"false\", \"...
[ "0.63817704", "0.63102347", "0.6045895", "0.5558513", "0.5465694", "0.54510826", "0.5408801", "0.53625476", "0.53564936", "0.5326564", "0.5249726", "0.52439344", "0.52134913", "0.52124333", "0.5165924", "0.5154762", "0.51323634", "0.5130722", "0.508087", "0.5070255", "0.50632...
0.8076228
0
Moves to the given x, y, and yaw in map coordinates.
def go_to(self, x_map, y_map, yaw_map): loginfo("Going to pose x = %s, y = %s, yaw = %s." % (x_map, y_map, yaw_map)) goal = MoveBaseGoal() goal.target_pose.header = Header(stamp=Time.now(), frame_id = '/map') goal.target_pose.pose = self._x_y_yaw_to_pose(x_map, y_map...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self, pitch: float, yaw: float):\n move_pitch = pitch - self.pitch\n move_yaw = yaw - self.yaw\n\n while move_pitch != 0 or move_yaw != 0:\n if (move_pitch > 0 and move_pitch < (STEP_DEGREES / 2)) or (move_pitch < 0 and -move_pitch < (STEP_DEGREES / 2)):\n mo...
[ "0.6938535", "0.6257815", "0.62501764", "0.6088437", "0.59798133", "0.59639096", "0.59628", "0.596222", "0.5912571", "0.5895394", "0.5874179", "0.5847769", "0.57818645", "0.5766529", "0.5648399", "0.55993503", "0.5585821", "0.558317", "0.5575346", "0.55749583", "0.55735433", ...
0.64824414
1
get the battery voltage
def get_voltage(self): print("voici le voltage de la batterie")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getBatteryVoltage(self):\n return self.values[BATTERY_VOLTAGE]", "def get_voltage(self):\n status = self.get_status_response()\n volts = status[20] + (status[21] * 0x100) + (status[22] * 0x10000) + (status[23] * 0x1000000)\n volts = float(volts)\n volts /= (1000.0 * 1000.0)...
[ "0.86550456", "0.8127854", "0.7928992", "0.78065944", "0.77453196", "0.7619697", "0.7566325", "0.7537705", "0.7511109", "0.747756", "0.74493533", "0.7421177", "0.74002737", "0.73456454", "0.73354095", "0.7327306", "0.7295995", "0.7285319", "0.7237761", "0.72339785", "0.717703...
0.8460618
1
Fixe l'offset des moteurs (en degres) (permet par exemple de reinitialiser a 0 l'etat du moteur gauche avec offset_motor_encode(self.MOTOR_LEFT,self.read_encoders()[0])
def offset_motor_encoder(self, port, offset): if not (isinstance(port, int)): print("le port passé doit être un int, ca n'est pas le cas") elif not (isinstance(offset, int)): print("l'offset passé doit être un int, ca n'est pas le cas") else : print("...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _change_offset(self, value, direction):\n if direction == 1:\n if value >= self.POSITIONS-1:\n value = 0\n else:\n value += 1\n elif direction == -1:\n if value == 0:\n value = self.POSITIONS-1\n else:\n ...
[ "0.5942462", "0.5827062", "0.57833177", "0.5647549", "0.55279064", "0.55191183", "0.55130816", "0.5497624", "0.54105806", "0.5408701", "0.538775", "0.53876925", "0.53823066", "0.5352017", "0.53499883", "0.5324033", "0.53148234", "0.5283687", "0.527997", "0.52785933", "0.52719...
0.6282114
0
calls CURL to pull the file from a given URL URL is the target URL on remote FILE is the output file location on local
def download(FILE,URL): CMD = ['curl','-o',FILE,URL] call(CMD)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_retrieve(url, output_file):\n r = requests.get(url, allow_redirects=True)\n if r.status_code != 200:\n raise ConnectionError(f\"Could not download {url}\\nError code: {r.status_code}\")\n\n output_file.write_bytes(r.content)", "def get_remote_file(url):\n # Disable the proxies by not t...
[ "0.74769384", "0.7252042", "0.7239829", "0.71526814", "0.7101987", "0.7098477", "0.7090487", "0.699232", "0.6973781", "0.69418174", "0.6901856", "0.68841106", "0.688299", "0.6854513", "0.6851065", "0.68380386", "0.6809919", "0.6761908", "0.6742494", "0.6732254", "0.66787374",...
0.76820236
0
Load status code table.
def load_status_table():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data():\n try:\n loader.download()\n load_table_data()\n status = 'loaded'\n except Exception as ex:\n log.log_traceback(ex)\n status = 'failed'\n return flask.jsonify({'status': status})", "def load_status(sec_status):\n with open(sec_status, 'r') as infil...
[ "0.6304792", "0.6128468", "0.6098472", "0.5995203", "0.55925363", "0.55922043", "0.55655104", "0.55066717", "0.54105455", "0.53784657", "0.5279865", "0.52605635", "0.51376367", "0.5121974", "0.5121277", "0.51052105", "0.5081247", "0.50530696", "0.5048871", "0.5047821", "0.504...
0.8231332
0
Print a response message and exit with 1, if the response wasn't a success.
def process_response(response): # Print it and exit with 1 if operation wasn't successful print(response['message']) if response['status'] != 'success': sys.exit(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_ok(msg):\n print('OK - %s' % (msg))\n sys.exit(0)", "def check_response(rv):\n if rv != 'OK':\n print \"No message found\"\n return False\n return True", "def _is_successful(response) -> bool:\n return response.status_code == 200", "def exit_success(message: Optional[st...
[ "0.7340724", "0.69758445", "0.67532015", "0.67513496", "0.66959393", "0.66255456", "0.65675175", "0.6507938", "0.64950174", "0.649325", "0.6481977", "0.6443774", "0.6417801", "0.64016646", "0.6399089", "0.63857675", "0.6373736", "0.6370738", "0.634704", "0.6334164", "0.632734...
0.81670505
0
Connect to a daemon's socket.
def connect_socket(root_dir): # Get config directory where the daemon socket is located config_dir = os.path.join(root_dir, '.config/pueue') # Create Socket and exit with 1, if socket can't be created try: client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) socket_path = os.path....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _connect_socket(self):\n self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.sock.connect((self.ip, self.port))\n print(\"Connected to %s at port %d\" % (self.ip, self.port))", "def __connect():\n # Create socket\n sock = socket.socket(socket.AF_INET, socket.SOCK_S...
[ "0.7152145", "0.7110767", "0.69015676", "0.68839574", "0.6861228", "0.68268406", "0.68084097", "0.6778838", "0.67785", "0.67722744", "0.67408895", "0.6712054", "0.66876894", "0.6654631", "0.6639277", "0.66327703", "0.6606217", "0.6582687", "0.65193504", "0.64702415", "0.64390...
0.76585114
0
Moves a given file from one directory to another, if the target file exists in that directory then the target is coppied as .bak
def moveFile(src, dest, bak="bak"): message = "processing: {0} -> {1}".format(src, dest) logger.info(message) #compare the source and destination, if the files are the same do nothing if os.path.exists(src) and os.path.exists(dest): message = "file {0} found, comparing to {1}".format(src, dest) logger.info(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def act_move_file(self, file_source, file_target):\n try:\n if not os.path.isfile(file_source):\n return\n path = os.path.dirname(file_target)\n if not os.path.exists(path):\n os.makedirs(path)\n shutil.move(file_source, file_target)\...
[ "0.69844866", "0.68424857", "0.67688906", "0.6750627", "0.6640949", "0.6619133", "0.64734495", "0.6451692", "0.64118326", "0.6409421", "0.6336517", "0.6331257", "0.62477756", "0.6222287", "0.61894214", "0.6184978", "0.6182519", "0.61495227", "0.61475456", "0.6146206", "0.6137...
0.73066294
0
uses sha512 to verify that the soruce file and the destination file are the same
def verifyFile(source, destination): sourceHash = hashlib.sha256(open(source, 'rb').read()).digest() destinationHash = hashlib.sha256(open(destination, 'rb').read()).digest() if sourceHash == destinationHash: return (True, str(sourceHash)) return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sha512_file(file_name):\n\n hash_func = hashlib.sha256()\n\n with open(file_name, \"rb\") as fd:\n hash_func.update(fd.read())\n\n return hash_func.hexdigest()", "def sha512(digest, fileName):\n\n rc = sha512sum(digest, fileName)\n logging.debug(\"SHA512 (%s) = %s\", fileName, 'ok' if r...
[ "0.67451125", "0.6664096", "0.657134", "0.6448049", "0.6399249", "0.625933", "0.6167828", "0.6108488", "0.60713184", "0.60061806", "0.5995028", "0.5963704", "0.5957321", "0.5945975", "0.59287506", "0.5924034", "0.59063375", "0.58697104", "0.58629924", "0.58619326", "0.584064"...
0.73826236
0
Registers a new key function. The key function will be invoked for each element in the input array, and must return a string identifier that is used to assign the element to its group. As most often the key function is just a simple accessor, this fuction also accepts a noncallable, which will be converted into a funct...
def key(self, fn): if not callable(fn): fn = itemgetter(fn) self._keys.append(fn) self._sortKeys.append({}) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(func):\n return func.__func__ if hasattr(func, \"__func__\") else func", "def key(func):\n return func.__func__ if hasattr(func, \"__func__\") else func", "def new_key(self, key_name=None):\r\n return self.key_class(self, key_name)", "def __call__(self, key):\n\n def wrapper(f...
[ "0.62338203", "0.62239367", "0.59718996", "0.5883624", "0.5770307", "0.57404315", "0.57356715", "0.57341254", "0.5666792", "0.5658345", "0.56313723", "0.5578466", "0.5519251", "0.5460523", "0.5439024", "0.54283136", "0.5402386", "0.53601855", "0.53601855", "0.5331967", "0.526...
0.6798151
0
Specifies the order for the mostrecently specified key.
def sortKeys(self, cmp=None, key=None, reverse=False): self._sortKeys[-1] = dict(cmp=cmp, key=key, reverse=reverse) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _augment_order(self, stmt, key, reverse):\n sqlstmt = stmt + \" ORDER BY %s\" % key\n if reverse:\n sqlstmt += \" DESC\"\n else:\n sqlstmt += \" ASC\"\n return sqlstmt", "def add(self, key, value):\r\n newest = Item(key, value) # make new item instan...
[ "0.5636925", "0.5439744", "0.54154766", "0.53488845", "0.53439325", "0.53188175", "0.5313001", "0.5313001", "0.52856255", "0.52856255", "0.5253114", "0.52403337", "0.52403337", "0.52403337", "0.5195061", "0.5147803", "0.5137212", "0.51138586", "0.5104338", "0.50992334", "0.50...
0.5488794
1
Specifies a rollup function to be applied on each group of leaf elements. The return value of the rollup function will replace the array of leaf values in either the associative array returned by the map operator, or the values attribute of each entry returned by the entries operator.
def rollup(self, fn): self._rollup = fn return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollup(self, name, keys, aggregators=None, callback=None) :\n\n class Wildcard(object) :\n def __repr__(self) :\n return '*'\n w = Wildcard()\n\n # get the records for this table\n #\n rows = [d.as_dict() for d in self]\n cols = [k.get_name() ...
[ "0.5321749", "0.5007049", "0.4889394", "0.4833893", "0.47824767", "0.47508833", "0.47499952", "0.4718424", "0.4704678", "0.4611858", "0.45925716", "0.45839456", "0.4580275", "0.45792785", "0.4532239", "0.45245072", "0.45216066", "0.44919682", "0.44884452", "0.44791734", "0.44...
0.5791968
0
Create a new Team and add two new Learners with different atomic actions. These Learners are added to the Learner population, and the Team is added to both the Team and root Team populations.
def initializeTeam(self): # Create two new Learners with different atomic actions a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE) a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE) while a1 == a2: a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE) l1 = Learner(action = a1) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_team_manager_to_team(self):\n pass", "def test_assign_managing_team(self):\n pass", "def post(self):\n req = team_req.parse_args(strict=True)\n curr_user = api.user.get_user()\n if curr_user[\"teacher\"]:\n raise PicoException(\"Teachers may not create...
[ "0.63931805", "0.62942845", "0.6094177", "0.6046148", "0.5987049", "0.5950534", "0.59209555", "0.59143233", "0.58799905", "0.58205515", "0.5810097", "0.57936954", "0.57741076", "0.57400084", "0.5725225", "0.5720262", "0.56885177", "0.5675747", "0.5647381", "0.5604889", "0.555...
0.7741807
0
Given a full Learner and Team population, where each Team points to two unique Learners, randomly add existing Learners to each Team until that Team reaches its full complement.
def fillTeamsInPopulation(self): for team in self.team_pop: while len(team.learners) < team.max_size: learners = [l for l in self.learner_pop if l not in team.learners] if len(learners) == 0: break else: learner ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initializeTeam(self):\n\n # Create two new Learners with different atomic actions\n a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n while a1 == a2:\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n\n l1 = Learner(action ...
[ "0.6198892", "0.60099727", "0.5909377", "0.5602736", "0.5578461", "0.5570028", "0.55162257", "0.54663473", "0.54535234", "0.5446338", "0.5419894", "0.5384661", "0.53839433", "0.537948", "0.53772473", "0.53582704", "0.53372985", "0.53203225", "0.5301221", "0.5300238", "0.52959...
0.71697813
0
Refill the root Team population up to R_SIZE root Teams. This is done as the first step of every iteration of evolution to ensure that we are always evaluating R_SIZE root Teams.
def generation(self): # Re-count and re-collect all root Teams from the main Team # population into self.agent_pop self.updateAgentPopulation() # Generate new root Teams as variations of other Teams while self.getNumRootTeams() < Trainer.R_SIZE: # Randomly select p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(self):\n r_keep = int(Trainer.R_SIZE * Trainer.PERCENT_KEEP)\n\n for i in range(r_keep):\n self.initializeTeam()\n self.fillTeamsInPopulation()\n\n # Double check that things are working as expected and that we now\n # have PERCENT_KEEP * R_SIZE Teams an...
[ "0.64052784", "0.63281214", "0.57870644", "0.57000005", "0.5607969", "0.5547907", "0.5515359", "0.544081", "0.54305696", "0.53787595", "0.53169703", "0.53117955", "0.5303638", "0.52940786", "0.5237861", "0.5228605", "0.5212393", "0.5164609", "0.5151552", "0.5115436", "0.51149...
0.7226053
0
Delete all Learners that are no longer owned by any Team.
def cleanOrphanedLearners(self): # Before deleting Learners, ensure that if any Learners that are about to be # deleted point to a Team as their action, then that Team's count of # referincing Learners is decremented. for learner in self.learner_pop: if learner.getNumReferen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all_teachers(connection):\r\n with connection:\r\n return connection.execute(DELETE_ALL_TEACHERS)", "def delete_teams_all(self, team_name):\n self.execute(TABELLE['teams']['delete']['all'])", "def _delete_roles(self):\n for role in self.roles:\n role.delete()", "...
[ "0.6313414", "0.6120818", "0.61091095", "0.60356534", "0.5935509", "0.5842929", "0.5828907", "0.5745722", "0.5733355", "0.5720132", "0.5718106", "0.57144076", "0.56988364", "0.56943846", "0.5681858", "0.567302", "0.5666653", "0.5639008", "0.56309897", "0.55954045", "0.5594834...
0.71644795
0
Updates the model description from a schema.yaml.
def update_model_description( self, content: Dict[str, Any], model_name: str, is_already_documented: bool = False ) -> Dict[str, Any]: message = f"Do you want to write a description for {model_name}" if is_already_documented: message = f"Do you want to change the model descriptio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_model(\n self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str]\n ) -> Dict[str, Any]:\n logger.info(f\"The model '{model_name}' already exists, updating its documentation.\")\n for model in content.get(\"models\", []):\n if model[\"name\"] == mod...
[ "0.6301844", "0.5955802", "0.58623356", "0.58260643", "0.5749849", "0.56432885", "0.5605579", "0.55699617", "0.5438667", "0.5400471", "0.5385811", "0.53735393", "0.53630406", "0.53451717", "0.5329007", "0.5327524", "0.52972335", "0.5264293", "0.5264293", "0.5262192", "0.52173...
0.66931194
0
Move keys name and description to the beginning of the dictionary.
def move_name_and_description_to_first_position(self, model: Dict[str, Any]): # DEPRECATION: Drop ordered dict when dropping python 3.6 support ordered_dict = OrderedDict(model) if ordered_dict.get("description"): ordered_dict.move_to_end("description", last=False) ordered_di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_prepend_key(self):\n self.prepend_key -= 1", "def harmonize_keys(self):\n self._data.key_regex_replacements = _key_regex_replacements\n self._data.key_replacements = _key_replacements", "def __parse_dict(self) -> OrderedDict:\r\n self.idx += 1\r\n d = OrderedDict(...
[ "0.5855813", "0.58174276", "0.5344455", "0.5334281", "0.5323044", "0.53075933", "0.53034145", "0.52598774", "0.5258003", "0.52408934", "0.52373326", "0.5168691", "0.5147976", "0.5109821", "0.50820005", "0.50367594", "0.5033817", "0.50227356", "0.5005109", "0.50036335", "0.498...
0.67776966
0
Adds the primary key tests (unique, not_null) to the primary key column.
def add_primary_key_tests( self, schema_content: Dict[str, Any], model_name: str, ) -> None: model_file_path = self.get_file_path_from_sql_model(model_name=model_name) if not model_file_path: return primary_key_column = self.get_primary_key_from_sql(model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_primary_key(self):\n assert self.tbl.primary_key == 'id'", "def test_code_add_primary_key(self):\n sql = \"\"\"\n CREATE TABLE public.address_no_primary_key\n (\n code character varying(10),\n address character varying(255),\n ...
[ "0.74589247", "0.66175616", "0.6569066", "0.64053077", "0.63456315", "0.63337296", "0.6306686", "0.62847334", "0.6270942", "0.6083501", "0.6062621", "0.60461", "0.60365766", "0.6021916", "0.59867954", "0.5968053", "0.59389657", "0.5910877", "0.5889046", "0.5881331", "0.587261...
0.70331806
1
Method to delete the failing tests from the schema.yml.
def delete_failed_tests_from_schema( self, path_file: Path, model_name: str, tests_to_delete: Dict[str, List[str]] ): content = open_yaml( path_file, preserve_yaml_order=self._sugar_config.config.get("preserve_yaml_order", False), ) for model in content["model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.sql', mode='r') as f:\n cur.execute(f.read())\n db.commit()\n cur.close()\n db.close()", "def t...
[ "0.7157708", "0.6840837", "0.6840837", "0.6744383", "0.67398924", "0.6644065", "0.663067", "0.6602651", "0.66019326", "0.65678084", "0.65678084", "0.65678084", "0.65678084", "0.6532619", "0.65185887", "0.6497793", "0.6494446", "0.6491216", "0.64835113", "0.648288", "0.6480997...
0.7389425
0
Method to document the columns from a model. Will ask the user which columns they want to document and collect the new definition.
def document_columns( self, columns: Dict[str, str], question_type: str = "undocumented_columns" ) -> None: allowed_question_types_map = { "undocumented_columns": "undocumented columns", "documented_columns": "documented columns", } assert ( questi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_model(\n self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str]\n ) -> Dict[str, Any]:\n logger.info(f\"The model '{model_name}' already exists, updating its documentation.\")\n for model in content.get(\"models\", []):\n if model[\"name\"] == mod...
[ "0.60908073", "0.55415165", "0.5372188", "0.5359274", "0.5354231", "0.5340466", "0.5325151", "0.5293703", "0.52432853", "0.5163885", "0.5160039", "0.5150177", "0.5130315", "0.5116568", "0.51087177", "0.509843", "0.5091603", "0.5084476", "0.5083437", "0.5062949", "0.50574535",...
0.6973812
0
Method to update the columns from a model in a schema.yaml content.
def update_model( self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str] ) -> Dict[str, Any]: logger.info(f"The model '{model_name}' already exists, updating its documentation.") for model in content.get("models", []): if model["name"] == model_name: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def upgradeSchema(self) -> None:", "def _patch_schema(self):\n fields = get_json()['data']['attributes'].keys()\n return make_entity_schema(\n self.SCHEMA, self.RESOURCE_NAME,\n make_data_schema(\n self.SCHEMA, id_required=True,\n only=field...
[ "0.6048077", "0.57747126", "0.5664433", "0.5589418", "0.5571424", "0.5421451", "0.5394761", "0.53772175", "0.53585315", "0.53123355", "0.52927804", "0.5254707", "0.5240652", "0.52377737", "0.52357596", "0.5179389", "0.51512194", "0.51078886", "0.51063067", "0.51058704", "0.51...
0.74676514
0
Method to create a new model in a schema.yaml content.
def create_new_model( self, content: Optional[Dict[str, Any]], model_name: str, columns_sql: Sequence[str] ) -> Dict[str, Any]: logger.info(f"The model '{model_name}' has not been documented yet. Creating a new entry.") columns = [] for column_sql in columns_sql: descript...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_model(self, ApiId: str, Name: str, Schema: str, ContentType: str = None, Description: str = None) -> Dict:\n pass", "def create_model(self):\n pass", "def create_model(self):\n pass", "def create_models( self ):", "def test_create_model(self):\n model = ControlledSche...
[ "0.75608915", "0.6931102", "0.6931102", "0.6764485", "0.673761", "0.6483227", "0.64785224", "0.6357424", "0.6350314", "0.63297427", "0.6329468", "0.6134453", "0.61336684", "0.6127344", "0.6127344", "0.60928607", "0.60823125", "0.60697037", "0.6068816", "0.6059946", "0.6040354...
0.6983313
1
Return a list of connected component of a given size
def connected_components_with_size(self, size): components = [x for x in nx.connected_component_subgraphs(self.return_undirected()) if x.number_of_nodes() == size] for graph in components: SynonymNetwork.convert_to_special(graph) return components
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected_component_nodes_with_size(self, size, showRending=False, printResults=False):\n\n graphsOfSize = self.connected_components_with_size(size)\n if showRending:\n ans = [{node:graph.rendering_of_graph_node(node) for node in super(SynonymNetwork, graph).nodes()} for graph in graph...
[ "0.7175926", "0.6962229", "0.68868196", "0.6776708", "0.6681602", "0.6661775", "0.664788", "0.6627815", "0.6584589", "0.6561159", "0.65440905", "0.64664924", "0.63913494", "0.6352398", "0.6340285", "0.62921864", "0.62775284", "0.6261488", "0.62403965", "0.62268996", "0.618964...
0.83368003
0
Return a list of infoboxes of a node
def infoboxes_of_graph_node(self, nodeName): return self.node[nodeName].keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infoboxes_of_graph(self):\n infoboxes = []\n for nodeName in super(SynonymNetwork, self).nodes():\n infoboxes = infoboxes + self.infoboxes_of_graph_node(nodeName)\n return list(set(infoboxes))", "def _available_boxes(self, graph):\n return sorted([node.name for node in ...
[ "0.6946358", "0.6361805", "0.6139065", "0.59413755", "0.5941131", "0.58889467", "0.5884175", "0.5850629", "0.58499706", "0.5776936", "0.573916", "0.5717519", "0.5703713", "0.5701958", "0.5700756", "0.56752574", "0.56741536", "0.5662098", "0.5639799", "0.562524", "0.5618712", ...
0.6962848
0
Return a (nonredunant) list of a graph's infoboxes
def infoboxes_of_graph(self): infoboxes = [] for nodeName in super(SynonymNetwork, self).nodes(): infoboxes = infoboxes + self.infoboxes_of_graph_node(nodeName) return list(set(infoboxes))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infoboxes_of_graph_node(self, nodeName):\n return self.node[nodeName].keys()", "def _available_boxes(self, graph):\n return sorted([node.name for node in graph.available_nodes()\n if not isinstance(node.meta, Ibox)])", "def infolist(self):\r\n return list(self.info...
[ "0.70919293", "0.65511703", "0.6170751", "0.56518734", "0.5469806", "0.5438119", "0.5431412", "0.5327349", "0.52892977", "0.5260679", "0.5251475", "0.5249176", "0.52470684", "0.5231178", "0.5216276", "0.51862216", "0.5169174", "0.5155935", "0.5152305", "0.5131187", "0.5118866...
0.7810729
0
Return either 'unrend', 'rend', or 'mixed' about a node
def rendering_of_graph_node(self, nodeName): rendingList = [item for sublist in self.node[nodeName].values() for item in sublist] # due to flattening [['unrend'],['rend','unrend']] etc. if all(items == 'unrend' for items in rendingList): return 'unrend' elif all(items == 'rend' for items in rend...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getNodeType(node): # {{{\n if node.nodeType == node.ELEMENT_NODE : return \"ELEMENT_NODE\"\n elif node.nodeType == node.ATTRIBUTE_NODE : return \"ATTRIBUTE_NODE\"\n elif node.nodeType == node.TEXT_NODE : return \"TEXT_NODE\"\n elif...
[ "0.59330434", "0.57472795", "0.55685306", "0.55460465", "0.5446833", "0.52605206", "0.5232469", "0.5225675", "0.5222645", "0.5222645", "0.5211315", "0.5193215", "0.5136534", "0.5125108", "0.50817764", "0.5080642", "0.5071563", "0.5054469", "0.5050788", "0.5024682", "0.5009587...
0.7448862
0
Return a list of nodes for each connected component of a given size, optionally showing the rendering state ('rend', 'unrend', or 'mixed'), and optionally priting the results in a readable manner
def connected_component_nodes_with_size(self, size, showRending=False, printResults=False): graphsOfSize = self.connected_components_with_size(size) if showRending: ans = [{node:graph.rendering_of_graph_node(node) for node in super(SynonymNetwork, graph).nodes()} for graph in graphsOfSize] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected_components_with_size(self, size):\n components = [x for x in nx.connected_component_subgraphs(self.return_undirected()) if x.number_of_nodes() == size]\n for graph in components:\n SynonymNetwork.convert_to_special(graph)\n\n return components", "def createNodes(self...
[ "0.7411901", "0.5986464", "0.5829044", "0.57453585", "0.56704384", "0.5544666", "0.5477517", "0.54514194", "0.5429409", "0.5378249", "0.5338306", "0.5332242", "0.5323817", "0.5284013", "0.52632344", "0.5228449", "0.52277344", "0.5223392", "0.51854527", "0.5174748", "0.5167538...
0.838628
0
Return whether the current player's score has the same absolute difference between its last two digits as the opponent's score.
def is_swap(player_score, opponent_score): # BEGIN PROBLEM 4 "*** YOUR CODE HERE ***" player_diff = abs(((player_score // 10)%10) - (player_score % 10)) opponent_diff = abs(((opponent_score // 10)%10) - (opponent_score % 10)) if player_diff == opponent_diff: return True return False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_end_of_game(self):\n return self.player_1.score + self.player_2.score >= self.number_of_cells", "def check_score(self):\r\n # If player reaches the exit before time expires\r\n final_score = int((5 - self._maze.items_remaining())*(self._time)*(100))\r\n score = (final_sc...
[ "0.64410603", "0.6398884", "0.61772853", "0.6137578", "0.6104868", "0.5995031", "0.5957221", "0.59311676", "0.5911049", "0.5877488", "0.5869364", "0.5831406", "0.5827793", "0.5821174", "0.5811221", "0.5742785", "0.573965", "0.5735727", "0.5733894", "0.57310593", "0.5688824", ...
0.6652104
0
Return a commentary function that announces lead changes. >>> f0 = announce_lead_changes() >>> f1 = f0(5, 0) Player 0 takes the lead by 5 >>> f2 = f1(5, 12) Player 1 takes the lead by 7 >>> f3 = f2(8, 12) >>> f4 = f3(8, 13) >>> f5 = f4(15, 13) Player 0 takes the lead by 2
def announce_lead_changes(previous_leader=None): def say(score0, score1): if score0 > score1: leader = 0 elif score1 > score0: leader = 1 else: leader = None if leader != None and leader != previous_leader: print('Player', leader, 'take...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_increment_function(delta):\n return lambda number: number + delta", "def updates(f):\n f.updates = True\n return f", "def announce_highest(who, previous_high=0, previous_score=0):\n assert who == 0 or who == 1, 'The who argument should indicate a player.'\n # BEGIN PROBLEM 7\n \"...
[ "0.52705693", "0.4956819", "0.48748475", "0.48450497", "0.47327447", "0.47263965", "0.4567901", "0.45541704", "0.45343226", "0.45111257", "0.4508821", "0.4503597", "0.44995", "0.4498226", "0.4497035", "0.44950983", "0.44797027", "0.44740486", "0.44602418", "0.44587052", "0.44...
0.75322604
0
Return a commentary function that announces when WHO's score increases by more than ever before in the game. >>> f0 = announce_highest(1) Only announce Player 1 score gains >>> f1 = f0(11, 0) >>> f2 = f1(11, 9) 9 point(s)! That's the biggest gain yet for Player 1 >>> f3 = f2(20, 9) >>> f4 = f3(12, 20) Player 1 gets 3 p...
def announce_highest(who, previous_high=0, previous_score=0): assert who == 0 or who == 1, 'The who argument should indicate a player.' # BEGIN PROBLEM 7 "*** YOUR CODE HERE ***" def highest_commentary(score0, score1): current_score = -1 if who == 0: current_score = score0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def announce_highest(who, previous_high=0, previous_score=0):\n assert who == 0 or who == 1, 'The who argument should indicate a player.'\n if who ==0 :\n if previous_score> previous_high:\n previous_high=previous_score\n if previous_score>1:\n print(previous_score...
[ "0.7569457", "0.5807958", "0.5743568", "0.56182736", "0.54227114", "0.54214245", "0.5420976", "0.5420976", "0.54136336", "0.54079795", "0.5385615", "0.5337723", "0.53179383", "0.5317137", "0.5281766", "0.5249433", "0.5247084", "0.51886827", "0.5187498", "0.51824766", "0.51737...
0.7925943
0
Return a strategy that always rolls N dice. A strategy is a function that takes two total scores as arguments (the current player's score, and the opponent's score), and returns a number of dice that the current player will roll this turn. >>> strategy = always_roll(5) >>> strategy(0, 0) 5 >>> strategy(99, 99) 5
def always_roll(n): def strategy(score, opponent_score): return n return strategy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def always_roll(n):\r\n def strategy(score, opponent_score):\r\n return n\r\n return strategy", "def always_roll(n):\r\n def strategy(score, opponent_score):\r\n return n\r\n return strategy", "def roll_dice(self):\n self.roll = (random.randint(1,6), random.randint(1,6))\n ...
[ "0.7990645", "0.7990645", "0.6305908", "0.6282267", "0.6265862", "0.6256419", "0.62271136", "0.6221337", "0.62017894", "0.60886043", "0.6063855", "0.6039743", "0.6021034", "0.6010283", "0.60091543", "0.5938398", "0.59243244", "0.59230936", "0.59065485", "0.59057117", "0.59048...
0.80193526
1
Return a function that returns the average value of FN when called. To implement this function, you will have to use args syntax, a new Python feature introduced in this project. See the project description. >>> dice = make_test_dice(4, 2, 5, 1) >>> averaged_dice = make_averaged(dice, 1000) >>> averaged_dice() 3.0
def make_averaged(fn, num_samples=1000): # BEGIN PROBLEM 8 "*** YOUR CODE HERE ***" def return_average(*args): k, total = 0, 0 while k < num_samples: total += fn(*args) k += 1 return total / num_samples return return_average # END PROBLEM 8
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_averaged(fn, num_samples=1000):\n # BEGIN PROBLEM 8\n def average(*args):\n sum = 0\n for i in range(num_samples):\n sum += fn(*args)\n return sum / num_samples\n return average\n # END PROBLEM 8", "def make_averaged(fn, num_samples=1000):\n # BEGIN PROBLEM...
[ "0.742507", "0.7286888", "0.69316167", "0.60547763", "0.60077626", "0.59997326", "0.5834956", "0.57966316", "0.5760647", "0.57417023", "0.57063097", "0.56811064", "0.5680927", "0.5663702", "0.55822456", "0.5506385", "0.5506385", "0.5506385", "0.546159", "0.54614824", "0.54594...
0.73083514
1
Return 0 if strategy0 wins against strategy1, and 1 otherwise.
def winner(strategy0, strategy1): score0, score1 = play(strategy0, strategy1) if score0 > score1: return 0 else: return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play(strategy0, strategy1):\r\n who = 0 # Which player is about to take a turn, 0 (first) or 1 (second)\r\n score0, score1 = 0, 0\r\n while who == 0:\r\n dice_num = dice_check(score0, score1, who, strategy0)\r\n score0 += take_turn(dice_num, score1, select_dice(score0, score1), name(who)...
[ "0.6689735", "0.6615073", "0.6372661", "0.6286028", "0.6247574", "0.62431514", "0.6144753", "0.61409026", "0.6093172", "0.60292673", "0.5996782", "0.5976392", "0.59516424", "0.59036964", "0.5876322", "0.5876114", "0.586334", "0.58454233", "0.58374006", "0.58091956", "0.579776...
0.8123433
1
Return the average win rate of STRATEGY against BASELINE. Averages the winrate when starting the game as player 0 and as player 1.
def average_win_rate(strategy, baseline=always_roll(4)): win_rate_as_player_0 = 1 - make_averaged(winner)(strategy, baseline) win_rate_as_player_1 = make_averaged(winner)(baseline, strategy) return (win_rate_as_player_0 + win_rate_as_player_1) / 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_ratio_avg(self):\n win_ratio = 0\n # Adds all the win ratios of team in this conference which will be\n # used to compute the win ratio average.\n for team_obj in self._conf_teams:\n ### INVARIANT: team_obj is a Team class object and\n ### self._con...
[ "0.6717765", "0.64588726", "0.63417643", "0.62936395", "0.6277814", "0.610984", "0.61046314", "0.6065044", "0.59797865", "0.5971465", "0.5899065", "0.5877843", "0.5819356", "0.5789211", "0.5763565", "0.57442445", "0.5724848", "0.57111496", "0.5692904", "0.5664826", "0.5659643...
0.8115959
1
Implements crossentropy as a function costs(theta) on given traning data
def cross_entropy(X, y): return lambda theta: -y * np.log(logistic_hypothesis(theta)(X) + 1e-9) - ( 1 - y ) * np.log(1 - logistic_hypothesis(theta)(X) + 1e-9)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(y_observed, p):\n\n pass", "def cross_entropy(t,y):\r\n #print(-1*t*np.log(y))\r\n #print(np.shape(np.log(y)))\r\n #print(np.shape(t))\r\n return t*np.log(y)*(-1)", "def cross_entropy(predictions, targets):\n likelihood = targets * np.log(predictions)\n return -np.sum(lik...
[ "0.73253536", "0.6912139", "0.6881294", "0.6762478", "0.6754978", "0.6689187", "0.6629159", "0.660048", "0.6590784", "0.65587205", "0.6547451", "0.6451672", "0.64506274", "0.6429443", "0.64189255", "0.63606083", "0.6355681", "0.633888", "0.6335124", "0.6334", "0.63227713", ...
0.71423405
1
Set up each webpage with a header and navigation bar.
def setup_page( self, html_page, links, label=None, title=None, approximant=None, background_colour=None, histogram_download=False ): html_file = webpage.open_html( web_dir=self.webdir, base_url=self.base_url, html_page=html_page, label=label ) html_fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_webpages(self):\n if self.add_to_existing:\n self.add_existing_data()\n self.make_home_pages()\n self.make_1d_histogram_pages()\n self.make_corner_pages()\n self.make_config_pages()\n if self.make_comparison:\n self.make_comparison_pages(...
[ "0.6627888", "0.6465586", "0.62752324", "0.6114537", "0.6103888", "0.606285", "0.60445887", "0.6036751", "0.60337174", "0.6021009", "0.5930741", "0.5924869", "0.5913862", "0.58483374", "0.5833003", "0.58251595", "0.57794666", "0.57769567", "0.57743686", "0.5753638", "0.575228...
0.6815308
0
Make a navbar for the homepage
def make_navbar_for_homepage(self): links = [ "home", ["Result Pages", self._result_page_links()], "Version" ] if len(self.samples) > 1: links[1][1] += ["Comparison"] if self.publication: links.insert(2, "Publication") if self.gwdata is not Non...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_nav():\n return render_template('home.html')", "def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")", "def index():\n return render_template(\n 'index.html',\n nav=nav,\n title='Home Page',\n year=datetime...
[ "0.736893", "0.67783135", "0.6750848", "0.66524625", "0.6623326", "0.6588633", "0.6580005", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.653496", "0.6521001", "0.6503073", "0.64983183", ...
0.71998024
1
Generate all webpages for all result files passed
def generate_webpages(self): if self.add_to_existing: self.add_existing_data() self.make_home_pages() self.make_1d_histogram_pages() self.make_corner_pages() self.make_config_pages() if self.make_comparison: self.make_comparison_pages() if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n for file_name in os.listdir(CONTENT_FOLDER):\n if file_name.endswith('.html'):\n try_generate_page(file_name)", "def make_all_html_results(cmd, folder_names = [], jobs=[]):\n run = cmd.results.current['run_name']\n if not os.path.exists(pjoin(cmd.me_dir, 'HTML', run)):\n ...
[ "0.7309482", "0.6664472", "0.6591473", "0.65694594", "0.6510609", "0.6404508", "0.6366648", "0.63231736", "0.6277945", "0.622136", "0.6204493", "0.6124423", "0.6105005", "0.60247594", "0.6022048", "0.5962354", "0.5959207", "0.59505546", "0.59500504", "0.5926389", "0.5917044",...
0.70953083
1
compute expected calibration error (ECE)
def expected_calibration_error(data_length, bucket_accs, bucket_confs, bucket_totals): # TODO: If the docstring is longer than the function logic, usually the docstring should be shorter or it shouldn't # be a function. # Remember that the point of a function is to be an abstraction: something that hides co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diff_of_errors(self):\n self.e_of_e = self.azimuth_error - self.altitude_error\n return self.e_of_e", "def calculate_energy_conservation_error(self):\n assert self.data is not None\n # calculate total energy at start and end of simulation\n energy_start = self.measure_total...
[ "0.7079219", "0.6710523", "0.6705349", "0.66143274", "0.6573631", "0.64684534", "0.64388514", "0.64110225", "0.6364667", "0.63354135", "0.6307564", "0.62935024", "0.6287445", "0.62517846", "0.6240687", "0.61839724", "0.6173702", "0.6167329", "0.61644596", "0.61461425", "0.613...
0.6969385
1
Calculates shade by converting the time passed since the start of the game to a percentage of the current day/night cycle.
def update(self): super().update() time_since_start = self.time_since_start() curr_mod = time_since_start%self.game.time_cycle_secs grade = abs(curr_mod - self.game.time_cycle_secs/2) / (self.game.time_cycle_secs/2) color_value = grade*(255-self.game.max_darkness) + self.game.ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_colour_time_based(self):\n\t\treturn self.get_hex_from_rgb(0, 0, int(255.0 * (get_elapsed_seconds_simulated() / SECONDS_PER_DAY)))", "def report_rest_percentage(self):\n self._logger.info(\"Running report for device {}\".format(self.name))\n tot_time_since_bday = (datetime.utcnow() - self.b...
[ "0.6328449", "0.5682314", "0.5677854", "0.5432159", "0.5369359", "0.53085834", "0.5219234", "0.5206503", "0.520525", "0.5153342", "0.5086756", "0.5010156", "0.5008131", "0.50076133", "0.5004993", "0.5000146", "0.49980986", "0.49826407", "0.49760562", "0.49475768", "0.4946041"...
0.578151
1
Displays the time in the game relative to the time cycle
def message(self): if self.display_time: return "Time: {}".format(int(self.physics_engine.time_since_start()%self.time_cycle_secs))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_time(self, time):\n pygame.draw.rect(self.screen, self.font_fgcolor, self.time_rect)\n self.screen.blit(self.small_font.render(\"Elapsed time: %.0f s\" % time, -1, (0, 0, 0)), (5, 720))\n pygame.display.update(self.time_rect)\n return", "def ShowTime():\n ClearDisplay()...
[ "0.80268294", "0.7536709", "0.7264826", "0.71524316", "0.709622", "0.7039029", "0.70333403", "0.6958243", "0.6939595", "0.69334245", "0.693148", "0.68405247", "0.6725378", "0.6715109", "0.66588914", "0.66478723", "0.6636626", "0.6634973", "0.66332513", "0.6627094", "0.6620326...
0.7924845
1
Creates a model, given the type of model and the output method. Adds the output layer with activation corresponding to the output type after the constructed model. This allows for easy switching between binary and multiclass classification, and prevents us from having to implement two types of each model. The model is ...
def create_model(model_type: str, input_size: Tuple[int, ...], output='binary', summary=True) -> keras.Model: if model_type in MODELS: inputs, outputs = MODELS[model_type](input_size) else: raise ValueError(f'Model type "{model_type}" not supported') if output == 'binary': activatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_model(input_dim, hidden_neurons, output_dim):\n\tmodel = Sequential([\n \tDense(hidden_neurons, input_dim=input_dim),\n Activation('relu'),\n Dropout(0.2),\n Dense(hidden_neurons),\n Activation('relu'),\n Dropout(0.2),\n Dense(output_dim, activation='softmax')...
[ "0.6704527", "0.66973925", "0.66615975", "0.66041964", "0.6572064", "0.6570199", "0.6549063", "0.647823", "0.6476947", "0.6459976", "0.6454561", "0.6407263", "0.64054805", "0.638561", "0.63830036", "0.63781667", "0.63442785", "0.6344052", "0.6315975", "0.6313631", "0.63134235...
0.71340376
0
Create UID for metric, tag_key and tag_value
def create_uid(self, host, index): msg = [] operation = "WRITE" url = "%s%s%s" % ("http://", host, "/api/uid/assign") payload = {"metric": [METRIC_NAME], "tagk": [TAGK], "tagv": ["%s.%d" % (TAGV, index)]} headers = {"content-type": "application/json"} m_uuid = False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tag_id():\n return uuid.uuid1().int", "def create_uid():\n return random_string(5, string.hexdigits.lower())\n # return (\"%x\" % (int(time.time()) * 0x10 % 0x1000000000)\n # + random_string(7, string.hexdigits.lower()))", "def uid_gen(prefix: str = \"\") -> str:\n uid: str = ...
[ "0.622496", "0.5914397", "0.5869701", "0.5807702", "0.5769845", "0.5710975", "0.56788355", "0.56183344", "0.56085813", "0.5602032", "0.5578855", "0.5568348", "0.555802", "0.553758", "0.5533039", "0.54645866", "0.54295546", "0.5413362", "0.54101545", "0.53708315", "0.53593594"...
0.6909411
0
Categorical Copula normalization for multidimentional array. This function apply the copnorm per categories.
def copnorm_cat_nd(x, y, axis=-1): assert isinstance(x, np.ndarray) and (x.ndim >= 1) if y is None: return copnorm_nd(x, axis=axis) return np.apply_along_axis(copnorm_cat_1d, axis, x, y)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copnorm_cat_1d(x, y):\n assert isinstance(x, np.ndarray) and (x.ndim == 1)\n assert isinstance(y, np.ndarray) and (x.ndim == 1)\n assert y.dtype in CONFIG['INT_DTYPE']\n x_cop = np.zeros_like(x)\n y_u = np.unique(y)\n for yi in y_u:\n _idx = y == yi\n x_cop[_idx] = copnorm_1d(x[...
[ "0.63591534", "0.5967849", "0.5967849", "0.5897528", "0.58845794", "0.5782783", "0.5721007", "0.5717328", "0.56614244", "0.56499016", "0.56471413", "0.56471413", "0.5636114", "0.5636114", "0.5629407", "0.560048", "0.5600006", "0.55716574", "0.55567706", "0.55072486", "0.54970...
0.62532276
1
Gets training data that includes tagged sentences. Returns a dictionary that maps every word in the training set to its most frequent tag. The dictionary should have a default value.
def most_frequent_train(train_data): ### YOUR CODE HERE tags_counts_for_each_word = {} # Filling a dictionary from words and tag tags to their counters # Going over the words and counting their tags appearances for sentance in train_data: for word, tag in sentance: # If first tim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MostCommonClassBaseline(training_set, test_set):\n pos_counts_dict = defaultdict(dict)\n max_pos_dict = dict()\n test_common_tags = []\n\n # Dictionary \"pos_counts_dict\" stores a dictionary for each word that stores counts of each pos of the word\n # This loop runs for each sentence (word, pos...
[ "0.62998277", "0.61069524", "0.60696596", "0.6068922", "0.6001002", "0.5926774", "0.5912238", "0.58869374", "0.58837795", "0.5883664", "0.5861991", "0.58473736", "0.5844703", "0.58288777", "0.5826551", "0.58042777", "0.5799191", "0.57924163", "0.5788701", "0.5764574", "0.5759...
0.7100879
0
converting json_bytes to dict or dict to json_bytes
def convert(data): result = None if isinstance(data, bytes): try: result = json.loads(data.decode(CODING)) except: print('wrong data format!') finally: return result elif isinstance(data, dict): try: result = json.dumps(data).en...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json_decode(data):\n if isinstance(data, bytes):\n data = data.decode(\"utf-8\")\n\n return json.loads(data)", "def _decode(self, data: bytes):\n\n return json.loads(data.decode('utf-8'))", "def json_loads(s: Union[bytes, str]) -> Dict[str, Any]:\n return json.loads(ensure_text(s, \"...
[ "0.6704753", "0.6599705", "0.6597806", "0.6580214", "0.6572985", "0.65350634", "0.6337056", "0.6297806", "0.62290484", "0.6216683", "0.62112856", "0.6185201", "0.6179623", "0.6128823", "0.6126266", "0.6124865", "0.6116758", "0.6101291", "0.60905", "0.609006", "0.6081644", "...
0.71246356
0
Return a list of latest build packages that are tagged with certain tag
def koji_tag2pkgs(kapi, tag): ret = [] for rpminfo in kapi.listTagged(tag, inherit=True, latest=True): pkg = _koji_buildinfo2pkg(kapi, rpminfo) ret.append(pkg) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_latest_build(tag, package):\n proc = Popen([\"osg-koji\", \"-q\", \"list-tagged\", \"--latest\", tag, package],\n stdout=PIPE)\n out = proc.communicate()[0] or b''\n ret = proc.returncode\n\n latest_build_line = out.decode(\"latin-1\").strip()\n\n if ret != 0 or not latest_b...
[ "0.6766918", "0.64562565", "0.6202034", "0.61146486", "0.59529054", "0.5890708", "0.58779067", "0.57897514", "0.5786915", "0.5756531", "0.57446975", "0.57202804", "0.57058716", "0.56544155", "0.5646688", "0.5629611", "0.5629158", "0.56251156", "0.557942", "0.55721", "0.556434...
0.6693938
1
Return a the build pacakges from a package id
def koji_pkgid2pkgs(kapi, pkgid): ret = [] for binfo in kapi.listBuilds(packageID=pkgid): pkg = _koji_buildinfo2pkg(kapi, binfo) ret.append(pkg) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_buildrequire_pkgs_from_build(build_id, session, config):\n print(\"Retriewing build metadata from: \", config.koji_host)\n build = session.getBuild(build_id)\n if not build:\n raise Exception(\"Build with id '{id}' has not been found.\".format(id=build_id))\n\n print(\"Build with the ID\...
[ "0.7184097", "0.6101216", "0.6087045", "0.60699105", "0.60417914", "0.6040838", "0.5977515", "0.5934301", "0.5913", "0.58773243", "0.58617723", "0.58331734", "0.5806986", "0.5787779", "0.5784125", "0.5781364", "0.5760907", "0.574403", "0.5714784", "0.5705453", "0.56750613", ...
0.6947734
1
Return a list of latest modules that are in the given compose
def composed_url2modules(baseurl): import compose c = compose.Compose(baseurl) cid = c.data_id() cstat = c.data_status() print('Mod Compose:', cid) print(' Status:', cstat) mdata = c.json_modules() m = compose.modules_from_compose(mdata) return compose.dedup_modules(m)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modules(self):\n return sorted([module for module in self._registry.values()],\n key=lambda scomp: (scomp.order, scomp.label))", "def _list_all(root_pkg, prog):\n res = \"\\n\".join(\n sorted(\n pkinspect.package_module_names(_import(root_pkg)),\n k...
[ "0.5734544", "0.5620557", "0.5515039", "0.54573196", "0.5440216", "0.5403242", "0.54014957", "0.5378393", "0.53708357", "0.5353265", "0.53318167", "0.53174704", "0.5289548", "0.52598995", "0.5258763", "0.52493656", "0.5242129", "0.5224267", "0.5214835", "0.5213591", "0.520834...
0.5680556
1
Get negative diagonals, going from topleft to bottomright.
def diagonalsNeg (matrix, cols, rows): for diagonal in ([(j, i - cols + j + 1) for j in range(cols)] for i in range(cols + rows - 1)): yield [matrix[i][j] for i, j in diagonal if i >= 0 and j >= 0 and i < cols and j < rows]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diagonals(self):\n left_top_shifts = map(lambda i: (-(i + 1), -(i + 1)), range(min(\n self.left_distance, self.top_distance)))\n left_bottom_shifts = map(lambda i: (-(i + 1), +(i + 1)), range(min(\n self.left_distance, self.bottom_distance)))\n right_top_shifts = map(...
[ "0.74394697", "0.70225304", "0.6999749", "0.6986131", "0.69826496", "0.68484116", "0.68346524", "0.6826511", "0.6775777", "0.6718986", "0.66814524", "0.6667113", "0.65236944", "0.65159935", "0.6481205", "0.6473899", "0.6424914", "0.6395643", "0.6351728", "0.6312667", "0.62737...
0.74049544
1
Insert the figure in the given column.
def insert (self, column, figure): c = self.board[column] if c[0] != NONE: raise Exception('Column is full') i = -1 while c[i] != NONE: i -= 1 c[i] = figure self.checkForWin()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place_disc(self, column):\n stdout.write(\"place_disc %d\\n\" % column)\n stdout.flush()", "def addColumn(self, *column):\n self.insertColumn(self._width, *column)", "def insert_after(self, text, line, col):\n col = self.canonicalize_column_index(line, col)\n col_off = se...
[ "0.663612", "0.66170853", "0.63207686", "0.6298038", "0.62482417", "0.6247075", "0.6229078", "0.6151331", "0.6122636", "0.61149824", "0.610697", "0.61038834", "0.6098983", "0.60879403", "0.60723233", "0.60662925", "0.6054099", "0.60376287", "0.60324526", "0.59339696", "0.5914...
0.8167265
0
To be run in a directory with LOTAAS classifier out files. Determines which pulsars are in at least 3 of the 5 models provided and lists them in a file
def categorize_classifier_files(out_dir): #sort all of the classifier files into a dictionary class_files = glob.glob("feature_extraction_m*") class_file_dict = {"positive":[], "negative":[]} class_cand_dict = {"m1":class_file_dict, "m2":class_file_dict, "m3":class_file_dict, "m4":class_file_dict, "m5"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_example(models, examples_path):\n frame_list = get_lidc_dataframes(examples_path, len(models))\n malignant_files = []\n for frame in frame_list:\n files = frame[\"File\"]\n for model, file in zip(models, files):\n prediction = np.argmax(model.predict(file))\n i...
[ "0.6200996", "0.58896387", "0.5857481", "0.5760066", "0.57523656", "0.5741391", "0.57344854", "0.5728773", "0.56916726", "0.568332", "0.56797236", "0.56721956", "0.56310445", "0.5614847", "0.558532", "0.5576366", "0.5574889", "0.557381", "0.5571876", "0.55642986", "0.55564094...
0.68747187
0
r"""Return grid locations used for tests in this file.
def test_grid(): with get_test_data('interpolation_test_grid.npz') as fobj: data = np.load(fobj) return data['xg'], data['yg']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_grid_position(self):\n tile_size_x = constants.WINDOW_WIDTH / constants.GRID_TILE_LENGTH\n tile_size_y = constants.WINDOW_HEIGHT / constants.GRID_TILE_LENGTH\n grid_x = tile_size_x / self.host.x\n grid_y = tile_size_y / self.host.y\n return grid_x, grid_y", "def generat...
[ "0.6918649", "0.63132507", "0.63131356", "0.6228707", "0.615756", "0.6123201", "0.6111844", "0.60771805", "0.60724473", "0.60664034", "0.6015367", "0.60129166", "0.6007126", "0.6001071", "0.5990227", "0.59845644", "0.5919908", "0.5914542", "0.5877363", "0.58720917", "0.586397...
0.6534552
1
r"""Test natural neighbor interpolation function.
def test_natural_neighbor(test_data, test_grid): xp, yp, z = test_data xg, yg = test_grid img = natural_neighbor(xp, yp, z, xg, yg) with get_test_data('nn_bbox0to100.npz') as fobj: truth = np.load(fobj)['img'] assert_array_almost_equal(truth, img)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nn_point(test_data):\n xp, yp, z = test_data\n\n tri = Delaunay(list(zip(xp, yp)))\n\n sim_gridx = [30]\n sim_gridy = [30]\n\n members, tri_info = find_natural_neighbors(tri,\n list(zip(sim_gridx, sim_gridy)))\n\n val = nn_point(xp, yp, z, [s...
[ "0.68133557", "0.6289575", "0.6225868", "0.62149423", "0.6126334", "0.60409766", "0.60360444", "0.5988397", "0.59295636", "0.59061944", "0.587684", "0.5838663", "0.5803554", "0.5777474", "0.5770294", "0.569739", "0.567572", "0.5646712", "0.5637545", "0.5592249", "0.5589785", ...
0.6973079
0
r"""Test inverse distance interpolation function.
def test_inverse_distance(method, test_data, test_grid): xp, yp, z = test_data xg, yg = test_grid extra_kw = {} if method == 'cressman': extra_kw['r'] = 20 extra_kw['min_neighbors'] = 1 test_file = 'cressman_r20_mn1.npz' elif method == 'barnes': extra_kw['r'] = 40 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__inverse_transform_continuous(self):", "def testInverted(self):\n invertedClass = xyTransformRegistry[\"inverted\"]\n invertedConfig = invertedClass.ConfigClass()\n affineClass = xyTransformRegistry[\"affine\"]\n invertedConfig.transform.retarget(affineClass)\n affineC...
[ "0.64221805", "0.6114815", "0.6088234", "0.60316193", "0.59683204", "0.58155304", "0.58098304", "0.5610405", "0.56054175", "0.56038624", "0.5599341", "0.5583385", "0.55830747", "0.558048", "0.55263007", "0.55263007", "0.5525398", "0.55220234", "0.55166364", "0.55103624", "0.5...
0.71566653
0
r"""Test find natural neighbors for a point interpolation function.
def test_nn_point(test_data): xp, yp, z = test_data tri = Delaunay(list(zip(xp, yp))) sim_gridx = [30] sim_gridy = [30] members, tri_info = find_natural_neighbors(tri, list(zip(sim_gridx, sim_gridy))) val = nn_point(xp, yp, z, [sim_gridx[0], sim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_natural_neighbor(test_data, test_grid):\n xp, yp, z = test_data\n xg, yg = test_grid\n\n img = natural_neighbor(xp, yp, z, xg, yg)\n\n with get_test_data('nn_bbox0to100.npz') as fobj:\n truth = np.load(fobj)['img']\n\n assert_array_almost_equal(truth, img)", "def problem5(self, s):...
[ "0.6897055", "0.6649428", "0.6639052", "0.6530777", "0.64982593", "0.63480467", "0.6291873", "0.62584484", "0.6234219", "0.62292683", "0.6225094", "0.6086198", "0.60818624", "0.6075852", "0.6039569", "0.60207516", "0.6012348", "0.6010177", "0.6008167", "0.5977195", "0.5965110...
0.73872244
0
r"""Test Barnes weights function.
def test_barnes_weights(): kappa = 1000000 gamma = 0.5 dist = np.array([1000, 2000, 3000, 4000])**2 weights = barnes_weights(dist, kappa, gamma) * 10000000 truth = [1353352.832366126918939, 3354.626279025118388, .152299797447126, .000000126641655] asse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_breeding(self):\n Herbivore.set_parameters({\"gamma\": 1})\n self.herb.weight = 50\n newborn_weight = self.herb.breeding(10)\n nt.assert_not_equal(None, newborn_weight)", "def c_test_weighting_bias(self, function):\r\n return general_weighting_bias(self.verbosity, func...
[ "0.7263572", "0.72594935", "0.72594935", "0.72594935", "0.69900525", "0.68501157", "0.6781213", "0.6605773", "0.6576652", "0.6557013", "0.6512069", "0.64957434", "0.6486371", "0.6484919", "0.646704", "0.6454388", "0.6386876", "0.6384625", "0.6384625", "0.63698995", "0.6315728...
0.7957706
1
r"""Test Cressman weights function.
def test_cressman_weights(): r = 5000 dist = np.array([1000, 2000, 3000, 4000])**2 weights = cressman_weights(dist, r) truth = [0.923076923076923, 0.724137931034482, 0.470588235294117, 0.219512195121951] assert_array_almost_equal(truth, weights)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_basic(self):\n result = NonLinearWeights(0.85)\n self.assertAlmostEqual(result.cval, 0.85)", "def test_feeding_weight_carn(self):\n original = self.carn.weight\n self.carn.fitness = 1\n herb = [Herbivore(age=90) for _ in range(50)]\n self.carn.feeding(herb)\n ...
[ "0.67748266", "0.6498026", "0.6415541", "0.6391458", "0.637254", "0.6250476", "0.6250476", "0.6250476", "0.6240067", "0.62005264", "0.61936164", "0.61265564", "0.6121124", "0.6113677", "0.6018572", "0.60182", "0.601679", "0.599509", "0.59852964", "0.59660983", "0.5918179", ...
0.8282531
1
r"""Test Cressman interpolation for a point function.
def test_cressman_point(test_data): xp, yp, z = test_data r = 40 obs_tree = cKDTree(list(zip(xp, yp))) indices = obs_tree.query_ball_point([30, 30], r=r) dists = dist_2(30, 30, xp[indices], yp[indices]) values = z[indices] truth = 1.05499444404 value = cressman_point(dists, values,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fixed_point(testFunctions, tol, printFlag): \n pass", "def test_fixed_point_system(testFunctions, tol, printFlag): \n pass", "def check_interp(self):\n\n points = np.loadtxt(\"skeleton_temp/\" + cell + \"_points.txt\", delimiter=',')\n\n self.initial_scatter = ax.scatter(poin...
[ "0.6262889", "0.6127593", "0.60630435", "0.59690744", "0.59616745", "0.59546226", "0.5874195", "0.58734214", "0.58238226", "0.58026075", "0.57872707", "0.5775866", "0.5738318", "0.5729117", "0.5704638", "0.5668535", "0.56655055", "0.5663175", "0.5661966", "0.56616485", "0.566...
0.72067887
0
r"""Test Barnes interpolation for a point function.
def test_barnes_point(test_data): xp, yp, z = test_data r = 40 obs_tree = cKDTree(list(zip(xp, yp))) indices = obs_tree.query_ball_point([60, 60], r=r) dists = dist_2(60, 60, xp[indices], yp[indices]) values = z[indices] truth = 4.08718241061 ave_spacing = np.mean((cdist(list(zip(x...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_single_point_bspline_radius() -> None:\n control_points = np.array([(0.0, 0.0, 0.0)])\n knot_vector = np.array([0, 0, 1, 1])\n curve = BSplineCurve(control_points, knot_vector)\n for parameter in np.linspace(0.0, 1.0, num=5):\n np.testing.assert_allclose(\n curve.radius_at(pa...
[ "0.65393716", "0.62299854", "0.621912", "0.6113236", "0.5917149", "0.5852951", "0.5850865", "0.5846754", "0.5818286", "0.58133703", "0.58133703", "0.57956046", "0.57805043", "0.5778642", "0.575499", "0.5752062", "0.57458085", "0.57200813", "0.5705935", "0.56873363", "0.568733...
0.7259133
0
Add metrealstation_no & metforecaststation_no to rl_kpis_df data
def add_met_real_forecast_station_col_to_rlkpis(self): rl_kpi_siteId_df = pd.DataFrame(self.rlkpi.imputed_rl_kpis_df.site_id.unique(), columns=['site_id']) # Assign the nearest station from met-real to the site Id rl_kpi_siteId_df['met-real-station_no'] = \ rl_kpi_siteId_df['si...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_train_data(self):\r\n ## Impute rlkpis\r\n print(\"Imputing rlKPI df\")\r\n self.rlkpi.add_target_labels(1)\r\n self.rlkpi.impute_rl_kpis()\r\n\r\n print(\"Add 'met-real-station_no' & met-forecast-station_no to rl_kpis_df\")\r\n self.add_met_real_forecast_stati...
[ "0.66093993", "0.53555703", "0.53393054", "0.533251", "0.53289", "0.5301145", "0.5197288", "0.5096265", "0.50771284", "0.5050672", "0.50454473", "0.50402033", "0.5028574", "0.50062984", "0.4998292", "0.49721038", "0.4968566", "0.4958544", "0.49429664", "0.49366996", "0.493378...
0.7614396
0
1 Add 'metrealstation_no' & metforecaststation_no to rl_kpis_df so that metforecast and metreal data can be merged easily 2 merge metreal resample data 3 merge metforecast data
def prepare_train_data(self): ## Impute rlkpis print("Imputing rlKPI df") self.rlkpi.add_target_labels(1) self.rlkpi.impute_rl_kpis() print("Add 'met-real-station_no' & met-forecast-station_no to rl_kpis_df") self.add_met_real_forecast_station_col_to_rlkpis() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_met_real_forecast_station_col_to_rlkpis(self):\r\n rl_kpi_siteId_df = pd.DataFrame(self.rlkpi.imputed_rl_kpis_df.site_id.unique(), columns=['site_id'])\r\n\r\n # Assign the nearest station from met-real to the site Id\r\n rl_kpi_siteId_df['met-real-station_no'] = \\\r\n rl_k...
[ "0.76217365", "0.5724756", "0.5574119", "0.5542644", "0.5527173", "0.5513221", "0.55130845", "0.5508425", "0.5384717", "0.5348086", "0.5330485", "0.5295532", "0.52790254", "0.52596587", "0.52467704", "0.5236038", "0.520138", "0.51984364", "0.5197946", "0.51753104", "0.5171422...
0.67931956
1
Apply principle component analysis to the Xarray to 3 dimensions and visualise the resulting matrix
def visualise_data_set(x_arr, y_arr): # Instantiate a PCA object for the sake of easy visualisation pca = PCA(n_components=3) # Fit and transform x to visualise inside a 3D feature space x_visualisation = pca.fit_transform(x_arr) figure = plt.figure() axis = Axes3D(figure) axis.scatter(x_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def principal_component_analysis(X, num_components):\n components = []\n for _ in range(num_components):\n component = first_principal_component(X)\n components.append(component)\n X = remove_projection(X, component)\n \n return components", "def principle_component_analysis(data...
[ "0.6146485", "0.60670024", "0.56167203", "0.559021", "0.5509418", "0.54846156", "0.5475294", "0.54682386", "0.54289496", "0.5405009", "0.53256935", "0.53170615", "0.52998364", "0.5298442", "0.5297327", "0.529588", "0.527562", "0.526715", "0.52493393", "0.5245872", "0.52402586...
0.63614935
0
Apply principle component analysis to the two Xarray"s to 3 dimensions and visualise the resulting matrices
def visualise_two_data_sets(x_arr, y_arr, x_arr_two, y_arr_two): # Instantiate a PCA object for the sake of easy visualisation pca = PCA(n_components=3) # Fit and transform x to visualise inside a 3D feature space x_visualisation = pca.fit_transform(x_arr) figure = plt.figure() axis = Axes3D(f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visualise_data_set(x_arr, y_arr):\n # Instantiate a PCA object for the sake of easy visualisation\n pca = PCA(n_components=3)\n\n # Fit and transform x to visualise inside a 3D feature space\n x_visualisation = pca.fit_transform(x_arr)\n\n figure = plt.figure()\n axis = Axes3D(figure)\n\n ...
[ "0.60191256", "0.5515485", "0.541513", "0.53996515", "0.5396888", "0.5376275", "0.53691566", "0.5345294", "0.53282833", "0.5317449", "0.5285818", "0.52789575", "0.52583647", "0.52462524", "0.52080536", "0.51868224", "0.5168219", "0.51670533", "0.5163496", "0.5150325", "0.5136...
0.6886152
0
Plots a Kaplan Meier graph of time to default to file
def plot_kaplan_meier_graph_of_time_to_default(time_to_default, data_set_description=""): kmf = KaplanMeierFitter() kmf.fit(time_to_default, event_observed=[1] * len(time_to_default)) ax = kmf.plot(title="{0} Kaplan Meier analysis of time to default".format(data_set_description).replace("_", " ")) ax.ge...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_time_frames(self):\n\n fig = plt.figure()\n plt.grid(True)\n\n plt.ylim([-1.5,1.5])\n plt.xlim([0,1])\n\n for key in self.timeframes.keys():\n if key == 0:\n plt.plot(self.x, self.timeframes[key], label=\"time: \" + str(round(key*self.dt, 3)), l...
[ "0.6950117", "0.6604719", "0.6425373", "0.6411647", "0.62945455", "0.62930465", "0.6272661", "0.61956865", "0.6073431", "0.60684174", "0.60633975", "0.60579836", "0.6050537", "0.6033914", "0.6004738", "0.6001769", "0.59888655", "0.5988027", "0.5968159", "0.5948308", "0.594171...
0.7070033
0
Plots difference from no balancer for different classifiers and data balancing schemes
def visualise_dataset_balancer_results(results, range=(-0.5, 0.5), colors=("#64B3DE", "#1f78b4", "#B9B914", "#FBAC44", "#bc1659", "#33a02c", "grey", "#b15928", "#6a3d9a", "#e31a1c", "#6ABF20", "#ff7f00", "#6a3d9a"), exclude=("SVM (linear)", "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_balancer_results_per_classifier(data_balancer_results_per_classifier, parameter=(2, \"Balanced Accuracy\")):\n classifier_arr = []\n color = iter(cm.Set1(np.linspace(0, 1, len(data_balancer_results_per_classifier) + 1)))\n mean_classifier_arr = [0] * len(data_balancer_results_per_classifier[0][1]...
[ "0.69392395", "0.6658223", "0.65169877", "0.64943475", "0.628095", "0.62724614", "0.61827344", "0.61158895", "0.60847265", "0.6029901", "0.5979186", "0.5974841", "0.5973415", "0.5971678", "0.59669495", "0.5962603", "0.59477496", "0.5941426", "0.59301496", "0.59257036", "0.591...
0.6860829
1