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 |
|---|---|---|---|---|---|---|
Exclusive cumulative product [a, b, c] => [1, a, a b]. | def exclusive_cumprod(x):
return torch.cumprod(torch.cat([x.new_ones(x.size(0), x.size(1), x.size(2), 1), x[:, :, :, :-1]], dim=-1), dim=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclusive_cumprod(x):\n batch_size, sequence_length = x.size()\n if torch.cuda.is_available():\n one_x = torch.cat([torch.ones(batch_size, 1).cuda(), x], dim=1)[:, :-1]\n else:\n one_x = torch.cat([torch.ones(batch_size, 1), x], dim=1)[:, :-1]\n return torch.cumprod(one_x, dim=1)",
... | [
"0.6493785",
"0.63520443",
"0.63430756",
"0.62086827",
"0.6141053",
"0.6095739",
"0.6074374",
"0.6036782",
"0.6014533",
"0.6008751",
"0.5996542",
"0.5989799",
"0.5978214",
"0.5975621",
"0.59702927",
"0.58960617",
"0.58550143",
"0.58122396",
"0.5811169",
"0.58085984",
"0.57931... | 0.7000043 | 0 |
Exclusive cumulative summation [a, b, c] => [0, a, a + b]. | def exclusive_cumsum(x):
return torch.cumsum(torch.cat([x.new_zeros(x.size(0), x.size(1), x.size(2), 1), x[:, :, :, :-1]], dim=-1), dim=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumulative_sum(array):\n res = []\n val = 0\n for elem in array:\n val += elem\n res.append(val)\n return res",
"def _cumulative_sum(xs):\r\n cumsum = 0\r\n for x in xs:\r\n cumsum += x\r\n yield cumsum",
"def cumulative_sum(self, lis):\n new_list = []\n ... | [
"0.6689731",
"0.66383153",
"0.6569255",
"0.6440996",
"0.6393785",
"0.63028944",
"0.6241263",
"0.6237763",
"0.62358797",
"0.62301064",
"0.6229351",
"0.6110942",
"0.61066085",
"0.6094809",
"0.60819846",
"0.6038847",
"0.6037633",
"0.59576744",
"0.5953263",
"0.5944911",
"0.592947... | 0.7269981 | 0 |
Numerically stable cumulative product by cumulative sum in logspace. | def safe_cumprod(x, eps):
return torch.exp(exclusive_cumsum(torch.log(torch.clamp(x, min=eps, max=1.0)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_cum_sum(A, output_sum=False):\n C = [A[0]]\n for a in A[1:]:\n C.append(log_add(C[-1], a))\n C_norm = np.array(C) - C[-1]\n if output_sum:\n return C_norm, C[-1]\n else:\n return C_norm",
"def logcumsumexp(x):\n return LogCumSumExp().apply((x,))[0]",
"def contour_cumsum(logZ):\n Z =... | [
"0.6546338",
"0.63571435",
"0.6330023",
"0.62616724",
"0.61612576",
"0.6146385",
"0.6043716",
"0.5988268",
"0.5953194",
"0.59457064",
"0.5920262",
"0.58826333",
"0.5816247",
"0.5797719",
"0.5794015",
"0.57365125",
"0.57337433",
"0.57286125",
"0.57194465",
"0.5693854",
"0.5685... | 0.66625124 | 0 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters_xavier_uniform(self, bias):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
nn.init.xavier_uniform_(self.w_value.weight, gain=1 / math.sqrt(2))
if bias:
nn.init.constant_(self.w_value.bias, 0.0)
nn.init.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.7344358",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.639197... | 0.73425686 | 5 |
Convert torch.Tensor to np.ndarray. | def tensor2np(x):
if x is None:
return x
return x.cpu().detach().numpy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _torch_to_numpy(tensor):\n return tensor.detach().cpu().numpy()",
"def to_numpy(tensor):\n raise NotImplementedError",
"def to_numpy(x):\n if isinstance(x, torch.Tensor):\n x = x.cpu().detach().numpy()\n return x",
"def to_numpy(tensor: torch.Tensor) -> np.ndarray:\n\n return (\... | [
"0.8792341",
"0.8669351",
"0.8364438",
"0.81377304",
"0.78867817",
"0.78581226",
"0.7845422",
"0.7812185",
"0.76115113",
"0.7564423",
"0.7490343",
"0.73312527",
"0.7305127",
"0.73012763",
"0.7248118",
"0.7237875",
"0.71136487",
"0.7094349",
"0.70864075",
"0.70842844",
"0.7084... | 0.74059236 | 11 |
Initialize parameters with normal distribution. | def reset_parameters(self):
logger.info('===== Initialize %s with normal distribution =====' % self.__class__.__name__)
for n, p in self.named_parameters():
init_like_transformer_xl(n, p, std=0.02) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeDistribution(self):\n if self.lowerBoundUsed == False and self.upperBoundUsed == False:\n self._distribution = distribution1D.BasicLogNormalDistribution(self.mean,self.sigma,self.low)\n self.lowerBound = 0.0\n self.upperBound = sys.float_info.max\n else:\n if self.lowerBoun... | [
"0.7574558",
"0.7343479",
"0.72798926",
"0.7274825",
"0.7132833",
"0.7121804",
"0.7114689",
"0.70850563",
"0.707883",
"0.70745164",
"0.70745164",
"0.7054318",
"0.70373267",
"0.7009945",
"0.7003029",
"0.6990678",
"0.6990551",
"0.69468653",
"0.69468653",
"0.69468653",
"0.694686... | 0.81345344 | 0 |
Plot attention for each head in all layers. | def plot_attention(self, n_cols=4):
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
save_path = mkdir_join(self.save_path, 'att_weights')
if save_path is not None and os.path.isdir(save_path):
shutil.rmtree(save_path)
os.mkdir(save_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_attention(self):\n self.enc._plot_attention(mkdir_join(self.save_path, 'enc_att_weights'))\n self.dec_fwd._plot_attention(mkdir_join(self.save_path, 'dec_att_weights'))\n if getattr(self, 'dec_fwd_sub1', None) is not None:\n self.dec_fwd_sub1._plot_attention(mkdir_join(self... | [
"0.646569",
"0.64632165",
"0.6310682",
"0.6269028",
"0.6232784",
"0.62253404",
"0.5981933",
"0.5880419",
"0.58211744",
"0.5814863",
"0.58055794",
"0.5751948",
"0.57507646",
"0.5551681",
"0.5551211",
"0.55414927",
"0.55142474",
"0.55113226",
"0.54786706",
"0.54748267",
"0.5438... | 0.6914619 | 1 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters_xavier_uniform(self):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
for n, p in self.named_parameters():
init_with_xavier_uniform(n, p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier u... | [
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.634... | 0.806636 | 1 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self):
logger.info('===== Initialize %s =====' % self.__class__.__name__)
nn.init.normal_(self.embed.weight, mean=0.0, std=self.d_model ** -0.5)
nn.init.constant_(self.embed.weight[self.pad], 0)
if self.output is not None and not self.tie_embedding:
nn.in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.641769... | 0.0 | -1 |
Plot attention for each head in all layers. | def plot_attention(self, n_cols=4):
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
save_path = mkdir_join(self.save_path, 'att_weights')
if save_path is not None and os.path.isdir(save_path):
shutil.rmtree(save_path)
os.mkdir(save_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_attention(self):\n self.enc._plot_attention(mkdir_join(self.save_path, 'enc_att_weights'))\n self.dec_fwd._plot_attention(mkdir_join(self.save_path, 'dec_att_weights'))\n if getattr(self, 'dec_fwd_sub1', None) is not None:\n self.dec_fwd_sub1._plot_attention(mkdir_join(self... | [
"0.646569",
"0.64632165",
"0.6310682",
"0.6269028",
"0.6232784",
"0.62253404",
"0.5981933",
"0.5880419",
"0.58211744",
"0.5814863",
"0.58055794",
"0.5751948",
"0.57507646",
"0.5551681",
"0.5551211",
"0.55414927",
"0.55142474",
"0.55113226",
"0.54786706",
"0.54748267",
"0.5438... | 0.6914619 | 0 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
for n, p in self.named_parameters():
init_with_xavier_uniform(n, p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.6340099... | 0.77669495 | 2 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters_xavier_uniform(self):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
for conv_layer in [self.pointwise_conv1, self.pointwise_conv2, self.depthwise_conv]:
for n, p in conv_layer.named_parameters():
init_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.63919... | 0.7344358 | 4 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters_xavier_uniform(self):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
for n, p in self.named_parameters():
init_with_xavier_uniform(n, p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier u... | [
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.634... | 0.806636 | 0 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self, bias):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
nn.init.xavier_uniform_(self.w_key.weight, gain=1 / math.sqrt(2))
nn.init.xavier_uniform_(self.w_value.weight, gain=1 / math.sqrt(2))
nn.init.xavier_unifo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.6340099... | 0.69540745 | 10 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
for n, p in self.named_parameters():
init_with_xavier_uniform(n, p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.6340099... | 0.77669495 | 3 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self, bias):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
nn.init.xavier_uniform_(self.w_key.weight, gain=1 / math.sqrt(2))
nn.init.xavier_uniform_(self.w_value.weight, gain=1 / math.sqrt(2))
nn.init.xavier_unifo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69540745",
"0.69540745",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.639197... | 0.69970345 | 9 |
Calculate relative positional attention efficiently. | def _rel_shift(self, xs):
bs, qlen, klen, n_heads = xs.size()
xs = xs.permute(0, 3, 2, 1)
idx = torch.arange(klen, device=xs.device)
k_idx, q_idx = idx.unsqueeze(0), idx.unsqueeze(1)
rel_pos_idx = torch.abs(k_idx - q_idx)
if klen != qlen:
rel_pos_idx = rel_pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attention(self):\n center_of_attention = 0\n distance = 10000\n for person in self.peoples:\n if person is not None:\n if person.X < distance: #person's depth is now their X position in edwin frame\n center_of_attention = person.ID\n ... | [
"0.648994",
"0.58828235",
"0.5755099",
"0.57287055",
"0.5671765",
"0.5566679",
"0.551269",
"0.54826665",
"0.545922",
"0.54565316",
"0.545392",
"0.5452417",
"0.54508513",
"0.5444638",
"0.54403037",
"0.5411769",
"0.5404094",
"0.5403679",
"0.54023945",
"0.5363162",
"0.53571427",... | 0.0 | -1 |
Initialize parameters with Xavier uniform distribution. | def reset_parameters(self, bias):
logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)
nn.init.xavier_uniform_(self.w_key.weight, gain=1 / math.sqrt(2))
nn.init.xavier_uniform_(self.w_value.weight, gain=1 / math.sqrt(2))
nn.init.xavier_unifo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters_xavier_uniform(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters_xavier_uniform(self):\n logger.info('===... | [
"0.806636",
"0.806636",
"0.77669495",
"0.77669495",
"0.7344358",
"0.73425686",
"0.73276925",
"0.71655196",
"0.7065156",
"0.69970345",
"0.68392104",
"0.6785259",
"0.6736141",
"0.6662863",
"0.662158",
"0.6493551",
"0.64513046",
"0.6444853",
"0.64176935",
"0.6391971",
"0.6340099... | 0.69540745 | 11 |
Plot attention for each head in all encoder layers. | def _plot_attention(self, save_path=None, n_cols=2):
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
if save_path is not None and os.path.isdir(save_path):
shutil.rmtree(save_path)
os.mkdir(save_path)
if not hasattr(self, 'aws_dict')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_attention(self, n_cols=4):\n from matplotlib import pyplot as plt\n from matplotlib.ticker import MaxNLocator\n save_path = mkdir_join(self.save_path, 'att_weights')\n if save_path is not None and os.path.isdir(save_path):\n shutil.rmtree(save_path)\n os.m... | [
"0.67286044",
"0.67286044",
"0.6587178",
"0.6359585",
"0.62902516",
"0.621487",
"0.6186881",
"0.6144011",
"0.6079009",
"0.5922048",
"0.56025463",
"0.55551493",
"0.55443436",
"0.5537384",
"0.5522669",
"0.54828805",
"0.5480976",
"0.54666936",
"0.5453203",
"0.5439486",
"0.541980... | 0.6361995 | 3 |
Calculate the total left context size accumulated by layer depth. This corresponds to the frame length after CNN subsampling. | def _total_chunk_size_left(self):
if self.streaming_type == 'reshape':
return self.N_l // self.conv_factor
elif self.streaming_type == 'mask':
return self.N_l // self.conv_factor * self.n_layers
elif self.unidir:
return 10000 // self.conv_factor
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_context_length(self):\n return self.context_length",
"def calculate_cache_size(self):\n cache_size = self._total_chunk_size_left()\n N_l = self.N_l // self.conv_factor\n cache_sizes = []\n for lth in range(self.n_layers):\n cache_sizes.append(cache_size)\n ... | [
"0.6590418",
"0.6038331",
"0.6025549",
"0.5989884",
"0.59609467",
"0.59070575",
"0.588969",
"0.58781016",
"0.58452356",
"0.58216274",
"0.5778645",
"0.5767148",
"0.57618845",
"0.57518864",
"0.5717351",
"0.5703931",
"0.5696618",
"0.5693991",
"0.56608164",
"0.56593925",
"0.56491... | 0.7225226 | 0 |
Flips a label probability matrix. This function rotates a label probability matrix and flips it. ``log_probs[i, b, l]`` stores log probability of label ``l`` at ``i``th input in ``b``th batch. The rotated matrix ``r`` is defined as ``r[i, b, l] = log_probs[i + xlens[b], b, l]`` | def _flip_label_probability(log_probs, xlens):
xmax, bs, vocab = log_probs.size()
rotate = (torch.arange(xmax, dtype=torch.int64)[:, None] + xlens) % xmax
return torch.flip(log_probs[rotate[:, :, None], torch.arange(bs, dtype=torch.int64)[None, :, None], torch.arange(vocab, dtype=torch.int64)[None, None, :]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _flip_path_probability(cum_log_prob, xlens, path_lens):\n xmax, bs, max_path_len = cum_log_prob.size()\n rotate_input = (torch.arange(xmax, dtype=torch.int64)[:, None] + xlens) % xmax\n rotate_label = (torch.arange(max_path_len, dtype=torch.int64) + path_lens[:, None]) % max_path_len\n return torch... | [
"0.64106804",
"0.5399662",
"0.52386487",
"0.52205276",
"0.52205276",
"0.51971644",
"0.5100227",
"0.5096308",
"0.5037345",
"0.50290304",
"0.5013716",
"0.49833155",
"0.49775818",
"0.49425662",
"0.48713636",
"0.48695782",
"0.48171163",
"0.48131028",
"0.47792274",
"0.4735433",
"0... | 0.7762457 | 0 |
Flips a path probability matrix. This function returns a path probability matrix and flips it. ``cum_log_prob[i, b, t]`` stores log probability at ``i``th input and at time ``t`` in a output sequence in ``b``th batch. The rotated matrix ``r`` is defined as ``r[i, j, k] = cum_log_prob[i + xlens[j], j, k + path_lens[j]]`... | def _flip_path_probability(cum_log_prob, xlens, path_lens):
xmax, bs, max_path_len = cum_log_prob.size()
rotate_input = (torch.arange(xmax, dtype=torch.int64)[:, None] + xlens) % xmax
rotate_label = (torch.arange(max_path_len, dtype=torch.int64) + path_lens[:, None]) % max_path_len
return torch.flip(cum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _flip_path(path, path_lens):\n bs = path.size(0)\n max_path_len = path.size(1)\n rotate = (torch.arange(max_path_len) + path_lens[:, None]) % max_path_len\n return torch.flip(path[torch.arange(bs, dtype=torch.int64)[:, None], rotate], dims=[1])",
"def _flip_label_probability(log_probs, xlens):\n ... | [
"0.57424736",
"0.51253265",
"0.507264",
"0.48246416",
"0.46797547",
"0.4674802",
"0.45938978",
"0.45460165",
"0.4514608",
"0.44524458",
"0.44298074",
"0.4391341",
"0.4348778",
"0.4341245",
"0.43182975",
"0.43150553",
"0.43010318",
"0.42937058",
"0.4281577",
"0.42590138",
"0.4... | 0.7787628 | 0 |
Compute KL divergence loss for label smoothing of CTC and Transducer models. | def kldiv_lsm_ctc(logits, ylens):
bs, _, vocab = logits.size()
log_uniform = logits.new_zeros(logits.size()).fill_(math.log(1 / (vocab - 1)))
probs = torch.softmax(logits, dim=-1)
log_probs = torch.log_softmax(logits, dim=-1)
loss = torch.mul(probs, log_probs - log_uniform)
loss_mean = sum([loss... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_KL_divergence(self):\n KL_loss = 0\n if(self.Bayesian):\n for i in range(self.num_layers):\n KL_loss += getattr(self, 'LSTMCell%i'%(i+1)).get_KL_divergence()\n \n return KL_loss",
"def get_KL_divergence(self):\n KL_loss_W = Vil.get_KL_d... | [
"0.7460967",
"0.7263157",
"0.70623726",
"0.6756357",
"0.66436434",
"0.6596325",
"0.65438193",
"0.64893746",
"0.64019805",
"0.63941824",
"0.6393777",
"0.63899916",
"0.6376338",
"0.6291182",
"0.62788856",
"0.62784314",
"0.62473625",
"0.6214018",
"0.6209181",
"0.6201188",
"0.618... | 0.5904937 | 37 |
Plot attention weights during training. | def plot_attention(self):
self.enc._plot_attention(mkdir_join(self.save_path, 'enc_att_weights'))
self.dec_fwd._plot_attention(mkdir_join(self.save_path, 'dec_att_weights'))
if getattr(self, 'dec_fwd_sub1', None) is not None:
self.dec_fwd_sub1._plot_attention(mkdir_join(self.save_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_nested_attention_weights(aw, token_list=[], label_list_sub=[],\n save_path=None, figsize=(10, 4)):\n plt.clf()\n plt.figure(figsize=figsize)\n\n # Plot attention weights\n sns.heatmap(awmap='viridis',\n xticklabels=label_list_sub,\n ... | [
"0.70825773",
"0.66172254",
"0.6505432",
"0.6505432",
"0.64537954",
"0.6428283",
"0.6311744",
"0.61905557",
"0.60598105",
"0.60046244",
"0.5993617",
"0.5930997",
"0.59203744",
"0.5884207",
"0.5874305",
"0.58698034",
"0.5843123",
"0.58024925",
"0.5788399",
"0.5785678",
"0.5757... | 0.6724346 | 1 |
Confirm image selection. After you have used the search API, you should hit this API to indicate photo usage to the server. | def confirm_image_selection(self, id):
path = {}
data = {}
params = {}
# REQUIRED - PATH - id
"""
The ID from the image_search result.
"""
path["id"] = id
self.logger.debug(
"POST /api/v1/image_selection/{id} with query params: {p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnImageChosen(self, event):\n if self._image_listbox.GetStringSelection() != '':\n self._image_path = os.path.join(self._image_dict[self._image_listbox.GetStringSelection()],self._image_listbox.GetStringSelection())\n \n self.update_information()",
"def chooseImage(prompt='Cho... | [
"0.60815364",
"0.60591024",
"0.5971393",
"0.5866761",
"0.58146304",
"0.5680011",
"0.56768984",
"0.54697263",
"0.5443554",
"0.54044807",
"0.5396056",
"0.5377519",
"0.5361159",
"0.5327195",
"0.53139585",
"0.5290029",
"0.5288028",
"0.5283098",
"0.5260646",
"0.52459484",
"0.52454... | 0.77937436 | 0 |
Encodes a sentence to token IDs | def _encode(self, sentence: str, **kwargs) -> Sequence[int]:
return NotImplemented | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(self, sentence):\n return sentence_to_token_ids(sentence, self.vocab)",
"def sentence_tokenize(tokenizer, sent):\n tokens = tokenizer.EncodeAsIds(sent).tokenization\n return tokens",
"def encode_tokens(self, sentence_tokens: str) -> str:\n return self.bpe.process_line(sentence_to... | [
"0.784519",
"0.7504808",
"0.6904413",
"0.68638766",
"0.67557085",
"0.6600543",
"0.6592142",
"0.65878546",
"0.6577898",
"0.65188795",
"0.6399734",
"0.6343282",
"0.62623745",
"0.6258507",
"0.62360007",
"0.62130123",
"0.61821526",
"0.61779237",
"0.6153952",
"0.61156243",
"0.6115... | 0.6249639 | 14 |
Encodes a sentence to token IDs | def encode(self,
sentence: str,
bos_token: bool = True,
eos_token: bool = True,
**kwargs) -> Sequence[int]:
sentence_tokens = self._encode(sentence, **kwargs)
if bos_token:
sentence_tokens = [self.bos_token_id] + sentence_tok... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(self, sentence):\n return sentence_to_token_ids(sentence, self.vocab)",
"def sentence_tokenize(tokenizer, sent):\n tokens = tokenizer.EncodeAsIds(sent).tokenization\n return tokens",
"def encode_tokens(self, sentence_tokens: str) -> str:\n return self.bpe.process_line(sentence_to... | [
"0.784519",
"0.7504808",
"0.6904413",
"0.68638766",
"0.67557085",
"0.6600543",
"0.6592142",
"0.6577898",
"0.65188795",
"0.6399734",
"0.6343282",
"0.62623745",
"0.6258507",
"0.6249639",
"0.62360007",
"0.62130123",
"0.61821526",
"0.61779237",
"0.6153952",
"0.61156243",
"0.61154... | 0.65878546 | 7 |
Draw bbox on image | def draw_bbox(image, im_id, catid2name, bboxes, threshold):
draw = ImageDraw.Draw(image)
catid2color = {}
color_list = colormap(rgb=True)[:40]
for dt in np.array(bboxes):
if im_id != dt['image_id']:
continue
catid, bbox, score = dt['category_id'], dt['bbox'], dt['score']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vis_bbox(im, bbox):\n im = im[:, :, (2, 1, 0)]\n fig, ax = plt.subplots(figsize=(12, 12))\n ax.imshow(im, aspect='equal')\n ax.add_patch(\n plt.Rectangle((bbox[0], bbox[1]),\n bbox[2] - bbox[0],\n bbox[3] - bbox[1], fill=False,\n ... | [
"0.7844244",
"0.7733483",
"0.763424",
"0.7585986",
"0.7556519",
"0.74551016",
"0.7384054",
"0.73698086",
"0.73661774",
"0.7340125",
"0.7295349",
"0.7256489",
"0.72380066",
"0.71986353",
"0.7193066",
"0.7150295",
"0.71277326",
"0.7121504",
"0.70976454",
"0.7080028",
"0.7075615... | 0.76586264 | 2 |
Find all Option subclasses within the class body. | def find_options(class_attributes):
new_attributes = {}
options = collections.OrderedDict()
for name in sorted(class_attributes.keys()):
attr = class_attributes[name]
if name.startswith('_') or not isinstance(attr, Option):
new_attributes[name] = att... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_match(cls, options):\n rv = []\n for o in options:\n if isinstance(o, cls):\n rv.append(o)\n return rv",
"def get_specific_options(cls):\n for option in cls._specific_options.items():\n yield option",
"def get_options(cls):\n for o... | [
"0.6700233",
"0.6005243",
"0.5927712",
"0.58216417",
"0.5799025",
"0.5682157",
"0.5671273",
"0.5663499",
"0.5656639",
"0.5645757",
"0.55054665",
"0.54646987",
"0.54521126",
"0.5439867",
"0.5369661",
"0.53226423",
"0.53000724",
"0.5294029",
"0.5286575",
"0.5278765",
"0.5254385... | 0.50640655 | 33 |
Returns the ~ expanded version of the path. When the value of this option is accessed by the user, special path characters like ~ will get expanded. | def presentation(self, value):
realpath = os.path.expanduser(value)
if self.auto_create:
if not os.path.exists(realpath):
os.makedirs(realpath)
return realpath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user(path = None):\n if path:\n return \"%s/%s\" % (expanduser(\"~\"), path)\n else:\n return expanduser(\"~\")",
"def _expand(self):\n return Path(os.path.expandvars(self)).expanduser().resolve()",
"def get_abs_path(self, value):\n return os.path.abspath(os.path.expanduser(os... | [
"0.6784629",
"0.6619663",
"0.65847844",
"0.65369976",
"0.64185065",
"0.6394105",
"0.63832426",
"0.6356524",
"0.6334117",
"0.63129795",
"0.63091785",
"0.6244657",
"0.62340623",
"0.6208723",
"0.61845237",
"0.6098848",
"0.60863096",
"0.60778296",
"0.6060992",
"0.6060992",
"0.599... | 0.55719197 | 47 |
Returns the absolute path for a file called name. The filepath will be prefixed with the profile's base folder. | def get_filepath(self, name):
return os.path.join(self._folder, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filename(name):\n return osp.join(osp.dirname(osp.abspath(__file__)), name)",
"def file_path(file_name, path):\n return path.rstrip('\\/') + \"/{0}\".format(file_name) if path else os.getcwd() + \"/{0}\".format(file_name)",
"def full_path(filename):\n\timport os.path\n\tfolder = os.path.dirname(o... | [
"0.7408075",
"0.7220649",
"0.71477026",
"0.70428133",
"0.6966862",
"0.6957699",
"0.69184697",
"0.69134665",
"0.6894038",
"0.6880726",
"0.68701875",
"0.6866602",
"0.685013",
"0.6830093",
"0.68043685",
"0.67887795",
"0.675643",
"0.6756192",
"0.67543495",
"0.6651768",
"0.6649237... | 0.73939204 | 1 |
Returns a ConfigStorage instance for a given config file name. The ConfigStorage instance is picked based on the file suffix. It will also be cached for future invocations of this method. | def get_storage(self, name):
if name not in self._storages:
for suffix, engine in self.STORAGE_MAP.iteritems():
if name.endswith(suffix):
self._storages[name] = engine(self.get_filepath(name))
break
if name in self._storages:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self, filename, config_class, storage_args=None, read_only=False):\r\n storage_args = storage_args if storage_args else []\r\n storage = self.get_storage(filename)\r\n\r\n if read_only:\r\n config = config_class()\r\n else:\r\n config = config_class(... | [
"0.6283567",
"0.6149989",
"0.60752046",
"0.60635674",
"0.60213107",
"0.5999776",
"0.5962711",
"0.5936942",
"0.59280765",
"0.5916855",
"0.58563405",
"0.578288",
"0.5650093",
"0.5635905",
"0.56232053",
"0.56190914",
"0.56184894",
"0.5599903",
"0.5597056",
"0.55775905",
"0.55651... | 0.7585347 | 0 |
Returns an instance of QtDBConnector for a specific database file. It is also cached for future gets. | def get_database(self, name='presentations.db'):
if name not in self._databases:
self._databases[name] = QtDBConnector(self.get_filepath(name), PluginManager(self))
return self._databases[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtainDatabaseConnection(self):\n\t\tself.databaseConnector = DatabaseConnector()",
"def get_database(self, database, instance=None):\n return self._get(_database.Database, database)",
"def get_db(self):\n db = getattr(g, '_database', None)\n if db is None:\n db = g._databas... | [
"0.65499777",
"0.6531017",
"0.6479456",
"0.6475421",
"0.64553714",
"0.6448269",
"0.6444755",
"0.6435012",
"0.64276147",
"0.6407837",
"0.63690937",
"0.63634807",
"0.6344516",
"0.6319384",
"0.63123065",
"0.6285647",
"0.62782127",
"0.62659407",
"0.62537956",
"0.62473345",
"0.620... | 0.6875657 | 0 |
Closes the connection the the database. | def __close_table(self):
self.talkdb.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_connection(cls):\n db.close()",
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close(self):\n Log.debug('DB -> close')\n # 关闭数据库连接\n self.conn.close()",
"def close(self):\n if... | [
"0.8423229",
"0.83118176",
"0.81984967",
"0.8115329",
"0.80796874",
"0.8047292",
"0.79485875",
"0.7920711",
"0.79123586",
"0.7863693",
"0.78515023",
"0.78372085",
"0.78211975",
"0.7790756",
"0.77665395",
"0.77621454",
"0.7749549",
"0.7694541",
"0.7672417",
"0.7618274",
"0.759... | 0.0 | -1 |
Creates the presentations table in the database. Should be used to initialize a new table. | def __create_presentations_table(self, schema=PRESENTATIONS_SCHEMA_310):
log.info("table created")
QtSql.QSqlQuery(schema) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_table(self):\n conn = self._connect_DB()\n cur = conn.cursor()\n cur.execute(\n \"CREATE TABLE IF NOT EXISTS movie_table (movie_title, people);\"\n )\n self._close_connection(conn)",
"def create_table(self):\n pass",
"def get_presentations_model(s... | [
"0.6891636",
"0.66136324",
"0.6591187",
"0.6580697",
"0.6518396",
"0.64512926",
"0.634442",
"0.62809783",
"0.6277774",
"0.6264603",
"0.6259949",
"0.6184911",
"0.6157998",
"0.6106391",
"0.6106391",
"0.6099652",
"0.608533",
"0.6084409",
"0.6079643",
"0.60758024",
"0.60718524",
... | 0.832884 | 0 |
Returns the talks hosted in a specified room, starting from the current date and time | def get_talks_by_room_and_time(self, room):
current_date = QDate.currentDate().toString(1) # yyyy-mm-dd
current_time = QTime.currentTime().toString() # hh:mm:ss
return QtSql.QSqlQuery('''SELECT * FROM presentations
WHERE Room='{}' AND Date='{}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_talks_by_room(self, room):\r\n return QtSql.QSqlQuery('''SELECT * FROM presentations WHERE Room=%s''' % room)",
"def list_talk(request, template=\"core/list_talk.html\"):\n response = {\n 'morning': Talk.objects.at_morning(),\n 'afternoon': Talk.objects.at_afternoon(),\n }\n ... | [
"0.72898185",
"0.57977074",
"0.5769667",
"0.5765742",
"0.56455386",
"0.5641132",
"0.55828846",
"0.55050105",
"0.548021",
"0.544113",
"0.54399073",
"0.5397757",
"0.5368652",
"0.534045",
"0.5333955",
"0.5319406",
"0.530521",
"0.52437645",
"0.522897",
"0.52179885",
"0.5210793",
... | 0.77285886 | 0 |
Checks if there's a presentation with the same Speaker and Title already stored | def presentation_exists(self, presentation):
result = QtSql.QSqlQuery('''SELECT * FROM presentations''')
while result.next():
if (unicode(presentation.title) == unicode(result.value(1).toString())
and unicode(presentation.speaker) == unicode(result.value(2).toString())):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_display_presentation(self):\n response = self._speaker_profile(True)\n self.assertContains(response, FIRST_PRESENTATION_TITLE)\n self.assertContains(response, SECOND_PRESENTATION_TITLE)",
"def _check_duplicate_notes(self, tokens, curr_note, step) -> bool:\n same_note_cnt ... | [
"0.6107987",
"0.59682816",
"0.5946899",
"0.58385265",
"0.5724065",
"0.5655673",
"0.5617594",
"0.55914724",
"0.55647063",
"0.5527154",
"0.54490554",
"0.5435396",
"0.5433292",
"0.5430205",
"0.5423344",
"0.5406763",
"0.5369781",
"0.5333614",
"0.53205067",
"0.5305187",
"0.5300801... | 0.7534151 | 0 |
Gets the Dates Model. Useful for Qt GUI based Frontends to load the Model into Views. | def get_dates_from_event_room_model(self, event, room):
self.datesModel = QtSql.QSqlQueryModel()
self.datesModel.setQuery(
"SELECT DISTINCT date FROM presentations WHERE Event='%s' and Room='%s' ORDER BY Date ASC"
% (event, room))
return self.datesModel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dates(self):\r\n return self.__dates",
"def get_events_model(self):\r\n self.eventsModel = QtSql.QSqlQueryModel()\r\n self.eventsModel.setQuery(\"SELECT DISTINCT Event FROM presentations ORDER BY Event ASC\")\r\n return self.eventsModel",
"def model_start_date(self):\n ... | [
"0.5705884",
"0.5615123",
"0.55988383",
"0.54863274",
"0.5466731",
"0.5466555",
"0.540893",
"0.53219855",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.5233031",
"0.52165014",
"0.5203645",
"0.51906663",... | 0.6044448 | 0 |
Creates the failures table in the database. Should be used to initialize a new table | def __create_failures_table(self, schema=REPORTS_SCHEMA_300):
QtSql.QSqlQuery(schema) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_table(self):\n pass",
"def test_create_table_successfully (self):\n\n new_table = self.wrapper.create_table(self.table, [self.bob, self.jane])\n self.assertIsNone(new_table)",
"def create_tables():\n db.create_all()",
"def create_tables():\n db.create_all()",
"... | [
"0.6455986",
"0.6380401",
"0.6250317",
"0.6250317",
"0.6247534",
"0.62390363",
"0.6142584",
"0.612685",
"0.61184937",
"0.6106679",
"0.6099699",
"0.6099627",
"0.60911924",
"0.604168",
"0.60373634",
"0.6031205",
"0.60282797",
"0.602502",
"0.60111713",
"0.597285",
"0.59723806",
... | 0.76129013 | 0 |
Returns a dictionary of tags and tag values. To be used for populating the current recording's file metadata. | def prepare_metadata(self, presentation):
return {"title": presentation.title,
"artist": presentation.speaker,
"performer": presentation.speaker,
"album": presentation.event,
"location": presentation.room,
"date": ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_dict(self):\n tag_dict = dict()\n for document in self.documents:\n for tag in document.tags:\n tag_type = tag['tag']\n tag_dict[tag_type] = tag_dict.get(tag_type, []) + [tag]\n return tag_dict",
"def tags_dict(self):\n return (... | [
"0.7035511",
"0.70078295",
"0.6877104",
"0.6778295",
"0.67773163",
"0.6720289",
"0.6624589",
"0.66131973",
"0.6546188",
"0.65144515",
"0.65049076",
"0.6495054",
"0.6467888",
"0.64606917",
"0.6436222",
"0.6415209",
"0.63623387",
"0.63217866",
"0.6292489",
"0.6292489",
"0.62589... | 0.0 | -1 |
Returns a list of plugins supported by the users OS as detected by python's sys.platform library. | def _get_supported_plugins(self, unfiltered_plugins):
plugins = []
for plugin in unfiltered_plugins:
if self._os_supported(plugin):
plugins.append(plugin)
return plugins | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_platforms(self):\n if self.platform == 'All':\n return PLATFORMS\n else:\n return self.platform.split(':')",
"def _os_supported(self, plugin):\r\n return sys.platform in plugin.plugin_object.get_supported_os()",
"def Platforms():\n return platforms",
"def... | [
"0.72985893",
"0.7283882",
"0.7168201",
"0.69370246",
"0.6900202",
"0.6823284",
"0.6732525",
"0.66962296",
"0.66472244",
"0.662313",
"0.6601848",
"0.6530038",
"0.6433104",
"0.63936",
"0.6370518",
"0.6357478",
"0.63471776",
"0.6337516",
"0.62964875",
"0.62600005",
"0.6236541",... | 0.7844969 | 0 |
Returns a list of all plugins supported by the users OS as detected by python's sys.platform library. | def get_all_plugins(self):
unfiltered_plugins = self.plugmanc.getAllPlugins()
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def get_platforms(self):\n if self.platform == 'All':\n ... | [
"0.77382034",
"0.73861444",
"0.7345659",
"0.71943957",
"0.70306087",
"0.6971812",
"0.6844104",
"0.68281686",
"0.67518365",
"0.6747798",
"0.6746065",
"0.6746002",
"0.6659813",
"0.6507606",
"0.65003127",
"0.6400642",
"0.6376292",
"0.63673455",
"0.632033",
"0.62241274",
"0.62225... | 0.65031844 | 14 |
Returns a list of all plugins in category supported by the users OS as detected by python's sys.platform library. | def get_plugins_of_category(self, category):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory(category)
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def Platforms():\n return platforms",
"def get_platforms(sel... | [
"0.75617886",
"0.7272844",
"0.71722955",
"0.6798423",
"0.665795",
"0.6642826",
"0.66282296",
"0.66169035",
"0.661609",
"0.65788454",
"0.6569684",
"0.6498198",
"0.641439",
"0.6388115",
"0.63538307",
"0.6197396",
"0.6190081",
"0.6190009",
"0.61859",
"0.61855155",
"0.60979843",
... | 0.62080634 | 15 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library. | def get_audioinput_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("AudioInput")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.79368526",
"0.73556834",
"0.73235315",
"0.71550614",
"0.6910232",
"0.6883927",
"0.6794174",
"0.67580575",
"0.67499226",
"0.6746735",
"0.66560733",
"0.66403115",
"0.66192377",
"0.65617675",
"0.6436656",
"0.6421008",
"0.6416548",
"0.6399893",
"0.6371246",
"0.63599277",
"0.63... | 0.5845591 | 46 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library. | def get_audiomixer_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("AudioMixer")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.7936612",
"0.73554045",
"0.73211354",
"0.7152719",
"0.6908177",
"0.68827266",
"0.6795189",
"0.67567515",
"0.6750313",
"0.674479",
"0.66543174",
"0.6638282",
"0.6617099",
"0.65593493",
"0.64342046",
"0.6419004",
"0.64146763",
"0.63980275",
"0.6371522",
"0.6360231",
"0.63465... | 0.61048704 | 30 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library. | def get_videoinput_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("VideoInput")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.7936468",
"0.7356596",
"0.7322321",
"0.7153212",
"0.6909109",
"0.6883553",
"0.67936367",
"0.6758265",
"0.67496264",
"0.67459214",
"0.6655095",
"0.66388136",
"0.6617212",
"0.6561126",
"0.6435235",
"0.64195013",
"0.6416187",
"0.6399518",
"0.6371334",
"0.63587546",
"0.6348029... | 0.5736147 | 57 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library. | def get_videomixer_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("VideoMixer")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.79365516",
"0.73553944",
"0.7321153",
"0.71524775",
"0.6908647",
"0.68818694",
"0.6795523",
"0.6756056",
"0.6751296",
"0.6745561",
"0.6654619",
"0.66385156",
"0.66167927",
"0.6559697",
"0.64342237",
"0.64190316",
"0.6414752",
"0.63981164",
"0.6371478",
"0.63603956",
"0.634... | 0.6119955 | 29 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library | def get_importer_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("Importer")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.79129916",
"0.74159265",
"0.7285682",
"0.7153763",
"0.6999479",
"0.6818088",
"0.68104583",
"0.6793398",
"0.67549634",
"0.6643139",
"0.6593669",
"0.6544676",
"0.65391076",
"0.65366703",
"0.6493501",
"0.6487547",
"0.64770794",
"0.6465127",
"0.641839",
"0.6418003",
"0.6374627... | 0.0 | -1 |
Returns a list of plugins that are supported by the users OS as detected by python's sys.platform library. | def get_output_plugins(self):
unfiltered_plugins = self.plugmanc.getPluginsOfCategory("Output")
return self._get_supported_plugins(unfiltered_plugins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supported_plugins(self, unfiltered_plugins):\r\n plugins = []\r\n\r\n for plugin in unfiltered_plugins:\r\n if self._os_supported(plugin):\r\n plugins.append(plugin)\r\n\r\n return plugins",
"def _os_supported(self, plugin):\r\n return sys.platform i... | [
"0.7936612",
"0.73554045",
"0.73211354",
"0.7152719",
"0.6908177",
"0.68827266",
"0.6795189",
"0.67567515",
"0.6750313",
"0.674479",
"0.66543174",
"0.6638282",
"0.6617099",
"0.65593493",
"0.64342046",
"0.6419004",
"0.64146763",
"0.63980275",
"0.6371522",
"0.6360231",
"0.63465... | 0.5985861 | 36 |
Returns the filename to use when recording. If a record name with a .None extension is returned, the record name will just be ignored by the output plugin (e.g. Video Preview plugin). Function will return None if neither presentation nor filename is passed. | def get_record_name(extension, presentation=None, filename=None, path="."):
if presentation is not None:
recordname = make_record_name(presentation)
elif filename is not None:
recordname = filename
else:
return None
count = 0
tempname = recordname
# Add a num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_record_name(presentation):\r\n tags = [\r\n make_shortname(presentation.event),\r\n make_shortname(presentation.room),\r\n make_shortname(presentation.speaker),\r\n make_shortname(presentation.title),\r\n ]\r\n record_name = unicode('-'.join(tag for tag in tags if tag)... | [
"0.6712573",
"0.66429",
"0.6576406",
"0.65374553",
"0.6429294",
"0.641951",
"0.63191086",
"0.63042486",
"0.614367",
"0.61265486",
"0.6108898",
"0.6088309",
"0.60874826",
"0.6086685",
"0.60688764",
"0.60688764",
"0.60688764",
"0.60688764",
"0.6066301",
"0.60636204",
"0.6055982... | 0.76043993 | 0 |
Deletes the Freeseer configuration directory | def reset(configdir):
if validate_configdir(configdir):
print('This will wipe out your freeseer configuration directory.')
if confirm_yes() is True:
shutil.rmtree(configdir)
else:
print("%s is not a invalid configuration directory." % configdir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean():\n Log.d(DEBUG_TAG, \"Delete config file...\")\n try:\n os.remove(CONFIG_FILE)\n except os.error as e:\n Log.e(DEBUG_TAG, \"Delete config file%s error, reason:%s\"%(CONFIG_FILE, e))",
"def delete_directory_config(DirectoryName=None):\n pass",
"def remove_user_configuration... | [
"0.756377",
"0.7332925",
"0.7104379",
"0.70966595",
"0.7030991",
"0.6887117",
"0.6732835",
"0.6728757",
"0.66730493",
"0.6658795",
"0.66038114",
"0.66005266",
"0.65580326",
"0.65256417",
"0.6515569",
"0.65040827",
"0.6487273",
"0.6477065",
"0.6474004",
"0.643315",
"0.6418418"... | 0.6914496 | 5 |
Returns the current selected presentation ID. | def current_presentation_id(self):
i = self.mainWidget.talkComboBox.currentIndex()
return self.mainWidget.talkComboBox.model().index(i, 1).data(QtCore.Qt.DisplayRole).toString() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_presentation(self):\r\n #i = self.mainWidget.talkComboBox.currentIndex()\r\n #p_id = self.mainWidget.talkComboBox.model().index(i, 1).data(QtCore.Qt.DisplayRole).toString()\r\n return self.db.get_presentation(self.current_presentation_id())",
"def _http_get_current_id(self):\n ... | [
"0.76649386",
"0.64830095",
"0.6475574",
"0.6252664",
"0.6227284",
"0.6220969",
"0.6220969",
"0.6220969",
"0.6220969",
"0.6220969",
"0.6220969",
"0.62110066",
"0.6183573",
"0.61418736",
"0.61114335",
"0.6079703",
"0.6079703",
"0.6079703",
"0.6079703",
"0.6079703",
"0.6079703"... | 0.8403566 | 0 |
Removes placeholder text in NewTalkWidget originally set by TalkDetailsWidget | def remove_new_talk_placeholder_text(self):
self.newTalkWidget.talkDetailsWidget.titleLineEdit.setPlaceholderText("")
self.newTalkWidget.talkDetailsWidget.presenterLineEdit.setPlaceholderText("")
self.newTalkWidget.talkDetailsWidget.categoryLineEdit.setPlaceholderText("")
self.newTal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_new_talk_fields(self):\r\n self.newTalkWidget.talkDetailsWidget.titleLineEdit.clear()\r\n self.newTalkWidget.talkDetailsWidget.presenterLineEdit.clear()\r\n self.newTalkWidget.talkDetailsWidget.descriptionTextEdit.clear()\r\n self.newTalkWidget.talkDetailsWidget.categoryLineEd... | [
"0.7479873",
"0.640479",
"0.63961995",
"0.61618006",
"0.6104689",
"0.60825175",
"0.6044464",
"0.5850562",
"0.5795192",
"0.574085",
"0.572183",
"0.5709666",
"0.5690688",
"0.5662016",
"0.55521953",
"0.5547171",
"0.5530288",
"0.5476284",
"0.54499424",
"0.5446066",
"0.5430934",
... | 0.872061 | 0 |
Retrieve the defaults value for client_secrets, video folder, etc. | def get_defaults():
profile = settings.profile_manager.get("default")
config = profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=True)
return {
"video_directory": config.videodir,
"oauth2_token": os.path.join(settings.configdir, "oauth2_toke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_secrets_basedir():\n default_basedir = Path.home() / BASEDIR_BASENAME\n return Path(\n os.getenv('D2_SECRETS_BASEDIR', default_basedir)\n )",
"def client_settings():\n return CLIENT_SETTINGS",
"def JWT_SECRET(default=None):\n return ParamStore.get('JWT_SECRET', default... | [
"0.6162359",
"0.616206",
"0.61385393",
"0.6121496",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6101328",
"0.6099773",
"0.6021092",
"0.6010107",
"0.6010107",
"0.6008685",
"0.6007823",
"0.5982695",
"0.5982695",
"0.59619176",
... | 0.76158243 | 0 |
Tests that setting the property for an option fails if the value is not valid. | def test_set_property_invalid(self):
try:
initial_value = self.config.values['option1']
self.config.option1 = 'invalid'
except Exception as e:
self.assertIsInstance(e, InvalidOptionValueError)
self.assertEqual(self.config.values['option1'], initial_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_value_invalid(self):\r\n name = 'option1'\r\n option = self.config.options[name]\r\n value = 'invalid'\r\n initial_value = self.config.values[name]\r\n\r\n self.assertRaises(InvalidOptionValueError, self.config.set_value, name, option, value)\r\n self.assertEq... | [
"0.7824185",
"0.7123878",
"0.70848763",
"0.70816195",
"0.70125777",
"0.6911095",
"0.6749176",
"0.66959757",
"0.66948247",
"0.6609118",
"0.6590277",
"0.644167",
"0.64102674",
"0.6405506",
"0.63662434",
"0.62976956",
"0.6267878",
"0.62483585",
"0.6242559",
"0.6221174",
"0.62026... | 0.81630886 | 0 |
Tests that saving a Config without a ConfigStorage instance attached to it fails. | def test_save(self):
self.assertRaises(StorageNotSetError, self.config.save) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_config_save_error(self):\n\n config_filename_initial = 'test_configuration2'\n config_filename_save = 'save_bad_configuration'\n\n # Get config path\n local_dir = os.path.dirname(__file__)\n config_path_initial = os.path.join(local_dir, config_filename_initial)\n ... | [
"0.6939522",
"0.6820595",
"0.67941993",
"0.679145",
"0.6714565",
"0.6529581",
"0.64409405",
"0.64293706",
"0.64031047",
"0.6341906",
"0.63379973",
"0.6337662",
"0.633663",
"0.63139397",
"0.62588674",
"0.62386256",
"0.6223882",
"0.6220531",
"0.62130964",
"0.6196741",
"0.618410... | 0.7940332 | 0 |
Tests that saving a Config with a ConfigStorage instance attached to it "succeeds". | def test_save(self):
self.config.save()
self.assertEqual(self.storage.store_args, self.store_args)
self.assertTrue(self.storage.store_called) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save(self):\r\n self.assertRaises(StorageNotSetError, self.config.save)",
"def test_create_config_with_save(self) -> None:\n config = self.integration.create_config(name='Config 1', save=True)\n self.assertFalse(config.enabled)\n self.assertIsNotNone(config.pk)",
"def test_... | [
"0.8046685",
"0.73511106",
"0.73434955",
"0.7169273",
"0.6884296",
"0.6876416",
"0.6791446",
"0.6595397",
"0.65865177",
"0.6527654",
"0.6498938",
"0.6444812",
"0.6431348",
"0.63753533",
"0.6358199",
"0.63272226",
"0.63085127",
"0.6283113",
"0.62084574",
"0.6201123",
"0.617458... | 0.80199003 | 1 |
Tests that get returns a Profile instance. | def test_get(self):
profile = self.profile_manager.get('testing')
self.assertIsInstance(profile, Profile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_retrieve_one(self):\n expected = {\n '_id': 'id',\n 'name': 'name',\n 'version': 4,\n 'status': 'active'\n }\n rsps = respx.get(f'{PROVISIONING_API_URL}/users/current/provisioning-profiles/id') \\\n .mock(return_value=Respon... | [
"0.7312036",
"0.7044072",
"0.7012618",
"0.69376755",
"0.68385655",
"0.6733739",
"0.6724329",
"0.6641575",
"0.6607912",
"0.6588818",
"0.65829813",
"0.6564754",
"0.65182537",
"0.65075755",
"0.6463411",
"0.6452508",
"0.6444672",
"0.643241",
"0.6426615",
"0.6387793",
"0.6365731",... | 0.8905702 | 0 |
Tests that get_storage(...) does not accept an invalid filename suffix. | def test_get_storage_invalid_suffix(self):
self.assertRaises(KeyError, self.profile.get_storage, ('testing.json,')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_storage_valid_suffix(self):\r\n json_storage = self.profile.get_storage('testing.json')\r\n self.assertIsInstance(json_storage, JSONConfigStorage)\r\n\r\n config_parser_storage = self.profile.get_storage('testing.conf')\r\n self.assertIsInstance(config_parser_storage, Confi... | [
"0.73666716",
"0.70315534",
"0.67280966",
"0.6676317",
"0.63362056",
"0.63152754",
"0.62885314",
"0.6180182",
"0.61586404",
"0.6158569",
"0.6132504",
"0.6128352",
"0.6124105",
"0.60555905",
"0.60358214",
"0.60279214",
"0.6018676",
"0.6016806",
"0.60146564",
"0.5971997",
"0.59... | 0.82502455 | 0 |
Normalizes every variable using max | def normalize(predictors):
normalization_constant = np.max(np.max(predictors, axis=1), axis=0)
return predictors / normalization_constant | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_normalization(array):\n return 1/np.max(array) * array.squeeze(axis=1)",
"def normalise(x):\n x = np.copy(x)\n n_cols = x.shape[1]\n for col_index in range(n_cols):\n col = x[:, col_index]\n factor = np.max(col)\n x[:, col_index] = col / factor\n\n return x",
"def no... | [
"0.7747201",
"0.704133",
"0.6899899",
"0.68891793",
"0.6837642",
"0.6725675",
"0.67215097",
"0.66784394",
"0.6663596",
"0.66256315",
"0.66071045",
"0.65837777",
"0.6565383",
"0.6564906",
"0.6542834",
"0.6519278",
"0.65048164",
"0.6494383",
"0.64928615",
"0.64300257",
"0.64300... | 0.6451444 | 19 |
Given an array's size, generate a compatible random shape | def gen_shape(size):
def _factors(n):
""" Returns the divisors of n
>>> _factors(4)
{1, 2, 4}"""
gen = ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)
return set(sum(gen, []))
assert size > 0
if size == 1:
return (1,)
shape = [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_array(size_tuple):\n\n output = np.random.rand(\n size_tuple[0], size_tuple[1])\n\n return output",
"def random(self, size=None):\n if size == None:\n hash_output = self.nextRandom()\n return int_from_hash(hash_output)*RECIP_HASHLEN\n else:\n ... | [
"0.7401366",
"0.713922",
"0.70448625",
"0.68830323",
"0.68687683",
"0.6829294",
"0.68208325",
"0.6630649",
"0.6623175",
"0.66078234",
"0.65968865",
"0.6585019",
"0.6582947",
"0.6542013",
"0.6542013",
"0.6522312",
"0.65220016",
"0.6504899",
"0.64905393",
"0.64803416",
"0.64777... | 0.72374964 | 1 |
Creates a SpanishFormatter with a specified line length. lineLen cannot be less than 10. | def __init__(self, lineLen):
if lineLen < 10:
raise ValueError('lineLen cannot be less than 10')
self.len = lineLen
self.currentSpace = lineLen
self.beginningOfLine = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shorten_lines(string, lineLen, maxLines):\n lines = string.split(\"\\n\")\n lineCount = 0\n newLines = \"\"\n for line in lines:\n length = int(len(line) / lineLen) if len(line) > lineLen else 1\n if len(line) > length * lineLen:\n length += 1\n lineCount += length\n... | [
"0.48463252",
"0.48394963",
"0.4832549",
"0.4827578",
"0.47190326",
"0.4641005",
"0.458849",
"0.4556391",
"0.45312765",
"0.45051035",
"0.45007434",
"0.44996944",
"0.43910083",
"0.43873096",
"0.43565497",
"0.43329096",
"0.4331628",
"0.43266696",
"0.43169022",
"0.42736357",
"0.... | 0.5641176 | 0 |
Returns a string corresponding to the user first and last names, given the user email. | def get_user_name_from_email(email):
u = db(db.auth_user.email == email).select().first()
if u is None:
return 'None'
else:
return ' '.join([u.first_name, u.last_name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_name_from_email(email):\n u = db(db.auth_user.email == email).select().first()\n if u is None:\n return 'None'\n else:\n return ' '.join([u.first_name, u.last_name])",
"def extract_name_from_email(record):\n\n email = record['email']\n email = email.split('@')[0]... | [
"0.7762684",
"0.7368976",
"0.73166937",
"0.71045375",
"0.71018267",
"0.70929414",
"0.6899623",
"0.6821828",
"0.6700426",
"0.6682283",
"0.6671532",
"0.66638327",
"0.662202",
"0.6606379",
"0.6570266",
"0.65187335",
"0.65053236",
"0.642686",
"0.6408557",
"0.6387535",
"0.63871694... | 0.76905864 | 1 |
This function prints and plots the confusion matrix. | def plot_confusion_matrix(cm, classes,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
plt.xticks(tick_marks, classes, rota... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def showConfusionMatrix(self): \r\n sn.heatmap(self.conf_matrix, annot=True)\r\n plt.plot( label=\"Accuracy\")\r\n plt.plot( label=\"Error\"... | [
"0.80894613",
"0.80770946",
"0.79976976",
"0.7946727",
"0.7921785",
"0.78448296",
"0.7833224",
"0.7781221",
"0.7775631",
"0.77574563",
"0.77061635",
"0.77016985",
"0.7692213",
"0.76785815",
"0.76588994",
"0.7641414",
"0.7622791",
"0.7611233",
"0.7610989",
"0.7598244",
"0.7587... | 0.0 | -1 |
Compute barycentric coordinates with respect to a given triangle on a grid. | def barycentric_coords(vertices, coordinates):
vertices = numpy.asarray(vertices)
coordinates = numpy.asarray(coordinates)
assert vertices.shape == (3, 2)
assert coordinates.shape[0] == 2 and coordinates.ndim >= 2
# set up the problem in the matrix-multiplication form from
# https://en.wikipedia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _barycentricXY(a,p1,p2,p3):\n x=a[0]\n y=a[1]\n\n x1=p1[0]\n y1=p1[1]\n\n x2=p2[0]\n y2=p2[1]\n\n x3=p3[0]\n y3=p3[1]\n\n denom=(y2-y3)*(x1-x3) + (x3-x2)*(y1-y3)\n\n if abs(denom) < epsilon:\n raise ValueError('degenerate triangle in barycentricXY call')\n \n lam1 = (... | [
"0.6973684",
"0.63870007",
"0.6306898",
"0.61990494",
"0.60253865",
"0.6019046",
"0.6010908",
"0.60088575",
"0.596708",
"0.58967304",
"0.5876926",
"0.58725095",
"0.5843975",
"0.5789882",
"0.57752776",
"0.5771837",
"0.57381994",
"0.57024926",
"0.5687057",
"0.56822354",
"0.5668... | 0.6629814 | 1 |
Return a mask containing ones for pixels in a given triangle. Very inefficient! Especially for a large image size and a small triangle. Provided SOLELY an example for using barycentric coordinates. Use zplib.image.draw.draw_mask() or mask_triangle_strip() for speed. | def draw_triangle(vertices, shape):
# add 0.5 to account for fact that pixel centers are at (0.5, 0.5)
barycenters = barycentric_coords(vertices, numpy.indices(shape) + 0.5)
return (barycenters >= 0).all(axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_triangle_strip(triangle_strip, shape):\n triangle_strip = numpy.asarray(triangle_strip, dtype=numpy.float32, order='C')\n assert triangle_strip.ndim == 2 and triangle_strip.shape[1] == 2 and len(triangle_strip) > 2\n num_vertices = len(triangle_strip)\n out = numpy.zeros(tuple(shape), dtype=bo... | [
"0.7281205",
"0.6225731",
"0.60093683",
"0.59599143",
"0.57943064",
"0.56701565",
"0.54368716",
"0.543669",
"0.53979045",
"0.53926724",
"0.5390957",
"0.5383106",
"0.53323233",
"0.5331376",
"0.53199",
"0.5312763",
"0.5304354",
"0.529728",
"0.52806085",
"0.52736354",
"0.5254653... | 0.5987096 | 3 |
Returns the RGBA values as floats between 0 and 1. | def normalize(self):
return (self.r / 255.0, self.g / 255.0, self.b / 255.0, self.a / 255.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grey(self):\n return sum((self.value(0), self.value(1), self.value(2)))/3",
"def rgba_floats_tuple(self, x):\n raise NotImplementedError",
"def get_four_float_color(color: Color) -> Tuple[float, float, float, float]:\r\n if len(color) == 4:\r\n return color[0] / 255, color[1] / 255,... | [
"0.64760697",
"0.64076364",
"0.6314892",
"0.6313924",
"0.6289981",
"0.6244078",
"0.6244078",
"0.62312675",
"0.61831796",
"0.6170044",
"0.6125085",
"0.6114659",
"0.6042371",
"0.60404474",
"0.6007779",
"0.5962359",
"0.59424114",
"0.5932198",
"0.59292537",
"0.586928",
"0.5861355... | 0.5755663 | 25 |
Validate if user is a tahoe User (or a list of Users). | def _validate_user(self, user):
valid_type = getclass("user")
if not isinstance(user, list):
user = [user]
new = set() # remove duplicate
for u in user:
if isinstance(u, str):
temp = self._backend.find_user(_hash=u, parse=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isUserType(user, usercls):\n try:\n u = usercls.objects.get(user_ptr=user.id)\n return True\n except:\n return False",
"def is_user(self, user='') -> int:\n try:\n if user in self.users:\n return(1)\n else:\n return(0)\n ... | [
"0.64983386",
"0.6457826",
"0.631484",
"0.61403275",
"0.61144984",
"0.6098655",
"0.60828245",
"0.6040151",
"0.6032643",
"0.59598744",
"0.595816",
"0.5946933",
"0.58864146",
"0.5872049",
"0.5855743",
"0.5855743",
"0.58228624",
"0.5804508",
"0.58025485",
"0.5798763",
"0.5786166... | 0.6486997 | 1 |
Calculates the Euclidean distance between the given cluster `mean` and the `example`. | def dist(mean, example):
return np.linalg.norm(example.row - mean) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(self, samples, clusters):\n n_samples = samples.shape[0]\n n_features = samples.shape[1]\n n_centroids = clusters.shape[0]\n dist = np.zeros(shape=(n_samples, n_centroids))\n\n # computing squared euclidian distance for each sample-cluster pair\n for i in ... | [
"0.6900373",
"0.68724096",
"0.63923854",
"0.6352132",
"0.6305247",
"0.6219739",
"0.6171905",
"0.60242695",
"0.60105205",
"0.5978419",
"0.5978419",
"0.5974478",
"0.5881102",
"0.5861805",
"0.5838987",
"0.58316904",
"0.58127695",
"0.57607037",
"0.5756948",
"0.5746843",
"0.573144... | 0.7825478 | 0 |
Return details about active connection. | def active(self) -> NetworkWirelessAP | None:
return self._active | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_connection_information(self):\n return self.connection_information",
"def info(self) -> ConnectionInfo:\n return ConnectionInfo(self.pgconn)",
"def getConnectionStatus(self): \n return getI1ProConnectionStatus()",
"def get_connection_info(self):\n return [(c.fullname, [... | [
"0.74998003",
"0.72935987",
"0.7197976",
"0.7050752",
"0.7013152",
"0.6976196",
"0.6920714",
"0.6841827",
"0.6841827",
"0.6837219",
"0.6820638",
"0.6783757",
"0.67714113",
"0.6768254",
"0.6732863",
"0.671612",
"0.671612",
"0.6678192",
"0.6669723",
"0.66409856",
"0.6616357",
... | 0.0 | -1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.76458347",
"0.764... | 0.77288336 | 10 |
Convert quaternion coefficients to rotation matrix. | def quat2mat(quat):
norm_quat = torch.cat([quat[:,:1].detach()*0 + 1, quat], dim=1)
norm_quat = norm_quat/norm_quat.norm(p=2, dim=1, keepdim=True)
w, x, y, z = norm_quat[:,0], norm_quat[:,1], norm_quat[:,2], norm_quat[:,3]
B = quat.size(0)
w2, x2, y2, z2 = w.pow(2), x.pow(2), y.pow(2), z.po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_to_rotation_matrix(quaternion):\n\n q_w, q_x, q_y, q_z = quaternion\n sqw, sqx, sqy, sqz = np.square(quaternion)\n norm = (sqx + sqy + sqz + sqw)\n rotation_matrix = np.zeros((3, 3))\n\n # division of square length if quaternion is not already normalized\n rotation_matrix[0, 0] = (... | [
"0.7666401",
"0.7480785",
"0.74480975",
"0.7431791",
"0.7220662",
"0.72003317",
"0.7190068",
"0.7073628",
"0.6941468",
"0.6884496",
"0.6882422",
"0.6881994",
"0.685318",
"0.68479955",
"0.68037885",
"0.67919123",
"0.677245",
"0.6759796",
"0.672846",
"0.670579",
"0.6654148",
... | 0.66775787 | 20 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81920755",
"0.8093736",
"0.8028212",
"0.8017333",
"0.79923165",
"0.7989431",
"0.79789335",
"0.7974398",
"0.795948",
"0.79555666",
"0.7935652",
"0.7932704",
"0.7932632",
"0.7929465",
"0.7924336",
"0.7922666",
"0.79221356",
"0.7921299",
"0.79209703",
"0.7920307",
"0.7916008"... | 0.0 | -1 |
Determines a loss weight map given the truth by balancing the classes from the classes argument. The classes argument can be used to only include certain classes (you may for instance want to exclude the background). | def weight_by_class_balance(truth, classes=None):
if classes is None:
# Include all classes
classes = np.unique(truth)
weight_map = np.zeros_like(truth, dtype=np.float32)
total_amount = np.product(truth.shape)
min_weight = sys.maxint
for c in classes:
class_mask = np.where... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_loss_weight_criteria(num_traits, num_classes=num_classes, weighted_loss=True, top_only=None):\n\tif (weighted_loss):\n\t\tprint(\"use different weight for each class\")\n\t\tprint(\"put more focus on locus with more significant DM p-values\")\n\t\tif (top_only):\n\t\t\tprint(\"weighted loss for the to... | [
"0.6411182",
"0.6411182",
"0.6361269",
"0.6260943",
"0.621185",
"0.61220396",
"0.60509235",
"0.60122633",
"0.59956783",
"0.5986741",
"0.5983742",
"0.5872256",
"0.5865614",
"0.58510935",
"0.58260155",
"0.5816751",
"0.5812305",
"0.5790965",
"0.5759261",
"0.5757175",
"0.56622493... | 0.79099 | 0 |
Compute the residuals between the sigmoid function and the data. | def residuals_Sigm(self, p, data, x):
err = data - self.Sigm(x,p)
return err | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def residuals(self) -> npt.NDArray[np.float64]:\n return self.data - self.theory",
"def _residual(self, x):\n h = x\n h = self.c1(h)\n h = self.activation(h)\n h = self.c2(h)\n h = F.avg_pool2d(h, 2)\n\n return h",
"def test_regress_residuals(self):\r\n x... | [
"0.71177983",
"0.70826733",
"0.7053853",
"0.70333874",
"0.69854593",
"0.6907196",
"0.6851557",
"0.684857",
"0.66976887",
"0.6687249",
"0.66839117",
"0.6617552",
"0.6480022",
"0.64617056",
"0.64489883",
"0.63895756",
"0.6373261",
"0.63653284",
"0.6360191",
"0.633652",
"0.63182... | 0.66315424 | 11 |
Return a vector containing the sum of the peak functions. | def fitfunc(self, x, p):
S = np.zeros(self.npt)
for i in range(0, len(p), self.maxparm):
ptyp = self.peakTyp[int(i/self.maxparm)]
xm = p[i]
amp = p[i+1]
w = p[i+2]
a = p[i+3]
m = p[i+4]
if ptyp == 'G':
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak_PSF(self):\n return self.compute_PSF(np.zeros(self.N_zern))",
"def peak(self):\n pass",
"def peak_PSF(self):\n im, strehl = self.compute_PSF(np.zeros(self.N_act))\n return strehl",
"def peak(data, fft_data=None):\n return np.max(np.abs(data))",
"def peak(self):\n ... | [
"0.6984379",
"0.6698461",
"0.6327123",
"0.61459666",
"0.6045917",
"0.5971726",
"0.59530294",
"0.5943072",
"0.5883302",
"0.5857846",
"0.5854855",
"0.58521384",
"0.5836948",
"0.5799264",
"0.57637596",
"0.5738355",
"0.5719306",
"0.56874996",
"0.5679826",
"0.56382746",
"0.5637987... | 0.0 | -1 |
Compute the Gaussian peak profile. | def gauss(self, X, xm, amp, w):
return amp * np.exp(-((X - xm) / w) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussfit(x, y, peak=1., center=0., std=.1):\r\n def res(p, y, x):\r\n top1, m1, std1 = p\r\n y_fit = mm.gauss(x, top1, m1, std1)\r\n err = y - y_fit\r\n return err\r\n p = [peak, center, std] # Initial guesses for leastsq\r\n plsq = leastsq(res, p, args = (y, x), maxfev=20... | [
"0.6364197",
"0.623246",
"0.6216074",
"0.6212289",
"0.619425",
"0.6186613",
"0.6060523",
"0.60587347",
"0.60171807",
"0.59983605",
"0.5984888",
"0.5976489",
"0.5970797",
"0.5862341",
"0.5861806",
"0.5832627",
"0.57940155",
"0.57804304",
"0.57527846",
"0.57506067",
"0.5734895"... | 0.59010243 | 13 |
Compute the Lorentzian peak profile. | def lorentz(self, X, xm, amp, w):
return amp / (1 + ((X - xm) / (w / 2)) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak_PSF(self):\n return self.compute_PSF(np.zeros(self.N_zern))",
"def peak_PSF(self):\n im, strehl = self.compute_PSF(np.zeros(self.N_act))\n return strehl",
"def peak(self):\n pass",
"def peak(self):\n return self.peak",
"def getPeakValue( self ):\n nCurrent... | [
"0.72995746",
"0.6566311",
"0.654055",
"0.637646",
"0.63627994",
"0.6102799",
"0.6033322",
"0.5952453",
"0.5939459",
"0.59103334",
"0.5906687",
"0.5873906",
"0.5858595",
"0.5827233",
"0.58253515",
"0.5756233",
"0.5714244",
"0.5683396",
"0.56586415",
"0.56477827",
"0.56377655"... | 0.5341669 | 41 |
Compute the asymmetric Gaussian peak profile. | def agauss(self, X, xm, amp, w, a):
# w(x) = 2 * w / (1 + np.exp(a * (X - xm)))
return amp * np.exp(-((X - xm) / (2 * w / (1 + np.exp(a * (X - xm))))) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussfit(x, y, peak=1., center=0., std=.1):\r\n def res(p, y, x):\r\n top1, m1, std1 = p\r\n y_fit = mm.gauss(x, top1, m1, std1)\r\n err = y - y_fit\r\n return err\r\n p = [peak, center, std] # Initial guesses for leastsq\r\n plsq = leastsq(res, p, args = (y, x), maxfev=20... | [
"0.6293587",
"0.62358934",
"0.62097913",
"0.6087951",
"0.60861367",
"0.605245",
"0.5974075",
"0.59732586",
"0.5967592",
"0.595449",
"0.587087",
"0.5870009",
"0.58616084",
"0.5853523",
"0.5816489",
"0.575692",
"0.5750751",
"0.5736164",
"0.57060003",
"0.5699098",
"0.5689975",
... | 0.55172855 | 42 |
Compute the asymmetric Lorentzian peak profile. | def alorentz(self, X, xm, amp, w, a):
# w(x) = 2 * w / (1 + np.exp(a * (X - xm)))
return amp / (1 + ((X - xm) / ((2 * w / (1 + np.exp(a * (X - xm)))) / 2)) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak_PSF(self):\n return self.compute_PSF(np.zeros(self.N_zern))",
"def peak_PSF(self):\n im, strehl = self.compute_PSF(np.zeros(self.N_act))\n return strehl",
"def peak(self):\n pass",
"def matchProfilePeak(pkp, p, w): #{\n vrbMsg(5, 'matchProfilePeak() pkp = ' + str(pkp) + ... | [
"0.73277205",
"0.6605022",
"0.64444894",
"0.6160604",
"0.6141797",
"0.6052952",
"0.59925836",
"0.59748125",
"0.5967491",
"0.59350735",
"0.5889566",
"0.58431536",
"0.58223355",
"0.58149827",
"0.58111596",
"0.57790834",
"0.5764254",
"0.5747256",
"0.5684734",
"0.5655537",
"0.559... | 0.0 | -1 |
Return the queryset against which an 'quotes' query should be executed. | def resolve_quotes(root, info, ids: list[int], **kwargs):
return Quote.objects.filter(id__in=ids) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_quotes(self) -> List[Quote]:\n query = '''\n SELECT *\n FROM quotes\n ORDER BY created_at DESC\n '''\n\n ret = self.__execute_query(query)\n\n return self.__build_quotes_from_query_result(ret.fetchall())",
"def qs(self) -> MIZQuerySet:\n ... | [
"0.6564898",
"0.618792",
"0.6134771",
"0.60598874",
"0.603354",
"0.603354",
"0.60065687",
"0.5974736",
"0.59375596",
"0.59103644",
"0.59103644",
"0.59021294",
"0.5901232",
"0.58975244",
"0.5885935",
"0.5885935",
"0.58627456",
"0.5852958",
"0.58356386",
"0.5800677",
"0.5773868... | 0.60396767 | 4 |
Add claims to JWT token | def add_claims_to_jwt(identity):
user = UserModel.find_by_id(identity)
if user.is_admin:
return {"is_admin": True}
return {"is_admin": False} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_claims_to_access_token(identity):\n if identity == 'admin':\n roles = 'admin'\n else:\n roles = 'peasant'\n\n now = datetime.utcnow()\n return {\n 'exp': now + current_app.config['JWT_EXPIRES'],\n 'iat': now,\n 'nbf': now,\n 'sub': identity,\n 'r... | [
"0.7821878",
"0.67328346",
"0.6654437",
"0.6622506",
"0.66054577",
"0.64577246",
"0.6385723",
"0.63410336",
"0.6148785",
"0.5864262",
"0.58537203",
"0.5846656",
"0.5811965",
"0.5796584",
"0.5792116",
"0.5760709",
"0.5654095",
"0.5645741",
"0.55854166",
"0.5566702",
"0.5556047... | 0.7737124 | 1 |
Get user by user user_id. | def getPapi(score):
#logging.info('UserController.getUser(%s)', user_id)
uraian = interpret_service.getPapi(score)
return uraian | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(user_id):\n\n return User.query.get(user_id)",
"def get_user_by_id(user_id):\n return User.query.get(user_id)",
"def get_user(user_id):\n try:\n return UserModel.objects.get(id=user_id)\n except UserModel.DoesNotExist:\n return None",
"def get_... | [
"0.8844916",
"0.8836316",
"0.87774795",
"0.87506026",
"0.87506026",
"0.87506026",
"0.87506026",
"0.8749268",
"0.87243897",
"0.86994576",
"0.86654264",
"0.86319464",
"0.86289185",
"0.8573473",
"0.8535361",
"0.8404858",
"0.8393947",
"0.83881545",
"0.8363875",
"0.83571035",
"0.8... | 0.0 | -1 |
Get user by user user_id. | def getPapiInterpretationById(self,score):
#logging.info('UserController.getUser(%s)', user_id)
uraian = interpret_service.getPapiInterpretationById(score)
return uraian | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(user_id):\n\n return User.query.get(user_id)",
"def get_user_by_id(user_id):\n return User.query.get(user_id)",
"def get_user(user_id):\n try:\n return UserModel.objects.get(id=user_id)\n except UserModel.DoesNotExist:\n return None",
"def get_... | [
"0.8844916",
"0.8836316",
"0.87774795",
"0.87506026",
"0.87506026",
"0.87506026",
"0.87506026",
"0.8749268",
"0.87243897",
"0.86994576",
"0.86654264",
"0.86319464",
"0.86289185",
"0.8573473",
"0.8535361",
"0.8404858",
"0.8393947",
"0.83881545",
"0.8363875",
"0.83571035",
"0.8... | 0.0 | -1 |
Returns a dag that inserts into a dimension table. Optionally creates table first and truncates it | def load_dim_table_dag(
parent_dag,
task_id,
redshift_conn_id,
aws_credentials_id,
table,
sql_create="",
drop_first=False,
sql_insert="",
truncate=True,
*args, **kwargs):
dag = DAG(f"{parent_dag}.{task_id}", **kwargs)
load_dim_table = LoadDimensionOperator(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_and_insert_dls(connection: DBConnection) -> None:\n print(\"\\n[-] creating table dls\", end=\"\")\n connection.execute(\"\"\"\n CREATE TABLE dls AS\n SELECT did, SUM(tf) AS len FROM tfs GROUP BY did\n \"\"\")\n print(\"\\r[+] creating table dls\")",
"def create_and_insert_d(... | [
"0.60723263",
"0.5962763",
"0.56705636",
"0.5535991",
"0.5523139",
"0.5464349",
"0.52993214",
"0.52567625",
"0.52302843",
"0.5219455",
"0.521653",
"0.51876223",
"0.51766443",
"0.5151148",
"0.5134393",
"0.5126815",
"0.5085533",
"0.50795525",
"0.50790215",
"0.5074062",
"0.50646... | 0.6552641 | 0 |
Sets the text of the checkbox. | def uiCheckboxSetText(checkbox, text):
clibui.uiCheckboxSetText(checkbox, bytes(text, 'utf-8')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_text(self):\n pass",
"def set(cls, text: str, title: str, graceful: bool = True) -> str:\n result, found, modified = cls._do_checkbox_setting(text, title, ('[ ]', '[x]', 1))\n\n if not found:\n raise UserInputError(\"Checkbox with title {!r} was not found in the provided t... | [
"0.71137416",
"0.697719",
"0.6968396",
"0.6908016",
"0.68112147",
"0.6774936",
"0.67715794",
"0.66549385",
"0.6642958",
"0.66389287",
"0.6630149",
"0.66155756",
"0.6605163",
"0.65802854",
"0.6578043",
"0.64467585",
"0.64430046",
"0.638455",
"0.63706493",
"0.6329293",
"0.62968... | 0.8231321 | 0 |
Given a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer p we want to find a positive integer k, if it exists, such as the sum of the digits of n taken to the successive powers of p is equal | def dig_pow(n, p):
t = sum(pow(int(j), p+i) for i, j in enumerate(str(n)))
return t/n if t % n == 0 else -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(n: int = 998001) -> int:\n\n answer = 0\n for i in range(999, 99, -1): # 3 digit numbers range from 999 down to 100\n for j in range(999, 99, -1):\n product_string = str(i * j)\n if product_string == product_string[::-1] and i * j < n:\n answer = max(... | [
"0.68687075",
"0.68681234",
"0.68437535",
"0.6837566",
"0.6809931",
"0.6789851",
"0.67678994",
"0.665737",
"0.665231",
"0.6639664",
"0.6623882",
"0.66205895",
"0.6618414",
"0.6604001",
"0.6597763",
"0.6577036",
"0.65451884",
"0.65379083",
"0.6534083",
"0.6528206",
"0.6516482"... | 0.6835901 | 4 |
Is the chassis at an ok distance and heading. | def isAligned(self):
return (
abs(self.desired_distance - self.vision.getDistance())
<= self.DISTANCE_TOLERANCE
) and (abs(self.vision.getHeading()) <= self.HEADING_TOLERANCE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isFinished(self) -> bool:\n\n # Need to convert distance travelled to degrees. The Standard\n # Romi Chassis found here, https://www.pololu.com/category/203/romi-chassis-kits,\n # has a wheel placement diameter (149 mm) - width of the wheel (8 mm) = 141 mm\n # or 5.551 inches. We th... | [
"0.66615814",
"0.6175901",
"0.6169441",
"0.61596024",
"0.60913706",
"0.60819495",
"0.60487646",
"0.59601647",
"0.59601647",
"0.59549314",
"0.59000343",
"0.58970785",
"0.58808845",
"0.58594424",
"0.58380467",
"0.5824308",
"0.5816009",
"0.57968396",
"0.5753469",
"0.5738332",
"0... | 0.6322278 | 1 |
The name of the solver. | def name(self):
return s.MOSEK | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return self.name + \"-\" + SatSolver.getName(self.satSolver)",
"def getName(satSolver):\n if satSolver == SatSolver.LINGELING:\n return \"lingeling\"\n elif satSolver == SatSolver.MINISAT:\n return \"minisat\"\n elif satSolver == SatSolver.PI... | [
"0.7075065",
"0.6923393",
"0.66534317",
"0.65357727",
"0.64830935",
"0.64577514",
"0.64566576",
"0.64563495",
"0.6404059",
"0.6391155",
"0.6370548",
"0.6363768",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679... | 0.0 | -1 |
Returns dictionary with keys and values switched from passed Enum | def reverse_enum(
enum_to_reverse: Union[
Type[SMOOTHIE_G_CODE],
Type[MAGDECK_G_CODE],
Type[TEMPDECK_G_CODE],
Type[THERMOCYCLER_G_CODE],
Type[HEATER_SHAKER_G_CODE],
]
) -> Dict:
# I don't know what is going on with mypy, it is complaining
# about keys not existing... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enum_dict(self):\n import warnings\n warnings.warn('You should not use enum_dict. Use enum instead',\n DeprecationWarning)\n return dict((item.key, item.value) for item in self.enum)",
"def mapping_for_enum(mapping):\n return dict(mapping.keys())",
"def enum(**e... | [
"0.73873127",
"0.7287482",
"0.6715382",
"0.6702338",
"0.6671906",
"0.6591376",
"0.643838",
"0.613837",
"0.6075028",
"0.60515",
"0.5982939",
"0.59165853",
"0.58932054",
"0.5892574",
"0.58207345",
"0.5817733",
"0.56924653",
"0.56874853",
"0.56688094",
"0.5668737",
"0.5668737",
... | 0.7200452 | 2 |
cut_array_border Sets one px wide border around the array to 0 | def cut_array_border(array):
array[:, [0, array.shape[1]-1]]=0
array[[0, array.shape[0]-1], :]=0
return array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cut_transformed_array_borders(array): \n for col in range(array.shape[1]): \n col_=array[:, col]\n \n where=np.where(col_>0)\n \n if len(where[0])>0:\n \n col_[[np.min(where[0]),np.min(where[0])+1, np.max(where[0]), np.max(where[0])-1 ]]=0\n ... | [
"0.692899",
"0.6507136",
"0.6466207",
"0.63531655",
"0.6335855",
"0.62455386",
"0.62202257",
"0.60580784",
"0.60332763",
"0.6007357",
"0.59450877",
"0.5913738",
"0.5901717",
"0.5861516",
"0.5836165",
"0.58290404",
"0.57566255",
"0.5711733",
"0.5709437",
"0.57052237",
"0.56971... | 0.7704499 | 0 |
Create an Nbin discrete colormap from the specified input map | def discrete_cmap(N, base_cmap=None):
# Note that if base_cmap is a string or None, you can simply do
# return plt.cm.get_cmap(base_cmap, N)
# The following works for string, None, or a colormap instance:
base = plt.cm.get_cmap(base_cmap)
color_list = base(np.linspac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n base = plt.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None):\n # see https://gist.github.com/jakevdp/91077b0cae40f8f8244a\... | [
"0.7242805",
"0.71656674",
"0.6901114",
"0.6861819",
"0.6861819",
"0.6861819",
"0.6861819",
"0.6861682",
"0.6854892",
"0.684856",
"0.67342144",
"0.66580445",
"0.6597808",
"0.65941465",
"0.65885794",
"0.6582792",
"0.6508348",
"0.64398456",
"0.64053196",
"0.63276744",
"0.631679... | 0.68781185 | 3 |
Create an Nbin discrete colormap from the specified input map | def discrete_cmap(N, base_cmap=None):
# Note that if base_cmap is a string or None, you can simply do
# return plt.cm.get_cmap(base_cmap, N)
# The following works for string, None, or a colormap instance:
base = plt.cm.get_cmap(base_cmap)
color_list = base(np.linspac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n base = plt.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None):\n # see https://gist.github.com/jakevdp/91077b0cae40f8f8244a\... | [
"0.7242397",
"0.71653104",
"0.69008815",
"0.6861418",
"0.6861418",
"0.6861418",
"0.6861418",
"0.6861333",
"0.68545824",
"0.6848159",
"0.6733649",
"0.66582817",
"0.6597989",
"0.65930843",
"0.65877783",
"0.6582562",
"0.6508166",
"0.64398545",
"0.64054126",
"0.63284075",
"0.6316... | 0.6877964 | 4 |
Create an Nbin discrete colormap from the specified input map | def discrete_cmap(N, base_cmap=None):
# Note that if base_cmap is a string or None, you can simply do
# return plt.cm.get_cmap(base_cmap, N)
# The following works for string, None, or a colormap instance:
base = plt.cm.get_cmap(base_cmap)
color_list = base(np.linspac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n base = plt.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None):\n # see https://gist.github.com/jakevdp/91077b0cae40f8f8244a\... | [
"0.7242805",
"0.71656674",
"0.6901114",
"0.6861819",
"0.6861819",
"0.6861819",
"0.6861819",
"0.6861682",
"0.6854892",
"0.684856",
"0.67342144",
"0.66580445",
"0.6597808",
"0.65941465",
"0.65885794",
"0.6582792",
"0.6508348",
"0.64398456",
"0.64053196",
"0.63276744",
"0.631679... | 0.68781185 | 5 |
Creates a transpose convolutional layer, with optional batch normalization. | def deconv(in_channels, out_channels, kernel_size, stride=2, padding=1, batch_norm=True):
layers = []
# append transpose conv layer
# TODO: shouldn't we set bias to NOT batch_norm instead of always being False ?
layers.append(nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride, padding, bi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transpose(incoming, conv, nonlinearity, *args, **kwargs):\n return TransposedConv2DLayer(incoming, conv.input_shape[1],\n conv.filter_size, stride=conv.stride,\n crop=conv.pad, W=conv.W,\n flip_filters=not conv.f... | [
"0.7462499",
"0.7347878",
"0.70849156",
"0.7082004",
"0.70411414",
"0.70256853",
"0.69217646",
"0.69170606",
"0.6878549",
"0.6840713",
"0.6840472",
"0.682022",
"0.675202",
"0.66635484",
"0.6655914",
"0.66203207",
"0.6613836",
"0.65701747",
"0.65648377",
"0.6539846",
"0.653325... | 0.5680423 | 71 |
Creates a grid consisting of pairs of columns, where the first column in each pair contains images source images and the second column in each pair contains images generated by the CycleGAN from the corresponding images in the first column. | def merge_images(sources, targets):
batch_size, channels, h, w = sources.shape
rows = int(np.sqrt(batch_size))
cols = int(math.ceil(batch_size / rows))
grid = np.zeros([channels, rows*h, cols*w*2], dtype=np.uint8)
for idx, (s, t) in enumerate(zip(sources, targets)):
i = idx // cols
j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_image(output):\n grid = []\n for data in output:\n grid += [make_grid(data, nrow=5, normalize=True)]\n return grid",
"def generate_image_grid(sess, df, filenames,op, op2):\n #x_points = np.arange(0, 1, 1.5).astype(np.float32)\n #y_points = np.arange(0, 1, 1.5).astype(np.float32)\n\... | [
"0.69411665",
"0.6738059",
"0.67267895",
"0.6512143",
"0.64766246",
"0.6342498",
"0.62053764",
"0.6200822",
"0.61819357",
"0.60954654",
"0.6062169",
"0.5935223",
"0.5913957",
"0.5892355",
"0.587261",
"0.580699",
"0.57915264",
"0.57721406",
"0.5745773",
"0.57394326",
"0.569796... | 0.6092752 | 10 |
Converts a tensor to a numpy array. | def tensor_to_image(x):
# scale back from [-1,1] to [0,255]
x = x.add(1).mul_(255).div_(2) # x = ((x + 1)*255 / (2))
if x.is_cuda:
x = x.cpu()
x = x.data.numpy().astype(np.uint8) # convert to numpy
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_numpy(tensor):\n raise NotImplementedError",
"def _torch_to_numpy(tensor):\n return tensor.detach().cpu().numpy()",
"def tensor2np(x):\n return x.cpu().numpy()",
"def to_numpy(tensor):\n return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()",
"def to_... | [
"0.88680196",
"0.7880515",
"0.76655036",
"0.7522597",
"0.74797785",
"0.7475946",
"0.737246",
"0.7314128",
"0.7301266",
"0.72804946",
"0.72249216",
"0.71495664",
"0.70966536",
"0.7014455",
"0.6997283",
"0.6866113",
"0.68626696",
"0.6861781",
"0.6804996",
"0.67857087",
"0.67622... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 10 each step size | def adjust_learning_rate(optimizer, iteration, step_size):
if iteration in step_size:
lr = args.lr * (0.1 ** (step_size.index(iteration) + 1))
print_with_time('Adjust learning rate to {}'.format(lr))
for param_group in optimizer.param_groups:
param_group['lr'] = lr
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self.... | [
"0.76339084",
"0.7539126",
"0.7539126",
"0.74836206",
"0.746592",
"0.74440557",
"0.74232185",
"0.74024343",
"0.7389444",
"0.73339856",
"0.7327335",
"0.7292844",
"0.72852933",
"0.72852933",
"0.72641027",
"0.7254303",
"0.72373533",
"0.7225786",
"0.7216376",
"0.7215519",
"0.7210... | 0.7455998 | 5 |
Return (but do not delete) the first element in the deque | def first(self):
if self.is_empty():
raise Empty("List is empty!")
return self._header._next._element | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\n return self.deque[0]",
"def first(self):\n if self.is_empty():\n raise Empty('Queue is empty')\n return self._data[self._front]",
"def first(self):\n\t\tif self.is_empty():\n\t\t\traise Empty('Queue is empty')\n\t\treturn self._head._element",
"def first(sel... | [
"0.8202498",
"0.7680047",
"0.76257837",
"0.7625511",
"0.7621606",
"0.75584203",
"0.75484765",
"0.7534082",
"0.75149435",
"0.74943185",
"0.73554665",
"0.73415995",
"0.7328521",
"0.7325389",
"0.73072535",
"0.72592473",
"0.7232916",
"0.72256714",
"0.7225426",
"0.7207149",
"0.714... | 0.0 | -1 |
Insert e into the front of the list | def insert_first(self, e):
self._insert_between(e, self._header, self._header._next) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_first(self, e):\n self._insert_between(e, self._head, self._head._next)",
"def insert_first(self, e):\n self._insert_between(e, self._head, self._head._next)",
"def _first_insert(self, e):\n self._start = self._Node(e, None, None)\n self._start._prev = self._start\n self._start._... | [
"0.7790675",
"0.7674725",
"0.73999256",
"0.7299574",
"0.7073377",
"0.7015303",
"0.6949782",
"0.6639982",
"0.66348696",
"0.66347545",
"0.65856266",
"0.6580404",
"0.6545663",
"0.65266675",
"0.64939046",
"0.64939046",
"0.6489516",
"0.6461378",
"0.64611506",
"0.64405155",
"0.6426... | 0.65714085 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.