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
Pops all messages with delay 0 from queue, decrements delay of all other messages in queue.
def popMsg(self): if not self.queue: return [] returned_msgs = [] for msg, delay in self.queue: delay -= 1 if delay < 1: returned_msgs.append(msg) else: self.pushMsg(msg, delay) self.queue = [] retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clearQueueAll():", "def flushMsgs(self):\n\n self.queue = self.pre_queue[:]\n self.pre_queue = []", "def process_queue_slowly(self):\n start = time.process_time()\n while self.queue and time.process_time() - start < 1.0 / TICKS_PER_SECOND:\n self.queue.popleft()()", ...
[ "0.67144364", "0.66757786", "0.6618901", "0.65488327", "0.6464834", "0.6428115", "0.6424008", "0.64020574", "0.6387836", "0.63875574", "0.6323554", "0.63065994", "0.6291893", "0.6290628", "0.6235985", "0.61975974", "0.6068567", "0.6021", "0.60010594", "0.5998538", "0.59967154...
0.7776639
0
Broadcast tx to all adjacent miners.
def broadcast(self, tx): for neighbor_id in self.adjacencies: self.sendMsg(neighbor_id, Message(self.id, Type.BLOCK, tx))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spreadTransactionToOtherMiners(self, requestTransaction):\n\n # Send transaction to miners (FOR EACH KNOWN HOST)\n for minerHostAddress in self.miningStatus.minerConfiguration.getKnownHosts():\n try:\n # Send transaction and do nothing\n # BROADCAST\n ...
[ "0.66038156", "0.6274829", "0.6043512", "0.5983298", "0.59150016", "0.57968414", "0.57570255", "0.56789345", "0.560874", "0.5598342", "0.5589789", "0.5573431", "0.549214", "0.5489175", "0.54376423", "0.5394886", "0.53701395", "0.5294905", "0.5232892", "0.52228385", "0.520348"...
0.7366961
0
Send request for a tx with target_hash. Provided so subclasses don't have to know about Message/Type classes.
def sendRequest(self, recipient_id, target_hash): self.sendMsg(recipient_id, Message(self.id, Type.REQUEST, target_hash))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def specific_tx(self, txs_hash: str) -> dict:\n \n specific_tx_url = self.network + bf_tx_url + txs_hash\n\n response = query_blockfrost(specific_tx_url, self.api_key, self.proxies)\n \n return response", "def fetch_transaction(self, tx_hash, cb):\r\n data = serialize.se...
[ "0.6335789", "0.5945272", "0.57339346", "0.55569977", "0.5473908", "0.5330927", "0.5299242", "0.52675045", "0.5127427", "0.5100161", "0.50913024", "0.5068615", "0.50218034", "0.5012753", "0.5006899", "0.49630117", "0.49577963", "0.49564967", "0.49495253", "0.494115", "0.49331...
0.73776096
0
Process new tx by adding it to miner's view of blockain and broadcasting tx if appropriate.
def handleNewTx(self, tx, sender_id): self.seen_tx[tx.hash] = tx for x in self.processNewTx(tx, sender_id): # ABSTRACT - Process tx. self.broadcast(x) # Broadcast new or first-time-seen-NON-ORPHAN tx only.
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def broadcast(self, tx):\n\n for neighbor_id in self.adjacencies:\n self.sendMsg(neighbor_id, Message(self.id, Type.BLOCK, tx))", "def inner_start_mining(self):\n print(\"Mining a new block\")\n blockchain = self.get_blockchain()\n self.request_transactions(blockchain)\n ...
[ "0.62435067", "0.6081548", "0.59205353", "0.58568287", "0.57794553", "0.57143486", "0.5689402", "0.5663524", "0.5662839", "0.5657658", "0.56520236", "0.56330717", "0.56166345", "0.56125706", "0.5542368", "0.55372036", "0.55286646", "0.54983795", "0.544925", "0.54399705", "0.5...
0.7271619
0
Receive all messages and handle by adding new tx to chain and sending requested tx.
def handleMsgs(self): force_sheep_check = self.changed_last_step self.changed_last_step = False if not self.queue: return need_to_check = False for msg in self.popMsg(): # Receive message(s) from queue. if msg.type == Type.BLOCK: new_tx ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handleNewTx(self, tx, sender_id):\n\n self.seen_tx[tx.hash] = tx\n for x in self.processNewTx(tx, sender_id): # ABSTRACT - Process tx.\n self.broadcast(x) # Broadcast new or first-time-seen-NON-ORPHAN tx only.", "def __process_requests(self):\n\t\tfor received_message in self.recei...
[ "0.63706714", "0.57967204", "0.564948", "0.5581043", "0.55281967", "0.5518762", "0.54766655", "0.54605657", "0.54169893", "0.539068", "0.536065", "0.53451145", "0.5340727", "0.5340727", "0.5340727", "0.5340293", "0.5337348", "0.5333433", "0.5331467", "0.5323918", "0.5318707",...
0.62888914
1
Make a new transaction (simulation rolled protocol's generation probability).
def makeNewTx(self): new_tx = self.makeTx() # ABSTRACT - Make a new tx. logging.info("New tx (%d) created by miner %d" % (new_tx.id, self.id)) self.changed_last_step = True self.handleNewTx(new_tx, self.id) self.checkAllTx()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeTx(self):\n new_tx = transaction.Tx(self.simulation.tick, self.id, self.id_bag.getNextId(), [])\n self.simulation.all_tx.append(new_tx)\n return new_tx", "def create_transaction():\n data = request.get_json()\n response = None\n status_code = None\n\n # Proposed transacti...
[ "0.688809", "0.6541269", "0.6458759", "0.63150495", "0.6303552", "0.61771643", "0.6159563", "0.60467774", "0.6026964", "0.598449", "0.5980803", "0.5973092", "0.5965499", "0.59579504", "0.59544593", "0.58957213", "0.58805126", "0.5879528", "0.58358264", "0.58014107", "0.579023...
0.69393706
0
Creates a default kernel configuration for sampling the assignment (clustering) vector. The default kernel is currently a gibbs sampler.
def default_assign_kernel_config(defn): # XXX(stephentu): model_descriptors should implement # is_conjugate() def is_nonconj(x): return x.name() == 'bbnc' nonconj_indices = [ idx for idx, x in enumerate(defn.models()) if is_nonconj(x) ] defn = _validate_definition(defn) #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_kernel_config(defn):\n return [('beam', {}),\n ('hypers',\n {\n 'alpha_a': 4.0,\n 'alpha_b': 2.0,\n 'gamma_a': 3.0, \n 'gamma_b': 6.0\n }\n )]", "def default_kernel_confi...
[ "0.71134216", "0.6542653", "0.631455", "0.61939925", "0.58622265", "0.58622265", "0.5806661", "0.58034617", "0.5737116", "0.5590373", "0.55743206", "0.5562998", "0.5560825", "0.5560825", "0.5536316", "0.5501189", "0.54971653", "0.54270834", "0.54206437", "0.53852093", "0.5381...
0.6652783
1
Creates a default kernel configuration for sampling the component (feature) model hyperparameters. The default kernel is currently a onedimensional slice sampler.
def default_feature_hp_kernel_config(defn): defn = _validate_definition(defn) # hyperparams hparams = {} for i, hp in enumerate(defn.hyperpriors()): if not hp: continue # XXX(stephentu): we are arbitrarily picking w=0.1 hparams[i] = {k: (fn, 0.1) for k, fn in hp.iter...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_kernel_config(defn):\n # XXX(stephentu): should the default config also include cluster_hp?\n return list(it.chain(\n default_assign_kernel_config(defn),\n default_feature_hp_kernel_config(defn)))", "def default_kernel_config(defn):\n return [('beam', {}),\n ('hypers...
[ "0.6796949", "0.6678182", "0.64459425", "0.60503626", "0.58838505", "0.55519116", "0.5517811", "0.54382676", "0.543245", "0.54167175", "0.53866047", "0.5364367", "0.53569466", "0.534915", "0.5333271", "0.530085", "0.5286953", "0.52530456", "0.52530456", "0.52390575", "0.52039...
0.6692787
1
Creates a default kernel configuration for sampling the component (feature) model hyperparameters via gridded gibbs.
def default_grid_feature_hp_kernel_config(defn): defn = _validate_definition(defn) config = {} grid = enumerate(zip(defn.models(), defn.hyperpriors())) for fi, (model, priors) in grid: partials = copy.deepcopy(model.default_partial_hypergrid()) if not partials: continue ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_kernel_config(defn):\n return [('beam', {}),\n ('hypers',\n {\n 'alpha_a': 4.0,\n 'alpha_b': 2.0,\n 'gamma_a': 3.0, \n 'gamma_b': 6.0\n }\n )]", "def default_kernel_confi...
[ "0.7038044", "0.66479754", "0.6639344", "0.6069703", "0.59834", "0.5876421", "0.58638674", "0.58139557", "0.56953424", "0.5643101", "0.5590353", "0.55644715", "0.55623347", "0.55576706", "0.5521305", "0.5481968", "0.5417475", "0.5417475", "0.53625685", "0.5361257", "0.5356784...
0.672701
1
Creates a default kernel configuration suitable for general purpose inference. Currently configures an assignment sampler followed by a component hyperparameter sampler.
def default_kernel_config(defn): # XXX(stephentu): should the default config also include cluster_hp? return list(it.chain( default_assign_kernel_config(defn), default_feature_hp_kernel_config(defn)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_kernel_config(defn):\n return [('beam', {}),\n ('hypers',\n {\n 'alpha_a': 4.0,\n 'alpha_b': 2.0,\n 'gamma_a': 3.0, \n 'gamma_b': 6.0\n }\n )]", "def default_assign_kerne...
[ "0.74664825", "0.6669633", "0.64068115", "0.6141077", "0.60617054", "0.59325707", "0.58984137", "0.5889346", "0.58742774", "0.5873526", "0.5721628", "0.56768763", "0.56751627", "0.5664445", "0.56459564", "0.5641544", "0.5609423", "0.56089675", "0.5594062", "0.558959", "0.5588...
0.6721311
1
Run the specified mixturemodel kernel for `niters`, in a single thread.
def run(self, r, niters=10000): validator.validate_type(r, rng, param_name='r') validator.validate_positive(niters, param_name='niters') model = bind(self._latent, self._view) for _ in xrange(niters): for name, config in self._kernel_config: if name == 'assign...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keras_multitask(self, args):\n start_time = time.time()\n\n # if self.args.log_metrics:\n # utils.wandb_init_logs(self.config[\"multitask_trainer\"])\n\n embedding_type = self.config[\"multitask_trainer\"][\"embedding_type\"]\n max_len = int(self.config[\"multitask_traine...
[ "0.526398", "0.5227684", "0.5223222", "0.5161868", "0.51457185", "0.51313883", "0.50994", "0.50941783", "0.5090904", "0.5052661", "0.5042556", "0.50333387", "0.49638876", "0.49547783", "0.49545497", "0.49525812", "0.49441355", "0.4915338", "0.49133337", "0.490859", "0.4903225...
0.56104976
0
Generate random identity in the range [0,MAX_IDENT)
def rand_ident(): return random.randrange(MAX_IDENT)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _random_id():\n return binascii.hexlify(os.urandom(4)).decode()", "def create_default_identifier():\n return random.randint(0, constants.UINT64_MAX)", "def _uniq_id():\n return random.getrandbits(64)", "def generate() -> int:\n return randint(0, 1000000000)", "def genAccountNo():\n f...
[ "0.72253335", "0.72219115", "0.7167471", "0.70747334", "0.6979588", "0.69670403", "0.69536585", "0.6940845", "0.6933056", "0.6932734", "0.6919691", "0.6914498", "0.6876722", "0.6872707", "0.686263", "0.6855753", "0.6773738", "0.6751347", "0.67492", "0.6744311", "0.67410314", ...
0.8698774
0
Go over a list of knodes, and remove knodes that show up more than once. In case of node ident showing more than once, we pick the shorter path.
def remove_knodes_duplicates(knodes): if len(knodes) == 0: return knodes knodes.sort(key=lambda kn:(kn.ident,kn.path_len)) # Resulting array cur_ident = knodes[0].ident res = [knodes[0]] for kn in knodes[1:]: if kn.ident != cur_ident: cur_ident = kn.ident ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _augment_keep_nodes_list(keep_node_paths, planned_prune_nodes, planned_keep_nodes):\n for path in keep_node_paths:\n for node in path:\n if node in planned_prune_nodes:\n planned_prune_nodes.remove(node)\n planned_keep_nodes.add(node)\n ...
[ "0.62400377", "0.61818063", "0.5942691", "0.59336096", "0.5920246", "0.5911783", "0.58328277", "0.58196455", "0.573857", "0.5710709", "0.5706729", "0.5706729", "0.56790596", "0.5645945", "0.56053144", "0.5599129", "0.5582787", "0.5565748", "0.550725", "0.55062926", "0.5481593...
0.7808545
0
Get the exact location of successor finger f.
def get_finger_succ_loc(self,f): return (self.ident + 2**f) % MAX_IDENT
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_finger_pred_loc(self,f):\n return (self.ident - 2**f) % MAX_IDENT", "def get_best_succ_finger(self,f):\n return min(self.best_finger_succ[f],\\\n key=lambda kn:dist_ident(self.get_finger_succ_loc(f),kn.ident))", "def get_position(self):\n fingers = self._finger\n\n ...
[ "0.7324578", "0.6701648", "0.6305842", "0.6113488", "0.5961032", "0.5939583", "0.5900967", "0.58954084", "0.582944", "0.5740464", "0.5649144", "0.56384355", "0.5636654", "0.5549057", "0.55214775", "0.551003", "0.5500065", "0.54814845", "0.5456797", "0.5407634", "0.5405606", ...
0.7737678
0
Get the exact location of predecessor finger f.
def get_finger_pred_loc(self,f): return (self.ident - 2**f) % MAX_IDENT
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_finger_succ_loc(self,f):\n return (self.ident + 2**f) % MAX_IDENT", "def get_pre_start_coordinate(self):\r\n if self.__orientation == Direction.VERTICAL:\r\n pre_start_coordinate = (self.__location[0] - 1,\r\n self.__location[1])\r\n if s...
[ "0.6941207", "0.63967246", "0.6356134", "0.6232716", "0.61281186", "0.6098431", "0.6043137", "0.601038", "0.5964785", "0.5905112", "0.5900349", "0.5870345", "0.5786246", "0.57826555", "0.5685832", "0.5669431", "0.56508344", "0.56330687", "0.56051207", "0.5595773", "0.55947304...
0.6845267
1
set knodes to be the neighbours of this Node.
def set_neighbours(self,knodes): self.neighbours = [] for kn in knodes: # Make sure we don't have ourselves as a neighbour: if kn.ident == self.ident: continue # A neighbour has a path length 1: self.neighbours.append(\ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_nodes(self, ndict):\n self.inode_ref = ndict[self.inode]\n self.jnode_ref = ndict[self.jnode]", "def _set_neighs_number(self, key):\n if self.staticneighs:\n self.idxs = np.array([[key]]*len(self.iss))\n else:\n if self.ks is None:\n self.k...
[ "0.6143316", "0.61328423", "0.61057997", "0.6096327", "0.5822501", "0.58154374", "0.5813451", "0.5793022", "0.5778608", "0.5768981", "0.5741788", "0.5711168", "0.56600326", "0.56487143", "0.56331366", "0.5609101", "0.5607822", "0.56023747", "0.55935335", "0.55854636", "0.5580...
0.8650126
0
If any of the nodes in knodes is a better candidate for the f's successor finger, we replace.
def add_known_best_finger_succ(self,f,knodes): pool = remove_knodes_duplicates(self.best_finger_succ[f] + knodes) self.best_finger_succ[f] = heapq.nsmallest(self.fk,pool,key=lambda kn:\ (dist_ident(self.get_finger_succ_loc(f),kn.ident),kn.path_len))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_known_best_finger_pred(self,f,knodes):\n pool = remove_knodes_duplicates(self.best_finger_pred[f] + knodes)\n self.best_finger_pred[f] = heapq.nsmallest(self.fk,pool,key=lambda kn:\\\n (dist_ident(kn.ident,self.get_finger_pred_loc(f)),kn.path_len))", "def add_known_nodes(self...
[ "0.65863997", "0.57711273", "0.5756308", "0.5654698", "0.55442864", "0.547416", "0.54474586", "0.5426827", "0.5420049", "0.5368275", "0.5300081", "0.528834", "0.52774775", "0.52709913", "0.52598345", "0.5227123", "0.52244043", "0.5201214", "0.51895624", "0.5179588", "0.515871...
0.691294
0
If any of the nodes in knodes is a better candidate for the f's predecessor finger, we replace.
def add_known_best_finger_pred(self,f,knodes): pool = remove_knodes_duplicates(self.best_finger_pred[f] + knodes) self.best_finger_pred[f] = heapq.nsmallest(self.fk,pool,key=lambda kn:\ (dist_ident(kn.ident,self.get_finger_pred_loc(f)),kn.path_len))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_known_best_finger_succ(self,f,knodes):\n pool = remove_knodes_duplicates(self.best_finger_succ[f] + knodes)\n self.best_finger_succ[f] = heapq.nsmallest(self.fk,pool,key=lambda kn:\\\n (dist_ident(self.get_finger_succ_loc(f),kn.ident),kn.path_len))", "def conditional_fptree(c...
[ "0.693827", "0.60230196", "0.5867795", "0.58434325", "0.5508809", "0.5360846", "0.53326386", "0.52740335", "0.5262194", "0.5252165", "0.52334034", "0.5219606", "0.5206954", "0.52016973", "0.5193245", "0.5191437", "0.5184126", "0.5121431", "0.5058852", "0.5048739", "0.5042447"...
0.6926302
1
Add a set of known nodes to self.known . Take the change of path_len into acount.
def add_known_nodes(self,source_path_len,knodes): # Update the path lengths: updated_knodes = [kn._replace(path_len=kn.path_len+source_path_len)\ for kn in knodes] # Make sure the node self.ident is not inside: updated_knodes = list(filter(lambda kn:kn.ident != self.iden...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadPaths(self):\n for ij in self.link:\n self.link[ij].flow = 0\n for p in self.path:\n for ij in self.path[p].links:\n self.link[ij].flow += self.path[p].flow\n for ij in self.link:\n self.link[ij].updateCost()\n for p in self.path:\n self.path[p...
[ "0.5705112", "0.5586761", "0.5573818", "0.54639876", "0.5189946", "0.5155706", "0.5123914", "0.510803", "0.51058125", "0.5105477", "0.5105477", "0.5105477", "0.5105477", "0.5098602", "0.50859404", "0.50795925", "0.5076114", "0.5060799", "0.50270456", "0.50270456", "0.5011845"...
0.68914646
0
Get the best successor for finger f.
def get_best_succ_finger(self,f): return min(self.best_finger_succ[f],\ key=lambda kn:dist_ident(self.get_finger_succ_loc(f),kn.ident))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_pred_finger(self,f):\n return min(self.best_finger_pred[f],\\\n key=lambda kn:dist_ident(kn.ident,self.get_finger_pred_loc(f)))", "def get_finger_succ_loc(self,f):\n return (self.ident + 2**f) % MAX_IDENT", "def add_known_best_finger_succ(self,f,knodes):\n pool ...
[ "0.78146094", "0.66287065", "0.6614685", "0.6437848", "0.63768697", "0.6372921", "0.62193644", "0.61676246", "0.61383694", "0.6065083", "0.5965671", "0.59089005", "0.5884506", "0.5874149", "0.5811637", "0.58102375", "0.57883865", "0.5720375", "0.5712061", "0.5701287", "0.5696...
0.8454211
0
Get the best predecessor for finger f.
def get_best_pred_finger(self,f): return min(self.best_finger_pred[f],\ key=lambda kn:dist_ident(kn.ident,self.get_finger_pred_loc(f)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_succ_finger(self,f):\n return min(self.best_finger_succ[f],\\\n key=lambda kn:dist_ident(self.get_finger_succ_loc(f),kn.ident))", "def predecessor(self, key):\r\n index = self.locate_predecessor(key)\r\n return self.keys[index] if index >= 0 else None", "def add...
[ "0.78589743", "0.6463797", "0.6380368", "0.63363165", "0.6327055", "0.6273297", "0.62648135", "0.6178588", "0.61382604", "0.6114862", "0.6012184", "0.59667087", "0.5960902", "0.5955692", "0.59211004", "0.5917483", "0.5893443", "0.5854102", "0.5837635", "0.5813187", "0.5765961...
0.7758518
1
Given an index i of a node in self.nodes, create a Knode tuple. Optionally set path_len.
def make_knode(self,i,path_len=0): return Knode(path_len=path_len,\ ident=self.nodes[i].ident,\ lindex=i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tuple(self, node, offset):\n raise NotImplementedError", "def _new_node(self):\n self._size += 1\n return self._node_factory()", "def new_node(name):\n\n return name, []", "def create_nodes(self):", "def add_node(p, nodes, retval, size=0):\n if p.id not in nodes:\n...
[ "0.5703165", "0.56307715", "0.5622106", "0.5513127", "0.54543275", "0.5440259", "0.541085", "0.529877", "0.5289851", "0.5273859", "0.52717495", "0.5248243", "0.52236366", "0.5221569", "0.51861733", "0.5162063", "0.51280314", "0.5104544", "0.509963", "0.5050595", "0.5047907", ...
0.7442352
0
Randomize immediate neighbours links between the nodes.
def rand_neighbours(self): # Initialize neighbours sets as empty sets: nodes_nei = [set() for _ in range(self.num_nodes)] for i,nd in enumerate(self.nodes): # Sample a set of indices (Which represent a set of nodes). # Those nodes will be nd's neighbours: nod...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topology_random_connect(self, probability):\n\t\tfor i in range(len(self.sites) - 1):\n\t\t\tfor j in range(i + 1, len(self.sites)):\n\t\t\t\tif not (self.sites[j] in self.sites[i].neighbors):\n\t\t\t\t\tif numpy.random.rand() < probability:\n\t\t\t\t\t\tself.sites[i].neighbors.append(self.sites[j])\n\t\t\t\t\...
[ "0.7466208", "0.72552603", "0.7183195", "0.6960398", "0.6936704", "0.6849447", "0.6582072", "0.6553823", "0.6552749", "0.6547171", "0.6515763", "0.64846265", "0.6471663", "0.6470682", "0.6429115", "0.6371298", "0.63630426", "0.6360093", "0.6310301", "0.6298965", "0.62629163",...
0.7368502
1
Ask all known nodes for better known nodes. i is the index of the node in self.nodes.
def iter_node(self,i): nd = self.nodes[i] for kn in nd.get_close(): # for kn in nd.get_known(): # for kn in nd.neighbours: kn_node = self.nodes[kn.lindex] nd.add_known_nodes(kn.path_len,kn_node.get_close())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_nodes(self):", "def iter_all(self):\n for i in range(self.num_nodes):\n self.iter_node(i)", "def findall_nodes(self):\n\n nodes = []\n for n in self.nodes:\n nodes += n.findall_forward()\n\n # Make sure list only contains every element once\n no...
[ "0.61433184", "0.60813344", "0.5848964", "0.5795101", "0.5587807", "0.5521741", "0.5448743", "0.5352327", "0.5309947", "0.52210253", "0.5205018", "0.51979536", "0.5189395", "0.51819515", "0.51623845", "0.5146305", "0.51394707", "0.5123654", "0.5118836", "0.5112863", "0.509401...
0.73433197
0
Perform a full iteration, where all nodes ask other nodes for better nodes.
def iter_all(self): for i in range(self.num_nodes): self.iter_node(i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def algorithm_loop(self):", "def iteration(self):\n T = self.generate_T()\n R = self.reproduce(T)\n self.P = self.choose_mi_best(R)\n #print(self.P)", "def _scanning_loop(self, indices_to_nodes, node_property,\n factor_aggregator, compute_statistics,\n ...
[ "0.64112765", "0.6376366", "0.6290607", "0.625625", "0.61058074", "0.6086212", "0.6046994", "0.6028196", "0.6016287", "0.5954837", "0.5954112", "0.59467137", "0.5915854", "0.59032404", "0.5859791", "0.5820535", "0.5805862", "0.58025163", "0.5785976", "0.5774789", "0.5770323",...
0.6852729
0
Verify the succ and pred fingers found for all nodes.
def verify_succ_pred_fingers(self): # Get all nodes (as Knodes), and sort them according to ident: lnodes = list(map(self.make_knode,range(self.num_nodes))) lnodes.sort(key=lambda ln:ln.ident) idents = [ln.ident for ln in lnodes] for i,ln in enumerate(lnodes): nd = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify(self):\n if not self.verify_succ_pred_fingers():\n return False\n\n return True", "def check_all_roots(trial):\r\n root_nodes = trial.node_map[0].children.copy()\r\n shuffle(root_nodes)\r\n states = []\r\n for node in root_nodes:\r\n trial_copy = copy.deepco...
[ "0.66580856", "0.570187", "0.5571804", "0.5347722", "0.53379714", "0.52541906", "0.52497715", "0.52165216", "0.5214105", "0.5211786", "0.52060664", "0.5186742", "0.5144179", "0.5125058", "0.5117712", "0.5065895", "0.505331", "0.50474966", "0.5039752", "0.50210714", "0.5002061...
0.75606465
0
For debugging, iterate over all segments and print the tour distances between them.
def print_all_distances(self): seg_pairs = [(begin, end) for begin in self.sim.segments for end in self.sim.segments if begin != end] for begin, end in seg_pairs: msg = "{} to {} is {}".format( begin, end, self.movement_model.shortest_distance(begin, end...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_routes(num_vehicles, locations, routing, assignment):\n total_dist = 0\n\n for vehicle_id in range(num_vehicles):\n index = routing.Start(vehicle_id)\n plan_output = 'Route for vehicle {0}:\\n'.format(vehicle_id)\n route_dist = 0\n\n while not routing.IsEnd(index):\n node = routing.Ind...
[ "0.6551842", "0.6328625", "0.61643714", "0.61071527", "0.5982154", "0.5948399", "0.5884795", "0.577238", "0.5771989", "0.5757012", "0.57092285", "0.5692484", "0.56700397", "0.5642345", "0.56388026", "0.56191444", "0.55993205", "0.55907816", "0.5544891", "0.5505479", "0.550499...
0.759176
0
Compute the communication delay between any two segments. This is done as per Equation 1 in FLOWER.
def communication_delay(self, begin, end): duration, path = self.movement_model.shortest_distance(begin, end) path_clusters = self.count_clusters(path) segment_speed_pairs = list() path_index = 0 last_segment = None for path_cluster in path_clusters: segment...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DDdelay(self):\n return self.delayInverse()+self.delayS()+self.delayA()", "def get_delay(self, pid1, pid2, is_block):\n is_slow = self.node_is_slow[pid1] or self.node_is_slow[pid2]\n p = random.uniform(Parameters.p_min, Parameters.p_max)\n c = Parameters.c_low if is_slow else Parameters.c_hig...
[ "0.6634899", "0.65710574", "0.6332385", "0.6312377", "0.6310698", "0.63046974", "0.6229603", "0.62076366", "0.6188229", "0.6138649", "0.61374885", "0.61205184", "0.61117893", "0.60913855", "0.60904974", "0.60808337", "0.6017291", "0.6009211", "0.6001124", "0.59958065", "0.598...
0.7175102
0
Merge the content of `csv1_path` and `csv2_path` and save the result to `csv_out_path`. After loading the content of `csv1_path` and `csv2_path` to two dataframes, the latter are joined based on the attribute ROW_ID, then the attribute RATIO is calculated as VAR1/VAR2. In case the value of df2.variable2 is 0, the ratio...
def merge(csv1_path, csv2_path, csv_out_path): df1 = prepare_df(csv1_path, var_name='variable1') df2 = prepare_df(csv2_path, var_name='variable2') if df1.shape[0] != df2.shape[0]: raise MergerError("Dataframes with different number of rows") df_merge = pd.merge(df1[[ROW_ID, STORE_ID, ADDRESS, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(path_to_mf_lf_1, path_to_mf_lf_2, path_to_mf_hf_1, path_to_mf_hf_2, path_to_sf,\n path_to_mf_lf, path_to_mf_hf, path_to_sf_copy):\n mf_lf = merge_one_case(pd.read_csv(path_to_mf_lf_1, index_col=0), pd.read_csv(path_to_mf_lf_2, index_col=0))\n mf_hf = merge_one_case(pd.read_csv(path_to_mf_h...
[ "0.59430826", "0.5510136", "0.5468078", "0.54010063", "0.53475004", "0.5254189", "0.5163402", "0.5108968", "0.50923437", "0.5082463", "0.4958747", "0.490054", "0.48976928", "0.48817962", "0.48293614", "0.4820845", "0.48040617", "0.47947568", "0.47924712", "0.4735074", "0.4720...
0.83744746
0
This is a private utility function for getBytesIOString to return chr(ord(x))
def _chr_ord(x): return chr(ord(x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def int2byte(i):\n return chr(i)", "def ToChar(byte):\n return chr(byte) if type(byte) != str else byte", "def int_to_char(cmd_x):\n i = 0\n cmd_r = ['~']\n while (i<len(cmd_x)):\n cmd_r += chr(int(cmd_x[i]))\n i+=1\n return cmd_r[1:]", "def int_to_char(cmd_x):\n i = 0\n cmd_r = ['~']\n...
[ "0.6812718", "0.67350185", "0.6676151", "0.6676151", "0.6642611", "0.6570406", "0.6552629", "0.65460235", "0.6507067", "0.6338866", "0.63328654", "0.63267094", "0.62464833", "0.6242555", "0.6218215", "0.6143248", "0.6124219", "0.6124219", "0.61205995", "0.611249", "0.61072904...
0.83996445
0
Return bytesIO.getvalue(), making sure the result is a str. This is necessary because getvalue() returns a bytes object in Python 3.
def getBytesIOString(bytesIO): if _BytesIOValueIsStr: # We don't need to convert. return bytesIO.getvalue() else: # Assume value is a Python 3 bytes object. Convert to str. return "".join(map(_bytesElementToChr, bytesIO.getvalue()))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getvalue(self):\n try:\n buffer_value = self.buffer.getvalue().decode()\n except UnicodeDecodeError:\n return self.buffer.getvalue()\n return super().getvalue() + buffer_value", "def to_str(value: bytes) -> str:\n if value is not None:\n out = valu...
[ "0.7136646", "0.708613", "0.7069398", "0.69311607", "0.68839103", "0.6821514", "0.68155074", "0.6760254", "0.669473", "0.6689737", "0.6595317", "0.6570502", "0.6566499", "0.6455121", "0.6454829", "0.64306384", "0.6425795", "0.64017624", "0.6376336", "0.6372872", "0.63647157",...
0.79677886
0
Check if obj has type str or (in Python 2) unicode. This is necessary because Python 2 has two string types, str and unicode, but Python 3 doesn't have type unicode so we have to be careful to check for type(obj) is unicode.
def typeIsString(obj): return type(obj) is str or _haveTypeUnicode and type(obj) is unicode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_string(self, obj):\n return isinstance(obj, unicode) or isinstance(obj, str)", "def not_a_string(obj):\n my_type = str(type(obj))\n if is_py3():\n is_str = my_type.find('bytes') < 0 and my_type.find('str') < 0\n return is_str\n\n return my_type.find('str') < 0 and \\\n ...
[ "0.84392506", "0.8279209", "0.78532845", "0.7850614", "0.7493695", "0.72205305", "0.70803994", "0.7060335", "0.7027205", "0.7022652", "0.6944461", "0.69087976", "0.6838188", "0.6789995", "0.67602634", "0.6694118", "0.657155", "0.65605915", "0.65587926", "0.65394413", "0.65368...
0.838337
1
If the input has type str (in Python 3) or unicode (in Python 2), then encode it as UTF8 and return an array of integers. If the input is str (in Python 2) then treat it as a "raw" string and just convert each element to int. Otherwise, if the input is not str or unicode, just return the input. This is necessary becaus...
def stringToUtf8Array(input): if _haveTypeUnicode: # Assume this is Python 2. if type(input) is str: # Convert the raw string to an int array. return map(ord, input) elif type(input) is unicode: # In Python 2, the result of enco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stringToInts(string):\r\n ints=[];\r\n for char in string:\r\n ints.append(charToInt(char));\r\n return ints;", "def str_to_int_array(str_number):\n return [int(digit) for digit in str_number]", "def int_list(data: bytes) -> list:\n byte_data = BytesIO(data)\n byte_list = []\n s...
[ "0.6829139", "0.6495251", "0.63872147", "0.6194526", "0.6155496", "0.6075865", "0.606455", "0.58894116", "0.5855386", "0.585386", "0.5843273", "0.5838782", "0.58286595", "0.5821874", "0.5803319", "0.5802284", "0.57906014", "0.57836956", "0.57609856", "0.5759111", "0.57570314"...
0.8145477
0
If value is None or negative, return None, otherwise return float(value). This is used in "setter" methods to ensure the correct type.
def nonNegativeFloatOrNone(value): return None if value == None or value < 0 else float(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def try_float(value: Any) -> Optional[float]:\n try:\n return float(value)\n except (TypeError, ValueError):\n return None", "def tryFloat(value):\n try:\n return float(value)\n except:\n return value", "def get_float_value(obj):\n if obj:\n value = obj.GetValu...
[ "0.81102824", "0.7993403", "0.7914879", "0.78282773", "0.77472675", "0.7721129", "0.76612204", "0.7554542", "0.75453144", "0.75139177", "0.7484502", "0.7447892", "0.7415617", "0.73664373", "0.7330329", "0.7286909", "0.7281832", "0.72585773", "0.7252314", "0.721841", "0.719989...
0.84067947
0
Encode the input as base64.
def base64Encode(input, addNewlines = False): base64Str = base64.b64encode(input) if not type(base64Str) is str: base64Str = "".join(map(chr, base64Str)) if not addNewlines: return base64Str result = "" i = 0 while i < len(base64Str):...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base64_encode(data):\n return base64.encodestring(data);", "def base64encode(self, value):\n\n return value.encode(\"base64\")[:-1].replace(\"\\n\", \"\")", "def _encode_base64(data: str) -> str:\n ebytes = base64.b64encode(data.encode(\"utf-8\"))\n estring = str(ebytes, \"utf-8\")\n ret...
[ "0.8130617", "0.7753844", "0.7700254", "0.7653159", "0.75856143", "0.750321", "0.74250084", "0.74191093", "0.7400606", "0.7338406", "0.7318883", "0.72607493", "0.7259977", "0.72417563", "0.71370274", "0.70966125", "0.7086378", "0.70632887", "0.7062696", "0.70384216", "0.70384...
0.79531
1
Ensure that the /locations endpoint returns location data
def test_locations(self): url = reverse("locations", args=[00000]) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertTrue(isinstance(response.data, list)) self.assertTrue(response.data) # list not empty location_data ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_location_GET(self):\r\n\r\n with self.client:\r\n u = User.query.first()\r\n response = self.client.get(\r\n f'/users/${u.username}/location', follow_redirects=True)\r\n self.assertIn(b'Unauthorized.', response.data)", "def get_locations(self):...
[ "0.7021286", "0.7005037", "0.6926361", "0.67708194", "0.67447066", "0.6726269", "0.66339976", "0.66304004", "0.6609766", "0.66056025", "0.6601121", "0.65188545", "0.6517053", "0.6501268", "0.6491278", "0.64708483", "0.6459681", "0.64490676", "0.6446491", "0.64254445", "0.6406...
0.72576606
0
Converts a sqlite3.Row to a string representing JSON
def row_to_json(row: sqlite3.Row) -> str: d = {} for key in row.keys(): d[key] = row[key] return json.dumps(d)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row_list_to_json(rows: List[sqlite3.Row]) -> str:\n l = []\n for row in rows:\n l.append(row_to_json(row))\n\n return json.dumps(l)", "def to_json_line(bq_row):\n row = dict()\n for key in bq_row:\n row[key] = bq_row[key]\n\n # default=str converts non JSON serializable object...
[ "0.81565416", "0.74537444", "0.74064386", "0.7377652", "0.7289121", "0.6780555", "0.672762", "0.6564707", "0.6396816", "0.6321192", "0.6316652", "0.6303767", "0.6242757", "0.6235095", "0.6218394", "0.6139007", "0.6124461", "0.61206156", "0.6118917", "0.61147624", "0.6109016",...
0.90898705
0
Converts a List[sqlite3.Row] to a string representing JSON
def row_list_to_json(rows: List[sqlite3.Row]) -> str: l = [] for row in rows: l.append(row_to_json(row)) return json.dumps(l)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row_to_json(row: sqlite3.Row) -> str:\n d = {}\n for key in row.keys():\n d[key] = row[key]\n\n return json.dumps(d)", "def convert_to_json(self, rows):\n\t\tjson_list = []\n\t\tfor row in rows:\n\t\t\tjson_record = {}\n\t\t\tjson_record[\"movie_id\"] = row[0]\n\t\t\tjson_record[\"title\"] = ...
[ "0.7739139", "0.752135", "0.7446329", "0.712356", "0.694361", "0.6843901", "0.6843901", "0.6747058", "0.6747058", "0.6701383", "0.66863126", "0.6674621", "0.66703725", "0.6659731", "0.6658011", "0.6646014", "0.6643814", "0.6618622", "0.65742904", "0.6567026", "0.6566061", "...
0.91807425
0
Check if user's answer is the same as the correct answer, ignoring case
def is_correct_answer(user_answer, correct_answer): string_correct_answer = str(correct_answer).lower() string_user_answer = str(user_answer).lower() return string_user_answer == string_correct_answer # If you accidentally used the same variable name # twice in the comparison, for example # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_answer(self, user_answer, correct_answer):\n if user_answer.lower() == correct_answer.lower():\n self.score += 1\n print(\"You got it right! \", end=\"\")\n else:\n print(\"That's wrong. \", end=\"\")\n print(f\"The correct answer was {correct_answer}...
[ "0.7174218", "0.7140115", "0.6744668", "0.662313", "0.659808", "0.6489284", "0.6437977", "0.6390512", "0.6330597", "0.63185096", "0.63103575", "0.62643456", "0.6169097", "0.61530346", "0.6133067", "0.60913175", "0.6076917", "0.6042778", "0.60328114", "0.60234153", "0.60234153...
0.7615992
0
Cuboid route. A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the opposite corner. By travelling on the surfaces of the room the shortest "straight line" distance from S to F is 10 and the path is shown on the diagram. ![](project/images/p086.gif) However, there are up to ...
def problem_086(limit,verbose): # Three routes: # *------F Sides labeled A, B, C, routes clockwise from S # | /| R1^2 = (A + C)^2 + B^2 # | / n R2^2 = (B + C)^2 + A^2 # +-----+------+-----F R3^2 = (A + B)^2 + C^2 # | | / | . `| ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_shortest_route_floyd(network, start,destination, excludings=[]):\n\n # On récupère la liste des villes\n list_city = network[1].keys()\n \n # Si la ville de départ ou de fin n'existe pas\n if start not in list_city or destination not in list_city:\n return None\n\n # On retire les villes à exclure...
[ "0.60230047", "0.572605", "0.568615", "0.56534576", "0.56427723", "0.5558263", "0.5554382", "0.5499549", "0.54854494", "0.5478313", "0.5477955", "0.547009", "0.54239124", "0.53992707", "0.53953576", "0.5393538", "0.53804255", "0.53707445", "0.5337153", "0.5330944", "0.5327894...
0.73762435
0
takes list of I3 OMKeys and I3 omgeo object and returns the positions of all hit DOMs.
def DOM_positions(omkeys, omgeo): x_list = [] y_list = [] z_list = [] r_list = [] for omkey in omkeys: x_list.append(omgeo[omkey].position.x) y_list.append(omgeo[omkey].position.y) z_list.append(omgeo[omkey].position.z) r_list.append(np.sqrt(omgeo[omkey].position.x**2...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTargetPositions(rg):\n targetPositions = OrderedDict()\n for r in rg.robotDict.values():\n x, y, z = r.metFiberPos\n targetPositions[r.id] = [x, y]\n return targetPositions", "def _pose_from_odom(self, odom): \n pose = odom.pose.pose.position\n return [p...
[ "0.5860236", "0.551378", "0.55034024", "0.5460928", "0.54038554", "0.5343139", "0.5251234", "0.5208269", "0.52062064", "0.51723003", "0.514916", "0.5143761", "0.51302123", "0.5128805", "0.5106739", "0.5091263", "0.508451", "0.5073758", "0.50681436", "0.5066503", "0.5037246", ...
0.76988184
0
Wait for a flag to be raised. Nonasyncio primitives are generally not our worry, but we support them for convenience.
async def wait_flag( flag: Optional[Flag], ) -> Any: if flag is None: return None elif isinstance(flag, asyncio.Future): return await flag elif isinstance(flag, asyncio.Event): return await flag.wait() elif isinstance(flag, concurrent.futures.Future): loop = async...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def raise_flag(\n flag: Optional[Flag],\n) -> None:\n if flag is None:\n return None\n elif isinstance(flag, asyncio.Future):\n flag.set_result(None)\n elif isinstance(flag, asyncio.Event):\n flag.set()\n elif isinstance(flag, concurrent.futures.Future):\n flag....
[ "0.713738", "0.6699332", "0.65952504", "0.65952504", "0.6502028", "0.64942116", "0.6449223", "0.64416105", "0.636671", "0.6330871", "0.62942857", "0.62816006", "0.6220285", "0.6209308", "0.6189142", "0.61727816", "0.6155536", "0.61540294", "0.6153748", "0.6128598", "0.6118138...
0.70962334
1
Raise a flag. Nonasyncio primitives are generally not our worry, but we support them for convenience.
async def raise_flag( flag: Optional[Flag], ) -> None: if flag is None: return None elif isinstance(flag, asyncio.Future): flag.set_result(None) elif isinstance(flag, asyncio.Event): flag.set() elif isinstance(flag, concurrent.futures.Future): flag.set_result(None...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flag():\n pass", "def test_handle_flag_error(self):\n pass", "def take_action_on_flags(self, *args, **kwargs):\r\n pass", "def check_flag(\n flag: Optional[Flag],\n) -> Optional[bool]:\n if flag is None:\n return None\n elif isinstance(flag, asyncio.Future):\n ...
[ "0.64379865", "0.6291809", "0.5789999", "0.5747449", "0.5700587", "0.5692241", "0.5669861", "0.5654849", "0.5612247", "0.5570142", "0.55194277", "0.5490948", "0.5454713", "0.54315066", "0.54022765", "0.54000425", "0.53945684", "0.53931487", "0.5376979", "0.53745085", "0.53550...
0.75605917
0
Normalize a URI (and return a string)
def normalize_uri(uri): return normalize_uri_result(uri).unsplit()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_uri(uri):\n if isinstance(uri, str):\n uri = uri.decode('utf-8')\n return uri.strip().replace(u' ', u'_')", "def _urlnorm(self, uri):\r\n (scheme, authority, path, query, fragment) = parse_uri(uri)\r\n if not scheme or not authority:\r\n raise Exception(\"Only ...
[ "0.8003105", "0.7775725", "0.7554363", "0.73275083", "0.7239493", "0.7188694", "0.70847034", "0.69223225", "0.6769839", "0.6718717", "0.661912", "0.6563927", "0.6532454", "0.6362552", "0.62949", "0.6290367", "0.6282449", "0.6190212", "0.6182322", "0.6176457", "0.6164549", "...
0.8340019
0
Normalize a URI (And return a URIResult)
def normalize_uri_result(uri): ref = uri_reference(uri).normalize() return ref._replace( authority=normalize_uri_authority(ref), query=normalize_uri_query(ref), path=normalize_uri_path(ref), )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_uri(uri):\n return normalize_uri_result(uri).unsplit()", "def _urlnorm(self, uri):\r\n (scheme, authority, path, query, fragment) = parse_uri(uri)\r\n if not scheme or not authority:\r\n raise Exception(\"Only absolute URIs are allowed. uri = %s\" % uri)\r\n autho...
[ "0.8090733", "0.76550364", "0.7136166", "0.7022947", "0.6984481", "0.6822511", "0.68086845", "0.6780735", "0.66093105", "0.6543287", "0.6404623", "0.63960683", "0.6173417", "0.6112646", "0.6043692", "0.6000578", "0.5998875", "0.59867203", "0.5972129", "0.58413917", "0.5839414...
0.81375635
0
function that calls the appropiate developed vtk writer to write the 3d vector field to the desired format. Inputs field Vector field which will be added to the vtk file numpy.array([x,y,z,u,v,w]) path path with name of file where the field will be written. VTKformat Desired VTK format from the developed.
def vF3d_VTK(field,name,VTKformat): if VTKformat == 'vtu': vf3d_vtu(field,name) elif VTKformat == None: print 'Please select a VTK format' else: print 'The selected format has not been developed yet' return #nothing, since functions output the written VTK file
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WriteVTK(self, filename=None, result=None, fmt=\"binary\", interpolation_degree=10, ProjectionFlags=None):\n\n self.__do_essential_memebers_exist__()\n\n if fmt == \"xml\":\n pass\n elif fmt == \"binary\":\n try:\n from pyevtk.hl import pointsToVTK, lin...
[ "0.714614", "0.71017635", "0.671099", "0.65398985", "0.6254326", "0.61986893", "0.6182938", "0.6051376", "0.5952164", "0.5940433", "0.59107643", "0.5909276", "0.58639026", "0.5827263", "0.5815102", "0.57894915", "0.5776451", "0.5746745", "0.5738138", "0.5691981", "0.5620056",...
0.8006676
0
Function that wtrites a .vtu file Inputs field Vector field which will be added to the vtk file numpy.array([x,y,z,u,v,w]) name Name of the .vtu field C.Losada de la Lastra 2015
def vf3d_vtu(field,name): [X,Y,Z,U,V,W] = field #3d velocity field #achieve the correct format Pnts = F3d_2_vtkFromat(N.array([X,Y,Z])) velF = F3d_2_vtkFromat(N.array([U,V,W])) #name the vtu file if name == None: vtu = 'vf3VTU.vtu' else: vtu = name + '.vtu' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vtp(self, f_vtu, f_vtp):\r\n reader = vtk.vtkXMLUnstructuredGridReader()\r\n reader.SetFileName(f_vtu)\r\n reader.Update()\r\n ugrid = reader.GetOutput()\r\n geometryFilter = vtk.vtkGeometryFilter()\r\n geometryFilter.SetInputData(ugrid)\r\n geometryFilter.Updat...
[ "0.75909907", "0.71495616", "0.6956499", "0.69028056", "0.5981677", "0.59470856", "0.5827962", "0.5824747", "0.57841843", "0.57806456", "0.5749297", "0.5723023", "0.55761325", "0.55515754", "0.5526952", "0.5523703", "0.55123943", "0.5507612", "0.5503049", "0.55005854", "0.547...
0.82499015
0
Function that turns a 3d field F3d in [Fx,Fy,Fz] format to a [[fx1,fy1,fz1], ... ,[fxn,fyn,fzn]] fomat Where FX is the zyx array corresponding to the x component of the field and fx1 is the x component of the field at the first point Inputs f3d field which will be converted by the function. C.Losada de la Lastra 2015
def F3d_2_vtkFromat(F3d): #asign variables [Fx,Fy,Fz] = F3d #generate the output array F3dVTK = N.array([N.zeros(3) for i in range(len(Fx)*len(Fy[0])*len(Fz[0][0]))]) #loop and rearange c=0 for k in range(len(Fz)): for j in range(len(Fz[0])): for i in range(len(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_3d_tranpose(): \n dic,data = ng.pipe.read_lowmem(\"common_data/3d_pipe/ft/test%03d.ft3\")\n fdic,fdata = ng.pipe.read(\"common_data/3d_pipe/ft/test%03d.ft3\")\n\n assert_array_equal(data.transpose()[0,1,2],fdata.transpose()[0,1,2])\n assert_array_equal(data.transpose((2,0,1))[0,1,2],\n ...
[ "0.6738585", "0.6631589", "0.6503169", "0.6495769", "0.6400366", "0.6348327", "0.62344724", "0.61679155", "0.61502033", "0.6063375", "0.60627055", "0.60346746", "0.598228", "0.5907918", "0.5868698", "0.584995", "0.58388567", "0.5815556", "0.58086735", "0.5725239", "0.5707815"...
0.7350591
0
This method saves a light curve to file.
def saveLightcurve(self, filename): lfile = open(filename, 'w') lfile.write("# time \t counts \t countrate \n") for t,c,cr in zip(self.time, self.counts, self.countrate): lfile.write(str(t) + "\t" + str(c) + "\t" + str(cr) + "\n") lfile.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, filename, overwrite=False, verbose=True, msg=''):\n if msg:\n msg = ' \"%s\"' % msg\n save_to_file(\n filename, self, overwrite=overwrite, verbose=verbose,\n showname='curve%s' % msg\n )", "def save(self, filename):\n with open(filename,...
[ "0.66553885", "0.6237099", "0.6189636", "0.6176335", "0.61510575", "0.6095389", "0.60930943", "0.6074219", "0.6071312", "0.60565275", "0.60470104", "0.6026951", "0.6022748", "0.6008713", "0.6005237", "0.5998112", "0.59923875", "0.5963575", "0.59631884", "0.5932931", "0.592020...
0.77671015
0
Test our own custom resource MyTestResource
def test_custom_resource(): data = { 'name': 'Wort wort', 'slug': 'sluggy', 'not_valid': 'nooo' } instance = PeopleResource(**data) # We should have this attribute assert hasattr(instance, 'name') # But this one is missing assert not hasattr(instance, 'another_thing')...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hypermedia_custom_resource():\n data = {\n 'name': 'Wort wort',\n 'slug': 'sluggy',\n 'not_valid': 'nooo',\n 'author': 'http://dev/api/authors/1'\n }\n instance = HypermediaBlogsResource(**data)\n assert hasattr(instance, 'get_authors')", "def test_get_api_resourc...
[ "0.7099405", "0.69632924", "0.6823595", "0.67922026", "0.6745148", "0.6694197", "0.66826195", "0.66318744", "0.65381837", "0.6506042", "0.64684325", "0.6439754", "0.64259404", "0.64126664", "0.64098823", "0.64051306", "0.6372424", "0.6321665", "0.6318653", "0.6314998", "0.631...
0.73522156
0
Test our custom Hypermedia resource loads correctly
def test_hypermedia_custom_resource(): data = { 'name': 'Wort wort', 'slug': 'sluggy', 'not_valid': 'nooo', 'author': 'http://dev/api/authors/1' } instance = HypermediaBlogsResource(**data) assert hasattr(instance, 'get_authors')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hypermedia_custom_resource_calling():\n responses.add(responses.GET, 'http://dev/api/authors/1',\n body='''\n {\"id\": \"1\", \"title\": \"blog title\",\n \"slug\": \"blog-title\",\n \"content\": \"This is some content\"}''',\n...
[ "0.69919366", "0.67214113", "0.6403555", "0.63620067", "0.6223368", "0.62137026", "0.6199328", "0.61439323", "0.6122087", "0.6088148", "0.59429365", "0.58977795", "0.58845276", "0.58641833", "0.5859203", "0.5820547", "0.5812688", "0.5810999", "0.58021426", "0.57535756", "0.57...
0.7485284
0
Test our custom Hypermedia resource handles URls that aren't registered.
def test_hypermedia_custom_resource_non_registered_urls(): data = { 'name': 'Wort wort', 'slug': 'sluggy', 'not_valid': 'nooo', # This should not appear! 'author': 'http://dev/api/foobar/1' } instance = HypermediaBlogsResource(**data) assert not hasattr(instance, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hypermedia_custom_resource():\n data = {\n 'name': 'Wort wort',\n 'slug': 'sluggy',\n 'not_valid': 'nooo',\n 'author': 'http://dev/api/authors/1'\n }\n instance = HypermediaBlogsResource(**data)\n assert hasattr(instance, 'get_authors')", "def test_dynamic_url(sel...
[ "0.7026299", "0.6746552", "0.6544264", "0.6300041", "0.6172381", "0.6109873", "0.5962861", "0.5946122", "0.59105587", "0.5873638", "0.58107054", "0.5787485", "0.5779619", "0.574595", "0.57324624", "0.57148445", "0.57081646", "0.57043415", "0.5655195", "0.56529117", "0.5642978...
0.769136
0
Test our custom Hypermedia resource make HTTP calls correctly
def test_hypermedia_custom_resource_calling(): responses.add(responses.GET, 'http://dev/api/authors/1', body=''' {"id": "1", "title": "blog title", "slug": "blog-title", "content": "This is some content"}''', status=20...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hypermedia_custom_resource():\n data = {\n 'name': 'Wort wort',\n 'slug': 'sluggy',\n 'not_valid': 'nooo',\n 'author': 'http://dev/api/authors/1'\n }\n instance = HypermediaBlogsResource(**data)\n assert hasattr(instance, 'get_authors')", "def test_get_api_resourc...
[ "0.73699474", "0.66059434", "0.65756327", "0.6351938", "0.6295698", "0.62716556", "0.6269212", "0.6264619", "0.6243846", "0.62275785", "0.622343", "0.622343", "0.6218943", "0.6218943", "0.6214484", "0.62131256", "0.62051314", "0.62051314", "0.6198172", "0.61512727", "0.614496...
0.75206643
0
Get locations using lat and long
def location_search(self, lat: float, lng: float) -> List[Location]: params = { "latitude": lat, "longitude": lng, # rankToken=c544eea5-726b-4091-a916-a71a35a76474 - self.uuid? # fb_access_token=EAABwzLixnjYBABK2YBFkT...pKrjju4cijEGYtcbIyCSJ0j4ZD } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_locations(self):", "def get_locations_by_ids(self, id_list):", "def location(self):\n return [self.lat, self.lon]", "def getAllLocation(table):\n\tlocs = []\n\n\tnum = len(table)\n\n\tfor i in range(num):\n\t\t# first field is the name\n\t\tloc = getLatAndLong(table[i][1])\n\n\t\tlocs.appe...
[ "0.7693293", "0.69700223", "0.6944842", "0.691839", "0.6822767", "0.68080145", "0.6780214", "0.67701066", "0.66917574", "0.66531813", "0.6612624", "0.6600952", "0.65849495", "0.65463954", "0.6545853", "0.65342355", "0.65268636", "0.6523105", "0.6491054", "0.6483377", "0.64800...
0.700629
1
Get a location using location pk
def location_info(self, location_pk: int) -> Location: try: location = self.location_info_a1(location_pk) except Exception: # Users do not understand the output of such information and create bug reports # such this - https://github.com/adw0rd/instagrapi/issues/364 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_location_by_id(self, location_id):", "def location_info_a1(self, location_pk: int) -> Location:\n try:\n data = self.public_a1_request(f\"/explore/locations/{location_pk}/\") or {}\n if not data.get(\"location\"):\n raise LocationNotFound(location_pk=location_p...
[ "0.83056635", "0.7161645", "0.6997164", "0.69892573", "0.6985856", "0.677929", "0.6764449", "0.6575493", "0.6507015", "0.65019083", "0.64922875", "0.64857066", "0.647148", "0.6378939", "0.62978673", "0.6285275", "0.62745583", "0.62498385", "0.62312996", "0.62029284", "0.61890...
0.7304978
1
Get chunk of medias for a location and max_id (cursor) by Private Mobile API
def location_medias_v1_chunk( self, location_pk: int, max_amount: int = 63, tab_key: str = "", max_id: str = None ) -> Tuple[List[Media], str]: assert tab_key in tab_keys_v1, f'You must specify one of the options for "tab_key" {tab_keys_a1}' data = { "_uuid": self.uuid, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_medias_a1_chunk(\n self, location_pk: int, max_amount: int = 24, sleep: float = 0.5, tab_key: str = \"\", max_id: str = None\n ) -> Tuple[List[Media], str]:\n assert tab_key in tab_keys_a1, f'You must specify one of the options for \"tab_key\" {tab_keys_a1}'\n unique_set = set(...
[ "0.70108753", "0.63211", "0.63043183", "0.6049421", "0.60285205", "0.60012764", "0.5798298", "0.56838083", "0.56336576", "0.55293196", "0.5483364", "0.5474531", "0.5469164", "0.5460453", "0.5391193", "0.536255", "0.53242964", "0.52727276", "0.52701753", "0.52579296", "0.52343...
0.7332647
0
Get medias for a location by Private Mobile API
def location_medias_v1( self, location_pk: int, amount: int = 63, tab_key: str = "" ) -> List[Media]: assert tab_key in tab_keys_v1, f'You must specify one of the options for "tab_key" {tab_keys_a1}' medias, _ = self.location_medias_v1_chunk(location_pk, amount, tab_key) if amount: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_media_v1(data):\n user = data[\"user\"]\n location = data.get(\"location\")\n if location:\n location = {\"pk\": int(location.get(\"pk\")), \"name\": location.get(\"name\")}\n video_url = \"\"\n if \"video_versions\" in data:\n # Select Best Quality by Resolutiuon\n ...
[ "0.60846806", "0.6021909", "0.59943146", "0.59915215", "0.5962074", "0.58977944", "0.5883239", "0.58768684", "0.58633447", "0.57226473", "0.5711756", "0.57047063", "0.56527084", "0.56228065", "0.55975425", "0.5571243", "0.5548932", "0.5502735", "0.53844947", "0.5370486", "0.5...
0.6176584
0
Get top medias for a location
def location_medias_top_v1( self, location_pk: int, amount: int = 21 ) -> List[Media]: return self.location_medias_v1(location_pk, amount, tab_key="ranked")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_medias_top(\n self, location_pk: int, amount: int = 27, sleep: float = 0.5\n ) -> List[Media]:\n try:\n return self.location_medias_top_a1(location_pk, amount, sleep)\n except Exception:\n # Users do not understand the output of such information and create...
[ "0.73138505", "0.6768053", "0.64170605", "0.626123", "0.5953661", "0.59084255", "0.58888716", "0.5817105", "0.5762804", "0.5730623", "0.57086635", "0.567145", "0.5601399", "0.5582982", "0.5582004", "0.55758744", "0.55658376", "0.55639356", "0.5559017", "0.55489486", "0.554510...
0.7716615
0
Get top medias for a location
def location_medias_top( self, location_pk: int, amount: int = 27, sleep: float = 0.5 ) -> List[Media]: try: return self.location_medias_top_a1(location_pk, amount, sleep) except Exception: # Users do not understand the output of such information and create bug report...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_medias_top_v1(\n self, location_pk: int, amount: int = 21\n ) -> List[Media]:\n return self.location_medias_v1(location_pk, amount, tab_key=\"ranked\")", "def location_medias_top_a1(\n self, location_pk: int, amount: int = 9, sleep: float = 0.5\n ) -> List[Media]:\n ...
[ "0.7716615", "0.6768053", "0.64170605", "0.626123", "0.5953661", "0.59084255", "0.58888716", "0.5817105", "0.5762804", "0.5730623", "0.57086635", "0.567145", "0.5601399", "0.5582982", "0.5582004", "0.55758744", "0.55658376", "0.55639356", "0.5559017", "0.55489486", "0.5545102...
0.73138505
1
Get recent medias for a location
def location_medias_recent_v1( self, location_pk: int, amount: int = 63 ) -> List[Media]: return self.location_medias_v1(location_pk, amount, tab_key="recent")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_medias_recent(\n self, location_pk: int, amount: int = 63, sleep: float = 0.5\n ) -> List[Media]:\n try:\n return self.location_medias_recent_a1(location_pk, amount, sleep)\n except Exception:\n # Users do not understand the output of such information and ...
[ "0.75493115", "0.70259583", "0.66915876", "0.64781964", "0.64781964", "0.64781964", "0.64781964", "0.6418566", "0.63502306", "0.6196454", "0.60770035", "0.5754988", "0.5667978", "0.5654277", "0.5646014", "0.55817765", "0.55670434", "0.55425507", "0.5542447", "0.55188864", "0....
0.78062093
0
Get recent medias for a location
def location_medias_recent( self, location_pk: int, amount: int = 63, sleep: float = 0.5 ) -> List[Media]: try: return self.location_medias_recent_a1(location_pk, amount, sleep) except Exception: # Users do not understand the output of such information and create bug ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_medias_recent_v1(\n self, location_pk: int, amount: int = 63\n ) -> List[Media]:\n return self.location_medias_v1(location_pk, amount, tab_key=\"recent\")", "def location_medias_recent_a1(\n self, location_pk: int, amount: int = 24, sleep: float = 0.5\n ) -> List[Media]:\n...
[ "0.78062093", "0.70259583", "0.66915876", "0.64781964", "0.64781964", "0.64781964", "0.64781964", "0.6418566", "0.63502306", "0.6196454", "0.60770035", "0.5754988", "0.5667978", "0.5654277", "0.5646014", "0.55817765", "0.55670434", "0.55425507", "0.5542447", "0.55188864", "0....
0.75493115
1
Launch the migration of a snapshot_name between 2 GlanceConnection regions in "streaming" mode If there are multiple the first one is taken
def migration(glance_source: GlanceConnection, glance_destination: GlanceConnection, snapshot_name_source: str, snapshot_name_destination: str, disk_format: str = "qcow2", container_format: str = "bare"): try: snapshot_uuid = get_snapshot_id_from_glance(glance_source, snapshot_name_source)[0] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migration_from_uuid(glance_source: GlanceConnection, glance_destination: GlanceConnection, snapshot_uuid: str,\n snapshot_name_destination: str, disk_format: str = \"qcow2\", container_format: str = \"bare\"):\n data = glance_source.connection.images.data(snapshot_uuid)\n pipe_file...
[ "0.6142792", "0.51603115", "0.51394206", "0.5022961", "0.49740535", "0.4968728", "0.4930513", "0.48875204", "0.48781464", "0.48741278", "0.48728433", "0.48384938", "0.48132", "0.48130515", "0.4798763", "0.47868022", "0.47747865", "0.4774409", "0.47589558", "0.4724463", "0.470...
0.6501979
0
Launch the migration of a snapshot_uuid between 2 GlanceConnection regions in "streaming" mode
def migration_from_uuid(glance_source: GlanceConnection, glance_destination: GlanceConnection, snapshot_uuid: str, snapshot_name_destination: str, disk_format: str = "qcow2", container_format: str = "bare"): data = glance_source.connection.images.data(snapshot_uuid) pipe_filename = Named...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migration(glance_source: GlanceConnection, glance_destination: GlanceConnection, snapshot_name_source: str,\n snapshot_name_destination: str, disk_format: str = \"qcow2\", container_format: str = \"bare\"):\n try:\n snapshot_uuid = get_snapshot_id_from_glance(glance_source, snapshot_name...
[ "0.62980413", "0.5216754", "0.52088845", "0.516482", "0.5022145", "0.49795946", "0.49775237", "0.49621928", "0.4918967", "0.4908141", "0.49032316", "0.48849428", "0.48745793", "0.48508608", "0.48393834", "0.48219466", "0.4815208", "0.47957528", "0.4794768", "0.47914645", "0.4...
0.6356415
0
Configure nginx, will trigger letsencrypt setup if required
def setup(): print(cyan('Configuring nginx on {}'.format(env.stage))) context = { 'ssl_letsencrypt': False, 'ssl_with_dhparam': False, 'ssl_cert': None, 'ssl_key': None, } if ctx('ssl.letsencrypt'): execute('letsencrypt.setup') elif ctx('ssl.key') and ctx('ss...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _config_nginx():\n if exists('/etc/nginx/sites-available/', use_sudo=False, verbose=False):\n print \"/etc/nginx/sites-available/ exists.\"\n put(os.path.join(env.local_directory, 'installer/simple_nginx_config'),\n '/etc/nginx/sites-available/default',\n use_sudo=True)\n...
[ "0.7212168", "0.7072643", "0.7053726", "0.6985131", "0.6912044", "0.68899894", "0.66487527", "0.65693736", "0.63348484", "0.6326479", "0.6257689", "0.6225147", "0.6212336", "0.60368735", "0.60256183", "0.5994347", "0.5948586", "0.5932281", "0.5884251", "0.58800805", "0.573583...
0.8036818
0
r""" Convert a list of lists into a DomainMatrix
def from_list(cls, rows, domain): nrows = len(rows) ncols = 0 if not nrows else len(rows[0]) conv = lambda e: domain(*e) if isinstance(e, tuple) else domain(e) domain_rows = [[conv(e) for e in row] for row in rows] return DomainMatrix(domain_rows, (nrows, ncols), domain)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def domatrixlist(inputlist, converter=proper):\n try:\n out = matrixlist(inputlist, converter)\n except:\n out = diagmatrixlist(inputlist, converter, domatrixlist)\n return out", "def DM(rows, domain):\n return DomainMatrix.from_list(rows, domain)", "def from_list_sympy(cls, nrows, nc...
[ "0.7477176", "0.7102854", "0.68626946", "0.6615472", "0.6396233", "0.62091166", "0.6160422", "0.6096409", "0.60517025", "0.6009054", "0.59535986", "0.5722408", "0.5716044", "0.5699461", "0.5686774", "0.56815535", "0.5672685", "0.5664568", "0.5634094", "0.5592686", "0.5586439"...
0.76817507
0
r""" Convert a list of lists of Expr into a DomainMatrix using construct_domain
def from_list_sympy(cls, nrows, ncols, rows, **kwargs): assert len(rows) == nrows assert all(len(row) == ncols for row in rows) items_sympy = [_sympify(item) for row in rows for item in row] domain, items_domain = cls.get_domain(items_sympy, **kwargs) domain_rows = [[items_dom...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_list(cls, rows, domain):\n nrows = len(rows)\n ncols = 0 if not nrows else len(rows[0])\n conv = lambda e: domain(*e) if isinstance(e, tuple) else domain(e)\n domain_rows = [[conv(e) for e in row] for row in rows]\n return DomainMatrix(domain_rows, (nrows, ncols), domain...
[ "0.7331906", "0.6706776", "0.6649751", "0.623576", "0.58796453", "0.5805989", "0.5466958", "0.54488945", "0.5355919", "0.5248747", "0.52375877", "0.5225369", "0.5224157", "0.51642734", "0.51350445", "0.5039469", "0.50125533", "0.5010558", "0.50013816", "0.4974261", "0.4973041...
0.7045915
1
r""" Returns a DomainMatrix with the appropriate field Returns ======= DomainMatrix DomainMatrix with the appropriate field Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DomainMatrix >>> A = DomainMatrix([ ... [ZZ(1), ZZ(2)], ... [ZZ(3), ZZ(4)]], (2, 2), ZZ) >>> A.to_field() DomainMatr...
def to_field(self): K = self.domain.get_field() return self.convert_to(K)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(self, domain):\n if domain == self.domain:\n return self.copy()\n elif domain == QQ and self.domain == ZZ:\n return self._new(flint.fmpq_mat(self.rep), self.shape, domain)\n elif domain == ZZ and self.domain == QQ:\n # XXX: python-flint has no fm...
[ "0.654172", "0.59655744", "0.5609826", "0.5518392", "0.55056614", "0.5493476", "0.54892707", "0.5365185", "0.53639084", "0.53302854", "0.5323675", "0.5316416", "0.5244148", "0.5231605", "0.52191514", "0.5202957", "0.5192652", "0.5187106", "0.51852727", "0.51494503", "0.513885...
0.62886566
1
Return a sparse DomainMatrix representation of self. Examples ======== >>> from sympy.polys.matrices import DomainMatrix >>> from sympy import QQ >>> A = DomainMatrix([[1, 0],[0, 2]], (2, 2), QQ) >>> A.rep [[1, 0], [0, 2]] >>> B = A.to_sparse() >>> B.rep
def to_sparse(self): if self.rep.fmt == 'sparse': return self return self.from_rep(self.rep.to_sdm())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_sparse(self):\n from divisi2.sparse import SparseMatrix\n return SparseMatrix(self, self.row_labels, self.col_labels)", "def to_Matrix(self):\n from sympy.matrices.dense import MutableDenseMatrix\n\n # XXX: If the internal representation of RepMatrix changes then this\n ...
[ "0.773887", "0.71733475", "0.6989664", "0.6939269", "0.6760598", "0.67543876", "0.6695928", "0.6680763", "0.66618556", "0.6660773", "0.6614343", "0.6555552", "0.64918286", "0.64784425", "0.64010775", "0.6375867", "0.6369247", "0.6367626", "0.6307377", "0.6302117", "0.6245039"...
0.8199418
0
Convert matrices to a common domain
def _unify_domain(cls, *matrices): domains = {matrix.domain for matrix in matrices} if len(domains) == 1: return matrices domain = reduce(lambda x, y: x.unify(y), domains) return tuple(matrix.convert_to(domain) for matrix in matrices)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def n2m(a):\n if not isinstance(a, np.ndarray): a = np.array(a)\n return multiprocessing.Array(a.dtype.char, a.flat, lock=False), tuple(a.shape), a.dtype.char, isinstance(a, np.matrix)", "def as_matrix(self) -> types.Matrix:", "def transform(self, x: Array2D) -> Array2D:", "def Matrix(arg0: List[List[com...
[ "0.6050297", "0.58851284", "0.5787925", "0.57617325", "0.56027615", "0.5584364", "0.5584364", "0.550137", "0.54972297", "0.5492538", "0.5490235", "0.54851127", "0.54707414", "0.54674196", "0.5372236", "0.5366143", "0.53611535", "0.53374946", "0.53374946", "0.5321904", "0.5320...
0.6222233
0
Convert matrices to the same format. If all matrices have the same format, then return unmodified. Otherwise convert both to the preferred format given as fmt which should be 'dense' or 'sparse'.
def _unify_fmt(cls, *matrices, fmt=None): formats = {matrix.rep.fmt for matrix in matrices} if len(formats) == 1: return matrices if fmt == 'sparse': return tuple(matrix.to_sparse() for matrix in matrices) elif fmt == 'dense': return tuple(matrix.to_de...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_format_matrix(self):\r\n a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\r\n row_labels = ['a', 'b', 'c']\r\n col_labels = [11, 22, 33]\r\n res = format_matrix(a, row_labels, col_labels)\r\n\r\n # test as list\r\n self.assertEqual(res,\r\n '\\t11\\t2...
[ "0.5688755", "0.55641603", "0.5437844", "0.5273598", "0.5039462", "0.49345073", "0.4920986", "0.49205166", "0.4854351", "0.47913963", "0.47909403", "0.47875938", "0.47787914", "0.47590226", "0.47499767", "0.47490776", "0.47445568", "0.47435653", "0.47385564", "0.47177893", "0...
0.7839384
0
Unifies the domains and the format of self and other matrices.
def unify(self, *others, fmt=None): matrices = (self,) + others matrices = DomainMatrix._unify_domain(*matrices) if fmt is not None: matrices = DomainMatrix._unify_fmt(*matrices, fmt=fmt) return matrices
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _unify_domain(cls, *matrices):\n domains = {matrix.domain for matrix in matrices}\n if len(domains) == 1:\n return matrices\n domain = reduce(lambda x, y: x.unify(y), domains)\n return tuple(matrix.convert_to(domain) for matrix in matrices)", "def Build(self, *args):\n ...
[ "0.63653666", "0.56634635", "0.5425807", "0.5365408", "0.5364738", "0.52989185", "0.526087", "0.5245564", "0.52374184", "0.5214996", "0.51645786", "0.51645786", "0.51625097", "0.5155141", "0.5134394", "0.5121414", "0.50976896", "0.50852925", "0.5025268", "0.501285", "0.500603...
0.6752345
0
r""" Convert DomainMatrix to Matrix Returns ======= Matrix MutableDenseMatrix for the DomainMatrix Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DomainMatrix >>> A = DomainMatrix([ ... [ZZ(1), ZZ(2)], ... [ZZ(3), ZZ(4)]], (2, 2), ZZ) >>> A.to_Matrix() Matrix([ [1, 2], [3, 4]]) See Also...
def to_Matrix(self): from sympy.matrices.dense import MutableDenseMatrix # XXX: If the internal representation of RepMatrix changes then this # might need to be changed also. if self.domain in (ZZ, QQ, EXRAW): if self.rep.fmt == "sparse": rep = self.copy() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_matrix(self): \n warnings.warn(f'{self} is being reconstructed into a matrix, consider operating on the decomposed form.')\n\n full = self.to_tensor()\n if self.n_matrices == ():\n return full.reshape(self.shape)\n else:\n return full.reshape(self.n_matrices...
[ "0.6727682", "0.66324234", "0.65958303", "0.6578293", "0.648405", "0.640233", "0.6331582", "0.6326066", "0.63073564", "0.6304777", "0.6302886", "0.6267597", "0.62278646", "0.61793214", "0.6177461", "0.6171702", "0.6171702", "0.6140751", "0.60431266", "0.601863", "0.60088795",...
0.7535301
0
Number of nonzero elements in the matrix. Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DM >>> A = DM([[1, 0], [0, 4]], ZZ) >>> A.nnz() 2
def nnz(self): return self.rep.nnz()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nnz(self):\n return self.to_ddm().nnz()", "def count_nonzero(tensor):\n raise NotImplementedError", "def count_nonzero(a):\n return (np.count_nonzero(a))", "def nnz(self):\n return len(self.data)", "def nnz(self):\n return len(self.value)", "def nnz(self):\n t = ...
[ "0.74422866", "0.69477165", "0.6806065", "0.6780774", "0.66739684", "0.65954864", "0.6497761", "0.641912", "0.63083607", "0.62465894", "0.62337273", "0.6192942", "0.6156127", "0.6117958", "0.60830486", "0.60629547", "0.5982373", "0.59793246", "0.59689945", "0.5955463", "0.595...
0.7394802
1
True if the matrix is diagonal. Can return true for nonsquare matrices. A matrix is diagonal if ``M[i,j] == 0`` whenever ``i != j``. Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DM >>> M = DM([[ZZ(1), ZZ(0)], [ZZ(0), ZZ(1)]], ZZ) >>> M.is_diagonal True See Also ======== is_upper is_lo...
def is_diagonal(self): return self.rep.is_diagonal()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isDiag(matrix):\n if np.isscalar(matrix) == True:\n return True\n elif type(matrix) is np.ndarray:\n if matrix.size == 1:\n return True\n elif np.count_nonzero(matrix - np.diag(np.diagonal(matrix))) == 0:\n return True\n else:\n return False\n ...
[ "0.7821849", "0.74941677", "0.74941677", "0.7441418", "0.7399577", "0.7367698", "0.73122686", "0.7057577", "0.7038562", "0.6748433", "0.6681966", "0.66680706", "0.66487104", "0.65727955", "0.6539708", "0.6457882", "0.64341956", "0.63791597", "0.62553805", "0.61958116", "0.617...
0.80671704
0
r"""Vertically stack the given matrices.
def vstack(A, *B): A, *B = A.unify(*B, fmt='dense') return DomainMatrix.from_rep(A.rep.vstack(*(Bk.rep for Bk in B)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stack(arrays, axis=0):\n raise NotImplementedError", "def vstack (tup ):\n\tl = len(tup[0])\n\tfor j in tup:\n\t\tif l!=len(j):\n\t\t\tprint \"error: dimensions don't match\"\n\t\t\treturn\n\tm = [];\n\tfor i in range(0,len(tup)):\n\t\tm.extend(zip(*tup[i]))\n\treturn zip(*m)", "def stack(arrs):\n\t...
[ "0.69222486", "0.62555104", "0.6102974", "0.606556", "0.59465873", "0.5939654", "0.58420026", "0.58351564", "0.58304244", "0.5670199", "0.566801", "0.5661688", "0.5656089", "0.56493187", "0.5616049", "0.5572585", "0.55671245", "0.55447096", "0.5520591", "0.5329278", "0.529381...
0.6296938
1
Compute the strongly connected components of a DomainMatrix Explanation =========== A square matrix can be considered as the adjacency matrix for a directed graph where the row and column indices are the vertices. In this graph if there is an edge from vertex ``i`` to vertex ``j`` if ``M[i, j]`` is nonzero. This routin...
def scc(self): if not self.is_square: raise DMNonSquareMatrixError('Matrix must be square for scc') return self.rep.scc()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strongly_connected_components(self):\n for node in self.graph:\n node.data.visited = False\n\n reverse_graph = self.reverse_graph()\n dfs_reverse_graph = DFS(reverse_graph.graph, generate_stack=True)\n dfs_reverse_graph.search()\n\n dfs_graph = DFS(self.graph, gene...
[ "0.5773663", "0.5618062", "0.55254614", "0.5449575", "0.5427485", "0.5381283", "0.53752255", "0.5343555", "0.53430593", "0.5320317", "0.52844644", "0.5275002", "0.52626216", "0.5261858", "0.5256358", "0.5253071", "0.5242483", "0.52411467", "0.52251196", "0.52184653", "0.52177...
0.61194855
0
Clear denominators, but keep the domain unchanged. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DM >>> A = DM([[(1,2), (1,3)], [(1,4), (1,5)]], QQ) >>> den, Anum = A.clear_denoms() >>> den.to_sympy() 60 >>> Anum.to_Matrix() Matrix([ [30, 20], [15, 12]]) >>> den A == Anum True The nume...
def clear_denoms(self, convert=False): elems0, data = self.to_flat_nz() K0 = self.domain K1 = K0.get_ring() if K0.has_assoc_Ring else K0 den, elems1 = dup_clear_denoms(elems0, K0, K1, convert=convert) if convert: Kden, Knum = K1, K1 else: Kden, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_denoms(f, convert=False):\n coeff, F = dmp_clear_denoms(f.rep, f.lev, f.dom, convert=convert)\n return coeff, f.per(F)", "def cancel_denom_elementwise(self, denom):\n K = self.domain\n M = self\n\n if K.is_zero(denom):\n raise ZeroDivisionError('denominator...
[ "0.57165486", "0.56645495", "0.5092446", "0.50069594", "0.493177", "0.49076656", "0.48613152", "0.4821023", "0.48004925", "0.47065172", "0.4687576", "0.4655348", "0.46409845", "0.46408403", "0.46321458", "0.46204683", "0.46165955", "0.45896116", "0.45622888", "0.45622888", "0...
0.66879064
0
Cancel factors between a matrix and a denominator. Returns a matrix and denominator on lowest terms. Requires ``gcd`` in the ground domain.
def cancel_denom(self, denom): M = self K = self.domain if K.is_zero(denom): raise ZeroDivisionError('denominator is zero') elif K.is_one(denom): return (M.copy(), denom) elements, data = M.to_flat_nz() # First canonicalize the denominator (e.g....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel_denom_elementwise(self, denom):\n K = self.domain\n M = self\n\n if K.is_zero(denom):\n raise ZeroDivisionError('denominator is zero')\n elif K.is_one(denom):\n M_numers = M.copy()\n M_denoms = M.ones(M.shape, M.domain)\n return (M_...
[ "0.5360136", "0.5269914", "0.5034444", "0.4850583", "0.48092243", "0.4807565", "0.4784231", "0.4743124", "0.47368827", "0.47209173", "0.47209173", "0.47035033", "0.46711946", "0.46532744", "0.46474", "0.4645103", "0.46407905", "0.46407604", "0.46176478", "0.45880303", "0.4557...
0.53664905
0
Cancel factors between the elements of a matrix and a denominator. Returns a matrix of numerators and matrix of denominators. Requires ``gcd`` in the ground domain. Examples ======== >>> from sympy.polys.matrices import DM >>> from sympy import ZZ >>> M = DM([[2, 3], [4, 12]], ZZ) >>> denom = ZZ(6) >>> numers, denoms =...
def cancel_denom_elementwise(self, denom): K = self.domain M = self if K.is_zero(denom): raise ZeroDivisionError('denominator is zero') elif K.is_one(denom): M_numers = M.copy() M_denoms = M.ones(M.shape, M.domain) return (M_numers, M_deno...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel_denom(self, denom):\n M = self\n K = self.domain\n\n if K.is_zero(denom):\n raise ZeroDivisionError('denominator is zero')\n elif K.is_one(denom):\n return (M.copy(), denom)\n\n elements, data = M.to_flat_nz()\n\n # First canonicalize the d...
[ "0.6634346", "0.5153074", "0.5128968", "0.5110255", "0.50896513", "0.5068658", "0.5046499", "0.50334495", "0.499617", "0.4993697", "0.49848732", "0.4969663", "0.49391907", "0.49382338", "0.49351898", "0.4918057", "0.49062005", "0.4899771", "0.48944438", "0.4885724", "0.487889...
0.7187386
0
r""" Returns the columnspace for the DomainMatrix Returns ======= DomainMatrix The columns of this matrix form a basis for the columnspace. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DomainMatrix >>> A = DomainMatrix([ ... [QQ(1), QQ(1)], ... [QQ(2), QQ(2)]], (2, 2), QQ) >>> A.colum...
def columnspace(self): if not self.domain.is_Field: raise DMNotAField('Not a field') rref, pivots = self.rref() rows, cols = self.shape return self.extract(range(rows), pivots)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def columnspace(M):\r\n v = orth(M)\r\n if (v.size == 0):\r\n return [np.zeros((M.shape[0],), dtype = int)]\r\n else:\r\n return v", "def _columnspace(M, simplify=False):\n\n reduced, pivots = M.echelon_form(simplify=simplify, with_pivots=True)\n\n return [M.col(i) for i in pivots]",...
[ "0.6642107", "0.60450304", "0.5669563", "0.5318385", "0.527138", "0.52638054", "0.5259681", "0.51557624", "0.51550597", "0.5136678", "0.5130931", "0.51126313", "0.50991285", "0.50743514", "0.5053361", "0.49423632", "0.49329153", "0.4902838", "0.48968655", "0.48773718", "0.487...
0.74377894
0
r""" Returns the rowspace for the DomainMatrix Returns ======= DomainMatrix The rows of this matrix form a basis for the rowspace. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DomainMatrix >>> A = DomainMatrix([ ... [QQ(1), QQ(1)], ... [QQ(2), QQ(2)]], (2, 2), QQ) >>> A.rowspace() Dom...
def rowspace(self): if not self.domain.is_Field: raise DMNotAField('Not a field') rref, pivots = self.rref() rows, cols = self.shape return self.extract(range(len(pivots)), range(cols))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rowspace(M, simplify=False):\n\n reduced, pivots = M.echelon_form(simplify=simplify, with_pivots=True)\n\n return [reduced.row(i) for i in range(len(pivots))]", "def Stirling1Matrix(dim):\r\n mat_space = MatrixSpace(CombinatorialScalarRing(),dim)\r\n l = list()\r\n for row in range(dim):\r\n ...
[ "0.5999986", "0.5500946", "0.5488759", "0.54061383", "0.53065866", "0.52507466", "0.5217611", "0.50644505", "0.5057237", "0.5050929", "0.5002036", "0.4987382", "0.49678788", "0.49395669", "0.49148446", "0.49129105", "0.49105978", "0.488222", "0.48811316", "0.48679706", "0.486...
0.7128956
0
r""" Returns the nullspace for the DomainMatrix Returns ======= DomainMatrix The rows of this matrix form a basis for the nullspace. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DM >>> A = DM([ ... [QQ(2), QQ(2)], ... [QQ(4), QQ(4)]], QQ) >>> A.nullspace() DomainMatrix([[1, 1]], (1, 2...
def nullspace(self, divide_last=False): A = self K = A.domain if divide_last and not K.is_Field: raise DMNotAField("Cannot normalize vectors over a non-field") if divide_last: A_rref, pivots = A.rref() else: A_rref, den, pivots = A.rref_den()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nullspace(self):\n # Code to compute nullspace using flint:\n #\n # V, nullity = self.rep.nullspace()\n # V_dfm = self._new_rep(V)._extract(range(self.rows), range(nullity))\n #\n # XXX: That gives the nullspace but does not give us nonpivots. So we\n # use the ...
[ "0.80473316", "0.64684784", "0.63527936", "0.620114", "0.5996723", "0.59096587", "0.5821271", "0.5791384", "0.57375884", "0.5592651", "0.55815107", "0.5562849", "0.55237114", "0.54635066", "0.54175854", "0.5413706", "0.5359096", "0.5325589", "0.5289732", "0.5281692", "0.52815...
0.6578458
1
Compute nullspace from rref and pivots. The domain of the matrix can be any domain. The matrix must be in reduced row echelon form already. Otherwise the
def nullspace_from_rref(self, pivots=None): null_rep, nonpivots = self.rep.nullspace_from_rref(pivots) return self.from_rep(null_rep)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nullspace_from_rref(self, pivots=None):\n # XXX: Use the flint nullspace method!!!\n sdm, nonpivots = self.to_sdm().nullspace_from_rref(pivots=pivots)\n return sdm.to_dfm(), nonpivots", "def nullspace(self):\n # Code to compute nullspace using flint:\n #\n # V, nulli...
[ "0.7357059", "0.6713441", "0.6405145", "0.6264603", "0.6065511", "0.5765782", "0.5728473", "0.57128084", "0.5668827", "0.56666315", "0.54693246", "0.5296893", "0.5260158", "0.524423", "0.52058345", "0.51957077", "0.5162076", "0.512621", "0.50536263", "0.5053464", "0.505206", ...
0.7388375
0
Solve matrix equation $Ax = b$ using fractionfree RREF Solves the matrix equation $Ax = b$ for $x$ and returns the solution as a numerator/denominator pair. Examples ======== >>> from sympy import ZZ >>> from sympy.polys.matrices import DM >>> A = DM([[ZZ(1), ZZ(2)], [ZZ(3), ZZ(4)]], ZZ) >>> b = DM([[ZZ(5)], [ZZ(6)]], ...
def solve_den_rref(self, b): A = self m, n = A.shape bm, bn = b.shape if m != bm: raise DMShapeError("Matrix equation shape mismatch.") if m < n: raise DMShapeError("Underdetermined matrix equation.") Aaug = A.hstack(b) Aaug_rref, denom,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve_den(self, b, method=None):\n m, n = self.shape\n bm, bn = b.shape\n\n if m != bm:\n raise DMShapeError(\"Matrix equation shape mismatch.\")\n\n if method is None:\n method = 'rref'\n elif method == 'charpoly' and m != n:\n raise DMNonSqu...
[ "0.6817579", "0.58376867", "0.5703249", "0.5505278", "0.5307997", "0.530061", "0.52751744", "0.52162683", "0.51056904", "0.5076569", "0.50505364", "0.50239944", "0.50141716", "0.498415", "0.49598092", "0.4950483", "0.48954886", "0.48951635", "0.48919958", "0.4873103", "0.4849...
0.744948
0
Return the polynomial $p$ such that $p(A) = adj(A)$ and also the determinant of $A$. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DM >>> A = DM([[QQ(1), QQ(2)], [QQ(3), QQ(4)]], QQ) >>> p, detA = A.adj_poly_det() >>> p [1, 5] >>> p_A = A.eval_poly(p) >>> p_A DomainMatrix([[4, 2], [3, ...
def adj_poly_det(self, cp=None): # Cayley-Hamilton says that a matrix satisfies its own minimal # polynomial # # p[0]*A^n + p[1]*A^(n-1) + ... + p[n]*I = 0 # # with p[0]=1 and p[n]=(-1)^n*det(A) or # # det(A)*I = -(-1)^n*(p[0]*A^(n-1) + p[1]*A^(n-2) +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_poly(self, p):\n A = self\n m, n = A.shape\n\n if m != n:\n raise DMNonSquareMatrixError(\"Matrix must be square\")\n\n if not p:\n return self.zeros(self.shape, self.domain)\n elif len(p) == 1:\n return p[0] * self.eye(self.shape, self.d...
[ "0.5803448", "0.517542", "0.5075261", "0.5074357", "0.50658363", "0.49985898", "0.49528894", "0.4936648", "0.49322113", "0.49080405", "0.4901721", "0.48930627", "0.48803708", "0.4873036", "0.48696494", "0.48486093", "0.48335832", "0.48222554", "0.48146945", "0.47905916", "0.4...
0.6757248
0
Evaluate polynomial function of a matrix $p(A)$. Examples ======== >>> from sympy import QQ >>> from sympy.polys.matrices import DM >>> A = DM([[QQ(1), QQ(2)], [QQ(3), QQ(4)]], QQ) >>> p = [QQ(1), QQ(2), QQ(3)] >>> p_A = A.eval_poly(p) >>> p_A DomainMatrix([[12, 14], [21, 33]], (2, 2), QQ) >>> p_A == p[0]A2 + p[1]A + p...
def eval_poly(self, p): A = self m, n = A.shape if m != n: raise DMNonSquareMatrixError("Matrix must be square") if not p: return self.zeros(self.shape, self.domain) elif len(p) == 1: return p[0] * self.eye(self.shape, self.domain) #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_poly_mul(self, p, B):\n A = self\n m, n = A.shape\n mb, nb = B.shape\n\n if m != n:\n raise DMNonSquareMatrixError(\"Matrix must be square\")\n\n if mb != n:\n raise DMShapeError(\"Matrices are not aligned\")\n\n if A.domain != B.domain:\n ...
[ "0.71299064", "0.70663744", "0.65621626", "0.64177775", "0.6402518", "0.63913256", "0.6379436", "0.63335276", "0.6210533", "0.6209777", "0.62025857", "0.6190722", "0.6171365", "0.61355305", "0.61310005", "0.6123174", "0.60930675", "0.60900426", "0.60341024", "0.60255563", "0....
0.82272595
0
r""" Evaluate polynomial matrix product $p(A) \times B$. Evaluate the polynomial matrix product $p(A) \times B$ using Horner's method without creating the matrix $p(A)$ explicitly. If $B$ is a column matrix then this method will only use matrixvector multiplies and no matrixmatrix multiplies are needed. If $B$ is squar...
def eval_poly_mul(self, p, B): A = self m, n = A.shape mb, nb = B.shape if m != n: raise DMNonSquareMatrixError("Matrix must be square") if mb != n: raise DMShapeError("Matrices are not aligned") if A.domain != B.domain: raise DMDoma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __matmul__(self, B):\n m, n = self.shape\n n_, r = B.shape\n assert n == n_, (\"Cannot multiply shapes \"\n \"({}, {}) and ({}, {})\".format(m, n, n_, r))\n mul_ = dict()\n # compute A_ik = sum_j A_ij*B_jk\n for i in range(m):\n for k...
[ "0.688725", "0.67086697", "0.6697296", "0.6682241", "0.66694915", "0.6640127", "0.6627668", "0.6623671", "0.6421248", "0.6417866", "0.64155585", "0.6400683", "0.63691294", "0.6357343", "0.62977296", "0.6214272", "0.61954314", "0.6161346", "0.61513346", "0.61390674", "0.613047...
0.8271141
0
r""" Returns Lower and Upper decomposition of the DomainMatrix Returns ======= (L, U, exchange) L, U are Lower and Upper decomposition of the DomainMatrix, exchange is the list of indices of rows exchanged in the decomposition. Raises ====== ValueError If the domain of DomainMatrix not a Field Examples ======== >>> fro...
def lu(self): if not self.domain.is_Field: raise DMNotAField('Not a field') L, U, swaps = self.rep.lu() return self.from_rep(L), self.from_rep(U), swaps
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lu(self):\n L, U, swaps = self.to_ddm().lu()\n return L.to_dfm(), U.to_dfm(), swaps", "def decomposeLU(self):\n self.check_square()\n\n N = self.rows\n L = make_matrix(N, N)\n U = make_matrix(N, N)\n A = self #for more math friendly notation\n\n\n for j...
[ "0.67831564", "0.66338325", "0.64929813", "0.6243098", "0.6048761", "0.60441554", "0.6030243", "0.58836514", "0.58255947", "0.5751735", "0.5627758", "0.5619059", "0.5552913", "0.54507905", "0.541826", "0.53341055", "0.53318167", "0.52960306", "0.5239963", "0.52393985", "0.521...
0.6831546
0
r""" Characteristic polynomial of a square matrix. Computes the characteristic polynomial in a fully expanded form using division free arithmetic. If a factorization of the characteristic polynomial is needed then it is more efficient to call
def charpoly(self): M = self K = M.domain factors = M.charpoly_factor_blocks() cp = [K.one] for f, mult in factors: for _ in range(mult): cp = dup_mul(cp, f, K) return cp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def charpoly_factor_list(self):\n M = self\n K = M.domain\n\n # It is more efficient to start from the partial factorization provided\n # for free by M.charpoly_factor_blocks than the expanded M.charpoly.\n factors = M.charpoly_factor_blocks()\n\n factors_irreducible = []\...
[ "0.61525375", "0.61195874", "0.6074622", "0.60637224", "0.60624367", "0.602509", "0.60038406", "0.5997644", "0.5995248", "0.5958489", "0.59322315", "0.5855145", "0.58519465", "0.58451384", "0.58403826", "0.5799992", "0.5794116", "0.57695705", "0.5752877", "0.5740463", "0.5708...
0.6488183
0
r""" Return diagonal matrix with entries from ``diagonal``. Examples ======== >>> from sympy.polys.matrices import DomainMatrix >>> from sympy import ZZ >>> DomainMatrix.diag([ZZ(5), ZZ(6)], ZZ)
def diag(cls, diagonal, domain, shape=None): if shape is None: N = len(diagonal) shape = (N, N) return cls.from_rep(SDM.diag(diagonal, domain, shape))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diagonal(matrix):\n if sp.sparse.issparse(matrix):\n diag = np.array(matrix.diagonal())\n else:\n diag = np.diagonal(matrix).copy()\n return diag", "def diagonal(self):\n M = self.rep\n m, n = self.shape\n return [M[i, i] for i in range(min(m, n))]", "def get_dia...
[ "0.75419396", "0.7343016", "0.7339475", "0.73322403", "0.7324302", "0.72696435", "0.7268999", "0.71389306", "0.70959455", "0.70923465", "0.7087194", "0.7062203", "0.7036768", "0.6925176", "0.6907123", "0.6873534", "0.68501925", "0.67881244", "0.67330426", "0.6728541", "0.6726...
0.8093071
0
Returns a zero DomainMatrix of size shape, belonging to the specified domain Examples ======== >>> from sympy.polys.matrices import DomainMatrix >>> from sympy import QQ >>> DomainMatrix.zeros((2, 3), QQ) DomainMatrix({}, (2, 3), QQ)
def zeros(cls, shape, domain, *, fmt='sparse'): return cls.from_rep(SDM.zeros(shape, domain))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zeros(cls, shape, domain):\n func = cls._get_flint_func(domain)\n return cls._new(func(*shape), shape, domain)", "def zeros(cls,size:(int,int)) -> 'Matrix': #note single quotes because this is the class, itself and has not been completely defined yet.\n N = size[0]\n M = size[1]\n...
[ "0.7649343", "0.71144277", "0.675991", "0.6754581", "0.66766864", "0.6600416", "0.65751183", "0.6549552", "0.6537978", "0.64248186", "0.6369417", "0.6352058", "0.63252354", "0.62965584", "0.6240357", "0.6233659", "0.6223721", "0.62208635", "0.62172264", "0.6206868", "0.619681...
0.7588312
1
Returns a DomainMatrix of 1s, of size shape, belonging to the specified domain Examples ======== >>> from sympy.polys.matrices import DomainMatrix >>> from sympy import QQ >>> DomainMatrix.ones((2,3), QQ) DomainMatrix([[1, 1, 1], [1, 1, 1]], (2, 3), QQ)
def ones(cls, shape, domain): return cls.from_rep(DDM.ones(shape, domain).to_dfm_or_ddm())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ones(cls, shape, domain):\n # XXX: flint matrices do not have anything like ones\n return DDM.ones(shape, domain).to_dfm()", "def ones(cls, size:(int,int)) -> 'Matrix': #note single quotes because this is the class, itself and has not been completely defined yet.\n N = size[0]\n M...
[ "0.78016037", "0.647386", "0.6080348", "0.60106575", "0.5950663", "0.5949277", "0.59068185", "0.5819181", "0.57772744", "0.5755645", "0.56927985", "0.56622535", "0.5645673", "0.5589026", "0.5548461", "0.5472495", "0.5467841", "0.54492027", "0.54479283", "0.54479283", "0.54453...
0.73886454
1
Collect repeating factors and sort. >>> from sympy.polys.matrices.domainmatrix import _collect_factors >>> _collect_factors([([1, 2], 2), ([1, 4], 3), ([1, 2], 5)]) [([1, 4], 3), ([1, 2], 7)]
def _collect_factors(factors_list): factors = Counter() for factor, exponent in factors_list: factors[tuple(factor)] += exponent factors_list = [(list(f), e) for f, e in factors.items()] return _sort_factors(factors_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sorted_factors(self):\n if not hasattr(self, \"_sorted_factors\"):\n self._sorted_factors = {}\n for expr in self.graded_dict:\n for order in self.graded_dict[expr]:\n for factors in self.graded_dict[expr][order]:\n for facto...
[ "0.6783973", "0.66071653", "0.66036606", "0.64551336", "0.64464295", "0.6410552", "0.63670474", "0.6348271", "0.633637", "0.6254592", "0.62532526", "0.62450665", "0.6219406", "0.6207736", "0.6181904", "0.61351377", "0.61143255", "0.6068154", "0.6047675", "0.604553", "0.604526...
0.75832295
0
Read XML file, , and return the XML tree and root As this is a test script, errors will throw exceptions.
def read_xml_file(filename): ############################################################################### with __FILE_OPEN(filename) as file_: tree = ET.parse(file_) root = tree.getroot() # End with return tree, root
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_xml(file_dir):\n tree = ElementTree()\n tree.parse(file_dir)\n return tree", "def parse_xml(xmlfile):\n # create element tree object\n root = ET.parse(xmlfile).getroot()\n return root", "def readXML(xmlfile, expectedRootTag=None):\n\n # Read in XML\n try:\n etree = XML.E...
[ "0.7760268", "0.7453753", "0.733421", "0.73040056", "0.73012733", "0.7232787", "0.71647125", "0.7052671", "0.6745657", "0.6729316", "0.6722795", "0.67133266", "0.6711991", "0.66637343", "0.6629158", "0.6603575", "0.6596506", "0.6555529", "0.6541779", "0.65170085", "0.64982194...
0.8288643
0
Test that a good registry with only variables validates. Check that generate_registry_data.py generates good Fortran and metadata files
def test_good_simple_registry(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_simple.xml") out_source_name = "physics_types_simple" in_source = os.path.join(_SAMPLE_FILES_DIR, out_source_name + '.F90') in_meta = os.path.join(_SAMPLE_FILES_DIR, out_source_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_good_complete_registry(self):\n\n # Setup test\n filename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_complete.xml\")\n out_source_name = \"physics_types_complete\"\n in_source = os.path.join(_SAMPLE_FILES_DIR, out_source_name + '.F90')\n in_meta = os.path.join(_SAMPLE_...
[ "0.7489583", "0.7300802", "0.72713065", "0.685101", "0.6775587", "0.6702503", "0.66882867", "0.66881794", "0.6464604", "0.6353552", "0.62917024", "0.6263196", "0.61989594", "0.6181846", "0.612416", "0.6051159", "0.6050129", "0.5797634", "0.57886386", "0.5773098", "0.56272197"...
0.7570558
0
Test code and metadata generation from a good registry with a DDT. Check that generate_registry_data.py generates good Fortran and metadata files. Check that the DDT contains the proper information depending on dycore
def test_good_ddt_registry(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_ddt.xml") out_name = "physics_types_ddt" for dycore in ['fv', 'eul', 'se']: out_source_name = out_name + '_' + dycore + '.F90' out_meta_name = out_name + '_' + dyco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_good_ddt_registry2(self):\n # Setup test\n filename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_ddt2.xml\")\n out_name = \"physics_types_ddt2\"\n out_source_name = out_name + '.F90'\n out_meta_name = out_name + '.meta'\n in_source = os.path.join(_SAMPLE_FILES_DIR...
[ "0.8150657", "0.7565065", "0.6838204", "0.6764464", "0.6748204", "0.6741213", "0.6665641", "0.6381703", "0.63033235", "0.625909", "0.6215853", "0.61569154", "0.6085395", "0.60218984", "0.5880829", "0.57654715", "0.5759406", "0.5720245", "0.5700319", "0.56878316", "0.5641759",...
0.846325
0
Test code and metadata generation from a good registry with DDTs with extends and bindC attributes. Check that generate_registry_data.py generates good Fortran and metadata files. Check that the DDT contains the proper information depending on dycore
def test_good_ddt_registry2(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_ddt2.xml") out_name = "physics_types_ddt2" out_source_name = out_name + '.F90' out_meta_name = out_name + '.meta' in_source = os.path.join(_SAMPLE_FILES_DIR, out_source_na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_good_ddt_registry(self):\n # Setup test\n filename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_ddt.xml\")\n out_name = \"physics_types_ddt\"\n for dycore in ['fv', 'eul', 'se']:\n out_source_name = out_name + '_' + dycore + '.F90'\n out_meta_name = out_na...
[ "0.78268164", "0.69744337", "0.64410394", "0.64040637", "0.6370886", "0.635825", "0.6201766", "0.6045982", "0.60271966", "0.59987247", "0.5991186", "0.5673386", "0.56367445", "0.55779827", "0.55396223", "0.5530007", "0.5502119", "0.5496661", "0.5492957", "0.54556763", "0.5426...
0.7504274
1
Test code and metadata generation from a good registry with DDTs containing an "Array" variable with multiple internal Array elements Check that generate_registry_data.py generates good Fortran and metadata files. Check that the DDT contains the proper information and the initialization code has the correct array calls
def test_good_array(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_ddt_array.xml") out_name = "physics_types_ddt_array" out_source_name = out_name + '.F90' out_meta_name = out_name + '.meta' in_source = os.path.join(_SAMPLE_FILES_DIR, out_source_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_good_ddt_registry2(self):\n # Setup test\n filename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_ddt2.xml\")\n out_name = \"physics_types_ddt2\"\n out_source_name = out_name + '.F90'\n out_meta_name = out_name + '.meta'\n in_source = os.path.join(_SAMPLE_FILES_DIR...
[ "0.6746992", "0.67384994", "0.6628652", "0.6535721", "0.65094197", "0.6091512", "0.5993546", "0.5975183", "0.5951474", "0.59180397", "0.5779919", "0.5694543", "0.5628137", "0.55455065", "0.5523362", "0.55089235", "0.55070615", "0.54735655", "0.5473288", "0.54532564", "0.54532...
0.7656157
0
Test code and metadata generation from a good registry with a DDT and a metadata file. Check that generate_registry_data.py generates good Fortran and metadata files. Check that the DDT contains the proper information for the SE dycore
def test_good_metadata_file_registry(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_mf.xml") out_name = "physics_types_ddt" in_source = os.path.join(_SAMPLE_FILES_DIR, out_name + '_se.F90') in_meta = os.path.join(_SAMPLE_FILES_DIR, out_name + '_se.meta')...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_good_ddt_registry(self):\n # Setup test\n filename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_ddt.xml\")\n out_name = \"physics_types_ddt\"\n for dycore in ['fv', 'eul', 'se']:\n out_source_name = out_name + '_' + dycore + '.F90'\n out_meta_name = out_na...
[ "0.8285107", "0.8143122", "0.7414683", "0.73035926", "0.71354866", "0.7121494", "0.6852475", "0.67165565", "0.63517076", "0.62971246", "0.62456083", "0.62327886", "0.61772054", "0.6046517", "0.5993407", "0.59612393", "0.5858055", "0.5852139", "0.5784658", "0.5783003", "0.5690...
0.81803554
1
Perform the same test as "test_good_metadata_file_registry", except with the metadata file located elsewhere, and the "src_root" input variable set accordingly.
def test_diff_src_root_metadata_file_registry(self): # Setup test filename = os.path.join(_SAMPLE_FILES_DIR, "reg_good_mf.xml") out_name = "physics_types_ddt" in_source = os.path.join(_SAMPLE_FILES_DIR, out_name + '_se.F90') in_meta = os.path.join(_SAMPLE_FILES_DIR, out_name + '_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_metadata_file_registry(self):\n # Setup test\n infilename = os.path.join(_SAMPLE_FILES_DIR, \"reg_good_mf.xml\")\n filename = os.path.join(_TMP_DIR, \"reg_no_mf.xml\")\n out_source_name = \"physics_types_no_mf\"\n out_source = out_source_name + '.F90'\n out_met...
[ "0.72111654", "0.6961151", "0.69579804", "0.63457835", "0.6259123", "0.62450695", "0.5939637", "0.5916219", "0.59020853", "0.58904076", "0.5867104", "0.58212537", "0.5816988", "0.58159906", "0.5801752", "0.57941043", "0.5760028", "0.56984866", "0.56493115", "0.5649008", "0.56...
0.7305677
0