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 |
|---|---|---|---|---|---|---|
Clean the input buffer and get a name that's typed in. | def getName():
tcflush(sys.stdin, TCIFLUSH)
name = input(" You say:\n ")
updateNameDatabase(name)
return name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(self):\n name = input(\"What is your name? \")\n if len(name) > 0:\n self.name = name",
"def input_name(self):\n return self.__input_name",
"def get_name():\n return raw_input(\"What's your name? \")",
"def get_name():\n print(\"\")\n name = input(\"Greet... | [
"0.6385",
"0.6207764",
"0.6180437",
"0.61366755",
"0.61346084",
"0.61324376",
"0.61028165",
"0.6036705",
"0.5994801",
"0.5983757",
"0.59797794",
"0.5919747",
"0.5912155",
"0.5897724",
"0.58420867",
"0.58420867",
"0.58420867",
"0.58420867",
"0.58420867",
"0.58420867",
"0.58420... | 0.6812864 | 0 |
Convert plain list to MutationList. | def coerce(cls, key, value):
self = MutationList((MutationObj.coerce(key, v) for v in value))
self._key = key
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_list(l):\r\n l = [list(elem) for elem in l]\r\n return l",
"def to_list(ls):\r\n if isinstance(ls, (list, tuple)):\r\n return list(ls)\r\n else:\r\n return [ls]",
"def to_list(x):\n if isinstance(x, list):\n return x\n return [x]",
"def _to_pylist(self):\r\n\t\tpyli... | [
"0.6553225",
"0.62707764",
"0.5875614",
"0.58627445",
"0.585077",
"0.58077997",
"0.57693684",
"0.5765776",
"0.5741986",
"0.5727797",
"0.5705437",
"0.56927955",
"0.5684148",
"0.567436",
"0.56562585",
"0.5626378",
"0.562477",
"0.5623232",
"0.5575543",
"0.55727285",
"0.5551089",... | 0.5824151 | 5 |
Mangles a column name to a standard form, remoing illegal characters. | def mangle_name(name):
import re
try:
return re.sub('_+','_',re.sub('[^\w_]','_',name).lower()).rstrip('_')
except TypeError:
raise TypeError(
'Trying to mangle name with invalid type of: ' + str(type(name))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_column_name(string):\n string = unidecode(string.replace(' ', '_').lower())\n return re.sub(r'[^0-9a-z_]','', string)",
"def _validate_column_name(col_name : str) -> str:\n\n if col_name[0].isdigit():\n return f'\"{col_name}\"'\n return col_name",
"def _valid_column(column_name):\n ... | [
"0.75011533",
"0.71863365",
"0.6850968",
"0.68286157",
"0.67849135",
"0.66737306",
"0.66737306",
"0.6603098",
"0.65745264",
"0.6540453",
"0.6537761",
"0.6483973",
"0.6468041",
"0.6402178",
"0.63911235",
"0.63911235",
"0.63876563",
"0.6334491",
"0.63137543",
"0.6306661",
"0.62... | 0.5826473 | 56 |
Set the Table ID based on the dataset number and the sequence number for the table. | def before_update(mapper, conn, target):
if isinstance(target, Column):
raise TypeError('Got a column instead of a table')
if target.id_ is None:
dataset_id = ObjectNumber.parse(target.d_id)
target.id_ = str(TableNumber(dataset_id, target.sequence_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_id(self) -> str:\n return pulumi.get(self, \"table_id\")",
"def newid(self, target_table):\n self.new_id[target_table] += 1\n return self.new_id[target_table]",
"def _set_id(self):\n raise NotImplementedError()",
"def __init__(self, name, sequence_number):\n super(SQL... | [
"0.6303707",
"0.61042374",
"0.59887666",
"0.59712815",
"0.5963648",
"0.5951662",
"0.5936735",
"0.5935326",
"0.5924849",
"0.59239405",
"0.5908809",
"0.5890164",
"0.57908034",
"0.57644045",
"0.5749948",
"0.5721006",
"0.56599724",
"0.56337774",
"0.56337774",
"0.5598158",
"0.5590... | 0.586561 | 12 |
Checking for white 220 is the threshold 0.8 is the tolerance level | def check_for_white(img):
return white_percentage(img, 220, 0.8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threshold(self, value):\r\n threshold = 0.5\r\n if value >= threshold:\r\n return 1\r\n else:\r\n return 0",
"def check_if_white_back_black_edge(pred):\n values = np.unique(pred)\n # print(values)\n\n # check if binary\n if len(values) > 2:\n print(\"Your prediction ... | [
"0.67174834",
"0.6487796",
"0.6463961",
"0.6462622",
"0.6449646",
"0.64339715",
"0.6431686",
"0.6416966",
"0.6413505",
"0.6399163",
"0.6366602",
"0.6365009",
"0.63525826",
"0.63525826",
"0.6338424",
"0.6333677",
"0.6312592",
"0.62757385",
"0.6274855",
"0.62545544",
"0.6245186... | 0.74915415 | 1 |
This is a helper method for constructing the transitions probability table. | def transitions(player1_row, player1_column, player2_row, player2_column, player1_possession, player1_action, player2_action):
s = (player1_row, player1_column, player2_row, player2_column, player1_possession)
transitions = []
# Case: Player 1 goes first
next_s, collision = SoccerEnv.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_transition_probs(self):\n n = len(self.speakers) # TODO why this line ???\n transitions = np.random.randint(5, size=(n, n)) + 1\n transitions += transitions.transpose()\n for i in range(0, math.floor(n / 2)):\n s1 = np.random.randint(n)\n s2 = np.random.r... | [
"0.7122934",
"0.6940506",
"0.66394025",
"0.63094825",
"0.6229575",
"0.6163949",
"0.6124621",
"0.61116207",
"0.6067541",
"0.6034366",
"0.6034286",
"0.6016178",
"0.60043514",
"0.5994777",
"0.5920206",
"0.5917823",
"0.5914002",
"0.59012115",
"0.58852696",
"0.58769065",
"0.587309... | 0.0 | -1 |
Initialize a new, empty Node Object. | def __init__(self):
self.number = None
self.pos = None
self.key = -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.root = Node(None)",
"def __init__(self):\n self.root = self.Node(None)",
"def __init__(self):\n self.root = Node('')",
"def __init__(self):\n self.root = Node(\"\")",
"def __init__(self):\n self.root = Node(\"\")",
"def __init__(self):\n ... | [
"0.81817526",
"0.81447303",
"0.8005726",
"0.7890686",
"0.7890686",
"0.78388584",
"0.7789606",
"0.77264416",
"0.76918375",
"0.76918375",
"0.76918375",
"0.7667791",
"0.7658282",
"0.7534381",
"0.7456405",
"0.7389766",
"0.7318487",
"0.73128605",
"0.73117876",
"0.7273617",
"0.7251... | 0.0 | -1 |
Initialize a new FRDNodeBlock Object. | def __init__(self, in_file=None):
self.key = 2
self.code = 'C'
self.numnod = None
self.format = None
self.nodes = []
if in_file is not None:
self._read(in_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, node_identifier):\n\t\tself.blockchain = bc.Blockchain(node_identifier)\n\t\tself.BUFFER_MAX_LEN = 20\n\t\tself.MINE_REWARD = 10\n\t\tself.node_identifier = node_identifier",
"def __init__(self, public_key, node_id):\n # Our starting block for the blockchain\n genesis_block = Blo... | [
"0.68633485",
"0.635676",
"0.6279823",
"0.62676376",
"0.624351",
"0.6088152",
"0.60277176",
"0.58723724",
"0.5871171",
"0.5861737",
"0.5832285",
"0.5820672",
"0.580619",
"0.5786449",
"0.5770142",
"0.57678574",
"0.5744416",
"0.5733594",
"0.572058",
"0.56931716",
"0.5689686",
... | 0.0 | -1 |
Initialize a new FRDResultBlock Object. | def __init__(self, in_file=None):
self.key = 100
self.code = 'C'
self.setname = None
self.value = None
self.numnod = None
self.text = None
self.ictype = None
self.numstep = None
self.analys = None
self.format = None
self.name = None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset, block):\n super().__init__(dataset, block)\n\n # these are results for display in the Tab\n self.freq_summed = None\n self.freq_current = None\n\n self.reset_results_arrays()",
"def __init__(self, result_code=None, message=None, value=None): # noqa... | [
"0.5401331",
"0.539294",
"0.5232692",
"0.52209604",
"0.5200635",
"0.5200635",
"0.51396316",
"0.51370955",
"0.5079849",
"0.5054977",
"0.5013498",
"0.49825",
"0.49679428",
"0.4955351",
"0.49491957",
"0.49361867",
"0.49157205",
"0.4913417",
"0.4884147",
"0.4884147",
"0.4883492",... | 0.0 | -1 |
Hook to ensure object is owned by request.user. | def get_object(self, queryset=None):
result = super(ResultPlot, self).get_object()
if not result.job.owner == self.request.user:
raise Http404("The user {} is not the owner of {}.".format(
self.request.user, result))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_ownership(self):\n user = self.request.user\n object = self.get_object()\n if object.owned_by(user):\n return True\n else:\n return False",
"def has_object_permission(self, request, view, obj):\n return request.user.id == obj.user_id",
"def has_o... | [
"0.7492899",
"0.7263095",
"0.720622",
"0.715437",
"0.71168154",
"0.7060507",
"0.7052732",
"0.70177627",
"0.7009931",
"0.7006181",
"0.69574875",
"0.6948073",
"0.692198",
"0.6901764",
"0.6897051",
"0.6883162",
"0.68580794",
"0.6827206",
"0.68249476",
"0.6810537",
"0.6810537",
... | 0.0 | -1 |
Step one pixel to the left. | def step(self, delta=1):
self._offset -= delta
if self._offset < -self.width:
self.is_done = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left(self, step: int = 1) -> None:\n if self.cursor_pos.y == 0:\n self.cursor_pos = Point(self.cursor_pos.x, self.width-step)\n else:\n self.cursor_pos = Point(self.cursor_pos.x, self.cursor_pos.y-step)",
"def shift_left(self):\n self.pointer = (self.pointer - ... | [
"0.7928519",
"0.75478077",
"0.7453782",
"0.7372932",
"0.73297393",
"0.73297393",
"0.72831464",
"0.7276859",
"0.7245116",
"0.7234374",
"0.70816076",
"0.7071769",
"0.7064034",
"0.7015732",
"0.698934",
"0.69884396",
"0.68827",
"0.6871533",
"0.68613535",
"0.68564945",
"0.6773133"... | 0.0 | -1 |
split each text to sentences and lemmatize them | def lemmatize_texts_rus(texts):
sentenized = [[s.text for s in razdel.sentenize(t)] for t in texts]
texts_lengths = [len(t) for t in sentenized]
sentences = [s for t in sentenized for s in t]
sentences_lemm = lemmatize_sentences_rus(sentences)
texts_lemm = []
pos = 0
for text_length in tex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n tokens = nltk.word_tokenize(text)\n lemmatizer = nltk.WordNetLemmatizer()\n \n lemmatized_words = []\n for word in tokens:\n lemmatized_words.append(lemmatizer.lemmatize(word).lower().strip())\n \n return lemmatized_words",
"def lemmatize(text, nlp):\n\n r... | [
"0.74349856",
"0.73827",
"0.73166144",
"0.7313327",
"0.72395587",
"0.7236935",
"0.7212994",
"0.7168978",
"0.7167267",
"0.71459424",
"0.7134891",
"0.71328896",
"0.71247697",
"0.7122165",
"0.70692074",
"0.7052754",
"0.70327723",
"0.6982322",
"0.6970459",
"0.69619834",
"0.696016... | 0.7229475 | 6 |
split text to sentences and lemmatize them | def lemmatize_text_rus(text):
text_lemm, text_sent = lemmatize_texts_rus([text])
text_lemm, text_sent = text_lemm[0], text_sent[0]
return text_lemm, text_sent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n tokens = nltk.word_tokenize(text)\n lemmatizer = nltk.WordNetLemmatizer()\n \n lemmatized_words = []\n for word in tokens:\n lemmatized_words.append(lemmatizer.lemmatize(word).lower().strip())\n \n return lemmatized_words",
"def lemmatize(text, nlp):\n\n r... | [
"0.74687606",
"0.7379463",
"0.7352364",
"0.7350641",
"0.73457325",
"0.7255446",
"0.7248259",
"0.72482115",
"0.72330636",
"0.7232925",
"0.7229702",
"0.7224981",
"0.7206296",
"0.72050154",
"0.71733004",
"0.7151718",
"0.7150805",
"0.71412253",
"0.7116664",
"0.7115599",
"0.711261... | 0.6754644 | 41 |
At the end of the web request, this makes sure to close the database connection. If you don't the database could run out of memory! | def teardown_request(exception):
try:
g.conn.close()
except Exception as e:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_request():\n db.close()",
"def close(self):\r\n self.conn.close()\r\n gc.collect()",
"def cleanup(_):\n self.db.close()",
"def close(self): \n self.connection.close()",
"def close(self):\n\t\tself.db.close()",
"def after_request(response):\n g.db.close(... | [
"0.79804355",
"0.7822464",
"0.76400095",
"0.753811",
"0.7476291",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.74484444",
"0.7436082",
"0.7436082",
"0.74210554",
"0.74196386",
"0... | 0.0 | -1 |
r""" Return the valency of this component. The valency of a component is the number of its neighbors, i.e. the other components which intersect it. | def valency(self):
return len(self.neighbors()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vertex_valence(self, idx=-1):\n if idx >= len(self.vertices):\n raise IndexError\n if idx >= 0:\n return np.sum(self.adj[:, idx]) + np.sum(self.adj[idx, :]) - self.adj[idx, idx]\n else:\n return self.adj.sum(axis=1)",
"def len(self):\n return m... | [
"0.62729096",
"0.6243316",
"0.623081",
"0.6148876",
"0.60621613",
"0.60530674",
"0.60283023",
"0.60259414",
"0.6007848",
"0.6007041",
"0.59651446",
"0.59489393",
"0.59165126",
"0.5877464",
"0.5871133",
"0.5861997",
"0.58568466",
"0.58439356",
"0.58051497",
"0.5788457",
"0.577... | 0.8152268 | 0 |
r""" Return the list of the neighbors of this component. A neighbor of a component is another component which intersects it. | def neighbors(self):
vertex = self.vertex()
neighbors = vertex.children()
if vertex.has_parent():
neighbors.append(vertex.parent())
return [v._attr["component"] for v in neighbors if "component" in v._attr] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def neighbors(self):\n return self.mesh.neighbors()",
"def neighbors(self):\n return self._neighbors",
"def neighbors(self):\n return self.graph.neighbors(self.id)",
"def get_neighbors(self):\n \n return [neighbor for neighbor,_ in self.neighbors.items()]",
"def get_neigh... | [
"0.81812406",
"0.80785656",
"0.7881611",
"0.785588",
"0.7847207",
"0.7847207",
"0.7847207",
"0.7847207",
"0.77727705",
"0.7752649",
"0.7677221",
"0.76742136",
"0.7659327",
"0.7634686",
"0.76329654",
"0.75171083",
"0.74922645",
"0.7481735",
"0.73576885",
"0.73568803",
"0.73472... | 0.8313218 | 0 |
r""" Return the predecessors of this Berkovich point. | def predecessors(xi):
X_K = xi.berkovich_line()
if xi.is_limit_point():
xi = xi.approximation()
y = xi.parameter()
v = xi.pseudovaluation_on_polynomial_ring()
v_list = v.augmentation_chain()[1:-1]
return [X_K.point_from_pseudovaluation_on_polynomial_ring(w, y)
for w in v_list... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_predecessors(self, pos: tuple):\n return self.get_successors(pos)",
"def get_predecessors(self, node): \n preds = []\n child_state = self.node_to_state(node)\n for it in self.predecessors:\n parent_node = (node[0] + it[0], node[1] + it[1])\n parent_state = self.node_to_state(... | [
"0.77336574",
"0.74647355",
"0.7312377",
"0.70575607",
"0.6882676",
"0.6880616",
"0.6732077",
"0.6554532",
"0.653753",
"0.65045804",
"0.6453065",
"0.6411364",
"0.63785994",
"0.6357544",
"0.63340384",
"0.63139695",
"0.6280114",
"0.62689817",
"0.6225963",
"0.6188394",
"0.615328... | 0.7547226 | 1 |
r""" Return the critical residue class of this point. | def critical_residue_class(xi):
from sage.rings.infinity import Infinity
from mclf.berkovich.type_V_points import TypeVPointOnBerkovichLine
if not xi.type() == "II" or xi.is_gauss_point():
return None
v = xi.pseudovaluation_on_polynomial_ring()
v0 = v.augmentation_chain()[1]
if v.E() == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def piece_coor(self):\n return self.piece_type[self.rotation]",
"def cole_coeff(self):\n return self.diseq_coeff(standardize=True)",
"def CAMC_class_level(self, class_entity: und.Ent):\n if \"Interface\" in class_entity.kindname():\n return 2.\n\n percentage = class_entit... | [
"0.60656065",
"0.5724504",
"0.57177883",
"0.57002723",
"0.5605799",
"0.55595136",
"0.55285037",
"0.5497443",
"0.5497443",
"0.54714996",
"0.54711515",
"0.54708683",
"0.5463815",
"0.5455728",
"0.54204273",
"0.5417683",
"0.53726715",
"0.53391033",
"0.5333919",
"0.5327187",
"0.53... | 0.69958276 | 0 |
The current virtual price of the pool LP token Useful for calculating profits LP token virtual price normalized to 1e18 | def get_virtual_price() -> uint256:
D: uint256 = self._get_D(self._xp(), self._A())
# D is in the units similar to DAI (e.g. converted to precision 1e18)
# When balanced, D = n * x_u - total virtual value of the portfolio
token_supply: uint256 = ERC20(self.lp_token).totalSupply()
return D * PRECISIO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price(self):\n return self._safe_value(VAR_PRICE, float)",
"def desired_price(self):\n return self._desired_price",
"def base_price(self):\n return self._base_price",
"def current_price(self) -> Dict[str, int]:\n return self._current_price",
"def __get_deal_price(self):\n ... | [
"0.65932363",
"0.65562904",
"0.6510884",
"0.64934933",
"0.64291865",
"0.63204134",
"0.63109577",
"0.629016",
"0.62893933",
"0.62772155",
"0.62541765",
"0.62437177",
"0.62437177",
"0.62437177",
"0.6230178",
"0.6203097",
"0.6173806",
"0.6173806",
"0.6171493",
"0.61435056",
"0.6... | 0.8022648 | 0 |
Returns a list of ngrams, each ngram represented as a 4tuple of filename, utterance id, speaker name, and list of words in the ngram | def read_files(filenames, gram_size=1):
assert isinstance(filenames, list), "filenames argument must be a list"
parser = MorParser()
for fn in filenames:
for uid, speaker, ngram in generate_chunks(parser.parse(fn), gram_size):
yield fn, uid, speaker, ngram | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_ngrams():\n grams = ()\n for i in range(0, 40):\n text_i = read_file(str(i))\n curr_grams = ngramize(text_i, n)\n grams = chain(grams, curr_grams)\n return grams",
"def get_ngrams(self, n = None):\n if not n:\n n = self.N\n\n temp = []\n f... | [
"0.7511536",
"0.70480585",
"0.69828093",
"0.6834482",
"0.6822036",
"0.6762867",
"0.6735106",
"0.6734953",
"0.66730297",
"0.662533",
"0.6593495",
"0.65693355",
"0.6565634",
"0.65468997",
"0.65367264",
"0.65129817",
"0.6505234",
"0.65043163",
"0.649223",
"0.64910996",
"0.646233... | 0.5657222 | 94 |
Sets chrome options for Selenium. Chrome options for headless browser is enabled. | def set_chrome_options():
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_prefs = {}
chrome_options.experimental_options["prefs"] = chrome_prefs
chrome_prefs["profil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chrome_options(chrome_options):\n # https://pytest-selenium.readthedocs.io/en/latest/user_guide.html#id2\n chrome_options.add_argument(\"--headless\")\n return chrome_options",
"def get_driver_options():\n # Define Browser Options\n chrome_options = Options()\n chrome_options.add_argument(\... | [
"0.8496415",
"0.7502271",
"0.7380162",
"0.732335",
"0.7207787",
"0.72045255",
"0.7193336",
"0.71788657",
"0.71749604",
"0.7159074",
"0.69817954",
"0.6930866",
"0.69131696",
"0.68333215",
"0.67308944",
"0.66156524",
"0.65814704",
"0.6520646",
"0.64218086",
"0.6401822",
"0.6392... | 0.8364757 | 1 |
Return the renderable's type (or class) | def getType(self, renderable):
if hasattr(renderable, 'type'):
return renderable.type
return renderable.__class__.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type(self):\n return self.type",
"def get_type(self):\n return self.type",
"def get_type ( self, object ):\n return self.type",
"def get_type ( self, object ):\n return self.type",
"def _get_type(self):\n return self.__type",
"def _get_type(self):\n return self._... | [
"0.738765",
"0.738765",
"0.7356796",
"0.7356796",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0.72969824",
"0... | 0.87245935 | 0 |
Gets the URI (file) as a steam | def get(self, uri, text=False):
osaka.utils.LOGGER.debug(
"Getting stream to URI: {0} Note: Using HTTP GET".format(uri)
)
# Use the standard HTTP handler for getting the product
return self.httpHandler.get(re.compile("^dav").sub("http", uri), text=text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file(URI):\n return file_fabric.get_class(URI).get_content(URI)",
"def get_url(self):\n return self.get_file(uri_type=URI_URL, no_copy=True)",
"def getSource(self):\n return urllib2.urlopen(Parser.SOURCE_URL)",
"def get_file(self):\n return self.theFile",
"def get_url(self):\n ... | [
"0.6582305",
"0.65651655",
"0.6001005",
"0.5889885",
"0.5810439",
"0.58087236",
"0.57913876",
"0.5754765",
"0.574611",
"0.57455057",
"0.5726757",
"0.5621217",
"0.56021684",
"0.5600786",
"0.5595253",
"0.55704397",
"0.5549709",
"0.55440325",
"0.5542883",
"0.5542883",
"0.5542883... | 0.0 | -1 |
Test that BadEmailRecipient is raised correctly | def test_bademail(mock_smtp):
msg_values = {'sender': 'dummy@moc.org',
'receiver': 'newuser1@moc.org',
'subject': 'Test Message Subject',
'body': 'This is a Test.'}
rejected_recipients = ['bademail1@moc.org', 'bademail2@moc.org']
msg = Message... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email_badAuth(get_email):\n e = get_email\n e.auth = 'baDp@ssw0rd'\n\n with pytest.raises(MessageSendError):\n e.send()",
"def test_failed_email(self):\n self.assertEqual(send_email(\"testtestcom\", \"test\", \"test\"), 'There was an error sending')",
"def test_bad_email_is_reje... | [
"0.76745105",
"0.7439456",
"0.7381916",
"0.73518157",
"0.7336578",
"0.7319879",
"0.72991",
"0.72176707",
"0.7176044",
"0.71172804",
"0.7101039",
"0.7054247",
"0.70468605",
"0.7007666",
"0.69897413",
"0.69525427",
"0.69355714",
"0.6870197",
"0.6861531",
"0.6830244",
"0.6777513... | 0.7262134 | 7 |
Determine the indices for labels that are not corrupted in the dataset. | def get_valid_indices(labels):
idxs = (labels != invalid_labels[0])
for l in invalid_labels[1:]:
idxs = idxs & (labels != l)
return idxs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unlabeled_idx(X_train, labeled_idx):\n return np.arange(X_train.shape[0])[np.logical_not(np.in1d(np.arange(X_train.shape[0]), labeled_idx))]",
"def test_label_indices_unknown():\n with pytest.raises(ValueError):\n util.get_label_indices(3, \"random_str\")",
"def labeled_indices(self):\n ... | [
"0.71164936",
"0.6890843",
"0.66725874",
"0.6499322",
"0.6470832",
"0.6461701",
"0.6385171",
"0.63188404",
"0.6288615",
"0.62110835",
"0.6081898",
"0.60789007",
"0.6048194",
"0.60084397",
"0.60058415",
"0.5992234",
"0.5959932",
"0.59489834",
"0.59395844",
"0.5922739",
"0.5922... | 0.767029 | 0 |
Add a colorbar to the right of an axis. | def _add_colorbar(self, im, ax, colormap, label=""):
import matplotlib as mpl
pos = ax.get_position()
cpos = [pos.x1 + pos.width * 0.01, pos.y0 + pos.height*.1,
0.01, pos.height * 0.8] # this list defines (left, bottom, width, height
cax = self.fig.add_axes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_colorbar(self, fig, ax, norm, colormap, label=\"\"):\n import matplotlib as mpl\n pos = ax.get_position()\n cpos = [pos.x1 + 0.025, pos.y0 + 0.0125,\n 0.015, pos.height * 0.8] # this list defines (left, bottom, width, height\n cax = fig.add_axes(cp... | [
"0.7577057",
"0.7577057",
"0.7418903",
"0.74102116",
"0.7179385",
"0.71613485",
"0.71574956",
"0.6979866",
"0.6953447",
"0.6930779",
"0.67889935",
"0.6788904",
"0.6615177",
"0.6534736",
"0.6524789",
"0.65199506",
"0.6450172",
"0.6343112",
"0.62681675",
"0.62551737",
"0.625244... | 0.7166474 | 5 |
Add a colorbar to the right of an axis. | def _add_hcolorbar(self, im, colormap="jet_r", label=""):
pos = self.ax.get_position()
cpos = [
pos.x0 + 0.3 * pos.width,
pos.y0 - 0.15 * pos.height,
pos.width * 0.5,
0.02,
] # this list defines (left, bottom, width, height)
cax = self.fig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_colorbar(self, fig, ax, norm, colormap, label=\"\"):\n import matplotlib as mpl\n pos = ax.get_position()\n cpos = [pos.x1 + 0.025, pos.y0 + 0.0125,\n 0.015, pos.height * 0.8] # this list defines (left, bottom, width, height\n cax = fig.add_axes(cp... | [
"0.7577057",
"0.7577057",
"0.7418903",
"0.74102116",
"0.7179385",
"0.7166474",
"0.71613485",
"0.71574956",
"0.6979866",
"0.6953447",
"0.6930779",
"0.67889935",
"0.6788904",
"0.6615177",
"0.6534736",
"0.6524789",
"0.6450172",
"0.6343112",
"0.62681675",
"0.62551737",
"0.625244"... | 0.65199506 | 16 |
Add a colorbar to the right of an axis. | def _add_colorbar(self, im, colormap="jet_r", label=""):
pos = self.ax.get_position()
cpos = [
pos.x1 + 0.15,
pos.y0 + 0.2 * pos.height,
0.02,
pos.height * 0.5,
] # this list defines (left, bottom, width, height)
cax = self.fig.add_axes(cp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_colorbar(self, fig, ax, norm, colormap, label=\"\"):\n import matplotlib as mpl\n pos = ax.get_position()\n cpos = [pos.x1 + 0.025, pos.y0 + 0.0125,\n 0.015, pos.height * 0.8] # this list defines (left, bottom, width, height\n cax = fig.add_axes(cp... | [
"0.75750417",
"0.75750417",
"0.7417919",
"0.7408142",
"0.71787065",
"0.7165443",
"0.7160115",
"0.71563584",
"0.6978977",
"0.6928187",
"0.67887163",
"0.6787255",
"0.66141695",
"0.6534215",
"0.6523998",
"0.65192235",
"0.64490265",
"0.6341669",
"0.6268099",
"0.62562",
"0.6251723... | 0.69518185 | 9 |
Returns true if there is a forgetful map out of this space. | def not_pushed_down(self):
return (self.genus >= 2 and self.n != 0) or (self.genus == 1 and self.n > 1) or (self.genus == 0 and self.n > 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkMap(self):\n return True",
"def __nonzero__(self):\n\n return not ipset.ipmap_is_empty(self.map)",
"def is_empty(self):\n\n return ipset.ipmap_is_empty(self.map)",
"def is_unoccupied(self, row, col):\n return self.maze[row][col] is EMPTY",
"def is_full(self):\n i... | [
"0.67249465",
"0.66899806",
"0.66786814",
"0.6617099",
"0.65594023",
"0.6538555",
"0.65054786",
"0.64949316",
"0.6427947",
"0.6398569",
"0.63808787",
"0.6360524",
"0.63576496",
"0.6355212",
"0.6343116",
"0.6303801",
"0.62969935",
"0.62950987",
"0.6289435",
"0.6248638",
"0.619... | 0.0 | -1 |
Get the database and check that the current user has write access. Optionally add nrows for each table and view. Raise KeyError if no such database. Raise ValueError if may not access. | def get_check_write(dbname, check_mode=True, nrows=False, complete=True):
db = get_db(dbname, complete=complete)
if db is None:
raise KeyError("no such database")
if not has_write_access(db, check_mode=check_mode):
raise ValueError("may not write to the database")
set_nrows(db, targets=n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_check_read(dbname, nrows=False, complete=True):\n db = get_db(dbname, complete=complete)\n if db is None:\n raise KeyError(\"no such database\")\n if not has_read_access(db):\n raise ValueError(\"may not read the database\")\n set_nrows(db, targets=nrows)\n return db",
"def _... | [
"0.62008744",
"0.5717889",
"0.5461007",
"0.54139274",
"0.5394495",
"0.53823745",
"0.5362482",
"0.53576916",
"0.5351964",
"0.5261355",
"0.51136035",
"0.4998261",
"0.4941331",
"0.4937972",
"0.49325716",
"0.48510417",
"0.4825769",
"0.48031938",
"0.47883636",
"0.47742996",
"0.476... | 0.6900375 | 0 |
Check if the authenticated user has 'admin' or 'attendant' role If 'admin' authorize, else if 'attendant' deny access | def post(self):
data = ProductsResource.parser.parse_args()
for user in User.users:
if user.role == 'attendant' and user.username == auth.username():
return {'message': 'Not authorised to access '}, 401
if user.role == 'admin' and user.username == auth.username()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_auth():\n if not current_user.is_authenticated:\n return render_template('401.html', base_template=appbuilder.base_template, appbuilder=appbuilder), 401\n for role in current_user.roles:\n if appbuilder.get_app.config['AUTH_ROLE_ADMIN'] == role.name:\n return None\n retu... | [
"0.7119449",
"0.68774784",
"0.6872807",
"0.6872807",
"0.6767177",
"0.6740289",
"0.67216414",
"0.6694622",
"0.66614085",
"0.65831244",
"0.6548067",
"0.6539639",
"0.6518462",
"0.651116",
"0.6498799",
"0.64806175",
"0.64806175",
"0.6465556",
"0.6463639",
"0.6463639",
"0.6443175"... | 0.0 | -1 |
Count the Chinese characters in the text. | def stats_text_cn(text):
text1 = text.replace(',','').replace('.','').replace('--','').replace('*','').replace('!','') # Remove the non-Chinese characters in the text.
text2 = list(text1) # Convert the string type to the list type.
dict = {x: text2.count(x) for x in text2} # Count the times of each characte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(text):\n return len(text)",
"def test_character_count(self):\n\t\tself.assertEqual(analyse_text(self.filename)[1], 133)",
"def getWordCharCount(w):\r\n rus = len(re.findall(r\"[а-я]\",w))\r\n eng = len(re.findall(r\"[a-z]\",w))\r\n c = len(w) \r\n return c, rus, eng",
"def test_ch... | [
"0.67015",
"0.6607649",
"0.6606629",
"0.6590809",
"0.65797144",
"0.6475554",
"0.6430852",
"0.61501974",
"0.6050413",
"0.60285336",
"0.6015077",
"0.59781206",
"0.5967439",
"0.5922929",
"0.5896226",
"0.58794916",
"0.585383",
"0.58402056",
"0.5804242",
"0.57875055",
"0.5774597",... | 0.6177398 | 7 |
Check than array of values specified using `c` can be used for a colormap. | def test_color_cmap_c_combination(self):
arr = self.arr
out = ternary(arr, c=np.linspace(0, 10, 10), cmap="viridis")
self.assertTrue(hasattr(out, "tax"))
self.assertEqual(
type(out.tax), pyternary.ternary_axes_subplot.TernaryAxesSubplot
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_color(c):\n\n c = asarray(c)\n if c.ndim == 1:\n c = c.flatten()\n c = c[newaxis, :]\n if c.shape[1] != 3:\n raise Exception(\"Color must have three values per point\")\n elif c.ndim == 2:\n if c.shape[1] != 3:\n raise Exception(\"Color array mus... | [
"0.7522997",
"0.6399244",
"0.6233486",
"0.61515546",
"0.5972068",
"0.5734837",
"0.5714697",
"0.57047075",
"0.56964606",
"0.5671895",
"0.5666058",
"0.5661867",
"0.5612082",
"0.5578248",
"0.5551499",
"0.5532785",
"0.5467735",
"0.5461801",
"0.54509157",
"0.5412546",
"0.5403892",... | 0.6554897 | 1 |
Creates the `ImageSearcher` object from a TensorFlow Lite model. | def create_from_file(
cls,
model_file_path: str,
index_file_path: Optional[str] = None) -> "ImageSearcher":
options = ImageSearcherOptions(
base_options=_BaseOptions(file_name=model_file_path),
search_options=_SearchOptions(index_file_name=index_file_path))
return cls.create_fr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_from_model_path(cls, model_path: str) -> 'FaceDetector':\n base_options = _BaseOptions(model_asset_path=model_path)\n options = FaceDetectorOptions(\n base_options=base_options, running_mode=_RunningMode.IMAGE\n )\n return cls.create_from_options(options)",
"def from_pretrained(\n ... | [
"0.58416957",
"0.57176334",
"0.5706374",
"0.54603827",
"0.54595345",
"0.5452045",
"0.5437048",
"0.5412006",
"0.53853303",
"0.5357966",
"0.53444433",
"0.53190815",
"0.53147674",
"0.5314517",
"0.53105253",
"0.5305688",
"0.5271952",
"0.51935625",
"0.5188544",
"0.51859486",
"0.51... | 0.5662296 | 3 |
Instantiate an ASVspoof dataset. | def __init__(self, root, partition, filt=None, read=None, transform=None):
self._evalkey = None
if partition == 'train':
root = os.path.join(root, 'ASVspoof2017_V2_train')
elif partition == 'valid':
root = os.path.join(root, 'ASVspoof2017_V2_dev')
elif partition =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset):\n self._dataset = dataset",
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def __init__(self, data, v1, v2):\n self.data = data\n self.v1 = v1\n self.v2 = v2",
"def _create_dataset(source=''):\n return ExperimentalData... | [
"0.56661063",
"0.5572199",
"0.55397993",
"0.5510062",
"0.54108816",
"0.53719366",
"0.5366002",
"0.5346476",
"0.5346476",
"0.5341396",
"0.5331791",
"0.5322447",
"0.53083295",
"0.53056693",
"0.5285903",
"0.52816117",
"0.52505565",
"0.5217569",
"0.5214454",
"0.5191689",
"0.51868... | 0.5287663 | 14 |
Initialisation of weights and biases for the embedding layer and the RNN layers. | def initialise_weights(self):
def initialise_process(param):
"""
Initialises weights of a given parameter following either Xavier or Kaiming uniform or normal processes.
: param (torch.Tensor):
"""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_layer(self.conv1)\n init_layer(self.conv2)\n init_bn(self.norm1)\n init_bn(self.norm2)",
"def instantiate_weights(self):\n with tf.variable_scope(\"embedding_projection\"), tf.device('/cpu:0'): # embedding matrix\n self.Embedding = tf.g... | [
"0.77943677",
"0.7777627",
"0.76114255",
"0.76029295",
"0.7508789",
"0.7387998",
"0.73835915",
"0.73677576",
"0.73591816",
"0.73591816",
"0.73591816",
"0.73556024",
"0.73530215",
"0.72580236",
"0.72257406",
"0.71798956",
"0.71372914",
"0.71090186",
"0.7084901",
"0.70644426",
... | 0.66120446 | 67 |
Initialises weights of a given parameter following either Xavier or Kaiming uniform or normal processes. | def initialise_process(param):
if self._initialisation_process == 'xavier_uniform':
tnni.xavier_uniform_(param.data)
elif self._initialisation_process == 'xavier_normal':
tnni.xavier_normal_(param.data)
elif self._initialisation_process ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\r\n xavier_init(self.output_proj, distribution='uniform', bias=0.)",
"def init_weights_(self):\n raise NotImplementedError",
"def initialise_weights(self): \n \n def initialise_process(param):\n \n \"\"\"\n Initialises weight... | [
"0.75284606",
"0.7397868",
"0.7371006",
"0.7275698",
"0.72356653",
"0.7192996",
"0.7187742",
"0.71090496",
"0.7088423",
"0.7076657",
"0.7066805",
"0.70589423",
"0.70522285",
"0.70522285",
"0.6999897",
"0.69886106",
"0.6960581",
"0.69561607",
"0.69436896",
"0.6931591",
"0.6925... | 0.65751314 | 54 |
Returns the list of container registries each of which is an ordered dictionary. | def output_format(result):
if 'value' in result and isinstance(result['value'], list):
result = result['value']
obj_list = result if isinstance(result, list) else [result]
return [_format_group(item) for item in obj_list] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_registries():\n url = \"/\".join([REGISTRY_BASE, \"_catalog\"])\n response = req(url)\n if response is not None:\n return response[\"repositories\"]\n return []",
"def containers(self):\r\n return [JSONContainer(c) for c\r\n in self.container.get(\"Containers\", [... | [
"0.69137096",
"0.6764479",
"0.6561832",
"0.6402633",
"0.6357411",
"0.62526804",
"0.61654025",
"0.612648",
"0.60717183",
"0.60332584",
"0.60280293",
"0.60130984",
"0.59799194",
"0.5978797",
"0.59747064",
"0.5971127",
"0.5962707",
"0.59357166",
"0.5931848",
"0.588443",
"0.58628... | 0.0 | -1 |
Returns an ordered dictionary of the container registry. | def _format_group(item):
table_info = {_property_map[key]: str(item[key]) for key in item if key in _property_map}
try:
table_info['SKU'] = item['sku']['name']
except (KeyError, TypeError):
pass
try:
table_info['USERNAME'] = item['username']
except (KeyError, TypeError):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_registry_keys( ):\n return _theRegistry.get_codes().keys()",
"def registry(self):\n if self._registry is None:\n print('Creating container registry...')\n registry_ops = self.registry_client.registries\n try:\n registry = registry_ops.get(\n ... | [
"0.67599016",
"0.6461334",
"0.6459659",
"0.64198136",
"0.64024276",
"0.63673127",
"0.6053186",
"0.6050705",
"0.5892358",
"0.5852548",
"0.58208233",
"0.5747135",
"0.5703876",
"0.5644097",
"0.5632085",
"0.5615898",
"0.56062925",
"0.5587612",
"0.558675",
"0.55411214",
"0.5534757... | 0.0 | -1 |
@ get all episodes in selected asset type, and if project type is not series then return None. | def bsw_getAllAssetEpisodes(astType):
# get basic inputs.
basePath = ProjectNamingInputs().basePath
projectName = ProjectNamingInputs().projectName
assetType = ProjectNamingInputs().assetType
projectType = ProjectNamingInputs().projectType
if projectType == 'series':
episodeDir = '{baseP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_episodes(self):\n return [series_episode for series_episode in SeriesEpisode.objects.filter(series=self)]",
"def episodes(self):\n if self._episode_cache_ver == self._db._version:\n return self._episode_cache\n\n # Get only rows from the preferred provider (provider id is... | [
"0.6472294",
"0.6238427",
"0.6109521",
"0.6061909",
"0.58215487",
"0.5817781",
"0.56866485",
"0.5580703",
"0.5557396",
"0.5460225",
"0.5414427",
"0.5404259",
"0.5401844",
"0.53146833",
"0.53129226",
"0.51491994",
"0.51185447",
"0.5114288",
"0.5105471",
"0.50925493",
"0.507416... | 0.7465757 | 0 |
Returns the active projects for the client. | def active_projects(self):
return self.projects.filter(active=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects(self):\n return conf.projects",
"def get_client_projects(self, client=None):\n if type(client) is Client:\n return [p for p in self.project_list if client.client_id == p.client_id]",
"def get_projects(self):\n return self.http_call(\"get\", url=f\"{self.base_url... | [
"0.79490113",
"0.7929667",
"0.77085984",
"0.7485822",
"0.7469964",
"0.74452794",
"0.74072176",
"0.73590404",
"0.7318829",
"0.724942",
"0.7204794",
"0.71989226",
"0.719029",
"0.7152463",
"0.7124276",
"0.7114484",
"0.7078646",
"0.7010834",
"0.7005374",
"0.6980954",
"0.6970034",... | 0.8063469 | 0 |
Return the Writer class from the `writer_name` module. | def get_writer_class(writer_name):
writer_name = writer_name.lower()
if writer_name in _writer_aliases:
writer_name = _writer_aliases[writer_name]
try:
module = __import__(writer_name, globals(), locals(), level=1)
except ImportError:
module = __import__(writer_name, globals(), l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_writer_class(cls) -> 'Type[SpectrumWriter]':\n raise NotImplementedError(SpectrumReader.get_writer_class.__qualname__)",
"def _get_writer(self, writer_name):\r\n if writer_name not in self._writers:\r\n path = os.path.join(self.log_dir, writer_name)\r\n writer = summary_ops_v2.create_... | [
"0.69305336",
"0.6689665",
"0.6409046",
"0.62630635",
"0.6220382",
"0.58785063",
"0.5845479",
"0.5839867",
"0.58295506",
"0.56432635",
"0.5637954",
"0.5606227",
"0.5554922",
"0.5537747",
"0.5523522",
"0.5474596",
"0.5463936",
"0.54269594",
"0.5412886",
"0.54028976",
"0.538162... | 0.9022644 | 0 |
Create and save a User with the given email and password. | def _create_user(self, email, password, **extra_fields):
if not email:
raise ValueError('The given email must be set')
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user",
"def... | [
"0.8545239",
"0.85126233",
"0.8508934",
"0.85035056",
"0.8503207",
"0.8490302",
"0.8490302",
"0.84895617",
"0.84895617",
"0.84895617",
"0.84866524",
"0.84778446",
"0.8476501",
"0.8457027",
"0.8457027",
"0.8457027",
"0.8455693",
"0.84490657",
"0.84451187",
"0.84442055",
"0.844... | 0.84760785 | 20 |
Logs a message at the ``WARNING`` log level. | def handle_warning(self, api, command):
return self.handle_log(api, command, level=logging.WARNING) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warn(self, message: str):\n self.log(Level.WARNING, message)",
"def warning(warning_message: str):\n logger.warning(warning_message)",
"def warning(message: str, *args: Any) -> None:\n Logger.log(logging.WARN, message, *args)",
"def logwarning(self, msg):\n self.logger.warning(msg... | [
"0.851772",
"0.8506773",
"0.85006905",
"0.8482524",
"0.84166867",
"0.8413865",
"0.8361264",
"0.8316793",
"0.82993543",
"0.8275807",
"0.82646966",
"0.82539433",
"0.82478034",
"0.8244659",
"0.823924",
"0.8237153",
"0.82192165",
"0.8213992",
"0.82070726",
"0.8206089",
"0.8191427... | 0.0 | -1 |
Make an HTTP PATCH request. | def handle_patch(self, api, command):
return self._make_request_from_command('PATCH', command) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def httpPatch(self, url='', data='', params={}, headers={}):\n\n return self.httpRequest('PATCH', url, data, params, headers)",
"def patch(url, data=None, **kwargs):\n\n return request('patch', url, data=data, **kwargs)",
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kw... | [
"0.8377986",
"0.77408034",
"0.7737159",
"0.7708333",
"0.7624386",
"0.7548285",
"0.75311804",
"0.75118834",
"0.74857336",
"0.73733705",
"0.7367035",
"0.7365305",
"0.73553634",
"0.73553634",
"0.73553634",
"0.7353132",
"0.7337053",
"0.7293803",
"0.72613055",
"0.7235854",
"0.7191... | 0.72490084 | 19 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
backup_all_existing_snapshot = dictionary.get('backupAllExistingSnapshot')
blacklisted_ip_addrs = dictionary.get("blacklistedIpAddrs")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83185387",
"0.81679726",
"0.81679726",
"0.81194353",
"0.80894536",
"0.79789025",
"0.7949881",
"0.7922983",
"0.7898846",
"0.7892914",
"0.7888425",
"0.7882915",
"0.7882119",
"0.78765213",
"0.7858605",
"0.78363335",
"0.78024834",
"0.78024834",
"0.78024834",
"0.78024834",
"0.7... | 0.0 | -1 |
Return a function to open a (gzipped) file. | def _open(fname: str, mode: Optional[str] = "r"):
if mode not in ["r", "w"]:
raise ValueError("mode must be either 'r' or 'w'.")
if fname.endswith(".gz"):
return gzip.open(fname, mode + "t")
return open(fname, mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_gz(filename, mode):\n return gzip.open(filename, mode)",
"def open_gzip(fn):\n magic = b'\\x1f\\x8b\\x08'\n l = len(magic)\n with open(fn, 'rb') as f:\n file_start = f.read(l)\n f.seek(0)\n # check if the file is compressed\n if file_start.startswith(magic):\n retu... | [
"0.82734615",
"0.8186003",
"0.8017077",
"0.78277725",
"0.7727428",
"0.7643111",
"0.73564893",
"0.73564893",
"0.732356",
"0.7103141",
"0.70543605",
"0.70016134",
"0.6944863",
"0.6920207",
"0.6873506",
"0.66928023",
"0.66770685",
"0.6631664",
"0.6631664",
"0.6600424",
"0.658002... | 0.677487 | 15 |
Function to tokenize a sentence (break up into words) based on the TOKENIZER regex | def tokenize(text: str) -> list:
TOKENIZER = re.compile(f'([!"#$%&\'()*+,-./:;<=>?@[\\]^_`|~“”¨«»®´·º½¾¿¡§£₤‘’\n\t])')
return TOKENIZER.sub(r' \1 ', text).split() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(sentence):\n return nltk.word_tokenize(sentence)",
"def tokenize(sentence):\n ret = []\n #for token in re.split('\\W+', sentence):\n for token in sentence.split(' '):\n token = token.strip()\n if not len(token):\n continue\n if token[-1] == '.' or token[-1... | [
"0.78913397",
"0.7821764",
"0.77582806",
"0.7687089",
"0.7668706",
"0.76109326",
"0.75864846",
"0.7557652",
"0.7526917",
"0.7497942",
"0.7435132",
"0.73910666",
"0.73733234",
"0.7371356",
"0.7359411",
"0.7332259",
"0.7331818",
"0.7313859",
"0.7303731",
"0.72848535",
"0.727875... | 0.0 | -1 |
Returns whether a string is a number or not | def is_digit_regex(s: str) -> bool:
if re.match("^\d+?\.\d+?$", s) is None:
return s.isdigit()
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_number(string):\r\n try:\r\n float(string)\r\n return True\r\n except ValueError: return False",
"def is_number(string):\n try:\n float(string)\n return True\n except ValueError:\n return False",
"def is_number(s):\r\n try:\r\n int(s)\r\n r... | [
"0.8744992",
"0.872017",
"0.86263174",
"0.861253",
"0.8594354",
"0.8553676",
"0.8550075",
"0.8513001",
"0.8513001",
"0.8513001",
"0.84561634",
"0.8438337",
"0.8430808",
"0.8331034",
"0.83163124",
"0.8291856",
"0.82304853",
"0.82140267",
"0.8140006",
"0.8120189",
"0.81172305",... | 0.7522996 | 48 |
computes the distance of a given cell to the enemy position | def dist(dm, sm, neighbors):
# Initialize list of possible distances
distances = []
# loop over all neighbors of the cell
for neighbor in neighbors:
# If the neighbor is valid
if dm[neighbor[0], neighbor[1]] != -1:
# add neighbor distance + 1 to possible distances
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist(unit, tile):\n return abs(tile['x'] - unit['x']) + abs(tile['y'] - unit['y'])",
"def distance_to_location(self, row, col):\n return float(sqrt(pow(self._row - row, 2) + pow(self._col - col, 2)))",
"def measure_distance(cell1, cell2):\n\n\tx1, y1 = cell1.location\n\tx2, y2 = cell2.location\n\... | [
"0.67895997",
"0.6736873",
"0.6661446",
"0.6541716",
"0.6479071",
"0.64211947",
"0.64211947",
"0.63727576",
"0.6362925",
"0.6362459",
"0.6351663",
"0.6339557",
"0.63383836",
"0.6333318",
"0.6301942",
"0.62578773",
"0.625512",
"0.6253803",
"0.62491465",
"0.62274194",
"0.622731... | 0.0 | -1 |
Return a tuple of two ints from 1 or 2 intish things. | def _tuple_from_one_or_two_ints(self, v):
try:
a, b = [int(x) for x in v]
except TypeError:
a, b = int(v), int(v)
return (a,b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_tuple(v: Union[int, Tuple[int, int]]) ->Tuple[int, int]:\n if torch.jit.isinstance(v, int):\n return v, v\n else:\n return v",
"def _to_tuple(values: Union[int, Iterable[int]]) -> Tuple[int, ...]:\n try:\n return tuple(values)\n except TypeError:\n return (values,)"... | [
"0.7521668",
"0.71872586",
"0.67897296",
"0.66056657",
"0.6550124",
"0.6381458",
"0.63615984",
"0.63500184",
"0.63150114",
"0.6306386",
"0.6288212",
"0.6223996",
"0.6137928",
"0.61346763",
"0.6120724",
"0.61114156",
"0.6105132",
"0.60968715",
"0.6076315",
"0.6074093",
"0.6072... | 0.81066763 | 0 |
Returns dictionary of placeholders that must be fed. Only valid after network() has been run. | def placeholders(self):
rv = dict()
for stage in self.stages:
for name, ph_var in stage.placeholders:
rv[name] = ph_var
return rv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def placeholders(self):\n x = [i.placeholder for i in self._input_desc]\n return x[0] if len(x) == 1 else x",
"def _validate_placeholders(self):\n if self.implementation.container is None:\n return\n\n valid_inputs = {} if self.inputs is None else self.inputs\n valid... | [
"0.6215448",
"0.6073801",
"0.592821",
"0.5835194",
"0.5761858",
"0.5752826",
"0.5747895",
"0.56185067",
"0.55785143",
"0.557546",
"0.5575306",
"0.5567209",
"0.5552609",
"0.5547895",
"0.5461414",
"0.54389316",
"0.5426337",
"0.5407213",
"0.5380769",
"0.5353769",
"0.5327057",
... | 0.6491004 | 0 |
Checks if this notification should be sent or not | def check_ratelimit(db, notification_object, override=False):
notification_priority = notification_object['priority_level']
to_username = notification_object['to_username']
if notification_priority == Priority.ALWAYS:
logger.debug('PRIORITY ALWAYS Checking')
return db.get_priority_count(t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_notification(self) -> bool:\n return pulumi.get(self, \"send_notification\")",
"def non_compliant_notification(self) -> bool:\n return pulumi.get(self, \"non_compliant_notification\")",
"def non_compliant_notification(self) -> bool:\n return pulumi.get(self, \"non_compliant_notifi... | [
"0.7569572",
"0.72110873",
"0.72110873",
"0.71615547",
"0.7113662",
"0.6953311",
"0.6791438",
"0.67768735",
"0.65806925",
"0.6497984",
"0.6497984",
"0.6497984",
"0.6437435",
"0.6412014",
"0.6401645",
"0.6398709",
"0.63752735",
"0.63381314",
"0.6334512",
"0.6313075",
"0.628304... | 0.0 | -1 |
Return the path to the image file. | def FindImage(image_path):
if os.path.isdir(image_path):
# Assume base image.
image_file = os.path.join(image_path, constants.BASE_IMAGE_NAME + '.bin')
if not os.path.exists(image_file):
raise ValueError('Cannot find base image %s' % image_file)
elif os.path.isfile(image_path):
image_file = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imagePath(self):\n return self.path",
"def get_pathname(self):\n return self.image_data.path",
"def imagefile(self):\n return os.path.join(self.__folder, self.__name + '.jpg')",
"def get_image_path(self) -> Optional[str]:\n if not self.image or not self.image.file_path:\n ... | [
"0.8316106",
"0.8163531",
"0.81182754",
"0.7961282",
"0.7760827",
"0.769565",
"0.76003695",
"0.75976634",
"0.7590159",
"0.75808513",
"0.7478475",
"0.74614805",
"0.7457801",
"0.7451773",
"0.7395841",
"0.7384844",
"0.7317921",
"0.72773635",
"0.7273996",
"0.72732276",
"0.7266428... | 0.0 | -1 |
Email and phone are optional, but one must be informed | def test_must_inform_email_or_phone(self):
form = self.make_validator_form(phone='', email='')
# Identifica erro no formulário e não em um campo.
self.assertListEqual(['__all__'], list(form.errors)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_must_inform_email_or_phone(self):\n form = self.make_validated_form(email='',phone='')\n self.assertListEqual(['__all__'], list(form.errors))",
"def test_must_inform_email_or_phone(self):\r\n form = self.make_validated_form(email='', phone='')\r\n self.assertListEqual(['__all... | [
"0.75361687",
"0.7490287",
"0.7065026",
"0.6368576",
"0.6270754",
"0.6209141",
"0.619869",
"0.6197438",
"0.6183619",
"0.6181492",
"0.6180816",
"0.6178619",
"0.61082476",
"0.60776365",
"0.60598195",
"0.6025348",
"0.6018382",
"0.60004056",
"0.59906375",
"0.59758604",
"0.595008"... | 0.73785985 | 2 |
Test if this node is the network node. | def is_network_node():
return config.NODE_IP == config.NETWORK_NODE_IP | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_network_type(self, name):\n nt = self.config[\"networks\"].get(name)\n return bool(nt)",
"def has_node(self, name):\n return self.source_net.has_node(name)",
"def __contains__ (self, item):\n if isinstance(item, Node):\n item = item.id\n return item in self.network",
"... | [
"0.7338448",
"0.68739766",
"0.6680434",
"0.6630339",
"0.6630339",
"0.66011393",
"0.6267848",
"0.62573254",
"0.62540036",
"0.61622053",
"0.61584145",
"0.6156845",
"0.61213005",
"0.6108773",
"0.60500073",
"0.6039537",
"0.60387963",
"0.60387963",
"0.60387963",
"0.5994629",
"0.59... | 0.831017 | 0 |
Returns time difference from starting time | def time_diff(start_time, end_time=None, choice='millis'):
if end_time is None:
end_time = datetime.now()
timediff = (end_time - start_time)
if choice == 'millis':
return timediff.seconds * 1000 + int(timediff.microseconds) / 1000
elif choice == 'micros':
return timediff.seconds ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_time(start_time):\r\n return round(time() - start_time, 2)",
"def get_time_diff(start_time, end_time):\n time_diff = end_time - start_time\n return timedelta(seconds=int(round(time_diff)))",
"def get_time_delta(start):\n\tend = datetime.now()\n\tduration = ((end-start).microseconds)/1000... | [
"0.8108136",
"0.75064516",
"0.74752355",
"0.74312955",
"0.7354597",
"0.73346627",
"0.7060144",
"0.7047898",
"0.70433176",
"0.7029544",
"0.6975039",
"0.6962269",
"0.69382143",
"0.69247186",
"0.6920252",
"0.68807906",
"0.686269",
"0.6860179",
"0.68554264",
"0.6852525",
"0.68067... | 0.66099024 | 37 |
Return as a list of field choices. | def as_choices():
return (
# Live is currently disabled as a choice
# pending implementation
("live", "Use working directory"),
("latest", "Use latest snapshot"),
("pinned", "Pinned to snapshot"),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_choices_for_model_field(cls):\n return [c[0:2] for c in cls.attr_choices]",
"def get_choices(self):\n raise NotImplementedError()",
"def get_choices(self):\n raise NotImplementedError()",
"def choices(self, typename, value_field='description'):\n rows = self.type(typename)... | [
"0.80070734",
"0.7434968",
"0.7434968",
"0.7353117",
"0.7302724",
"0.72494674",
"0.71962416",
"0.7108783",
"0.69741213",
"0.69617325",
"0.6852431",
"0.6775638",
"0.6750487",
"0.6722035",
"0.6578648",
"0.6571623",
"0.6537159",
"0.6513538",
"0.64543384",
"0.64526904",
"0.645085... | 0.0 | -1 |
Get the scheduled deletion time of a temporary project. | def scheduled_deletion_time(self) -> Optional[datetime.datetime]:
if not self.temporary:
return None
delta = Project.TEMPORARY_PROJECT_LIFESPANS.get(
self.account.name, Project.TEMPORARY_PROJECT_LIFESPANS.get("default")
)
return self.created + delta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduled_deletion_warning(self) -> Optional[datetime.datetime]:\n time = self.scheduled_deletion_time\n return time - Project.TEMPORARY_PROJECT_WARNING if time else None",
"def delete_time(self) -> str:\n return pulumi.get(self, \"delete_time\")",
"def delete_time(self) -> str:\n ... | [
"0.6921164",
"0.6562803",
"0.6562803",
"0.6188812",
"0.58171326",
"0.5730795",
"0.5701719",
"0.5518333",
"0.55177927",
"0.5512329",
"0.54670966",
"0.5458026",
"0.54461396",
"0.5335375",
"0.53240615",
"0.5315584",
"0.5306388",
"0.5295981",
"0.5270675",
"0.5270596",
"0.5227072"... | 0.81216675 | 0 |
Get the theme for the project. | def get_theme(self) -> str:
return self.theme or self.account.theme | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_theme():\n # Return None if theming is disabled\n if not is_comprehensive_theming_enabled():\n return None\n\n site_theme = get_current_site_theme()\n if not site_theme:\n return None\n try:\n return Theme(\n name=site_theme.theme_dir_name,\n ... | [
"0.77218676",
"0.756868",
"0.7343077",
"0.711062",
"0.70631874",
"0.70348823",
"0.68387085",
"0.66256326",
"0.65988183",
"0.654876",
"0.6471758",
"0.6386882",
"0.63486433",
"0.63153225",
"0.62846875",
"0.6231964",
"0.62230563",
"0.6190626",
"0.61657983",
"0.61640877",
"0.6141... | 0.8288318 | 0 |
Get the location of one of the project's files relative to the root of the storage volume. | def file_location(self, file: str) -> str:
return os.path.join(str(self.id), file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location(self):\n\n p = os.path.abspath(__file__)\n pathSP = os.path.split(p)\n return pathSP",
"def path(self):\n path = os.path.join(self.base_dir, self.store().replace(' ', '_'), self.package_name())\n return os.path.abspath(path)",
"def get_absolute_pathname(self):\n ... | [
"0.666451",
"0.66000694",
"0.658896",
"0.6555157",
"0.65166426",
"0.647148",
"0.6465352",
"0.6453355",
"0.6424935",
"0.6400169",
"0.63222474",
"0.628216",
"0.62486446",
"0.6230657",
"0.6214746",
"0.62136924",
"0.6198161",
"0.6198161",
"0.6198161",
"0.6198161",
"0.6173934",
... | 0.58607525 | 79 |
Make the project create an owner. Makes sure each project has at least one owner. | def make_project_creator_an_owner(
sender, instance: Project, created: bool, *args, **kwargs
):
if sender is Project and created and instance.creator:
ProjectAgent.objects.create(
project=instance, user=instance.creator, role=ProjectRole.OWNER.name
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_owner(self):\n url = reverse(\n 'projectroles:api_role_create',\n kwargs={'project': self.project.sodar_uuid},\n )\n post_data = {\n 'role': PROJECT_ROLE_OWNER,\n 'user': str(self.assign_user.sodar_uuid),\n }\n response ... | [
"0.6795974",
"0.67435247",
"0.6457388",
"0.6397213",
"0.6334437",
"0.61915594",
"0.6109523",
"0.6071861",
"0.6055635",
"0.59651107",
"0.59185636",
"0.59049666",
"0.5854356",
"0.5853638",
"0.5830807",
"0.5797529",
"0.5782358",
"0.57266897",
"0.5696159",
"0.56787217",
"0.565595... | 0.7869675 | 0 |
Returns an iterator of number of code points in each grapheme of the string. | def grapheme_lengths(string):
return iter(len(g) for g in graphemes(string)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self) -> Iterator[Tuple[int, str]]:\n length = \"\"\n for c in super().__iter__():\n if c in CIGAR_CHARS:\n yield (int(length), c)\n length = \"\"\n else:\n length += c",
"def get_char_counts(string):\n counts = {}\n... | [
"0.63102376",
"0.6066801",
"0.58364946",
"0.5682218",
"0.56752527",
"0.5587007",
"0.5516279",
"0.5483019",
"0.5476278",
"0.5476278",
"0.5432439",
"0.54060763",
"0.5371684",
"0.5355845",
"0.5348796",
"0.5294735",
"0.5293246",
"0.5278698",
"0.5262752",
"0.5248184",
"0.52327317"... | 0.82796204 | 0 |
Start autonomous mode. This initialises the selected autonomous mode. Call this from your ``autonomousInit`` method. | def start(self) -> None:
self.timer = wpilib.Timer()
self.timer.start()
self._on_autonomous_enable() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autonomousInit(self):\n self.globalInit()\n self.autonomous.start()",
"def _on_autonomous_enable(self) -> None:\n\n # XXX: FRC Dashboard compatibility\n # -> if you set it here, you're stuck using it. The FRC Dashboard\n # doesn't seem to have a default (nor will it show... | [
"0.7841093",
"0.71122485",
"0.628487",
"0.6095509",
"0.60859686",
"0.60364497",
"0.60302883",
"0.60259026",
"0.59982705",
"0.5997922",
"0.59907854",
"0.5944252",
"0.5905381",
"0.584049",
"0.58149403",
"0.5811002",
"0.58014745",
"0.57960796",
"0.5778222",
"0.57653964",
"0.5742... | 0.6558177 | 2 |
Derivative of the sigmoid function. | def sigmoid_prime(z):
#计算 σ函数的导数
return 1.716*(1-np.tanh(2/3*z)**2)*2/3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(x):\n return x * (1-x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_der... | [
"0.847575",
"0.8451228",
"0.83970946",
"0.8348836",
"0.8348836",
"0.8298695",
"0.8054636",
"0.7753853",
"0.77075475",
"0.7498936",
"0.74652743",
"0.74541104",
"0.74023646",
"0.73854893",
"0.7383694",
"0.7347074",
"0.73223907",
"0.73099685",
"0.71926326",
"0.71140707",
"0.7092... | 0.0 | -1 |
Create a image folder dataset in a temporary directory for use in tests. | def fixture_image_data(tmp_path_factory, request):
# Make root dir
root = tmp_path_factory.mktemp("data")
# Set params
num_images = request.param
# Create image files
paths = [root / Path(f"{idx}.png") for idx in range(num_images)]
dimensions = [(idx % 10 + 1, (10 - idx) % 10 + 1) for idx ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_directories(train_path, test_path):\n train_path.joinpath(\"images\").mkdir(parents=True)\n test_path.joinpath(\"images\").mkdir(parents=True)",
"def make_directory_dataset(directory_path: str) -> None:\n dataset_path = Path(directory_path)\n test_path = dataset_path / 'test'\n train_pa... | [
"0.71932167",
"0.71284103",
"0.69951254",
"0.69644856",
"0.6944171",
"0.6929569",
"0.6812385",
"0.6766725",
"0.673779",
"0.6720452",
"0.67042",
"0.6691994",
"0.6689989",
"0.65835524",
"0.65601933",
"0.65417504",
"0.65079594",
"0.64762",
"0.6473956",
"0.6467302",
"0.64517516",... | 0.7515927 | 0 |
Read audio chunks from queue and yield. | def audio_stream() -> typing.Iterable[bytes]:
frames = frame_queue.get()
while frames:
yield frames
frames = frame_queue.get() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_audio():\n\tbuf = None\n\tnum_new_bytes = BUFFER_SIZE // REFRESH_BUFFER_FACTOR\n\twith open(INFILE) as fifo:\n\t\twhile True:\n\t\t\tif buf is None:\n\t\t\t\tbuf = fifo.read(BUFFER_SIZE)\n\t\t\telse:\n\t\t\t\tbuf = buf[num_new_bytes:] + fifo.read(num_new_bytes)\n\t\t\tyield buf",
"async def async_readchu... | [
"0.7123791",
"0.68189037",
"0.6682187",
"0.6352251",
"0.6322491",
"0.62974507",
"0.6286665",
"0.62764674",
"0.62634826",
"0.62544084",
"0.6230898",
"0.61809504",
"0.61534625",
"0.60943",
"0.60639846",
"0.6044643",
"0.6019628",
"0.6015428",
"0.60127366",
"0.5972718",
"0.595726... | 0.7560682 | 0 |
Set the value of the CategoryParent input for this Choreo. ((optional, string) Indicates the ID of the highestlevel category to return. Multiple CategoryParent IDs can be specified in a commaseparated list.) | def set_CategoryParent(self, value):
super(GetCategoriesInputSet, self)._set_input('CategoryParent', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sub_category(self, name, category_id, parent_category_id, **kwargs):\n kwargs[\"parent_category_id\"] = parent_category_id\n self.client._put(f\"/categories/{category_id}.json\", **kwargs)",
"def parent_id(self, parent_id: int):\n if parent_id is None:\n raise ValueError(\... | [
"0.6129967",
"0.5472301",
"0.5323792",
"0.52963334",
"0.5156003",
"0.5122369",
"0.51155204",
"0.51121783",
"0.51076823",
"0.51076823",
"0.51076823",
"0.51076823",
"0.5062186",
"0.50444716",
"0.49758205",
"0.4972529",
"0.49427202",
"0.49028528",
"0.48824716",
"0.4873548",
"0.4... | 0.73892105 | 0 |
Set the value of the CategorySiteID input for this Choreo. ((optional, string) The ID for the site for which to retrieve the category hierarchy. Use the numeric site code (e.g., 0 for US, 77 for eBay Germany, etc).) | def set_CategorySiteID(self, value):
super(GetCategoriesInputSet, self)._set_input('CategorySiteID', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_SiteID(self, value):\n super(GetCategoriesInputSet, self)._set_input('SiteID', value)",
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def categories_id(self, categories_id):\n\n self._categories_id = ... | [
"0.6707115",
"0.5398025",
"0.5398025",
"0.5373852",
"0.5183332",
"0.49956957",
"0.46219173",
"0.45263055",
"0.4510416",
"0.44572973",
"0.44089535",
"0.43879732",
"0.4354011",
"0.41838205",
"0.40762675",
"0.40462708",
"0.4037234",
"0.39882267",
"0.39651904",
"0.39525023",
"0.3... | 0.743803 | 0 |
Set the value of the LevelLimit input for this Choreo. ((optional, string) Indicates the maximum depth of the category hierarchy to retrieve, where the toplevel categories (metacategories) are at level 1. Default is 0.) | def set_LevelLimit(self, value):
super(GetCategoriesInputSet, self)._set_input('LevelLimit', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetLimit(self, *args):\n return _BRepAlgo.BRepAlgo_NormalProjection_SetLimit(self, *args)",
"def categories_level(self, categories_level):\n\n self._categories_level = categories_level",
"def set_limit(self, limit):\n self.limit = limit\n self._prune()",
"def setRevisionLimit(... | [
"0.59802634",
"0.5946763",
"0.5711779",
"0.5509778",
"0.5490343",
"0.54478884",
"0.54478884",
"0.54478884",
"0.5437157",
"0.54352576",
"0.5423509",
"0.5397781",
"0.5367426",
"0.5363926",
"0.53585196",
"0.53347886",
"0.5326937",
"0.53143334",
"0.5291554",
"0.52813643",
"0.5179... | 0.78116244 | 0 |
Set the value of the SandboxMode input for this Choreo. ((conditional, boolean) Indicates that the request should be made to the sandbox endpoint instead of the production endpoint. Set to 1 to enable sandbox mode.) | def set_SandboxMode(self, value):
super(GetCategoriesInputSet, self)._set_input('SandboxMode', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sandbox(self, sandbox):\n\n self._sandbox = sandbox",
"def is_sandbox_environment(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"is_sandbox_environment\")",
"def CreateSandbox() -> Sandbox:\n global _sandbox_name\n if _sandbox_name is None:\n return NullSandbox()\n e... | [
"0.5614144",
"0.5567158",
"0.51500666",
"0.51233065",
"0.51149535",
"0.50982213",
"0.49350753",
"0.48719332",
"0.48414156",
"0.48161337",
"0.46198162",
"0.44927067",
"0.44751006",
"0.44662586",
"0.44561806",
"0.44053355",
"0.43435562",
"0.4293769",
"0.4281894",
"0.42796412",
... | 0.67555255 | 0 |
Set the value of the SiteID input for this Choreo. ((optional, string) The eBay site ID that you want to access. Defaults to 0 indicating the US site.) | def set_SiteID(self, value):
super(GetCategoriesInputSet, self)._set_input('SiteID', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def web_site_id(self, web_site_id):\n\n self._web_site_id = web_site_id",
"def set_CategorySiteID(self, value):\n super(GetCategoriesInputSet, self)._set_input('Ca... | [
"0.7500939",
"0.7500939",
"0.6129336",
"0.6034459",
"0.5938549",
"0.5903619",
"0.5803138",
"0.54688704",
"0.5419744",
"0.536414",
"0.5242638",
"0.4969907",
"0.49572378",
"0.49247172",
"0.4897453",
"0.4897453",
"0.4870887",
"0.48449123",
"0.4842923",
"0.484094",
"0.4771758",
... | 0.6480584 | 2 |
Set the value of the ViewAllNodes input for this Choreo. ((optional, boolean) A flag that controls whether all eBay categories are returned, or only leaf categories are returned. To retrieve leaf categories, set this parameter to 'false'.) | def set_ViewAllNodes(self, value):
super(GetCategoriesInputSet, self)._set_input('ViewAllNodes', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_nodes(self):\n return self._get_all_nodes()",
"def add_nodes_from(self, nodes):\n self._Impl._nodes[\"all_nodes\"] = cudf.Series(nodes)",
"def all_nodes(self, namespace=None):\n source = self._source(namespace)\n return self._list(source, 'all')",
"def deactivate_all(s... | [
"0.5391109",
"0.5390056",
"0.52510315",
"0.50688076",
"0.50596285",
"0.49692878",
"0.49534097",
"0.4930699",
"0.48903552",
"0.4888203",
"0.48538244",
"0.48459598",
"0.47947457",
"0.47933027",
"0.47827104",
"0.4774255",
"0.47677267",
"0.47593287",
"0.47422218",
"0.4693059",
"0... | 0.7972372 | 0 |
The value of the resource. | def value(self):
if self.getter is None:
raise NotReadable('Resource not readable.')
if callable(self.getter):
result = self.getter()
elif self.obj is not None:
result = getattr(self.obj, self.getter)
else:
raise NotReadable('Cannot read from resource.')
self.verify_dimensions(result)
# Appl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n return self.get_data(\"value\")",
"def value(self) -> str:\n return pulumi.get(self, \"value\")",
"def value(self) -> str:\n return pulumi.get(self, \"value\")",
"def value(self) -> str:\n return pulumi.get(self, \"value\")",
"def value(self) -> str:\n ... | [
"0.74665505",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.7334829",
"0.732872",
"0.72743225",
"0.722479",
"0.7208811",
"0.7181056",
"0.7146232",
"... | 0.0 | -1 |
Produce a Resource which is a wrapper around this Resource. | def wrapped(self, name, getter_filter=None, setter_filter=None):
result = copy(self)
result.wrappers = self.wrappers + [(name, getter_filter, setter_filter)]
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wrap(self, resource):\n\t\treturn ResourceWrapper(self, resource)",
"def make_instance(self, include_optional):\n # model = yapily.models.resource.Resource() # noqa: E501\n if include_optional :\n return Resource(\n description = '0', \n file = yapily.... | [
"0.7497035",
"0.68926394",
"0.67446154",
"0.66210735",
"0.6620925",
"0.64650744",
"0.6292766",
"0.6151775",
"0.6151398",
"0.6121766",
"0.60489506",
"0.60388047",
"0.6012709",
"0.5981098",
"0.59604263",
"0.590962",
"0.5886807",
"0.5848324",
"0.58403087",
"0.58258355",
"0.58189... | 0.0 | -1 |
Get the state of a previously configured CAN bus. | def can_state(send, bus):
response = {'r': 'can_state', 'state': None}
can = can_bus_map.get(bus, None)
if can is not None:
response['state'] = {
pyb.CAN.STOPPED: 'stopped',
pyb.CAN.ERROR_ACTIVE: 'error_active',
pyb.CAN.ERROR_WARNING: 'error_warning',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_device_state():\n \n try:\n _debug_print(\"Connecting to bus...\")\n i2c_bus = smbus.SMBus(_bus_id)\n\n current_state = i2c_bus.read_byte(_device_addr) & 0x0F\n\n return int(current_state)\n\n except:\n print(\"Error: There was a problem reading from the device... | [
"0.6698612",
"0.6196475",
"0.6130076",
"0.61101615",
"0.6062818",
"0.6031746",
"0.6006805",
"0.59833187",
"0.59467405",
"0.5912973",
"0.5870844",
"0.5869142",
"0.58660966",
"0.5829685",
"0.5827593",
"0.5827593",
"0.5827593",
"0.5827593",
"0.5827593",
"0.5827593",
"0.5827593",... | 0.7267014 | 0 |
Converts array whose rows represent diagonal entries of a matrix into the matrix itself. See scipy.linalg.solve_banded | def diag_to_matrix(l_and_u, diag):
l, u = l_and_u
dim = diag.shape[1]
matrix = np.zeros((dim, dim))
for i in range(l+u+1):
np.fill_diagonal(
matrix[max(0,i-u):,max(0,u-i):],
diag[i,max(0,u-i):]
)
return matrix | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inv_banded(banded_matrix):\n banded_matrix = banded_matrix.toarray()\n nrows = banded_matrix.shape[0]\n nbands = np.min([np.count_nonzero(row) for row in banded_matrix])\n ab = np.zeros((nbands, nrows))\n for i in np.arange(1, nbands):\n ab[i, :] = np.concatenate(\n (\n ... | [
"0.69575876",
"0.64048153",
"0.6234123",
"0.6205045",
"0.61761206",
"0.6006811",
"0.59896874",
"0.5946012",
"0.5924541",
"0.589005",
"0.58739597",
"0.58455795",
"0.58453",
"0.5809746",
"0.58006567",
"0.5790228",
"0.57842326",
"0.57267654",
"0.5726118",
"0.5716055",
"0.5690097... | 0.5298268 | 86 |
Set defaults to calculation parameters | def _set_default_parameters(self, parameters):
parameters_dict = parameters.get_dict()
from aiida_crystal_dft.io.f9 import Fort9
with self.inputs.wavefunction.open(mode='rb') as f:
file_name = f.name
wf = Fort9(file_name)
if 'band' in parameters_dict:
# a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _default_parameters(cls) -> Options:\n params = super()._default_parameters()\n params.main_axes = None\n params.i_means = None\n params.q_means = None\n params.scales = None\n\n return params",
"def set_default_parameters(self):\n super().set_default_paramete... | [
"0.6943066",
"0.6919235",
"0.6629486",
"0.6605372",
"0.65865785",
"0.65397674",
"0.6539674",
"0.6494178",
"0.64272714",
"0.63984066",
"0.63891405",
"0.63767976",
"0.6373579",
"0.6346972",
"0.63348526",
"0.63092655",
"0.6272867",
"0.6268823",
"0.62534904",
"0.62277675",
"0.622... | 0.5884307 | 57 |
Build an actor (policy) network that maps states > actions. | def forward(self, state):
x = self.fc(state)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_actor_network(states, num_controls, params, scope_name):\n scope_key = scope_name + '/'\n with tf.variable_scope(scope_name):\n hidden_1 = tf.layers.dense(states,\n units=params.actor_hidden_units[0],\n activation=None,\n ... | [
"0.69361234",
"0.6364334",
"0.6270192",
"0.6208838",
"0.62005234",
"0.6187673",
"0.6147678",
"0.61465186",
"0.61283225",
"0.6019157",
"0.60020804",
"0.5976981",
"0.59597296",
"0.59523076",
"0.59488183",
"0.5928019",
"0.5916519",
"0.58979034",
"0.58936965",
"0.5891595",
"0.588... | 0.0 | -1 |
Add a new experience to memory. | def add(self, state, action, reward, next_state, done):
e = self.experience(state, action, reward, next_state, done)
self.memory.append(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_experience(self, state, action, reward, next_state, done):\n e = self.experience(state, action, reward, next_state, done, self.max_priority)\n self.memory.append(e)",
"def add(self, state, action, reward, next_state, done):\n experience = Experience(state, action, reward, next_st... | [
"0.79568833",
"0.79042006",
"0.78795445",
"0.7577913",
"0.7570969",
"0.74478436",
"0.7361023",
"0.72697705",
"0.721816",
"0.71451885",
"0.7106998",
"0.7101183",
"0.69837016",
"0.68905056",
"0.68842727",
"0.6755663",
"0.6712557",
"0.6677425",
"0.64961654",
"0.6488678",
"0.6486... | 0.71984994 | 15 |
Return the current size of internal memory. | def __len__(self):
return len(self.memory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSize(self) -> int:\n return len(self.mem)",
"def getSize(self):\n return self.bf.memory()",
"def memsize(self):\n return self.xlist(\"get-memsize\")[1][0] * 1024",
"def size(self):\n size = 0\n size += self.data.size * sys.getsizeof(self.data)\n return size / ... | [
"0.8573486",
"0.8216719",
"0.8200263",
"0.80869377",
"0.80215144",
"0.7890612",
"0.78215307",
"0.7801178",
"0.77899903",
"0.77588975",
"0.77554387",
"0.77554387",
"0.7755218",
"0.775394",
"0.773285",
"0.77322316",
"0.7719518",
"0.77139354",
"0.7708652",
"0.77072173",
"0.76973... | 0.75126064 | 55 |
Property returning all the cells accumulated on this partial row. | def cells(self):
return copy.deepcopy(self._cells) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cells_total(self):\n return self._inv.get(\"cells\", len(self))",
"def get_total_cells(self):\n return self._get(\"cells\")",
"def cells(self):\n return self.container['cells']",
"def cells(self):\n return chain.from_iterable(self.cols)",
"def cells(self):\r\n return ... | [
"0.7329604",
"0.72963184",
"0.7285541",
"0.71675426",
"0.70034677",
"0.6740002",
"0.6697525",
"0.6685098",
"0.6658701",
"0.66584843",
"0.653525",
"0.6513235",
"0.6502038",
"0.6449473",
"0.6402963",
"0.63210136",
"0.62875944",
"0.6282429",
"0.6233849",
"0.61757165",
"0.6172168... | 0.69514596 | 5 |
Getter for the current (partial) row's key. | def row_key(self):
return self._row_key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __key__(self) -> Tuple[int, int]:\n return self.col, self.row",
"def get_key(self) -> int:\n return self.__key",
"def get_key(self) -> int:\n return self.key",
"def get_key(self):\n return self.key",
"def get_key(self):\n return self.key",
"def key(self):\n r... | [
"0.72316724",
"0.72159064",
"0.7207303",
"0.7157399",
"0.7157399",
"0.71138483",
"0.7061789",
"0.7047705",
"0.6999932",
"0.6988818",
"0.6988818",
"0.6988818",
"0.6988818",
"0.6960423",
"0.6876054",
"0.683839",
"0.68287086",
"0.6781018",
"0.6758112",
"0.67410135",
"0.6730147",... | 0.84983855 | 0 |
Return a list of OpenVSwitch node ids in this Topology. | def get_switch_ids(self):
switch_ids = []
for node_id in self.nodes:
if isinstance(self.nodes[node_id], OVSNode):
switch_ids.append(node_id)
return switch_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_ids(self):\n return [self.node_id]",
"def get_node_ids(self):\n \n return self.node_ids",
"def all_node_ids(self):\n return [i for i in range(0, self.n_inputs + self.n_hidden + self.n_outputs)]",
"def _node_ids(self, nodes=None): # this function comes from BaseCard.py\n ... | [
"0.7999517",
"0.7927706",
"0.7313502",
"0.7179201",
"0.69924164",
"0.69775486",
"0.69099134",
"0.6908216",
"0.68880624",
"0.6844725",
"0.68219465",
"0.68216735",
"0.6820734",
"0.67531025",
"0.6720736",
"0.66904956",
"0.6629367",
"0.6593734",
"0.6553961",
"0.6481646",
"0.64808... | 0.78524137 | 2 |
Add a qos to the OVSNode object. Updates qos if it already exists. Does not add a qos to a physical switch. The qos input should just be the json sent to the controller. | def add_qos(self, qos):
qos_id = qos["ovsdb:qos-entries"][0]["qos-id"]
self.qos_dict[qos_id] = qos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_qos(tenant_id, qos_name, qos_desc):\n LOG.debug(\"add_qos() called\")\n session = db.get_session()\n try:\n qos = (session.query(network_models_v2.QoS).\n filter_by(tenant_id=tenant_id).\n filter_by(qos_name=qos_name).one())\n raise c_exc.QosNameAlreadyExi... | [
"0.675133",
"0.6740849",
"0.6509288",
"0.63825524",
"0.6261487",
"0.623508",
"0.61480707",
"0.6146155",
"0.6125985",
"0.60934",
"0.5971305",
"0.5832702",
"0.5652961",
"0.56214666",
"0.55383885",
"0.55369544",
"0.55208385",
"0.5508991",
"0.5416964",
"0.5408776",
"0.52939504",
... | 0.8248631 | 0 |
Create an `iframe` element in the current browsing context and insert it into the document. Return an element reference. | def create_frame(session):
def create_frame():
append = """
var frame = document.createElement('iframe');
document.body.appendChild(frame);
return frame;
"""
response = session.execute_script(append)
return create_frame | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iframe(src, width=400, height=300):\n return TAG.iframe(_src=src, _width=width, _height=height)",
"def as_iframe(self, html_data):\n\n srcdoc = html_data.replace('\"', \"'\")\n return ('<iframe id=\"{div_id}\", srcdoc=\"{srcdoc}\" style=\"width: {width}; '\n 'height: {heig... | [
"0.6174784",
"0.55865693",
"0.54760414",
"0.5332886",
"0.51973313",
"0.5196938",
"0.51477903",
"0.48718172",
"0.48631668",
"0.48425317",
"0.48268217",
"0.47691065",
"0.47580108",
"0.47167465",
"0.47058505",
"0.46702343",
"0.45552185",
"0.45123303",
"0.4505555",
"0.44861558",
... | 0.6257008 | 0 |
Open new window and return the window handle. | def create_window(session):
def create_window():
windows_before = session.handles
name = session.execute_script("window.open()")
assert len(session.handles) == len(windows_before) + 1
new_windows = list(set(session.handles) - set(windows_before))
return new_windows.pop()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_new_window(event):\n url = event.GetURL()\n webbrowser.open(url)",
"def _open_window(self):\r\n\t\t# Creating the window\r\n\t\tself._window = Window(self, Locations.RESTAL)",
"def open_new_window(self, selector):\n current_window = self.driver.current_window_handle\n ele... | [
"0.69135225",
"0.6894578",
"0.67950994",
"0.67186034",
"0.66880804",
"0.6459025",
"0.6384433",
"0.6371975",
"0.63716286",
"0.63049585",
"0.6247003",
"0.61046994",
"0.608595",
"0.60641366",
"0.6063295",
"0.60611963",
"0.60415345",
"0.6027003",
"0.5991303",
"0.59858763",
"0.595... | 0.6855852 | 2 |
Freezer is based on top of the pkg module. Return True since the `pkg` module should always exist. This avoids the overhead of loading all modules. | def __virtual__():
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _package_available(package_name: str) -> bool:\n try:\n return find_spec(package_name) is not None\n except ModuleNotFoundError:\n return False",
"def is_pkg(cls, path):\n return exists(join(path, '__init__.py'))",
"def is_package(self, fullname):\n return hasattr(self.__g... | [
"0.72167784",
"0.7054037",
"0.67946243",
"0.67609817",
"0.67345065",
"0.6663047",
"0.66244084",
"0.66183674",
"0.6577075",
"0.6577075",
"0.6500366",
"0.64847684",
"0.6473244",
"0.64359987",
"0.64204097",
"0.64127177",
"0.641208",
"0.6371272",
"0.63555104",
"0.6305438",
"0.626... | 0.0 | -1 |
Return True if there is already a frozen state. A frozen state is merely a list of packages (including the version) in a specific time. This information can be used to compare with the current list of packages, and revert the installation of some extra packages that are in the system. name Name of the frozen state. Opt... | def status(name=None):
name = "freezer" if not name else name
return all(os.path.isfile(i) for i in _paths(name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def we_are_frozen():\r\n\treturn hasattr(sys, \"frozen\")",
"def is_frozen():\r\n return hasattr(sys, 'frozen') and sys.frozen",
"def is_frozen(self, type_name):\n return self._symtab[type_name].is_frozen()",
"def frozen_project():\n return hasattr(sys, \"frozen\")",
"def freeze(name=None, force=F... | [
"0.68721086",
"0.6851596",
"0.68231916",
"0.6491958",
"0.63796014",
"0.6135377",
"0.6115065",
"0.5805816",
"0.5657362",
"0.5609856",
"0.5582771",
"0.55413973",
"0.54397535",
"0.53899515",
"0.5386102",
"0.53778887",
"0.53278416",
"0.53246194",
"0.53165835",
"0.52400833",
"0.52... | 0.5422256 | 13 |
Return the list of frozen states. | def list_():
ret = []
states_path = _states_path()
if not os.path.isdir(states_path):
return ret
for state in os.listdir(states_path):
if state.endswith(("-pkgs.yml", "-reps.yml")):
# Remove the suffix - both files start with the freezer
# name
ret.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_list(self) -> Sequence[TState]:\n pass",
"def get_list_of_states(self):\n return self.states",
"def getstate(self):\n return [elem.getstate() for elem in self]",
"def initial_states(self):\n return list(self.iter_initial_states())",
"def all_states(self):\n retu... | [
"0.69866335",
"0.6971545",
"0.6748766",
"0.66988707",
"0.66819704",
"0.6678218",
"0.66705126",
"0.66479045",
"0.6599758",
"0.6587541",
"0.6573471",
"0.6547036",
"0.65039486",
"0.6479427",
"0.6453777",
"0.63992965",
"0.63978416",
"0.6305674",
"0.626267",
"0.6252373",
"0.623590... | 0.63569236 | 17 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.8330957",
"0.8284237",
"0.82376367",
"0.8229314",
"0.8219836",
"0.81859726",
"0.8184298",
"0.8174704",
"0.8170969",
"0.8169349",
"0.81659627",
"0.81640005",
"0.8163328",
"0.8161707",
"0.8161707",
"0.8161707",
"0.8161707",
"0.8161707",
"0.8161707",
"0.8161707",
"0.8161707",... | 0.78468007 | 98 |
Returns value for in configuration file; if is missing, an error message is logged when there is no associated value, otherwise is returned for a missing entry | def value (self,
key : String,
defaultValue : Object = missingValue) -> Object:
Logging.trace(">>: key = %s, defaultValue = %r",
key, defaultValue)
isMandatory = (defaultValue == missingValue)
result = None
if key in self._keyToValue... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_config(config, section, item):\n value = config.get(section, item)\n if value == \"None\":\n return None\n return value",
"def config_value(name):\n def get():\n try:\n return config.get('yourls', name)\n except (NoOptionError, NoSectionError):\n re... | [
"0.67917",
"0.6635625",
"0.6563727",
"0.64952976",
"0.64884275",
"0.64454025",
"0.63905793",
"0.6375485",
"0.629574",
"0.62699145",
"0.6211306",
"0.62047195",
"0.61872745",
"0.617998",
"0.6173474",
"0.6172952",
"0.6149519",
"0.6134496",
"0.6125716",
"0.6074267",
"0.6069744",
... | 0.0 | -1 |
Returns an instantiated list of each rule that has been registered. | def get_rules(cls) -> list:
return [factory() for factory in cls._rules_factories] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rules(self):\n rules = []\n for item in self.rule:\n rules.append(item)\n return rules",
"def get_rules(self):\n rules = []\n for item in self.name:\n rules.append(item)\n return rules",
"def getListOfRules(self):\n return self.mode... | [
"0.81854767",
"0.8028653",
"0.7681446",
"0.747593",
"0.7188627",
"0.7024562",
"0.6993731",
"0.69882214",
"0.67589486",
"0.6748225",
"0.67445904",
"0.67356396",
"0.6722869",
"0.6689858",
"0.6678105",
"0.6660337",
"0.6650291",
"0.65893424",
"0.6547568",
"0.6512674",
"0.6477749"... | 0.81147885 | 1 |
Applies the Softmax function to an ndimensional input Tensor rescaling them | def softmax(arr: np.ndarray, axis: int = -1):
c = arr.max(axis=axis, keepdims=True)
s = arr - c
nominator = np.exp(s)
denominator = nominator.sum(axis=axis, keepdims=True)
probs = nominator / denominator
return probs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(input, dim, inplace=False):\n return FunctionLib.apply(\n 'Softmax', input.device, [input],\n outputs=[input if inplace else None], axis=dim)",
"def softmax4(x):\n ndim = K.ndim(x)\n if ndim == 2:\n return K.softmax(x)\n elif ndim == 3:\n e = K.exp(x - K.max(x,... | [
"0.7957886",
"0.7658958",
"0.7509899",
"0.7509899",
"0.7487856",
"0.7486355",
"0.744741",
"0.7405989",
"0.7357403",
"0.73492765",
"0.7309486",
"0.7249288",
"0.7239053",
"0.7204867",
"0.7204867",
"0.7201723",
"0.7198571",
"0.7180414",
"0.7176051",
"0.7175737",
"0.71715707",
... | 0.0 | -1 |
Draw samples from a standard Normal distribution (mean=0, stdev=1). | def standard_normal(random_state, size=None, chunk_size=None, gpu=None, dtype=None):
if dtype is None:
dtype = np.random.RandomState().standard_normal(size=(0,)).dtype
size = random_state._handle_size(size)
seed = gen_random_seeds(1, random_state.to_numpy())[0]
op = TensorStandardNormal(size=siz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_normal(self):\n means, scale = self.get_means_and_scales()\n return np.random.normal(means,scale,size=[self.sims,means.shape[0]]).T",
"def normal(mean, std):\n\n return random.gauss(mean, std)",
"def test_normal(self):\r\n s = np.random.normal(-0.42, 0.55, 5000)\r\n ... | [
"0.75756955",
"0.7359071",
"0.72345424",
"0.7150394",
"0.71197146",
"0.7093101",
"0.69451076",
"0.6877788",
"0.6869891",
"0.6642873",
"0.66425455",
"0.6602457",
"0.6599727",
"0.6596702",
"0.6525589",
"0.64931434",
"0.64451784",
"0.64451784",
"0.64451784",
"0.64451784",
"0.644... | 0.58724236 | 59 |
A small utility function that check if the provided string is either None, '', or just a string containing only spaces | def is_empty(val):
return val in [None, ''] or val.isspace() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(string):\n return string == None or re.sub(\"\\\\s+\", \"\", string) == \"\"",
"def is_null_or_empty(string_val):\n if string_val and string_val.strip():\n return False\n return True",
"def is_str_none_or_empty(val):\n if val is None:\n return True\n if isinstance(val,... | [
"0.8237053",
"0.8124945",
"0.8037569",
"0.79108196",
"0.7764869",
"0.7685698",
"0.75816345",
"0.7575924",
"0.7477997",
"0.74721014",
"0.7454891",
"0.74143285",
"0.7358262",
"0.7233534",
"0.7226879",
"0.7201261",
"0.71897626",
"0.7131125",
"0.70505905",
"0.69395953",
"0.693698... | 0.77871525 | 4 |
Add one point to the map | def add_point(map, x, y, size, label, marker=settings.MARKER, color=settings.MARKER_COLOR):
s = get_class_size(size)
folium.map.Marker(
location=[y, x],
popup=label,
icon=DivIcon(
#icon_size=(150,36),
icon_anchor=(0,0),
html='<i class="fa '+marker+'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addPoint(self, point):\n self.points.append(point)",
"def add(self, point):\n self.points.append(point)",
"def add_point(self, pt):\n self.points.append(pt)",
"def add_point(self, x: int, y: int):\n self.state[x, y] = 1",
"def add_point(self, x: int, y: int):\n self.s... | [
"0.74777544",
"0.7411591",
"0.7302735",
"0.717282",
"0.717282",
"0.717282",
"0.7149496",
"0.7075055",
"0.7043802",
"0.70243937",
"0.70046866",
"0.70044357",
"0.695466",
"0.68703127",
"0.67992646",
"0.67937094",
"0.67550814",
"0.6747055",
"0.67115504",
"0.6681633",
"0.66295254... | 0.62047684 | 33 |
Test getting a nonexisting user from the database. | def test_get_user_when_non_existing(user_store: MockStore):
# GIVEN a database with a user
# WHEN querying for a user that doesn't exist
user: User = user_store.get_user(email="this_is_a_made_up_email@fake_example.com")
# THEN it should return as None
assert user is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_user_non_exist_id(self):\n print('(' + self.test_get_user_non_exist_id.__name__+')',\n self.test_get_user_non_exist_id.__doc__)\n self.assertIsNone(self.connection.get_user(NON_EXIST_PATIENT_USERNAME))",
"def test_get_bad_user(self):\r\n user = UserMgr.get(username=... | [
"0.856584",
"0.8538134",
"0.8256169",
"0.80339926",
"0.7959935",
"0.7942771",
"0.7879475",
"0.78456324",
"0.77836406",
"0.77539635",
"0.77476394",
"0.77425784",
"0.7734177",
"0.7665938",
"0.7625372",
"0.7607034",
"0.7594667",
"0.7572818",
"0.7503314",
"0.7482438",
"0.7456589"... | 0.8029911 | 4 |
Test getting a user with username and email. | def test_get_users(user_store: MockStore, user_email: str, username: str):
# GIVEN a database with a user
# WHEN getting users
users: List[User] = user_store.get_users(name=username, email=user_email)
# THEN the user should be returned
assert users[0].email == user_email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_user_by_emailuser_email_get(self):\n pass",
"def test_get_user(user_store: MockStore, user_email: str):\n # GIVEN a database with a user\n\n # WHEN querying for a user\n user: User = user_store.get_user(email=user_email)\n\n # THEN it should be returned\n assert user.email == u... | [
"0.81518275",
"0.79463357",
"0.7895598",
"0.7859849",
"0.7718898",
"0.77024853",
"0.7650548",
"0.76115036",
"0.76060903",
"0.7491955",
"0.748591",
"0.74647605",
"0.7454479",
"0.74482834",
"0.74220383",
"0.7405741",
"0.73980224",
"0.7391085",
"0.73631626",
"0.73486465",
"0.734... | 0.7497986 | 9 |
Generates DataLoader instances for training and validation data | def _get_data(
self, train_dataset: TensorDataset, validation_dataset: TensorDataset
):
return (
DataLoader(train_dataset, batch_size=self.batch_size, shuffle=True),
DataLoader(validation_dataset, batch_size=self.batch_size * 2),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_creator(config):\n train_dataset, val_dataset = LinearDataset(2, 5), LinearDataset(2, 5)\n train_loader = DataLoader(train_dataset, batch_size=config[\"batch_size\"])\n val_loader = DataLoader(val_dataset, batch_size=config[\"batch_size\"])\n return train_loader, val_loader",
"def creates_da... | [
"0.8210852",
"0.8109314",
"0.8044301",
"0.7968612",
"0.7917862",
"0.7887867",
"0.78700924",
"0.77869165",
"0.7760952",
"0.77082145",
"0.76851207",
"0.7662429",
"0.7631286",
"0.76265687",
"0.7601167",
"0.75591475",
"0.75547343",
"0.750435",
"0.7474078",
"0.74594635",
"0.742464... | 0.75457203 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.