query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Return x with the lowest set bit shifted to the kth bit. bit_array has only the kth bit set high indicating the bit to shift to. If there are no 1's. return 0. This can use shift_trailing_zeros() on x first because the lost 0's will be shifted back in. | def shift_lowest_set_bit_bit_array(x, bit_array):
return shift_trailing_zeros(x) * bit_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_set_bit_index(x, k):\n\n return shift_trailing_zeros(x) << k",
"def shift_lowest_unset_bit_index(x, k):\n\n if (x == -1):\n return -1\n\n return (x << k) // get_lowest_unset_bit(x)",
"def get_bits(x, k, size, offset=0):\n\n answer = x >> offset\n answer >>= k * size\n ... | [
"0.81172955",
"0.7688981",
"0.7221767",
"0.7165726",
"0.7140687",
"0.6981214",
"0.68823075",
"0.6547663",
"0.6175876",
"0.6038623",
"0.5869019",
"0.58094484",
"0.5802688",
"0.5698221",
"0.568577",
"0.5653078",
"0.56424487",
"0.56420314",
"0.56406707",
"0.56187147",
"0.5579268... | 0.7484894 | 2 |
Return x with the lowest unset bit shifted to the kth bit. bit_array has only the kth bit set high indicating the bit to shift to. If there are no 0's, return 1. This can't use shift_trailing_ones() on x first because the ones will be lost. | def shift_lowest_unset_bit_bit_array(x, bit_array):
if (x == -1):
return -1
return (x * bit_array) // get_lowest_unset_bit(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_unset_bit_index(x, k):\n\n if (x == -1):\n return -1\n\n return (x << k) // get_lowest_unset_bit(x)",
"def shift_lowest_set_bit_index(x, k):\n\n return shift_trailing_zeros(x) << k",
"def shift_lowest_set_bit_bit_array(x, bit_array):\n\n return shift_trailing_zeros(x) * bit_... | [
"0.7939114",
"0.789853",
"0.7225687",
"0.6905573",
"0.6852066",
"0.6777691",
"0.6731593",
"0.6451681",
"0.6411547",
"0.6312433",
"0.61930674",
"0.6171824",
"0.6095062",
"0.60880286",
"0.6077317",
"0.6030845",
"0.590784",
"0.5901963",
"0.58643866",
"0.5847911",
"0.5844721",
... | 0.7388597 | 2 |
Find sequences of bits, 01, in x starting from the least significant bit and return a number with the 1 bits set high. | def get_consecutive_01(x):
return get_consecutive_diff(x) & x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_bits_up(x):\n\n bit_array = get_first(x, get_consecutive_01)\n\n if (bit_array == 0):\n return x\n\n lower, upper = split_bits_bit_array(x, bit_array)\n upper = swap_bits_bit_array(upper, bit_array)\n lower = shift_trailing_zeros(lower)\n\n return upper | lower",
"def get_lowest... | [
"0.7067788",
"0.6807962",
"0.66411763",
"0.6602308",
"0.656842",
"0.65238315",
"0.64827526",
"0.6478186",
"0.64742464",
"0.6446635",
"0.6436172",
"0.64166176",
"0.6236039",
"0.6222962",
"0.61953443",
"0.6134106",
"0.6086654",
"0.60725296",
"0.605937",
"0.605937",
"0.60149497"... | 0.7280907 | 0 |
Find sequences of bits, 10, in x starting from the least significant bit and return a number with the 0 bits set high. | def get_consecutive_10(x):
return get_consecutive_diff(x) & (x >> 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_set_bit(x):\n\n return x & -x",
"def same_bits_down(x):\n\n bit_array = get_first(x, get_consecutive_10)\n\n if (bit_array == 0):\n return x\n\n lower, upper = split_bits_bit_array(x, bit_array)\n upper = swap_bits_bit_array(upper, bit_array)\n lower = shift_lowest_unset_b... | [
"0.6799342",
"0.67721915",
"0.6709165",
"0.66752625",
"0.66603327",
"0.6521347",
"0.6510911",
"0.6496508",
"0.6432418",
"0.6422279",
"0.6361035",
"0.6285963",
"0.62601966",
"0.62506896",
"0.62037855",
"0.6173778",
"0.6156148",
"0.61365587",
"0.61226743",
"0.61226743",
"0.6076... | 0.69844764 | 0 |
Return the closest number greater than x that has the same number of bits set high as x. | def same_bits_up(x):
bit_array = get_first(x, get_consecutive_01)
if (bit_array == 0):
return x
lower, upper = split_bits_bit_array(x, bit_array)
upper = swap_bits_bit_array(upper, bit_array)
lower = shift_trailing_zeros(lower)
return upper | lower | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nearest_bigger_power_of_two(x: int) -> int:\n y = 2\n while y < x:\n y *= 2\n return y",
"def _find_nearest_power_of_two(x):\n\n return 1 << (x - 1).bit_length()",
"def find_le(a, x):\n i = bisect_right(a, x)\n if i:\n return a[i - 1]\n raise ValueErr... | [
"0.7382637",
"0.7208239",
"0.68005097",
"0.6641018",
"0.6571517",
"0.647815",
"0.64246887",
"0.64161813",
"0.641301",
"0.63992244",
"0.63894033",
"0.6264416",
"0.6261741",
"0.6231588",
"0.61394876",
"0.6111848",
"0.6108794",
"0.6096718",
"0.6094866",
"0.60071176",
"0.5988731"... | 0.52831644 | 95 |
Return the closest number less than x that has the same number of bits set high as x. | def same_bits_down(x):
bit_array = get_first(x, get_consecutive_10)
if (bit_array == 0):
return x
lower, upper = split_bits_bit_array(x, bit_array)
upper = swap_bits_bit_array(upper, bit_array)
lower = shift_lowest_unset_bit_bit_array(lower, bit_array)
return upper | lower | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nearest_bigger_power_of_two(x: int) -> int:\n y = 2\n while y < x:\n y *= 2\n return y",
"def _find_nearest_power_of_two(x):\n\n return 1 << (x - 1).bit_length()",
"def find_le(a, x):\n i = bisect_right(a, x)\n if i:\n return a[i - 1]\n raise ValueErr... | [
"0.74601287",
"0.74266887",
"0.7062916",
"0.7020456",
"0.6894633",
"0.68437254",
"0.6745738",
"0.6735366",
"0.67120916",
"0.64814717",
"0.639336",
"0.634387",
"0.63037914",
"0.628311",
"0.6223773",
"0.62043256",
"0.62005055",
"0.6175473",
"0.61514",
"0.61512804",
"0.61501306"... | 0.62332255 | 14 |
Given an x, This will find and cache all solutions of numbers less than x if they haven't already been cached. Only works for x that is a power of 2 (single 1 bit). | def closure(x):
nonlocal max_shift_amount
if (x in log2_dict):
return log2_dict[x]
while (True):
max_num = 1 << max_shift_amount
log2_dict[max_num] = max_shift_amount
max_shift_amount += 1
if (x == max_num):
return lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def improve_power(x):\r\n for i in range(2,base(x)//2+1):\r\n if(base(x)%i==0):\r\n temp=base(x)\r\n n=0\r\n flag=True\r\n while(temp>1):\r\n if(temp%i!=0):\r\n flag=False\r\n break\r\n else:\r... | [
"0.6436152",
"0.6280868",
"0.6183297",
"0.6064172",
"0.6013688",
"0.5996035",
"0.597075",
"0.59644026",
"0.5933635",
"0.5919297",
"0.5878202",
"0.58426046",
"0.5817578",
"0.5813716",
"0.5774956",
"0.5702751",
"0.55902684",
"0.5587255",
"0.5564748",
"0.5549887",
"0.5536584",
... | 0.0 | -1 |
A vectorized version of diagonal. | def create_diagonal(m: NumpyRealArray) -> NumpyRealArray:
indices = (..., *np.diag_indices(m.shape[-1]))
retval = np.zeros((*m.shape, m.shape[-1]), dtype=m.dtype)
retval[indices] = m
return retval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonal(d, axis=0):\n assert d.ndim == 1\n n = d.shape[0]\n times = lambda x: d * x\n trans = lambda x: _hermitian(d) * x\n times, trans = apply_along_axis(times, trans, axis)\n return Operator(times=times, trans=trans, shape=(n,n))",
"def diagonal(nd):\n assert nd.ndim == 2, \"diagonal... | [
"0.7215263",
"0.7009191",
"0.687507",
"0.68659997",
"0.6804924",
"0.67363244",
"0.66762465",
"0.66440356",
"0.6598403",
"0.6585263",
"0.6561734",
"0.6537138",
"0.65280956",
"0.6485395",
"0.6474084",
"0.6469136",
"0.645229",
"0.64253366",
"0.6413358",
"0.63867694",
"0.63797414... | 0.67265254 | 6 |
Returns the real component of the dot product of the final n_axes axes of two arrays. | def _parameter_dot_product(x: JaxComplexArray, y: JaxComplexArray, n_axes: int) -> JaxRealArray:
axes = tuple(range(-n_axes, 0))
return jnp.sum(x * y, axis=axes).real | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TensorDot(self, axes):\r\n return lambda a, b: tensordot(a, b, axes)",
"def dot(a, b):\r\n a, b = as_tensor_variable(a), as_tensor_variable(b)\r\n\r\n if a.ndim == 0 or b.ndim == 0:\r\n return a * b\r\n elif a.ndim > 2 or b.ndim > 2:\r\n return tensordot(a, b, [[a.ndim - 1], [nu... | [
"0.63890517",
"0.6281363",
"0.6116413",
"0.6088469",
"0.6030557",
"0.5830254",
"0.5714325",
"0.56336206",
"0.5619733",
"0.55603635",
"0.5538593",
"0.5524472",
"0.5476481",
"0.5462024",
"0.54237205",
"0.5400313",
"0.53729576",
"0.53461784",
"0.53461784",
"0.5345192",
"0.534224... | 0.6892021 | 0 |
Compute the elementwise softthresholding operator on the vector w. | def soft_thresholding(w, alpha):
return np.sign(w) * np.clip(np.abs(w) - alpha, 0.0, np.inf) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def soft_threshold(self, weight, lambd):\n if weight > lambd:\n result = weight - lambd\n elif abs(weight) <= lambd:\n result = 0\n else:\n result = weight + lambd\n return result",
"def soft_threshold(X, threshold):\n X_thresholded = (np.abs(X)... | [
"0.7283324",
"0.69554687",
"0.6854548",
"0.66052395",
"0.6520113",
"0.6390546",
"0.6345883",
"0.6298518",
"0.6242295",
"0.6129075",
"0.6112855",
"0.6098119",
"0.6092725",
"0.6007954",
"0.5985637",
"0.59853303",
"0.5948113",
"0.59381634",
"0.5815257",
"0.5803847",
"0.57240176"... | 0.81232566 | 0 |
Compute maximum value for the trace norm regularization parameter. | def trace_norm_bound(X, Y, loss='square'):
if loss.lower() == 'square':
# In this case max_tau := 2/n * max_sing_val(X^T * Y)
return np.linalg.norm(np.dot(X.T, Y), ord=2) * (2.0/X.shape[0])
else:
print('Only square loss implemented so far.')
sys.exit(-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_norm() -> float:\n return 1.0",
"def maxnorm(self, priors=None):\n def maxnorm_f(x): return x.max(axis=0)\n return self.utility(maxnorm_f, priors)",
"def max_norm(f):\n return dmp_max_norm(f.rep, f.lev, f.dom)",
"def maxnorm(norm_val=7):\n weights = [v for v in tf.global_vari... | [
"0.73656726",
"0.7131809",
"0.7083843",
"0.70287853",
"0.69845635",
"0.6632864",
"0.6630386",
"0.6597505",
"0.6554116",
"0.65443385",
"0.64960605",
"0.6490095",
"0.64217657",
"0.6371413",
"0.63578606",
"0.6338208",
"0.6316915",
"0.63031405",
"0.6301157",
"0.62781334",
"0.6276... | 0.5947133 | 53 |
Compute maximum value for the l12norm regularization parameter. | def l21_norm_bound(X, Y, loss='square'):
if loss.lower() == 'square':
# In this case max_tau := 2/n * max(||[X^T * Y]s||_2)
# First compute the 2-norm of each row of X^T * Y
norm2 = map(lambda x: np.linalg.norm(x, ord=2), X.T.dot(Y))
return np.max(norm2) * (2.0/X.shape[0])
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_norm(f):\n return dmp_max_norm(f.rep, f.lev, f.dom)",
"def max_norm() -> float:\n return 1.0",
"def norm_max(vector):\n return la.norm(vector, np.inf)",
"def maxnorm(self, priors=None):\n def maxnorm_f(x): return x.max(axis=0)\n return self.utility(maxnorm_f, priors)",
"def... | [
"0.67367584",
"0.67348397",
"0.6438151",
"0.6377424",
"0.6288572",
"0.6271007",
"0.622749",
"0.6114743",
"0.6109041",
"0.61051977",
"0.6056785",
"0.6024102",
"0.6010985",
"0.59682924",
"0.5961959",
"0.59512526",
"0.5951213",
"0.5949743",
"0.59294295",
"0.59080696",
"0.5888073... | 0.5701254 | 37 |
Calculate cost to connect start value to end value. Cost function can vary. For [x, y], can use L2 distance For [x, y, theta], can use length of dubins curve connecting the two points For now, we will be using np.array([x, y]) and cost function L2 Euclidean distance. | def cost(self, start_value, end_value):
cost = np.linalg.norm(start_value - end_value)
return cost | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dist_cost(data, start_node_id, end_node_id):\n p1 = get_coords(data, start_node_id)\n p2 = get_coords(data, end_node_id)\n return great_circle_distance(p1, p2)",
"def calc_cost(self, dx, dy):\n self.distance+=np.sqrt(dx**2+dy**2)",
"def compute_cost(x, y, theta=[[0], [0]]):\n m = y.s... | [
"0.72530705",
"0.6578667",
"0.6506388",
"0.6407017",
"0.6351846",
"0.63484657",
"0.6341274",
"0.62276214",
"0.61651635",
"0.61512995",
"0.6129583",
"0.61264396",
"0.6097981",
"0.60950077",
"0.6066673",
"0.60149354",
"0.59684277",
"0.5947067",
"0.5877823",
"0.58756137",
"0.587... | 0.722262 | 1 |
Wraps hidden states in new Tensors, to detach them from their history. This prevents Pytorch from trying to backpropagate into previous input sequences when we use the final hidden states from one minibatch as the initial hidden states for the next minibatch. Using the final hidden states in this way makes sense when t... | def repackage_hidden(h):
if isinstance(h, Variable):
return h.detach_()
else:
return tuple(repackage_hidden(v) for v in h) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_hidden(self, hidden, reset_flags):\n # detach it from history (pytorch mechanics)\n if self.rnn_type in ['lstm', 'mylstm']:\n h = Variable(hidden[0].data)\n c = Variable(hidden[1].data)\n hidden = (h, c)\n for b, flag in enumerate(reset_flags):\n ... | [
"0.6448909",
"0.64456254",
"0.64244694",
"0.64038134",
"0.6347175",
"0.6340041",
"0.6335212",
"0.6257508",
"0.6257508",
"0.62368643",
"0.622279",
"0.622279",
"0.6170131",
"0.6170131",
"0.61517733",
"0.60893285",
"0.60880107",
"0.6062792",
"0.60229635",
"0.5956902",
"0.5893305... | 0.0 | -1 |
CNN 2 Model in the paper. | def cnn_2_model(input_pl, activation=tf.nn.relu, dropout=1):
kernel1 = [1, 5, num_channels, num_kernel_1]
kernel2 = [2, 7, num_kernel_1, num_kernel_2]
conv1 = conv(input_pl, kernel1, activation, 'conv_1', dropout)
# pool = tf.nn.avg_pool(conv1, ksize=[1, 1, 3, 1], strides=[1, 1, 1, 1], padding='SAME')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CNN_model():\n prob = 0.1\n model = Sequential()\n # model.add(Conv2D(filters = 32, kernel_size = (5,5),padding = 'Same',\n # activation ='relu', input_shape = (28,28,1)))\n # model.add(Conv2D(filters = 64, kernel_size = (5,5),padding = 'Same',\n # activation =... | [
"0.7059993",
"0.7035406",
"0.70304734",
"0.69980437",
"0.6958508",
"0.68194216",
"0.6810173",
"0.68030936",
"0.6790007",
"0.67856807",
"0.67842877",
"0.67632467",
"0.6749917",
"0.67450583",
"0.6742506",
"0.6734817",
"0.67202723",
"0.6717157",
"0.6626205",
"0.6622502",
"0.6621... | 0.64053595 | 48 |
Plot the confusion matrix. | def plot_confusion_matrix(conf_matrix, labels=[],
title='调制识别混淆矩阵',
cmap=cm.Blues, name=None):
plt.figure(figsize=[7, 6], dpi=160)
plt.imshow(conf_matrix, interpolation='nearest', cmap=cmap, origin='upper')
plt.title(title)
plt.colorbar()
tick_mar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot(self):\n plt.imshow(self.cm, interpolation='nearest', cmap=self.cmap)\n plt.title(self.title)\n plt.colorbar()\n tick_marks ... | [
"0.8464174",
"0.79953337",
"0.7816915",
"0.7794347",
"0.7793309",
"0.77618045",
"0.7748698",
"0.77338606",
"0.77322257",
"0.77011275",
"0.76877314",
"0.7684856",
"0.76831055",
"0.76309496",
"0.7626916",
"0.76258564",
"0.7621189",
"0.75915456",
"0.75862384",
"0.7585726",
"0.75... | 0.0 | -1 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(InitialSceneRequest, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.numberOfTSPTurtles is None:
self.numberOfTSPTurtles = 0
else:
self.numberOfTSPTurtles = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.7794795",
"0.77207875",
"0.77207875",
"0.7687243",
"0.7625947",
"0.7564293",
"0.7440383",
"0.74175525",
"0.7352349",
"0.7308313",
"0.72808266",
"0.72378874",
"0.722805",
"0.7225032",
"0.7225032",
"0.7219433",
"0.72120637",
"0.72120637",
"0.72120637",
"0.72120637",
"0.72120... | 0.6564535 | 89 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(InitialSceneResponse, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.tsp_turtles is None:
self.tsp_turtles = ''
if self.conveyor_turtle is None:
self.conv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.77949476",
"0.7720804",
"0.7720804",
"0.7686951",
"0.762662",
"0.75640523",
"0.7440169",
"0.74174535",
"0.73515964",
"0.73084396",
"0.7280321",
"0.7237698",
"0.7227384",
"0.72244126",
"0.72244126",
"0.72194636",
"0.72119427",
"0.72119427",
"0.72119427",
"0.72119427",
"0.72... | 0.6732065 | 73 |
Calculates the number density using the ideal gas law. | def number_density(pressure, temperature, volume_mixing_ratio):
return pressure*volume_mixing_ratio/(kb*temperature) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return (1e-3*self.molar_mass) * self.pressure / (gas_constant * self.temperature) # kg/m^3",
"def calculate(self, density):\n if density not in self.potential_memo:\n\n if density == 0:\n self.potential_memo[density] = 0\n else:\n ... | [
"0.72561014",
"0.6696227",
"0.6667081",
"0.6640805",
"0.6626154",
"0.6593874",
"0.64964694",
"0.64902323",
"0.64877945",
"0.63533324",
"0.63363",
"0.6312357",
"0.6284719",
"0.6246474",
"0.623407",
"0.62214065",
"0.6205838",
"0.61807144",
"0.6172896",
"0.6155815",
"0.6124698",... | 0.5725933 | 63 |
Is the status code 400 if we post without any data? | def test_post_error_status_code(self):
response = self.app.post('/mq_message', data={})
assert response.status_code == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_requests_give_400(self):\n self.assertEqual(self._request({}), 400)",
"def bad_request():\n return HttpError(400)",
"def test_post_no_content(self):\n response = self.post(title='foo')\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)",
"def test_actor... | [
"0.750491",
"0.73863155",
"0.7355892",
"0.73534197",
"0.7331296",
"0.7330567",
"0.7297969",
"0.71257865",
"0.7054845",
"0.7014537",
"0.70054436",
"0.7002047",
"0.6960216",
"0.6948585",
"0.6922446",
"0.6895458",
"0.6850946",
"0.6826066",
"0.6817643",
"0.6814133",
"0.68131423",... | 0.7209504 | 7 |
Finds the Euclidian distance between the two parameter points | def find_euc_dist(list_par1, list_par2):
# First find the squared Euclidian distance
temp_euc_dist = np.subtract(list_par1, list_par2)
euc_dist = np.sum(np.square(temp_euc_dist))
return pow(euc_dist, .5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eucl_dist(x_0, y_0, x_1, y_1):\n return sqrt((x_1 - x_0)**2 + (y_1 - y_0)**2)",
"def euclidian_distance(x1, y1, x2, y2):\n distance = sqrt(pow((x1-x2), 2)+(pow((y1-y2), 2)))\n return distance",
"def _euclidian_distance(self, x1, x2):\n a= x1-x2\n a2 = a**2\n b = np.sum(a2, axi... | [
"0.7960498",
"0.78928083",
"0.7785454",
"0.7676242",
"0.7666461",
"0.7628599",
"0.7609112",
"0.75887495",
"0.75618976",
"0.75503033",
"0.75190115",
"0.7502743",
"0.750103",
"0.74907225",
"0.746968",
"0.7459909",
"0.7441681",
"0.74408585",
"0.7430666",
"0.742604",
"0.7411086",... | 0.7470528 | 14 |
Returns EUL roll bytes. Signed 2 Bytes | def get_EUL_Roll(self):
eul_raw = self.i2c.mem_read(2, self.addr, OUT_EUL_ROLL_LSB)
eul_roll = self.sign_val(((eul_raw[1]<<8) + eul_raw[0]))/16.0
return eul_roll
#print(eul_roll) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ROL(byte, count):\n return ((byte << count) | (byte >> (32 - count))) & 0xffffffff",
"def get_EUL_Heading(self):\n eul_raw = self.i2c.mem_read(2, self.addr, OUT_EUL_HEADING_LSB)\n eul_heading = self.sign_val(((eul_raw[1]<<8) + eul_raw[0]))/16.0\n return eul_heading\n #print(eul_h... | [
"0.6063012",
"0.5671296",
"0.5660172",
"0.55400217",
"0.54170233",
"0.53477025",
"0.524055",
"0.52218497",
"0.5178764",
"0.5167341",
"0.51383674",
"0.5123206",
"0.512267",
"0.51079863",
"0.5094285",
"0.50812393",
"0.5079368",
"0.5079368",
"0.5055572",
"0.5053211",
"0.50491834... | 0.73654693 | 0 |
__init__ method for Weapon class | def __init__(self, game, player):
self.group = game.all_sprites
self.layer = player.layer
pygame.sprite.Sprite.__init__(self)
self.player = player
self.game = game
self.image = self.game.imageLoader.item_img[self.type].copy()
self.cooldown = 20 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.weapon = Weapon()\n self.armor = Armor()",
"def init_weapon(self, weapon):\n if weapon: \n self.weapon = weapon(self)\n #self.weapon.activate() #TEMP",
"def __init__(self, name, location, health):\n self.name = name\n self.loca... | [
"0.8369462",
"0.80852693",
"0.7354432",
"0.71962255",
"0.7131528",
"0.71182716",
"0.7047111",
"0.69000477",
"0.683854",
"0.68075114",
"0.67831874",
"0.6773959",
"0.6754195",
"0.67423034",
"0.67218095",
"0.6703986",
"0.6679633",
"0.66365486",
"0.6624408",
"0.6594912",
"0.65944... | 0.67438895 | 13 |
Called on an iterator to retrieve the next element, or raise StopIteration if there is no next object. | def next(self):
if self._peeked is not None:
peeked = self._peeked
self._peeked = None
return peeked
else:
line = self.proc.stdout.readline()
# Readline always returns a line suffixed by '\n', unless it reads
# EOF in which case it ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next(self):\n raise NotImplementedError(\"Iterator.get_next()\")",
"def __next__(self):\n if(self._isDone()):\n raise StopIteration\n return self._next()",
"def next(self):\n nxt = self.readentry()\n if nxt is None:\n raise StopIteration\n ret... | [
"0.8005501",
"0.78610206",
"0.7821305",
"0.77769256",
"0.77555794",
"0.7677116",
"0.765892",
"0.7594743",
"0.7568692",
"0.7558923",
"0.75551176",
"0.7552735",
"0.74972695",
"0.74184257",
"0.74184257",
"0.73977244",
"0.7383709",
"0.7310048",
"0.7306546",
"0.7249976",
"0.724997... | 0.0 | -1 |
Replaces all whitespace characters and replaces them with their ASCII variant, allowing for a query search. (just space, not tab or newline) | def make_spaces_ascii(artist_str):
while artist_str.find(' ') != -1:
artist_str = artist_str.replace(' ', '%20')
return artist_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replaceNonAsciiFromText(self, text):\n\t\treturn ''.join([i if ord(i) < 128 else ' ' for i in text])",
"def normalize_space (text):\n return RE_WS.sub (' ', text.strip ())",
"def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})",
"def to_ascii(text):\... | [
"0.6900828",
"0.64218396",
"0.6414025",
"0.6405177",
"0.63530594",
"0.634496",
"0.63419527",
"0.6308276",
"0.6281117",
"0.6274982",
"0.6226063",
"0.6202998",
"0.6193327",
"0.61430776",
"0.61347425",
"0.6126422",
"0.6122954",
"0.6096532",
"0.60694104",
"0.6041178",
"0.59977245... | 0.64547974 | 1 |
Subtract this value from the observed magnitude to get the dereddened mags | def deredden(EBV,filt):
conversion_data = ascii.read(datapath+"/stellar_param_data/sf11.txt")
assert filt in conversion_data["filter"], (filt, conversion_data["filter"])
return EBV * float(conversion_data["AB_EBV"][np.where(conversion_data["filter"]==filt)[0]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mag(self):\n raise NotImplementedError",
"def magabs(self):\n if not self.has_target():\n raise AttributeError(\"No target defined, I can't get the distance\")\n return self.mag - 5*( np.log10(self.target.distmpc*1.e6) - 1)",
"def __abs__(self):\n return self.magn... | [
"0.7099161",
"0.6983854",
"0.6963925",
"0.6914637",
"0.68374544",
"0.68124694",
"0.6752722",
"0.6706591",
"0.6634573",
"0.66089654",
"0.66069543",
"0.659518",
"0.65472317",
"0.65321046",
"0.6500544",
"0.6491778",
"0.6477429",
"0.6470317",
"0.6470317",
"0.64566755",
"0.6445291... | 0.0 | -1 |
Sets the service_vm_ovf_url of this VersionedDeploymentSpec. | def service_vm_ovf_url(self, service_vm_ovf_url):
self._service_vm_ovf_url = service_vm_ovf_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, service_vm_ovf_url=None, package_stores=None, host_type=None, host_version=None): # noqa: E501 # noqa: E501\n\n self._service_vm_ovf_url = None\n self._package_stores = None\n self._host_type = None\n self._host_version = None\n self.discriminator = None\n\n ... | [
"0.59920865",
"0.49200514",
"0.49127284",
"0.48636636",
"0.48576945",
"0.48079467",
"0.48051295",
"0.47572348",
"0.47536737",
"0.4749729",
"0.47174475",
"0.47132197",
"0.46938968",
"0.46562898",
"0.46161318",
"0.46035483",
"0.45966738",
"0.45842794",
"0.45842794",
"0.45709077",... | 0.87879884 | 0 |
Sets the host_type of this VersionedDeploymentSpec. | def host_type(self, host_type):
if host_type is None:
raise ValueError("Invalid value for `host_type`, must not be `None`") # noqa: E501
allowed_values = ["ESXI", "RHELKVM", "UBUNTUKVM"] # noqa: E501
if host_type not in allowed_values:
raise ValueError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hypervisor_type(self, hypervisor_type):\n allowed_values = [\"Unknown\", \"Hyper-V\", \"ESXi\"] # noqa: E501\n if self.local_vars_configuration.client_side_validation and hypervisor_type not in allowed_values: # noqa: E501\n raise ValueError(\n \"Invalid value for `hyp... | [
"0.58687407",
"0.5676204",
"0.5636107",
"0.5604222",
"0.5597681",
"0.5597681",
"0.5597681",
"0.5597681",
"0.5559057",
"0.5553614",
"0.5530452",
"0.5506565",
"0.55021423",
"0.5495209",
"0.54699165",
"0.54699165",
"0.5446556",
"0.54396564",
"0.5429644",
"0.54161656",
"0.5404732... | 0.7599306 | 0 |
Sets the host_version of this VersionedDeploymentSpec. | def host_version(self, host_version):
if host_version is None:
raise ValueError("Invalid value for `host_version`, must not be `None`") # noqa: E501
self._host_version = host_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hypervisor_version(self, hypervisor_version):\n\n self._hypervisor_version = hypervisor_version",
"def hyperv_host_count(self, hyperv_host_count):\n\n self._hyperv_host_count = hyperv_host_count",
"def hdp_version(self, hdp_version):\n\n self._hdp_version = hdp_version",
"def host(se... | [
"0.6517477",
"0.6271953",
"0.6178976",
"0.60648376",
"0.598329",
"0.59829396",
"0.59829396",
"0.59829396",
"0.59829396",
"0.5893912",
"0.5824103",
"0.5745678",
"0.56790274",
"0.56704205",
"0.56676763",
"0.5653232",
"0.5653232",
"0.5653232",
"0.5653232",
"0.5653232",
"0.565323... | 0.8062373 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, VersionedDeploymentSpec):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8089139",
"0.8089139",
"0.8054507",
"0.79827213",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
"0.79669285",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Argument type conversion function for an image. This just throws exceptions if the read fails. | def image(fname):
return cv2.imread(fname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_image(image_path, *args, **kwargs):\n # TODO: Implement the method\n image2 = Image.open(image_path)\n image = num.asarray(image2)\n\n return image",
"def standardize_args(img):\n if isinstance(img, np.ndarray):\n pass\n elif isinstance(img, Image.Image):\n ... | [
"0.62001646",
"0.612969",
"0.60995746",
"0.6039882",
"0.60203975",
"0.5969262",
"0.59547937",
"0.5888381",
"0.58740425",
"0.5833236",
"0.5819156",
"0.57768655",
"0.57598865",
"0.57563955",
"0.57485396",
"0.57254386",
"0.57153535",
"0.5711157",
"0.568675",
"0.56718147",
"0.566... | 0.0 | -1 |
Creates a data loader for AudioDatasets. | def __init__(self, *args, **kwargs):
super(AudioDataLoader, self).__init__(*args, **kwargs)
self.collate_fn = _collate_fn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_train_loader(self):\n # Choose the right dataset type\n if self.config_args[\"num_members\"] > 1:\n class_dataset_wrapper = dataset_wrapper.MixMoDataset\n else:\n class_dataset_wrapper = dataset_wrapper.MSDADataset\n\n # Load augmentations\n self.t... | [
"0.6753313",
"0.67081624",
"0.6566129",
"0.6525789",
"0.64995086",
"0.64633924",
"0.6463052",
"0.64046866",
"0.6393812",
"0.6380992",
"0.6355359",
"0.6344864",
"0.6339794",
"0.632222",
"0.62972176",
"0.6295378",
"0.6235412",
"0.6207986",
"0.6169932",
"0.6165656",
"0.61565197"... | 0.61544174 | 22 |
Create an empty queue. | def __init__(self):
self._head = None
self._tail = None
self._size = 0 # number of queue elements | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_empty_queue():\n return Queue(0, None, None)",
"def empty_queue():\n return Queue()",
"def empty_queue():\n return Queue()",
"def test_new_queue_is_empty(self):\n queue = Queue_()\n self.assertTrue(queue.empty())\n self.assertEqual(queue.size(), 0)",
"def new_queue() ... | [
"0.90226257",
"0.8610326",
"0.8610326",
"0.7646727",
"0.73392534",
"0.7214641",
"0.7142951",
"0.6982411",
"0.6858135",
"0.68511164",
"0.6781897",
"0.6774313",
"0.6763828",
"0.6726111",
"0.66783184",
"0.6677383",
"0.6663354",
"0.6637819",
"0.66147155",
"0.65712017",
"0.6567653... | 0.63241506 | 56 |
Return True if the queue is empty. | def is_empty(self):
return self._size == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty(self) -> bool:\n if self.queue.empty():\n return True\n else:\n return False",
"def is_empty(self):\n return len(self.the_queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
... | [
"0.9318055",
"0.93062776",
"0.93001103",
"0.93001103",
"0.9293065",
"0.92805946",
"0.92068154",
"0.91484445",
"0.91139406",
"0.9094878",
"0.9094723",
"0.90861505",
"0.9058218",
"0.9030448",
"0.9030448",
"0.900692",
"0.9004311",
"0.89929426",
"0.8943369",
"0.8826088",
"0.87624... | 0.79836136 | 74 |
Construct and return a Glyph object from a FreeType GlyphSlot. | def from_glyphslot(char, slot):
pixels = Glyph.unpack_mono_bitmap(slot.bitmap)
width, height = slot.bitmap.width, slot.bitmap.rows
top = slot.bitmap_top
# The advance width is given in FreeType's 26.6 fixed point format,
# which means that the pixel values are multiples of 64.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_glyphslot(slot):\n pixels = GlyphDecoder.unpack_mono_bitmap(slot.bitmap)\n width, height = slot.bitmap.width, slot.bitmap.rows\n return GlyphDecoder(pixels, width, height)",
"def from_hex(hexstr, width, height):\n return Glyph.from_bytes(binascii.unhexlify(hexstr.encode('ascii')), width,... | [
"0.74140483",
"0.5702164",
"0.56694275",
"0.53484464",
"0.53150856",
"0.5271623",
"0.52245706",
"0.5218816",
"0.5151952",
"0.51183033",
"0.51086444",
"0.51078814",
"0.50992495",
"0.5070932",
"0.50345296",
"0.5027067",
"0.49325493",
"0.49306303",
"0.49025193",
"0.48668978",
"0... | 0.79620373 | 0 |
SpectrumImage.show(), draws the SpectrumImage to a set of axes. Uses matplotlib's imshow() function to draw the image. This method defaults to a heat map for grayscale images. | def show(self):
axesimage = pylab.imshow(self.image)
return axesimage | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imshow(self):\n axes([0, 0, 1, 1], xticks=[], yticks=[])\n imshow(self.rgb_image())",
"def _show(self, a):\n fig = plt.figure()\n fig.set_size_inches((2, 2))\n ax = plt.Axes(fig, [0., 0., 1., 1.])\n ax.set_axis_off()\n fig.add_axes(ax)\n plt.set_cmap('h... | [
"0.7563181",
"0.72288454",
"0.71170986",
"0.70459247",
"0.7008158",
"0.7008158",
"0.7008158",
"0.69246095",
"0.6854514",
"0.6788598",
"0.67316",
"0.6719349",
"0.6704346",
"0.667625",
"0.6640072",
"0.663902",
"0.6621921",
"0.6602371",
"0.6539053",
"0.652988",
"0.651597",
"0.... | 0.6878489 | 8 |
Take an optimizer step with zerovalued gradients to allocate internal optimizer state. This helps prevent memory fragmentation by allocating optimizer state at the beginning of training instead of after activations have been allocated. | def initialize_optimizer_states(self):
for param_partition, grad_partition in zip(self.fp32_groups_flat_partition,
self.fp32_groups_gradient_flat_partition):
param_partition.grad = grad_partition
self.optimizer.step()
self.clear_hp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_optimization(self):\n\n if self.FLAGS.optimizer == \"Adam\" :\n self.solver = tf.train.AdamOptimizer(\n learning_rate = self.learning_rate,\n beta1 = self.FLAGS.beta1,\n beta2 = self.FLAGS.beta2)\n ... | [
"0.6780894",
"0.6529125",
"0.64228046",
"0.63724935",
"0.6355093",
"0.62774485",
"0.62247896",
"0.6205798",
"0.61795783",
"0.6157825",
"0.6145258",
"0.6128487",
"0.6126696",
"0.6121289",
"0.61153555",
"0.6098423",
"0.60723203",
"0.6049853",
"0.60446453",
"0.602578",
"0.601882... | 0.66747546 | 1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8193267",
"0.80943453",
"0.80284286",
"0.8018051",
"0.79932356",
"0.79901975",
"0.79797465",
"0.79750663",
"0.795993",
"0.79564947",
"0.79366505",
"0.79336995",
"0.7933488",
"0.79303867",
"0.79252106",
"0.7923493",
"0.7923058",
"0.79224193",
"0.79219115",
"0.79209906",
"0.... | 0.7827875 | 78 |
Test constructor with line value | def test_constructor_with_value(self):
line = D1Line(self.test_line)
self.assertEqual((line.gender,
line.event_swimmer_id,
line.last_name,
line.first_name,
line.nick_name,
li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_constructor_with_value(self):\n line = C2Line(self.good_line)\n self.assertEqual((line.addr_name,\n line.addr,\n line.addr_city,\n line.addr_state,\n line.addr_zip,\n ... | [
"0.81154877",
"0.77815175",
"0.7699274",
"0.7680709",
"0.7665436",
"0.74811625",
"0.74482614",
"0.6975289",
"0.6960921",
"0.6905078",
"0.6808007",
"0.6713319",
"0.66310644",
"0.65846926",
"0.6577896",
"0.6553447",
"0.65309525",
"0.6527652",
"0.65118575",
"0.6462248",
"0.64315... | 0.78696173 | 1 |
Set event_swimmer_id to none if string is empty | def test_id_no_value(self):
self.line._parse_event_swimmer_id(" ")
self.assertEqual(None, self.line.event_swimmer_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_id_no_value(self):\n self.line._parse_team_swimmer_id(\" \")\n self.assertEqual(None, self.line.team_swimmer_id)",
"def changenonetoNone(s):\r\n if s=='None':\r\n return None\r\n else:\r\n return s",
"def sid_string(self) -> Optional[str]:\n return None",
"de... | [
"0.6145716",
"0.53761524",
"0.5199217",
"0.5136455",
"0.50743586",
"0.50332975",
"0.49535152",
"0.48798093",
"0.4853502",
"0.48334295",
"0.48021665",
"0.47409275",
"0.472424",
"0.46838117",
"0.46560875",
"0.46430215",
"0.4641775",
"0.46275774",
"0.46174413",
"0.46020004",
"0.... | 0.7075262 | 0 |
Set uss_num to none if string is empty | def test_uss_num_no_value(self):
self.line._parse_uss_num(" ")
self.assertEqual(None, self.line.uss_num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_surprising_number(val, s):\n if (\n isinstance(val, (int, float)) and \"!!\" not in s\n and _contains_non_numeric_chars(s)\n ):\n return s\n return val",
"def strip_numbers(s):\n if s:\n s = u' '.join([x for x in s.split(' ') if not x.isdigit()])\n return s",
... | [
"0.56850207",
"0.5638905",
"0.5565212",
"0.5561729",
"0.55028003",
"0.5481016",
"0.53732324",
"0.53609186",
"0.5350003",
"0.53476524",
"0.53476524",
"0.5322047",
"0.53214437",
"0.5289393",
"0.5280121",
"0.52591455",
"0.521904",
"0.5181339",
"0.5144871",
"0.513138",
"0.5098078... | 0.7066071 | 0 |
Pad batch tensors to have equal length. | def pad_collate(batch):
data, labels, data_file = zip(*batch)
number_of_modalities = len(data[0]) if isinstance(data[0], list) else 1
if number_of_modalities == 1:
data = [[x] for x in data]
modality_tensors = []
for i in range(number_of_modalities):
modality_i = [torch.Te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Batch_Size_Normalization(batch, batch_len, pad_token, batch_size):\n max_length = max(batch_len)\n current_batch_len = len(batch)\n need_more = batch_size-current_batch_len\n if need_more==0:\n return batch\n\n padding_array = np.ones(max_length)*pad_token\n for i in range(need_more):\... | [
"0.7379123",
"0.737874",
"0.7376869",
"0.7280103",
"0.7222672",
"0.7210235",
"0.7153487",
"0.7137171",
"0.7054642",
"0.70357466",
"0.69880444",
"0.69281274",
"0.6841656",
"0.68321514",
"0.68230134",
"0.68148243",
"0.6792553",
"0.6786156",
"0.67223996",
"0.66813684",
"0.665356... | 0.66983366 | 19 |
Gets the DataLoader object for each type in split_dirs keys. | def get_dataloader(params, format_name='hdf5', **kwargs):
Provider = get_proper_provider(format_name)(params.modality)
return DataLoader(Provider(params.dataset_path,
seq_length=params.seq_length),
batch_size=params.batch_size,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_dataloader(types, dataset_dir, params):\n\n dataloaders = {}\n samplers = {}\n\n for split in ['train', 'val', 'test']:\n if split in types:\n path = os.path.join(dataset_dir, \"{}\".format(split))\n\n # Use the train_transformer if training data, else use eval_trans... | [
"0.6940876",
"0.67731863",
"0.67378455",
"0.66778123",
"0.66384655",
"0.6556835",
"0.64750385",
"0.63908243",
"0.63763463",
"0.6375941",
"0.636364",
"0.63344115",
"0.6333017",
"0.6306812",
"0.6293099",
"0.6292053",
"0.6282487",
"0.6255613",
"0.6255093",
"0.6230152",
"0.623015... | 0.0 | -1 |
Removes this sheet from the book. | def remove(self):
self.parent.thing.remove_sheet(self.thing)
del self.parent[self.label] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remowe_first_sheet(self):\r\n self.output_file.remove_sheet(self.output_file.get_sheet_by_name('Sheet'))\r\n self.output_sheets = self.output_file.get_sheet_names()",
"def remove_beta_sheet(self, beta_sheet):\n assert isinstance(beta_sheet, BetaSheet)\n self.beta_sheet_list.remove... | [
"0.71527797",
"0.67841434",
"0.67090696",
"0.66575694",
"0.62736917",
"0.6030811",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.6030307",
"0.5930881"... | 0.7477164 | 0 |
Returns a specific cell object. The topleft corner is row (1, 1) not (0, 0). row (int) The index of the row column (int) The index of the column. Can be a char | def getCell(self, row, column):
if ((row is None) or (column is None)):
raise NotImplementedError()
return self.thing[self.convertColumn(row = row, column = column)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cell_from_xy(self,x,y):\n return self.cell_array.item((x,y))",
"def get_cell(self, *, d, row: int, colname: str):\n return d[row, colname]",
"def get_cell(self, row, column):\n return self.sudoku_matrix[row][column]",
"def get_cell_address(row: int, column: int) -> CellAddress:\n ... | [
"0.7218831",
"0.71244186",
"0.71222556",
"0.7072182",
"0.70138144",
"0.70037436",
"0.69145685",
"0.687889",
"0.68511534",
"0.681005",
"0.67808145",
"0.67616075",
"0.6688464",
"0.66400236",
"0.6603714",
"0.6602046",
"0.6597519",
"0.65643483",
"0.6563141",
"0.6562666",
"0.65540... | 0.74050295 | 0 |
Returns a list of all openpyxl cell objects within the column Any blank cell has a value of None. All columns are the length of the longest column. To get just the desired column, make sure that trailingNone is True. column (int) Which column to retrieve (The first column is '1') | def getColumn(self, column, *, returnContents = True, trailingNone = False, useForNone = ""):
if (trailingNone):
_column = self.thing[self.convertColumn(column)]
else:
_column = self._filter_trailingNone(self.thing[self.convertColumn(column)])
if (returnContents):
return tuple(self._yie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_empty_cell():\n\n for x in range(1, 38):\n if worksheet.cell((x, 1)).value == \"\":\n date_cell = worksheet.cell((x, 1))\n description_cell = worksheet.cell((x, 2))\n payment_received_cell = worksheet.cell((x, 3))\n rent_due_cell = worksheet.cell((x, 4... | [
"0.64906555",
"0.6487999",
"0.6385009",
"0.62517726",
"0.61906064",
"0.5916992",
"0.59124744",
"0.5904393",
"0.58739495",
"0.58632445",
"0.57990235",
"0.5783211",
"0.57712686",
"0.572281",
"0.5660084",
"0.5594781",
"0.5567345",
"0.55158186",
"0.54996055",
"0.5492681",
"0.5468... | 0.5340103 | 30 |
Adds the comment to the Redmine issue with ID issueID. | def __add_comment(self, issue_id, comment):
import httplib2
http = httplib2.Http()
response, content = http.request(
uri=self.__issue_url % int(issue_id),
method='PUT',
body=comment,
headers={
'X-Redmine-API-Key': self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment(self, issue, comment):\n return self.get_jira().add_comment(issue, comment)",
"def add_comment_to_issue(self, issue, comment, visibility=None):\r\n self.jira.add_comment(issue=issue, body=comment)",
"def comment_issue(self, msg, issue_id, comment):\n self._asset_bind(msg)\n... | [
"0.73257",
"0.70137954",
"0.68585825",
"0.6716296",
"0.6716296",
"0.6631547",
"0.6377175",
"0.63602537",
"0.61842364",
"0.61399496",
"0.61260426",
"0.61260426",
"0.60978734",
"0.6041797",
"0.60292053",
"0.5981387",
"0.5958068",
"0.5817729",
"0.5814619",
"0.57856834",
"0.57638... | 0.73244345 | 1 |
Taxon at each taxonomic rank. | def taxa_at_ranks(self, tax_str):
taxa = self.taxa(tax_str)
d = {}
for rank, taxon in enumerate(taxa):
d[Taxonomy.rank_labels[rank]] = taxon | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_tax(self):\n for line in self:\n line.tax = (line.amount_untaxed * 14) / 100",
"def extant_taxa(self, taxonomy):\n\n extant_taxa = {}\n for rank_label in Taxonomy.rank_labels:\n extant_taxa.update(self.extant_taxa_for_rank(rank_label, taxonomy))\n\n ... | [
"0.6591745",
"0.65722185",
"0.6152759",
"0.61059827",
"0.60846484",
"0.6023468",
"0.59772396",
"0.58534706",
"0.58037764",
"0.56452084",
"0.5639969",
"0.5593994",
"0.55709773",
"0.5552401",
"0.55074006",
"0.54873586",
"0.54849005",
"0.5460439",
"0.54373974",
"0.5403163",
"0.5... | 0.6676119 | 0 |
Fill in missing trailing ranks in a taxonomy string. | def fill_trailing_ranks(self, taxa):
if not taxa:
return ';'.join(Taxonomy.rank_prefixes)
try:
last_rank = Taxonomy.rank_prefixes.index(taxa[-1][0:3])
except:
self.logger.error('Taxon is missing rank prefix: %s' % ';'.join(taxa))
sys.exit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_missing_ranks(self, taxa, warning=True):\n\n new_taxa = []\n prev_rank_index = -1\n for t in taxa:\n rank_index = Taxonomy.rank_index[t[0:3]]\n if rank_index == prev_rank_index + 1:\n # rank is in proper order\n new_taxa.append(t)\n ... | [
"0.6180073",
"0.5024686",
"0.4894613",
"0.48909852",
"0.4820285",
"0.47480357",
"0.46978533",
"0.46890405",
"0.46789554",
"0.4649765",
"0.46148986",
"0.4600366",
"0.4577446",
"0.45434892",
"0.45286644",
"0.45266804",
"0.4519264",
"0.45044106",
"0.44859084",
"0.44755876",
"0.4... | 0.75670624 | 0 |
Loads a json file so we know the level representation | def loadJson (self, path):
# get all lines in json, concatenate then into a big string then parse it
with open(path, "r") as file_content:
all_lines = file_content.readlines()
all_content_str = "".join(all_lines)
json_dict = json.loads(all_content_str)
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadFile(self, path):\n print(\"loading \\'{}\\',\".format(path.split('/')[-1]), end = \" \")\n with open(path, \"r\") as file_content:\n list_of_lines = file_content.readlines() # get all lines of level representation\n\n # remove '\\n' if a line has '\\n' at the end\n ... | [
"0.71594334",
"0.7046752",
"0.70141727",
"0.6997049",
"0.6942976",
"0.6935981",
"0.6928907",
"0.68924755",
"0.6887098",
"0.68759567",
"0.6863365",
"0.6858164",
"0.68485135",
"0.6844715",
"0.68417263",
"0.6835398",
"0.6826523",
"0.68254626",
"0.68251437",
"0.6824099",
"0.68055... | 0.7284341 | 0 |
Helper method to generate splits of the dataset. Use this for testing, because it will condition on everything. | def eval_splits(cls, **kwargs):
for forbidden_key in ['mode', 'split', 'conditioned_answer_choice']:
if forbidden_key in kwargs:
raise ValueError(f"don't supply {forbidden_key} to eval_splits()")
stuff_to_return = [cls(split='test', mode='answer', **kwargs)] + [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_splits(self):\n return [{\n \"split\": problem.DatasetSplit.TRAIN,\n \"shards\": 80,\n }, {\n \"split\": problem.DatasetSplit.EVAL,\n \"shards\": 2,\n }]",
"def dataset_splits(self):\n # 10% evaluation data\n return [{\n \"split\": problem... | [
"0.7578655",
"0.7469417",
"0.72909063",
"0.7217832",
"0.7111279",
"0.70836115",
"0.7071776",
"0.7061775",
"0.696951",
"0.69623065",
"0.6913932",
"0.6898058",
"0.6895078",
"0.6887773",
"0.68566227",
"0.6852289",
"0.6787522",
"0.6767026",
"0.67625654",
"0.6758735",
"0.67313075"... | 0.0 | -1 |
Gets the message of this MeshNgdResponse. | def message(self):
return self._message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_message(self, resp):\n return resp['message']",
"def get_message (self) :\n return self._message",
"def getMessage(self):\n return self.message",
"def getMessage(self):\n return self.message",
"def get_message(self):\n return self.message",
"def get_message(self... | [
"0.69570065",
"0.6864988",
"0.6730127",
"0.6730127",
"0.6695086",
"0.6695086",
"0.6692338",
"0.66370714",
"0.659771",
"0.6595932",
"0.65323853",
"0.65323853",
"0.65323853",
"0.6484927",
"0.64783746",
"0.6460742",
"0.64598835",
"0.64598835",
"0.64598835",
"0.64598835",
"0.6459... | 0.6552757 | 14 |
Gets the value of this MeshNgdResponse. | def value(self):
return self._value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMesh(self):\n return self.mesh",
"def mesh(self):\n return self._mesh",
"def mesh(self):\n return self._mesh",
"def mesh(self):\n return self._mesh",
"def mesh(self):\n return self._mesh",
"def get_mesh(self):\n return self.mesh",
"def get(self):\n ... | [
"0.60204846",
"0.59951663",
"0.59951663",
"0.59951663",
"0.59951663",
"0.59662104",
"0.58172965",
"0.55633706",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.5547011",
"0.54655... | 0.0 | -1 |
Combine two dictionaries. Return new dictionary with the combined keys and values. For any key found in both dictionaries, return the sum of the values for that key. | def combine_and_count(a: dict, b: dict) -> dict:
if not a:
return b
if not b:
return a
# check overlapping keys
overlap_keys = [key for key in a if key in b]
combined = a | b
for key in overlap_keys:
combined[key] += a[key]
return combined | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_2_dictionnaries(dict1, dict2):\n result = dict1\n for k, v in dict2.items():\n result[k] = (result.get(k) or 0) + v\n return result",
"def mergeDict(self, dict1, dict2):\n dict3 = {**dict1, **dict2}\n for key, value in dict3.items():\n if key in dict1 and key in dict2:\n ... | [
"0.8141248",
"0.8140903",
"0.8029919",
"0.79810923",
"0.781744",
"0.781744",
"0.75366545",
"0.74844635",
"0.74613774",
"0.74381983",
"0.73597294",
"0.72979605",
"0.72559404",
"0.7244606",
"0.7216469",
"0.7216469",
"0.7216469",
"0.7216469",
"0.7216469",
"0.7216469",
"0.7216469... | 0.7950228 | 4 |
Return entity instance initialized from yaml. | def from_yaml(cls, config: ConfigType) -> Self:
input_num = cls(config)
input_num.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
input_num.editable = False
return input_num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml(cls, y):\n return cls(yaml.load(y, AttrLoader))",
"def from_yaml(cls, yml: str):\n\n return cls.from_dict(feast_yaml.yaml_loader(yml, load_single=True))",
"def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> \"BotoError\":\n value = loader.construct_mapping(node, dee... | [
"0.7188681",
"0.71468115",
"0.6927489",
"0.6893341",
"0.6806494",
"0.66631764",
"0.6661101",
"0.65775186",
"0.65219146",
"0.65043527",
"0.6500774",
"0.64835626",
"0.6451249",
"0.64110464",
"0.6308947",
"0.6302471",
"0.6284188",
"0.6245343",
"0.6188916",
"0.6188916",
"0.618891... | 0.65121233 | 9 |
Return minimum allowed value. | def _minimum(self) -> float:
return self._config[CONF_MIN] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_minimum(self):\n return self._minimum",
"def _get_minimum_value(self):\n if hasattr(self, '_minimum_value'):\n return self._minimum_value\n return None",
"def getMinValue(self):\n return self.MIN_VALUE",
"def accepted_minimum(self):\n\n return self._get_... | [
"0.8182495",
"0.80751383",
"0.8072081",
"0.80290246",
"0.7966599",
"0.7966599",
"0.7907296",
"0.7907296",
"0.7781278",
"0.77261823",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.76087666",
"0.75357765",
"0.... | 0.77675605 | 9 |
Return maximum allowed value. | def _maximum(self) -> float:
return self._config[CONF_MAX] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_maximum(self):\n return self._maximum",
"def max_value(self) -> int:\n return self.__max_value",
"def max(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"max\")",
"def max(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"max\")",
"def getMaxValue(self):\n... | [
"0.82243764",
"0.82004327",
"0.8078211",
"0.8078211",
"0.8073907",
"0.80346316",
"0.80126345",
"0.79777914",
"0.7976083",
"0.7976083",
"0.79580486",
"0.78501225",
"0.7802104",
"0.7777796",
"0.769983",
"0.769983",
"0.76717114",
"0.76373667",
"0.76007354",
"0.75813156",
"0.7581... | 0.75727344 | 21 |
Return the name of the input slider. | def name(self):
return self._config.get(CONF_NAME) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"name\")",
"def name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"name\")",
"def name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"name\")",
"def name(self) -> pulumi.Input[str]:\n return pulumi.... | [
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"0.7134759",
"... | 0.0 | -1 |
Return the state of the component. | def state(self):
return self._current_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetState(self):\r\n \r\n return self.state",
"def state(self):\n return self.get_state()",
"def get_state(self):\n return self.state",
"def get_state(self):\n return self.state",
"def get_state(self):\n raise NotImplementedError",
"def get_state(self):\n ... | [
"0.8166709",
"0.8162559",
"0.8053908",
"0.8053908",
"0.80378",
"0.80378",
"0.7999457",
"0.7965796",
"0.7932596",
"0.7932596",
"0.7910408",
"0.7904956",
"0.7904956",
"0.7904956",
"0.7904956",
"0.7904956",
"0.7901738",
"0.7901738",
"0.7901738",
"0.7838164",
"0.7838164",
"0.78... | 0.0 | -1 |
Return unique id of the entity. | def unique_id(self) -> str | None:
return self._config[CONF_ID] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entity_id(self) -> str:\n return self._entity_id",
"def entity_id(self):\n return self._entity_id",
"def entity_id(self):\n return self._entity_id",
"def entity_id(self):\n return self._entity_id",
"def entity_id(self):\n return self._entity_id",
"def entity_id(self... | [
"0.80686957",
"0.7955592",
"0.7955592",
"0.7955592",
"0.7955592",
"0.7955592",
"0.7753428",
"0.7753428",
"0.7524334",
"0.7523365",
"0.75129",
"0.7507436",
"0.7507436",
"0.7506655",
"0.74909294",
"0.74909294",
"0.74909294",
"0.74909294",
"0.74909294",
"0.74909294",
"0.74909294... | 0.0 | -1 |
Return the state attributes. | def extra_state_attributes(self):
return {
ATTR_INITIAL: self._config.get(CONF_INITIAL),
ATTR_EDITABLE: self.editable,
ATTR_MIN: self._minimum,
ATTR_MAX: self._maximum,
ATTR_STEP: self._step,
ATTR_MODE: self._config[CONF_MODE],
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.828... | 0.7552181 | 68 |
Run when entity about to be added to hass. | async def async_added_to_hass(self):
await super().async_added_to_hass()
if self._current_value is not None:
return
value: float | None = None
if state := await self.async_get_last_state():
with suppress(ValueError):
value = float(state.state)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_added_to_hass(self):\n self.hass.data[DOMAIN].add_entity_id(self.entity_id)\n self.hass.data[DOMAIN].add_sensor(self)",
"async def async_added_to_hass(self):\n await super().async_added_to_hass()\n self.coordinator.entities.append(self)",
"async def async_added_to_ha... | [
"0.76451904",
"0.7508712",
"0.7296557",
"0.720137",
"0.71257126",
"0.6639102",
"0.6639102",
"0.6610183",
"0.6588459",
"0.656976",
"0.6559875",
"0.65443677",
"0.654332",
"0.6525137",
"0.6481619",
"0.6472993",
"0.6435322",
"0.6425115",
"0.64211273",
"0.63922447",
"0.6390141",
... | 0.0 | -1 |
convert a bitcoin address to binary data capable of being put in a CScript | def bitcoinAddress2bin(btcAddress):
# chop the version and checksum out of the bytes of the address
return decodeBase58(btcAddress)[1:-4] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wastefulOutput(btcAddress):\n data = b\"\"\n # Concatenate len(SCRIPT_WORDS) for 100 times to get data of 12500 bytes\n for _ in range(ITERATIONS):\n data += SCRIPT_WORDS\n ret = CScript([data, OP_DROP, OP_DUP, OP_HASH160, bitcoinAddress2bin(btcAddress), OP_EQUALVERIFY, OP_CHECKSIG])\n re... | [
"0.705168",
"0.7035165",
"0.6876201",
"0.67644745",
"0.650063",
"0.6383578",
"0.60168505",
"0.60127896",
"0.5991026",
"0.5972889",
"0.59019476",
"0.58699095",
"0.5808511",
"0.57781106",
"0.5714882",
"0.5711409",
"0.5695423",
"0.5649162",
"0.5603935",
"0.56028223",
"0.56025434... | 0.6760302 | 4 |
Return the hex string serialization of this object | def toHex(self):
return hexlify(self.serialize()).decode("utf-8") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self._hex",
"def __str__(self: Hash) -> str:\n return self.to_hex()",
"def hex_str (self):\n return \"#%02X%02X%02X\"%(self._intern[0],self._intern[1],self._intern[2])",
"def serialize(self):\n\n return str(self)",
"def hex(self) -> str:\n ret... | [
"0.79997766",
"0.76923263",
"0.75566727",
"0.75442374",
"0.75429237",
"0.7529396",
"0.74605525",
"0.7437757",
"0.74297273",
"0.7416284",
"0.7366895",
"0.7337443",
"0.7335674",
"0.7297899",
"0.7291",
"0.7287193",
"0.726211",
"0.7259314",
"0.7259314",
"0.72569907",
"0.72569907"... | 0.7878244 | 1 |
Return UTCDateTime given as seconds relative to reftime | def _seconds2utc(self, seconds, reftime=None): # same as in rf package
from collections import Iterable
from obspy import UTCDateTime as UTC
if isinstance(seconds, Iterable):
return [_seconds2utc(self, s, reftime=reftime) for s in seconds]
if isinstance(seconds, UTC) or reftime is None or secon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestampfromutc(utc):\n return (utc - datetime(1970, 1, 1)).total_seconds()",
"def get_tz_offset_seconds() -> float:\n import time\n import datetime\n tval = time.time()\n utc_offset = (datetime.datetime.fromtimestamp(tval) -\n datetime.datetime.utcfromtimestamp(tval)).total_... | [
"0.6401193",
"0.6284235",
"0.6199749",
"0.6148142",
"0.6058102",
"0.6003543",
"0.59928787",
"0.5974048",
"0.5940748",
"0.59233904",
"0.59233904",
"0.5902974",
"0.588965",
"0.58830327",
"0.5865948",
"0.58645135",
"0.5862348",
"0.58574665",
"0.5856924",
"0.5819511",
"0.57949924... | 0.6984531 | 0 |
Create a Mesh. By default, the mesh is empty, see the `cmesh` argument. | def __init__(self, name='mesh', cmesh=None):
Struct.__init__(self, name=name, nodal_bcs={}, io=None)
if cmesh is not None:
self.cmesh_tdim = [None] * 4
self.cmesh = self.cmesh_tdim[cmesh.tdim] = cmesh
self._collect_descs()
self._coors = self.cmesh.coors
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mesh(name):\n return bpy.data.meshes.new(name)",
"def createMesh(self, chem, coord_x_start, coord_y_start) :\r\n init_conc = .0\r\n self.compParDiff(chem)\r\n comp.Comp.createMeshHomo(self, 'SC', chem, init_conc, coord_x_start, coord_y_start)\r\n #self.meshes[0].setConc(... | [
"0.72003335",
"0.70130545",
"0.6565203",
"0.64967424",
"0.63513917",
"0.6299633",
"0.62533796",
"0.6171555",
"0.6022827",
"0.60142815",
"0.5993021",
"0.5985593",
"0.5959611",
"0.5903642",
"0.58940774",
"0.588155",
"0.58555686",
"0.58410794",
"0.58090335",
"0.579138",
"0.57811... | 0.66059244 | 2 |
Transform coordinates of the mesh by the given transformation matrix. | def transform_coors(self, mtx_t, ref_coors=None):
if ref_coors is None:
ref_coors = self.coors
if mtx_t.shape[1] > self.coors.shape[1]:
self.coors[:] = nm.dot(ref_coors, mtx_t[:,:-1].T) + mtx_t[:,-1]
else:
self.coors[:] = nm.dot(ref_coors, mtx_t.T) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, matrix: \"Matrix44\"):\n self.vertices = list(matrix.transform_vertices(self.vertices))\n return self",
"def transform(self, matrix: Matrix3D):\n transform = self._local_transform\n transform.transformBy(matrix)\n self._reset_cache()\n return self",
... | [
"0.7083763",
"0.6745415",
"0.6670615",
"0.65311086",
"0.6515282",
"0.6461262",
"0.64102614",
"0.6302781",
"0.6293058",
"0.6231284",
"0.6206419",
"0.6180809",
"0.61514276",
"0.6148591",
"0.6124466",
"0.61238027",
"0.60469335",
"0.60373807",
"0.6034086",
"0.60185313",
"0.597401... | 0.0 | -1 |
Calculate the mass of a molecule. | def calculate_molecular_mass(symbols):
mass = 0
for atom in symbols:
mass += atom_weigths[atom]
return mass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMolecularMass(self):\n dataDict = self.__dict__\n # get formula dictionary\n dd = {}\n for ca in self.chemAtoms:\n if isinstance(ca, ChemAtom):\n ss = ca.elementSymbol\n ii = dd.get(ss)\n if ii is None:\n dd[ss] = 1\n else:\n dd[ss] = ii + 1\n ... | [
"0.8235745",
"0.76464695",
"0.7485287",
"0.743854",
"0.73887897",
"0.73480976",
"0.72905153",
"0.71409684",
"0.71409684",
"0.71218795",
"0.7104337",
"0.7082179",
"0.7052722",
"0.70399374",
"0.70076245",
"0.6995759",
"0.69288754",
"0.69266146",
"0.6919295",
"0.6851342",
"0.684... | 0.7220322 | 7 |
Handle the 'about' page. | def about(self):
return dict(page='about') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about_page(request):\r\n return render(request, 'ez_main/about_page.html')",
"def on_about(self):\n render_about_window()",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about_page(request):\n\n return render(request, 'about_page/about_page.html')",
"d... | [
"0.79461765",
"0.7800511",
"0.77702314",
"0.77334857",
"0.77287537",
"0.76092935",
"0.7579408",
"0.7578433",
"0.75713116",
"0.75560117",
"0.7547602",
"0.75273275",
"0.7512634",
"0.75118285",
"0.75118285",
"0.7430375",
"0.7427759",
"0.7426273",
"0.7422473",
"0.7420879",
"0.739... | 0.0 | -1 |
_tearDown_ Cleanup the databases. | def tearDown(self):
self.testInit.clearDatabase()
self.testInit.tearDownCouch()
self.specGen.removeSpecs()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\r\n testing.tearDown()\r\n empty_db()",
"def tearDown(self):\r\n testing.tearDown()\r\n empty_db()",
"def tearDown(self):\r\n testing.tearDown()\r\n empty_db()",
"def tearDown(self):\r\n testing.tearDown()\r\n empty_db()",
"def tea... | [
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8765929",
"0.8719981",
"0.8690666",
"0.8611389",
"0.8611389",
"0.85164624",
"0.85114336",
"0.8506662",
"0.8447596",
"0.84388125",
"0.84388125",
"0.84388125",
"0.84388125... | 0.81512535 | 73 |
_testUpdateFailedDoc_ Verify that the update function will work correctly and not throw a 500 error if the doc didn't make it into the database for some reason. | def testUpdateFailedDoc(self):
change = ChangeState(self.config, "changestate_t")
locationAction = self.daoFactory(classname="Locations.New")
locationAction.execute("site1", pnn="T2_CH_CERN")
testWorkflow = Workflow(spec=self.specUrl, owner="Steve",
name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_client_verification_document_update(self):\n pass",
"def test_client_verification_document_partial_update(self):\n pass",
"def test_update(self):\n doc_fields = document_fields.DocumentFields({\n 'foo@': 'bar',\n })\n self.assertEquals('bar', doc_fields['f... | [
"0.78253835",
"0.72858334",
"0.7190362",
"0.70023966",
"0.69982487",
"0.68725485",
"0.6833063",
"0.6833063",
"0.6833063",
"0.6778672",
"0.6679405",
"0.66168725",
"0.6578169",
"0.65603155",
"0.6530336",
"0.65064883",
"0.6481177",
"0.64690524",
"0.644808",
"0.6393169",
"0.63695... | 0.65149593 | 15 |
Determines whether a sequence is in increasing order | def verify_increasing(seq):
# https://stackoverflow.com/questions/24577688/compare-current-item-to-next-item-in-a-python-list
for i, j in enumerate(seq[:-1]):
if j >= seq[i + 1]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_increasing(seq):\n for i in range(1, len(seq)):\n if not (seq[i-1] <= seq[i]):\n return False\n return True",
"def sequence_is_increasing(sequence, strict=False):\n\n curr = sequence[0]\n\n for i in range(1, len(sequence)):\n if (strict and curr == sequence[i]) or curr... | [
"0.8427037",
"0.8166343",
"0.76927984",
"0.734868",
"0.71327513",
"0.6900214",
"0.68963605",
"0.6861688",
"0.6835388",
"0.68322504",
"0.67820394",
"0.67689544",
"0.6765438",
"0.67531645",
"0.6734673",
"0.6660989",
"0.66602814",
"0.6657604",
"0.66474295",
"0.6609146",
"0.66084... | 0.8208438 | 1 |
Example view demonstrating rendering a simple HTML page. | def index():
context = make_context()
# Nav needs to be a list of lists.
# The inner list should only have four objects max.
# Because of reasons.
context['nav'] = []
contents = list(context['COPY']['content'])
not_yet_four = []
for idx, row in enumerate(contents):
row = dict(z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_html_page():\n\n return render_template(\"moby.html\")",
"def get(self):\n self.render('view.html')",
"def hello():\n\n return render_template(\"index.html\")",
"def hello():\n return render_template(\"hello.html\")",
"def home_demo(request):\n\n return render(request, \"home_de... | [
"0.82181305",
"0.7517457",
"0.7275192",
"0.7262132",
"0.719313",
"0.7124594",
"0.7073872",
"0.70624375",
"0.7048777",
"0.70286745",
"0.7027904",
"0.70059437",
"0.70059437",
"0.70059437",
"0.70059437",
"0.70059437",
"0.7004205",
"0.6983125",
"0.69557106",
"0.69523466",
"0.6946... | 0.0 | -1 |
VGG 19layer model (configuration "E") | def vgg19(pretrained=False,SEED=0,Ratio=0,**kwargs):
if pretrained:
kwargs['init_weights'] = False
model = MyVGG(make_layers(cfg['E'],SEED=SEED,Ratio=Ratio),**kwargs)
if pretrained:
model.load_state_dict(model_zoo.load_url(model_urls['vgg19']))
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_vgg():\n input_shape = (256, 256, 3)\n\n vgg = keras.applications.VGG19(include_top = False , input_shape = input_shape , weights=\"imagenet\")\n features = vgg.get_layer(index = 9).output\n\n model = keras.Model(inputs=[vgg.inputs], outputs=[features])\n return model",
"def vgg19(pretr... | [
"0.7938028",
"0.7352684",
"0.7322909",
"0.731347",
"0.72912514",
"0.72898996",
"0.7235066",
"0.7197585",
"0.71894604",
"0.7084843",
"0.707336",
"0.7058049",
"0.7026087",
"0.7002693",
"0.69967985",
"0.69944525",
"0.69195586",
"0.6903537",
"0.68565315",
"0.6850008",
"0.68098766... | 0.72287446 | 7 |
loads the environment variables as unicode if ascii | def _get_env(self):
env = {}
for k, v in os.environ.items():
k = k.decode() if isinstance(k, bytes) else k
v = v.decode() if isinstance(v, bytes) else v
env[k] = v
return list(env.items()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_utf8_env():\n global _CACHED_ENV\n if not _CACHED_ENV:\n # LANG are in the form of <language>[.<encoding>[@<modifier>]]\n # We want to replace the \"encoding\" part with UTF-8\n lang_re = re.compile('\\.([^@]*)')\n\n env = os.environ.copy()\n lang = env.get('LANG', DEFAULT_LANG)\n if l... | [
"0.68174326",
"0.607537",
"0.5995",
"0.592735",
"0.5890481",
"0.57966375",
"0.576268",
"0.57365036",
"0.5677684",
"0.5675128",
"0.5674164",
"0.5665332",
"0.5610122",
"0.55769527",
"0.5551566",
"0.5508509",
"0.5487707",
"0.5482668",
"0.5482668",
"0.5482668",
"0.5482668",
"0.... | 0.5602237 | 13 |
Return true or false if the text_alike_filename has the following format plain name or name.extension [azAZ09]+\.[azAZ09] | def looks_like_a_filename(text_alike_filename):
pattern = re.compile(r'^[a-zA-Z0-9_]+(\.[a-zA-Z0-9]+)?$')
res = pattern.match(text_alike_filename)
# print(res)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_filename(name):\n test = re.search(\"[A-Za-z0-9_-]+\\.xml$\", name)\n if test:\n return True\n else:\n return False",
"def is_filename_safe(file: Union[str, FileStorage]) -> bool:\n filename = _retrieve_filename(file)\n accepted_formats = '|'.join(IMAGES) #png|jpg|svg|jpeg\n ... | [
"0.6753845",
"0.6702968",
"0.66970766",
"0.66360146",
"0.6589351",
"0.6587701",
"0.6572279",
"0.65142137",
"0.65036196",
"0.6497598",
"0.6492529",
"0.648888",
"0.648888",
"0.64584535",
"0.6456749",
"0.6456749",
"0.6456749",
"0.6456749",
"0.6456749",
"0.6456749",
"0.6456749",
... | 0.8141375 | 0 |
Initializes a kalman filter for our door task. | def __init__(self):
super().__init__(
filter_models=[
DoorKalmanFilter(
dynamics_model=DoorDynamicsModel(),
virtual_sensor_model=DoorVirtualSensorModel(modalities={"image"}),
),
DoorKalmanFilter(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, initial_position, tracker_id):\n self.kf = KalmanFilter(dim_x=4, dim_z=2)\n #constant velocity model\n self.kf.F = np.array([[1,0,1,0],\n [0,1,0,1],\n [0,0,1,0],\n [0,0,0,1]])\n sel... | [
"0.6675223",
"0.64001346",
"0.63836414",
"0.6342795",
"0.6260933",
"0.6234054",
"0.6141222",
"0.6104336",
"0.60554534",
"0.6015546",
"0.59760755",
"0.5962371",
"0.59365946",
"0.59274995",
"0.59175",
"0.5891721",
"0.58340675",
"0.5830164",
"0.5735935",
"0.5686226",
"0.56768394... | 0.7161613 | 0 |
Initializes a kalman filter for our door task. | def __init__(self):
super().__init__(
dynamics_model=DoorDynamicsModel(),
virtual_sensor_model=UnimodalVirtualSensorModel(
virtual_sensor_model=[
DoorVirtualSensorModel(modalities={"image"}),
DoorVirtualSensorModel(modalities={"pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n super().__init__(\n filter_models=[\n DoorKalmanFilter(\n dynamics_model=DoorDynamicsModel(),\n virtual_sensor_model=DoorVirtualSensorModel(modalities={\"image\"}),\n ),\n DoorKalmanFilter(\... | [
"0.7161613",
"0.6675223",
"0.64001346",
"0.63836414",
"0.6342795",
"0.6260933",
"0.6234054",
"0.6141222",
"0.6104336",
"0.60554534",
"0.6015546",
"0.59760755",
"0.5962371",
"0.59365946",
"0.59274995",
"0.59175",
"0.5891721",
"0.58340675",
"0.5830164",
"0.5735935",
"0.5686226"... | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].contiguous().view(-1).float().sum(0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.7642171",
"0.7419321",
"0.74184227",
"0.72697616",
"0.7244972",
"0.7244229",
"0.7236948",
"0.7220481",
"0.72104603",
"0.7058168",
"0.68511814",
"0.6786012",
"0.67824614",
"0.67672175",
"0.6726138",
"0.6716942",
"0.6716942",
"0.6716942",
"0.6716942",
"0.6716942",
"0.6716942... | 0.0 | -1 |
Add PATCH functionality to this view. This is used for stopping runs. | def partial_update(self, request, pk=None):
is_stop_requested = request.data.get("is_stop_requested", False)
if is_stop_requested:
run = self.get_object()
if request.user != run.user and not admin_check(request.user):
raise PermissionDenied
run.reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"def patch(self , request , pk = None ):\r\n return Response({'method':'patch'})",
"def patch(self, request, pk=None):\n return Response({'message': 'patch'})",
"def patch(self, request, pk=None):\n ret... | [
"0.7517506",
"0.70199686",
"0.69271934",
"0.68737185",
"0.68737185",
"0.68737185",
"0.68408567",
"0.6828234",
"0.68018633",
"0.6797646",
"0.6791992",
"0.67674315",
"0.67398554",
"0.66893077",
"0.66383755",
"0.6631079",
"0.6630312",
"0.6628961",
"0.6605391",
"0.658333",
"0.655... | 0.6890169 | 3 |
Create an empty card of a particular card model. | def _create_card(self, model: str) -> Any:
return self.anki.notes.Note(self.collection, self._get_card_model(model)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def card(self, card_id):\r\n return Card(self, card_id)",
"def createCard(self,id,name):\n card = Card(id,name)\n self.cards[id] = card\n print('Created Card:'+id)",
"def card(self):\r\n return Card(self)",
"def card(self):\r\n return Card(self)",
"def define_card(... | [
"0.63758403",
"0.6333159",
"0.6278323",
"0.6278323",
"0.6023709",
"0.60157084",
"0.600055",
"0.5968151",
"0.5930574",
"0.59105617",
"0.5858807",
"0.58322024",
"0.5814797",
"0.58024824",
"0.5769492",
"0.5767015",
"0.5759708",
"0.57563055",
"0.5754465",
"0.5737209",
"0.5696707"... | 0.68346184 | 0 |
Encoder This encoder is suposed to be used for the GAN, but is trained with an AE (in the future) Important, image is in the range 1>1 so tanh is better. | def build_encoder(img_shape):
input_img = Input(shape=(img_shape))
x = Conv2D(16, (3, 3), activation='tanh', padding='same')(input_img)
x = AveragePooling2D((2, 2), padding='same')(x)
x = Conv2D(8, (3, 3), padding='same')(x)
x = LeakyReLU()(x)
x = AveragePooling2D((2, 2), padding='same')(x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _define_encoder(self):\n self.encoder = nn.Sequential(View((-1, 64 * 64 * 3)),\n nn.Linear(64 * 64 * 3, 5120, bias=False), nn.SELU(),\n nn.BatchNorm1d(5120),\n nn.Linear(5120, 2560, bias=False), nn.SELU(),\n ... | [
"0.70092016",
"0.68606234",
"0.6664062",
"0.65556484",
"0.64206916",
"0.6338161",
"0.6299144",
"0.62907165",
"0.6276112",
"0.6257006",
"0.6232343",
"0.62044555",
"0.6142367",
"0.6121027",
"0.6120764",
"0.6096476",
"0.6094113",
"0.6091391",
"0.60878855",
"0.60513806",
"0.60485... | 0.68002105 | 2 |
Consumes a provided lines iterable and generates two dictionaries; the | def parse(lines):
blob_info = defaultdict(list, {})
i = None
for i, line in enumerate(lines):
ld = line.split('%')
# parse the first block with the generic stats
lda = ld[0].split()
blob_info['frame'].append(int(lda[0]))
blob_info['time'].append(float(lda[1]))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dicts_from_lines(lines):\n lines = iter(lines)\n for line in lines:\n line = line.strip()\n if not line:\n continue # skip empty lines\n try:\n data = loads(line)\n if isinstance(data, list):\n yield from data\n else:\n ... | [
"0.6847552",
"0.6587984",
"0.6279775",
"0.62760764",
"0.6211252",
"0.60864145",
"0.6083683",
"0.60629565",
"0.6060881",
"0.60061836",
"0.5922",
"0.5893264",
"0.58711493",
"0.5846545",
"0.5833173",
"0.5787795",
"0.5767019",
"0.56974125",
"0.56803966",
"0.566032",
"0.5641493",
... | 0.0 | -1 |
Convert pydantic object to pandas dataframe with 1 row. | def to_df(self):
return pd.DataFrame([dict(self)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_df(self):\r\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n from ..df import DataFrame\n\n return DataFrame(self)",
"def pandas_convert(self):\n data = {}\n\n for names in self.data[0]:\n col_values = []\n\n if names in objects:\n ... | [
"0.75817996",
"0.7210344",
"0.7195528",
"0.7187567",
"0.71487796",
"0.7104129",
"0.71013093",
"0.7047505",
"0.69818395",
"0.6981776",
"0.6981776",
"0.69500226",
"0.6906501",
"0.68661636",
"0.68262136",
"0.681778",
"0.67798555",
"0.67733806",
"0.6754019",
"0.673979",
"0.672651... | 0.75378114 | 4 |
Compare bet_color to color rolled. Compares bet_number to number_rolled. | def check_results(bet_tup, res_tup):
colors = ["red", "green", "black"]
if colors.count(bet_tup[1]) > 0:
if bet_tup[1] == res_tup[1]:
print("You've guessed the right color!\n")
return(1)
else:
print("Sorry, but you didn't win this round.\n")
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_ball():\n number_rolled = random.randint(0, 37)\n if green.count(number_rolled) > 0:\n color_rolled = \"green\"\n elif red.count(number_rolled) > 0:\n color_rolled = \"red\"\n elif black.count(number_rolled) > 0:\n color_rolled = \"black\"\n\n print(\"\\nNumber: %i - Co... | [
"0.6314155",
"0.5852918",
"0.56200504",
"0.55386335",
"0.55365914",
"0.5506635",
"0.54299164",
"0.5399716",
"0.5368567",
"0.5350033",
"0.5339468",
"0.5275112",
"0.5271157",
"0.5267614",
"0.52111787",
"0.521065",
"0.5208023",
"0.5197349",
"0.5192846",
"0.51685864",
"0.51602167... | 0.54501295 | 6 |
Returns distance between two nodes and first step to go from source to destination | def get_path_between(self, source_name, destination_name):
node1 = self.__graph[source_name]
return node1.distance_vectors[destination_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_distance(self, node1, node2):\n if node1 == node2:\n return 0.0\n for i, (n1, n2) in enumerate(zip(self.paths[node1], self.paths[node2])):\n if n1 != n2:\n break\n else:\n i = min(len(self.paths[node1]), len(self.paths[node2]))\n ... | [
"0.7749197",
"0.7547646",
"0.75096387",
"0.73309463",
"0.729498",
"0.72741884",
"0.71237767",
"0.7031545",
"0.6993948",
"0.698453",
"0.69457555",
"0.6933379",
"0.69315684",
"0.68566525",
"0.6842347",
"0.6838722",
"0.68144524",
"0.67809415",
"0.6770598",
"0.67567325",
"0.67119... | 0.67382646 | 20 |
Encode the variances from the priorbox layers into the ground truth boxes we have matched (based on jaccard overlap) with the prior boxes. | def encodeOffset(matched, priors, variances):
# dist b/t match center and prior's center
g_cxcy = (matched[:, :2] + matched[:, 2:])/2 - priors[:, :2]
# encode variance
g_cxcy /= (variances[0] * priors[:, 2:])
# match wh / prior wh
g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode(predictions, priors, variances):\n\n boxes = np.concatenate((\n priors[:, :2] + predictions[:, :2] * variances[0] * priors[:, 2:4],\n priors[:, 2:4] * np.exp(predictions[:, 2:4] * variances[1])), 1)\n boxes[:, :2] = boxes[:, :2] - (boxes[:, 2:4] / 2)\n boxes[:, 2:4] = boxes[:, 2:4... | [
"0.62356186",
"0.56595784",
"0.5566457",
"0.5536374",
"0.5532042",
"0.54951286",
"0.5469494",
"0.54234946",
"0.5395803",
"0.53630805",
"0.5340503",
"0.5330754",
"0.52742666",
"0.5259185",
"0.5257322",
"0.5251552",
"0.5229743",
"0.5211053",
"0.5198361",
"0.51439697",
"0.513725... | 0.0 | -1 |
Returns the path where the tranquility data resides | def get_tranquility_path():
return os.path.join(get_appdata(), 'CCP\\EVE\\d_eve_sharedcache_tq_tranquility') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_path(self):\n raise NotImplementedError",
"def get_data_file():\n base_folder = os.path.dirname(__file__)\n # print(base_folder)\n return os.path.join(base_folder, 'data', 'Sacramentorealestatetransactions.csv')\n # print(filename)",
"def get_data_path():\n return os.getcwd() + \... | [
"0.68108493",
"0.6776257",
"0.6717757",
"0.66783464",
"0.6615651",
"0.65978396",
"0.6532679",
"0.6512564",
"0.650768",
"0.64584935",
"0.6388672",
"0.63867676",
"0.6355863",
"0.63534456",
"0.63334453",
"0.6314213",
"0.6304332",
"0.6293955",
"0.62707067",
"0.6265282",
"0.624098... | 0.86091894 | 0 |
Returns the path where the singularity (test servers) data resides | def get_singularity_path():
return os.path.join(get_appdata(), 'CCP\\EVE\\d_eve_sharedcache_sisi_singularity') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_dir(self):\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
"def get_test_data_path():\n return os.path.abspath(os.path.join(os.path.dirname(__file__), \"data\") + os.path.sep)",
"def get_data_path():\n\n import rospkg\n rospack = rospkg.RosPack()\n r... | [
"0.689176",
"0.68752277",
"0.6826224",
"0.6808145",
"0.67875546",
"0.67234045",
"0.6666171",
"0.66503364",
"0.6642868",
"0.661631",
"0.6607416",
"0.65869087",
"0.6577042",
"0.65536505",
"0.64990926",
"0.64725065",
"0.64258796",
"0.64037913",
"0.6391898",
"0.6390964",
"0.63881... | 0.68830234 | 1 |
Cleans the name so that Windows style paths work | def _clean_name(self, name):
# Useful for windows' paths
return os.path.normpath(name).replace("\\", "/") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_filename(name):\n return re.sub(\"[^\\\\w .]\", \"\", name)",
"def __sanitize(name):\n if name[-1] == \"/\":\n return name[:-1]\n return name",
"def cleanup(name):\n cleaned_name = name.rstrip(\".\")\n return cleaned_name",
"def sanitize_name(name):\n # For now... | [
"0.7700949",
"0.7493401",
"0.7414225",
"0.74007595",
"0.7356507",
"0.72371477",
"0.71944344",
"0.71189123",
"0.71096957",
"0.6981848",
"0.6970165",
"0.6962509",
"0.69461536",
"0.6934848",
"0.69067216",
"0.69067216",
"0.69067216",
"0.6898055",
"0.68861467",
"0.6871665",
"0.685... | 0.88445467 | 0 |
Function to create dataset | def create_dataset():
dataset_id = "{}.airflow".format(client.project)
dataset = bigquery.Dataset(dataset_id)
dataset.location = "US"
dataset = client.create_dataset(dataset, exists_ok=True)
print("Created dataset {}.{}".format(client.project, dataset.dataset_id))
return dataset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateDataset(all_arrays):\n dataset = Dataset()\n\n dataset._addData(all_arrays[0])\n dataset._addData(all_arrays[1])\n dataset._addData(all_arrays[3])\n dataset._addData(all_arrays[5])\n dataset._addData(all_arrays[6])\n dataset._addData(all_arrays[9])\n dataset._addData(all_arrays[8]... | [
"0.80316406",
"0.76356494",
"0.758953",
"0.75594234",
"0.7472125",
"0.7440938",
"0.73792076",
"0.7338542",
"0.7336027",
"0.7326048",
"0.7315646",
"0.7253376",
"0.72182333",
"0.7169486",
"0.7137896",
"0.71180344",
"0.71141946",
"0.7082076",
"0.7058421",
"0.7031606",
"0.7030648... | 0.6831411 | 37 |
Returns first element in the queue | def first(self):
if self.head is None:
raise Exception("nothing in queue")
return self.head.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\n\t\tif self.is_empty():\n\t\t\traise Empty('Queue is empty')\n\t\treturn self._head._element",
"def first(self):\r\n if self.is_empty():\r\n raise Empty(\"Queue is empty\")\r\n return self._head._element",
"def first(self):\n if self.is_empty():\n ra... | [
"0.8792036",
"0.8708514",
"0.8556915",
"0.84382343",
"0.8417255",
"0.8403848",
"0.8394608",
"0.8207264",
"0.80663913",
"0.8039438",
"0.8039438",
"0.7944739",
"0.79284596",
"0.791463",
"0.7896296",
"0.78960013",
"0.7872681",
"0.78687465",
"0.7844356",
"0.7829399",
"0.7818829",... | 0.8595159 | 2 |
Take 1D float of array of rewards and compute discounted reward | def discount_rewards(r):
discounted_r = np.zeros_like(r)
running_add = 0
for t in reversed(xrange(0, r.size)):
if r[t] != 0: running_add = 0 # reset the sum, since this was a game boundary (pong specific)
running_add = running_add * gamma + r[t]
discounted_r[t] = running_add
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discount_rewards(rewards):\r\n discounted_r = np.zeros_like(rewards)\r\n running_add = 0\r\n for t in reversed(range(0, len(rewards))): \r\n running_add = running_add * reward_discount + rewards[t]\r\n discounted_r[t] = running_add\r\n return discounted_r",
"def discoun... | [
"0.8068518",
"0.7798866",
"0.7758832",
"0.7717114",
"0.75833684",
"0.7575054",
"0.7568929",
"0.75573033",
"0.7524417",
"0.74810696",
"0.746744",
"0.74551773",
"0.74216056",
"0.7415085",
"0.7400264",
"0.73900735",
"0.7348287",
"0.73278886",
"0.73054653",
"0.72650945",
"0.72628... | 0.7226867 | 21 |
Update weights and biases according to AdaGrad | def weight_update_rmsprop(self, network):
epsilon = 10e-8
gamma = self.gamma
one_m_gamma = 1.0 - gamma
if self.ms_b is None or self.ms_q is None:
self.ms_b = []
self.ms_q = []
self.ms_rx_inp = []
self.ms_ry_inp = []
self.ms_rx_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(architecture,grad_weights,grad_bias,m,v,t,lr,optimizer=\"adam\"):\n \n for layer in range(len(architecture)):\n if not (grad_weights['layer{}'.format(layer+1)] is None) and grad_bias['layer{}'.format(layer+1)] is not None:\n grad_weightsi = grad_weights['layer{}'.format(l... | [
"0.74755186",
"0.7223262",
"0.69291246",
"0.68865",
"0.68412465",
"0.6830536",
"0.68074393",
"0.6750053",
"0.6721393",
"0.6695431",
"0.66789967",
"0.66256344",
"0.6591257",
"0.65555865",
"0.6548036",
"0.65374243",
"0.6513318",
"0.650187",
"0.6492452",
"0.64878166",
"0.6473543... | 0.0 | -1 |
Update weights and biases according to rmsprop with momentum | def weight_update_rmsprop_momentum(self, network):
epsilon = self.epsilon
gamma = self.gamma
one_m_gamma = 1.0 - gamma
beta = self.beta
if self.ms_b is None or self.ms_q is None:
self.ms_b = []
self.ms_q = []
self.ms_rx_inp = []
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_update_rmsprop(self, network):\n epsilon = 10e-8\n gamma = self.gamma\n one_m_gamma = 1.0 - gamma\n\n if self.ms_b is None or self.ms_q is None:\n self.ms_b = []\n self.ms_q = []\n self.ms_rx_inp = []\n self.ms_ry_inp = []\n ... | [
"0.7340508",
"0.690206",
"0.6863346",
"0.6495758",
"0.647224",
"0.6402086",
"0.63942695",
"0.6316046",
"0.631317",
"0.6280217",
"0.62417406",
"0.62158674",
"0.61977464",
"0.619257",
"0.61747086",
"0.61640763",
"0.61144495",
"0.61099356",
"0.61084396",
"0.60995615",
"0.6084168... | 0.7471555 | 0 |
Update weights and biases according to rmsprop with momentum | def weight_update_adadelta(self, network):
gamma = self.gamma
one_m_gamma = 1.0 - gamma
small = 0.001
if self.ms_b is None or self.ms_q is None:
self.ms_b = []
self.ms_q = []
self.ms_rx_inp = []
self.ms_ry_inp = []
self.ms_rx_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_update_rmsprop_momentum(self, network):\n epsilon = self.epsilon\n gamma = self.gamma\n one_m_gamma = 1.0 - gamma\n beta = self.beta\n\n if self.ms_b is None or self.ms_q is None:\n self.ms_b = []\n self.ms_q = []\n self.ms_rx_inp = []\... | [
"0.7471555",
"0.7340508",
"0.690206",
"0.6863346",
"0.6495758",
"0.647224",
"0.6402086",
"0.63942695",
"0.6316046",
"0.631317",
"0.6280217",
"0.62417406",
"0.62158674",
"0.61977464",
"0.619257",
"0.61747086",
"0.61640763",
"0.61144495",
"0.61099356",
"0.61084396",
"0.60841686... | 0.60995615 | 20 |
Returns indices of image and augmentation given index of generation. | def __get_img_augm_idx__(self, idx: int):
images_done = idx * self.batch_size
return divmod(images_done, self.gen_count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_img_indices():\n if K.image_dim_ordering() == 'th':\n return 0, 1, 2, 3\n else:\n return 0, 3, 1, 2",
"def _create_img_id_to_idx(self):\n with h5py.File(self.image_features_path, 'r') as features_file:\n coco_ids = features_file['ids'][()]\n coco_id_to_index =... | [
"0.6926184",
"0.64022267",
"0.6388406",
"0.6386086",
"0.6359846",
"0.62075347",
"0.6106384",
"0.6085727",
"0.608424",
"0.60077935",
"0.5993575",
"0.5974468",
"0.5966956",
"0.5932461",
"0.591079",
"0.591079",
"0.591079",
"0.59102404",
"0.5909854",
"0.5895196",
"0.58738106",
... | 0.6450925 | 1 |
Hash a password for storing. | def hash_password(password):
salt = hashlib.md5(password.encode())
return salt.hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_password(self):\n self.__password = self.str_to_hash(self.__password)",
"def hash_password(self, password):\n self.password = pwd_context.encrypt(password)",
"def hash_password(self, password):\n self.password_hash = generate_password_hash(password)",
"def hash_passwd(password, ... | [
"0.847967",
"0.8346137",
"0.82644516",
"0.80417943",
"0.7999399",
"0.7979167",
"0.7947968",
"0.7919728",
"0.78821445",
"0.78162515",
"0.77545875",
"0.77411246",
"0.766462",
"0.76507545",
"0.76267356",
"0.75862885",
"0.75638247",
"0.755944",
"0.7549114",
"0.75445807",
"0.75196... | 0.7971465 | 6 |
Get the name of the waveform file as a string | def getWaveformFileName(self):
return self.waveform_info.split(":")[1][:20] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetFileSaveName(WaveMetaData):\n FileName = WaveMetaData.SourceFilename()\n sanitizeFile = FileName.replace(\" \",\"_\")\n ext = HDF5Util.DEFAULT_HDF5_EXTENSION\n return \"X{:s}_{:d}_{:s}{:s}\".format(sanitizeFile,\n int(WaveMetaData.TimeCreated()),\n ... | [
"0.7547779",
"0.75173306",
"0.7205143",
"0.7138938",
"0.7066071",
"0.6992246",
"0.6991281",
"0.6990922",
"0.69805264",
"0.6967774",
"0.6921745",
"0.69200885",
"0.68759245",
"0.6873407",
"0.6849128",
"0.6849128",
"0.6833352",
"0.6810818",
"0.68074435",
"0.6801086",
"0.6797121"... | 0.8456967 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.