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 |
|---|---|---|---|---|---|---|
Validate that the parameter provided in the yaml file for configuration is correct. Some of the params requires list of two values. This is mostly checked as part of this function | def validate_yaml_values(yaml_values, multicar):
# Verify if all the yaml keys required for launching models have same number of values
same_len_values = [MODEL_S3_BUCKET_YAML_KEY, MODEL_S3_PREFIX_YAML_KEY, MODEL_METADATA_FILE_S3_YAML_KEY,
CAR_COLOR_YAML_KEY]
LOG.info(yaml_values)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate(self):\n if not isinstance(self.parameter_schema, dict):\n raise TypeError(\"parameter_schema must be a dictionary\")\n # TODO: Settle on an input file schema and validation library\n self._parameter_names = list(self.parameter_schema.keys())\n # List, sets, and... | [
"0.6815742",
"0.666671",
"0.662292",
"0.65539265",
"0.6547447",
"0.6517362",
"0.6448434",
"0.64415306",
"0.6429363",
"0.64210576",
"0.6413348",
"0.64084303",
"0.639821",
"0.6383561",
"0.636115",
"0.6339327",
"0.63338935",
"0.63338935",
"0.63218206",
"0.6320479",
"0.6298177",
... | 0.6856142 | 0 |
Return true if connection open. | def connection_open(self):
return self.conn_status == self.CONN_OPEN | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_open(self):\n\t\treturn self.conn.open",
"def is_open(self) -> bool:\n return self._connection is not None",
"def is_open(self):\n return self.connection.isOpen()",
"def is_connected(self):\n return self._connection and self._connection.is_open",
"def is_open(self):\n ret... | [
"0.8859106",
"0.8789426",
"0.87475836",
"0.8539903",
"0.83996904",
"0.83766246",
"0.80371636",
"0.80156213",
"0.7942192",
"0.79175633",
"0.784329",
"0.78295565",
"0.7800843",
"0.77957827",
"0.7741089",
"0.773933",
"0.77221006",
"0.7644822",
"0.76414007",
"0.7607545",
"0.75935... | 0.88138354 | 1 |
Return true if connection closed. | def connection_closed(self):
return self.conn_status == self.CONN_CLOSED | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_closed(self) -> bool:",
"def close_connection(self) -> bool:\n return self.get_header('Connection') != 'keep-alive'",
"def closed(self) -> bool:\n return self.pgconn.status == ConnStatus.BAD",
"def isClosed(self) -> bool:\n return self._connection is None",
"def is_close... | [
"0.84769607",
"0.8242719",
"0.7979521",
"0.796748",
"0.79436976",
"0.7401407",
"0.73887956",
"0.72837645",
"0.72837645",
"0.72705364",
"0.72705364",
"0.7250111",
"0.7236907",
"0.72351795",
"0.7211585",
"0.7134584",
"0.71017545",
"0.70844245",
"0.70419157",
"0.70255566",
"0.70... | 0.8416074 | 1 |
Return true if connection failed. | def connection_failed(self):
return self.conn_status == self.CONN_FAILED | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_failed(self, connection, error):\n assert False",
"def _connect_failed(self):\n\t\tself.root.stdout.write(\"Error: Connection Failed!\\n\")\n\t\tself.client = False",
"def _CheckConnect(self):\n try:\n resp = requests.get(self._target_url, timeout=2)\n if resp.headers['Maximu... | [
"0.76815915",
"0.72939175",
"0.7174199",
"0.7173939",
"0.7085975",
"0.70545787",
"0.70519024",
"0.70445323",
"0.69770306",
"0.69688153",
"0.6818643",
"0.68122923",
"0.6778391",
"0.6717677",
"0.6707202",
"0.6702052",
"0.66111636",
"0.66098875",
"0.65836877",
"0.6574816",
"0.65... | 0.839965 | 0 |
Compute setpoints from node and domoticz data | def computeSetpoints(node: dict, domo: dict) -> dict:
# url = u'http://{}:{}/templow={}&temphigh={}&minduty={}&maxduty={}&hyster={}&addressCtrl={}'
data = {}
if node is None:
return {}
sensors = node['sensors']
if len(sensors) == 0:
return {}
if len(sensors) == 1:
address... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_points(self, divisions=100):",
"def get_node_points(node):\n for item in coordinate_list:\n if item[0] == node.value:\n return (item[1], item[2])",
"def _updateProjectedPts(self):\n for pointSetName in self.pointSets:\n pointSet = self.pointSets[pointSetName]\n ... | [
"0.6075896",
"0.58490354",
"0.58050025",
"0.58025885",
"0.57375175",
"0.5730053",
"0.5685268",
"0.568077",
"0.5596504",
"0.55412656",
"0.5526672",
"0.5502367",
"0.54950976",
"0.54852754",
"0.544555",
"0.54434407",
"0.5431688",
"0.5425213",
"0.54221356",
"0.5412496",
"0.539094... | 0.7103121 | 0 |
Builds a residual block with repeating bottleneck blocks. | def _residual_block(input, id_block, conv_block, mid_f, output_f, repetitions, stage, is_first_layer=False):
for i in range(repetitions):
if i == 0 and is_first_layer is True:
input = conv_block(mid_f, output_f, stage, i, input, stride=(1, 1))
elif i == 0 and is_first_layer is False:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def residual_block(self, x, block_type, filter_num, repeats, is_first_layer=False):\n for i in range(repeats):\n init_strides = (1, 1)\n if i == 0 and not is_first_layer:\n init_strides = (2, 2)\n is_first = (is_first_layer and i == 0)\n\n if block_... | [
"0.6507806",
"0.6374493",
"0.6317341",
"0.62087023",
"0.611913",
"0.6094651",
"0.6091319",
"0.6075556",
"0.5997031",
"0.599633",
"0.5970693",
"0.5963587",
"0.58644557",
"0.58611804",
"0.58022916",
"0.579565",
"0.5790783",
"0.5775797",
"0.5754129",
"0.57040554",
"0.56548786",
... | 0.64811885 | 1 |
Test case for get_evidence | def test_get_evidence(self):
query_string = [('keywords', 'keywords_example'),
('pageNumber', 56),
('pageSize', 56)]
response = self.client.open('/api/evidence/{statementId}'.format(statementId='statementId_example'),
me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_evidence_1(base_settings):\n filename = (\n base_settings[\"unittest_data_dir\"]\n / \"evidence-example-stroke-no-alteplase-fatalICH.json\"\n )\n inst = evidence.Evidence.parse_file(\n filename, content_type=\"application/json\", encoding=\"utf-8\"\n )\n assert \"Eviden... | [
"0.68562466",
"0.6721957",
"0.6674695",
"0.6591843",
"0.6518838",
"0.64771515",
"0.63950706",
"0.63682437",
"0.6075483",
"0.60133964",
"0.5980025",
"0.5887339",
"0.58502823",
"0.58166045",
"0.57613623",
"0.5755346",
"0.572492",
"0.5685638",
"0.5647998",
"0.55966866",
"0.55827... | 0.7157481 | 0 |
Load modules, set keybinding and create L{deskbar.core.ThreadPool.ThreadPool} | def run(self):
# Ready to load modules
self._module_loader.load_all_async()
self._setup_keybinder()
self._threadpool.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_pooling(key, module):\n register(key, module, pooling_dict)",
"def __init__(self, module, poolclass=QueuePool, **kw):\n\n self.module = module\n self.kw = kw\n self.poolclass = poolclass\n self.pools = {}\n self._create_pool_mutex = threading.Lock()",
"def sta... | [
"0.61915106",
"0.6082867",
"0.5944113",
"0.57061934",
"0.5584452",
"0.55621535",
"0.553043",
"0.553043",
"0.54864764",
"0.53727007",
"0.5364852",
"0.5362851",
"0.53054655",
"0.52711916",
"0.52711916",
"0.5258856",
"0.521594",
"0.5195682",
"0.51848394",
"0.517445",
"0.51434076... | 0.71231675 | 0 |
Get directory where modules are stored | def get_modules_dir(self):
return self._modules_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetPackageDirectory():\n return os.path.dirname(__file__)",
"def module_directory(file_path):\n return os.path.dirname(os.path.realpath(file_path))",
"def default_module_dir(self):\n return os.path.dirname(self._modules['default'].path)",
"def module_path(self):\n return self.config['cwd'... | [
"0.8037318",
"0.79695654",
"0.791168",
"0.7835981",
"0.77839756",
"0.7754749",
"0.77420557",
"0.7610356",
"0.7568536",
"0.75120974",
"0.7503393",
"0.7500169",
"0.7392109",
"0.7383796",
"0.73750055",
"0.73674023",
"0.7365304",
"0.73419416",
"0.7288379",
"0.7278813",
"0.727033"... | 0.8287971 | 0 |
Connect to module's C{queryready} signal Load history if all modules have been initialized | def on_module_initialized(self, loader, module):
self._inited_modules += 1
# Forward results
module.connect ('query-ready', self.forward_query_ready)
if (self._inited_modules == self._loaded_modules):
self._history.load()
self._emit_initialized() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ready(self):\n import exams.signals # pylint: disable=unused-import",
"def ready(self):\n import main.signals # noqa",
"def slot_fullhistory_processed(self, _sender, _data):\r\n self.check_connect_ready()",
"def ready(self):\n\n from . import signals # noqa",
"def ready(s... | [
"0.6416909",
"0.6405394",
"0.62069213",
"0.6181104",
"0.6166752",
"0.61031646",
"0.6088049",
"0.6025865",
"0.59627044",
"0.5903577",
"0.59016055",
"0.5836651",
"0.5823571",
"0.5814508",
"0.5739278",
"0.57218504",
"0.5707234",
"0.5691313",
"0.56798786",
"0.5658247",
"0.5634498... | 0.7448059 | 0 |
Implements `tensorflow_privacy.DPQuery.get_noised_result`. Updates tree state, and returns noised cumulative sum and updated state. Computes new cumulative sum, and returns its noised value. Grows tree state by one new leaf, and returns the new state. | def get_noised_result(self, sample_state, global_state):
new_cumulative_sum = tf.nest.map_structure(
tf.add, global_state.samples_cumulative_sum, sample_state)
cumulative_sum_noise, new_tree_state = self._tree_aggregator.get_cumsum_and_update(
global_state.tree_state)
noised_cumulative_sum =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_noised_result(self, sample_state, global_state):\n # The [0] is needed because of how tf.RaggedTensor.from_two_splits works.\n # print(tf.RaggedTensor.from_row_splits(values=[3, 1, 4, 1, 5, 9, 2, 6],\n # row_splits=[0, 4, 4, 7, 8, 8]))\n # <tf.RaggedTensor ... | [
"0.66539407",
"0.60514474",
"0.604872",
"0.5423762",
"0.5403341",
"0.5341307",
"0.5308367",
"0.5190128",
"0.51838744",
"0.50993407",
"0.49817097",
"0.49701074",
"0.49481267",
"0.49349594",
"0.4906724",
"0.48961648",
"0.4884102",
"0.48736203",
"0.48687285",
"0.48543125",
"0.48... | 0.66304296 | 1 |
Returns a query instance with L2 norm clipping and Gaussian noise. | def build_l2_gaussian_query(cls,
clip_norm,
noise_multiplier,
record_specs,
noise_seed=None,
use_efficient=True):
if clip_norm <= 0:
raise ValueError(f'`clip_no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_central_gaussian_query(cls,\n l2_norm_clip: float,\n stddev: float,\n arity: int = 2):\n if l2_norm_clip <= 0:\n raise ValueError(f'`l2_norm_clip` must be positive, got {l2_norm_clip}.')\n\n i... | [
"0.5956823",
"0.5268126",
"0.525906",
"0.51341707",
"0.51055115",
"0.5103174",
"0.49586508",
"0.49290007",
"0.4928099",
"0.4872917",
"0.48474833",
"0.48159385",
"0.47413",
"0.47353283",
"0.47147936",
"0.47097415",
"0.47097415",
"0.46906346",
"0.46762535",
"0.46730715",
"0.467... | 0.72789 | 0 |
Returns state after resetting the tree. This function will be used in `restart_query.RestartQuery` after calling `get_noised_result` when the restarting condition is met. | def reset_state(self, noised_results, global_state):
del noised_results
new_tree_state = self._tree_aggregator.reset_state(global_state.tree_state)
return attr.evolve(
global_state,
previous_tree_noise=self._zero_initial_noise(),
tree_state=new_tree_state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_state(self):\n\t\treturn self.state",
"def reset(self):\n self._current_state = self._initial_state\n return self._current_state",
"def state(self):\n result = self.getResult()\n return result.state",
"def reset_state(self, noised_results, global_state):\n new_tree_... | [
"0.6235567",
"0.6205294",
"0.61933804",
"0.61889935",
"0.60124147",
"0.6009189",
"0.5993048",
"0.59235406",
"0.5815908",
"0.5802378",
"0.5795542",
"0.5755649",
"0.5747292",
"0.5735273",
"0.57172436",
"0.5709553",
"0.5698203",
"0.565802",
"0.56420815",
"0.56406504",
"0.5627447... | 0.643667 | 0 |
A function constructs a complete tree given all the leaf nodes. The function takes a 1D array representing the leaf nodes of a tree and the tree's arity, and constructs a complete tree by recursively summing the adjacent children to get the parent until reaching the root node. Because we assume a complete tree, if the ... | def _build_tree_from_leaf(leaf_nodes: tf.Tensor, arity: int) -> tf.RaggedTensor:
def pad_zero(leaf_nodes, size):
paddings = [[0, size - len(leaf_nodes)]]
return tf.pad(leaf_nodes, paddings)
leaf_nodes_size = tf.constant(len(leaf_nodes), dtype=tf.float32)
num_layers = tf.math.ceil(
tf.math.log(leaf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_tree():\n root = TreeNode(5)\n root.left = TreeNode(3)\n root.right = TreeNode(8)\n root.left.left = TreeNode(2)\n root.left.right = TreeNode(4)\n root.right.left = TreeNode(7)\n return root",
"def increment_leaves(t):\n if is_leaf(t):\n return tree(label(t) + 1)\n ... | [
"0.60422784",
"0.5954496",
"0.59224623",
"0.58749163",
"0.58607495",
"0.58496094",
"0.5846953",
"0.58350945",
"0.5808153",
"0.5794747",
"0.57655746",
"0.5758684",
"0.57576525",
"0.5739191",
"0.57258",
"0.56992185",
"0.5657313",
"0.56559247",
"0.5611313",
"0.5580399",
"0.55652... | 0.66371644 | 0 |
Implements `tensorflow_privacy.DPQuery.preprocess_record`. This method builds the tree, flattens it and applies `inner_query.preprocess_record` to the flattened tree. | def preprocess_record(self, params, record):
arity, inner_query_params = params
preprocessed_record = _build_tree_from_leaf(record, arity).flat_values
# The following codes reshape the output vector so the output shape of can
# be statically inferred. This is useful when used with
# `tff.aggregators... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _preprocess(self):\n # A 2D table storing all possible queries.\n self._table = {}\n\n # Build the table using bottom-up dynamic programming.\n for p in breadth_first_traversal(self._tree):\n self._table[p.index()] = [p]\n\n l = 0\n while (l < self._... | [
"0.5816456",
"0.5209207",
"0.50791806",
"0.49638155",
"0.49106506",
"0.4743634",
"0.46487808",
"0.46216828",
"0.4619339",
"0.46100935",
"0.4566832",
"0.45600775",
"0.45276245",
"0.45236808",
"0.44982338",
"0.44945985",
"0.4477679",
"0.4471945",
"0.44442165",
"0.44167742",
"0.... | 0.7913433 | 0 |
Implements `tensorflow_privacy.DPQuery.get_noised_result`. This function reconstructs the `tf.RaggedTensor` from the flattened tree output by `preprocess_records.` | def get_noised_result(self, sample_state, global_state):
# The [0] is needed because of how tf.RaggedTensor.from_two_splits works.
# print(tf.RaggedTensor.from_row_splits(values=[3, 1, 4, 1, 5, 9, 2, 6],
# row_splits=[0, 4, 4, 7, 8, 8]))
# <tf.RaggedTensor [[3, 1, 4... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_noised_result(self, sample_state, global_state, noise_flag=True):\n #print(\"SUM Query get_noised_result\")\n def add_noise(v):\n if noise_flag:\n return v + tf.random_normal(tf.shape(v), stddev=global_state.stddev)\n else:\n return v\n\n\n return nest.map_structure(add_noi... | [
"0.53281695",
"0.5155004",
"0.51467645",
"0.5093361",
"0.507004",
"0.4995979",
"0.49548063",
"0.4835851",
"0.4835851",
"0.47925606",
"0.4791984",
"0.47834897",
"0.46680832",
"0.4645934",
"0.4617304",
"0.46026275",
"0.46007198",
"0.45929497",
"0.45774785",
"0.45580658",
"0.453... | 0.66883826 | 0 |
Utility function to decide which `add_noise` to use according to tf version. | def _get_add_noise(stddev, seed: int = None):
if distutils.version.LooseVersion(
tf.__version__) < distutils.version.LooseVersion('2.0.0'):
# The seed should be only used for testing purpose.
if seed is not None:
tf.random.set_seed(seed)
def add_noise(v):
return v + tf.random.normal(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sample_new_noise(self, *, tf_sess=None):\n if self.framework == \"tf\":\n tf_sess.run(self.tf_sample_new_noise_op)\n elif self.framework == \"tf2\":\n self._tf_sample_new_noise_op()\n else:\n for i in range(len(self.noise)):\n self.noise[i] ... | [
"0.65933436",
"0.6148029",
"0.6120062",
"0.6105077",
"0.59642065",
"0.5959322",
"0.594963",
"0.5939457",
"0.58493304",
"0.58342236",
"0.57876354",
"0.57769424",
"0.5763656",
"0.57124543",
"0.5710894",
"0.5685687",
"0.5681812",
"0.5636605",
"0.560741",
"0.5598038",
"0.55895907... | 0.6919989 | 0 |
Function that adds a line at the top of a dataframe | def appforth(df, line):
df.loc[-1]=line
df.index = df.index + 1 # shifting index
df = df.sort_index() # sorting by index
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertLines(data):\n data = pd.DataFrame(data)\n for _,row in data.iterrows():\n insertLine(row)",
"def append_row(row: pd.DataFrame, df: pd.DataFrame, to_top=True):\n # return pd.concat([row,df], keys=list(get_player_dict().keys())) # persist player_dict so don't have to call func each time\... | [
"0.6450391",
"0.6103644",
"0.60023224",
"0.5928826",
"0.5883956",
"0.5686137",
"0.56739867",
"0.56389904",
"0.556931",
"0.5552866",
"0.54786396",
"0.5454885",
"0.5451427",
"0.5447397",
"0.5443985",
"0.54176456",
"0.54099715",
"0.54071224",
"0.5404459",
"0.5392393",
"0.5390264... | 0.70635945 | 0 |
Scopes a CAR object name, via dm[object][action], or dm[object] | def car_object_scoper(object_name):
return "match(tag, \"dm-{}-.*\")".format(object_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_find_object(intent, session):\n\n session_attributes = {}\n card_title = intent['name']\n should_end_session = False\n\n # gets the name of the object to find from the CocoLabels \n if 'CocoLabel' in intent['slots']:\n find_object = intent['slots']['CocoLabel']['value']\n\n # u... | [
"0.49998254",
"0.49394655",
"0.4830572",
"0.47007003",
"0.4640364",
"0.4611399",
"0.45747447",
"0.4572054",
"0.45297208",
"0.45125824",
"0.44931853",
"0.4492525",
"0.44041118",
"0.43627155",
"0.43458802",
"0.43364504",
"0.43242493",
"0.43224373",
"0.4312224",
"0.42707038",
"0... | 0.60656214 | 0 |
Scopes a basic data model object name, via a tag for that object | def default_object_scoper(object_name):
return "tag=\"{}\"".format(object_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope(self, name):\r\n raise NotImplementedError",
"def enterScope(self, name):",
"def tag(request, tag_name):\n raise NotImplementedError",
"def car_object_scoper(object_name):\n return \"match(tag, \\\"dm-{}-.*\\\")\".format(object_name)",
"def get_name_tag(obj):\n if 'Name' in obj.tags:\... | [
"0.59146094",
"0.5570406",
"0.55264395",
"0.5388028",
"0.52947885",
"0.528724",
"0.52704865",
"0.5238314",
"0.51886225",
"0.5183685",
"0.5134695",
"0.5121833",
"0.50938827",
"0.50138915",
"0.500384",
"0.4985468",
"0.4984962",
"0.49840176",
"0.49785545",
"0.49749237",
"0.49721... | 0.654432 | 0 |
Return starting and ending positions of next url in 'page' | def get_next_target(page):
start_link = page.find('<a href=')
if start_link == -1:
return None,0
url_start = page.find('"',start_link)
url_end = page.find('"',url_start+1)
url= page[url_start+1:url_end]
return url, url_end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_page(url):\n match = re.search(r\".*/(\\d+)_p/\", url)\n if match:\n next_number = int(match.group(1)) + 1\n next_url = urljoin(BEGIN_RENT_LISTINGS, f\"{next_number}_p/\")\n return next_url\n else:\n # the first page has no page index\n return urljoin(BEGIN_... | [
"0.6779975",
"0.6501436",
"0.65007085",
"0.6494547",
"0.6434313",
"0.6422518",
"0.63540596",
"0.6335683",
"0.63250726",
"0.6303088",
"0.6284856",
"0.6263668",
"0.6229728",
"0.61964154",
"0.6182833",
"0.6176746",
"0.61159736",
"0.61122054",
"0.6098143",
"0.60820466",
"0.604802... | 0.7293851 | 0 |
Return the content of 'page' as a string | def get_page(page):
import urllib2
source = urllib2.urlopen(page)
return source.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gzipPage(page):\n #if not hasattr(page,\"info\"):\n # return(\"\")\n data = object()\n # Check if content encoding is gzip\n if page.info().get('Content-Encoding') == 'gzip':\n buf = StringIO(page.read())\n f = gzip.GzipFile(fileobj=buf)\n ... | [
"0.6812407",
"0.6779268",
"0.6730493",
"0.6714532",
"0.66052943",
"0.6539855",
"0.6525119",
"0.6456388",
"0.6429239",
"0.6354027",
"0.63502115",
"0.62898964",
"0.6212344",
"0.6207898",
"0.61903757",
"0.6112677",
"0.60466343",
"0.6025773",
"0.6025773",
"0.6025773",
"0.59985214... | 0.7084817 | 0 |
Add keyword and correspoding url to index | def add_to_index(index,keyword,url):
if keyword in index:
if url not in index[keyword]:
index[keyword].append(url)
else:
index[keyword] = [url] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_index(index, keyword, url):\n for entry in index:\n if entry[0] == keyword:\n for link in entry[1]:\n if link[0] == url:\n return\n entry[1].append([url, 0])\n return\n # not found, add new keyword to index\n index.append... | [
"0.7244178",
"0.718754",
"0.708995",
"0.6512627",
"0.62463087",
"0.61937195",
"0.6045089",
"0.5995985",
"0.591784",
"0.58594745",
"0.5852419",
"0.5837323",
"0.57760435",
"0.5757303",
"0.57329094",
"0.5677471",
"0.5675483",
"0.5658136",
"0.56528085",
"0.56026316",
"0.5600233",... | 0.75011736 | 0 |
Add given content as correspoding to given url into index | def add_page_to_index(index,url,content):
keywords = split_string(content,".,-!<>/=\"")
for keyword in keywords:
add_to_index(index,keyword,url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_page_to_index(index, url, content):\n words = content.split()\n for word in words:\n add_to_index(index, word, url)\n return index",
"def add_to_index(self, url, soup):\n # Check if its been indexed\n if self.is_indexed(url):\n return\n print('Indexing ' + ... | [
"0.7923618",
"0.70689374",
"0.66906023",
"0.6685535",
"0.62889946",
"0.61518013",
"0.61401385",
"0.61159647",
"0.59772736",
"0.59241956",
"0.58785456",
"0.58241045",
"0.5757223",
"0.56649214",
"0.56147075",
"0.5602823",
"0.55195284",
"0.5516285",
"0.551462",
"0.54848856",
"0.... | 0.78251207 | 1 |
Return all crawled links starting with seed page never exceeding max_depth number of links | def web_crawler(seed, max_depth):
to_crawl = [seed]
crawled = []
next_depth = []
current_depth = 0
while to_crawl and current_depth <= max_depth:
link = to_crawl.pop(0)
if link not in crawled:
content = get_page(link)
add_page_to_index(index, link, content)
outlinks = get_all_links(content)
grap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_crawler(seed_url, max_depth=2):\n rp = robotparser.RobotFileParser()\n rp.set_url(seed_url)\n rp.read()\n user_agent = 'Mozilla/5.0'\n throttle = Throttle(2)\n\n crawl_queue = [seed_url]\n # seen = set(crawl_queue)\n seen = {}\n while crawl_queue:\n url = crawl_queue.pop(... | [
"0.6875229",
"0.66055876",
"0.6267404",
"0.6253713",
"0.62250006",
"0.61569595",
"0.61212385",
"0.6112696",
"0.60850215",
"0.606888",
"0.6043061",
"0.60217476",
"0.6012997",
"0.5966401",
"0.5952373",
"0.59483755",
"0.592668",
"0.5901948",
"0.5891726",
"0.5855988",
"0.58293915... | 0.7582555 | 0 |
Returns a challenge list in which the participant team has participated. | def get_participant_team_challenge_list(request, participant_team_pk):
try:
participant_team = ParticipantTeam.objects.get(pk=participant_team_pk)
except ParticipantTeam.DoesNotExist:
response_data = {"error": "Participant Team does not exist"}
return Response(response_data, status=statu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def challenges(self):\n return [gc.challenge for gc in GrandChallenge.objects.filter(round=self.round_number).order_by('challenge__status')]",
"def get_teams_and_corresponding_challenges_for_a_participant(\n request, challenge_pk\n):\n # first get list of all the participants and teams related to th... | [
"0.680435",
"0.66060233",
"0.6537005",
"0.63112986",
"0.597053",
"0.5943581",
"0.5930192",
"0.5917891",
"0.5883498",
"0.5836435",
"0.57701683",
"0.57308173",
"0.57189554",
"0.56186867",
"0.5602969",
"0.5601824",
"0.55860543",
"0.5477212",
"0.5473619",
"0.5410445",
"0.5397491"... | 0.74032825 | 0 |
Deletes a participant from a Participant Team | def delete_participant_from_team(request, participant_team_pk, participant_pk):
try:
participant_team = ParticipantTeam.objects.get(pk=participant_team_pk)
except ParticipantTeam.DoesNotExist:
response_data = {"error": "ParticipantTeam does not exist"}
return Response(response_data, stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_participant(namespace, workspace, participant_id):\n body = [{\"entityType\": \"participant\", \"entityName\": participant_id}]\n res = firecloud_api.delete_entities(namespace, workspace, body)\n return res",
"def test_teams_delete_team_v1(self):\n pass",
"def remove_participant_team... | [
"0.7903541",
"0.73878294",
"0.7301038",
"0.7076802",
"0.70719147",
"0.70630145",
"0.6979449",
"0.6949171",
"0.69224036",
"0.68868876",
"0.6761044",
"0.65837455",
"0.6563054",
"0.65048635",
"0.6489657",
"0.6477331",
"0.64720404",
"0.64182156",
"0.639442",
"0.63762146",
"0.6370... | 0.8019204 | 0 |
Returns list of teams and corresponding challenges for a participant | def get_teams_and_corresponding_challenges_for_a_participant(
request, challenge_pk
):
# first get list of all the participants and teams related to the user
participant_objs = Participant.objects.filter(
user=request.user
).prefetch_related("team")
is_challenge_host = is_user_a_host_of_cha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_participant_team_challenge_list(request, participant_team_pk):\n try:\n participant_team = ParticipantTeam.objects.get(pk=participant_team_pk)\n except ParticipantTeam.DoesNotExist:\n response_data = {\"error\": \"Participant Team does not exist\"}\n return Response(response_data... | [
"0.7486413",
"0.6884057",
"0.6744358",
"0.63074934",
"0.6212099",
"0.60113627",
"0.5894778",
"0.58834064",
"0.5869901",
"0.5677612",
"0.5669971",
"0.5663816",
"0.5663816",
"0.5662114",
"0.565243",
"0.564603",
"0.5620577",
"0.56161445",
"0.5612477",
"0.560553",
"0.558742",
"... | 0.7442681 | 1 |
API to remove the participant team from a challenge | def remove_participant_team_from_challenge(
request, challenge_pk, participant_team_pk
):
challenge = get_challenge_model(challenge_pk)
participant_team = get_participant_model(participant_team_pk)
if participant_team.created_by == request.user:
if participant_team.challenge_set.filter(id=chal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_self_from_participant_team(request, participant_team_pk):\n try:\n participant_team = ParticipantTeam.objects.get(pk=participant_team_pk)\n except ParticipantTeam.DoesNotExist:\n response_data = {\"error\": \"ParticipantTeam does not exist!\"}\n return Response(response_data, ... | [
"0.7473976",
"0.72688293",
"0.71886873",
"0.7148638",
"0.7045636",
"0.70265687",
"0.6818663",
"0.67133147",
"0.66402155",
"0.66349757",
"0.6601563",
"0.65917593",
"0.65877056",
"0.65525466",
"0.6514433",
"0.6494568",
"0.64471155",
"0.6436979",
"0.6409133",
"0.63364136",
"0.63... | 0.82082254 | 0 |
Prepare a batch import of stock from the WMS | def import_warehouse_stock_qty_batch(session, model_name, backend_id, filters=None):
if filters is None:
filters = {'skus': 'ALL'}
env = get_environment(session, model_name, backend_id)
importer = env.get_connector_unit(WarehouseImport)
importer.run(filters['skus']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batcher(self, stock_list=None, batch_size=3): \n \n if stock_list is None:\n stock_list = self.target_df[\"stock_id\"].unique().tolist()\n \n for b in range(int(np.ceil(len(stock_list)/batch_size))):\n \n # load data for current batch of s... | [
"0.63788944",
"0.6079358",
"0.6077869",
"0.5958602",
"0.5896479",
"0.5851557",
"0.56427634",
"0.5628975",
"0.5591365",
"0.5588544",
"0.55817103",
"0.55682635",
"0.5555077",
"0.5523834",
"0.55184215",
"0.5513052",
"0.54832745",
"0.5449837",
"0.54431075",
"0.54243374",
"0.54130... | 0.6733992 | 0 |
create dark mask for adding black box | def create_dark_mask():
black_dx = 60
black_dy = 20
dark_mask = np.zeros((black_dx, black_dy))
for k in range(black_dy):
dark_mask[:, k] = (np.abs(k - black_dy // 2) / (black_dy / 2.)) ** 2
return dark_mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _draw_mask_on_image(self, mask):\n mask = self.STANDARD_COLORS_ARRAY[mask]\n cv2.addWeighted(mask,self.config.ALPHA,self.image,1.0,0,self.image)",
"def darkText(img):\n kernel = np.ones((30, 30), np.uint8) \n img_orig = cv2.morphologyEx(img, cv2.MORPH_BLACKHAT, kernel)\n \n TH = 150\n ... | [
"0.63838786",
"0.63049793",
"0.62848854",
"0.6153061",
"0.61257046",
"0.6056754",
"0.60519767",
"0.60442626",
"0.60140884",
"0.6011093",
"0.60109454",
"0.5998653",
"0.5976996",
"0.5952318",
"0.59447837",
"0.5942385",
"0.594157",
"0.5940272",
"0.59369177",
"0.5935086",
"0.5897... | 0.7751801 | 0 |
create indices for elastic deformation used once at the start epoch | def create_elastic_indices():
# initial values
alpha, alpha2, sigma = 10, 10, 50
shape = (96, 288) # same as shape of input images
x_mesh, y_mesh = np.meshgrid(np.arange(shape[1]), np.arange(shape[0]))
# below is used once per epoch for the elastic deformation
g_1d = signal.gaussian(300, sigma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_indices():\n destroy_indices()\n\n ActionDocument._index.create(ignore=[400, 404])\n ClassificationDocument._index.create(ignore=[400, 404])\n FunctionDocument._index.create(ignore=[400, 404])\n PhaseDocument._index.create(ignore=[400, 404])\n RecordDocument._index.create(ignore=[400, ... | [
"0.66859436",
"0.66719866",
"0.6349877",
"0.6213434",
"0.62014925",
"0.6187456",
"0.6145705",
"0.6125054",
"0.60850066",
"0.60762537",
"0.6061925",
"0.60564893",
"0.603865",
"0.603088",
"0.592026",
"0.5913104",
"0.5910337",
"0.58373445",
"0.58350444",
"0.5829702",
"0.58171064... | 0.74854475 | 0 |
Tell how many package langpacks are in a repository. | def _count_langpacks(server_config, repo_id):
keyword = 'Package Langpacks:'
completed_proc = cli.Client(server_config).run((
'pulp-admin repo list --repo-id {} '
'--fields content_unit_counts'
).format(repo_id).split())
lines = [
line for line in completed_proc.stdout.splitlines... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumberOfRepoMetas(language: scrape_repos_pb2.LanguageToClone) -> int:\n path = pathlib.Path(language.destination_directory)\n if path.is_dir():\n return len([x for x in path.iterdir() if x.suffix == '.pbtxt'])\n else:\n return 0",
"def get_language_distribution(username):\n users_repos, api_ca... | [
"0.66752565",
"0.6532368",
"0.6046342",
"0.59336007",
"0.5558157",
"0.54607993",
"0.54088056",
"0.53695124",
"0.53459215",
"0.5338504",
"0.53373575",
"0.53265643",
"0.5307102",
"0.5282407",
"0.5189841",
"0.517864",
"0.5156967",
"0.5152993",
"0.51480114",
"0.5142072",
"0.51319... | 0.79024357 | 0 |
Upload a langpack to the repository. | def test_01_upload_langpacks(self):
cmd = (
'pulp-admin rpm repo uploads langpacks --repo-id {0} '
'--name {1} --install {1}-%s'
).format(self.repo_id, utils.uuid4()).split()
self.client.run(cmd)
num_langpacks = _count_langpacks(self.cfg, self.repo_id)
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self):\n self.parser.add_argument('lp_file',\n help=\"Language pack file.\")\n args = self.parser.parse_args()\n with open(args.lp_file) as lang_pack_file:\n try:\n data = json.load(lang_pack_file)\n except ValueEr... | [
"0.62043434",
"0.61931455",
"0.56932753",
"0.5622727",
"0.5565598",
"0.5508079",
"0.5461822",
"0.53841746",
"0.5354653",
"0.5328929",
"0.52714604",
"0.5268928",
"0.5264531",
"0.52438486",
"0.52255696",
"0.5210193",
"0.5205726",
"0.51858276",
"0.5173261",
"0.51670825",
"0.5150... | 0.696309 | 0 |
Remove all langpacks from the repository. | def test_02_remove_langpacks(self):
cmd = (
'pulp-admin rpm repo remove langpacks --repo-id {0} '
'--str-eq repo_id={0}'
).format(self.repo_id).split()
self.client.run(cmd)
package_counts = _count_langpacks(self.cfg, self.repo_id)
self.assertEqual(package_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updaterun(self):\n self.comp('packmanager').updaterun_allpacks()",
"def clean(self) -> None:\n # remove all *.py and *.pyi files in the folder\n for wc in [\"*.py\", \"*.pyi\", \"modules.json\"]:\n for f in (self.package_path).rglob(wc):\n f.unlink()",
"def de... | [
"0.66892415",
"0.63567525",
"0.6288578",
"0.62467444",
"0.61771727",
"0.6155896",
"0.6002582",
"0.59961915",
"0.599042",
"0.5969188",
"0.5913592",
"0.5901261",
"0.5809616",
"0.5789034",
"0.5758695",
"0.5745822",
"0.5745124",
"0.57391536",
"0.57295966",
"0.5711309",
"0.5705105... | 0.74062234 | 0 |
E_recoverable = n_rb E_available | def ComputeERecoverable(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ComputeEAvailable(self):\r\n pass",
"def Available(self) -> int:",
"def Available(self) -> int:",
"def Available(self) -> int:",
"def nsbchainallocfailrate(self) :\n\t\ttry :\n\t\t\treturn self._nsbchainallocfailrate\n\t\texcept Exception as e:\n\t\t\traise e",
"def emergency_recover_states_fr... | [
"0.7259141",
"0.6207658",
"0.6207658",
"0.6207658",
"0.5967218",
"0.5759527",
"0.5751798",
"0.5640953",
"0.5592255",
"0.5592102",
"0.5578379",
"0.5560529",
"0.5543831",
"0.5530444",
"0.55110765",
"0.5491762",
"0.54166013",
"0.53990567",
"0.5389732",
"0.5366482",
"0.53451365",... | 0.7416888 | 0 |
Balance the weights between positive and negative class. | def balance_training_weight(w, y):
sample_weight = w.copy()
neg_mask = (y == 0)
pos_mask = (y == 1)
bkg_sum_weight = np.sum(sample_weight[neg_mask])
sig_sum_weight = np.sum(sample_weight[pos_mask])
sample_weight[pos_mask] = sample_weight[pos_mask] / sig_sum_weight
sample_weight[neg_mas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_weights_for_balanced_classes(self):\n\n count = [0] * self.get_num_classes()\n\n # label = self.class_map_dict[self.meta_data.loc[image_id]['dx']]\n # labels = [self.class_map_dict[l] for l in self.get_labels()]\n\n labels = self.get_labels()\n\n # Count how many instanc... | [
"0.68336725",
"0.6566826",
"0.6540164",
"0.651501",
"0.64945495",
"0.6477396",
"0.64635986",
"0.62950265",
"0.629437",
"0.6283344",
"0.6141206",
"0.60930645",
"0.6090759",
"0.6088292",
"0.60794246",
"0.6062189",
"0.6026726",
"0.6010749",
"0.60101426",
"0.59969455",
"0.5962372... | 0.687342 | 0 |
Steps the solution (should be overridden) return True if more work to be done | def step_solution(self):
import time, random
time.sleep(1.0)
print '(step_solution) Implement me!'
return True if random.random() < 0.25 else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solveOneStep(self):\n ### Student code goes here\n return True",
"def solve(self, print_steps=False) -> bool:\n (state, _cost_to_goal) = self.ida_heuristic()\n steps = self.steps(state)\n\n if steps:\n for step in steps:\n self.parent.rotate(step)\... | [
"0.7533063",
"0.7151375",
"0.7089587",
"0.7013403",
"0.6946627",
"0.68247205",
"0.6823569",
"0.682202",
"0.6733594",
"0.67238253",
"0.6709113",
"0.66496783",
"0.6643983",
"0.66237456",
"0.66221094",
"0.66221094",
"0.66221094",
"0.6612477",
"0.6555148",
"0.649842",
"0.6438424"... | 0.7640185 | 0 |
Starts the algorithm thread | def start_threading(self):
if self.algorithm_thread == None:
self.reset_algorithm()
self.algorithm_thread = Thread(target=self.run_algorithm)
self.running = True
self.algorithm_thread.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_algorithm(self):\r\n pass",
"def start(self):\n self.thread.start()",
"def run(self):\n self.thread = threading.Thread(target=self._main)\n self.thread.start()\n self.running = True",
"def run(self):\n self.debug('Starting new thread')\n while True:\... | [
"0.72073776",
"0.6548943",
"0.64515096",
"0.6427067",
"0.6424888",
"0.64214873",
"0.63795894",
"0.6370999",
"0.6370999",
"0.63574445",
"0.6355481",
"0.63353544",
"0.62769985",
"0.6262419",
"0.62350714",
"0.6229823",
"0.62021965",
"0.61984926",
"0.6172129",
"0.6153177",
"0.612... | 0.81287515 | 0 |
Called when run is clicked | def on_run_clicked(self):
self.start_threading()
self.stepping = False
self.step_event.set() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_run_button(self, event):\n text = _(u\"Run button pressed.\")\n if self.state == 0:\n self.canvas_2d.render(text)\n else:\n self.canvas_3d.render()\n self.run_command()",
"def action_run(self):\n pass",
"def on_run_clicked(self, button):\n ... | [
"0.776996",
"0.7159776",
"0.7127498",
"0.711462",
"0.7077018",
"0.7053827",
"0.6858014",
"0.6811964",
"0.67369586",
"0.6681562",
"0.6671963",
"0.66519713",
"0.66119826",
"0.6604397",
"0.66033155",
"0.6573459",
"0.65371513",
"0.6488229",
"0.647721",
"0.64404744",
"0.6439631",
... | 0.7667751 | 1 |
Called when step is clicked | def on_step_clicked(self):
self.start_threading()
self.stepping = True
self.step_event.set() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):",
"def step(self, **kwargs):\n pass",
"def step(self):\n\n pass",
"def step(self, action):\n pass",
"def step(self, action):\n pass",
"def do_step(self) -> None:",
"def step(self, step=None):\n pass",
"def step(self):\n self.driver.step()",
... | [
"0.76680094",
"0.7664967",
"0.74570215",
"0.74103165",
"0.74103165",
"0.74082524",
"0.7369268",
"0.73554176",
"0.7342362",
"0.7126725",
"0.7122076",
"0.712172",
"0.70810664",
"0.7073016",
"0.7067284",
"0.7016274",
"0.69972795",
"0.69972795",
"0.69972795",
"0.695149",
"0.69514... | 0.7995173 | 0 |
Puts the buttons into the layout, this lets additional buttons to be inserted | def pack_buttons(self):
button_layout = QtGui.QHBoxLayout()
for button in self.buttons:
button_layout.addWidget(button)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.costmap_widget)
layout.addLayout(button_layout)
# layout.addStretch(1)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_side_buttons(self):\n # Top and bottom buttons\n for col in range(self._grid.width):\n top_button = widgets.HExitButton('^', -1, col)\n bottom_button = widgets.HExitButton('v', self._grid.height, col)\n self._graphic_grid.addWidget(top_button, 1, 2 + col)\n ... | [
"0.75349486",
"0.7389897",
"0.735289",
"0.72757477",
"0.727273",
"0.7214057",
"0.7162141",
"0.7138631",
"0.7111026",
"0.7106109",
"0.70633",
"0.69639516",
"0.69321036",
"0.6900489",
"0.6888164",
"0.68828595",
"0.68777716",
"0.6867355",
"0.6846782",
"0.6838435",
"0.68343973",
... | 0.75596774 | 0 |
Tests that the put_template is called when a Distllery is saved. | def test_distillery_saved(self, mock_template):
distillery = Distillery.objects.get_by_natural_key(
'elasticsearch.test_index.test_docs')
distillery.save()
self.assertEqual(mock_template.call_count, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_template(self):\n distillery = Distillery.objects.get_by_natural_key(\n 'mongodb.test_database.test_docs')\n try:\n distillery.save()\n except AttributeError:\n self.fail('put_template() raised AttributeError unexpectedly')",
"def test_update_temp... | [
"0.6996458",
"0.6920677",
"0.6608226",
"0.6474705",
"0.6427574",
"0.6425407",
"0.64048684",
"0.6386568",
"0.6384004",
"0.6301151",
"0.6287031",
"0.62696403",
"0.6257897",
"0.62187016",
"0.6218047",
"0.6211397",
"0.6169345",
"0.6141047",
"0.60961807",
"0.60961807",
"0.59944934... | 0.7588906 | 0 |
Tests that the put_template is called when a Collection is saved. | def test_collection_saved(self, mock_template):
collection = Collection.objects.get_by_natural_key(
'elasticsearch', 'test_index', 'test_docs')
collection.save()
self.assertEqual(mock_template.call_count, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_collection(self):\n pass",
"def test_create_collection(self):\n pass",
"def test_collection_put(testapp, execute_counter):\n initial = {\n 'title': \"Testing\",\n 'type': \"object\", # include a non-required field\n 'description': \"This is the initial inse... | [
"0.6980898",
"0.6820879",
"0.6740693",
"0.65089387",
"0.6254954",
"0.62282354",
"0.6181171",
"0.61265177",
"0.6032391",
"0.5999189",
"0.5942901",
"0.59207255",
"0.5890596",
"0.58821326",
"0.5867017",
"0.5847702",
"0.580511",
"0.5792177",
"0.5790407",
"0.5789679",
"0.5789038",... | 0.7935593 | 0 |
Tests that the put_template is called when a Distllery is saved. | def test_no_template(self):
distillery = Distillery.objects.get_by_natural_key(
'mongodb.test_database.test_docs')
try:
distillery.save()
except AttributeError:
self.fail('put_template() raised AttributeError unexpectedly') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_distillery_saved(self, mock_template):\n distillery = Distillery.objects.get_by_natural_key(\n 'elasticsearch.test_index.test_docs')\n distillery.save()\n self.assertEqual(mock_template.call_count, 1)",
"def test_update_template_registration(self):\n pass",
"def ... | [
"0.7586853",
"0.6920392",
"0.66093814",
"0.64756733",
"0.64292437",
"0.6425549",
"0.6404809",
"0.63888687",
"0.63837016",
"0.63025904",
"0.62876683",
"0.6271569",
"0.6257832",
"0.6219582",
"0.6216816",
"0.62102026",
"0.61700255",
"0.614135",
"0.6095817",
"0.6095817",
"0.59941... | 0.69946975 | 1 |
Return offset of local zone from GMT | def _local_time_offset():
if time.localtime().tm_isdst and time.daylight:
return -time.altzone
else:
return -time.timezone | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow()\n # XXX: `return -time.timezone`?\n return timedelta.total_seconds()",
"def timezone_offset():\r\n\r\n return _random.choice(\r\n [\r\n... | [
"0.7432826",
"0.7360823",
"0.7292204",
"0.72637445",
"0.7237618",
"0.7083396",
"0.6958518",
"0.69471073",
"0.67810845",
"0.67092437",
"0.6597678",
"0.65896887",
"0.64723",
"0.64647484",
"0.6375368",
"0.6350449",
"0.63273025",
"0.6307903",
"0.6293711",
"0.62897044",
"0.6239180... | 0.8144448 | 0 |
Check if the ants image is LPI | def is_lpi(image: ANTsImage) -> bool:
return ants.get_orientation(image) == "LPI" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pil_available():\n out = False\n try:\n from PIL import Image # noqa\n out = True\n except ImportError:\n pass\n return out",
"def has_legacy_image(self):\n pass",
"def has_legacy_image(self):\n pass",
"def check_type(filename):\n try:\n im = Imag... | [
"0.6723706",
"0.64862984",
"0.64862984",
"0.6341957",
"0.5932047",
"0.58131933",
"0.56591177",
"0.56364685",
"0.5607884",
"0.5581156",
"0.5554165",
"0.5522299",
"0.5472068",
"0.5465147",
"0.54574215",
"0.54384565",
"0.53776044",
"0.53488296",
"0.53404135",
"0.53373593",
"0.53... | 0.7424667 | 0 |
A convenient function to throw an error if all threads are not closed | def verify_all_threads_closed(allowable_threads=None):
if allowable_threads is None:
allowable_threads = []
allowable_threads += ['pydevd.Writer',
'pydevd.Reader',
'pydevd.CommandThread',
'profiler.Reader',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_thread_pool_with_exception():\r\n thread_pool = ThreadPool()\r\n result = []\r\n\r\n def throw_ex_task():\r\n raise Exception()\r\n\r\n def populate_result_task():\r\n result.extend([i for i in range(0, 10)])\r\n return\r\n\r\n thread_pool.add_task(throw_ex_task)\r\n ... | [
"0.61719173",
"0.61607677",
"0.60640156",
"0.5974588",
"0.5685633",
"0.56818783",
"0.56537515",
"0.561098",
"0.56060076",
"0.5574318",
"0.554333",
"0.5520906",
"0.5511527",
"0.549633",
"0.548776",
"0.5474221",
"0.54601955",
"0.54417574",
"0.5439107",
"0.54386246",
"0.5437763"... | 0.70901555 | 0 |
Displays the list of computers currently owned by the company with links to details for each one. | def computers(request):
computers = Computer.objects.all().order_by("make", "model")
context = {
"computers": computers
}
return render(request, 'agileHR/computers.html', context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner_account_chooser():\n owner_accounts = fetch_owner_accounts()\n return render_template('export.html', owner_accounts=owner_accounts)",
"def list_all(request):\n companies = Company.objects.order_by('-created')\n context = dict(companies=companies)\n return render(request, 'companies/all.h... | [
"0.6253107",
"0.59324056",
"0.58755654",
"0.58396393",
"0.57442504",
"0.56902754",
"0.5683713",
"0.565747",
"0.5612516",
"0.5517808",
"0.55136454",
"0.5477685",
"0.5473058",
"0.5449596",
"0.5444004",
"0.5425859",
"0.5419863",
"0.5411725",
"0.5410857",
"0.5403279",
"0.5403265"... | 0.6093117 | 1 |
Displays search results when a user searches for a computer by make or model | def computer_search(request):
if request.method == "POST":
search_text = request.POST["search_text"]
if search_text is not "":
by_make = Computer.objects.filter(make__contains=search_text).order_by("make", "model")
by_model = Computer.objects.filter(model__contains=search_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search():\n pass",
"def search(request):\r\n\tinput_text = request.GET.get('search-text', '')\r\n\tgames = Game.objects.filter(name__icontains=input_text)\r\n\treturn render(request, 'home.html', {'games': games, 'MEDIA_URL': settings.MEDIA_URL})",
"def search_for_books(main_page): # Add information to ... | [
"0.6533811",
"0.6525533",
"0.6519397",
"0.64811003",
"0.6453113",
"0.6427011",
"0.6418048",
"0.64067143",
"0.6396014",
"0.6374171",
"0.6330449",
"0.63195837",
"0.63165426",
"0.63151616",
"0.6295678",
"0.6280252",
"0.62586784",
"0.62574804",
"0.6254213",
"0.62514913",
"0.62486... | 0.8004056 | 0 |
Displays the details about a single computer owned by the company. | def computer_detail(request, computer_id):
computer = get_object_or_404(Computer, pk=computer_id)
current_assignment = EmployeeComputer.objects.filter(computer_id=computer_id).filter(date_revoked=None)
assignment_history = EmployeeComputer.objects.filter(computer_id=computer_id).exclude(date_revoked=None).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description(self):\n return 'computer'",
"def computers(request):\n\n computers = Computer.objects.all().order_by(\"make\", \"model\")\n context = {\n \"computers\": computers\n }\n return render(request, 'agileHR/computers.html', context)",
"def computer_name(self) -> str:\n ... | [
"0.62624913",
"0.5999128",
"0.5842863",
"0.57410765",
"0.5672899",
"0.56446904",
"0.56317085",
"0.5596943",
"0.5563353",
"0.55473655",
"0.5522891",
"0.55059206",
"0.547992",
"0.54577863",
"0.541162",
"0.53678155",
"0.5332331",
"0.5331928",
"0.5323322",
"0.52985793",
"0.529587... | 0.6635081 | 0 |
Deletes a computer ONLY if it has NEVER been assigned to an employee. | def delete_computer(request, computer_id):
if request.method == "POST":
computer = Computer.objects.get(pk=computer_id)
computer.delete()
return HttpResponseRedirect(reverse("agileHR:computers"))
else:
computer = Computer.objects.get(pk=computer_id)
assignments = Employ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_co_worker(self, employee):\n self.co_worker_list.remove(employee)",
"def delete_machine(args):\n session = Session()\n # the following is used to help with code completion\n \"\"\"session.query(PoolMachine).filter(PoolMachine.hostname==args.hostname).delete()\n session.commit()\"\"\"\n... | [
"0.5744213",
"0.56434953",
"0.5477502",
"0.5122596",
"0.5101459",
"0.50881106",
"0.5044403",
"0.502228",
"0.501728",
"0.500022",
"0.49681902",
"0.49646664",
"0.493525",
"0.4907587",
"0.489429",
"0.48942274",
"0.4852634",
"0.48438546",
"0.48341876",
"0.48213306",
"0.4804352",
... | 0.67493343 | 0 |
Assigns a random amount of lives for each new target that is created. Lives can increase as the score increases | def generate_lives(self, score, shooter):
self.lives = random.randint(1, (score.score * shooter.damage // 4 + 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_target(self):\n\n # I used a random number variable (rand_target) in order to randomize the target created each time this function\n # is called.\n stand = StandardTarget()\n strong = StrongTarget()\n safe = SafeTarget()\n bird = Bird()\n\n rand_target = ... | [
"0.62358",
"0.60951334",
"0.5810027",
"0.56423146",
"0.562529",
"0.5622455",
"0.5576731",
"0.5566029",
"0.55580276",
"0.55335104",
"0.55330426",
"0.55187297",
"0.5494676",
"0.54944474",
"0.54737073",
"0.5470941",
"0.54631233",
"0.5460893",
"0.5458668",
"0.5449712",
"0.5438155... | 0.6909246 | 0 |
Computes Random Walk Controversy Polarization | def random_walk_pol(G, ms, n_influencers, n_sim, n_walks):
left_nodes = [node for node in ms if ms[node] == 0]
right_nodes = [node for node in ms if ms[node] == 1]
left_influencers, right_influencers = get_influencer_nodes(G, left_nodes, right_nodes, n_influencers)
rwc_dist = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_walk(n, p):\n random_array = np.random.uniform(0, 1, n)\n left = random_array[random_array > p].size\n right = n - left\n \n return (right-left)",
"def random_walk(n):\n x,y = 0,0\n for i in range(n):\n (dx,dy) = random.choice([(0,1),(1,0),(0,-1),(-1,0)])\n x += dx\n... | [
"0.64451915",
"0.64212126",
"0.61803705",
"0.6049008",
"0.60178906",
"0.60031974",
"0.59854954",
"0.5984448",
"0.5982466",
"0.58951014",
"0.58724207",
"0.5848034",
"0.58389634",
"0.5827656",
"0.5765312",
"0.5725907",
"0.56847906",
"0.56816673",
"0.5660458",
"0.56476724",
"0.5... | 0.6636564 | 0 |
Return a pyll graph with hyperparameters that will construct a sklearn.ensemble.AdaBoostClassifier model. | def ada_boost_classifier(name: str, algorithm: typing.Union[str, Apply] = None, **kwargs):
def _name(msg):
return f"{name}.ada_boost_{msg}"
hp_space = _weight_boosting_hp_space(_name, **kwargs)
hp_space["algorithm"] = _weight_boosting_algorithm(_name("algorithm")) if algorithm is None else algorit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modelAdaBoost():\n num_estimators = [1,5,10,50,100,150]\n learning_rate = 0.1\n max_depth = 3\n base_estimate = DecisionTreeClassifier(max_depth=max_depth)\n random_state = 20 # Do not change this random_state\n \n obj_boost = []\n \n \"\"\" \n Create a list of objects for the cla... | [
"0.69063085",
"0.596918",
"0.5892502",
"0.58808553",
"0.5843065",
"0.58327013",
"0.5793288",
"0.57409567",
"0.56476426",
"0.5644033",
"0.5619147",
"0.5616801",
"0.5600891",
"0.55941826",
"0.5588114",
"0.5583402",
"0.5579925",
"0.55448747",
"0.5507633",
"0.5495947",
"0.5482757... | 0.61925894 | 1 |
Get the day of the week (Monday, Tuesday, Wednesday, etc) | def day_of_week():
return calendar.day_name[datetime.date.today().weekday()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_of_week(self) -> str:\n return self.elements[4]",
"def get_day_of_week() -> str:\n return datetime.now(pytz.timezone('US/Eastern')).strftime(\"%a\").lower()",
"def day_of_week(self) -> str:\n return pulumi.get(self, \"day_of_week\")",
"def day_of_week(self) -> str:\n return pu... | [
"0.8247234",
"0.8183238",
"0.8182204",
"0.8182204",
"0.8168941",
"0.8079663",
"0.806551",
"0.806551",
"0.80587745",
"0.78576976",
"0.7838403",
"0.77996874",
"0.77952296",
"0.7770408",
"0.7761057",
"0.7761057",
"0.77507246",
"0.7699813",
"0.7677836",
"0.76695144",
"0.76283634"... | 0.88490623 | 0 |
Get the day of the month (1, 2, 3, 4, 5, etc) | def day_of_month():
return datetime.date.today().day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_day_of_month(date):\n return date.day",
"def day_of_month(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"day_of_month\")",
"def day_of_month(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"day_of_month\")",
"def date_day(date):\n return date_day_of_month(date)",
... | [
"0.8311167",
"0.81161326",
"0.81161326",
"0.80362916",
"0.7710154",
"0.74247456",
"0.7126231",
"0.70446944",
"0.70041364",
"0.6935808",
"0.6885859",
"0.6820927",
"0.68159795",
"0.67683005",
"0.6750017",
"0.67277735",
"0.6714676",
"0.6682958",
"0.66780627",
"0.66780627",
"0.66... | 0.85066766 | 0 |
Return a song based on the day of the week | def get_weekday_song():
current_day = day_of_week()
print(f"WEEKDAY:{current_day}")
if (current_day == "Monday"):
return random.choice([ \
"Monday - Imagine Dragons", \
"Monday Morning - Quinn XCII", \
"Monday Mornin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_week_day(self, wday):\r\n\t\twdays = ['Domingo', 'Lunes', 'Martes', 'Miercoles',\r\n\t\t\t\t 'Jueves', 'Viernes', 'Sabado']\r\n\t\tfor i in range(7):\r\n\t\t\tif wday == i: \r\n\t\t\t\treturn wdays[i]",
"def get_schedule(self, day, week):\n return self.schedule['schedule'][day][week]",
"def day_... | [
"0.66413635",
"0.64186805",
"0.63379294",
"0.6306051",
"0.62266356",
"0.6226067",
"0.6144873",
"0.61414444",
"0.6112487",
"0.605221",
"0.60010046",
"0.5916634",
"0.5883549",
"0.5879353",
"0.5878558",
"0.58230346",
"0.57595557",
"0.5712286",
"0.56974393",
"0.5672608",
"0.56671... | 0.72779745 | 0 |
Return a song based on the day of the month | def get_monthday_song():
current_day = day_of_month()
print(f"MONTHDAY:{current_day}")
if (current_day == 1):
return random.choice([ \
"One of Us", \
"One - Harry Nilsson", \
"One More Night ", \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_of_month():\n return datetime.date.today().day",
"def test_date_by_yr_mo_day_wholemonth_and_suffix(self):\n spi_search = \"find date 1976-04-01 and t dog\"\n inv_search = 'year:1976-04 and title:dog'\n self._compare_searches(inv_search, spi_search)",
"def get_weekday... | [
"0.5975182",
"0.57491094",
"0.56695724",
"0.5635316",
"0.5606536",
"0.5602042",
"0.558604",
"0.557349",
"0.5563977",
"0.5557702",
"0.55482537",
"0.553907",
"0.5537243",
"0.55025655",
"0.5427321",
"0.54185236",
"0.54171646",
"0.54015607",
"0.53624105",
"0.53299695",
"0.5278434... | 0.7177243 | 0 |
Returns the xpath associated with the element tag as described in the elements file. | def get_element_xpath(self, element_tag):
try:
return self.__ui_data[element_tag]
except KeyError:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_element_locator(self):\n return self._find_by_locator().locator",
"def get_element(self, xpath):\n self.check_for_root()\n if xpath[:2] is not '//':\n # Add the // to the front of the string if it isn't there\n return [element for element in self.tree.xpath('{}/... | [
"0.6427682",
"0.6061646",
"0.5979559",
"0.5928333",
"0.5915957",
"0.5844216",
"0.5687552",
"0.5687552",
"0.56828606",
"0.56325024",
"0.5564216",
"0.55452305",
"0.5530095",
"0.5529969",
"0.55159473",
"0.55143285",
"0.5499186",
"0.5471709",
"0.54565793",
"0.5443705",
"0.541825"... | 0.67972606 | 0 |
Creating a log transformed target matrix. | def _create_target_matrix(A, tranmat):
A = A.dot(tranmat)
# TODO: add lambda parameter to math.log
scores = np.log(A.data) - math.log(A.shape[0])
A.data[scores >= 0] = 0.
A.eliminate_zeros()
return A | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self: Float[LinearOperator, \"*batch M N\"]) -> Float[LinearOperator, \"*batch M N\"]:\n return self.__class__(self._diag.log())",
"def __convert_to_log(self):\n for i in range(self.nStates):\n if self.pi[i]>0:\n self.pi[i]=log(self.pi[i])\n else:\n ... | [
"0.6375063",
"0.6364748",
"0.60665005",
"0.60589683",
"0.6024316",
"0.59903306",
"0.592674",
"0.5909036",
"0.5879884",
"0.58597875",
"0.5793226",
"0.57410306",
"0.5740621",
"0.5688141",
"0.5677478",
"0.5677007",
"0.5659471",
"0.5632872",
"0.562108",
"0.56155103",
"0.55416805"... | 0.73841774 | 0 |
Returns ``True`` if the proband is a reported male, ``False`` if reported female, and ``None`` if no sex is defined. | def is_male(self):
if self._is_female is None:
return None
return self._is_female is False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_female(self):\n\n if self._is_female is None:\n return None\n\n return self._is_female is True",
"def is_female_gender(gender: Union[Gender, CommonGender, int]) -> bool:\n if gender is None:\n return False\n return int(gender) == int(Gender.FEMALE)",
"de... | [
"0.7406541",
"0.6689995",
"0.66545075",
"0.6604037",
"0.6538624",
"0.63535047",
"0.62776583",
"0.6140091",
"0.60818195",
"0.60818195",
"0.60526204",
"0.598491",
"0.59749717",
"0.59157175",
"0.59126544",
"0.59126544",
"0.5818972",
"0.57935834",
"0.57357544",
"0.5674575",
"0.56... | 0.76010215 | 0 |
Returns ``True`` if the proband is a reported female, ``False`` if reported male, and ``None`` if no sex is defined. | def is_female(self):
if self._is_female is None:
return None
return self._is_female is True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_male(self):\n\n if self._is_female is None:\n return None\n\n return self._is_female is False",
"def is_female(sim_info: SimInfo) -> bool:\n return CommonGenderUtils.is_female_gender(CommonGenderUtils.get_gender(sim_info))",
"def is_female_gender(gender: Union[Gender, Com... | [
"0.72025895",
"0.70655465",
"0.7045585",
"0.6230416",
"0.6137822",
"0.61242425",
"0.60456795",
"0.6009963",
"0.59918064",
"0.59918064",
"0.5882768",
"0.58422476",
"0.58285475",
"0.5817581",
"0.58055806",
"0.5804832",
"0.5746617",
"0.5746617",
"0.57369816",
"0.57336664",
"0.56... | 0.78145677 | 0 |
Read a PLINK .fam file and return a pedigree object. Examples >>> ped = hl.Pedigree.read('data/test.fam') Notes | def read(cls, fam_path, delimiter='\\s+') -> 'Pedigree':
trios = []
missing_sex_count = 0
missing_sex_values = set()
with Env.fs().open(fam_path) as file:
for line in file:
split_line = re.split(delimiter, line.strip())
num_fields = len(split_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(klass, f):\n members = []\n for line in f:\n line = line.strip()\n if not line:\n continue # skip empty lines\n members.append(PedigreeMember.parse_line(line))\n return Pedigree(members)",
"def parse(klass, f):\n members = []\... | [
"0.61609685",
"0.61609685",
"0.61526024",
"0.6068482",
"0.5742182",
"0.56351286",
"0.56070286",
"0.54263204",
"0.54250044",
"0.541498",
"0.53941107",
"0.5362101",
"0.53111976",
"0.5297576",
"0.5234441",
"0.52220476",
"0.52161014",
"0.5209632",
"0.5200081",
"0.518931",
"0.5182... | 0.68046296 | 0 |
List of trio objects in this pedigree. | def trios(self):
return self._trios | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def samples(self):\n samples = set()\n for trio in self.trios:\n if trio.child is None or trio.mother is None or trio.father is None:\n continue\n samples.add(trio.father)\n samples.add(trio.mother)\n samples.add(trio.child)\n return l... | [
"0.6735502",
"0.6648545",
"0.6611865",
"0.6585326",
"0.6218765",
"0.61787325",
"0.6174128",
"0.6173725",
"0.6133093",
"0.6071013",
"0.60465074",
"0.6045711",
"0.60023105",
"0.59655607",
"0.59582776",
"0.59162223",
"0.59141374",
"0.58219033",
"0.5811836",
"0.57785505",
"0.5767... | 0.7676709 | 0 |
Filter the pedigree to a given list of sample IDs. Notes | def filter_to(self, samples):
sample_set = set(samples)
filtered_trios = []
for trio in self._trios:
restricted_trio = trio._restrict_to(sample_set)
if restricted_trio is not None:
filtered_trios.append(restricted_trio)
return Pedigree(filtered_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filtered_pedigree_with_samples(self):\n # TODO: unit test me\n return [x for x in self.pedigree if x[\"has_gt_entries\"]]",
"def test_filter_samples_from_otu_table_sample_ids_dense(self):\r\n otu_table = parse_biom_table_str(dense_otu_table1)\r\n\r\n # keep two samples\r\n ... | [
"0.659389",
"0.6361002",
"0.6256912",
"0.6020373",
"0.60049963",
"0.6004205",
"0.59966123",
"0.5976863",
"0.5926716",
"0.58929926",
"0.5659209",
"0.5645515",
"0.55612063",
"0.5554483",
"0.5511055",
"0.54451704",
"0.5436258",
"0.5402296",
"0.53726274",
"0.535017",
"0.5344617",... | 0.66476685 | 0 |
Write a .fam file to the given path. Examples >>> ped = hl.Pedigree.read('data/test.fam') >>> ped.write('output/out.fam') Notes | def write(self, path):
lines = [t._to_fam_file_line() for t in self._trios]
with Env.fs().open(path, mode="w") as file:
for line in lines:
file.write(line + "\n") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, fname):\n pass",
"def write_tree_to_file(self, output_file_name):\n with open(output_file_name, \"w\") as output:\n tree_string = self.decisionTree.get_tree_string(self.decisionTree.root)\n output.write(tree_string[:len(tree_string) - 1])",
"def write_flo_fil... | [
"0.59857523",
"0.5832496",
"0.5771363",
"0.5758511",
"0.5664059",
"0.56320995",
"0.5585951",
"0.5580624",
"0.55791306",
"0.55761415",
"0.5549038",
"0.55375755",
"0.5501043",
"0.54699826",
"0.5469006",
"0.54428756",
"0.5435358",
"0.54327416",
"0.54309034",
"0.5425128",
"0.5409... | 0.6600989 | 0 |
grab_dates parses through the data log and returns a pandas data frame containing all of the data for the days within start_date to stop_date. | def grab_dates(self, start_date, stop_date):
if isinstance(start_date, datetime.datetime):
start_date = start_date.date()
if isinstance(stop_date, datetime.datetime):
stop_date = stop_date.date()
if not self.quiet:
print(f'Grabbing data for dates '
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dates(file,start,end):\r\n \r\n data = format_data(file)\r\n data = data.loc[start:end,:] \r\n dates = list(data.index)\r\n \r\n return dates",
"def get_cut_day_dataframe(start, end):\n entries = get_dataframe(start, end)\n data = entries.copy()\n data['datetime'] = data['to'].... | [
"0.5937762",
"0.5829548",
"0.58009493",
"0.5795244",
"0.575669",
"0.5756663",
"0.56216335",
"0.56131834",
"0.55979854",
"0.5578273",
"0.554233",
"0.55039835",
"0.54955375",
"0.54815054",
"0.5473767",
"0.5472899",
"0.5451333",
"0.54324186",
"0.5430546",
"0.5420038",
"0.540932"... | 0.8097546 | 0 |
refresh_data parses through the data log returning a pandas data frame which contains all of the data from start_datetime.date() through the present moment. The Loader class keeps track of which data has previously been loaded by saving previously loaded data in self.data and keeping track of how many lines of data hav... | def refresh_data(self, start_datetime):
start_date = start_datetime.date()
stop_datetime = datetime.datetime.now()
stop_date = stop_datetime.date()
if not self.quiet:
print(f'Refreshing data from '
f'{start_datetime.strftime(self.datetime_format)} through '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self):\n self.data = pd.read_pickle(self.DATE_PKL)\n self.data.index.name = DATE_COL\n\n for hname, h in self.handlers.items():\n print(\"Loading %s\" % hname)\n cur_out = '../'+h.out_path\n df = pd.read_pickle(cur_out).resample('D').ffill() # make da... | [
"0.6342159",
"0.60637885",
"0.5984677",
"0.5964448",
"0.5834086",
"0.5562486",
"0.55576605",
"0.54735065",
"0.5468586",
"0.5460081",
"0.5438057",
"0.53949714",
"0.537182",
"0.534681",
"0.5342294",
"0.5324912",
"0.52919924",
"0.5274832",
"0.52563834",
"0.52485645",
"0.5244914"... | 0.8001262 | 0 |
Log the path, headers and body of the HTTP request on a key value store db, key is heroku request id. | def log_request(self, key, path, headers, body):
if not body:
body = {}
# Build a dict with key, headers and body.
now = datetime.datetime.now().isoformat()
data = {'request_id': key, 'body': body, 'path': path, 'created': now}
for k, v in headers.items():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self):\n\n\t\theader_dict = dict(request.headers)\n\n\t\ttry:\n\t\t\ttracker_id = header_dict[\"tracker_id\"]\n\t\texcept Exception:\n\t\t\ttracker_id = None\n\t\t\n\t\ttry:\n\t\t\tuser_agent = header_dict[\"User-Agent\"]\n\t\texcept Exception:\n\t\t\tuser_agent = None\n\n\t\ttry:\n\t\t\tlanguage = header_... | [
"0.6207996",
"0.608821",
"0.60648984",
"0.59222084",
"0.5876785",
"0.57388335",
"0.5582543",
"0.5472554",
"0.5428918",
"0.53771406",
"0.5333785",
"0.53263205",
"0.5316794",
"0.5309617",
"0.5303252",
"0.5271772",
"0.52717364",
"0.52658504",
"0.5257094",
"0.5221705",
"0.5198366... | 0.7369401 | 0 |
Searches for content items who use content items which are deprecated. | def find_items_using_deprecated_items(self, file_paths: List[str]) -> List[dict]:
with self.driver.session() as session:
return session.execute_read(get_items_using_deprecated, file_paths) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initIsDeprecated(self):\n self._isDeprecated = re.search(\"deprecated\", self._description, re.IGNORECASE) is not None",
"def contains_deprecated(self, value):\n n = self._find(value)\n return n.value == value",
"def find_deprecated_usages(\n schema: GraphQLSchema, ast: DocumentNod... | [
"0.5903279",
"0.5874698",
"0.5692535",
"0.54962724",
"0.5471929",
"0.54580015",
"0.5436169",
"0.52949667",
"0.51453805",
"0.5107867",
"0.5092518",
"0.5052375",
"0.49769858",
"0.49340463",
"0.49053013",
"0.4902324",
"0.48772797",
"0.4874188",
"0.48646548",
"0.48631492",
"0.485... | 0.58797324 | 1 |
Searches and retrieves core packs who depends on content items who are not core packs. | def find_core_packs_depend_on_non_core_packs(
self,
pack_ids: List[str],
marketplace: MarketplaceVersions,
core_pack_list: List[str],
) -> List[BaseContent]:
with self.driver.session() as session:
results: Dict[str, Neo4jRelationshipResult] = session.execute_read(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMissingLangPacks(self):\n missing = []\n for langInfo in self._cache.getLanguageInformation():\n #print langInfo.languageCode\n trans_package = \"language-pack-%s\" % langInfo.languageCode\n # we have a langpack installed, see if we have all of them\n ... | [
"0.5844865",
"0.56288564",
"0.5305181",
"0.5145996",
"0.5121106",
"0.5113091",
"0.51018935",
"0.5066267",
"0.5049074",
"0.5015875",
"0.5003654",
"0.49998888",
"0.4996081",
"0.49868163",
"0.49670112",
"0.49517143",
"0.49420753",
"0.49389118",
"0.49273887",
"0.49173078",
"0.491... | 0.7412916 | 0 |
Retrieves all the packs that are dependent on hidden packs | def find_mandatory_hidden_packs_dependencies(
self, pack_ids: List[str]
) -> List[BaseContent]:
with self.driver.session() as session:
results = session.execute_read(validate_hidden_pack_dependencies, pack_ids)
self._add_nodes_to_mapping(result.node_from for result in results... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filtered_pack(self):\n return self.list_pack",
"def filter_packs(self, packs):\n return [\n pack for pack in packs\n if len(pack) < self.model.pack_size_threshold\n ]",
"def repackage_hidden(h):\n if isinstance(h, Variable):\n return h.detach_()\n ... | [
"0.6249858",
"0.57863724",
"0.57501745",
"0.57501745",
"0.57274675",
"0.57187104",
"0.5646709",
"0.5643042",
"0.5603607",
"0.55847675",
"0.5521124",
"0.5513294",
"0.54559505",
"0.5426062",
"0.5404806",
"0.53915006",
"0.53811455",
"0.53811455",
"0.53475803",
"0.53475803",
"0.5... | 0.72173077 | 0 |
Returns a anonymized url. Updates the dictionary inplace if a new ip is encountered | def _anonymize_url(url: str, ip_dict: Dict[str, int]) -> str:
regex_match = re.match(r"(?i)(^https?://)(.*?)([/:].*$)", url)
ip = regex_match.group(2)
try:
num = ip_dict[ip]
except KeyError:
ip_dict[ip] = len(ip_dict.values()) + 1
num = ip_dict[ip]
return f"{regex_match.gro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_anonymized_match(self, request):\n request.url = _anonymize_url(request.url, ip_lookup)\n return _BASE_FIND_MATCH(self, request)",
"def processUrl(self, original_url):\n red = self.dbConnect()\n original_url=str(original_url)\n print(\"ORIGINAL URL: \" + origi... | [
"0.59908295",
"0.567846",
"0.56121016",
"0.5589944",
"0.55587417",
"0.5552212",
"0.5491503",
"0.5426955",
"0.5397124",
"0.53490055",
"0.5345326",
"0.52776814",
"0.5267759",
"0.5266539",
"0.5258101",
"0.5234648",
"0.5226115",
"0.5208223",
"0.5195822",
"0.5194908",
"0.5181018",... | 0.7041803 | 0 |
Returns a file path for API response logs for a given test and test parameters | def _build_response_log_path(
*, test_func: Callable, response_logs_dir: Optional[Union[str, Path]], **kwargs,
) -> Path:
# Convert test arguments and their values to a string, skipping ignored arguments
test_params = "_".join([f"{k}={v}" for k, v in {**kwargs}.items()])
# Remove reserved characters fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pytest_logger_logsdir(self, config):",
"def get_result_path(self):\n return logPath",
"def get_request_output_path(request_id: str) -> str:\n log_path = turbinia_config.toDict().get('OUTPUT_DIR')\n request_output_path = os.path.join(log_path, request_id)\n if not os.path.exists(request_output_pat... | [
"0.6237418",
"0.62098247",
"0.617455",
"0.6104958",
"0.604926",
"0.59575886",
"0.5952942",
"0.5924976",
"0.5898674",
"0.5868801",
"0.5865163",
"0.5826229",
"0.57983434",
"0.5795761",
"0.57857513",
"0.5759325",
"0.57548827",
"0.5749969",
"0.5749912",
"0.5687604",
"0.56830466",... | 0.6887815 | 0 |
Allows responses library to match requests for an ip address to match to an anonymized ip address | def _find_anonymized_match(self, request):
request.url = _anonymize_url(request.url, ip_lookup)
return _BASE_FIND_MATCH(self, request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_api_keys(key, ip):",
"def ip_lookup(ip):\n # Create the required data dictionary for Host/Reputation\n api_data = {\n 'host': ip\n }\n response = http_request(endpoint=HOST_REPUTE_API, data=api_data)\n\n if response.get('errorNo') != 0:\n return_error('API Returned, {}:{}'.... | [
"0.6691815",
"0.6559479",
"0.6526992",
"0.6377633",
"0.63570005",
"0.6183474",
"0.6133214",
"0.60974246",
"0.6085869",
"0.6071973",
"0.6069834",
"0.60657233",
"0.60224444",
"0.6004343",
"0.5992652",
"0.59689736",
"0.5910469",
"0.59050214",
"0.59004307",
"0.5896589",
"0.589265... | 0.69186604 | 0 |
Runs a test function against a Tamr instance and saves the API responses to a file | def _run_online_test(response_log_path: Path, test_function: Callable, **kwargs) -> None:
LOGGER.info(
f"Online test running against Tamr instance. "
f"Creating new file at {response_log_path}. This may take a while ..."
)
os.makedirs(response_log_path.parent, exist_ok=Tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_test_file(data):\n set_get_pairs = determine_set_get_pairs(data['methods'])\n visited_pairs = []\n full_class_name = data['name']\n s = full_class_name.split('::')\n class_name = s.pop()\n with open('tests.txt', 'a') as f:\n f.write('\\n')\n f.write(\"\"\"\nconst libCellML... | [
"0.6305272",
"0.6052397",
"0.60403144",
"0.59742624",
"0.5826436",
"0.581387",
"0.5796609",
"0.57870185",
"0.57866037",
"0.57728595",
"0.572977",
"0.5725987",
"0.57110965",
"0.5703883",
"0.57013094",
"0.5701191",
"0.5692433",
"0.5671706",
"0.566342",
"0.5622021",
"0.5621249",... | 0.68773705 | 0 |
Logs the response from BASE_SEND_REAL | def _send_real_with_log(*args, **kwargs) -> Response:
response = _BASE_SEND_REAL(*args, **kwargs)
# Prevent recursion
with mock.patch("responses._real_send", new=_BASE_SEND_REAL):
_log_response(log_path=response_log_path, response=response, ip_dict=ip_lookup)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __send_response(self, response):\n logger.debug(' >>> %s', binascii.b2a_qp(response[0]))\n self.request.send(struct.pack('!I', len(response)))\n self.request.send(response)",
"def _log_request(self):\n log = self.server.log\n if log:\n if hasattr(log, \"info\"):\n log.info(self.form... | [
"0.6145119",
"0.6136643",
"0.6102331",
"0.59985536",
"0.59892577",
"0.5943033",
"0.5928824",
"0.5917603",
"0.5900816",
"0.5784663",
"0.56915206",
"0.569016",
"0.569016",
"0.569016",
"0.5687963",
"0.56845677",
"0.5675967",
"0.56713235",
"0.5664893",
"0.5653703",
"0.5637768",
... | 0.6820585 | 0 |
Find largest streak of largest element | def problem_a(n, a):
largest = max(a)
i = 0
old_streak_begin = 0
old_streak_end = 0
while i < n:
if a[i] == largest:
streak_begin = i
while i < n and a[i] == largest:
i += 1
streak_end = i - 1
i -= 1 # adjust index ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_streak(tracker_data):\n max_streak = 0\n streak = 0\n streak_start = None\n streak_end = None\n current_start = None\n last_day = None\n for entry in tracker_data:\n entry_day = str_to_date(entry[1])\n next_day = (entry_day - timedelta(days=1))\n if last_day ==... | [
"0.70915633",
"0.64860517",
"0.6438803",
"0.63706475",
"0.63307226",
"0.62690336",
"0.62579376",
"0.6257385",
"0.62402254",
"0.6230928",
"0.6225729",
"0.62250805",
"0.62221646",
"0.62217516",
"0.618703",
"0.6171039",
"0.61514086",
"0.61401564",
"0.6137454",
"0.6114383",
"0.61... | 0.7181839 | 0 |
Takes as input a tuple that represents a color in HSV format, and optionally a scale factor. Return an RGB string that is the converted HSV color, scaled by the given factor. | def scale_color((h, s, v), factor=1.):
if (h < 0.) or (h > 360.):
raise Exception('[scale_color()] Hue value out of range (0, 360): ' + str(h))
if (s < 0.) or (s > 100.):
raise Exception('[scale_color()] Saturation value out of range (0, 100): ' + str(s))
if (v < 0.) or (v > 100.):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def HSVtoRGB(h, s, v):\n\n\tc = v * s\n\th2 = h / 60\n\tx = c * (1 - abs((h2 % 2) - 1))\n\n\tif h2 < 1:\n\t\tr, g, b = c, x, 0\n\telif h2 < 2:\n\t\tr, g, b = x, c, 0\n\telif h2 < 3:\n\t\tr, g, b = 0, c, x\n\telif h2 < 4:\n\t\tr, g, b = 0, x, c\n\telif h2 < 5:\n\t\tr, g, b = x, 0, c\n\telif h2 < 6:\n\t\tr, g, b = c... | [
"0.69030184",
"0.6724031",
"0.6680665",
"0.6618948",
"0.6617808",
"0.6522847",
"0.65206295",
"0.6476674",
"0.6472725",
"0.6439532",
"0.6435905",
"0.64047784",
"0.63969535",
"0.63826805",
"0.63578546",
"0.635008",
"0.6344226",
"0.63373214",
"0.6325231",
"0.6301221",
"0.6261745... | 0.78258586 | 0 |
Sort by the abundance level all the taxonomy that represent at least two levels. Return the first ``xxx`` most abundant. | def get_most_abundant(abundances, xxx):
abundant = []
for a in abundances:
if a.count('|') > 0:
abundant.append((float(abundances[a]), a.replace('|', '.')))
elif a.count('.') > 0:
abundant.append((float(abundances[a]), a))
abundant.sort(reverse=True)
return abun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_most_abundant(self):\r\n ids = \\\r\n \"R27DLI_4812 R27DLI_600 R27DLI_727 U1PLI_403 U1PLI_8969\".split(\r\n )\r\n seqs = dict(parse_fasta(dna_seqs.splitlines(),\r\n label_to_name=label_to_name))\r\n f = make_most_abu... | [
"0.6010901",
"0.53763974",
"0.52897644",
"0.52457494",
"0.52267855",
"0.52150905",
"0.51941186",
"0.51887584",
"0.5123752",
"0.50874877",
"0.50427705",
"0.50427705",
"0.50341606",
"0.50297135",
"0.50240934",
"0.5001931",
"0.49770966",
"0.4957268",
"0.49548873",
"0.4925892",
"... | 0.6979877 | 0 |
Return the value of ``abu`` scaled to ``max_abu`` logarithmically, and then map from ``minn`` to ``maxx``. | def scale_clade_size(minn, maxx, abu, max_abu):
return minn + maxx * log10(1. + 9. * (abu/max_abu)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loglam_minmax(self):\n return np.log10(8000.0), np.log10(25700)",
"def u_max(self):\n if self._u_max is None:\n return self.uv_max\n else:\n return self._u_max",
"def atmax(a,upperlimit,dimension=None,inclusive=1):\r\n if inclusive: upperfcn = N.less\r... | [
"0.60555166",
"0.60316104",
"0.59343225",
"0.58993846",
"0.58850724",
"0.568889",
"0.5688513",
"0.5662755",
"0.5598933",
"0.55914974",
"0.5591325",
"0.557225",
"0.5538817",
"0.5532083",
"0.55306137",
"0.5522167",
"0.5520818",
"0.55112964",
"0.55017966",
"0.5499569",
"0.546979... | 0.66463673 | 0 |
Filter a distribution of logits using topk and/or nucleus (topp) filtering | def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):
if logits.dim() == 2:
logits = torch.stack([top_k_top_p_filtering(p, top_k, top_p) for p in logits])
# print(logits.shape)
return logits
assert logits.dim() == 1 # batch size 1 for now - could be updated... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_filtering(logits, top_k=0, top_p=0.0, threshold=-float('Inf'), filter_value=-float('Inf')):\n assert logits.dim() == 1 # Only work for batch size 1 for now - could update but it would obfuscate a bit the code\n top_k = min(top_k, logits.size(-1))\n if top_k > 0:\n # Remove all tokens with ... | [
"0.7180262",
"0.7068208",
"0.7061862",
"0.700239",
"0.69135123",
"0.68506724",
"0.6112614",
"0.5891321",
"0.58246046",
"0.57338977",
"0.5532266",
"0.54567426",
"0.53620654",
"0.53531677",
"0.5296981",
"0.52720696",
"0.5259605",
"0.5256998",
"0.5241194",
"0.5229437",
"0.516973... | 0.7188894 | 0 |
Negation. >>> M=mat4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) >>> print M [ 1.0000, 2.0000, 3.0000, 4.0000] [ 5.0000, 6.0000, 7.0000, 8.0000] [ 9.0000, 10.0000, 11.0000, 12.0000] [ 13.0000, 14.0000, 15.0000, 16.0000] | def __neg__(self):
return mat4(map(lambda x: -x, self.mlist)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __neg__(self):\n # \n # TODO - your code here\n #\n result = [];\n for row in self.g:\n result.append([-1*n for n in row]);\n \n return Matrix(result);",
"def inverse(self):\r\n \r\n Mi=mat4()\r\n d=self.determinant()\r\n ... | [
"0.6832261",
"0.67651165",
"0.6667079",
"0.664892",
"0.65906334",
"0.6569882",
"0.63613784",
"0.61436284",
"0.58839893",
"0.5871535",
"0.58194584",
"0.57603437",
"0.5759127",
"0.5742525",
"0.57409775",
"0.5714808",
"0.57032365",
"0.57028055",
"0.569835",
"0.56963867",
"0.5685... | 0.7590555 | 0 |
Return a list containing the matrix elements. By default the list is in columnmajor order (which can directly be used in OpenGL or RenderMan). If you set the optional argument rowmajor to 1, you'll get the list in rowmajor order. >>> M=mat4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) >>> print M.toList() [1, 5, 9, 13, 2, 6... | def toList(self, rowmajor=0):
if rowmajor:
return copy.copy(self.mlist)
else:
return self.transpose().mlist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_list(self):\n data = []\n for row in self._matrix_data:\n for column in row:\n data.append(column)\n return data",
"def mat2list(m: np.ndarray) -> List[np.ndarray]:\n return [v for v in m]",
"def as_list_of_lists(self):\n return self._matrix_data"... | [
"0.69468004",
"0.69222885",
"0.6656317",
"0.64434236",
"0.6170803",
"0.61650264",
"0.603177",
"0.58373696",
"0.5763565",
"0.57506144",
"0.5724563",
"0.56793326",
"0.5654223",
"0.5653765",
"0.56409115",
"0.5627797",
"0.56052494",
"0.56023407",
"0.55804235",
"0.55344415",
"0.54... | 0.7618433 | 0 |
Return identity matrix. >>> print mat4().identity() [ 1.0000, 0.0000, 0.0000, 0.0000] [ 0.0000, 1.0000, 0.0000, 0.0000] [ 0.0000, 0.0000, 1.0000, 0.0000] [ 0.0000, 0.0000, 0.0000, 1.0000] | def identity(self):
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identity_matrix():\r\n return numpy.identity(4)",
"def identity_matrix():\n return numpy.identity(4)",
"def IdentityMatrix():\n return RotationMatrix([\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1]\n ])",
"def makeIdentity(m):\n Matrix.validate_dimensions(m, m)\n da... | [
"0.87248576",
"0.8694794",
"0.7907894",
"0.72260714",
"0.71498245",
"0.7136767",
"0.71074843",
"0.71074843",
"0.71074843",
"0.70615125",
"0.69027126",
"0.68542427",
"0.678137",
"0.67580533",
"0.67580533",
"0.668904",
"0.6607793",
"0.6571645",
"0.6571317",
"0.6568231",
"0.6496... | 0.89374554 | 0 |
Transpose matrix. >>> M=mat4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) >>> print M.transpose() [ 1.0000, 5.0000, 9.0000, 13.0000] [ 2.0000, 6.0000, 10.0000, 14.0000] [ 3.0000, 7.0000, 11.0000, 15.0000] [ 4.0000, 8.0000, 12.0000, 16.0000] | def transpose(self):
m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44 = self.mlist
return mat4(m11,m21,m31,m41,
m12,m22,m32,m42,
m13,m23,m33,m43,
m14,m24,m34,m44) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transpose(M):\n rows = len(M)\n cols = len(M[0])\n\n MT = zeros_matrix(cols, rows)\n\n for i in range(rows):\n for j in range(cols):\n MT[j][i] = M[i][j]\n\n return MT",
"def transpose(M):\n # Section 1: if a 1D array, convert to a 2D array = matrix\n if not isinstance(... | [
"0.7771121",
"0.7648841",
"0.76094943",
"0.7479733",
"0.7460929",
"0.74588114",
"0.74090874",
"0.73757505",
"0.73563504",
"0.72935945",
"0.72345984",
"0.7189379",
"0.71887887",
"0.70874745",
"0.7070108",
"0.7052813",
"0.70478565",
"0.7042636",
"0.7033615",
"0.70205855",
"0.70... | 0.8291731 | 0 |
Return inverse matrix. >>> M=mat4(0,2.0,0,0, 2.0,0,0,0, 0,0,2,0, 0,0,0,2) >>> print M.inverse() [ 0.0000, 0.5000, 0.0000, 0.0000] [ 0.5000, 0.0000, 0.0000, 0.0000] [ 0.0000, 0.0000, 0.5000, 0.0000] [ 0.0000, 0.0000, 0.0000, 0.5000] | def inverse(self):
Mi=mat4()
d=self.determinant()
for i in range(4):
for j in range(4):
sign=1-((i+j)%2)*2
m3=self._submat(i,j)
Mi[j,i]=sign*m3.determinant()/d
return Mi | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getInverseMatrix(self) -> CMatrix4:\n ...",
"def inverse(self,mat):\n result = np.linalg.inv(mat)\n self.out = result\n return self.out",
"def inverse(self):\n if not self.is_square():\n raise(ValueError, \"Non-square Matrix does not have an inverse.\")\n ... | [
"0.81339246",
"0.75934964",
"0.7578332",
"0.748669",
"0.741083",
"0.7331316",
"0.7279936",
"0.7167508",
"0.7035069",
"0.7019255",
"0.69645965",
"0.6959112",
"0.6920141",
"0.6919742",
"0.6902522",
"0.6893832",
"0.6853545",
"0.6733695",
"0.6733695",
"0.67301846",
"0.67291325",
... | 0.8095634 | 1 |
equivalent to the OpenGL command glFrustum() | def frustum(self, left, right, bottom, top, near, far):
return mat4( (2.0*near)/(right-left), 0.0, float(right+left)/(right-left), 0.0,
0.0, (2.0*near)/(top-bottom), float(top+bottom)/(top-bottom), 0.0,
0.0, 0.0, -float(far+near)/(far-near), -(2.0*far*near)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fov(self):\n return 2.*pi",
"def screenToCamera(self,x,y):\n #self.x = x\n #self.y = y\n new_x = x / (self.surf.get_width() - 1) - 0.5\n #-(new_x)\n new_y = y / (self.surf.get_height() - 1)\n new_y = (1.0 - cy) - 0.5\n new_z = -self.camNear\n ... | [
"0.598913",
"0.5821637",
"0.564336",
"0.562938",
"0.5614187",
"0.5596554",
"0.5558889",
"0.5558754",
"0.5558079",
"0.5444497",
"0.5442735",
"0.53770024",
"0.53711",
"0.53401995",
"0.53266174",
"0.5271925",
"0.525307",
"0.521437",
"0.5198958",
"0.5172657",
"0.5168535",
"0.51... | 0.68738544 | 0 |
Look from pos to target. The resulting transformation moves the origin to pos and rotates so that The zaxis points to target. The yaxis is as close as possible to the up vector. | def lookAt(self, pos, target, up=_vec3(0,0,1)):
dir = (target - pos).normalize()
up = up.normalize()
up -= (up * dir) * dir
try:
up = up.normalize()
except:
# We're looking along the up direction, so choose
# an arbitrary direction th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head_towards(self):\n dest = self.target_destination - self.location\n if dest.length() != 0:\n dest.scale_to_length(self.speed)\n dest.normalize()\n self.rect.left += dest.x\n self.rect.top += dest.y",
"def point_at(obj, target, roll=0):\n if not isinstan... | [
"0.63867235",
"0.6174689",
"0.6100806",
"0.60780716",
"0.60386586",
"0.6026328",
"0.6026328",
"0.5969622",
"0.5969622",
"0.5930626",
"0.5918353",
"0.582788",
"0.5806989",
"0.5760675",
"0.5746078",
"0.571055",
"0.5699697",
"0.5695556",
"0.55726534",
"0.55695117",
"0.5561427",
... | 0.7076027 | 0 |
Decomposes the matrix into a translation, rotation and scaling part. Returns a tuple (translation, rotation, scaling). The translation and scaling parts are given as vec3's, the rotation is still given as a mat4. | def decompose(self):
dummy = self.ortho()
dummy.setRow(3,_vec4(0.0, 0.0, 0.0, 1.0))
x = dummy.getColumn(0)
y = dummy.getColumn(1)
z = dummy.getColumn(2)
xl = x.length()
yl = y.length()
zl = z.length()
scale = _vec3(xl,yl,zl)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __compose_transformation(self):\n s = self.scale\n rotR = self.rotation\n t = self.translation\n T = np.eye(4)\n T[0:3, 3] = t\n R = np.eye(4)\n R[0:3, 0:3] = rotR\n M = T.dot(R)\n if s == 1:\n M = T.dot(R)\n else:\n S ... | [
"0.65959865",
"0.59985363",
"0.56775165",
"0.56729084",
"0.5643762",
"0.5516922",
"0.5491905",
"0.5479591",
"0.5413127",
"0.5405925",
"0.5361287",
"0.53541017",
"0.535323",
"0.53331834",
"0.53259045",
"0.5305544",
"0.5288668",
"0.52755517",
"0.5258584",
"0.523991",
"0.5236473... | 0.6354126 | 1 |
Convert to mat3 by discarding 4th row and column. | def getMat3(self):
m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44 = self.mlist
return _mat3(m11,m12,m13,
m21,m22,m23,
m31,m32,m33) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_matrix(self):\n return self._matrix[:3, :]",
"def matrix4_to_3x4_array(mat):\r\n return tuple(f for v in mat[0:3] for f in v)",
"def matrix_3d_to_4x4(matrix: np.matrix) -> np.matrix:\n return np.matrix([\n [matrix.item(0, 0), matrix.item(0, 1), matrix.item(0, 2), 0],\n [matri... | [
"0.6594154",
"0.63680017",
"0.63458836",
"0.6305676",
"0.5926818",
"0.5799303",
"0.577558",
"0.57755524",
"0.571899",
"0.56805104",
"0.56732726",
"0.5565543",
"0.5562937",
"0.5538932",
"0.5500829",
"0.5490002",
"0.5460419",
"0.5436018",
"0.541732",
"0.54148245",
"0.54027385",... | 0.6781476 | 0 |
Adds several channels to the NIDAQ Task object. | def add_channels(self, channels):
for i in range(len(channels)):
self.task.ai_channels.add_ai_voltage_chan(channels[i]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Add_Channels(self,AIchans,min_volts=-10.0,max_volts=10.0):\n self.num_channels += len(AIchans.split(','))\n self._CHK(nidaq.DAQmxCreateAIVoltageChan(self.task_handle,AIchans,\"\",\n DAQmx_Val_NRSE,\n float64(min_v... | [
"0.62658584",
"0.60897845",
"0.60323",
"0.5717829",
"0.56967604",
"0.5602049",
"0.55638844",
"0.55111706",
"0.55108154",
"0.54773504",
"0.54725236",
"0.54507923",
"0.5393515",
"0.5389309",
"0.5372433",
"0.5362801",
"0.53244853",
"0.52995205",
"0.52456725",
"0.52298516",
"0.52... | 0.6989536 | 0 |
This is added as a testing helper, not actually as part of the parser tests. Since the same particles will be used for the driver test it is helpful to write them to .yml in the same form they need in the results.yml files here. | def particle_to_yml(self, particle):
particle_dict = particle.generate_dict()
# open write append, if you want to start from scratch manually delete this file
fid = open('particle.yml', 'a')
fid.write(' - _index: 0\n')
fid.write(' internal_timestamp: %f\n' % particle_dict.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def particle_to_yml(self, particles, filename, mode='w'):\n # open write append, if you want to start from scratch manually delete this fid\n fid = open(os.path.join(RESOURCE_PATH, filename), mode)\n\n fid.write('header:\\n')\n fid.write(\" particle_object: 'MULTIPLE'\\n\")\n fid... | [
"0.62344426",
"0.6044037",
"0.5897675",
"0.5842312",
"0.57624775",
"0.5600481",
"0.5595495",
"0.5594393",
"0.558318",
"0.5582441",
"0.5496771",
"0.5492899",
"0.5474142",
"0.54318386",
"0.538441",
"0.5378681",
"0.5369552",
"0.5365752",
"0.5351015",
"0.5343943",
"0.5321152",
... | 0.61015004 | 1 |
Test changing to a new state after initializing the parser and reading data, as if new data has been found and the state has changed | def test_set_state(self):
self.stream_handle = open(os.path.join(RESOURCE_PATH, 'adcpt_20130929_091817.DAT'))
self.parser = AdcpsJlnStcParser(self.config, self.start_state, self.stream_handle,
self.state_callback, self.pub_callback, self.exception_callback)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_state(self):\n pass",
"def test_update_state2(self):\n pass",
"def test_update_state1(self):\n pass",
"def test_update_state4(self):\n pass",
"def test_update_state3(self):\n pass",
"def test_update_file_state(self):\n # blocks [0 4012], based on ... | [
"0.6681974",
"0.6582587",
"0.6535782",
"0.6432503",
"0.64053005",
"0.63845706",
"0.60632944",
"0.5856464",
"0.5801237",
"0.573452",
"0.5718316",
"0.570647",
"0.57061875",
"0.56859386",
"0.5667507",
"0.5644675",
"0.5634167",
"0.5615299",
"0.55790114",
"0.5575045",
"0.5562348",... | 0.67140824 | 0 |
Ensure that bad data is skipped when it exists. | def test_bad_data(self):
# Bad checksum
# If checksum is bad, skip the record and continue parsing.
self.stream_handle = StringIO(AdcpsJlnStcParserUnitTestCase.BAD_CHECKSUM)
self.parser = AdcpsJlnStcParser(self.config, self.start_state, self.stream_handle,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_for_incomplete_input(self):\n pass",
"def test_bad_data(self):\n # bad data file has:\n # 1 bad status\n # particle A has bad timestamp\n # particle B has bad dark fit\n # particle C has bad frame type\n # particle D has bad year\n stream_handle ... | [
"0.6379193",
"0.6308143",
"0.6299434",
"0.6243725",
"0.6231215",
"0.61784744",
"0.61682063",
"0.6074258",
"0.60719675",
"0.60550016",
"0.60518795",
"0.60318846",
"0.6005139",
"0.60004735",
"0.5981865",
"0.5960596",
"0.59356374",
"0.59296703",
"0.5912226",
"0.59095657",
"0.587... | 0.63898325 | 0 |
Initializes the hidden and memory cell with given batch size. | def init_hidden(self, batch_size, use_cuda=False):
# The axes semantics are (num_layers, minibatch_size, hidden_dim)
# The tuple reprensents hidden cell and memory cell.
hidden = [
autograd.Variable(
torch.zeros(self.n_layers, batch_size, self.hidden_dim),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_hidden(self, batch_size):\r\n \r\n self.hidden_state = (\r\n torch.zeros(((1+self.bidirectional)*self.num_layers,\r\n batch_size,\r\n self.hidden_size)).to(self.device),\r\n torch.zeros(((1+self.bidirectional)*self.num_lay... | [
"0.76831126",
"0.7411178",
"0.7411178",
"0.73938495",
"0.73049426",
"0.73020536",
"0.7278598",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7277387",
"0.7267112",
"0.7267112",
"0.7253098",
"0.7253098",
"0.72000086",
"0.6970245"... | 0.7421998 | 1 |
Use this decorator to have another method run for dealing with validation errors. For example, you have a method '/new' which features a form and a method '/create' which actually processes its data (after an POST request). The latter has validators set and thus yields an exception if they fail. By having set for '/new... | def error_handler(call_on_errors):
assert callable(call_on_errors)
def entangle(method):
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
try:
return method(self, *args, **kwargs)
except InputInvalidException:
return call_on_err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkIsValid(f):\n\n @wraps(f)\n def wrapper(self, *args, **kwargs):\n if self.validator.isValid:\n return f(self, *args, **kwargs)\n else:\n error = self.validator._exceptionClass('Called: {} method before data validated'.format(f.__name__))\n self.validato... | [
"0.6306944",
"0.6010284",
"0.58214426",
"0.576826",
"0.5741134",
"0.57147294",
"0.568659",
"0.5656105",
"0.564157",
"0.5631703",
"0.5623964",
"0.5620047",
"0.56194556",
"0.56007147",
"0.55997527",
"0.55741894",
"0.55452645",
"0.5532373",
"0.5474961",
"0.5435076",
"0.5415873",... | 0.6507089 | 0 |
Ensures both operands of a binary operation are safe (int limit). | def _check_binop_operands(self, a, b):
if isinstance(a, int) and (a < self._config.min_int or a > self._config.max_int):
_raise_in_context(NumberTooHigh, "This number is too large")
if isinstance(b, int) and (b < self._config.min_int or b > self._config.max_int):
_raise_in_contex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _binaryop(self, other, op: str):\n raise NotImplementedError",
"def test_bin_op_support():\n check_peval_expression(\"1 + 2\", {}, \"3\", fully_evaluated=True, expected_value=3)\n check_peval_expression(\"2 - 1\", {}, \"1\", fully_evaluated=True, expected_value=1)\n check_peval_expression(\"2 * 3... | [
"0.63735",
"0.6305239",
"0.6293286",
"0.6292594",
"0.6202902",
"0.61657506",
"0.6111996",
"0.60946226",
"0.60724956",
"0.6068034",
"0.60609406",
"0.6032665",
"0.6018244",
"0.5949832",
"0.59092194",
"0.58977455",
"0.58256775",
"0.5801949",
"0.5790173",
"0.5778309",
"0.57403183... | 0.7187781 | 0 |
Like zip(a, b), but zips the element at ``a[star_index]`` with a list of 0..len(b) elements such that every other element of ``a`` maps to exactly one element of ``b``. >>> zip_star(['a', 'b', 'c'], [1, 2, 3, 4], star_index=1) like a, b, c = [1, 2, 3, 4] [('a', 1), ('b', [2, 3]), ('c', 4)] >>> zip_star(['a', 'b', 'c'],... | def zip_star(a: Sequence, b: Sequence, star_index: int):
if not 0 <= star_index < len(a):
raise IndexError("'star_index' must be a valid index of 'a'")
if not len(b) >= len(a) - 1:
raise ValueError("'b' must be no more than 1 shorter than 'a'")
length_difference = len(b) - (len(a) - 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longzip(a, b):\n aiter = iter(a)\n biter = iter(b)\n try:\n for item1 in aiter:\n yield item1, next(biter)\n except StopIteration:\n for item1 in aiter:\n yield item1, None\n else:\n for item2 in biter:\n yield None, item2",
"def zipper(lis... | [
"0.49714458",
"0.4755166",
"0.46647733",
"0.4656372",
"0.4642045",
"0.4552972",
"0.44579065",
"0.4431346",
"0.4427235",
"0.44107243",
"0.4404392",
"0.43820265",
"0.43638325",
"0.42930743",
"0.42877764",
"0.42748657",
"0.4237909",
"0.4236996",
"0.42363018",
"0.4232134",
"0.422... | 0.81742585 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.