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 |
|---|---|---|---|---|---|---|
title is an alias to transaction name | def test_title_alias(self):
self.store_transaction_metric(
1,
tags={"transaction": "foo_transaction"},
timestamp=self.min_ago,
)
response = self.do_request(
{
"field": ["title", "p50()"],
"query": "event.type:transa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_title():",
"def getTitle(self):\n return \"ERP5BankingStopPayment\"",
"def getTitle(self): #$NON-NLS-1$\r",
"def getTitle(self): #$NON-NLS-1$\r",
"def title(self) -> String:\n pass",
"def title(self) -> str:\n pass",
"def name_with_title(self):\n return \"%s %s\" % (self.tit... | [
"0.66933125",
"0.66578645",
"0.6369052",
"0.6369052",
"0.6346037",
"0.6335202",
"0.6292599",
"0.6291467",
"0.6273389",
"0.623667",
"0.62135303",
"0.617376",
"0.617376",
"0.61358505",
"0.6135086",
"0.6130095",
"0.6130095",
"0.61255455",
"0.6125201",
"0.6118025",
"0.6088375",
... | 0.68748486 | 0 |
Action Boiling water, depends on outside mechanism. Reduce water tank level | def run(self):
self.coffee_machine.water_tank.decrease_weight(self.coffee_machine.chosen_coffee_data.get('water_weight')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sprinkler_tick(self, water_available=-1):\n # idk if Python uses pass by reference, so I'm copying this variable just to be safe\n available_water = water_available\n for room in self.room_list:\n if room.sprinkling and room.fire_level > 0 and available_water != 0:\n ... | [
"0.6434661",
"0.63874775",
"0.63674766",
"0.63130474",
"0.62202126",
"0.61891794",
"0.6106221",
"0.60616267",
"0.6025514",
"0.60109717",
"0.5955799",
"0.5954038",
"0.5939184",
"0.5916864",
"0.5909904",
"0.58544374",
"0.5797723",
"0.5784482",
"0.57756746",
"0.57756406",
"0.573... | 0.6906882 | 0 |
Given two instances of players 'p1' and 'p2', play out a game between them. Returns the winning player. Returns 'None' in case of a draw. When 'show' is true, display each move in the game. | def playOneGame(self, p1, p2, show):
currentPlayer, otherPlayer = p1, p2
winner = None
gameFinished = False
#
while not(gameFinished):
if show:
self.display() # show the board
#
move = currentPlayer.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_game(self, player_1, player_2, show_flag=True):\n players = [player_1, player_2]\n player = players[self.ready_player - 1]\n\n if show_flag:\n print('initial state:')\n self.show_board()\n\n while True:\n if self.check_end_game():\n ... | [
"0.7757454",
"0.7080622",
"0.6999645",
"0.6924849",
"0.68479705",
"0.66570437",
"0.6610707",
"0.65846026",
"0.65660465",
"0.6541189",
"0.64332145",
"0.64253837",
"0.6362032",
"0.6289165",
"0.6238523",
"0.62379724",
"0.62286764",
"0.6227411",
"0.62102544",
"0.61412436",
"0.611... | 0.81484276 | 0 |
Play n handicapped games between p1 and p2 Player p1 starts with h extra moves Report the number of wins for each player | def playHandicappedGameSeries(self, p1, p2, h, n, verbose):
numWinP1 = 0
numWinP2 = 0
for i in range(n):
self.reset()
for i_h in range(h):
move = p1.getMove(self.deepCopy())
self.makeMove(p1.colour, move)
winner = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_play_game_hard(self):\r\n wins = [0,0,0]\r\n\r\n for i in range(1,10):\r\n a_player_1_id = 1\r\n a_player_2_id = 2\r\n a_players = [RandomPlayer(a_player_1_id), RandomPlayer(a_player_2_id)]\r\n a_x_dist = i\r\n a_y_dist = i\r\n a_num_to_win = 3\r\n a_game = Game(a_... | [
"0.67143434",
"0.65993416",
"0.6596372",
"0.6594233",
"0.65595084",
"0.6502603",
"0.6461119",
"0.6410232",
"0.6389686",
"0.6366237",
"0.6357459",
"0.630248",
"0.627658",
"0.6275543",
"0.6247166",
"0.62411034",
"0.61899066",
"0.61440593",
"0.61317956",
"0.61289644",
"0.6118452... | 0.7917367 | 0 |
Records the player's colour, either black or for white. Should also set the name of the player. | def __init__(self, colour):
self.colour = colour
self.name = "Player" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updatePlayer(self, _player):\n if _player.color == 'black': self.players['black'] = _player\n else: self.players['white'] = _player",
"def player(self):\n return self._color",
"def switch_player(self):\n if self.playerOne:\n # sets the chip color to blue\n ... | [
"0.75764513",
"0.6954662",
"0.6630727",
"0.6328392",
"0.6285385",
"0.6149251",
"0.6125379",
"0.60314083",
"0.60195285",
"0.58754647",
"0.58627224",
"0.5834706",
"0.5774131",
"0.57675064",
"0.5767079",
"0.57331955",
"0.5710875",
"0.5673335",
"0.5668842",
"0.56438184",
"0.56277... | 0.71703076 | 1 |
Implement the deep copy of Neural Network object | def deepcopy(self):
newNN = NeuralNetwork(self.max_epochs, self.loss, self.metric, self.momentum_rate,
self.regularization_rate, self.type, self.batch_size, self.type_classifier)
[newNN.add_layer(layer.deepcopy()) for layer in self.layers]
return newNN | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\r\n clone = NeuralNet()\r\n for layer in self.layers:\r\n clone.layers.append(layer.copy())\r\n return clone",
"def copy(self):\r\n clone = NeuralNetLayer(self.input_size, self.output_size)\r\n clone.weights = self.weights.copy()\r\n return clo... | [
"0.8019589",
"0.78924936",
"0.74327624",
"0.7114037",
"0.70309705",
"0.6934484",
"0.68992925",
"0.674655",
"0.6724125",
"0.66695285",
"0.66653687",
"0.66366273",
"0.661949",
"0.66111404",
"0.6591295",
"0.6576126",
"0.6495452",
"0.64302903",
"0.63686264",
"0.63668686",
"0.6362... | 0.84814703 | 0 |
Check batch_size value inserted in NN constructor | def check_batch_size(self, batch_size):
if self.optimizer == "SGD" and batch_size == 1:
return batch_size
elif batch_size > 0:
return batch_size
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _global_batch_size(self):\n return True",
"def _validate_train_size(train_size):\n assert isinstance(train_size, float) and (0. < train_size < 1.), \\\n \"train_size should be a float between 0 and 1\"",
"def train(self, num_batches: int):",
"def test_cnn_batchnorm_dim(self):\n model ... | [
"0.6695539",
"0.660996",
"0.6543754",
"0.65384096",
"0.64781255",
"0.6472762",
"0.63730353",
"0.63723344",
"0.6348025",
"0.6336142",
"0.6298661",
"0.62844867",
"0.62795174",
"0.626129",
"0.625797",
"0.6193461",
"0.6188281",
"0.6168586",
"0.6138426",
"0.61377376",
"0.61233",
... | 0.79229623 | 0 |
Check valid loss function inserted in NN constructor | def check_loss(self, loss):
if loss in loss_functions:
return loss
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_loss(self, loss):\n assert not np.isnan(loss), \"Model diverged with loss = NaN\"",
"def loss_fn(self, pred: Tensor, true: Tensor) -> Tensor:\n pass",
"def loss_fn(self, targets, outputs, model):",
"def validate(model,val_dataloader,loss_fn):\n model.eval()\n total_loss = 0\n \n... | [
"0.7083934",
"0.6815832",
"0.663371",
"0.65763426",
"0.653153",
"0.65229464",
"0.6504693",
"0.64926296",
"0.64890563",
"0.6458937",
"0.6408656",
"0.6299797",
"0.62972724",
"0.6276639",
"0.62531155",
"0.622724",
"0.6202314",
"0.6190926",
"0.6175068",
"0.6144149",
"0.6134495",
... | 0.79832155 | 0 |
Check max_epochs value inserted in constructor | def check_max_epochs(self, max_epochs):
if max_epochs > 0:
return max_epochs
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_epochs(self):\n return self.trainer_cfg[\"max_num_epochs\"]",
"def max_epochs(self):\n return self.trainer_cfg[\"max_num_epochs\"] + self.trainer_cfg[\"swa_epochs\"]",
"def __init__(self, \n training_epochs):\n self.training_epochs = training_epochs",
"def __init__(self, maxEp... | [
"0.7318201",
"0.7116694",
"0.68464327",
"0.65773886",
"0.6535207",
"0.6413379",
"0.6348574",
"0.6344781",
"0.6344781",
"0.6344781",
"0.6344781",
"0.63414633",
"0.6307486",
"0.6291952",
"0.6285296",
"0.6106394",
"0.5986773",
"0.5956194",
"0.59559923",
"0.59476197",
"0.5937254"... | 0.81879485 | 0 |
Check momentum_rate value inserted in Constructor | def check_momentum(self, momentum_rate):
if momentum_rate >= 0:
return momentum_rate
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, learning_rate, momentum_coef):\n self.learning_rate = learning_rate\n self.momentum_coef = momentum_coef",
"def __init__(self):\n super().__init__()\n self.nan_penalty = nan_penalty\n self.nan_tol = nan_tol",
"def __init__(self):\n super(... | [
"0.68485373",
"0.60576665",
"0.5930227",
"0.58038116",
"0.5746112",
"0.573324",
"0.5654724",
"0.5638974",
"0.56013876",
"0.5534972",
"0.5529621",
"0.55125046",
"0.55054575",
"0.5487874",
"0.5469919",
"0.54678315",
"0.5461478",
"0.54407245",
"0.54371405",
"0.5428778",
"0.54252... | 0.7451733 | 0 |
Check optimizer value inserted in NN constructor | def check_optimizer(self, optimizer):
if optimizer in optimizer_implemented:
return optimizer
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_optimization(self):\n\n if self.FLAGS.optimizer == \"Adam\" :\n self.solver = tf.train.AdamOptimizer(\n learning_rate = self.learning_rate,\n beta1 = self.FLAGS.beta1,\n beta2 = self.FLAGS.beta2)\n ... | [
"0.63378745",
"0.62747973",
"0.6231336",
"0.61521405",
"0.60902923",
"0.60639024",
"0.60639024",
"0.60562927",
"0.604475",
"0.6033664",
"0.60318226",
"0.6012947",
"0.60101813",
"0.59740704",
"0.59728706",
"0.59406507",
"0.5924537",
"0.592252",
"0.5897922",
"0.586312",
"0.5846... | 0.69428104 | 0 |
Check regularization_rate value inserted in NN costructor | def check_regularization(self, regularization_rate):
if regularization_rate >= 0:
return regularization_rate
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_regularization_0size_interval(self):\n reg = modelgen.get_regularization(2, 2)\n assert reg == 0.01",
"def test_base_hyper_parameters_reg(self):\n hyper_parameter_set = modelgen.generate_base_hyper_parameter_set()\n assert 'regularization_rate' in hyper_parameter_set.keys()",... | [
"0.64733064",
"0.6080422",
"0.6012724",
"0.59053385",
"0.586913",
"0.58615154",
"0.5735454",
"0.5699984",
"0.5684051",
"0.56704646",
"0.56701547",
"0.566797",
"0.56386405",
"0.56375617",
"0.56305265",
"0.56194293",
"0.56082106",
"0.5580371",
"0.5578775",
"0.5571667",
"0.55689... | 0.7832157 | 0 |
Check type of Classifier for NN model | def check_type_classifier(self, type_classifier):
if type_classifier in ["classification", "regression"]:
return type_classifier
else:
raise InvalidNeuralNetwork() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_type(self):\n a = model_classifier(self.model_filepath)\n\n size = os.stat(self.model_filepath).st_size\n size = size / 1000000 # in MB\n print('Model size in MB: {}'.format(size))\n self.model_size = size\n\n if abs(size - a.resnet50_size) < abs(size - a.inc... | [
"0.7047372",
"0.6815799",
"0.6774307",
"0.66634643",
"0.65803456",
"0.64675516",
"0.64462304",
"0.6414384",
"0.6412238",
"0.63710207",
"0.6273675",
"0.6256342",
"0.6248238",
"0.62357795",
"0.6229274",
"0.6199279",
"0.61413556",
"0.61408454",
"0.6103418",
"0.6103418",
"0.60966... | 0.7577078 | 0 |
add a layer in the neural network | def add_layer(self, layer):
if not isinstance(layer, Layer):
raise ValueError('layer must be a Layer object')
# the first layer added define the input dimension of the neural network
if len(self.layers) == 0:
self.input_dimension = layer.get_num_input()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_layer(self, in_dim, out_dim, activation: Module or None, i=None):\n i = i or len(self.modules)\n self.modules.insert(i, Linear(in_dim=in_dim, out_dim=out_dim, activation=activation))",
"def add(self, layer):\n if len(self.layers) == 0:\n if not layer.n_inputs:\n ... | [
"0.77999234",
"0.7658628",
"0.7539678",
"0.7524055",
"0.74295366",
"0.7343234",
"0.73359543",
"0.7331911",
"0.7300239",
"0.7234359",
"0.7221923",
"0.72213215",
"0.707859",
"0.7062022",
"0.70211965",
"0.69954705",
"0.69603395",
"0.69295865",
"0.69064677",
"0.688323",
"0.686853... | 0.7798334 | 1 |
FeedwardSignal feedward the signal from input to output of a feedforward NN | def _feedward_signal(self, sample):
if sample.shape[1] != self.input_dimension:
raise ValueError
input_layer = sample
for layer in self.layers:
output_layer = layer.function_signal(input_layer)
input_layer = output_layer
return output_laye... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, graph, feat):\n graph = graph.local_var()\n\n if isinstance(feat, tuple):\n h_src = self.feat_drop(feat[0])\n h_dst = self.feat_drop(feat[1])\n feat_src = self.fc_src(h_src).view(-1, self._num_heads, self._out_feats)\n feat_dst = self.fc_dst(h_dst).view(-1, self._num_hea... | [
"0.6680435",
"0.66292983",
"0.6571072",
"0.6558021",
"0.6553469",
"0.65326595",
"0.650482",
"0.64945894",
"0.6455602",
"0.645217",
"0.6448832",
"0.6444206",
"0.6435576",
"0.6401489",
"0.6387515",
"0.6365323",
"0.63195395",
"0.63123065",
"0.63065445",
"0.6301157",
"0.6299346",... | 0.66505885 | 1 |
Handles 500 error code from server. Stores html server response to file | def _handle_code_500(self, server_response):
filename = "server_error.html"
try:
with open(filename, 'w') as f:
f.write(server_response)
except IOError:
print("Can not open file '%s' to write server answer. Skipping." % filename)
return None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_internal_server_error(self):\n template_filename = self._get_config_template('500')\n text = read_template(\n template_filename,\n title='%s - Internal Error' % SERVER_NAME,\n header='Internal error')\n if not text:\n # fallback to hard-cod... | [
"0.75398505",
"0.7530522",
"0.7507729",
"0.7506237",
"0.7433129",
"0.7404533",
"0.72993875",
"0.72346693",
"0.72197866",
"0.7171509",
"0.71490103",
"0.70881546",
"0.70772207",
"0.70410943",
"0.70052004",
"0.6964809",
"0.69293904",
"0.69293904",
"0.6915995",
"0.6896048",
"0.68... | 0.8311209 | 0 |
Handler for code 400 to override this function if needed and save reverse compatibility | def _handle_code_400(text):
return '; server response: ' + text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_request():\n return HttpError(400)",
"def internal_error_400(error):\n return jsonify({'error':\n \"Die Anfrage wurde syntaktisch falsch erstellt.\"}), 400",
"def resp400(msg):\n app.logger.error(msg)\n return Resp({'message':msg, 'success':False}, status=400)",
"def te... | [
"0.6975429",
"0.66431403",
"0.6516081",
"0.6435446",
"0.6423636",
"0.6423057",
"0.63836926",
"0.6378437",
"0.63523775",
"0.6342306",
"0.6332832",
"0.6325043",
"0.6310606",
"0.63001835",
"0.62141716",
"0.61905223",
"0.61851406",
"0.6128791",
"0.6127547",
"0.6081759",
"0.607516... | 0.70281965 | 0 |
Convert to array of [x, y, blocksize, blocksize, 3] i.e. a coordinate system that allows for an X/Y indexing with blocks. | def toXY(im, blocksize):
blocks = img.reshape(
img.shape[0]//blocksize,
blocksize,
img.shape[1]//blocksize,
blocksize, 3).swapaxes(1, 2)
return blocks | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_coords_to_block_coords(\n x: int, z: int, chunk_x_size: int = 16, chunk_z_size: int = 16\n) -> ChunkCoordinates:\n return x * chunk_x_size, z * chunk_z_size",
"def _block(self, x, y):\n\n cells = []\n\n ix = x - (x%3)\n iy = y - (y%3)\n\n for y in range(iy, iy+3):\n ... | [
"0.6671259",
"0.64263934",
"0.63331187",
"0.6333016",
"0.6325375",
"0.61881614",
"0.6173598",
"0.61610925",
"0.6149343",
"0.6100957",
"0.6100957",
"0.6100957",
"0.6012429",
"0.601241",
"0.59837717",
"0.5964142",
"0.5961271",
"0.5925309",
"0.59243315",
"0.59138536",
"0.5880371... | 0.6979222 | 0 |
Converts to array of [xy, blocksize, blocksize, 3] which allows for a single inices to move through blocks of the input image | def toBlocks(im, blocksize):
blocks = im.reshape(
im.shape[0]//blocksize,
blocksize,
im.shape[1]//blocksize,
blocksize, 3).swapaxes(1, 2)
blocks = blocks.reshape(
im.shape[0]*im.shape[1]//(blocksize**2),
blocksize,
1,
blocksize, 3).swapaxes(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toXY(im, blocksize):\n blocks = img.reshape(\n img.shape[0]//blocksize, \n blocksize, \n img.shape[1]//blocksize, \n blocksize, 3).swapaxes(1, 2)\n return blocks",
"def chunks(img, n):\n shape = img.shape\n imgs = []\n\n nx = int(n * (shape[1]/(shape[0] + shape[1]))... | [
"0.736783",
"0.64031017",
"0.63952625",
"0.63311845",
"0.63032115",
"0.6204883",
"0.61552095",
"0.6125623",
"0.6098224",
"0.6098224",
"0.6098224",
"0.609399",
"0.609343",
"0.60217804",
"0.6005323",
"0.59990126",
"0.5990907",
"0.5960376",
"0.5958849",
"0.5940742",
"0.59154576"... | 0.6954152 | 1 |
Transcribes the dna_string into an rna_string, replacing thymine with uracil. | def transcribe(dna_string):
from utils import thymine, uracil
return dna_string.replace(thymine, uracil) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_rna(self):\n thymidine = 'T'\n uracil = 'U'\n return self.dna.replace(thymidine, uracil)",
"def to_rna(dna):\r\n return dna.translate(str.maketrans('ATGC','UACG'))",
"def transcribe_dna_to_rna(s):\n rna_code = {'A': 'A', 'C': 'C', 'G': 'G', 'T': 'U', '':''}\n # Treat unknowns\n retu... | [
"0.784889",
"0.7380322",
"0.7038265",
"0.6916737",
"0.68604106",
"0.6847413",
"0.6774244",
"0.6663243",
"0.66273814",
"0.6581832",
"0.6499714",
"0.6304763",
"0.62765527",
"0.6172654",
"0.6072747",
"0.6062749",
"0.6061104",
"0.60426646",
"0.5961122",
"0.58773696",
"0.5819397",... | 0.8195274 | 0 |
Given an ROI zip (created with ImageJ's ROI Manager), analyze each ROI and return a dictionary with its keys including 'area' which is a list of X/Y pixel pairs encircled by the ROI. Also adds a 'bounds' key [X1,X2,Y1,Y2] of the bounds of the ROI based on its area. Unsupported shapes will have their bounds detected aut... | def roi_areas(roiFile):
assert os.path.exists(roiFile)
rois = read_roi_zip(roiFile)
print("Found %d ROIs in %s"%(len(rois),os.path.basename(roiFile)))
# this is a hack to turn unsupported shapes into rectangles
# just set its top,left,width, and height and change type to rectangle
for i,roi in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getROIobjects(zip_path, class_id, height=None, width=None): # image_path=None,\n if zip_path is None:\n zip_path = splitext(image_path)[0] + '.zip'\n \n # Must have a .zip file\n assert zip_path.lower().endswith('.zip'), \"Must be a .ZIP file\"\n \n# if image_path is not None:\n#... | [
"0.6623416",
"0.645033",
"0.6111518",
"0.5756325",
"0.56444615",
"0.56058615",
"0.55692494",
"0.5505762",
"0.55033624",
"0.5488482",
"0.543777",
"0.53487927",
"0.53020895",
"0.52980006",
"0.5292569",
"0.52756864",
"0.52502763",
"0.52340233",
"0.522306",
"0.52219003",
"0.52156... | 0.7635946 | 0 |
given a SINGLE roi, return the average of its area by frame. | def image_roi_average(img3d,roi):
AVGs=np.empty(len(img3d))
for frame in range(len(img3d)):
values=np.empty(len(roi['area']))
for i,pair in enumerate(roi['area']):
values[i]=img3d[frame,pair[1],pair[0]]
AVGs[frame]=np.average(values)
#print("WARNING: LOWPASSING")
#AVG... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roi_average(self,image3d,roiNumber):\n assert roiNumber<len(self.rois)\n return image_roi_average(image3d,self.rois[roiNumber])",
"def test_roi_averaging(self):\n filename = get_test_data_path() + 'sgacc_mask.nii.gz'\n regions = self.dataset.masker.mask(filename, in_global_mask=Tr... | [
"0.6755899",
"0.6294813",
"0.62218404",
"0.61800045",
"0.6034768",
"0.60223055",
"0.5927423",
"0.58399975",
"0.57611537",
"0.57602847",
"0.57516325",
"0.5677798",
"0.5668899",
"0.5647401",
"0.5619018",
"0.5614188",
"0.56072277",
"0.55798095",
"0.5569298",
"0.55382943",
"0.551... | 0.7468556 | 0 |
Given a huge string of XML, find the first match of a given a string, then go to the next value="THIS" and return the THIS as a string. if the match ends in ~2~, return the second value. | def xml_value_from_key(xml,match,matchNumber=1):
for i in range(1,10):
if match.endswith("~%d~"%i):
match=match.replace("~%d~"%i,'')
matchNumber=i
if not match in xml:
return None
else:
val=xml.split(match)[1].split("value=",3)[matchNumber]
val=val.spl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_text_in_tag(st, tag):\n if tag == \"e1\":\n st = st.replace(\"<e2>\", \"\")\n st = st.replace(\"</e2>\", \"\")\n elif tag == \"e2\":\n st = st.replace(\"<e1>\", \"\")\n st = st.replace(\"</e1>\", \"\")\n\n for i in range(len(st) - (len(tag)+2) + 1): # +2 is for < and >... | [
"0.6115918",
"0.5887178",
"0.58807653",
"0.5396295",
"0.53171426",
"0.52617246",
"0.5260662",
"0.52405983",
"0.52242106",
"0.5209413",
"0.5166903",
"0.5148296",
"0.514424",
"0.514424",
"0.5110966",
"0.5089587",
"0.508889",
"0.50828266",
"0.50709355",
"0.5059757",
"0.50504935"... | 0.59208435 | 1 |
Given a list of images, create a 3D numpy array to represent them and save it as a given filename (ending in .npy). All images must be identical dimensions. Saves the data, and also returns it. Alternatively, if the save path already exists, just load and return it. | def images_to_numpy(imageList,saveAs):
saveAs=os.path.abspath(saveAs)
if os.path.exists(saveAs):
print("loading data from %s ..."%(os.path.basename(saveAs)))
data=np.load(saveAs)
if len(data)==len(imageList):
print(" loaded %.02f MB array"%(data.nbytes/2**20),data.shape)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe_save_images(images, filenames):\n\n if FLAGS.output_dir is not None:\n batch_size = images.shape[0]\n for i in xrange(batch_size):\n image_array = images[i, :, :]\n file_path = os.path.join(FLAGS.output_dir, filenames[i])\n image = Image.fromarray(np.uint... | [
"0.6884683",
"0.64679337",
"0.62741685",
"0.61704886",
"0.61682105",
"0.61396915",
"0.60557383",
"0.6034646",
"0.6021969",
"0.599016",
"0.59869087",
"0.59666246",
"0.5923276",
"0.59129447",
"0.59066796",
"0.58843315",
"0.58667195",
"0.58599645",
"0.58546424",
"0.5854446",
"0.... | 0.7248182 | 0 |
given a specially formatted tags list (see that function), add shading, labels, vertical lines, etc. where appropraite. Assume the matplotlib figure is already selected. | def plot_add_tags(tags,seconds=False):
for i,tag in enumerate(tags):
#color=plt.get_cmap('Dark2')(tag[1]/tags[-1][1])
color=plt.get_cmap('Dark2')(i/len(tags))
name,vals=tag[0],tag[1:]
if seconds:
vals=[x*60 for x in vals]
if len(vals)==2:
plt.axvspan(v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __draw_ubl_style(self, ax, item, p, thumb=False):\n low_labs = []\n for d in item[\"domains\"]:\n if d[\"fam\"] == \"FAMILY-DEFINING\":\n # special code to convert RING finger -> RNF finger\n item[\"type\"] = item[\"type\"].replace(\"RING finger\", \"RNF f... | [
"0.5737643",
"0.5620798",
"0.5582805",
"0.5442718",
"0.5373449",
"0.5354813",
"0.53369105",
"0.5334176",
"0.5324177",
"0.5320856",
"0.5282867",
"0.52601737",
"0.5254371",
"0.5218851",
"0.5212703",
"0.51822543",
"0.5181311",
"0.5165962",
"0.5162732",
"0.5159016",
"0.5150994",
... | 0.58151007 | 0 |
minimal complexity lowpass filtering. Filter size is how "wide" the filter will be. Sigma will be 1/10 of this filter width. If filter size isn't given, it will be 1/10 of the data size. | def lowpass(data,filterSize=None):
def convolve(signal,kernel):
pad=np.ones(len(kernel)/2)
signal=np.concatenate((pad*signal[0],signal,pad*signal[-1]))
signal=np.convolve(signal,kernel,mode='same')
signal=signal[len(pad):-len(pad)]
return signal
def kernel_gaussian(size... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lowpass_filter(s, sample_rate, cutoff_freq, filter_order=5, rescale=False):\n #create a butterworth filter\n nyq = sample_rate / 2.0\n b,a = filter_design.butter(filter_order, cutoff_freq / nyq)\n\n #filter the signal\n filtered_s = filtfilt(b, a, s)\n\n if rescale:\n #rescale filtered... | [
"0.67416304",
"0.62253124",
"0.61686134",
"0.61298764",
"0.61133033",
"0.60365754",
"0.6025106",
"0.593028",
"0.5900752",
"0.58414334",
"0.58083665",
"0.57891893",
"0.57846516",
"0.57718295",
"0.577108",
"0.57693815",
"0.57622135",
"0.57596284",
"0.5721743",
"0.5698967",
"0.5... | 0.7505937 | 0 |
given a 3D image, return the frame by frame averge by ROI number. | def roi_average(self,image3d,roiNumber):
assert roiNumber<len(self.rois)
return image_roi_average(image3d,self.rois[roiNumber]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_roi_average(img3d,roi):\n AVGs=np.empty(len(img3d))\n for frame in range(len(img3d)):\n values=np.empty(len(roi['area']))\n for i,pair in enumerate(roi['area']):\n values[i]=img3d[frame,pair[1],pair[0]]\n AVGs[frame]=np.average(values)\n #print(\"WARNING: LOWPASSI... | [
"0.7479218",
"0.5970928",
"0.5794377",
"0.5758532",
"0.5754576",
"0.57394356",
"0.5709834",
"0.5703441",
"0.5683379",
"0.56751555",
"0.5629606",
"0.5588582",
"0.5584365",
"0.55748296",
"0.55689776",
"0.5566228",
"0.55086094",
"0.5500038",
"0.54996157",
"0.54922295",
"0.547956... | 0.6538563 | 1 |
Returns the baseline G/R (1d array) of the given ROI). Lower percentile is used instead of baseline subtraction. | def deltaGoverR(self,roiNumber,baselinePercentile=20,method=2):
assert roiNumber<len(self.rois)
if method is 1:
# returns (dG)/R
G=self.roi_average(self.G,roiNumber)
BL=np.percentile(G[self.baselineFrames()],baselinePercentile)
return 100*(G-BL)/self.roi_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deltaGoverRs(self,baselinePercentile=20,save=True):\n self.dGoRs=np.empty((len(self.rois),len(self.timeH)))*np.nan\n for roiNum in range(len(self.rois)):\n try:\n self.dGoRs[roiNum]=self.deltaGoverR(roiNum,baselinePercentile)\n except:\n print(\... | [
"0.6215594",
"0.56141245",
"0.55357003",
"0.5462232",
"0.5440348",
"0.53966045",
"0.5372987",
"0.53280956",
"0.5324073",
"0.5307038",
"0.5286908",
"0.52231914",
"0.52146673",
"0.5204071",
"0.51973736",
"0.5187279",
"0.51863956",
"0.51751196",
"0.51731634",
"0.5165288",
"0.511... | 0.5851767 | 1 |
Creates the dG/R of every ROI (2d array, %dG/R). Just calls deltaGoverR() for every ROI. | def deltaGoverRs(self,baselinePercentile=20,save=True):
self.dGoRs=np.empty((len(self.rois),len(self.timeH)))*np.nan
for roiNum in range(len(self.rois)):
try:
self.dGoRs[roiNum]=self.deltaGoverR(roiNum,baselinePercentile)
except:
print("FAILED ON R... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deltaGoverR(self,roiNumber,baselinePercentile=20,method=2):\n assert roiNumber<len(self.rois)\n\n if method is 1:\n # returns (dG)/R\n G=self.roi_average(self.G,roiNumber)\n BL=np.percentile(G[self.baselineFrames()],baselinePercentile)\n return 100*(G-B... | [
"0.5692691",
"0.55820924",
"0.5340427",
"0.5324745",
"0.52920693",
"0.5245566",
"0.5106666",
"0.5057599",
"0.49684495",
"0.4905693",
"0.48922518",
"0.48829758",
"0.48698854",
"0.48355037",
"0.48055547",
"0.4801239",
"0.47966656",
"0.4770671",
"0.4765963",
"0.4762934",
"0.4761... | 0.66860396 | 0 |
Returns a list of frames in the 'baseline' tag. If that tag doesn't exist, return only the first frame. | def baselineFrames(self):
frames=[]
for tag,T1,T2 in [x for x in self.tags if x[0]=='baseline']:
for i,timePoint in enumerate(self.conf['times']):
if timePoint>=T1*60 and timePoint<=T2*60:
frames.append(i)
return frames
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_iaq_baseline(self) -> List[int]:\n # name, command, signals, delay\n return self._run_profile((\"iaq_get_baseline\", [0x20, 0x15], 2, 0.01))",
"def baseline(records, baseline_samples=40):\n if not len(records):\n return\n samples_per_record = len(records[0]['data'])\n\n # Ar... | [
"0.64950025",
"0.6423113",
"0.6206931",
"0.6019464",
"0.59429324",
"0.58945584",
"0.5440909",
"0.53897977",
"0.5387242",
"0.5373073",
"0.5372249",
"0.53293777",
"0.52745813",
"0.52477145",
"0.521149",
"0.52098405",
"0.5184785",
"0.5152884",
"0.51494724",
"0.5104601",
"0.50983... | 0.8266882 | 0 |
Show a delta G/R plot like you'd see in a publication. You can define rois individually, or plot them all. Averages may also be plotted (perhaps with stdev). You can save the figure (as PNG) and/or show it. | def figure_dGoR_roi(self,showEach=True,rois='all',
saveAs=False,show=None):
#TODO: average only plotted ROIs.
# prepare list of ROIs to plot
if type(rois) is str:
rois=list(range(len(self.rois)))
elif type(rois) == int:
rois=[int(rois)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot(self, step, rewards, losses):\n plt.figure(figsize=(20, 5))\n plt.subplot(131)\n plt.title('Total Episode Reward')\n plt.plot(rewards)\n plt.subplot(132)\n plt.title('MSE Loss')\n plt.plot(losses)\n plt.show()",
"def _plot(self, rewards, losses, e... | [
"0.6553822",
"0.6510721",
"0.64059585",
"0.6274427",
"0.62392783",
"0.62354237",
"0.6119872",
"0.61014044",
"0.6072218",
"0.59579444",
"0.59469134",
"0.5929419",
"0.58745337",
"0.58690023",
"0.5865823",
"0.5863542",
"0.5862734",
"0.5831095",
"0.5822547",
"0.581467",
"0.576031... | 0.72057134 | 0 |
Given an ROI (number), create a figure to show G, R, G/R, and d(G/R). | def figure_roi_inspect(self,roiNumber,percentile=(1,99),
saveAs=False,show=None):
channels=[[231,"CH1 (red) average",self.Ravg,'magenta'],
[232,"CH2 (green) average",self.Gavg,'green'],
[234,"G/R average",self.GoRavg,'gray'],
[235,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def figure_rois(self):\n channels=[[221,\"CH1 (red) average\",self.Ravg,'magenta'],\n [222,\"CH2 (green) average\",self.Gavg,'green'],\n [223,\"G/R average\",self.GoRavg,'gray'],\n [224,\"Gstd/Ravg\",self.Gstd/self.Ravg,'jet'],\n ]\n\n ... | [
"0.6339431",
"0.6246698",
"0.5650425",
"0.5491095",
"0.54502165",
"0.5386656",
"0.5363755",
"0.53122777",
"0.53117144",
"0.5304906",
"0.5303235",
"0.52893186",
"0.5276121",
"0.5276121",
"0.52473474",
"0.52464134",
"0.52404094",
"0.5237361",
"0.52111095",
"0.52088785",
"0.5204... | 0.67415607 | 0 |
deletes every nonnpy file in the save folder. | def cleanUp(self):
print(" cleaning up",self.folderSave)
for fname in glob.glob(self.folderSave+"/*.*"):
if not fname.endswith(".npy") and not fname.endswith(".csv"):
print(" deleting",os.path.basename(fname))
os.remove(fname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_save_name():\n clear_dir(MODEL_SAVE_DIR)\n clear_dir(SUMMARY_SAVE_DIR)\n clear_dir(IMG_SAVE_DIR)",
"def delete_leftovers(self):\n for each_file, artist in self.past_songs_db_data:\n if os.path.isfile(each_file): \n os.remove(each_file)\n print \"... | [
"0.6767967",
"0.673993",
"0.6701789",
"0.6633448",
"0.66288275",
"0.6587753",
"0.6565626",
"0.65655583",
"0.653942",
"0.65365565",
"0.64887315",
"0.6484406",
"0.6424238",
"0.63926363",
"0.6349127",
"0.6334342",
"0.63122845",
"0.63101",
"0.6306597",
"0.6299452",
"0.62974817",
... | 0.803143 | 0 |
Given a master folder containing a bunch of TSeries folders, process each of those TSeries folders. If mustContain is a string, only folders with that string in their folder name will be analyzed. | def index_tseries_all(folder,mustContain=False,reanalyze=False):
for fname in sorted(glob.glob(folder+"/TSeries-*")):
if mustContain and not mustContain in fname:
print(fname,"<-- skipping")
else:
index_tseries_single(fname,reanalyze,genIndex=False)
index_indexes(folder) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_monte(loc, runs):\n new_runs = []\n for r in runs:\n if 'MONTE' in r:\n for root, dirs, files in os.walk(os.path.join(loc, r)):\n for d in dirs:\n if 'RUN' in d:\n new_runs.append(os.path.join(r, d))\n break ... | [
"0.53159994",
"0.50963223",
"0.50252074",
"0.48984993",
"0.4873931",
"0.48572516",
"0.48539597",
"0.48504704",
"0.48401144",
"0.48164046",
"0.48130804",
"0.4792796",
"0.47268498",
"0.4668705",
"0.46603715",
"0.46588147",
"0.46547273",
"0.46494663",
"0.46088126",
"0.46025124",
... | 0.5822887 | 0 |
given a master folder, find all '/SWH2P/index.html' files and create a master index to them. | def index_indexes(folder,saveAs="index2.html"):
indexes=[]
saveAs=os.path.abspath(os.path.join(folder,saveAs))
for subFolder in glob.glob(folder+"/*/"):
if os.path.exists(subFolder+"/SWH2P/index.html"):
indexes.append(os.path.abspath(subFolder+"/SWH2P/index.html"))
html='<html><body... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_all_files(self, root_dir):\n pass",
"def create_path_and_index(subdir: str) -> None:\n if not os.path.exists(WEBOUT_PATH + subdir):\n os.makedirs(WEBOUT_PATH + subdir)\n create_blank_index(WEBOUT_PATH + subdir + \"index.html\")",
"def index_site() -> None:\n app = create_web_ap... | [
"0.64253676",
"0.6393964",
"0.6320134",
"0.5997497",
"0.59246576",
"0.59179205",
"0.58944166",
"0.5874091",
"0.5835972",
"0.58345187",
"0.58128005",
"0.580263",
"0.57776195",
"0.5764706",
"0.5756803",
"0.57511175",
"0.57256013",
"0.572",
"0.57150215",
"0.5685824",
"0.5683478"... | 0.68039715 | 0 |
check if the node is already added in the graph. If not, add the node and declare dict for storing prefix/suffix and weight | def add_node(self, node):
if node in self.node_set:
return
self.num_node = self.num_node + 1
self.node_set.add(node)
self.prefix[node] = {}
self.suffix[node] = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(self, node: Node):\n if node not in self.__graph_dict:\n self.__graph_dict[node] = []",
"def add_node(self, n):\r\n keys = self.d.keys()\r\n #check for node in graph\r\n if n not in keys:\r\n self.d.update({str(n): set()})",
"def add_node(self, nod... | [
"0.703877",
"0.69984454",
"0.6685165",
"0.65518063",
"0.6544979",
"0.6536636",
"0.6478059",
"0.6438793",
"0.6395167",
"0.6392988",
"0.63881314",
"0.6365691",
"0.6359163",
"0.63036823",
"0.6251448",
"0.62418115",
"0.62189555",
"0.6198953",
"0.6190167",
"0.61848694",
"0.6175110... | 0.7673769 | 0 |
remove edges between two nodes u is the prefix of v | def remove_edge(self, u, v):
try:
del self.prefix[v][u]
del self.suffix[u][v]
except:
print("ERROR: The edges not in graph") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_edge(self, u, v):\r\n elements = self.d.keys()\r\n #check for nodes in graph\r\n if u not in elements or v not in elements:\r\n raise KeyError(str(u) + \" and \" + str(v) + \" must be in graph\")\r\n #remove other node from each value set\r\n self.d[u].remov... | [
"0.6961871",
"0.6945348",
"0.6524405",
"0.6465725",
"0.6416186",
"0.6353857",
"0.6248376",
"0.6245896",
"0.6242955",
"0.61854666",
"0.6116636",
"0.596716",
"0.5910925",
"0.5883716",
"0.58649135",
"0.5849119",
"0.5820194",
"0.5815717",
"0.5813326",
"0.5791789",
"0.57850176",
... | 0.7971036 | 0 |
return number of edge by prefix or suffix of the node | def get_num_edge(self, node, direction):
if direction == 'prefix':
return len(self.prefix[node])
elif direction == 'suffix':
return len(self.suffix[node])
else:
print("""
Make sure you have key in the correct parameters.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_degree(self, node):\n \n try:\n return len(self.prefix[node])\n \n except:\n print(\"ERROR: The node does not exist.\")",
"def edge_count(self):\r\n return int(sum(self.degree(node) for node in range(self.size))/2)",
"def edgecount(self):\n\n ... | [
"0.65750366",
"0.6390569",
"0.6371768",
"0.62601626",
"0.6241744",
"0.61824644",
"0.6162332",
"0.61044914",
"0.6092629",
"0.608535",
"0.60482794",
"0.6045235",
"0.6018363",
"0.59623265",
"0.5848294",
"0.5796438",
"0.5789938",
"0.57475805",
"0.57451224",
"0.5731268",
"0.570590... | 0.8257913 | 0 |
return the number of subgraphs in the graph | def num_of_subgraphs(self):
G = self.to_undirected_graph()
count = G.num_subgraph()
print('The number of disconnected components in the graph is ', count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngraphs(self):\n return len(self.__graph_list)",
"def __len__(self):\n return len(self.subgraph_list)",
"def graph_count(self) -> int:\n return int(self.graph_tuple_stats.graph_count)",
"def __len__(self) -> int:\n return len(self.graphs)",
"def Nedges(self):\n return len... | [
"0.8073201",
"0.79633546",
"0.7285349",
"0.72463423",
"0.7187033",
"0.71759033",
"0.7161565",
"0.71102256",
"0.70808554",
"0.7021192",
"0.69902027",
"0.695379",
"0.6935887",
"0.6914862",
"0.68882954",
"0.68802977",
"0.68694854",
"0.6839879",
"0.6822821",
"0.679994",
"0.679574... | 0.86686105 | 0 |
return the edge that has minimum weight from a series of node | def find_min_weight(self, path, node):
min_edge = []
# assign edge weight first pair of node as min_weight
min_weight = self.get_weight(path[-1], node)
min_edge.append(path[-1])
min_edge.append(node)
# start from last node in path
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_min_weight_edge(self, weight, visited):\n minimum = INF\n min_index = None\n for v in range(self.vertices):\n if weight[v] < minimum and not visited[v]:\n minimum = weight[v]\n min_index = v\n return min_index",
"def min_neighbor_node... | [
"0.76575947",
"0.69813734",
"0.6833412",
"0.681978",
"0.67860854",
"0.6699366",
"0.6600109",
"0.6505628",
"0.650449",
"0.6501016",
"0.64986247",
"0.64281064",
"0.63960636",
"0.637293",
"0.6349893",
"0.62983257",
"0.628961",
"0.6272806",
"0.62529486",
"0.6231457",
"0.6231046",... | 0.77309334 | 0 |
remove cycle from the graph | def remove_cycle(self):
if self.is_cyclic() is True:
while self.is_cyclic():
min_edge = self.remove_cycle_recur()
self.remove_edge(min_edge[0], min_edge[1])
print("All the cycles are removed from the graph.")
else:
print("The graph ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanGraph(self,graph):\n i=0\n while i+1<len(graph):\n if self.getDistance(graph[i],graph[i+1])==0:\n del graph[i+1]\n else:\n i+=1\n return graph",
"def remove_cycle_helper(self, node, visited, path):\n \n visited.add(no... | [
"0.73683816",
"0.6554168",
"0.6548214",
"0.65214854",
"0.65176415",
"0.6499553",
"0.6371285",
"0.63669866",
"0.6364885",
"0.6312999",
"0.62595993",
"0.6174405",
"0.61596394",
"0.614464",
"0.61338407",
"0.61070246",
"0.61008537",
"0.6052887",
"0.6049411",
"0.60109544",
"0.5986... | 0.8347247 | 0 |
return the topological sorted nodes | def topological_sort(self):
visited = set()
sorted_node = []
# sort all the node in the graph
for i in self.node_set:
if i not in visited:
visited = self.topological_sort_helper(i, visited, sorted_node)
visited.clear()
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes_in_topological_order(self):\n if not self.sorted:\n self._topological_sort()\n return self._topological_order",
"def sorted_nodes(self):\n if self._sorted_nodes is None:\n self.sorting()\n return self._sorted_nodes",
"def topo_sort(self):\n # T... | [
"0.86757326",
"0.7941809",
"0.7831289",
"0.77638334",
"0.7723247",
"0.76890737",
"0.7553771",
"0.75459903",
"0.74956596",
"0.7480662",
"0.746987",
"0.746735",
"0.7387775",
"0.7338431",
"0.7337434",
"0.7197771",
"0.7197771",
"0.7084288",
"0.6985168",
"0.69776237",
"0.69662887"... | 0.8529063 | 1 |
perform transitive reduction on the graph | def transitive_reduction(self, sorted_node):
if self.is_cyclic() is False:
visited = set()
path = []
for i in sorted_node:
if i not in visited:
visited = self.transitive_reduction_helper(i, visited, path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitive_reduction_helper(self, node, visited, path):\n\n visited.add(node)\n path.append(node)\n \n for i in self.suffix[node].copy(): \n self.transitive_reduction_helper(i, visited, path)\n\n # determine if the prefix can be reduced\n ... | [
"0.6501194",
"0.61718416",
"0.5973364",
"0.57962114",
"0.57746035",
"0.5757504",
"0.5687268",
"0.5686101",
"0.5671033",
"0.5655539",
"0.562876",
"0.5624042",
"0.5591549",
"0.55154675",
"0.5511583",
"0.5511031",
"0.54999703",
"0.54662293",
"0.5427818",
"0.54190755",
"0.5412237... | 0.74065816 | 0 |
return the graph that has been reduced to best overlap graph proceed from removing the edge with the min weight | def filter_graph(self, sorted_node, ploidy):
for node in sorted_node:
# while number of prefix edge > ploidy level
while len(self.prefix[node]) > ploidy:
min_weight_node = min(self.prefix[node], key=self.prefix[node].get)
self.remove_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exact_min_vertex_cover(graph):\n for N in range(1,len(graph.nodes())+1):\n for graph_sub in it.combinations(sorted(graph.nodes(), reverse=True), N):\n graph_temp = graph.copy()\n graph_temp.remove_nodes_from(graph_sub)\n if len(graph_temp.edges()) == 0:\n ... | [
"0.660728",
"0.63847685",
"0.63119173",
"0.62551916",
"0.6219968",
"0.6182214",
"0.6149228",
"0.6107184",
"0.60990906",
"0.6067819",
"0.59592104",
"0.5955457",
"0.59368974",
"0.5917554",
"0.5895752",
"0.58931464",
"0.5879703",
"0.5871705",
"0.5870311",
"0.5862259",
"0.5817303... | 0.7260723 | 0 |
return the superbubbles in graph | def superbubble_detection(self, sorted_node):
source = sorted_node[0]
path = []
bubble = {}
# transverse topologically sorted node
for i in sorted_node:
count_prefix = 0
# check if it is the exit of bubble
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAncestors():",
"def _bubble(self, c, sigma):\n ax = logical_and(self._neigx > c[0]-sigma,\n self._neigx < c[0]+sigma)\n ay = logical_and(self._neigy > c[1]-sigma,\n self._neigy < c[1]+sigma)\n return outer(ax, ay)*1.",
"def graph(self)... | [
"0.60287493",
"0.58140856",
"0.5644865",
"0.56226814",
"0.5621479",
"0.5582052",
"0.55558234",
"0.54799724",
"0.541736",
"0.53860945",
"0.53245956",
"0.53174645",
"0.53121185",
"0.53104234",
"0.5295514",
"0.5272587",
"0.526781",
"0.5255505",
"0.5250299",
"0.52500135",
"0.5241... | 0.64109683 | 0 |
Declare an extrn symbol. | def extrn(self, name):
if name in self.symbols:
raise Redeclaration(name)
self.symbols[name] = Symbol(name, 'extrn', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSymbol(self, address: ghidra.program.model.address.Address, name: unicode, makePrimary: bool) -> ghidra.program.model.symbol.Symbol:\n ...",
"def MakeSymbolName(self,content):\n return self.register(SymbolName(content,reg=self))",
"def createSymbol(self, address: ghidra.program.model.ad... | [
"0.60258573",
"0.5883859",
"0.5747088",
"0.5738443",
"0.5723495",
"0.5706114",
"0.5654179",
"0.5617745",
"0.5538224",
"0.55351937",
"0.55130404",
"0.5489159",
"0.5488434",
"0.5477479",
"0.54550415",
"0.5438278",
"0.5433852",
"0.5413047",
"0.5368802",
"0.53409994",
"0.5340571"... | 0.7677975 | 0 |
Lookup a symbol. If implicit_extrn is True and this is the first fetch of this variable, declare it as an extrn. Otherwise, it must be a label. | def fetch(self, name, implicit_extrn=False):
if name not in self.symbols:
if implicit_extrn:
self.extrn(name)
else:
self.label(name, None)
return self.symbols[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extrn(self, name):\n if name in self.symbols:\n raise Redeclaration(name)\n self.symbols[name] = Symbol(name, 'extrn', None)",
"def resolve_symbol(self, symbol):\n if symbol in self.labels:\n return self.labels[symbol]\n if symbol in PREDEFINED_MEM:\n ... | [
"0.6169494",
"0.5972883",
"0.5459213",
"0.5338175",
"0.5249722",
"0.52001464",
"0.5198688",
"0.51028335",
"0.5051382",
"0.5046638",
"0.5035687",
"0.49785256",
"0.49657345",
"0.49439415",
"0.49278852",
"0.48954237",
"0.48881257",
"0.48838553",
"0.48028132",
"0.47846344",
"0.47... | 0.7447887 | 0 |
For each kind of descriptor, compute a meta descriptor encoding a sub area of the total image. | def _compute_meta_descriptors(self, outputs):
for v in self._variances:
outputs[v + '_meta_desc'] = self._compute_meta_descriptor(
outputs['raw_' + v], self.vlad_layers[v]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scalarInfo(img, cnt):\n\tm = cntInfo(img, cnt)\n\td = {\"perimeter\":m[\"perimeter\"], \"oreientation\":m[\"orientation\"], \"solidity\":m[\"solidity\"],\"height\":m[\"height\"], \"extent\":m[\"extent\"], \"aspect ratio\":m[\"aspect ratio\"], \"area\":m[\"area\"], \"sum intensity\":m[\"sum intensity\"], \"widt... | [
"0.56884176",
"0.56321985",
"0.5531493",
"0.51598287",
"0.5115131",
"0.5110594",
"0.51022947",
"0.506333",
"0.49924102",
"0.4918009",
"0.49160764",
"0.4901871",
"0.48966342",
"0.48910174",
"0.48507077",
"0.4849521",
"0.48342612",
"0.48136494",
"0.48012587",
"0.4793972",
"0.47... | 0.59809315 | 0 |
Gets the reason of this CardBlockRequest. | def reason(self) -> str:
return self._reason | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reason(self) -> str:\n return pulumi.get(self, \"reason\")",
"def getreason(self):\n return self.__reason",
"def reason(self) -> Optional[str]:\n return self._reason",
"def Reason(self):\n if self.force_auto_sync:\n self.get('Reason')\n return self._Reason",
... | [
"0.71660304",
"0.71028066",
"0.6880529",
"0.6835825",
"0.67449474",
"0.6725266",
"0.67087805",
"0.6672109",
"0.6413535",
"0.6385302",
"0.62738997",
"0.622205",
"0.6151032",
"0.6070554",
"0.59448934",
"0.5927387",
"0.5874492",
"0.5781728",
"0.57482886",
"0.57043654",
"0.562187... | 0.7185133 | 0 |
Sets the reason of this CardBlockRequest. | def reason(self, reason: str):
self._reason = reason | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reason(self, reason):\n\n self._reason = reason",
"def reason(self, reason: ConfirmClaimRequestpropertiesReason):\n if reason is None:\n raise ValueError(\"Invalid value for `reason`, must not be `None`\") # noqa: E501\n\n self._reason = reason",
"def reason(self, reason):\... | [
"0.7403091",
"0.6910681",
"0.67546326",
"0.6032213",
"0.5873592",
"0.58431584",
"0.5818502",
"0.5811183",
"0.5774912",
"0.5589284",
"0.55496687",
"0.55214894",
"0.55205685",
"0.55125827",
"0.54951584",
"0.5462187",
"0.5295989",
"0.52650696",
"0.524958",
"0.5178163",
"0.510312... | 0.73440963 | 1 |
Gets the source_audit of this CardBlockRequest. | def source_audit(self) -> SourceAudit:
return self._source_audit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSource(self):\n return self.__source",
"def getSource(self):\n return self.source",
"def Source(self):\r\n\t\treturn self._get_attribute('source')",
"def get_source(self):\n return self.source",
"def source_audit(self, source_audit: SourceAudit):\n\n self._source_audit = ... | [
"0.6085202",
"0.60144895",
"0.5894504",
"0.5844087",
"0.58139217",
"0.57429355",
"0.57429355",
"0.57429355",
"0.57429355",
"0.57429355",
"0.57119244",
"0.57057965",
"0.5669427",
"0.5646263",
"0.56192684",
"0.55895394",
"0.55484444",
"0.5453853",
"0.5453853",
"0.5453853",
"0.5... | 0.76474404 | 0 |
Sets the source_audit of this CardBlockRequest. | def source_audit(self, source_audit: SourceAudit):
self._source_audit = source_audit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_flow_source(self, source):\n self._source = source",
"def source_audit(self) -> SourceAudit:\n return self._source_audit",
"def setAddressSource(self, address_source):\n # type: (str)->None\n\n self._validator.validate_one(\n 'source', VALID_OPTS['source'], addres... | [
"0.5957494",
"0.566332",
"0.5647799",
"0.5565775",
"0.55316824",
"0.55316824",
"0.55316824",
"0.55316824",
"0.55316824",
"0.55316824",
"0.55316824",
"0.5481093",
"0.546279",
"0.5437351",
"0.542086",
"0.5414173",
"0.5371826",
"0.5371163",
"0.5370105",
"0.53390163",
"0.53390163... | 0.7956447 | 0 |
Add sample (stddev,corrcoeff) to the Taylor diagram. args and kwargs are directly propagated to the Figure.plot command. | def add_sample(self, stddev, corrcoef, *args, **kwargs):
l, = self.ax.plot(np.arccos(corrcoef), stddev,
*args, **kwargs) # (theta,radius)
self.samplePoints.append(l)
return l | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_sample(self, stddev, corrcoef, *args, **kwargs):\n\n l, = self.ax.plot(NP.arccos(corrcoef), stddev,\n *args, **kwargs) # (theta,radius)\n self.samplePoints.append(l)\n\n return l",
"def add_sample(self, stddev, corrcoef, *args, **kwargs):\n sc = self.... | [
"0.6757501",
"0.65829",
"0.65829",
"0.5692774",
"0.5514722",
"0.5509461",
"0.54691994",
"0.54640293",
"0.54410326",
"0.54265124",
"0.5407961",
"0.54050523",
"0.5370153",
"0.5349401",
"0.53469855",
"0.53199446",
"0.53075475",
"0.52938116",
"0.5289785",
"0.52767354",
"0.5266633... | 0.68189937 | 0 |
Add constant centered RMS difference contours. | def add_rms_contours(self, levels=5, **kwargs):
rs, ts = np.meshgrid(np.linspace(self.smin, self.smax),
np.linspace(0, np.pi / 2))
# Compute centered RMS difference
rms = np.sqrt(self.refstd**2 + rs**2 - 2 *
self.refstd * rs * np.cos(ts))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_contours(self, levels=5, **kwargs):\n\n rs, ts = NP.meshgrid(NP.linspace(self.smin, self.smax),\n NP.linspace(0, NP.pi/2))\n # Compute centered RMS difference\n rms = NP.sqrt(self.refstd**2 + rs**2 - 2*self.refstd*rs*NP.cos(ts))\n\n contours = self.ax... | [
"0.58924735",
"0.58924735",
"0.5853381",
"0.5553739",
"0.53997827",
"0.5385587",
"0.5280881",
"0.5254052",
"0.5211319",
"0.51522267",
"0.508421",
"0.5068785",
"0.5061027",
"0.4950682",
"0.4928843",
"0.487059",
"0.48605928",
"0.48431018",
"0.48383564",
"0.48283488",
"0.4820034... | 0.68430185 | 0 |
Add a curved line with a radius of std between two points [std, corr1] and [std, corr2] | def add_stddev_contours(self, std, corr1, corr2, **kwargs):
t = np.linspace(np.arccos(corr1), np.arccos(corr2))
r = np.zeros_like(t) + std
return self.ax.plot(t, r, 'red', linewidth=2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_contours(self, std1, corr1, std2, corr2, **kwargs):\n\n t = np.linspace(np.arccos(corr1), np.arccos(corr2))\n r = np.linspace(std1, std2)\n\n return self.ax.plot(t, r, 'red', linewidth=2)",
"def add_sample(self, stddev, corrcoef, *args, **kwargs):\n\n l, = self.ax.plot(np.arcc... | [
"0.68652004",
"0.57863116",
"0.5751419",
"0.5751419",
"0.5670405",
"0.5355617",
"0.53522384",
"0.52992535",
"0.5248331",
"0.52457625",
"0.5242233",
"0.5220162",
"0.5207517",
"0.51971936",
"0.51946145",
"0.5194268",
"0.51777804",
"0.5150461",
"0.50821924",
"0.50783974",
"0.506... | 0.7493696 | 0 |
Add a line between two points [std1, corr1] and [std2, corr2] | def add_contours(self, std1, corr1, std2, corr2, **kwargs):
t = np.linspace(np.arccos(corr1), np.arccos(corr2))
r = np.linspace(std1, std2)
return self.ax.plot(t, r, 'red', linewidth=2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_stddev_contours(self, std, corr1, corr2, **kwargs):\n\n t = np.linspace(np.arccos(corr1), np.arccos(corr2))\n r = np.zeros_like(t) + std\n return self.ax.plot(t, r, 'red', linewidth=2)",
"def draw_line(cvs, p1, p2, antialias):\n xs, ys = np.array([p1[0], p2[0]]), np.array([p1[1], ... | [
"0.73186386",
"0.6330753",
"0.6172619",
"0.6076223",
"0.60636544",
"0.60072315",
"0.5959107",
"0.59067386",
"0.58517635",
"0.5826788",
"0.5796374",
"0.57432646",
"0.5697054",
"0.56763124",
"0.56763124",
"0.5629721",
"0.5583803",
"0.55724424",
"0.556278",
"0.5562631",
"0.55447... | 0.66322917 | 1 |
Predict the prevalence of the positive class, otherwise called response fraction Input stimulus refSamples C | def infer_prevalence(self, stimulus, refSamples, C):
predict_prevalence = np.zeros(stimulus.size)
for j in range(stimulus.size):
predict_prevalence[j] = infer_prevalence(self.pars,
stimulus[j],
refSamples, C)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_pro(self, samples):\n if self.fit_intercept:\n samples = self.__add_intercept(samples)\n return self.__sigmod(np.dot(samples, self.weight))",
"def recall(qtd_true_positives, list_of_true_positive_documents, ref=0):\n\n\tfn = 0\n\tfor d in list_of_true_positive_documents:\n\t\... | [
"0.62712324",
"0.6223435",
"0.6087985",
"0.6056025",
"0.6040623",
"0.6028583",
"0.60005635",
"0.59807616",
"0.59600836",
"0.5928466",
"0.5899224",
"0.5894624",
"0.5866199",
"0.5861603",
"0.58466834",
"0.5838378",
"0.58365655",
"0.583102",
"0.58299696",
"0.57993054",
"0.579344... | 0.6870069 | 0 |
Does a search on items in a word list on spotify api to get track ids | def get_track_id_from_word_list():
auth_header = get_auth_header()
file = open("Spotify_Random_Playlist_Generator\search_list.txt", 'r')
count = 0
#last failed index = 43, 108, 301, 458
#tracks saved = 5822, 10019, ?, 3228
index = 458
#get words without \n
file_lines = file.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spotify_tracklist():\n sp = credentials()\n chart = chartdata()\n trackid_list = []\n #find a way to get track IDS\n for track in chart:\n searchQuery = track[0]\n searchResults = sp.search(q=searchQuery, limit=1, type='track', market=\"US\")\n trackid_list.append(searchResu... | [
"0.72295976",
"0.6520772",
"0.6324297",
"0.62383896",
"0.61299515",
"0.61180586",
"0.60814196",
"0.603637",
"0.59122217",
"0.5902133",
"0.58748233",
"0.58666617",
"0.5857717",
"0.58297074",
"0.5817832",
"0.5796036",
"0.5729023",
"0.571359",
"0.5684976",
"0.5629297",
"0.561635... | 0.7679729 | 0 |
Test creation of agent model and ensure proper database entry is created | def test_agent_creation():
agent = AgentFactory()
agent.name = 'agent test name'
agent.save()
assert agent.name == 'agent test name' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_database_object_can_be_created(self):\n database = generate_database_object()",
"def test_create(self):\n pass",
"def test_create_record(self):\n pass",
"def test_create_run(self):\n pass",
"def test_create_activity(self):\n pass",
"def test_create_scenario(sel... | [
"0.7028632",
"0.6890748",
"0.67822415",
"0.6711665",
"0.6650198",
"0.664975",
"0.6587109",
"0.65455353",
"0.6520005",
"0.64628804",
"0.6453338",
"0.6415676",
"0.6367579",
"0.63672197",
"0.6364511",
"0.634559",
"0.63355756",
"0.6300233",
"0.6289619",
"0.628875",
"0.6281613",
... | 0.80221206 | 0 |
Test creation of customer model and ensure proper database entries are created | def test_customer_creation():
agent = AgentFactory()
customer = CustomerFactory(agent=agent)
assert agent == customer.agent
customer.name = 'customer test name 1'
customer.customer_type = 'hom'
customer.save()
assert customer.name == 'customer test name 1'
customer.name = 'customer tes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_customer_create(self):\n self._create_model(\"customer\", self.customer_data, [\"name\", \"email\", \"phone\"])",
"def test_create_customer_success(self):\n customer = Customer.objects.create(**customer_data)\n\n self.assertTrue(isinstance(customer, Customer))\n self.assertEq... | [
"0.9037479",
"0.7929487",
"0.7815056",
"0.7810243",
"0.78039974",
"0.7660339",
"0.75118303",
"0.73750347",
"0.7290455",
"0.7232011",
"0.7226966",
"0.72233826",
"0.7200086",
"0.7174529",
"0.7131517",
"0.70323175",
"0.7030921",
"0.70296866",
"0.70179826",
"0.70053357",
"0.69812... | 0.79592866 | 1 |
Test creation of quote model and ensure proper database entries are created | def test_quote_creation():
agent = AgentFactory()
customer = CustomerFactory(agent=agent)
quote = QuoteFactory(customer=customer)
assert quote.customer.agent == agent
assert quote.customer == customer
quote.address = "123 Test St. Newark, CA"
quote.new_quote = True
quote.price = 100.00
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init(self):\n self.assertEqual(self.new_quote.id,23)\n self.assertEqual(self.new_quote.author,'J.F.Kenedy')\n self.assertEqual(self.new_quote.quote,'never Give up')",
"def test_create_order(self):\n self.assertEqual(Order.objects.count(), 1)",
"def test_database_object_can_... | [
"0.73205185",
"0.6861714",
"0.66376954",
"0.6607822",
"0.6576269",
"0.6574195",
"0.6541732",
"0.65118575",
"0.64529586",
"0.6439316",
"0.6426955",
"0.64018846",
"0.6347831",
"0.63333225",
"0.6329495",
"0.63246757",
"0.63226277",
"0.6300234",
"0.6296156",
"0.6288043",
"0.62559... | 0.7030059 | 1 |
Check to see if the number is divisible by all possible 3 digit substrings. | def substring_divisible(number):
string = str(number)
for offset in xrange(1, len(string)-2):
substring = string[offset:offset+3]
# print '%s / %d' % (substring, PRIMES[offset-1])
if int(substring) % PRIMES[offset-1]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_divisible(num, n):\n return num % n == 0",
"def concats_divisible_by_divisors(num_string: str) -> bool:\n \n # check if all concatenated numbers are divisible by divisors in DIVISORS\n for i in range(divisor_count):\n # form number by concatenating digits of num_string\n indi... | [
"0.68361807",
"0.6700276",
"0.66646105",
"0.65157944",
"0.65157944",
"0.64472467",
"0.6445171",
"0.6416292",
"0.64152324",
"0.6393683",
"0.6390676",
"0.636498",
"0.6359953",
"0.63241255",
"0.6315646",
"0.62723976",
"0.6238878",
"0.6234731",
"0.6212701",
"0.6184209",
"0.617644... | 0.824374 | 0 |
Orders the output data frame in the correct format. | def order_output(self):
self.output = self.output[self.cols] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_outputdf(self):\n keys = self.info_df['Trace'].values.tolist()\n frame = deepcopy([line.df for line in self.info_df['Line'].values.tolist()])\n for i in range(len(frame)):\n df = frame[i]\n num = list(range(len(df)))\n angle_gr = list(map(deg2grad,df['... | [
"0.6386336",
"0.6304658",
"0.60655826",
"0.59718025",
"0.5926101",
"0.5876387",
"0.5807852",
"0.5783987",
"0.5767403",
"0.5697308",
"0.5649952",
"0.5644205",
"0.563268",
"0.56028485",
"0.5589636",
"0.5558761",
"0.5553007",
"0.55476147",
"0.55371463",
"0.55236256",
"0.55236256... | 0.75799704 | 0 |
Populates the 'Location' and 'Position' attributes of the output data frame. | def generate_position_data(self):
# populate 'Location' field randomly
self.output['Location'] = np.random.choice(self.locations, self.obs)
# clean up geodata data frame and create 'Position' attribute
nc = self.geodata[['Lat', 'Lng', 'Elevation']].round(2)
nc['Elevation'] = nc[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_polling_location_txt(self):\n self.base_df['address_line'] = self.base_df.apply(\n lambda row: self.get_address_line(row['index'], row['address1'], row['address2'], row['city'],\n row['state'], row['zip_code']), axis=1)\n\n self.base_d... | [
"0.62895596",
"0.6167864",
"0.5798795",
"0.56739914",
"0.559937",
"0.5570834",
"0.55245775",
"0.55079836",
"0.5503302",
"0.55030453",
"0.54448843",
"0.54265153",
"0.540338",
"0.53972685",
"0.53596455",
"0.5354807",
"0.5341209",
"0.5332801",
"0.5316041",
"0.53142416",
"0.52993... | 0.7951581 | 0 |
Populates the 'Local Time' field by location, using a date range from a randomly selected start date. | def generate_time_data(self):
# generate random dates and append to a list
sd = self.start_date
ed = self.end_date
dates = [random_date(start=sd, end=ed) for d in range(0, self.obs)]
# convert to ISO 8601 format and update "Local Time" field
self.output['Local Time'] = m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_time_loc_unit(self, table_types):\n t = table_types()\n t['a'] = Time(self.time, format='isot', scale='utc',\n location=EarthLocation(1,2,3, unit='km'))\n\n table, hdr = time_to_fits(t)\n\n # Check the header\n hdr['OBSGEO-X'] == t['a'].location.x.to... | [
"0.5427438",
"0.53565097",
"0.53078413",
"0.51943207",
"0.5110164",
"0.509749",
"0.5057534",
"0.5047616",
"0.50202024",
"0.4998468",
"0.49949226",
"0.49803096",
"0.4934281",
"0.49197945",
"0.49164397",
"0.49080452",
"0.49006557",
"0.48999467",
"0.48908088",
"0.48737174",
"0.4... | 0.6537657 | 0 |
Populates the 'Temperature', 'Humidity', and 'Pressure' attributes using historical values calculated on a monthly level. | def generate_weather_data(self):
months = pd.to_datetime(self.output['Local Time']).dt.month
self.output['Month'] = months # set month values for later joins
# merge output data frame with historical data to get ranges
keys = ['Location', 'Month']
m = pd.merge(self.output, self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_temperature_values(self):\n year = self._current_date.year\n month = self._current_date.month\n\n self.ensure_temperatures(dt.date(year, month, 15))\n self.set_temperature_arrays(dt.date(year, month, 15))",
"def __populate_historical_trade_data(self):\n\n trade_data ... | [
"0.7055962",
"0.60502565",
"0.5943409",
"0.58105415",
"0.57932097",
"0.57503676",
"0.57128704",
"0.5700356",
"0.5683397",
"0.56795806",
"0.5653718",
"0.56241685",
"0.55628806",
"0.5554878",
"0.5512449",
"0.54554194",
"0.54337835",
"0.5432135",
"0.54099226",
"0.53980225",
"0.5... | 0.6786752 | 1 |
Testing code for the methods written for the Fifteen Puzzle solver | def run_suite():
# create a TestSuite (and an object)
suite = poc_simpletest.TestSuite()
# create scrumbled boards to test the solver methods with
init_board = [[15, 16, 0, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [1, 2, 17, 18, 19]]
PuzzleBoard0 = solver.Puzzle(4, 5, init_board)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_solution(self):\n pass",
"def test_solve_task(self):\n pass",
"def test_is_solved(self):\n p = hw.TilePuzzle([[1, 2], [3, 0]])\n self.assertTrue(p.is_solved())\n p = hw.TilePuzzle([[0, 1], [3, 2]])\n self.assertFalse(p.is_solved())",
"def test_puzzle_har... | [
"0.77490586",
"0.7196642",
"0.7029969",
"0.70047534",
"0.69888854",
"0.68187547",
"0.6817368",
"0.6812827",
"0.67931575",
"0.67918605",
"0.67844784",
"0.67478377",
"0.67454064",
"0.67426723",
"0.67191386",
"0.6667318",
"0.66313934",
"0.66267616",
"0.66141",
"0.66141",
"0.6611... | 0.72510237 | 1 |
True ZODB was connected. | def is_connected(self) -> bool:
return hasattr(_app_ctx_stack.top, "zodb_connection") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_connected(self):\n if not self._host:\n if self._database:\n return True\n else:\n return False\n else:\n return self._factory.is_connected()",
"def is_connected(self):\n if self.connected and self.connack_rec:\n ... | [
"0.77997726",
"0.768575",
"0.7641867",
"0.75732785",
"0.7569566",
"0.7555719",
"0.7487968",
"0.7477421",
"0.74618804",
"0.74609774",
"0.744961",
"0.7449495",
"0.7432927",
"0.74114513",
"0.7406131",
"0.7391242",
"0.73453254",
"0.7340854",
"0.7340854",
"0.7339016",
"0.73242414"... | 0.8251572 | 0 |
Return the current transfer counts for the current connection | def transfers(self):
return _app_ctx_stack.top.zodb_connection.getTransferCounts() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getconnectioncount(self):\n return self.proxy.getconnectioncount()",
"def bytes_transferred(self):\n return self._bytes_transferred",
"def number_transfers(self, quota):\n if self.elected:\n return len(self.first_votes) - quota\n else:\n return 0",
"def t... | [
"0.725359",
"0.6573824",
"0.6572507",
"0.64971364",
"0.64769197",
"0.64439213",
"0.6375509",
"0.62791693",
"0.6235836",
"0.6204822",
"0.617409",
"0.617409",
"0.6149532",
"0.6119608",
"0.6060948",
"0.6019507",
"0.60131615",
"0.6007676",
"0.6007676",
"0.59899485",
"0.5987723",
... | 0.8200511 | 0 |
Reads input log file, parses for x,y pose data and calls a plot function. | def logplot(in_dir, fname, xlim, ylim, title):
with open(in_dir + fname,'r') as logfile:
lf_lines = logfile.readlines()
traj_x = []
traj_y = []
for row in lf_lines:
if row[:4] == 'pose':
#print(float(row[10:-2]))
tup = row[7:]
sep_pos = tup.find(' ,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(self, log_dir):\n if not os.path.isfile(log_dir):\n raise Exception('Please ensure that you enter log file path using \\'-l\\'')\n\n df = pd.read_csv(log_dir)\n headers = list(df)[1:]\n x_axis = list(df)[0]\n df.plot(x=x_axis, y=headers, grid=True, style='-')\... | [
"0.63495785",
"0.5932129",
"0.5927451",
"0.5868104",
"0.5818082",
"0.5720938",
"0.57115245",
"0.5659857",
"0.56433",
"0.5629294",
"0.56244123",
"0.56195736",
"0.55641747",
"0.55357873",
"0.5524778",
"0.54822934",
"0.54796195",
"0.54770964",
"0.54689604",
"0.545383",
"0.544263... | 0.7878952 | 0 |
Returns a key hexed from random bytes at the given length for crypto. | def GenerateRandomHexKey(length=_RANDOM_BYTE_LENGTH):
# After encoded in hex, the length doubles.
return os.urandom(length).encode('hex') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __generate_key(length):\n if length % 2 != 0:\n raise ValueError(\"'length' must be a multiple of 2\")\n length_bytes = int(length / 2) # length of key in bytes\n key_bytes = os.urandom(length_bytes)\n return binascii.hexlify(key_bytes).decode()",
"def genKey(length=32... | [
"0.83131474",
"0.8192357",
"0.8062324",
"0.7946797",
"0.7785568",
"0.778308",
"0.7620973",
"0.7614206",
"0.76092666",
"0.7577782",
"0.7569808",
"0.7401408",
"0.73823965",
"0.73588",
"0.72859305",
"0.7280881",
"0.7273216",
"0.7152287",
"0.70835525",
"0.7049502",
"0.70331925",
... | 0.8589039 | 0 |
Returns a secret key for the user and creates it on demand. | def GetSecretKey(cls, user_id):
uid = hashlib.sha256(str(user_id)).hexdigest()
entity = ndb.Key(cls, uid).get()
if not entity:
entity = cls(id=uid, secret_key=GenerateRandomHexKey())
entity.put()
return entity.secret_key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self):\n id_access_secretkey = uuid.uuid4()\n id_webuser = Base.logged_id_webuser or None\n keys = Token().generate_secretkey(config.PACKAGE_NAME)\n\n with Database() as db:\n db.insert(Table(id_access_secretkey, id_webuser, config.PACKAGE_NAME,\n ... | [
"0.7324596",
"0.72214526",
"0.72132105",
"0.7090786",
"0.6981754",
"0.68352497",
"0.6779381",
"0.6758661",
"0.6754858",
"0.6733832",
"0.673319",
"0.66629153",
"0.66599303",
"0.6649016",
"0.6635857",
"0.66297954",
"0.6534042",
"0.65165365",
"0.6507127",
"0.64891934",
"0.648668... | 0.72581303 | 1 |
Encode the tree representation into a list representation. | def to_list(self):
root = self.label
if len(self.children) > 0:
children = [c.to_list() for c in self.children]
else:
children = []
return [root, [children]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self, root):\n if not root:\n return []\n res = [root.val] + [self.serialize(root.left)] + [self.serialize(root.right)] \n # print(res)\n return res",
"def aslist(self, **kwargs):\n return [tree.copy() for tree in self.trees(**kwargs)]",
"def serializ... | [
"0.68143153",
"0.6790135",
"0.6761439",
"0.67127454",
"0.66836816",
"0.6619445",
"0.6607104",
"0.6606354",
"0.6601269",
"0.6555694",
"0.6451154",
"0.64063966",
"0.6398278",
"0.63337296",
"0.62684506",
"0.623983",
"0.6233243",
"0.6203131",
"0.6194114",
"0.618758",
"0.6153098",... | 0.6941849 | 0 |
Return the set of labels in the tree. | def labels_set(self):
if len(self.children) == 0:
return {self.label}
else:
children_labels = set()
for c in self.children:
children_labels = children_labels | c.labels_set()
return set([self.label]) | children_labels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_labels(self) -> Set[str]:",
"def get_labels(self):\n return set(k.label for k in self)",
"def get_labels(self):\n return set(category.label for category in\n self.get_categories(LABELS_SCHEME))",
"def labels(cls) -> FrozenSet[str]:\n return cls._meta.labels",
"def lab... | [
"0.8310455",
"0.8003972",
"0.7718051",
"0.747817",
"0.74677056",
"0.743571",
"0.74325526",
"0.7376549",
"0.7335723",
"0.72463816",
"0.72463816",
"0.72463816",
"0.72463816",
"0.72463816",
"0.72463816",
"0.72325975",
"0.72159684",
"0.7163361",
"0.71344405",
"0.71293837",
"0.710... | 0.83989704 | 0 |
Test empty metadata as produced by TaskWrapper. | def test_empty_metadata(self):
self.include_metadata = True
self.include_work_dir_outputs = False
self.job_wrapper.metadata_line = ' '
# Empty metadata command do not touch command line.
expected_command = _surround_command("%s; return_code=$?; cd '%s'" % (MOCK_COMMAND_LINE, self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_builddict_empty(self):\r\n # We don't care _that_ much that execution be silent. Nice if at least\r\n # one test executes the task and doesn't explode, tho.\r\n self.assertEqual('', self.execute_task())",
"def testMetadata(self):\n self.assertGreater(len(self.unauth.metadata(self.dataset... | [
"0.69131213",
"0.66285217",
"0.65700155",
"0.65433896",
"0.64699525",
"0.6389835",
"0.63616544",
"0.62794167",
"0.623913",
"0.6233621",
"0.62330127",
"0.61613744",
"0.6152688",
"0.613188",
"0.61033595",
"0.61027807",
"0.6100446",
"0.60455775",
"0.6030086",
"0.6000621",
"0.595... | 0.7516191 | 0 |
Should mark the import as error, and write an error for the missing columns | def test_missing_columns(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,messaging consent,edd year,edd month,baby dob year,"
b"baby dob month,baby dob day\n",
)
form = MomConnectImportForm(
data={"source": "MomConnect Import"}, files={"file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_throw(self,stage):\n if self.is_table_info == False:\n print(\"please enter table info by table_info()\")\n sys.exit(0)\n if stage == 'rank':\n if self.import_method == 'none':\n self.error_output_import()\n elif stage == 'output':\n ... | [
"0.64449805",
"0.6280456",
"0.62718606",
"0.6264621",
"0.62620723",
"0.6237717",
"0.62326837",
"0.62005895",
"0.61623615",
"0.61306417",
"0.60901326",
"0.60772496",
"0.6076609",
"0.60497916",
"0.6022188",
"0.60181355",
"0.60033184",
"0.60019606",
"0.59792775",
"0.59725654",
"... | 0.6646303 | 0 |
research_consent should have a valid value | def test_invalid_research_consent(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,facility code,id type,id number,messaging consent,"
b"research_consent,edd year,edd month,edd day,baby dob year,"
b"baby dob month,baby dob day\n"
b"+27820001001,1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_research_consent_default(self):\n file = SimpleUploadedFile(\n \"test.csv\",\n b\"msisdn,facility code,id type,id number,messaging consent,\"\n b\"research_consent,edd year,edd month,edd day,baby dob year,\"\n b\"baby dob month,baby dob day\\n\"\n ... | [
"0.6556687",
"0.5967552",
"0.59195745",
"0.5886712",
"0.5884561",
"0.5853548",
"0.58495194",
"0.58094496",
"0.57835925",
"0.57113624",
"0.55745965",
"0.5566579",
"0.5560272",
"0.555966",
"0.5551175",
"0.5516704",
"0.5510434",
"0.5482361",
"0.5415021",
"0.5409777",
"0.5343834"... | 0.6772131 | 0 |
research_consent should default to False | def test_research_consent_default(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,facility code,id type,id number,messaging consent,"
b"research_consent,edd year,edd month,edd day,baby dob year,"
b"baby dob month,baby dob day\n"
b"+27820001001,1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patient_consent(self):\n return 1 if self.patient_consent_date is not None else 0",
"def patient_consent(self):\n return self.patient_consent_date != None # noqa: E711",
"def screening_e_consent_flag(self, screening_e_consent_flag):\n\n self._screening_e_consent_flag = screening_e_con... | [
"0.5945645",
"0.5705167",
"0.5302114",
"0.5273008",
"0.5265113",
"0.52543366",
"0.51404434",
"0.50720304",
"0.50387293",
"0.5028184",
"0.5001957",
"0.4994958",
"0.4991718",
"0.4969628",
"0.49488336",
"0.49355793",
"0.493464",
"0.49285325",
"0.49206492",
"0.49000403",
"0.48879... | 0.5845754 | 1 |
previous_optout should have a valid value | def test_invalid_previous_optout(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,facility code,id type,id number,messaging consent,"
b"previous_optout,edd year,edd month,edd day,baby dob year,"
b"baby dob month,baby dob day\n"
b"+27820001001,123... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testoptdone(self):\r\n assert self.data.optdone\r\n assert numpy.all(numpy.abs(self.data.geovalues[-1]) <= self.data.geotargets)",
"def optOut(self):\n self._updateOptOut('opt_out')",
"def testoptdone(self):\r\n assert self.data.optdone\r\n target_e, target_g, target_s = ... | [
"0.6026479",
"0.596915",
"0.59580666",
"0.5917056",
"0.5910894",
"0.58836484",
"0.58515966",
"0.5697169",
"0.56677574",
"0.5589641",
"0.5576127",
"0.5495089",
"0.5460744",
"0.5431634",
"0.5323369",
"0.53164595",
"0.5295722",
"0.5234297",
"0.52237314",
"0.5212482",
"0.5210892"... | 0.6120908 | 0 |
dob is required for none id type | def test_idtype_dob(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,facility code,id type,messaging consent,edd year,edd month,"
b"edd day,baby dob year,baby dob month,baby dob day\n"
b"+27820001001,123456,none,true,2021,2,3,,,\n",
)
form = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dob_field(self):\n dob_field = self.record.find('field[@name=\\'dob\\']')\n dob_date = datetime.strptime(dob_field.text, '%Y-%m-%d %H:%M:%S')\n self.assertTrue(isinstance(dob_date, datetime), 'Date isn\\'t correct')",
"def test_patient_one_date_of_birth(self):\r\n self.assert... | [
"0.6857196",
"0.62779737",
"0.62635475",
"0.6136365",
"0.613052",
"0.6085115",
"0.60663915",
"0.59972715",
"0.59574336",
"0.59203374",
"0.5918133",
"0.59066415",
"0.58619964",
"0.5858407",
"0.5855922",
"0.5793606",
"0.5792784",
"0.57353854",
"0.57253164",
"0.5723704",
"0.5720... | 0.6909169 | 0 |
dob should be a valid date | def test_invalid_dob(self):
file = SimpleUploadedFile(
"test.csv",
b"msisdn,facility code,id type,messaging consent,edd year,edd month,"
b"edd day,dob year,dob month,dob day,baby dob year,baby dob month,"
b"baby dob day\n"
b"+27820001001,123456,none,tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dob_field(self):\n dob_field = self.record.find('field[@name=\\'dob\\']')\n dob_date = datetime.strptime(dob_field.text, '%Y-%m-%d %H:%M:%S')\n self.assertTrue(isinstance(dob_date, datetime), 'Date isn\\'t correct')",
"def birthdate_validator(birthdate):\n max_year = birthdate.re... | [
"0.79484457",
"0.7276426",
"0.714593",
"0.6983303",
"0.69634765",
"0.69538075",
"0.69061834",
"0.6879649",
"0.68692034",
"0.6865753",
"0.67990154",
"0.67990154",
"0.6733425",
"0.6720168",
"0.668135",
"0.6642073",
"0.6623905",
"0.6616593",
"0.66149586",
"0.66113603",
"0.660532... | 0.72920334 | 1 |
Ping all running nodes | def rosnode_ping_all(verbose=False):
master = rosnode.rosgraph.Master(rosnode.ID)
try:
state = master.getSystemState()
except rosnode.socket.error:
raise rosnode.ROSNodeIOException("Unable to communicate with master!")
nodes = []
for s in state:
for t, l in s:
no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lnet_ping(self):\n try:\n nodes = Conf.get(self._index, 'cluster>server_nodes')\n except:\n raise MotrError(errno.EINVAL, \"Server nodes not found\")\n\n check_type(nodes, dict, \"server_nodes\")\n\n nids = get_nids(self, nodes)\n\n sys.stdout.write(\"lnet pinging on all nodes in c... | [
"0.7102116",
"0.6910679",
"0.6757321",
"0.6623002",
"0.64989126",
"0.63570446",
"0.62056553",
"0.61354077",
"0.61152244",
"0.61062026",
"0.6055285",
"0.60534537",
"0.59831697",
"0.59796685",
"0.5970946",
"0.59675807",
"0.5954365",
"0.5951595",
"0.5859234",
"0.58462834",
"0.58... | 0.70204407 | 1 |
This is a semihidden routine for cleaning up stale node registration information on the ROS Master. The intent is to remove this method once Master TTLs are properly implemented. | def rosnode_cleanup():
pinged, unpinged = rosnode_ping_all()
if unpinged:
master = rosnode.rosgraph.Master(rosnode.ID)
rosnode.cleanup_master_blacklist(master, unpinged)
return pinged, unpinged | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_registered_nodes(self):\n self.__nodes.clear()\n self.__names.clear()\n self.__aliases.clear()",
"def destroy(self):\n del self.nodes\n self.nodes = {}",
"def clean_registries(self):\n registry = self.connection.get_finished_registry(name=self.name)\n ... | [
"0.6292442",
"0.6288391",
"0.6160538",
"0.61364675",
"0.5995464",
"0.5958893",
"0.59078294",
"0.58937675",
"0.57813525",
"0.5770071",
"0.5698018",
"0.56488544",
"0.5646381",
"0.56252265",
"0.56191456",
"0.5608486",
"0.5607572",
"0.5599541",
"0.5586419",
"0.55753237",
"0.55684... | 0.7028323 | 0 |
Read randomaccess file on positions given as unicode string | def ra_unicode_read(fh, start, end):
tmp_pos = fh.tell()
fh.seek(0)
buf = u""
iter_fh = (line.decode('utf-8') for line in fh)
for line in iter_fh:
line_len = len(line)
# .. recalibrate start/end ...
if line_len < start:
start = start - line_len
if en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_read(infile, nbytes, start_offset, num_samples): \n\tseq = \"\"\n\twhile len(seq) < num_samples:\n\t\t# Assuming 1 byte chars.\n\t\tstartidx = random.randint(start_offset, nbytes - num_samples)\n\t\tinfile.seek(startidx)\n\n\t\tseq = \"\"\n\t\tfor line in infile:\n\t\t\tfor ch in line:\n\t\t\t\tif is_va... | [
"0.5925096",
"0.591352",
"0.5852963",
"0.5843576",
"0.5791898",
"0.57870597",
"0.57750916",
"0.5763844",
"0.5758523",
"0.57421714",
"0.57094836",
"0.56960773",
"0.5681039",
"0.5644694",
"0.562519",
"0.5601118",
"0.5593286",
"0.5566989",
"0.55620193",
"0.5552162",
"0.5550878",... | 0.5996268 | 0 |
Opens a second and waits till a client connects. Then sends the map updates till the client disconnects. Start over. | def run(self):
while not self.setup() and self.running:
pass
while self.running:
# Create a byte array to receive the computed maps
mapb = bytearray(self.MAP_SIZE_PIXELS * self.MAP_SIZE_PIXELS)
# Get final map
self.slam.getmap(mapb)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_map(self):\n if self._send_name:\n self._send_string(self._name)\n self._done_sending()\n self._send_name = False\n logging.info(\"---NEW TURN---\")\n recv = self._get_string()\n\n if recv == \"\":\n self.close()\n self.d... | [
"0.5948128",
"0.5948128",
"0.5912513",
"0.5863806",
"0.5813158",
"0.5696389",
"0.5692664",
"0.5674981",
"0.56618327",
"0.56504405",
"0.5645965",
"0.5635372",
"0.56345457",
"0.56252253",
"0.5622779",
"0.561738",
"0.55454177",
"0.55443925",
"0.55346435",
"0.5533475",
"0.552013"... | 0.6564271 | 0 |
installs packages using aptdcon (waits for apt to be free) | def aptdcon_install(packages: Iterable, delete_debs=True):
packages = sorted(set(packages))
print(f"Installing {' '.join(packages)}")
packages_in_quotes = (f'"{p}"' for p in packages)
command = ('aptdcon', '--hide-terminal', '--install', *packages_in_quotes)
# https://askubuntu.com/questions/132059/how-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apt_install(pkgs):\n return run([\"apt-get\", \"install\", \"-y\"] + list(pkgs))",
"def apt_packages(apt_packages):\n packages = reduce(lambda a, x: \"%s %s\" % (a, x), apt_packages, '')\n sudo(\"apt-get -y install %s &> /dev/null\" % packages)",
"def apt(conf):\n proc = subprocess.Popen(\n ... | [
"0.80230325",
"0.75827897",
"0.757094",
"0.7311718",
"0.7161689",
"0.693189",
"0.6829693",
"0.6787234",
"0.6776966",
"0.67361",
"0.6661351",
"0.66015506",
"0.6565081",
"0.6563814",
"0.64341074",
"0.6428863",
"0.64157003",
"0.6412461",
"0.63777494",
"0.63136494",
"0.630359",
... | 0.77327996 | 1 |
Check for common worthless features that preclude the need for any further processing. If UA string is not worthless, process against normalizing regexes. Some client User Agent strings such as Antivirus services add file version information that is of no use outside the application itself. Remove such information to p... | def normalize(self):
normalized = self.all_details.get('normalized', '')
if normalized:
return normalized
if self.is_digit():
self.all_details['normalized'] = 'Numeric'
elif self.is_uuid():
self.all_details['normalized'] = 'UUID'
elif self.is_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent():\n ua_list = [\n\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50\",\n\"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50\",\n\"Mozilla/5.0 (compatible; MSIE ... | [
"0.59508073",
"0.5567024",
"0.55373317",
"0.55285686",
"0.53682196",
"0.53230673",
"0.52816755",
"0.52816755",
"0.525382",
"0.5248616",
"0.52296937",
"0.5206499",
"0.5195623",
"0.5127395",
"0.50619835",
"0.50361603",
"0.49984938",
"0.49487025",
"0.4929719",
"0.49234223",
"0.4... | 0.58029103 | 1 |
Add data to secondary_client details | def supplement_secondary_client_data(self, app_idx):
data = {
'name': app_idx.pretty_name(),
'version': app_idx.version(),
'type': 'generic',
}
self.client.secondary_client.update(data)
try:
self.all_details['client']['secondary_client'].up... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_details(self, value):\n self._client_details = value",
"def __set_client_detail(self):\r\n ClientDetail = self.client.factory.create('ClientDetail')\r\n ClientDetail.AccountNumber = self.config_obj.account_number\r\n ClientDetail.MeterNumber = self.config_obj.meter_number\r... | [
"0.63887924",
"0.63267803",
"0.62598485",
"0.5535828",
"0.53982127",
"0.53977334",
"0.5377849",
"0.5368721",
"0.52181464",
"0.5194819",
"0.5177076",
"0.5168567",
"0.5168567",
"0.51539075",
"0.514536",
"0.51118016",
"0.5107409",
"0.5107135",
"0.5090947",
"0.5048622",
"0.502776... | 0.756209 | 0 |
Parses the UA for client information using the Client parsers | def parse_client(self) -> None:
if self.client:
return
app_idx = ApplicationIDExtractor(self.user_agent)
app_id = app_idx.extract().get('app_id', '')
for Parser in self.CLIENT_PARSERS:
parser = Parser(
self.user_agent,
self.ua_has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parsing():\n # User Agents\n user_agents = '''\nAvailable User-Agents:\n winxpie60 Internet Explorer 6.0 (Windows XP)\n winxpie61 Internet Explorer 6.1 (Windows XP)\n winxpie70 Internet Explorer 7.0 (Windows XP)\n winxpie80 Interne... | [
"0.590148",
"0.5350632",
"0.5285229",
"0.5257975",
"0.51484895",
"0.5117726",
"0.5089743",
"0.5084178",
"0.50023645",
"0.49971578",
"0.49957904",
"0.49457458",
"0.491224",
"0.49110934",
"0.48702016",
"0.48244387",
"0.4816928",
"0.4802733",
"0.47705266",
"0.4741134",
"0.474016... | 0.70403004 | 0 |
Parses the UA for Device information using the Device or Bot parsers | def parse_device(self) -> None:
if self.device or self.skip_device_detection:
return
for Parser in self.DEVICE_PARSERS:
parser = Parser(
self.user_agent,
self.ua_hash,
self.ua_spaceless,
self.VERSION_TRUNCATION,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_device_info(self, info_string):\n device = {}\n block_list = [\"[\\x1b[0;\", \"removed\"]\n if not any(keyword in info_string for keyword in block_list):\n try:\n device_position = info_string.index(\"Device\")\n except ValueError:\n ... | [
"0.5927514",
"0.5856839",
"0.5822313",
"0.5555496",
"0.5500421",
"0.544209",
"0.5427536",
"0.5419593",
"0.5386314",
"0.53571004",
"0.5274734",
"0.52526796",
"0.52368134",
"0.5220131",
"0.51558113",
"0.51438075",
"0.5080555",
"0.5068006",
"0.5054993",
"0.5048496",
"0.5041046",... | 0.74597013 | 0 |
Parses the UA for bot information using the Bot parser | def parse_bot(self) -> None:
if not self.skip_bot_detection and not self.bot:
self.bot = Bot(
self.user_agent,
self.ua_hash,
self.ua_spaceless,
self.VERSION_TRUNCATION,
).parse()
self.all_details['bot'] = self.bo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parsing():\n # User Agents\n user_agents = '''\nAvailable User-Agents:\n winxpie60 Internet Explorer 6.0 (Windows XP)\n winxpie61 Internet Explorer 6.1 (Windows XP)\n winxpie70 Internet Explorer 7.0 (Windows XP)\n winxpie80 Interne... | [
"0.5815526",
"0.576538",
"0.5530181",
"0.5361174",
"0.5238907",
"0.5186696",
"0.51807165",
"0.51636994",
"0.5147042",
"0.51430947",
"0.51146054",
"0.50761336",
"0.50038475",
"0.49923426",
"0.4892667",
"0.4833916",
"0.48253688",
"0.48065528",
"0.47575602",
"0.47519308",
"0.474... | 0.74724376 | 0 |
Parses the UA for Operating System information using the OS parser | def parse_os(self) -> None:
if not self.os:
self.os = OS(
self.user_agent,
self.ua_hash,
self.ua_spaceless,
self.VERSION_TRUNCATION,
).parse()
self.all_details['os'] = self.os.ua_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_os_info(self):\n pipe = subprocess.Popen([self.core_exe, '-o'], 0, None, None, subprocess.PIPE)\n lines = pipe.stdout.readlines()\n x = 0\n json_str = ''\n while x < len(lines):\n json_str += lines[x].decode('utf-8').strip()\n x += 1\n decod... | [
"0.7051689",
"0.62823594",
"0.60854435",
"0.59581906",
"0.59486276",
"0.5879036",
"0.5805302",
"0.57024014",
"0.56578296",
"0.5619709",
"0.56172025",
"0.56043786",
"0.5574878",
"0.55164677",
"0.5508888",
"0.5484248",
"0.5480448",
"0.5469822",
"0.5436326",
"0.5410858",
"0.5402... | 0.81483954 | 0 |
All detected feature phones running Android are more likely a smartphone | def android_feature_phone(self) -> bool:
try:
return self.device.dtype() == 'feature phone' and self.os.family() == 'Android'
except AttributeError:
pass
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def androidDetectDevices():\n\tdevices = []\n\ttry:\n\t\tif (sys.platform == 'win32'):\n\t\t\tadb_output = check_output([\"adb\",\"devices\"])\n\t\t\tif len(adb_output) > 28:\n\t\t\t\tdevices = adb_output\n\t\telse:\n\t\t\tadb_output = subprocess.Popen([\"adb\",\"devices\"], stdout=subprocess.PIPE)\n\t\t\tgrep_out... | [
"0.6254344",
"0.58775765",
"0.57957834",
"0.5762953",
"0.5729878",
"0.5661511",
"0.5618693",
"0.56150615",
"0.5606316",
"0.5501489",
"0.54904604",
"0.54254305",
"0.5363985",
"0.5363047",
"0.5329461",
"0.5323508",
"0.52952904",
"0.52948785",
"0.52868885",
"0.5285169",
"0.52705... | 0.6730855 | 0 |
Devices running Kylo or Espital TV Browsers are assumed to be a TV | def is_television(self) -> bool:
if self.client_name() in ('Kylo', 'Espial TV Browser'):
return True
return TV_FRAGMENT.search(self.user_agent) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supported_features(self):\n return SUPPORT_LGSMARTTV",
"def usefulFunction():\n print(platform.uname()) #displayed this computer's specifications",
"def platform():\n return \"micaz\"",
"def platform(self):\n return self.random.choice([\n 'Laptop', \n 'Desktop', ... | [
"0.5744891",
"0.5734308",
"0.56359726",
"0.5561529",
"0.5514246",
"0.54529834",
"0.5396307",
"0.5392471",
"0.5379869",
"0.5369017",
"0.5355782",
"0.535401",
"0.5341236",
"0.5328208",
"0.5269777",
"0.5269777",
"0.5269777",
"0.5269777",
"0.5269777",
"0.5269777",
"0.5269777",
... | 0.6768258 | 0 |
Load default storage factory. | def storage_factory(self):
return load_or_import_from_config(
'SIPSTORE_FILE_STORAGE_FACTORY', app=self.app
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storage_factory():\n return storage(transaction.manager, **kwargs)",
"def default_storage(request):\n return import_by_path(settings.MESSAGE_STORAGE)(request)",
"def storage_factory(cls, prefix, storage_cls=None, storage_uri=None):\n\n key_prefix = '{}_{}_'.format(cls.__name__.upper(), pre... | [
"0.65856045",
"0.6405212",
"0.6322174",
"0.627396",
"0.62665975",
"0.6103902",
"0.60754937",
"0.6054778",
"0.6051295",
"0.5982906",
"0.5955662",
"0.59248656",
"0.59177333",
"0.5910031",
"0.58968294",
"0.58762205",
"0.58672637",
"0.58549625",
"0.58389825",
"0.58333415",
"0.576... | 0.7609113 | 0 |
Return the archive location URI. | def archive_location(self):
name = self.app.config['SIPSTORE_ARCHIVER_LOCATION_NAME']
return Location.query.filter_by(name=name).one().uri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_path(self):\n return os.path.join(self.destination_directory, self.__archive_name__)",
"def getArchiveURI(sha1,archivePath,fileType='jpg'):\n (sha1Path,filename)=getSha1Path(sha1)\n return(archivePath+'/'+sha1Path+'/'+filename+'.'+fileType)",
"def location_uri(self) -> Optional[str]:\n ... | [
"0.7043057",
"0.69406134",
"0.66881",
"0.6617685",
"0.65890115",
"0.6554932",
"0.6544251",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6534544",
"0.6497794",
"0.6494776",
"0.6486501",
"0.6429628",
"0.6412059",
"0.63765144",
"0.6333575",
"0.6287437",
... | 0.83230734 | 0 |
Set the message token/channel, then call the bas class constructor. | def _construct_message(self):
self.message = {"token": self._auth, "channel": self.channel}
super()._construct_message() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, message):\n self.message = message",
"def __init__(self, message):\n self.message = message",
"def __init__(self, message):\n self.message = message",
"def __init__(self, message, *args, **kwargs):\n self.message = message\n super().__init__(*args, **kwar... | [
"0.7340327",
"0.7340327",
"0.7340327",
"0.7285108",
"0.7276043",
"0.72251916",
"0.72251916",
"0.7214396",
"0.7208427",
"0.71547794",
"0.7151964",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.71008223",
"0.7... | 0.74445486 | 0 |
Build a binary tree with the given elements | def build_tree(elements):
print("Building tree with these elements:",elements)
root = BinarySearchTreeNode(elements[0])
for i in range(1, len(elements)):
root.add_child(elements[i])
return root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tree(arr):\n\n for i in range(len(arr)):\n arr, val = mid(arr)\n\n if i == 0: \n binary = BinaryNode(val)\n\n else:\n binary.insert(val)\n\n return binary",
"def build():\n # root = TreeNode(5)\n # root.left = TreeNode(2)\n # root.right = Tree... | [
"0.7232607",
"0.71041435",
"0.68787444",
"0.68639416",
"0.6812087",
"0.6794115",
"0.66795504",
"0.6610092",
"0.6553841",
"0.6519083",
"0.6499353",
"0.6482064",
"0.64559954",
"0.64536077",
"0.64274764",
"0.6410858",
"0.63792187",
"0.63171667",
"0.62927115",
"0.6289411",
"0.626... | 0.85262054 | 0 |
Function to extract all gateways from data file. Takes data from file "cells_abcd.csv". Returns | def get_all_gateways():
gateways: List[Gateway] = []
with open("/home/agora/Documents/Popular_paths/Data/saint_foy/saint_foy/cells_abcd.csv", "r") as f:
csv_reader = csv.reader(f, delimiter = ';')
for line in csv_reader:
if line[0] == 'ci': # Title line
pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bus_routes():\n route_list = []\n os.chdir(\"../Data\")\n for file in glob.glob(\"*.csv\"):\n print(file)\n reader = csv.reader(open(file))\n for line in reader:\n route=extract_bus_route(line[3]) #Journey ID field\n if route not in route_list and route!=\"\"... | [
"0.55952203",
"0.54756844",
"0.53670186",
"0.5285604",
"0.5249518",
"0.5228122",
"0.52078974",
"0.518618",
"0.5115791",
"0.51021045",
"0.5073642",
"0.50566363",
"0.50187373",
"0.49812573",
"0.49712855",
"0.49188593",
"0.4918186",
"0.48839107",
"0.48824528",
"0.4854182",
"0.48... | 0.75958407 | 0 |
Host to which the HTTP server should bind. | def host(self):
return '127.0.0.1' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHost():",
"def getHost():",
"def get_host(self):\n return '{}://{}{}'.format(self.protocol, self.host, self.port)",
"def server_address():\n return '127.0.0.1'",
"def bind_server(self):\n self.MAIN_CONNECTION.bind((self.HOST, self.PORT))",
"def host(self):\r\n return self._... | [
"0.7170153",
"0.7170153",
"0.71659726",
"0.7077862",
"0.70450103",
"0.6980777",
"0.6967813",
"0.6858179",
"0.680847",
"0.680847",
"0.680847",
"0.680847",
"0.680847",
"0.680847",
"0.680847",
"0.6787266",
"0.67810446",
"0.67719537",
"0.6771787",
"0.6766853",
"0.6754981",
"0.6... | 0.72355944 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.