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 |
|---|---|---|---|---|---|---|
Replace specific layer of model | def replace_layer(old_layer, init_weight, init_bias=None, keeping=False):
if hasattr(old_layer, "bias") and old_layer.bias is not None:
bias_flag = True
else:
bias_flag = False
if isinstance(old_layer, MaskConv2d) and keeping:
new_layer = MaskConv2d(
init_weight.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _replace(self, match_layer_node, replacement_layer_node):\n if self._is_functional_model(self.model):\n self._replace_functional(match_layer_node, replacement_layer_node)\n else:\n self._replace_sequential(match_layer_node, replacement_layer_node)",
"def _add_replacement_layer(layer_node):\n ... | [
"0.711397",
"0.65308017",
"0.64022875",
"0.6257557",
"0.6102601",
"0.6083795",
"0.60042804",
"0.59850025",
"0.58890045",
"0.5859135",
"0.57935053",
"0.5748658",
"0.57331145",
"0.5721178",
"0.57164836",
"0.57109594",
"0.56713575",
"0.565625",
"0.56204945",
"0.561972",
"0.56019... | 0.63853943 | 3 |
The forward pass of the LGN GNN. | def forward(
self,
data: Union[Dict[str, torch.Tensor], torch.Tensor, np.ndarray],
covariance_test: bool = False,
) -> Union[GVec, Tuple[GVec, List[GVec]]]:
# Extract node features and masks
node_scalars, node_ps, node_mask, edge_mask = self._prepare_input(data)
# Ca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self):\n self.img_gen, self.loss_reg, self.parsav = self.net_G(self.input_P1, self.input_P2, self.input_BP1, self.input_BP2, self.input_SPL1, self.input_SPL2)",
"def L_model_forward(X, parameters):\n pass",
"def forward(self, x, h_last=None):\n\n # forward pass of the RNNLM network... | [
"0.7021746",
"0.6606525",
"0.650498",
"0.6491817",
"0.64837533",
"0.64366865",
"0.6392006",
"0.6380099",
"0.6379494",
"0.6359318",
"0.6337736",
"0.63366437",
"0.6324792",
"0.6317061",
"0.6185036",
"0.6175763",
"0.6145614",
"0.61447585",
"0.6138968",
"0.6118653",
"0.6102638",
... | 0.0 | -1 |
Aggregate to the latent space. | def aggregate(map_to_latent: str, latent_features: Union[GVec, torch.Tensor]) -> GVec:
if map_to_latent.lower() == "sum":
return GVec(
{
weight: torch.sum(value, dim=-3, keepdim=True).unsqueeze(dim=-3)
for weight, value in latent_features.items()
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate(global_params, running_aggregate, aggregation_result):\n running_ref = running_aggregate.get_ref('values')\n agg_ref = aggregation_result.get_ref('values')\n for i in range(global_params.dims):\n running_ref[i] += agg_ref[i]\n return running_aggregate",
"def aggregate(self):\n ... | [
"0.5966278",
"0.59019816",
"0.58396506",
"0.5788319",
"0.5744982",
"0.5739673",
"0.5610623",
"0.5600835",
"0.5543926",
"0.5533339",
"0.55264705",
"0.54555935",
"0.5397923",
"0.5355549",
"0.5339577",
"0.5326833",
"0.5324007",
"0.530614",
"0.530614",
"0.530614",
"0.530614",
"... | 0.57190406 | 6 |
Returns parameters of a diagonal Gaussian distribution. | def forward(self, z, mask=None):
np_1 = torch.zeros(z.shape[0], z.shape[1], self.out_dim)
np_2 = torch.zeros_like(np_1)
# Pass through individual networks.
for dim, z_dim in enumerate(z.transpose(0, 1)):
if mask is not None:
idx = torch.where(mask[:, dim])[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_gaussian_params(X):\n mu = X.mean(axis=0)\n var = X.std(axis=0)**2.0\n return mu,var",
"def gaussian_parameters(h, dim=-1):\n m, h = torch.split(h, h.size(dim) // 2, dim=dim)\n v = F.softplus(h) + 1e-8\n return m, v",
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma... | [
"0.6621343",
"0.6526359",
"0.63007694",
"0.6299114",
"0.6171184",
"0.61131835",
"0.6096726",
"0.60409284",
"0.5998236",
"0.5990908",
"0.5940768",
"0.59406936",
"0.591469",
"0.58912814",
"0.5884686",
"0.58705956",
"0.5857832",
"0.5830444",
"0.5819672",
"0.5807093",
"0.579993",... | 0.0 | -1 |
Returns parameters of a diagonal Gaussian distribution. | def forward(self, z, mask=None):
out = torch.zeros(z.shape[0], z.shape[1], self.inter_dim)
# Pass through individual networks.
for dim, z_dim in enumerate(z.transpose(0, 1)):
if mask is not None:
idx = torch.where(mask[:, dim])[0]
z_in = z_dim[idx].un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_gaussian_params(X):\n mu = X.mean(axis=0)\n var = X.std(axis=0)**2.0\n return mu,var",
"def gaussian_parameters(h, dim=-1):\n m, h = torch.split(h, h.size(dim) // 2, dim=dim)\n v = F.softplus(h) + 1e-8\n return m, v",
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma... | [
"0.6621343",
"0.6526359",
"0.63007694",
"0.6299114",
"0.6171184",
"0.61131835",
"0.6096726",
"0.60409284",
"0.5998236",
"0.5990908",
"0.5940768",
"0.59406936",
"0.591469",
"0.58912814",
"0.5884686",
"0.58705956",
"0.5857832",
"0.5830444",
"0.5819672",
"0.5807093",
"0.579993",... | 0.0 | -1 |
Returns parameters of a diagonal Gaussian distribution. | def forward(self, z, mask=None):
out = torch.zeros(z.shape[0], z.shape[1], self.inter_dim)
# Pass through first network.
for dim, z_dim in enumerate(z.transpose(0, 1)):
if mask is not None:
idx = torch.where(mask[:, dim])[0]
z_in = z_dim[idx].unsqueez... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_gaussian_params(X):\n mu = X.mean(axis=0)\n var = X.std(axis=0)**2.0\n return mu,var",
"def gaussian_parameters(h, dim=-1):\n m, h = torch.split(h, h.size(dim) // 2, dim=dim)\n v = F.softplus(h) + 1e-8\n return m, v",
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma... | [
"0.6621343",
"0.6526359",
"0.63007694",
"0.6299114",
"0.6171184",
"0.61131835",
"0.6096726",
"0.60409284",
"0.5998236",
"0.5990908",
"0.5940768",
"0.59406936",
"0.591469",
"0.58912814",
"0.5884686",
"0.58705956",
"0.5857832",
"0.5830444",
"0.5819672",
"0.5807093",
"0.579993",... | 0.0 | -1 |
Computing the sigmoid of z | def sigmoid(z):
s = 1 / (1 + np.exp(-z)) #definition of the sigmoid function
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(z): \n return 1/(1 + np.e**(-z))",
"def sigmoid(z):\n return 1 / (1 + e ** -z)",
"def sigmoid(z):\r\n \r\n return 1.0 / (1.0+np.exp(-z))",
"def sigmoid(z):\n\treturn 1.0/(1.0+np.exp(-z))",
"def sigmoid(z):\n return 1 / (1 ... | [
"0.92135817",
"0.9133256",
"0.9079438",
"0.901815",
"0.8965425",
"0.896515",
"0.8942718",
"0.89072293",
"0.89060616",
"0.89042807",
"0.8901639",
"0.8889068",
"0.88449734",
"0.8842557",
"0.88396263",
"0.88335305",
"0.881918",
"0.8803741",
"0.87993366",
"0.878562",
"0.8776092",... | 0.8830553 | 16 |
CrossEntropy Cost function of logisticregression. | def cross_entropy_cost(m, A, L):
cost = (-1 / m) * np.sum(L * np.log(A) + (1 - L) * (np.ma.log(1 - A))) #Note: Using numpy masked array np.ma for values of log(0)
# Sanity checks
cost = np.squeeze(cost) #squeeze() removes single dimensional elements from the array: e.g. (1, 3, 1) -> (3,)
assert(cost.shape == ())... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cross_entropy(self):\n assert (self.dataset is not None) and (self.labels is not None), 'Logistic Regression requires a dataset and labels.'\n potential = 0.0\n logits = self.dataset @ self.parameters[:self.dataset.shape[1]]\n max_logits = torch.max(torch.zeros(logits.shape[0]),... | [
"0.7620326",
"0.7539808",
"0.72711164",
"0.7247201",
"0.71958846",
"0.7160275",
"0.7102912",
"0.7061106",
"0.7030144",
"0.7016394",
"0.7009053",
"0.6960069",
"0.69513154",
"0.69331586",
"0.69112384",
"0.6907551",
"0.6875128",
"0.6865492",
"0.68419284",
"0.6829443",
"0.6815052... | 0.74914515 | 2 |
Converts a bytes objects containing RGB/BGR data to a `numpy`_ array. | def bytes_to_rgb(data, resolution):
width, height = resolution
fwidth, fheight = raw_resolution(resolution)
# Workaround: output from the video splitter is rounded to 16x16 instead
# of 32x16 (but only for RGB, and only when a resizer is not used)
if len(data) != (fwidth * fheight * 3):
fwid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_to_np(img: bytes) -> np.ndarray:\n im = Image.open(BytesIO(img))\n im = im.convert(\"RGB\")\n return np.array(im)",
"def image_decoder(rawbytes):\n img = Image.open(BytesIO(rawbytes))\n array = np.asarray(img, dtype=np.uint8)\n return array",
"def jpg2rgb(image_data: bytes) -> np.ndarray:... | [
"0.8172505",
"0.7486111",
"0.71808004",
"0.69675016",
"0.6933188",
"0.6792523",
"0.6778288",
"0.6738023",
"0.6633244",
"0.6520258",
"0.651501",
"0.64373976",
"0.63514537",
"0.63396627",
"0.63338727",
"0.63251585",
"0.62947226",
"0.62290615",
"0.6226957",
"0.62201655",
"0.6193... | 0.6526338 | 9 |
Computes topk accuracy, from predicted and true labels. | def accuracy(scores, targets, k):
batch_size = targets.size(0)
_, ind = scores.topk(k, 1, True, True)
correct = ind.eq(targets.view(-1, 1).expand_as(ind))
correct_total = correct.view(-1).float().sum() # 0D tensor
return correct_total.item() * (100.0 / batch_size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(output, target, topk=(1,)):\n maxk = max(topk)\n batch_size = target.size(0)\n\n _, pred = output.topk(maxk, 1, True, True)\n pred = pred.t()\n correct = pred.eq(target.view(1, -1).expand_as(pred))\n\n res = []\n for k in topk:\n correct_k = correct[:k].view(-1).float().sum... | [
"0.8226467",
"0.8210115",
"0.8147518",
"0.8125917",
"0.81230915",
"0.8099589",
"0.80985445",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8095448",
"0.8091758",
"0.8091758",
... | 0.0 | -1 |
Return this anomaly's effect on a location's pressure in terms of millibars of deviation from norm. | def pressure_effect(self, location):
return self.__pressure_effect_impl(location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized_effect_size(self):\n mus = self.mu + self.absolute_effects\n pop_mu = (mus * self.test_splits).sum()\n sigma2_m = (self.test_splits * np.square(mus - pop_mu)).sum()\n f = np.sqrt(sigma2_m) / self.sigma\n return f",
"def get_pressure_normal(self):\n # obp_l... | [
"0.6159483",
"0.5705549",
"0.5658776",
"0.56413823",
"0.5622811",
"0.56132203",
"0.561322",
"0.56084454",
"0.5599146",
"0.5551584",
"0.55485165",
"0.55442214",
"0.55362886",
"0.55347073",
"0.55325395",
"0.5526802",
"0.5523249",
"0.55143136",
"0.54921734",
"0.5482909",
"0.5480... | 0.65173686 | 0 |
x_orig is tensor (requires_grad=False) | def __call__(self, net, x_orig, label, targeted=False, epsilon=0.1,
max_epsilon=0.3, max_iterations=1000, num_restart=1,
rand_start=True):
# make sure we run at least once
if num_restart < 1:
num_restart = 1
# if not using randomized start, no poin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_tensor(self, x):\n pass",
"def transform(self, X: Tensor) -> Tensor:\n pass # pragma: no cover",
"def state_requires_grad(x):\n if isinstance(x, torch.Tensor):\n x.requires_grad = True\n elif isinstance(x, list):\n for i in range(len(x)):\n x[i] = state... | [
"0.6925579",
"0.66803175",
"0.6670634",
"0.6656589",
"0.66133577",
"0.653196",
"0.64696497",
"0.6465423",
"0.6389738",
"0.63113385",
"0.6260618",
"0.6214925",
"0.6193738",
"0.61846596",
"0.61753476",
"0.61601675",
"0.6096982",
"0.6094436",
"0.60743785",
"0.6052605",
"0.602723... | 0.0 | -1 |
Updates dictionary with environment variables | def update_from_env(d: dict, variables: List[str], inplace: bool = False):
new_keys = {}
for var in variables:
new_keys[var] = os.environ[var]
if inplace:
d.update(new_keys)
return d
for key in d:
if key not in new_keys:
new_keys[key] = d[key]
return new_keys | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, key, item):\n super(EnvironmentVariables, self).__setitem__(key, item)\n os.environ[key] = item",
"def set_environment_variables(env_dict, session):\n for key, value in env_dict.items():\n session.env[key] = value",
"def update_environ():\n\n # Environment varia... | [
"0.7314896",
"0.72648215",
"0.7112216",
"0.70797706",
"0.7009642",
"0.69214106",
"0.68997514",
"0.6867747",
"0.68147206",
"0.6757548",
"0.66731036",
"0.6655416",
"0.6598182",
"0.659608",
"0.6526021",
"0.65181667",
"0.6470328",
"0.64606106",
"0.6452754",
"0.6435232",
"0.642371... | 0.75369257 | 0 |
It calculates the kl_divergence as a score. | def _cal_score_kl_divergence(self, h_mu, h_sigma, r_mu, r_sigma, t_mu, t_sigma):
comp_sigma = h_sigma + r_sigma
comp_mu = h_mu + r_mu
trace_fac = (comp_sigma / t_sigma).sum(-1)
mul_fac = ((t_mu - comp_mu) ** 2 / t_sigma).sum(-1)
det_fac = (torch.log(t_sigma) - torch.log(comp_sigm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kl_divergence(self):\n return self._kl_divergence_func",
"def kl_divergence(self) -> Tensor:\n return self.variational_strategy.kl_divergence().sum(dim=1).mean()",
"def kl_divergence(y_true, y_pred):\n y_pred = tensor_conversion.convert_to_tensor_v2_with_dispatch(y_pred)\n y_true = math_ops... | [
"0.8053553",
"0.80061203",
"0.7779511",
"0.76303214",
"0.74634075",
"0.74550104",
"0.74369895",
"0.74270064",
"0.73695624",
"0.7272954",
"0.72707105",
"0.7267948",
"0.71323913",
"0.7086379",
"0.7082419",
"0.70802724",
"0.7037046",
"0.69306886",
"0.68392843",
"0.68245673",
"0.... | 0.8041528 | 1 |
Read contents of the specified file. ARGUMENTS filename (string) the name of the file to be read RETURNS lines (list of strings) the contents of the file, split by line | def read_file(filename):
infile = open(filename, 'r')
lines = infile.readlines()
infile.close()
return lines | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file_in_lines(filename):\r\n\twith open(filename) as infile:\r\n\t\tlines = infile.readlines()\r\n\treturn [line.strip() for line in lines]",
"def read_lines(filename):\n with open(filename, 'r') as f:\n lines = f.readlines()\n return lines",
"def read_lines_from_file(filename):\n with... | [
"0.858824",
"0.85054225",
"0.8361589",
"0.8360774",
"0.81262994",
"0.81197053",
"0.8099488",
"0.806281",
"0.7953241",
"0.7928299",
"0.78831995",
"0.78567314",
"0.78141814",
"0.7810065",
"0.77770936",
"0.77601427",
"0.7739125",
"0.77176076",
"0.7690341",
"0.7680881",
"0.764715... | 0.8505801 | 1 |
Function to remove stopwords | def remove_stopwords(lista,stopwords):
lista_out = list()
for idx, text in enumerate(lista):
text = ' '.join([word for word in text.split() if word not in stopwords])
text = text.strip()
lista_out.append(text)
#print("Len original: {} - Len processed stopwords: {}".format(len(lista),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)",
"def remove_stopwords(text):\n stopwords = [\"i\", \"me\", \"my\", ... | [
"0.88531566",
"0.8369413",
"0.83565724",
"0.83411294",
"0.8336053",
"0.83236694",
"0.83236694",
"0.83236694",
"0.83236694",
"0.82478267",
"0.82329667",
"0.8223114",
"0.8221244",
"0.8219732",
"0.8200693",
"0.8179456",
"0.81679446",
"0.8165128",
"0.81632656",
"0.81591564",
"0.8... | 0.7826675 | 40 |
Function to normalize accents (removing them) | def strip_accents(lista):
lista_out = list()
for idx,text in enumerate(lista):
try:
text = unicode(text, 'utf-8')
except (TypeError, NameError): # unicode is a default on python 3
pass
text = unicodedata.normalize('NFD', text)
text = text.encode('ascii', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_accented_chars(text):\n text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf-8', 'ignore')\n return text",
"def remove_accented_chars(text):\n text = unidecode.unidecode(text)\n return text",
"def remove_accents(string):\n return unicodedata.normalize('NFKD... | [
"0.7737781",
"0.7663987",
"0.7574864",
"0.75457937",
"0.7367997",
"0.7315611",
"0.72645396",
"0.72284305",
"0.7221782",
"0.7184099",
"0.71731895",
"0.7123765",
"0.7105772",
"0.7094537",
"0.7090537",
"0.6981628",
"0.6979017",
"0.69722664",
"0.6968377",
"0.6952318",
"0.6951829"... | 0.6391861 | 75 |
Assert that an attribute on the video dict is correctly transferred to the underlying model. | def assert_attribute_sync(self, video_attr, model_attr=None, test_value='testing'):
model_attr = model_attr if model_attr is not None else video_attr
v1, = set_resources_and_sync([make_video(**{'media_id': '1234', video_attr: test_value})])
self.assertEqual(
test_value, getattr(mpmod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_attributes_equal(self, video, attrs):\r\n for key, value in attrs.items():\r\n self.assertEquals(getattr(video, key), value)",
"def test_old_video_data(self):\r\n module_system = DummySystem(load_error_modules=True)\r\n xml_data = \"\"\"\r\n <video display_na... | [
"0.74175906",
"0.67295045",
"0.6641028",
"0.63907754",
"0.63814163",
"0.6377068",
"0.6370724",
"0.63302046",
"0.62866104",
"0.6269615",
"0.6154549",
"0.6146784",
"0.614477",
"0.6081221",
"0.60801196",
"0.60602754",
"0.6039293",
"0.60016364",
"0.6001627",
"0.5975568",
"0.59705... | 0.7205434 | 1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Taskrouter.V1.WorkersRealTimeStatisticsInstance {}>".format(
context
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
return "<Twilio.Taskrouter.V1.WorkersRealTimeStatisticsContext {}>".format(
context
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Taskrouter.V1.WorkersRealTimeStatisticsList>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Compute softmax values for each sets of scores in x, numerically stable way. | def softmax(self, x):
""" Meaning: avoid very large exponents by reducing the largest to zero
and everything else to less than that"""
ex = np.exp(x - np.max(x))
return ex / np.sum(ex, axis = 1, keepdims=True) #Sums over rows np.sum([[0, 1], [0, 5]], axis=1) = array([1, 5]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(scores):\n exp_score = np.exp(scores)\n return exp_score / np.sum(exp_score)",
"def _compute_softmax(scores):\n if not scores:\n return []\n\n max_score = None\n for score in scores:\n if max_score is None or score > max_score:\n max_score = score\n\n exp_scores = []\n total_sum... | [
"0.8070468",
"0.80433625",
"0.80231184",
"0.79677385",
"0.79677385",
"0.79677385",
"0.79677385",
"0.7876052",
"0.7836074",
"0.767107",
"0.7657951",
"0.75998616",
"0.75975287",
"0.7573749",
"0.7555996",
"0.7550059",
"0.7547298",
"0.75378263",
"0.7537748",
"0.75364673",
"0.7527... | 0.74474466 | 53 |
Compute softmax values for each sets of scores in x, numerically stable way. | def softmax(x):
""" Meaning: avoid very large exponents by reducing the largest to zero
and everything else to less than that, so they go to zero instead of infinity an Nan"""
ex = np.exp(x - np.max(x))
return ex / ex.sum(axis=1, keepdims = True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(scores):\n exp_score = np.exp(scores)\n return exp_score / np.sum(exp_score)",
"def _compute_softmax(scores):\n if not scores:\n return []\n\n max_score = None\n for score in scores:\n if max_score is None or score > max_score:\n max_score = score\n\n exp_scores = []\n total_sum... | [
"0.8070468",
"0.80433625",
"0.80231184",
"0.79677385",
"0.79677385",
"0.79677385",
"0.79677385",
"0.7876052",
"0.7836074",
"0.767107",
"0.7657951",
"0.75998616",
"0.75975287",
"0.7573749",
"0.7555996",
"0.7550059",
"0.7547298",
"0.75378263",
"0.7537748",
"0.75364673",
"0.7527... | 0.0 | -1 |
Return (x1 != x2) elementwise. | def not_equal(
x1: PolyLike,
x2: PolyLike,
out: Optional[numpy.ndarray] = None,
where: numpy.typing.ArrayLike = True,
**kwargs: Any,
) -> numpy.ndarray:
x1, x2 = numpoly.align_exponents(x1, x2)
if not x1.flags["OWNDATA"]:
x1 = numpoly.polynomial(x1)
if not x2.flags["OWNDATA"]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_equal(x1, x2):\n return compare_chararrays(x1, x2, '!=', True)",
"def pairwise(a,b):\n return a != b",
"def __ne__(self, other):\n return self.x != other.x or self.y != other.y",
"def are_not(self, value1, value2):\n (group_1, val_1) = self.get_val_tuple(value1)\n (group_2,... | [
"0.77226806",
"0.7119816",
"0.70943594",
"0.7031799",
"0.69675016",
"0.6948729",
"0.6907602",
"0.68954045",
"0.6892511",
"0.6875043",
"0.68544334",
"0.68489695",
"0.6784118",
"0.6784118",
"0.67814606",
"0.67814606",
"0.6756815",
"0.6754151",
"0.67435956",
"0.67435956",
"0.674... | 0.67324036 | 24 |
Merge dataframes by index | def merge (*a_data) :
i = 0
for loc_data in a_data :
i += 1
if i == 1 :
loc_new_df = loc_data
else :
loc_new_df = __pd.merge(loc_new_df,loc_data,left_index=True,right_index=True)
return loc_new_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _merge_by_index(self, tables: Tuple[Table, ...], index: str):\n columns = uniq(column for table in tables for column in table.columns)\n merged = Table(columns=columns)\n\n seen = {}\n\n def find_index(row):\n \"\"\"Find index for row, if key already exists.\"\"\"\n ... | [
"0.6812233",
"0.655756",
"0.64117616",
"0.64100575",
"0.6078502",
"0.6052337",
"0.60420763",
"0.60106623",
"0.6002248",
"0.60022134",
"0.5940136",
"0.592078",
"0.59182715",
"0.59171253",
"0.5911129",
"0.58682007",
"0.5834415",
"0.58135813",
"0.5799486",
"0.57939404",
"0.57607... | 0.6686684 | 1 |
Return the name of a random card with 3 or less defense. | def eggsplosion_card(cards: list) -> str:
cards = [
card
for card in cards
if card_types[card["char_type"]] == "Follower" and card["life"] <= 3
]
return random.choice(cards)["card_name"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name():\r\n return _random.choice([male_first(), female_first()])",
"def get_random_lastname_family ():\n if one_chance_in(3):\n return get_random_lastname_irish ()\n elif coinflip():\n return get_random_lastname_scottish ()\n else:\n return get_random_lastname_nameson()",
... | [
"0.6715359",
"0.6683583",
"0.65180373",
"0.64784664",
"0.6403936",
"0.6373773",
"0.63078946",
"0.628647",
"0.6264274",
"0.62553495",
"0.62134594",
"0.62086356",
"0.6189115",
"0.61798203",
"0.6160609",
"0.61584073",
"0.61531466",
"0.61512375",
"0.6133655",
"0.61049354",
"0.610... | 0.72727215 | 0 |
Tests that updating with a malformed value fails | def test_put(populate_hostnames, authenticated_client):
rv = authenticated_client.get(
'/api/observables/{0:d}/'.format(populate_hostnames[0].id))
observable_json = json.loads(rv.data)
rv = authenticated_client.put(
'/api/observables/{0:d}/'.format(observable_json['id']),
data=json.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_item_incorrect_value_type(test_client, item_with_bad_value):\n\n response = test_client.put(GOOD_ITEM_URL,\n data=json.dumps(item_with_bad_value),\n content_type='application/json')\n\n data = json.loads(response.get_data())\n\n a... | [
"0.7336618",
"0.7207815",
"0.71554583",
"0.70740587",
"0.7045646",
"0.697905",
"0.6965757",
"0.69573295",
"0.6954627",
"0.6905297",
"0.68724275",
"0.6771606",
"0.67441",
"0.67182475",
"0.67114776",
"0.6710993",
"0.6707138",
"0.6698792",
"0.6677346",
"0.6671433",
"0.6666845",
... | 0.0 | -1 |
Calculated planet Flux from fluxRatio | def planetFlux_fromFluxRatio(fluxRatio):
vegaFlux = 6.958*10.**(-35.) # $W/m^2
pFlux = fluxRatio*vegaFlux
return pFlux | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flux_ratio(self):\n return self._flux_ratio",
"def Flux(self, flux, r_lim, z_lim):\n if flux == 'mass':\n set_integrand = lambda x: x\n\n elif flux == 'momentum':\n set_integrand = lambda x: x**2\n\n elif flux == 'buoyancy':\n b = self.read_vars(['... | [
"0.702318",
"0.6540288",
"0.6403921",
"0.61347276",
"0.6107439",
"0.6063611",
"0.6063337",
"0.6048169",
"0.60073334",
"0.5975089",
"0.59630424",
"0.5957901",
"0.5957133",
"0.59500575",
"0.59119695",
"0.59119695",
"0.58879894",
"0.5767778",
"0.5764693",
"0.5733011",
"0.5722366... | 0.79457533 | 0 |
For a list of points, return the value and ind of the second smallest | def secondSmallest(d_diff_pts):
tmp_inds = np.arange(len(d_diff_pts))
tmp_inds_min0 = np.argmin(d_diff_pts)
tmp_inds = np.delete(tmp_inds, tmp_inds_min0)
tmp_d_diff_pts =np.delete(d_diff_pts, tmp_inds_min0)
secondSmallest_value = min(tmp_d_diff_pts)
secondSmallest_ind = np.argmin(np.abs(d_diff_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min_point(points):\r\n smallest_point_index = 0\r\n for i in range(1, len(points)):\r\n if points[i][1] < points[smallest_point_index][1]:\r\n smallest_point_index = i\r\n elif points[i][0] > points[smallest_point_index][0] and points[i][1] == points[smallest_point_index][1]... | [
"0.79402167",
"0.7153393",
"0.7102703",
"0.69617814",
"0.6841433",
"0.6822349",
"0.68184066",
"0.6758638",
"0.6753647",
"0.67330354",
"0.67191845",
"0.66847414",
"0.66691005",
"0.66613626",
"0.665042",
"0.6640727",
"0.6623711",
"0.66230416",
"0.6605486",
"0.65277404",
"0.6479... | 0.7209412 | 1 |
For a list of points, return the value and ind of the second smallest | def secondTwoSmallest(d_diff_pts):
d_diff_pts_saved = d_diff_pts
#Find the second smallest
secondSmallest_value, secondSmallest_ind = secondSmallest(d_diff_pts)
#Delete the second smallest
d_diff_pts = np.delete(d_diff_pts,secondSmallest_ind)
#Delete the smallest
tmp_inds = np.arange(len(d_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min_point(points):\r\n smallest_point_index = 0\r\n for i in range(1, len(points)):\r\n if points[i][1] < points[smallest_point_index][1]:\r\n smallest_point_index = i\r\n elif points[i][0] > points[smallest_point_index][0] and points[i][1] == points[smallest_point_index][1]... | [
"0.79402167",
"0.7209412",
"0.7153393",
"0.7102703",
"0.69617814",
"0.6841433",
"0.6822349",
"0.68184066",
"0.6758638",
"0.6753647",
"0.67330354",
"0.67191845",
"0.66847414",
"0.66613626",
"0.665042",
"0.6640727",
"0.6623711",
"0.66230416",
"0.6605486",
"0.65277404",
"0.64795... | 0.66691005 | 13 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.header is None:
self.header = std_msgs.msg.Header()
if self.cmd is None:
self.cmd =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, message=None):\n self.message = message",
"def __init__(self, message=None):\n self.message = message",
"def __init__(self, message=None) -> None:\n super().__init__(message)",
"def __init__(self, message: str = None, **kwargs):\n self.message = message\n ... | [
"0.77207875",
"0.77207875",
"0.7687243",
"0.7625947",
"0.7564293",
"0.7440383",
"0.74175525",
"0.7352349",
"0.7308313",
"0.72808266",
"0.72378874",
"0.722805",
"0.7225032",
"0.7225032",
"0.7219433",
"0.72120637",
"0.72120637",
"0.72120637",
"0.72120637",
"0.72120637",
"0.7212... | 0.7794795 | 0 |
Prints the string representation of an instance | def do_show(self, args):
temp = args.split()
if len(temp) == 0:
print("** class name missing **")
return
elif temp[0] not in self.myclasses:
print("** class doesn't exist **")
return
elif len(temp) < 2:
print('** instance id mi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display(self):\n print(str(self))",
"def __str__(self):\r\n return repr(self)",
"def __repr__(self):\n str(self)",
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def __str__(self):\n return repr(self)",
"def display(self):\n print(self)",
... | [
"0.78180873",
"0.7659494",
"0.76525486",
"0.7631973",
"0.7624355",
"0.75274724",
"0.75187683",
"0.7486338",
"0.74702305",
"0.7459381",
"0.74542874",
"0.74296963",
"0.74252236",
"0.73999614",
"0.7346746",
"0.7341109",
"0.7331948",
"0.73284656",
"0.7324425",
"0.7309293",
"0.729... | 0.0 | -1 |
Returns list of nodes with just one neighbor node. | def get_end_nodes(graph):
nodelist = [
i
for i in graph.nodes_iter()
if len(graph.neighbors(i))==1
]
return nodelist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbours(self):\n return [x.node for x in self.edges]",
"def neighbor_node(self, node):\n neighborhood_node = []\n for i in range(self.nodenum):\n if(self.Adjmatrix[node, i] == 1):\n neighborhood_node.append(i)\n \n return neighborhood_node",
"... | [
"0.74010164",
"0.737462",
"0.72532517",
"0.7129969",
"0.70706856",
"0.7011543",
"0.69622153",
"0.69497406",
"0.69088656",
"0.68546456",
"0.68523836",
"0.6778627",
"0.67689604",
"0.67326325",
"0.6719073",
"0.6684964",
"0.6674869",
"0.6668576",
"0.6661993",
"0.6661993",
"0.6661... | 0.62598306 | 53 |
Creates a networkx graph out of all Voronoi ridge vertices which are inside the original geometry. | def graph_from_voronoi(vor, geometry):
graph = nx.Graph()
for i in vor.ridge_vertices:
if i[0]>-1 and i[1]>-1:
point1 = Point(vor.vertices[i][0])
point2 = Point(vor.vertices[i][1])
# Eliminate all points outside our geometry.
if point1.within(geometry) and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voronoi(geometry,\n network,\n propname,\n **params):\n print('voronoi: nothing yet')",
"def get_voronoi_vertices(self, epsilon=2.5e-4, distance_threshold=0, width_buffer=10):\n voro = Voronoi(self._structure.get_extended_positions(width_buffer)+epsilon)\n xx... | [
"0.70450276",
"0.6434969",
"0.63071525",
"0.62754816",
"0.6202212",
"0.6193984",
"0.6181318",
"0.61705446",
"0.61538225",
"0.61533594",
"0.6105733",
"0.60412776",
"0.59484005",
"0.58958876",
"0.5893371",
"0.5882006",
"0.58768106",
"0.58678263",
"0.58341247",
"0.5813684",
"0.5... | 0.83008176 | 0 |
Model function to construct a tf.estimator.EstimatorSpec. It creates a network given input features (e.g. from a dltk.io.abstract_reader) and training targets (labels). Further, loss, optimiser, evaluation ops and custom tensorboard summary ops can be added. For additional information, | def model_fn(features, labels, mode, params):
print('Estimator constructing model function.....')
# 1. create a model and its outputs
net_output_ops = resnet_3d(
inputs=features,
num_res_units=2,
num_classes=NUM_CLASSES,
filters=(16, 32, 64, 128, 256),
strid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_estimator_spec(features, labels, mode):\n if mode not in {\"train\", \"infer\", \"eval\"}:\n raise ValueError('mode should be in {\"train\", \"infer\", \"eval\"}')\n\n logits = get_logits(features)\n preds = tf.argmax(logits, axis=-1)\n probs = tf.nn.softmax(logits, axis=-1)\n predict... | [
"0.7326729",
"0.7191808",
"0.71243787",
"0.71142024",
"0.7031326",
"0.69994724",
"0.69602257",
"0.6863793",
"0.6835929",
"0.6834096",
"0.67945176",
"0.6793571",
"0.6780604",
"0.6773075",
"0.6762669",
"0.6758128",
"0.673286",
"0.6720593",
"0.67154515",
"0.6710283",
"0.66890466... | 0.6561989 | 34 |
Initialise the iterator after the session has been created. | def after_create_session(self, session, coord):
print("interator session after created..........", config._task_type)
self.iterator_initializer_func(session) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_create_session(self, session, coord):\n self.iterator_initializer_func(session)",
"def after_create_session(self, session, coord):\n self.iterator_initializer_func(session)",
"def init_session(self):\n pass",
"def init_session(self):\n pass",
"def after_create_session(... | [
"0.7544628",
"0.7544628",
"0.7154914",
"0.7154914",
"0.6747339",
"0.6677135",
"0.6412246",
"0.6376045",
"0.6362696",
"0.6277933",
"0.6266516",
"0.6255239",
"0.6247051",
"0.62424946",
"0.6233093",
"0.62212116",
"0.6186286",
"0.6172497",
"0.6155909",
"0.610087",
"0.60536087",
... | 0.6880919 | 4 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(Interaction, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.name is None:
self.name = ''
if self.compatibility is None:
self.compatibility = ''
if s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.77940345",
"0.77196896",
"0.77196896",
"0.7685901",
"0.76253456",
"0.75629234",
"0.7438996",
"0.74165684",
"0.73517054",
"0.73081905",
"0.7280219",
"0.7237793",
"0.7226802",
"0.7223405",
"0.7223405",
"0.7218974",
"0.72109884",
"0.72109884",
"0.72109884",
"0.72109884",
"0.7... | 0.0 | -1 |
Return saved session expiration seconds if any. Is retuned in the form of a timedelta data type. None is returned if there's no value stored or it's malformed. | def expiration_delta(self):
if self.extra_data:
name = getattr(settings, 'AUTHENTICATOR_EXPIRATION', 'expires')
try:
return timedelta(seconds=int(self.extra_data.get(name)))
except (ValueError, TypeError):
pass
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expiration(self) -> typing.Optional[aws_cdk.core.Duration]:\n return self._values.get('expiration')",
"def expiration_time(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"expiration_time\")",
"def _get_expiration(self, expiration_seconds):\n timestamp = time.time()\n ... | [
"0.7113243",
"0.67239463",
"0.6675779",
"0.66589063",
"0.66589063",
"0.65820515",
"0.65542966",
"0.6550881",
"0.6526911",
"0.6467386",
"0.6467224",
"0.6449834",
"0.6429491",
"0.6411405",
"0.64054066",
"0.63921326",
"0.63505644",
"0.6322792",
"0.6313116",
"0.6313116",
"0.62894... | 0.77770007 | 0 |
The primary link URL for this activity item. | def details_url(self):
if self._data.get('details_url'):
path = self._data.get('details_url')
try:
path, hash_ = path.split('#')
hash_ = '#' + hash_
except ValueError:
hash_ = ''
return '{}?from_activity={}{}'.format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIdLink(self):\n return self.urlLink()",
"def get_item_url(self):\n try:\n return self.content_object.get_absolute_url()\n except AttributeError:\n return self.external_url",
"def get_item_url(self, item):\n return self.get_absolute_url(item, 'detail')",
... | [
"0.73726964",
"0.7309584",
"0.72686356",
"0.70228505",
"0.70104975",
"0.70104975",
"0.69942373",
"0.6989369",
"0.6947148",
"0.69264704",
"0.6911357",
"0.6911357",
"0.6885276",
"0.6864332",
"0.68346316",
"0.68308234",
"0.68308234",
"0.6750072",
"0.6750072",
"0.6750072",
"0.675... | 0.0 | -1 |
return a color based on the value given the information on the colormap and its normalization is used for that purpose | def __value2color(self, v):
if np.isscalar(v):
r = self.cmap(self.norm(np.asarray([v])))
else:
r = self.cmap(self.norm(v))
return r.flatten() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_norm(col):\n\n norm_col = [x/255.0 for x in col]\n return norm_col",
"def norm(self):\n return self._color_mapper",
"def _cal_color(xy, norm=False):\n color = gaussian_kde(xy)(xy)\n if norm:\n cmin = np.min(color)\n cmax = np.max(color)\n color = (color - cmin)... | [
"0.6880266",
"0.6859639",
"0.6822679",
"0.6686454",
"0.6606535",
"0.66033316",
"0.65864146",
"0.6570994",
"0.6555635",
"0.6551877",
"0.6515759",
"0.6489695",
"0.6444691",
"0.64401853",
"0.6409031",
"0.6366957",
"0.6344691",
"0.6274081",
"0.62629175",
"0.62438357",
"0.6235757"... | 0.76134557 | 0 |
1. max heapify the array (start at n/2) 2. repeatedly "remove" the first element and move to end | def sort(self,arr):
self.heapify(arr)
for i in range(len(arr)-1,0,-1):
#swap the first and last elements of the heap
arr[i],arr[0] = arr[0],arr[i]
self.bubbleDown(arr,0,i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_heap(arr):\n for i in range(len(arr)-1, -1, -1):\n down_heapify(arr, len(arr), i)",
"def heap_sort_nip(A):\n build_max_heap(A)\n res = []\n for i in range(len(A) - 1, 1, -1):\n res.insert(0, A[1])\n A[1], A[i] = A[i], A[1]\n del A[i]\n A[0] -= 1\n m... | [
"0.7332355",
"0.72560877",
"0.72517484",
"0.71246964",
"0.70521635",
"0.7043834",
"0.7041317",
"0.70364994",
"0.70221657",
"0.70093197",
"0.70074666",
"0.6999831",
"0.69765586",
"0.6943542",
"0.6897989",
"0.68533564",
"0.68164957",
"0.6767977",
"0.67209536",
"0.670007",
"0.66... | 0.0 | -1 |
Retrieves the learning rate with the given state. | def _get_lr(self, var_device, var_dtype, apply_state):
if apply_state is None:
return self._decayed_lr_t[var_dtype], {} # pragma: no cover
apply_state = apply_state or {}
coefficients = apply_state.get((var_device, var_dtype))
if coefficients is None:
coefficien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_rate(self, t):\n # return self.init_learning_rate * (1 - t)\n return self.init_learning_rate / (1 + t)\n # return self.init_learning_rate * exp(-t)\n # return self.init_learning_rate * (.005 / self.init_learning_rate) ** t",
"def learning_rate(epoch):\n self.lr... | [
"0.69861066",
"0.6899162",
"0.6853552",
"0.67728704",
"0.66987705",
"0.6642295",
"0.6564562",
"0.65318996",
"0.6474359",
"0.64466333",
"0.6422898",
"0.6398414",
"0.6398414",
"0.63893676",
"0.63480973",
"0.62532663",
"0.62220645",
"0.6197645",
"0.6156201",
"0.6155164",
"0.6096... | 0.5417424 | 69 |
Whether to use L2 weight decay for `param_name`. | def _do_use_weight_decay(self, param_name):
if self._exclude_from_weight_decay:
for r in self._exclude_from_weight_decay:
if re.search(r, param_name) is not None:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_use_weight_decay(self, param_name):\n if not self.weight_decay_rate:\n return False\n if self.exclude_from_weight_decay:\n for r in self.exclude_from_weight_decay:\n if re.search(r, param_name) is not None:\n return False\n return True",
"def _do_use_weight_decay(self, ... | [
"0.70576096",
"0.70576096",
"0.70576096",
"0.70576096",
"0.70576096",
"0.70372206",
"0.6972458",
"0.6972458",
"0.6972458",
"0.6972458",
"0.61478865",
"0.61143965",
"0.60728186",
"0.5874968",
"0.57316977",
"0.5686603",
"0.5607701",
"0.5540735",
"0.5532297",
"0.5527218",
"0.549... | 0.70423925 | 5 |
Builds multihead dotproduct attention computations. This function builds attributes necessary for `_compute_attention` to costomize attention computation to replace the default dotproduct attention. | def _build_attention(self, qkv_rank):
if self._attention_axes is None:
self._attention_axes = tuple(range(1, qkv_rank - 2))
else:
self._attention_axes = tuple(self._attention_axes) # pragma: no cover
(
self._dot_product_equation,
self._combine_equ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _attention(self, inputs):\n attn_weights = K.batch_dot(x=inputs,\n y=K.permute_dimensions(inputs,\n pattern=(0, 2, 1)))\n return K.permute_dimensions(attn_weights, (0, 2, 1))",
"def compute_attention(t1, ... | [
"0.638531",
"0.62716824",
"0.6053262",
"0.59797245",
"0.5960362",
"0.5960104",
"0.59157217",
"0.58548576",
"0.5838938",
"0.57846445",
"0.57538456",
"0.5741836",
"0.5666804",
"0.56033784",
"0.5596749",
"0.5576758",
"0.5559035",
"0.5538889",
"0.5529286",
"0.55249345",
"0.545297... | 0.5855358 | 7 |
Strips accents from a piece of text. | def _run_strip_accents(self, text):
text = unicodedata.normalize("NFD", text)
output = []
for char in text:
cat = unicodedata.category(char)
if cat == "Mn":
continue # pragma: no cover
output.append(char)
return "".join(output) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_accented_chars(text):\n text = unidecode.unidecode(text)\n return text",
"def remove_accented_chars(text):\n text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf-8', 'ignore')\n return text",
"def _run_strip_accents(self, text):\n text = unicodedata.nor... | [
"0.8073748",
"0.7942181",
"0.7824997",
"0.7815759",
"0.77855134",
"0.7652594",
"0.75760865",
"0.7575228",
"0.755694",
"0.7513403",
"0.70939153",
"0.700332",
"0.700332",
"0.6948511",
"0.6939078",
"0.6920245",
"0.6917249",
"0.68867254",
"0.6855788",
"0.68418425",
"0.6819216",
... | 0.78255457 | 2 |
Tokenizes a piece of text into its word pieces. This uses a greedy longestmatchfirst algorithm to perform tokenization using the given vocabulary. | def tokenize(self, text):
text = convert_to_unicode(text)
output_tokens = []
for token in whitespace_tokenize(text):
chars = list(token)
if len(chars) > self.max_input_chars_per_word:
output_tokens.append(self.unk_token) # pragma: no cover
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_tokenize(text):\n for (regexp, replacement) in RULES1:\n text = sub(regexp, replacement, text)\n # add extra space to make things easier\n text = \" \" + text + \" \"\n for (regexp, replacement) in RULES2:\n text = sub(regexp, replacement, text)\n for regexp in CONTRACTIONS:\n... | [
"0.6765058",
"0.65785444",
"0.6558721",
"0.65466934",
"0.6538157",
"0.652818",
"0.65059775",
"0.650288",
"0.6488385",
"0.64681923",
"0.6442634",
"0.6410379",
"0.6393091",
"0.6368067",
"0.6365707",
"0.63618565",
"0.6360565",
"0.63564456",
"0.63431764",
"0.6338991",
"0.6333006"... | 0.6225257 | 39 |
Checks whether `chars` is a control character. | def _is_control(char):
# These are technically control characters but we count them as whitespace
# characters.
if char == "\t" or char == "\n" or char == "\r":
return False # pragma: no cover
cat = unicodedata.category(char)
if cat in ("Cc", "Cf"):
return True # pragma: no cover
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_control(char):\n # These are technically control characters but we count them as whitespace\n # characters.\n if char == \"\\t\" or char == \"\\n\" or char == \"\\r\":\n return False\n cat = unicodedata.category(char)\n if cat.startswith(\"C\"):\n return True\n return False"... | [
"0.81981814",
"0.81981814",
"0.8177336",
"0.80915713",
"0.6468453",
"0.58763784",
"0.582512",
"0.5796899",
"0.5719301",
"0.57148904",
"0.57065594",
"0.56959367",
"0.5653251",
"0.5603813",
"0.5585948",
"0.55843735",
"0.55716395",
"0.55498976",
"0.55498976",
"0.55404437",
"0.55... | 0.8169858 | 3 |
Checks whether `chars` is a whitespace character. | def _is_whitespace(char):
# \t, \n, and \r are technically control characters but we treat them
# as whitespace since they are generally considered as such.
if char == " " or char == "\t" or char == "\n" or char == "\r":
return True
cat = unicodedata.category(char)
if cat == "Zs":
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_whitespace(char):\n if char == ' ' or char == '\\t' or char == '\\n' or char == '\\r':\n return True\n cat = unicodedata.category(char)\n if cat == 'Zs':\n return True\n return False",
"def _is_whitespace(char):\n # \\t, \\n, and \\r are technically contorl characters but we ... | [
"0.78012747",
"0.7680234",
"0.7633813",
"0.7108098",
"0.6929217",
"0.6814356",
"0.67606235",
"0.65372074",
"0.64895546",
"0.64892155",
"0.6466964",
"0.64537275",
"0.64364225",
"0.6071991",
"0.5989213",
"0.59863365",
"0.59160656",
"0.5889098",
"0.5882985",
"0.58735234",
"0.580... | 0.76118195 | 3 |
Runs basic whitespace cleaning and splitting on a piece of text. | def whitespace_tokenize(text):
text = text.strip()
if not text:
return []
tokens = text.split()
return tokens | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n return text.split(' ')",
"def whitespace_tokenize(text):\n text = text.strip()\n if not text:\n return []\n tokens = text.split()\n return tokens",
"def clean_whitespace(text):\n return text\n #return re.sub(r'\\r\\n|\\n', \"\\t\", text)",
"def _split(self):\n \n ... | [
"0.6439049",
"0.6300005",
"0.6284847",
"0.62824225",
"0.62147355",
"0.6206382",
"0.6165981",
"0.61554945",
"0.61485386",
"0.61298126",
"0.6112172",
"0.61113316",
"0.6097497",
"0.60766",
"0.6067344",
"0.6060772",
"0.60185647",
"0.6017855",
"0.59917736",
"0.59917736",
"0.598616... | 0.6255953 | 6 |
Test if a ValueError is raised when the wires and estimation_wires share a common wire | def test_shared_wires(self):
wires = range(2)
estimation_wires = range(1, 3)
with pytest.raises(ValueError, match="No wires can be shared between the wires"):
quantum_monte_carlo(
lambda: None, wires=wires, target_wire=0, estimation_wires=estimation_wires
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_duplicate_wire(self, circuit):\n with pytest.raises(ValueError, match=\"Wire ID 0 is specified more than once.\"):\n circuit._validate_wire_ids(wire_ids=[0, 0])",
"def _check_wires(self, wires):\n for w in wires:\n if not isinstance(w, numbers.Integral):\n ... | [
"0.68065894",
"0.64262474",
"0.6414444",
"0.6394105",
"0.63860834",
"0.62661153",
"0.60675037",
"0.59802395",
"0.5968405",
"0.58011216",
"0.5683497",
"0.56751174",
"0.56156397",
"0.56084615",
"0.55811405",
"0.55757123",
"0.5575299",
"0.5575011",
"0.5567577",
"0.5564831",
"0.5... | 0.71431446 | 0 |
Returns a JSONserializable dictionary representation of the model. This can and should be overridden on individual model classes, defining how to respond to different verbosities and/or fields that should never be returned to the frontend (e.g password). | def get_dictionary(self, verbosity='all'):
return dict([
# This maps the model to its columns except for id, for which the
# database mapping and python mapping differ.
(c.name, str(getattr(self, c.name if c.name != 'id' else 'id_')))
for c in self.__table__.col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self):\n return {\n 'id' : self.id,\n 'username' : self.username,\n 'email' : self.email\n }",
"def serialize(self):\n return {\n 'id' :self.id,\n 'name' : self.name,\n 'email' : self.email\n }",
"def serialize(self):\... | [
"0.76372707",
"0.7567897",
"0.7443316",
"0.7402637",
"0.7387442",
"0.7387168",
"0.7363538",
"0.73442256",
"0.7330595",
"0.73022056",
"0.7282856",
"0.72817403",
"0.72600263",
"0.72157305",
"0.72102416",
"0.7188342",
"0.7185816",
"0.71589166",
"0.71589166",
"0.713486",
"0.71275... | 0.0 | -1 |
Creates and saves a superuser with the given email, username and password. | def create_superuser(self, email, username, gender, first_name, last_name, password):
user = self.create_user(
email = self.normalize_email(email),
username = username,
password = password,
gender = gender,
first_name = first_name,
last_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_superuser(username, email, password):\n if username and email and password:\n user, created = User.objects.get_or_create(pk=defaults.USERWARE_SUPERUSER_ID)\n if user:\n user.username = username\n user.email = email\n user.set_password(password)\n ... | [
"0.8327063",
"0.82684207",
"0.8239756",
"0.8201451",
"0.8126284",
"0.8121195",
"0.8117709",
"0.8103684",
"0.80794984",
"0.8067033",
"0.80594385",
"0.80552614",
"0.8051731",
"0.80415666",
"0.80360025",
"0.80214",
"0.8019713",
"0.8017799",
"0.8015289",
"0.8013824",
"0.8009226",... | 0.77343285 | 75 |
Serialize the model instance into a dictionary. If backrefs, include that data in the dictionary. | def _serialize_model(model, backrefs=None):
backrefs = [] if not backrefs else backrefs
ret = {c.name: getattr(model, c.name) for c in model.__table__.columns}
for br in backrefs:
# not going to work right if it isn't M:1 but that's ok for now.
ret[br] = _serialize_list(getattr(model, br))
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self):\n return self.ref",
"def serialize(self):\n return {\n 'id': self.id,\n 'name': self.name,\n 'url': self.url,\n 'created': self.created,\n 'update': self.update,\n 'active': self.active,\n }",
"def seria... | [
"0.70947915",
"0.7008315",
"0.6774467",
"0.6774467",
"0.67580295",
"0.67198455",
"0.67198455",
"0.67198455",
"0.67198455",
"0.67198455",
"0.67198455",
"0.67198455",
"0.6716714",
"0.6716714",
"0.6716714",
"0.6702301",
"0.6701337",
"0.6701337",
"0.6701337",
"0.6701337",
"0.6680... | 0.6491994 | 44 |
ID of the billing account to set a budget on. | def billing_account(self) -> pulumi.Input[str]:
return pulumi.get(self, "billing_account") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_billing_account_id():\n org_client = boto3.client(\"organizations\")\n response = org_client.describe_organization()\n return response[\"Organization\"][\"MasterAccountId\"]",
"def account_id(self):\n return self._account_id",
"def account_id(self) -> str:\n return pulumi.get(se... | [
"0.708502",
"0.6489374",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.63689065",
"0.6368068",
"0.6344874",
"0.6307345",
"0.6282439",
"0.6272353",
"0.61288166",
"0.610314",
"0.610314",
"0.6043427",
"0.6043427",
"0... | 0.6405801 | 3 |
ID of the billing account to set a budget on. | def billing_account(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "billing_account") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_billing_account_id():\n org_client = boto3.client(\"organizations\")\n response = org_client.describe_organization()\n return response[\"Organization\"][\"MasterAccountId\"]",
"def account_id(self):\n return self._account_id",
"def billing_account(self) -> pulumi.Input[str]:\n r... | [
"0.708502",
"0.6489374",
"0.6405801",
"0.6405801",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.63689065",
"0.6368068",
"0.6344874",
"0.6307345",
"0.6282439",
"0.6272353",
"0.61288166",
"0.610314",
"0.610314",
"0... | 0.6043427 | 22 |
Budget configuration for a billing account. | def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
all_updates_rule: Optional[pulumi.Input[pulumi.InputType['BudgetAllUpdatesRuleArgs']]] = None,
amount: Optional[pulumi.Input[pulumi.InputType['BudgetAmountArgs']]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self, budget):\n\t\traise NotImplementedError('This function needs to be overwritten in %s.'%(self.__class__.__name__))",
"async def __getBBL_async(self, account, projectedBillData) -> dict:\n _LOGGER.info(\"Getting budget billing data\")\n data = {}\n\n try:\n asyn... | [
"0.65199035",
"0.61683655",
"0.58218235",
"0.58218235",
"0.56769747",
"0.56369734",
"0.56016386",
"0.5583894",
"0.55695295",
"0.55638516",
"0.55638516",
"0.55513984",
"0.5501267",
"0.5501267",
"0.5501267",
"0.548243",
"0.54692054",
"0.53957015",
"0.53661966",
"0.5364296",
"0.... | 0.48221228 | 78 |
Budget configuration for a billing account. | def __init__(__self__,
resource_name: str,
args: BudgetArgs,
opts: Optional[pulumi.ResourceOptions] = None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self, budget):\n\t\traise NotImplementedError('This function needs to be overwritten in %s.'%(self.__class__.__name__))",
"async def __getBBL_async(self, account, projectedBillData) -> dict:\n _LOGGER.info(\"Getting budget billing data\")\n data = {}\n\n try:\n asyn... | [
"0.6522192",
"0.61680603",
"0.58205515",
"0.58205515",
"0.5675533",
"0.563814",
"0.5600954",
"0.5585118",
"0.55699074",
"0.5562507",
"0.5562507",
"0.55531263",
"0.5499314",
"0.5499314",
"0.5499314",
"0.54829043",
"0.5468307",
"0.5397864",
"0.53652316",
"0.53650486",
"0.532660... | 0.0 | -1 |
Get an existing Budget resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
all_updates_rule: Optional[pulumi.Input[pulumi.InputType['BudgetAllUpdatesRuleArgs']]] = None,
amount: Optional[pulumi.Input[pulumi.InputType['BudgetAmountArgs']]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_by_id(state_id):\n state = storage.get(State, state_id)\n if not state:\n abort(404)\n return jsonify(state.to_dict()), 200",
"def get_state_by_id(state_id):\n for key, value in storage.all(\"State\").items():\n if state_id == value.id:\n return jsonify(value.to... | [
"0.6262431",
"0.6234552",
"0.622097",
"0.61422807",
"0.60420555",
"0.60233253",
"0.6003036",
"0.5935654",
"0.59261733",
"0.5897349",
"0.586654",
"0.5797569",
"0.57443506",
"0.5740599",
"0.5601058",
"0.55432564",
"0.5519228",
"0.5507455",
"0.5493679",
"0.54431945",
"0.54207486... | 0.61533576 | 3 |
ID of the billing account to set a budget on. | def billing_account(self) -> pulumi.Output[str]:
return pulumi.get(self, "billing_account") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_billing_account_id():\n org_client = boto3.client(\"organizations\")\n response = org_client.describe_organization()\n return response[\"Organization\"][\"MasterAccountId\"]",
"def account_id(self):\n return self._account_id",
"def billing_account(self) -> pulumi.Input[str]:\n r... | [
"0.708502",
"0.6489374",
"0.6405801",
"0.6405801",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.6375092",
"0.63689065",
"0.6368068",
"0.6344874",
"0.6307345",
"0.6282439",
"0.6272353",
"0.61288166",
"0.610314",
"0.610314",
"0... | 0.60315883 | 25 |
Gets the is_anonymous_access_allowed of this AuthenticationPolicy. Whether an unauthenticated user may access the API. Must be \"true\" to enable ANONYMOUS route authorization. | def is_anonymous_access_allowed(self):
return self._is_anonymous_access_allowed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anonymous_access_allowed(self, is_anonymous_access_allowed):\n self._is_anonymous_access_allowed = is_anonymous_access_allowed",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous... | [
"0.708901",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0.6142753",
"0... | 0.8045708 | 0 |
Sets the type of this AuthenticationPolicy. Type of the authentication policy to use. | def type(self, type):
allowed_values = ["CUSTOM_AUTHENTICATION"]
if not value_allowed_none_or_none_sentinel(type, allowed_values):
type = 'UNKNOWN_ENUM_VALUE'
self._type = type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_auth_type(self, auth_type):\n pass",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self.type = type",
"def set_type(self, type):\n self._type = type",
"def policy_type_name(self, policy_type_name):\n allowed_values = [\"patch\", \"cu... | [
"0.7034677",
"0.6720151",
"0.6720151",
"0.66803694",
"0.6468778",
"0.6277851",
"0.6233267",
"0.6233267",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
"0.621259",
... | 0.5964965 | 46 |
Reduced mass as calculated via Eq. 6 in Bartel et al. (2018) | def _reduced_mass(structure) -> float:
reduced_comp = structure.composition.reduced_composition
num_elems = len(reduced_comp.elements)
elem_dict = reduced_comp.get_el_amt_dict()
denominator = (num_elems - 1) * reduced_comp.num_atoms
all_pairs = combinations(elem_dict.items(), 2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def molar_mass_dry_air():\n return 28.9647",
"def mass(self):\n\t\treturn self.volume*self.density",
"def calc_mass(self):\n\n star = self.star\n\n K, N = star.mesh_size\n mu = star.mu_coords\n r = star.r_coords\n\n def Q1(j):\n return np.sum((mu[2::2] - mu[:-2:... | [
"0.7130783",
"0.6914461",
"0.6703815",
"0.67022073",
"0.6620656",
"0.65342885",
"0.649345",
"0.6477738",
"0.6461547",
"0.6452561",
"0.6407926",
"0.64046454",
"0.6374643",
"0.63651633",
"0.6311055",
"0.6302636",
"0.62981766",
"0.6280396",
"0.62456787",
"0.62456787",
"0.6239235... | 0.75347704 | 0 |
Constructor method for initializing GibbsComputedStructureEntry objects from T = 0 K ComputedStructureEntry objects, as acquired from a thermochemical database e.g. The Materials Project. | def from_entries(cls, entries, temp=300, gibbs_model="SISSO") -> List["GibbsComputedStructureEntry"]:
from pymatgen.analysis.phase_diagram import PhaseDiagram
pd = PhaseDiagram(entries)
return cls.from_pd(pd, temp, gibbs_model) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,kT=None,T=None):\n if kT is not None: kT = kT\n elif T is not None: kT = u.boltzmann*T\n else: raise Exception(\"kT or k must be passed to BlackBody\")\n\n energy_density=BlackBody.compute_energy_density(kT)\n super(BlackBody,self).__init__(energy_density=energy... | [
"0.6100014",
"0.5945892",
"0.5932906",
"0.58661455",
"0.5715771",
"0.5551368",
"0.55083233",
"0.54757524",
"0.5468362",
"0.546769",
"0.5460204",
"0.54149",
"0.535257",
"0.5349873",
"0.53221256",
"0.5294084",
"0.5267462",
"0.52574295",
"0.5252764",
"0.5240393",
"0.5236929",
... | 0.5453731 | 11 |
Return the name of the thermostat. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return f\"{self._tc_object.name} {SENSOR_TYPES[self.type][0]}\"",
"def thermostat(self) -> dict[str, Any]:\n return self.data.ecobee.get_thermostat(self.thermostat_index)",
"def name(self) -> str:\n return f\"{get_friendly_name(self._name)} temperature\"",
"def name(sel... | [
"0.68962795",
"0.6839454",
"0.67705506",
"0.6765792",
"0.6695404",
"0.667108",
"0.6555283",
"0.6515466",
"0.6505295",
"0.6478986",
"0.64298517",
"0.64298517",
"0.64298517",
"0.64109445",
"0.6402691",
"0.63823766",
"0.6380735",
"0.6307367",
"0.6297553",
"0.62935513",
"0.627699... | 0.0 | -1 |
Return the current running hvac operation if supported. | def hvac_action(self) -> Optional[str]:
if self._module_type == NA_THERM:
return CURRENT_HVAC_MAP_NETATMO[self._data.boilerstatus]
# Maybe it is a valve
if self._room_id in self._data.room_status:
if (
self._data.room_status[self._room_id].get("heating_pow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hvac_action(self):\n if self._hvac_mode == HVAC_MODE_OFF:\n return CURRENT_HVAC_OFF\n elif self._hvac_mode == HVAC_MODE_HEAT:\n return CURRENT_HVAC_HEAT\n elif self._hvac_mode == HVAC_MODE_COOL:\n return CURRENT_HVAC_COOL\n elif self._hvac_mode == HV... | [
"0.67991453",
"0.6570889",
"0.6501783",
"0.6492559",
"0.6478242",
"0.64674306",
"0.6346102",
"0.63246834",
"0.62782544",
"0.6266564",
"0.62638766",
"0.60962176",
"0.60799146",
"0.6050013",
"0.6030969",
"0.6017185",
"0.5996483",
"0.5996483",
"0.59854007",
"0.5945989",
"0.59053... | 0.6395503 | 6 |
Set new preset mode. | def set_preset_mode(self, preset_mode: str) -> None:
if self.target_temperature == 0:
self._data.homestatus.setroomThermpoint(
self._data.home_id, self._room_id, STATE_NETATMO_HOME,
)
if (
preset_mode in [PRESET_BOOST, STATE_NETATMO_MAX]
a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_preset_mode(self, preset_mode: str | None) -> None:\n self.svc_set_system_mode(PRESET_TO_TCS.get(preset_mode, SystemMode.AUTO))",
"def set_preset_mode(self, preset_mode: str | None) -> None:\n self.svc_set_zone_mode(\n mode=PRESET_TO_ZONE.get(preset_mode),\n setpoint=s... | [
"0.7811572",
"0.74921536",
"0.7414985",
"0.72874016",
"0.722293",
"0.72137654",
"0.71587706",
"0.7121615",
"0.71170485",
"0.709526",
"0.7089373",
"0.67866254",
"0.6745228",
"0.6735515",
"0.67020357",
"0.6690951",
"0.66362596",
"0.662614",
"0.65985346",
"0.6585491",
"0.6556873... | 0.75192153 | 1 |
Return the state attributes of the thermostat. | def device_state_attributes(self):
attr = {}
if self._battery_level is not None:
attr[ATTR_BATTERY_LEVEL] = self._battery_level
return attr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self) -> Dict[str, Any]:\n return {**super(WarmupThermostat, self).state_attributes, **self.attributes}",
"def state_attributes(self):\n return self._wan",
"def device_state_attributes(self):\n # Move these to Thermostat Device and make them global\n return {\n ... | [
"0.8418585",
"0.80888754",
"0.79596484",
"0.7928174",
"0.77769744",
"0.7770484",
"0.7748039",
"0.7748039",
"0.77043676",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",
"0.7701051",... | 0.73462206 | 46 |
Auxiliary function to join same elements of a list of dictionaries if the elements are not None. | def _join(lst, key, sep=";"):
return sep.join([d[key] for d in lst if d[key]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concatinate_list_of_dicts_field(list_of_dicts, field_key):\r\n return ''.join([item[field_key] for item in list_of_dicts])",
"def _join_dicts(dicts):\n if dicts is None: # pragma: no cover\n return\n assembled_dict = {k: v for D in dicts for k, v in D.items()}\n return assembled_dict"... | [
"0.6752827",
"0.65902615",
"0.657744",
"0.65073544",
"0.5951905",
"0.59319854",
"0.58993757",
"0.5854717",
"0.5824596",
"0.5747121",
"0.574537",
"0.57205224",
"0.5719377",
"0.5690327",
"0.5657774",
"0.5656398",
"0.56356674",
"0.562333",
"0.56164575",
"0.55979055",
"0.55917406... | 0.63428897 | 4 |
Test errors when loading output writer. | def test_output_writer_errors():
with pytest.raises(TypeError):
load_output_writer("not_a_dictionary")
with pytest.raises(errors.MapcheteDriverError):
load_output_writer({"format": "invalid_driver"}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_output_reader_errors():\n with pytest.raises(TypeError):\n load_output_reader(\"not_a_dictionary\")\n with pytest.raises(errors.MapcheteDriverError):\n load_output_reader({\"format\": \"invalid_driver\"})",
"def test_invalid_writer_output_format(self):\n pandoc_default_files =... | [
"0.68782914",
"0.65955675",
"0.65878344",
"0.64211863",
"0.6330506",
"0.62519413",
"0.62303394",
"0.6192315",
"0.61917186",
"0.61762226",
"0.6170766",
"0.6150937",
"0.61222345",
"0.6103166",
"0.60609335",
"0.605934",
"0.60482365",
"0.603483",
"0.60322934",
"0.60283756",
"0.60... | 0.7453423 | 0 |
Test errors when loading output writer. | def test_output_reader_errors():
with pytest.raises(TypeError):
load_output_reader("not_a_dictionary")
with pytest.raises(errors.MapcheteDriverError):
load_output_reader({"format": "invalid_driver"}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_output_writer_errors():\n with pytest.raises(TypeError):\n load_output_writer(\"not_a_dictionary\")\n with pytest.raises(errors.MapcheteDriverError):\n load_output_writer({\"format\": \"invalid_driver\"})",
"def test_invalid_writer_output_format(self):\n pandoc_default_files =... | [
"0.7453423",
"0.65955675",
"0.65878344",
"0.64211863",
"0.6330506",
"0.62519413",
"0.62303394",
"0.6192315",
"0.61917186",
"0.61762226",
"0.6170766",
"0.6150937",
"0.61222345",
"0.6103166",
"0.60609335",
"0.605934",
"0.60482365",
"0.603483",
"0.60322934",
"0.60283756",
"0.602... | 0.68782914 | 1 |
Returns a list of relative paths to all files in a given directory. | def _RecursiveDirectoryListing(dirpath):
result = []
for root, _, files in os.walk(dirpath):
for f in files:
result.append(os.path.relpath(os.path.join(root, f), dirpath))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_filepaths(self, directory):\n folder_paths = [os.path.join(directory, folder) for folder in os.listdir(directory) if not folder.startswith('.')]\n filepaths = [[os.path.join(cur_folder, cur_file) for cur_file in os.listdir(cur_folder)] for cur_folder in folder_paths]\n return filepath... | [
"0.8055599",
"0.79886746",
"0.79731804",
"0.794857",
"0.7937602",
"0.78996915",
"0.7894679",
"0.7894679",
"0.7894679",
"0.78331876",
"0.77627844",
"0.7741969",
"0.77416927",
"0.7725269",
"0.76547843",
"0.7590531",
"0.75630206",
"0.7539824",
"0.745997",
"0.74569285",
"0.745020... | 0.7440919 | 21 |
Asserts that a given lcov file looks correct. | def verify_lcov_file(self, filepath):
with open(filepath) as f:
data = f.read()
self.assertGreater(data.count('SF:'), 100)
self.assertGreater(data.count('crypto'), 100)
self.assertGreater(data.count('libpng'), 10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testFileInReturn(self):\n self.assertEqual(\n os.path.abspath('../testcdl.cc'),\n self.cc.file_in\n )",
"def test_lint_pass(self, style):\n result = run_linter_throw(\"path/to/file\",\n \"{s} /path/to/file\\n{m}\\n{m} \"\n ... | [
"0.62462837",
"0.60858697",
"0.59298176",
"0.58539486",
"0.5833971",
"0.5815549",
"0.57958853",
"0.57904416",
"0.57902086",
"0.57738185",
"0.57738185",
"0.57678044",
"0.57413566",
"0.57206935",
"0.56823903",
"0.5668264",
"0.5667233",
"0.5666068",
"0.56513697",
"0.5649028",
"0... | 0.8207256 | 0 |
Returns a string representation of a QMargins value QMargin | def margins(value):
if value.isNull():
return '(Null)'
return '({}, {}, {}, {})'.format(value.left(), value.top(),
value.right(), value.bottom()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def margin(self):\r\n return self._generate_spacing_info(self.config['margin'])",
"def get_margin(self):\n return unicode(self._visual_indent * 20)",
"def Margin(self):\n s = self.margin\n assert s in range(1,6), \"Margin score out of bounds.\"\n if s == 1: return 'Poor'\n ... | [
"0.63377017",
"0.62946135",
"0.59487504",
"0.5801097",
"0.5608227",
"0.5561273",
"0.55491626",
"0.5530275",
"0.5444173",
"0.5404274",
"0.53964984",
"0.53795576",
"0.5343619",
"0.53428197",
"0.5291503",
"0.528745",
"0.5276566",
"0.5254994",
"0.52293867",
"0.5224911",
"0.511155... | 0.64198756 | 0 |
Returns a string representation of a QSize or QSizeF. This method does a check that the object contains valid values. value QSize or QSizeF | def size(value):
if not value.isValid():
return '0.0 x 0.0' if isinstance(value, QSizeF) else '0 x 0'
return '{} x {}'.format(value.width(), value.height()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"[Rectangle] {:d}/{:d}\".format(self.__size, self.__size)",
"def __str__(self):\n string = \"[\" + str(self.__class__.__name__) + \"] \"\n string += str(self.__width) + \"/\" + str(self.__height)\n return string",
"def icon(value):\r\n if value.is... | [
"0.5679681",
"0.5601566",
"0.55886585",
"0.5533588",
"0.55160904",
"0.5509368",
"0.5477414",
"0.54466695",
"0.54235065",
"0.5405775",
"0.53907436",
"0.53874195",
"0.53401846",
"0.5338173",
"0.5338173",
"0.5291414",
"0.52656025",
"0.52499866",
"0.51680547",
"0.5125621",
"0.512... | 0.74496454 | 0 |
Plot the recovered, denoised image against the original noisy image. | def plot(self, solution: Matrix) -> None:
plots.plot_matrices("Total Variation Denoising", self.M, solution) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_image(image):\n plt.imshow(image, cmap=\"gray\", interpolation=\"nearest\")\n plt.axis(\"off\")",
"def plot(self):\n self.fig = plt.figure('black hole')\n self.fig.clf() #clear the graph to avoir superposing data from the same set (can be deactivated if need to superpose)\n se... | [
"0.660839",
"0.63400066",
"0.62194234",
"0.617116",
"0.61477906",
"0.6144434",
"0.6137176",
"0.6114389",
"0.60935974",
"0.60610205",
"0.6015203",
"0.59666353",
"0.59666353",
"0.59666353",
"0.5940771",
"0.59283465",
"0.5927446",
"0.59108126",
"0.5905365",
"0.58989346",
"0.5886... | 0.61898726 | 3 |
Convert value to a unicode string. Useful in case lxml _ElementUnicodeResult are passed from parser. | def process(self, value):
return six.text_type(value) if value is not None else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _unicodeify(self, value, encoding=\"utf8\"):\n if isinstance(value, str):\n return value\n return str(value, encoding)",
"def to_unicode(value):\r\n if isinstance(value, _TO_UNICODE_TYPES):\r\n return value\r\n if not isinstance(value, bytes_type):\r\n raise TypeE... | [
"0.7821383",
"0.727739",
"0.72302073",
"0.7228143",
"0.70030206",
"0.69981647",
"0.69933206",
"0.6982127",
"0.69078726",
"0.69078344",
"0.6877367",
"0.679782",
"0.6778012",
"0.6735071",
"0.67033744",
"0.6667322",
"0.6653696",
"0.66503304",
"0.6636011",
"0.66216564",
"0.661525... | 0.0 | -1 |
Convert value to a float. | def process(self, value):
return float(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_float(value):\n if isinstance(value, bytes):\n value = value.decode(\"utf-8\")\n return float(value)",
"def make_float(value):\n return float(value[0])",
"def to_float(self) -> float:\n return (1.0 * self.as_int) / sensor_fixed_point_conversion",
"def Float(val):\n try:\... | [
"0.78976417",
"0.75630367",
"0.7364891",
"0.7253369",
"0.7198622",
"0.71746206",
"0.7126937",
"0.7025372",
"0.7022159",
"0.7009298",
"0.6938404",
"0.69061303",
"0.69003206",
"0.6897675",
"0.6850696",
"0.6832981",
"0.6822565",
"0.68208617",
"0.6818528",
"0.6795948",
"0.6778537... | 0.74487424 | 2 |
Transform a system tensor (e.g. momenta, positions) from the bead representation to normal mode representation. | def beads2normal(self, x_beads):
return torch.mm(self.c_transform, x_beads.view(self.n_beads, -1)).view(
x_beads.shape
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_space(normal_map, rotmat):\n rotmat = np.array(rotmat)\n orig_shape = normal_map.shape\n normal = normal_map.reshape(-1, 3).T # 3-by-N\n\n normal_trans = rotmat.dot(normal)\n\n normal_map_trans = normal_trans.T.reshape(orig_shape)\n return normal_map_trans",
"def transform_back_mu... | [
"0.5709367",
"0.56751055",
"0.55866325",
"0.5580938",
"0.5559423",
"0.5529208",
"0.5527101",
"0.5506568",
"0.5494658",
"0.5489031",
"0.54667944",
"0.54554945",
"0.5433022",
"0.5432339",
"0.5417427",
"0.54168886",
"0.54163045",
"0.54127645",
"0.53733605",
"0.5351195",
"0.53410... | 0.5960305 | 0 |
Transform a system tensor (e.g. momenta, positions) in normal mode representation back to bead representation. | def normal2beads(self, x_normal):
return torch.mm(
self.c_transform.transpose(0, 1), x_normal.view(self.n_beads, -1)
).view(x_normal.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_back_mu(self, tensor):\n tensor = tensor.unsqueeze(1)\n tensor = self.unwhiten_back(tensor)\n return tensor.squeeze()",
"def transform_space(normal_map, rotmat):\n rotmat = np.array(rotmat)\n orig_shape = normal_map.shape\n normal = normal_map.reshape(-1, 3).T # 3-by-N... | [
"0.61418706",
"0.60468835",
"0.579758",
"0.57889146",
"0.5649253",
"0.56146234",
"0.5614125",
"0.55837077",
"0.5575418",
"0.55576724",
"0.55475426",
"0.5457938",
"0.54524076",
"0.54435235",
"0.5440697",
"0.5430992",
"0.54261565",
"0.54013205",
"0.53961426",
"0.5360042",
"0.53... | 0.5053089 | 68 |
Test if the shapes of array are controlled correctly | def test_02_test_shape(self, persons_gi):
groups, zones = persons_gi.shape
example = Example(groups, zones)
# jobs_j should have the shape (zones)
# correct shape
arr = np.ones((zones))
example.jobs_j = arr
# try to set values with the wrong shape
arr =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(placeholder_shape, data_shape):\n\n return True",
"def check_shapes(arrs):\r\n shps = [i.shape for i in arrs]\r\n eq = np.all(np.array([shps[0] == i for i in shps[1:]]))\r\n err = \"Arrays arr not of the same shape...\"\r\n if not eq:\r\n raise ValueError(\"{}\\n{}\".format... | [
"0.7237129",
"0.70915836",
"0.68639266",
"0.6769724",
"0.6748328",
"0.66852474",
"0.6679506",
"0.6670008",
"0.6651786",
"0.6621895",
"0.6611125",
"0.65656805",
"0.6538437",
"0.65175635",
"0.64801854",
"0.647985",
"0.6470205",
"0.6439113",
"0.6433918",
"0.6429732",
"0.64163154... | 0.58736426 | 95 |
Initializes main dialog frame. | def initialize(self, frame):
self.grid_size = 5
Label(frame, text="Grid Size:").grid(row=0)
self.e1 = Scale(frame, from_=self.grid_size, to=25, orient=HORIZONTAL)
self.e1.grid(row=0, column=1)
return self.e1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initGUI(self):\n\n\t\t# Set main frame's location \n\t\tself.grid(row=0, column=0, sticky=\"nsew\")\n\n\t\t# Set path entry frame and its location\n\t\tself.entryFrame = Frame(self, relief = RAISED, borderwidth = 1)\n\t\tself.entryFrame.pack(fill = BOTH, expand = False)\n\t\t# Make label\n\t\tif self.message:\... | [
"0.7207368",
"0.7144111",
"0.697066",
"0.6905309",
"0.68904036",
"0.6870412",
"0.68672746",
"0.68440104",
"0.67923754",
"0.6756218",
"0.6755066",
"0.67265075",
"0.669984",
"0.66945815",
"0.66767776",
"0.6669715",
"0.66659874",
"0.6647658",
"0.65984374",
"0.65926766",
"0.65688... | 0.0 | -1 |
Gives the sign of an integer value. | def sign(a):
return (a > 0) - (a < 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(num: float):\n return 1 if num >= 0 else -1",
"def sign(x):\n if x >= 0:\n return 1\n else:\n return -1",
"def sign(x):\n if x >= 0:\n return 1\n return -1",
"def sign(n: float) -> int:\n return 1 if n > 0 else -1",
"def sign(self):\n return 1 - 2 * self._... | [
"0.78953445",
"0.7849158",
"0.7765364",
"0.7635893",
"0.7574197",
"0.7398475",
"0.73113626",
"0.72201025",
"0.72113454",
"0.7205951",
"0.70523185",
"0.6735592",
"0.6697158",
"0.66668814",
"0.6531586",
"0.6527021",
"0.6483014",
"0.6330007",
"0.6320855",
"0.62975794",
"0.627424... | 0.73552984 | 6 |
Reset error gradient for each parameter to zero. | def reset_error(self):
self.dLdu = np.zeros(self.u.shape)
self.dLdw = np.zeros(self.w.shape)
self.dLdv = np.zeros(self.v.shape)
self.dLdb = np.zeros(self.b.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_grad(self):\r\n for param in self.params:\r\n param.grad = None",
"def zero_grad(self):\n for p, grad, v, square_grad_avg, delta_x_acc in self.params:\n grad.zero_()",
"def zero_grad(self):\n for p, grad, v, square_grad_avg, delta_x_acc in self.params:\n ... | [
"0.7839233",
"0.77851003",
"0.77851003",
"0.7762884",
"0.76592577",
"0.7301362",
"0.7244817",
"0.71104336",
"0.709133",
"0.70351666",
"0.70351666",
"0.70351666",
"0.7024648",
"0.70245177",
"0.7004316",
"0.69648176",
"0.6938334",
"0.69196504",
"0.6908809",
"0.68880373",
"0.684... | 0.70254785 | 12 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# Gets user input for city, allowing for 1 choice of 3 cities. Solves for case and entries not in dataset.
while True:
city = input('Please select one of the following cities: Chicago, New York City or Washington.\n').lower()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
df = pd.read_csv(CITY_DATA[city])
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month_names'] = df['Start Time'].dt.month
df['day_names'] = df['Start Time'].dt.weekday
df['hour'] = df['Start Time'].dt.hour
if month != 'all':
months = ['januar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.788921... | 0.77409494 | 52 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# Displays the most common month
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month'] = df['Start Time'].dt.month
common_month = df['month_names'].mode()[0]
print('Most com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.7407186 | 44 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# Displays most commonly used start station
start_station = df['Start Station'].mode().values[0]
print('Most commonly used start station is:', start_station)
# Displays most commonly... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.78160876",
"0.76626086",
"0.75538874",
"0.7491789",
"0.7475186",
"0.7446511",
"0.74301356",
"0.7424136",
"0.7417956",
"0.7400676",
"0.738748",
"0.7385726",
"0.73651963",
"0.7359407",
"0.73569685",
"0.73552465",
"0.73522156",
"0.7351514",
"0.7350588",
"0.73423624",
"0.73401... | 0.7012856 | 74 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# Displays total travel time
time_adj = df['Trip Duration'].sum()
time_adj =float(time_adj)
day = time_adj // (24 * 3600)
time_adj = time_adj % (24 * 3600)
hour = time_adj // 3600
time_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.7592443 | 90 |
set naive time but return tz_aware | def test_download_date_tz_1A(temp_file):
from osxmetadata import OSXMetaData
from osxmetadata.datetime_utils import datetime_naive_to_local
import datetime
meta = OSXMetaData(temp_file, tz_aware=True)
dt = datetime.datetime.now()
meta.set_attribute("downloadeddate", dt)
dt_tz = datetime_nai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enforce_timezone(self, value):\n try:\n tz = timezone._active.value\n if (self.default_timezone is not None) and not timezone.is_aware(value):\n return timezone.make_aware(value, tz)\n return value\n except AttributeError:\n return super()... | [
"0.72881097",
"0.7276686",
"0.7219671",
"0.7164358",
"0.70574176",
"0.7050138",
"0.68129563",
"0.6715712",
"0.66850775",
"0.66716754",
"0.6650505",
"0.66403687",
"0.66263413",
"0.66108817",
"0.66103673",
"0.6566376",
"0.651921",
"0.6417913",
"0.6392966",
"0.63769513",
"0.6327... | 0.0 | -1 |
set naive time but return tz_aware | def test_download_date_tz_1B(temp_file):
from osxmetadata import OSXMetaData
from osxmetadata.datetime_utils import datetime_naive_to_local
import datetime
meta = OSXMetaData(temp_file, tz_aware=True)
dt = datetime.datetime.now()
meta.downloadeddate = dt
dt_tz = datetime_naive_to_local(dt)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enforce_timezone(self, value):\n try:\n tz = timezone._active.value\n if (self.default_timezone is not None) and not timezone.is_aware(value):\n return timezone.make_aware(value, tz)\n return value\n except AttributeError:\n return super()... | [
"0.72872037",
"0.7276051",
"0.7218538",
"0.7164761",
"0.7056801",
"0.704845",
"0.681425",
"0.6716103",
"0.668416",
"0.66723514",
"0.6650535",
"0.66406727",
"0.6624614",
"0.6610256",
"0.66092974",
"0.65665007",
"0.65189904",
"0.6418135",
"0.63959616",
"0.63767225",
"0.63279647... | 0.0 | -1 |
set tz_aware and return tz_aware | def test_download_date_tz_2(temp_file):
from osxmetadata import OSXMetaData
from osxmetadata.datetime_utils import datetime_naive_to_local
import datetime
meta = OSXMetaData(temp_file, tz_aware=True)
dt = datetime.datetime.now()
dt_tz = datetime_naive_to_local(dt)
meta.downloadeddate = dt_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tz_aware(local_dt):\n aware_dt = timezone('US/Eastern').localize(local_dt)\n return aware_dt",
"def make_aware(value: datetime, timezone=None, is_dst=None) -> datetime:\n\n if timezone is None:\n timezone = get_current_timezone()\n\n if hasattr(timezone, \"localize\"):\n # This... | [
"0.77902937",
"0.7407251",
"0.7317652",
"0.72423315",
"0.7150354",
"0.6956492",
"0.6789247",
"0.67872435",
"0.6649201",
"0.6567073",
"0.6562394",
"0.6562091",
"0.64981014",
"0.64677525",
"0.63072425",
"0.6023535",
"0.595172",
"0.5918615",
"0.58226705",
"0.58154744",
"0.57995"... | 0.0 | -1 |
set tz_aware and return naive | def test_download_date_tz_3(temp_file):
from osxmetadata import OSXMetaData
from osxmetadata.datetime_utils import datetime_naive_to_local
import datetime
meta = OSXMetaData(temp_file, tz_aware=False)
dt = datetime.datetime.now()
dt_tz = datetime_naive_to_local(dt)
meta.downloadeddate = dt_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tz_aware(local_dt):\n aware_dt = timezone('US/Eastern').localize(local_dt)\n return aware_dt",
"def is_aware(value):\n return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None",
"def enforce_timezone(self, value):\n try:\n tz = timezone._active.value\n ... | [
"0.7650652",
"0.7420323",
"0.7361271",
"0.7259289",
"0.72245604",
"0.7082538",
"0.6987106",
"0.69194007",
"0.69067246",
"0.682611",
"0.66928273",
"0.6543727",
"0.64618766",
"0.6443703",
"0.64219415",
"0.64032936",
"0.63677996",
"0.62989587",
"0.62486553",
"0.6245093",
"0.6217... | 0.0 | -1 |
Pytest fixture. Returns a helper function that sends API data via the provided `api_client`, to the provided `url`, with the given `req_body`, via the given HTTP `method`. An API user is created and used for authentication. You may optionally supply a `content_type` string; if not supplied, then JSON is assumed by defa... | def send_api_data(apiuser_with_custom_defaults, simple_sig_auth_credentials):
content_types = {
'put': 'application/json',
'patch': 'application/json-patch+json',
'post': 'application/json'
}
def _send_api_data(api_client, url, req_body, method, content_type=None):
test_cls ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fake_request(user=None, method='GET', data=None, url='/', content_type='text/html; charset=utf-8'):\n factory = RequestFactory()\n\n # Get the method to be used for the request (i.e. get, put, post, delete)\n method = getattr(factory, method.lower())\n\n # If the user is passing in a json object\n ... | [
"0.61155903",
"0.5794737",
"0.5753015",
"0.57197547",
"0.56969064",
"0.557769",
"0.5564543",
"0.5538658",
"0.5472358",
"0.54568255",
"0.54416364",
"0.5437556",
"0.54182875",
"0.53952324",
"0.5387781",
"0.5371268",
"0.5369466",
"0.53601396",
"0.53528917",
"0.5327641",
"0.53228... | 0.6728471 | 0 |
get_quantiles function DESCRIPTION This function returns, in the default case, the parameter median and the error% credibility around it. This assumes you give a nonordered distribution of parameters. OUTPUTS Median of the parameter,upper credibility bound, lower credibility bound | def get_quantiles(dist,alpha = 0.68, method = 'median'):
ordered_dist = dist[np.argsort(dist)]
param = 0.0
# Define the number of samples from posterior
nsamples = len(dist)
nsamples_at_each_side = int(nsamples*(alpha/2.)+1)
if(method == 'median'):
med_idx = 0
if(nsamples%2 == 0.0)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quantiles(dist,alpha = 0.68, method = 'median'):\n ordered_dist = dist[np.argsort(dist)]\n param = 0.0 \n # Define the number of samples from posterior\n nsamples = len(dist)\n nsamples_at_each_side = int(nsamples*(alpha/2.)+1)\n if(method == 'median'):\n med_idx = 0 \n if(nsa... | [
"0.6858628",
"0.67476875",
"0.6725998",
"0.6548512",
"0.653098",
"0.6496208",
"0.64916563",
"0.648396",
"0.6447812",
"0.6438925",
"0.6411301",
"0.6411301",
"0.6364302",
"0.6335008",
"0.631982",
"0.6302163",
"0.6255526",
"0.62076485",
"0.61966246",
"0.6191901",
"0.61763775",
... | 0.67731297 | 2 |
Creates a reference for a nonexistent WAV file, tests for the existence of a nonexistent file and throws an exception. | def test_simple_wav_source_constructor_exception():
TESTPATH = "/usr/local/share/testfile.wav"
with pytest.raises(robox.RDJResourceErr):
test01 = WavSource(dpath=TESTPATH, dexist=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_missing_file(self):\n # Technically there's a race condition here, but... I'm not\n # particularly fussed about it.\n\n filename = '/%s' % (uuid.uuid4())\n while os.path.exists(filename): # pragma: no cover\n filename = '/%s' % (uuid.uuid4())\n\n with sel... | [
"0.668015",
"0.6432405",
"0.63682777",
"0.60861546",
"0.6024312",
"0.5937979",
"0.57162154",
"0.5714317",
"0.5679928",
"0.5677926",
"0.56735337",
"0.56684846",
"0.56417286",
"0.5636146",
"0.5632148",
"0.5628496",
"0.5618027",
"0.5602688",
"0.5599429",
"0.5599429",
"0.5597285"... | 0.65980446 | 1 |
Displays current server time | def time( self, mess, args):
return str(datetime.datetime.now()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def servertime(self):\r\n return servertime.Servertime(self)",
"def time_at_server():\n return time.asctime()",
"def now():\n print(strftime(\"%Y-%m-%d %H:%M:%S\", gmtime()))",
"def currentTime():\n return strftime(\"%H:%M:%S\", time.localtime())",
"async def server_time(self):\n uri... | [
"0.76804984",
"0.7634974",
"0.744474",
"0.73868763",
"0.7247567",
"0.7243079",
"0.7138182",
"0.7100776",
"0.70977163",
"0.7066082",
"0.70605445",
"0.703727",
"0.69715315",
"0.6967022",
"0.6944744",
"0.69272226",
"0.6922758",
"0.691844",
"0.68838453",
"0.68630517",
"0.68524677... | 0.6470981 | 67 |
Function to return a array of zeroes with default value of reduced sample dimension. | def sampleArray(sizeOfReducedSample = DEFSIZEOFREDUCEDSAMPLE):
return np.zeros((sizeOfReducedSample, sizeOfReducedSample)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initalize_with_zeros(dim):\n return np.zeros((dim, 1)), 0.0",
"def get_dummy_sample():\n return np.array([softmax(np.random.rand(5)), softmax(np.random.rand(5))])",
"def zero_mean(x):\n\treturn np.zeros((x.shape)[0])",
"def zero_init(self, shape):\n return np.zeros((shape[0],shape[1]))",
"... | [
"0.6959772",
"0.6695267",
"0.6606711",
"0.6514023",
"0.6512686",
"0.65034324",
"0.642425",
"0.64052325",
"0.6393395",
"0.6381696",
"0.6352487",
"0.6315115",
"0.62364453",
"0.6201444",
"0.6170654",
"0.614417",
"0.6143871",
"0.6099281",
"0.6094501",
"0.60891706",
"0.60891706",
... | 0.76832634 | 0 |
Function to convert json containing the energy deposition at the calorimeter cells in eta or phi in a numpy array. | def convert(filename, signal=sampleArray(),
centerEta = DEFCENTERETA, centerPhi = DEFCENTERPHI):
numEvents = 0
listOfSignals = []
# First we open the file
with open(filename, "r") as f:
content = f.readlines()
numEvents = len(content)
for i in range(0, numEvents):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_cal():\n energy_cal = np.load(energy_file)\n return energy_cal",
"def n_array(self,z,EeV):\n if np.isscalar(EeV):\n EeV = np.array([EeV])\n elif type(EeV) == list or type(EeV) == tuple:\n EeV = np.array(EeV)\n if np.isscalar(z):\n z = np.arra... | [
"0.5965343",
"0.5602189",
"0.5384499",
"0.5193185",
"0.5180364",
"0.5068045",
"0.50662905",
"0.50615436",
"0.5045386",
"0.5033097",
"0.5033097",
"0.5033097",
"0.50214005",
"0.49990612",
"0.4998855",
"0.49786782",
"0.4965441",
"0.49606353",
"0.49399415",
"0.4915139",
"0.491298... | 0.0 | -1 |
Adds nuclei name to the decay scheme. | def addNucleiName(self, nucleiName=r'$^{63}$Ni'):
plt.text(0.48, 0.05, nucleiName, fontsize=48, transform=plt.gcf().transFigure) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_name(self, node):\n if 'name' in self.options:\n name = nodes.fully_normalize_name(self.options.pop('name'))\n if 'name' in node:\n del(node['name'])\n node['names'].append(name)\n self.state.document.note_explicit_target(node, node)",
"de... | [
"0.55771524",
"0.53778124",
"0.5270179",
"0.50406164",
"0.5015267",
"0.49791",
"0.49690175",
"0.49417266",
"0.49317145",
"0.49250448",
"0.49205774",
"0.48887715",
"0.48887378",
"0.4882484",
"0.48623207",
"0.4856066",
"0.48457834",
"0.4805393",
"0.4805393",
"0.4805393",
"0.480... | 0.6775695 | 0 |
Converts json item into it's str form. | def _convert_json_item_signature(item: Any) -> List[str]:
if isinstance(item, list): # Cart list of dicts
for j in item:
return [str(k) for k in j.values()]
elif item is True:
return ['true']
elif item is False:
return ['false']
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_str(item):\n\n if isinstance(item, dict):\n #return {json_str(key): json_str(value) for key, value in item.iteritems()}\n return dict((json_str(key), json_str(value)) for key, value in item.iteritems())\n elif isinstance(item, list):\n return [json_str(element) for element in it... | [
"0.79153395",
"0.7643881",
"0.7293917",
"0.69882804",
"0.6945032",
"0.6924018",
"0.67677647",
"0.66152084",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",
"0.6613552",... | 0.66272205 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.