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 |
|---|---|---|---|---|---|---|
tf.Node > String > [tf.Variable]? > (tf.Op, tf.Op) Create an Adam optimiser operation, along with an operation for initialising only the variables used internally by the optimiser. | def default_adam_optimiser_with_initialiser(loss_node, name, variables=None):
optimiser = tf.train.AdamOptimizer(name=name + ".adam_optimiser")
return (
optimiser.minimize(loss_node, var_list=variables, name=name + ".minimise"),
tf.variables_initializer(optimiser.variables()),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_adam_optimiser(loss_node, name, variables=None):\n return tf.train.AdamOptimizer(name=name + \".adam_optimiser\").minimize(\n loss_node, var_list=variables, name=name + \".minimise\"\n )",
"def create_Adam_op(loss, alpha, beta1, beta2, epsilon):\n\n optimizer = tf.train.AdamOptimizer(... | [
"0.7339279",
"0.7098565",
"0.68570757",
"0.6683464",
"0.6683464",
"0.6646473",
"0.65805656",
"0.62965107",
"0.62862504",
"0.61791027",
"0.6176915",
"0.61711526",
"0.61447394",
"0.61211",
"0.610805",
"0.610314",
"0.608412",
"0.6071762",
"0.6050657",
"0.59981775",
"0.5984885",
... | 0.7426982 | 0 |
LossNode > String > [tf.Variable]? > Optimiser Create an Adam optimiser with default learning parameters set to minimise the given loss node. | def default_adam_optimiser(loss_node, name, variables=None):
return tf.train.AdamOptimizer(name=name + ".adam_optimiser").minimize(
loss_node, var_list=variables, name=name + ".minimise"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_adam_optimiser_with_initialiser(loss_node, name, variables=None):\n optimiser = tf.train.AdamOptimizer(name=name + \".adam_optimiser\")\n return (\n optimiser.minimize(loss_node, var_list=variables, name=name + \".minimise\"),\n tf.variables_initializer(optimiser.variables()),\n ... | [
"0.77614534",
"0.65809083",
"0.64527076",
"0.64447564",
"0.628383",
"0.627875",
"0.62308496",
"0.61939293",
"0.6152135",
"0.614899",
"0.60573304",
"0.6016081",
"0.6007274",
"0.5994265",
"0.5990766",
"0.590552",
"0.58883333",
"0.58883333",
"0.58530587",
"0.5850922",
"0.5848501... | 0.80250835 | 0 |
tf.Tensor > tf.Tensor > String > tf.Tensor Create a node which measures the accuracy of a predictor as compared to a target node, where the prediction is considered correct if it is on the same side of 0.5 as the target. | def accuracy(prediction_node, target_node, name):
prediction_positive = tf.less(0.5, prediction_node)
target_positive = tf.less(0.5, target_node)
correct = tf.equal(prediction_positive, target_positive)
correct_floats = tf.cast(correct, tf.float32)
return tf.reduce_mean(correct_floats, name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(pred, target):\n N = pred.shape[0]\n return (pred == target).sum() * 1.0 / N",
"def accuracy(predictions, targets):\n return accuracy",
"def compute_accuracy(self):\n self.test_predictions = tf.cast(tf.argmax(self.test_logits, 1), tf.int32)\n correct = tf.equal(self.data.test_labels, se... | [
"0.7079352",
"0.6912245",
"0.6909229",
"0.68987846",
"0.6858103",
"0.662857",
"0.6624069",
"0.66183066",
"0.6618164",
"0.660678",
"0.65963423",
"0.6563165",
"0.6493501",
"0.6467855",
"0.6448372",
"0.64231324",
"0.6413067",
"0.64091104",
"0.6404787",
"0.63856125",
"0.638258",
... | 0.80452174 | 0 |
load the simulated trajectories of 2D Ising model. | def load_ising(lattice=10, seed=1, sim_steps=100000, init='random',
value=1, progress_bar=True, pbar_mode=None, **kwargs):
np.random.seed(seed)
sim = Ising2DSimulator(lattice=lattice, relax_step=sim_steps, use_step=sim_steps, **kwargs)
traj = sim.run(init=init, value=value, progress_bar=progr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(self):\n try:\n self.model = Word2Vec.load(self.config[\"model_path\"])\n self.model.init_sims(replace=True)\n except Exception as e:\n print(e)\n print(\"error in model loading!\")",
"def load_model(self):\n self.pred_net.load((self.sav... | [
"0.58747417",
"0.5863853",
"0.58609813",
"0.5859702",
"0.5719889",
"0.5703873",
"0.56517583",
"0.5564063",
"0.55619967",
"0.55362326",
"0.5523201",
"0.55176467",
"0.55116284",
"0.54991645",
"0.5489901",
"0.54735005",
"0.54502994",
"0.5447441",
"0.5440734",
"0.5426373",
"0.541... | 0.60248286 | 0 |
Load the folding pathway example of the protein HP35. | def load_pathway(path_idx=1, preprocess=True):
assert path_idx in [1, 2], 'Unavailable index, must be 1 or 2.'
url = f'https://raw.githubusercontent.com/PengTao-HUST/GDNB/master/data/pathway{path_idx}.txt'
cache_dir = sys.modules['gdnb'].__path__[0] + '/data/'
if not os.path.exists(cache_dir):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_a_path(self, id_fold, id_file):\n# print(id_fold, id_file)\n# print(self.List_of_dir)\n# print(self.List_of_files)\n pair_name = self.List_of_files[self.List_of_dir[id_fold]][id_file]\n input_name, output_name = convertion_name(pair_name)\n input_path = os.path.jo... | [
"0.52677524",
"0.52157503",
"0.5115826",
"0.5113141",
"0.5112162",
"0.5068445",
"0.49790227",
"0.4888651",
"0.48835805",
"0.48501226",
"0.48230326",
"0.48149526",
"0.48038372",
"0.4798549",
"0.4793103",
"0.47747013",
"0.47707465",
"0.47684556",
"0.4762963",
"0.4757433",
"0.47... | 0.530141 | 0 |
Load the gene expression data of the muscle of mouses. | def load_muscle(preprocess=True, mean_cut=None):
url = f'https://raw.githubusercontent.com/PengTao-HUST/GDNB/master/data/muscle.txt'
cache_dir = sys.modules['gdnb'].__path__[0] + '/data/'
if not os.path.exists(cache_dir):
os.makedirs(cache_dir)
data_file = os.path.basename(url)
full_path ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_gene_data_from_file(self) -> None:\n logger.info(\"Loading genes data from file\")\n if not self.gene_data or len(self.gene_data.items()) == 0:\n self.gene_data = {}\n file_path = self._get_cached_file(cache_path=self.gene_data_cache_path, file_source_url=self.gene_data... | [
"0.5836877",
"0.54561037",
"0.5377903",
"0.5307625",
"0.5304628",
"0.529156",
"0.52851266",
"0.52428126",
"0.5229348",
"0.52247983",
"0.52221364",
"0.5196699",
"0.5191041",
"0.51657045",
"0.51443344",
"0.51357305",
"0.51070154",
"0.50811136",
"0.5071482",
"0.504506",
"0.50239... | 0.57791704 | 1 |
Create an executable script. In case a py_script_mode has been set to create a .py script the shell is expected to have the PATHEXT environment variable to include ".PY" in order to properly launch the command without the .py extension. | def create_executable_script(filepath, body, program=None, py_script_mode=None):
from rez.config import config
from rez.utils.platform_ import platform_
program = program or "python"
py_script_mode = py_script_mode or config.create_executable_script_mode
# https://github.com/AcademySoftwareFoundati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_executable(filename):\n st = os.stat(filename)\n os.chmod(filename, st.st_mode | stat.S_IEXEC)",
"def test_create_script(executable, expected):\n filename = os.path.join(tempfile.gettempdir(), \"hello_world\")\n text = \"echo 'Hello World'\"\n\n create_script(filename, text, executable)\n... | [
"0.62161857",
"0.5928515",
"0.5896043",
"0.58740044",
"0.58740044",
"0.58740044",
"0.5815193",
"0.5796866",
"0.57856506",
"0.57607824",
"0.5744096",
"0.5706912",
"0.5616298",
"0.5598501",
"0.5583095",
"0.5580723",
"0.55441135",
"0.5540947",
"0.5527958",
"0.55124485",
"0.54778... | 0.7708163 | 0 |
Evaluates the py_script_mode for the requested filepath on the given platform. | def _get_python_script_files(filepath, py_script_mode, platform):
script_filepaths = []
base_filepath, extension = os.path.splitext(filepath)
has_py_ext = extension == ".py"
is_windows = platform == "windows"
if (
py_script_mode == ExecutableScriptMode.single
or py_script_mode == Ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pyscript(fp, **context):\n try:\n exec fp in context\n except SystemExit:\n pass\n return context['response']",
"def is_py_script(item: str):\n is_it_py_script : bool = False\n ext : str = \".py\"\n if ext in item:\n is_it_py_script = True\n ...\n\n return is_... | [
"0.59299475",
"0.5714231",
"0.5451267",
"0.54345316",
"0.5409861",
"0.5405886",
"0.53852355",
"0.5385079",
"0.53622746",
"0.5346597",
"0.5294189",
"0.52576613",
"0.52226037",
"0.5182986",
"0.51810735",
"0.51808757",
"0.51706356",
"0.51338667",
"0.5133775",
"0.51278734",
"0.51... | 0.5955449 | 0 |
Create a 'forwarding' script. A forwarding script is one that executes some arbitrary Rez function. This is used internally by Rez to dynamically create a script that uses Rez, even though the parent environment may not be configured to do so. | def create_forwarding_script(filepath, module, func_name, *nargs, **kwargs):
from rez.utils.platform_ import platform_
if platform_.name == "windows" and \
os.path.splitext(filepath)[-1].lower() != ".cmd":
filepath += ".cmd"
doc = dict(
module=module,
func_name=func_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_hookscript (\n fspath, filename, root, HOOK_SCRIPT_CLS=self.HOOK_SCRIPT_CLS\n ):\n return HOOK_SCRIPT_CLS ( fspath, filename=filename )",
"def fastforward(self):\n self.run_command('fastforward')",
"def create_proxy(proxyname):\n # Running in a software collection?\n en... | [
"0.541581",
"0.53856206",
"0.53378963",
"0.53307",
"0.5269018",
"0.51131356",
"0.50167906",
"0.49951193",
"0.49066535",
"0.49001172",
"0.48973036",
"0.48971385",
"0.4863548",
"0.48512775",
"0.48252502",
"0.48138702",
"0.47785538",
"0.4777733",
"0.47680974",
"0.47633788",
"0.4... | 0.78955215 | 0 |
This function stores memory transitions. It takes in the current state, the action taken, the reward received, and the resulting state. | def store_transition(self, state, action, reward, new_state):
# Compute index and store transition data
index = self.memory_counter % self.max_mem_size
self.memory[index, :] = np.hstack((state, [action, reward], new_state))
# Increment counter for next index
self.memory_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store(self, state, action, reward, next_state, done):\n self.replay_memory.append((state, action, reward, next_state, done))",
"def _add_to_memory(self, state, action, next_state, reward, done):\n if len(self.memory) >= self.size_max_memory:\n self.memory.pop(0)\n self.memory ... | [
"0.78003925",
"0.7743828",
"0.7680608",
"0.7605921",
"0.74234176",
"0.7423264",
"0.7420604",
"0.7280403",
"0.7150004",
"0.7060317",
"0.70299804",
"0.70268667",
"0.70176506",
"0.69925076",
"0.69925076",
"0.69904715",
"0.69667745",
"0.6926161",
"0.6858057",
"0.6842293",
"0.6714... | 0.82133657 | 0 |
This function performs batch learning. It does random sampling of state transitions through the memory space to converge to an optimal strategy. It uses a target counter to keep track of how often we replace the target network | def learn(self, batch_size, target_cntr):
# Update target parameter and learn step counter
if self.learn_step_counter % target_cntr == 0:
self.Q_target.load_state_dict(self.Q_eval.state_dict())
self.learn_step_counter += 1
# Select a random sub-sample of memory and get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learn(self):\r\n \r\n # take a mini-batch from replay experience\r\n cur_batch_size = min(len(self.replay_exp), self.batch_size)\r\n mini_batch = random.sample(self.replay_exp, cur_batch_size)\r\n \r\n # batch data\r\n sample_states = np.ndarray(shape = (cur_bat... | [
"0.6701833",
"0.6621242",
"0.65925276",
"0.65663385",
"0.6558445",
"0.6551062",
"0.6511524",
"0.6504481",
"0.6503476",
"0.6485344",
"0.6481118",
"0.6474066",
"0.6470951",
"0.6459082",
"0.6435035",
"0.6432022",
"0.63968164",
"0.635988",
"0.6323439",
"0.6313047",
"0.6299505",
... | 0.7006806 | 0 |
Searches logs for id by company shorthand or id | def searchLogs(self, searchTerm):
ids = list(self.LOGS.keys())
if "by_date" in ids: ids.remove("by_date")
for id in ids:
if searchTerm.lower() == id.lower() or self.LOGS.get(id).get("companyShorthand") == searchTerm.upper():
return id
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_log_id(xcresult_path):\n parsed = xcresulttool_json('get', '--path', xcresult_path)\n actions = parsed['actions']['_values']\n action = actions[-1]\n\n result = action['actionResult']['logRef']['id']['_value']\n _logger.debug('Using log id %s', result)\n return result",
"def get_log(ident):\n r... | [
"0.59049225",
"0.5751372",
"0.57136863",
"0.5603779",
"0.55185336",
"0.5462903",
"0.5444954",
"0.54432875",
"0.5276768",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",
"0.5239232",... | 0.7500952 | 0 |
Adds a new work item to the logs | def addNewWorkItem(self, id, company, companySH, summary, logData):
now = datetime.datetime.now()
data = {"status": ["open", now.strftime(CASE_DATE_FORMAT)], "companyName": company, "companyShorthand": companySH, "summary": summary, "log": [[now.strftime(LOG_DATE_FORMAT), logData]]}
self.LOGS[id] = data
self.lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, item):\n self.work.append(item)",
"def add_entry(name, title, duration, notes):\n clear()\n print('Entry added to work log!')\n return Entry.create(\n employee_name=name,\n task_title=title,\n time_spent=duration,\n task_notes=notes\n )",
"def add... | [
"0.72224724",
"0.6754549",
"0.673706",
"0.66879654",
"0.6610633",
"0.65605116",
"0.642679",
"0.6380546",
"0.6369654",
"0.6357915",
"0.6327839",
"0.6309158",
"0.63019407",
"0.6156809",
"0.6151777",
"0.6144943",
"0.60816175",
"0.6076465",
"0.6071608",
"0.6069662",
"0.6069662",
... | 0.74274564 | 0 |
Writes datetime & message to log. | def log(self, msg):
current_datetime = self.get_date_time()
self.file.write("%s %s\n" % (current_datetime, msg)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self, line):\n now = datetime.datetime.now()\n time = datetime.datetime.strftime(now, '(%d %b %Y %H:%M:%S)')\n with open(self.logfile, 'a') as log:\n log.write(time + ' ' + line + '\\n')",
"def write_debug_log(self, msg):\n now = datetime.now().strftime('%Y-%m-%d %H... | [
"0.740713",
"0.7402972",
"0.7399504",
"0.7355511",
"0.7294201",
"0.7168819",
"0.70977354",
"0.707861",
"0.6994308",
"0.69615734",
"0.6888617",
"0.68863827",
"0.6877326",
"0.68338794",
"0.6829375",
"0.68224084",
"0.68095285",
"0.6805445",
"0.67909783",
"0.67885906",
"0.6762090... | 0.84167415 | 0 |
Sends data to server via data channel. | def send_to_data_channel(self, sock, data):
resp = sock.send(data)
print_debug(resp)
self.logger.log("Sent: %s" % data)
return resp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_data(self, data):\n self._transport.write(data)",
"def send_data(self):\n data = self.datastore.use(self.data_name)\n if data is None:\n self.dbg(\"sockets_warning\", \"Data is none for {}\", [self.data_name])\n encoded_data = json.dumps(data).encode()\n sel... | [
"0.7871033",
"0.7764725",
"0.76120305",
"0.75970256",
"0.75970256",
"0.7581541",
"0.7565133",
"0.75039774",
"0.7475579",
"0.74102646",
"0.7358395",
"0.7338913",
"0.73358583",
"0.7312296",
"0.72890496",
"0.72705024",
"0.7228028",
"0.7227434",
"0.7214416",
"0.72059953",
"0.7181... | 0.8098659 | 0 |
Bind port socket so server can connect to it. | def port_connection(self, sock):
sock.bind(('', 0)) # Bind to OS-assigned available & random port.
sock.listen(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind(self, server_name: str, port: int) -> None:\n self.socket.bind((server_name, port))",
"def bind(self):\n self._conn = socket.socket(socket.AF_INET, self.protocol.value)\n try:\n self._conn.bind((self.host, self.port))\n except OSError as e:\n self.close(... | [
"0.82351744",
"0.77958804",
"0.77739507",
"0.75891495",
"0.7556575",
"0.75071263",
"0.74849635",
"0.74412334",
"0.7431863",
"0.7397807",
"0.733679",
"0.7315707",
"0.73055035",
"0.73055035",
"0.72372025",
"0.71100944",
"0.70841384",
"0.7007295",
"0.68404245",
"0.68225646",
"0.... | 0.7989616 | 1 |
Helper for port_cmd() to parse in IP and Port of data channel. | def parse_port_req(self, sock):
try:
host_ip = self.s.getsockname()[0] # Get local IPv4 addr of client.
host_port = sock.getsockname()[1] # Get opened port of socket.
# PORT requires parameters split up as:
# octet1,octet2,octet3,octet4,p1,p2
list_cs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ip_port_tshark(str_data):\n separator = str_data.rindex(\":\")\n ip = str_data[:separator]\n port = str_data[separator + 1:]\n return ip, port",
"def _check_ip_port_split(self):\n if self._type == \"A\":\n formatted_value = self._value.split(':')\n self._ip = form... | [
"0.72231406",
"0.6945276",
"0.670802",
"0.670155",
"0.6354064",
"0.63276404",
"0.63212955",
"0.6242342",
"0.6183757",
"0.6112563",
"0.6104118",
"0.60944426",
"0.6082879",
"0.6069114",
"0.604688",
"0.60350764",
"0.59876347",
"0.5881139",
"0.5853971",
"0.5853971",
"0.58115685",... | 0.71617377 | 1 |
Send PASS command to server. | def pass_cmd(self, password):
print_debug("Executing PASS")
command = "PASS %s\r\n" % password
msg_rec = self.send_and_log(self.s, command)
return msg_rec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pass_cmd(cli, nick, chan, rest):\n if nick in GUARDED:\n pm(cli, nick, messages[\"already_protecting\"])\n return\n PASSED.add(nick)\n pm(cli, nick, messages[\"guardian_no_protect\"])\n debuglog(\"{0} ({1}) PASS\".format(nick, get_role(nick)))",
"def pass_cmd(var, wrapper, message):... | [
"0.736316",
"0.7179512",
"0.67074823",
"0.6308097",
"0.61746085",
"0.5954589",
"0.58175766",
"0.5797731",
"0.5773009",
"0.5747147",
"0.57010406",
"0.5693463",
"0.5662075",
"0.5596627",
"0.55654454",
"0.55423546",
"0.55099803",
"0.55082065",
"0.54921466",
"0.549191",
"0.546071... | 0.80341125 | 0 |
Send CWD command to server. | def cwd_cmd(self, new_dir):
print_debug("Executing CWD")
command = "CWD %s\r\n" % new_dir
msg_rec = self.send_and_log(self.s, command)
return msg_rec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pwd_cmd(self):\n print_debug(\"Executing PWD\")\n command = \"PWD\\r\\n\"\n msg_rec = self.send_and_log(self.s, command)\n return msg_rec",
"def send_data_with_cwd(self, client, some_data):\n\n client.sock.send(str.encode(some_data + str(getcwd()) + '> ' + '~!_TERM_$~'))\n ... | [
"0.6978125",
"0.6906484",
"0.6818308",
"0.62719524",
"0.62477314",
"0.6138421",
"0.60999066",
"0.609435",
"0.6078306",
"0.6067173",
"0.5997155",
"0.5958913",
"0.59435695",
"0.5922067",
"0.58474785",
"0.5840055",
"0.5828506",
"0.5805459",
"0.5753152",
"0.5732296",
"0.5727713",... | 0.753063 | 0 |
Send QUIT command to server. | def quit_cmd(self):
print_debug("Executing QUIT")
command = "QUIT\r\n"
msg_rec = self.send_and_log(self.s, command)
self.close_socket(self.s) # Close socket since we're done.
return msg_rec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quit(self):\n self.socket.send(\"QUIT\")",
"def request_quit(self):\n self._socketpair[1].send(b'\\x00')",
"def request_quit(self):\n self._socketpair[1].send(b'\\x00')",
"def command_quit(self, arg):\n self.write('221 Bye', self.finish)",
"def quit():\n sio.emit('qui... | [
"0.76735914",
"0.7504194",
"0.7504194",
"0.7212169",
"0.7062584",
"0.67776567",
"0.6698397",
"0.6694406",
"0.6656138",
"0.66220427",
"0.6608679",
"0.66051966",
"0.6596909",
"0.6564562",
"0.65236837",
"0.65114695",
"0.6453585",
"0.6434045",
"0.6434045",
"0.6434045",
"0.6434045... | 0.76703995 | 1 |
Send PASV command to server. | def pasv_cmd(self):
print_debug("Executing PASV")
command = "PASV\r\n"
msg_rec = self.send_and_log(self.s, command)
print_debug(msg_rec)
# PASV creates a new connection from client to server.
sock = new_socket()
pasv_ip, pasv_port = self.parse_pasv_resp(msg_rec)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_pasv (self, line):\r\n pc = self.new_passive_acceptor()\r\n port = pc.addr[1]\r\n ip_addr = pc.control_channel.getsockname()[0]\r\n self.respond (\r\n '227 Entering Passive Mode (%s,%d,%d)' % (\r\n ip_addr.replace('.', ','),\r\n ... | [
"0.7160492",
"0.69107234",
"0.6513795",
"0.57388157",
"0.53116184",
"0.528785",
"0.52565587",
"0.52513045",
"0.52451116",
"0.5223381",
"0.51911014",
"0.51864535",
"0.5184464",
"0.5145373",
"0.51401895",
"0.5134958",
"0.5129067",
"0.5105347",
"0.5087492",
"0.50785804",
"0.5076... | 0.8470187 | 0 |
Send PORT command to server. | def port_cmd(self):
print_debug("Executing PORT")
# PORT creates a new connection from server to client.
sock = new_socket()
self.port_connection(sock)
# Get required parameters for PORT command.
port_params, host_ip, host_port = self.parse_port_req(sock)
print_de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _send_port_command(self, host: str, port: int):\n hbytes = host.split('.')\n pbytes = [repr(port//256), repr(port%256)]\n cmd = \"PORT \" + \",\".join(hbytes + pbytes) + CRLF\n response = self.send_cmd(cmd.encode())\n return response",
"def cmd_port (self, line):\r\n ... | [
"0.8131484",
"0.74534994",
"0.71377313",
"0.68969315",
"0.6824487",
"0.6666698",
"0.6634072",
"0.65321106",
"0.64532715",
"0.6441933",
"0.6401715",
"0.63596004",
"0.6350395",
"0.63112825",
"0.6214937",
"0.6200928",
"0.61769456",
"0.6176025",
"0.6141704",
"0.61211824",
"0.6106... | 0.7966922 | 1 |
Send EPSV command to server. | def epsv_cmd(self, proto="1"):
print_debug("Executing EPSV")
net_prt = proto
command = "EPSV %s\r\n" % net_prt
msg_rec = self.send_and_log(self.s, command)
print_debug(msg_rec)
# EPSV creates a new connection from client to server.
sock = new_socket()
# Ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pasv_cmd(self):\n print_debug(\"Executing PASV\")\n command = \"PASV\\r\\n\"\n msg_rec = self.send_and_log(self.s, command)\n print_debug(msg_rec)\n # PASV creates a new connection from client to server.\n sock = new_socket()\n pasv_ip, pasv_port = self.parse_pa... | [
"0.6286559",
"0.60377014",
"0.5961562",
"0.5931039",
"0.5901993",
"0.58147866",
"0.57967216",
"0.57568485",
"0.57518137",
"0.5676314",
"0.5674593",
"0.5577394",
"0.5562855",
"0.55404943",
"0.55402046",
"0.5527151",
"0.5511855",
"0.5489658",
"0.54685646",
"0.5452809",
"0.54171... | 0.81925577 | 0 |
Send EPRT command to server. | def eprt_cmd(self, proto="1"):
print_debug("Executing EPRT")
sock = new_socket()
# Create port connection using extended info.
self.port_connection(sock)
net_prt = proto
# Get required parameters for EPRT command.
eprt_params, net_addr, tcp_port = self.parse_eprt_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sendCmdExec(self, tcPacket):\n LOG_INFO(\"EDEN.Client.sendCmdExec\", \"EDEN\")\n pdu = EGSE.EDENPDU.PDU()\n pdu.pduType = EGSE.EDENPDU.PDU_TYPE_CMD\n pdu.subType = EGSE.EDENPDU.SUB_TYPE_EXEC\n pdu.setDataField(tcPacket)\n self.sendPDU(pdu)",
"def epsv_cmd(self, proto=\"1\"):\n print_... | [
"0.63428414",
"0.6323487",
"0.6156996",
"0.60678923",
"0.59865",
"0.58926654",
"0.5816514",
"0.58056515",
"0.578455",
"0.5749576",
"0.5714112",
"0.5698482",
"0.5627552",
"0.56161",
"0.56084716",
"0.5605127",
"0.5589362",
"0.5584043",
"0.55688924",
"0.5536603",
"0.55257577",
... | 0.7765013 | 0 |
Send RETR command to server. | def retr_cmd(self, sock, path, transfer_type):
print_debug("Executing RETR")
command = "RETR %s\r\n" % path
msg_rec = self.send_and_log(self.s, command)
print_debug(msg_rec)
# Ensure we got a success message from the FTP server.
if get_ftp_server_code(msg_rec) == FTP_STAT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ftp_RETR(self, line):\n file = self.fs.ftp2fs(line)\n\n if not self.authorizer.r_perm(self.username, file):\n self.log('FAIL RETR \"s\". Not enough privileges.'\n %self.fs.ftpnorm(line))\n self.respond(\"550 Can't RETR: not enough privileges.\")\n ... | [
"0.65780747",
"0.5643528",
"0.55977094",
"0.55818594",
"0.5468193",
"0.5465944",
"0.5438272",
"0.5427386",
"0.5423746",
"0.5400634",
"0.5369911",
"0.5341084",
"0.53108615",
"0.52989376",
"0.52708113",
"0.52609885",
"0.520371",
"0.51890373",
"0.5175364",
"0.5160737",
"0.515903... | 0.6583031 | 0 |
Send STOR command to server. | def stor_cmd(self, sock, local_file, remote_path, transfer_type):
print_debug("Executing STOR")
command = "STOR %s\r\n" % remote_path
msg_rec = self.send_and_log(self.s, command)
print_debug(msg_rec)
# Ensure we got a success message from the FTP server.
if get_ftp_server... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def STOR(self, msg):\n\n # Flatten a possible Message object.\n # ==================================\n\n if isinstance(msg, basestring):\n msg = msg\n elif isinstance(msg, Message):\n fp = StringIO()\n g = Generator(fp, mangle_from_=False, maxheaderlen=0... | [
"0.60684437",
"0.56428534",
"0.55217427",
"0.5322431",
"0.52826756",
"0.52566123",
"0.5237251",
"0.51836663",
"0.51493484",
"0.5141088",
"0.5140841",
"0.512129",
"0.5112694",
"0.51038647",
"0.5060501",
"0.50262517",
"0.5001151",
"0.49564612",
"0.49481446",
"0.49448568",
"0.49... | 0.6473614 | 0 |
Send PWD command to server. | def pwd_cmd(self):
print_debug("Executing PWD")
command = "PWD\r\n"
msg_rec = self.send_and_log(self.s, command)
return msg_rec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cwd_cmd(self, new_dir):\n print_debug(\"Executing CWD\")\n command = \"CWD %s\\r\\n\" % new_dir\n msg_rec = self.send_and_log(self.s, command)\n return msg_rec",
"def send_data_with_cwd(self, client, some_data):\n\n client.sock.send(str.encode(some_data + str(getcwd()) + '>... | [
"0.659332",
"0.6458046",
"0.6419454",
"0.6116812",
"0.60006076",
"0.597677",
"0.5788603",
"0.5770086",
"0.573263",
"0.5720297",
"0.5709724",
"0.56983554",
"0.5666187",
"0.56639135",
"0.5599411",
"0.5596471",
"0.5575641",
"0.5519163",
"0.54947823",
"0.54947704",
"0.54138196",
... | 0.7469398 | 0 |
Send SYST command to server. | def syst_cmd(self):
print_debug("Executing SYST")
command = "SYST\r\n"
msg_rec = self.send_and_log(self.s, command)
return msg_rec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_syst (self, line):\r\n # Replying to this command is of questionable utility, because\r\n # this server does not behave in a predictable way w.r.t. the\r\n # output of the LIST command. We emulate Unix ls output, but\r\n # on win32 the pathname can contain drive information at ... | [
"0.7037263",
"0.63606536",
"0.63040715",
"0.6243764",
"0.6192061",
"0.6154574",
"0.61108834",
"0.6065064",
"0.6045037",
"0.6028878",
"0.5955034",
"0.5950341",
"0.5944908",
"0.5922424",
"0.5913101",
"0.5901019",
"0.58507913",
"0.5793192",
"0.57814187",
"0.5732716",
"0.57270676... | 0.82447004 | 0 |
Cast port to an int and ensure it is between 0 and 65535. | def validate_port(port):
try:
port = int(port)
# Is port a valid port number?
if port > 65535 or port < 0:
raise ValueError('Port is not between 0 and 65535!')
except ValueError:
error_quit("Port is not between 0 and 65535!", 400)
except Exception:
error_q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_port(ctx, param, value):\n try:\n value = int(value)\n except ValueError:\n pass\n\n return value",
"def _validate_port(port_value):\n try:\n port_value = int(port_value)\n except (ValueError, TypeError):\n return None\n\n if not (1024 <= port_value <= 49151):\n retur... | [
"0.7750401",
"0.75579613",
"0.75579613",
"0.7446295",
"0.7323195",
"0.7198424",
"0.68698597",
"0.67130536",
"0.6670352",
"0.6606632",
"0.6573438",
"0.65546757",
"0.6506908",
"0.6459796",
"0.64532673",
"0.6400392",
"0.62404805",
"0.6236082",
"0.6232377",
"0.61924905",
"0.61651... | 0.76498437 | 1 |
Prompt user for Username. | def prompt_username():
msg = "Enter Username: "
username = raw_input(msg)
return username | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsername():\n return input(\"Username\")",
"def __prompt_name(self):\n self.clear_screen()\n self.__print_logo()\n\n name = input(\"[!] Enter new player name and press ENTER:\\n\\n \")\n if not (2 < len(name) < 16):\n self.clear_screen()\n self.__prin... | [
"0.7916125",
"0.7641603",
"0.7599964",
"0.75646496",
"0.74984545",
"0.74364716",
"0.7309836",
"0.72933227",
"0.72845024",
"0.7255822",
"0.7116093",
"0.706705",
"0.7061898",
"0.70427215",
"0.70427215",
"0.70427215",
"0.70427215",
"0.70427215",
"0.70427215",
"0.70427215",
"0.70... | 0.855089 | 0 |
Prompt user for Password. Hide input (make stdin invisible). | def prompt_pass():
msg = "Enter Password: "
password = getpass.getpass(msg)
return password | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask_input(prompt = '', is_password = False):\n\n while True:\n answer = getpass.getpass() if is_password == True else input(prompt)\n if answer is not '':\n return answer",
"def _prompt_for_password(self, args):\n if not args.password:\n args.password = getpass.g... | [
"0.69035655",
"0.6864212",
"0.68409425",
"0.6785014",
"0.6770495",
"0.66329646",
"0.6625388",
"0.66023016",
"0.65161467",
"0.6480811",
"0.6393367",
"0.6382482",
"0.63621384",
"0.63288796",
"0.6311691",
"0.62387365",
"0.6220257",
"0.61567914",
"0.61139905",
"0.60686934",
"0.60... | 0.6911492 | 0 |
Returns the error code (a threedigit string) of an FTP server response. | def get_ftp_server_code(resp_msg):
if resp_msg.startswith("'"):
print_debug(resp_msg[1:4])
return resp_msg[1:4]
else:
print_debug(resp_msg[0:3])
return resp_msg[0:3] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_code(self):\n return self.json['response'].get('error_code')",
"def error_code(self) -> int:\n return pulumi.get(self, \"error_code\")",
"def error_code(self):\n return self._error_code",
"def error_code(self):\r\n return self._arm.error_code",
"def error_code(self):\n... | [
"0.6765313",
"0.67154056",
"0.6683254",
"0.6651856",
"0.664981",
"0.6641223",
"0.6605638",
"0.6581578",
"0.6531901",
"0.6437872",
"0.6289795",
"0.61443824",
"0.6127929",
"0.6110161",
"0.6106642",
"0.61025757",
"0.6033589",
"0.60227853",
"0.6002123",
"0.5998232",
"0.5939049",
... | 0.7461827 | 0 |
Prompt user for Username & Password, authenticate with FTP server. | def login(ftp):
# Get username
username = prompt_username()
ftp.user_cmd(username)
# Get password
password = prompt_pass()
pass_data = ftp.pass_cmd(password)
# Retry inputs if unsuccessful authentication.
while get_ftp_server_code(pass_data) != FTP_STATUS_CODES["SUCCESSFUL_LOGIN"]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login(self, username=None, password=None):\r\n self.ftp.login()",
"def do_ftp(ftp):\n login(ftp)\n main_menu(ftp)",
"def ftp_PASS(self, line):\n\n if self.authenticated:\n self.respond(\"503 User already authenticated.\")\n return\n if not self.username:\n ... | [
"0.7224003",
"0.69027174",
"0.66074723",
"0.655",
"0.6514936",
"0.6376942",
"0.634871",
"0.62492335",
"0.6201155",
"0.59672207",
"0.59651625",
"0.5886684",
"0.5868272",
"0.58612955",
"0.584182",
"0.58353853",
"0.58063745",
"0.578823",
"0.5744458",
"0.57360375",
"0.57233524",
... | 0.75492543 | 0 |
Return a new socket. | def new_socket():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_socket():\n sock = socket.socket()\n return sock",
"def _create_new_socket(self):\n sock = socket()\n sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, True)\n return sock",
"def get_socket():\n return socket.create_connection((HOST, PORT))",
"def _setupSocket(self):\n ... | [
"0.85883504",
"0.83133113",
"0.81775373",
"0.7265505",
"0.7253858",
"0.71978414",
"0.7188385",
"0.71822166",
"0.7016967",
"0.6989401",
"0.6954748",
"0.694214",
"0.692904",
"0.68714786",
"0.68409353",
"0.68270826",
"0.6816352",
"0.6798193",
"0.67947054",
"0.67551154",
"0.67506... | 0.8778516 | 0 |
Prompt for what to download, then call the appropriate FTP command. | def do_download(ftp):
# Active (PORT), Passive (PASV), ExtActive (EPRT), or ExtPassive (EPSV)?
output, sock, transfer_type = get_transfer_output_and_socket(ftp)
print_debug(output + "\n")
# What file to download?
path = raw_input("What file do you want to download?\n> ")
while not path:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_ftp(ftp):\n login(ftp)\n main_menu(ftp)",
"def ftp():\n pass",
"def _execute(self):\n print(\"[ -ENGINE- ] Executing FTP Download ..\")\n # self.time_point(tag = 'execution')\n main = self.import_engine_as_python_function()\n downloaded_files = main(\n ftp... | [
"0.70737374",
"0.6248836",
"0.5974423",
"0.58715105",
"0.5798677",
"0.5693074",
"0.56724286",
"0.5637648",
"0.56327075",
"0.56082886",
"0.5565309",
"0.55652404",
"0.5553374",
"0.5537053",
"0.5513997",
"0.54844195",
"0.5422093",
"0.5414378",
"0.5385415",
"0.53834456",
"0.53639... | 0.76580745 | 0 |
Writes content of data_rec to a file in path. | def write_to_local(path, data_rec):
path, filename = os.path.split(path)
with open(filename, 'wb') as f:
f.write(data_rec)
f.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveOnFile(self, path, data):\n with open(path, \"w\") as f:\n f.write(data)",
"def _writeRecord(self, path, name, data):\n file_path = os.path.join(path, name)\n with open(file_path, 'w') as f:\n for item in data:\n f.write(str(item)+'\\t')\n ... | [
"0.724344",
"0.7202587",
"0.6811576",
"0.6740009",
"0.67045426",
"0.6685575",
"0.66832274",
"0.6630497",
"0.66290486",
"0.6628973",
"0.6590096",
"0.6582314",
"0.6566478",
"0.6478841",
"0.63861674",
"0.6383586",
"0.6374996",
"0.6367748",
"0.6356103",
"0.63403445",
"0.6335851",... | 0.7552993 | 0 |
Prompt for what to upload, then call the appropriate FTP command. | def do_upload(ftp):
# Active (PORT), Passive (PASV), ExtActive (EPRT), or ExtPassive (EPSV)?
output, sock, transfer_type = get_transfer_output_and_socket(ftp)
print_debug(output + "\n")
# What file to upload?
local_file = raw_input("What local file do you want to upload?\n> ")
is_file = os.path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_ftp(ftp):\n login(ftp)\n main_menu(ftp)",
"def UploadFileFTP(file_path_name, server_ip, remote_path, username, password):\n filepath = getFileDir(file_path_name)\n filename = getBaseName(file_path_name)\n import ftplib\n import os\n import sys\n print(\"POPUP: <p>Connecting to <str... | [
"0.69453764",
"0.63357604",
"0.6291335",
"0.6240836",
"0.6205516",
"0.6174741",
"0.61274874",
"0.59906185",
"0.5723766",
"0.5710006",
"0.5676588",
"0.5619927",
"0.5605565",
"0.55726355",
"0.5546787",
"0.55352604",
"0.5444533",
"0.5422009",
"0.54203093",
"0.5392397",
"0.536127... | 0.7706304 | 0 |
Prompt for what to list, then call the appropriate FTP command. | def do_list(ftp):
# Active (PORT), Passive (PASV), ExtActive (EPRT), or ExtPassive (EPSV)?
output, sock, transfer_type = get_transfer_output_and_socket(ftp)
print_debug(output + "\n")
path = raw_input("What directory or file do you want to list (blank=current)?\n> ")
try:
if path:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_ftp(ftp):\n login(ftp)\n main_menu(ftp)",
"def ftp():\n pass",
"def ftp_LIST(self, line):\n # - If no argument, fall back on cwd as default.\n # - Some older FTP clients erroneously issue /bin/ls-like LIST\n # formats in which case we fall back on cwd as default.\n ... | [
"0.7061565",
"0.6500838",
"0.62256056",
"0.6213985",
"0.6074314",
"0.60450107",
"0.59631056",
"0.5919219",
"0.5765811",
"0.55488336",
"0.5324865",
"0.53202313",
"0.5257542",
"0.52259934",
"0.5222791",
"0.52047676",
"0.51872694",
"0.51816875",
"0.51794195",
"0.5155459",
"0.514... | 0.76297075 | 0 |
Prompt for what dir to change to; call the appropriate FTP command. | def do_cwd(ftp):
new_dir = raw_input("What directory do you want to change to?\n> ")
try:
output = ftp.cwd_cmd(new_dir)
if get_ftp_server_code(output) == FTP_STATUS_CODES["SUCCESSFUL_CWD"]:
print("Successfully changed directory\n")
else:
print("Invalid directory o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_ftp(ftp):\n login(ftp)\n main_menu(ftp)",
"def chdir(self):\r\n self.directory=tkf.askdirectory()",
"def do_list(ftp):\n # Active (PORT), Passive (PASV), ExtActive (EPRT), or ExtPassive (EPSV)?\n output, sock, transfer_type = get_transfer_output_and_socket(ftp)\n print_debug(output... | [
"0.69513685",
"0.6237783",
"0.62206316",
"0.5956098",
"0.5929026",
"0.5914192",
"0.58596015",
"0.5816571",
"0.5766575",
"0.56716156",
"0.5641542",
"0.560212",
"0.5587736",
"0.55813056",
"0.5506698",
"0.5480192",
"0.547631",
"0.5452441",
"0.5425448",
"0.5354994",
"0.52918863",... | 0.7426076 | 0 |
Call the appropriate FTP command to display the server's help info. | def do_help(ftp):
try:
cmd = raw_input("What command do you need help with (blank=general)?\n> ")
if cmd:
output = ftp.help_cmd(cmd)
else:
output = ftp.help_cmd()
output = parse_server_response(output)
print("%s\n" % output)
except Exception as e:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ftp_HELP(self, line):\n if line:\n if line.upper() in proto_cmds:\n self.respond(\"214 %s\" %proto_cmds[line.upper()])\n else:\n self.respond(\"501 Unrecognized command.\")\n else:\n # provide a compact list of recognized commands\n ... | [
"0.72652334",
"0.71549714",
"0.6991888",
"0.6787502",
"0.67421865",
"0.6715089",
"0.6695756",
"0.6658835",
"0.66138166",
"0.6613501",
"0.66058886",
"0.6592547",
"0.6586962",
"0.6586962",
"0.65519094",
"0.6549582",
"0.6549582",
"0.654393",
"0.654393",
"0.654393",
"0.654393",
... | 0.820547 | 0 |
Calls function associated with user's Main Menu choice. | def handle_main_menu_choice(choice, ftp):
function_to_call = MAIN_MENU_SELECTIONS[choice][1]
globals()[function_to_call](ftp) # Call the function. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_main_menu(self) -> None:\n user_choice = None\n while user_choice != 5:\n user_choice = Menu.prompt_main_menu()\n if user_choice == 1:\n self.view_budgets()\n elif user_choice == 2:\n self.record_transaction()\n eli... | [
"0.7570253",
"0.72065353",
"0.72050446",
"0.719796",
"0.70766664",
"0.70223397",
"0.70143354",
"0.7009289",
"0.6964302",
"0.696051",
"0.69531804",
"0.6914631",
"0.6897453",
"0.6895246",
"0.68840843",
"0.68789095",
"0.6863167",
"0.6836073",
"0.6815794",
"0.6811624",
"0.6811137... | 0.7867916 | 0 |
Main driver that parses args, creates our Logger & FTP objects, and starts the do_ftp driver. | def main():
print_debug("Starting...")
host, log_file, port = parse_args()
logger = Logger(log_file)
ftp = FTP(host, logger, port)
do_ftp(ftp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n print(\"*\" * 50)\n print(\"[LOG] Printing command line arguments\\n\", \",\".join(sys.argv))\n check_file_name()\n print(\"*\" * 50)\n\n # This argument is required.\n # For a server, this means the IP that the server socket\n # will use.\n # The IP of the server, some defa... | [
"0.62050337",
"0.61970246",
"0.61698395",
"0.6148644",
"0.59998655",
"0.5825256",
"0.5802349",
"0.5791866",
"0.5754186",
"0.5752836",
"0.56938434",
"0.56443655",
"0.56323737",
"0.56278557",
"0.5615108",
"0.5615108",
"0.55898476",
"0.55799305",
"0.55646735",
"0.5542371",
"0.55... | 0.817029 | 0 |
Test current power if there is no data. | def test_current_power_w_no_data(self):
self.port.data = {"notpower": 123}
assert 0 == self.switch.current_power_w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available(self):\n return self._power is not None",
"def setPowerIfNecessary(self):\n if self.p.power == 0 and self.p.powerDensity > 0:\n self.setPowerFromDensity()",
"def is_full_power(self):\n power_mode = self.power_mode\n if not power_mode:\n return Non... | [
"0.72917026",
"0.6984508",
"0.65791166",
"0.6563099",
"0.65388227",
"0.6528629",
"0.6483023",
"0.64697427",
"0.6436037",
"0.637924",
"0.63668966",
"0.6363195",
"0.6350259",
"0.6295966",
"0.624097",
"0.6214891",
"0.62106955",
"0.61786634",
"0.6125931",
"0.6115478",
"0.6077944"... | 0.7734776 | 0 |
Compute the accuracy per class and average puts 1 for invalid values (division per 0) returns average accuracy, accuracy per class | def stats_accuracy_per_class(cm):
# equvalent to for class i to
# number or true positive of class i (data[target==i]==i).sum()/ number of elements of i (target==i).sum()
sums = np.sum(cm, axis=1)
mask = (sums>0)
sums[sums==0] = 1
accuracy_per_class = np.diag(cm) / sums #sum over lines
accur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(cls, test_labels):\n N = len(test_labels)\n\n # Calculate total correct as precentage\n total_correct = 100*(N - np.count_nonzero(cls - test_labels))/N\n\n # Calculate precentag correct for each class\n lab = np.unique(test_labels)\n cls_correct = {}\n ... | [
"0.7893734",
"0.7818329",
"0.77689517",
"0.76843685",
"0.76652426",
"0.76370513",
"0.76244384",
"0.76234657",
"0.76198924",
"0.7611668",
"0.7505606",
"0.7499754",
"0.7482586",
"0.7482586",
"0.74815303",
"0.745904",
"0.7453107",
"0.7402469",
"0.73717004",
"0.73671013",
"0.7332... | 0.8185889 | 0 |
Compute the iou per class and average iou Puts 1 for invalid values returns average iou, iou per class | def stats_iou_per_class(cm, ignore_missing_classes=True):
sums = (np.sum(cm, axis=1) + np.sum(cm, axis=0) - np.diag(cm))
mask = (sums>0)
sums[sums==0] = 1
iou_per_class = np.diag(cm) / sums
iou_per_class[np.logical_not(mask)] = -1
if mask.sum()>0:
average_iou = iou_per_class[mask].mea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iou(self):\n if self.confusion_matrix is None:\n return None\n\n ious = []\n for label in range(self.num_classes):\n tp = np.longlong(self.confusion_matrix[label, label])\n fn = np.longlong(self.confusion_matrix[label, :].sum()) - tp\n fp = np.lo... | [
"0.72402334",
"0.72395897",
"0.6624736",
"0.65000564",
"0.6477391",
"0.64249456",
"0.6412686",
"0.63618803",
"0.63491553",
"0.6138594",
"0.612149",
"0.61194825",
"0.6111104",
"0.61068004",
"0.6071576",
"0.6022943",
"0.59990185",
"0.59948176",
"0.5977327",
"0.5976387",
"0.5966... | 0.7901392 | 0 |
Compute f1 scores per class and mean f1. puts 1 for invalid classes returns average f1 score, f1 score per class | def stats_f1score_per_class(cm):
# defined as 2 * recall * prec / recall + prec
sums = (np.sum(cm, axis=1) + np.sum(cm, axis=0))
mask = (sums>0)
sums[sums==0] = 1
f1score_per_class = 2 * np.diag(cm) / sums
f1score_per_class[np.logical_not(mask)] = -1
average_f1_score = f1score_per_class[ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f1_score(self):\n self.overall_f1_score = f1_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_f1_score = f1_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
"def f1_score(true, pred, ... | [
"0.7942139",
"0.7179192",
"0.71064353",
"0.6890557",
"0.68818843",
"0.68659306",
"0.6865899",
"0.6848298",
"0.67640775",
"0.67640567",
"0.6723882",
"0.6697886",
"0.666991",
"0.6634273",
"0.662941",
"0.6615536",
"0.6580577",
"0.6576204",
"0.6558755",
"0.65561616",
"0.65508336"... | 0.80979335 | 0 |
Return ordered list of graph points | def getGraphPoints(self, includeThresholds=True):
gps = (gp for gp in self.graphPoints()
if includeThresholds or not gp.isThreshold)
def graphPointKey(a):
try:
return int(a.sequence)
except ValueError:
return sys.maxint
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices(self):\n return self.pointlist",
"def points(self):\n p = []\n for v in self.iter():\n p.append((v.x, v.y))\n return p",
"def to_list(self):\n path = []\n for point in self.points:\n path.append(point.to_dict())\n\n return path... | [
"0.70240885",
"0.7012779",
"0.66501844",
"0.6583625",
"0.6531102",
"0.64805174",
"0.64763343",
"0.6448333",
"0.64184207",
"0.63812035",
"0.6358945",
"0.63551766",
"0.6343266",
"0.6341476",
"0.6331771",
"0.6314596",
"0.6313858",
"0.6313858",
"0.6313858",
"0.6313858",
"0.631385... | 0.7026516 | 0 |
Get ordered list of threshold graph points | def getThresholdGraphPoints(self):
gps = [gp for gp in self.getGraphPoints() if gp.isThreshold]
return gps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGraphPoints(self, includeThresholds=True):\n gps = (gp for gp in self.graphPoints()\n if includeThresholds or not gp.isThreshold)\n def graphPointKey(a):\n try:\n return int(a.sequence)\n except ValueError:\n return sys.maxint\... | [
"0.7607397",
"0.66536295",
"0.6436318",
"0.6127309",
"0.6073962",
"0.60349965",
"0.6001307",
"0.5977962",
"0.5976739",
"0.5859659",
"0.58081985",
"0.5782553",
"0.5765708",
"0.57592034",
"0.5733284",
"0.56729",
"0.56695044",
"0.56491417",
"0.5618703",
"0.5613451",
"0.55938035"... | 0.7823319 | 0 |
Return true if there is a thresholdgraphpoint with threshId=threshid | def isThresholdGraphed(self, threshId):
return any(gp.threshId == threshId
for gp in self.getThresholdGraphPoints()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains_point(self, point):\n\t\tthreshold = 0.6\n\t\tx = point[0]\n\t\ty = point[1]\n\t\tif (x >= (self.xmin - threshold) and x <= (self.xmax + threshold) and\n\t\t\ty >= (self.ymin - threshold) and y <= (self.ymax + threshold)):\n\t\t return True\n\t\treturn False",
"def isDataPointGraphed(self, dpName... | [
"0.60158515",
"0.57470196",
"0.5671017",
"0.5586125",
"0.558302",
"0.5582523",
"0.5568134",
"0.55033576",
"0.5479934",
"0.54433304",
"0.54149306",
"0.5361757",
"0.53600204",
"0.53467625",
"0.5327538",
"0.53202915",
"0.5319352",
"0.5314343",
"0.5287429",
"0.52778983",
"0.52764... | 0.76099724 | 0 |
Return true if there is at least one graphpoint with a dsName equal to dpName. | def isDataPointGraphed(self, dpName):
from DataPointGraphPoint import DataPointGraphPoint
return any(isinstance(gp, DataPointGraphPoint) and gp.dpName == dpName
for gp in self.getGraphPoints(includeThresholds=False)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPointGraphPoints(self, dpName):\n from DataPointGraphPoint import DataPointGraphPoint\n return [gp for gp in self.graphPoints()\n if isinstance(gp, DataPointGraphPoint)\n and gp.dpName == dpName]",
"def exists(self, name):\n assert name, \"Must input ... | [
"0.6595093",
"0.6454463",
"0.6090387",
"0.6087896",
"0.607874",
"0.5942403",
"0.5921128",
"0.5857084",
"0.5807831",
"0.57941604",
"0.57728535",
"0.5758609",
"0.5742762",
"0.5714896",
"0.56621575",
"0.56566477",
"0.5627397",
"0.56004417",
"0.5542626",
"0.55242914",
"0.5519199"... | 0.80648524 | 0 |
Return list of graph point ids | def getGraphPointsNames(self):
return [gp.id for gp in self.getGraphPoints()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids(self):\n return self._graphs.keys()",
"def vertex_ids(self):\n return self.get_ids()",
"def getIDs():",
"def polygon_ids(self):\n return self.get_ids()",
"def get_ids(self) -> List[str]:",
"def vertices(self):\n return self.pointlist",
"def ids(self):\n re... | [
"0.728458",
"0.7125037",
"0.7050036",
"0.69690293",
"0.6625779",
"0.6516615",
"0.64978516",
"0.64978516",
"0.64630836",
"0.63863146",
"0.6368165",
"0.63664937",
"0.6290894",
"0.62689674",
"0.6245919",
"0.6236567",
"0.6234951",
"0.6229913",
"0.6193675",
"0.6190388",
"0.6187838... | 0.7535281 | 0 |
Return a string that lists the names of the graphpoints used in this graph definition. If this graph definition has a perf template then note in the string which graphpoints are broken (in that they refer to nonexistent datapoints.) | def getGraphPointNamesString(self):
names = []
for gp in self.getGraphPoints():
if hasattr(aq_base(gp), 'isBroken') and gp.isBroken():
names.append('%s(<span style="color: red">missing</span>)' %
gp.id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGraphPointsNames(self):\n return [gp.id for gp in self.getGraphPoints()]",
"def __str__(self):\n return '%i traces in the SEG Y structure.' % len(self.traces)",
"def _predefined_statistics() -> str:\n return \"\\n\".join(\n f\"[{i}] {name}\"\n for i, (name, _) ... | [
"0.6581509",
"0.5687178",
"0.55907863",
"0.5580345",
"0.5579442",
"0.5375419",
"0.53422034",
"0.53322834",
"0.53235954",
"0.53217274",
"0.5271567",
"0.5241841",
"0.5218385",
"0.5217808",
"0.521348",
"0.5208027",
"0.5189648",
"0.5175198",
"0.51476526",
"0.5146572",
"0.5133721"... | 0.7654417 | 0 |
Create the graphpoint with the given id or something similar and add to self.graphPoints | def createGraphPoint(self, cls, newId):
def getUniqueId(container, base):
ids = set(container.objectIds())
new = base
i = 2
while new in ids:
new = '%s%s' % (base, i)
i += 1
return new
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_addCustomGraphPoint(self, new_id, flavor, REQUEST=None):\n exec 'import %s' % flavor\n cls = eval('%s.%s' % (flavor, flavor))\n gp = self.createGraphPoint(cls, new_id)\n if REQUEST:\n audit('UI.GraphDefinition.AddGraphPoint', self.id, graphPointType=flavor, graphPo... | [
"0.69145787",
"0.6693024",
"0.6420326",
"0.6369396",
"0.63306963",
"0.6280349",
"0.6266855",
"0.62570244",
"0.625416",
"0.6250375",
"0.6236164",
"0.6208379",
"0.604665",
"0.6035292",
"0.6028105",
"0.60058343",
"0.59759307",
"0.59386885",
"0.59359396",
"0.59172916",
"0.5912506... | 0.7698291 | 0 |
Create a new graphpoint of the given class and id | def manage_addCustomGraphPoint(self, new_id, flavor, REQUEST=None):
exec 'import %s' % flavor
cls = eval('%s.%s' % (flavor, flavor))
gp = self.createGraphPoint(cls, new_id)
if REQUEST:
audit('UI.GraphDefinition.AddGraphPoint', self.id, graphPointType=flavor, graphPoint=gp.id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createGraphPoint(self, cls, newId):\n def getUniqueId(container, base):\n ids = set(container.objectIds())\n new = base\n i = 2\n while new in ids:\n new = '%s%s' % (base, i)\n i += 1\n retur... | [
"0.81278574",
"0.6096134",
"0.6061245",
"0.5865029",
"0.58092636",
"0.56551373",
"0.56374055",
"0.5585015",
"0.5562552",
"0.55296904",
"0.55094796",
"0.5504043",
"0.5475501",
"0.5452237",
"0.5451785",
"0.53719693",
"0.53395826",
"0.53367645",
"0.53167063",
"0.5294983",
"0.529... | 0.6541513 | 1 |
Create new graph points The migrate script graphDefinitions and friends depends on the first element in newGps being the DataPointGraphPoint when only one name is passed in dpNames. | def manage_addDataPointGraphPoints(self, dpNames=None,
includeThresholds=False,
REQUEST=None):
if not dpNames:
if REQUEST:
messaging.IMessageSender(self).sendToBrowser(
'Error',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_addDataPointsToGraphs(self, ids=(), graphIds=(), REQUEST=None):\n newGps = []\n for graphDefId in graphIds:\n graphDef = self.rrdTemplate.graphDefs._getOb(graphDefId, None)\n if graphDef:\n for dpId in ids:\n dp = self.datapoints._get... | [
"0.67767674",
"0.63806224",
"0.5912672",
"0.57786644",
"0.5706548",
"0.5552784",
"0.5382578",
"0.5276864",
"0.5203132",
"0.51095146",
"0.5072795",
"0.4982833",
"0.4972218",
"0.49587017",
"0.495192",
"0.49434945",
"0.49430406",
"0.492555",
"0.48750484",
"0.4871452",
"0.4853968... | 0.726797 | 0 |
Make sure that Threshold graph points exist for all thresholds that use the given dpName. Return a list of all graphpoints created by this call. | def addThresholdsForDataPoint(self, dpName):
from ThresholdGraphPoint import ThresholdGraphPoint
newGps = []
for thresh in self.rrdTemplate().thresholds():
if thresh.canGraph(self) \
and dpName in thresh.dsnames \
and not self.isThresholdGraphe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPointGraphPoints(self, dpName):\n from DataPointGraphPoint import DataPointGraphPoint\n return [gp for gp in self.graphPoints()\n if isinstance(gp, DataPointGraphPoint)\n and gp.dpName == dpName]",
"def isDataPointGraphed(self, dpName):\n from DataPoi... | [
"0.6864683",
"0.64802474",
"0.635279",
"0.5850847",
"0.57837",
"0.52177763",
"0.49125263",
"0.49067888",
"0.49015516",
"0.4859402",
"0.48192385",
"0.481864",
"0.48152307",
"0.47734347",
"0.47504014",
"0.47430125",
"0.4695709",
"0.46470293",
"0.46412593",
"0.46164593",
"0.4614... | 0.80139285 | 0 |
Create new threshold graph points | def manage_addThresholdGraphPoints(self, threshNames, REQUEST=None):
from ThresholdGraphPoint import ThresholdGraphPoint
newGps = []
for threshName in threshNames:
#thresh = getattr(self.rrdTemplate.thresholds, threshName)
gp = self.createGraphPoint(ThresholdGraphPoint, t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getThresholdGraphPoints(self):\n gps = [gp for gp in self.getGraphPoints() if gp.isThreshold]\n return gps",
"def addThresholdsForDataPoint(self, dpName):\n from ThresholdGraphPoint import ThresholdGraphPoint\n newGps = []\n for thresh in self.rrdTemplate().thresholds():\n ... | [
"0.6711182",
"0.64872766",
"0.5963074",
"0.5814214",
"0.58044225",
"0.56232315",
"0.5615262",
"0.5567077",
"0.55606556",
"0.54865366",
"0.5445044",
"0.5435383",
"0.5435228",
"0.542892",
"0.54268223",
"0.54155546",
"0.5396727",
"0.539133",
"0.53884137",
"0.53862387",
"0.538533... | 0.6487608 | 1 |
Return list of rrd variable names that are defined by DEF, CDEF or VDEF statements in the rrd commands. If upToPoint is not None then only consider statements generated by graphoints where sequence < upToPoint | def getRRDVariables(self, upToPoint=None):
cmds = self.getFakeGraphCmds(upToPoint=upToPoint)
names = [line[line.find(':')+1:line.find('=')]
for line in cmds.split('\n')
if line[:line.find(':')] in ('DEF', 'CDEF', 'VDEF')]
nameSet = set(names)
resul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_variable_names(self):\n return [VariableString(s) for s in\n self._design.GetVariables()+self._design.GetPostProcessingVariables()]",
"def get_all_variables_names(self):\n return self.project.get_variable_names() + self.design.get_variable_names()",
"def getOriVarNames( sel... | [
"0.5392958",
"0.5360166",
"0.5346256",
"0.5300868",
"0.52450055",
"0.5127352",
"0.50558656",
"0.5036664",
"0.49936756",
"0.49881113",
"0.4899204",
"0.4888795",
"0.48883924",
"0.48659468",
"0.48622027",
"0.48596534",
"0.48502183",
"0.48455408",
"0.4807104",
"0.4780318",
"0.474... | 0.7487037 | 0 |
Return a list of DataPointGraphPoints that use the given dpName | def getDataPointGraphPoints(self, dpName):
from DataPointGraphPoint import DataPointGraphPoint
return [gp for gp in self.graphPoints()
if isinstance(gp, DataPointGraphPoint)
and gp.dpName == dpName] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isDataPointGraphed(self, dpName):\n from DataPointGraphPoint import DataPointGraphPoint\n return any(isinstance(gp, DataPointGraphPoint) and gp.dpName == dpName\n for gp in self.getGraphPoints(includeThresholds=False))",
"def addThresholdsForDataPoint(self, dpName):\n ... | [
"0.7042241",
"0.6933445",
"0.5913596",
"0.58924407",
"0.56992984",
"0.56479335",
"0.5186509",
"0.51690507",
"0.5135687",
"0.5112067",
"0.5082431",
"0.50791544",
"0.50612926",
"0.4981294",
"0.4980575",
"0.48528296",
"0.48498768",
"0.47901708",
"0.47775364",
"0.47705182",
"0.47... | 0.862947 | 0 |
Get a list of all unique datapoint names | def getUniqueDpNames(self, limit=None):
dpNames = set()
limitReached = False
for t in self.dmd.Devices.getAllRRDTemplates():
for ds in t.datasources():
# If we have a broken datasource (likely from a missing zenpack)
# then don't try to parse datapoint... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_names(self):\n return sorted(list(self.df[[Data.SDATA_NAME]].drop_duplicates().iloc[:, 0]))",
"def getGraphPointsNames(self):\n return [gp.id for gp in self.getGraphPoints()]",
"def get_data_names(self):\n return list(self.__data.keys())",
"def unique_detector_names() :\n retu... | [
"0.6854127",
"0.6741628",
"0.6649525",
"0.65908784",
"0.6469822",
"0.64435005",
"0.6409845",
"0.6399029",
"0.6359025",
"0.63451564",
"0.63337636",
"0.6274506",
"0.6174809",
"0.61704624",
"0.6149493",
"0.61419106",
"0.61280954",
"0.61201894",
"0.60574156",
"0.6019814",
"0.6019... | 0.6928489 | 0 |
Get a list of all unique threshold names | def getUniqueThresholdNames(self, limit=100):
names = set()
limitReached = False
for t in self.dmd.Devices.getAllRRDTemplates():
for thresh in t.thresholds():
names.add(thresh.id)
if len(names) >= limit:
limitReached = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_detector_names() :\n return experiment_info.unique_detector_names()",
"def unique_names(self):\n return list(self._nmtensor_uniname_dict.keys()) + [\"loss\"]",
"def get_threshold_data(self):\n return [list(x) for x in list(zip(self.thresholds,self.autothreshs))]",
"def thresholds(... | [
"0.6982296",
"0.67586267",
"0.6342752",
"0.6229806",
"0.59339887",
"0.57809794",
"0.57517564",
"0.57465345",
"0.57393974",
"0.5733423",
"0.57203734",
"0.5685221",
"0.56789505",
"0.5663762",
"0.5652926",
"0.5645425",
"0.56357867",
"0.5632528",
"0.56159985",
"0.5607792",
"0.560... | 0.8072748 | 0 |
Reads in the unbinned data cube, slices it, and writes the subsampled result to a file. | def subsample():
nwav = 872
nrow = 1600
ncol = 1560
fpath = os.path.join(HYSS_ENVIRON['HYSS_WRITE'],'raw_binned/nrow1600')
fnames = ['full_frame_20ms_faster_VNIR_1600.raw',
'full_frame_20ms_faster_VNIR_1600_flat.raw']
for fname in fnames:
print("SUBSAMPLE: reading data ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_cube(filename, data, data_view):\r\n display_ev = copy.copy(data_view.display_ev)\r\n no_ext_filename, ext = os.path.splitext(filename)\r\n out_filename = no_ext_filename + '.csv'\r\n rows, columns, slices = np.shape(data.ycube[...])\r\n spectra_count = 0\r\n for i in np.arange(rows):\... | [
"0.55757666",
"0.5460864",
"0.54045403",
"0.53365445",
"0.52652186",
"0.52342904",
"0.5185635",
"0.51854694",
"0.51804364",
"0.5116652",
"0.5111689",
"0.5088675",
"0.5083934",
"0.5082626",
"0.50710607",
"0.50566447",
"0.50512046",
"0.5036312",
"0.50205815",
"0.5008774",
"0.49... | 0.64611065 | 0 |
Read in the dark file, generate a smoothed spectrum of the instrument response, and write to a file. | def get_dark():
# -- utilities
nwav = 872
nrow = 1600
ncol = 20
dpath = "../../data/middleton/night time vnir full frame"
dname = "full frame 20ms dark_VNIR.raw"
fname = os.path.join(dpath,dname)
# -- read the file
raw = 1.0*np.fromfile(open(fname,'rb'),np.uint16 \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n (time, heart_rate, pace) = parse_file()\n (hr_filt, v_filt) = smoothing(time, heart_rate, pace)\n plot_data(hr_filt, v_filt)",
"def dark(config):\n\n # -----------DARK CURRENT----------------------\n files = sorted(glob.glob(config['raw_dir'] + '/radiance/{}/dark/dark_*.txt'.format(c... | [
"0.58927697",
"0.5681595",
"0.5657923",
"0.56110847",
"0.5580465",
"0.55745167",
"0.55745167",
"0.54152626",
"0.5414319",
"0.5370322",
"0.5366383",
"0.52836233",
"0.5229017",
"0.5214732",
"0.5196705",
"0.5193699",
"0.5192641",
"0.51783437",
"0.51697797",
"0.5122681",
"0.50855... | 0.6594187 | 0 |
Script to grab the NOAA templates from the web. By default the (.xls) files are put into the HYSS_ENVIRON path NOAA_DPATH. | def get_noaa(dpath=HYSS_ENVIRON['NOAA_DPATH']):
# -- define the file list
flist = ["Oil_Lanterns_20100311.xls",
"Pressurized_Gas_Lanterns_20100311.xls",
"Incandescent_Lamps_20100311.xls",
"Quart_Halogen_Lamps_20100311.xls",
"Mercury_Vapor_Lamp_20100311.xls",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_templates(self):\n filename1 = self._download_data('CecchiG_LB_s1_ok.txt', 'syn4538204')\n filename2 = self._download_data('CecchiG_LB_s2_ok.txt', 'syn4538216')\n return filename1, filename2",
"def offline_copy(_export_path):\n global export_path\n export_path = _export_pa... | [
"0.5943352",
"0.5255455",
"0.51865923",
"0.50773525",
"0.5076494",
"0.5047779",
"0.5043179",
"0.5041334",
"0.5022174",
"0.5021732",
"0.5015381",
"0.49852312",
"0.49753955",
"0.49717417",
"0.49602827",
"0.49584928",
"0.49582386",
"0.49548584",
"0.49407244",
"0.49401984",
"0.49... | 0.660937 | 0 |
Estimate the noise in a spectrum by computing the noise in the derivative spectrum. This function takes the derivative of an input spectrum and estimates the noise over a specified index range. | def estimate_noise(spec, ind_range=None):
# -- set the index range (nb, ends at len(spec)-1 since the derivative has
# one fewer points than the spectrum).
ind_range = ind_range if ind_range else [0,spec.shape[0]-1]
# -- compute the derivative and estimate the noise over the range
noise = (spec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_overf_noise(amp, index, f0, dt, n):\n\n white_noise = rand.normal(size=n)\n power_spectrum = overf_power_spectrum(amp, index, f0, dt, n)\n # Power spectrum is in physical units of T**2/Hz. Put in discrete units by\n # multiplying by twice the bandwidth.\n power_spectrum *= 1.0/dt\n ... | [
"0.702901",
"0.6871313",
"0.65687114",
"0.6269162",
"0.6253128",
"0.62081975",
"0.60975736",
"0.60969824",
"0.60851437",
"0.6075622",
"0.60577714",
"0.60396844",
"0.6028947",
"0.6027315",
"0.60238516",
"0.60153043",
"0.599087",
"0.5982897",
"0.5941623",
"0.5941623",
"0.594162... | 0.8284522 | 0 |
Decode int from bytes. | def IntDecode(int_bytes: bytes) -> int:
return ed25519_lib.int_decode(int_bytes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_integer(bytes_data): # type: (bytes) -> int\n values = [ord(b) for b in bytes_data]\n # check if the integer is normalized\n if (\n len(values) > 1\n and (\n values[0] == 0xff\n and values[1] & 0x80\n or values[0] ... | [
"0.7763512",
"0.7684034",
"0.7388712",
"0.72739875",
"0.71266925",
"0.7058717",
"0.7042124",
"0.69569165",
"0.6943808",
"0.6863106",
"0.68557376",
"0.6704994",
"0.670142",
"0.6676659",
"0.66630024",
"0.6645818",
"0.6612824",
"0.6604446",
"0.65574235",
"0.65430087",
"0.6537385... | 0.81048435 | 0 |
Encode int to bytes. | def IntEncode(int_val: int) -> bytes:
return ed25519_lib.int_encode(int_val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encode_int(source: int) -> bytes:\n return b\"i\" + str(source).encode(\"ascii\") + b\"e\"",
"def encode_int(n):\n return struct.pack(\">I\", n)",
"def int2byte(i):\n return bytes([i])",
"def varint_encode(num):\n buf = b''\n while True:\n towrite = num & 0x7f\n num >>= ... | [
"0.7768913",
"0.76607764",
"0.71565133",
"0.70630246",
"0.70243216",
"0.69567454",
"0.692022",
"0.6882505",
"0.6880596",
"0.68392557",
"0.68386066",
"0.6828192",
"0.6821115",
"0.67898715",
"0.6788577",
"0.6756882",
"0.6690159",
"0.65969104",
"0.65892905",
"0.6582101",
"0.6575... | 0.8162552 | 0 |
Convert rststyle sections into custom directives that ONLY insert the HTML header tags. | def convertSections(tabContent):
return PAT_RST_SECTION.sub(
lambda match: HEADING_TEMPLATE_RST.format(template.Options.HEADING_LEVELS.index(match.group(2)[0]) + 1, match.group(1)),
tabContent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_headers(mkd):\n\t\n\tfor md_code in re.findall(r\"^#####[^#].*\", mkd, re.M):\n\t\ttex_code = \"\\subparagraph{\" + re.findall(r\"#####(.*)\", md_code, re.M)[0] + \"}\"\n\t\tmkd = mkd.replace(md_code, tex_code)\n\n\tfor md_code in re.findall(r\"^####[^#].*\", mkd, re.M):\n\t\ttex_code = \"\\paragraph{\... | [
"0.60922647",
"0.55768925",
"0.5386777",
"0.52994424",
"0.5276414",
"0.5260321",
"0.52593523",
"0.520902",
"0.52028346",
"0.518432",
"0.51827896",
"0.51461744",
"0.5136546",
"0.5134101",
"0.5123161",
"0.510263",
"0.50878054",
"0.5085329",
"0.50826234",
"0.5078765",
"0.5047504... | 0.60107994 | 1 |
Produce all possible outcomes of n dsided dice, which obey the statistics of a particle of a given type. | def throw_table(n, d=6, type='classical'):
table = None
roll = range(1, d+1)
if type == 'classical':
table = list(itertools.product(roll, repeat=n))
else:
table = list(itertools.combinations(roll, n))
if type == 'bosonic':
# TODO: This only works for 2 dice!!!!
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_outcomes(num_die_sides):\n outcomes = []\n\n for value in range(1, num_die_sides + 1):\n outcomes.append(value)\n\n return outcomes",
"def get_outcomes(num_die_sides):\n outcomes = []\n\n for value in range(1, num_die_sides + 1):\n outcomes.append(value)\n\n return outcome... | [
"0.67074645",
"0.6509757",
"0.61289227",
"0.6124727",
"0.6005895",
"0.5866692",
"0.5778149",
"0.5729734",
"0.5703246",
"0.5701769",
"0.56961715",
"0.5677074",
"0.56402177",
"0.5599924",
"0.5596269",
"0.5543767",
"0.5526923",
"0.55050397",
"0.54603785",
"0.545836",
"0.5457857"... | 0.6920275 | 0 |
Calculate the probability of a given throw. | def prob(throw, n, d=6, type='classical'):
count = 0
table = throw_table(n, d, type)
for t in table:
if sum(t) == throw:
count += 1
return float(count)/len(table) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_probability(self):\n return 0",
"def _basic_probability(count: int, sequence_total_count: int) -> float:\n return float(count) / sequence_total_count",
"def prob(self, w):\n return self.counts[w] / self.total_count",
"def probability(series, params):\n\n prob = 1\n\n ... | [
"0.7053704",
"0.7047515",
"0.6409117",
"0.64043826",
"0.6395619",
"0.6391987",
"0.63346165",
"0.63067746",
"0.62886447",
"0.622437",
"0.6219629",
"0.62183815",
"0.6179436",
"0.61547804",
"0.61222196",
"0.61136377",
"0.6075865",
"0.6072008",
"0.60392725",
"0.60346323",
"0.6025... | 0.80324084 | 0 |
Run test on data using MDCAS classifier | def test(ctx, input_file, model, output_file):
# parse extra input args
kwargs = {ctx.args[i][2:]: ctx.args[i+1].strip('"') for i in range(0, len(ctx.args), 2)}
if 'use_groups' in kwargs:
if kwargs['use_groups']:
no_groups = 0
else:
no_groups = 1
else:
no_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_machine_learning():",
"def test(self, test_instances, test_labels):\n scores = self.classifier.predict(test_instances)\n # TODO: print report",
"def test_test_model(self):\n\n dataset = ClassificationTestDataset()\n model = ClassificationTestModel(dataset)\n preds = list(model.p... | [
"0.67008555",
"0.6378347",
"0.6342166",
"0.6327326",
"0.6322822",
"0.6302529",
"0.6294743",
"0.62541914",
"0.6243948",
"0.62220806",
"0.6205867",
"0.6179752",
"0.6162232",
"0.61506665",
"0.61263275",
"0.61179",
"0.61056167",
"0.6094072",
"0.60545284",
"0.6043587",
"0.6028298"... | 0.7321648 | 0 |
Sorts list Calls basic_list_exception.make_list(). The return is assigned variable name fun_list. Fun_list is sorted and returned. | def sort_list():
fun_list = basic_list_exception.make_list()
fun_list.sort()
return fun_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_list(self,list_):\r\n list_.sort()",
"def sort_list(user_input):\n user_input.sort()\n return user_input # added a return statement for a cleaner looking main function",
"def __sort(self, _list, _index, desc, pop_first_element=False):\n if _index != 0:\n _list = [(x[_in... | [
"0.7453129",
"0.6671785",
"0.6671766",
"0.6534962",
"0.6533778",
"0.6467076",
"0.640895",
"0.63817436",
"0.63570315",
"0.62686217",
"0.6252278",
"0.6245305",
"0.61799634",
"0.61680365",
"0.6136614",
"0.6133791",
"0.61328065",
"0.60831654",
"0.60668707",
"0.60594517",
"0.60523... | 0.9210571 | 0 |
Returns the index of the desired list item Calls basic_list_exception.make_list(). This return is assigned variable name fun_list. Parameter 'search' is searched for in fun_list and the index returned. An invalid search will return 1. This function will only return the first occurrence of the desired item. Multiple occ... | def search_list(search):
fun_list = basic_list_exception.make_list()
for x in range(len(fun_list)):
try:
location = fun_list.index(search)
return location
except ValueError:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_find(f, items):\n for i, x in enumerate(items):\n if f(x):\n return i\n return None",
"def linear_search(vlist, srchval): # somewhat different from book\n#Look at each item in list. If it equals the value you are looking for, stop.\n # linear_search_2.py\n index = 0\n fo... | [
"0.6771207",
"0.6602768",
"0.650768",
"0.6498043",
"0.6469767",
"0.63211566",
"0.62758034",
"0.6255265",
"0.62466764",
"0.6216497",
"0.620921",
"0.6201614",
"0.61916924",
"0.6107707",
"0.61071455",
"0.6093973",
"0.6076261",
"0.6058098",
"0.6032263",
"0.5959486",
"0.5954687",
... | 0.8350853 | 0 |
Render a template asynchronously. Can only be used within async functions. | async def render(
self, filename: str, *args: dict, **kwargs: typing.Any
) -> str:
with self._enable_async():
return await self._get_template(filename).render_async(
*args, **kwargs
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_sync(\n self, filename: str, *args: dict, **kwargs: typing.Any\n ) -> str:\n return self._get_template(filename).render(*args, **kwargs)",
"def run(self):\n try:\n self.event_loop = asyncio.new_event_loop()\n asyncio.set_event_loop(self.event_loop)\n ... | [
"0.64550006",
"0.61115015",
"0.5858807",
"0.5840916",
"0.5813506",
"0.57708234",
"0.57173",
"0.5715866",
"0.56986624",
"0.567303",
"0.5666513",
"0.5629261",
"0.5629261",
"0.5620829",
"0.56106263",
"0.5604572",
"0.55759907",
"0.5574777",
"0.55589956",
"0.55512637",
"0.5535814"... | 0.7226008 | 0 |
Render a template synchronously. See Also [Templates.render](render) for the accepted arguments. | def render_sync(
self, filename: str, *args: dict, **kwargs: typing.Any
) -> str:
return self._get_template(filename).render(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def render(\n self, filename: str, *args: dict, **kwargs: typing.Any\n ) -> str:\n with self._enable_async():\n return await self._get_template(filename).render_async(\n *args, **kwargs\n )",
"def render(*args, **kwargs):\n if args:\n assert l... | [
"0.7103638",
"0.6488621",
"0.6091482",
"0.60512024",
"0.6046113",
"0.6046113",
"0.5998374",
"0.59440666",
"0.5929027",
"0.5928621",
"0.59090745",
"0.5892084",
"0.58335584",
"0.5819274",
"0.57872176",
"0.57715476",
"0.5762185",
"0.57322615",
"0.5720736",
"0.56930006",
"0.56850... | 0.7095242 | 1 |
Open a file and its directory. The file is opened in binary mode and created if it does not exist. Both file descriptors must be closed after use to prevent them from leaking. | def open_file_in_dir(path: str) -> Tuple[io.FileIO, int]:
directory = os.path.dirname(path)
if not os.path.isdir(directory):
raise ValueError('No directory {}'.format(directory))
if not os.path.exists(path):
file_fd = open(path, mode='x+b', buffering=0)
else:
file_fd = open(path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opens(path, mode='rb', buffer_size=None, replication=None,\n default_block_size=None):\n fs.open(path, mode, buffer_size, replication, default_block_size)",
"def open(*args, **kwargs):\n d, *_ = os.path.split(args[0])\n if exists(d):\n if isfile(d):\n raise TypeError(\"Dir... | [
"0.65409726",
"0.63802326",
"0.63102823",
"0.6294549",
"0.62618923",
"0.6247112",
"0.62401265",
"0.6219079",
"0.62062967",
"0.61988574",
"0.6170711",
"0.6049113",
"0.6037458",
"0.60335326",
"0.60250247",
"0.6024615",
"0.59191006",
"0.5911622",
"0.5903085",
"0.58515257",
"0.58... | 0.7273465 | 0 |
Check that the interaction accepts a 'name' argument and has a 'name' attribute. | def test_interaction_accepts_name():
demag = ThinFilmDemag()
assert hasattr(demag, 'name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_interaction_accepts_name():\n dmi = DMI(1)\n assert hasattr(dmi, 'name')",
"def _check_name(self):\n\t\tpass",
"def test_should_name_field(self):\n self.assertIn(\"name\", self.fields)",
"def test_name(self):\n self.assertTrue(type(x.name) == str)",
"def test_name_required(self... | [
"0.7532491",
"0.71104854",
"0.6598713",
"0.65789807",
"0.65729326",
"0.6569929",
"0.6569805",
"0.65491575",
"0.65404105",
"0.6504166",
"0.6494333",
"0.6456961",
"0.6447923",
"0.6423309",
"0.6411447",
"0.6388383",
"0.6388383",
"0.6361176",
"0.6346425",
"0.63347346",
"0.6290485... | 0.7578395 | 0 |
Reset the error for integral sum so it doesn't run away | def reset_sum(self):
self._error_sum = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.integral = 0.0\n self.previous_error = 0.0",
"def reset_sum(self):\n self.sum_e = 0",
"def _integralTerm(self):\n\n\t\tself._accumulator = self._accumulator + self._getErrorFunction()\n\n\t\treturn self._Ki * self._accumulator * self._dt",
"def reset(self):\n ... | [
"0.75498784",
"0.6927585",
"0.62957966",
"0.6203336",
"0.60278976",
"0.59877455",
"0.5963143",
"0.593947",
"0.5938881",
"0.59044284",
"0.58871657",
"0.588392",
"0.5849137",
"0.58067584",
"0.5684856",
"0.5684856",
"0.568373",
"0.567355",
"0.56084055",
"0.55686873",
"0.5567206"... | 0.7755517 | 0 |
Remove the columns from dataset DataFrame that are specified in drop_list and convert to numpy array loaded in data | def drop_dfcol(self, drop_list):
self.data = self.df
for lbl in drop_list:
self.data = self.data.drop(lbl, axis=1)
self.n_features = np.shape(self.data)[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_columns(data):\n\n #Channels to be excluded\n features_delete = np.arange(46, 50)\n features_delete = np.concatenate([features_delete, np.arange(59, 63)])\n features_delete = np.concatenate([features_delete, np.arange(72, 76)])\n features_delete = np.concatenate([features_delete, np.arang... | [
"0.61597055",
"0.60008204",
"0.5865014",
"0.5797544",
"0.5754437",
"0.57444704",
"0.57335347",
"0.57189685",
"0.5717436",
"0.57109314",
"0.5648482",
"0.5634242",
"0.5596472",
"0.5593351",
"0.5570326",
"0.55594",
"0.5557522",
"0.55556387",
"0.55008364",
"0.5449504",
"0.5433073... | 0.6640361 | 0 |
Function returning the next batch When dataset has been fully fetched, a permutation is done By default, the labels will be onehot encoded | def get_next_batch(self, onehot=True):
if self.current_batch_idx == 0:
self.permutation()
next_beg = self.current_batch_idx * self.batch_size
next_end = (self.current_batch_idx + 1) * self.batch_size
if next_end > self.n_samples:
next_end = self.n_samples
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_batch(self, batch_size, shuffle=True):",
"def get_batch(batch_size):\n global ctr\n global data\n\n # shuffle the data if we don't have enough left, then go back to start\n if ctr*batch_size > len(data)-batch_size: \n data = np.random.permutation(data)\n ctr = -1\n ctr += 1\... | [
"0.74130744",
"0.7169552",
"0.70574874",
"0.7049608",
"0.7028859",
"0.7022153",
"0.6985804",
"0.6843323",
"0.68365353",
"0.6815268",
"0.6807453",
"0.67897123",
"0.6734823",
"0.6727332",
"0.6711093",
"0.6690314",
"0.6684776",
"0.6684776",
"0.664704",
"0.6625962",
"0.65804404",... | 0.7941934 | 0 |
Run permutations in the dataset to ensure that the different extracted sets will contain all type of labels | def permutation(self):
perm = np.random.permutation(self.n_samples)
self.data = self.data.iloc[perm]
self.labels = self.labels.iloc[perm]
self.labels_onehot = self.labels_onehot.iloc[perm]
self.df_perm = self.df_perm.iloc[perm] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_data_sets(reviews, labels, write_to_pickle=True, problem=\"\"):\n def sanity_check(labels):\n print str(len(labels)) + \" total labels. \" + str(sum(labels)) + \" positive labels. \" \\\n + str(len(labels) - sum(labels)) + \" negative labels. \"\n\n train_reviews = []\n trai... | [
"0.5995923",
"0.5990936",
"0.590176",
"0.58958864",
"0.58721405",
"0.58247125",
"0.5785727",
"0.5779371",
"0.5761028",
"0.57568294",
"0.57314676",
"0.5714494",
"0.57035154",
"0.56832904",
"0.567221",
"0.56679183",
"0.56375337",
"0.56362116",
"0.56142265",
"0.5609765",
"0.5594... | 0.6718072 | 0 |
Split dataset in n_subset parts and create as many dataset objects containing samples of original dataset chosen randomly with replacement | def random_sampling(self, n_subset):
t = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print("[INFO] {} - Random sampling with replacement ...".format(t))
subset_list = []
training_set = self
subset_size = math.ceil(training_set.n_samples / n_subset)
# create subsets
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsampleData(self, count):\n size = 0\n for block in self.blocks: size += len(block[1])\n subset = numpy.random.permutation(size)[:count]\n subset.sort()\n\n pos = 0\n index = 0\n ret = Dataset()\n for block in self.blocks:\n while subset[index]<(pos+len(block[1])):\n loc =... | [
"0.73276055",
"0.7179101",
"0.7172126",
"0.7058606",
"0.6954144",
"0.69088185",
"0.6906458",
"0.6873635",
"0.68358445",
"0.6793397",
"0.67461157",
"0.6732814",
"0.67272097",
"0.6716224",
"0.6622986",
"0.66004455",
"0.6593303",
"0.6583319",
"0.65280646",
"0.6527357",
"0.651893... | 0.73997825 | 0 |
Clip values a DataFrame | def clip(df, clip_val_low, clip_val_high):
clipped_df = df.clip(lower=clip_val_low, upper=clip_val_high)
return clipped_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip(df, lower, upper):\n\n # Pandas' clip-function doesn't allow dicts with bounds for only some\n # columns, so we convert them to Pandas Series which is allowed.\n if isinstance(lower, dict):\n lower = pd.Series(lower)\n if isinstance(upper, dict):\n upper = pd.Series(upper)\n\n ... | [
"0.699936",
"0.6971734",
"0.6647458",
"0.659986",
"0.65984356",
"0.6454323",
"0.6393906",
"0.6372437",
"0.63698834",
"0.6282307",
"0.6270707",
"0.618893",
"0.61671174",
"0.6096334",
"0.60405916",
"0.60226613",
"0.5984183",
"0.59821224",
"0.59791714",
"0.59673196",
"0.5928964"... | 0.7802768 | 0 |
Quantize in 8bit integer the input DataFrame | def quantize(self, df):
if len(self.dict_scalers) == 0:
raise Exception("[ERROR] quantize method called prior to"
"normalization transform method ")
quant_df = pd.DataFrame()
if 'OneForAll' in self.dict_scalers:
# quantization is applied on al... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_quanti_df(df: pd.DataFrame) -> pd.DataFrame:\n\n # create a dictionary that contains datatype of each column\n dtypeDict = dict(df.dtypes)\n # create a list of column names that contains only quantitative data\n quanti_cols = [\n key\n for key, value in dtypeDict.items()\n ... | [
"0.61353993",
"0.5912769",
"0.5888356",
"0.57613087",
"0.5717298",
"0.56393826",
"0.55785394",
"0.5569781",
"0.5552599",
"0.55363476",
"0.5456126",
"0.5450216",
"0.54477096",
"0.5378363",
"0.53030753",
"0.52675116",
"0.5234889",
"0.52308214",
"0.5218224",
"0.52171713",
"0.521... | 0.6261273 | 0 |
Set parameters specific to the optimizer and configure accordingly the optimizer | def set_optimizer_params(self):
n_params = len(self.optim_params)
if self.optimizer_name == 'GradientDescent' and n_params == 1:
self.optimizer = tf.keras.optimizers.SGD(
learning_rate=self.optim_params[0],
momentum=0)
elif self.optimizer_name == 'Mome... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setOptimizerParams(self,lr,momentum,decay):\n self.optimizer = SGD(lr=lr,momentum=momentum,decay=decay)",
"def _set_optimizer(self):\n\n if self.optimizer_name == 'Adam':\n self.optimizer = optim.Adam(self.net.parameters(),\n lr=self.learning_ra... | [
"0.78858274",
"0.7347013",
"0.72403",
"0.72388047",
"0.72245294",
"0.7192869",
"0.7171816",
"0.71698374",
"0.71178406",
"0.70970005",
"0.7080384",
"0.7080252",
"0.7080252",
"0.70799685",
"0.70799685",
"0.70665634",
"0.70665634",
"0.70665634",
"0.70620936",
"0.70452297",
"0.69... | 0.78668094 | 1 |
Create a tensorflow layer Returns | def create(self):
output = None
if self.output_bias is not None:
output_bias = tf.keras.initializers.Constant(self.output_bias)
else:
output_bias = None
kernel_init = None
if self.activation_name == 'relu' or self.activation_name == 'elu':
# K... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_layer(prev, n, activation):\n\n kernel_ini = tf.contrib.layers.variance_scaling_initializer(mode=\"FAN_AVG\")\n layer = tf.layers.Dense(units=n, activation=activation,\n kernel_initializer=kernel_ini, name='layer')\n\n return layer(prev)",
"def add_layer(inputs, in_... | [
"0.7084781",
"0.6995747",
"0.68748116",
"0.6861905",
"0.682327",
"0.6651122",
"0.6620249",
"0.6570826",
"0.65648794",
"0.65595657",
"0.6548422",
"0.6535935",
"0.65260965",
"0.65102136",
"0.6508955",
"0.6496199",
"0.6476136",
"0.6464349",
"0.64168966",
"0.63907206",
"0.6385728... | 0.7174275 | 0 |
Add a layer in the topology description | def add_layer(self, layer):
idx = len(self.dict_topo)
idx += 1
self.dict_topo[idx] = layer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, layer):\n self._top = layer(self._top)\n layer_name_ = layer.__class__.__name__\n layer_params_ = layer.params\n self._info.append((layer_name_, layer_params_))",
"def add_layer(self, layer_name, layer_def):\n\n layer_idx, datatype = layer_def.split(\"/\")\n layer_idx = in... | [
"0.7805753",
"0.7541488",
"0.7516729",
"0.7448067",
"0.7106162",
"0.7006872",
"0.6986021",
"0.6960728",
"0.690463",
"0.6880677",
"0.68639874",
"0.6814776",
"0.6797021",
"0.66522044",
"0.65949833",
"0.6578789",
"0.649572",
"0.6461116",
"0.6447533",
"0.64351547",
"0.64181596",
... | 0.79526275 | 0 |
Patch method on the CTC loss function. | def replacement_ctc(self, model, target, output):
if model.get_backend().get_name() == 'pytorch':
pytest.xfail('Backend "pytorch" does not use a CTC loss function.')
return replacement_ctc.original(self, model, target, output) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ctc_loss(input, target, padding_mask=-1, reduction='mean'):\n return FunctionLib.apply(\n 'CTCLoss', input.device, [input, target],\n padding_mask=padding_mask, reduction=reduction.upper())",
"def loss_fun(para):\n\n return -data_processing(my_cir(para))",
"def compute_loss(self):",
"... | [
"0.6675707",
"0.6387273",
"0.6372352",
"0.62484735",
"0.6132804",
"0.6079117",
"0.60688186",
"0.606799",
"0.60481673",
"0.5984609",
"0.5964755",
"0.5933834",
"0.58745325",
"0.5865406",
"0.5853754",
"0.58390427",
"0.5826628",
"0.5811279",
"0.58002925",
"0.57244164",
"0.5716214... | 0.6861857 | 0 |
Prepares the distribution to be used later in KS and CvM, merges equal data, computes (summed) weights and cumulative distribution. All output arrays are of same length and correspond to each other. | def prepare_distibution(data, weights):
weights = weights / numpy.sum(weights)
prepared_data, indices = numpy.unique(data, return_inverse=True)
prepared_weights = numpy.bincount(indices, weights=weights)
prepared_cdf = compute_cdf(prepared_weights)
return prepared_data, prepared_weights, prepared_cd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_precomputed_data(self):\n if self.num_sampled == 0:\n self._K_chol = numpy.array([])\n self._K_inv_y = numpy.array([])\n else:\n covariance_matrix = python_utils.build_covariance_matrix(\n self._covariance,\n self._points_sampl... | [
"0.58526564",
"0.58262277",
"0.5758998",
"0.5748369",
"0.57075936",
"0.56584954",
"0.559263",
"0.5550285",
"0.5528897",
"0.5528054",
"0.54900885",
"0.54486",
"0.54329103",
"0.54175764",
"0.54162246",
"0.541557",
"0.53902715",
"0.53786284",
"0.5368939",
"0.53679097",
"0.535114... | 0.66014075 | 0 |
For arbitrary number of variables computes the indices of data, the indices are unique numbers of bin from zero to \prod_j (len(bin_limits[j])+1) | def compute_bin_indices(X_part, bin_limits=None, n_bins=20):
if bin_limits is None:
bin_limits = []
for variable_data in range(X_part.shape[1]):
bin_limits.append(numpy.linspace(numpy.min(variable_data), numpy.max(variable_data), n_bins + 1)[1: -1])
bin_indices = numpy.zeros(len(X_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fft_bin_to_index(self, bins):\n idx = bins.copy()\n return idx",
"def II_eq_counts(tobin_series, num_bins):\n num_pbin = int(len(tobin_series) / num_bins)\n obs_list = tobin_series.sort_values().tolist()\n upper_bounds = [obs_list[(i + 1) * num_pbin] for i in range(num_bins)]\n lowe... | [
"0.6472701",
"0.6416261",
"0.63878626",
"0.6359179",
"0.6314764",
"0.6230381",
"0.61053705",
"0.60628146",
"0.60599846",
"0.6049954",
"0.60333955",
"0.6018827",
"0.5976351",
"0.58945024",
"0.5893819",
"0.58688754",
"0.5865678",
"0.5849126",
"0.58324975",
"0.5822173",
"0.58002... | 0.7419312 | 0 |
Transforms bin_indices into group indices, skips empty bins | def bin_to_group_indices(bin_indices, mask):
assert len(bin_indices) == len(mask), "Different length"
bins_id = numpy.unique(bin_indices)
result = list()
for bin_id in bins_id:
result.append(numpy.where(mask & (bin_indices == bin_id))[0])
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groupDigitized(arr, bins, edges='right'):\n edges = edges.lower()\n if edges.startswith('r'): right = True\n elif edges.startswith('l'): right = False\n else: RuntimeError(\"``edges`` must be 'right' or 'left'!\")\n\n # `numpy.digitize` always assumes `bins` are right-edges (in effect)\n shif... | [
"0.6790227",
"0.60028476",
"0.59623134",
"0.59570706",
"0.5907395",
"0.5899478",
"0.5867087",
"0.5864903",
"0.5864903",
"0.58454823",
"0.5812525",
"0.58035856",
"0.57689106",
"0.5740283",
"0.5694048",
"0.56503814",
"0.56228024",
"0.5616195",
"0.5608595",
"0.5593722",
"0.55829... | 0.81799394 | 0 |
Computes cumulative distribution function (CDF) by ordered weights, be sure that sum(ordered_weights) == 1 | def compute_cdf(ordered_weights):
return numpy.cumsum(ordered_weights) - 0.5 * ordered_weights | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(weights):\r\n\treturn np.cumsum(weights) / sum(weights)",
"def build_cdf(self,\n label: str, \n weights : str = None) -> np.array :\n\n if not weights == None:\n table = self.sample.sort_values(label)\n w = table[weights].values\n return np.array([tab... | [
"0.7808867",
"0.6640013",
"0.6417415",
"0.64035153",
"0.63425964",
"0.6248766",
"0.6175385",
"0.6148169",
"0.6113682",
"0.61068696",
"0.6064439",
"0.5981427",
"0.5885678",
"0.587889",
"0.58629364",
"0.5734454",
"0.57086366",
"0.5649806",
"0.56232774",
"0.56004256",
"0.5599004... | 0.90470666 | 0 |
Group weight = sum of divided weights of indices inside that group. | def compute_group_weights(group_indices, sample_weight):
divided_weight = compute_divided_weight(group_indices, sample_weight=sample_weight)
result = numpy.zeros(len(group_indices))
for i, group in enumerate(group_indices):
result[i] = numpy.sum(divided_weight[group])
return result / numpy.sum(r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_divided_weight(group_indices, sample_weight):\n indices = numpy.concatenate(group_indices)\n occurences = numpy.bincount(indices, minlength=len(sample_weight))\n return sample_weight / numpy.maximum(occurences, 1)",
"def group_weights(self):\n return self._group_weights",
"def make_... | [
"0.7939019",
"0.7005258",
"0.6503108",
"0.6283467",
"0.6041539",
"0.59712166",
"0.5937707",
"0.5931625",
"0.5931625",
"0.5931625",
"0.585102",
"0.5840155",
"0.58163464",
"0.58008605",
"0.57846296",
"0.57718515",
"0.57582396",
"0.57571346",
"0.5677269",
"0.5672433",
"0.5662619... | 0.8071284 | 0 |
Efficiency of bin = total weight of (signal) events that passed the cut in the bin / total weight of signal events in the bin. Returns small negative number for empty bins | def compute_bin_efficiencies(y_score, bin_indices, cut, sample_weight, minlength=None):
y_score = column_or_1d(y_score)
assert len(y_score) == len(sample_weight) == len(bin_indices), "different size"
if minlength is None:
minlength = numpy.max(bin_indices) + 1
bin_total = numpy.bincount(bin_ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computeBinWidth(self):\n self.binWidth = (self.data[-1] - self.data[0]) / self.numBins\n # Fill the frequencies array with zero\n for i in range(self.numBins):\n self.frequencies.append(0)",
"def bin_width(self):\n return self.bins[2] - self.bins[1]",
"def hist_bin_op... | [
"0.6985526",
"0.6976061",
"0.6611083",
"0.6557816",
"0.6479786",
"0.6422993",
"0.62774515",
"0.62433946",
"0.62018967",
"0.6179098",
"0.61688465",
"0.61647296",
"0.61596763",
"0.6153586",
"0.6150716",
"0.61418563",
"0.61181736",
"0.61181736",
"0.60886174",
"0.605678",
"0.6050... | 0.72251797 | 0 |
KolmogorovSmirnov flatness on groups | def groups_based_ks(y_pred, mask, sample_weight, groups_indices):
assert len(y_pred) == len(sample_weight) == len(mask)
group_weights = compute_group_weights(groups_indices, sample_weight=sample_weight)
prepared_data, prepared_weight, prep_F = prepare_distibution(y_pred[mask], weights=sample_weight[mask])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ks_test(mode):\n indices = np.random.randint(0, 1000, 1000)\n out = compute_indices_ks_test(indices, 1000, mode=mode)\n assert all([o > 0.0 for o in out])",
"def ks_permutation(df, test, depend, N=100):\n df_miss = df.assign(test_is_null=df[test].isnull()) # Convert to True/False\n \n ... | [
"0.6005968",
"0.56198287",
"0.5610313",
"0.5579879",
"0.55310446",
"0.5473759",
"0.5451436",
"0.5448116",
"0.54453945",
"0.54423434",
"0.540879",
"0.54013926",
"0.5363996",
"0.5346235",
"0.53235096",
"0.53212035",
"0.53028125",
"0.52973664",
"0.5262193",
"0.5248925",
"0.52450... | 0.608119 | 0 |
Create new customer until the sim time reaches 120. with poisson process | def customer_arrivals(env,n_customer,res_counter,kitchen,parameters,result_fifo):
for i in range(n_customer):
yield env.timeout(random.poisson(1/parameters['lamb']))
env.process(customer(env, i+1, res_counter, kitchen,parameters, result_fifo)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_generator_proc(env, numberOfCustomers, timeBetween, patience, reneged, queue, newArrivalEvents):\n k = 0\n while k<numberOfCustomers:\n yield env.timeout( random.expovariate(1.0/timeBetween) )\n k += 1\n env.process( reneging_customer_proc(env, name = \"Customer-%d\" %k, pat... | [
"0.6840482",
"0.6832827",
"0.66417027",
"0.64847577",
"0.6410035",
"0.63926697",
"0.63023084",
"0.62798744",
"0.6184291",
"0.60859585",
"0.59795135",
"0.59249324",
"0.59051925",
"0.5734989",
"0.55950016",
"0.55909395",
"0.5579533",
"0.5536693",
"0.5523081",
"0.54954857",
"0.5... | 0.7021973 | 0 |
Parses a textual table that the console commands generate. Each row is converted into a dictionary. | def _parse_table(value):
lines = value.split('\n')
header = None
rows = []
for l in lines:
if l.startswith('+-'):
pass
elif l.startswith('|'):
columns = [c.strip() for c in l.split('|')[1:-1]]
if header is None:
header = columns
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_table(text):\n\n text = str(text)\n try:\n text = text.split(\"<pre>\")[1]\n text = text.split(\"</pre>\")[0]\n text = text.split(\"To save this output\")[0]\n lines = text.split(\"\\n\")\n except Exception as exc:\n raise NNDCRequestError(f\"Unable to parse t... | [
"0.71673447",
"0.60959446",
"0.5971185",
"0.5959461",
"0.58425015",
"0.5720146",
"0.5672264",
"0.5623402",
"0.55867875",
"0.55597275",
"0.55413747",
"0.55306673",
"0.5491815",
"0.5470142",
"0.54245096",
"0.5415857",
"0.53637147",
"0.5355543",
"0.5339088",
"0.5334059",
"0.5285... | 0.6948149 | 1 |
Hull has a chance of being breached if less than the dangerzone. Chance of survival is determined by how much % hull remains. Returns input hull amount if RNG thinks it should, otherwise 0. | def hull_breach(hull, max_hull, damage,
hull_danger_zone=HULL_DANGER_ZONE):
damaged_hull = hull - damage
chance_of_survival = damaged_hull / max_hull
return not (chance_of_survival < hull_danger_zone and
chance_of_survival < random.random()) and damaged_hull or 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack_success(self) -> float:\n return (0.5 * (1 + self.health / 100) *\n random.randint(50 + self.experience, 100) / 100)",
"def starve_checker(hunger):\n death_chance = -30\n hunger -= 1\n\n if (death_chance * (hunger-1)) > random.randint(1,100):\n death = True\n e... | [
"0.5800374",
"0.5777586",
"0.5722534",
"0.56271267",
"0.5575537",
"0.5561197",
"0.54654646",
"0.545684",
"0.5455878",
"0.54383594",
"0.54310936",
"0.5420394",
"0.54159355",
"0.5407532",
"0.5384197",
"0.5382327",
"0.53513324",
"0.534415",
"0.534136",
"0.5327161",
"0.5322189",
... | 0.7209705 | 0 |
Check whether the damage has enough power to damage the shield or just harmlessly bounce off it, only if there is a shield available. Shield will be returned if the above conditions are not met, otherwise the current shield less damage taken will be returned. Returns the new shield value. | def shield_bounce(shield, max_shield, damage,
shield_bounce_zone=SHIELD_BOUNCE_ZONE):
# really, shield can't become negative unless some external factors
# hacked it into one.
return ((damage < shield * shield_bounce_zone) and shield > 0 and
shield or shield - damage) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shield(self) -> Union[int, float]:\n return self.proto.shield",
"def shield(self) -> Union[int, float]:\n return self.proto.shield",
"def shield_percentage(self) -> Union[int, float]:\n if not self.proto.shield_max:\n return 0\n return self.proto.shield / self.proto.s... | [
"0.6871626",
"0.6871626",
"0.6710707",
"0.6710707",
"0.664567",
"0.6606711",
"0.6223943",
"0.61304355",
"0.61304355",
"0.6111382",
"0.6082744",
"0.6006835",
"0.59314424",
"0.5845344",
"0.58417785",
"0.5830175",
"0.5772714",
"0.5765584",
"0.5765008",
"0.5757683",
"0.5755831",
... | 0.7109316 | 0 |
Calculates damage factor on size. If weapon size is greater than the target size, then only the area that falls within the target will the damage be applied. | def size_damage_factor(weapon_size, target_size):
if weapon_size <= target_size:
return damage
return (target_size ** 2) / (weapon_size ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def true_damage(damage, weapon_size, target_size, source_debuff, target_debuff):\n\n # source_debuffs: tracking disruption\n tracking_disrupt = 1 + source_debuff.get('active', {}).get(\n 'tracking_disruption', 0)\n # target_debuffs: target painter, web\n target_painter = 1 + target_debuff.get('a... | [
"0.6976738",
"0.614433",
"0.6112917",
"0.5962203",
"0.5929868",
"0.59076524",
"0.58056116",
"0.57666886",
"0.5642174",
"0.563287",
"0.5591096",
"0.5555944",
"0.55480963",
"0.55103374",
"0.54974663",
"0.5475105",
"0.540319",
"0.54011244",
"0.5390442",
"0.5346287",
"0.53433824"... | 0.87186164 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.