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 |
|---|---|---|---|---|---|---|
Calculates the "distance" from `one` to `two` using the 1norm. Assumes len(one) == len(two) == 2, and binary entries. | def dist(self, one, two):
return sum((one[0] != two[0], one[1] != two[1])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist(self, one, two):\n return np.sqrt((one[0] - two[0]) ** 2 + (one[1] - two[1]) ** 2)",
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-point_two)",
"def distance_to(x_one, y_one, x_two, y_two):\n x_dist = abs(x_one - x_two)\n y_dist = abs(y_one - y_two)\n... | [
"0.79038966",
"0.6785712",
"0.67456216",
"0.67014",
"0.6649711",
"0.6617488",
"0.6610858",
"0.660316",
"0.65297544",
"0.65189403",
"0.65137064",
"0.64862025",
"0.6483011",
"0.64792967",
"0.64750874",
"0.64743537",
"0.6474063",
"0.64538825",
"0.6452116",
"0.6450026",
"0.643916... | 0.7274371 | 1 |
Calculates the "distance" from `one` to `two` using the 2norm. That's the difference between hard and soft decoding! Assumes len(one) == len(two) == 2. | def dist(self, one, two):
return np.sqrt((one[0] - two[0]) ** 2 + (one[1] - two[1]) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDistanceBetweenTwoPoints(self, one, two):\n dx = one.x - two.x\n dy = one.y - two.y\n return math.sqrt(dx * dx + dy * dy)",
"def dist(self, one, two):\n return sum((one[0] != two[0], one[1] != two[1]))",
"def _get_distance(a, b):\n return np.sqrt(np.sum((a - b) ** 2))"... | [
"0.707182",
"0.701687",
"0.6861951",
"0.6842525",
"0.68095803",
"0.6804894",
"0.67806137",
"0.676701",
"0.6712558",
"0.6705202",
"0.6693495",
"0.6692881",
"0.6685786",
"0.6627979",
"0.66191596",
"0.6604278",
"0.66015995",
"0.6579138",
"0.65773344",
"0.6572661",
"0.6564942",
... | 0.79897654 | 0 |
Return True if `ancestor` is an ancestor of `child`, QObjecttreewise. | def isAncestorOf(ancestor, child):
while child is not None:
if child is ancestor:
return True
child = child.parent()
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ancestor(ancestor, parent):\n try:\n subprocess.check_call([\"git\", \"merge-base\", \"--is-ancestor\", ancestor, parent],)\n return True\n except subprocess.CalledProcessError:\n return False",
"def is_ancestor(self, other):\n\n if other is self:\n return True... | [
"0.7371715",
"0.7361766",
"0.6966555",
"0.68548286",
"0.6693012",
"0.66637033",
"0.6605285",
"0.65904605",
"0.6562593",
"0.6367331",
"0.63378483",
"0.62433606",
"0.6171506",
"0.6167557",
"0.5997285",
"0.59555304",
"0.59499377",
"0.5750634",
"0.5721365",
"0.56865203",
"0.56593... | 0.8260295 | 0 |
Get all nodes in a graph. | def nodes(self, data: bool = True) -> Dict:
return self.graph.nodes(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_nodes(self):\n return self._get_all_nodes()",
"def extract_nodes(graph):\n return graph.get_nodes()",
"def all_nodes(self, namespace=None):\n source = self._source(namespace)\n return self._list(source, 'all')",
"def get_nodes(self):\n\n return list(self.graph.nodes... | [
"0.77091503",
"0.760868",
"0.7549968",
"0.7536263",
"0.745354",
"0.7450652",
"0.7413506",
"0.7399367",
"0.73982674",
"0.7393966",
"0.7385526",
"0.73451203",
"0.7320129",
"0.7149469",
"0.71483934",
"0.71285284",
"0.71285284",
"0.70991033",
"0.7025902",
"0.69661707",
"0.694417"... | 0.6046957 | 89 |
Check whether a given edge exists in the graph. | def has_edge(
self, subject_node: str, object_node: str, edge_key: Optional[str] = None
) -> bool:
return self.graph.has_edge(subject_node, object_node, key=edge_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, edge):\n return edge in self.edges",
"def has_edge(self, otherNode):\n\t\t\treturn otherNode in self.edges",
"def __contains__(self, edge):\n return edge in self._edges",
"def does_edge_exist(self, src_key, dest_key):\n return self.vertices[src_key].does_it_point_to(se... | [
"0.77678376",
"0.76000905",
"0.7549828",
"0.7353355",
"0.7337852",
"0.7167825",
"0.71188307",
"0.69278324",
"0.6914114",
"0.6906198",
"0.68406177",
"0.67502916",
"0.67278266",
"0.6700696",
"0.6618549",
"0.6605293",
"0.65771097",
"0.6553928",
"0.653476",
"0.65278673",
"0.64212... | 0.75051755 | 3 |
Returns the number of edges in a graph. Returns int | def number_of_edges(self) -> int:
return self.graph.number_of_edges() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_of_edge(self):\n try:\n return self.edges\n except:\n print(\"ERROR: No graph exists\")",
"def edge_count(self) -> int:\n return self._n_edges",
"def compute_num_edges(graph):\n # return the number of edges\n return sum([len(graph[source_node].ke... | [
"0.84171635",
"0.8363548",
"0.83126014",
"0.8200226",
"0.8197102",
"0.8184014",
"0.8145859",
"0.8136901",
"0.813491",
"0.8114597",
"0.8098173",
"0.8067217",
"0.8061981",
"0.7983248",
"0.7976524",
"0.79012674",
"0.775356",
"0.7750693",
"0.77065814",
"0.7648719",
"0.76378673",
... | 0.85889 | 0 |
Return the amount of seconds in the given hours, minutes and seconds. | def to_seconds(hours, minutes, seconds):
return hours*3600+minutes*60+seconds | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_seconds(hours, minutes, seconds):\n return hours*60**2 + minutes*60 + seconds",
"def to_seconds(hours,minutes,seconds):\n return hours*3600+minutes*60+seconds",
"def calculate_seconds_in_hours(hours):\n return int(hours * 3600)",
"def seconds_in(sec):\r\n return int(sec - (hours_in(sec)*36... | [
"0.8396335",
"0.81968415",
"0.77937186",
"0.7690401",
"0.74884737",
"0.7384871",
"0.73680025",
"0.72977984",
"0.7262264",
"0.7246769",
"0.7189427",
"0.71467364",
"0.71397495",
"0.71044165",
"0.7064364",
"0.70461124",
"0.70402586",
"0.7024502",
"0.70112914",
"0.69861704",
"0.6... | 0.8334056 | 1 |
Just a simple wrapper to catch division by zero errors. | def safe_div(op1, op2, default=None):
try:
return Decimal(str(op1)) / Decimal(str(op2))
except (DivisionByZero, DivisionUndefined, InvalidOperation):
if default:
return default
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def division(a, b):\n if b == 0:\n raise ZeroDivisionError",
"def div(num1, num2):\n try:\n return num1 / num2\n except ZeroDivisionError:\n print(\"Handled division by zero. Returning zero.\")\n return 0",
"def provoke_and_handle_ZeroDivisionError():\n try:\n pri... | [
"0.8274809",
"0.8263087",
"0.81263286",
"0.7754147",
"0.7683689",
"0.76218987",
"0.76123476",
"0.75604194",
"0.7498887",
"0.741882",
"0.73985213",
"0.7379615",
"0.7375117",
"0.7356776",
"0.7346022",
"0.72581375",
"0.72404",
"0.711731",
"0.7061548",
"0.70211583",
"0.698808",
... | 0.6545747 | 36 |
Generate a random secret token. | def cli(bytes):
return logging.info(binascii.b2a_hex(os.urandom(bytes))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_token():\n chars = ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')\n rand = random.SystemRandom()\n random_string = ''.join(rand.choice(chars) for _ in range(40))\n return hmac.new(\n config.SECRET_KEY,\n random_string,\n hashlib.sha256\n ).hexdig... | [
"0.84882534",
"0.778233",
"0.7721034",
"0.7646876",
"0.74951106",
"0.74162614",
"0.73780096",
"0.7292843",
"0.72551775",
"0.7192354",
"0.71424663",
"0.7116661",
"0.71128446",
"0.7102652",
"0.710143",
"0.70217425",
"0.7007748",
"0.69886214",
"0.6977222",
"0.6928419",
"0.692832... | 0.0 | -1 |
This returns a new SnliInstance with a different label. | def to_attention_instance(self):
if self.label == self.label_mapping["entails"] or self.label == self.label_mapping["contradicts"]:
new_label = "attention_true"
elif self.label == self.label_mapping["neutral"]:
new_label = "attention_false"
else:
raise Runtime... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_label(cls, label):\n return cls(label.specimen_id, label.views)",
"def __init__(self, label):\n self.label = label",
"def __init__(self, label: str):\n pass",
"def __call__(self, *args, **kwargs) -> L:\n label = self._label_adapter.create_label(*args,\n ... | [
"0.6165852",
"0.6081733",
"0.6060745",
"0.5987793",
"0.583477",
"0.5806856",
"0.573119",
"0.56577414",
"0.56361556",
"0.5527584",
"0.5507143",
"0.5471564",
"0.5458686",
"0.5415453",
"0.5415259",
"0.53921777",
"0.5352919",
"0.53397983",
"0.53354985",
"0.53312767",
"0.5325046",... | 0.5890569 | 4 |
This returns a new SnliInstance with a different label. The new label will be binary (entails / not entails), but we need to distinguish between two different label types. Sometimes we need the label to be encoded in a single dimension (i.e., either `0` or `1`), and sometimes we need it to be encoded in two dimensions ... | def to_entails_instance(self, activation: str):
if self.label == self.label_mapping["entails"]:
new_label = "entails"
elif self.label == self.label_mapping["neutral"] or self.label == self.label_mapping["contradicts"]:
new_label = "not_entails"
else:
raise Run... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_attention_instance(self):\n if self.label == self.label_mapping[\"entails\"] or self.label == self.label_mapping[\"contradicts\"]:\n new_label = \"attention_true\"\n elif self.label == self.label_mapping[\"neutral\"]:\n new_label = \"attention_false\"\n else:\n ... | [
"0.69053423",
"0.6342885",
"0.6028976",
"0.5929179",
"0.5884997",
"0.5867978",
"0.5857494",
"0.5857124",
"0.56711537",
"0.5654825",
"0.56493825",
"0.5632242",
"0.55979145",
"0.5586989",
"0.5569911",
"0.5564142",
"0.5561175",
"0.5529135",
"0.5528745",
"0.55137444",
"0.5511393"... | 0.63832754 | 1 |
SMOTE to correct for imbalanced data on training set only. | def oversampling(models, X_train, y_train):
print("SMOTE...")
sm = over_sampling.SMOTE(random_state=42, n_jobs=2)
X_train, y_train = sm.fit_sample(X_train, y_train)
for m in models:
nobs = len(X_train[y_train == m])
return X_train, y_train | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_SMOTE(self):\n smote = SMOTE()\n self.X_train, self.y_train = smote.fit_resample(self.X_train, self.y_train)",
"def overSampling( self, feature, Class, random_state = 0 ):\n oversampler = SMOTE(random_state=0)\n feature_resample, Class_resample = oversampler.fit_sample(feature... | [
"0.71241504",
"0.63493407",
"0.58541244",
"0.57468057",
"0.5711068",
"0.56028295",
"0.560007",
"0.55782914",
"0.5574103",
"0.55056715",
"0.5397866",
"0.53328216",
"0.53048587",
"0.5282733",
"0.5244319",
"0.5239389",
"0.5227761",
"0.52076864",
"0.51859105",
"0.51831734",
"0.51... | 0.6019532 | 2 |
Clear just_cheated_x attribute corresponding to the rolled die. | def clear_just_cheated(self, dice_to_roll):
if type(dice_to_roll) != type([]):
raise TypeError("Expecting list of strings argument containing "
"any combination of 'a' and 'b'.")
else:
for member in dice_to_roll:
if type(member) != type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_damage(self):\n\n self.damaged.clear()\n self.all_damaged = False",
"def test_clear_just_cheated_die_a(self):\n\n self.new_angry_dice.just_cheated_a = True\n self.new_angry_dice.just_cheated_b = True\n self.new_angry_dice.clear_just_cheated([\"a\"])\n\n self.as... | [
"0.6093966",
"0.60897785",
"0.59165394",
"0.58398616",
"0.57415193",
"0.57077104",
"0.57070756",
"0.5687656",
"0.56513035",
"0.56294996",
"0.55960155",
"0.5559307",
"0.5512523",
"0.54636306",
"0.5463037",
"0.5454732",
"0.5392828",
"0.53846973",
"0.5384",
"0.5349258",
"0.53488... | 0.61247575 | 0 |
Reading a file and returning a list of lines | def readFile(filePath):
with open(filePath, 'r') as f:
return [l.strip() for l in f.readlines()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_lines_from_file(fname):\n return []",
"def read_file_in_lines(filename):\r\n\twith open(filename) as infile:\r\n\t\tlines = infile.readlines()\r\n\treturn [line.strip() for line in lines]",
"def _get_lines_from_file(path: str) -> List[str]:\n if os.path.isfile(path):\n with open(path, 'r'... | [
"0.84100485",
"0.8372363",
"0.83242637",
"0.8291465",
"0.8244524",
"0.82229877",
"0.8174983",
"0.8135221",
"0.80979735",
"0.80869704",
"0.8050238",
"0.8036265",
"0.802061",
"0.7977255",
"0.7959579",
"0.79514414",
"0.7941957",
"0.79132456",
"0.7906682",
"0.7884006",
"0.7854082... | 0.7476133 | 42 |
Convert a sequence of sequences to a string with the given separator. For each inner sequence, seq_to_str is called with the "inner" arguments. | def seqs_to_str(seq, sep="\n", with_len=True, len_sep="\n", end_sep="\n",
inner_sep=" ", inner_with_len=False, inner_len_sep=" ",
inner_end_sep=""):
result = ""
if with_len:
result += "%d%s" % (len(seq), len_sep)
result += sep.join(seq_to_str(s, sep=inner_sep, with_le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seq_to_str(seq, sep=\"\\n\", with_len=True, len_sep=\"\\n\", end_sep=\"\\n\"):\n result = \"\"\n if with_len:\n result += \"%d%s\" % (len(seq), len_sep)\n result += sep.join(str(i) for i in seq) + end_sep\n return result",
"def seq2str(seq):\n return ','.join(map(cleanstr, seq))",
"de... | [
"0.70367473",
"0.6647186",
"0.635488",
"0.6172872",
"0.6056115",
"0.6009292",
"0.6006598",
"0.5889126",
"0.5838938",
"0.5814085",
"0.5777865",
"0.57107055",
"0.5698392",
"0.5656473",
"0.55281365",
"0.55090827",
"0.55077714",
"0.5496044",
"0.5444832",
"0.54382753",
"0.5428676"... | 0.716984 | 0 |
Starting from sequential data, the batchify() arranges the dataset intp columns, trimming off any tokens remaining after the data has been divided into batches of size batch_size | def batchify(TEXT, data, batch_size, device):
data = TEXT.numericalize([data.examples[0].text])
num_batches = data.size(0)//batch_size
data = data.narrow(0, 0, num_batches * batch_size)
data = data.view(batch_size, -1).t().contiguous()
return data.to(device) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batchify(data, batch_size, args):\n # Work out how cleanly we can divide the dataset into batch_size parts (i.e. continuous seqs).\n nbatch = data.size(0) // batch_size\n # Trim off any extra elements that wouldn't cleanly fit (remainders).\n data = data.narrow(0, 0, nbatch * batch_size)\n # Eve... | [
"0.7297938",
"0.7251288",
"0.6872428",
"0.68177694",
"0.6600222",
"0.6571178",
"0.641436",
"0.63890374",
"0.6384236",
"0.63660455",
"0.6326783",
"0.6313386",
"0.62811315",
"0.62690556",
"0.6256025",
"0.625531",
"0.6204216",
"0.61977667",
"0.6187933",
"0.61774594",
"0.6166082"... | 0.65878534 | 5 |
Return the filtered queryset based on the value provided in the query string. | def queryset(self, request: HttpRequest, queryset: QuerySet) -> QuerySet:
return {
'superuser': queryset.filter(is_superuser=True),
'staff': queryset.filter(is_staff=True),
'scanlator': queryset.filter(groups__name='Scanlator'),
'regular': queryset.exclude(is_staf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n qs = super().get_queryset()\n search_value = self.request.GET.get('search_box')\n\n if search_value is not None:\n qs = qs.search_by(search_value)\n\n return qs",
"def queryset(self, request, queryset):\n # Compare the requested value (eithe... | [
"0.7024135",
"0.6897933",
"0.6748511",
"0.66725063",
"0.6627247",
"0.65580183",
"0.6539171",
"0.653511",
"0.648303",
"0.6478353",
"0.64393246",
"0.64334667",
"0.6348668",
"0.6341871",
"0.6338102",
"0.6323467",
"0.63224304",
"0.6288785",
"0.62858015",
"0.62451816",
"0.62451565... | 0.5874862 | 46 |
Get the scanlator status of the user. | def is_scanlator(self) -> bool:
return self.groups.filter(name='Scanlator').exists() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_status(cls):\n return jsonify(status=cls._user_status())",
"def status(self):\n return self._query_status()['status']",
"def get_status(self):\n return self.status",
"def get_status(self):\n return self.status",
"def get_status(self):\n return self.status",
"de... | [
"0.6683924",
"0.6497763",
"0.6488896",
"0.6488896",
"0.6488896",
"0.6488289",
"0.64799196",
"0.6430905",
"0.6422595",
"0.6407763",
"0.6368498",
"0.63034356",
"0.6261872",
"0.625344",
"0.6237864",
"0.6233514",
"0.621384",
"0.621384",
"0.6200417",
"0.6188729",
"0.61505544",
"... | 0.0 | -1 |
Get the full name of the user. | def full_name(self, obj: User) -> str:
return obj.get_full_name() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(self):\n return self.user.get_full_name() or None",
"def get_user_fullname(self):\n member = self.get_user()\n if member:\n return member.getProperty('fullname')",
"def get_full_name(self):\n return self.username",
"def get_full_name(self):\n return... | [
"0.87690705",
"0.8747",
"0.8724583",
"0.8724583",
"0.8621909",
"0.86065215",
"0.8583411",
"0.8547224",
"0.8546757",
"0.8494118",
"0.8471809",
"0.84096867",
"0.8402171",
"0.83782655",
"0.8303755",
"0.8250958",
"0.8177631",
"0.81676626",
"0.81320035",
"0.8117729",
"0.806362",
... | 0.82100075 | 16 |
Return a string representing the object. | def __str__(self) -> str:
return f'{self.name} ({self.provider})' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.__dict__['_obj'])",
"def __str__(self):\n return str(self.obj)",
"def __str__(self):\n\n return '__str__ for Object'",
"def __str__(self):\n return str(self.__dict__)",
"def __str__(self):\n return str(self.__dict__)",
"def g... | [
"0.8366619",
"0.8253037",
"0.80648184",
"0.7979195",
"0.7979195",
"0.7961396",
"0.7948838",
"0.7868511",
"0.7846744",
"0.7846744",
"0.7846744",
"0.7846744",
"0.7846744",
"0.7820616",
"0.77964026",
"0.77852654",
"0.77786344",
"0.7751776",
"0.7751776",
"0.7751776",
"0.7746966",... | 0.0 | -1 |
Takes a DataFrame and saves it as a CSV file. | def save_dataframe(dataframe, filename):
with open(filename, "w", encoding="utf8") as outfile:
dataframe.to_csv(outfile, sep=",") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_df(data_frame, file_path):\r\n data_frame.to_csv(file_path)\r\n return None",
"def write_tocsv(file_name, dataframe) :\n print(\"\\nSaved result to {}\\n\".format(file_name))\n dataframe.to_csv(file_name, mode='a', header=False,index=False)",
"def info2csv(df, csv_path):\n df.to_csv(csv... | [
"0.8289829",
"0.8062362",
"0.7988541",
"0.7987734",
"0.7897614",
"0.7866384",
"0.77966964",
"0.77878785",
"0.77680683",
"0.7750325",
"0.7651082",
"0.76436794",
"0.76303864",
"0.76124233",
"0.76009506",
"0.75601083",
"0.7545807",
"0.75314903",
"0.7523139",
"0.75217366",
"0.746... | 0.8487915 | 0 |
Create a schedule with a learning rate that decreases following the values of the cosine function between the initial lr set in the optimizer to 0, after a warmup period during which it increases linearly between 0 and the initial lr set in the optimizer. | def get_cosine_schedule_with_warmup(
optimizer: Optimizer,
num_warmup_steps: int,
num_training_steps: int,
num_cycles: float = 0.5,
last_epoch: int = -1,
):
def lr_lambda(current_step):
if current_step < num_warmup_steps:
return float(current_step) / float(max(1, num_warmup_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_schedule(num_epochs):\n return lambda epoch: 1.0",
"def WarmupCosineLR(\n optimizer: torch.optim.Optimizer,\n max_iters: int,\n pct_start: Optional[float] = None,\n warmup_steps: Optional[int] = None,\n warmup_factor: float = (1.0 / 1000),\n) -> torch.optim.lr_scheduler._LRScheduler:\n\n... | [
"0.6967163",
"0.6898374",
"0.6894173",
"0.68814844",
"0.68814844",
"0.6820696",
"0.68103194",
"0.6796456",
"0.6787354",
"0.67858905",
"0.6777413",
"0.677703",
"0.6745729",
"0.66972697",
"0.66934925",
"0.6689289",
"0.6657276",
"0.65717137",
"0.65697855",
"0.6554842",
"0.653776... | 0.655485 | 19 |
Close the underlying connection without returning it to the pool. | def manual_close(self):
if self.is_closed():
return False
# Obtain reference to the connection in-use by the calling thread.
conn = self.connection()
# A connection will only be re-added to the available list if it is
# marked as "in use" at the time it is closed. W... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n # Instead of actually closing the connection,\n # return it to the pool so that it can be reused.\n if self._con is not None:\n self._pool.returnConnection(self._con)\n self._con = None",
"def close(self):\n with self.connlock:\n sel... | [
"0.8193281",
"0.7695636",
"0.76289475",
"0.754914",
"0.7496222",
"0.7477636",
"0.74679375",
"0.74518347",
"0.74428105",
"0.7429108",
"0.7395676",
"0.73953724",
"0.7394828",
"0.73835135",
"0.7379031",
"0.73761666",
"0.73584384",
"0.7340392",
"0.7337949",
"0.73361313",
"0.73157... | 0.69867504 | 52 |
Factory for creating a DatasetUploader using production settings. | def make_dataset_uploader(upload_queue, exit_event):
return DatasetUploader(upload_queue, sc.make_sia_client(),
sia_conditions.make_waiter(exit_event), exit_event) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dataloader(self) -> DataLoader:\n return self._custom_data_loader()",
"def create_loader(dataset: Dataset, cfg: trainer_configs.BaseDatasetConfig, batch_size: int, *,\r\n collate_fn: Optional[Callable[[List[Any]], Any]] = None) -> DataLoader:\r\n # return DataLoader(\r\n # ... | [
"0.62301743",
"0.6095822",
"0.60810554",
"0.5985217",
"0.5974425",
"0.59560555",
"0.59413296",
"0.58990353",
"0.58819467",
"0.58491737",
"0.5846084",
"0.5836595",
"0.58215916",
"0.5816171",
"0.58023167",
"0.5789928",
"0.57702106",
"0.5765083",
"0.57467026",
"0.5697352",
"0.56... | 0.5589572 | 28 |
Creates a new DatasetUploader instance. | def __init__(self, upload_queue, sia_client, sia_condition_waiter,
exit_event):
self._upload_queue = upload_queue
self._sia_client = sia_client
self._sia_condition_waiter = sia_condition_waiter
self._exit_event = exit_event | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_DataLoader(self, **kwargs):\r\n return DataLoader(self, **kwargs)",
"def test_dataloader(self) -> DataLoader:\n return DataLoader(\n self.test_dataset,\n batch_size=self.hparams.batch_size,\n shuffle=False,\n num_workers=multiprocessing.cpu_count()... | [
"0.6825156",
"0.67535233",
"0.66384614",
"0.6605796",
"0.6599184",
"0.65129477",
"0.6508764",
"0.65066624",
"0.6478104",
"0.6473745",
"0.64697295",
"0.64686304",
"0.6467938",
"0.64676327",
"0.6427608",
"0.6329636",
"0.62843245",
"0.62626386",
"0.62377393",
"0.6232635",
"0.616... | 0.0 | -1 |
True if two arrays, left and right, have equal nonNaN elements, and NaNs in corresponding locations. False otherwise. It is assumed that left and right are NumPy arrays of the same dtype. The behavior of this function (particularly with respect to NaNs) is not defined if the dtypes are different. | def array_equivalent(left, right, strict_nan=False):
left, right = np.asarray(left), np.asarray(right)
# shape compat
if left.shape != right.shape:
return False
# Object arrays can contain None, NaN and NaT.
# string dtypes must be come to this path for NumPy 1.7.1 compat
if is_string... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_equal_nan(a1, a2):\n try:\n a1, a2 = np.asarray(a1), np.asarray(a2)\n except Exception:\n return False\n if a1.shape != a2.shape:\n return False\n # Handling NaN values\n a1nan, a2nan = np.isnan(a1), np.isnan(a2)\n # NaN's occur at different locations\n if not (a... | [
"0.77027184",
"0.7098412",
"0.682699",
"0.67512697",
"0.6693697",
"0.65482426",
"0.6519363",
"0.6425628",
"0.6414976",
"0.6280379",
"0.6228744",
"0.6224679",
"0.62139237",
"0.6212381",
"0.61686844",
"0.6166839",
"0.6153617",
"0.61487854",
"0.61004955",
"0.6092569",
"0.6088238... | 0.82189834 | 0 |
infer the fill value for the nan/NaT from the provided scalar/ndarray/listlike if we are a NaT, return the correct dtyped element to provide proper block construction | def _infer_fill_value(val):
if not is_list_like(val):
val = [val]
val = np.array(val, copy=False)
if is_datetimelike(val):
return np.array('NaT', dtype=val.dtype)
elif is_object_dtype(val.dtype):
dtype = lib.infer_dtype(_ensure_object(val))
if dtype in ['datetime', 'date... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_nan(array):\n idx = np.arange(array.shape[0])\n good = np.where(np.isfinite(array))\n interp = interpolate.interp1d(idx[good], array[good], bounds_error=False)\n return np.where(np.isfinite(array), array, interp(idx))",
"def fill_nan(A):\n\tinds = np.arange(A.... | [
"0.62822986",
"0.61665845",
"0.60879344",
"0.607589",
"0.60758805",
"0.6065",
"0.60577345",
"0.60004556",
"0.5966257",
"0.59631926",
"0.5933353",
"0.59052914",
"0.58782446",
"0.5829862",
"0.5816821",
"0.57602626",
"0.5698528",
"0.5687225",
"0.5672501",
"0.56494015",
"0.564270... | 0.7608484 | 0 |
if we have a compatiable fill_value and arr dtype, then fill | def _maybe_fill(arr, fill_value=np.nan):
if _is_na_compat(arr, fill_value):
arr.fill(fill_value)
return arr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _infer_fill_value(val):\n\n if not is_list_like(val):\n val = [val]\n val = np.array(val, copy=False)\n if is_datetimelike(val):\n return np.array('NaT', dtype=val.dtype)\n elif is_object_dtype(val.dtype):\n dtype = lib.infer_dtype(_ensure_object(val))\n if dtype in ['da... | [
"0.7154746",
"0.66281444",
"0.64221364",
"0.6418418",
"0.63861954",
"0.6376564",
"0.6329606",
"0.6304048",
"0.6267058",
"0.6235196",
"0.62289536",
"0.62234855",
"0.62154794",
"0.61920124",
"0.61202973",
"0.6117986",
"0.60500056",
"0.6016399",
"0.59837204",
"0.5981334",
"0.597... | 0.786033 | 0 |
Number of lattice sites. | def nsites(self) -> int:
return len(self.A) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n(self):\n return len(self.data.sites)",
"def num_sites(self):\n return self._ll_tree.get_num_sites()",
"def countSites(self):\n self.ni = len(self.sites)\n return self.ni",
"def number_of_sites(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"number_of_sites\")... | [
"0.8177708",
"0.7997218",
"0.7914483",
"0.7519629",
"0.7519629",
"0.7068941",
"0.70138055",
"0.68337756",
"0.6801635",
"0.68016064",
"0.67919874",
"0.67819905",
"0.67737967",
"0.6759923",
"0.67296755",
"0.6725009",
"0.6700922",
"0.6700884",
"0.6694308",
"0.6637853",
"0.659845... | 0.6700187 | 18 |
Construct the MPS representation of the vector `v` via the TTSVD algorithm, for local dimension `d`. All quantum numbers are set to zero for simplicity. | def from_vector(cls, d: int, nsites: int, v: np.ndarray, tol: float = 0):
v = np.array(v)
assert v.ndim == 1 and len(v) == d**nsites, f"`v` has length {len(v)}, expecting {d**nsites}."
# allocate a MPS with dummy virtual bonds of dimension 1
mps = cls(d*[0], [[0] for _ in range(nsites + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def S(t, d):\n out = 0.\n for i in range(m): #: Iterate over 0-indexed point indices\n out += P[i][d]*b_n(t, i, V)\n return out",
"def pc1(d):\n\timport numpy as np\n\tfrom sklearn.decomposition import TruncatedSVD\n\t# Normalize data\n\tt1 = d.T\n\tt1 = t1 - t1.mean(axis=0)\n\tt1 = t1 / (np.sqrt((... | [
"0.61096257",
"0.5763474",
"0.57123303",
"0.5682944",
"0.56389254",
"0.5590949",
"0.5537744",
"0.5469586",
"0.5453205",
"0.5436052",
"0.54348725",
"0.5433552",
"0.541846",
"0.5417964",
"0.54086834",
"0.5366208",
"0.5270755",
"0.52615505",
"0.52454746",
"0.5235257",
"0.5211031... | 0.71603477 | 0 |
Create a shapely line object from an array of points. | def line(points):
return LineString(points) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line(canvas, points, line_width, line_color):\n \n # duplicate first point in case only one point was given\n points = points[0], points\n canvas.create_line(points, width = int(line_width), fill = line_color)",
"def createLine(self, points):\n\n data = {\n \"type\": \"LineString\",\n ... | [
"0.6623521",
"0.66141057",
"0.6515262",
"0.6321061",
"0.6300571",
"0.6204704",
"0.6204704",
"0.61412835",
"0.61147666",
"0.61147666",
"0.61147666",
"0.6063745",
"0.59938043",
"0.5987808",
"0.5976602",
"0.59655744",
"0.5936027",
"0.58540195",
"0.58507276",
"0.58445966",
"0.580... | 0.69928676 | 0 |
Create a new ngram map. 'init_mapping' is a dictionary which maps ngrams to values as an initialization to this mapping. | def __init__(self, init_mapping=dict()):
self.root = _NGramMapNode()
self.size_freqs = dict() #A dictionary recording the frequencies of each n-gram size.
self.ele_freqs = dict() #A dictionary recording the frequencies of all elements in all n-grams.
for ngram in init_mapping:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._ngrams = {}",
"def create_n_1_gram_map(self) -> Dict[str, List[str]]:\n assert self.count_map is not None, 'count map is not initialized'\n # assert self.n_grams > 1, 'n-grams must be greater than 1 in order to create n_1 gram map'\n\n res: Dict[str, List[s... | [
"0.6318456",
"0.6183283",
"0.5912786",
"0.5887945",
"0.5811843",
"0.5742754",
"0.5739212",
"0.571624",
"0.5668436",
"0.5662621",
"0.5647781",
"0.56302255",
"0.5620188",
"0.5572944",
"0.5566678",
"0.55536765",
"0.5539655",
"0.55276245",
"0.5520395",
"0.55122614",
"0.55077565",... | 0.8016444 | 0 |
Assign a value to an ngram, overwriting the existing value if the ngram exists. 'ngram' must be hashable and in an ordered container whose length is defined. | def __setitem__(self, ngram, value):
ngram_size = len(ngram)
if ngram not in self:
#Record size of n-gram.
if ngram_size not in self.size_freqs:
self.size_freqs[ngram_size] = 0
self.size_freqs[ngram_size] += 1
#Record elements of n-gram.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, ngram, value):\n #N-gram is consumed element by element from first to last and each time this function will pass the rest of the n-gram to the next node.\n #When the n-gram is completely consumed, the current node will be marked a terminating node.\n \n #Base case:... | [
"0.7583918",
"0.6616948",
"0.6342986",
"0.6039196",
"0.60368603",
"0.5871451",
"0.5766659",
"0.5693661",
"0.5693661",
"0.5667171",
"0.56473887",
"0.5618953",
"0.5567666",
"0.55247504",
"0.5520946",
"0.55208",
"0.5518532",
"0.5512293",
"0.5488784",
"0.5441368",
"0.543345",
"... | 0.7632352 | 0 |
Get the value associated with an ngram. 'ngram' must be an ordered container whose length is defined and whose elements are hashable. | def __getitem__(self, ngram):
return self.root.__getitem__(ngram) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, ngram):\n return self._ngrams.get(ngram, 0.0)",
"def __getitem__(self, ngram):\n #N-gram is consumed element by element from first to last and each time this function will pass the rest of the n-gram to the next node.\n #When the n-gram is completely consumed, the value... | [
"0.7893862",
"0.70572263",
"0.65976536",
"0.6577211",
"0.65031636",
"0.6319129",
"0.63027817",
"0.62642807",
"0.6251673",
"0.6233725",
"0.60155207",
"0.59330195",
"0.5918859",
"0.58260345",
"0.576483",
"0.5739598",
"0.5680283",
"0.5643305",
"0.56048065",
"0.5573188",
"0.55591... | 0.7005985 | 2 |
Check if an ngram exists in the mapping. 'ngram' must be an ordered container whose length is defined and whose elements are hashable. | def __contains__(self, ngram):
return ngram in self.root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, ngram):\n return ngram in self._ngrams",
"def is_valid_ngram(ngram):\n for char in ngram:\n if char not in LETTERS:\n return False\n\n return True",
"def __contains__(self, ngram):\n #N-gram is consumed element by element from first to last and each ... | [
"0.74624544",
"0.672782",
"0.66697156",
"0.6321509",
"0.6098308",
"0.60515743",
"0.60140294",
"0.57353586",
"0.56611484",
"0.5589244",
"0.55703336",
"0.55676883",
"0.55613637",
"0.55199206",
"0.54616016",
"0.54283756",
"0.542572",
"0.53963643",
"0.53683317",
"0.53566176",
"0.... | 0.72606087 | 1 |
Get an iterator over all the ngrams which contain the given target element. 'target' must be an element. Returned ngrams are tuples. | def ngrams_with_ele(self, target):
return self.root.ngrams_with_ele(target) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams_with_ele(self, target):\n return self.__ngrams_with_ele(target, (), False)",
"def __ngrams_with_ele(self, target, partial_ngram, found):\n #An n-gram is constructed element by element and passed on to each of the child nodes.\n #When the target element has been added to the constr... | [
"0.7747526",
"0.6339296",
"0.6030595",
"0.5957258",
"0.57518154",
"0.57177156",
"0.571229",
"0.5663291",
"0.5516033",
"0.5509249",
"0.54458296",
"0.54436725",
"0.53690785",
"0.53618604",
"0.53244305",
"0.52820814",
"0.5226586",
"0.5209852",
"0.5171289",
"0.5167459",
"0.513623... | 0.79351914 | 0 |
Get an iterator over all the ngrams of a particular size which contain the given target element. 'target' must be an element. Returned ngrams are tuples. | def sized_ngrams_with_ele(self, target, size):
return self.root.sized_ngrams_with_ele(target, size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams_with_ele(self, target):\n return self.root.ngrams_with_ele(target)",
"def ngrams_with_ele(self, target):\n return self.__ngrams_with_ele(target, (), False)",
"def sized_ngrams_with_ele(self, target, size):\n return self.__sized_ngrams_with_ele(target, size, (), False)",
"def _... | [
"0.78791815",
"0.7718325",
"0.75665516",
"0.6790233",
"0.6379662",
"0.6277664",
"0.6270078",
"0.6156313",
"0.6063653",
"0.5979615",
"0.5906672",
"0.5804904",
"0.57438445",
"0.5675507",
"0.5644449",
"0.5538669",
"0.5445053",
"0.54386264",
"0.54064316",
"0.53920126",
"0.5337258... | 0.7627288 | 2 |
Get an iterator over all the ngrams which match an ngram template consisting of elements, some of which will be ignored as place holders. Place holders are elements that can be substituted by any element. The indices of the place holders must be specified. Returned ngrams are tuples. | def ngrams_by_template(self, ngram_template, placeholder_indices):
return self.root.ngrams_by_template(ngram_template, placeholder_indices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams_by_template(self, ngram_template, placeholder_indices):\n return self.__ngrams_by_template(ngram_template, placeholder_indices, 0, ())",
"def __ngrams_by_template(self, ngram_template, placeholder_indices, curr_index, partial_ngram):\n #An n-gram is constructed element by element and pas... | [
"0.71862",
"0.7177105",
"0.6563308",
"0.65052736",
"0.6401643",
"0.6342532",
"0.6296502",
"0.62851375",
"0.62512165",
"0.62358487",
"0.6228715",
"0.6185367",
"0.6180656",
"0.6177027",
"0.6173319",
"0.6116257",
"0.61118305",
"0.6015318",
"0.6013477",
"0.60034376",
"0.60000235"... | 0.72176874 | 0 |
Iterate over all the ngrams in the mapping. Returned ngrams are tuples. | def __iter__(self):
return self.root.ngrams() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n return self.ngrams()",
"def iter_ngrams(self, sentence, n):\n return [tuple(sentence[i : i+n]) for i in range(len(sentence)-n+1)]",
"def ngrams(self):\n return self.__ngrams(())",
"def everygrams(seq):\n for n in range(1, len(seq) + 1):\n for ng in... | [
"0.7243851",
"0.719758",
"0.7115495",
"0.7102535",
"0.7079672",
"0.69493896",
"0.6916515",
"0.6859841",
"0.68306607",
"0.6791651",
"0.6745082",
"0.66850847",
"0.6682363",
"0.66656184",
"0.66496146",
"0.66400284",
"0.6634526",
"0.6605614",
"0.6581879",
"0.6559552",
"0.65448093... | 0.726928 | 0 |
Add all ngrams from an ngram map into this ngram map. | def update(self, other):
for (ngram, value) in other.items():
self[ngram] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_ngrams(mydict,sentence):\n ngrams = get_ngrams(sentence,2,3)\n for ngram in ngrams:\n if ngram in mydict:\n mydict[ngram]+=1\n else:\n mydict[ngram]=1\n return mydict",
"def ngrams(self):\n return self.__ngrams(())",
"def add_ngram(self, feature_vecto... | [
"0.6722685",
"0.63497686",
"0.61519915",
"0.611247",
"0.5996436",
"0.5959093",
"0.5877456",
"0.58703744",
"0.5850235",
"0.5830215",
"0.5829584",
"0.5825282",
"0.57959586",
"0.5756498",
"0.5729093",
"0.5719245",
"0.57158285",
"0.5688177",
"0.5640109",
"0.56110865",
"0.5599376"... | 0.5807582 | 12 |
Get the number of ngrams in the mapping. | def __len__(self):
return sum(self.size_freqs.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self._ngrams)",
"def ngrams(self):\n return self.root.ngrams()",
"def count_ngrams(self):\n self.unigram = self.count_unigram(self.word_list)\n self.bigram = self.count_bigram(self.word_list)\n # self.trigram = self.count_trigram(self.word_list... | [
"0.77339387",
"0.7379124",
"0.7268892",
"0.7060166",
"0.7008096",
"0.6973376",
"0.69708985",
"0.6883942",
"0.6852379",
"0.6775619",
"0.6724267",
"0.67239416",
"0.66688645",
"0.6632595",
"0.6583369",
"0.6555929",
"0.6552279",
"0.6550539",
"0.6521097",
"0.64935976",
"0.64634776... | 0.0 | -1 |
Get the different elements of ngrams contained in the mapping. | def ngram_eles(self):
return set(self.ele_freqs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams(self):\n return self.__ngrams(())",
"def ngrams(self):\n return self.root.ngrams()",
"def get_ngrams(seq, n):\n return",
"def find_all_ngrams(dataset, n):\n return zip(*[dataset[i:] for i in xrange(n)])",
"def ngrams(words, n=1):\n return [tuple(words[j:j + n]) for j in rang... | [
"0.724075",
"0.7087319",
"0.6971676",
"0.6722071",
"0.66296977",
"0.66069394",
"0.6587585",
"0.65617836",
"0.65595126",
"0.65336573",
"0.6523318",
"0.6518207",
"0.64550173",
"0.64389473",
"0.641603",
"0.6401946",
"0.6353739",
"0.6346563",
"0.63275045",
"0.63083094",
"0.630589... | 0.63313603 | 18 |
Return a string representation of this ngram map. | def __repr__(self):
return "NGramMap({" + (", ".join("%r: %r"%(ngram, value) for (ngram, value) in self.items())) + "})" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"{\" + (\", \".join(\"%s: %s\"%(ngram, value) for (ngram, value) in self.items())) + \"}\"",
"def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))",
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def to_str(self):... | [
"0.7748204",
"0.7475837",
"0.7324068",
"0.7159174",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"0.7028326",
"... | 0.8391108 | 0 |
Return a string representation of this ngram map. | def __str__(self):
return "{" + (", ".join("%s: %s"%(ngram, value) for (ngram, value) in self.items())) + "}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return \"NGramMap({\" + (\", \".join(\"%r: %r\"%(ngram, value) for (ngram, value) in self.items())) + \"})\"",
"def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))",
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def to... | [
"0.83909094",
"0.7476066",
"0.73251355",
"0.7157827",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
"0.7026954",
... | 0.7746536 | 1 |
Assign a value to an ngram, overwriting the existing value if the ngram exists. | def __setitem__(self, ngram, value):
#N-gram is consumed element by element from first to last and each time this function will pass the rest of the n-gram to the next node.
#When the n-gram is completely consumed, the current node will be marked a terminating node.
#Base case: N-gram f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, ngram, value):\n ngram_size = len(ngram)\n if ngram not in self:\n #Record size of n-gram.\n if ngram_size not in self.size_freqs:\n self.size_freqs[ngram_size] = 0\n self.size_freqs[ngram_size] += 1\n\n #Record elements... | [
"0.71547335",
"0.65202487",
"0.5946258",
"0.5911529",
"0.58350307",
"0.5757941",
"0.5734994",
"0.5502923",
"0.54564464",
"0.54384446",
"0.54088247",
"0.53939223",
"0.53766024",
"0.5347754",
"0.5347754",
"0.5298357",
"0.5289621",
"0.5288909",
"0.5279145",
"0.5249072",
"0.51909... | 0.7507985 | 0 |
Check if an ngram exists in the mapping. | def __contains__(self, ngram):
#N-gram is consumed element by element from first to last and each time this function will pass the rest of the n-gram to the next node.
#When the n-gram is completely consumed, whether or not the current node is a terminating node is returned.
#Base case:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, ngram):\n return ngram in self._ngrams",
"def __contains__(self, ngram):\n return ngram in self.root",
"def has_next_Ngram(self, label):\n return label in self.next_grams",
"def is_valid_ngram(ngram):\n for char in ngram:\n if char not in LETTERS:\n ... | [
"0.77131784",
"0.74963987",
"0.679249",
"0.67041343",
"0.6680157",
"0.6679143",
"0.62161094",
"0.61447066",
"0.60762155",
"0.6042812",
"0.589592",
"0.58136135",
"0.5792211",
"0.5780393",
"0.57620233",
"0.57428557",
"0.5674803",
"0.5658368",
"0.56382865",
"0.560158",
"0.560070... | 0.65355676 | 6 |
Get an iterator over all the ngrams of a particular size which contain the given target element. 'target' must be an element. Returned ngrams are tuples. | def sized_ngrams_with_ele(self, target, size):
return self.__sized_ngrams_with_ele(target, size, (), False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams_with_ele(self, target):\n return self.root.ngrams_with_ele(target)",
"def ngrams_with_ele(self, target):\n return self.__ngrams_with_ele(target, (), False)",
"def sized_ngrams_with_ele(self, target, size):\n return self.root.sized_ngrams_with_ele(target, size)",
"def __sized_n... | [
"0.78790325",
"0.77178675",
"0.7625032",
"0.67904514",
"0.6377609",
"0.6274168",
"0.62714595",
"0.61526585",
"0.6061747",
"0.59766287",
"0.59048617",
"0.58024263",
"0.57426584",
"0.56738836",
"0.56423086",
"0.5539143",
"0.54438484",
"0.54372346",
"0.5403369",
"0.5389369",
"0.... | 0.7564047 | 3 |
Get an iterator over all the ngrams which match an ngram template consisting of elements, some of which will be ignored as place holders. Place holders are elements which can be substituted by any element. The indices of the place holders must be specified. Returned ngrams are tuples. | def ngrams_by_template(self, ngram_template, placeholder_indices):
return self.__ngrams_by_template(ngram_template, placeholder_indices, 0, ()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngrams_by_template(self, ngram_template, placeholder_indices):\n return self.root.ngrams_by_template(ngram_template, placeholder_indices)",
"def __ngrams_by_template(self, ngram_template, placeholder_indices, curr_index, partial_ngram):\n #An n-gram is constructed element by element and passed ... | [
"0.72236276",
"0.7186499",
"0.6575608",
"0.65252453",
"0.6414356",
"0.6356047",
"0.63138264",
"0.63006294",
"0.62682825",
"0.62498105",
"0.6239136",
"0.62043107",
"0.6191288",
"0.61855006",
"0.6184687",
"0.61340755",
"0.61334044",
"0.6026838",
"0.6023955",
"0.6017067",
"0.601... | 0.71916455 | 1 |
Iterate over all the ngrams in the mapping. Returned ngrams are tuples. | def __iter__(self):
return self.ngrams() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n return self.root.ngrams()",
"def iter_ngrams(self, sentence, n):\n return [tuple(sentence[i : i+n]) for i in range(len(sentence)-n+1)]",
"def ngrams(self):\n return self.__ngrams(())",
"def everygrams(seq):\n for n in range(1, len(seq) + 1):\n for ... | [
"0.726928",
"0.719758",
"0.7115495",
"0.7102535",
"0.7079672",
"0.69493896",
"0.6916515",
"0.6859841",
"0.68306607",
"0.6791651",
"0.6745082",
"0.66850847",
"0.6682363",
"0.66656184",
"0.66496146",
"0.66400284",
"0.6634526",
"0.6605614",
"0.6581879",
"0.6559552",
"0.65448093"... | 0.7243851 | 1 |
returns a tensorflow tensor of shape [batchsize, embedding_size] (that is [?, embedding_size] | def get_user_embedding(self):
raise NotImplementedError("has to be overwritten") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((vocab_size, embed_dim), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, input_data)\n\n return embed",
"def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((voc... | [
"0.76868254",
"0.7601166",
"0.7565882",
"0.75105757",
"0.70561224",
"0.67799985",
"0.67111593",
"0.67034227",
"0.6685086",
"0.6615129",
"0.6591247",
"0.6588812",
"0.65634483",
"0.6548686",
"0.6464751",
"0.64586306",
"0.64576787",
"0.6430524",
"0.6427789",
"0.63914526",
"0.638... | 0.0 | -1 |
returns a tensorflow tensor of shape [batchsize, embedding_size] (that is [?, embedding_size] | def get_movie_embedding(self):
raise NotImplementedError("has to be overwritten") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((vocab_size, embed_dim), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, input_data)\n\n return embed",
"def get_embed(input_data, vocab_size, embed_dim):\n embedding = tf.Variable(tf.random_uniform((voc... | [
"0.7687604",
"0.7602255",
"0.75668997",
"0.75116",
"0.7056728",
"0.6781897",
"0.6711354",
"0.670397",
"0.66858035",
"0.6615496",
"0.659269",
"0.65883946",
"0.6563994",
"0.6549171",
"0.646561",
"0.64602315",
"0.64579606",
"0.6431784",
"0.6428042",
"0.6391141",
"0.63855565",
... | 0.0 | -1 |
init goal and array | def add_goal(self, goal):
self.sys_da_array = []
self.usr_da_array = []
self.goal = deepcopy(goal)
for domain in self.belief_domains:
if 'final' in self.goal[domain]:
for key in self.goal[domain]['final']:
self.goal[domain][key] = self.goal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, initial, goal):\n self.initial = initial; self.goal = goal",
"def __init__(self, initial, goal=None):\n\t\tself.initial = initial\n\t\tself.goal = goal",
"def __init__(self, initial, goal=None):\n self.initial = initial\n self.goal = goal",
"def initialize(self):\n ... | [
"0.70106",
"0.686764",
"0.67846495",
"0.67612714",
"0.66968673",
"0.66091245",
"0.6580018",
"0.6543949",
"0.644557",
"0.6434783",
"0.64335686",
"0.64054155",
"0.63938874",
"0.63897276",
"0.63495743",
"0.63495743",
"0.63495743",
"0.63495743",
"0.63136935",
"0.62423414",
"0.619... | 0.5832078 | 69 |
init goal and array | def add_goal(self, goal):
self.sys_da_array = []
self.usr_da_array = []
self.goal = deepcopy(goal)
for domain in self.belief_domains:
if 'final' in self.goal[domain]: #If 'final' key is present in goal
for key in self.goal[domain]['final']:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, initial, goal):\n self.initial = initial; self.goal = goal",
"def __init__(self, initial, goal=None):\n\t\tself.initial = initial\n\t\tself.goal = goal",
"def __init__(self, initial, goal=None):\n self.initial = initial\n self.goal = goal",
"def initialize(self):\n ... | [
"0.70106",
"0.686764",
"0.67846495",
"0.67612714",
"0.66968673",
"0.66091245",
"0.6580018",
"0.6543949",
"0.644557",
"0.6434783",
"0.64335686",
"0.64054155",
"0.63938874",
"0.63897276",
"0.63495743",
"0.63495743",
"0.63495743",
"0.63495743",
"0.63136935",
"0.62423414",
"0.619... | 0.58266234 | 70 |
r""" Succintly represents ``self``. | def __repr__(self):
return str((("P" if self.is_P() else "Q"),self._children)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n\n return '%s +%s -%s %s' %(\n repr(self.value),\n #False positive, pylind does not see members created by __new__\n #pylint: disable=no-member\n repr(self.plus_error),\n repr(self.minus_error),\n str(self.unit)\n ... | [
"0.64251125",
"0.6403911",
"0.632313",
"0.6298039",
"0.6296791",
"0.6269664",
"0.62431633",
"0.6241012",
"0.62261975",
"0.62261975",
"0.62127995",
"0.6201114",
"0.6182513",
"0.61738026",
"0.61738026",
"0.61738026",
"0.61738026",
"0.61738026",
"0.61738026",
"0.61738026",
"0.61... | 0.0 | -1 |
The ID of the local gateway. | def local_gateway_id(self) -> Optional[str]:
return pulumi.get(self, "local_gateway_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self):\n return self._light.address",
"def transit_gateway_id(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"transit_gateway_id\")",
"def vpn_gateway_id(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"vpn_gateway_id\")",
"def transit_g... | [
"0.7327788",
"0.7310967",
"0.71508974",
"0.7128758",
"0.7128758",
"0.712455",
"0.71148616",
"0.7004527",
"0.7004527",
"0.6952937",
"0.6857196",
"0.680342",
"0.6782488",
"0.66821116",
"0.66556567",
"0.66474044",
"0.66069317",
"0.6602509",
"0.65839857",
"0.6543752",
"0.65433115... | 0.861385 | 0 |
The ARN of the local gateway route table. | def local_gateway_route_table_arn(self) -> Optional[str]:
return pulumi.get(self, "local_gateway_route_table_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arn(self) -> str:\n return pulumi.get(self, \"arn\")",
"def arn(self) -> str:\n return pulumi.get(self, \"arn\")",
"def arn(self) -> str:\n return pulumi.get(self, \"arn\")",
"def arn(self) -> str:\n return pulumi.get(self, \"arn\")",
"def arn(self) -> str:\n return p... | [
"0.6260963",
"0.6260963",
"0.6260963",
"0.6260963",
"0.6260963",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"0.62489665",
"... | 0.8440978 | 0 |
The ID of the local gateway route table virtual interface group association. | def local_gateway_route_table_virtual_interface_group_association_id(self) -> Optional[str]:
return pulumi.get(self, "local_gateway_route_table_virtual_interface_group_association_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_local_gateway_route_table_virtual_interface_group_association_output(local_gateway_route_table_virtual_interface_group_association_id: Optional[pulumi.Input[str]] = None,\n opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Out... | [
"0.68205214",
"0.66702497",
"0.65828985",
"0.6557337",
"0.64438486",
"0.64438486",
"0.6383603",
"0.63721997",
"0.63464606",
"0.63464606",
"0.63464606",
"0.63451296",
"0.6319242",
"0.62986463",
"0.6282167",
"0.6239581",
"0.6239581",
"0.6239581",
"0.6239581",
"0.6239581",
"0.62... | 0.8835276 | 0 |
The owner of the local gateway route table virtual interface group association. | def owner_id(self) -> Optional[str]:
return pulumi.get(self, "owner_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_gateway_route_table_virtual_interface_group_association_id(self) -> Optional[str]:\n return pulumi.get(self, \"local_gateway_route_table_virtual_interface_group_association_id\")",
"def get_local_gateway_route_table_virtual_interface_group_association_output(local_gateway_route_table_virtual_int... | [
"0.7407207",
"0.6471637",
"0.60806406",
"0.5966262",
"0.5951595",
"0.59018344",
"0.59018344",
"0.59018344",
"0.59018344",
"0.59018344",
"0.586852",
"0.58546907",
"0.5843893",
"0.5796705",
"0.5795118",
"0.5760635",
"0.575962",
"0.5703012",
"0.5703012",
"0.5703012",
"0.567067",... | 0.57050836 | 17 |
Validates any project/experiment/run names for datasets | def is_invalid_proj_exp_runnames(name):
return re.search(f'[^{settings.ALLOWED_PROJEXPRUN_CHARS}]', name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_dataset(self):\n pass",
"def test_with_valid_input(self):\n for dataset_type in ['regular', 'raw', 'REGULAR', 'RAW']:\n try:\n check_dataset_type(dataset_type)\n except ValueError:\n self.fail(\"Dataset {0} should be valid\".format(da... | [
"0.6910052",
"0.68486965",
"0.6757872",
"0.65904015",
"0.654097",
"0.65349126",
"0.65275973",
"0.6302439",
"0.62728626",
"0.6110243",
"0.6017979",
"0.60038745",
"0.598042",
"0.598042",
"0.5966641",
"0.5918598",
"0.58484274",
"0.58459157",
"0.58327806",
"0.58326423",
"0.582559... | 0.561478 | 30 |
Return all currently registered node type identifiers. | def names(self):
return self.__names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_node_types(self):\n return list(nodelist.all_nodes.keys())",
"def node_types(self) -> List[NodeType]:\n return list(self._node_store_dict.keys())",
"def ntypes(self) -> Sequence[str]:\n ntypes = list(self.num_nodes_dict.keys())\n return ntypes",
"def node_name_list(self):... | [
"0.77885723",
"0.7621027",
"0.73690116",
"0.6777612",
"0.67709786",
"0.65106374",
"0.64637154",
"0.6449043",
"0.64485866",
"0.64349216",
"0.6409829",
"0.63657075",
"0.63594407",
"0.6317012",
"0.6307697",
"0.6298361",
"0.6292921",
"0.62826544",
"0.6272148",
"0.6246685",
"0.622... | 0.0 | -1 |
Limit the self._x to within the screen dimensions | def x(self, value: int):
if not (0 < value < SCREEN_WIDTH - self.width):
self.dir_x = -self.dir_x
self._x += abs(self._x - value) * self.dir_x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keepInBounds(self):\n screenWidth, screenHeight = self.screen.get_size()\n\n self.pos.x = max(0, self.pos.x)\n self.pos.x = min(screenWidth, self.pos.x)\n\n self.pos.y = max(0, self.pos.y)\n self.pos.y = min(screenHeight, self.pos.y)",
"def move(self):\n if self.x_po... | [
"0.7048233",
"0.6961968",
"0.6914811",
"0.6878182",
"0.67955613",
"0.6725112",
"0.66647375",
"0.66493714",
"0.66307575",
"0.65996194",
"0.6593339",
"0.6587011",
"0.65832436",
"0.65676373",
"0.6567056",
"0.6567056",
"0.6564179",
"0.65417176",
"0.65330803",
"0.6528127",
"0.6509... | 0.72235626 | 0 |
Limit the self._y to within the screen dimensions | def y(self, value):
if not (0 < value < SCREEN_HEIGHT - self.height):
self.dir_y = -self.dir_y
self._y += abs(self._y - value) * self.dir_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_y(self, y):\n self.scene.set_y_loc(y)\n self.redraw()",
"def setY(self, y):\n self.position.setY(y)",
"def get_y_position(self): \n return self.rect.y",
"def set_y(self,Y):\n self.posY = Y",
"def checkYPos(self, *args):\n x = self.initialXScale.get()... | [
"0.7228565",
"0.7224084",
"0.7013458",
"0.69773144",
"0.6946419",
"0.69397783",
"0.6937778",
"0.688762",
"0.6879244",
"0.6868933",
"0.684636",
"0.6830678",
"0.6805958",
"0.67819005",
"0.67757076",
"0.6728401",
"0.67253286",
"0.6723002",
"0.6713959",
"0.6675673",
"0.666359",
... | 0.7458478 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ComDayCommonsHttpclientProperties):
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 |
Calculate quarter (1 indexed) from month (1 indexed). >>> [quarter_from_month(month) for month in range(1, 13)] [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4] | def quarter_from_month(month: int) -> int:
return ((month - 1) // 3) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quarter(self):\n\n self.quarter_nums = cal_data.calc_quarter(self.active_date[2],\n self.active_date[1])\n self.quarter = cal_data.get_quarter(self.active_date[2],\n self.active_date[1])",
"def next_... | [
"0.66965705",
"0.66740316",
"0.6591736",
"0.6500939",
"0.6397785",
"0.63314295",
"0.62508905",
"0.6160819",
"0.59535784",
"0.5887964",
"0.5797946",
"0.57865",
"0.569497",
"0.5691616",
"0.56217575",
"0.54737055",
"0.5466125",
"0.5466125",
"0.5443386",
"0.5273369",
"0.5207362",... | 0.83025986 | 0 |
Derive pep440 compliant version string from PyCalVer version string. >>> to_pep440("v201811.0007beta") '201811.7b0' | def to_pep440(version: str) -> str:
return str(parse_version(version)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pep440_from_semver(semver):\n segment = ''\n if semver.prerelease:\n segment = '.dev{}'.format('.'.join(semver.prerelease))\n local_version = '.'.join(semver.build)\n local_version = local_version.replace('-', '.')\n version_str = '{}.{}.{}{}'.format(semver.major, semver.minor, semver.pat... | [
"0.72433025",
"0.6444893",
"0.6428337",
"0.6300033",
"0.61961496",
"0.61874396",
"0.61550283",
"0.61127645",
"0.6087762",
"0.6081975",
"0.6043224",
"0.59825194",
"0.5965236",
"0.5945156",
"0.59330505",
"0.59276074",
"0.5901325",
"0.5894179",
"0.5889854",
"0.58780223",
"0.5863... | 0.8242642 | 0 |
Assert that a list of resource objects is equal to an expected list of resource objects (or faked resource objects). | def assert_resources(resources, exp_resources, prop_names):
# Assert the resource URIs
uris = set([res.uri for res in resources])
exp_uris = set([res.uri for res in exp_resources])
assert uris == exp_uris
for res in resources:
# Search for the corresponding expected profile
exp_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertResourceListEqual(self, actual, expected, resource_type):\n self.assertEqual(\n [resource_type(**f).to_dict(computed=False) for f in expected],\n [f.to_dict(computed=False) for f in actual],\n )",
"def check_lists_equal( list1, list2, assertobject ):\n assertEqualsI... | [
"0.75010824",
"0.6969786",
"0.686773",
"0.6816491",
"0.68150854",
"0.6623479",
"0.6455179",
"0.64441675",
"0.6388659",
"0.636739",
"0.6286687",
"0.62667996",
"0.6234209",
"0.62246007",
"0.6219633",
"0.6217692",
"0.6198986",
"0.61986077",
"0.6196974",
"0.6165539",
"0.61343163"... | 0.70901173 | 1 |
Reset the logger for the specified log component (unless it is the root logger) to add a NullHandler if it does not have any handlers. Having a handler prevents a log request to be propagated to the parent logger. | def reset_logger(log_comp):
name = LOGGER_NAMES[log_comp]
logger = logging.getLogger(name)
if name != '' and not logger.handlers:
logger.addHandler(logging.NullHandler()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logger(log_comp, handler, level):\n\n name = LOGGER_NAMES[log_comp]\n logger = logging.getLogger(name)\n\n for h in logger.handlers:\n if isinstance(h, logging.NullHandler):\n logger.removeHandler(h)\n\n handler.setLevel(level)\n logger.addHandler(handler)\n logger.set... | [
"0.65901434",
"0.64577067",
"0.63996834",
"0.61595136",
"0.61468714",
"0.6036333",
"0.6030601",
"0.6002729",
"0.5838749",
"0.5738981",
"0.5729172",
"0.57205653",
"0.5695924",
"0.5643764",
"0.56191725",
"0.5611869",
"0.555219",
"0.55307704",
"0.5512023",
"0.55055296",
"0.54995... | 0.7699055 | 0 |
Assert that two FakedMetricGroupDefinition objects are equal. | def assert_equal_metric_group_def(mgd1, mgd2):
assert isinstance(mgd1, FakedMetricGroupDefinition)
assert isinstance(mgd2, FakedMetricGroupDefinition)
assert mgd1.name == mgd2.name
assert mgd1.types == mgd2.types | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_equal_metric_values(mv1, mv2):\n assert isinstance(mv1, FakedMetricObjectValues)\n assert isinstance(mv2, FakedMetricObjectValues)\n assert mv1.group_name == mv2.group_name\n assert mv1.resource_uri == mv2.resource_uri\n assert mv1.timestamp == mv2.timestamp\n assert mv1.values == mv2.... | [
"0.716624",
"0.6490823",
"0.64803016",
"0.63746274",
"0.63697225",
"0.6251126",
"0.6227035",
"0.6075038",
"0.5982981",
"0.59823006",
"0.5964316",
"0.59214693",
"0.59056485",
"0.589379",
"0.5885677",
"0.58776385",
"0.58679885",
"0.586775",
"0.58639735",
"0.58533764",
"0.583389... | 0.87121534 | 0 |
Return the input datetime object as a timezoneaware datetime object. If the input object is already timezoneaware, it is returned. If the input object is timezonenaive, the local timezone information is added to a copy of the input object and that copy is returned. | def timestamp_aware(dt):
if dt.tzinfo is None:
dt = dt.replace(tzinfo=tz.tzlocal()) # new object
return dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_make_timezone_aware(datetime_object, timezone_string=None):\n if timezone_string:\n # make the date timezone aware using the given timezone_string\n timezone_object = pytz_timezone_object(timezone_string)\n timezone_aware_datetime_object = timezone_object.localize(datetime_object)\... | [
"0.76542145",
"0.7495154",
"0.73218477",
"0.7056183",
"0.69305295",
"0.6927569",
"0.68284774",
"0.6748129",
"0.6686388",
"0.6595904",
"0.653807",
"0.6420742",
"0.6369841",
"0.6366947",
"0.636612",
"0.63538593",
"0.6287582",
"0.62643504",
"0.61496973",
"0.6093182",
"0.60779953... | 0.6875443 | 6 |
Return a tuple of a tf Graph, Iterator, Model, and Session. | def create_model(hparams, mode):
graph = tf.Graph()
with graph.as_default():
with tf.name_scope("input_pipe"):
dataset = create_dataset(hparams, mode)
iterator = dataset.make_initializable_iterator()
model = LMandBDRNNModel(hparams=hparams,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tensors(loaded_graph):\n g = loaded_graph\n InputTensor = g.get_tensor_by_name(\"input:0\")\n InitialStateTensor = g.get_tensor_by_name(\"initial_state:0\")\n FinalStateTensor = g.get_tensor_by_name(\"final_state:0\") \n ProbsTensor = g.get_tensor_by_name(\"probs:0\")\n\n return Input... | [
"0.6443534",
"0.62095916",
"0.6141547",
"0.6089227",
"0.60805553",
"0.60772645",
"0.6049631",
"0.5943432",
"0.58611465",
"0.58396626",
"0.5818176",
"0.5691271",
"0.56734",
"0.5609604",
"0.5528351",
"0.5513516",
"0.54753006",
"0.54457146",
"0.5432793",
"0.5393822",
"0.53916126... | 0.0 | -1 |
Set new value to Const node and recompute all necessary shapes in this node and data nodes | def set_node_value(node: Node, value: np.ndarray):
if node.type != 'Const':
raise Exception('Can\'t set value for non-constant node {}'.format(node.name))
data_type = np.float32
if node.out_port(0).is_data_type_defined():
data_type = node.out_port(0).get_data_type()
node.out_port(0).data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_node(node, value):\n node.N += 1\n node.W += value\n node.Q = node.W / node.N",
"def update_attr(self):\n\n # Retrieve all current values\n all_values = nx.get_node_attributes(self.G, 'value')\n\n new_values = {}\n\n # Loop over all nodes\n for ... | [
"0.620524",
"0.6088918",
"0.5987213",
"0.5935326",
"0.5913673",
"0.58181375",
"0.57887936",
"0.5785095",
"0.57735175",
"0.57488483",
"0.57043356",
"0.5697049",
"0.5686154",
"0.5672313",
"0.5655895",
"0.56520516",
"0.56189376",
"0.5583461",
"0.5570622",
"0.5547451",
"0.5536954... | 0.65960515 | 0 |
Generate ngrams from corpus Returns a dictionary of kgrams (from 2 to nth degree) | def __makeNgrams(self, n):
# start_time = time.time()
ngrams = dict()
itergrams = dict()
for k in range(2,n+1):
itergrams[k] = list(nltk.ngrams(self.words, k))
for k, grams in itergrams.items():
kgrams = defaultdict(Counter)
for gram in grams... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_ngram(corpus,n=2):\r\n def generate_ngram_str(text,n):\r\n text = tokenizer.tokenize(text)\r\n for i in range(0, len(text)-n+1):\r\n yield text[i:i+n]\r\n if isinstance(corpus,str):\r\n for ngram in generate_ngram_str(corpus,n):\r\n yield ngram\r\n e... | [
"0.73345",
"0.73013943",
"0.7156764",
"0.71051204",
"0.7047381",
"0.703042",
"0.69959635",
"0.6983927",
"0.68515825",
"0.6844244",
"0.6822454",
"0.6794173",
"0.6786707",
"0.6779912",
"0.6773878",
"0.6754185",
"0.6752084",
"0.6730475",
"0.6708785",
"0.66996104",
"0.6680698",
... | 0.752389 | 0 |
Render website's home page. | def home():
return render_template('home.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n return render_template('homepage.html')",
"def home():\n\n return render_template('home_page.html')",
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"... | [
"0.87248576",
"0.85797024",
"0.85035866",
"0.8486288",
"0.84611857",
"0.84365207",
"0.84302676",
"0.841985",
"0.8396901",
"0.8396901",
"0.8375347",
"0.8356703",
"0.83518267",
"0.8341115",
"0.8341115",
"0.83366895",
"0.8330097",
"0.83294135",
"0.832544",
"0.83175427",
"0.82938... | 0.8337803 | 22 |
Render the website's about page. | def about():
return render_template('about.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about():\n\n\treturn render_template(\"about.html\")",
"def about():\n return render_template(\n 'about.html',\n title='About',\n ... | [
"0.87910306",
"0.8698105",
"0.86404276",
"0.86124563",
"0.8490408",
"0.84784615",
"0.8467779",
"0.84352976",
"0.84289914",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242... | 0.8325753 | 33 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.8224081",
"0.8223272",
"0.8223272",
"0.8223272",
"0.8223272",
"0.81964976",
"0.81132656",
"0.808731",
"0.79732955",
"0.786621",
"0.76618445",
"0.72377926",
"0.7159863",
"0.715322",
"0.715322",
"0.71517026",
"0.71517026",
"0.7142053",
"0.71373916",
"0.712861",
"0.712861",
... | 0.81641245 | 21 |
Return color escape code like '[31m' for red. | def _code(color: str) -> str:
# Escape codes for the 8 main colors go from 30 to 37.
num_str = str(30 + COLORS.index(color))
return f"[{num_str}m" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color(code):\n return lambda t: \"\\033[{0}{1}\\033[0;m\".format(code, t)",
"def textColor(colorNumber):\n return '\\033[%dm' % (30 + colorNumber)",
"def _ansi_equivalent(self, s: str) -> str:\r\n color_id = self._color_id_regexp.search(s).groups()[0]\r\n\r\n # TODO: Replace this with a... | [
"0.7140825",
"0.70151657",
"0.69217825",
"0.6841887",
"0.6753863",
"0.6733817",
"0.6724648",
"0.67032886",
"0.6586259",
"0.6546856",
"0.65339065",
"0.6521417",
"0.6499164",
"0.64895546",
"0.64630944",
"0.6448338",
"0.6443699",
"0.64356476",
"0.64348394",
"0.6401379",
"0.63773... | 0.76702976 | 0 |
Provide helpful representation when printed. | def __repr__(self):
return "<User user_id=%s, name = %s, email=%s, password=%s>" % (self.user_id,
self.first_name, self.email, self.password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Ride ride_id={}, driver={}, start={}, end={}, date={}>".format(self.ride_id,
self.driver, self.start_city, self.end_city, self.start_timestamp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Rider id={}, ride_id={}, user_id={}>".format(self.id,
self.ride_id, self.user_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Requests id={}, ride_id={}, requester={}, seats={}>".format(self.id,
self.ride_id, self.requester, self.seats) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Check whether the line is unordered list, if it is, change it into html format | def check_unordered_list(line):
if line[:2] == '* ' or line[:2] == '- ' or line[:2] == '+ ' and len(line) > 2:
return True, '<ul><li>' + line[2:] + '</li></ul>'
return False, '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_html_ul(\n value: str,\n convert_dashes: bool = True,\n with_title: bool = False\n) -> str:\n if not value:\n return ''\n\n value = value.replace('\\r', '').strip('\\n')\n value = value.replace('\\n\\n', '\\n \\n')\n\n if not convert_dashes:\n return '<p>{}</p>'.format(\n ... | [
"0.6722098",
"0.6535788",
"0.6483703",
"0.6427917",
"0.6324625",
"0.62481564",
"0.6228694",
"0.6195857",
"0.61753297",
"0.61499524",
"0.61137676",
"0.6087956",
"0.6077381",
"0.60515636",
"0.6034332",
"0.5991393",
"0.5839859",
"0.5827158",
"0.5765641",
"0.56919575",
"0.5661814... | 0.71478677 | 0 |
Index page. Return the template. | def index():
return render_template('index.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_page():\n\n return render_template(\"index.html\")",
"def index_page():\n\n return render_template(\"index.html\")",
"def index_page():\n\n return render_template(\"index.html\")",
"def index():\r\n return render_template('index.html')",
"def index():\n return rende... | [
"0.8373988",
"0.8373988",
"0.8373988",
"0.831972",
"0.8307974",
"0.8264882",
"0.82596594",
"0.82596594",
"0.82573396",
"0.8256507",
"0.8238303",
"0.8196232",
"0.8194035",
"0.8194035",
"0.81606764",
"0.8131964",
"0.80896056",
"0.80896056",
"0.80896056",
"0.80896056",
"0.808960... | 0.808243 | 52 |
Flask application instantiation with extensions and blueprints | def create_app(mode=os.environ.get('FLASK_MODE', 'app.config.Development')):
app = APIFlask(__name__)
# add configurations
app_config = config.get(mode)
app.config.from_object(app_config)
app_config().init_app(app)
# initialize all extensions
init_extensions(app)
# register blueprints
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_app(app):\n app.load_extension(__name__)",
"def create_app():\n app = Flask(__name__)\n app.register_blueprint(playlists)\n app.register_blueprint(comments)\n return app",
"def create_app():\n app = Flask(__name__, instance_relative_config=False)\n app.config.from_object('config.C... | [
"0.7628948",
"0.7624795",
"0.75975955",
"0.74849623",
"0.7472157",
"0.7410981",
"0.7386237",
"0.73710954",
"0.7359548",
"0.73337257",
"0.73082376",
"0.7292675",
"0.72830945",
"0.727428",
"0.72539616",
"0.7229635",
"0.7212875",
"0.7206148",
"0.7193071",
"0.7192912",
"0.7190982... | 0.7059199 | 36 |
Get the data for a particular day from a Pandas dataframe. The data are mapped to numbers for min/max operation. | def get_daily(Data, Y, M, D):
start = datetime(year=Y, month=M, day=D, hour=0, minute=0)
end = datetime(year=Y, month=M, day=D, hour=23, minute=59, second=59)
return Data[start:end]["clouds"].map(value_by_cloud) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_day_of_data(self, column_name, day):\n self.check_for_column(column_name)\n dt = pd.Timestamp(day)\n column = self.data[column_name]\n return column[column.index.date == dt.date()]",
"def get_data(day, unixstart=None, unixend=None):\n global subnet\n df_data = pd.DataFrame([... | [
"0.6640035",
"0.6327252",
"0.620272",
"0.5961652",
"0.586962",
"0.58031136",
"0.5778132",
"0.5740736",
"0.5650758",
"0.55911034",
"0.5584576",
"0.55757034",
"0.55558676",
"0.5535217",
"0.55223465",
"0.5516037",
"0.5494917",
"0.54693806",
"0.54676884",
"0.54649603",
"0.5455006... | 0.5714151 | 8 |
Validate interior_temp or exterior_temp. If the value is "U" then set is as None. | def temp_validator(cls, value, field):
if value == "U":
LOGGER.warning("{field.name} value is 'U'. Setting to None.")
return None
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_temperatures_value(self):\n self.assertEqual(self.TminValue, 450.0)",
"def _check_types(self):\n if isinstance(self.unique_id, (int, str)): # should unique_id be a float?\n self.unique_id = str(self.unique_id)\n else:\n raise TypeError(f'unique_id incorrect typ... | [
"0.55307305",
"0.5214903",
"0.5141292",
"0.5097829",
"0.5091537",
"0.5089358",
"0.5074625",
"0.5054196",
"0.49922997",
"0.49919182",
"0.49849528",
"0.49699223",
"0.4960044",
"0.49462032",
"0.49411967",
"0.49335268",
"0.49271277",
"0.49264887",
"0.4916088",
"0.4910812",
"0.490... | 0.6286469 | 0 |
Return True if GridPegSolitairePuzzle self is equivalent to other. | def __eq__(self, other):
return (type(self) == type(other) and
self._marker == other._marker and
self._marker_set == other._marker_set) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n for i in range(len(self.puzzle)):\n for j in range(len(self.puzzle[0])):\n if(self.puzzle[i][j] != other.puzzle[i][j]):\n return False\n return True",
"def __eq__(self, other):\n return np.all(self.grid == other.grid) an... | [
"0.7777365",
"0.7128192",
"0.7128096",
"0.7042899",
"0.7001565",
"0.7001565",
"0.6998009",
"0.69683576",
"0.6954856",
"0.6910418",
"0.6902253",
"0.6834667",
"0.6729442",
"0.6708907",
"0.67054313",
"0.66855025",
"0.66852814",
"0.66748196",
"0.6672553",
"0.6660348",
"0.66281164... | 0.0 | -1 |
Return whether GridPegSolitairePuzzle self is solved. | def is_solved(self):
peg_count = 0
for row in self._marker:
for item in row:
if item == '*':
peg_count += 1
return peg_count == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_solution(self) -> bool:\n if self in [self.SATISFIED, self.ALL_SOLUTIONS, self.OPTIMAL_SOLUTION]:\n return True\n return False",
"def is_solved(self):\n # Iterate through each square of the puzzle\n for row in range(self.sl):\n for col in range(self.sl):\... | [
"0.77643764",
"0.77169114",
"0.752162",
"0.75107074",
"0.74955964",
"0.748712",
"0.7420569",
"0.7420569",
"0.7420569",
"0.72661453",
"0.7248253",
"0.7240494",
"0.72115725",
"0.7206371",
"0.7131853",
"0.70426935",
"0.7031681",
"0.69903743",
"0.6943916",
"0.68941855",
"0.686962... | 0.58760005 | 90 |
This function open the file dialog and sets visibility of the buttons | def open_slot(self):
caption = 'Open files'
directory = './'
filter_mask = "JPEG File Interchange Format (*.jpg *.jpeg *jfif)|" + "*.jpg;*.jpeg;*.jfif"
files = QFileDialog.getOpenFileNames(None, caption, directory, filter_mask)[0]
self._model.set_filenames(files)
if len(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_openFilesButton_clicked(self):\n self.__enableFindButton()",
"def openFileDialog(self): \n self.dialog = ocempgui.widgets.Box(373, 372)\n self.dialog.topleft = 528, 205\n\n background = guiobjects.OcempImageMapTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(WINDOW_UPLOAD))\... | [
"0.72894037",
"0.7242647",
"0.7164755",
"0.7144964",
"0.6774855",
"0.6722693",
"0.67042464",
"0.6652502",
"0.65270233",
"0.647964",
"0.6474142",
"0.64635694",
"0.645917",
"0.6433844",
"0.63806635",
"0.6360893",
"0.6357875",
"0.6348367",
"0.63313246",
"0.63103557",
"0.62739646... | 0.7027692 | 4 |
``is_consumed()`` should return ``True`` for a consumed ticket. | def test_ticket_consumed(self):
st = ServiceTicketFactory()
st.consume()
st = ServiceTicket.objects.get(ticket=st.ticket)
self.assertTrue(st.is_consumed()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ticket_not_consumed(self):\n st = ServiceTicketFactory()\n self.assertFalse(st.is_consumed())",
"def test_consume_tickets(self):\n st1 = ServiceTicketFactory()\n st2 = ServiceTicketFactory()\n ServiceTicket.objects.consume_tickets(self.user)\n self.assertTrue(Se... | [
"0.73946923",
"0.65348846",
"0.60418725",
"0.6009015",
"0.59206754",
"0.5847624",
"0.5800885",
"0.56733304",
"0.556838",
"0.5565925",
"0.5530513",
"0.55278057",
"0.5487619",
"0.5466903",
"0.5459315",
"0.54396045",
"0.54198873",
"0.54085886",
"0.53738415",
"0.53653556",
"0.535... | 0.74744517 | 0 |
``is_consumed()`` should return ``False`` for a valid ticket. | def test_ticket_not_consumed(self):
st = ServiceTicketFactory()
self.assertFalse(st.is_consumed()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ticket_consumed(self):\n st = ServiceTicketFactory()\n st.consume()\n st = ServiceTicket.objects.get(ticket=st.ticket)\n self.assertTrue(st.is_consumed())",
"def test_validate_ticket_consumed_ticket(self):\n st = ServiceTicketFactory(consume=True)\n with self.as... | [
"0.7490909",
"0.6866085",
"0.65920156",
"0.646661",
"0.64139706",
"0.6358583",
"0.6321051",
"0.6178995",
"0.61237866",
"0.60870266",
"0.5980425",
"0.5969279",
"0.5955901",
"0.580964",
"0.573562",
"0.5668784",
"0.5657935",
"0.5654111",
"0.56439453",
"0.56143516",
"0.5534359",
... | 0.8097508 | 0 |
``is_primary()`` should return ``False`` if the ``ServiceTicket`` was not created from the presentation of a user's credentials. | def test_secondary(self):
st = ServiceTicketFactory()
self.assertFalse(st.is_primary()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_primary(self):\n st = ServiceTicketFactory(primary=True)\n self.assertTrue(st.is_primary())",
"def is_primary(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"is_primary\")",
"def is_primary(self):\n\n return not self.parent.non_primary",
"def is_primary... | [
"0.774287",
"0.6480841",
"0.61077434",
"0.60278285",
"0.60127294",
"0.590651",
"0.5659118",
"0.56576586",
"0.5656655",
"0.5564442",
"0.5562564",
"0.55597234",
"0.5544762",
"0.55424017",
"0.5534804",
"0.5521728",
"0.5515009",
"0.5499338",
"0.54892373",
"0.54863167",
"0.5475738... | 0.65328586 | 1 |
If a signout request to a service returns an invalid status code, the resulting exception should be handled. | def test_request_sign_out_invalid_status(self):
st = ServiceTicketFactory()
with patch('requests.post') as mock:
mock.return_value.status_code = 500
st.request_sign_out() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signout(self):\r\n return self.app.get('/account/signout', follow_redirects=True)",
"def test_request_sign_out_exception(self):\n st = ServiceTicketFactory()\n with patch('requests.post') as mock:\n mock.side_effect = requests.exceptions.RequestException\n st.reques... | [
"0.63054806",
"0.629941",
"0.61814815",
"0.60013455",
"0.5949701",
"0.5928705",
"0.5746081",
"0.5724325",
"0.565421",
"0.5625145",
"0.5602006",
"0.55991226",
"0.55964124",
"0.55929434",
"0.55850244",
"0.556946",
"0.55682904",
"0.5561876",
"0.55376303",
"0.5502395",
"0.5485038... | 0.7099548 | 0 |
Sets the logging level. | def set_level(self, debug_level, verbose=False):
self.debug_level = debug_level
self.verbosity = verbose
level = logging.INFO
if debug_level > 4:
level = logging.DEBUG - 3
elif debug_level > 0:
level = logging.DEBUG - debug_level + 1
elif verbose:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_level(self, level: str):\n self._logger.setLevel(getattr(logging, level))",
"def set_log_level(self, level):\n if level == 'info':\n level = logging.INFO\n if level == 'debug':\n level = logging.DEBUG\n if level == 'error':\n level = loggin... | [
"0.84028757",
"0.828369",
"0.82148135",
"0.81969815",
"0.8164995",
"0.8149665",
"0.8124171",
"0.8103577",
"0.8100742",
"0.78753537",
"0.780043",
"0.77098274",
"0.77062374",
"0.76996934",
"0.764992",
"0.76456445",
"0.7643418",
"0.7577295",
"0.7567677",
"0.7535593",
"0.75258625... | 0.71664625 | 31 |
Constructor for QNetwork. Takes a name and a learning rate for the GradientDescentOptimizer | def __init__(self, name: str, learning_rate: float, beta: float = 0.00001):
self.learningRate = learning_rate
self.beta = beta
self.name = name
# Placeholders
self.input_positions = None
self.target_q = None
self.actions = None
# Internal tensors
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, shared_mem_name, learning_rate):\n self.name = literals.GRADIENT_DESCENT\n super(GradientDescent, self).__init__(learning_rate=learning_rate,\n shared_mem_name=shared_mem_name)",
"def __init__(self, lr, eps=1e-6):\n LearningRate... | [
"0.69575447",
"0.6389306",
"0.63450027",
"0.6286006",
"0.6283014",
"0.6243793",
"0.62011105",
"0.61675113",
"0.6087021",
"0.6079052",
"0.60755813",
"0.6070673",
"0.6032599",
"0.5955677",
"0.5899364",
"0.5879908",
"0.58416426",
"0.58233106",
"0.57994694",
"0.579642",
"0.578464... | 0.6270861 | 5 |
Constructor for the Neural Network player. | def __init__(self, name: str, reward_discount: float = 0.99, win_value: float = 10.0, draw_value: float = 0.0,
loss_value: float = -10.0, learning_rate: float = 0.01, training: bool = True,
random_move_prob: float = 0.9999, random_move_decrease: float = 0.9997, batch_size=60,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\n #super(Net, self).__init__()\n nn.Module.__init__(self)\n # Build CNN\n module, shapes, optim = build_neuron_network(**kwargs)\n self._configuration = kwargs\n self.add_module('cnn', module)\n self.shapes = shapes\n # Loss and ... | [
"0.7182839",
"0.7063412",
"0.70152503",
"0.6915938",
"0.6843988",
"0.68340147",
"0.68023753",
"0.6760313",
"0.6699622",
"0.6692155",
"0.6686875",
"0.66656804",
"0.6661924",
"0.6656292",
"0.6602225",
"0.66011685",
"0.6600179",
"0.6595561",
"0.6573153",
"0.65593153",
"0.6542436... | 0.0 | -1 |
Basic confusion matrix plot | def plot_confusion_matrix(cm, classes=None, ax=None, rotate_y=True, cmap='Blues'):
if ax is None:
fig, ax = plt.subplots(figsize=(8, 6))
# If cm not put in, create one
if isinstance(cm, list) or isinstance(cm, tuple):
cm = confusion_matrix(cm[0], cm[1])
if not classes:
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 plot_cnf_matrix(self):\n\t\tplt.figure()\n\t\tanalysis.plot_cnf_matrix(self.y_pred, self.y_test)",
"def plot_confusion_matrix(cm, class_names):\n figure =... | [
"0.85036325",
"0.8166569",
"0.80888236",
"0.8074209",
"0.80336994",
"0.7922803",
"0.79187",
"0.79014534",
"0.7880731",
"0.7879117",
"0.784483",
"0.78275734",
"0.78185475",
"0.77897936",
"0.7789382",
"0.77866894",
"0.778651",
"0.7780942",
"0.7778837",
"0.7778837",
"0.77771765"... | 0.0 | -1 |
Sets up an roc plot and returns the ax object | def plot_roc_curves(labels, probas, name='', ax=None):
# Setup axis
if ax is None:
fig, ax = plt.subplots(figsize=(20, 10))
plot_roc(labels, probas, name=name, ax=ax)
# Plot chance
ax.plot([0, 1], [0, 1], linestyle='--', lw=2, color='black', alpha=.8)
# Fill bottom right
ax.fill_b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _InitAxes( self ):\n self.ax = self.fig.add_subplot( 111 )",
"def init_axes(self):\n plt.switch_backend(\"cairo\")\n fig = plt.figure(figsize=(15,10))\n ax = fig.add_axes([0.05, 0.15, 0.9, 0.80,])\n return (fig, ax)",
"def build_corr_plot():\r\n fig = plt.figure(figsize=(1... | [
"0.6646863",
"0.6585978",
"0.6225929",
"0.6147457",
"0.6141379",
"0.6110672",
"0.60083985",
"0.59946185",
"0.5986516",
"0.5933751",
"0.5891394",
"0.58716166",
"0.5858632",
"0.58488417",
"0.58306015",
"0.58172256",
"0.57976377",
"0.5776978",
"0.57742596",
"0.5768438",
"0.57561... | 0.5731476 | 22 |
Convert a scipy sparse matrix to a torch sparse tensor. | def sparse_mx_to_torch_sparse_tensor(sparse_mx):
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
shape = torch.Size(sparse_mx.shape)
return torch.sparse.FloatTen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csr2tensor(self, matrix: sp.csr_matrix):\n matrix = matrix.tocoo()\n x = torch.sparse.FloatTensor(\n torch.LongTensor(np.array([matrix.row, matrix.col])),\n torch.FloatTensor(matrix.data.astype(np.float32)),\n matrix.shape,\n ).to(self.device)\n retu... | [
"0.8299787",
"0.8148542",
"0.8045949",
"0.80325705",
"0.80134654",
"0.79973555",
"0.79973555",
"0.7985302",
"0.7985302",
"0.7985302",
"0.7977018",
"0.79650825",
"0.7754673",
"0.7713117",
"0.7429514",
"0.7429514",
"0.735423",
"0.71969247",
"0.7156927",
"0.69882196",
"0.6969645... | 0.80300856 | 13 |
public setter for self._use_aux_heads, called every time an assignment to self.use_aux_heads is applied. if use_aux is False, `_remove_auxiliary_heads` is called to delete auxiliary and detail heads. if use_aux is True, and self._use_aux_heads was already set to False a ValueError is raised, recreating aux and detail h... | def use_aux_heads(self, use_aux: bool):
if use_aux is True and self._use_aux_heads is False:
raise ValueError(
"Cant turn use_aux_heads from False to True. Try initiating the module again with"
" `use_aux_heads=True` or initiating the auxiliary heads modules manually.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _auxiliary_head_forward_train(self, x, img_metas, gt_semantic_seg):\n losses = dict()\n if isinstance(self.auxiliary_head, nn.ModuleList):\n for idx, aux_head in enumerate(self.auxiliary_head):\n loss_aux = aux_head.forward_train(x, img_metas,\n ... | [
"0.52376163",
"0.45844907",
"0.45811093",
"0.45760122",
"0.45500726",
"0.45051795",
"0.4464918",
"0.44381142",
"0.43665466",
"0.43560833",
"0.4311725",
"0.42804468",
"0.4253698",
"0.42298898",
"0.42072165",
"0.41669574",
"0.41252705",
"0.4124604",
"0.41143984",
"0.4101132",
"... | 0.88334244 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.