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 |
|---|---|---|---|---|---|---|
Positive Predictive Value (Precision) | def PPV(self):
return _div(self.TP, self.TP + self.FP) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(y_true, y_pred):\n tp = true_positive(y_true, y_pred)\n fp = false_positive(y_true, y_pred)\n precision = tp / (tp + fp)\n return precision",
"def precision(y_true, y_pred):\n true_positives = bk.sum(bk.round(bk.clip(y_true * y_pred, 0, 1)))\n predicted_positives =... | [
"0.7537611",
"0.7495781",
"0.74261993",
"0.74110746",
"0.7379363",
"0.7375774",
"0.7362881",
"0.7359402",
"0.7359402",
"0.7359402",
"0.7359402",
"0.7359402",
"0.7359402",
"0.73436195",
"0.73436195",
"0.73436195",
"0.73436195",
"0.73436195",
"0.73436195",
"0.73436195",
"0.7343... | 0.0 | -1 |
Dice similarity (NeiLi coefficient) This is the same as F1score, but calculated slightly differently here. Note that Dice can be zero if total number of positives is zero, but Fscore is undefined in that case (because recall is undefined). When adjusted for chance, this coefficient becomes identical to ``kappa`` [1]_. ... | def dice_coeff(self):
a, c, _, b = self.to_ccw()
return _div(2 * a, 2 * a + b + c) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dice_similarity_compiled():\n vector1 = np.array([1, 1, 0, 0])\n vector2 = np.array([1, 1, 1, 1])\n score11 = dice_similarity(vector1, vector1)\n score12 = dice_similarity(vector1, vector2)\n score22 = dice_similarity(vector2, vector2)\n\n assert score12 == 2 * 2/6, \"Expected different ... | [
"0.63968897",
"0.6298465",
"0.6039402",
"0.5972374",
"0.5929134",
"0.59069747",
"0.58138174",
"0.57797",
"0.5738599",
"0.56201506",
"0.56147563",
"0.5597568",
"0.5576217",
"0.5575533",
"0.55707824",
"0.55635524",
"0.55538195",
"0.55049616",
"0.54662335",
"0.54580075",
"0.5453... | 0.58844334 | 6 |
Ochiai coefficient adjusted for chance This index is nearly identical to Mattthews' Correlation Coefficient, which should be used instead. See Also matthews_corr, ochiai_coeff | def ochiai_coeff_adj(self):
a, c, d, b = self.to_ccw()
p1, p2 = a + b, a + c
n = a + b + c + d
if n == 0:
return np.nan
elif a == n or d == n:
# only one (diagonal) cell is non-zero
return 0.5
elif p1 == 0 or p2 == 0:
# fir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_codon_usage_ecoli(self):\n CAI = CodonAdaptationIndex()\n self.assertEqual(\"%0.5f\" % CAI.cai_for_gene(\"ATGCGTATCGATCGCGATACGATTAGGCGGATG\"),\n \"0.09978\")",
"def ochiai_coeff(self):\n a, c, _, b = self.to_ccw()\n p1, p2 = a + b, a + c\n if a... | [
"0.6168726",
"0.61560255",
"0.6076595",
"0.5996975",
"0.59137934",
"0.5889379",
"0.58655757",
"0.5863109",
"0.57514805",
"0.57322496",
"0.57304287",
"0.5713021",
"0.5609372",
"0.5556029",
"0.5533251",
"0.55322",
"0.55151486",
"0.54179597",
"0.5414626",
"0.54048055",
"0.539884... | 0.5250608 | 37 |
Alternative to ``loevinger_coeff`` but with 1 lower bound | def xcoeff(self):
a, c, d, b = self.to_ccw()
p1, q1 = a + b, c + d
p2, q2 = a + c, b + d
n = p1 + q1
cov = self.covar()
if n == 0:
return np.nan
elif a == n or d == n:
return 0.5
elif b == n or c == n:
return -1.0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loevinger_coeff(self):\n a, c, d, b = self.to_ccw()\n p1, q1 = a + b, c + d\n p2, q2 = a + c, b + d\n n = p1 + q1\n\n cov = self.covar()\n\n if n == 0:\n return np.nan\n elif a == n or d == n:\n # only one (diagonal) cell is non-zero\n ... | [
"0.69579",
"0.6535232",
"0.62601644",
"0.6158418",
"0.61392105",
"0.60678256",
"0.60008043",
"0.5949383",
"0.5909069",
"0.5884709",
"0.58622473",
"0.585793",
"0.58550423",
"0.58364886",
"0.58325654",
"0.5821418",
"0.58129066",
"0.58123386",
"0.5753914",
"0.5742803",
"0.574129... | 0.5650722 | 31 |
Matthews Correlation Coefficient (Phi coefficient) MCC is directly related to the Chisquare statistic. Its value is equal to the Chisquare value normalized by the maximum value the Chisquare can achieve with given margins (for a 2x2 table, the maximum Chisquare score is equal to the grand total N) transformed to correl... | def matthews_corr(self):
a, c, d, b = self.to_ccw()
p1, q1 = a + b, c + d
p2, q2 = a + c, b + d
n = p1 + q1
if n == 0:
return np.nan
elif a == n or d == n:
# only one (diagonal) cell is non-zero
return 0.5
elif b == n or c == n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mcc(self):\n tp = self.tp\n tn = self.tn\n fp = self.fp\n fn = self.fn\n return tp * tn / np.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))",
"def phi_coefficient (subgroup,target1,target2):\r\n return matthews_corrcoef(subgroup[target1], subgroup[target2])",
"def... | [
"0.6900127",
"0.63219273",
"0.62719274",
"0.615176",
"0.6130886",
"0.60598147",
"0.6017959",
"0.59958196",
"0.5965482",
"0.5964544",
"0.590723",
"0.59058297",
"0.58133423",
"0.5797792",
"0.5775759",
"0.57507163",
"0.57450265",
"0.5742589",
"0.57221305",
"0.57080007",
"0.57012... | 0.58900714 | 12 |
Cole coefficient This is exactly the same coefficient as Lewontin's D'. It is defined | def cole_coeff(self):
return self.diseq_coeff(standardize=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coefficient(self) -> float:\n ...",
"def calc_cophenetic_coeff(self):\n c, d = cophenet(self.__linkage, self.__distance_matrix)\n return round(c, 3)",
"def coefC(x0,y0,x1,y1):\n return (x1*y0-x0*y1)/(x1-x0)",
"def loevinger_coeff(self):\n a, c, d, b = self.to_ccw()\n ... | [
"0.7293047",
"0.72357273",
"0.71487033",
"0.69903094",
"0.68885046",
"0.66674757",
"0.665887",
"0.6591166",
"0.65218145",
"0.6498302",
"0.6466508",
"0.6424332",
"0.6397224",
"0.6362008",
"0.63035357",
"0.6299721",
"0.6285829",
"0.6268667",
"0.62502396",
"0.6237105",
"0.623627... | 0.79435325 | 0 |
Return a datetime representing the current selected date. | def selection(self):
if not self._selection:
print("not working")
return None
year, month = self._date.year, self._date.month
if len(str(month))==1:
month = "0{}".format(month)
return ("{}{}{}".format(year, month, self._selection[0]),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_datetime(self):\n return DateAccessor().today()",
"def get_current_date():\n return datetime.datetime.today().strftime(constants.DATE_FORMAT)",
"def getActiveDate(self):\n dateAsQDate = self.workCalendar.selectedDate()\n dateString = str(dateAsQDate.toString('dd/MM/yyyy'... | [
"0.7593795",
"0.7487077",
"0.7192208",
"0.6952059",
"0.6941804",
"0.6941494",
"0.6923644",
"0.68453515",
"0.6812885",
"0.6794715",
"0.6773453",
"0.67528844",
"0.6748852",
"0.674398",
"0.67234397",
"0.6689601",
"0.6637448",
"0.6609131",
"0.6597001",
"0.6590164",
"0.6588638",
... | 0.5793867 | 94 |
In the constructor we instantiate two nn.Linear module | def __init__(self):
# Initializing the Model with the class
super(Model, self).__init__()
# torch.nn.Linear applies a Linear transformation. The first parameter is the size of each input sample. The second is the size of the output sample
self.linear = torch.nn.Linear(1, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n super(LinearND, self).__init__()\n self.fc = nn.Linear(*args)",
"def __init__(self, D_in, H, D_out):\n super(TwoLayerNet, self).__init__()\n self.linear1 = torch.nn.Linear(D_in, H)\n self.linear2 = torch.nn.Linear(H, D_out)",
"def __init__(self, linear_args, ... | [
"0.8139916",
"0.77856356",
"0.7779488",
"0.76740634",
"0.7631713",
"0.75710815",
"0.7567377",
"0.75636655",
"0.75636655",
"0.75618804",
"0.7533823",
"0.74972975",
"0.7468926",
"0.7427854",
"0.74263495",
"0.7364112",
"0.73462653",
"0.72788036",
"0.72590977",
"0.7220011",
"0.72... | 0.7467439 | 13 |
The VPC's region. Defaults to the region of the AWS provider. | def vpc_region(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "vpc_region") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vpc_region(self) -> Optional[str]:\n return pulumi.get(self, \"vpc_region\")",
"def vpc_region(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"vpc_region\")",
"def region(self) -> str:\n return pulumi.get(self, \"region\")",
"def region(self) -> str:\n return pulumi.g... | [
"0.8810863",
"0.8605279",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.759258",
"0.7554983",
"0.7544524",
"0.7544524",
"0.7544524",
"0.7544524",
"0.73472196",
"0.72412014",
"0.72412014",
"0.72412014",
"0.71378714",
"0.71378714",
"0.71... | 0.8632728 | 2 |
The VPC's region. Defaults to the region of the AWS provider. | def vpc_region(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "vpc_region") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vpc_region(self) -> Optional[str]:\n return pulumi.get(self, \"vpc_region\")",
"def vpc_region(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"vpc_region\")",
"def region(self) -> str:\n return pulumi.get(self, \"region\")",
"def region(self) -> str:\n return pulumi.g... | [
"0.8810863",
"0.8605279",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.76336026",
"0.759258",
"0.7554983",
"0.7544524",
"0.7544524",
"0.7544524",
"0.7544524",
"0.73472196",
"0.72412014",
"0.72412014",
"0.72412014",
"0.71378714",
"0.71378714",
"0.71... | 0.8632728 | 1 |
The VPC's region. Defaults to the region of the AWS provider. | def vpc_region(self) -> pulumi.Output[str]:
return pulumi.get(self, "vpc_region") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vpc_region(self) -> Optional[str]:\n return pulumi.get(self, \"vpc_region\")",
"def vpc_region(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"vpc_region\")",
"def vpc_region(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"vpc_region\")",
"def regi... | [
"0.881003",
"0.86319816",
"0.86319816",
"0.76314455",
"0.76314455",
"0.76314455",
"0.76314455",
"0.76314455",
"0.76314455",
"0.75904685",
"0.7552888",
"0.7542399",
"0.7542399",
"0.7542399",
"0.7542399",
"0.7344929",
"0.7239079",
"0.7239079",
"0.7239079",
"0.71356124",
"0.7135... | 0.8604312 | 3 |
Return True if the original user has admin permission | def can_proxy_restclient(request, service, url):
if not hasattr(request, "can_proxy_restclient"):
request.can_proxy_restclient = is_admin()
return request.can_proxy_restclient | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin_user(self):\n if \"is_admin\" in self._properties and self.is_admin == 'YES':\n return True\n return False",
"def is_main_admin(self):\n if self.user is None:\n return False\n return self.user.has_permission(\"admin\")",
"def check_admin() -> bool:... | [
"0.8273403",
"0.8225382",
"0.81994957",
"0.8171669",
"0.8155228",
"0.8144289",
"0.8136331",
"0.8120649",
"0.8099617",
"0.8058328",
"0.80383426",
"0.80365944",
"0.8035828",
"0.8035777",
"0.80250275",
"0.80187863",
"0.80037284",
"0.7977565",
"0.7965918",
"0.79504347",
"0.795043... | 0.0 | -1 |
Parameters are the same as for get_from_convergence. Uses a slightly different convergence condition (see BaseMapping.compute_from_stepwise_convergence for an explanation), which is often faster than the other one. Defaults to logarithmic intervals for the direct discretization | def get_from_stepwise_convergence(J, domain, nof_coefficients, disc_type='sp_quad',
interval_type='log', mapping_type='sp_hes', permute=None,
residual=True, low_memory=True, stable=False, min_ncap=10,
max_ncap=2000, st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convergence_criterion(self,points,_,log_prob_norm):\n return np.sum(log_prob_norm)",
"def _convergence_criterion_simplified(self,points,_,log_prob_norm):\n return np.sum(log_prob_norm)",
"def loglam_minmax(self):\n return np.log10(8000.0), np.log10(25700)",
"def _log_convergence(sel... | [
"0.6102564",
"0.60438013",
"0.57693464",
"0.5714703",
"0.5686729",
"0.56542444",
"0.5635856",
"0.55969924",
"0.55803245",
"0.5575746",
"0.55213153",
"0.5504445",
"0.54373133",
"0.53834134",
"0.5363251",
"0.53427327",
"0.5340355",
"0.5314625",
"0.53093964",
"0.5277214",
"0.526... | 0.49210688 | 94 |
Code chooses a model based on name | def get_model_config(model_name, args):
if model_name == 'WaveGlow':
model_config = dict(
n_mel_channels=args.n_mel_channels,
n_flows=args.flows,
n_group=args.groups,
n_early_every=args.early_every,
n_early_size=args.early_size,
WN_conf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_by_name(cls, name):\n model_name = inflection.camelize(name) # class name of the model to use\n model = cls.models[model_name]\n return model",
"def get_model(model_name):\n module_name = 'strain.models.strain_' + model_name.lower()\n model_module = importlib.import_modu... | [
"0.773356",
"0.74082035",
"0.738873",
"0.7371019",
"0.7271772",
"0.70867914",
"0.7086557",
"0.69840664",
"0.697384",
"0.69190407",
"0.6893326",
"0.6890805",
"0.6867806",
"0.67394376",
"0.66829073",
"0.6662161",
"0.6634368",
"0.6620342",
"0.66084063",
"0.6599154",
"0.6539856",... | 0.0 | -1 |
List escalation policies belonging to this account | def list_policies(profile=None, api_key=None):
return salt.utils.pagerduty.list_items(
"escalation_policies",
"id",
__salt__["config.option"](profile),
api_key,
opts=__opts__,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_policies(self):\n client = self.connect(VAULT_TOKEN)\n return client.list_policies()",
"def policies(self):\n return self._policies",
"def policies(self):\n return self._data.get('policies')",
"def list_policies(self):\n return self.con.list_policies(\n ... | [
"0.66221696",
"0.6198025",
"0.6194609",
"0.6094182",
"0.6024351",
"0.59862185",
"0.5946263",
"0.5895928",
"0.5824226",
"0.5772952",
"0.5693319",
"0.56879264",
"0.56557685",
"0.5597097",
"0.55378485",
"0.54972947",
"0.5490396",
"0.54499733",
"0.53823185",
"0.5375433",
"0.53698... | 0.7295848 | 0 |
Get the value of a variable, i.e. the result of its pipeline. The 'variable' can either be a Variable, from which a temporary pipeline will be built, or a VariableInformation, representing an existing pipeline. | def get_variable_value(variable):
def pipeline_from_info(variableinfo):
controller = variableinfo._controller
version = controller.vistrail.get_version_number(
'dat-var-%s' % variable.name)
return controller.vistrail.getPipeline(version), version
def pipeline_from_generator(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_variable(self, request, context):\n response = GetVariableResponse()\n value = self._delegator.get_variable(request.component, request.variable)\n response.value = encode(value)\n return response",
"def get_variable(self, variable_name):\n with self._graph.as_default():\n ... | [
"0.6539785",
"0.648628",
"0.64014816",
"0.6388843",
"0.6385091",
"0.63771605",
"0.6161528",
"0.6147946",
"0.60184354",
"0.597502",
"0.595944",
"0.5957056",
"0.5916144",
"0.5897836",
"0.5835453",
"0.5750163",
"0.5730265",
"0.5715077",
"0.5698372",
"0.56881833",
"0.56858885",
... | 0.8015312 | 0 |
Load the variable and return it. Implement this in subclasses to load whatever data the user selected as a Variable object. | def load(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self):\n return self._value",
"def loadVar(name):\n with open(name+'.pickle','rb') as fl:\n return pickle.load(fl)",
"def get_data(self, variable):\n return self.data.get(variable)",
"async def read_variable_by_name(self, name: str) -> Optional[Variable]:\n try:\n ... | [
"0.657049",
"0.6563246",
"0.6410845",
"0.6376609",
"0.6266435",
"0.6211618",
"0.61463904",
"0.6096326",
"0.607682",
"0.60722077",
"0.60567755",
"0.6053437",
"0.60302836",
"0.60010594",
"0.59607434",
"0.59539104",
"0.5933655",
"0.59105605",
"0.588043",
"0.587299",
"0.5869864",... | 0.0 | -1 |
Create a pipeline from a recipe and return its information. | def create_pipeline(controller, recipe, row, column, var_sheetname,
typecast=None):
# Build from the root version
controller.change_selected_version(0)
reg = get_module_registry()
generator = PipelineGenerator(controller)
inputport_desc = reg.get_descriptor_by_name(
'o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipeline(args) :\n from pipeliner import create_pipeline\n create_pipeline(args)",
"def construct(args,\n **kwargs):\n kw = parse_args(args)\n kw.update(kwargs)\n return (build_pipeline(**kw),\n kw)",
"def make_pipeline():\r\n\r\n # Custom universe containing only ... | [
"0.6389445",
"0.6383199",
"0.6034997",
"0.5830952",
"0.58033293",
"0.57903403",
"0.5713877",
"0.5713516",
"0.56414485",
"0.5621396",
"0.55686563",
"0.55486304",
"0.55427545",
"0.55334556",
"0.54980105",
"0.54647094",
"0.54605",
"0.54423845",
"0.54258776",
"0.54218894",
"0.541... | 0.58849597 | 3 |
Return a string representation of this structure | def __str__(self):
d = {}
d["allocation_id_csv"] = self.allocation_id_csv
d["bandwidth"] = self.bandwidth
d["center_frequency"] = self.center_frequency
d["complex"] = self.complex
d["decimation"] = self.decimation
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return p... | [
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274"... | 0.0 | -1 |
Return a string representation of this structure | def __str__(self):
d = {}
d["tuner_number"] = self.tuner_number
d["output_format"] = self.output_format
d["output_source"] = self.output_source
return str(d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return pprint.pformat(self.to_dict())",
"def to_str(self):\n return p... | [
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274",
"0.81904274"... | 0.0 | -1 |
This function prints and plots the confusion matrix | def plot_confusion_matrix(conf_mat, classes, title='Confusion matrix', cmap=plt.cm.Blues):
plt.imshow(conf_mat, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
plt.xticks(tick_marks, classes, rotation=90)
plt.yticks(tick_marks, classes)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def showConfusionMatrix(self): \r\n sn.heatmap(self.conf_matrix, annot=True)\r\n plt.plot( label=\"Accuracy\")\r\n plt.plot( label=\"Error\"... | [
"0.82446307",
"0.82064825",
"0.8003078",
"0.7950049",
"0.7938799",
"0.79245925",
"0.78669244",
"0.78329617",
"0.7791349",
"0.77882665",
"0.77743405",
"0.77672374",
"0.77396595",
"0.7717026",
"0.7693782",
"0.7673597",
"0.7663732",
"0.76593524",
"0.7648418",
"0.7639382",
"0.763... | 0.0 | -1 |
Excecutes an action in the gym environment. Builds current state (concatenation of agent_history_length1 previous frames and current one). Pops oldest frame, adds current frame to the state buffer. Returns current state. | def step(self, action_index):
x_t1, r_t, terminal, info = self.env.step(self.gym_actions[action_index])
s_t1 = self.get_preprocessed_RAM(x_t1)
return s_t1, r_t, terminal, info | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\n obs = self.gym.get_observations()\n all_actions = self.gym.act(obs)\n all_actions.insert(self.gym.training_agent, action)\n state, reward, terminal, info = self.gym.step(all_actions)\n agent_state = self.featurize(state[self.gym.training_agent])\n\n ... | [
"0.6380256",
"0.63442373",
"0.63255674",
"0.6178981",
"0.6029926",
"0.6002586",
"0.593787",
"0.59097886",
"0.58737737",
"0.58592814",
"0.58407587",
"0.582588",
"0.5823106",
"0.57838845",
"0.5761409",
"0.57539594",
"0.57490873",
"0.5737222",
"0.57129216",
"0.5709785",
"0.57049... | 0.0 | -1 |
__init__(self, inputCol=None, outputCol=None, graph=None, inputTensor=utils.IMAGE_INPUT_PLACEHOLDER_NAME, outputTensor=None, outputMode="vector") | def __init__(self, inputCol=None, outputCol=None, graph=None,
inputTensor=utils.IMAGE_INPUT_PLACEHOLDER_NAME, outputTensor=None,
outputMode="vector"):
super(TFImageTransformer, self).__init__()
self._setDefault(inputTensor=utils.IMAGE_INPUT_PLACEHOLDER_NAME)
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setParams(self, inputCol=None, outputCol=None, graph=None,\n inputTensor=utils.IMAGE_INPUT_PLACEHOLDER_NAME, outputTensor=None,\n outputMode=\"vector\"):\n kwargs = self._input_kwargs\n return self._set(**kwargs)",
"def _init_(self, input_column, output_column)... | [
"0.7075553",
"0.63728833",
"0.6216239",
"0.61196035",
"0.6019875",
"0.5985511",
"0.5976182",
"0.5909064",
"0.59070784",
"0.5873992",
"0.5858646",
"0.5833762",
"0.58273697",
"0.582374",
"0.58151144",
"0.58135617",
"0.5787638",
"0.57775325",
"0.5761204",
"0.5749984",
"0.5746121... | 0.8731906 | 0 |
Plots a correlation matrix between artist follower_counts and twitter metrics. Uses sql to filter and join the artist_socials and twitter tables from our database. Next, we calculate a correlation matrix between the following | def plot_twitter_influence(base_dir):
# make sure the plot directory exists or create it so we can save our plot
plot_dir = Path(base_dir) / "plot"
Path(plot_dir).mkdir(parents=True, exist_ok=True)
# load tables into pandas
with engine.connect() as conn:
# filter-join artist_socials and tw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_track_follower_relationship(base_dir):\n\n # make sure the plot directory exists or create it so we can save our plot\n plot_dir = Path(base_dir) / \"plot\"\n Path(plot_dir).mkdir(parents=True, exist_ok=True)\n\n # load tables into pandas\n with engine.connect() as conn:\n\n # Joins ... | [
"0.6787683",
"0.66082495",
"0.5672543",
"0.565548",
"0.5551678",
"0.55449915",
"0.5352404",
"0.53244853",
"0.5316419",
"0.5311218",
"0.52798855",
"0.5222884",
"0.5183737",
"0.51477927",
"0.509537",
"0.5093629",
"0.50893676",
"0.5080533",
"0.5078685",
"0.5039114",
"0.5037911",... | 0.77112406 | 0 |
Handler for home page. | def index():
return render_template('connect.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(self, *args, **kwargs):\n pass",
"def _home(self, op, context):\n self.page = \"HOME\"\n return {'FINISHED'}",
"def home() -> Any:\n return home_page()",
"def home():\n\n return render_template('home_page.html')",
"def home_page(request):\r\n return render(request, 'ez... | [
"0.795485",
"0.7690412",
"0.75666",
"0.7509171",
"0.7493455",
"0.7440583",
"0.7393242",
"0.73337483",
"0.73337483",
"0.7329066",
"0.73148423",
"0.7314383",
"0.7308979",
"0.727491",
"0.7274888",
"0.7255021",
"0.7245429",
"0.72324365",
"0.7231551",
"0.7228083",
"0.722035",
"0... | 0.0 | -1 |
The ``config_dir`` for this endpoint. If no directory was given during initialization, this will be computed based on the current platform and environment. | def config_dir(self) -> str:
if not self._config_dir:
self._config_dir = self._detect_config_dir()
return self._config_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_directory(self):\n\n return self.get_raw(\"config_directory\")",
"def config_dir(self) -> Path:\n return self._config_dir",
"def get_config_dir():\n return Path(environ.get(CONFIG_DIR_ENV_VAR, _default_dir))",
"def conf_dir(self):\r\n return self._conf_dir",
"def _locate_... | [
"0.80683774",
"0.79523635",
"0.7849052",
"0.73649687",
"0.7312178",
"0.7309532",
"0.72727877",
"0.7241069",
"0.7105416",
"0.6998711",
"0.6961406",
"0.68385434",
"0.6778454",
"0.6773097",
"0.67632025",
"0.67389584",
"0.6729064",
"0.6722731",
"0.67191744",
"0.6687117",
"0.66448... | 0.80900747 | 0 |
Stops the timer if it is running and returns the elapsed time since start, otherwise returns 0. | def stop(self):
if self.running():
self._final = time.clock()
self._time = self._final - self._start
self._total += self._time
self._start = None
return self._time
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n if self._start_time is None:\n raise TimerError(\"Timer is not running. Use start() to start it\")\n\n elapsed_time = time.perf_counter() - self._start_time\n self._start_time = None\n return (f\"Elapsed time: {elapsed_time:0.4f} seconds\")",
"def StopTime... | [
"0.7976962",
"0.78302556",
"0.7786654",
"0.7735445",
"0.77226615",
"0.76225233",
"0.72012854",
"0.7157758",
"0.7142221",
"0.70828354",
"0.7075189",
"0.70701414",
"0.70468736",
"0.7038251",
"0.7024647",
"0.70238924",
"0.68212354",
"0.68210024",
"0.6649668",
"0.66418403",
"0.66... | 0.7829048 | 2 |
Computes the offset between image1 and image2 using crosscorrelation. Provides integer pixel accuracy. Returns | def get_cross_correlation_integer_pixel_offset(self):
# Replace any suprious values with local median values
array1, array2 = self._replace_negatives_and_nans_with_medians()
# Do an array flipped convolution, which is a correlation.
corrImage = signal.fftconvolve(
array2,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_corl_offset(img1, img2):\n assert img1.shape == img2.shape, \"Images must be the same shape\"\n corl = correlate2d(img1, img2, mode=\"same\")\n corl_max = np.argmax(corl)\n return np.unravel_index(corl_max, img1.shape)",
"def image_correlation(image1, image2):\n im1=im_to_coord(image1)\n ... | [
"0.7301131",
"0.7033461",
"0.6711448",
"0.65482587",
"0.652275",
"0.6500958",
"0.63490087",
"0.6050604",
"0.6046648",
"0.60278577",
"0.6003053",
"0.59870666",
"0.59044105",
"0.5851388",
"0.5796769",
"0.5792918",
"0.5745302",
"0.5695238",
"0.568531",
"0.5678566",
"0.5663714",
... | 0.71422255 | 1 |
p, n = planeFit(points) Given an array, points, of shape (d,...) representing points in ddimensional space, fit an ddimensional plane to the points. Return a point, p, on the plane (the pointcloud centroid), and the normal, n. | def planeFit(points):
points = np.reshape(points, (np.shape(points)[0], -1)) # Collapse trialing dimensions
assert points.shape[0] <= points.shape[1], "There are only {} points in {} dimensions.".format(points.shape[1], points.shape[0])
ctr = points.mean(axis=1)
x = poin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def planeFit(points):\n import numpy as np\n from numpy.linalg import svd\n points = np.reshape(points, (np.shape(points)[0], -1)) # Collapse trialing dimensions\n assert points.shape[0] <= points.shape[1], \"There are only {} points in {} dimensions.\".format(points.shape[1], points.shape[0])\n ctr... | [
"0.7482481",
"0.7457372",
"0.74258035",
"0.7349887",
"0.71463597",
"0.6993942",
"0.6729022",
"0.6729022",
"0.65462005",
"0.6473204",
"0.64421755",
"0.6408085",
"0.63596845",
"0.6329129",
"0.6268745",
"0.6268745",
"0.6260973",
"0.61547804",
"0.6124241",
"0.6111411",
"0.6101236... | 0.7332707 | 4 |
Computes the offset between image1 and image2 using crosscorrelation. Provides subpixel accuracy. | def get_cross_correlation_subpixel_offset(self, satLimit=16e3,
cutoutSize=21):
# TODO: Test if rough pixel-level alignment is required
pass
# # Test if a quick WCS integer pixel alignment is possible.
# if self.image1.has_wcs and self.image2.has_wcs:
# # Compute the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_corl_offset(img1, img2):\n assert img1.shape == img2.shape, \"Images must be the same shape\"\n corl = correlate2d(img1, img2, mode=\"same\")\n corl_max = np.argmax(corl)\n return np.unravel_index(corl_max, img1.shape)",
"def image_correlation(image1, image2):\n im1=im_to_coord(image1)\n ... | [
"0.6991338",
"0.6978736",
"0.67498446",
"0.6421898",
"0.6341395",
"0.62322813",
"0.6147605",
"0.6081714",
"0.6062456",
"0.5952915",
"0.5911397",
"0.58957773",
"0.58607197",
"0.58575463",
"0.58377993",
"0.58033276",
"0.5801882",
"0.57932466",
"0.57862973",
"0.57701534",
"0.574... | 0.6219957 | 6 |
Extracts and returns a 3D numpy.ndarray containing the image uncertainty. | def _extract_uncert_sub_stack(self, startRow, endRow):
# Grab the shape of the image stack
nz, ny, nx = self.shape
# Build a list of which of these images have uncertainty
numWithUncert = np.sum([img.has_uncertainty for img in self.imageList])
# If not ALL of the images have un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uncertainty(self):\n return self.uncertainty_per_deg * self.temp * self.n_atoms",
"def uncertainty(self):\n return self.uncertainty_per_atom * self.n_atoms",
"def calc_uncertainty(self):\n y = self.y\n y_true = self.y_true\n j_lim = self.j_lim\n Nj = self.Nj\n ... | [
"0.6201934",
"0.593521",
"0.59123576",
"0.5810697",
"0.5658321",
"0.5528615",
"0.5528615",
"0.547507",
"0.54685664",
"0.5423556",
"0.54046303",
"0.5381787",
"0.5362259",
"0.52918696",
"0.52916265",
"0.52225935",
"0.5194472",
"0.51823366",
"0.51745564",
"0.5168267",
"0.5159127... | 0.59214175 | 2 |
Writes a collection of records to json. | def _write_json(
output_path, records
):
output_path.write_text(json.dumps(records)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_json(self):\r\n logging.info('Writing records to JSON')\r\n with open(self.backup, 'w') as fp:\r\n json.dump(self.record, fp)\r\n logging.info(\"Finished writing records to JSON\")",
"def _recordsToResponse(self, records):\n fieldsList = []\n count = 0\n... | [
"0.66271585",
"0.63096404",
"0.6154962",
"0.6135605",
"0.5970243",
"0.5959931",
"0.59551185",
"0.58898646",
"0.588094",
"0.58630246",
"0.586016",
"0.5852959",
"0.5851691",
"0.58457917",
"0.5827118",
"0.5809331",
"0.58080846",
"0.58049065",
"0.5800502",
"0.57744616",
"0.575394... | 0.74904406 | 0 |
Creates a JSONoriented Flask app. All error responses that you don't specifically manage yourself will have application/json content | def make_json_app(import_name, **kwargs):
def make_json_error(ex):
response = jsonify(message=str(ex))
response.status_code = (ex.code
if isinstance(ex, HTTPException)
else 500)
return response
app = Flask(import_name, **kw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_json_app(import_name, **kwargs):\n\n def make_json_error(ex):\n \"\"\"This is an error handler for handling exceptions for the app. It allows\n us to simply handle all the exceptions here as opposed to writing try catches\n everywhere. The ResourceExceptions defined in the app will... | [
"0.8140003",
"0.8090276",
"0.77563775",
"0.70049465",
"0.69091845",
"0.674112",
"0.66742253",
"0.65706575",
"0.6546808",
"0.6541503",
"0.65002114",
"0.64109004",
"0.6404402",
"0.63604534",
"0.63249665",
"0.6312997",
"0.63054514",
"0.6276694",
"0.62707996",
"0.61979383",
"0.61... | 0.7813924 | 2 |
Return a setting object. the setting to support cache must have a persistent __registry__ attributes, this is where plone.app.theming store it's cache | def getSettings(self):
context = findContext(self.request)
switcher = component.getMultiAdapter((context, self.request),
name=u"themeswitcher")
return switcher.getSettings(self._old_getSettings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setting(self, setting):\r\n return SettingResource(self, setting)",
"def settings(self):\r\n return SettingResource(self)",
"def get_setting_object(cls, key, **kwargs):\n key = str(key).strip().upper()\n\n filters = {\n 'key__iexact': key,\n }\n\n # Filt... | [
"0.69497824",
"0.6913658",
"0.6667225",
"0.66329104",
"0.6577356",
"0.64232695",
"0.6336031",
"0.62293035",
"0.61940813",
"0.61917335",
"0.61403996",
"0.6117913",
"0.61154205",
"0.6110727",
"0.6093428",
"0.6076313",
"0.6061548",
"0.6001132",
"0.5973419",
"0.58888966",
"0.5885... | 0.5399717 | 60 |
Enable PWM output on specified pin. Set to initial percent duty cycle value (0.0 to 100.0) and frequency (in Hz). | def setup_pin(self, pin, dutycycle, frequency=2000):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def togglePWMPinEnable(self, PWMpin):\n bitPos = PWMpin + 8\n mask = 1 << bitPos\n self._injectFault(\"PWM1PCR\",self.PCR,mask)",
"def setup_motor(self,pin_num):\n pi.set_servo_pulsewidth(pin_num, 2000)\n sleep(2)\n pi.set_servo_pulsewidth(pin_num, 500 )\n sleep(2... | [
"0.71088386",
"0.68166107",
"0.6816506",
"0.67688787",
"0.67072624",
"0.66083163",
"0.6575058",
"0.6572862",
"0.64575446",
"0.6388722",
"0.6336557",
"0.6325436",
"0.6281215",
"0.6279041",
"0.6267511",
"0.62373865",
"0.62321174",
"0.6218576",
"0.6169488",
"0.6127881",
"0.61051... | 0.6709293 | 4 |
Set frequency (in Hz) of PWM output on specified pin. | def set_frequency(self, pin, frequency):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pwm_freq(self, servo_frequency: int):\n prescaleval = float(self._frequency)\n prescaleval /= float(self._resolution)\n prescaleval /= float(servo_frequency)\n prescaleval -= 1\n logger.info('Setting PWM frequency to %d Hz', servo_frequency)\n logger.info('Estimate... | [
"0.71367824",
"0.6968085",
"0.6783706",
"0.6783289",
"0.67156214",
"0.66167897",
"0.65295315",
"0.64630246",
"0.6448775",
"0.6448775",
"0.63789034",
"0.6305361",
"0.62634516",
"0.62620354",
"0.62339425",
"0.6210036",
"0.61933285",
"0.6182513",
"0.61687297",
"0.6136568",
"0.60... | 0.75850415 | 0 |
A py.test for returning status code 404 on a GET request. | def test_resourcenotfound():
URL_STR = "http://52.24.157.193:5000/api/fibonacci/foo"
response = requests.get( URL_STR )
data = response.json()
assert response.status_code == 404 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_request_returns_404(client):\n assert client.get(\"/url_que_nao_existe\").status_code == 404",
"def test_custom_404(self):\n c = Client()\n response = c.get(\"/apimock/mocked/non_exsitng-url\")\n self.assertEqual(response.status_code, 404)\n self.assertEqual('MockedApi 404... | [
"0.83874846",
"0.8339204",
"0.82349473",
"0.8230041",
"0.81664664",
"0.81248033",
"0.8065352",
"0.8062373",
"0.80091923",
"0.80063033",
"0.80017436",
"0.7939534",
"0.79235035",
"0.78943527",
"0.7884354",
"0.7882464",
"0.7882252",
"0.7864267",
"0.7842597",
"0.78281415",
"0.782... | 0.7727729 | 27 |
List the access policies for this network. Only valid for MS networks. | def getNetworkSwitchAccessPolicies(self, networkId: str):
metadata = {
'tags': ['switch', 'configure', 'accessPolicies'],
'operation': 'getNetworkSwitchAccessPolicies',
}
resource = f'/networks/{networkId}/switch/accessPolicies'
return self._session.get(metadata... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_policies(self):\n client = self.connect(VAULT_TOKEN)\n return client.list_policies()",
"def list_policies(self):\n return self.con.list_policies(\n Scope='Local'\n )",
"def get_access_list(self):\n return self.manager.get_access_list(self)",
"def list_ac... | [
"0.70848995",
"0.70402074",
"0.6637166",
"0.6478583",
"0.64495164",
"0.63233936",
"0.63120216",
"0.61663705",
"0.6128441",
"0.6079479",
"0.6057938",
"0.6056339",
"0.605352",
"0.6037729",
"0.6023668",
"0.6003189",
"0.6003189",
"0.5891457",
"0.5887274",
"0.58610207",
"0.5825159... | 0.667263 | 2 |
Add a switch to a stack | def addNetworkSwitchSwitchStack(self, networkId: str, switchStackId: str, serial: str):
kwargs = locals()
metadata = {
'tags': ['switch', 'configure', 'switchStacks'],
'operation': 'addNetworkSwitchSwitchStack',
}
resource = f'/networks/{networkId}/switch/switch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_to_switch(self, _switch, context):\n _network = context.current['id']\n _vlanid = context.current['provider:segmentation_id']\n\n # BRIDGE_PORT_URL = '{url_prefix}://{switch_name_or_ip}:{port}/networks/{vlan}/{network_id}/{port_id}'\n for _switchport in _switch.get('ports'):\n ... | [
"0.6274812",
"0.6271452",
"0.605345",
"0.5973303",
"0.58784497",
"0.5859572",
"0.5855364",
"0.58099306",
"0.5780862",
"0.57577795",
"0.57577795",
"0.5751239",
"0.5750184",
"0.5750184",
"0.5730615",
"0.57025576",
"0.5643972",
"0.5590209",
"0.55604666",
"0.55205625",
"0.5452611... | 0.5208901 | 45 |
List the switch profiles for your switch template configuration | def getOrganizationConfigTemplateSwitchProfiles(self, organizationId: str, configTemplateId: str):
metadata = {
'tags': ['switch', 'configure', 'configTemplates', 'profiles'],
'operation': 'getOrganizationConfigTemplateSwitchProfiles',
}
resource = f'/organizations/{orga... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_profiles(cls) -> List[str]:\n return list(cfg.get(\"profiles\"))",
"def list_profiles(request, pk=0):\n context = {'items': [], 'resource_type': 'Profile'}\n handle_expired_profiles()\n if pk == 0:\n context['h2'] = \"Configuration Profiles\"\n context['header_1'] = \"... | [
"0.6609702",
"0.64510405",
"0.6447929",
"0.63891304",
"0.61870676",
"0.61326253",
"0.6096009",
"0.59686196",
"0.595392",
"0.5881029",
"0.58558416",
"0.58239317",
"0.5785712",
"0.5782131",
"0.5778134",
"0.57351315",
"0.5715119",
"0.5666582",
"0.5665228",
"0.56652033",
"0.56279... | 0.5051594 | 58 |
Returns if the word is in the trie. | def search(self, word: str) -> bool:
node = self.root
for w in word:
node = node.children.get(w)
if not node:
return False
return node.end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_trie(self, trie, word):\n current_dict = trie\n for letter in word:\n if letter in current_dict:\n current_dict = current_dict[letter]\n else:\n return False\n else:\n if '_end_' in current_dict:\n return curr... | [
"0.83862334",
"0.81503016",
"0.81233966",
"0.78567004",
"0.7830559",
"0.7793441",
"0.7792726",
"0.77641875",
"0.77533525",
"0.77476454",
"0.77111906",
"0.7681577",
"0.7677003",
"0.76645255",
"0.76505435",
"0.7633823",
"0.7628248",
"0.76113766",
"0.75775784",
"0.75606924",
"0.... | 0.7569505 | 19 |
The input tensor for this loom. | def input_tensor(self):
if self._direct_feed_dict:
raise TypeError('This loom has direct_feed_dict set, '
'so it has no input tensor')
return self._loom_input_tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_tensor(interpreter):\n tensor_index = interpreter.get_input_details()[0]['index']\n return interpreter.tensor(tensor_index)()[0]",
"def get_tensor_from_input(input_data: Dict[str, Any]) -> torch.Tensor:\n return input_data['img']",
"def get_tensor_from_input(self, input_data: Dict[str, A... | [
"0.73565006",
"0.70768464",
"0.703099",
"0.7005733",
"0.6999828",
"0.69345206",
"0.69223535",
"0.6916421",
"0.68665445",
"0.681536",
"0.67679954",
"0.6736799",
"0.6710873",
"0.6705851",
"0.66967446",
"0.6676575",
"0.6618773",
"0.6610656",
"0.6610656",
"0.66015023",
"0.6601502... | 0.81976163 | 0 |
The maximum depth of any LoomResult created by this input. | def deepest(self):
return self._weaver.Deepest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth(self):\n return self._max_depth",
"def max_depth(self) -> int:\n return 0",
"def max_depth(self) -> int:\n return pulumi.get(self, \"max_depth\")",
"def max_depth(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"max_depth\")",
"def get_max_depth(self):... | [
"0.8101155",
"0.8089143",
"0.80267674",
"0.7944192",
"0.7820142",
"0.76349354",
"0.7546716",
"0.7299001",
"0.72795945",
"0.7181516",
"0.7178106",
"0.71688116",
"0.6966567",
"0.6954262",
"0.69485104",
"0.6931996",
"0.68912846",
"0.6877682",
"0.6874599",
"0.68563455",
"0.683462... | 0.0 | -1 |
Returns the TypeShape of the tensor represented by `result`. | def get_type_shape(self, result):
ts_idx = self._weaver.GetTypeShape(result)
if ts_idx == -1:
raise AssertionError('Invalid LoomResult ID passed to get_type_shape.')
return self._loom._type_shapes[ts_idx] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infer_shape(inputs, mod=None):\n out_type = infer_type(inputs, mod=mod)\n checked_type = out_type.checked_type\n if hasattr(checked_type, 'shape'):\n # Regular operator that outputs tensors\n return get_const_tuple(out_type.checked_type.shape)\n # The return type is not a tensor, for ... | [
"0.60604703",
"0.57523584",
"0.56772864",
"0.56256115",
"0.5609576",
"0.55918676",
"0.55779743",
"0.55730885",
"0.55276537",
"0.5511898",
"0.5457616",
"0.5454666",
"0.5431701",
"0.5413221",
"0.5402413",
"0.5397301",
"0.5392369",
"0.539175",
"0.5375362",
"0.53464776",
"0.53446... | 0.80041337 | 0 |
Return a LoomResult which stands for en element of a batch_input tensor. | def batch_input(self, type_shape, batch_idx):
try:
ts_idx = self._loom._type_shape_to_idx[type_shape]
except KeyError:
raise TypeError('Constant is not of a recognized TypeShape: %s' %
str(type_shape))
batch_input = self._weaver.BatchInput(ts_idx, batch_idx)
if batch_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embed(self, word_batch: List[List[str]]) -> Tuple[FloatTensor, LongTensor]:\n return self.embed_with_info(word_batch)[0]",
"def __getitem__(self, batch):\n batch.scatter()\n if self.num_gpus == 1:\n return self(*batch[0])\n replicas = nn.parallel.replicate(self, devices... | [
"0.5873507",
"0.58207387",
"0.581136",
"0.57051605",
"0.5679295",
"0.56149834",
"0.5591659",
"0.5546206",
"0.55291194",
"0.548267",
"0.5413637",
"0.54080975",
"0.5397522",
"0.53467125",
"0.5331509",
"0.5321381",
"0.5298644",
"0.527126",
"0.5251314",
"0.52474713",
"0.521469",
... | 0.0 | -1 |
Construct a Rule with provided config | def __init__(self, config: Dict[str, Any]) -> None:
self.config = config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_snat_rule(self, **attrs):\n return self._create(_snat.Rule, **attrs)",
"def create(**rules_config) -> 'APIRules':\n obj = {\n k: v for k, v in rules_config.items() if k in APIRules.__fields__\n }\n # Validation will fail if required `api_version` is missing\n ... | [
"0.63909686",
"0.63515145",
"0.6220028",
"0.6096427",
"0.6096427",
"0.6096427",
"0.6096427",
"0.6096427",
"0.5999254",
"0.594441",
"0.5718587",
"0.5697568",
"0.5661411",
"0.56414604",
"0.5619194",
"0.5617692",
"0.5585104",
"0.5565815",
"0.5541151",
"0.5541151",
"0.55042064",
... | 0.0 | -1 |
Returns the polarity of the given number. | def polarity(num):
if num > 0:
return 1
if num < 0:
return -1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polarity(self):\n return utils.readstr_all(os.path.join(_CHANNEL_PATH(self._chip,\n self._channel),\n \"polarity\"))",
"def _polarity(waveform):\n return waveform * -1",
"def _calculate_pol... | [
"0.72577846",
"0.721421",
"0.6435097",
"0.60469276",
"0.5926555",
"0.5905662",
"0.5877928",
"0.5832896",
"0.5780458",
"0.5771478",
"0.5751061",
"0.5533766",
"0.55297863",
"0.54719305",
"0.5467685",
"0.53833956",
"0.5382943",
"0.53554684",
"0.5352362",
"0.5229949",
"0.5190591"... | 0.86392003 | 0 |
Tests the ``metrics_since`` template tag when displaying metric history. | def test_metrics_since_history(self):
slug = "test-slug"
years = 5
link_type = "history"
now = datetime(2014, 7, 4)
module = 'redis_metrics.templatetags.redis_metric_tags.datetime'
with patch(module) as mock_datetime:
mock_datetime.utcnow.return_value = now
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metrics_since_aggregate(self):\n\n slugs = ['test-a', 'test-b']\n years = 5\n link_type = \"aggregate\"\n granularity = \"weekly\"\n now = datetime(2014, 7, 4)\n\n module = 'redis_metrics.templatetags.redis_metric_tags.datetime'\n with patch(module) as mock... | [
"0.6019125",
"0.5740954",
"0.54856664",
"0.5480795",
"0.5347069",
"0.5237282",
"0.5163278",
"0.514513",
"0.5142455",
"0.5065899",
"0.50648713",
"0.506278",
"0.50430965",
"0.4997453",
"0.49701205",
"0.49211988",
"0.49198145",
"0.4881194",
"0.4796087",
"0.47748923",
"0.47681224... | 0.70553166 | 0 |
Tests the ``metrics_since`` template tag when displaying metric aggregate history. | def test_metrics_since_aggregate(self):
slugs = ['test-a', 'test-b']
years = 5
link_type = "aggregate"
granularity = "weekly"
now = datetime(2014, 7, 4)
module = 'redis_metrics.templatetags.redis_metric_tags.datetime'
with patch(module) as mock_datetime:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metrics_since_history(self):\n\n slug = \"test-slug\"\n years = 5\n link_type = \"history\"\n now = datetime(2014, 7, 4)\n\n module = 'redis_metrics.templatetags.redis_metric_tags.datetime'\n with patch(module) as mock_datetime:\n mock_datetime.utcnow.r... | [
"0.69441414",
"0.5780654",
"0.5338999",
"0.53282684",
"0.52697426",
"0.5147069",
"0.5113139",
"0.5109778",
"0.49500215",
"0.4949478",
"0.49084675",
"0.48970738",
"0.4890287",
"0.48425573",
"0.48338982",
"0.4815454",
"0.48143122",
"0.47780755",
"0.47671506",
"0.47323912",
"0.4... | 0.65493506 | 1 |
Returns the representation of this instance. | def __repr__(self):
# sort the column keys
sorted_columns = sorted(self.__table__.columns, key=lambda c: c.key)
# build a generator for the instance attributes
sorted_pairs = ((column.key, getattr(self, column.key)) for column in sorted_columns)
return '<{name}: {data}>'.forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def serialize(self):\n\n return str(self)",
"def __repr__(self) -> str:\n return str(self.as_dict())",
"def serialize(self):\n\n\t\treturn str(self)",
"def __repr__(self):\n return json.dumps(self.__dict__)",
... | [
"0.8081303",
"0.7944065",
"0.7927741",
"0.790831",
"0.7860494",
"0.7808865",
"0.77567977",
"0.7728072",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"0.7724217",
"... | 0.0 | -1 |
sliding the patch size window, crop from the whole images | def sliding_window(image, patch_size: tuple, step: int, show_debug: bool = False) -> list:
if isinstance(image, Image.Image):
image = np.array(image)
if step == 0:
h, w = image.shape[0], image.shape[1] # 720, 1280
w_iter, h_iter = w // patch_size[0], h // patch_size[1]
crop_ima... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_image(X, patch_size=(8, 8)):\n (h, w) = np.shape(X)\n cropped_h = h - patch_size[0] + 1\n cropped_w = w - patch_size[1] + 1\n middle_linear_index = int(\n ((patch_size[0] / 2) * patch_size[1]) + (patch_size[1] / 2))\n columns = im2col(X, patch_size)\n return np.reshape(columns[mid... | [
"0.6370932",
"0.63030666",
"0.62686056",
"0.62647355",
"0.6154691",
"0.61108613",
"0.6092395",
"0.6087495",
"0.6034879",
"0.6034879",
"0.60003567",
"0.59626615",
"0.59435636",
"0.59248",
"0.58851135",
"0.5882424",
"0.5879814",
"0.5877315",
"0.58733976",
"0.58596194",
"0.58429... | 0.8076959 | 0 |
Loads ``barcodes`` from ``pickle``. | def load_barcodes(self, path):
self._barcodes = pickle.load(open(path, 'rb')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_barcodes(self, path):\n pickle.dump(self.barcodes, open(path, 'wb'))",
"def load_barcodes(mattr, args):\n mattr.nclasses = 2\n annotations = \"../tgb/segmentation_datasets/\"\\\n \"finished_datasets/segment_dataset_v2/annotations/\"\n images = \"../tgb/segmentation_datasets/\"\\\n... | [
"0.6822507",
"0.63150346",
"0.6110992",
"0.60763186",
"0.6074421",
"0.5939473",
"0.587943",
"0.5866716",
"0.5859612",
"0.5829132",
"0.5798056",
"0.5772924",
"0.57697535",
"0.5761609",
"0.57462966",
"0.5736092",
"0.57284",
"0.5697138",
"0.5697138",
"0.5697138",
"0.56936055",
... | 0.87024045 | 0 |
Saves ``barcodes`` as ``pickle``. | def save_barcodes(self, path):
pickle.dump(self.barcodes, open(path, 'wb')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_barcodes(self, path):\n self._barcodes = pickle.load(open(path, 'rb'))",
"def save_pickle(self, path):\n with open(path, 'wb') as f:\n pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL)",
"def save(self):\n pickle.dump(self, open(self.path, \"wb\"))",
"def save_lexico... | [
"0.6964327",
"0.62289214",
"0.6149612",
"0.60661054",
"0.6004148",
"0.5985235",
"0.5963022",
"0.5946376",
"0.594207",
"0.5930772",
"0.58562684",
"0.5846724",
"0.5843606",
"0.583789",
"0.5825719",
"0.5822329",
"0.5766928",
"0.5739477",
"0.5709933",
"0.5701226",
"0.5692728",
... | 0.8715689 | 0 |
Returns a new ``wiki.Net`` with a randomized copy of ``graph``. Set ``null_type`` as one of ``'year'``, ``'target'``. | def randomize(self, null_type,
compute_core_periphery=True, compute_communities=True,
compute_community_cores=True):
network = Net()
network.graph = self.graph.copy()
if null_type == 'year':
years = list(nx.get_node_attributes(network.graph, 'year'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_graph(self, name='', dump=None, nodes=None, depth_goal=1,\n filter_top=True, remove_isolates=True, add_years=True,\n fill_empty_years=True, model=None, dct=None,\n compute_core_periphery=True, compute_communities=True,\n compute_... | [
"0.6179526",
"0.5721828",
"0.5680782",
"0.5679056",
"0.5657903",
"0.5640398",
"0.5504725",
"0.5428419",
"0.542506",
"0.5424499",
"0.5420026",
"0.5418955",
"0.5411543",
"0.5388563",
"0.5351763",
"0.53286916",
"0.530672",
"0.5303137",
"0.5289109",
"0.5276351",
"0.5273676",
"0... | 0.6863215 | 0 |
Set the weights of graph (``networkx.DiGraph``) as the cosine similarity between ``graph.graph['tfidf']]`` vectors of nodes. | def set_weights(graph):
vecs = graph.graph['tfidf']
for n1, n2 in graph.edges:
v1 = vecs[:,list(graph.nodes).index(n1)].transpose()
v2 = vecs[:,list(graph.nodes).index(n2)].transpose()
graph[n1][n2]['weight'] = smp.cosine_similarity(X=v1, Y=v2)[0,0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_weight_tf(index_utils, graph, node, node_name):\n tf = tf_score(node, graph.nr_nodes())\n nr_documents = index_utils.stats()[\"documents\"]\n\n if node.node_type == \"term\":\n # term --> return tfidf\n filtered_term = utils.clean_NE_term(node_name)\n df = index_utils.get_ter... | [
"0.5976922",
"0.5623886",
"0.55290174",
"0.55122125",
"0.5466464",
"0.5401006",
"0.5334145",
"0.5324023",
"0.5261086",
"0.52610046",
"0.52597946",
"0.525758",
"0.52434456",
"0.5241329",
"0.52203876",
"0.5211625",
"0.51853",
"0.51673824",
"0.5161811",
"0.51409906",
"0.5133531"... | 0.8788405 | 0 |
Initialize your minimax model | def initialize_model(self, initial_data):
# EDIT THIS METHOD TO RETURN A MINIMAX MODEL ###
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, model, patience: int): # , maximise: bool):\n self.patience = patience\n # self.maximise = maximise\n self.model_state_dict = None\n self.model = model\n self.saved_epoch = 0\n self.scores = []\n self.min_score = float(\"inf\")",
"def initializ... | [
"0.6737955",
"0.63457155",
"0.6237764",
"0.62018657",
"0.6194111",
"0.6165867",
"0.6163512",
"0.6145286",
"0.6131634",
"0.61186785",
"0.61160356",
"0.61079365",
"0.6104674",
"0.6091995",
"0.6078375",
"0.6057484",
"0.60304254",
"0.6027806",
"0.6002429",
"0.5989204",
"0.5984984... | 0.65499306 | 1 |
Calculate zero rates at times | def getZeros(self, times):
T = convertTimes(times = times, log = self.log)
T[T == 0.] = 1.e-16 # replace by epsilon to allow division
return -self.getLnDisc(times = T)/T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_zero_rates(self):\r\n self.__bootstrap_zero_coupons__()\r\n self.__get_bond_spot_rates__()\r\n return [self.zero_rates[T] for T in self.get_maturities()]",
"def test_result_zero(self, rate, n, init_wealth, n_bars):\n series_wealth = init_wealth + np.zeros(n_bars)\n resu... | [
"0.7226655",
"0.66580045",
"0.6550657",
"0.65249866",
"0.628569",
"0.6077306",
"0.59705204",
"0.59179354",
"0.58566296",
"0.5823429",
"0.58169466",
"0.5795331",
"0.57866067",
"0.57850724",
"0.57492954",
"0.56803024",
"0.56468993",
"0.5581997",
"0.55341893",
"0.5526146",
"0.55... | 0.66041106 | 2 |
returns the location of the agent in current world | def get_location(self):
return self.location | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_location(self):\n return self.enu_2_local()",
"def get_location(self):\n\t\treturn self.location",
"def my_location(state):\n return state['gladiators'][state['current_player']]['pos']",
"def get_location(self):\n return self.location",
"def get_location(self):\r\n r... | [
"0.7479693",
"0.7316228",
"0.71619517",
"0.7131864",
"0.70879245",
"0.7036751",
"0.6999459",
"0.6953448",
"0.6909283",
"0.6885189",
"0.6811549",
"0.68051416",
"0.68051416",
"0.6779158",
"0.6751021",
"0.6751021",
"0.6751021",
"0.6751021",
"0.6751021",
"0.6751021",
"0.6751021",... | 0.6889657 | 9 |
returns agent's last action | def last_move(self):
return self.last_action | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_action(self):\n return self.a_",
"def getAction(self):\n HistoryAgent.getAction(self)\n \n self.lastaction = self.module.activate(self.lastobs).copy()\n self.module.backward()\n self.loglh = self.module.derivs.copy()\n \n d = self.module.derivs... | [
"0.8461964",
"0.7293331",
"0.7201097",
"0.7097",
"0.6827284",
"0.67422307",
"0.67221457",
"0.6719178",
"0.67005867",
"0.663944",
"0.6607351",
"0.65623075",
"0.65256834",
"0.65153825",
"0.65148175",
"0.6511475",
"0.6506838",
"0.65067035",
"0.6499792",
"0.6492769",
"0.6467208",... | 0.78556544 | 1 |
Returns a list of Model.curriculum_json() from a collection. | def list_map_curriculum(collection: list) -> list:
return list(map(lambda item: check_curriculum_json(item), collection)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allCategoriesJSON():\n categories = db_session.query(Category).all()\n return jsonify(categories=[c.serialize for c in categories])",
"def getCategoriesJSON():\r\n categories = session.query(Category).all()\r\n return jsonify(Categories=[c.serialize for c in categories])",
"def collections():\n... | [
"0.61630845",
"0.61355174",
"0.61320204",
"0.60396653",
"0.6039583",
"0.60313666",
"0.6025524",
"0.6000824",
"0.58961713",
"0.58393115",
"0.5768227",
"0.5747838",
"0.5722727",
"0.5701377",
"0.56928575",
"0.5538361",
"0.5528969",
"0.5515996",
"0.5511781",
"0.5489658",
"0.54846... | 0.6822574 | 0 |
Return the default parameters to use for this instrument. | def default_pypeit_par(cls):
par = super().default_pypeit_par()
# Wavelengths
# 1D wavelength solution with OH lines
par['calibrations']['wavelengths']['rms_threshold'] = 1.0
par['calibrations']['wavelengths']['sigdetect']=[5,10,10,10,10,20,30,30,30,30,30,10,30,30,60,30,30,10,20... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _default_params(self) -> dict[str, Any]:\n return {\n \"max_tokens\": self.max_tokens,\n \"temperature\": self.temperature,\n \"top_p\": self.top_p,\n \"logprobs\": self.logprobs,\n \"echo\": self.echo,\n \"stop_sequences\": self.stop_seq... | [
"0.7805762",
"0.7763104",
"0.7677062",
"0.76613677",
"0.76345515",
"0.7562868",
"0.7504112",
"0.730552",
"0.7289221",
"0.7286193",
"0.7200711",
"0.7171834",
"0.7141095",
"0.7116199",
"0.71101665",
"0.70824164",
"0.7082395",
"0.7082248",
"0.7058412",
"0.70473176",
"0.6971215",... | 0.0 | -1 |
Return the logarithmic step in wavelength for output spectra. | def dloglam(self):
# This number was determined using the resolution and sampling quoted on the FIRE website
R = 6000.0 * 2.7
dloglam = 1.0 / R / np.log(10.0)
return dloglam | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_log_wavelength(self):\n\n if self.unit == 'f_loglam':\n raise ValueError('Spectrum is already in logarithmic wavelength')\n\n elif self.unit == 'f_lam':\n self.flux = self.flux * self.dispersion\n self.dispersion = np.log(self.dispersion)\n\n elif self.u... | [
"0.7493847",
"0.7087096",
"0.69903374",
"0.66377324",
"0.65416306",
"0.63977396",
"0.63820463",
"0.6293249",
"0.62568474",
"0.6239293",
"0.6225839",
"0.6225839",
"0.62053424",
"0.62026006",
"0.61853015",
"0.61137426",
"0.61019605",
"0.6093712",
"0.60872555",
"0.60847926",
"0.... | 0.6626822 | 4 |
Return the default parameters to use for this instrument. | def default_pypeit_par(cls):
par = super().default_pypeit_par()
# Wavelengths
# 1D wavelength solution with arc lines
par['calibrations']['wavelengths']['rms_threshold'] = 1.0
par['calibrations']['wavelengths']['sigdetect']=3
par['calibrations']['wavelengths']['fwhm'] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _default_params(self) -> dict[str, Any]:\n return {\n \"max_tokens\": self.max_tokens,\n \"temperature\": self.temperature,\n \"top_p\": self.top_p,\n \"logprobs\": self.logprobs,\n \"echo\": self.echo,\n \"stop_sequences\": self.stop_seq... | [
"0.7805762",
"0.7763104",
"0.7677062",
"0.76613677",
"0.76345515",
"0.7562868",
"0.7504112",
"0.730552",
"0.7289221",
"0.7286193",
"0.7200711",
"0.7171834",
"0.7141095",
"0.7116199",
"0.71101665",
"0.70824164",
"0.7082395",
"0.7082248",
"0.7058412",
"0.70473176",
"0.6971215",... | 0.0 | -1 |
Ensures a ValueError is thrown if an invalid cleaning style is passed in. | def test_invalid_cleaning_style(currency_df):
with pytest.raises(ValueError):
currency_df.currency_column_to_numeric(
"a_col", cleaning_style="foobar"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lint_fail_malformed(self, style):\n with ExpectedException(LinterFailure):\n run_linter_throw(\"path/to/file\",\n \"{s}\\n{m} Text{e}\",\n style,\n whitelist=[\"headerblock/desc_space\"])",
"def test_va... | [
"0.59218323",
"0.56287014",
"0.5581485",
"0.5542612",
"0.55204904",
"0.5510286",
"0.5442022",
"0.5440427",
"0.54214877",
"0.5411682",
"0.53685945",
"0.5356265",
"0.5342053",
"0.5315057",
"0.5281827",
"0.52361107",
"0.5232657",
"0.5225366",
"0.52174765",
"0.52042294",
"0.51633... | 0.6867292 | 0 |
Convert an numpy representation image to Image protobuf | def make_image(tensor):
from PIL import Image
if len(tensor.shape) == 4:
_, height, width, channel = tensor.shape
elif len(tensor.shape) == 3:
height, width, channel = tensor.shape
elif len(tensor.shape) == 2:
height, width = tensor.shape
channel = 1
tensor = tensor.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_proto_to_image(image_pb: NLImage) -> np.ndarray:\n input_array = np.frombuffer(image_pb.data, dtype=np.uint8)\n dimensions = [image_pb.height, image_pb.width]\n if image_pb.color:\n dimensions.append(3)\n input_image = input_array.reshape(dimensions)\n return input_image",
"def ... | [
"0.8226601",
"0.7897594",
"0.6929633",
"0.670019",
"0.6560244",
"0.65142274",
"0.6463379",
"0.64408094",
"0.6419978",
"0.6419778",
"0.64189965",
"0.6313256",
"0.6307196",
"0.6275541",
"0.62635785",
"0.6239375",
"0.6237469",
"0.6229509",
"0.61961174",
"0.6191846",
"0.6188482",... | 0.0 | -1 |
Sets the line_alignment of this StringFormatData. | def line_alignment(self, line_alignment):
allowed_values = ["Near", "Center", "Far"] # noqa: E501
if not line_alignment.isdigit():
if line_alignment not in allowed_values:
raise ValueError(
"Invalid value for `line_alignment` ({0}), must be one of {1}" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_line_alignment(self, alignment, line_no):\n self.change_alignment_for_a_line(alignment, line_no)\n return self",
"def SetAlignment(self, l):\r\n\r\n self.alignment = l",
"def change_alignment_for_a_line(self, alignment, line_no):\n self.lines[1][line_no] = alignment\n ... | [
"0.79749227",
"0.7050633",
"0.6972697",
"0.6823073",
"0.6379708",
"0.63768065",
"0.62209624",
"0.6153149",
"0.5897558",
"0.5778309",
"0.57146305",
"0.56486166",
"0.56142867",
"0.5606152",
"0.5605471",
"0.5605471",
"0.557022",
"0.54843247",
"0.54812396",
"0.54786867",
"0.54595... | 0.7714295 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, StringFormatData):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Calculates values of contingency table marginals from its values. | def _marginals(*contingency):
raise NotImplementedError("The contingency table is not available"
"in the general ngram case") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_marginal(self, variable):\n from bn.distribs.distribution_builder import CategoricalTableBuilder\n marginal = CategoricalTableBuilder(variable)\n\n for row in self.get_values():\n prob = self._table.get(row)\n if prob > 0.:\n marginal.add_row(row.ge... | [
"0.65448076",
"0.6421941",
"0.6377883",
"0.6342417",
"0.6014765",
"0.5994637",
"0.59599924",
"0.59231114",
"0.5904534",
"0.583836",
"0.581722",
"0.57512474",
"0.5741737",
"0.5714252",
"0.57047415",
"0.5623585",
"0.56032014",
"0.5584019",
"0.55352485",
"0.55305654",
"0.5527665... | 0.6731085 | 0 |
Use the expected likelihood estimate to create a probability distribution for the experiment used to generate ``freqdist``. | def __init__(self, freqdist, bins=None):
LidstoneProbDist.__init__(self, freqdist, 0.5, bins) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, freqdist):\n assert _chktype(1, freqdist, FreqDist)\n\n self._freqdist = freqdist\n ### B*N/(B+N) approximates the count of the unseen words in a kinda Witten-Bell like way\n self._freqdist.inc('$UNKNOWN$',self._freqdist.B()*self._freqdist.N()/(self._freqdist.N()+self... | [
"0.63154405",
"0.6058339",
"0.5956301",
"0.5889322",
"0.58733606",
"0.58424205",
"0.5738549",
"0.56600887",
"0.55943614",
"0.55705047",
"0.5547784",
"0.5542658",
"0.55276763",
"0.5522444",
"0.550945",
"0.5501418",
"0.54811126",
"0.54495364",
"0.5449473",
"0.5441642",
"0.54332... | 0.6063547 | 1 |
Return a string representation of this ``ProbDist``. | def __repr__(self):
return '<ELEProbDist based on %d samples>' % self._freqdist.N() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n prob = str(round(self.probability, 5))\n dprob = str(round(self.postdProbability, 5))\n output = \"dprob: \" + dprob + \" \\tprob: \" + prob + \"\\t: \"\n for key in self.attackDict.keys():\n output += key + \" \"\n return output",
"def __str__(self):\n return (st... | [
"0.73700964",
"0.7327288",
"0.7284532",
"0.7249286",
"0.7223584",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
"0.72153014",
... | 0.0 | -1 |
Test that items with a simple union property deserializes. | def test_union_simple():
valid_test_cases = [
{"one": 1},
{"one": "1"},
]
invalid_test_cases = [
{"one": 3.1415},
{"one": None},
{"one": BasicUnionClass()},
]
for test_case in valid_test_cases:
instance = deserialize.deserialize(BasicUnionClass, test... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_union():\n\n valid_test_cases = [\n {\"one\": 1, \"two\": 2, \"three\": 3},\n {\"one\": 1, \"two\": \"2\", \"three\": 3},\n {\"one\": \"1\", \"two\": 2, \"three\": 3},\n {\"one\": \"1\", \"two\": \"2\", \"three\": 3},\n {\"one\": 1, \"two\": 2, \"three\": None},\n ... | [
"0.7488148",
"0.6653085",
"0.65819937",
"0.63366824",
"0.5972224",
"0.58781177",
"0.58326125",
"0.580162",
"0.57115126",
"0.5660082",
"0.5638931",
"0.56364965",
"0.5619064",
"0.5604353",
"0.55956984",
"0.55815804",
"0.5555937",
"0.5544328",
"0.55204266",
"0.55160135",
"0.5498... | 0.7904497 | 0 |
Test that items with union properties deserializes. | def test_union():
valid_test_cases = [
{"one": 1, "two": 2, "three": 3},
{"one": 1, "two": "2", "three": 3},
{"one": "1", "two": 2, "three": 3},
{"one": "1", "two": "2", "three": 3},
{"one": 1, "two": 2, "three": None},
{"one": 1, "two": "2", "three": None},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_union_simple():\n valid_test_cases = [\n {\"one\": 1},\n {\"one\": \"1\"},\n ]\n\n invalid_test_cases = [\n {\"one\": 3.1415},\n {\"one\": None},\n {\"one\": BasicUnionClass()},\n ]\n\n for test_case in valid_test_cases:\n instance = deserialize.des... | [
"0.7645374",
"0.6449052",
"0.6432911",
"0.61877793",
"0.6033475",
"0.58758175",
"0.5848756",
"0.5798526",
"0.5798007",
"0.5717057",
"0.5703102",
"0.56958264",
"0.56921417",
"0.566025",
"0.564898",
"0.56430227",
"0.5603495",
"0.5569083",
"0.5547235",
"0.552055",
"0.5485514",
... | 0.75959176 | 1 |
Draws a spiral with a given tartle object (t) Starting point is random Color is random blue Width is random | def spirala(t):
t.penup()
t.setx(random.randrange(-200,200))
t.sety(random.randrange(-200,200))
t.pencolor(random.randrange(0,255),random.randrange(0,255),200)
t.width(random.randrange(2,13))
t.pendown()
for i in range(120):
t.forward(20+i)
t.left(30 - i/1.5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_spiral(t):\r\n\r\n colors = [\"red\", \"orange\", \"yellow\", \"green\", \"blue\", \"purple\"]\r\n\r\n for x in range(400):\r\n c = colors[x % 6]\r\n t.pencolor(c)\r\n\r\n t.forward(x)\r\n t.left(59)",
"def spiralaa(x,y):\n #print('inside')\n #turtle.setx(x)\n ... | [
"0.8532208",
"0.73737293",
"0.73475784",
"0.71637094",
"0.7064557",
"0.68535894",
"0.661409",
"0.65896684",
"0.6453537",
"0.6441009",
"0.63928133",
"0.63774896",
"0.636377",
"0.6340896",
"0.6217609",
"0.6188141",
"0.6159667",
"0.6159667",
"0.61413157",
"0.61248314",
"0.610954... | 0.73922867 | 1 |
Draws a spiral with a given tartle object (t) Starting point is random Color is random blue Width is random | def spiralaa(x,y):
#print('inside')
#turtle.setx(x)
#turtle.sety(y)
#t.pendown()
turtle.home()
# Random color
turtle.pencolor(random.randrange(0,255),random.randrange(0,255),200)
# Random width
turtle.width(random.randrange(2,13))
# Random dire... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_spiral(t):\r\n\r\n colors = [\"red\", \"orange\", \"yellow\", \"green\", \"blue\", \"purple\"]\r\n\r\n for x in range(400):\r\n c = colors[x % 6]\r\n t.pencolor(c)\r\n\r\n t.forward(x)\r\n t.left(59)",
"def spirala(t):\n t.penup()\n t.setx(random.randrange(-200,20... | [
"0.8531522",
"0.73929274",
"0.73464626",
"0.71629775",
"0.7061303",
"0.6851696",
"0.6615585",
"0.658733",
"0.6454293",
"0.6441142",
"0.63940364",
"0.63777053",
"0.6362774",
"0.6338176",
"0.6216455",
"0.61881834",
"0.61576253",
"0.61576253",
"0.6141355",
"0.6122811",
"0.610910... | 0.7370991 | 2 |
Apply a DeltaY transformation to a given triangle of G. | def DeltaYTrans(G, triangle):
a, b, c = triangle
G = G.copy()
G.delete_edges([(a, b), (b, c), (c, a)])
v = G.order()
G.add_edges([(a, v), (b, v), (c, v)])
return G.canonical_label() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def YDeltaTrans(G, v):\n G = G.copy()\n a, b, c = G.neighbors(v)\n G.delete_vertex(v)\n G.add_cycle([a, b, c])\n return G.canonical_label()",
"def dphi(x):\n return grad(phi)(x)",
"def _dy(self, T):\n return self._h(np.diff(T)) * self._a / self._m / self._c * np... | [
"0.585367",
"0.5800146",
"0.5778132",
"0.56374407",
"0.55930173",
"0.55769867",
"0.5530593",
"0.54592",
"0.544769",
"0.54330635",
"0.53295517",
"0.5322159",
"0.52585864",
"0.52553797",
"0.5251277",
"0.524976",
"0.5246614",
"0.5242066",
"0.5204973",
"0.5168935",
"0.5156828",
... | 0.7867547 | 0 |
Apply a YDelta transformation to a given vertex v of G. | def YDeltaTrans(G, v):
G = G.copy()
a, b, c = G.neighbors(v)
G.delete_vertex(v)
G.add_cycle([a, b, c])
return G.canonical_label() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeltaYTrans(G, triangle):\n a, b, c = triangle\n G = G.copy()\n G.delete_edges([(a, b), (b, c), (c, a)])\n v = G.order()\n G.add_edges([(a, v), (b, v), (c, v)])\n return G.canonical_label()",
"def LD_Vx_Vy(self, x, y):\n\t\tself.V[x] = self.V[y]",
"def vector_trans... | [
"0.5756971",
"0.5423134",
"0.53880703",
"0.5296961",
"0.52598196",
"0.52283907",
"0.5200139",
"0.5178948",
"0.51686203",
"0.51538736",
"0.510383",
"0.50428915",
"0.5037406",
"0.50129",
"0.49869114",
"0.49469376",
"0.4933664",
"0.49244413",
"0.4921037",
"0.4846723",
"0.4844762... | 0.77994007 | 0 |
Returns a Wheel graph with n nodes. A Wheel graph is a basic structure where one node is connected to all other nodes and those (outer) nodes are connected cyclically. This constructor depends on NetworkX numeric labels. | def WheelGraph(n):
pos_dict = {}
pos_dict[0] = (0,0)
for i in range(1,n):
x = float(cos((pi/2) + ((2*pi)/(n-1))*(i-1)))
y = float(sin((pi/2) + ((2*pi)/(n-1))*(i-1)))
pos_dict[i] = (x,y)
import networkx
G = networkx.wheel_graph(n)
return Graph(G, pos=pos_dict, name="Wheel ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete_graph(n):\n return wgraph_from_adjacency(np.ones((n, n)))",
"def disconnected_graph(n):\n g = nx.DiGraph()\n for i in range(0, n):\n g.add_node(i)\n return g",
"def create_ring_lattice(self, n: int, k: int) -> nx.Graph:\n graph = nx.Graph()\n nodes = tuple(range(n)... | [
"0.6718892",
"0.6513083",
"0.6391693",
"0.626701",
"0.60785466",
"0.60180026",
"0.6015612",
"0.5982759",
"0.5920652",
"0.5908803",
"0.5893314",
"0.5868521",
"0.58659035",
"0.58532166",
"0.58408165",
"0.57590723",
"0.57524616",
"0.57473785",
"0.5735271",
"0.56783754",
"0.56765... | 0.80530113 | 0 |
r""" Return the ringed tree on klevels. A ringed tree of level `k` is a binary tree with `k` levels (counting the root as a level), in which all vertices at the same level are connected by a ring. More precisely, in each layer of the binary tree (i.e. a layer is the set of vertices `[2^i...2^{i+1}1]`) two vertices `u,v... | def RingedTree(k, vertex_labels = True):
if k<1:
raise ValueError('The number of levels must be >= 1.')
from sage.graphs.graph_plot import _circle_embedding
# Creating the Balanced tree, which contains most edges already
g = BalancedTree(2,k-1)
g.name('Ringed Tree on '+str(k)+' levels')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_kdtree(points, depth=0):\n n = len(points) - 1\n\n if n <= 0:\n return None\n\n axis = depth % k\n\n sorted_points = sorted(points, key=lambda point: point[axis])\n\n return {\n 'point': sorted_points[n / 2],\n 'left': build_kdtree(sorted_points[:n / 2], depth + 1),\n ... | [
"0.61119753",
"0.61119753",
"0.58470166",
"0.57172436",
"0.57138646",
"0.5677505",
"0.5654784",
"0.5628402",
"0.5593826",
"0.55354047",
"0.5529132",
"0.54350376",
"0.5416871",
"0.54154575",
"0.5409094",
"0.54012865",
"0.5397651",
"0.53716016",
"0.5343481",
"0.53078634",
"0.52... | 0.7533576 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ApiBuildDetails):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Testing endpoint if flask is working | def ping():
return jsonify({'response': 'pong'}), 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_helloworld():\n with app.test_client() as c:\n response = c.get('/')\n assert response.status_code == 200",
"def test_index():\n\n with flask_app.test_client() as client:\n response = client.get(\"/\")\n assert response.status_code == 200\n assert b\"milhouse... | [
"0.7372463",
"0.7322876",
"0.6990144",
"0.69734716",
"0.6971341",
"0.68920416",
"0.6849844",
"0.6785656",
"0.67743945",
"0.67691183",
"0.67686504",
"0.6766635",
"0.67289954",
"0.6726423",
"0.66964626",
"0.66803503",
"0.6639498",
"0.66294736",
"0.66293174",
"0.660206",
"0.6588... | 0.0 | -1 |
Creates a normal distribution | def __call__(self, *args, **kwargs):
return tfd.Normal(loc=self.mu, scale=tf.eye(self.size)), self.mu | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_standard_normal_distribution():\n return np.random.normal(0, 1)",
"def _gen_normal(self, count, **kwargs):\n normal = scipy.stats.norm(loc=kwargs['mean'], scale=kwargs['stdev'])\n rvs = normal.rvs(count)\n return rvs",
"def normal(mean, std):\n\n return random.gauss(m... | [
"0.79006064",
"0.7616657",
"0.7550172",
"0.7503223",
"0.74515957",
"0.7332067",
"0.73073775",
"0.7253977",
"0.7214759",
"0.7188729",
"0.71860707",
"0.7050024",
"0.6998059",
"0.69644165",
"0.6880078",
"0.68568313",
"0.68504125",
"0.6830572",
"0.6807997",
"0.6807997",
"0.680799... | 0.0 | -1 |
Updating bullet position and cleaning up offscreen bullets | def update_bullets(bullets, settings, dbags, stats, scoreboard):
# Position
bullets.update()
# Detect bullet dbag collisions and remove both
collisions = pygame.sprite.groupcollide(bullets, dbags, True, True)
if collisions:
for aliens in collisions.values():
stats.game_score += len(aliens) * settings.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_bullet(self):\n\n # update position of old bullets\n self.bullets.update()\n\n # Get rid of bullets that are off screen\n for bullet in self.bullets.copy():\n if bullet.rect.left >= self.screen_width:\n self.bullets.remove(bullet)\n\n # see i... | [
"0.80964524",
"0.77866817",
"0.7721283",
"0.7681616",
"0.761185",
"0.757912",
"0.75648457",
"0.7489411",
"0.7452929",
"0.7303895",
"0.724602",
"0.7227357",
"0.72142315",
"0.7198151",
"0.71565586",
"0.70439506",
"0.70351493",
"0.6929909",
"0.6900306",
"0.67736936",
"0.6687867"... | 0.7208566 | 13 |
Gets queryset of Character objects | def get_queryset(self):
return ObjectDB.objects.filter(roster__roster__name=self.roster_name).order_by(
"db_key"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self, request):\n qs = super(CharacterValuesInline, self).get_queryset(request)\n qs = qs.filter(character__value_type='TEXT')\n return qs",
"def fetch_all_characters(cls) -> Dict[str, Any]:\n res = cls._send_request(\"character\")\n return res",
"def get_que... | [
"0.632586",
"0.6316752",
"0.6271068",
"0.6207162",
"0.6107626",
"0.6107626",
"0.6107626",
"0.59277385",
"0.59139544",
"0.5883869",
"0.5850454",
"0.5787711",
"0.57826006",
"0.5752896",
"0.5744132",
"0.5729064",
"0.57013",
"0.57013",
"0.5685609",
"0.56810755",
"0.56758875",
"... | 0.5140714 | 62 |
Gets queryset of crises visible to user | def viewable_crises(self):
from world.dominion.plots.models import Plot
return Plot.objects.viewable_by_player(self.request.user).filter(
chapter__in=self.get_queryset()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return Reserva.objects.filter(\n cliente=self.request.user)",
"def get_queryset(self):\n user = self.request.user\n return Beer.objects.filter(owner=user)",
"def visible(self):\n return self.get_queryset().filter(\n record_status=s... | [
"0.65413004",
"0.62252325",
"0.62067497",
"0.6198121",
"0.619654",
"0.61939687",
"0.6176374",
"0.61623436",
"0.6120976",
"0.61065656",
"0.60476834",
"0.604131",
"0.60259753",
"0.60153306",
"0.6008934",
"0.6005143",
"0.60013986",
"0.5999659",
"0.59719354",
"0.5967511",
"0.5949... | 0.71511406 | 0 |
remove zeros from input list nums and returns a list | def rzeros(nums):
total = len(nums)
zeros = 0
nozeros = []
for x in nums:
if x != 0:
nozeros.append(x)
else:
zeros = zeros + 1
return (nozeros, total - zeros, zeros) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moveZeroes(self, nums: List[int]) -> None:\n count = 0\n ans = []\n for num in nums:\n if num != 0:\n ans.append(num)\n else:\n count += 1\n for zero in range(count):\n ans.append(0)\n return ans",
"def moveZero... | [
"0.7754822",
"0.74741715",
"0.73266304",
"0.7300468",
"0.726975",
"0.72468483",
"0.7241793",
"0.7175091",
"0.71160793",
"0.70926416",
"0.70689934",
"0.70519006",
"0.7049651",
"0.70161",
"0.70151573",
"0.7012215",
"0.69244623",
"0.69103646",
"0.6867549",
"0.6850669",
"0.684713... | 0.6731986 | 29 |
Write ZCL attribute to device. | def write_zcl_attribute(devCtrl, cluster: str, attribute: str, nodeId: int, endpoint: int, value):
res = None
err = 0
try:
allAttrs = devCtrl.ZCLAttributeList()
if cluster not in allAttrs:
raise exceptions.UnknownCluster(cluster)
attrDetails = allAttrs.get(cluster).get(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attr(zone, attr, line):\n zone.set_attr(attr, line[attr])",
"def read_zcl_attribute(devCtrl, cluster: str, attribute: str, nodeId: int, endpoint: int):\n res = None\n err = 0\n try:\n allAttrs = devCtrl.ZCLAttributeList()\n if cluster not in allAttrs:\n raise exce... | [
"0.59143525",
"0.5742964",
"0.57335114",
"0.55635786",
"0.55037254",
"0.5486111",
"0.5436843",
"0.5400249",
"0.5362732",
"0.5317275",
"0.52600807",
"0.5219653",
"0.521079",
"0.5195303",
"0.5145787",
"0.51433784",
"0.51367813",
"0.5131351",
"0.5130464",
"0.5125153",
"0.5125153... | 0.73363155 | 0 |
Test that by default, completely empty url values are allowed | def test_is_valid_manifest_format_with_empty_url(caplog):
result = is_valid_manifest_format(
"tests/validate_manifest_format/manifests/manifest_with_empty_url.tsv",
)
assert caplog.text == ""
assert result == True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_url(self):\n pass",
"def test_non_urls():\n assert normalize_url(\"\") is None\n assert normalize_url(\"abc xyz\") is None\n assert normalize_url(\"asb#abc\") is None\n assert normalize_url(\"Яндекс.рф\") is not None\n assert normalize_url(\"google.blog\") is not None\n asse... | [
"0.74157834",
"0.72275394",
"0.7219132",
"0.71249086",
"0.70876473",
"0.7037901",
"0.70310265",
"0.70058775",
"0.69733536",
"0.68008894",
"0.6760697",
"0.6755672",
"0.6665654",
"0.66611177",
"0.66579634",
"0.6648906",
"0.66263205",
"0.6572682",
"0.65497243",
"0.6544601",
"0.6... | 0.0 | -1 |
Test that completely missing size column is detected and reported in error log | def test_is_valid_manifest_with_missing_size_column(caplog):
result = is_valid_manifest_format(
"tests/validate_manifest_format/manifests/manifest_with_missing_size_column.tsv",
)
missing_size_message = (
'could not find a column name corresponding to required "Columns.SIZE"'
)
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_num_columns(self):\n pass",
"def test_errors(self):\n self.assertRaises(TypeError, columnize, 5, 'reject input - not array')\n return",
"def test_too_many_cols1():\n text = dedent(\n \"\"\"\n A B C\n 1 2 3\n 4 5 6\n 7 8 9 10\n 11 12 13\n \"\"\"\n )\n... | [
"0.69683856",
"0.6851017",
"0.68202066",
"0.66601074",
"0.6651312",
"0.6647557",
"0.6627167",
"0.6597451",
"0.63647574",
"0.636252",
"0.63615775",
"0.63447803",
"0.63332015",
"0.6330652",
"0.63228285",
"0.62817943",
"0.6280158",
"0.6266968",
"0.6239067",
"0.62319374",
"0.6212... | 0.66481894 | 5 |
Generates jwt tokens for testing purpose | def generate_token(exp=None):
secret_key = getenv('JWT_SECRET_KEY')
user = {
'first_name': fake.name(),
'last_name': fake.name(),
'email': fake.email(),
'is_admin': IsAdmin.yes,
'password': fake.password()
}
payload = {'id': str(User.find_or_create(user, email=u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_jwt_token(self):\n import jwt\n from datetime import datetime, timedelta\n from django.conf import settings\n\n dt = datetime.now() + timedelta(days=60)\n\n token = jwt.encode({\n 'id': self.pk,\n 'username': self.username,\n 'exp': ... | [
"0.7670267",
"0.7621497",
"0.76110476",
"0.7584536",
"0.73802036",
"0.7214288",
"0.7207798",
"0.7143483",
"0.7127217",
"0.70886004",
"0.70051503",
"0.69771886",
"0.69413775",
"0.6931876",
"0.6920954",
"0.69002753",
"0.6861252",
"0.6839348",
"0.68309265",
"0.67779905",
"0.6766... | 0.6675631 | 21 |
Given an argument that's either a string or a list of strings, return either a list with the string or the unmodified list. | def listify(arg):
if isinstance(arg, list):
return arg
else:
return [arg] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_list(arg):\n if _is_list(arg):\n return arg\n return [arg]",
"def str_or_list(value):\n if isinstance(value, list):\n return value\n return [value]",
"def process_list_arg(arg):\n if isinstance(arg, list):\n return arg\n elif isinstance(arg, basestring):\n a... | [
"0.7870838",
"0.76046187",
"0.75769836",
"0.74634093",
"0.7280125",
"0.71984303",
"0.70810795",
"0.7066956",
"0.70175314",
"0.70072824",
"0.69570756",
"0.69154006",
"0.6861279",
"0.6730067",
"0.6727405",
"0.6706853",
"0.668337",
"0.661907",
"0.6554379",
"0.6535319",
"0.653508... | 0.8100695 | 0 |
Deletes the records that have indexed address fields that fall within the given range. Uses the address map to convert the address range into 1 or more key ranges. (Address ranges may not be continuous after converting to long space). | def deleteRecords(table: db.Table, colIx: int, addrMap: ghidra.program.database.map.AddressMap, start: ghidra.program.model.address.Address, end: ghidra.program.model.address.Address, filter: ghidra.program.database.util.RecordFilter) -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteAddressRange(self, start: ghidra.program.model.address.Address, end: ghidra.program.model.address.Address, monitor: ghidra.util.task.TaskMonitor) -> None:\n ...",
"def deleteRecords(table: db.Table, addrMap: ghidra.program.database.map.AddressMap, start: ghidra.program.model.address.Address, end... | [
"0.70232767",
"0.65857506",
"0.5648791",
"0.55734104",
"0.5347719",
"0.5291572",
"0.52802646",
"0.52778846",
"0.5267992",
"0.5259169",
"0.52532387",
"0.524792",
"0.52428156",
"0.5169019",
"0.5165104",
"0.5163443",
"0.50623786",
"0.5005855",
"0.49559483",
"0.48858702",
"0.4884... | 0.6511686 | 2 |
take 1D float array of rewards and compute discounted reward | def discounted_rewards(r, gamma):
discounted_r = np.zeros_like(r)
running_sum = 1
for i in reversed(range(0,len(r))):
discounted_r[i] = running_sum * r[i]
running_sum = discounted_r[i]
return list(discounted_r) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discount_rewards(rewards):\r\n discounted_r = np.zeros_like(rewards)\r\n running_add = 0\r\n for t in reversed(range(0, len(rewards))): \r\n running_add = running_add * reward_discount + rewards[t]\r\n discounted_r[t] = running_add\r\n return discounted_r",
"def discoun... | [
"0.8100923",
"0.78397125",
"0.7792625",
"0.7742053",
"0.7653779",
"0.75987715",
"0.7583268",
"0.75820553",
"0.7579539",
"0.7536054",
"0.7519005",
"0.75047183",
"0.7467692",
"0.7456702",
"0.7433794",
"0.7426565",
"0.74062765",
"0.73950297",
"0.7370545",
"0.73564714",
"0.732851... | 0.699616 | 27 |
Transforms all whitespaces to '__' | def underscore(text):
# return '__'+text.replace(' ','__') + '__'
return text.replace(' ', '__') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unscorize(s):\n return s.replace(\" \", \"_\")",
"def descorize(s):\n return s.replace(\"_\", \" \")",
"def pre_underscore(text):\n return f\"__{text}__\"",
"def normalize(item):\n item = item.lower().strip().rstrip('_')\n return item",
"def sanitize(s):\n s = s.replace(\"_\",... | [
"0.7199742",
"0.69762504",
"0.6920799",
"0.68958604",
"0.6893941",
"0.6801768",
"0.67126185",
"0.6624194",
"0.6595911",
"0.65062135",
"0.6503099",
"0.6477841",
"0.6430283",
"0.6379816",
"0.63594973",
"0.6350791",
"0.63263345",
"0.6237142",
"0.62154305",
"0.6175146",
"0.614563... | 0.7582222 | 0 |
Adds "__" at the beginning and the end | def pre_underscore(text):
return f"__{text}__" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscore(text):\n # return '__'+text.replace(' ','__') + '__'\n return text.replace(' ', '__')",
"def add_double_mash(line):\n return '## %s' % line",
"def generate_rename_direct(self, prefix):\n return \"#define %s%s %s\" % (prefix, self.__name, self.__rename)",
"def _with_underscore(cls, ... | [
"0.68895334",
"0.6093519",
"0.59684664",
"0.58302426",
"0.5791327",
"0.57899594",
"0.57772505",
"0.57772505",
"0.57732666",
"0.5747939",
"0.56885666",
"0.56879616",
"0.5676266",
"0.5588613",
"0.5565246",
"0.55352026",
"0.55073047",
"0.54364276",
"0.5421308",
"0.5361941",
"0.5... | 0.700092 | 0 |
Compute the average precision, given the recall and precision curves. | def compute_ap(recall, precision):
# correct AP calculation
# first append sentinel values at the end
mrec = np.concatenate(([0.], recall, [1.]))
mpre = np.concatenate(([0.], precision, [0.]))
# compute the precision envelope
for i in range(mpre.size - 1, 0, -1):
mpre[i - 1] = np.maximu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ... | [
"0.836952",
"0.81346226",
"0.7751113",
"0.77245736",
"0.7717672",
"0.7692633",
"0.76912516",
"0.76259345",
"0.7558349",
"0.75363964",
"0.7475437",
"0.7272525",
"0.7250063",
"0.7227905",
"0.72088754",
"0.7200133",
"0.7182856",
"0.7160525",
"0.7129954",
"0.7086959",
"0.70641106... | 0.76490915 | 7 |
Set a new name | def setName(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, newname=\"\"):\n self.name = newname",
"def new_name(self,new_name):\n self.name = new_name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n self.name = name # overwrite the existi... | [
"0.91213536",
"0.9042617",
"0.8880091",
"0.8880091",
"0.8784002",
"0.87088794",
"0.87088794",
"0.86480236",
"0.8599288",
"0.8599288",
"0.8599288",
"0.8599288",
"0.8599288",
"0.8506301",
"0.8472496",
"0.84654236",
"0.8426325",
"0.84248644",
"0.8394375",
"0.8394375",
"0.8392832... | 0.83829343 | 24 |
Set a new ID | def setID(self, idNb):
self._id = idNb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_id(self, value):\n pass",
"def SetId(self, new_id):\r\n\r\n self.id = new_id",
"def set_id(self, id):\n self.data['id'] = id",
"def _set_id(self):\n raise NotImplementedError()",
"def setID(self, idf):\n self.id = idf",
"def set_id(self, id):\n self.__id... | [
"0.8605839",
"0.8574502",
"0.824217",
"0.82337266",
"0.8197639",
"0.8179071",
"0.8134063",
"0.8119561",
"0.80982935",
"0.8087128",
"0.8037419",
"0.79466134",
"0.7910861",
"0.79026157",
"0.78843284",
"0.78606343",
"0.78512704",
"0.78512704",
"0.78512704",
"0.78512704",
"0.7851... | 0.0 | -1 |
Inverse of age of a given item | def ageInverse(self):
return 1.0/int(self.getAge()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_age(self):\n for employee in self:\n if employee.sudo().birthday:\n employee.age = relativedelta(\n fields.Date.from_string(fields.Date.today()),\n fields.Date.from_string(employee.sudo().birthday)).years\n else:\n ... | [
"0.63819337",
"0.6334721",
"0.6334721",
"0.631763",
"0.61333543",
"0.61052155",
"0.6093427",
"0.59906286",
"0.59628606",
"0.59494656",
"0.591256",
"0.5878036",
"0.5873152",
"0.5860877",
"0.5857174",
"0.58472496",
"0.5823043",
"0.578316",
"0.57376266",
"0.5721781",
"0.5721781"... | 0.7437109 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.