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 |
|---|---|---|---|---|---|---|
Apply pytorch's numpy() to all tensors in this container. | def numpy(self):
for key, value in self.__dict__.items():
self.__dict__[key] = value.numpy()
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numpy(self) -> np.ndarray:\n return self.tensor.numpy()",
"def numpy(x):\n if isinstance(x, torch.Tensor):\n x = x.detach().cpu().numpy()\n elif isinstance(x, tf.Tensor):\n x = x.numpy()\n return x.astype(np.float64)",
"def numpy_call(self, *args: numpy.array, **kwargs: numpy... | [
"0.7050513",
"0.67372775",
"0.6470698",
"0.6256704",
"0.6256704",
"0.6159221",
"0.6120382",
"0.6105047",
"0.6089257",
"0.600709",
"0.5993618",
"0.59524715",
"0.5920927",
"0.57963824",
"0.5777872",
"0.5756638",
"0.5746586",
"0.56652826",
"0.5582875",
"0.5530412",
"0.55053324",... | 0.6605963 | 2 |
Returns whether the stack is empty. | def empty(self) -> bool:
return len(self.q1) >= 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.the_stack) == 0",
"def is_empty(self):\n return len(self.stack) == 0",
"def empty(self) -> bool:\n return len(self.stack) == 0",
"def isEmpty(self):\n return len(self.stack) == 0",
"def empty(self):\n return len(self.stack) == 0",
"... | [
"0.9207258",
"0.91276956",
"0.90185934",
"0.9000551",
"0.89481044",
"0.89481044",
"0.8914844",
"0.8904091",
"0.8881541",
"0.88791907",
"0.8867761",
"0.87955654",
"0.8768181",
"0.8748518",
"0.87393755",
"0.8728073",
"0.8719241",
"0.87090814",
"0.87090814",
"0.85431594",
"0.850... | 0.0 | -1 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.8221727",
"0.8220911",
"0.8220911",
"0.8220911",
"0.8220911",
"0.81940746",
"0.81111443",
"0.80852413",
"0.79712725",
"0.78637785",
"0.7659569",
"0.72363365",
"0.71586627",
"0.71513546",
"0.71513546",
"0.71502376",
"0.71502376",
"0.7140211",
"0.7135492",
"0.7126684",
"0.71... | 0.8161616 | 29 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return (e_x / e_x.sum()) * 100 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.0 | -1 |
Compute the mean and standarddeviation with sum and squaresum. This method also maintains the moving average on the master device. | def _compute_mean_std(self, sum_, ssum, size):
assert size > 1, 'BatchNorm computes unbiased standard-deviation, which requires size > 1.'
mean = sum_ / size
sumvar = ssum - sum_ * mean
unbias_var = sumvar / (size - 1)
bias_var = sumvar / size
self.running_mean = (1 - se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_std_calc(dataloader):\n mean = 0\n std = 0\n samples = 0\n for data, _, _ in dataloader:\n batch_samples = data.size(0)\n data = data.view(batch_samples, data.size(1), -1)\n mean += data.mean(2).sum(0)\n std += data.std(2).sum(0)\n samples += batch_samples\n\... | [
"0.66462785",
"0.64786965",
"0.64267075",
"0.64203566",
"0.6418312",
"0.6347366",
"0.62360185",
"0.62356174",
"0.6232282",
"0.62295747",
"0.62187797",
"0.6194624",
"0.61598617",
"0.6144616",
"0.6137827",
"0.61261624",
"0.61238027",
"0.61215687",
"0.6107176",
"0.60992616",
"0.... | 0.7329819 | 0 |
Remove all BPS (Bands, People, Setlist) entries for this show. | def clear_bps(self, show_id):
for band in ShowsOtherBands.query.filter_by(ShowID=show_id).all():
db.session.delete(band)
for person in ShowsPeopleMapping.query.filter_by(ShowID=show_id).all():
db.session.delete(person)
for setlist in ShowsSongsMapping.query.filte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all_wells(self):\n self.wells = []",
"def deleteBolts(self):\n a = self.get_bolts()\n for i in self.get_bolts():\n if i.y>GAME_HEIGHT:\n a.remove(i)\n self.set_plyrbolts(0)\n elif i.y<=-BOLT_HEIGHT:\n a.remove(i)",... | [
"0.63737714",
"0.6121931",
"0.5946539",
"0.58252776",
"0.5700144",
"0.5693185",
"0.5645602",
"0.562517",
"0.56059253",
"0.5601287",
"0.5601287",
"0.5587865",
"0.55781394",
"0.5577015",
"0.55397683",
"0.55282784",
"0.5525994",
"0.5524189",
"0.5520914",
"0.55065125",
"0.5489033... | 0.7064796 | 0 |
Error messages are prefaced with [STDERR]. | def test_matl_error_handling(self, logger: Logger, mocker: MockerFixture) -> None:
task = OctaveTask()
task.session_id = "123"
handler = OutputHandler(task)
logger.addHandler(handler)
send_func = mocker.patch("matl_online.tasks.OutputHandler.send")
errmsg = "MATL run-ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_err(msg):\n print(msg, file=sys.stderr)",
"def printerr(msg):\n print(msg, file=sys.stderr)",
"def log_err(msg):\n msg = 'ERROR: {0}\\n'.format(msg)\n sys.stderr.write(msg)",
"def eprint(errmsg):\n print(errmsg, file=STDERR)",
"def error(message):\n print(message, file=sys.stder... | [
"0.72245663",
"0.71898955",
"0.7165053",
"0.71384954",
"0.7119173",
"0.7086841",
"0.69864136",
"0.6986005",
"0.6959528",
"0.69459236",
"0.6938232",
"0.69247705",
"0.68971133",
"0.6886008",
"0.687208",
"0.6836156",
"0.68293613",
"0.6817481",
"0.681233",
"0.6791641",
"0.6791444... | 0.0 | -1 |
Sample an action from an action probability distribution output by the policy network. | def __sample_policy_action(probs):
# Subtract a tiny value from probabilities in order to avoid
# "ValueError: sum(pvals[:-1]) > 1.0" in numpy.multinomial
probs = probs - np.finfo(np.float32).epsneg
action_indexes = [int(np.nonzero(np.random.multinomial(1, p))[0]) for p in probs]
######... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def act(observation):\n current_policy = sess.run(policy, {observation_: [observation]})\n action = np.random.choice(action_size, p=current_policy[0])\n return action",
"def sample_action(policy, state):\n nS, nA = policy.shape\n all_actions = np.arange(nA)\n return np.random.choice(all_actions, p=po... | [
"0.7927682",
"0.78702253",
"0.78041124",
"0.74795485",
"0.7469959",
"0.7424221",
"0.7419444",
"0.7416112",
"0.741265",
"0.73738307",
"0.73725945",
"0.73670685",
"0.73599637",
"0.73405933",
"0.7316091",
"0.7311871",
"0.7306006",
"0.7279277",
"0.72479177",
"0.7214168",
"0.71813... | 0.74728686 | 4 |
Get variables to record during simulation. Returns | def get_vars_to_record(self):
vars_to_record = []
if any({'spiketrains', 'spikerates', 'correlation', 'spikecounts',
'hist_spikerates_activations'} & self._plot_keys) \
or 'spiketrains_n_b_l_t' in self._log_keys:
vars_to_record.append(str('spikes'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_variables(self):\n\t\treturn self.variables",
"def get_variables(self):\n return [self.g_t, self.m_t]",
"def getVariables(self):\n statVars = [self[vn] for vn in self.statVars]\n timeVars = [self[vn] for vn in self.timeVars]\n return statVars + timeVars",
"def get_variables(se... | [
"0.7280395",
"0.7114551",
"0.6989882",
"0.6989056",
"0.6961578",
"0.6958487",
"0.69002414",
"0.6894577",
"0.6826803",
"0.6781089",
"0.6767439",
"0.6723185",
"0.6701707",
"0.66958815",
"0.6643457",
"0.663752",
"0.6595439",
"0.65801805",
"0.6514942",
"0.64942634",
"0.6468738",
... | 0.713675 | 1 |
Generate JWT Token for test authentication. | def generate_access_token(user_id, is_expired=False):
iat = datetime.datetime.utcnow()
return jwt.encode({
'sub': user_id, # Subject of this token
'iat': iat, # Issued at
'exp': iat + datetime.timedelta(hours=1) # Expired a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_jwt_token(self):\n import jwt\n from datetime import datetime, timedelta\n from django.conf import settings\n\n dt = datetime.now() + timedelta(days=60)\n\n token = jwt.encode({\n 'id': self.pk,\n 'username': self.username,\n 'exp': ... | [
"0.83058345",
"0.82918435",
"0.81699115",
"0.79178643",
"0.7912147",
"0.7807201",
"0.77179766",
"0.7675893",
"0.76463836",
"0.76463836",
"0.76463836",
"0.7559545",
"0.75385803",
"0.75092405",
"0.7504505",
"0.74325085",
"0.7415941",
"0.7385624",
"0.73287976",
"0.7273556",
"0.7... | 0.63344246 | 95 |
Generate a random string of fixed length | def random_string(string_length=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for _ in range(string_length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8680464",
"0.8573714",
"0.85486245",
"0.85297275",
"0.85209286",
"0.84331024",
"0.8432044",
"0.84157014",
"0.84120053",
"0.8389201",
"0.8345882",
"0.8343962",
"0.83406156",
"0.83348686",
"0.83240855",
"0.82986933",
"0.82911193",
"0.8281826",
"0.82818025",
"0.82811046",
"0.... | 0.7778832 | 82 |
Plot the lift vector as a kernel density estimation. This is a private function. For a public interface, see plot_positive_lift(). | def _plot_positive_lift(self, numerator_name, denominator_name):
lift = self.lift[numerator_name][denominator_name]
ax = sns.kdeplot(lift, shade=True)
line = ax.get_lines()[0]
x, y = line.get_data()
mask = x > 0
x, y = x[mask], y[mask]
ax.fill_between(x, y1=y, alp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(sigma, strikes, dips):\n values, vectors = principal(sigma)\n sigma1, sigma2, sigma3 = vectors\n\n fig = plt.figure()\n ax = fig.add_subplot(111, projection='stereonet')\n plt.hold(True)\n ax.density_contourf(strikes, dips)\n #ax.pole(strikes, dips, 'b.')\n ax.line(sigma1[0],sigma1... | [
"0.5444048",
"0.53254974",
"0.5290202",
"0.5228908",
"0.51871353",
"0.5185597",
"0.51764834",
"0.5174385",
"0.51722497",
"0.5166236",
"0.5132964",
"0.5050319",
"0.501193",
"0.5001828",
"0.49989724",
"0.4973415",
"0.495442",
"0.49384078",
"0.4923361",
"0.48951834",
"0.48850557... | 0.6817418 | 0 |
Returns a list with the indices of the nonabsorbing states of the matrix m | def getTransientStates(m):
t= list(range(len(m)))
for r in range(len(m)):
if(sum(m[r])==0): t.remove(r)
return t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAbsorbingStates(m):\n\t\n a=[]\n for r in range(len(m)):\n if(sum(m[r])==0): a.append(r)\n return a",
"def non_masked_indices(mask):\n\treturn np.nonzero(np.ravel(mask-1,order='C'))[0]",
"def allowed_positions(self, curr_state):\n return [i for i, val in enumerate(curr_state) if np.... | [
"0.74737734",
"0.6273748",
"0.6081004",
"0.6081004",
"0.6081004",
"0.5884089",
"0.5731453",
"0.5705016",
"0.5695767",
"0.5660442",
"0.56407326",
"0.5636819",
"0.5619551",
"0.5594982",
"0.5540036",
"0.55303717",
"0.5521208",
"0.55203396",
"0.54813194",
"0.5477717",
"0.54296315... | 0.67774504 | 1 |
Compares two JSON values for equality | def compare_json(json1, json2):
return JsonType.eq(json1, json2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_json(js1, js2):\n return js1.items() <= js2.items()",
"def compare_json_to_json(json1, json2): # , json_object, filters):\n return ordered(json1) == ordered(json2)",
"def __eq__(self, other) -> bool:\n if json.dumps(self.data,sort_keys=True) == json.dumps(other.data,sort_keys=True):\n... | [
"0.82151186",
"0.79170644",
"0.7396203",
"0.71702",
"0.6966213",
"0.692302",
"0.65704304",
"0.656646",
"0.64911",
"0.6481012",
"0.6456275",
"0.6456275",
"0.6439256",
"0.6424932",
"0.64065677",
"0.6404577",
"0.6372428",
"0.6308959",
"0.63035566",
"0.63012934",
"0.6256624",
"... | 0.8457077 | 0 |
Checks that the real path of `path2` is inside `path1`. | def check_relpath(path1, path2, exception=True):
p1 = op.normpath(path1)
p2 = op.normpath(op.join(path1, path2))
if op.relpath(p1, p2).endswith(op.basename(p1)):
if exception:
raise ValueError("Invalid path '%s'" % path2)
return False
return p2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _issubpath(self, a, b):\n p1 = a.rstrip(os.sep).split(os.sep)\n p2 = b.rstrip(os.sep).split(os.sep)\n return p1[:len(p2)] == p2",
"def is_subpath(path: Path, other: Path):\n try:\n Path(path).relative_to(other)\n except ValueError:\n return False\n else:\n r... | [
"0.7348888",
"0.7168463",
"0.70453674",
"0.6925065",
"0.69230103",
"0.6644422",
"0.6269746",
"0.625992",
"0.6188712",
"0.618065",
"0.61572427",
"0.6140488",
"0.60960907",
"0.6062624",
"0.60051584",
"0.6004871",
"0.59513336",
"0.5907477",
"0.5897944",
"0.58460873",
"0.5807989"... | 0.74305385 | 0 |
Returns word_list with words removed, that were likely read incorrectly. Or come from somerhing that wasn't supposed to be read in the first place. | def remove_garbage(word_list, garbage_method = 'char_confidence', garbage_threshold = 0.85, height = None, **kwargs):
if garbage_method is None:
return word_list
elif garbage_method == 'char_confidence':
#Caluclate average character confidence
for word in word_list:
word... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bad_word_list(self):\n self.bad_words = self.read_word_file(self.bad_word_file)",
"def rm_stop_words(self, words):\n return [word for word in words if word.lower() not in self.stopwords]",
"def remove_unsuitable_words(words):\n\n max_length = Board.SIZE\n return [word for wo... | [
"0.75039864",
"0.68356854",
"0.68268657",
"0.6726498",
"0.6712652",
"0.669339",
"0.6674355",
"0.66189545",
"0.66034395",
"0.65762395",
"0.6546424",
"0.6536305",
"0.6529826",
"0.6515039",
"0.6488991",
"0.6475345",
"0.6472976",
"0.6472613",
"0.6436441",
"0.64308923",
"0.6422168... | 0.0 | -1 |
Merges list of words into one. | def merge_cluster(word_list, merge_method = None):
#Calculates average of property of list of dictionaries.
def avg(l, key):
s = 0
for w in l:
s+= w[key]
return s / len(l)
result = {}
result['longleft'] = avg(word_list, 'longleft')
result['longright'] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_words(w, z):\n\n list_w = list(w)\n list_z = list(z)\n\n return recursive_build_list(\"\", list_w, list_z)",
"def merge_words(sequences):\n results = []\n for seq in sequences:\n words = \" \".join(seq)\n results.append(words)\n return results",
"def word_join(self, wo... | [
"0.71951133",
"0.70604545",
"0.6652419",
"0.6483666",
"0.6456939",
"0.6455576",
"0.6123326",
"0.6006835",
"0.59596854",
"0.59460866",
"0.59044945",
"0.5888816",
"0.5880894",
"0.58382314",
"0.58344173",
"0.5833595",
"0.5814909",
"0.58103395",
"0.58005226",
"0.5780524",
"0.5774... | 0.0 | -1 |
Merges padding of ZeroPadding2D and Convolution2D | MaxPooling2D | AveragePooling2D layer | def optimize(self, graph: Graph) -> Tuple[Graph, bool]:
# this optimization is always applied (since backends do not implement padding)
flag_changed = False
for tail_layer in [Convolution2D, MaxPooling2D, AveragePooling2D]:
matches = search_sub_structure(graph, [ZeroPadding2D, Varia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_conv_layers_bn_padding(self): ## 20 Convs, used for pretrained by IMAGE Net 1000 class\n conv = nn.Sequential(\n nn.Conv2d(in_channels=3, out_channels=64, kernel_size=7, stride=2, padding=3, bias=False), # padding=3 so, output is 224.\n nn.BatchNorm2d(64),\n nn.Lea... | [
"0.7022112",
"0.69777626",
"0.6659854",
"0.65137196",
"0.65080684",
"0.64650005",
"0.63808006",
"0.626055",
"0.62506133",
"0.62506133",
"0.62428194",
"0.6233859",
"0.62205845",
"0.62169003",
"0.6200956",
"0.6194681",
"0.6192606",
"0.61797595",
"0.6153535",
"0.6136569",
"0.610... | 0.0 | -1 |
Evaluates a given xpath expression against a given node and returns the first result or None if there are no results. | def getXpathOptionalNode(elem, xpath):
valueElems = elem.xpath(xpath)
if len(valueElems) > 0:
return valueElems[0]
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xpath(elt, xp, ns, default=None):\n \n res = elt.xpath(xp, namespaces=ns)\n if len(res) == 0: return default\n else: return res[0]",
"def xpath(elt, xp, ns, default=None):\n \n res = elt.xpath(xp, namespaces=ns)\n if len(res) == 0: return default\n else: return res[0]",
"def find(el... | [
"0.692793",
"0.692793",
"0.6924378",
"0.6770427",
"0.67206484",
"0.65070736",
"0.6431222",
"0.6343448",
"0.62507474",
"0.61280894",
"0.60473865",
"0.6046977",
"0.60401464",
"0.6009245",
"0.59925634",
"0.5989543",
"0.594469",
"0.5931862",
"0.57995486",
"0.57659215",
"0.5748138... | 0.6890114 | 3 |
Returns the ModelStat queryset for this Stat | def _get_model_queryset(self, date=timezone.now().date()):
_kwargs = self._get_manager_kwargs(date)
try:
model_obj, created = ModelStat.objects.get_or_create(**_kwargs)
except ModelStat.MultipleObjectsReturned:
# Race condition detected.
# try to merge all ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(cls):\n return cls.model._default_manager.all()",
"def get_queryset(self):\n return Measurement.objects.all()",
"def get_queryset(self):\n return ReadStats.objects.filter(user=self.request.user)",
"def get_queryset(self):\n return self.model.objects.all()",
"def get... | [
"0.67512923",
"0.66309273",
"0.64449465",
"0.63718694",
"0.6307163",
"0.62458825",
"0.623093",
"0.6118509",
"0.60971016",
"0.60894823",
"0.6074114",
"0.59311545",
"0.589475",
"0.5892084",
"0.58806956",
"0.5861497",
"0.584629",
"0.5831853",
"0.5761274",
"0.5739863",
"0.5726331... | 0.6794354 | 0 |
Euclidean distance between current pose and the goal. | def euclidean_distance(self, goal_pose):
return sqrt(pow((goal_pose.x - self.pose.x), 2) +
pow((goal_pose.y - self.pose.y), 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(self, goal_pose):\n\t\treturn sqrt(pow((goal_pose.x - self.pose.x), 2) +\n\t\t\t\t pow((goal_pose.y - self.pose.y), 2))",
"def euclidean_distance(self):\n return sqrt(pow((self.goal_pose.x - self.ground_truth_pose.x), 2) +\n pow((self.goal_pose.y - self.ground_... | [
"0.84976757",
"0.8286828",
"0.76960045",
"0.73938185",
"0.7165636",
"0.6998838",
"0.6989489",
"0.6879274",
"0.6778549",
"0.6766484",
"0.67339146",
"0.67335176",
"0.6725434",
"0.6725434",
"0.6725434",
"0.6725434",
"0.6725434",
"0.6725434",
"0.6725434",
"0.67160606",
"0.6687794... | 0.8481381 | 1 |
Return a static 200 OK response. | def ping_response():
return Response("ok", status=200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root():\n return Response(\"It's alive!\", status=200)",
"def response_ok(body, content_type):\n headers = {\n \"Content-Length\": len(body),\n \"Content-Type\": content_type,\n }\n response = Response(200, \"OK\", body=body, headers=headers)\n\n return response.return_response_s... | [
"0.71800315",
"0.681691",
"0.68165326",
"0.67884004",
"0.6744858",
"0.6724145",
"0.67228824",
"0.6634929",
"0.65743613",
"0.65438306",
"0.65379614",
"0.6535778",
"0.6526113",
"0.65248907",
"0.6511375",
"0.65031135",
"0.6484859",
"0.64418674",
"0.64399076",
"0.6439768",
"0.643... | 0.74615145 | 0 |
We'd first load half of the dummy data for the given city. We'd then load the whole data set. We expect that the old data is fully replaced with the new one | def test_update(self):
metadata = self.metadata_sofia # the metadata'd stay the same
places_initial_batch = dict(
list(self.places_sofia.items())[:len(self.places_sofia) // 2]) # get the first half of a dict
load_to_datastore(places=places_initial_batch, metadata=metadata)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n if city == 'chicago':\n city_df = pd.read_csv('chicago.csv')\n elif city == 'new york city':\n city_df = pd.read_csv('new_york_city.csv')\n else:\n # city_df = pd.read_csv('washington.csv')\n print(\"else is running\")\n\n print(city_df.hea... | [
"0.6551829",
"0.6503957",
"0.64861834",
"0.640927",
"0.6382879",
"0.63787067",
"0.6366296",
"0.6344441",
"0.6331917",
"0.6326113",
"0.6321885",
"0.6313767",
"0.6303727",
"0.6297733",
"0.6266999",
"0.6260142",
"0.6258054",
"0.62452614",
"0.6239858",
"0.6238182",
"0.62272274",
... | 0.0 | -1 |
Loads masks from dataset. | def load_mask(self, image_id):
# load image infos
info = self.image_info[image_id]
patch_path = info['path']
height = info['height']
width = info['width']
mag_path = os.path.join(patch_path,"mag")
tissue_path = os.path.join(patch_path,"tissue")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_mask(self, image_id):\n info = self.image_info[image_id]\n mask_paths = glob.glob(info['path'].replace('images', 'masks').replace('.png', '*.png'))\n masks = []\n class_ids = []\n for mask_path in mask_paths:\n# print(mask_path)\n mask = cv2.imread... | [
"0.7305298",
"0.722336",
"0.718072",
"0.71522343",
"0.71456295",
"0.7088234",
"0.7076364",
"0.6956015",
"0.69180125",
"0.67707175",
"0.6725268",
"0.6724248",
"0.66833884",
"0.6676314",
"0.66598105",
"0.66520643",
"0.6649231",
"0.6624163",
"0.661632",
"0.6581018",
"0.65769225"... | 0.6725806 | 10 |
Splits up a DataFrame into train and test sets. ============ | def data_split(self, test_size=0.2, stratify=None):
return train_test_split(
self, test_size=test_size, random_state=42, stratify=stratify
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_test_split(df, test_size=0.3):\r\n # split df here\r\n train_size = int(df.shape[0] * (1 - test_size))\r\n test_size = df.shape[0] - train_size\r\n train = df[:train_size]\r\n test = df[train_size:]\r\n\r\n return train, test # return the train and test datasets\r",
"def splitting_df... | [
"0.82248056",
"0.81863195",
"0.81436044",
"0.8073969",
"0.78963536",
"0.7892499",
"0.78856504",
"0.78234833",
"0.77969587",
"0.77424717",
"0.7735196",
"0.77239436",
"0.7634888",
"0.76220816",
"0.7533184",
"0.7509559",
"0.74060285",
"0.73831785",
"0.7360377",
"0.7296296",
"0.7... | 0.0 | -1 |
Takes `outputs`, which are a set of values about to be returned from the current module. If `_qtensor_info` attributes do not already exist on any tensors in `outputs`, this function adds them, initializing the dtype to `torch.float`. This allows us to reason about module output dtypes even if the last op in the module... | def _first_call_assign_qtensor_infos_to_mod_outputs(
self,
outputs: Any,
qtensor_id: List[int],
) -> Any:
# TODO: handle objects with deeper nested tensors
if isinstance(outputs, torch.Tensor):
self._first_call_assign_qtensor_infos_to_mod_outputs_tensor(outputs, q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _maybe_mod_outputs_dtype_transform(\n self,\n outputs: Any,\n ) -> Any:\n if not self.needs_dtype_transform_on_outputs:\n return outputs\n\n if isinstance(outputs, torch.Tensor):\n qtensor_info = self.output_qtensor_infos[0]\n if self.output_dtype... | [
"0.7234004",
"0.6778822",
"0.6767061",
"0.6478161",
"0.64146495",
"0.604019",
"0.58449084",
"0.5618533",
"0.5605903",
"0.5590267",
"0.5581455",
"0.55696774",
"0.5568241",
"0.5552041",
"0.5516331",
"0.5471985",
"0.5444533",
"0.54123664",
"0.5408028",
"0.5408028",
"0.53826886",... | 0.72056925 | 1 |
Takes `outputs` which are about to be returned from this module to the caller. If this module has restrictions on the dtypes of tensors it has to return, does the dtype conversion. Otherwise, does nothing. | def _maybe_mod_outputs_dtype_transform(
self,
outputs: Any,
) -> Any:
if not self.needs_dtype_transform_on_outputs:
return outputs
if isinstance(outputs, torch.Tensor):
qtensor_info = self.output_qtensor_infos[0]
if self.output_dtypes is not None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputs_convert_hook(\n self,\n outputs: Any,\n ) -> Any:\n outputs = self._maybe_mod_outputs_dtype_transform(outputs)\n return outputs",
"def set_needs_dtype_transform_on_outputs(self):\n self.needs_dtype_transform_on_outputs = False\n\n if not len(self.output_qt... | [
"0.7660219",
"0.7137217",
"0.6946627",
"0.64697677",
"0.6188353",
"0.6143662",
"0.59642446",
"0.5778277",
"0.5743891",
"0.5681654",
"0.56685454",
"0.5659667",
"0.56383216",
"0.56383216",
"0.56159514",
"0.5574802",
"0.5568728",
"0.5468316",
"0.54544806",
"0.544662",
"0.544662"... | 0.8121109 | 0 |
Yeilds files matching pattern found in root and its subdirectories. An exception is thrown if root doesn't exist. | def LocateFiles(pattern, root=os.curdir):
for path, _, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walk_recursive(root, pattern='*.py'):\r\n for root, dirnames, filenames in os.walk(root):\r\n for filename in fnmatch.filter(filenames, pattern):\r\n yield os.path.join(root, filename)",
"def list_and_filter(self, pattern, root_path):\n for path, dirs, files in os.walk(os.path.abspath... | [
"0.67759204",
"0.67616934",
"0.6670386",
"0.66505307",
"0.6456412",
"0.6372018",
"0.6330972",
"0.62085027",
"0.6173305",
"0.6150569",
"0.61061627",
"0.61045414",
"0.6094112",
"0.6089785",
"0.6079915",
"0.6041841",
"0.6026217",
"0.60221183",
"0.60220826",
"0.60140896",
"0.5991... | 0.67182815 | 2 |
Finds the desired object's parent, searching upward from the start_dir. Searches within start_dir and within all its parents looking for the desired directory or file, which may be given in one or more path components. Returns the first directory in which the top desired path component was found, or raises PathNotFound... | def FindUpwardParent(start_dir, *desired_list):
desired_path = os.path.join(*desired_list)
last_dir = ''
cur_dir = start_dir
found_path = os.path.join(cur_dir, desired_path)
while not os.path.exists(found_path):
last_dir = cur_dir
cur_dir = os.path.dirname(cur_dir)
if last_dir == cur_dir:
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindInPathParents(path_to_find, start_path, test_func=None):\n if test_func is None:\n test_func = os.path.exists\n for path in IteratePathParents(start_path):\n target = os.path.join(path, path_to_find)\n if test_func(target):\n return target\n return None",
"def FindUpward(start_dir, *desi... | [
"0.68884987",
"0.66576576",
"0.65121746",
"0.6431206",
"0.6309778",
"0.6242849",
"0.622943",
"0.62164813",
"0.6186842",
"0.61390775",
"0.61100143",
"0.609737",
"0.60620207",
"0.6036359",
"0.60303724",
"0.6028851",
"0.60098743",
"0.5971119",
"0.5952902",
"0.5945069",
"0.591127... | 0.7572469 | 0 |
Returns the executable command name, depending on the platform. | def GetGClientCommand(platform=None):
if not platform:
platform = sys.platform
if platform.startswith('win'):
# Windows doesn't want to depend on bash.
return 'gclient.bat'
else:
return 'gclient' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_executable(self) -> str:\n ...",
"def get_ipc_message_util_executable():\n app_directory = environment.get_value('APP_DIR')\n platform = environment.platform()\n\n try:\n executable = IPC_MESSAGE_UTIL_EXECUTABLE_FOR_PLATFORM[platform]\n except KeyError:\n # Current platform is not suppor... | [
"0.7504294",
"0.7262533",
"0.7131338",
"0.7104467",
"0.7004376",
"0.6944966",
"0.69395924",
"0.6903498",
"0.68582785",
"0.6770532",
"0.67492676",
"0.6668505",
"0.66588515",
"0.664624",
"0.66443825",
"0.66322273",
"0.66092163",
"0.66012925",
"0.65805984",
"0.6578445",
"0.65512... | 0.65303254 | 25 |
Get current checkout's subdir, if checkout uses subdir layout. | def GetActiveSubdir():
subdir = os.getenv('INFRA_BUILDBOT_SLAVE_ACTIVE_SUBDIR')
if subdir is not None:
# Empty string in enviornment variable is cached version of None return
# value (see "run_slave.py").
return subdir or None
basedir = os.path.dirname(BUILD_DIR)
subdir_rootdir = os.path.dirname(ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_dir(self):\n parent = os.path.dirname(self.dirn)\n if self.is_subdir:\n parent = os.path.basename(parent)\n else:\n if self.platform is not None and parent.endswith(self.platform):\n parent = parent[:-len(self.platform)].rstrip(os.sep)\n ... | [
"0.63436604",
"0.62213314",
"0.62213314",
"0.62213314",
"0.62213314",
"0.6199754",
"0.61840326",
"0.6176942",
"0.61609375",
"0.6109741",
"0.6093772",
"0.60682404",
"0.6066987",
"0.6064445",
"0.6031232",
"0.5986928",
"0.59745586",
"0.5973641",
"0.59667623",
"0.59578377",
"0.59... | 0.6396528 | 0 |
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. | def Which(cmd, mode=os.F_OK | os.X_OK, path=None):
# Check that a given file can be accessed with the correct mode.
# Additionally check that `file` is not a directory, as on Windows
# directories pass the os.access check.
def _access_check(fn, mode):
return (os.path.exists(fn) and os.access(fn, mode)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def which(cmd, mode=os.F_OK | os.X_OK, path=None):\n # Check that a given file can be accessed with the correct mode.\n # Additionally check that `file` is not a directory, as on Windows\n # directories pass the os.access check.\n def _access_check(fn, mode):\n ... | [
"0.7710544",
"0.7460606",
"0.74535376",
"0.69431406",
"0.6540076",
"0.63951135",
"0.60807884",
"0.5903502",
"0.58789366",
"0.58784086",
"0.57512003",
"0.5732224",
"0.5709676",
"0.5672236",
"0.5576158",
"0.55755967",
"0.55527914",
"0.54989916",
"0.545132",
"0.54457504",
"0.542... | 0.7276463 | 3 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
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))
# pdb.set_trace()
res = []
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.8330198",
"0.8286244",
"0.8239507",
"0.8231228",
"0.82214344",
"0.8187793",
"0.81863457",
"0.81766933",
"0.8172925",
"0.81715053",
"0.81679446",
"0.81658614",
"0.81652",
"0.816366",
"0.816366",
"0.816366",
"0.816366",
"0.816366",
"0.816366",
"0.816366",
"0.816366",
"0.81... | 0.7877335 | 64 |
Splits a given dataset into train and validation | def split_dataset(dataset, Ntotal, val_frac,
batch_size, num_workers,
random_seed=0, shuffle=True, balance=False):
Nval = math.floor(Ntotal*val_frac)
train_ds, val_ds = ch.utils.data.random_split(dataset,
[Ntotal - Nval, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_test_split(data, validate_size=0.3):\r\n\r\n split = len(data) * (1 - validate_size)\r\n split = int(split)\r\n train = data[:split]\r\n validate = data[split:]\r\n\r\n return train, validate",
"def __split_dataset(self):\n self.train, self.valid, _, _ = train_test_split(self.data... | [
"0.8286266",
"0.8269386",
"0.8189092",
"0.7935197",
"0.7926775",
"0.78991723",
"0.7886786",
"0.78474474",
"0.7706437",
"0.7706437",
"0.7706437",
"0.769847",
"0.76706713",
"0.76536226",
"0.7642111",
"0.76167077",
"0.7610265",
"0.76087016",
"0.7603794",
"0.76035",
"0.7575361",
... | 0.0 | -1 |
Converts a field to categorical type in order to save memory space and speed up basis expansion. | def categorical_cast(dataframe, cat_field):
if _is_object_type(dataframe, cat_field):
dataframe[cat_field] = dataframe[cat_field].astype('category')
return dataframe
else:
raise TypeError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_categorical(self, meta_field):\n self._data[meta_field] = pd.Categorical(self._data[meta_field])",
"def _is_categorical(df, field):\n return df[field].dtype.name == 'category'",
"def _convert_category(category_field):\n\n return category_field # TODO",
"def __encode_categorical_util(sel... | [
"0.72345245",
"0.7223713",
"0.7104019",
"0.6217048",
"0.6093363",
"0.59935856",
"0.5939084",
"0.57817966",
"0.5755735",
"0.5750588",
"0.56978595",
"0.5677694",
"0.56638664",
"0.565698",
"0.5643744",
"0.5641929",
"0.5622583",
"0.56026095",
"0.56026095",
"0.55933833",
"0.558536... | 0.7618379 | 0 |
Take a list of Attr names and return a dict of those attributes values with names as keys | def getSelectedAttr(self, listAttrNames):
d = {}
for item in listAttrNames:
if self.__dict__.has_key(item):
d[item] = self.__dict__[item]
return d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_attribute_dic(self, attrs):\n attr_dic = {}\n for attr_pair in attrs:\n attr_dic[attr_pair[0]] = attr_pair[1]\n return attr_dic",
"def process_attrs(attrs):\n if attrs.getLength() == 0:\n return {}\n tmp_dict = {}\n for name in attrs.getNames():\n t... | [
"0.74385136",
"0.73659223",
"0.73240274",
"0.7025269",
"0.69200003",
"0.6716692",
"0.66161066",
"0.66107565",
"0.6585543",
"0.65166026",
"0.6450366",
"0.644488",
"0.636546",
"0.63389707",
"0.62444085",
"0.621897",
"0.6197052",
"0.61782056",
"0.615368",
"0.61457676",
"0.613419... | 0.72084755 | 3 |
Take the dict given and find the next available ID | def getNextID(self, d):
try:
listOrdered = d.keys()
listOrdered = funcs.sortStringList(listOrdered)
lastID = int(listOrdered[-1])
nextID = str(lastID + 1)
for i in range(1,int(nextID)):
if str(i) not in listOrdered:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GFID(myDict):\n return (myDict[next(iter(myDict))])",
"def get_next_match_id():\n conn = get_connect()\n cursor = conn.execute(\"SELECT matchId FROM match WHERE isSearched = 0 LIMIT 1\")\n result_list = cursor.fetchone()\n conn.close()\n if result_list is None:\n print(\"no more matc... | [
"0.6483836",
"0.6410202",
"0.6378688",
"0.6368327",
"0.63469493",
"0.61641645",
"0.60935175",
"0.60431",
"0.60092604",
"0.60064125",
"0.6004894",
"0.6004418",
"0.59482497",
"0.5948075",
"0.59113324",
"0.5890131",
"0.5867724",
"0.58641475",
"0.58446217",
"0.5829393",
"0.579382... | 0.71750766 | 0 |
Make each sample have a mean of zero by subtracting mean along the feature axis. | def sample_zero_mean(x):
return x - np.mean(x, axis=1).reshape((x.shape[0], 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_zero_mean(x, xtest):\n mu = np.mean(x, axis=0)\n return x - mu, xtest - mu",
"def demeaned(self):\n return self.data - self.mean",
"def zero_mean(x):\n\treturn np.zeros((x.shape)[0])",
"def dim_zero_mean(x: Tensor) ->Tensor:\n return torch.mean(x, dim=0)",
"def normalize_feature... | [
"0.74405015",
"0.680625",
"0.67393494",
"0.6726073",
"0.66002244",
"0.65840334",
"0.65359443",
"0.64321744",
"0.63846374",
"0.6363144",
"0.63400084",
"0.63195056",
"0.62589437",
"0.6194102",
"0.61927855",
"0.61706245",
"0.6116202",
"0.6110677",
"0.6110677",
"0.6110677",
"0.61... | 0.7610733 | 0 |
Make each feature have a mean of zero by subtracting mean along sample axis. Using training statistics to normalize test data. | def feature_zero_mean(x, xtest):
mu = np.mean(x, axis=0)
return x - mu, xtest - mu | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_features(X):\n std = X.std(axis=0)\n std = np.where(std == 0, 1, std) # to avoid division by zero\n x_normed = (X - X.mean(axis=0)) / std\n return x_normed",
"def sample_zero_mean(x):\n return x - np.mean(x, axis=1).reshape((x.shape[0], 1))",
"def feature_normalization(train, test... | [
"0.7077883",
"0.7011696",
"0.69073236",
"0.68003464",
"0.67613477",
"0.6718349",
"0.6636497",
"0.66312796",
"0.6482037",
"0.64746094",
"0.6443299",
"0.6437047",
"0.63987243",
"0.6361115",
"0.63539654",
"0.6342208",
"0.6302504",
"0.6262094",
"0.6226308",
"0.61833024",
"0.61833... | 0.7740042 | 0 |
Initialize a Ball object mass the mass of ball radius the radius of ball position the position vector of ball velocity the velocity vector of ball | def __init__(self, mass, radius, position, velocity):
self.mass = mass
self.radius = radius
self.position = position
self.velocity = velocity
print(self.velocity)
self.vafter = np.copy(velocity) # temp storage for velocity of next step
self.delete = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, posn_x, posn_y, velocity_x, velocity_y, kula): \n self.posn_x = posn_x # x position of box containing the ball (bottom). \n self.posn_y = posn_y # x position of box containing the ball (left edge). \n self.velocity_x = velocity_x # amount of x-mo... | [
"0.7672465",
"0.7261102",
"0.71749353",
"0.70791095",
"0.70615464",
"0.70206445",
"0.6979953",
"0.69783694",
"0.6917194",
"0.67497057",
"0.6733276",
"0.67286646",
"0.67049617",
"0.6673413",
"0.6598071",
"0.65521103",
"0.65495366",
"0.65427196",
"0.65285766",
"0.6517548",
"0.6... | 0.6932775 | 8 |
Reward of agent i as observed in o, given all agents behave according to X. | def obtain_Rio(self, X, Bios=None, Xisa=None):
Bios = self.obtain_Bios(X) if Bios is None else Bios
Xisa = self.obtain_Xisa(X) if Xisa is None else Xisa
i = 0 # agent i
s = 1 # state s
sprim = 2 # next state s'
o = 3 # observation o
b2d = list(range(4... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reward(self, i, rewards, reward=1):\n for j,a in enumerate(self.agents):\n if a.index==i or a.index==0:\n rewards[j]+=reward\n if self.zero_sum:\n if a.index!=i or a.index==0:\n rewards[j] -= reward",
"def step(self, action):\n ... | [
"0.68329924",
"0.67081255",
"0.6350624",
"0.6335578",
"0.63130635",
"0.6304448",
"0.6303894",
"0.62661266",
"0.6243979",
"0.6240213",
"0.6208016",
"0.61624104",
"0.6147371",
"0.61459017",
"0.6138077",
"0.61248505",
"0.6090167",
"0.6090167",
"0.6090167",
"0.6090167",
"0.609016... | 0.0 | -1 |
Obtain stationary distribution for X | def _obtain_statdist(self, Tss, tol=1e-10, adapt_tol=True,
verbose=True):
oeival, oeivec = la.eig(Tss, right=False, left=True)
oeival = oeival.real
oeivec = oeivec.real
mask = abs(oeival - 1) < tol
printflag = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_stationary_distribution(self):\n return self.mc.stationary_distributions",
"def stationary_distribution(self):\n P = self.markov_transition()\n N = len(P)\n I = np.identity(N)\n A = P.T - I # get right-kernel\n pi = null_space(A)\n pi = pi / sum(pi)\n ... | [
"0.73740333",
"0.6996491",
"0.6314904",
"0.6266839",
"0.61767805",
"0.6117579",
"0.61107326",
"0.6062917",
"0.6035157",
"0.5994648",
"0.59207827",
"0.5904452",
"0.58859724",
"0.58756155",
"0.58692527",
"0.585742",
"0.585659",
"0.58244133",
"0.5823404",
"0.57891405",
"0.577842... | 0.0 | -1 |
Given a document (represented as a string), return a list of all of the words in that document, in order. Process document by coverting all words to lowercase, and removing any punctuation or English stopwords. | def tokenize(document):
# Initialize the list of words, punctuation and stopwords
keywords = []
punctuations_list = string.punctuation
stopwords_list = nltk.corpus.stopwords.words("english")
# Make a naive tokenized copy of the `document`
naive_list = nltk.word_tokenize(document)
for item... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(document):\n raw_words=[word.lower() for word in nltk.word_tokenize(document) if word.isalpha()]\n raw_words=[word.lower() for word in raw_words]\n final_words=[]\n for word in raw_words:\n if word not in string.punctuation and word not in nltk.corpus.stopwords.words(\"english\"):\n... | [
"0.7946411",
"0.79221493",
"0.7899376",
"0.77563936",
"0.7736424",
"0.77264714",
"0.76672745",
"0.73873055",
"0.72902703",
"0.7227008",
"0.7074942",
"0.7042964",
"0.70238566",
"0.7017628",
"0.7017628",
"0.699229",
"0.6973201",
"0.6968546",
"0.6966155",
"0.69499093",
"0.694576... | 0.7340858 | 8 |
Returns a KafkaClient based off of the kafka_hosts and kafka_port configs set in the active runtime. | def get_kafka_client(num_retries=20, retry_sleep=1):
kafka_hosts = runtime.get_active_config('kafka_hosts').values()
kafka_port = runtime.get_active_config('kafka_port')
assert len(kafka_hosts) > 0, 'Missing required configuration: kafka_hosts'
connect_string = ','.join(map(lambda h: h + ':{0},'.format(kafka_po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_brokerclient(self, host, port):\n host_key = (nativeString(host), port)\n if host_key not in self.clients:\n # We don't have a brokerclient for that host/port, create one,\n # ask it to connect\n log.debug(\"%r: creating client for %s:%d\", self, host, port)\... | [
"0.66664684",
"0.6258427",
"0.6240911",
"0.6115197",
"0.60555416",
"0.5923222",
"0.5914974",
"0.5900213",
"0.5867888",
"0.57806224",
"0.5724228",
"0.56831545",
"0.5682155",
"0.5627294",
"0.56111276",
"0.55973774",
"0.5585405",
"0.5579921",
"0.5470888",
"0.54186803",
"0.539805... | 0.7897692 | 0 |
Reset this calibrator for reuse. The calibrator will clear any dynamic ranges cached from previous calibration runs, and will attempt to rewind the data loader (note that generators cannot be rewound). Typically, this is only required if the same calibrator is used for multiple different networks. | def reset(self):
# Attempt to reset data loader
self.data_loader_iter = iter(self.data_loader)
self.num_batches = 0
# Make sure calibrator will check the cache again when reset.
self.cache_contents = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n\n self.scaler = None\n self.isFitted = False\n self.__create_scaler()",
"def reset(self):\n self.source_data = self.get_dict_from_range(None, None)\n self.selection_bounds = None\n self.selection = []\n for c in self.callbacks[\"reset_data\"]:\n... | [
"0.70852745",
"0.6861143",
"0.67036825",
"0.6627967",
"0.6627967",
"0.66118205",
"0.65607685",
"0.65275306",
"0.64724976",
"0.6468237",
"0.6442534",
"0.6436194",
"0.6433947",
"0.64259875",
"0.6397934",
"0.63935053",
"0.6386685",
"0.6386685",
"0.6386685",
"0.6386685",
"0.63866... | 0.7576188 | 0 |
Compute the values of the formal ECDF generated from `data` at points `x`. I.e., if F is the ECDF, return F(x). | def _ecdf(x, data):
y = np.arange(len(data) + 1) / len(data)
return y[np.searchsorted(np.sort(data), x, side="right")] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ecdf(data):\n\n # Number of data points: n\n n = len(data)\n\n # x-data for the ECDF: x\n x = np.sort(data)\n\n # y-data for the ECDF: y\n y = np.arange(1, len(data)+1) / n\n\n return x, y",
"def ecdf(data):\n\n # Number of data points: n\n n = len(data)\n\n # x-data for the ECD... | [
"0.74496126",
"0.74496126",
"0.7419554",
"0.7411833",
"0.7411163",
"0.74062026",
"0.74062026",
"0.73986036",
"0.7385595",
"0.7385595",
"0.7374215",
"0.7373502",
"0.7358343",
"0.73137045",
"0.67853445",
"0.67297626",
"0.6715188",
"0.66331124",
"0.64757735",
"0.64067775",
"0.62... | 0.673349 | 15 |
Determine if all entries in two arrays are close to each other. | def _allclose(x, y, rtol=1e-7, atol=1e-14):
for a, b in zip(x, y):
if np.abs(a - b) > (atol + rtol * np.abs(b)):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_array_dominated(array_0, array_1):\n for val_0, val_1 in zip(sorted(array_0), sorted(array_1)):\n if val_0 >= val_1:\n return False\n return True",
"def arecloseenough(x1, x2):\n\n if abs(x1 - x2) <= VERYSMALL:\n return True\n \n return False",
"def array_equal(a, b, unit_t... | [
"0.72856426",
"0.7004255",
"0.69977117",
"0.6966303",
"0.68846136",
"0.67174697",
"0.6690083",
"0.6689063",
"0.6662894",
"0.66489667",
"0.66488373",
"0.6634391",
"0.66275704",
"0.6593512",
"0.65904367",
"0.65818846",
"0.65675235",
"0.65675235",
"0.65658337",
"0.65460753",
"0.... | 0.689851 | 4 |
returns a view to record array theta which behaves like a (N,d) float array | def as_2d_array(theta):
v = theta.view(np.float)
N = theta.shape[0]
v.shape = (N, - 1)
# raise an error if v cannot be reshaped without creating a copy
return v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __array__(self, dtype=None):\n theta, phi = float(self.params[0]), float(self.params[1])\n cos = math.cos(theta / 2)\n sin = math.sin(theta / 2)\n exp_m = exp(-1j * phi)\n exp_p = exp(1j * phi)\n return numpy.array([[cos, -1j * exp_m * sin], [-1j * exp_p * sin, cos]], ... | [
"0.6559363",
"0.63110006",
"0.6234961",
"0.60487247",
"0.60072535",
"0.59213066",
"0.58990246",
"0.5865741",
"0.5822473",
"0.5756527",
"0.57273597",
"0.5722455",
"0.5718258",
"0.57057023",
"0.570516",
"0.5700155",
"0.56831706",
"0.5662109",
"0.55988514",
"0.5593993",
"0.55616... | 0.6458964 | 1 |
Displays the homepage with forms for current or historical data. | def home():
return render_template('index.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n return render_template('home.html', form=None)",
"def home():\n\n return render_template('index.html',\n date = d,\n mood = mood,\n header_color = color,\n day = day,\n ... | [
"0.7288106",
"0.7038824",
"0.70268315",
"0.70189595",
"0.7011207",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69257265",
"0.6920755",
"0.6914717",
"0.6891607",
"0.6880401",
"0.... | 0.0 | -1 |
Displays the homepage with forms for current or historical data. | def uploaddocs():
sampleDataTitle = ["Medical Document 1", "Medical Document 2", "Medical Document 3",
"Medical Document 4", "Medical Document 5", "Medical Document 6"]
sampleData = ["This is Medical Document 1", "This is Medical Document 2",
"This is Medical Docum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n return render_template('home.html', form=None)",
"def home():\n\n return render_template('index.html',\n date = d,\n mood = mood,\n header_color = color,\n day = day,\n ... | [
"0.7288106",
"0.7038824",
"0.70268315",
"0.70189595",
"0.7011207",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69343853",
"0.69257265",
"0.6920755",
"0.6914717",
"0.6891607",
"0.6880401",
"0.... | 0.0 | -1 |
Displays the homepage with forms for current or historical data. | def features():
return render_template('features.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n return render_template('home.html', form=None)",
"def home():\n\n return render_template('index.html',\n date = d,\n mood = mood,\n header_color = color,\n day = day,\n ... | [
"0.7288882",
"0.703977",
"0.70289063",
"0.7020779",
"0.7013105",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6936235",
"0.6927369",
"0.6922565",
"0.69154614",
"0.6892315",
"0.6881946",
"0.6870623",
... | 0.0 | -1 |
given a sklearn confusion matrix (cm), make a nice plot Arguments | def plot_confusion_matrix(cm, save_path,
target_names,
title='Confusion matrix',
cmap=None,
normalize=False):
accuracy = np.trace(cm) / np.sum(cm).astype('float')
misclass = 1 - accuracy
if cmap is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, class_names):\n figure = plt.figure(figsize=(10, 10))\n plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)\n plt.title(\"Confusion matrix\")\n plt.colorbar()\n tick_marks = np.arange(len(class_names))\n plt.xticks(tick_marks, class_names, rotation=45)\n plt.yticks(tick_... | [
"0.7998953",
"0.79943913",
"0.7946874",
"0.79344404",
"0.79131955",
"0.7896219",
"0.78781104",
"0.78595",
"0.78595",
"0.78530246",
"0.7848679",
"0.78483564",
"0.78388304",
"0.7833984",
"0.7827247",
"0.7823944",
"0.78033894",
"0.7800449",
"0.7780714",
"0.77779824",
"0.77747816... | 0.0 | -1 |
Return the state attributes of the device. | def extra_state_attributes(self) -> dict[str, Any]:
return {
ATTR_LAST_UPDATE: self.coordinator.data.now.date,
ATTR_SENSOR_ID: self.entity_description.key,
ATTR_SITE_ID: self.coordinator.data.site.id,
ATTR_SITE_NAME: self.coordinator.data.site.name,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\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):\n return self._state_attrs",
"def device_state_a... | [
"0.92744374",
"0.92059016",
"0.9151105",
"0.9151105",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.9149194",
"0.91486025",
"0.91486025",
"0.9138181",
"0.911002",
... | 0.0 | -1 |
Make a copy of self.__dict__ containing all the data we need. | def save_state_to_dict(self):
return self.__dict__.copy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __copy__(self):\n d = dict()\n d.update(self.items())\n return d",
"def get(self) -> dict:\n return clone(self.__dict__)",
"def __getstate__(self) -> dict:\n self_dict = self.__dict__.copy()\n # we remove large objects from `__getstate__` to allow\n # pickli... | [
"0.7480182",
"0.73705435",
"0.72972506",
"0.7257804",
"0.72359824",
"0.7218769",
"0.7200764",
"0.71798927",
"0.71011966",
"0.708534",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.7001143",
"0.6955425",... | 0.0 | -1 |
Loads a file into a dataframe. | def load_file_to_dataframe(self, file_path: str) -> pd.DataFrame:
return pd.read_csv(file_path, sep="\t") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_from_file(filename):\r\n df = pd.read_csv(filename)\r\n return df",
"def gp_dataframe_import(filename):\n path = os.path.join('..', 'data', filename)\n frame = pd.read_csv(path)\n return frame",
"def load(self) -> pd.DataFrame:\n if os.path.exists(self.file_name):\n ... | [
"0.76687145",
"0.7653037",
"0.76111704",
"0.7507581",
"0.7441309",
"0.738278",
"0.73757744",
"0.73757744",
"0.73757744",
"0.7349036",
"0.733366",
"0.7327498",
"0.7265091",
"0.7261275",
"0.7255459",
"0.7242784",
"0.7239481",
"0.7223496",
"0.71594656",
"0.71554536",
"0.71416515... | 0.8056603 | 0 |
Get the xArm sn | def get_robot_sn(self):
return self._arm.get_robot_sn() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSN(self):\n return self.spavg.getSN()",
"def _get_lot_sn(self, cr, uid, context=None):\r\n if context is None:\r\n context = {}\r\n prod = self.pool.get('mrp.production').browse(cr, uid,\r\n context.get('active_id', False), context=context)\r\... | [
"0.59955907",
"0.5897949",
"0.58873993",
"0.5851898",
"0.5732977",
"0.5709128",
"0.56892914",
"0.56664675",
"0.5595404",
"0.5577645",
"0.55438673",
"0.5537128",
"0.5499664",
"0.5441282",
"0.5428752",
"0.54274464",
"0.54167736",
"0.53755075",
"0.5365413",
"0.5365413",
"0.53272... | 0.6770372 | 0 |
Get the reported torque or electric current | def get_report_tau_or_i(self):
return self._arm.get_report_tau_or_i() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current(self) -> float:\n return self._electric_current",
"def get_current(self):\n return self.x",
"def get_current(self):\n return self.node.sdo[0x221c].phys # mA",
"def holding_current(self):\n if self.clamp_mode == 'ic':\n return self._meta['holding_current']\n... | [
"0.6915121",
"0.63950765",
"0.63919914",
"0.63905597",
"0.6281592",
"0.62534684",
"0.6244732",
"0.61967987",
"0.6163203",
"0.60896194",
"0.60650295",
"0.6016116",
"0.6004637",
"0.5953467",
"0.59473234",
"0.59246176",
"0.591543",
"0.5905062",
"0.5902845",
"0.587249",
"0.586963... | 0.563886 | 45 |
Return timestamp as string | def dformat(val):
if isinstance(val, datetime):
return val.strftime(DATE_FORMAT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_timestamp():\n return time.strftime('%Y-%m-%d %H:%M:%S')",
"def timestamp():\n return datetime.now().strftime(\"%Y%m%dT%H%M%S\")",
"def _get_timestamp():\n return str(int(time.time()))",
"def timeStamp():\n import time\n return str(time.strftime(\"%a %d %b %Y %I:%M:%S %p\")... | [
"0.84595764",
"0.8452315",
"0.834696",
"0.83181596",
"0.82687974",
"0.8199908",
"0.81917363",
"0.8177214",
"0.81734216",
"0.81527543",
"0.81527543",
"0.806251",
"0.8028516",
"0.80272096",
"0.8003765",
"0.79967266",
"0.79472953",
"0.7929054",
"0.79101396",
"0.7907151",
"0.7907... | 0.0 | -1 |
Return good's price based on type of deal | def get_good_price_by_deal(self):
if self.deal == SALE:
return self.new_price
elif self.deal == AUCTION:
return self.max_price
else:
return self.price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_deal_price(self):\n return self.create_random_decimal(min=1, max=100000)",
"def get_discount(self, price):\r\n pass",
"def check_price(self):\n return self.day*self.price",
"def priceGetDeal(soup):\n price = soup.find('td', id='priceblock_dealprice', class_='a-color-price a-... | [
"0.6644808",
"0.65682167",
"0.6532625",
"0.64710706",
"0.6455097",
"0.63737863",
"0.6288195",
"0.62673044",
"0.6265837",
"0.62357223",
"0.62357223",
"0.62309647",
"0.6229608",
"0.61884034",
"0.6179516",
"0.6103663",
"0.6090371",
"0.60744655",
"0.607241",
"0.6064521",
"0.60645... | 0.799945 | 0 |
Test update returns entry two. | def test_update_returns_entry_1(dummy_request, new_session):
from .views.default import update
model = Entry(title=ENTRIES[0]["title"],
body=ENTRIES[0]["body"],
creation_date=ENTRIES[0]["creation_date"])
new_session.add(model)
dummy_request.matchdict['id'] = 1
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_one(self):\n pass",
"def test_update_case(self):\n pass",
"def test_update_twice_same_result():\n starting_db = create_db(STARTING_DB_INPUT)\n actual: dict = o_obj.update_object_in_db(\n starting_db,\n \"some_uid\",\n INP\n )\n actual2: dict = o_ob... | [
"0.78487426",
"0.7705983",
"0.7644137",
"0.7604735",
"0.7604735",
"0.7604735",
"0.7475997",
"0.7340763",
"0.7201492",
"0.7161953",
"0.7153125",
"0.7138606",
"0.70288074",
"0.6959076",
"0.69444627",
"0.68858033",
"0.6791265",
"0.6790361",
"0.6768783",
"0.6742385",
"0.673082",
... | 0.7172413 | 9 |
Test update returns entry two. | def test_update_returns_entry_2(dummy_request, new_session):
from .views.default import update
model = Entry(title=ENTRIES[1]["title"],
body=ENTRIES[1]["body"],
creation_date=ENTRIES[1]["creation_date"])
new_session.add(model)
dummy_request.matchdict['id'] = 1
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_one(self):\n pass",
"def test_update_case(self):\n pass",
"def test_update_twice_same_result():\n starting_db = create_db(STARTING_DB_INPUT)\n actual: dict = o_obj.update_object_in_db(\n starting_db,\n \"some_uid\",\n INP\n )\n actual2: dict = o_ob... | [
"0.7849215",
"0.77072555",
"0.7642399",
"0.76056343",
"0.76056343",
"0.76056343",
"0.73415804",
"0.72023034",
"0.717432",
"0.71624506",
"0.71534634",
"0.71395636",
"0.70302844",
"0.695992",
"0.69459033",
"0.6887193",
"0.67918575",
"0.6791425",
"0.67702633",
"0.67445785",
"0.6... | 0.7477039 | 6 |
Create an instance of webtests TestApp for testing routes. | def testapp():
from webtest import TestApp
from learning_journal import main
app = main({}, **{'sqlalchemy.url': 'postgres:///amosboldor'})
testapp = TestApp(app)
session_factory = app.registry["dbsession_factory"]
engine = session_factory().bind
Base.metadata.drop_all(bind=engine)
Bas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testapp():\n from space_rocks import main\n app = main({})\n from webtest import TestApp\n return TestApp(app)",
"def test_create_app():\n app = web.YumWeb(__name__)\n assert app.name == 'web_tests'",
"def create_app(test_config=None):\n app = Flask(__name__)\n\n # apply the bluepri... | [
"0.78882056",
"0.75199705",
"0.7329518",
"0.7145451",
"0.71350235",
"0.7101695",
"0.7101695",
"0.7101695",
"0.7092823",
"0.708616",
"0.7057276",
"0.7006798",
"0.69613785",
"0.695518",
"0.6902935",
"0.6882514",
"0.6873027",
"0.687293",
"0.6869679",
"0.68674725",
"0.6840979",
... | 0.6448393 | 53 |
The home page has all html elements from index template. | def test_home_route_does_not_have_all_lists(testapp):
response = testapp.get('/', status=200)
html = response.html
assert len(html.find_all("main")) == 1
assert len(html.find_all("ul")) == 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n\n return render_template(\n 'home_page/index.html',\n **locals()\n )",
"def index():\r\n return render_template('home.html')",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)",
"def i... | [
"0.86931694",
"0.8557559",
"0.852793",
"0.8503373",
"0.8468145",
"0.8452784",
"0.8437967",
"0.8433049",
"0.84280074",
"0.8419608",
"0.8419336",
"0.8416375",
"0.8410132",
"0.8402134",
"0.8402134",
"0.8402134",
"0.8402134",
"0.839989",
"0.8386757",
"0.8386757",
"0.8386757",
"... | 0.0 | -1 |
A character escape aware string replace function s = string to perform replacement with old = substring to replace new = string to replace old escape = the escape character to be aware of | def escape_replace(s, old, new, escape='\\'):
newstr = []
if len(old) == 0:
return
for i, c in enumerate(s):
if old[0] == c and s[i-1] != escape:
newstr.extend(new)
else:
newstr.append(c)
return ''.join(newstr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _escape(s):\n assert isinstance(s, str), \\\n \"expected %s but got %s; value=%s\" % (type(str), type(s), s)\n s = s.replace(\"\\\\\", \"\\\\\\\\\")\n s = s.replace(\"\\n\", \"\\\\n\")\n s = s.replace(\"\\t\", \"\\\\t\")\n s = s.replace(\",\", \"\\t\")\n return s",
"def _escape_string(s, surroun... | [
"0.71093017",
"0.6772709",
"0.66766363",
"0.6643009",
"0.6548074",
"0.6544306",
"0.64055717",
"0.63309604",
"0.63257927",
"0.6304961",
"0.63039154",
"0.6300425",
"0.62840927",
"0.6262964",
"0.6226028",
"0.62190616",
"0.6218974",
"0.62155104",
"0.62065333",
"0.61945885",
"0.61... | 0.8363607 | 0 |
Turn a list of Month objects into a list of verbose name months | def convert_to_verbose_months(month_objects):
MONTHS = {
"1": "Jan", "2": "Fev", "3": "Mar", "4": "Abr", "5": "Mai", "6": "Jun",
"7": "Jul", "8": "Ago", "9": "Set", "10": "Out", "11": "Nov", "12": "Dez"
}
return [MONTHS[month.month_number] for month in month_objects] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_months(self, cr, uid, context):\n months=[(str(n),str(n)) for n in range(1,13)]\n return months",
"def get_months(self):\n m = []\n for post in self:\n d = \"-\".join(post.Date.split(\"-\")[:2])\n m.append(d)\n return list(sorted(set(m), reverse=Tru... | [
"0.656306",
"0.64996326",
"0.64751613",
"0.6297216",
"0.60888386",
"0.60457885",
"0.60351866",
"0.5960159",
"0.59091276",
"0.5853055",
"0.5753325",
"0.57242507",
"0.56981564",
"0.56429726",
"0.5590511",
"0.5590191",
"0.55769444",
"0.55431104",
"0.552884",
"0.5495866",
"0.5467... | 0.8111117 | 0 |
Creates a plotly scattter chart using transactions of each month of a selected year. | def create_income_expense_scatter_plot(year_id):
month_objects = get_months_by_year(year_id)
# build chart data
months = convert_to_verbose_months(month_objects)
y_expenses = get_transactions_sum_data(month_objects, amount_type='expenses')
y_incomes = get_transactions_sum_data(mont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monthly_overview():\n df = (\n monzo\n [~monzo.category.isin(['general', 'transfer'])]\n .pivot_table('amount', 'month', 'category',\n aggfunc='sum', fill_value=0)\n .reset_index()\n .melt(id_vars=['month'], value_name='amount')\n )\n inc = df[df.... | [
"0.6755238",
"0.66003144",
"0.6203996",
"0.6101464",
"0.6094934",
"0.60415655",
"0.59438545",
"0.5774241",
"0.57738733",
"0.5750559",
"0.5690196",
"0.56015974",
"0.5585369",
"0.5550076",
"0.54837686",
"0.5462159",
"0.5456734",
"0.54441255",
"0.54012376",
"0.53953665",
"0.5364... | 0.67077535 | 1 |
Creates a plotly grouped box chart showing sidebyside total volume of expenses x incomes by month of a selected year | def create_income_expense_grouped_bar_chart(year_id):
month_objects = get_months_by_year(year_id)
# get chart data
months = convert_to_verbose_months(month_objects)
y_expenses = get_transactions_sum_data(month_objects, amount_type='expenses')
y_incomes = get_transactions_sum_data(month_objec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box(df):\n data = []\n\n for prop_type in df['property_type'].unique():\n df_filt = df[df['property_type'] == prop_type]\n data.append(\n go.Box(\n y=df_filt['price_paid'].values,\n x=df_filt['year'].values,\n name=prop_type,\n ... | [
"0.66928685",
"0.6506821",
"0.6484316",
"0.63289565",
"0.62608916",
"0.62477225",
"0.6053129",
"0.6028411",
"0.5814293",
"0.5698219",
"0.5598641",
"0.5483527",
"0.5405478",
"0.5234495",
"0.5203201",
"0.51476794",
"0.5138125",
"0.51352656",
"0.5107589",
"0.5104113",
"0.5065121... | 0.6472378 | 3 |
This method renders the home page | def home(request):
temp_data = Temperature.objects.all()
if temp_data:
temp_value = temp_data.temp_value
created_time = temp_data.created_time
context = {'temp_value', 'created_time'}
return render(request, 'base/home.html', context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n\n return render_template('home_page.html')",
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template(\"home.html\")",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def ... | [
"0.86938477",
"0.8555688",
"0.8507455",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8450381",
"0.8438189",
"0.8438189",
... | 0.0 | -1 |
Generate anchors for once. Anchors are stored with (center_x, center_y, w, h) format. | def _generate_anchors(self, sizes, ratios, step, alloc_size, offsets):
assert len(sizes) == 2, "SSD requires sizes to be (size_min, size_max)"
anchors = []
for i in range(alloc_size[0]):
for j in range(alloc_size[1]):
cy = (i + offsets[0]) * step
cx = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_anchors(self):\n self.anchors = np.zeros((self.anchor_num, 4), dtype=np.float32)\n size = self.stride * self.stride\n count = 0\n for r in self.ratios:\n ws = int(math.sqrt(size * 1. / r))\n hs = int(ws * r)\n\n for s in self.scales:\n ... | [
"0.8031988",
"0.74405766",
"0.7432096",
"0.7314839",
"0.7310115",
"0.7278248",
"0.7133064",
"0.711425",
"0.7112615",
"0.70137215",
"0.70137215",
"0.6983981",
"0.6969387",
"0.69610834",
"0.6958479",
"0.6925973",
"0.6854886",
"0.68512803",
"0.6824095",
"0.68085194",
"0.6801783"... | 0.6724028 | 25 |
Generate anchors for once. Anchors are stored with (center_x, center_y, w, h) format. | def _generate_anchors(self, sizes, ratios, step, alloc_size, offsets):
assert len(sizes) == 2, "SSD requires sizes to be (size_min, size_max)"
anchors = []
for i in range(alloc_size[0]):
for j in range(alloc_size[1]):
cy = (i + offsets[0]) * step
cx = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_anchors(self):\n self.anchors = np.zeros((self.anchor_num, 4), dtype=np.float32)\n size = self.stride * self.stride\n count = 0\n for r in self.ratios:\n ws = int(math.sqrt(size * 1. / r))\n hs = int(ws * r)\n\n for s in self.scales:\n ... | [
"0.80315864",
"0.74409926",
"0.74320155",
"0.7315402",
"0.7310704",
"0.7278811",
"0.7133166",
"0.71147346",
"0.7112511",
"0.70135254",
"0.70135254",
"0.6983212",
"0.6969283",
"0.6960877",
"0.6959094",
"0.6926591",
"0.6855371",
"0.68506205",
"0.68238485",
"0.6808129",
"0.68023... | 0.67372733 | 23 |
excluding all instances of transcriptions in words from the dataset | def exclude_words(self, words):
idcs = []
for i in range(len(self)):
if not self.transcript(i) in words:
idcs.append(i)
subset = self.sub_set(idcs)
return subset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter(q_words):\n filtered_words = [\"how\",\"what\"]\n for word in q_words:\n if word in filtered_words:\n q_words.remove(word)",
"def remove_non_wordnet(tokens):\n return [token for token in tokens if wn.synsets(token)]",
"def purge_words(self):\n\n\t\tword_list = self.transcr... | [
"0.67918664",
"0.678129",
"0.66423994",
"0.6593626",
"0.6567239",
"0.65217733",
"0.6472336",
"0.6453485",
"0.64481556",
"0.64279586",
"0.6414487",
"0.6400135",
"0.63763654",
"0.6373032",
"0.63698655",
"0.6360216",
"0.63394004",
"0.63276196",
"0.6317346",
"0.6303222",
"0.62984... | 0.81581765 | 0 |
Unique ID of an item. Sometimes provided by the database, otherwise it should be the index. | def id(self, idx):
row = self.table.iloc[idx]
word_id = row['word_id']
return word_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_id(self):\n return self._item_id",
"def get_id(self, item):\n return self.exist_products.get(hash(item['title']))",
"def getItemId(self):\n self.itemId += 1\n return self.itemId",
"def GetId(self,item):\r\n id = self.item_itemId.get(item)\r\n if id: return i... | [
"0.74380034",
"0.7283227",
"0.7151609",
"0.7022012",
"0.6928274",
"0.6928274",
"0.6815761",
"0.6812032",
"0.6796511",
"0.6771045",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
"0.6766315",
... | 0.0 | -1 |
Generates subset of this set, containing only the items with respective indices in idcs | def sub_set(self, idcs):
return SubSet(dset=self, idcs=idcs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _subset(self, idxs):\n vertices = [self.vertices[i] for i in idxs]\n if hasattr(self, \"data\"):\n data = Table(data=[self.data._data[i] for i in idxs], fields=self.data.fields)\n return type(self)(vertices, properties=self.properties, data=data, crs=self.crs)\n else:... | [
"0.7081254",
"0.6871851",
"0.6846369",
"0.68372005",
"0.66942054",
"0.6400488",
"0.6339034",
"0.63284713",
"0.6237367",
"0.6074455",
"0.60385156",
"0.59339106",
"0.5922915",
"0.57868207",
"0.57667744",
"0.5741674",
"0.5630765",
"0.5595789",
"0.55833864",
"0.5576422",
"0.55723... | 0.6739173 | 4 |
Takes a widget container as input (where the user has selected varables) and returns a pandas dataframe with the values for the selected variables. Example df = read_box(box) | def read_box(from_box):
query = get_json(from_box)
url = from_box.children[3].value
data = requests.post(url, json = query)
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
return results[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_input_features():\n sepal_length = st.sidebar.slider('Sepal length', 4.3, 7.9, 5.4) # the sidebar.slider magic function receive the max, min and default value in out sidebar\n sepal_width = st.sidebar.slider('Sepal width', 2.0, 4.4, 3.4)\n petal_length = st.sidebar.slider('Petal length', 1.0, 6.9... | [
"0.6033229",
"0.5905692",
"0.57060325",
"0.5519732",
"0.55083025",
"0.54302645",
"0.5422",
"0.53522366",
"0.53394306",
"0.52531415",
"0.52504456",
"0.5209191",
"0.5185303",
"0.5157767",
"0.51412284",
"0.51298785",
"0.5065238",
"0.5063606",
"0.5053986",
"0.5029163",
"0.4999956... | 0.0 | -1 |
Returns a pandas dataframe of the premade table indicated by the premade table_id or the full_url. | def read_url(full_url = None,
table_format = 'json'):
if table_format == 'json':
data = requests.get(full_url)
df = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
df = df[0]
elif table_format == 'csv':
df = pd.read_csv(full_url)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_from_table(self, table_name):\n sql_str = \"SELECT * FROM {tb}\".format(tb=table_name)\n cur = self.conn.cursor()\n cur.execute(sql_str)\n names = [description[0] for description in cur.description]\n\n rows = cur.fetchall()\n\n df = pd.DataFrame(rows, columns =... | [
"0.6911987",
"0.66861784",
"0.65258104",
"0.6461572",
"0.63336194",
"0.6329985",
"0.62915593",
"0.626002",
"0.62410593",
"0.6223202",
"0.62034434",
"0.6192353",
"0.6169904",
"0.61495626",
"0.6139391",
"0.6136701",
"0.6050624",
"0.6037779",
"0.6029309",
"0.5984283",
"0.5980155... | 0.6009387 | 19 |
Returns a pandas dataframe of the premade table indicated by the premade table_id or the full_url. | def read_premade(premade_id = None,
language = 'en',
base_url = 'http://data.ssb.no/api/v0/dataset',
full_url = None,
table_format = 'json'):
if full_url is None:
full_url = '{base_url}/{premade_id}.{table_format}?lang={language}'.format(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_from_table(self, table_name):\n sql_str = \"SELECT * FROM {tb}\".format(tb=table_name)\n cur = self.conn.cursor()\n cur.execute(sql_str)\n names = [description[0] for description in cur.description]\n\n rows = cur.fetchall()\n\n df = pd.DataFrame(rows, columns =... | [
"0.69111186",
"0.6685955",
"0.6461527",
"0.63337725",
"0.63293916",
"0.629165",
"0.6259393",
"0.62412864",
"0.62239844",
"0.62044525",
"0.6192934",
"0.6170574",
"0.6149594",
"0.61382776",
"0.61354333",
"0.60509586",
"0.6037656",
"0.6029328",
"0.6007886",
"0.5984737",
"0.59798... | 0.65252066 | 2 |
Loads the dataset from the files contained in the list of root directories. | def load_dataset(self, root_directory_list: list, class_list: ThermoClassList, load_all_data: bool = False) -> None:
self.root_directory_list = root_directory_list
self.thermo_class_list = class_list
self.__image_file_names = np.array([], dtype=str)
self.__labels = np.array([], dtype=np... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_all(self, root_dir, file_list=None, pattern=None):\n\n # Select paths for training and evaluation\n if file_list is None:\n data_paths = glob.glob(os.path.join(root_dir, '*')) # list of all paths\n else:\n data_paths = [os.path.join(root_dir, p) for p in file_li... | [
"0.73055416",
"0.72774255",
"0.7263645",
"0.7236538",
"0.715158",
"0.7128404",
"0.7098536",
"0.709505",
"0.7066855",
"0.69573873",
"0.69253486",
"0.6915877",
"0.6877164",
"0.68377745",
"0.67645735",
"0.6679192",
"0.666423",
"0.66375405",
"0.6515971",
"0.6508193",
"0.6500643",... | 0.6965724 | 9 |
Returns the image shape of the dataset. | def image_shape(self) -> np.ndarray:
return self.__image_shape | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shape(self):\n return self.dataset.shape",
"def image_shape(self):\n return self.data.shape[:2]",
"def image_shape(self):\n return self.data.shape[:2]",
"def shape(self):\n return self._img.shape",
"def shape(self):\n return self.image.shape",
"def get_shape(self):\... | [
"0.83238006",
"0.81199074",
"0.81199074",
"0.8056691",
"0.8030066",
"0.7969854",
"0.7955067",
"0.7858771",
"0.7835794",
"0.7792992",
"0.7792992",
"0.7792992",
"0.7792992",
"0.7792992",
"0.778404",
"0.778404",
"0.778404",
"0.7743766",
"0.7696428",
"0.7640274",
"0.7592229",
"... | 0.76583236 | 19 |
Returns the size of the validation data, i.e. the total number of images available for validation. | def validation_size(self) -> int:
return int(self.data_size * self.__validation_fraction) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_valid_data_size(self):\n return len(self.pipeline.data['test'])",
"def size(self):\r\n return len(self._train_datas)",
"def size(self):\n return self.data.size",
"def __len__(self):\n return math.ceil(self.number_of_images / self.batch_size)",
"def size(self):\n r... | [
"0.81134355",
"0.7505644",
"0.7204089",
"0.71143353",
"0.7100024",
"0.7100024",
"0.7100024",
"0.7100024",
"0.7100024",
"0.7069579",
"0.7066821",
"0.7014976",
"0.7004748",
"0.70029414",
"0.7002628",
"0.7001811",
"0.7000675",
"0.6999229",
"0.6986158",
"0.6983428",
"0.69546866",... | 0.83689624 | 0 |
Derives the ReLU lower linear relaxation of the equations | def lower_relu_relax(self,
lower=None,
upper=None,
approx=ReluApproximation.MIN_AREA):
if lower is None:
if self.lower_bounds is None:
raise Exception("Missing lower bounds")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_ReLU(self):\n y = self.x\n y[y<=0] = 0\n y[y>0] = 1\n return y\n raise NotImplementedError(\"ReLU gradient not implemented\")",
"def grad_ReLU(self):\n grad = np.where(self.x > 0, 1, 0)\n return grad",
"def relu_grad(self, X):\n X[X<=0]=0\n X[X>0]... | [
"0.7131731",
"0.6747368",
"0.6707108",
"0.66877747",
"0.6657281",
"0.6642916",
"0.6642612",
"0.6607677",
"0.6585322",
"0.6545697",
"0.6419472",
"0.64046717",
"0.6376201",
"0.6376201",
"0.6376201",
"0.6376201",
"0.6376201",
"0.6376201",
"0.6376201",
"0.6376201",
"0.63710904",
... | 0.6170773 | 36 |
Derives the ReLU upper linear relaxation of the equations | def upper_relu_relax(self, lower=None, upper=None):
if lower is None:
if self.lower_bounds is None:
raise Exception("Missing lower bounds")
else:
lower = self.lower_bounds
if upper is None:
if self.upper_bounds is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relu_backward(self, dUpper, cache):\n x = cache\n #############################################################################\n # TODO: Implement the ReLU backward pass. #\n #########################################################################... | [
"0.7306047",
"0.7157563",
"0.7006479",
"0.68646705",
"0.68079174",
"0.67728573",
"0.6710409",
"0.66703856",
"0.66508466",
"0.66477334",
"0.66354465",
"0.6621035",
"0.66203266",
"0.66203266",
"0.6595877",
"0.64985704",
"0.6485435",
"0.6472963",
"0.6459412",
"0.6459412",
"0.645... | 0.68053263 | 5 |
Parallel ReLU approximation of the given equation. | def parallel(self, coeffs, const, l, u, bound_line):
if not bound_line in ['lower','upper']:
raise Exception('Got invalid bound line')
adj = u / (u - l)
coeffs *= adj
if bound_line == 'lower':
const *= adj
else:
const = const * adj -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grad_ReLU(self):\n y = self.x\n y[y<=0] = 0\n y[y>0] = 1\n return y\n raise NotImplementedError(\"ReLU gradient not implemented\")",
"def ReLU(self, x):\n self.x = x\n output = np.maximum(0, x)\n return output",
"def solver(u_init, eta_0, eta, eta_lin, T, H, L_lh... | [
"0.60607123",
"0.6044863",
"0.6026348",
"0.60195994",
"0.6013499",
"0.6012523",
"0.5983782",
"0.597557",
"0.59669906",
"0.5895011",
"0.58894837",
"0.5825326",
"0.58149797",
"0.5802161",
"0.58004385",
"0.5769199",
"0.5764912",
"0.5763584",
"0.57361203",
"0.5735019",
"0.5728779... | 0.0 | -1 |
Rotates the right side of the cube_list clockwise. | def rotate_right_list(liste):
rotate_cube_left_list(liste)
rotate_front_list(liste)
rotate_cube_right_list(liste)
return liste | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_right_prime_list(liste):\n \n rotate_cube_left_list(liste)\n rotate_front_prime_list(liste)\n rotate_cube_right_list(liste)\n \n return liste",
"def test_rotate_right(self):\n # Testing 'down' rotation clockwise\n side = 'R'\n rotation = list(self.cube.rotate_cub... | [
"0.76209295",
"0.761266",
"0.7418328",
"0.7176604",
"0.710287",
"0.7078367",
"0.6937082",
"0.69143003",
"0.6856673",
"0.68461305",
"0.6794458",
"0.676427",
"0.67381024",
"0.6703621",
"0.6685076",
"0.6683571",
"0.6667203",
"0.65772945",
"0.65599954",
"0.6471596",
"0.6449253",
... | 0.81258357 | 0 |
Rotates the right side of the cube_list counterclockwise. | def rotate_right_prime_list(liste):
rotate_cube_left_list(liste)
rotate_front_prime_list(liste)
rotate_cube_right_list(liste)
return liste | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_right_list(liste):\n \n rotate_cube_left_list(liste)\n rotate_front_list(liste)\n rotate_cube_right_list(liste)\n \n return liste",
"def test_rotate_right(self):\n # Testing 'down' rotation clockwise\n side = 'R'\n rotation = list(self.cube.rotate_cube(side))\n ... | [
"0.80161667",
"0.7563545",
"0.74146587",
"0.72397256",
"0.7107339",
"0.6995983",
"0.68357015",
"0.67977905",
"0.6779721",
"0.6744077",
"0.6717455",
"0.66077065",
"0.6592382",
"0.6561183",
"0.6556645",
"0.6533344",
"0.6495726",
"0.6460009",
"0.64518946",
"0.64374316",
"0.63750... | 0.7527656 | 2 |
Rotates the left side of the cube_list clockwise. | def rotate_left_list(liste):
rotate_cube_right_list(liste)
rotate_front_list(liste)
rotate_cube_left_list(liste)
return liste | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_cube_left_list(liste):\n \n rotate_cube_right_list(liste)\n rotate_cube_right_list(liste)\n rotate_cube_right_list(liste)\n \n return liste",
"def test_rotate_left(self):\n # Testing 'Left' rotation clockwise\n side = 'L'\n rotation = list(self.cube.rotate_cube(s... | [
"0.8521198",
"0.79685587",
"0.7698663",
"0.74194646",
"0.7376219",
"0.7364561",
"0.723923",
"0.71934074",
"0.7075466",
"0.7056575",
"0.70334315",
"0.69970316",
"0.69277805",
"0.68947583",
"0.68325144",
"0.68210965",
"0.67885363",
"0.6783461",
"0.6738628",
"0.66348",
"0.657631... | 0.8266426 | 1 |
Rotates the left side of the cube_list counterclockwise. | def rotate_left_prime_list(liste):
rotate_cube_right_list(liste)
rotate_front_prime_list(liste)
rotate_cube_left_list(liste)
return liste | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_cube_left_list(liste):\n \n rotate_cube_right_list(liste)\n rotate_cube_right_list(liste)\n rotate_cube_right_list(liste)\n \n return liste",
"def rotate_left_list(liste):\n \n rotate_cube_right_list(liste)\n rotate_front_list(liste)\n rotate_cube_left_list(liste)\n \n... | [
"0.85012096",
"0.818709",
"0.794474",
"0.74676716",
"0.7256383",
"0.72369987",
"0.70646816",
"0.6961701",
"0.6946463",
"0.69390154",
"0.6892068",
"0.6867442",
"0.6828253",
"0.6825331",
"0.68026096",
"0.6723013",
"0.66132116",
"0.65768117",
"0.65574956",
"0.65163153",
"0.65104... | 0.7628549 | 3 |
that converts a numeric label vector into a onehot matrix | def one_hot_encode(Y, classes):
if type(classes) is not int:
return None
if Y is None or type(Y) != np.ndarray:
return None
for c in Y:
if c >= classes or c < 0:
return None
m = Y.shape[0]
mtx = np.zeros((m, classes))
for row, c_label in zip(mtx, Y):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def To1hot(label,num_class):\n onehot = np.zeros(num_class)\n onehot[label] = 1\n return onehot",
"def label_to_one_hot(label, num_of_class=2):\r\n import numpy as np\r\n one_hot = np.zeros((len(label), num_of_class), dtype=np.uint8)\r\n for i in range(len(label)):\r\n one_hot[i, int(lab... | [
"0.84427243",
"0.83169335",
"0.8248666",
"0.8032837",
"0.80040425",
"0.7981706",
"0.79662246",
"0.79623336",
"0.7956706",
"0.7950935",
"0.79505235",
"0.7917842",
"0.7912336",
"0.79033035",
"0.7900165",
"0.7855747",
"0.78505445",
"0.78505445",
"0.78505445",
"0.7847322",
"0.784... | 0.0 | -1 |
Convert to/from Decimal when working with DynamoDB (which only accepts Decimals for numbers) WARN There may be a loss of precision but it is assumed to not affect our usecase | def add_support_for_floats_to_dynamodb():
# Ignore loss of precision rather than raising exception
DYNAMODB_CONTEXT.clear_traps()
# Keep a reference to the original serialization methods
boto3_serialize_orig = TypeSerializer.serialize
boto3_deserialize_orig = TypeDeserializer.deserialize
# Wr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_bson(self, value):\r\n return value.to_decimal()",
"def transform_bson(self, value):\r\n return value.to_decimal()",
"def convert_decimal(value: t.Any) -> Decimal:\n return Decimal(value)",
"def _serialize_decimal(val):\n return float(val)",
"def decode(val):\n ... | [
"0.7714067",
"0.7714067",
"0.75539654",
"0.72507405",
"0.69677407",
"0.680333",
"0.68014437",
"0.6641506",
"0.65624845",
"0.6536792",
"0.6483981",
"0.64125466",
"0.64125466",
"0.6299127",
"0.6287727",
"0.6280396",
"0.6261581",
"0.62260425",
"0.61969995",
"0.6175216",
"0.61097... | 0.6726598 | 7 |
Return the path where the project is stored If no path is given then the directory equals the project name | def project_path(manifest, project):
return manifest.findall('project[@name="{}"]'.format(project))[0]\
.attrib.get('path', project) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_directory(self):\n\n # try to figure it out from the maps\n # search for Project path\n\n project_dir = None\n maps = self.comp_prefs['Paths'].get('Map', None)\n if maps:\n project_dir = maps.get('Project:', None)\n\n #if not project_dir:\n # ... | [
"0.8023564",
"0.78888243",
"0.7857894",
"0.76962245",
"0.7675844",
"0.7612164",
"0.7544314",
"0.753739",
"0.7445059",
"0.7439758",
"0.73728657",
"0.73215693",
"0.7263962",
"0.7229706",
"0.72038746",
"0.71774435",
"0.7167297",
"0.7091329",
"0.7079118",
"0.705912",
"0.7002835",... | 0.65714806 | 62 |
Compute the Gaussian term in the BFE | def cost_gauss(self):
J = np.mean(self.zvar1/self.rvar1 + np.log(2*np.pi*self.rvar1))
J = J*np.product(self.shape1)
if not self.is_complex:
J = J / 2
return J | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Gaussian(x, mu=0, sigma=26.4, A=1, y0=0):\r\n #width = sigma*(2*np.sqrt(2*np.log(2)))\r\n b = 1/(sigma*np.sqrt(2*np.pi))\r\n f = b*np.power(np.e, -(((x-mu)**2)/(2*sigma**2)))\r\n return A*f + y0",
"def gaussian(x, mean, sigma):\n return np.exp(-np.square(x-mean)/(2*np.square(sigma))) / (np.sqr... | [
"0.703246",
"0.69801235",
"0.6965129",
"0.6963982",
"0.69310075",
"0.691842",
"0.6871344",
"0.68653834",
"0.68414223",
"0.681016",
"0.6799086",
"0.67345613",
"0.6701154",
"0.66861856",
"0.66811895",
"0.66327184",
"0.66315466",
"0.6629523",
"0.66265506",
"0.6623255",
"0.661402... | 0.0 | -1 |
Convert a ProxyFSstyle Unix timestamp to a Swift XTimestamp header. ProxyFS uses an integral number of nanoseconds since the epoch, while Swift uses a floatingpoint number with centimillisecond (10^5 second) precision. | def x_timestamp_from_epoch_ns(epoch_ns):
return "{0:.5f}".format(float(epoch_ns) / 1000000000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_to_timestamp(unix):\n return int(round(unix * 1e6))",
"def to_unix_milli(self):\n try:\n dt_obj = duparser.parse(timestamp)\n self.out_unix_milli = str(int((dt_obj - self.epoch_1970).total_seconds()*1000))\n except Exception as e:\n if not args.log:\n ... | [
"0.6420203",
"0.641238",
"0.6385286",
"0.63408726",
"0.63316077",
"0.63173443",
"0.6270595",
"0.62387526",
"0.6224708",
"0.6172716",
"0.6169617",
"0.6118644",
"0.6104126",
"0.6067934",
"0.6057176",
"0.6057018",
"0.6016646",
"0.5998626",
"0.599771",
"0.59944415",
"0.5992304",
... | 0.7334592 | 0 |
Convert a Unix timestamp to an ISO8601 timestamp. | def iso_timestamp_from_epoch_ns(epoch_ns):
iso_timestamp = datetime.datetime.utcfromtimestamp(
epoch_ns / 1000000000.0).isoformat()
# Convieniently (ha!), isoformat() method omits the
# fractional-seconds part if it's equal to 0. The Swift proxy server
# does not, so we match its output.
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_to_iso(unix_time):\n return datetime.datetime.fromtimestamp(\n int(unix_time)).strftime('%Y-%m-%d %H:%M:%S')",
"def iso8601_from_timestamp(timestamp):\r\n return isotime(datetime.datetime.utcfromtimestamp(timestamp))",
"def timestamp_to_iso_format(timestamp):\n if timestamp is ... | [
"0.7533406",
"0.7212999",
"0.70693547",
"0.69501615",
"0.6945923",
"0.68842906",
"0.6734284",
"0.6683595",
"0.6657134",
"0.6648342",
"0.6617415",
"0.659037",
"0.65685993",
"0.65102386",
"0.6463697",
"0.64242846",
"0.6393386",
"0.639169",
"0.63544",
"0.6320679",
"0.62869465",
... | 0.63215464 | 19 |
Convert a Unix timestamp to an IMFFixdate timestamp. | def last_modified_from_epoch_ns(epoch_ns):
return time.strftime(
'%a, %d %b %Y %H:%M:%S GMT',
time.gmtime(math.ceil(epoch_ns / 1000000000.0))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_timestamp_date(unix=1459141485):\n return datetime.datetime.fromtimestamp(int(unix))",
"def unix_to_timestamp(unix):\n return int(round(unix * 1e6))",
"def timestamp_to_unix(timestamp):\n return timestamp / 1e6",
"def datetimeToUnix(date):\n return int(time.mktime(date.timetuple())*1000)... | [
"0.7322303",
"0.7154461",
"0.7041307",
"0.70184076",
"0.68960834",
"0.68862784",
"0.67894566",
"0.6457113",
"0.63675153",
"0.6362558",
"0.6274187",
"0.62563026",
"0.62460876",
"0.6234938",
"0.62332195",
"0.62326264",
"0.6224717",
"0.61910015",
"0.6173991",
"0.6158443",
"0.613... | 0.0 | -1 |
Get shape of array or 1 if the object does not support shape | def shape_or_default(arr, index):
try:
return arr.shape[index]
except AttributeError:
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_shape(x):\n\n return None if jnp.isscalar(x) else x.shape",
"def shape(self):\n\n self._check_assigned()\n\n if (\n self.lazy\n and self.transformer is not None\n and hasattr(self.transformer, \"get_transformed_shape\")\n ):\n return sel... | [
"0.7697862",
"0.7428352",
"0.73896754",
"0.7322635",
"0.72524244",
"0.7245066",
"0.71863836",
"0.7156521",
"0.713971",
"0.7101113",
"0.70778614",
"0.7028759",
"0.7028759",
"0.70055145",
"0.69855595",
"0.69683975",
"0.6959355",
"0.6941429",
"0.6924605",
"0.69074667",
"0.690072... | 0.743687 | 1 |
Returns a version of A with the minimum number of dimensions specified by "ndmin". I `A` is `None`, return the defult given by `A_default` | def set_minimum_dimensions(A, A_default, ndmin=3):
if A is None:
return np.array(A_default, ndmin=ndmin)
else:
return np.array(A, ndmin=ndmin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atmin(a,lowerlimit=None,dimension=None,inclusive=1):\r\n if inclusive: lowerfcn = N.greater\r\n else: lowerfcn = N.greater_equal\r\n if dimension == None:\r\n a = N.ravel(a)\r\n dimension = 0\r\n if lowerlimit == None:\r\n lowerlimit = N.minimum.red... | [
"0.6284689",
"0.6102426",
"0.6052727",
"0.6025506",
"0.60000527",
"0.5954084",
"0.59052277",
"0.5786386",
"0.57333195",
"0.5711122",
"0.56931424",
"0.56679213",
"0.5667801",
"0.5596154",
"0.55952406",
"0.55802566",
"0.5565413",
"0.5558123",
"0.5557664",
"0.5513188",
"0.546084... | 0.8403805 | 0 |
Set the name for this run. | def name_option(args, run):
run.experiment_info["name"] = args
run.run_logger = run.root_logger.getChild(args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n ... | [
"0.8201576",
"0.8201576",
"0.8201576",
"0.8201576",
"0.8201576",
"0.8194042",
"0.8194042",
"0.8188446",
"0.8176618",
"0.8176618",
"0.81599504",
"0.81488526",
"0.813865",
"0.813366",
"0.8089178",
"0.807367",
"0.8053386",
"0.80366105",
"0.78878784",
"0.7826724",
"0.78101045",
... | 0.0 | -1 |
plot loss or accuracy vs epoch of nn models. | def train_nn(train_nn_results, label, title, yaxis):
plt.figure(figsize=(12,5))
for i in range(len(label)):
plt.plot(train_nn_results[i], label=label[i], alpha=0.75)
plt.title(title)
plt.xlabel('epoch')
plt.ylabel(yaxis)
plt.legend(bbox_to_anchor=(1.05, 1.0), loc='upper left')
plt.ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_viz(self) :\n self.train\n history = self.history\n plot_loss(history)",
"def plot_observations():\n plt.plot(history.history['loss'], label='training_loss')\n plt.plot(history.history['val_loss'], label='val_loss ')\n plt.xlabel('Epoch')\n plt.ylabel('Loss')\n pl... | [
"0.7840626",
"0.7762002",
"0.7590462",
"0.7568865",
"0.7496373",
"0.7421823",
"0.73668873",
"0.736629",
"0.7361258",
"0.73251235",
"0.7300026",
"0.7290479",
"0.72688633",
"0.72678214",
"0.726457",
"0.7261784",
"0.72438496",
"0.7228393",
"0.72273076",
"0.71962136",
"0.71784425... | 0.7580432 | 3 |
Precision metric. Only computes a batchwise average of precision. Computes the precision, a metric for multilabel classification of how many selected items are relevant. | def precision(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
precision = true_positives / (predicted_positives + K.epsilon())
return precision | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(self):\n self.overall_precision = precision_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_precision = precision_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)",
"def comp... | [
"0.74892753",
"0.72888154",
"0.7159203",
"0.7152673",
"0.7065861",
"0.6985656",
"0.6965553",
"0.69546396",
"0.69123477",
"0.6835058",
"0.68175006",
"0.68092614",
"0.68046975",
"0.68046975",
"0.68046975",
"0.68046975",
"0.68046975",
"0.68046975",
"0.67853945",
"0.6754717",
"0.... | 0.6757285 | 27 |
Recall metric. Only computes a batchwise average of recall. Computes the recall, a metric for multilabel classification of how many relevant items are selected. | def recall(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
recall = true_positives / (possible_positives + K.epsilon())
return recall | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall(y_true, y_pred, average, labels):\n\n y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)\n\n result = None\n\n m = len(y_true)\n n = len(labels)\n\n confusion_matrix = get_confusion_matrix(y_true, y_pred, labels).T\n\n if average == \"micro\":\n numerator = np.t... | [
"0.7604412",
"0.7447652",
"0.74042964",
"0.72808254",
"0.7208795",
"0.7165644",
"0.7157375",
"0.71450114",
"0.71450114",
"0.71450114",
"0.71450114",
"0.71450114",
"0.71450114",
"0.7131455",
"0.7100775",
"0.70969015",
"0.70969015",
"0.70969015",
"0.70969015",
"0.70969015",
"0.... | 0.70625025 | 44 |
Create the message object | def __init__(self, func, connection, *args):
self.func = func
self.connection = connection
self.args = args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createMessage( self, *args, **kw ):\n return MailMessage( *args, **kw )",
"def construct_message(self):\n msg_type = self.msg_type\n if msg_type == \"PUBMSG\":\n msg_type = \"PRIVMSG\"\n ret = \"{} {}\".format(msg_type, self.target)\n if self.content:\n ... | [
"0.76504874",
"0.7585833",
"0.75186765",
"0.74360585",
"0.74298024",
"0.7383071",
"0.7336232",
"0.72981703",
"0.7278692",
"0.7187506",
"0.7160506",
"0.71086955",
"0.71086955",
"0.71086955",
"0.70868015",
"0.70794654",
"0.70493186",
"0.7034987",
"0.70267284",
"0.7016149",
"0.7... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.