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 |
|---|---|---|---|---|---|---|
Equivalent to theano.tensor.addbroadcast. For NumPy objects, checks that broadcasted dimensions have length 1, but otherwise does nothing. | def addbroadcast(x, *axes):
if is_theano_object(x):
# T.addbroadcast only works with positive axes
axes = [ ax if ax >= 0 else x.ndim + ax for ax in axes ]
return T.addbroadcast(x, *axes)
else:
for ax in axes:
if x.shape[ax] != 1:
raise ValueError("Tri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_broadcast_dims():\r\n test((1, 2, 3))\r\n test((2, 1, 3))\r\n test((2, 3, 1))\r\n test2((1, 2, 3))\r\n test2((2, 1, 3))\r\n test2((2, 3, 1))",
"def test_unbroadcast_addbroadcast(self):\r\n\r\n x = matrix()\r\n assert unbroadcast(x, 0) is x\r\n assert unbroadcast(x,... | [
"0.71459633",
"0.6914185",
"0.68297416",
"0.66783226",
"0.654165",
"0.6527929",
"0.651774",
"0.6381184",
"0.6363589",
"0.6338809",
"0.6334122",
"0.63105303",
"0.63056207",
"0.62698644",
"0.6191693",
"0.6153234",
"0.6143489",
"0.6117331",
"0.6100611",
"0.6088057",
"0.6025157",... | 0.7421298 | 0 |
Call this function on any expression that might appear in a Theano graph as a boolean (Theano expects integers rather than booleans.) | def bool(a):
# Booleans need to be converted to integers for Theano
if cf.use_theano and isinstance(a, (builtins.bool, np.bool_)):
return np.int8(a)
elif cf.use_theano or is_theano_object(a):
return a
else:
return builtins.bool(a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluateBoolean(compiled_expression):",
"def boolean_func(experiment):",
"def on_true(self) -> global___Expression:",
"def _op(\n x: Union[bool, dts.Boolean, tps.BooleanValue],\n y: Union[bool, dts.Boolean, tps.BooleanValue],\n ) -> T:",
"def __nonzero__(self):\n raise RuntimeEr... | [
"0.66782403",
"0.66504705",
"0.6595281",
"0.64725804",
"0.6440128",
"0.6385642",
"0.63522696",
"0.6339515",
"0.6285484",
"0.62269044",
"0.6185963",
"0.6184478",
"0.6112703",
"0.6025595",
"0.5911982",
"0.590077",
"0.58995366",
"0.5801486",
"0.57946014",
"0.57801527",
"0.570051... | 0.6897003 | 0 |
All parameters except `outshape` are the same as for theano.ifelse.ifelse `outshape` is an extra parameter to allow the then_branch and else_branch | def ifelse(condition, then_branch, else_branch, name=None, outshape=None):
# First check if we can replace an Theano conditional by a Python one
if is_theano_object(condition) and is_constant(condition):
condition = bool(condition.data)
# Now the actual function
if (cf.use_theano
and no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch(condition, then_expression, else_expression):\n x_shape = copy.copy(then_expression.get_shape())\n x = tf.cond(tf.cast(condition, 'bool'),\n lambda: then_expression,\n lambda: else_expression)\n x.set_shape(x_shape)\n return x",
"def ifelse(condition, then_bra... | [
"0.5731582",
"0.5591258",
"0.555741",
"0.5469535",
"0.5441478",
"0.53432226",
"0.5295958",
"0.52848524",
"0.5284638",
"0.5276015",
"0.5276015",
"0.5276015",
"0.5193365",
"0.51561433",
"0.51561433",
"0.5092851",
"0.5084068",
"0.5084068",
"0.5070655",
"0.5028776",
"0.49839672",... | 0.6365673 | 0 |
Returns the default broadcastable pattern for a shape, replacing 1s with `True`. | def shape_to_broadcast(shape):
return tuple(n==1 for n in shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mask(shape):\n return np.zeros(shape).astype(bool)",
"def broadcastable(self):\n return tuple(s==1 for s in self.shape)",
"def generate_default_mask(data, dim1=None):\n batch_size = data.size(1)\n sequence_len = data.size(0)\n if dim1 is None:\n dim1 = sequence_len\n ret... | [
"0.6918157",
"0.6437492",
"0.6300757",
"0.6217095",
"0.6205907",
"0.6100955",
"0.6060882",
"0.59409136",
"0.59366935",
"0.5933645",
"0.5914848",
"0.59019846",
"0.58798945",
"0.5850175",
"0.58367413",
"0.5828354",
"0.5715668",
"0.56040365",
"0.5578355",
"0.5577387",
"0.5566503... | 0.7036175 | 0 |
Make an object into a tensor. If `object` is a numpy array, a new tensor matching its shape and dtype is returned. The array values are used to set the test value. | def tensor(object, name=None, dtype=None):
# Try to infer the tensor shape, test_value, dtype and broadcast pattern
broadcastable = None
shape = None
if isinstance(object, np.ndarray):
# Numpy arrays become the symbolic's test value
shape = object.shape
test_value = object
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj2tensor(pyobj, device='cuda'):\n storage = torch.ByteStorage.from_buffer(pickle.dumps(pyobj))\n return torch.ByteTensor(storage).to(device=device)",
"def istorch(*obj):\n\n return istype(torch.Tensor, *obj)",
"def to_scalar(obj):\n if isinstance(obj, np.generic):\n return obj.item()\n... | [
"0.64124453",
"0.611078",
"0.6001016",
"0.59482175",
"0.5769962",
"0.57507235",
"0.56285244",
"0.5619557",
"0.55715656",
"0.55606765",
"0.5538848",
"0.5523602",
"0.548882",
"0.54432493",
"0.54424465",
"0.5397815",
"0.5368648",
"0.5290406",
"0.5290406",
"0.5290406",
"0.5289074... | 0.7057965 | 0 |
If `allow_resize` is false (default), will raise an error if new_value has a different shape than the stored variable. | def set_value(self, new_value, borrow=False):
new_value = np.array(new_value, copy = not borrow)
try:
if self.shape != new_value.shape:
self.resize(new_value.shape, refcheck=False)
# refcheck is necessary to get this to work, but bypasses
# the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize(self, old, new):",
"def _fix_shape(self, value):\n for k, v in self.variables.items():\n if len(v.shape) < len(value.shape):\n a, b = self._broadcast(value, v)\n self.variables[k] = np.zeros(a.shape, dtype=b.dtype) + b",
"def cell(self, value):\n if... | [
"0.6160011",
"0.5616089",
"0.5501954",
"0.53800654",
"0.53766894",
"0.5319863",
"0.5319749",
"0.53089726",
"0.53088486",
"0.52785385",
"0.5275074",
"0.52321464",
"0.5216825",
"0.51956314",
"0.519471",
"0.5184352",
"0.51834565",
"0.5168249",
"0.51639163",
"0.5145052",
"0.51329... | 0.6490318 | 0 |
In contrast to Theano's `shared()`, the broadcast pattern is set to be compatible with NumPy's behaviour; i.e., any axis in `value` with dimension 1 is considered broadcastable by default. As with Theano's `shared()`, broadcast pattern can by changed by passing | def shared(value, name=None, strict=False, allow_downcast=None, symbolic=True,
**kwargs):
if not isinstance(value, np.ndarray):
value = np.asarray(value)
if 'dtype' in kwargs:
logger.warning("You passed the keyword 'dtype' to the shared constructor. "
"Theano do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sharedX(value, name=None, borrow=False):\n return theano.shared(theano._asarray(value, dtype=theano.config.floatX),\n name=name,\n borrow=borrow)",
"def sharedX_value(value, name=None, borrow=None, dtype=None):\n if dtype is None:\n dtype = theano.... | [
"0.6955052",
"0.68128425",
"0.6489515",
"0.6380227",
"0.6346469",
"0.62513626",
"0.60865706",
"0.6063434",
"0.5991516",
"0.5971064",
"0.5877886",
"0.58261615",
"0.5815576",
"0.58030784",
"0.57885367",
"0.577562",
"0.5775391",
"0.5771261",
"0.5756086",
"0.57556057",
"0.5688109... | 0.6865 | 1 |
In contrast to `numpy.atleast_1d`, will not cast lists or tuples to arrays. This is to allow lists of symbolic variables. | def atleast_1d(*arrays):
if len(arrays) == 1:
a = arrays[0]
if isscalar(a):
a = add_axes(a, 1)
return a
else:
assert len(arrays) > 1
return [atleast_1d(a) for a in arrays] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atleast_1d(*arys):\n res = []\n for a in arys:\n if not isinstance(a, cupy.ndarray):\n raise TypeError('Only cupy arrays can be atleast_1d')\n if a.ndim == 0:\n a = a.reshape(1)\n res.append(a)\n if len(res) == 1:\n res = res[0]\n return res",
"de... | [
"0.7054152",
"0.66508734",
"0.64807516",
"0.6265879",
"0.62099147",
"0.614839",
"0.61127764",
"0.60296506",
"0.59864676",
"0.59615374",
"0.5930761",
"0.59285194",
"0.59205323",
"0.59188753",
"0.5905526",
"0.5883461",
"0.5868971",
"0.5861243",
"0.5836253",
"0.5815137",
"0.5810... | 0.7249189 | 0 |
Add an axis to `x`, e.g. to treat a scalar as a 1x1 matrix. String arguments for `pos` should cover most typical use cases; for more complex operations, like adding axes to the middle, specify the insertion position for the axes directly. | def add_axes(x, num=1, pos='left'):
if is_theano_object(x):
if pos in ['left', 'before', 'begin', 'first']:
shuffle_pattern = ['x']*num
shuffle_pattern.extend(range(x.ndim))
elif pos in ['right', 'after', 'end', 'last']:
shuffle_pattern = list(range(x.ndim))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_x(self, *args, **kwargs) -> Any:\n pass",
"def set_pos(self, x):\n self._pos = x",
"def set_new_pos_in_x(self, new_pos):\n self.__pos_x = new_pos",
"def format_x_axis(self, text=None, positionx=None, positiony=None, color=None, fontsize=None):\n if text is not None:\n ... | [
"0.5671687",
"0.56453615",
"0.5537362",
"0.5427651",
"0.53706735",
"0.53447604",
"0.5194955",
"0.5190737",
"0.5185418",
"0.512035",
"0.5075469",
"0.5074113",
"0.50620127",
"0.50525665",
"0.50525665",
"0.5034201",
"0.50065833",
"0.4998663",
"0.49879915",
"0.49418423",
"0.49294... | 0.6144922 | 0 |
All parameters except `array_shape` are the same as for np.pad. `array_shape` is necessary because while we can deal with a Theano array, we need to know its shape. | def pad(array, array_shape, pad_width, mode='constant', **kwargs):
if mode not in ['constant']:
raise ValueError("theano_shim does not support mode '{}'".format(mode))
if not is_theano_object(array):
assert(array.shape == array_shape)
# If this fails, than the Theano code will also f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(arr, target_shape, constant_values=0):\n arr_shape = arr.shape\n npad = ()\n for dim in range(len(arr_shape)):\n diff = target_shape[dim] - arr_shape[dim]\n if diff > 0:\n before = int(diff / 2)\n after = diff - before\n else:\n before = 0\n ... | [
"0.72683674",
"0.69279623",
"0.6815563",
"0.6631931",
"0.6603894",
"0.6579442",
"0.65710515",
"0.6466191",
"0.646429",
"0.6456382",
"0.63967574",
"0.6391941",
"0.630208",
"0.6301449",
"0.62548065",
"0.6236044",
"0.6222941",
"0.61766315",
"0.61551076",
"0.61501074",
"0.6145136... | 0.774596 | 0 |
Convolve each component of data_arr with kernel_arr and stack the result into an array. data_arr is an NxM array, where N is the number of time bins and M the number of components kernel_arr is an MxM array, for which the element with index (i,j) represents the contribution of component j to component i. (Consistent wi... | def conv1d(data_arr, kernel_arr, tarr_len, discrete_kernel_shape, mode='valid'):
assert(data_arr.ndim == 2)
output_shape = discrete_kernel_shape[1:]
if (kernel_arr.ndim == 2):
# Algorithm assumes a "to" axis on the kernel. Add it.
kernel_arr = add_axes(kernel_arr, 1, 'before last')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convolution2D(ndarray, kernel, kernel_pivot):\n\t#validation of arrays types\n\tassert ndarray.dtype == np.float, 'Invalid dtype of ndarray should be float'\n\tassert kernel.dtype == np.float, 'Invalid dtype of kernel should be float'\n\tassert ndarray.ndim == 2, 'Invalid ndarray dimension'\n\tassert kernel.nd... | [
"0.63226545",
"0.60152525",
"0.55545235",
"0.5552033",
"0.5547346",
"0.5546287",
"0.5444849",
"0.53988546",
"0.5391903",
"0.5335605",
"0.5316029",
"0.53053594",
"0.52910376",
"0.5272581",
"0.52257395",
"0.52186984",
"0.5215682",
"0.5211804",
"0.5200732",
"0.5198506",
"0.51931... | 0.6499635 | 0 |
Wrapper for the linear filter operator implemented by scipy.signal.lfilter At the moment, the implementation is restricted to the case a = 1. | def lfilter(size, b, a, x, *args, **kwargs):
sym_a = is_theano_object(a)
sym_b = is_theano_object(b)
sym_x = is_theano_object(x)
M, N = size
if sym_b or sym_x:
s = x * b[0]
for tau in range(1, M):
u = x[:-tau] * b[tau]
s = T.inc_subtensor(s[tau:], u)
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lfilter(b, a, x, axis=-1, zi=None):\n a = np.atleast_1d(a)\n if len(a) == 1:\n # This path only supports types fdgFDGO to mirror _linear_filter below.\n # Any of b, a, x, or zi can set the dtype, but there is no default\n # casting of other types; instead a NotImplementedError is rai... | [
"0.69632137",
"0.6564763",
"0.65372974",
"0.6445048",
"0.6321419",
"0.6162388",
"0.6106465",
"0.5994196",
"0.5921511",
"0.5803433",
"0.5786575",
"0.57217765",
"0.5690797",
"0.5678843",
"0.55839986",
"0.5573224",
"0.55679464",
"0.5538213",
"0.55143213",
"0.55127573",
"0.549178... | 0.67906237 | 1 |
Method used to search for a specific blob, commit or tree. If a tree is searched for, the result is splitted into its components (blobs and directories), which are again splitted into their mode, hash and name. In the case of a commit, we split the information string and the tree hash and parent's commit hash are retur... | def search(hash, type):
out = bash('echo ' + hash + ' | ~/lookup/showCnt ' + type)
if type == 'tree':
return [blob.split(';') for blob in out.strip().split('\n')]
if type == 'commit':
splitted = out.split(';')
# the tree and parent commit hashes are the second and third word, respectively
# the commit time... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_lookup(self, target_path, commit):\n segments = target_path.split(\"/\")\n tree_or_blob = commit.tree\n path = ''\n while segments:\n dirent = segments.pop(0)\n if isinstance(tree_or_blob, pygit2.Tree):\n if dirent in tree_or_blob:\n ... | [
"0.620875",
"0.55707973",
"0.5503819",
"0.5488553",
"0.54023314",
"0.52747744",
"0.5221155",
"0.5140808",
"0.5135953",
"0.5121725",
"0.5115463",
"0.5029685",
"0.50186586",
"0.5016464",
"0.4965771",
"0.49135715",
"0.48894116",
"0.48343554",
"0.48126018",
"0.481247",
"0.4811850... | 0.6542909 | 0 |
Method used to check the usage of Continuous Integration in a tree, given its hash. | def ci_lookup(tree_hash):
query = 'echo ' + tree_hash + ' | ~/lookup/showCnt tree | egrep "' + '|'.join(ci_files) +'"'
out = bash(query)
"""
# alternate method
blobs = search(tree_hash, 'tree')
index = {'mode':1, 'hash':1, 'name':2}
ci = False
for blob in blobs:
name = blob[index['name']]
hash = blob[ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkGit(directory):",
"def check_build_status(owner, repository, ref):\n return get_hvcs().check_build_status(owner, repository, ref)",
"def check_dependency(self, repo, minhash=None):\n try:\n p = Project.objects.get(repo_url=repo)\n except Project.DoesNotExist:\n r... | [
"0.5615642",
"0.5446968",
"0.53468597",
"0.53203434",
"0.5279424",
"0.5214733",
"0.51891404",
"0.51716375",
"0.5140349",
"0.5117159",
"0.5067787",
"0.5063527",
"0.5044477",
"0.50306433",
"0.5022968",
"0.5018853",
"0.50033265",
"0.4998231",
"0.49759716",
"0.49759635",
"0.49651... | 0.62855154 | 0 |
We check the parent commit to see if its child commit introduced or modified a CI config file. | def check_if_introduction(commit, result):
tree_hash, parent_commit_hash, time = search(commit, 'commit')
# controlling for the case of no parent commits
if parent_commit_hash == '':
return True
# controlling for the case of multiple parent commits
all_parent_CI = False
for parent in parent_commit_hash.split... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lint_commit_base(commit):\n success = True\n # Merge commits have two parents, we maintain a linear history.\n if len(commit.parents) > 1:\n error(\n \"Please resolve merges by re-basing. Merge commits are not allowed.\",\n commit)\n success = False\n\n return su... | [
"0.59226084",
"0.5910878",
"0.5807173",
"0.57713675",
"0.5732562",
"0.5723487",
"0.5709827",
"0.56935096",
"0.5671692",
"0.5613732",
"0.55919313",
"0.5571465",
"0.5569481",
"0.55452746",
"0.55405",
"0.55384827",
"0.5518048",
"0.54979306",
"0.5494411",
"0.5483143",
"0.54710555... | 0.6080408 | 0 |
Used to investigate how many commits, from a user, modified a unit testing file. Unix commands are used to achieve a better performance. The blobs are parsed, looking for unit testing library imports. An alternative would be using the thruMaps directories or the ClickHouse API, but those options seem slower. | def calc_test(commits, author):
open('modifications.csv', 'w').close()
for count, commit in enumerate(commits):
# status update
if (count + 1) % 5 == 0:
print commit, '.. ..', count + 1, ' / ', len(commits)
# getting every blob from a given commit
query = ('for x in $(echo ' + commit + ' | ~/lookup/g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repo_commit_count():\n\n commit_count = BehavioralUtils.count_commits('drupal', 'builds')\n assert commit_count == 4",
"def get_git_commiter_count(path):\n process = subprocess.Popen(['git', 'shortlog', '-sn'], cwd=path, stdout=subprocess.PIPE)\n stdout, _ = process.communicate()\n ... | [
"0.6643158",
"0.60023016",
"0.58225226",
"0.581164",
"0.564116",
"0.5630193",
"0.5622561",
"0.5608913",
"0.5597471",
"0.55932194",
"0.55867994",
"0.5578852",
"0.5450797",
"0.5377554",
"0.5376797",
"0.53600526",
"0.5338216",
"0.5317002",
"0.5301987",
"0.52945113",
"0.5284733",... | 0.67948884 | 0 |
Method used to count the usage of certain languages' good practices and modern approaches. We parse the diff of a modified file and the content of an introduced file, in order to find those practices, and we count the extent of the usage. Then, we write to a file, for each commit that included these features. | def calc_lang_features(commits, author):
lang_features = ['/\*\*', '\\"\\"\\"', '///', # documentation
'^\s*@', 'def.+:.+->', 'using\s+System\.ComponentModel\.DataAnnotations', # assertion
'assert', 'TODO', 'lambda']
# delete contents
open('lang_features.csv', 'w').close()
for count, commit in enumerate(co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_line_counts(self):\n diff = (\n b'+ This is some line before the change\\n'\n b'- And another line\\n'\n b'Index: foo\\n'\n b'- One last.\\n'\n b'--- README 123\\n'\n b'+++ README (new)\\n'\n b'@@ -1,1 +1,1 @@\\n'\n ... | [
"0.55916655",
"0.55377793",
"0.549463",
"0.5345161",
"0.53267086",
"0.5320616",
"0.526287",
"0.52469856",
"0.5209883",
"0.51992834",
"0.5179559",
"0.51548904",
"0.5102893",
"0.5010156",
"0.50060344",
"0.49976557",
"0.49974072",
"0.49898696",
"0.49847335",
"0.49833786",
"0.498... | 0.6791736 | 0 |
Find the name of the program for Popen. Windows is finnicky about having the complete file name. Popen won't search the %PATH% for you automatically. (Adapted from ctypes.find_library) | def find_program(name):
# See MSDN for the REAL search order.
base, ext = os.path.splitext(name)
if ext:
exts = [ext]
else:
exts = ['.bat', '.exe']
for directory in os.environ['PATH'].split(os.pathsep):
for e in exts:
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindEnv(progname):\n for path in os.environ['PATH'].split(':'):\n fullname = os.path.join(path, progname)\n if os.access(fullname, os.X_OK):\n return fullname\n raise AssertionError(\n \"Could not find an executable named '%s' in the system path\" % progname)",
"def _prog(shell_cmd):\n c... | [
"0.7055392",
"0.7032965",
"0.6972828",
"0.6802683",
"0.6751492",
"0.67297626",
"0.66937417",
"0.66916645",
"0.66209626",
"0.6619629",
"0.661692",
"0.66129804",
"0.66069007",
"0.6597765",
"0.65944254",
"0.6529503",
"0.6529503",
"0.6499914",
"0.6469315",
"0.6443715",
"0.6432038... | 0.7439804 | 0 |
Run svn cmd in PIPE exit if svn cmd failed | def run_svn(args, fail_if_stderr=False, encoding="utf-8"):
def _transform_arg(a):
if isinstance(a, unicode):
a = a.encode(encoding or locale_encoding)
elif not isinstance(a, str):
a = str(a)
return a
t_args = map(_transform_arg, args)
cmd = find_prog... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_svn(*cmd, **kwargs):\n kwargs.setdefault('stdin', subprocess2.PIPE)\n kwargs.setdefault('stdout', subprocess2.PIPE)\n kwargs.setdefault('stderr', subprocess2.PIPE)\n\n cmd = (SVN_EXE,) + cmd\n proc = subprocess2.Popen(cmd, **kwargs)\n ret, err = proc.communicate()\n retcode = proc.wait()\n if retco... | [
"0.8139468",
"0.6768759",
"0.6742464",
"0.6726329",
"0.64676774",
"0.61645204",
"0.60822946",
"0.5962468",
"0.59567994",
"0.5952341",
"0.59217626",
"0.5921187",
"0.5896519",
"0.58793974",
"0.58608013",
"0.58277047",
"0.58246434",
"0.5786155",
"0.5755748",
"0.57454145",
"0.573... | 0.7465438 | 1 |
Parse an SVN date as read from the XML output and return the corresponding timestamp. | def svn_date_to_timestamp(svn_date):
# Strip microseconds and timezone (always UTC, hopefully)
# XXX there are various ISO datetime parsing routines out there,
# cf. http://seehuhn.de/comp/pdate
date = svn_date.split('.', 2)[0]
time_tuple = time.strptime(date, "%Y-%m-%dT%H:%M:%S")
return c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getversion_svn(path=None): # pragma: no cover\n _program_dir = path or _get_program_dir()\n tag, rev, date = svn_rev_info(_program_dir)\n hsh, date2 = github_svn_rev2hash(tag, rev)\n if date.tm_isdst >= 0 and date2.tm_isdst >= 0:\n assert date == date2, 'Date of version is not consistent'\n... | [
"0.6344183",
"0.63013804",
"0.6238115",
"0.60493755",
"0.59930885",
"0.59590983",
"0.59490615",
"0.59364974",
"0.58739996",
"0.5863237",
"0.5850068",
"0.5847718",
"0.5834404",
"0.5801015",
"0.5763705",
"0.5755848",
"0.5741187",
"0.57391524",
"0.57288116",
"0.57245946",
"0.571... | 0.75384796 | 0 |
Parse the XML output from an "svn info" command and extract useful information as a dict. | def parse_svn_info_xml(xml_string):
d = {}
tree = ET.fromstring(xml_string)
entry = tree.find('.//entry')
if entry:
d['url'] = entry.find('url').text
d['revision'] = int(entry.get('revision'))
d['repos_url'] = tree.find('.//repository/root').text
d['last_changed_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn_info():\n code, result = popen('svn info --xml .', False, False)\n parser = ElementTree.XMLTreeBuilder()\n parser.feed(''.join(result))\n return parser.close()",
"def get_svn_info(svn_url_or_wc, rev_number=None):\r\n if rev_number is not None:\r\n args = [svn_url_or_wc + \"@\" + str... | [
"0.8203796",
"0.7418163",
"0.7025013",
"0.693242",
"0.69245094",
"0.66416997",
"0.6343546",
"0.62355715",
"0.6154227",
"0.6129481",
"0.6104162",
"0.6081777",
"0.5968167",
"0.58136433",
"0.57634497",
"0.57295316",
"0.5708708",
"0.5692372",
"0.5637466",
"0.5557835",
"0.54935837... | 0.78879315 | 1 |
Parse the XML output from an "svn log" command and extract useful information as a list of dicts (one per log changeset). | def parse_svn_log_xml(xml_string):
l = []
tree = ET.fromstring(xml_string)
for entry in tree.findall('logentry'):
d = {}
d['revision'] = int(entry.get('revision'))
# Some revisions don't have authors, most notably
# the first revision in a repository.
author =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn_log():\n code, result = popen('svn log --stop-on-copy --xml %s' % base_url(),\n False, False)\n parser = ElementTree.XMLTreeBuilder()\n parser.feed(''.join(result))\n return parser.close()",
"def log(repo, args):\n args = args or []\n out = subprocess2.check_output(\n ['svn', 'l... | [
"0.7319128",
"0.72359306",
"0.66491866",
"0.6320032",
"0.62218016",
"0.6190972",
"0.6050652",
"0.6038229",
"0.60048187",
"0.5899122",
"0.58628863",
"0.5842269",
"0.58312356",
"0.58181256",
"0.58050287",
"0.5794505",
"0.5756526",
"0.57474965",
"0.5689585",
"0.5652634",
"0.5652... | 0.8071326 | 0 |
Parse the XML output from an "svn status" command and extract useful info as a list of dicts (one per status entry). | def parse_svn_status_xml(xml_string, base_dir=None):
l = []
tree = ET.fromstring(xml_string)
for entry in tree.findall('.//entry'):
d = {}
path = entry.get('path')
if base_dir is not None:
assert path.startswith(base_dir)
path = path[len(base_dir):].ls... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn_info():\n code, result = popen('svn info --xml .', False, False)\n parser = ElementTree.XMLTreeBuilder()\n parser.feed(''.join(result))\n return parser.close()",
"def get_svn_status(svn_wc):\r\n # Ensure proper stripping by canonicalizing the path\r\n svn_wc = os.path.abspath(svn_wc)\r\... | [
"0.72432333",
"0.71974355",
"0.6659712",
"0.6412356",
"0.62618715",
"0.62445164",
"0.6192214",
"0.6184007",
"0.61359966",
"0.6080127",
"0.5983944",
"0.5895939",
"0.58736753",
"0.58303154",
"0.58027536",
"0.57808256",
"0.5779228",
"0.57057047",
"0.570344",
"0.5685933",
"0.5664... | 0.7791763 | 0 |
Get SVN information for the given URL or working copy, with an optionally specified revision number. Returns a dict as created by parse_svn_info_xml(). | def get_svn_info(svn_url_or_wc, rev_number=None):
if rev_number is not None:
args = [svn_url_or_wc + "@" + str(rev_number)]
else:
args = [svn_url_or_wc]
xml_string = run_svn(svn_info_args + args,
fail_if_stderr=True)
return parse_svn_info_xml(xml_string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_svn_info_xml(xml_string):\r\n d = {}\r\n tree = ET.fromstring(xml_string)\r\n entry = tree.find('.//entry')\r\n if entry:\r\n d['url'] = entry.find('url').text\r\n d['revision'] = int(entry.get('revision'))\r\n d['repos_url'] = tree.find('.//repository/root').text\r\n ... | [
"0.74792516",
"0.7262006",
"0.6978561",
"0.6912358",
"0.6846923",
"0.6805328",
"0.67821187",
"0.64899975",
"0.64640033",
"0.6269762",
"0.6125339",
"0.61188823",
"0.60885954",
"0.6075489",
"0.6045305",
"0.6036259",
"0.60327077",
"0.60039306",
"0.59969646",
"0.5993393",
"0.5896... | 0.85259694 | 0 |
Checkout the given URL at an optional revision number. | def svn_checkout(svn_url, checkout_dir, rev_number=None):
args = []
if rev_number is not None:
args += ['-r', rev_number]
args += [svn_url, checkout_dir]
return run_svn(svn_checkout_args + args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout(self, url=None, rev=None):\r\n args = []\r\n if url is None:\r\n url = self.url\r\n if rev is None or rev == -1:\r\n if (py.std.sys.platform != 'win32' and\r\n svncommon._getsvnversion() == '1.3'):\r\n url += \"@HEAD\" \r\n ... | [
"0.7587817",
"0.69942826",
"0.69249",
"0.66799235",
"0.66345185",
"0.6605867",
"0.6593704",
"0.5971365",
"0.58886915",
"0.5854396",
"0.57321954",
"0.5711707",
"0.56829685",
"0.56620574",
"0.5588385",
"0.5566829",
"0.5447706",
"0.5394447",
"0.53901905",
"0.53690535",
"0.535483... | 0.734565 | 1 |
Fetch up to 'limit' SVN log entries between the given revisions. | def run_svn_log(svn_url_or_wc, rev_start, rev_end, limit, stop_on_copy=False):
if stop_on_copy:
args = ['--stop-on-copy']
else:
args = []
args += ['-r', '%s:%s' % (rev_start, rev_end), '--limit',
str(limit), svn_url_or_wc]
xml_string = run_svn(svn_log_args + args)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_svn_log_entries(svn_url, first_rev, last_rev):\r\n cur_rev = first_rev\r\n chunk_length = log_min_chunk_length\r\n chunk_interval_factor = 1.0\r\n while last_rev == \"HEAD\" or cur_rev <= last_rev:\r\n start_t = time.time()\r\n stop_rev = min(last_rev, cur_rev + int(chunk_length ... | [
"0.70947737",
"0.67464644",
"0.64936244",
"0.62931967",
"0.6224911",
"0.6203545",
"0.6197707",
"0.6176134",
"0.6131039",
"0.61278427",
"0.6080677",
"0.5966624",
"0.596037",
"0.5953586",
"0.5938793",
"0.59325117",
"0.57986856",
"0.5760113",
"0.57526404",
"0.5749698",
"0.572157... | 0.73090345 | 0 |
Get SVN status information about the given working copy. | def get_svn_status(svn_wc):
# Ensure proper stripping by canonicalizing the path
svn_wc = os.path.abspath(svn_wc)
args = [svn_wc]
xml_string = run_svn(svn_status_args + args)
return parse_svn_status_xml(xml_string, svn_wc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetStatus(self, filename):\r\n if not self.options.revision:\r\n status = RunShell([\"svn\", \"status\", \"--ignore-externals\",\r\n self._EscapeFilename(filename)])\r\n if not status:\r\n ErrorExit(\"svn status returned no output for %s\" % filename)\r\n status... | [
"0.71096194",
"0.7067892",
"0.647219",
"0.63601357",
"0.6357903",
"0.6204381",
"0.6062598",
"0.6060114",
"0.6008719",
"0.6006883",
"0.5979798",
"0.59328514",
"0.5929919",
"0.59271693",
"0.5922021",
"0.5919111",
"0.5851352",
"0.5848176",
"0.5807185",
"0.57792634",
"0.5682582",... | 0.7943254 | 0 |
Get the first SVN log entry in the requested revision range. | def get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=False):
entries = run_svn_log(svn_url, rev_start, rev_end, 1, stop_on_copy)
if not entries:
display_error("No SVN log for %s between revisions %s and %s" %
(svn_url, rev_start, rev_end))
return entries[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_first_svn_log_entry(svn_url, rev_start, rev_end):\r\n return get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=True)",
"def get_last_svn_log_entry(svn_url, rev_start, rev_end):\r\n return get_one_svn_log_entry(svn_url, rev_end, rev_start, stop_on_copy=True)",
"def log(self, rev_star... | [
"0.8594663",
"0.77562016",
"0.6639953",
"0.6424312",
"0.63635945",
"0.6149215",
"0.6090127",
"0.59696937",
"0.5898888",
"0.57166743",
"0.567495",
"0.5618679",
"0.5595425",
"0.5574369",
"0.55588615",
"0.5477116",
"0.5469488",
"0.54385024",
"0.5427549",
"0.5397868",
"0.53943014... | 0.852757 | 1 |
Get the first log entry after/at the given revision number in an SVN branch. By default the revision number is set to 0, which will give you the log entry corresponding to the branch creaction. | def get_first_svn_log_entry(svn_url, rev_start, rev_end):
return get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=False):\r\n entries = run_svn_log(svn_url, rev_start, rev_end, 1, stop_on_copy)\r\n if not entries:\r\n display_error(\"No SVN log for %s between revisions %s and %s\" %\r\n (svn_url, rev_start, rev_end))\r\n\r\n ... | [
"0.7474543",
"0.7324269",
"0.64620775",
"0.6080599",
"0.6027151",
"0.6015015",
"0.5875284",
"0.58532226",
"0.5841055",
"0.58372486",
"0.58316255",
"0.5739844",
"0.57326627",
"0.5732128",
"0.57199556",
"0.57193303",
"0.56884575",
"0.5652329",
"0.56429666",
"0.5642953",
"0.5626... | 0.7538443 | 0 |
Get the last log entry before/at the given revision number in an SVN branch. By default the revision number is set to HEAD, which will give you the log entry corresponding to the latest commit in branch. | def get_last_svn_log_entry(svn_url, rev_start, rev_end):
return get_one_svn_log_entry(svn_url, rev_end, rev_start, stop_on_copy=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest_branch_revision(self, branch):\n return self.repo.get_refs()['refs/remotes/origin/' + branch]",
"def get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=False):\r\n entries = run_svn_log(svn_url, rev_start, rev_end, 1, stop_on_copy)\r\n if not entries:\r\n display_error... | [
"0.6765192",
"0.67387676",
"0.66078806",
"0.6342817",
"0.6319162",
"0.6254498",
"0.6168754",
"0.6143793",
"0.6119326",
"0.6102056",
"0.6072445",
"0.6065642",
"0.60258543",
"0.60138184",
"0.5993434",
"0.59712136",
"0.5943732",
"0.5923224",
"0.5839787",
"0.5791853",
"0.57440645... | 0.75275195 | 0 |
Iterate over SVN log entries between first_rev and last_rev. This function features chunked log fetching so that it isn't too nasty to the SVN server if many entries are requested. | def iter_svn_log_entries(svn_url, first_rev, last_rev):
cur_rev = first_rev
chunk_length = log_min_chunk_length
chunk_interval_factor = 1.0
while last_rev == "HEAD" or cur_rev <= last_rev:
start_t = time.time()
stop_rev = min(last_rev, cur_rev + int(chunk_length * chunk_interval_fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self, rev_start=None, rev_end=1, verbose=False):\r\n from py.__.path.svn.urlcommand import _Head, LogEntry\r\n assert self.check() # make it simpler for the pipe\r\n rev_start = rev_start is None and _Head or rev_start\r\n rev_end = rev_end is None and _Head or rev_end\r\n\r\n... | [
"0.6570125",
"0.65208936",
"0.63974756",
"0.6192296",
"0.61243796",
"0.6018704",
"0.59748876",
"0.5943721",
"0.589428",
"0.5800521",
"0.57751346",
"0.577392",
"0.57538754",
"0.5708253",
"0.56509763",
"0.5612253",
"0.5603118",
"0.55822706",
"0.55163515",
"0.5505781",
"0.550519... | 0.87408674 | 0 |
Given an SVN log entry and an optional sequence of files, do an svn commit. | def commit_from_svn_log_entry(entry, files=None, keep_author=False):
# This will use the local timezone for displaying commit times
timestamp = int(entry['date'])
svn_date = str(datetime.fromtimestamp(timestamp))
# Uncomment this one one if you prefer UTC commit times
#svn_date = "%d 0" % times... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn_client_commit(svn_client_commit_info_t_commit_info_p, apr_array_header_t_targets, svn_boolean_t_nonrecursive, svn_client_ctx_t_ctx, apr_pool_t_pool): # real signature unknown; restored from __doc__\n pass",
"def svn_fs_commit_txn(*args):\r\n return _fs.svn_fs_commit_txn(*args)",
"def commit (files)... | [
"0.68557906",
"0.67462325",
"0.6638299",
"0.6335978",
"0.62727916",
"0.6222189",
"0.61176294",
"0.60768735",
"0.60218906",
"0.5964429",
"0.59317654",
"0.5900699",
"0.5886317",
"0.582448",
"0.5789793",
"0.57313246",
"0.5703045",
"0.5606527",
"0.5589553",
"0.55780494",
"0.55426... | 0.7727907 | 0 |
Pull SVN changes from the given log entry. Returns the new SVN revision. If an exception occurs, it will rollback to revision 'svn_rev 1'. | def pull_svn_rev(log_entry, svn_url, target_url, svn_path, original_wc, keep_author=False):
svn_rev = log_entry['revision']
run_svn(["up", "--ignore-externals", "-r", svn_rev, original_wc])
removed_paths = []
merged_paths = []
unrelated_paths = []
commit_paths = []
for d in log_entr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_svn_log_entry(svn_url, rev_start, rev_end):\r\n return get_one_svn_log_entry(svn_url, rev_end, rev_start, stop_on_copy=True)",
"def get_one_svn_log_entry(svn_url, rev_start, rev_end, stop_on_copy=False):\r\n entries = run_svn_log(svn_url, rev_start, rev_end, 1, stop_on_copy)\r\n if not entr... | [
"0.68926513",
"0.67179364",
"0.63539994",
"0.6260936",
"0.623889",
"0.61554503",
"0.6080435",
"0.5869495",
"0.58553165",
"0.58542365",
"0.5845239",
"0.5809937",
"0.5799207",
"0.577643",
"0.57277685",
"0.57229894",
"0.57108986",
"0.56525624",
"0.5649471",
"0.5644801",
"0.56429... | 0.782687 | 0 |
Decrements the field in the position x, y (zero based) x int y int | def decrement(self, x, y):
self.field.add(x, y, -1)
self.depth += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self, x, y):\n # Update impact to row, column and block containing (x, y)\n val = self.field[x][y]\n\n for i in range(0, 9):\n self.reset_detail(x, y, val, x, i)\n \n for i in range(0, 9):\n self.reset_detail(x, y, val, i, y)\n\n cx = int(in... | [
"0.6667889",
"0.6542566",
"0.63265264",
"0.6257075",
"0.62394804",
"0.6153629",
"0.61325014",
"0.6112912",
"0.60975367",
"0.6093218",
"0.60634387",
"0.59816176",
"0.59665287",
"0.59466773",
"0.5920354",
"0.5912557",
"0.59046715",
"0.5892904",
"0.58569384",
"0.5818755",
"0.579... | 0.77877957 | 0 |
field Field returns optimal move | def _find_optimal_impl(self, field, depth, is_r, alpha, beta):
# Try to evaluate the field right now
if field.is_terminal():
final_value = self.eval_field(field, depth, is_r)
return Move(final_value, 0, 0)
self.unrolled += 1
# copy = field.copy()
value =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_move(self):\n if self._move is not None:\n return self._move\n else:\n return self.pass_move",
"def find_best_move(state: GameState) -> None:",
"def move(self, _vec):\n\n\t\t_dest = self._grid[0] + _vec[0], self._grid[1] + _vec[1], self._grid[2] + _vec[2]\n\t\tif _v... | [
"0.6263069",
"0.6059461",
"0.5905605",
"0.58534604",
"0.58158803",
"0.5784372",
"0.5657567",
"0.5616514",
"0.55931526",
"0.55312353",
"0.55171657",
"0.5478466",
"0.5442166",
"0.540294",
"0.5393491",
"0.53857905",
"0.5375167",
"0.5373872",
"0.53728926",
"0.536618",
"0.5354955"... | 0.63401204 | 0 |
Decorator for a custom writer, but a default reader | def _writer(func):
name = func.__name__
return property(fget=lambda self: getattr(self, '_%s' % name), fset=func) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_writer(fn, samples):\n if is_bed(fn):\n return BedWriter(fn, samples)\n elif is_vcf(fn):\n return VcfWriter(fn, samples)\n else:\n raise ValueError(\"Could not get reader for %s\" % fn)",
"def _json_default_encoder(func):\n\n @wraps(func)\n def inner(self, o):\n ... | [
"0.595238",
"0.54192704",
"0.53424925",
"0.52520764",
"0.52455467",
"0.52088577",
"0.51499164",
"0.5144171",
"0.5096153",
"0.50615203",
"0.49974352",
"0.4978391",
"0.49752855",
"0.49655232",
"0.49428678",
"0.49167585",
"0.49089715",
"0.4900687",
"0.4897344",
"0.48930278",
"0.... | 0.5535025 | 1 |
Encodes a certificate into PEM format | def pem_armor_certificate(certificate):
return asymmetric.dump_certificate(certificate) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_certificate(self, cert):\n return cert.public_bytes(\n serialization.Encoding.PEM,\n ).decode(encoding='UTF-8')",
"def cert_to_pem(cert):\n return cert.public_bytes(Encoding.PEM)",
"def encode_csr(self, csr):\n return csr.public_bytes(\n serialization.En... | [
"0.790705",
"0.67137074",
"0.66287994",
"0.62648046",
"0.62635964",
"0.6201385",
"0.6190777",
"0.6079637",
"0.57039255",
"0.5664951",
"0.5664951",
"0.56504196",
"0.55824506",
"0.55710584",
"0.5538198",
"0.54970545",
"0.5482253",
"0.5482253",
"0.5482253",
"0.5480252",
"0.54799... | 0.71420515 | 1 |
An asn1crypto.x509.Certificate object of the issuer. Used to populate both the issuer field, but also the authority key identifier extension. | def issuer(self, value):
is_oscrypto = isinstance(value, asymmetric.Certificate)
if not isinstance(value, x509.Certificate) and not is_oscrypto:
raise TypeError(_pretty_message(
'''
issuer must be an instance of asn1crypto.x509.Certificate or
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_issuer_id(self):\n return self._certificate_issuer_id",
"def certificate_issuer_value(self):\n\n if self._processed_extensions is False:\n self._set_extensions()\n return self._certificate_issuer_value",
"def issuer(self) -> str:\n return self._issuer",
... | [
"0.73816204",
"0.6945147",
"0.66578543",
"0.6484168",
"0.6398865",
"0.639261",
"0.6361317",
"0.6319611",
"0.62974656",
"0.6297223",
"0.6297223",
"0.62301636",
"0.6222359",
"0.61747855",
"0.6001003",
"0.5899635",
"0.5805775",
"0.5805775",
"0.57601124",
"0.5741107",
"0.5689454"... | 0.7783984 | 0 |
An asn1crypto.keys.PublicKeyInfo or oscrypto.asymmetric.PublicKey object of the subject's public key. | def subject_public_key(self, value):
is_oscrypto = isinstance(value, asymmetric.PublicKey)
if not isinstance(value, keys.PublicKeyInfo) and not is_oscrypto:
raise TypeError(_pretty_message(
'''
subject_public_key must be an instance of
asn1cry... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pubkey(self):\n return self._csr['certificationRequestInfo']['subjectPublicKeyInfo']",
"def get_public_key_in_pem(self):\n serialized_public = self.public_key_obj.public_bytes(\n encoding=serialization.Encoding.PEM,\n format=serialization.PublicFormat.SubjectPublicKeyI... | [
"0.7763876",
"0.76124096",
"0.7592928",
"0.7516889",
"0.7312235",
"0.7280198",
"0.72754097",
"0.7230182",
"0.71164966",
"0.6709869",
"0.67095035",
"0.665919",
"0.66478723",
"0.66478723",
"0.66474545",
"0.6620959",
"0.6620501",
"0.6620501",
"0.66195834",
"0.6607613",
"0.656907... | 0.83701605 | 0 |
A list of unicode strings the domains in the subject alt name extension. | def subject_alt_domains(self):
return self._get_subject_alt('dns_name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_gnames(self, ext):\n res = []\n for gn in ext:\n if isinstance(gn, x509.RFC822Name):\n res.append('email:' + as_unicode(gn.value))\n elif isinstance(gn, x509.DNSName):\n res.append('dns:' + as_unicode(gn.value))\n elif isinsta... | [
"0.72788537",
"0.6887314",
"0.68745184",
"0.6768655",
"0.66532815",
"0.6598599",
"0.6590056",
"0.64256465",
"0.63596284",
"0.6282002",
"0.62713486",
"0.61748195",
"0.6156774",
"0.6148802",
"0.6116992",
"0.60856193",
"0.60594046",
"0.60446495",
"0.5983179",
"0.5977446",
"0.589... | 0.7977574 | 0 |
A list of unicode strings the email addresses in the subject alt name extension. | def subject_alt_emails(self):
return self._get_subject_alt('rfc822_name') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_list(self) -> Sequence[str]:\n return pulumi.get(self, \"email_list\")",
"def _get_subject_alt(self, name):\n\n if self._subject_alt_name is None:\n return []\n\n output = []\n for general_name in self._subject_alt_name:\n if general_name.name == name:\... | [
"0.72356385",
"0.6921819",
"0.6838051",
"0.6719125",
"0.6706177",
"0.6345417",
"0.6270645",
"0.6250385",
"0.6169006",
"0.6162307",
"0.60720193",
"0.60488534",
"0.5979134",
"0.5948501",
"0.5937776",
"0.5931379",
"0.57942194",
"0.5780418",
"0.5780418",
"0.5755309",
"0.5742887",... | 0.78213984 | 0 |
A list of unicode strings the IPs in the subject alt name extension. | def subject_alt_ips(self):
return self._get_subject_alt('ip_address') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_alt_domains(self):\n\n return self._get_subject_alt('dns_name')",
"def extract_gnames(self, ext):\n res = []\n for gn in ext:\n if isinstance(gn, x509.RFC822Name):\n res.append('email:' + as_unicode(gn.value))\n elif isinstance(gn, x509.DNSNam... | [
"0.6537365",
"0.646454",
"0.6455185",
"0.62171775",
"0.616625",
"0.59316343",
"0.5899585",
"0.5891852",
"0.58809155",
"0.58578",
"0.5840667",
"0.58072513",
"0.5775309",
"0.57627815",
"0.5722256",
"0.5714882",
"0.5680381",
"0.56474614",
"0.5626229",
"0.55998427",
"0.5547352",
... | 0.72669786 | 0 |
A list of unicode strings the URIs in the subject alt name extension. | def subject_alt_uris(self):
return self._get_subject_alt('uniform_resource_identifier') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_alt_emails(self):\n\n return self._get_subject_alt('rfc822_name')",
"def extract_gnames(self, ext):\n res = []\n for gn in ext:\n if isinstance(gn, x509.RFC822Name):\n res.append('email:' + as_unicode(gn.value))\n elif isinstance(gn, x509.DNSN... | [
"0.6799801",
"0.66808426",
"0.66736543",
"0.6628554",
"0.6431734",
"0.61050284",
"0.60392606",
"0.594447",
"0.5796263",
"0.57637",
"0.568384",
"0.5626839",
"0.5591084",
"0.5591084",
"0.5548497",
"0.5543832",
"0.55101144",
"0.54757005",
"0.54666746",
"0.5451787",
"0.5436031",
... | 0.7319736 | 0 |
Returns the native value for each value in the subject alt name extension that is an asn1crypto.x509.GeneralName of the type specified by the name param. | def _get_subject_alt(self, name):
if self._subject_alt_name is None:
return []
output = []
for general_name in self._subject_alt_name:
if general_name.name == name:
output.append(general_name.native)
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_gnames(self, ext):\n res = []\n for gn in ext:\n if isinstance(gn, x509.RFC822Name):\n res.append('email:' + as_unicode(gn.value))\n elif isinstance(gn, x509.DNSName):\n res.append('dns:' + as_unicode(gn.value))\n elif isinsta... | [
"0.60357517",
"0.60340154",
"0.58107865",
"0.57732433",
"0.57518286",
"0.52605563",
"0.52396375",
"0.5225003",
"0.51472336",
"0.50632966",
"0.50319296",
"0.50171",
"0.4920979",
"0.4885249",
"0.48720473",
"0.48472485",
"0.48396906",
"0.48279297",
"0.48234767",
"0.47389436",
"0... | 0.72134984 | 0 |
Replaces all existing asn1crypto.x509.GeneralName objects of the choice represented by the name param with the values. | def _set_subject_alt(self, name, values):
if self._subject_alt_name is not None:
filtered_general_names = []
for general_name in self._subject_alt_name:
if general_name.name != name:
filtered_general_names.append(general_name)
self._subjec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_x509_name(name):\n types = {\n 'country_name': 'C',\n 'state_or_province_name': 'ST',\n 'locality_name': 'L',\n 'organization_name': 'O',\n 'organizational_unit_name': 'OU',\n 'common_name': 'CN',\n 'email_address': 'emailAddress'\n }\n\n return... | [
"0.54285276",
"0.52805185",
"0.5233348",
"0.5175837",
"0.5152925",
"0.5109464",
"0.50863415",
"0.50817627",
"0.5079362",
"0.50544924",
"0.5022161",
"0.5008312",
"0.50026274",
"0.50002813",
"0.49956682",
"0.49948135",
"0.49948135",
"0.49823135",
"0.49680725",
"0.49542877",
"0.... | 0.676688 | 0 |
A set of unicode strings the allowed usage of the key from the extended key usage extension. | def extended_key_usage(self):
if self._extended_key_usage is None:
return set()
return set(self._extended_key_usage.native) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ext_key_usages(self) -> pulumi.Output[Optional[Sequence[str]]]:\n return pulumi.get(self, \"ext_key_usages\")",
"def ext_key_usages(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:\n return pulumi.get(self, \"ext_key_usages\")",
"def ext_key_usages(self) -> Optional[pulumi.Input[... | [
"0.7455842",
"0.7374315",
"0.7374315",
"0.71024346",
"0.6737492",
"0.6654881",
"0.6457139",
"0.6399681",
"0.6399681",
"0.60323876",
"0.591794",
"0.58423394",
"0.57243574",
"0.5681344",
"0.5556404",
"0.5525818",
"0.55181473",
"0.54313207",
"0.5347413",
"0.5326456",
"0.53208786... | 0.7662352 | 0 |
Location of the delta CRL for the certificate. Will be one of the | def delta_crl_url(self):
if self._freshest_crl is None:
return None
return self._get_crl_url(self._freshest_crl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_crl_distribution_points(self):\n\n if self._delta_crl_distribution_points is None:\n self._delta_crl_distribution_points = []\n\n if self.freshest_crl_value is not None:\n for distribution_point in self.freshest_crl_value:\n distribution_poin... | [
"0.6988407",
"0.6318833",
"0.6084879",
"0.56201124",
"0.5176203",
"0.51518315",
"0.50600994",
"0.48365542",
"0.48194048",
"0.4758225",
"0.47277874",
"0.46993938",
"0.46964672",
"0.4641692",
"0.46160996",
"0.46053565",
"0.46053565",
"0.46053565",
"0.46053565",
"0.45939425",
"0... | 0.72536683 | 0 |
Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object | def _get_crl_url(self, distribution_points):
if distribution_points is None:
return None
for distribution_point in distribution_points:
name = distribution_point['distribution_point']
if name.name == 'full_name' and name.chosen[0].name == 'uniform_resource_identifie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crl_url(self):\n\n if self._crl_distribution_points is None:\n return None\n\n return self._get_crl_url(self._crl_distribution_points)",
"def _make_crl_distribution_points(self, name, value):\n\n if value is None:\n return None\n\n is_tuple = isinstance(value... | [
"0.667195",
"0.6278513",
"0.5788191",
"0.57319546",
"0.5548122",
"0.5375431",
"0.53468317",
"0.5276551",
"0.5264446",
"0.5262795",
"0.5246713",
"0.5246206",
"0.519427",
"0.5137729",
"0.5130993",
"0.5105424",
"0.5057051",
"0.5054585",
"0.503951",
"0.5028308",
"0.5016119",
"0... | 0.7561168 | 0 |
Constructs an asn1crypto.x509.CRLDistributionPoints object | def _make_crl_distribution_points(self, name, value):
if value is None:
return None
is_tuple = isinstance(value, tuple)
if not is_tuple and not isinstance(value, str_cls):
raise TypeError(_pretty_message(
'''
%s must be a unicode string o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_crl_distribution_points(self):\n\n if self._delta_crl_distribution_points is None:\n self._delta_crl_distribution_points = []\n\n if self.freshest_crl_value is not None:\n for distribution_point in self.freshest_crl_value:\n distribution_poin... | [
"0.54835486",
"0.5322369",
"0.5205519",
"0.49923587",
"0.48922306",
"0.48400053",
"0.4827509",
"0.48133376",
"0.4768135",
"0.47563958",
"0.47420117",
"0.47342488",
"0.46844715",
"0.46796644",
"0.46796644",
"0.4675792",
"0.46536493",
"0.46308368",
"0.46132258",
"0.45735577",
"... | 0.6899878 | 0 |
Location of the OCSP responder for this certificate. Will be one of the | def ocsp_url(self):
if self._authority_information_access is None:
return None
for ad in self._authority_information_access:
if ad['access_method'].native == 'ocsp' and ad['access_location'].name == 'uniform_resource_identifier':
return ad['access_location'].cho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_ocsp_server(self, cert_path):\n try:\n url, _err = util.run_script(\n [\"openssl\", \"x509\", \"-in\", cert_path, \"-noout\", \"-ocsp_uri\"],\n log=logger.debug)\n except errors.SubprocessError:\n logger.info(\"Cannot extract OCSP URI ... | [
"0.6131117",
"0.5615289",
"0.5481226",
"0.52892077",
"0.5258419",
"0.5220536",
"0.51888037",
"0.51888037",
"0.510542",
"0.50266665",
"0.5012942",
"0.49867067",
"0.49449998",
"0.49422258",
"0.49315235",
"0.49149665",
"0.49149665",
"0.48778692",
"0.48690465",
"0.48679858",
"0.4... | 0.61559165 | 0 |
Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.x509.Extension to determine the appropriate object type for a given extension. Extensions are marked as cr... | def set_extension(self, name, value, allow_deprecated=False):
extension = x509.Extension({
'extn_id': name
})
# We use native here to convert OIDs to meaningful names
name = extension['extn_id'].native
if name in self._deprecated_extensions and not allow_deprecated:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_extension(name, value, critical=0, _pyfree=1):\n if name == 'subjectKeyIdentifier' and \\\n value.strip('0123456789abcdefABCDEF:') is not '':\n raise ValueError('value must be precomputed hash')\n lhash = m2.x509v3_lhash()\n ctx = m2.x509v3_set_conf_lhash(lhash)\n x509_ext_ptr = m... | [
"0.6438263",
"0.6328225",
"0.6300037",
"0.61802584",
"0.6002731",
"0.5839028",
"0.5822578",
"0.5822578",
"0.57922786",
"0.56969255",
"0.5691874",
"0.5555141",
"0.55509424",
"0.5463055",
"0.53673494",
"0.5295832",
"0.52437776",
"0.5206584",
"0.51691777",
"0.50493395",
"0.49365... | 0.73829615 | 0 |
Helper function for slicing the audio file by window size and sample rate with [1stride] percent overlap (default 50%). | def slice_signal(file, window_size, stride, sample_rate):
wav, sr = librosa.load(file, sr=sample_rate)
hop = int(window_size * stride)
slices = []
for end_idx in range(window_size, len(wav), hop):
start_idx = end_idx - window_size
slice_sig = wav[start_idx:end_idx]
#print(type(sl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_clips_by_stride2(stride, frames_list, sequence_size):\n clips = []\n sz = len(frames_list)\n clip = []\n cnt = 0\n for start in range(0, sz-sequence_size):\n for i in range(start, start+sequence_size):\n clip.append(frames_list[i])\n clips.append(clip)\n clip ... | [
"0.600388",
"0.5930789",
"0.58244437",
"0.5814211",
"0.5788517",
"0.57616496",
"0.5741947",
"0.5716796",
"0.5714888",
"0.5699974",
"0.56802857",
"0.56785756",
"0.56071216",
"0.5601426",
"0.55252904",
"0.5479792",
"0.54793173",
"0.5475118",
"0.5470689",
"0.54675853",
"0.542913... | 0.70155334 | 0 |
Helper function to make calls to Airtable REST API. | def airtable_api(base, table, token, action = '', parameters = {}, method = 'get', data = {}):
headers = {
'Content-type': 'application/json',
'Accept-Encoding': 'gzip',
'Authorization': 'Bearer %s' % token
}
url = "https://api.airtable.com/v0/%s/%s/%s" % (base, table, action)
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _api_call(self, **kwargs):\n params = {\n 'format': 'json',\n }\n params.update(kwargs)\n r = requests.get(self.api_base_url, params=params)\n return r.json()",
"def test_api_response(self):\n # url = 'http://127.0.0.1:8000/api/aircraft/'\n url = re... | [
"0.61390936",
"0.61125934",
"0.60539144",
"0.6022661",
"0.59775054",
"0.597503",
"0.5948181",
"0.5932787",
"0.59238493",
"0.59189403",
"0.5911685",
"0.5896667",
"0.58928114",
"0.5880146",
"0.58788973",
"0.586516",
"0.5859757",
"0.5797205",
"0.5797205",
"0.579526",
"0.5782091"... | 0.765456 | 0 |
Tokenize data file and turn into tokenids using given vocabulary file. This function loads data linebyline from data_path, calls the above sentence_to_token_ids, and saves the result to target_path. See comment for sentence_to_token_ids on the details of tokenids format. | def data_to_token_ids(data_path, target_path, vocabulary_path,
tokenizer=None, normalize_digits=True):
if not gfile.Exists(target_path):
print("Tokenizing data in %s" % data_path)
vocab, _ = data_utils.initialize_vocabulary(vocabulary_path)
with gfile.GFile(data_path, m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_to_token_ids(data_path, target_path, vocabulary_path):\n if not gfile.Exists(target_path):\n print(\"Tokenizing data in %s\" % data_path)\n vocab, _ = initialize_vocabulary(vocabulary_path)\n with gfile.GFile(data_path, mode=\"rb\") as data_file:\n with gfile.GFile(targe... | [
"0.88158065",
"0.8449106",
"0.83855826",
"0.8366422",
"0.82797813",
"0.8102873",
"0.7367587",
"0.726734",
"0.7234463",
"0.7134788",
"0.7093858",
"0.70898783",
"0.70898783",
"0.70594037",
"0.7039706",
"0.6949376",
"0.6746222",
"0.67304814",
"0.6648989",
"0.6558965",
"0.6438027... | 0.8453001 | 1 |
Finds and retrieves sbfdInitiator resources from the server. All named parameters are evaluated on the server using regex. The named parameters can be used to selectively retrieve sbfdInitiator resources from the server. To retrieve an exact match ensure the parameter value starts with ^ and ends with $ By default the ... | def find(
self,
Count=None,
DescriptiveName=None,
MplsLabelCount=None,
Name=None,
SessionInfo=None,
):
# type: (int, str, int, str, List[str]) -> SbfdInitiator
return self._select(self._map_locals(self._SDM_ATT_MAP, locals())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generic_find(controller, heading, patterns):\n msg.info(heading)\n msg.info(\"--------------------------\")\n msg.blank()\n for pattern in patterns:\n for entry in controller.find(pattern):\n if hasattr(entry, \"uuid\"):\n eid = entry.uuid\n elif hasattr... | [
"0.49518782",
"0.48978445",
"0.47183838",
"0.4708106",
"0.45406547",
"0.45046747",
"0.44876707",
"0.44648275",
"0.4458623",
"0.43709165",
"0.4347843",
"0.43476033",
"0.43475124",
"0.4342113",
"0.43302515",
"0.4325594",
"0.43250877",
"0.43101805",
"0.43035924",
"0.42664522",
"... | 0.5184359 | 0 |
Add L1feature selection (LASSO) to a classifier | def with_l1_feature_selection(class_T, **kwargs):
class FeatureSelect(class_T):
def fit(self, X, y):
# The smaller C, the stronger the regularization.
# The more regularization, the more sparsity.
self.transformer_ = class_T(penalty="l1", **kwargs)
logger.inf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_features(self):\n print 'tuning alpha'\n hyper_params_model = lm.LassoCV(normalize=True, n_jobs=-1).fit(\n self.data.loc[self.train_index, self.features_], self.data.loc[self.train_index, self.target_name])\n print 'alpha is: {}'.format(hyper_params_model.alpha_)\n ... | [
"0.62955976",
"0.606903",
"0.59849876",
"0.5970041",
"0.5945682",
"0.59200114",
"0.5896963",
"0.58824384",
"0.5863572",
"0.5863572",
"0.57160354",
"0.56982696",
"0.5672844",
"0.5630173",
"0.56192195",
"0.5605374",
"0.5594883",
"0.55813015",
"0.5549581",
"0.55495733",
"0.55330... | 0.6665041 | 0 |
Inserts or updates a row in the agdds table. | def add_agdd_row(station_id, source_id, gdd, agdd, year, doy, date, base, missing, tmin, tmax):
cursor = mysql_conn.cursor(buffered=True)
cursor.execute(search_for_agdd_row, (station_id, source_id, date, base))
if cursor.rowcount < 1:
cursor.execute(insert_agdd_row, (station_id, source_id, gdd, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_or_update(self, table, connection, row):\n\n # find line, if it exist\n dbrow = self.find(connection, table, row)\n\n # TODO XXX use actual database function instead of this stupid thing\n now = datetime.datetime.now()\n\n column_names = table.columns.keys()\n\n ... | [
"0.71272016",
"0.64908445",
"0.64370745",
"0.6415218",
"0.63375866",
"0.62611103",
"0.62001574",
"0.61876833",
"0.6153674",
"0.6153602",
"0.6137083",
"0.6070958",
"0.6063594",
"0.60508627",
"0.6006844",
"0.59999216",
"0.5953526",
"0.5928303",
"0.59262604",
"0.5911096",
"0.590... | 0.6496721 | 1 |
Retrieves tmin and tmax data from climate source and computes agdds to be inserted into the agdd table. | def populate_agdds(start_date, end_date, source, source_id, stations):
# possibly grab ACIS station data (for entire date range)
if source == 'ACIS':
station_ids = []
for station in stations:
station_ids.append(station['char_network_id'])
acis_data = get_acis_climate_da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_temps(start_date, end_date):\n \n return session.query(func.min(Measurement.tobs), func.avg(Measurement.tobs), func.max(Measurement.tobs)). filter(Measurement.date >= start_date).filter(Measurement.date <= end_date).all()",
"def calc_temps(start_date, end_date):\n engine = create_engine(... | [
"0.5735708",
"0.5730932",
"0.5722183",
"0.56052613",
"0.5589223",
"0.55774945",
"0.555737",
"0.5545903",
"0.55298",
"0.5475786",
"0.5471325",
"0.5433377",
"0.5417408",
"0.54048234",
"0.5404228",
"0.5385842",
"0.5363252",
"0.5359528",
"0.5340754",
"0.5295347",
"0.52815783",
... | 0.6996738 | 0 |
Populates the agdds table with urma, acis, and prism temps and agdds for qc purposes. | def populate_agdd_qc(urma_start, urma_end, acis_start, acis_end, prism_start, prism_end):
logging.info(' ')
logging.info('-----------------beginning climate quality check population-----------------')
stations = get_stations()
sources = get_sources()
acis_source_id = None
urma_source_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_agdds(start_date, end_date, source, source_id, stations):\r\n # possibly grab ACIS station data (for entire date range)\r\n if source == 'ACIS':\r\n station_ids = []\r\n for station in stations:\r\n station_ids.append(station['char_network_id'])\r\n acis_data = ge... | [
"0.7020696",
"0.59384745",
"0.57721275",
"0.55029595",
"0.54911304",
"0.535942",
"0.5247746",
"0.52255356",
"0.5182375",
"0.51726794",
"0.5150156",
"0.5148654",
"0.5112237",
"0.510183",
"0.5043503",
"0.5028003",
"0.5018343",
"0.5009472",
"0.5000762",
"0.4996117",
"0.49891308"... | 0.6922955 | 1 |
Compute the reciprocal rank of a ranked list against some ground truth. | def reciprocal_rank(ranking, references, atk=None):
for k, prediction in enumerate(ranking[:atk], 1):
if prediction in references:
return 1.0 / k
return 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recip_rank(recs, truth):\n good = recs['item'].isin(truth.index)\n npz, = np.nonzero(good)\n if len(npz):\n return 1.0 / (npz[0] + 1.0)\n else:\n return 0.0",
"def mrr(ground_truth, prediction):\n rr = 0.\n for rank, item in enumerate(prediction):\n if item in ground_tr... | [
"0.73031837",
"0.6954642",
"0.69224846",
"0.6495415",
"0.6495415",
"0.6495415",
"0.64866287",
"0.63244474",
"0.62833434",
"0.6090479",
"0.6087416",
"0.6059336",
"0.6052769",
"0.5926173",
"0.59248835",
"0.5920617",
"0.59073466",
"0.58768547",
"0.5853657",
"0.57954407",
"0.5781... | 0.7614039 | 0 |
Compute the average precision of a ranked list against some ground truth | def average_precision(ranking, references, atk=None):
total, num_correct = 0.0, 0.0
for k, prediction in enumerate(ranking[:atk], 1):
if prediction in references:
num_correct += 1
total += num_correct / k
return total / num_correct if total > 0 else 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(ground_truth, prediction):\n ground_truth = remove_duplicates(ground_truth)\n prediction = remove_duplicates(prediction)\n precision_score = count_a_in_b_unique(prediction, ground_truth) / float(len(prediction))\n assert 0 <= precision_score <= 1\n return precision_score",
"def avera... | [
"0.7208344",
"0.7128738",
"0.70493734",
"0.70493734",
"0.69964546",
"0.69185257",
"0.6745876",
"0.6717349",
"0.6709977",
"0.670711",
"0.66209596",
"0.66137177",
"0.65935045",
"0.65935045",
"0.6568909",
"0.6563142",
"0.65568525",
"0.6533323",
"0.6532258",
"0.65147334",
"0.6491... | 0.7527089 | 0 |
Compute the mean average precision. Input should be a list of prediction rankings and a list of ground truth rankings. | def mean_average_precision(rankings, references, atk=None):
return _mean_score(rankings, references, partial(average_precision, atk=atk)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_average_precision(ground_truth_boxes, predicted_boxes):\n # DO NOT EDIT THIS CODE\n all_gt_boxes = []\n all_prediction_boxes = []\n confidence_scores = []\n\n for image_id in ground_truth_boxes.keys():\n pred_boxes = predicted_boxes[image_id][\"boxes\"]\n scores = predicted_bo... | [
"0.7831679",
"0.7574589",
"0.75513065",
"0.75513065",
"0.75288075",
"0.74372524",
"0.732722",
"0.7210581",
"0.7141075",
"0.6975217",
"0.69228095",
"0.6889771",
"0.6889771",
"0.6876503",
"0.67573595",
"0.67374164",
"0.6712426",
"0.668879",
"0.66805184",
"0.66583216",
"0.664517... | 0.77060956 | 1 |
Return the margin, or absolute difference between the highest irrelevant item and the lowest relevant one. | def margin(ranking, references):
lowest_relevant, highest_irrelevant = 0, 0
for k, prediction in enumerate(ranking, 1):
if prediction not in references and highest_irrelevant is 0:
highest_irrelevant = k
if prediction in references and k > lowest_relevant:
lowest_relevant... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_margin(self) -> float:\n return self.position.exchange.available_margin",
"def score_margin(self):\n if self.previous_event is None:\n score = self.score\n else:\n score = self.previous_event.score\n offense_team_id = self.get_offense_team_id()\n ... | [
"0.6683197",
"0.6535715",
"0.6526499",
"0.64784586",
"0.6443067",
"0.637917",
"0.63374513",
"0.6324491",
"0.6324483",
"0.6308849",
"0.62230015",
"0.59055555",
"0.576389",
"0.57285047",
"0.56073964",
"0.56070846",
"0.55782366",
"0.5575528",
"0.55331033",
"0.55096865",
"0.54899... | 0.6742604 | 0 |
Completes the bird's active ride. | def CompleteRide(self,endTime,endX,endY):
ride = self.currRide
ride.EndRide(endX,endY,endTime)
self.totalDistance+=ride.GetDistance()
self.totalDuration+=ride.GetDuration()
self.rides.append(ride)
self.currRide = None
self.idleTime = endTime
self.Calculat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end(self):\n # Stop driving\n self.robot.drivetrain.arcade_drive(0.0, 0.0)",
"def end(self, interrupted: bool) -> None:\n self.drive.arcadeDrive(0, 0)",
"def endCompetition(self):\n self.robot_exit = True",
"def complete(self):\n self._is_complete = True",
"def end(se... | [
"0.6222994",
"0.60794526",
"0.6044299",
"0.6004306",
"0.59830385",
"0.5944956",
"0.5893873",
"0.5867495",
"0.57774293",
"0.5750507",
"0.5740049",
"0.5732889",
"0.57264733",
"0.5721332",
"0.56923115",
"0.56396633",
"0.5600887",
"0.55898863",
"0.55898863",
"0.5544427",
"0.55334... | 0.6494587 | 0 |
Getter for distance from drop point Return | def GetDistanceFromDropPoint(self):
return self.distanceFromDropPoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self):\n return self._distance",
"def get_distance(self) -> int:\n return self.get_measurement_data().distance",
"def get_distance(start, end):\n\n\t\tloc_start, loc_end, dst_node = create_distance(start, end)\n\t\tdistance = cmds.getAttr(\"%s.distance\" % dst_node)\n\n\t\tcmds.delet... | [
"0.76265997",
"0.7575346",
"0.73508847",
"0.7346014",
"0.7258451",
"0.7191502",
"0.70774806",
"0.7016465",
"0.7005957",
"0.6948037",
"0.68207526",
"0.68057805",
"0.67899567",
"0.676611",
"0.6720881",
"0.6713946",
"0.6695198",
"0.6695198",
"0.6695198",
"0.6695198",
"0.6695198"... | 0.8377415 | 0 |
Getter for maximum wait time Return | def GetMaxWaitTime(self):
return max(self.waitTimes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MaxWaitTime(self):\r\n\t\treturn self._get_attribute('maxWaitTime')",
"def max_timeout(self):\n return self._max_timeout",
"def max_waiting(self):\n return self._max_waiting",
"def get_timeout(self) -> int:",
"def get_wait_timeout(self):\n if self.__wait_timeout is not None:\n ... | [
"0.82421374",
"0.8093026",
"0.8073709",
"0.7785421",
"0.7377285",
"0.7354005",
"0.730726",
"0.72938687",
"0.72644025",
"0.71912974",
"0.7185561",
"0.7089766",
"0.70715714",
"0.69640744",
"0.69640744",
"0.69523233",
"0.69438374",
"0.69140947",
"0.6854665",
"0.6839531",
"0.6828... | 0.81754684 | 1 |
Getter for total Duration Return | def GetTotalDuration(self):
return self.totalDuration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration(self):\n return self.duration",
"def get_duration(self):\n return self._duration",
"def Duration(self):\r\n\t\treturn self._get_attribute('duration')",
"def Duration(self):\n\t\treturn self._get_attribute('duration')",
"def duration(self):\n return self._get('duration'... | [
"0.8640967",
"0.8465019",
"0.8192792",
"0.81764585",
"0.81736344",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81567216",
"0.81281835",
"0.81279856",
"0.81210256",
"0.80905044",
"0.79546475",
"0.7880334",
"0.78671366",
... | 0.8545387 | 1 |
returns all options of the strip characters in required length | def bruteforce(strip, min_length, max_length):
return (''.join(char) for char in chain.from_iterable(product(strip, repeat=x)
for x in range(min_length, max_length+1))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sanitize(self, opts_list):\n for opt in opts_list:\n if len(opt.strip()) == 0:\n opts_list.remove(opt)\n return opts_list",
"def lstrip(self, chars=None):\n return asarray(lstrip(self, chars))",
"def filter_min_length(self, string):\n newstring = strin... | [
"0.56886077",
"0.5513566",
"0.53906834",
"0.5386568",
"0.5321687",
"0.5275547",
"0.5219687",
"0.52139086",
"0.5201099",
"0.5179651",
"0.5171791",
"0.5100026",
"0.5069645",
"0.50526756",
"0.5038516",
"0.50358015",
"0.49880165",
"0.4964224",
"0.4960884",
"0.49529618",
"0.494691... | 0.60040057 | 0 |
This function updates knownfaces dynamo table with the data derived from Slack and AWS Rekognition | def update_dynamo(username, userid, match_percentage, image_id, url, \
age, gender, smile, beard, happy, sad, angry):
put_into_dynamo = RekognitionKnown(
user_name = username,
slack_user_id = userid,
match_percentage = match_percentage,
image_id = image_id,
image_url = ur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_data():\n fetch_missingpersons = request.get_json()\n update_data = MissingPerson.query.filter_by(id=fetch_missingpersons['id']).first()\n update_data.embedding = fetch_missingpersons['embedding']\n db.session.commit()\n return jsonify(fetch_missingpersons)",
"def update_unknown_dynamo(... | [
"0.5749878",
"0.56376445",
"0.55223274",
"0.5288706",
"0.5233593",
"0.5223677",
"0.5190544",
"0.51581466",
"0.51386875",
"0.5101116",
"0.50991535",
"0.50734353",
"0.5036171",
"0.5016885",
"0.49960828",
"0.496741",
"0.49518254",
"0.4918262",
"0.49122834",
"0.49036375",
"0.4895... | 0.6076229 | 0 |
This function updates unknownfaces dynamo table with the data derived AWS Rekognition | def update_unknown_dynamo(url, age, gender, \
smile, beard, happy, sad, angry):
put_into_unknown_dynamo = RekognitionUnknown(
image_url = url,
age_range = age,
gender = gender,
is_smiling = smile,
has_beard = beard,
is_happy = happy,
is_sad = sad,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_dynamo(username, userid, match_percentage, image_id, url, \\\n age, gender, smile, beard, happy, sad, angry):\n put_into_dynamo = RekognitionKnown(\n user_name = username,\n slack_user_id = userid,\n match_percentage = match_percentage,\n image_id = image_id,\n i... | [
"0.6149813",
"0.5659518",
"0.56375855",
"0.5558385",
"0.54713255",
"0.5422148",
"0.5335955",
"0.5258836",
"0.5254008",
"0.5233241",
"0.5213646",
"0.51518",
"0.5145294",
"0.51217556",
"0.51177675",
"0.5106467",
"0.5100847",
"0.50853866",
"0.50845665",
"0.5082567",
"0.5066661",... | 0.6175062 | 0 |
Returns a default LabelStoreConfig to fill in any missing ones. | def get_default_label_store(self, scene: SceneConfig) -> LabelStoreConfig:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_config(cls):\n default = super(LSHNearestNeighborIndex, cls).get_default_config()\n\n lf_default = plugin.make_config(get_lsh_functor_impls())\n default['lsh_functor'] = lf_default\n\n di_default = plugin.make_config(get_descriptor_index_impls())\n default['descri... | [
"0.6221486",
"0.60220504",
"0.5819019",
"0.5805407",
"0.5782555",
"0.57711416",
"0.57619035",
"0.57562435",
"0.5748874",
"0.56956226",
"0.56690294",
"0.5653731",
"0.5632784",
"0.55963796",
"0.55954915",
"0.55846584",
"0.55831254",
"0.55684423",
"0.5543517",
"0.55301565",
"0.5... | 0.77048916 | 0 |
Returns a default EvaluatorConfig to use if one isn't set. | def get_default_evaluator(self) -> EvaluatorConfig:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_config():\n # pylint: disable=cyclic-import\n from raylab.agents.sac import DEFAULT_CONFIG\n\n return DEFAULT_CONFIG",
"def get_default_config(self):\n return config.read(pathlib.Path(__file__).parent / \"ext.conf\")",
"def default(self):\n return self._config... | [
"0.69978195",
"0.67205906",
"0.6683171",
"0.6621579",
"0.63026786",
"0.62763005",
"0.62488645",
"0.62030625",
"0.61780494",
"0.61780494",
"0.6141372",
"0.6116631",
"0.6102302",
"0.6101332",
"0.60781455",
"0.6034338",
"0.6029229",
"0.60245436",
"0.5991673",
"0.5976192",
"0.596... | 0.85756123 | 0 |
Visualization routine for generating a calendar visualization with Bokeh. | def _bokeh_visualization(
calendar: "Calendar",
n_years: int,
relative_dates: bool,
add_yticklabels: bool = True,
**kwargs,
) -> plotting.figure:
if add_yticklabels:
tooltips = [
("Interval", "@desc"),
("Size", "@width_days days"),
("Type", "@type"),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bokeh_dashboard_creator(dataframe):\r\n ############################################\r\n # Revenue, Impressions by Day by Partner\r\n ############################################\r\n \r\n output_file(\"dashboard.html\")\r\n \r\n df = dataframe\r\n df['Day'] = pd.to_datetime(df['Day'])\r... | [
"0.68911076",
"0.68793774",
"0.60817",
"0.6039826",
"0.5992555",
"0.5942231",
"0.5935102",
"0.58497673",
"0.58346933",
"0.57104707",
"0.56599814",
"0.565917",
"0.5641684",
"0.5613914",
"0.56110364",
"0.56102514",
"0.55630434",
"0.5560685",
"0.5560528",
"0.5540341",
"0.553218"... | 0.7399681 | 0 |
Registers a global stack transformation that merges a set of tags with whatever was also explicitly added to the resource definition. | def register_auto_tags(auto_tags: Mapping[str, str]) -> None:
pulumi.runtime.register_stack_transformation(lambda args: auto_tag(args, auto_tags)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_tags(event):\n\n add_tags_from_presets()",
"def add_tags_to_resource(ResourceId=None, Tags=None):\n pass",
"def hook_tags_for_projects(task):\n if task['project'] in TAGS_FOR_PROJECTS.keys():\n for tag in TAGS_FOR_PROJECTS[task['project']]:\n task['tags'].add(tag)",
"def au... | [
"0.5524886",
"0.54226065",
"0.51583046",
"0.51563334",
"0.50898856",
"0.506334",
"0.49708322",
"0.49250105",
"0.4869671",
"0.48399723",
"0.48346636",
"0.47867766",
"0.47468102",
"0.47392708",
"0.47238922",
"0.4723705",
"0.46952054",
"0.46935907",
"0.46483028",
"0.46255636",
"... | 0.61592054 | 0 |
Returns true if the given resource type is an AWS resource that supports tags. | def is_taggable(t: str) -> bool:
return t in taggable_resource_types | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsTagExists(self, ResourceId, TagName):\n\n try:\n if self.Service == 'ec2':\n response = self.DescribeTags(ResourceId)\n if TagName in list(map(lambda x: x['Key'], [x for x in response['Tags']])):\n return True\n elif self.Service =... | [
"0.6399579",
"0.63201123",
"0.62766284",
"0.6256046",
"0.62011147",
"0.61333555",
"0.6058019",
"0.6058019",
"0.5869327",
"0.5817959",
"0.57866144",
"0.5778956",
"0.57481205",
"0.57481205",
"0.57481205",
"0.5704926",
"0.5670921",
"0.5625209",
"0.55327207",
"0.551816",
"0.54557... | 0.7635412 | 0 |
add a file full of user agents to use The loading of more than one user agent implies the use of random user agents. | def add_user_agent(self, useragent_path):
with open(useragent_path) as wordlist_f:
for useragent in wordlist_f.read().split("\n"):
useragent = useragent.strip()
if useragent:
self.user_agents.append(useragent) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_agents(self, file_name):\n with open(file_name) as f:\n self.user_agents = json.load(f)\n self.headers[\"User-Agent\"] = random.choice(self.user_agents)",
"def add_user_agent(self, value):\n # type: (str) -> None\n self.user_agent_policy.add_user_agent(value)",... | [
"0.7073403",
"0.70005083",
"0.65844756",
"0.64439905",
"0.6365973",
"0.62721574",
"0.62331593",
"0.6203372",
"0.6203372",
"0.6193418",
"0.6089249",
"0.59869266",
"0.5959281",
"0.5702221",
"0.55101806",
"0.5510148",
"0.54230016",
"0.5420298",
"0.5412782",
"0.5324192",
"0.53180... | 0.8312047 | 0 |
Run a full attack on the domain with which we have been configured. Brute force a directory and file structure based on the wordlists with which we have been configured. | def brute(self, follow_redirects, max_depth, method="GET"):
"""TODO option to make max_depth be obeyed relative to the
last
successful dir?
ie: with max_depth 3, example.com/fail/fail/fail fails out but
once we hit example.com/fail/success/, keep going until we hit
exam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runAttacks(self,\n policy: Policy,\n outputDir: str=None):\n outputDir = policy.getOutputDir(parent=outputDir) if \\\n policy else outputDir\n\n acCache = AccessListCache.get()\n acListInst = acCache.getAccessListFromPolicy(policy)\n\n ... | [
"0.61052847",
"0.5582462",
"0.5421415",
"0.5398599",
"0.5380833",
"0.52952486",
"0.5163187",
"0.5157558",
"0.50875354",
"0.50039095",
"0.49987626",
"0.4996667",
"0.49739432",
"0.4954363",
"0.4850667",
"0.4829968",
"0.47634757",
"0.47529042",
"0.47518617",
"0.47344095",
"0.472... | 0.5599937 | 1 |
String for representing the Organization object (in Admin site etc.). | def __str__(self):
if self.name != None and self.name != '':
return self.name
else:
return "Organization object owned by %s."%(self.owner) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str('%s (%s)' % (self.company, self.owner))",
"def organization_name(self):\n if self.organization is not None:\n return self.organization.name\n\n return ''",
"def org_urn(self):\n return f\"psc:org:{self.credentials.org_key}\"",
"def organi... | [
"0.7165319",
"0.6806214",
"0.6790389",
"0.64104795",
"0.6407919",
"0.6346011",
"0.6310931",
"0.63100046",
"0.630681",
"0.6305702",
"0.6300019",
"0.62802875",
"0.6278159",
"0.6271169",
"0.626531",
"0.62608826",
"0.6247357",
"0.620912",
"0.6205226",
"0.61515045",
"0.61467075",
... | 0.76456773 | 0 |
Yields counts of character ngrams from string s of order n. | def extract_char_ngrams(self, s: str, n: int) -> Counter:
return Counter([s[i:i + n] for i in range(len(s) - n + 1)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_char_ngrams(s: str, n: int) -> Counter:\n return Counter([s[i:i + n] for i in range(len(s) - n + 1)])",
"def precook(s, n=4, out=False):\n words = s.split()\n counts = defaultdict(int)\n for k in xrange(1,n+1):\n for i in xrange(len(words)-k+1):\n ngram = tuple(words[i:i+k])\n coun... | [
"0.82485414",
"0.76264787",
"0.73532337",
"0.73268604",
"0.71129584",
"0.7092459",
"0.70224917",
"0.6941578",
"0.6845443",
"0.67267495",
"0.6712389",
"0.6680387",
"0.66529167",
"0.6583822",
"0.6576275",
"0.65749717",
"0.65712875",
"0.6563945",
"0.6559195",
"0.6554432",
"0.653... | 0.8287722 | 1 |
Yields counts of character ngrams from string s of order n. | def extract_char_ngrams(self, s: str, n: int) -> Counter:
return Counter([s[i:i + n] for i in range(len(s) - n + 1)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_char_ngrams(s: str, n: int) -> Counter:\n return Counter([s[i:i + n] for i in range(len(s) - n + 1)])",
"def precook(s, n=4, out=False):\n words = s.split()\n counts = defaultdict(int)\n for k in xrange(1,n+1):\n for i in xrange(len(words)-k+1):\n ngram = tuple(words[i:i+k])\n coun... | [
"0.82485414",
"0.76264787",
"0.73532337",
"0.73268604",
"0.71129584",
"0.7092459",
"0.70224917",
"0.6941578",
"0.6845443",
"0.67267495",
"0.6712389",
"0.6680387",
"0.66529167",
"0.6583822",
"0.6576275",
"0.65749717",
"0.65712875",
"0.6563945",
"0.6559195",
"0.6554432",
"0.653... | 0.8287722 | 0 |
Apply Gaussian noise to an input tensor. | def gaussian_noise(tensor, mean, stddev):
noise = Variable(tensor.data.new(tensor.size()).normal_(mean, std))
return tensor + noise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_noise(self, tensor):\n return tensor.new_empty(tensor.size()).normal_(std=self._discreteness)",
"def task_gaussian_noise(input_array, noise_factor):\n return(np.random.normal(0, noise_factor, input_array.shape))",
"def add_gaussian_noise(X, mu=0, sigma=0.1):\n noise = np.random.normal... | [
"0.78414464",
"0.7245466",
"0.71811473",
"0.71459424",
"0.68363976",
"0.6799063",
"0.66733646",
"0.66543114",
"0.65751487",
"0.6564241",
"0.6492763",
"0.64736784",
"0.64736784",
"0.64586484",
"0.64251614",
"0.6397649",
"0.6334172",
"0.63252485",
"0.6302892",
"0.6299813",
"0.6... | 0.7755156 | 1 |
Add a `canon` option to `f` which toggles canonicalizes the return value of `f`. | def canon(f):
@wraps(f)
def wrapped(G, H, canon=True):
game = f(G, H)
if canon:
game = canonicalize(game)
return game
return wrapped | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pony_func(func):\n func.is_pony_func = True\n return func",
"def main():\n parser = argparse.ArgumentParser(description=(\n 'Canonicalize Call Graphs to FASTEN Canonical Call Graphs'))\n parser.add_argument('directory', help=(\n 'a directory with the Call Graph, and description file... | [
"0.49801686",
"0.48075998",
"0.4801738",
"0.47585616",
"0.47026438",
"0.47009388",
"0.46868795",
"0.46559855",
"0.46223104",
"0.46175477",
"0.45939246",
"0.45530087",
"0.4538339",
"0.44475698",
"0.4445085",
"0.44408873",
"0.44223046",
"0.4421128",
"0.44015473",
"0.43992308",
... | 0.635531 | 0 |
Fast calculation of the last digit for nth fibonacci number | def get_fibonacci_last_digit_fast(n):
fibonacci = [0 for i in range(n + 1)]
fibonacci[1] = 1
for i in range(2, n + 1):
fibonacci[i] = (fibonacci[i - 1] + fibonacci[i - 2]) % 10
return fibonacci[n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fast_fibonacci(n):\n return _fast_fibonacci(n)[0]",
"def fibonacci_iterative(nth_nmb: int) -> int:\n old, new = 0, 1\n if nth_nmb in (0, 1):\n return nth_nmb\n for __ in range(nth_nmb - 1):\n old, new = new, old + new\n return new",
"def fibonacci(n):",
"def last_fib_digit(n)... | [
"0.80113834",
"0.7926261",
"0.7902663",
"0.78782165",
"0.7486979",
"0.74626005",
"0.74536633",
"0.7413848",
"0.74006814",
"0.7387231",
"0.7384485",
"0.7369879",
"0.7365468",
"0.7360676",
"0.73546636",
"0.7345966",
"0.73451585",
"0.73291713",
"0.7324162",
"0.7309868",
"0.73053... | 0.8372285 | 0 |
find any sub dict contains pattern to list | def find_dict_to_list(target, pattern):
result = []
if isinstance(target, dict):
for k, v in target.items():
if k == pattern:
result.append(v)
if isinstance(v, dict) or isinstance(v, list):
result.extend(find_dict_to_list(v, pattern))
if isinst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_pattern(d, pattern):\n\n arr = pattern.split(',')\n\n # deep first traversal\n def dfs(d, ks):\n for k, v in d.iteritems():\n deep_ks = ks + [k]\n if isinstance(v, dict):\n for x in dfs(v, deep_ks):\n yield x\n elif isinsta... | [
"0.64181477",
"0.62333",
"0.60661954",
"0.6053393",
"0.6028654",
"0.5919138",
"0.59016573",
"0.57957387",
"0.56953204",
"0.5691425",
"0.56884915",
"0.56753486",
"0.5641824",
"0.5589715",
"0.55569094",
"0.55542064",
"0.5539916",
"0.5538737",
"0.5517244",
"0.54823405",
"0.54643... | 0.66776407 | 0 |
Perform random search on hyper parameters list, saves models and validation accuracies. | def run_random_search(X, y, params, no_of_searches=1):
val_accs_list = []
for i in range(no_of_searches):
# Creating a tuple for each iteration of random search with selected parameters
params_dict = {"iteration": i + 1,
"no_of_filters": rd.choice(params["no_of_filters"]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_search(x_train, y_train, class_weights, iterations):\n # convert to dict\n class_weights = dict(enumerate(class_weights))\n model = KerasClassifier(build_fn=create_model)\n search = RandomizedSearchCV(estimator=model, param_distributions=get_param_grid(), n_jobs=-1,\n ... | [
"0.69401574",
"0.69086534",
"0.6886166",
"0.6811497",
"0.6625235",
"0.6580007",
"0.65565014",
"0.6550856",
"0.6543451",
"0.6388397",
"0.63488215",
"0.63394517",
"0.6330335",
"0.6284484",
"0.6281461",
"0.6221932",
"0.6217799",
"0.6199469",
"0.6148033",
"0.6145245",
"0.6135914"... | 0.728307 | 0 |
Open the given filepath as new document | def open_document(filepath, show=True):
k = krita.Krita.instance()
print('Debug: opening %s' % filepath)
doc = k.openDocument(filepath)
if show:
Application.activeWindow().addView(doc)
return doc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OpenFile(self,path):\n\t\tself.acad.Documents.Open(path)",
"def open( self, filename ):\r\n #http://www.oooforum.org/forum/viewtopic.phtml?t=35344\r\n properties = []\r\n properties.append( OpenOfficeDocument._makeProperty( 'Hidden', True ) ) \r\n properties = tuple( properties )\... | [
"0.71345687",
"0.7077146",
"0.6891692",
"0.6803087",
"0.6435113",
"0.6405236",
"0.6325574",
"0.6319938",
"0.63061064",
"0.62936294",
"0.62163293",
"0.6183678",
"0.6156022",
"0.613546",
"0.6112902",
"0.6065005",
"0.6061486",
"0.60015565",
"0.599104",
"0.59909385",
"0.59620774"... | 0.74578357 | 0 |
Return layers for given document | def get_layers(doc):
nodes = []
root = doc.rootNode()
for node in root.childNodes():
print('Debug: found node of type %s: %s' % (node.type(), node.name()))
if node.type() == "paintlayer":
nodes.append(node)
return nodes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetLayers(self, *args):\n return _XCAFDoc.XCAFDoc_LayerTool_GetLayers(self, *args)",
"def layers(self):\n return self['layers']",
"def layers(self):\r\n return self._flc.layers",
"def get_layers(self):\n layers = set()\n for element in itertools.chain(self.polygons, sel... | [
"0.6520093",
"0.62724316",
"0.6226186",
"0.6219585",
"0.6184488",
"0.617257",
"0.6022751",
"0.5999213",
"0.5996449",
"0.59911495",
"0.59911495",
"0.59885573",
"0.5977705",
"0.5920823",
"0.59155387",
"0.5907288",
"0.578981",
"0.577481",
"0.5718451",
"0.57168806",
"0.5716836",
... | 0.7382613 | 0 |
r"""Linear Buckling Analysis It can also be used for more general eigenvalue analyzes if `K` is the tangent stiffness matrix of a given load state. | def lb(K, KG, tol=0, sparse_solver=True, silent=False,
num_eigvalues=25, num_eigvalues_print=5):
msg('Running linear buckling analysis...', silent=silent)
msg('Eigenvalue solver... ', level=2, silent=silent)
k = min(num_eigvalues, KG.shape[0]-2)
if sparse_solver:
mode = 'cayley'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kl(self):\n weights_logvar = self.weights_logvar\n kld_weights = self.prior_stdv.log() - weights_logvar.mul(0.5) + \\\n (weights_logvar.exp() + (self.weights.pow(2) - self.prior_mean)) / (\n 2 * self.prior_stdv.pow(2)) - 0.5\n kld_bias ... | [
"0.6005177",
"0.59679455",
"0.5812458",
"0.56899565",
"0.5655882",
"0.56436425",
"0.56320107",
"0.56068176",
"0.5601498",
"0.5588093",
"0.5575658",
"0.5563244",
"0.5541758",
"0.5533754",
"0.5525226",
"0.55245745",
"0.5521456",
"0.5518431",
"0.5517133",
"0.5510947",
"0.5510646... | 0.6743835 | 0 |
Tests that the shape exceptions are not raised. | def test_blend_exception_not_raised(self, *shapes):
self.assert_exception_is_not_raised(linear_blend_skinning.blend, shapes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_filter_shape(self):\r\n self.assertRaises(AssertionError, self.validate,\r\n (3, 2, 8, 8), (4, 3, 5, 5),\r\n 'valid')",
"def test_invalid_input_shape(self):\r\n seed_rng()\r\n verbose = 0\r\n random = True\r\n p... | [
"0.6945418",
"0.6755534",
"0.67414993",
"0.6694937",
"0.6694023",
"0.66600835",
"0.66173315",
"0.6591706",
"0.6588925",
"0.6570135",
"0.655559",
"0.6552962",
"0.6538423",
"0.6515649",
"0.6501363",
"0.6500557",
"0.6499036",
"0.6486666",
"0.6479138",
"0.64725447",
"0.6472377",
... | 0.7027076 | 0 |
Test the Jacobian of the blend function. | def test_blend_jacobian_random(self):
(x_points_init, x_weights_init, x_rotations_init,
x_translations_init) = test_helpers.generate_random_test_lbs_blend()
self.assert_jacobian_is_correct_fn(
linear_blend_skinning.blend,
[x_points_init, x_weights_init, x_rotations_init, x_translations_ini... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jacobian(self, x):\n pass",
"def test_gradable_funcs(self):\n self.jit_grad_wrap(self.basic_lindblad.evaluate_rhs)(\n 1.0, Array(np.array([[0.2, 0.4], [0.6, 0.8]]))\n )\n\n self.basic_lindblad.rotating_frame = Array(np.array([[3j, 2j], [2j, 0]]))\n\n self.jit_gra... | [
"0.6469237",
"0.6433962",
"0.63694566",
"0.60735285",
"0.6070178",
"0.6053421",
"0.60161763",
"0.6014657",
"0.6007361",
"0.59562653",
"0.5943752",
"0.58451694",
"0.5841551",
"0.5827975",
"0.5810254",
"0.57658637",
"0.5765021",
"0.5762377",
"0.5761058",
"0.5746416",
"0.5742485... | 0.7760398 | 0 |
Module fixture for the IrisDataset class | def iris():
return IrisDataset() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.dataset = self.dataset_cls()",
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def test_get_iris_setosa_data(self):\n iris = get_iris_setosa_data()\n self.assertEqual(len(iris.data), 150)\n self.assertEqual(len(iris.labels), 150)",
... | [
"0.7222384",
"0.71654016",
"0.6917572",
"0.68906116",
"0.6813696",
"0.68106896",
"0.6733908",
"0.6733908",
"0.6693054",
"0.6673248",
"0.6665914",
"0.66434",
"0.6637773",
"0.6597069",
"0.6580226",
"0.6575524",
"0.65625507",
"0.65582585",
"0.6514318",
"0.64990556",
"0.6495193",... | 0.8066619 | 0 |
Test that the dataset exposes features correctly | def test_features(iris):
assert iris.num_features == 4
assert iris.feature_names == [
"sepal length (cm)",
"sepal width (cm)",
"petal length (cm)",
"petal width (cm)",
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_all_features_with_data(self):\n feature1 = Feature('looktest1')\n feature1.set_percentage(5)\n\n feature2 = Feature('looktest2')\n feature2.activate()\n feature2.add_to_whitelist(3)\n\n feature3 = Feature('looktest3')\n feature3.activate()\n feature3... | [
"0.78587687",
"0.71364605",
"0.7094765",
"0.69733465",
"0.69565916",
"0.68933004",
"0.6886788",
"0.68324894",
"0.66474664",
"0.6644134",
"0.6628947",
"0.65567976",
"0.6553603",
"0.6534997",
"0.6520395",
"0.65046775",
"0.64937705",
"0.64824164",
"0.64187455",
"0.6407952",
"0.6... | 0.74759233 | 1 |
Test that the dataset exposes targets correctly | def test_targets(iris):
assert iris.num_targets == 3
np.testing.assert_array_equal(
iris.target_names, ["setosa", "versicolor", "virginica"]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_which_targets():\n num_multi_targets = 0\n for which_targets_day in which_targets:\n # All inputs have a label\n assert np.all(which_targets_day.sum(axis=1) > 0)\n # No inputs have more than 3 targets\n assert np.all(which_targets_day.sum(axis=1) < 4)\n\n num_multi... | [
"0.69623315",
"0.67906576",
"0.6738044",
"0.6517456",
"0.64846396",
"0.6483993",
"0.6368017",
"0.6326693",
"0.6194556",
"0.61361384",
"0.61305344",
"0.60743195",
"0.60652053",
"0.60409486",
"0.6014033",
"0.6007334",
"0.5987667",
"0.5984631",
"0.5972297",
"0.5966366",
"0.59359... | 0.7648803 | 0 |
Test that the setting of feature values works as expected | def test_feature_values(iris, name, x_feature, y_feature, x_vals, y_vals):
iris.x_feature = x_feature
iris.y_feature = y_feature
assert iris.title == "{} x {}".format(x_feature, y_feature)
data = iris.sources[name].data
np.testing.assert_array_almost_equal(data["x"][:2], x_vals)
np.testing.asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_feature(feature, value, good_features):\r\n\tbase_write(good_features,\"bin/stanford-ner-2015-04-20/base.prop\")\r\n\tbase_prop = open(\"bin/stanford-ner-2015-04-20/base.prop\", \"a\")\r\n\tbase_prop.write(feature.strip() + \"=\" + str(value) + \"\\n\")\r\n\tbase_prop.close()\r\n\r\n\t#Test read base.prop... | [
"0.68222433",
"0.67018443",
"0.6689757",
"0.6671468",
"0.6527837",
"0.6522304",
"0.64916915",
"0.63647443",
"0.6364705",
"0.63577926",
"0.6188192",
"0.61652994",
"0.615353",
"0.6115886",
"0.60559314",
"0.6019748",
"0.6010639",
"0.5998711",
"0.5995934",
"0.598738",
"0.59807867... | 0.72363967 | 0 |
Find the user with the given foreign_id and return their id, or None if no such user exists. | def find_user_by_foreign_id(db, foreign_id):
users = db.tables.users
return db.load_scalar(
table=users, value={'foreign_id': foreign_id}, column='id') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_user_by_id(self, _id):\n user_resp = self._db.Users(database_pb2.UsersRequest(\n request_type=database_pb2.UsersRequest.FIND,\n match=database_pb2.UsersEntry(global_id=_id)))\n if user_resp.result_type != database_pb2.UsersResponse.OK:\n self._logger.warning(... | [
"0.70395887",
"0.6893945",
"0.68748236",
"0.6826718",
"0.6506314",
"0.64983785",
"0.63102484",
"0.62940043",
"0.62502694",
"0.62369335",
"0.6227704",
"0.6204206",
"0.6147459",
"0.6142715",
"0.6100349",
"0.6096249",
"0.6082242",
"0.6069531",
"0.6063481",
"0.6041236",
"0.604002... | 0.8142203 | 0 |
Test for graph thresholding based on the mean degree. | def test_graphs_threshold_mean_degree():
# Groundtruth
expected = np.load("groundtruth/graphs_threshold/mean_degree.npy")
# Data
graph = np.load("sample_data/graphs_threshold/graph.npy")
# Run
mean_degree_threshold = 5
binary_mask = threshold_mean_degree(graph, mean_degree_threshold)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_graphs_threshold_mst_mean_degree():\n\n # Groundtruth\n expected = np.load(\"groundtruth/graphs_threshold/mst_mean_degree.npy\")\n\n # Data\n graph = np.load(\"sample_data/graphs_threshold/graph.npy\")\n\n # Run\n tree = threshold_mst_mean_degree(graph, 3.6)\n\n # Test\n np.testing... | [
"0.7343063",
"0.6230984",
"0.6227097",
"0.59750366",
"0.592538",
"0.5885326",
"0.58132714",
"0.5791767",
"0.57543737",
"0.5753648",
"0.57160234",
"0.56842065",
"0.5601132",
"0.55997413",
"0.559663",
"0.55863345",
"0.55824107",
"0.5575837",
"0.55386645",
"0.54688543",
"0.54656... | 0.77867466 | 0 |
Test for graph thresholding based in the MST's mean degree. | def test_graphs_threshold_mst_mean_degree():
# Groundtruth
expected = np.load("groundtruth/graphs_threshold/mst_mean_degree.npy")
# Data
graph = np.load("sample_data/graphs_threshold/graph.npy")
# Run
tree = threshold_mst_mean_degree(graph, 3.6)
# Test
np.testing.assert_array_equal(e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_graphs_threshold_mean_degree():\n\n # Groundtruth\n expected = np.load(\"groundtruth/graphs_threshold/mean_degree.npy\")\n\n # Data\n graph = np.load(\"sample_data/graphs_threshold/graph.npy\")\n\n # Run\n mean_degree_threshold = 5\n binary_mask = threshold_mean_degree(graph, mean_deg... | [
"0.7577464",
"0.6088447",
"0.59741616",
"0.5968032",
"0.5943267",
"0.59310496",
"0.58874136",
"0.5818282",
"0.57937276",
"0.57740355",
"0.575114",
"0.5746745",
"0.56150544",
"0.56090194",
"0.5577418",
"0.5543613",
"0.5527074",
"0.5510839",
"0.550282",
"0.5501128",
"0.5493747"... | 0.7683516 | 0 |
Test the kcore decomposition algorithm. | def test_graphs_k_core_decomposition():
# Groundtruth
expected = np.load("groundtruth/graphs_threshold/k_cores.npy")
# Data
graph = np.load("sample_data/graphs_threshold/graph_binary.npy")
# Run
kcores = k_core_decomposition(graph, 10)
# Test
np.testing.assert_array_equal(expected, k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_determine_k(self):\n test_dir_name = os.path.dirname(__file__)\n feat_array_fn = os.path.join(\n test_dir_name, \"data\", \"four_clusters.csv\")\n df = pd.read_csv(feat_array_fn)\n feat_array = df[[\"x\", \"y\"]].values\n\n clusterer = Clusterer(feat_array_fn,... | [
"0.65353006",
"0.6201982",
"0.61541474",
"0.59206885",
"0.5893882",
"0.5891255",
"0.58582777",
"0.58117867",
"0.5787755",
"0.5753176",
"0.5752086",
"0.5741526",
"0.57332134",
"0.57115597",
"0.57095844",
"0.56855834",
"0.56358075",
"0.561449",
"0.5607308",
"0.56061035",
"0.559... | 0.78939664 | 0 |
Test for graph thresholding base on shortest paths. | def test_graphs_threshold_shortest_paths():
# Groundtruth
expected = np.load("groundtruth/graphs_threshold/shortest_paths.npy")
# Data
graph = np.load("sample_data/graphs_threshold/graph.npy")
# Run
binary_mask = threshold_shortest_paths(graph, treatment=False)
# Test
np.testing.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _importance_based_graph_cut(self, graph, threshold):\n for node, data in graph.nodes_iter(data=True):\n if float(data['importance']) < threshold:\n graph.remove_node(node)\n return",
"def test_soft_threshold():\n assert snet.soft_threshold(10, 100) == 0\n assert ... | [
"0.6131582",
"0.60717225",
"0.6015632",
"0.59195125",
"0.58422256",
"0.5766306",
"0.5730042",
"0.5726501",
"0.56735456",
"0.56374514",
"0.5626174",
"0.558326",
"0.5571611",
"0.5564247",
"0.5563607",
"0.55588573",
"0.5531529",
"0.55283445",
"0.5512286",
"0.5507463",
"0.5498243... | 0.68768716 | 0 |
Test for graph threshlding using global cost efficiency (GCE). | def test_graphs_threshold_global_cost_efficiency():
# Groundtruth
expected = np.load("groundtruth/graphs_threshold/gce.npy")
# Data
graph = np.load("sample_data/graphs_threshold/graph.npy")
# Run
iterations = 50
binary_mask, _, _, _, _ = threshold_global_cost_efficiency(graph, iterations)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_graphs_threshold_omst_global_cost_efficiency2():\n # the function is optmized at the 3rd OMST, so it is going to yeild the same results\n # as the exhaustive search\n\n # Groundtruth\n expected = np.load(\"groundtruth/graphs_threshold/omst_gce.npy\")\n\n # Data\n graph = np.load(\"sample... | [
"0.7292351",
"0.7188489",
"0.6268269",
"0.62489986",
"0.6099057",
"0.60639197",
"0.6047734",
"0.5858285",
"0.58377826",
"0.58192337",
"0.5765622",
"0.57653415",
"0.5758362",
"0.5695797",
"0.5664252",
"0.5663531",
"0.5658476",
"0.5658476",
"0.5658476",
"0.56560165",
"0.5646739... | 0.7786456 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.