query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
!Get transects locations along input vector lines. | def get_transects_locs(vector, transect_spacing, dist_function, last_point):
# holds locations where transects should intersect input vector lines
transect_locs = []
vectors = []
for line in vector:
transect_locs.append([line[0]])
vectors.append([[line[0], line[1]]])
# i starts a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transect_ends(transect_locs, vectors, trend, dleft, dright):\n transect_ends = []\n if not trend:\n for k, transect in enumerate(transect_locs):\n # if a line in input vec was shorter than transect_spacing\n if len(transect) < 2:\n continue # then don't pu... | [
"0.63135153",
"0.59478843",
"0.5900003",
"0.57753754",
"0.572772",
"0.5653143",
"0.562377",
"0.55997103",
"0.55771756",
"0.55584687",
"0.55505735",
"0.5534073",
"0.549853",
"0.54831463",
"0.54450405",
"0.5424618",
"0.5399742",
"0.539676",
"0.5395751",
"0.5379726",
"0.5361239"... | 0.8311026 | 0 |
!From transects locations along input vector lines, get transect ends. | def get_transect_ends(transect_locs, vectors, trend, dleft, dright):
transect_ends = []
if not trend:
for k, transect in enumerate(transect_locs):
# if a line in input vec was shorter than transect_spacing
if len(transect) < 2:
continue # then don't put a transec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transects_locs(vector, transect_spacing, dist_function, last_point):\n # holds locations where transects should intersect input vector lines\n transect_locs = []\n vectors = []\n for line in vector:\n transect_locs.append([line[0]])\n vectors.append([[line[0], line[1]]])\n ... | [
"0.7829282",
"0.5986902",
"0.58439416",
"0.5737113",
"0.56587785",
"0.54360026",
"0.5381559",
"0.5353021",
"0.5303393",
"0.5286405",
"0.5271834",
"0.52648467",
"0.52199537",
"0.51981175",
"0.5193811",
"0.5183831",
"0.5180789",
"0.517281",
"0.51669097",
"0.5162157",
"0.5157939... | 0.7529391 | 1 |
!Calculates distance between two points | def dist_euclidean(line, i1, i2):
return sqrt((line[i1][0] - line[i2][0]) ** 2 + (line[i1][1] - line[i2][1]) ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(a: Point, b: Point) -> float:\n return math.sqrt(math.pow(b.x - a.x, 2) + math.pow(b.y - a.y, 2))",
"def distance(p1,p2):\n return ((p1.x - p2.x)**2 + (p1.y - p2.y)**2)**0.5",
"def distance(pt1, pt2):\n return (pt1[0] - pt2[0]) ** 2 + (pt1[1] - pt2[1]) ** 2",
"def distance(point1, point... | [
"0.824698",
"0.8218777",
"0.82076883",
"0.82004195",
"0.81980836",
"0.81697613",
"0.8165599",
"0.8161239",
"0.8160229",
"0.81211036",
"0.81072855",
"0.80845916",
"0.8078344",
"0.8072711",
"0.8058527",
"0.80481434",
"0.8041866",
"0.80382955",
"0.80352324",
"0.8029343",
"0.8015... | 0.0 | -1 |
!Take a vector, normalize and rotate it 90 degrees. | def NR(ip, fp):
x = fp[0] - ip[0]
y = fp[1] - ip[1]
r = sqrt(x ** 2 + y ** 2)
return array([-y / r, x / r]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(vector):\n return vector / np.linalg.norm(vector)",
"def unit_vector(vector):\r\n return vector / np.linalg.norm(vector)",
"def unit_vector(vector):\r\n return vector / np.linalg.norm(vector)",
"def unit_vector(vector):\r\n return vector / np.linalg.norm(vector)",
"def normali... | [
"0.71244574",
"0.6952223",
"0.6952223",
"0.6952223",
"0.6928747",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.69084775",
"0.6848545",
"0.6826794",
"0.6784497",
"0.6762535",
"0.6... | 0.0 | -1 |
Output A dictionary where | def generate_computational_graph(RHS, schema):
computational_graph=dict()
for level in range(3):
#use brute force to generate candidates for each level
computational_graph[level]=[]
if level== 0:
for attribute in schema:
if attribute !=RHS:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _output_dict(self):\n lang = self.ddnGuiLanguage.get()\n\n fileout = os.path.normpath('{}/{}-{}.xml'.\\\n format(self.MapCreator, self.Source, self.ddnCurProject.get()))\n linesout = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>', \\\n '<DictionarySet xmlns... | [
"0.626367",
"0.6158378",
"0.6154627",
"0.6088036",
"0.60848767",
"0.60715324",
"0.6032361",
"0.5953388",
"0.5948614",
"0.5925433",
"0.5871326",
"0.58541113",
"0.58324593",
"0.58283913",
"0.5819767",
"0.5788225",
"0.5762686",
"0.5759843",
"0.57423204",
"0.5714705",
"0.5708769"... | 0.0 | -1 |
A control flow function | def controller(df, func):
# Initialization: Generate computational graph for each attribute which will be on RHS
schema = df.columns
computational_graph = dict()
FDs = []
for RHS in schema:
computational_graph[RHS] = generate_computational_graph(RHS, schema)
for level in range(3):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def control():\n pass",
"def flow_control(self):\r\n c1 = self.eat_char()\r\n c2 = self.eat_char()\r\n cmd = c1+c2\r\n if cmd=='ss':\r\n #Mark a location in the program with label n\r\n self.log += ' Mark label '\r\n label = self.read_label()\r\n ... | [
"0.6417498",
"0.63510245",
"0.62501335",
"0.6089226",
"0.6010559",
"0.6001342",
"0.5981382",
"0.5963451",
"0.5929673",
"0.590212",
"0.58852947",
"0.58637094",
"0.58308494",
"0.5769991",
"0.57693505",
"0.5766577",
"0.57623595",
"0.5761478",
"0.5751903",
"0.57381326",
"0.573332... | 0.0 | -1 |
Add column 'category' with thread category. | def categorize_threads(threads):
# The 'default' category: pretty even tree discussions
threads.loc[:, 'category'] = 'tree'
# Trivial threads with no depth (they're basically one email threads)
threads.loc[threads.depth == 0, 'category'] = 'atom'
# Combs (mainly patches)
threads.loc[threads.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_category(df):\n df[\"category\"] = df.apply(lambda row: transform_cat(row), axis=1)\n df = drop_cols(df, [\"booking_bool\", \"click_bool\"])\n return df",
"def add_category(self, category):\n raise NotImplementedError()",
"def _change_category(cls, category):\n time_now = cls.__s... | [
"0.68607515",
"0.6420164",
"0.6190837",
"0.60352033",
"0.60275376",
"0.5926683",
"0.5817372",
"0.57799584",
"0.5748897",
"0.5737034",
"0.57201755",
"0.57172453",
"0.56799304",
"0.5674924",
"0.56745946",
"0.5669773",
"0.56500214",
"0.5603405",
"0.55407333",
"0.55407333",
"0.55... | 0.5909483 | 6 |
Adds an element to structure.elements with centroid geometric key. | def add_element(self, nodes, type, thermal=False, axes={}, mass=None):
if len(nodes) == len(set(nodes)):
ekey = self.check_element_exists(nodes)
if ekey is None:
ekey = self.element_count()
element = func_dict[type]()
element.axes = axe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_centroid(self, element):\n return centroid_points(self.nodes_xyz(nodes=self.elements[element].nodes))",
"def add_centroid(self, new_cen):\n \n self.add_vector(\n new_cen.name,\n new_cen.vector_cnt,\n new_cen.cen... | [
"0.63995886",
"0.6217979",
"0.60775435",
"0.5922356",
"0.58659434",
"0.5769847",
"0.54183793",
"0.5387267",
"0.5354052",
"0.5300437",
"0.52861667",
"0.5282519",
"0.5266797",
"0.5226121",
"0.52104324",
"0.5180196",
"0.51735896",
"0.5165735",
"0.5148651",
"0.51408607",
"0.51385... | 0.0 | -1 |
Adds multiple elements of the same type to structure.elements. | def add_elements(self, elements, type, thermal=False, axes={}):
return [self.add_element(nodes=nodes, type=type, thermal=thermal, axes=axes) for nodes in elements] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addElements( self, elements, plane = 0):\n for e in elements:\n self.addElement( e, plane )",
"def __add__(self, element):\r\n self.elements += element",
"def add_list(self, elements):\n if not isinstance(elements, (list, tuple)):\n warn(\"Input must be a list or ... | [
"0.6932413",
"0.6647059",
"0.6410584",
"0.62046254",
"0.61571664",
"0.60924846",
"0.6082265",
"0.6054165",
"0.60392433",
"0.60392433",
"0.6007566",
"0.59567493",
"0.5934673",
"0.5911498",
"0.5884601",
"0.587952",
"0.58746034",
"0.5872647",
"0.5837587",
"0.5834314",
"0.5812739... | 0.67169875 | 1 |
Adds the element to the element_index dictionary. | def add_element_to_element_index(self, key, nodes, virtual=False):
centroid = centroid_points([self.node_xyz(node) for node in nodes])
gkey = geometric_key(centroid, '{0}f'.format(self.tol))
if virtual:
self.virtual_element_index[gkey] = key
else:
self.element_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, elt):\n try :\n self[elt] += 1\n except KeyError :\n self[elt] = 1",
"def add(self, element):\n pass",
"def add(self, element):\n if not self.contains(element):\n bucket_index = self._bucket_index(element)\n self.buckets[buck... | [
"0.6890163",
"0.64507174",
"0.6404615",
"0.632291",
"0.62308216",
"0.6193717",
"0.61378443",
"0.6060049",
"0.60245675",
"0.6005325",
"0.6002771",
"0.59679997",
"0.593079",
"0.5904357",
"0.58926666",
"0.58647794",
"0.58592534",
"0.5857333",
"0.5827703",
"0.5827703",
"0.5812845... | 0.6392639 | 3 |
Check if an element already exists based on nodes or centroid. | def check_element_exists(self, nodes=None, xyz=None, virtual=False):
if not xyz:
xyz = centroid_points([self.node_xyz(node) for node in nodes])
gkey = geometric_key(xyz, '{0}f'.format(self.tol))
if virtual:
return self.virtual_element_index.get(gkey, None)
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(self, element):\n pass",
"def contains(self, element) -> bool:\n\n return self.__find_node(element) is not None",
"def __contains__(self, point):\n for component, dim in zip(point, self.dimensions):\n if component not in dim:\n return False\n r... | [
"0.60550416",
"0.5977769",
"0.592818",
"0.5824264",
"0.5823655",
"0.5782504",
"0.57631004",
"0.57197577",
"0.57041025",
"0.5618146",
"0.56131375",
"0.5596627",
"0.55922264",
"0.55544585",
"0.5548297",
"0.55086267",
"0.5484296",
"0.5472488",
"0.54446507",
"0.5439354",
"0.54372... | 0.61814296 | 0 |
Return the number of elements in the Structure. | def element_count(self):
return len(self.elements) + len(self.virtual_elements) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_count(self):\r\n result = conf.lib.clang_getNumElements(self)\r\n if result < 0:\r\n raise Exception('Type does not have elements.')\r\n\r\n return result",
"def getNumElements(self):\n return 0",
"def count(self):\n return len(self._elements)",
"def ... | [
"0.8115405",
"0.8007429",
"0.79685843",
"0.79547155",
"0.793771",
"0.79066867",
"0.7865182",
"0.7827344",
"0.78051794",
"0.7729744",
"0.77125853",
"0.76890045",
"0.74821746",
"0.7468352",
"0.74036944",
"0.7376613",
"0.7367706",
"0.7358235",
"0.7339007",
"0.728285",
"0.7272287... | 0.75727457 | 12 |
Return the centroid of an element. | def element_centroid(self, element):
return centroid_points(self.nodes_xyz(nodes=self.elements[element].nodes)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def centroid(self) -> PointValue:\n return ops.GeoCentroid(self).to_expr()",
"def get_element_centroids(self):\n if self.centroids is None:\n self.centroids = np.vstack((\n np.mean(self.grid['x'], axis=1),\n np.mean(self.grid['z'], axis=1)\n )).T\... | [
"0.7748887",
"0.76868415",
"0.7632962",
"0.75434023",
"0.7536017",
"0.75336224",
"0.7488187",
"0.73457927",
"0.73423916",
"0.73017126",
"0.72235227",
"0.71224225",
"0.7083174",
"0.70831215",
"0.7082723",
"0.698191",
"0.68854874",
"0.68596756",
"0.6837567",
"0.6779904",
"0.677... | 0.89669955 | 0 |
Adds a nodal element to structure.elements with the possibility of adding a coincident virtual node. Virtual nodes are added to a node set called 'virtual_nodes'. | def add_nodal_element(self, node, type, virtual_node=False):
if virtual_node:
xyz = self.node_xyz(node)
key = self.virtual_nodes.setdefault(node, self.node_count())
self.nodes[key] = {'x': xyz[0], 'y': xyz[1], 'z': xyz[2],
'ex': [1, 0, 0], 'ey':... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_virtual_element(self, nodes, type, thermal=False, axes={}):\n ekey = self.check_element_exists(nodes, virtual=True)\n\n if ekey is None:\n\n ekey = self.element_count()\n element = func_dict[type]()\n element.axes = axes\n element.nodes = nodes\n ... | [
"0.6634317",
"0.61566204",
"0.5652742",
"0.56208146",
"0.5584139",
"0.55827653",
"0.5531385",
"0.55188775",
"0.55154985",
"0.5491441",
"0.5474709",
"0.547417",
"0.54539937",
"0.54539937",
"0.54503345",
"0.5447374",
"0.5445971",
"0.54049236",
"0.537154",
"0.53474987",
"0.53453... | 0.7079097 | 0 |
Adds a virtual element to structure.elements and to element set 'virtual_elements'. | def add_virtual_element(self, nodes, type, thermal=False, axes={}):
ekey = self.check_element_exists(nodes, virtual=True)
if ekey is None:
ekey = self.element_count()
element = func_dict[type]()
element.axes = axes
element.nodes = nodes
eleme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_virtual_element(self, name, value=None, add_indicator=None):\n value_handler=values_module.VirtualValueHandler(value)\n if add_indicator is None:\n add_indicator=self.add_indicator\n indicator_handler=values_module.VirtualIndicatorHandler if add_indicator else None\n ... | [
"0.6141414",
"0.6013547",
"0.56858826",
"0.56753224",
"0.56295085",
"0.5576654",
"0.5532625",
"0.55177027",
"0.5484219",
"0.5482841",
"0.5423925",
"0.53376055",
"0.529714",
"0.5155314",
"0.50902706",
"0.5089768",
"0.5015175",
"0.5010791",
"0.4927697",
"0.48706532",
"0.4843721... | 0.5852425 | 2 |
Assign the ElementProperties object name to associated Elements. | def assign_element_property(self, element_property):
if element_property.elset:
elements = self.sets[element_property.elset].selection
else:
elements = element_property.elements
for element in elements:
self.elements[element].element_property = element_proper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromElement(self, element):\n from comoonics.ComProperties import Properties\n props=element.getElementsByTagName(Properties.TAGNAME)\n #log.debug(\"fromElement: %s, %u\" %(element, len(props)))\n if len(props)>=1:\n self.properties=Properties(props[0])\n for p... | [
"0.6765604",
"0.5937132",
"0.593495",
"0.5834883",
"0.56832635",
"0.5542729",
"0.55254275",
"0.54816675",
"0.5402877",
"0.535998",
"0.5290429",
"0.5289492",
"0.52726215",
"0.52641964",
"0.52641964",
"0.5244588",
"0.5224988",
"0.5219556",
"0.520917",
"0.51843125",
"0.51752377"... | 0.7392299 | 0 |
take `num` elements from sample `smp` similar to random.sample but even if `num` > len(`smp`). | def grow_sample(smp, num):
smp = np.asarray(smp)
smp_len = len(smp)
if smp_len > num:
return np.array(random.sample(list(smp), num))
div = int(np.floor(num / smp_len))
rem = num - div * smp_len
rem_el = np.array(random.sample(list(smp), rem))
base_el = np.tile(smp, div)
return np.concatenate((base_el, rem_el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_sampling(elements, n):\r\n import random\r\n return [random.choice(elements) for i in range(n)]",
"def take_samples(self, num_samples: int) -> List:\n if num_samples > len(self.samples):\n return random.sample(self.samples, len(self.samples))\n return random.sample(self.... | [
"0.68522865",
"0.648896",
"0.6459786",
"0.6449171",
"0.64182615",
"0.6378369",
"0.6269525",
"0.6269366",
"0.6265996",
"0.6110838",
"0.6074783",
"0.6069164",
"0.60457987",
"0.6039458",
"0.6031454",
"0.60261863",
"0.60166687",
"0.6005243",
"0.6001939",
"0.5999907",
"0.59767216"... | 0.8121735 | 0 |
Returns a array with one sample from each discrete action space | def sample(self):
# For each row: round(random .* (max - min) + min, 0)
random_array = prng.np_random.rand(self.num_discrete_space)
return [int(x) for x in np.floor(np.multiply((self.high - self.low + 1.), random_array) + self.low)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_space_sample(self):\n return np.random.choice(self.possible_actions)",
"def sample(self):\n return self._action_out(\n [self.action_space.sample() for _ in range(self.batch_size)]\n )",
"def sample(self):\n return self._action_out(self._env.action_space.sample())",
"def sample... | [
"0.773534",
"0.7430677",
"0.7215112",
"0.7125647",
"0.69660443",
"0.68396944",
"0.67650235",
"0.66935027",
"0.66743064",
"0.6635198",
"0.66298485",
"0.66145176",
"0.6585872",
"0.6581748",
"0.6571255",
"0.6563881",
"0.6558905",
"0.6444396",
"0.64072853",
"0.63822645",
"0.63787... | 0.6053503 | 36 |
Log in user by returning token for future auth checking. | def do_login(user):
access_token = create_access_token(identity=user)
return (jsonify(token=access_token), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_user(self):\n response = self.client.post(self.login_url, self.login_data, format='json')\n return response.data['token']",
"def login(self):\n r = self._login_token()",
"def login_user(self):\n username = self.request.GET['username']\n api_token = self.request.GET[... | [
"0.7537836",
"0.7407799",
"0.72434175",
"0.71986794",
"0.71783644",
"0.71584034",
"0.70996326",
"0.70978427",
"0.7061141",
"0.70213175",
"0.701451",
"0.6968114",
"0.6894106",
"0.6851875",
"0.68486446",
"0.6838847",
"0.6823613",
"0.68078375",
"0.6803706",
"0.6791101",
"0.67853... | 0.6631565 | 32 |
Handle user signup. Create new user and add to DB. | def signup():
user_data = request.form
file = request.files.get('image_url')
form = UserSignUpForm(formdata=user_data)
if form.validate():
try:
user = User.signup(form)
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_up():\n form = RegisterForm()\n if request.method == \"GET\":\n return render_template('adduser.html', title='Add New User', form=form)\n if request.method == 'POST' and form.validate_on_submit():\n username = form.username.data\n password = form.password1.data\n email... | [
"0.796354",
"0.794196",
"0.7917311",
"0.7814326",
"0.7689266",
"0.7680645",
"0.76801836",
"0.7669408",
"0.76627326",
"0.76289976",
"0.7624781",
"0.76110274",
"0.7576079",
"0.7557743",
"0.7549387",
"0.75390756",
"0.7515333",
"0.75080764",
"0.74885774",
"0.74852425",
"0.7450352... | 0.0 | -1 |
Show user details. Returns => { | def user_show(username):
user = User.query.get_or_404(username)
# TODO: grab messages for user inbox (to_user = user) and
# user outbox (from_user = user)
# order messages by most recent from the database
return (jsonify(user=user.serialize()), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_user():\n\n return render_template('user/show_by_user.html', title='Show Profile', user = current_user)",
"def show_user(request):\n return _show_user(request)",
"def show_user(request):\n return _show_user(request)",
"def show_user_info(self):\n name = self.get_user_name()\n prin... | [
"0.8086204",
"0.80691504",
"0.80691504",
"0.8057358",
"0.79427403",
"0.78174114",
"0.7764818",
"0.7717915",
"0.7717915",
"0.7714498",
"0.7680341",
"0.7642919",
"0.760462",
"0.75965494",
"0.75780016",
"0.75545",
"0.75474465",
"0.74859643",
"0.74281335",
"0.74281335",
"0.740639... | 0.6835674 | 69 |
Show user's created listings | def user_listings(username):
user = User.query.get_or_404(username)
created_listings = user.created_listings
serialized = [
listing.serialize(isDetailed=False)
for listing in created_listings
]
return (jsonify(listings=serialized), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request):\n listings = self.get_queryset().all().order_by(\"start_date\")\n username = None\n auth = request.user.is_authenticated\n if auth:\n username = request.user.username\n return render(request, 'listings/list.html', {'listings': listings,\n ... | [
"0.7004472",
"0.6673305",
"0.6630085",
"0.6528049",
"0.6506623",
"0.6486702",
"0.64642733",
"0.64642733",
"0.64642733",
"0.64642733",
"0.64642733",
"0.64642733",
"0.6457943",
"0.64462024",
"0.6429502",
"0.6318806",
"0.62973744",
"0.62960905",
"0.62940705",
"0.6247468",
"0.622... | 0.76791966 | 0 |
Show messages between two users. Returns => { | def messages_list(from_username, to_username):
User.query.get_or_404(from_username)
User.query.get_or_404(to_username)
messages = Message.find_all(from_username, to_username)
serialized = [message.serialize() for message in messages]
return (jsonify(messages=serialized), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_messages(self):\n\n\t\twhile self.joined:\n\t\t\tif len(self.messages) != 0:\n\t\t\t\tfor msg in self.messages:\n\t\t\t\t\t#: If the message is empty, ignore it.\n\t\t\t\t\tif msg == \"\":\n\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t#: If the message is close\", then the server has told the client\n\t\t\t\t\t#:... | [
"0.6388468",
"0.63082397",
"0.6230974",
"0.61316925",
"0.602502",
"0.60192716",
"0.60118103",
"0.598183",
"0.59651697",
"0.5906656",
"0.5899067",
"0.58894104",
"0.58868337",
"0.58751917",
"0.5873003",
"0.5843157",
"0.580884",
"0.5784857",
"0.57808447",
"0.57771546",
"0.576388... | 0.5989809 | 7 |
Show listings based on query parameters of max price, longitude, latitude, number of beds, or number of bathrooms Returns => { | def listings_list():
inputs = Listing.convert_inputs(request.args)
form = ListingSearchForm(data=inputs)
if form.validate():
listings = Listing.find_all(inputs)
serialized = [listing.serialize(
isDetailed=False
) for listing in listings]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listingsPage(city, stateCode=None):\n try:\n # Retrieve listings from Hoya database\n listings = list(db.listings.find({\"address\": {\"city\": city}}))\n\n # Retrieve listings from external (realtor) API\n url = os.getenv(\"API_URL\")\n\n querystring = {\n \"ci... | [
"0.6379855",
"0.6356285",
"0.62549347",
"0.61244184",
"0.60855544",
"0.60742897",
"0.6054216",
"0.6041205",
"0.6029348",
"0.5999373",
"0.5972371",
"0.596631",
"0.5953028",
"0.5931009",
"0.58853513",
"0.5883086",
"0.58543015",
"0.5838612",
"0.57740444",
"0.5765065",
"0.5743168... | 0.5530103 | 40 |
Show a listing. Returns => { | def listing_show(listing_id):
listing = Listing.query.get_or_404(listing_id)
return (jsonify(listing=listing.serialize(isDetailed=True)), 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listing(request):\n lakes = Lake.objects.all().order_by(\"title\")\n\n return render(request, \"lakes/listing.html\", {\n \"lakes\": lakes,\n })",
"def show_listings(offset):\n items = Item.query.filter(Item.status == \"listed\").order_by(desc(Item.date_listed)).offset(offset).limit(LIMIT)... | [
"0.69484735",
"0.6776792",
"0.6761225",
"0.6761225",
"0.6761225",
"0.67378205",
"0.65945524",
"0.65146893",
"0.64641935",
"0.6459318",
"0.6453462",
"0.645169",
"0.6412892",
"0.63761",
"0.637451",
"0.63693076",
"0.6330857",
"0.62925524",
"0.6270236",
"0.62691593",
"0.6267482",... | 0.7389735 | 0 |
Show messages belonging to a listing thread Returns => { | def listing_messages(listing_id):
Listing.query.get_or_404(listing_id)
auth_username = get_jwt_identity()
all_messages = Message.find_by_listing(listing_id, auth_username)
print("ALL MESSAGES: ", all_messages)
serialized = [message.serialize() for message in all_messages]
return (jsonify(messag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_messages(self):",
"def show_messages(self):\n for msg in self.messages:\n print msg['text']",
"def trelloView(self, args):\n\n l = self.getListByID(args[\"threadID\"] ) \n\n result = \"\"\n for card in l: result.append(f' * {card.name}\\n')\n return result... | [
"0.7499831",
"0.672327",
"0.63941616",
"0.6241167",
"0.6189074",
"0.6139349",
"0.6121853",
"0.607185",
"0.6056436",
"0.60333997",
"0.5997617",
"0.5995988",
"0.5987205",
"0.597698",
"0.5975364",
"0.5946861",
"0.5916165",
"0.5889432",
"0.5873572",
"0.5863976",
"0.5851506",
"0... | 0.6513653 | 2 |
Create a new listing. | def listing_create():
listing_data = request.json.get("listing")
form = ListingCreateForm(data=listing_data)
if form.validate():
listing = Listing.create(form)
db.session.commit()
# TODO: reevaluate error with a try and except later
return (jsonify(listing=listing.serialize(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newListing():\n try:\n # Create newListing, initialize with user input from form\n newListing = {\n \"numBedrooms\": request.form.get(\"numBedrooms\"),\n \"sqFootage\": request.form.get(\"sqFootage\"),\n \"numBathrooms\": request.form.get(\"numBathrooms\"),\n ... | [
"0.7329421",
"0.7028599",
"0.6506419",
"0.6243624",
"0.6172223",
"0.60724956",
"0.6068415",
"0.605586",
"0.6049541",
"0.5983175",
"0.5927461",
"0.5834615",
"0.5830206",
"0.5818242",
"0.5696018",
"0.56799376",
"0.5675575",
"0.56571704",
"0.5647056",
"0.5627651",
"0.562004",
... | 0.79246366 | 0 |
Add noncaching headers on every request. | def add_header(response):
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
response.cache_control.no_store = True
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(req):\n req.headers[\"Cache-Control\"] = \"no-cache\"\n return req",
"def disable_caching(self):\n\n def after_request(r: flask.Response):\n if 'Cache-Control' not in r.headers:\n r.headers['Cache-Control'] = 'no-store'\n return r\n\n ... | [
"0.74973166",
"0.748153",
"0.73780614",
"0.7354821",
"0.7340503",
"0.7238027",
"0.7234116",
"0.71540225",
"0.7139049",
"0.70819616",
"0.70819616",
"0.7081777",
"0.70774555",
"0.7069949",
"0.7069949",
"0.7069949",
"0.7069949",
"0.7069949",
"0.7069949",
"0.7069949",
"0.7069949"... | 0.74886334 | 2 |
Tests if a user is able to registrate | def test_register_information(self):
form = UserRegistrationForm(
{
'email': 'testing@gmail.com',
'username': 'Name',
'password1': 'SuperSecretPassword',
'password2': 'SuperSecretPassword'
})
self.assertTrue(form.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_can_register(self):\n response = self.client.post(\n CONSTS.USER_REGISTER_URL,\n data=self.user_data,\n format='json'\n )\n self.assertEqual(response.status_code, status.HTTP_201_CREATED)\n self.assertEqual(User.objects.count(), 1)\n ... | [
"0.7685858",
"0.7519004",
"0.72195536",
"0.70758814",
"0.70114166",
"0.700335",
"0.6997962",
"0.69537324",
"0.69537324",
"0.6950043",
"0.6911927",
"0.69042796",
"0.68562794",
"0.6856086",
"0.68457437",
"0.68400973",
"0.67808664",
"0.67730355",
"0.6773031",
"0.6755631",
"0.672... | 0.0 | -1 |
Tests if the correct registration errors occur through empty input | def test_correct_result_for_no_value(self):
form = UserRegistrationForm(
{
'email': '',
'username': '',
'password1': '',
'password2': ''
})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_email():\n expect_error(register, InputError, \"a\", \"abdkjjd\", \"a\", \"A\", \"\")",
"def test_empty_username():\n expect_error(register, InputError, \"\", \"abcdef\", \"A\", \"A\", \"A\")",
"def _check_for_incomplete_input(self):\n pass",
"def test_registration_empty_Fields(se... | [
"0.70723534",
"0.7011326",
"0.67816174",
"0.67182285",
"0.6696591",
"0.651364",
"0.64728117",
"0.6415004",
"0.6400659",
"0.63573617",
"0.6349792",
"0.6309029",
"0.63077474",
"0.6302934",
"0.62947196",
"0.6263945",
"0.62520313",
"0.6216125",
"0.621058",
"0.6195165",
"0.6157549... | 0.6086308 | 25 |
Return a valid set of data | def get_post_data(self, random_str):
return {
'root_domain': '{0}.{0}.mozilla.com'.format(
random_label() + random_str),
'soa_primary': 'ns1.mozilla.com',
'soa_contact': 'noc.mozilla.com',
'nameserver_1': 'ns1.mozilla.com',
'nameserver_2': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data(self):\n\n return self.__valid_data, self.__valid_labels",
"def clean_data(self):\n data_clean = []\n for item in self.data:\n if int(item[2]) >= self.seq_length and int(item[2]) <= self.max_frames:# and item[1] in self.classes:\n data_clean.append(ite... | [
"0.6572218",
"0.63573205",
"0.63466954",
"0.62495863",
"0.6107567",
"0.59780973",
"0.5960616",
"0.59139663",
"0.591239",
"0.58570516",
"0.583943",
"0.5813389",
"0.5805638",
"0.5783873",
"0.5777706",
"0.57579625",
"0.56897855",
"0.568282",
"0.5671242",
"0.56682026",
"0.5648480... | 0.0 | -1 |
This uses tasks as a block box measurement to see if conflicts are being handled | def test_svn_conflict(self):
root_domain = create_fake_zone('conflict')
b1 = DNSBuilder(STAGE_DIR=self.stage_dir, PROD_DIR=self.prod_dir,
LOCK_FILE=self.lock_file, LOG_SYSLOG=False,
FIRST_RUN=True, PUSH_TO_PROD=True,
STOP_UPDATE_FIL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_task_stagnant(task):",
"def checkForOverlappingTasks(tasks, machines):\n for m in machines:\n compatibleTasks = []\n for t in tasks:\n if m == t.machine:\n compatibleTasks.append(t)\n slots = [] # time slot\n for ct in compatibleTasks:\n ... | [
"0.6660232",
"0.6535595",
"0.6127876",
"0.60616106",
"0.59879404",
"0.5961803",
"0.5934658",
"0.58697385",
"0.5862346",
"0.5777182",
"0.57650435",
"0.573195",
"0.5729254",
"0.5703972",
"0.5692266",
"0.5681535",
"0.56760156",
"0.56522393",
"0.5651635",
"0.56361294",
"0.5627655... | 0.0 | -1 |
def a for class A | def a(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def a1(self):\n print(\"Hello from an instance of A\")",
"def __init__(self,a): \n self.a = a",
"def b_class_a(self):\n return self._b_class_a",
"def fA(self):\n pass",
"def a(self):\r\n return self.__a",
"def getA(self):\n\t\treturn self.a",
"def fun_a(self):\n ... | [
"0.6785395",
"0.67790973",
"0.67719483",
"0.66484004",
"0.65515727",
"0.6428552",
"0.6374703",
"0.62903553",
"0.62113595",
"0.61528116",
"0.6152233",
"0.60726637",
"0.59858364",
"0.5968785",
"0.5968785",
"0.5896728",
"0.5852677",
"0.5852677",
"0.5852677",
"0.58128977",
"0.580... | 0.73799604 | 1 |
def b for class A | def b(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b_class_a(self):\n return self._b_class_a",
"def method_b(self):",
"def a(self):\n pass",
"def a(self):\n pass",
"def fA(self):\n pass",
"def a1(self):\n print(\"Hello from an instance of A\")",
"def method_a(self):",
"def fun_a(self):\n pass",
"def apply_t... | [
"0.81225514",
"0.7177318",
"0.6980328",
"0.6980328",
"0.69559944",
"0.67253184",
"0.6674369",
"0.6585292",
"0.63309807",
"0.6221917",
"0.6135347",
"0.61243135",
"0.6044034",
"0.6024267",
"0.5972179",
"0.5855993",
"0.58310544",
"0.58310544",
"0.5770733",
"0.5753046",
"0.571631... | 0.6847917 | 6 |
def c for class B | def c(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b_class_a(self):\n return self._b_class_a",
"def method_b(self):",
"def b(self):\n pass",
"def b(self):\n pass",
"def fA(self):\n pass",
"def apply_to(self, b):\n raise NotImplementedError(\"base class called\")",
"def a1(self):\n print(\"Hello from an instance... | [
"0.72559613",
"0.64843786",
"0.59596163",
"0.59596163",
"0.5816997",
"0.5727323",
"0.56905144",
"0.5590985",
"0.55544794",
"0.55544794",
"0.54432875",
"0.5427815",
"0.54071224",
"0.52513546",
"0.52464956",
"0.5181195",
"0.5168766",
"0.51669246",
"0.5132274",
"0.51249254",
"0.... | 0.5878098 | 5 |
def d for class B | def d(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b_class_a(self):\n return self._b_class_a",
"def b(self):\n pass",
"def b(self):\n pass",
"def method_b(self):",
"def DM(self):",
"def a(self):\n pass",
"def a(self):\n pass",
"def __call__(self, a, b):\n return _table.DSTable___call__(self, a, b)",
"def a1... | [
"0.6579814",
"0.56798184",
"0.56798184",
"0.565089",
"0.54218364",
"0.53211176",
"0.53211176",
"0.52607226",
"0.52396244",
"0.5215984",
"0.5213931",
"0.5103858",
"0.5028466",
"0.5022928",
"0.5002006",
"0.49860397",
"0.49682003",
"0.49272045",
"0.49025878",
"0.48974836",
"0.48... | 0.65280885 | 2 |
get a list of all class members, ordered by class | def getmembers(klass, members=None):
if members is None:
members = []
for k in klass.__bases__:
print(k)
getmembers(k, members)
for m in dir(klass):
print(m)
if m not in members:
members.append(m)
return members | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(cls):\n return [(k, v) for k, v in cls.__members__.items()]",
"def get_members():",
"def all_names(cls) -> List[str]:\n return list(member_name for member_name in cls.__members__.keys())",
"def list(cls):\n return [cls.__dict__.get(name) for name in dir(cls) if (\n not... | [
"0.7196665",
"0.70308536",
"0.6879248",
"0.67503995",
"0.6459501",
"0.6431725",
"0.6319217",
"0.6284791",
"0.62736416",
"0.6240478",
"0.6227316",
"0.6226022",
"0.6189405",
"0.6184931",
"0.6156415",
"0.6146528",
"0.61306727",
"0.60859036",
"0.6068512",
"0.60406107",
"0.6035632... | 0.76963896 | 0 |
check for isomorphism directly instead of using hash. | def really_covalent_isomorphic(mol1, mol2):
return nx.is_isomorphic(
mol1.covalent_graph,
mol2.covalent_graph,
node_match = iso.categorical_node_match('specie', None)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_isomorphism(self):\n mol1 = Molecule(smiles='[O-][N+]#N')\n mol2 = Molecule(smiles='[N-]=[N+]=O')\n self.assertTrue(converter.check_isomorphism(mol1, mol2))",
"def determine_obj(self, obj):\n if type(obj) is Ohm:\n self._ohm_exists = self._ohm_exists ^ True\n... | [
"0.589274",
"0.55066395",
"0.53797334",
"0.5262819",
"0.52508837",
"0.51115096",
"0.5107703",
"0.5105388",
"0.50875807",
"0.5055891",
"0.50287867",
"0.5004008",
"0.4990145",
"0.49889457",
"0.4956799",
"0.49453872",
"0.4945348",
"0.49255258",
"0.49251246",
"0.48831788",
"0.488... | 0.0 | -1 |
run each molecule through the species decision tree and then choose the lowest weight coordimer based on the coordimer_weight function. | def species_filter(
dataset_entries,
mol_entries_pickle_location,
species_report,
species_decision_tree,
coordimer_weight,
species_logging_decision_tree=Terminal.DISCARD,
generate_unfiltered_mol_pictures=False
):
log_message("starting species filter")
log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight(self):",
"def run(self):\n population_p = self.create_population()\n population_p = self.sort_population(population_p)\n best_x = population_p[0]\n for k in range(self.iteration):\n population_r = []\n # random.shuffle(population_p)\n for i ... | [
"0.55571777",
"0.54573673",
"0.5408982",
"0.5379211",
"0.5377183",
"0.53011286",
"0.52403504",
"0.5238987",
"0.52350104",
"0.52283037",
"0.5216082",
"0.52013195",
"0.5187105",
"0.5168902",
"0.5143446",
"0.51354057",
"0.5131264",
"0.51268613",
"0.51061064",
"0.5103975",
"0.509... | 0.51223826 | 18 |
Multiline string based on max available width. | def same_len(txt, name_len):
return '\n'.join(txt + ([' '] * (name_len - len(txt)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _multiline_width(multiline_s, line_width_fn=len):\n return max(map(line_width_fn, re.split(\"[\\r\\n]\", multiline_s)))",
"def limit_max_len(data, indentation, max_length=MAX_LENGTH): \n buf = ''\n while len(data) > MAX_LENGTH:\n idx = data.rfind(' ', 0, MAX_LENGTH)\n buf += '%s\\n%... | [
"0.7045821",
"0.6897236",
"0.67795783",
"0.67193043",
"0.6708668",
"0.65434706",
"0.6513859",
"0.64862955",
"0.6335112",
"0.63170445",
"0.6309135",
"0.6297263",
"0.6276366",
"0.6260004",
"0.6234242",
"0.62333167",
"0.6220249",
"0.62160796",
"0.61966604",
"0.6147532",
"0.61455... | 0.0 | -1 |
Format permissions based on requirements. | def perms_result(perms, req_perms):
data = []
meet_req = perms >= req_perms
result = "**PASS**" if meet_req else "**FAIL**"
data.append(f"{result} - {perms.value}\n")
true_perms = [k for k, v in dict(perms).items() if v is True]
false_perms = [k for k, v in dict(perms).items() if v is False]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_format_permissions_and_docstring(self):\n self.assertEqual(\n format_permissions_and_docstring(\n [\"permission formatted string\"],\n {\"some\": \"docstring\"},\n ),\n (\n \"## Permissions\\n\\n\"\n \"perm... | [
"0.6724399",
"0.6366341",
"0.6327934",
"0.627944",
"0.6209144",
"0.60631084",
"0.60415566",
"0.6037447",
"0.6026216",
"0.60039556",
"0.59658164",
"0.59431684",
"0.5918092",
"0.58747816",
"0.5852575",
"0.5852575",
"0.5847964",
"0.5837934",
"0.57385314",
"0.57385314",
"0.570883... | 0.58270013 | 18 |
Set bot status to online, idle or dnd | async def set_status(self, ctx, *, status: str = "online"):
try:
status = discord.Status[status.lower()]
except KeyError:
await ctx.error("Invalid Status", "Only `online`, `idle` or `dnd` statuses are available.")
else:
await self.bot.change_presence(status=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def status(self, ctx, *, status=None):\n # [p]set status <status>\n\n statuses = {\n \"online\": discord.Status.online,\n \"idle\": discord.Status.idle,\n \"dnd\": discord.Status.dnd,\n \"invisible\": discord.Status.inv... | [
"0.7229784",
"0.7148614",
"0.69359046",
"0.6784688",
"0.6700738",
"0.65831655",
"0.6553433",
"0.6454904",
"0.62434053",
"0.62246996",
"0.6186946",
"0.61738676",
"0.6167214",
"0.6167214",
"0.6167214",
"0.6127212",
"0.6101693",
"0.6087031",
"0.6058194",
"0.60546035",
"0.6040849... | 0.7328083 | 0 |
Show how long the bot has been running for | async def uptime(self, ctx):
try:
await ctx.embed('Uptime', self.bot.uptime_str, colour='blue', icon="https://i.imgur.com/82Cqf1x.png")
except discord.errors.Forbidden:
await ctx.send(f"Uptime: {self.bot.uptime_str}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def alive(self, ctx):\n now = datetime.now()\n delta = now - runtime\n time = str(timedelta(seconds=delta.seconds)).split(\":\")\n days = \"\" if delta.days == 0 else str(delta.days) + \" days, \"\n hours = \"\" if time[0] == \"0\" else time[0] + \" hours, \"\n minut... | [
"0.72483665",
"0.6973728",
"0.6913436",
"0.68573534",
"0.6856942",
"0.68513674",
"0.6820655",
"0.66653305",
"0.6598535",
"0.6590169",
"0.646273",
"0.6459161",
"0.6393419",
"0.63527864",
"0.63522536",
"0.63416576",
"0.6337638",
"0.6321478",
"0.629618",
"0.62718636",
"0.6270746... | 0.62042725 | 22 |
Provide the bot invite link | async def invite(self, ctx, plain_url: bool = False):
if not plain_url:
try:
await ctx.embed(
'Click to invite me to your server!',
title_url=self.bot.invite_url,
colour='blue',
icon="https://i.imgur.com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link(self):\n return f\"https://{DOMAIN}/invite/{self.code}\"",
"async def invite(self, ctx):\r\n myInvite = discord.utils.oauth_url(self.bot.user.id, permissions=discord.Permissions(permissions=8))\r\n await ctx.channel.send('Invite me to *your* server with this link: \\n\\n<{}>'.format... | [
"0.8056528",
"0.8004137",
"0.79830885",
"0.7955939",
"0.79000896",
"0.773974",
"0.7718806",
"0.7641234",
"0.76343787",
"0.7460639",
"0.7315977",
"0.72894794",
"0.7227164",
"0.7205976",
"0.71410364",
"0.7038381",
"0.7016796",
"0.69034225",
"0.68183804",
"0.67678905",
"0.675286... | 0.73445517 | 10 |
Show information about Firetail | async def about(self, ctx):
author_repo = "https://github.com/scragly"
bot_repo = author_repo + "/Firetail"
server_url = "https://discord.gg/ZWmzTP3"
owner = "Discord: Scragly#5146\nEVE: Kyo Kuronami"
member_count = sum(g.member_count for g in self.bot.guilds)
server_cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def info(self):\n # [p]info\n\n await self.bot.say(strings.info.format(\n CacheAPI.get(key='dwarf_repository'),\n CacheAPI.get(key='dwarf_invite_link')))",
"async def info(self, ctx):\n\t\tembed = discord.Embed(\n\t\t\tdescription=\"Created By Seperoph#1399 and AkaBaka#4... | [
"0.6433732",
"0.6324648",
"0.6237341",
"0.62119997",
"0.62119997",
"0.6136656",
"0.61218625",
"0.6103292",
"0.6083123",
"0.60803884",
"0.60434544",
"0.5989061",
"0.59512115",
"0.59127724",
"0.59003747",
"0.5899654",
"0.5893113",
"0.5861106",
"0.58039325",
"0.57983714",
"0.579... | 0.6182582 | 5 |
Show current bot settings | async def get_(self, ctx):
await ctx.send_help(ctx.command) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def showsettings(self, ctx: commands.Context):\n data = await self.config.all()\n channel = self.bot.get_channel(data[\"logChannel\"])\n channel = channel.mention if channel else \"None\"\n description = (\n f\"Name: {data['plagueName']}\\n\"\n f\"Log Channel... | [
"0.7790527",
"0.7418267",
"0.71628183",
"0.7150781",
"0.7067257",
"0.6931699",
"0.6821637",
"0.6818597",
"0.6705083",
"0.66577",
"0.66496336",
"0.65689814",
"0.6524367",
"0.6492573",
"0.64677846",
"0.63896227",
"0.63681394",
"0.6340193",
"0.6306574",
"0.625953",
"0.6211916",
... | 0.0 | -1 |
Show all current contextual permissions for Firetail. | async def permissions(self, ctx, *, channel_id: int = None):
if not await ctx.is_co_owner() and channel_id is not None:
return await ctx.error('Only co-owners of the bot can specify channel')
channel = ctx.get(ctx.bot.get_all_channels(), id=channel_id)
guild = channel.guild if chan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission_list(**kwargs):\n print(AppPermissionSchema(many=True).dumps(\n get_protected_routes(ignored_methods=[\"HEAD\", \"OPTIONS\"]), indent=4))",
"def permissions(self):\n return self.get_permissions()",
"def get_all_permissions(self, obj=None):",
"def list_perms(request):\n\tpe... | [
"0.68545026",
"0.6703244",
"0.6653488",
"0.6619001",
"0.65269685",
"0.6475284",
"0.63374853",
"0.6324723",
"0.6316331",
"0.62841374",
"0.6274684",
"0.62725604",
"0.62696904",
"0.62159365",
"0.6204679",
"0.6190119",
"0.6185705",
"0.6183314",
"0.6182407",
"0.6182407",
"0.617709... | 0.0 | -1 |
Show permissions for Firetail for the current guild. | async def perms_guild(self, ctx):
guild_perms = ctx.guild.me.guild_permissions
perms_compare = guild_perms >= self.bot.req_perms
msg = f"Guild Permissions: {guild_perms.value}\n"
msg += f"Met Minimum Permissions: {perms_compare}\n\n"
if not perms_compare:
msg += (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def permissions(self, ctx):\n await ctx.send_help(ctx.command)",
"async def permissions(self, ctx):\n if len(ctx.message.mentions) == 0:\n for perm in ctx.message.author.server_permissions:\n print(perm)\n else:\n users = ctx.message.mentions\n ... | [
"0.67478997",
"0.6537415",
"0.64798903",
"0.63688457",
"0.6293479",
"0.6206859",
"0.60562044",
"0.5984013",
"0.58921415",
"0.58398074",
"0.581788",
"0.5812316",
"0.58116597",
"0.5799472",
"0.5751063",
"0.57509077",
"0.57100934",
"0.57100934",
"0.57089597",
"0.5688369",
"0.567... | 0.6232407 | 5 |
Get permissions for Firetail for the current channel. | async def perms_channel(self, ctx):
chan_perms = ctx.channel.permissions_for(ctx.guild.me)
req_perms = self.bot.req_perms
perms_compare = chan_perms >= req_perms
msg = f"Channel Permissions: {chan_perms.value}\n"
msg += f"Met Minimum Permissions: {perms_compare}\n\n"
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permissions(self) -> discord.Permissions:\n return self.channel.permissions_for(self.guild.me)",
"def octopus_permissions_get(self, msg, args):\r\n return self.permissions.get_permissions()",
"def get_permissions(self):\n return self.settings[\"permissions\"]",
"def permissions(self)... | [
"0.7595527",
"0.72696835",
"0.7151413",
"0.7082322",
"0.7068909",
"0.6992472",
"0.6849245",
"0.68158346",
"0.6726031",
"0.66407394",
"0.65249467",
"0.64995545",
"0.6469854",
"0.6443854",
"0.6402226",
"0.64015806",
"0.6399386",
"0.63904816",
"0.6370302",
"0.63420635",
"0.63410... | 0.60696447 | 44 |
Get websocket reconnection count. | async def resumes(self, ctx):
await ctx.info(f"Connections Resumed: {self.bot.resumed_count}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getconnectioncount(self):\n return self.proxy.getconnectioncount()",
"def updated():\n ws = request.environ.get('wsgi.websocket', None)\n print(\"web socket retrieved\")\n app.number_of_connexion += 1\n if ws:\n while True:\n delay = random.randint(MIN_DELAY, MAX_DELAY)\n... | [
"0.7130144",
"0.63142276",
"0.61699164",
"0.6150626",
"0.6093861",
"0.60927045",
"0.5967321",
"0.59588295",
"0.5890932",
"0.5845503",
"0.58278555",
"0.5825101",
"0.5817591",
"0.5773662",
"0.575895",
"0.574898",
"0.57289207",
"0.56968397",
"0.56816065",
"0.5676014",
"0.5655668... | 0.0 | -1 |
Get the Discord API response time. | async def ping(self, ctx):
msg = f"{(self.bot.ws.latency * 1000):.2f} ms"
await ctx.info(f"Bot Latency: {msg}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def server_time(self):\n uri = \"/v3/time\"\n success, error = await self.request(\"GET\", uri)\n return success, error",
"def millisecond_response_time(self):\n return int(self.responseTime * 1000)",
"def elapsed_time(self) -> 'outputs.DurationResponse':\n return pulum... | [
"0.7005152",
"0.6981814",
"0.69236654",
"0.6922128",
"0.6828977",
"0.67511743",
"0.6624996",
"0.6571519",
"0.6559509",
"0.6536248",
"0.6454459",
"0.6447548",
"0.64466363",
"0.6397029",
"0.63684434",
"0.63023984",
"0.6286374",
"0.6286374",
"0.6260646",
"0.6257144",
"0.62487143... | 0.0 | -1 |
Delete a number of messages from the channel. Default is 10. Max 100. | async def purge(self, ctx, msg_number: int = 10):
if ctx.guild.id == 202724765218242560:
return
if msg_number > 100:
await ctx.error("No more than 100 messages can be purged at a time.")
return
deleted = await ctx.channel.purge(limit=msg_number)
s =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def channel_(self, ctx, number=10):\n number = number if number <= 100 else 100\n question = await ctx.send(f\"this will delete the last {number} messages from ALL users. Continue?\")\n await question.add_reaction(self.reactions[0])\n await question.add_reaction(self.reactions[1])... | [
"0.7288479",
"0.72206223",
"0.7182962",
"0.7022472",
"0.6961094",
"0.69093484",
"0.6867969",
"0.6842305",
"0.6701014",
"0.6677718",
"0.6663868",
"0.666008",
"0.6650558",
"0.6520946",
"0.65097123",
"0.6386746",
"0.6380716",
"0.6371731",
"0.6360819",
"0.6308435",
"0.62655646",
... | 0.7220789 | 1 |
Get and set server prefix. Use the argument 'reset' to reset the guild prefix to default. | async def prefix(self, ctx, *, new_prefix: str = None):
if not ctx.guild:
if new_prefix:
await ctx.error("Prefix cannot be set in DMs.")
return
await ctx.info(f"Prefix is {self.bot.default_prefix}")
return
if not new_prefix:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def setprefix(self, ctx, *, prefix=bot_prefix):\n prefix = prefix.lower()\n current_server_prefix = await self.ex.get_server_prefix(ctx.guild.id)\n if len(prefix) > 8:\n await ctx.send(\"> **Your prefix can not be more than 8 characters.**\")\n else:\n # Defa... | [
"0.8096553",
"0.74361634",
"0.7325818",
"0.7303438",
"0.7146142",
"0.71359897",
"0.71139777",
"0.7093602",
"0.7084125",
"0.7039627",
"0.70124114",
"0.70011115",
"0.6926423",
"0.6858783",
"0.68378776",
"0.65731335",
"0.64941794",
"0.6477685",
"0.6385448",
"0.6202525",
"0.61545... | 0.7321538 | 3 |
Whitelist a role to allow server/channel access to the bot. Use '!whitelist server/channel/remove role_name' | async def whitelist(self, ctx, scope: str, role: discord.Role):
scopes = {
'server': ctx.guild,
'channel': ctx.channel,
'remove': False
}
try:
scope = scopes[scope.lower()]
except KeyError:
await ctx.error(
'In... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def oauth_whitelist(self, ctx, target: Union[Role, utils.User]):\n whitelisted = self.bot.config[\"oauth_whitelist\"]\n\n # target.id is not int??\n if target.id in whitelisted:\n whitelisted.remove(target.id)\n removed = True\n else:\n whitelisted... | [
"0.6592266",
"0.6458174",
"0.5970901",
"0.59082526",
"0.5907761",
"0.590355",
"0.58978397",
"0.5852671",
"0.5787354",
"0.576652",
"0.573009",
"0.57242316",
"0.5718454",
"0.5717965",
"0.5704382",
"0.5697546",
"0.56893694",
"0.5687715",
"0.56833106",
"0.5663093",
"0.5621843",
... | 0.78769565 | 0 |
Prints that the user has gained a certain number of points. | def gain_point(self, points):
self.points += points
print(f"Yay! You have gained {points} point(s)! That means you now have {self.points} points!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def points(self, event, user):\n if not self.checkPerms(event, \"mod\"):\n return\n event.msg.delete()\n if not str(user) in self.participants.keys():\n message = \"This user has not participated in the event yet.\"\n else:\n message = \"Points so far fo... | [
"0.6295395",
"0.6198117",
"0.6163108",
"0.61107635",
"0.60114384",
"0.59564227",
"0.59373504",
"0.57842314",
"0.5758313",
"0.572314",
"0.5715337",
"0.568637",
"0.5660312",
"0.5635703",
"0.56299436",
"0.5620789",
"0.5615362",
"0.5604543",
"0.5599886",
"0.5595842",
"0.55945617"... | 0.66765255 | 0 |
Prints that the user has lost a certain number of points. | def lose_point(self, points):
self.points -= points
print(f"Oh no! You have lost {points} point(s)! That means you now have {self.points} points!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showNbLevelLose(self) :\n nbLevelLose = 0\n for level in self.level_history :\n if level.result == 0:\n nbLevelLose += 1\n Scenario.messageGetNbLevelLose(nbLevelLose)",
"def player_lose(self):\r\n\r\n self.summary = (\" \" * 83) + \"YOU LOSE\"\r\n ... | [
"0.6341795",
"0.6303589",
"0.6055089",
"0.6032912",
"0.5981581",
"0.576775",
"0.5738321",
"0.5728738",
"0.5715829",
"0.5710318",
"0.56970185",
"0.5694103",
"0.5685966",
"0.5660271",
"0.5614931",
"0.5583165",
"0.55793786",
"0.55679923",
"0.5566543",
"0.55512065",
"0.55066997",... | 0.7405634 | 0 |
Function that find minimal element in array | def min_search(arr: Sequence) -> int:
if len(arr) == 0:
print("упс")
return
i = 0
min_index = 0
min_value = arr[0]
while i < len(arr) - 1:
i += 1
if arr[i] < min_value:
min_value = arr[i]
min_index = i
print(f"arr:{arr},\nmin:{min_value}; index:{min_index}")
return min_index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min(self):\n a = self.array_form\n min = len(a)\n for i in xrange(len(a)):\n if a[i] != i and a[i] < min:\n min = a[i]\n return min",
"def min_search(arr: Sequence) -> int:\n\tprint(arr)\n\tmin_index = None\n\tmin_elem = arr[0]\n\tfor i in range(1, len(ar... | [
"0.7925055",
"0.7658557",
"0.76490307",
"0.7593806",
"0.75074613",
"0.74905646",
"0.74420714",
"0.7398279",
"0.7398279",
"0.735186",
"0.7324894",
"0.7082873",
"0.70476097",
"0.70369023",
"0.7016719",
"0.7015526",
"0.7004855",
"0.6989546",
"0.6985163",
"0.69713104",
"0.6943967... | 0.72386086 | 11 |
Check if the program is halted | def is_halted(self):
return self.pos == -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halted(self) -> bool:\n raise NotImplementedError(\"halted not implemented.\")",
"def halt(*_, **kwargs):\n raise ExecutionFinished(\"Reached halt\")",
"def halt(self):\n\n print(\"Halt program. Exit emulator.\")\n self.running = False\n sys.exit()",
"def halt(self):\n ... | [
"0.7268108",
"0.7246402",
"0.7129206",
"0.696312",
"0.6937122",
"0.686522",
"0.6818229",
"0.67811525",
"0.67796963",
"0.67501026",
"0.67468417",
"0.6687306",
"0.65247",
"0.64684963",
"0.642628",
"0.6406404",
"0.6354035",
"0.6339628",
"0.6337857",
"0.6326271",
"0.6289439",
"... | 0.67427045 | 11 |
Check if program is paused | def is_paused(self):
return self.pause | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paused(self) -> bool:",
"def is_paused(self):\n return self._is_paused",
"def is_paused(self):\n self.get_state()\n return self._is_paused()",
"def _is_paused(self):\n self.paused = self.state == 0\n return self.paused",
"def is_paused(self):\n return not self.... | [
"0.8045834",
"0.743452",
"0.74097407",
"0.73986506",
"0.7395203",
"0.7352385",
"0.7223583",
"0.71946",
"0.70427316",
"0.6981936",
"0.6897812",
"0.68908",
"0.6877727",
"0.6867015",
"0.68560666",
"0.6597903",
"0.6584473",
"0.65398806",
"0.6531661",
"0.6517159",
"0.64821386",
... | 0.7790882 | 1 |
If the process is paused you can start it again and add more input data as a list | def unpause(self, input_data = []):
self.input_data += input_data
self.pause = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_processing(self):",
"def populatereadylist():\n readyList.append(Process(\"P1\", time(0, 0, 1), time(0, 0, 4)))\n readyList.append(Process(\"P2\", time(0, 0, 2), time(0, 0, 6)))\n readyList.append(Process(\"P3\", time(0, 0, 3), time(0, 0, 2)))",
"def run(self):\n while(not self.stop_e... | [
"0.61868435",
"0.58790064",
"0.5825519",
"0.57422364",
"0.57005554",
"0.5649333",
"0.56405336",
"0.563904",
"0.5616837",
"0.5570273",
"0.5565236",
"0.55415046",
"0.55398834",
"0.553416",
"0.55335915",
"0.55188465",
"0.55148154",
"0.5511352",
"0.5510301",
"0.54770416",
"0.5475... | 0.58466136 | 2 |
Start the execution of the program | def calculate(self):
while self.pos != -1 and not self.pause:
param = self.data[ self.pos ]
opcode = f"{param%100:02d}"
self.func[ opcode ](param) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\r\n\r\n os.system(\"start python Program.py\")",
"def run(self):\n self.process.start()",
"def main():\n run_program()",
"def start(self):\n self.start_time = dt.datetime.now()\n self.call = ' '.join(sys.argv)\n self.commands = []",
"async def start_program(sel... | [
"0.8028352",
"0.7577727",
"0.7532822",
"0.7272453",
"0.71325374",
"0.7099492",
"0.7088178",
"0.7032843",
"0.70214736",
"0.7005394",
"0.6972598",
"0.69330704",
"0.68924904",
"0.68924904",
"0.68924904",
"0.68924904",
"0.6867798",
"0.684711",
"0.68389744",
"0.682391",
"0.6801941... | 0.0 | -1 |
get_mode returns mode (positional/immediate/relative) for parameters of the function | def get_mode(self, n, *, ret_n):
ns = f"{n:05d}"
return map(lambda x: int(x), ns[:3][::-1][:ret_n]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mode(self, ):\n return self.get_parameter('mode')",
"def _get_mode(self):\n raise NotImplementedError",
"def _get_mode():\n return context.get_context('mode')",
"def get_mode(self):\n self.read(\":FUNC?\")",
"def mode(self, mode: Optional[int] = None) -> Optional[int]:\n ... | [
"0.77541846",
"0.74093044",
"0.73348755",
"0.7175708",
"0.71209836",
"0.7083389",
"0.7039257",
"0.697183",
"0.6960951",
"0.69605714",
"0.6911137",
"0.69027394",
"0.690037",
"0.68150693",
"0.67780936",
"0.6714792",
"0.6714792",
"0.66736287",
"0.66460234",
"0.66199505",
"0.6593... | 0.60344315 | 67 |
Return the address depending on the offset of the parameter {1, 2, 3} and mode of the instruction {0, 1, 2} | def get_address(self, mode, offset):
address = None
if mode == 0:
address = self.data[ self.pos + offset ]
elif mode == 1:
address = self.pos + offset
elif mode == 2:
address = self.rel_pos + self.data[ self.pos + offset ]
else:
print("FAIL - wrong mode parameter")
return address | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_address(self, index, mode):\n if mode == IMMEDIATE_MODE:\n return index\n elif mode == POSITION_MODE:\n return self.program[index]\n elif mode == RELATIVE_MODE:\n return self.program[index] + self.relative_base\n raise Exception(f\"unknown mode: ... | [
"0.6668745",
"0.6327547",
"0.5890035",
"0.57063246",
"0.5650212",
"0.55881464",
"0.5513472",
"0.5477615",
"0.545401",
"0.5398909",
"0.5370811",
"0.5368167",
"0.53471595",
"0.5330211",
"0.5236021",
"0.5231211",
"0.5202355",
"0.5170001",
"0.51551473",
"0.51044565",
"0.5052717",... | 0.73673 | 0 |
Set the addr of data or registers to the value passed | def set_data(self, addr, value):
if addr < 0:
print("FAIL - negative address")
if addr >= len(self.data):
self.regs[ addr ] = value
else:
self.data[ addr ] = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_address_value(cls, addr, val):\n\t\tprint \" Called set_address_value({}, {})\".format(addr, val)\n\t\ttype = abs(addr) // 1000 # integer division\n\t\trelative_address = abs(addr) - (type * 1000)\n\t\tprint \"> Rel = {} - {}\".format(abs(addr), (type * 1000))\n\t\tprint \"> Set mem value: type = {}, addr... | [
"0.73658466",
"0.7286056",
"0.6579337",
"0.65497005",
"0.652987",
"0.6482303",
"0.6474041",
"0.6472174",
"0.6444143",
"0.6431403",
"0.6389778",
"0.63475466",
"0.6292115",
"0.6291647",
"0.62172794",
"0.61805683",
"0.6144672",
"0.61247176",
"0.6120023",
"0.6089628",
"0.60878253... | 0.8273164 | 0 |
Get value from data or registers based on address | def get_data(self, addr):
ret_val = None
if addr < 0:
print("FAIL - negative address")
if addr >= len(self.data):
try:
ret_val = self.regs[ addr ]
except:
ret_val = 0
else:
ret_val = self.data[ addr ]
return ret_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self, address):\n\n return self.data[address]",
"def _getReg(address):\n return struct.unpack(\"<L\", mem[address:address+4])[0]",
"def read_register(self, address):\n\n return self.register[address]",
"def get_address_value(cls, addr):\n\t\tprint \" Called get_address_value({... | [
"0.7964677",
"0.7391587",
"0.72287935",
"0.7128195",
"0.6796428",
"0.6705089",
"0.6661176",
"0.6637643",
"0.6637581",
"0.65186596",
"0.6502824",
"0.6396661",
"0.63817567",
"0.63555515",
"0.6342883",
"0.6311233",
"0.627899",
"0.627899",
"0.62426364",
"0.62329155",
"0.6205405",... | 0.8028823 | 0 |
Change the relative address for the IntCode program | def rel_base(self, p_addr = 0):
rel_pos = self.get_address(p_addr, 1)
rel_val = self.get_data(rel_pos)
self.rel_pos += rel_val
self.pos += 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(ctx, debug, address):\n ctx.obj['address'] = address",
"def jmp_to_addr(self):\n self.pc = self.opcode & 0x0FFF\n logger.info(\"Jumped to address at {}\".format(hex(self.pc)))\n # PC gets incremented after every instruction this counteracts that\n self.pc -= 2",
"def set... | [
"0.59858197",
"0.59513867",
"0.58189446",
"0.5754215",
"0.57180464",
"0.5638407",
"0.5626619",
"0.56262827",
"0.5620053",
"0.5611804",
"0.56056243",
"0.5602992",
"0.5593085",
"0.5554808",
"0.55259293",
"0.55187166",
"0.5517452",
"0.54867977",
"0.54833007",
"0.54251236",
"0.54... | 0.48363248 | 78 |
Jump if not zero | def jnz(self, f_addr = 0, s_addr = 0):
f_pos = self.get_address(f_addr,1)
s_pos = self.get_address(s_addr,2)
cond = self.get_data(f_pos) != 0
if cond:
self.pos = self.get_data(s_pos)
else:
self.pos += 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_jump(t):\n return np.where(t >= 0, 1, 0)",
"def check_non_zero(self, expr, yes_block, no_block):\n value = self.gen_expr(expr, rvalue=True)\n zero = self.emit_const(0, expr.typ)\n self.emit(ir.CJump(value, \"==\", zero, no_block, yes_block))",
"def unit_jump(n):\n as... | [
"0.683348",
"0.649843",
"0.6333107",
"0.62104744",
"0.620659",
"0.6184327",
"0.60766864",
"0.6067619",
"0.6009112",
"0.60062784",
"0.59788036",
"0.59224045",
"0.5922349",
"0.59168893",
"0.59008044",
"0.59008044",
"0.5856243",
"0.5831968",
"0.583045",
"0.58275187",
"0.58198273... | 0.0 | -1 |
Get input data and set it to some address | def input(self, p_addr = 0):
if len(self.input_data):
in_pos = self.get_address(p_addr, 1)
in_val = self.input_data.pop(0)
self.set_data(in_pos, in_val)
self.pos += 2
else:
if self.disp_pause:
print("PAUSED")
self.pause = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setData(self,address):\n self.data = _pack_address(address)",
"def set_data(self, addr, value):\n\t\tif addr < 0:\n\t\t\tprint(\"FAIL - negative address\")\n\t\tif addr >= len(self.data):\n\t\t\tself.regs[ addr ] = value\n\t\telse:\n\t\t\tself.data[ addr ] = value",
"def fill_host(self, data):\n ... | [
"0.677795",
"0.61024487",
"0.60747546",
"0.60747546",
"0.5995873",
"0.59874356",
"0.5980571",
"0.5855804",
"0.58105445",
"0.5714172",
"0.57112557",
"0.5697777",
"0.56853783",
"0.5671499",
"0.56569827",
"0.56569827",
"0.5614624",
"0.55797696",
"0.55797696",
"0.55589336",
"0.55... | 0.616052 | 1 |
Put the data in the output buffer, if in debug mode display the data | def output(self, p_addr = 0):
out_pos = self.get_address(p_addr, 1)
self.out_param += [self.get_data(out_pos)]
if self.debug:
print("DIAGNOSTIC:", self.out_param[-1])
self.pos += 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug_print(input_data, debug_flag):\n if debug_flag:\n if input_data:\n #print(\"################################################ debug_print #############################################################\")\n for item in input_data:\n print(\" {0:<60}\... | [
"0.66899395",
"0.6541076",
"0.6472404",
"0.64191073",
"0.64059126",
"0.63924104",
"0.6390893",
"0.6388498",
"0.63533485",
"0.63501054",
"0.6346816",
"0.6213297",
"0.61643595",
"0.6155606",
"0.61538637",
"0.6139867",
"0.6121732",
"0.6112834",
"0.6082199",
"0.60407764",
"0.6017... | 0.57430935 | 41 |
Get output buffer (last `last` positions), if `last` equals 1 flush the buffer | def get_output(self, last = 1):
if last == -1:
tmp = self.out_param[::]
self.out_param = []
return tmp
return self.out_param[-last:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flush_output():\n if len(buffered) == 1:\n code.add_line(\"append_result(%s)\" % buffered[0])\n elif len(buffered) > 1:\n code.add_line(\"extend_result([%s])\" % \", \".join(buffered))\n del buffered[:]",
"def getLast(self):\n return self.... | [
"0.6151036",
"0.58266515",
"0.5722285",
"0.5619657",
"0.5505953",
"0.5459501",
"0.5450963",
"0.5439512",
"0.54322183",
"0.54322183",
"0.54322183",
"0.54322183",
"0.5419056",
"0.53555685",
"0.53318954",
"0.5315741",
"0.5314499",
"0.5301618",
"0.53014266",
"0.5296619",
"0.52758... | 0.63626224 | 0 |
Begin a multipart upload | def initiate_multipart_upload(self):
request = self.s3.create_request("OBJECT_POST", uri = self.uri, headers = self.headers_baseline, extra = "?uploads")
response = self.s3.send_request(request)
data = response["data"]
self.upload_id = getTextFromXml(data, "UploadId")
return self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_all_parts(self):\n if not self.upload_id:\n raise RuntimeError(\"Attempting to use a multipart upload that has not been initiated.\")\n\n if self.file.name != \"<stdin>\":\n size_left = file_size = os.stat(self.file.name)[ST_SIZE]\n nr_parts = file_... | [
"0.7138374",
"0.6898224",
"0.674426",
"0.6724694",
"0.67057806",
"0.65629184",
"0.644504",
"0.64089704",
"0.63789344",
"0.637555",
"0.6371153",
"0.63569987",
"0.63420403",
"0.62841195",
"0.6240211",
"0.6233155",
"0.6224858",
"0.61901563",
"0.61885554",
"0.61602145",
"0.615350... | 0.7357991 | 0 |
Execute a full multipart upload on a file Returns the seq/etag dict TODO use num_processes to thread it | def upload_all_parts(self):
if not self.upload_id:
raise RuntimeError("Attempting to use a multipart upload that has not been initiated.")
if self.file.name != "<stdin>":
size_left = file_size = os.stat(self.file.name)[ST_SIZE]
nr_parts = file_size / self.chu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initiate_multipart_upload(self):\n request = self.s3.create_request(\"OBJECT_POST\", uri = self.uri, headers = self.headers_baseline, extra = \"?uploads\")\n response = self.s3.send_request(request)\n data = response[\"data\"]\n self.upload_id = getTextFromXml(data, \"UploadId\")\n ... | [
"0.67758095",
"0.6575503",
"0.6391231",
"0.6376673",
"0.63235295",
"0.6313379",
"0.6240101",
"0.62331957",
"0.61913866",
"0.6171247",
"0.61689883",
"0.6092085",
"0.6071277",
"0.60122454",
"0.6002311",
"0.5958963",
"0.5948954",
"0.5945641",
"0.5943182",
"0.59146935",
"0.590215... | 0.70243835 | 0 |
Upload a file chunk | def upload_part(self, seq, offset, chunk_size, labels, buffer = ''):
# TODO implement Content-MD5
debug("Uploading part %i of %r (%s bytes)" % (seq, self.upload_id, chunk_size))
headers = { "content-length": chunk_size }
query_string = "?partNumber=%i&uploadId=%s" % (seq, self.upload_id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_chunk(self, file_obj, length, offset=0, upload_id=None):\n\n params = dict()\n\n if upload_id:\n params['upload_id'] = upload_id\n params['offset'] = offset\n\n url, ignored_params, headers = self.request(\"/chunked_upload\", params,\n ... | [
"0.75966084",
"0.759227",
"0.75214267",
"0.7378558",
"0.73484313",
"0.7311245",
"0.70927095",
"0.70529234",
"0.70486563",
"0.68820477",
"0.6879894",
"0.68237096",
"0.67937803",
"0.67707115",
"0.6742024",
"0.6738623",
"0.6725202",
"0.67084616",
"0.6673101",
"0.6636667",
"0.663... | 0.76274014 | 0 |
Finish a multipart upload | def complete_multipart_upload(self):
debug("MultiPart: Completing upload: %s" % self.upload_id)
parts_xml = []
part_xml = "<Part><PartNumber>%i</PartNumber><ETag>%s</ETag></Part>"
for seq, etag in self.parts.items():
parts_xml.append(part_xml % (seq, etag))
body = "<... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_finish(self, cloud_file):",
"def complete_multipart_upload(Bucket=None, Key=None, MultipartUpload=None, UploadId=None, RequestPayer=None):\n pass",
"def complete_upload(self):\r\n xml = self.to_xml()\r\n return self.bucket.complete_multipart_upload(self.key_name,\r\n ... | [
"0.754383",
"0.7357068",
"0.724577",
"0.6746937",
"0.6701442",
"0.667674",
"0.6626828",
"0.65539736",
"0.6546125",
"0.6496346",
"0.6464488",
"0.64643455",
"0.64143026",
"0.6378168",
"0.6369848",
"0.63605607",
"0.6272264",
"0.6211301",
"0.61743736",
"0.6162679",
"0.6140481",
... | 0.77730435 | 0 |
Return a string representing `seconds` in hours, minutes, and seconds | def _format_time(seconds):
hrs = seconds // 3600
seconds -= 3600 * hrs
mins = seconds // 60
seconds -= 60 * mins
return '%02dh%02dm%02ds' % (hrs, mins, seconds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_to_str(seconds):\n (hours, remainder) = divmod(seconds, 3600)\n (minutes, seconds) = divmod(remainder, 60)\n return \"h{}m{}s{}\".format(int(hours), int(minutes), float(seconds))",
"def seconds_to_string(seconds):\n # make sure in-between values are not hidden\n can_hide = True... | [
"0.7985087",
"0.7927779",
"0.78666437",
"0.7790731",
"0.7691134",
"0.76810104",
"0.7675468",
"0.76443154",
"0.7635998",
"0.76181585",
"0.76176625",
"0.76154625",
"0.7566962",
"0.7502296",
"0.7456564",
"0.7446724",
"0.74389625",
"0.7429142",
"0.7353068",
"0.7315711",
"0.730817... | 0.75329566 | 13 |
Run the command loop | def run(self, initial_rate=1.0, initial_position=None):
if initial_position is not None:
cmd = self._io.input_('Skip to %d seconds in (y/N)? ' % initial_position)
use_initial_position = cmd == 'y'
else:
use_initial_position = False
# initialize playback
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n self.cmdloop()",
"def _run(self):\n while(self._loop):\n pass",
"def loop(self):\n pass",
"def run(self):\n while self.container.process(): pass",
"def loop():\n\n load_config_project()\n\n L.debug(\"running with version: %s\", sys.version)\n ... | [
"0.88521683",
"0.784812",
"0.75956494",
"0.7566495",
"0.74251306",
"0.73776996",
"0.7359088",
"0.7339298",
"0.72546345",
"0.720726",
"0.7191838",
"0.7121323",
"0.7091604",
"0.7087283",
"0.7082603",
"0.7025119",
"0.69866335",
"0.697694",
"0.6959657",
"0.6956156",
"0.6914895",
... | 0.0 | -1 |
Return a menu displaying the current state of the playback as well as the commands available to the user. | def _status_menu(self):
title = 'Now Playing: %s' % self._player.get_media_name()
stats = (
('Playback rate', '%1.1fx' % self._player.get_playback_rate()),
('Elapsed', _format_time(self._player.get_position())),
('Total Length', _format_time(self._player.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_menu(self):\n menu_string = \"Main menu\\n\"\n menu_string += \"\\t1. Modify a list\\n\"\n menu_string += \"\\t2. Grade submenu\\n\"\n menu_string += \"\\t3. Search for something\\n\"\n menu_string += \"\\t4. Get a statistic\\n\"\n menu_string += \"\\t5. Undo/Redo... | [
"0.6616436",
"0.65773684",
"0.65322655",
"0.65151155",
"0.6474119",
"0.63803834",
"0.6375771",
"0.63460505",
"0.63337165",
"0.6296742",
"0.629645",
"0.62860733",
"0.6281516",
"0.62407094",
"0.62387776",
"0.62313604",
"0.62286526",
"0.6203076",
"0.618405",
"0.61693865",
"0.615... | 0.7697497 | 0 |
load single batch of cifar | def load_CIFAR_batch(filename):
with open(filename, 'rb')as f:
datadict = p.load(f)
X = datadict['data']
Y = datadict['labels']
print X.shape
X = X.reshape(X.shape[0], SHAPE[0], SHAPE[1], SHAPE[2])
Y = np.array(Y)
return X, Y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_batch(n):\r\n print ('Loadng one batch...')\r\n batchfilename = flist[n - 1] + '.pkl'\r\n if not os.path.exists(batchfilename):\r\n set_batch_data()\r\n with open(batchfilename, 'rb') as cifar_pickle:\r\n data = six.moves.cPickle.load(cifar_pickle)\r\n return data",
"def loa... | [
"0.77448887",
"0.73430336",
"0.72560585",
"0.7178619",
"0.71393806",
"0.7076672",
"0.70523053",
"0.7052134",
"0.6975868",
"0.69164515",
"0.6887961",
"0.68793666",
"0.6875748",
"0.68301976",
"0.68297756",
"0.6727222",
"0.6713286",
"0.66872877",
"0.66724056",
"0.6622946",
"0.65... | 0.6669608 | 19 |
Round x down to a multiple of m. | def round_down(x, m):
return int(m * round(float(x) / m)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roundup_int(x, m):\n\treturn int(math.ceil(x / float(m))) * m",
"def _round(self, x):\n return x - x % self.minutes_per_step",
"def _round_to_nearest_multiple_down(x, n=5):\n return n * math.floor(float(x) / n)",
"def round_down(x):\n return int(math.floor(x / 10.0)) * 10",
"def downround(... | [
"0.7884007",
"0.7406131",
"0.6921282",
"0.6884489",
"0.6798002",
"0.6689872",
"0.6604047",
"0.6459293",
"0.64234096",
"0.6301848",
"0.62860346",
"0.62750673",
"0.6249495",
"0.6141186",
"0.61311156",
"0.6113276",
"0.6092585",
"0.60622334",
"0.60341126",
"0.60335",
"0.60030574"... | 0.8763403 | 0 |
Log all values in a dict as scalars to TensorBoard. | def _log_scalars(self, scalar_dict, print_to_stdout=True):
for k, v in scalar_dict.items():
if print_to_stdout:
self.write('[{}: {:.3g}]'.format(k, v))
k = k.replace('_', '/') # Group in TensorBoard by phase
self.summary_writer.add_scalar(k, v, self.global_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_scalars(self, scalars_dict, accum_reduction=None):\n for k, v in scalars_dict.items():\n self.log_scalar(k, v, accum_reduction)",
"def log_scalars(self, scalar_dict,\n iterations, steps_per_epoch=None,\n step_in_epoch=None, cur_epoch=None,\n ... | [
"0.7614835",
"0.73455614",
"0.6878443",
"0.68174237",
"0.6627913",
"0.6470473",
"0.63354903",
"0.62226635",
"0.5921609",
"0.5793472",
"0.57802165",
"0.5715617",
"0.56895524",
"0.56635505",
"0.56635505",
"0.5589343",
"0.5585543",
"0.55748105",
"0.55388325",
"0.5432968",
"0.538... | 0.79419255 | 0 |
Plot all curves in a dict as RGB images to TensorBoard. | def _plot_curves(self, curves_dict):
for name, curve in curves_dict.items():
fig = plt.figure()
ax = plt.gca()
plot_type = name.split('_')[-1]
ax.set_title(plot_type)
if plot_type == 'PRC':
precision, recall, _ = curve
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_curve(epochs, hist, list_of_metrics): \n # list_of_metrics should be one of the names shown in:\n # https://www.tensorflow.org/tutorials/structured_data/imbalanced_data#define_the_model_and_metrics \n\n plt.figure()\n plt.xlabel(\"Epoch\")\n plt.ylabel(\"Value\")\n\n for m in list_of_metrics:\n ... | [
"0.6789922",
"0.66710466",
"0.6281462",
"0.62689495",
"0.61134017",
"0.61091185",
"0.609572",
"0.5982698",
"0.5902102",
"0.58739376",
"0.586099",
"0.5776823",
"0.57448447",
"0.5722574",
"0.57052886",
"0.570347",
"0.56815606",
"0.56657416",
"0.5663962",
"0.5657919",
"0.5642024... | 0.7033957 | 0 |
Visualize predictions and targets in TensorBoard. | def visualize(self, probs_batch, targets_batch, obscured_probs_batch, phase, unique_suffix=None, make_separate_prediction_img=False):
probs_batch = probs_batch.detach().to('cpu')
probs_batch = probs_batch.numpy().copy()
targets_batch = targets_batch.detach().to('cpu')
targets_batch = t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_predictions(self, images, preds, targets):\n\n class_names = ['angry', 'happy', 'sad']\n images = images[:8]\n preds = preds[:8]\n targets = targets[:8]\n\n # determine size of the grid based for the given batch size\n num_rows = int(torch.tensor(len(images))... | [
"0.69095033",
"0.69080466",
"0.67002314",
"0.6608207",
"0.6606041",
"0.65776247",
"0.65171015",
"0.6512835",
"0.6481565",
"0.64805526",
"0.6343465",
"0.6341676",
"0.62306404",
"0.6218248",
"0.61839086",
"0.61696154",
"0.6146126",
"0.6093032",
"0.60885805",
"0.60784423",
"0.60... | 0.0 | -1 |
Write a message to the log. If print_to_stdout is True, also print to stdout. | def write(self, message, print_to_stdout=True):
with open(self.log_path, 'a') as log_file:
log_file.write(message + '\n')
if print_to_stdout:
print(message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(self, message):\n self._logger.write(message)",
"def log(message: str, stdout: bool) -> None:\n if stdout:\n print(message)\n sys.stdout.flush()",
"def log_and_print(self, message):\n self.f.write(message + \"\\n\")\n print message",
"def log(self, msg, alwaysPri... | [
"0.68014693",
"0.67202073",
"0.6549682",
"0.64982516",
"0.64770395",
"0.638645",
"0.63148785",
"0.6288935",
"0.6273223",
"0.6226357",
"0.622524",
"0.62056506",
"0.6170666",
"0.6157295",
"0.6129139",
"0.6129139",
"0.60974735",
"0.60917294",
"0.6054858",
"0.6040961",
"0.6015219... | 0.8373233 | 0 |
Log info for start of an iteration. | def start_iter(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logStarted(build, step, log):",
"def start(self):\n if self.debug:\n print(\"%s start\" % self.name)",
"def begin(self):\n self._logger.debug(\"Begin\")",
"def start_of_batch_hook(self, progress, logging_epoch):\n pass",
"def start_of_test_batch_hook(self, progress, log... | [
"0.67186344",
"0.6699998",
"0.663114",
"0.64892954",
"0.64652264",
"0.6435621",
"0.6426273",
"0.6422593",
"0.63526523",
"0.63134766",
"0.6266499",
"0.6250712",
"0.6235454",
"0.62322986",
"0.6230841",
"0.6158858",
"0.61347973",
"0.60957825",
"0.60110354",
"0.5991415",
"0.59339... | 0.5745851 | 36 |
Log info for end of an iteration. | def end_iter(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _report_iteration(self):\n # Call report_iteration_items for a subclass-friendly function\n self._report_iteration_items()\n self._reporter.write_timestamp(self._iteration)\n self._reporter.write_last_iteration(self._iteration)",
"def end(self):\n self._log.debug('%s: doing... | [
"0.68734866",
"0.67931527",
"0.67524725",
"0.6522723",
"0.64652896",
"0.6384184",
"0.63195825",
"0.6310161",
"0.6263036",
"0.6179817",
"0.6106831",
"0.6103952",
"0.60915196",
"0.60643315",
"0.60600895",
"0.6052429",
"0.60004616",
"0.599891",
"0.599735",
"0.599735",
"0.599735"... | 0.6603974 | 3 |
Log info for start of an epoch. | def start_epoch(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_epoch_begin(self, epoch, logs=None):",
"def on_epoch_begin(self, epoch, logs=None):",
"def on_epoch_start(self, epoch, logs: Optional[Dict] = None):\n pass",
"def epoch_start(self, epoch):\n self.epoch = epoch",
"def on_epoch_begin(\n self, epoch: int, logs: tp.Optional[tp.Dict[... | [
"0.79984033",
"0.79984033",
"0.77748525",
"0.7612501",
"0.738663",
"0.7341092",
"0.72750026",
"0.69703484",
"0.68956685",
"0.68442315",
"0.6820935",
"0.6654576",
"0.6566485",
"0.65350455",
"0.647521",
"0.6398659",
"0.6383946",
"0.63410395",
"0.6334539",
"0.6323002",
"0.630638... | 0.73397434 | 6 |
Log info for end of an epoch. Save model parameters and update learning rate. | def end_epoch(self, metrics, curves):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_epoch_end(self, epoch, logs=None):",
"def on_epoch_end(self, epoch, logs=None):",
"def on_epoch_end(self, epoch, logs=None):\n loss = None\n acc = None\n if self.x is not None and self.y is not None:\n loss, acc = self.model.evaluate(x=self.x, y=self.y, batch_size=self.ba... | [
"0.77136654",
"0.77136654",
"0.7689244",
"0.7631503",
"0.7542826",
"0.75256336",
"0.7496674",
"0.7495087",
"0.7477773",
"0.74387175",
"0.74368805",
"0.7417503",
"0.7364952",
"0.73374003",
"0.73374003",
"0.7314465",
"0.7272832",
"0.72617924",
"0.7259786",
"0.71698105",
"0.7164... | 0.0 | -1 |
Tries to log in a user. | def login(self, username, password):
try:
session_id, junk = self.fasclient.login(username, password)
user = junk.user
if hasattr(flask.g.fas_user, 'approved_memberships'):
user.groups = [x.name for x in user.approved_memberships]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_user(self):\r\n self.client.login(username=self.user.username, password=\"password\")",
"def login_user():\n pass",
"def log_user_in():\n\n print request.form.to_dict()\n user_id = data_manager.get_user_by_email(request.form.to_dict())\n\n if not user_id:\n flash(\"We do not... | [
"0.7806672",
"0.7696327",
"0.7459982",
"0.7419262",
"0.7311351",
"0.73076624",
"0.72552145",
"0.722819",
"0.7126464",
"0.7122563",
"0.71136516",
"0.70697093",
"0.70668054",
"0.70668054",
"0.70085114",
"0.6992964",
"0.69896466",
"0.6988082",
"0.69860405",
"0.6965302",
"0.69633... | 0.0 | -1 |
Flask decorator to ensure that the user is logged in against FAS. To use this decorator you need to have a function named 'auth_login'. Without that function the redirect if the user is not logged in will not work. | def fas_login_required(function):
@wraps(function)
def decorated_function(*args, **kwargs):
if flask.g.fas_user is None:
return flask.redirect(flask.url_for('auth_login',
next=flask.request.url))
return function(*args, **kwargs)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_required(f):\n @wraps(f)\n def decorated_function(*args, **kwargs):\n # checks is user login\n if session.get(\"user_id\") is None:\n return redirect(url_for(\"login\", next=request.url))\n return f(*args, **kwargs)\n return decorated_function",
"def login_requi... | [
"0.837868",
"0.8279903",
"0.82517165",
"0.81909364",
"0.8137846",
"0.8122242",
"0.8110708",
"0.810528",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8087524",
"0.8085632",
"0.80726266",
... | 0.87268835 | 0 |
Flask decorator to retrict access to CLA+1. To use this decorator you need to have a function named 'auth_login'. Without that function the redirect if the user is not logged in will not work. | def cla_plus_one_required(function):
@wraps(function)
def decorated_function(*args, **kwargs):
valid = True
if flask.g.fas_user is None:
valid = False
else:
non_cla_groups = [x.name
for x in flask.g.fas_user.approved_memberships
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_required(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n if g.user is None:\n flash('You have to log in first')\n return redirect(url_for('authentication.login', next=url_for(request.endpoint)))\n return func(*args, **kwargs)\n return wrapper... | [
"0.732592",
"0.72168237",
"0.7196734",
"0.71593267",
"0.71382457",
"0.71322644",
"0.7121525",
"0.7114829",
"0.71041447",
"0.7086904",
"0.7071358",
"0.70599216",
"0.70553786",
"0.7038602",
"0.70329577",
"0.70130295",
"0.69808865",
"0.69355214",
"0.6922633",
"0.691092",
"0.6891... | 0.0 | -1 |
Scale bytes to its proper format | def get_size(bytes, suffix="B"):
factor = 1024
for unit in ["", "K", "M", "G", "T", "P"]:
if bytes < factor:
return f"{bytes:.2f}{unit}{suffix}"
bytes /= factor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_bytes(s):\n if pandas.isnull(s):\n return s\n\n scales = {\n 'k': 1024,\n }\n if not s.endswith('b'):\n raise Exception(f\"{s} doesn't look like a size\")\n\n scale = 1\n s = s[:-1]\n\n if not s[-1].isdigit():\n scale = scales[s[-1]]\n s = s[:-... | [
"0.6739693",
"0.65193975",
"0.6341325",
"0.63402796",
"0.62289983",
"0.621575",
"0.6016291",
"0.6016291",
"0.5977507",
"0.5971246",
"0.5944512",
"0.59222436",
"0.59002984",
"0.59002984",
"0.59002984",
"0.58884454",
"0.588602",
"0.5870659",
"0.5869431",
"0.58612984",
"0.585261... | 0.0 | -1 |
Return total % CPU utilization (avg % usage per core) | def get_cpu_usage():
return psutil.cpu_percent() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cpu_usage(self):\n usages = []\n for w, info in self.worker_info.items():\n usages.append(info['metrics']['cpu'])\n if len(usages)>0:\n return sum(usages) / len(usages)\n else:\n return 0",
"def get_total_n_cpu(self) -> int:",
"def get_cpu_percen... | [
"0.83504343",
"0.81945914",
"0.8116258",
"0.79455423",
"0.7928484",
"0.78884053",
"0.786604",
"0.77494586",
"0.767282",
"0.7616385",
"0.75324875",
"0.74936175",
"0.748903",
"0.74561995",
"0.7450575",
"0.74457794",
"0.7434709",
"0.7367025",
"0.7358259",
"0.73214525",
"0.729923... | 0.84161854 | 0 |
Recherche du prix tarif | def _get_prix_tarif(self,cout,pricelist):
cr = self._cr
product=cout.name
prix_tarif=0
date=time.strftime('%Y-%m-%d') # Date du jour
if pricelist:
#Convertion du lot_mini de US vers UA
min_quantity = self.env['product.uom']._compute_qty(cout.name.uom_id.id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(self, term):",
"def recherche_inter_prix(self,basse_prix, haut_prix) :\n if self.__prix_HT >= basse_prix or self.__prix_HT <= haut_prix :\n return True\n return False",
"def search(self, query):",
"def get_query(self,q,request):\n return Order.objects.filt... | [
"0.5684117",
"0.56505483",
"0.563474",
"0.5424623",
"0.5358215",
"0.53247166",
"0.52267486",
"0.51839435",
"0.5174544",
"0.5166507",
"0.5166507",
"0.5166507",
"0.5166507",
"0.51130676",
"0.51018935",
"0.5072971",
"0.50545275",
"0.50414896",
"0.50323683",
"0.5011461",
"0.49965... | 0.5238767 | 6 |
Given your API_KEY, send a GET request to the API. | def request(host, path, api_key, url_params=None):
url_params = url_params or {}
url = '{0}{1}'.format(host, quote(path.encode('utf8')))
headers = {
'Authorization': 'Bearer %s' % api_key,
}
print(u'Querying {0} ...'.format(url))
response = requests.request('GET', url, headers=headers,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_from_api(url, *, verbose=False):\n vprint = lambda *a, **kwa: print(*a, **kwa) if verbose else None\n\n with open(\"APIKey.txt\", \"r\") as keyFile:\n apiKey=keyFile.readline()\n if apiKey[-1] == '\\n':\n apiKey = apiKey[:-1]\n \n headers = {'X-API-Key': apiKey}... | [
"0.71633285",
"0.7151662",
"0.71055615",
"0.70133626",
"0.6983833",
"0.6902751",
"0.67121387",
"0.66783774",
"0.6671866",
"0.6665534",
"0.6645118",
"0.66395867",
"0.6595869",
"0.6568327",
"0.655233",
"0.6525138",
"0.64264745",
"0.64151573",
"0.6351877",
"0.63407135",
"0.63403... | 0.65734816 | 14 |
Query the Search API by a search term and location. | def search(api_key, term, location, limit, offset):
url_params = {
'term': term.replace(' ', '+'),
'location': location.replace(' ', '+'),
'limit': limit,
'offset': offset
}
return request(API_HOST, SEARCH_PATH, api_key, url_params=url_params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(api_key, term, location):\n\n\n\n url_params = {\n\n 'term': term.replace(' ', '+'),\n\n 'location': location.replace(' ', '+'),\n\n 'limit': SEARCH_LIMIT\n\n }\n\n return request(API_HOST, SEARCH_PATH, api_key, url_params=url_params)",
"def search(api_key, term, location... | [
"0.84324044",
"0.8417473",
"0.83940375",
"0.8188645",
"0.81796783",
"0.80863994",
"0.78661513",
"0.7747398",
"0.77378565",
"0.77186066",
"0.72582996",
"0.725296",
"0.7207238",
"0.7186218",
"0.7073225",
"0.7054379",
"0.70208955",
"0.69806105",
"0.6975707",
"0.693256",
"0.68924... | 0.8253797 | 3 |
Returns a dictionary containg the default settings specified in this class. These settings cover global toolbox settings, such as ``enableCExtensions``, as well as the image preprocessing settings (e.g. resampling). Feature class specific are defined in the respective feature classes and and not included here. Similarl... | def _getDefaultSettings(cls):
return {'minimumROIDimensions': 1,
'minimumROISize': None, # Skip testing the ROI size by default
'normalize': False,
'normalizeScale': 1,
'removeOutliers': None,
'resampledPixelSpacing': None, # No resampling by default
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings(self) -> Dict[str, Any]:\n settings = {}\n if self.pre_thresholder is not None:\n settings['pre_thresh'] = self.pre_thresholder.threshold\n if self.pre_thresholder.val_low_class != 0.:\n settings['pre_val_low'] = self.pre_thresholder.val_low_class\n ... | [
"0.7154207",
"0.70924383",
"0.6903164",
"0.68919384",
"0.68635166",
"0.68474275",
"0.6748116",
"0.67425704",
"0.672394",
"0.66872275",
"0.66056347",
"0.65817654",
"0.6545441",
"0.65379333",
"0.65102243",
"0.64229476",
"0.6391109",
"0.6390645",
"0.6373113",
"0.6338724",
"0.631... | 0.74119973 | 0 |
Enable or disable reporting of additional information on the extraction. This information includes toolbox version, enabled input images and applied settings. Furthermore, additional information on the image and region of interest (ROI) is also provided, including original image spacing, total number of voxels in the R... | def addProvenance(self, provenance_on=True):
self.kwargs['additionalInfo'] = provenance_on | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProvenance(self, imageFilepath, maskFilepath, mask):\n self.logger.info('Adding additional extraction information')\n\n provenanceVector = collections.OrderedDict()\n generalinfoClass = generalinfo.GeneralInfo(imageFilepath, maskFilepath, mask, self.kwargs, self.inputImages)\n for k, v in six.it... | [
"0.61324704",
"0.5580118",
"0.5303036",
"0.5202163",
"0.51500565",
"0.50971496",
"0.50424165",
"0.50296223",
"0.5022306",
"0.5014191",
"0.4949853",
"0.4909818",
"0.48938707",
"0.48500672",
"0.4841513",
"0.47821522",
"0.47727352",
"0.4742481",
"0.47420958",
"0.47383097",
"0.47... | 0.5907224 | 1 |
Parse specified parameters file and use it to update settings in kwargs, enabled feature(Classes) and input | def loadParams(self, paramsFile):
dataDir = os.path.abspath(os.path.join(radiomics.__path__[0], 'schemas'))
schemaFile = os.path.join(dataDir, 'paramSchema.yaml')
schemaFuncs = os.path.join(dataDir, 'schemaFuncs.py')
c = pykwalify.core.Core(source_file=paramsFile, schema_files=[schemaFile], extensions=[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_params(self, params_file=None, params_dict=None):\n core = pykwalify.core.Core(source_file=params_file, source_data=params_dict,\n schema_files=[schema_yaml], extensions=[schema_func])\n params = core.validate()\n self.settings = params.get('settin... | [
"0.70521",
"0.6384262",
"0.631315",
"0.61696446",
"0.6099771",
"0.5991575",
"0.59906685",
"0.5986007",
"0.59695005",
"0.59633684",
"0.59365594",
"0.58831966",
"0.5859198",
"0.5771429",
"0.5761396",
"0.5752638",
"0.57498896",
"0.57198375",
"0.57108396",
"0.56926817",
"0.567959... | 0.70090264 | 1 |
Enable all possible input images without any custom settings. | def enableAllInputImages(self):
self.logger.debug('Enabling all input image types')
for imageType in getInputImageTypes():
self.inputImages[imageType] = {}
self.logger.debug('Enabled input images types: %s', self.inputImages) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disableAllInputImages(self):\n self.logger.debug('Disabling all input image types')\n self.inputImages = {}",
"def enableInputImages(self, **inputImages):\n self.logger.debug('Updating enabled input images types with %s', inputImages)\n self.inputImages.update(inputImages)\n self.logger.debug(... | [
"0.8545291",
"0.7877609",
"0.6650875",
"0.63693947",
"0.60548675",
"0.5960338",
"0.5820554",
"0.5762784",
"0.57597774",
"0.5749555",
"0.5707793",
"0.5700091",
"0.56888616",
"0.5675954",
"0.5668432",
"0.5668432",
"0.5668432",
"0.55423605",
"0.54909945",
"0.5482339",
"0.5470032... | 0.85969824 | 0 |
Disable all input images. | def disableAllInputImages(self):
self.logger.debug('Disabling all input image types')
self.inputImages = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enableAllInputImages(self):\n self.logger.debug('Enabling all input image types')\n for imageType in getInputImageTypes():\n self.inputImages[imageType] = {}\n self.logger.debug('Enabled input images types: %s', self.inputImages)",
"def __disableControls(self):\n self.ignoreAll()",
"de... | [
"0.71531355",
"0.69245046",
"0.66767097",
"0.66115755",
"0.6515991",
"0.6458505",
"0.64366573",
"0.64130753",
"0.6400546",
"0.6382839",
"0.6297096",
"0.6286217",
"0.62648803",
"0.6264742",
"0.6259228",
"0.6251675",
"0.624604",
"0.6194302",
"0.61609715",
"0.6100095",
"0.607541... | 0.90328544 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.