query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Adds an inside vertex | def add_inside(self, node_id: int, weight: float) -> bool:
if self.key is node_id:
return False
if self.inside.get(node_id):
if self.inside.get(node_id) != weight:
self.inside[node_id] = weight
return True
return False
self.insi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex):\n if vertex.id not in self.vertices.keys():\n self.vertices[vertex.id] = vertex",
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"... | [
"0.71836925",
"0.71335185",
"0.7067255",
"0.70615387",
"0.6988647",
"0.6774825",
"0.6688056",
"0.66817236",
"0.6671108",
"0.66281044",
"0.659934",
"0.65882474",
"0.6582463",
"0.6570729",
"0.6552053",
"0.65422636",
"0.6531072",
"0.6505948",
"0.64750487",
"0.64719784",
"0.64551... | 0.0 | -1 |
Adds an outside vertex | def add_outside(self, node_id: int, weight: float) -> bool:
if self.key is node_id:
return False
if self.outside.get(node_id):
if self.outside.get(node_id) != weight:
self.outside[node_id] = weight
return True
return False
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, v):\n v = {'x': v[0], 'y': v[1]}\n if v not in self:\n self.append(v)\n return len(self)-1\n return self.index(v)",
"def add_vertex(self, room):\r\n if room['room_id'] not in self.rooms:\r\n self.rooms[room['room_id']] = room\r\n ... | [
"0.6421191",
"0.63592166",
"0.63458955",
"0.628437",
"0.6213638",
"0.6186063",
"0.615865",
"0.61473626",
"0.6141896",
"0.6139843",
"0.613575",
"0.61279947",
"0.6105902",
"0.6093051",
"0.6091404",
"0.60801154",
"0.6063551",
"0.6054368",
"0.60366595",
"0.60334563",
"0.60274625"... | 0.0 | -1 |
Returns a dictionary of the vertices connected to a specific vertex from outside direction | def get_outside(self) -> dict:
return self.outside | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices(self):\r\n return self.adjacent.keys()",
"def find_isolated_vertices(self):\n graph = self.__graph_dict\n isolated = []\n for vertex in graph:\n # print(isolated,vertex)\n if not graph[vertex]:\n isolated += [vertex]\n return is... | [
"0.7012711",
"0.69432765",
"0.6697136",
"0.6631581",
"0.66094506",
"0.65801495",
"0.63487077",
"0.61955774",
"0.61808264",
"0.617997",
"0.6148347",
"0.61476284",
"0.6138338",
"0.61366916",
"0.61316067",
"0.6113954",
"0.6085245",
"0.6077181",
"0.60770446",
"0.60770446",
"0.607... | 0.0 | -1 |
Returns the vertices as dictionary dict | def as_dict(self) -> dict:
tmp_dict = self.__dict__
return tmp_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vertices(self):\n return str(self.vert_dict.keys())",
"def obtener_vertices(self):\n return list(self.vertices.keys())",
"def vertices(self):\n return self.keys()",
"def get_vertices(self):\n return list(self.vertices.keys())",
"def vertices(self):\n return list(s... | [
"0.7718016",
"0.7711875",
"0.7609068",
"0.75979906",
"0.73958236",
"0.7350509",
"0.73418397",
"0.7332526",
"0.7290376",
"0.7290376",
"0.7290376",
"0.7200055",
"0.71530837",
"0.71381366",
"0.71183676",
"0.71183676",
"0.7052699",
"0.702025",
"0.69967544",
"0.6985055",
"0.692813... | 0.0 | -1 |
Checks if the flow is in either a Pending state or Running state. Either are valid starting points (because we allow simultaneous runs of the same flow run). | def check_flow_is_pending_or_running(self, state: State) -> State:
# the flow run is already finished
if state.is_finished() is True:
self.logger.info("Flow run has already finished.")
raise ENDRUN(state)
# the flow run must be either pending or running (possibly redund... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_flow_reached_start_time(self, state: State) -> State:\n if isinstance(state, Scheduled):\n if state.start_time and state.start_time > pendulum.now(\"utc\"):\n self.logger.debug(\n \"Flow '{name}': start_time has not been reached; ending run.\".format(\n... | [
"0.6322989",
"0.62589765",
"0.6248364",
"0.6052122",
"0.60332125",
"0.60229397",
"0.59706455",
"0.59273404",
"0.59149945",
"0.5901337",
"0.58716357",
"0.5861699",
"0.58297974",
"0.5826445",
"0.582463",
"0.57808644",
"0.57808644",
"0.57808644",
"0.57808644",
"0.57808644",
"0.5... | 0.7600161 | 0 |
This is a 3param gaussian | def gaus(x,A,B,C):
return A * np.exp( -(x-B)**2 / (2*C**2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauss3(x,a1,c1,w1,a2,c2,w2,a3,c3,w3):\n return gaussian(x,a1,c1,w1)+gaussian(x,a2,c2,w2)+gaussian(x,a3,c3,w3)",
"def gaussian3d(center_z, center_x, center_y, height, width_z, width_x, width_y):\n width_x = float(width_x)\n width_y = float(width_y)\n width_z = float(width_z)\n return lambda z,x... | [
"0.7764392",
"0.7368256",
"0.7126248",
"0.68187535",
"0.68117154",
"0.67819506",
"0.6776907",
"0.6769205",
"0.6755668",
"0.67036194",
"0.6658462",
"0.6610645",
"0.657615",
"0.6556784",
"0.655331",
"0.6544997",
"0.6544997",
"0.6544997",
"0.653657",
"0.6527379",
"0.65186995",
... | 0.5803271 | 91 |
Convert a scipy sparse matrix to a torch sparse tensor. | def sparse_mx_to_torch_sparse_tensor(sparse_mx):
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
shape = torch.Size(sparse_mx.shape)
return torch.sparse.FloatTen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csr2tensor(self, matrix: sp.csr_matrix):\n matrix = matrix.tocoo()\n x = torch.sparse.FloatTensor(\n torch.LongTensor(np.array([matrix.row, matrix.col])),\n torch.FloatTensor(matrix.data.astype(np.float32)),\n matrix.shape,\n ).to(self.device)\n retu... | [
"0.8299787",
"0.8148542",
"0.8045949",
"0.80325705",
"0.80134654",
"0.79973555",
"0.79973555",
"0.7985302",
"0.7985302",
"0.7985302",
"0.7977018",
"0.79650825",
"0.7754673",
"0.7713117",
"0.7429514",
"0.7429514",
"0.735423",
"0.71969247",
"0.7156927",
"0.69882196",
"0.6969645... | 0.80300856 | 9 |
Return the device specific state attributes. | def extra_state_attributes(self):
attrs = {
ATTR_NODE_ID: self.node_id,
ATTR_NODE_NAME: self._name,
ATTR_MANUFACTURER_NAME: self._manufacturer_name,
ATTR_PRODUCT_NAME: self._product_name,
}
attrs.update(self._attributes)
if self.battery_lev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.88270175",
"0.8766329",
"0.8766329",
"0.87205243",
"0.87205243",
"0.8702202",
"0.8687991",
"0.8683084",
"0.86829257",
"0.86669654",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"0.85930043",
"... | 0.739842 | 91 |
Validate if `url` is in proper `/permlink` format. | def _validate_url(url):
if not url or url.count('/') != 1 or url[0] != '@':
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateURL(url):\n pattern = re.compile(\"^https*:\\/\\/\\w+(\\.\\w+){2}[\\/A-Za-z\\d\\?\\=]*$\")\n match = pattern.match(url)\n\n return True if match else False",
"def validate_url(url):\n\n RE_D = re.compile(r'^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]... | [
"0.7518321",
"0.74316734",
"0.7352114",
"0.7325069",
"0.7318047",
"0.7232617",
"0.7221705",
"0.7174442",
"0.71481484",
"0.7135341",
"0.7122323",
"0.7051631",
"0.7019709",
"0.6983181",
"0.6973562",
"0.6972786",
"0.6950415",
"0.69438344",
"0.69401485",
"0.6937085",
"0.690732",
... | 0.7651278 | 0 |
Get shard iterator for a given shard. | def get_iterator(self, shard: dict) -> str:
shard_id = shard['ShardId']
shard_iterator, date = self._iterators.get(shard_id, (None, None))
if shard_iterator and date:
# validate iterator datetime and
date = parser.parse(date)
now = datetime.now().astimezone(py... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_kinesis_shard_iterator(client, stream_name):\n # get Kinesis stream params - shard id and shard iterator\n response = client.describe_stream(StreamName=stream_name)\n my_shard_id = response['StreamDescription']['Shards'][0]['ShardId']\n shard_iterator = client.get_shard_iterator... | [
"0.7192797",
"0.62523794",
"0.6116193",
"0.5885215",
"0.577385",
"0.5532134",
"0.5280438",
"0.5217994",
"0.5217994",
"0.5179227",
"0.5157431",
"0.5128413",
"0.5034047",
"0.50297487",
"0.49781013",
"0.49362624",
"0.49286574",
"0.48785993",
"0.48781207",
"0.48583364",
"0.483682... | 0.7620191 | 0 |
Takes a date object and returns a zone aware datetime | def get_zone_aware_datetime(date):
return datetime.combine(date, datetime.max.time(), pytz.UTC) if date else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date(zone, offset=0):\n return datetime.date(datetime.fromtimestamp(\n time.time() + 86400 * offset, tz=zone))",
"def date_make_timezone_aware(datetime_object, timezone_string=None):\n if timezone_string:\n # make the date timezone aware using the given timezone_string\n timezo... | [
"0.7193999",
"0.7054922",
"0.68901473",
"0.67446345",
"0.65962493",
"0.6535375",
"0.638806",
"0.6359219",
"0.6280445",
"0.6258549",
"0.62524897",
"0.62382853",
"0.6218987",
"0.6215384",
"0.6214274",
"0.61468345",
"0.6121447",
"0.6096888",
"0.6089573",
"0.6083176",
"0.6082781"... | 0.7805616 | 0 |
Associate external course pages to Django course models | def migrate_external_courses(apps, schema_editor):
Course = apps.get_model("courses", "Course")
CourseRun = apps.get_model("courses", "CourseRun")
ExternalCoursePage = apps.get_model("cms", "ExternalCoursePage")
external_courses = ExternalCoursePage.objects.all()
for external_course in external_cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_pages(self):\n return None",
"def course_pages(self):\n return None",
"def course_about(request, course_id):\r\n\r\n if microsite.get_value(\r\n 'ENABLE_MKTG_SITE',\r\n settings.FEATURES.get('ENABLE_MKTG_SITE', False)\r\n ):\r\n raise Http404\r\n course_ke... | [
"0.6477166",
"0.6477166",
"0.6336113",
"0.62562925",
"0.62015265",
"0.6166837",
"0.6085344",
"0.60606176",
"0.60219526",
"0.6019237",
"0.5945737",
"0.5912677",
"0.5882595",
"0.5833876",
"0.5775226",
"0.57573265",
"0.5741362",
"0.5719905",
"0.5715485",
"0.5690176",
"0.56696534... | 0.6691036 | 0 |
Consensus of a list of dictionaries. | def consense_dicts(dicts):
all_keys = sorted(set(chain(*(dc for dc in dicts))))
return {key: consense_values([dc[key] for dc in dicts if key in dc])
for key in all_keys} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_consensus_taxonomy(dict_taxs):\n dict_consensus = {}\n for read_id in dict_taxs:\n hits = dict_taxs[read_id]['hits']\n taxonomy = dict_taxs[read_id]['taxonomy']\n first_taxonomy = taxonomy[0] # take first taxonomy list of the list, will be used to fill tax fields\n length... | [
"0.60353035",
"0.5730304",
"0.57016355",
"0.5694886",
"0.56013584",
"0.5562397",
"0.54984576",
"0.5468515",
"0.54335755",
"0.5322114",
"0.53037775",
"0.51644427",
"0.51602983",
"0.510432",
"0.50905037",
"0.50755966",
"0.5069798",
"0.50596905",
"0.50582767",
"0.49916092",
"0.4... | 0.57249355 | 2 |
Get Boms for a matching bom name. | def get_bom_by_name(request):
if not request.user.is_authenticated:
return JsonResponse({"success": False}, status=401)
if request.method == "GET" and request.is_ajax():
bom_name = request.GET.get("searchTerm")
try:
boms = BillOfMaterial.objects.filter(
bom_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_for_name(self, name):\n for p in self.books_all:\n if p['name'] == name:\n return p",
"def search_brands_by_name(mystr):\n \n return Brand.query.filter(Brand.name.like('%' + mystr + '%')).all()",
"def search_brands_by_name(mystr):\n brands = Brand.query.filt... | [
"0.6045196",
"0.5948885",
"0.5944216",
"0.58564234",
"0.5758092",
"0.57219",
"0.5596165",
"0.5521047",
"0.542841",
"0.53813523",
"0.5380748",
"0.5351",
"0.5328619",
"0.5299221",
"0.52870035",
"0.52837086",
"0.52292097",
"0.52208513",
"0.5187401",
"0.51843613",
"0.5167846",
... | 0.62645096 | 0 |
Constructor for the BucketingSampler. | def __init__(self, dataset, batch_size, seeds, bucketing=True,
world_size=None, rank=None, sort=False):
if world_size is None:
world_size = get_world_size()
if rank is None:
rank = get_rank()
self.dataset = dataset
self.world_size = world_size
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, data_source: any, batch_size: int=1):\n super(BucketingSampler, self).__init__(data_source)\n self.data_source = data_source\n ids = list(range(0, len(data_source)))\n # TODO: Optimise\n self.bins = [ids[i:i + batch_size] for i in range(0, len(ids), batch_size)... | [
"0.75637",
"0.71414083",
"0.67601734",
"0.6705536",
"0.66726756",
"0.6621034",
"0.65706056",
"0.65571207",
"0.64985555",
"0.6489903",
"0.6488347",
"0.6376893",
"0.6347636",
"0.6326816",
"0.6302755",
"0.62951547",
"0.6226418",
"0.6222358",
"0.61367416",
"0.610817",
"0.61043847... | 0.57243294 | 75 |
kstmz allows you to patch yaml files | def main(input_params):
store = kgenlib.BaseStore()
input_files = input_params["files"]
output_file = input_params.get("output_file")
for file in input_files:
store.add(kgenlib.BaseStore.from_yaml_file(file))
mutations = input_params.get("mutations", {})
store.process_mutations(mutat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_file(filename,d):\n if os.path.exists(filename):\n f_old = open(filename,'r')\n d_old = yaml.load(f_old)\n f_old.close()\n d_old.update(d)\n d = d_old\n f = open(filename, 'w')\n yaml.dump(d, f)\n f.close()",
"def test_yaml_extension():\n ligand_path =... | [
"0.62510467",
"0.59419835",
"0.5916267",
"0.58507866",
"0.5776558",
"0.57671976",
"0.5693943",
"0.5681508",
"0.5680345",
"0.5658667",
"0.56353635",
"0.55904007",
"0.55638605",
"0.55621797",
"0.55418324",
"0.5508838",
"0.5454045",
"0.5392916",
"0.53826904",
"0.5376619",
"0.535... | 0.0 | -1 |
Create tracker object that represents the users head position, specifically the center of the eyes. The position provided by the head tracker must be in the same reference frame as the cave wall coordinates. This will normally be a tracking sensor, but for this example we will simulate a head tracker using the keyboard... | def attachViewToGlasses(self,visNode):
self.head_tracker = viz.link(visNode,viz.NullLinkable,srcFlag=viz.ABS_PARENT)
"""
Create CaveView object for manipulating the virtual viewpoint.
cave_origin is a node that controls the position of the cave within the virtual world.
For example, if you wanted to simula... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_head_looking_up():\n return _move_head(cozmo.robot.MAX_HEAD_ANGLE)",
"def head_control(contr):\n # get the object this script is attached to\n human = contr.owner\n \n # if the human is external, do nothing\n if human.get('External_Robot_Tag') or human['disable_keyboard_control']:\n ... | [
"0.57941705",
"0.56604224",
"0.55843425",
"0.55400264",
"0.5403688",
"0.53899133",
"0.5298788",
"0.51507187",
"0.51499766",
"0.5142753",
"0.5091761",
"0.5026207",
"0.5014688",
"0.5010304",
"0.50078386",
"0.4992488",
"0.49772325",
"0.49481988",
"0.4912237",
"0.49034262",
"0.48... | 0.0 | -1 |
Strips newline characters from the end of lines in a file. Returns a list of strings containing each line in the file stripped of newlines as elements. | def strip_newlines(file):
newline_regex = re.compile(os.linesep + "$")
strings = []
for line in file:
string = newline_regex.sub("", line)
strings.append(string)
return strings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fileLinesToList(filename) :\n o = []\n with open(filename, \"r\") as fi :\n for l in fi :\n if l.strip() != \"\" :\n o.append(l.strip())\n return o",
"def process_file(file_name):\n f_in = open(file_name)\n return list(map(lambda s: s.strip(), f_in.readlines()... | [
"0.76120645",
"0.71979326",
"0.70958954",
"0.70676273",
"0.70444244",
"0.6974028",
"0.6968933",
"0.6806044",
"0.6769268",
"0.6762899",
"0.665428",
"0.66402096",
"0.66235924",
"0.6608165",
"0.6604989",
"0.65912527",
"0.65751976",
"0.65520537",
"0.65461266",
"0.65330404",
"0.65... | 0.8252451 | 0 |
Expires to timestamp Converts expiration to a unix timestamp. The expiration date may be in | def expires_to_timestamp(expires):
# from timestamp (no conversion)
if isinstance(expires, int):
return expires
if isinstance(expires, str) and expires.isdigit():
return int(expires)
# from datetime or arrow
if isinstance(expires, datetime) or isinstance(expires, arrow.Arrow):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_expiration(self, expiration_seconds):\n timestamp = time.time()\n if self.nbf:\n timestamp = self.nbf\n return timestamp + expiration_seconds",
"def ttl_from_expiration(expires):\n now = int(calendar.timegm(datetime.utcnow().utctimetuple()))\n expires = expires_to_t... | [
"0.7118507",
"0.68239003",
"0.6407982",
"0.6393658",
"0.6314486",
"0.6160947",
"0.6089729",
"0.6056558",
"0.60342675",
"0.5960767",
"0.5960767",
"0.59320486",
"0.583859",
"0.5834686",
"0.58339375",
"0.57999915",
"0.5785512",
"0.57680786",
"0.57013965",
"0.5701129",
"0.5677718... | 0.76515394 | 0 |
Return the user's cumulative score from winning games in this server. If another 'member' is provided, their score would be provided instead. | async def scoreboard(self, ctx, member: discord.Member=None):
member = member or ctx.author
await ctx.send(f"{member} has a score of {self.data[ctx.guild.id]['score'][member.id]}.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_score(game, player):\n if game.is_loser(player):\n return -math.inf\n\n if game.is_winner(player):\n return math.inf\n\n opp_moves = game.get_legal_moves(game.get_opponent(player))\n own_moves = game.get_legal_moves(player)\n\n return len(own_moves) / max(len(opp_moves), 1e-... | [
"0.6549577",
"0.63670886",
"0.6314973",
"0.6297403",
"0.62935114",
"0.62074935",
"0.6055076",
"0.60199654",
"0.59752357",
"0.596425",
"0.59560317",
"0.5944383",
"0.59333956",
"0.59275687",
"0.585545",
"0.58492273",
"0.583742",
"0.58227104",
"0.58196825",
"0.5755095",
"0.57496... | 0.5772363 | 19 |
Utility function to create an absolute path to data in the tests directory. | def create_file_path(fname, direc="data/result/"):
path = os.path.join(TOP_LEVEL, direc, fname)
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_data_path():\n return os.path.abspath(os.path.join(os.path.dirname(__file__), \"data\") + os.path.sep)",
"def test_data_dir(self):\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
"def data_dir():\n return os.path.join(os.path.dirname(_here), 'test', 'data')... | [
"0.8383622",
"0.79448307",
"0.7746029",
"0.7702224",
"0.76625496",
"0.7441402",
"0.73831517",
"0.72584957",
"0.7249172",
"0.7204988",
"0.7183254",
"0.7168532",
"0.7112031",
"0.7070676",
"0.7066764",
"0.70530677",
"0.7052982",
"0.70235974",
"0.69926006",
"0.69705695",
"0.69205... | 0.0 | -1 |
Scatter plot of 2D latent space with labelbased color schemme. | def label_2d_latent(model,data_loader,embeddings=False):
model.eval()
plt.style.use('seaborn')
fig, ax = plt.subplots(dpi=100)
for batch_idx, (data,target) in enumerate(data_loader):
data = data.float()
z, recon_batch, mu, logvar = model(data.view(-1,numpy.prod(data.shape[-2:])))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scatterPlot2():\n N = 100\n x = np.random.rand(N)\n y = np.random.rand(N)\n colors = np.random.rand(N)\n\n plt.scatter(x, y, c=colors, alpha=0.5)\n plt.show()",
"def ScatterPlot(data, labels, gamma):\n\n fig, ax = plt.subplots(figsize=(16, 8))\n for i, label in enumerate(labels):\n ... | [
"0.6926447",
"0.6850378",
"0.6826258",
"0.66562134",
"0.6613039",
"0.6384699",
"0.63777167",
"0.63579726",
"0.6356086",
"0.6338047",
"0.6319183",
"0.6299937",
"0.62458634",
"0.62442166",
"0.62303174",
"0.6214994",
"0.62015116",
"0.61705285",
"0.6154986",
"0.6147447",
"0.61216... | 0.5681855 | 88 |
Key is past max access age threshold, key is marked as expired | def test_old_access(self):
created = datetime.datetime(2019, 1, 1, tzinfo=datetime.timezone.utc)
last_used = datetime.datetime(2019, 1, 2, tzinfo=datetime.timezone.utc)
key = Key('username', 'keyid', 'Active', created, last_used)
key.audit(60, 80, 10, 9)
assert key.audit_state ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_old_expiration(self):\n created = datetime.datetime(2019, 1, 1, tzinfo=datetime.timezone.utc)\n last_used = datetime.datetime(2019, 1, 2, tzinfo=datetime.timezone.utc)\n key = Key('username', 'keyid', 'Active', created, last_used)\n key.audit(10, 11, 10, 8)\n assert key.... | [
"0.76386654",
"0.70951307",
"0.6688859",
"0.6546757",
"0.6526796",
"0.65088487",
"0.6508622",
"0.65017235",
"0.64936125",
"0.64833486",
"0.64225686",
"0.64198256",
"0.6409737",
"0.6390927",
"0.6375919",
"0.6373345",
"0.6368775",
"0.63388246",
"0.6336545",
"0.63274604",
"0.630... | 0.70629853 | 2 |
load image, returns tensor | def image_loader(image_name, dev):
image = Image.open(image_name)
image = loader(image).float()
image = Variable(image, requires_grad=True)
image = image.unsqueeze(0) #this is for VGG, may not be needed for ResNet
return image.to(dev) #assumes that you're using GPU | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_image(self, id_: str) -> Tensor:\n filename = os.path.join(self.root, \"output\", id_ + \".jpg\")\n with Image.open(filename) as img:\n array = np.array(img)\n tensor: Tensor = torch.from_numpy(array) # type: ignore[attr-defined]\n # Convert from HxWxC to C... | [
"0.8322746",
"0.79828805",
"0.771963",
"0.76471734",
"0.7613312",
"0.7497175",
"0.7443528",
"0.73994523",
"0.73994523",
"0.7335932",
"0.73087394",
"0.7267389",
"0.7207316",
"0.7166437",
"0.7033066",
"0.7005002",
"0.7003158",
"0.6993807",
"0.6976924",
"0.69716966",
"0.6958558"... | 0.66169643 | 35 |
Close a session. Any changes not yet saved are rolled back. Any lock on the file/DB is released. | def __exit__(self, exc_type, exc_val, exc_tb):
session = self.session
# cancel pending changes
session.rollback()
# if self._acquire_lock:
# # remove the lock
# session.delete_lock()
session.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_session(self, session):\r\n session.close()",
"def _close(self):\n if self.__session is not None:\n self._rollback()\n self.__session.close()",
"def close_session(self):\n self.sess.close()",
"def close(self):\n self.__session.close()",
"def cl... | [
"0.8331682",
"0.8128601",
"0.777445",
"0.74958736",
"0.74958736",
"0.74958736",
"0.74958736",
"0.74958736",
"0.74958736",
"0.74443996",
"0.74360126",
"0.7427004",
"0.7320106",
"0.7227131",
"0.71729976",
"0.7133008",
"0.7083968",
"0.7083968",
"0.7083968",
"0.70200545",
"0.6971... | 0.6220419 | 78 |
Do not return anything, modify rooms inplace instead. | def wallsAndGates(self, rooms: List[List[int]]) -> None:
rows = len(rooms)
if rows == 0:
return
cols = len(rooms[0])
GATE = 0
EMPTY = pow(2, 31) - 1
DIRECTIONS = [(0, 1), (0, -1), (1, 0), (-1, 0)]
q = deque([])
for i in range(rows):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rooms(self, rooms):\n\n self._rooms = rooms",
"def _add_rooms(self):\r\n rooms = self.model.get_all_rooms()\r\n\r\n for room in rooms:\r\n self._add_room(room)",
"def rooms(*args):\n send.system_message('\\n'.join(rooms()))",
"def all_rooms(self):\n pass",
... | [
"0.67922723",
"0.6150443",
"0.5985418",
"0.59520423",
"0.5938853",
"0.5910455",
"0.5802791",
"0.5788961",
"0.57677865",
"0.56960684",
"0.56584203",
"0.56518275",
"0.5649922",
"0.56375164",
"0.5580176",
"0.5570199",
"0.5540112",
"0.5534412",
"0.5534412",
"0.5529608",
"0.549605... | 0.5460034 | 23 |
Returns True if obj is a nonstring iterable object. | def nonstringiter(obj):
return not isinstance(obj, string_types) and isinstance(obj, Iterable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_non_string_iterable(obj: object) -> bool:\n return not (isinstance(obj, str) or isinstance(obj, bytes))\\\n and isinstance(obj, Iterable)",
"def isiterable(obj, strings=False, isinstance=isinstance, Iterable=Iterable):\n return (isinstance(obj, Iterable) and\n not (isinstance(obj, ... | [
"0.8769276",
"0.84019774",
"0.83208054",
"0.8303332",
"0.8276503",
"0.8242771",
"0.81886476",
"0.8142765",
"0.80669045",
"0.80608785",
"0.80084723",
"0.7929773",
"0.7885438",
"0.78732795",
"0.7776357",
"0.7725954",
"0.7707758",
"0.76324904",
"0.7588271",
"0.75394404",
"0.7526... | 0.8663122 | 1 |
Returns a generator that yields rows as lists of Unicode values. The Python 2 `csv` module does not support Unicode directly. For best results, the official docs recommend encoding text as UTF8 before passing it to csv.reader(). | def _unicode_rows(stream, encoding, dialect, **kwds):
# Get Unicode stream.
if isinstance(stream, io.IOBase):
streamreader_type = codecs.getreader(encoding)
unicode_stream = streamreader_type(stream)
elif isinstance(stream, Iterable):
first_row, stream = iterp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unicode_csv_reader(data, **kwargs):\r\n\tdata_file = csv.reader(data, **kwargs)\r\n\tfor row in data_file:\r\n\t\tyield [str(cell) for cell in row]",
"def unicode_csv_reader(utf8_data, dialect=csv.excel, **kwargs):\n csv_reader = csv.reader(utf8_data, dialect=dialect, **kwargs)\n for row in csv_reader:... | [
"0.8484453",
"0.84060776",
"0.71879286",
"0.6814008",
"0.6681783",
"0.65349054",
"0.6454056",
"0.64046",
"0.63790095",
"0.6275561",
"0.620938",
"0.62066805",
"0.62039715",
"0.61292076",
"0.6103779",
"0.60903275",
"0.60261106",
"0.5959049",
"0.5956673",
"0.5956673",
"0.5937357... | 0.76517415 | 2 |
Takes a pandas DataFrame, Series, Index, or MultiIndex and returns a generator. | def _from_pandas(obj, index=True):
if hasattr(obj, 'to_frame') and hasattr(obj, 'index'):
# Convert series to DataFrame.
df = obj.to_frame()
elif hasattr(obj, 'to_frame') and not hasattr(obj, 'index'):
# Convert MultiIndex (pandas >=0.20.0) or Index (pandas >=0.21.0)
# to DataFra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def single_column_iterator(df, colidx):\n for _, values in df.iterrows():\n yield values.iloc[colidx]",
"def doc_generator(df, indexName, use_these_keys):\n df_iter = df.iterrows()\n for index, document in df_iter:\n yield {\n \"_index\": indexName,\n \"_doc\": \"_doc... | [
"0.63963443",
"0.6208751",
"0.60073286",
"0.5969254",
"0.5878352",
"0.58665895",
"0.5814632",
"0.57476914",
"0.5702693",
"0.56785303",
"0.5654869",
"0.5650501",
"0.56110317",
"0.5608028",
"0.5572566",
"0.55543923",
"0.5529357",
"0.5509298",
"0.5501081",
"0.5483026",
"0.547576... | 0.55681276 | 15 |
Returns the full parquet path as an output for the Luigi Task (e.g. impc/dr15.2/parquet/specimen_level_experiment_cross_ref_parquet) | def output(self):
return ImpcConfig().get_target(
f"{self.output_path}specimen_level_experiment_cross_ref_parquet"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_path(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"full_path\")",
"def path(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"path\")",
"def path(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"path\")",
"def path(self) -> pulumi.Output[Optio... | [
"0.6533308",
"0.64390385",
"0.63871586",
"0.63871586",
"0.62944216",
"0.62339675",
"0.61864024",
"0.6177731",
"0.61519563",
"0.5980581",
"0.5957651",
"0.589875",
"0.58222425",
"0.58048904",
"0.5793464",
"0.576836",
"0.57592386",
"0.5758471",
"0.5758471",
"0.5758471",
"0.57570... | 0.6369067 | 4 |
Tests vgg by preloading the set of weights and visualizing the features. They should be sensible looking | def test_vggmini_visualize(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model(self):\n\n vgg16 = VGG16()\n data_dir = os.path.dirname(os.path.abspath(__file__))\n data = os.path.join(data_dir, 'data/elephant.jpg')\n\n features = vgg16.produce(data)\n self.assertEqual(len(features[-1]), 4096)",
"def test_rep_vgg_3d(self):\n feat_keys... | [
"0.647064",
"0.604565",
"0.597815",
"0.594945",
"0.5891055",
"0.5863789",
"0.58489895",
"0.5821453",
"0.5806127",
"0.57984746",
"0.57887316",
"0.57601553",
"0.57482725",
"0.5731225",
"0.5642885",
"0.5587915",
"0.5578199",
"0.55711675",
"0.55429167",
"0.55340135",
"0.5532104",... | 0.7265509 | 0 |
Compute softmax values for each sets of scores in x. | def softmax(x):
return np.exp(x) / np.sum(np.exp(x), axis=0)
# return ( x / np.sum(x, axis=0) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7800231",
"0.776332",
"0.7762483",
"0.77600384",
"0.76607925",
"0.76607925",
"0.76607925",
"0.76607925",
"0.7585753",
"0.7432371",
"0.7409777",
"0.73932534",
"0.7360278",
"0.731833",
"0.72708684",
"0.7263948",
"0.7262435",
"0.7257905",
"0.7231808",
"0.72159433",
"0.7203519... | 0.697636 | 90 |
Round a numberValue, to multiples of baseValue | def roundTo(numberValue, baseValue):
# Round a numberValue, to multiples of baseValue
return( numberValue + (baseValue - numberValue) % baseValue ) # roundTo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_round(x, base):\n\n return base * round(x/base)",
"def roundMultiple(x, base=4):\n return int(base * round(float(x)/base))",
"def my_round(x, base=10):\n return base * round(x / base)",
"def round_mult(x, base=10):\n a = ((abs(x) - 1) // base) * base # nearest multiple\n b = ... | [
"0.7828959",
"0.7811229",
"0.7690296",
"0.7665569",
"0.7308242",
"0.7265471",
"0.70024484",
"0.6784922",
"0.6631272",
"0.6602243",
"0.6582831",
"0.65628433",
"0.65511423",
"0.6456156",
"0.6426835",
"0.6369615",
"0.63627154",
"0.63428456",
"0.63417673",
"0.6337017",
"0.6303017... | 0.85407674 | 0 |
Removes stopwords from the text | def remove_stopwords(text):
tokens = word_tokenize(text)
filtered = [word for word in tokens if word not in stop_words]
filtered = ' '.join(filtered)
return filtered | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords(self,text):\n return \" \".join([word for word in str(text).split() if word not in self.STOPWORDS])",
"def remove_stopwords(text):\n text = \" \"+text\n text = text.upper()\n for word in STOP_WORDS:\n text = text.replace(word.upper(),\" \")\n return text",
"def re... | [
"0.8865683",
"0.8768834",
"0.8728632",
"0.871943",
"0.86845076",
"0.85868096",
"0.84865296",
"0.84806865",
"0.8478678",
"0.84414834",
"0.83935106",
"0.8091809",
"0.80871063",
"0.80845195",
"0.80812234",
"0.80735224",
"0.8054236",
"0.80439436",
"0.8012102",
"0.7998525",
"0.797... | 0.8709054 | 4 |
Constructor to set the population_util, render_mode and path, and initialize figure | def __init__(self, population_util: PopulationUtil, render_mode: bool = False, render_path: str ="render"):
self.putil = population_util
# Disable toolbar
mpl.rcParams['toolbar'] = 'None'
# Initialize figure
self.fig = plt.figure(figsize=(6.5,7.5))
self.fig.canvas.set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_plot(self) -> None:\n\n # create a grayscale plot\n out = sys.stdout\n sys.stdout = open(\"/dev/null\", \"w\")\n hdu = self.image_generator.image(self.ra, self.dec)\n self.plot = aplpy.FITSFigure(hdu)\n self.plot.show_grayscale()\n self.plot.set_theme(\"pu... | [
"0.6981952",
"0.6739068",
"0.6726679",
"0.64870244",
"0.64748615",
"0.64502597",
"0.64103454",
"0.6363721",
"0.6346759",
"0.63291746",
"0.63291746",
"0.62878656",
"0.62779963",
"0.6247279",
"0.61594915",
"0.6153537",
"0.6144503",
"0.6142327",
"0.61329937",
"0.6106053",
"0.609... | 0.7158734 | 0 |
the aboutus page for the contributors information | def about(request):
return render(request, 'code_challenge/about.html', {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about_us():\r\n return render_template(\"about_us.html\")",
"def about_us():\n\n return render_template('about_us.html')",
"def contributors(request):\n return render(request, 'metro_app/contributors.html')",
"def about():\n return render_template(\n 'about.jade',\n title='About... | [
"0.7454984",
"0.74276495",
"0.722088",
"0.71819055",
"0.7175889",
"0.7118464",
"0.71019506",
"0.70818996",
"0.70716953",
"0.7028422",
"0.700497",
"0.6933832",
"0.6907691",
"0.6906867",
"0.68919134",
"0.68711346",
"0.6855787",
"0.6830909",
"0.6821098",
"0.6808566",
"0.6796436"... | 0.0 | -1 |
Return a random parameter set for the model. | def random():
length = 10**np.random.uniform(2, 6)
radius = 10**np.random.uniform(1, 3)
axis_ratio = 10**np.random.uniform(-1, 1)
kuhn_length = 10**np.random.uniform(-2, -0.7)*length # at least 10 segments
pars = dict(
length=length,
radius=radius,
axis_ratio=axis_ratio,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_individual():\r\n return [ random.random() for _ in range(PARAMETERS_COUNT) ]",
"def get_random_fit_parameters(self):\n all_random = self.par_obj.get_random_all()\n return np.asarray([all_random[p] for p in self.fit_parameters])",
"def generate_params(self, randomize=True):\n ... | [
"0.71404666",
"0.6880614",
"0.68059534",
"0.6634644",
"0.6539095",
"0.63720685",
"0.6308819",
"0.62558764",
"0.62219083",
"0.6213681",
"0.61988467",
"0.6198028",
"0.61554956",
"0.6154143",
"0.61520594",
"0.6131589",
"0.61241823",
"0.6102374",
"0.606971",
"0.606971",
"0.602846... | 0.0 | -1 |
Displays the home page of the site. | def index(request):
# Fetches the latest 3 listings published
listings = Listing.objects.order_by('-list_date').filter(is_published=True)[:3]
context = {
'listings': listings,
'state_choices': state_choices,
'bedroom_choices': bedroom_choices,
'price_choices': price_choices
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def homepage():\n\treturn render_template(\"home/a_homepage.html\", title=\"Welcome\")",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.... | [
"0.84078366",
"0.83761525",
"0.8334035",
"0.8282487",
"0.8245316",
"0.8232632",
"0.82234603",
"0.81999093",
"0.8190846",
"0.8190846",
"0.81876814",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242",
"0.8144242"... | 0.0 | -1 |
Displays the about page of the site. | def about(request):
realtors = Realtor.objects.order_by('-hire_date')
mvp_realtors = Realtor.objects.all().filter(is_mvp=True)
context = {
'realtors': realtors,
'mvp_realtors': mvp_realtors
}
return render(request, 'pages/about.html', context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n\n\treturn render_template('about.html', title='About',\n\t\t\t\t\t\t year=datetime.now().year,\n\t\t\t\t\t\t message='Your application description page.')",
"def about():\n return render_template('about.html', title='About')",
"def about():\r\n return render_template(\r\n 'a... | [
"0.8424365",
"0.84033513",
"0.8397298",
"0.8395143",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.837663",
"0.8353596",
"0.8346676",
"0.832068",
"0.8266205",
"0.8246654",
... | 0.0 | -1 |
Creates an arc of arclength ``theta`` starting at angle ``start_angle``. | def arc(radius = 10, width = 0.5, theta = 45, start_angle = 0,
angle_resolution = 2.5, layer = 0):
inner_radius = radius - width/2
outer_radius = radius + width/2
angle1 = (start_angle) * pi/180
angle2 = (start_angle + theta) * pi/180
t = np.linspace(angle1, angle2, int(np.ceil(abs(theta)/an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arc(self, x, y, radius, startangle=0, endangle=2 * pi, anticlockwise=False):\n self._impl.arc(x, y, radius, startangle, endangle, anticlockwise)",
"def createArc(self, start, finish):\n return Arc(start, finish)",
"def AddArc(self,centerPnt,radius,startAngle,endAngle):\n\t\tarc=self.Space.Add... | [
"0.69182444",
"0.66217697",
"0.6483972",
"0.6466424",
"0.64196515",
"0.6205599",
"0.62045527",
"0.61128265",
"0.6096801",
"0.6077302",
"0.6064247",
"0.6040236",
"0.60327893",
"0.5998765",
"0.58496094",
"0.58134425",
"0.5784273",
"0.57754374",
"0.56797725",
"0.56748056",
"0.56... | 0.7355424 | 0 |
Creates a circularstar shape from lines, used as a lithographic resolution test pattern. | def litho_star(num_lines = 20,
line_width = 2,
diameter = 200,
layer = 0):
D = Device('litho_star')
degree = 180 / num_lines
R1 = rectangle(size = (line_width, diameter), layer = layer)
for i in range(num_lines):
r1 = D.add_ref(R1).rotate(degree * i)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circle(x: float, y: float, r: float, quantization: float):\n\n n = math.ceil(2 * math.pi * r / quantization)\n angle = np.array(list(range(n)) + [0]) / n * 2 * math.pi\n return LineCollection([r * (np.cos(angle) + 1j * np.sin(angle)) + complex(x, y)])",
"def generate_lines(self):\n x = self.s... | [
"0.59547365",
"0.5703942",
"0.5664267",
"0.5597338",
"0.55664325",
"0.5462601",
"0.5418031",
"0.53909445",
"0.53822535",
"0.5379863",
"0.5348105",
"0.5347115",
"0.53257895",
"0.5317498",
"0.5288432",
"0.5224814",
"0.5216462",
"0.52160704",
"0.52097315",
"0.5165006",
"0.516409... | 0.65843743 | 0 |
Creates a tapered trapezoid/rectangle geometry. | def taper(length = 10, width1 = 5, width2 = None, port = None, layer = 0):
if type(port) is Port and width1 is None: width1 = port.width
if width2 is None: width2 = width1
xpts = [0, length, length, 0]
ypts = [width1/2, width2/2, -width2/2, -width1/2]
D = Device('taper')
D.add_polygon([xpts, yp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trapezoids_and_rectangles(\n target,\n pore_diameter='pore.diameter',\n throat_diameter='throat.diameter'\n):\n from openpnm.models.geometry import conduit_lengths\n out = conduit_lengths.trapezoids_and_rectangles(\n target, pore_diameter=pore_diameter, throat_diameter=throat_diameter\n ... | [
"0.61551476",
"0.6098336",
"0.6037007",
"0.5797026",
"0.57216644",
"0.57096046",
"0.5693195",
"0.56295866",
"0.5562343",
"0.5556732",
"0.5539967",
"0.55036324",
"0.5467957",
"0.5304218",
"0.5293198",
"0.5275429",
"0.5267037",
"0.52627665",
"0.52621764",
"0.5261303",
"0.520455... | 0.57950306 | 4 |
Creates parameter combinations from a dict filled with list values, e.g. parameters_dict = { | def _parameter_combinations(parameters_dict):
value_combinations = list(itertools.product(*parameters_dict.values()))
keys = list(parameters_dict.keys())
return [{keys[n]:values[n] for n in range(len(keys))} for values in value_combinations] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ParameterCombinations(parameter_dict):\n d = parameter_dict\n return [dict(zip(d, v)) for v in itertools.product(*d.values())]",
"def package_parameters(parameter_dict):\n parameter_dict = {\n k: v for k, v in parameter_dict.iteritems() if isinstance(v, list)\n }\n keys_sorted = sorted(... | [
"0.81359535",
"0.7647715",
"0.76189387",
"0.75617224",
"0.73750454",
"0.714337",
"0.6960897",
"0.69338304",
"0.690913",
"0.6800184",
"0.67803603",
"0.67032933",
"0.6686063",
"0.6607078",
"0.6579359",
"0.65793484",
"0.6496566",
"0.64935875",
"0.64815354",
"0.64480793",
"0.6413... | 0.81325126 | 1 |
Checks if a variable is in the form of an iterable (list/tuple) and if not, returns it as a list. Useful for allowing argument inputs to be either lists (e.g. [1, 3, 4]) or singlevalued (e.g. 3). | def _loop_over(var):
if hasattr(var,"__iter__"):
return var
else:
return [var] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_list(iterable: Iterable[A]) -> List[A]:\n if isinstance(iterable, list):\n return iterable\n else:\n return list(iterable)",
"def ensure_list(iterable: Iterable[A]) -> List[A]:\n if isinstance(iterable, list):\n return iterable\n else:\n return list(iterable)",
... | [
"0.7286247",
"0.7286247",
"0.72141564",
"0.7148676",
"0.6915076",
"0.6883108",
"0.68479526",
"0.68468153",
"0.68409854",
"0.6808568",
"0.68034506",
"0.6796208",
"0.6768891",
"0.67553115",
"0.6742299",
"0.6641273",
"0.6589122",
"0.6550471",
"0.6519452",
"0.6513606",
"0.6500041... | 0.0 | -1 |
Creates an optimallyrounded SNSPD. | def snspd(wire_width = 0.2, wire_pitch = 0.6, size = (10,8),
num_squares = None, turn_ratio = 4, terminals_same_side = False,
layer = 0):
# Convenience tests to auto-shape the size based
# on the number of squares
if num_squares is not None and ((size is None) or ((size[0] is None) \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snspd_expanded(wire_width = 0.2, wire_pitch = 0.6, size = (10,8),\n num_squares = None, connector_width = 1,\n connector_symmetric = False, turn_ratio = 4,\n terminals_same_side = False, layer = 0):\n D = Device('snspd_expanded')\n S = snspd(wire_widt... | [
"0.56617934",
"0.54840404",
"0.5358254",
"0.52907157",
"0.51503605",
"0.50934327",
"0.5074087",
"0.5069123",
"0.5046648",
"0.49930352",
"0.48971698",
"0.4866133",
"0.4850441",
"0.47866306",
"0.47542366",
"0.47506884",
"0.47362882",
"0.4729253",
"0.4702261",
"0.46968874",
"0.4... | 0.5771747 | 0 |
Function to remove all stopwords from our text. | def remove_stop_words(text_tokens):
return [words for words in text_tokens if words not in stop_words] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords(text):\n tokens = word_tokenize(text)\n filtered = [word for word in tokens if word not in stop_words]\n filtered = ' '.join(filtered)\n return filtered",
"def remove_stopwords(self,text):\n return \" \".join([word for word in str(text).split() if word not in self.STOPWORD... | [
"0.8490817",
"0.84780365",
"0.8471625",
"0.8419556",
"0.840544",
"0.83893234",
"0.83262855",
"0.8266525",
"0.821738",
"0.81351143",
"0.8110988",
"0.8087311",
"0.80277866",
"0.79697526",
"0.796975",
"0.7949956",
"0.7949956",
"0.7949956",
"0.7949956",
"0.7919064",
"0.78922236",... | 0.7767828 | 30 |
Function to lemmatize all words in our text. | def lemmatize(text, nlp):
return [word.lemma_ for word in nlp(text)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatize_words(text: str, lemmatizer=WordNetLemmatizer()) -> str:\n return ' '.join(lemmatizer.lemmatize(word) for word in text.split())",
"def lemmatizeWords(self, words):\n\t\tlemmas = [self.lemmatizer.lemmatize(word) for word in words]\n\t\treturn lemmas",
"def lemmatize_fun(self):\n tokens =... | [
"0.85499704",
"0.8268073",
"0.82079077",
"0.8186022",
"0.8152535",
"0.8151027",
"0.7895257",
"0.78895575",
"0.7851737",
"0.7800797",
"0.7765397",
"0.77534753",
"0.77497154",
"0.7729273",
"0.7702165",
"0.76635",
"0.7657912",
"0.7648806",
"0.7588402",
"0.7535952",
"0.7519851",
... | 0.7877481 | 8 |
Returns a boolean specifying if the package has been unorphaned or not. | def unorphaned(self):
return self.new_owner == self.user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isOrphaned(self):\n return len(self.user_storage.all()) == 0",
"def orphaned(self):\n return (self.parent is None)",
"def __bool__(self):\n return not self.undefine",
"def not_installed(self) -> bool:\n return pulumi.get(self, \"not_installed\")",
"def is_installed(self):\n ... | [
"0.6621838",
"0.6543227",
"0.62511706",
"0.6115527",
"0.5900718",
"0.5807024",
"0.5746391",
"0.57066596",
"0.56932074",
"0.56583685",
"0.5641182",
"0.5578226",
"0.5573346",
"0.5573306",
"0.5564212",
"0.5551215",
"0.55447036",
"0.5522709",
"0.5520322",
"0.5516875",
"0.5507191"... | 0.65746266 | 1 |
String representation of the object adjusted for the ownership change. | def to_string(self):
if self.new_owner == self.user:
output = u'%s unorphaned : %s [%s]' % (
self.user.ljust(15), self.name, ','.join(sorted(self.branch)))
elif self.new_owner == 'orphan':
output = u'%s [%s] was orphaned by %s' % (
self.name, ','.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.__dict__['_obj'])",
"def __str__(self):\n return str('%s (%s)' % (self.company, self.owner))",
"def __str__(self):\n return str(self.obj)",
"def __str__(self):\n return f'{self.user_owner} {self.created_at} {self.updated_at}'",
"def _... | [
"0.7168897",
"0.7161167",
"0.7082937",
"0.7027653",
"0.6982358",
"0.6949853",
"0.6808013",
"0.6808013",
"0.6664189",
"0.66515255",
"0.66407824",
"0.6633331",
"0.6619409",
"0.66149205",
"0.66149205",
"0.66103643",
"0.66065395",
"0.65993714",
"0.6593101",
"0.6562468",
"0.655830... | 0.746626 | 0 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91896784",
"0.9168378",
"0.890185",
"0.8770976",
"0.8511273",
"0.8479953",
"0.844435",
"0.8299758",
"0.8186503",
"0.8105667",
"0.8079737",
"0.8066149",
"0.8049647",
"0.7700968",
"0.7612295",
"0.7611456",
"0.7600605",
"0.7600605",
"0.7600605",
"0.75392073",
"0.75166553",
... | 0.0 | -1 |
Return the units of measurement. | def unit_of_measurement(self):
return DEVICE_MAP[self._sensor_type][DEVICE_MAP_INDEX.index('UNIT_OF_MEASURE_INDEX')] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_of_measurement(self):\n return self._units",
"def unitsofmeasure(self):\n return self._unitsofmeasure",
"def units(self):\n return self._units",
"def units(self):\n return self._units",
"def units(self):\n pass",
"def unit_of_measurement(self):\n return ... | [
"0.8761163",
"0.8672248",
"0.86451316",
"0.86451316",
"0.8517744",
"0.8458637",
"0.84352386",
"0.8411765",
"0.83127886",
"0.82855666",
"0.8274016",
"0.81320137",
"0.81320137",
"0.81320137",
"0.81320137",
"0.81320137",
"0.81320137",
"0.81320137",
"0.80762535",
"0.80762535",
"0... | 0.79998624 | 35 |
old_params is just a requirement by mcmc_global and has no significance in the definition of this function. We put a flat prior (zero and unity) on the parameters and define their range to be between 0 and 200 | def prior(old_params,params):
for s in range(len(params)):
if params[s] < 0.0 or params[s] > 2:
return 0
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_parameters(self):\n # We update gamma, gamma0, lambda and nu in turn (Bottolo et al, 2011)\n self.update_gamma()\n self.update_gamma0()\n self.update_lambda()\n self.update_nu()\n if self.sample_xi:\n self.update_xi()",
"def set_params(self, new_par... | [
"0.618104",
"0.61772186",
"0.61578333",
"0.61531264",
"0.6147884",
"0.6024243",
"0.6003807",
"0.5984827",
"0.5944582",
"0.5911808",
"0.5869742",
"0.58526397",
"0.5821203",
"0.5814942",
"0.58012223",
"0.578155",
"0.57797647",
"0.5762599",
"0.5758702",
"0.575807",
"0.5745608",
... | 0.5687151 | 33 |
find out dot products among the computation path of {y}. | def dotps(y):
def isdot(e):
return type(e) is T.TensorVariable and str(e).startswith('dot')
return parms(y, isdot) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dotproduct(x, y):\n return sum(imap(operator.mul, x, y))",
"def tree_vdot(tree_x, tree_y):\n vdots = tree_multimap(_vdot_safe, tree_x, tree_y)\n return tree_reduce(operator.add, vdots)",
"def dot(x,y):\n\treturn sum([xi*yi for (xi,yi) in zip(x,y)])",
"def vec_dot(x, y):\r\n return sum(a * b for a, ... | [
"0.69734466",
"0.663023",
"0.65787554",
"0.6566777",
"0.6315818",
"0.62924796",
"0.62703747",
"0.62658304",
"0.624315",
"0.6189476",
"0.61323863",
"0.6013362",
"0.6009598",
"0.5977597",
"0.59481186",
"0.5946522",
"0.5916134",
"0.5911265",
"0.58836174",
"0.58768964",
"0.586320... | 0.6585009 | 2 |
test card __init__ , get_rank(), get_suit() methods | def testCard(self):
# test1
cardObj1 = Card('A','d')
self.assertEquals(1,cardObj1.get_rank())
self.assertEquals('d',cardObj1.get_suit())
# test2
cardObj2 = Card('J','d')
self.assertEquals(10,cardObj2.get_rank())
# test3
cardObj3 = Card(5,'d')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init(self):\n self.assertEqual(self.card.suit, \"Spades\")\n self.assertEqual(self.card.value, \"A\")",
"def test_init_(self):\n card = Card('Archer', 3, 0, 2)\n self.assertEqual(card.name, 'Archer')\n self.assertEqual(card.attack, 3)\n self.assertEqual(card.mon... | [
"0.809689",
"0.79151005",
"0.7716452",
"0.763676",
"0.75678635",
"0.75493795",
"0.75117683",
"0.7462301",
"0.7455237",
"0.74528223",
"0.7395459",
"0.73303074",
"0.7319083",
"0.7313358",
"0.7304878",
"0.7219271",
"0.7201742",
"0.7156314",
"0.7149407",
"0.71467525",
"0.7143723"... | 0.85291684 | 0 |
Tries to strip one of the given suffixes, iterating over them. If succesful, returns (stripped_value, True). Otherwise, returns (value, False). | def strip_suffix(value:str, suffixes:Iterable[str]) -> Tuple[str, bool]:
for suffix in suffixes:
if value.endswith(suffix):
return value[:len(value) - len(suffix)], True
return value, False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s",
"def v7_lstrip(iterable, strip_value):\n iterator = iter(iterable)\n for item in iterator:\n if (callable(strip_value) and not strip_value(item)\n ... | [
"0.6115835",
"0.6094498",
"0.5921399",
"0.5815144",
"0.5782515",
"0.5745079",
"0.5707965",
"0.56852424",
"0.5643175",
"0.56098616",
"0.5573488",
"0.54744166",
"0.546762",
"0.5296147",
"0.518041",
"0.50585926",
"0.49865663",
"0.49604824",
"0.49022174",
"0.4840293",
"0.48208615... | 0.78061074 | 0 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in xrange(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.77288336",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.764... | 0.0 | -1 |
If x is not an iterable or is a string, transforms it in a list | def to_list(x):
import collections
if not isinstance(x, collections.Iterable) or isinstance(x, str):
x = [x]
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listify(x):\n if (not isinstance(x, basestring)) and isinstance(x, Sequence):\n return x\n else:\n return [x]",
"def tolist(x):\n return x if isinstance(x, list) else [x]",
"def to_list(x):\n if isinstance(x, list):\n return x\n return [x]",
"def listify(x):\n\n if isinstan... | [
"0.8212966",
"0.7719973",
"0.7719824",
"0.73368007",
"0.7295595",
"0.7273797",
"0.72704834",
"0.7222545",
"0.70650977",
"0.7031084",
"0.6982997",
"0.6972325",
"0.69247663",
"0.6921604",
"0.6898757",
"0.6897752",
"0.68975806",
"0.68360776",
"0.6797766",
"0.6788874",
"0.6710859... | 0.8549031 | 0 |
Returns the current system time as a string. | def current_time():
now = datetime.datetime.now()
time = now.strftime("%Y-%m-%d %H:%M:%S:%f")
return time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_current_time() -> str:\n return datetime.now().strftime(\"%FT%H:%M:%S\")",
"def get_current_timestamp_str(self):\n return str(time.mktime(datetime.datetime.now().timetuple()))",
"def get_current_time():\n return time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.localtime())",
"def time_now() ->... | [
"0.8203018",
"0.8201877",
"0.81002456",
"0.79997194",
"0.78119814",
"0.7670555",
"0.7659952",
"0.76400006",
"0.76087743",
"0.75608253",
"0.75479335",
"0.7538281",
"0.7535772",
"0.7534596",
"0.75140697",
"0.7513856",
"0.7502751",
"0.7457391",
"0.7455281",
"0.7445748",
"0.74457... | 0.7766427 | 5 |
Reset performance statistics to zero across the cluster. | def zero_cluster():
if _TRAFFICCTL:
cmd = _traffic_ctl("metric", "clear", "--cluster")
else:
cmd = _traffic_line("-Z")
return _subprocess(cmd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()",
"def stats_reset(self):\n self.stats.reset()",
"def stats_reset(self):\n self.stats.reset()",
"def reset(self):\n reset_system_health_series()",
"def reset(self) -> None:\n ... | [
"0.7827252",
"0.7534795",
"0.7534795",
"0.7402714",
"0.7365327",
"0.7331224",
"0.7309859",
"0.72884315",
"0.72294605",
"0.71887064",
"0.70849186",
"0.7044942",
"0.70418096",
"0.701435",
"0.701435",
"0.701435",
"0.70138794",
"0.6930379",
"0.6849832",
"0.6824036",
"0.6729499",
... | 0.6572295 | 31 |
Create an Nbin discrete colormap from the specified input map | def discrete_cmap(N, base_cmap=None):
# Note that if base_cmap is a string or None, you can simply do
# return plt.cm.get_cmap(base_cmap, N)
# The following works for string, None, or a colormap instance:
# By Jake VanderPlas
# License: BSD-style
base = plt.cm.get_cmap(base_cmap)
color_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_cmap(N, base_cmap=None):\n base = plt.get_cmap(base_cmap)\n color_list = base(np.linspace(0, 1, N))\n cmap_name = base.name + str(N)\n return base.from_list(cmap_name, color_list, N)",
"def discrete_cmap(N, base_cmap=None):\n # see https://gist.github.com/jakevdp/91077b0cae40f8f8244a\... | [
"0.72420394",
"0.71648407",
"0.69006306",
"0.6877493",
"0.6877493",
"0.6877493",
"0.6861162",
"0.6861162",
"0.6861162",
"0.6861162",
"0.6861134",
"0.68545055",
"0.67333055",
"0.66576743",
"0.6597572",
"0.6593752",
"0.65882033",
"0.6581711",
"0.650824",
"0.6439444",
"0.6404952... | 0.68478703 | 12 |
Construct a layernorm module in the TF style (epsilon inside the square root). | def __init__(self, config, variance_epsilon=1e-12):
super(BertLayerNorm, self).__init__()
self.gamma = nn.Parameter(torch.ones(config.hidden_size))
self.beta = nn.Parameter(torch.zeros(config.hidden_size))
self.variance_epsilon = variance_epsilon | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verhulst(nb_init, t0, tf, eps, methode, gamma, K) :\n f=lambda y,t : gamma*y*(1-y/K)\n Y=meth_epsilon(nb_init, t0, tf, eps, f, methode)\n return Y",
"def malthusiens(nb_init, t0, tf, eps, methode, gamma ) :\n\n f=lambda y, t : gamma*y\n Y=meth_epsilon(nb_init, t0, tf, eps, f, methode)\n ... | [
"0.6276811",
"0.601525",
"0.57934755",
"0.5740662",
"0.5537108",
"0.55179226",
"0.5422493",
"0.5411982",
"0.5388148",
"0.536833",
"0.53512096",
"0.5286971",
"0.52560353",
"0.5232842",
"0.52287155",
"0.52252483",
"0.52195704",
"0.5218574",
"0.5192697",
"0.5192697",
"0.51919794... | 0.0 | -1 |
Return the output of Bert For Cloze. | def forward(self, x_input):
pad_token_id = self.config.pad_token_id
articles, articles_mask, ops, question_pos = x_input
bsz = ops.size(0)
ops = ops.reshape(bsz, 1, 5, -1)
opnum = ops.size(1)
out = self.bert(
articles, attention_mask=articles_mask... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dut():\n yield PyBERT(gui=False)",
"def lake(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"lake\")",
"def output(self) -> str:\n return self.stdout",
"def bye():\r\n return \"<p>Bye World! <p>\"",
"def getBanter(self):\r\n return self.__banterAssembler.assembleStri... | [
"0.58488697",
"0.5087005",
"0.5085445",
"0.5082853",
"0.5044446",
"0.5004547",
"0.49827224",
"0.4977691",
"0.4974965",
"0.49677548",
"0.4949249",
"0.49347672",
"0.48943877",
"0.48943877",
"0.4890921",
"0.48884332",
"0.48745984",
"0.48695076",
"0.48517925",
"0.484535",
"0.4843... | 0.0 | -1 |
Create a PyODPS DataFrame from this partition. | def to_df(self):
from ..df import DataFrame
return DataFrame(self.table).filter_parts(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_df(self):\n from ..df import DataFrame\n\n return DataFrame(self)",
"def data_frame_creator(self):\n\n return pd.DataFrame()",
"def to_vdf(self):\n\t\treturn (vDataFrame(self.name, self.cursor))",
"def get_df(self) -> pd.DataFrame:\n return pd.DataFrame(self.fetchall(), col... | [
"0.6410501",
"0.6409843",
"0.631184",
"0.6302039",
"0.6254428",
"0.6240888",
"0.6221495",
"0.62074184",
"0.6169409",
"0.6092469",
"0.6092469",
"0.6092469",
"0.6092469",
"0.6092469",
"0.60744876",
"0.6049744",
"0.60237014",
"0.6014713",
"0.59848326",
"0.5980033",
"0.5975205",
... | 0.63820857 | 2 |
The skill growth type. One of "Caster", "Hybrid", or "NonCaster". | def growthType(self):
return self._growthType | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skill(self):\n return self._get(\"skill\")",
"def getType(self):\n if (self.type == 's'):\n #suit type\n type = \"suit\"\n elif (self.type == 'b'):\n #boss type\n type = \"boss\"\n else:\n notify.error(\"Invalid DNA type: \", ... | [
"0.6139959",
"0.60505414",
"0.5908837",
"0.5729082",
"0.559966",
"0.5550725",
"0.5464064",
"0.5439212",
"0.540731",
"0.5383495",
"0.53482735",
"0.5322756",
"0.53177196",
"0.5306013",
"0.524031",
"0.524031",
"0.52115494",
"0.52005047",
"0.51884246",
"0.5183538",
"0.5169487",
... | 0.6925503 | 0 |
Returns True if this character is the characterClass provided or has the base class provided as its primary base class. | def isClass(self, className):
return self.characterClass == className or self.baseClass == className | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isinstance(self, class_or_string):\n if class_or_string is None:\n return False\n import inspect\n if inspect.isclass(class_or_string):\n return isinstance(self, class_or_string)\n else:\n return self.__class__.__name__.lower() == class_or_string.low... | [
"0.64994603",
"0.63883084",
"0.63236517",
"0.62002075",
"0.60200167",
"0.59671956",
"0.59391063",
"0.59264797",
"0.58480954",
"0.58382076",
"0.5809324",
"0.5773775",
"0.5710325",
"0.56561506",
"0.5652726",
"0.5646972",
"0.558053",
"0.55660844",
"0.5552702",
"0.5544474",
"0.55... | 0.7872064 | 0 |
The Style this Ninja is currently using. If this playercharacter is not a Ninja, it should always be None. | def ninjaStyle(self):
return int(self._ninjaStyle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def style(self):\n return self['style']",
"def style(self):\n return self.container['style']",
"def style(self):\n return self._style",
"def style(self):\n return self._style",
"def get_style ( self, object ):\n return self.style",
"def ninjaStyle(self, value):\n ... | [
"0.71365476",
"0.7038234",
"0.69076836",
"0.69076836",
"0.67609936",
"0.664686",
"0.6559305",
"0.6306887",
"0.6089656",
"0.60890204",
"0.58917797",
"0.58830625",
"0.58830625",
"0.5865744",
"0.57532555",
"0.57532555",
"0.5749389",
"0.5721678",
"0.5668969",
"0.56575227",
"0.565... | 0.75237757 | 0 |
The Style this Ninja is currently using. If this playercharacter is not a Ninja, it should always be None. | def ninjaStyle(self, value):
if self.characterClass != "Ninja":
return
elif value in ["Tiger", "Panther", "Snake", "Crane", "Dragon"]:
self._ninjaStyle = value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ninjaStyle(self):\n return int(self._ninjaStyle)",
"def style(self):\n return self['style']",
"def style(self):\n return self.container['style']",
"def style(self):\n return self._style",
"def style(self):\n return self._style",
"def get_style ( self, object ):\n ... | [
"0.75248295",
"0.7135282",
"0.70366",
"0.6906625",
"0.6906625",
"0.67599493",
"0.6557639",
"0.63036156",
"0.608707",
"0.6087017",
"0.5890021",
"0.58814216",
"0.58814216",
"0.58654",
"0.57515717",
"0.57515717",
"0.57476807",
"0.5720216",
"0.5667569",
"0.5655578",
"0.56504744",... | 0.66505957 | 6 |
Perform and check a HTTP GET request, returning additional data. This will perform the request to the resource and validate that all the results are what the caller expects. | def api_get(self, *args, **kwargs):
return self.api_get_with_response(*args, **kwargs)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_GET(self):\n self._try_to_process_request(self._handle_get_request)",
"def test_get(self):\n return self.doRequest(self.url, method=\"GET\", body=self.input)",
"def do_GET(self):\n self.http_method = 'GET'\n self.response()",
"def _http_get(self, url, params={}):\n i... | [
"0.7560701",
"0.7227384",
"0.7187559",
"0.69666916",
"0.69394773",
"0.6935016",
"0.69043523",
"0.68974036",
"0.68702024",
"0.68553275",
"0.68527097",
"0.68363225",
"0.67705095",
"0.6748008",
"0.6701178",
"0.669002",
"0.6689964",
"0.6679247",
"0.66511047",
"0.6632099",
"0.6630... | 0.0 | -1 |
Perform and check a HTTP GET request to an API resource. This will perform the request to the resource and validate that all the results are what the caller expects. | def api_get_with_response(self, path, data={}, **kwargs):
return self.api_call(client_http_method=self.client.get,
path=path,
data=data,
**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _http_get(self, url, params={}):\n if not self.token:\n self.get_token()\n headers = {'Authorization': self.token, 'Accept': 'application/json; indent=4'}\n url = self.server + '/api2' + url\n try:\n r = requests.get(url=url, headers=headers, params=params)\n ... | [
"0.6998109",
"0.69132936",
"0.6825636",
"0.6818823",
"0.67906386",
"0.676036",
"0.6684529",
"0.667307",
"0.6641333",
"0.6535306",
"0.65230304",
"0.6488716",
"0.6460008",
"0.6451254",
"0.6432881",
"0.63907796",
"0.6387903",
"0.6368967",
"0.6365885",
"0.63573444",
"0.6347204",
... | 0.0 | -1 |
Perform and check an HTTP PUT to an API resource. This will perform the request to the resource and validate that all the results are what the caller expects. | def api_put(self, *args, **kwargs):
return self.api_put_with_response(*args, **kwargs)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_PUT(self,):\n self.http_method = 'PUT'\n # Nothing to do for now.\n pass",
"def test_PUT(self):\n if not self.url:\n return\n response = self.client.put(self.url, {}, format='json')\n self.assertIn(response.status_code, [status.HTTP_405_METHOD_NOT_ALLOW... | [
"0.74917644",
"0.7485476",
"0.7350395",
"0.72159547",
"0.71027565",
"0.7096223",
"0.7004549",
"0.6951121",
"0.69139427",
"0.69017315",
"0.68908924",
"0.6882145",
"0.68803865",
"0.6856098",
"0.68419015",
"0.68007785",
"0.6794042",
"0.6786725",
"0.6777051",
"0.6738387",
"0.6709... | 0.6607047 | 35 |
Assert that a response was OK and optionally has caching headers. | def assertHttpOK(self, response, check_last_modified=False,
check_etag=False):
self.assertEqual(response.status_code, 200)
if check_last_modified:
self.assertIn('Last-Modified', response)
if check_etag:
self.assertIn('ETag', response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertHttpOK(self, response):\r\n self.assertEqual(response.status_code, 200)",
"def verify_response(self, expected_status_code=200, params=None, url=None, cacheable=False):\n if params:\n self.query_params.update(params)\n response = self.client.get(url or self.url, self.quer... | [
"0.7178712",
"0.71496934",
"0.7064061",
"0.6939842",
"0.6876333",
"0.6846226",
"0.68445605",
"0.68276155",
"0.6606328",
"0.6579522",
"0.6516582",
"0.6514711",
"0.64558417",
"0.64323646",
"0.6411007",
"0.6337603",
"0.6324263",
"0.6321689",
"0.63064855",
"0.6296818",
"0.6284002... | 0.76214844 | 0 |
Assert that the response was HTTP 304 Not Modified. | def assertHttpNotModified(self, response):
self.assertEqual(response.status_code, 304)
self.assertEqual(response.content, b'') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertHttpNotModified(self, resp):\r\n return self.assertEqual(resp.status_code, 304)",
"def test_not_modified_headers(self):\n\n def get_response(req):\n resp = self.client.get(req.path_info)\n resp[\"Date\"] = \"Sat, 12 Feb 2011 17:35:44 GMT\"\n resp[\"Last-Mo... | [
"0.909007",
"0.79713374",
"0.76501834",
"0.7598178",
"0.7469644",
"0.73889446",
"0.7349728",
"0.72101575",
"0.7090123",
"0.68975306",
"0.67755",
"0.6768324",
"0.67128545",
"0.66503507",
"0.65544546",
"0.6530178",
"0.65116745",
"0.6509352",
"0.6417122",
"0.6357714",
"0.6326523... | 0.8895653 | 1 |
Returns a string equal to s, but with a space added after every n characters | def add_space(s,n):
t = ""
for i in xrange(len(s)):
# Add white space after every n characters.
if i % n == 0 and i != 0:
t += ' '
t += s[i]
return t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_by_word(s, n):\n\ta = s.split()\n\tret = ''\n\tfor i in range(0, len(a), n):\n\t\tret += ' '.join(a[i:i+n]) + '\\n'\n\treturn ret",
"def indent_lines(s, n):\n return \"\\n\".join(map(lambda line: \" \" * n + line, \n s.split('\\n')))",
"def space(n):\n rstr = \" \" *... | [
"0.75147533",
"0.6939255",
"0.68727666",
"0.6850466",
"0.6787072",
"0.6705455",
"0.6694406",
"0.66637486",
"0.6594109",
"0.644319",
"0.635787",
"0.6339606",
"0.63323545",
"0.6322035",
"0.6314994",
"0.6263823",
"0.6216911",
"0.6158638",
"0.61580086",
"0.6148299",
"0.6139733",
... | 0.856906 | 0 |
Check two string for equality. | def main(*args: str) -> NoReturn:
args = _parseArgs(args)
result = "ОК" if _isEqual(args.text, args.pattern) else "КО" # NB: "ОК" and "КО" written with cyrillic letters
print(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isEqual(string1, string2):\n return (True)",
"def strings_equal(s1, s2):\n s1 = unicodedata.normalize('NFKC', s1)\n s2 = unicodedata.normalize('NFKC', s2)\n return compare_digest(s1, s2)",
"def test_strings_are_equal(self):\n string1 = 'this is the first string'\n string2 = 'this is... | [
"0.8286097",
"0.7838371",
"0.77676857",
"0.77110237",
"0.7698066",
"0.75700486",
"0.75269747",
"0.7487495",
"0.7377882",
"0.7353101",
"0.7257572",
"0.7250175",
"0.70830333",
"0.69853055",
"0.69742966",
"0.69737196",
"0.69543505",
"0.6930489",
"0.6900058",
"0.6830279",
"0.6793... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81925154",
"0.8093376",
"0.8027219",
"0.80169857",
"0.7991475",
"0.7988959",
"0.79785",
"0.7973596",
"0.7959107",
"0.7956459",
"0.793519",
"0.79322356",
"0.79320693",
"0.79289055",
"0.79240024",
"0.79221827",
"0.792161",
"0.79209834",
"0.7920566",
"0.7919846",
"0.791543",
... | 0.7812085 | 96 |
Test that an ImportError with the correct message is raised given an invalid module path. | def test_import_string_invalid_path(self):
invalid_path = 'some invalid module path'
with pytest.raises(ImportError) as error:
utils.import_string(invalid_path)
assert '{} doesn\'t look like a module path'.format(
invalid_path) == str(error.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_import_string_missing_module(self):\n invalid_module = 'ttgn.nonexistent_module.foobar'\n with pytest.raises(ImportError):\n utils.import_string(invalid_module)",
"def test_ImportError(n=2):\n\n p = bad_import()\n\n try:\n p.result()\n except ImportError:\n ... | [
"0.79570305",
"0.7689355",
"0.7388606",
"0.73546016",
"0.73336875",
"0.7321655",
"0.7305616",
"0.7255673",
"0.71862626",
"0.70956326",
"0.7076577",
"0.70657676",
"0.7059845",
"0.7058774",
"0.6950361",
"0.6922619",
"0.6857875",
"0.68275666",
"0.6780171",
"0.67393184",
"0.66217... | 0.82979053 | 0 |
Test that an ImportError with the correct message is raised given a name that does not correspond to an importable module. | def test_import_string_missing_module(self):
invalid_module = 'ttgn.nonexistent_module.foobar'
with pytest.raises(ImportError):
utils.import_string(invalid_module) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ImportError(n=2):\n\n p = bad_import()\n\n try:\n p.result()\n except ImportError:\n print(\"Caught ImportError\")\n else:\n assert False, \"Raise the wrong Error\"",
"def test_ensureFailsWhenImported(self):\n module = object()\n modules = {\"m2\": module}\... | [
"0.7597786",
"0.75931257",
"0.7343852",
"0.7309115",
"0.7275484",
"0.7243739",
"0.71951145",
"0.6992243",
"0.6979921",
"0.6965877",
"0.6944954",
"0.6912893",
"0.68370533",
"0.6816652",
"0.6809805",
"0.6772058",
"0.6760251",
"0.67575914",
"0.675393",
"0.6730853",
"0.66940403",... | 0.7640379 | 0 |
Test that an ImportError with the correct message is raised given a name that does not correspond to an importable class or attribute on an importable module. | def test_import_string_missing_class_or_attribute(self):
valid_module = 'ttgn.pokedex'
invalid_class = 'NonexistentClass'
with pytest.raises(ImportError) as error:
utils.import_string('{}.{}'.format(valid_module, invalid_class))
assert 'Module {} has no class or attribute {}'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ensureFailsWhenImported(self):\n module = object()\n modules = {\"m2\": module}\n self.patch(sys, \"modules\", modules)\n e = self.assertRaises(\n ImportError,\n ensureNotImported,\n [\"m1\", \"m2\"],\n \"A message.\",\n pr... | [
"0.7703309",
"0.74920857",
"0.7486999",
"0.7364031",
"0.7319275",
"0.72641766",
"0.70818245",
"0.70341796",
"0.7001553",
"0.70003086",
"0.69795656",
"0.6979278",
"0.69665396",
"0.6963909",
"0.69360757",
"0.68839735",
"0.6860142",
"0.68049556",
"0.6716528",
"0.67145526",
"0.66... | 0.75992084 | 1 |
Method validate ground size (coordinates should not go beyond the ground) | def validate_ground_size(ground: tuple, points: tuple) -> None:
for coordinates in points:
limit = any(
size < point for size, point in zip(ground, coordinates)
)
if limit:
raise GroundSizeLimitError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_size(self,x,y):\n assert(x <= 10**3), 'Width larger than 1000' \n assert(y <= 10**3), 'Height larger than 1000' \n assert(x*y <= 3*(10**5)), 'Resolution larger than 300000'",
"def _assert_valid(self, y: int, x: int) -> None:\n if not (0 <= y < self.size[0] and... | [
"0.6457886",
"0.6294506",
"0.6132573",
"0.60817254",
"0.59851617",
"0.5971602",
"0.59639955",
"0.59502816",
"0.59259653",
"0.59239584",
"0.5920646",
"0.5894178",
"0.58852047",
"0.58603555",
"0.5845241",
"0.58419657",
"0.5824202",
"0.58037156",
"0.579982",
"0.57987565",
"0.578... | 0.7522807 | 0 |
Create and configure a new app instance for tests. | def app():
# create a temp file to isolate the db for each test
db_fd, db_path = tempfile.mkstemp()
app = create_app()
app.config['TESTING'] = True
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['DATABASE'] = db_path
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app(self):\n\n app = create_app()\n app.config.from_object('project.config.TestingConfig')\n return app",
"def create_app(self):\n app.config.from_object('config.TestingConfig')\n return app",
"def create_app(test_config=\"test_config.py\"):\n app = Flask(__name... | [
"0.8529462",
"0.8502788",
"0.7916234",
"0.7842042",
"0.78236634",
"0.7692026",
"0.768145",
"0.7679991",
"0.75927925",
"0.7587311",
"0.75695646",
"0.7557448",
"0.7541567",
"0.75321954",
"0.75258666",
"0.75188154",
"0.7498003",
"0.74910367",
"0.74682814",
"0.74572736",
"0.74503... | 0.0 | -1 |
this method is responsible to produce the OneHot encoding for the DNA strings. The OneHOt matrix is used for the convolutional process If we need to bridge between the prediction to HTSELEX sequences we will use set_redundant_linker_to_avergae method | def set_one_hot_matrix(self, dna_data):
self.one_hot_data = np.array(list(map(functools.partial(self.one_hot_encoder), dna_data)))
if self.selex_predict_str_adaptor > 0:
self.one_hot_data = self.set_redundant_linker_to_avergae(modified_matrix=self.one_hot_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encoder(self, DNA_string):\n\n if self.selex_predict_str_adaptor != 0:\n DNA_string = \"A\" * self.selex_predict_str_adaptor + DNA_string + 'A' * self.selex_predict_str_adaptor\n\n trantab = DNA_string.maketrans('ACGT', '0123')\n str_arr = [\"\" for x in range(self.num_o... | [
"0.7821786",
"0.74596447",
"0.7209337",
"0.70798385",
"0.69494355",
"0.6662855",
"0.6661924",
"0.6628616",
"0.64712954",
"0.64597034",
"0.64237636",
"0.6379793",
"0.63741404",
"0.6350285",
"0.634517",
"0.6328219",
"0.6291674",
"0.62795573",
"0.62381124",
"0.6232887",
"0.62091... | 0.7559954 | 1 |
Helper function that transforms string into hash | def string_to_hash(text):
obj = {}
items = text.split(",")
for i in items:
obj[i] = True
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_string(input_str):\n input_b = str.encode(input_str)\n input_hash = hashlib.md5(input_b.lower())\n input_hash_str = input_hash.hexdigest()\n\n return input_hash_str",
"def __str_to_hash(string_to_hash: str, errors: str = 'ignore') -> str:\n string_hash = string_to_hash.encode(encoding=\"u... | [
"0.76837784",
"0.7520116",
"0.75106823",
"0.74467844",
"0.7326718",
"0.73156357",
"0.7304415",
"0.7231918",
"0.7176494",
"0.71617675",
"0.70800173",
"0.7020654",
"0.69116765",
"0.6866536",
"0.68540996",
"0.68479973",
"0.6847203",
"0.68161696",
"0.6802587",
"0.6796893",
"0.678... | 0.6832907 | 17 |
Search for deepest and latest child of current element. Returns None if there's no children Tag or None | def find_deepest_child(self):
if not self.children:
return None
deepest_child = self
while True:
deepest_child = deepest_child.children[-1]
if not deepest_child.children:
break
return deepest_child | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child_by(self, selector):\r\n for child in self.get_children():\r\n if selector(child):\r\n return child\r\n return None",
"def find_after(node, *find_args, **find_kwargs):\n while True:\n if not node.next_sibling:\n return None\n node =... | [
"0.6620952",
"0.629232",
"0.60401285",
"0.59193635",
"0.5893962",
"0.5881531",
"0.58469707",
"0.5818505",
"0.575708",
"0.5733191",
"0.57048327",
"0.57005054",
"0.5694782",
"0.56900626",
"0.5688232",
"0.5687768",
"0.5687162",
"0.5662775",
"0.56547505",
"0.5654523",
"0.565259",... | 0.73347884 | 0 |
Helper method to get a key from os.environ Return value of environment variable name if it exists, None otherwise | def environ_key(name=None):
try:
return os.environ[name]
except KeyError:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(key:str):\n value = environ.get(key)\n if value == None or len(str(value)) == 0:\n raise ValueError('Missing env: '+key)\n return value",
"def get_from_environ(key: str, default: Any = None) -> str:\n return os.environ.get(key, default)",
"def __getitem__(self, key):\n return os.e... | [
"0.8275373",
"0.82124984",
"0.8175934",
"0.81435573",
"0.8137051",
"0.8034983",
"0.801669",
"0.79110456",
"0.79039234",
"0.78000516",
"0.77659166",
"0.7699683",
"0.76929814",
"0.7613438",
"0.75850135",
"0.75556827",
"0.7549692",
"0.7483565",
"0.746693",
"0.7426781",
"0.741766... | 0.87061214 | 0 |
Timestamp in the format required for Monitis API post requests Return a string containing current datetime in GMT | def timestamp():
return datetime.utcnow().strftime("%F %T") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp():\n return datetime.now().strftime(\"%Y%m%dT%H%M%S\")",
"def timestamp():\n my_date_object = datetime.utcnow()\n my_date_string = my_date_object.strftime('%d-%m-%Y %H:%M:%S')\n return my_date_string",
"def get_timestamp(self):\n return datetime.datetime.utcnow()",
"def _... | [
"0.7731979",
"0.74293196",
"0.73007035",
"0.7278086",
"0.7278086",
"0.726755",
"0.72519994",
"0.7225553",
"0.72061074",
"0.7176319",
"0.71756583",
"0.7151485",
"0.70245695",
"0.70061195",
"0.6973579",
"0.695613",
"0.69196403",
"0.69106525",
"0.68919057",
"0.6880653",
"0.68496... | 0.74469423 | 1 |
Resolve the Monitis Secret Key from the invoking shell Find the secret key First, check for a key local to this instance of Monitis. If not found in the instance, then check the class. Finally, check the environment variable. If no key is found in any of these places, then raise an exception. | def resolve_secretkey(self):
# check the instance variable
secretkey = self.secretkey
if secretkey is not None:
return secretkey
# check the class variable
secretkey = resolve_secretkey()
if secretkey is not None:
return secretkey
# if we... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_apikey(self):\n # check the instance variable\n apikey = self.apikey\n if apikey is not None:\n return apikey\n\n # check the class variable and environment\n apikey = resolve_apikey()\n if apikey is not None:\n return apikey\n\n # ... | [
"0.6604518",
"0.6228942",
"0.5899979",
"0.5881667",
"0.58807373",
"0.5870864",
"0.57252306",
"0.5686935",
"0.56491184",
"0.5640668",
"0.5598092",
"0.556976",
"0.55188745",
"0.5513074",
"0.5494099",
"0.5482864",
"0.5477822",
"0.54728305",
"0.5441457",
"0.54343104",
"0.5410499"... | 0.76553166 | 0 |
Return a `Logger` instance for `name`. | def get_logger(name: str) -> logging.Logger:
logger = logging.getLogger(name)
logger.addHandler(logging.StreamHandler(sys.stdout))
logger.setLevel(logging.DEBUG)
return logger | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_logger(name):\n # type: (str) -> Logger\n return logging.getLogger(name)",
"def get_logger(name: str) -> logging.Logger:\n \n return logging.getLogger(name)",
"def get_logger(self, name):\n if not isinstance(name, six.string_types):\n name = \"{}.{}\".format(name._... | [
"0.84206396",
"0.83887017",
"0.82777995",
"0.8252546",
"0.8225331",
"0.8156735",
"0.8119326",
"0.8021441",
"0.79970115",
"0.7963476",
"0.79481715",
"0.7865247",
"0.7851089",
"0.78504586",
"0.78381956",
"0.77661276",
"0.7738144",
"0.7676106",
"0.7650628",
"0.7644962",
"0.76284... | 0.7719111 | 17 |
Return the data file path to store result. | def get_data_file(source_file_name):
# type: (str) -> (str)
path = list(os.path.split(source_file_name))
path[-1] = path[-1].split('_')[0] + '.K'
return os.path.join(*path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return self._data_file",
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def get_data_path():\n\treturn _paths[_DATA_DIRECTORY_KEY]",
"def data_path(self):\n raise NotImplementedError",
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def ... | [
"0.8061998",
"0.80271935",
"0.78542125",
"0.7819732",
"0.77184355",
"0.7651086",
"0.7596013",
"0.7460183",
"0.7458415",
"0.74091625",
"0.7368192",
"0.73656493",
"0.7331445",
"0.7308935",
"0.72883517",
"0.7259342",
"0.72356224",
"0.72046554",
"0.7148827",
"0.71437025",
"0.7143... | 0.0 | -1 |
Gets the event_classifier_code of this BaseEventBody. | def event_classifier_code(self) -> EventClassifierCode:
return self._event_classifier_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_classifier_code(self, event_classifier_code: EventClassifierCode):\n if event_classifier_code is None:\n raise ValueError(\"Invalid value for `event_classifier_code`, must not be `None`\") # noqa: E501\n\n self._event_classifier_code = event_classifier_code",
"def getTypeCode(... | [
"0.6702293",
"0.56719744",
"0.55466104",
"0.546373",
"0.54469144",
"0.53670603",
"0.53670603",
"0.53670603",
"0.53670603",
"0.53596544",
"0.5338883",
"0.53193784",
"0.53050923",
"0.526972",
"0.526972",
"0.526972",
"0.526972",
"0.5269698",
"0.5247862",
"0.5195467",
"0.51818925... | 0.87557083 | 0 |
Sets the event_classifier_code of this BaseEventBody. | def event_classifier_code(self, event_classifier_code: EventClassifierCode):
if event_classifier_code is None:
raise ValueError("Invalid value for `event_classifier_code`, must not be `None`") # noqa: E501
self._event_classifier_code = event_classifier_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_classifier_code(self) -> EventClassifierCode:\n return self._event_classifier_code",
"def __init__(self, event_classifier_code: EventClassifierCode=None, event_date_time: EventDateTime=None): # noqa: E501\n self.swagger_types = {\n 'event_classifier_code': EventClassifierCode,... | [
"0.69499815",
"0.632529",
"0.5930145",
"0.5869521",
"0.5869521",
"0.5542561",
"0.55067146",
"0.5318185",
"0.5290215",
"0.5290215",
"0.5253841",
"0.5253841",
"0.5240324",
"0.52186793",
"0.5216071",
"0.51874185",
"0.51800096",
"0.51304144",
"0.5006048",
"0.49526876",
"0.4920659... | 0.8047717 | 0 |
Gets the event_date_time of this BaseEventBody. | def event_date_time(self) -> EventDateTime:
return self._event_date_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_time(self):\n return self._event_time",
"def event_date(self):\r\n return self.end_date",
"def lastEventTime(self):\n return self._lastEventTime",
"def datetime(self):\n return self._datetime",
"def last_event_time(self) -> str:\n return pulumi.get(self, \"last_... | [
"0.74574095",
"0.6752176",
"0.6703337",
"0.6584806",
"0.6541693",
"0.64581084",
"0.6340981",
"0.63097185",
"0.63097185",
"0.63097185",
"0.6300379",
"0.6268151",
"0.62665874",
"0.6245302",
"0.6234447",
"0.6228861",
"0.6169212",
"0.6169212",
"0.6169212",
"0.6169212",
"0.6167258... | 0.8377439 | 0 |
Sets the event_date_time of this BaseEventBody. | def event_date_time(self, event_date_time: EventDateTime):
if event_date_time is None:
raise ValueError("Invalid value for `event_date_time`, must not be `None`") # noqa: E501
self._event_date_time = event_date_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_time(self, event_time):\n\n self._event_time = event_time",
"def date_time(self, date_time):\n\n self._date_time = date_time",
"def set_datetime(self, date):\n self.date = date",
"def event_timestamp(self, event_timestamp):\n\n self._event_timestamp = event_timestamp",
... | [
"0.7517018",
"0.7205672",
"0.68746305",
"0.64322984",
"0.6293137",
"0.62878615",
"0.61811817",
"0.6165507",
"0.6114253",
"0.60943276",
"0.6080245",
"0.60106504",
"0.59457815",
"0.59372777",
"0.59372777",
"0.5889337",
"0.5840443",
"0.5840443",
"0.5840443",
"0.5840443",
"0.5840... | 0.7558409 | 0 |
Reshape 3D variable into 2D variable | def reshape_var(var):
dims = np.shape(var)
nx = dims[0]
ny = dims[1]
nz = dims[2]
var_2d = var.reshape(nx * ny, nz)
return var_2d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape_tensor3d(self, x):\n if self.dim_ordering == 'th':\n tx = K.reshape(x, (-1, self.nb_filter, self.cols * self.rows))\n else:\n tx = K.reshape(x, (-1, self.cols * self.rows, self.nb_filter))\n tx = K.transpose(tx, (0,2,1))\n if self.cov_mode == 'chann... | [
"0.6848973",
"0.6836927",
"0.6829969",
"0.6646843",
"0.65912175",
"0.64465654",
"0.63915986",
"0.6298965",
"0.6202828",
"0.6198852",
"0.6189575",
"0.6189491",
"0.61888695",
"0.61879003",
"0.6172004",
"0.61597854",
"0.6120508",
"0.6116805",
"0.6114309",
"0.61032337",
"0.608490... | 0.69736993 | 0 |
Get the start and end feature positions as numbers, 1based, endinclusive (so the first two bases are 12). BCBio uses 0based endexclusive positions, so the first two bases are 02. | def get_feature_start_end(feature_record):
return (feature_record.location.start.position+1, feature_record.location.end.position) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPositions(self, base):\n return self.basetoint[base]",
"def getIntPos(self):\n return (int(self.pos[0]),int(self.pos[1]))",
"def get_frame_range(self):\n #self._root = self.get_root_node()\n #startFrame = int(self._root.knob('first_frame').value())\n #endFrame = int(se... | [
"0.61259127",
"0.60753757",
"0.60702485",
"0.6049797",
"0.60203093",
"0.6019387",
"0.60126346",
"0.60044223",
"0.59099317",
"0.5899844",
"0.58711326",
"0.57824624",
"0.5712146",
"0.5698966",
"0.5691967",
"0.563424",
"0.56325626",
"0.5602289",
"0.5581114",
"0.55703086",
"0.556... | 0.71615696 | 0 |
Add custom headers if requested, default authorisation header included in __init__. | def InjectAttrs(self, **kwargs):
if kwargs.get("headers"):
self.headers = {**self.headers, **kwargs.get("headers")}
if kwargs.get("start"):
self.body.update({"start": kwargs.get("start")}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _addAuthenticationToRequestHeader(request, client):\n request.addAuthorization(client.id, client.secret)",
"def add_header(response):\n response.headers['Authorization'] = response\n return response",
"def _add_auth_header(\n self,\n headers: t.Union[None, t.Dict[str,... | [
"0.7353661",
"0.7324151",
"0.71065944",
"0.70654595",
"0.69951355",
"0.69510144",
"0.6773286",
"0.6701749",
"0.6687371",
"0.65706086",
"0.65706086",
"0.65557694",
"0.6518384",
"0.65040374",
"0.6463564",
"0.6418586",
"0.64073306",
"0.6391673",
"0.6383222",
"0.637051",
"0.63705... | 0.0 | -1 |
Create a ProjectedGradientDescent instance. | def __init__(self, model, dtype='float32', default_rand_init=True, **kwargs):
super(ProjectedGradientDescent, self).__init__(model, dtype, **kwargs)
self.feedable_kwargs = ('eps', 'eps_iter', 'y', 'y_target', 'clip_min',
'clip_max')
self.structural_kwar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pgd_create_adv_graph(self, sess, X, y, eps, eta, scope):\n #with tf.variable_scope(scope, reuse = tf.AUTO_REUSE) as scope:\n #temp = set(tf.all_variables())\n init_delta = tf.random_uniform(shape = tf.shape(self.x), minval = -eps, maxval = eps)\n delta = tf.Variable(init_delta, name... | [
"0.54526305",
"0.51554906",
"0.51040447",
"0.5098218",
"0.49897125",
"0.49874538",
"0.492931",
"0.49107775",
"0.49085018",
"0.48810413",
"0.48705968",
"0.4849176",
"0.48166034",
"0.48099804",
"0.48094797",
"0.48006076",
"0.47812736",
"0.47781053",
"0.47624183",
"0.4760126",
"... | 0.5419119 | 1 |
Generate date in RFC822 format | def _rfc822_datetime(self, t=None):
if t is None:
t = datetime.utcnow()
return formatdate(timegm(t.timetuple()), usegmt=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rfc3999(date):\n if not date: return ''\n date = date + datetime.timedelta(seconds = -time.timezone)\n if time.daylight:\n date += datetime.timedelta(seconds = time.altzone)\n return date.strftime('%m-%d-%YT%H:%M:%SZ')",
"def plastic_date():\n return 'Zun, 99 Zun 9999 99:61:61'",
"def... | [
"0.6822165",
"0.6498265",
"0.64973253",
"0.6477146",
"0.64293927",
"0.6391553",
"0.62528574",
"0.62382996",
"0.623358",
"0.6224578",
"0.6122579",
"0.6100064",
"0.6088956",
"0.60434943",
"0.60304725",
"0.601684",
"0.60119104",
"0.59787744",
"0.5967807",
"0.5960612",
"0.5946998... | 0.68210834 | 1 |
Method used to obtain the canonical string used to sign the aws request. | def get_canonical_string(self, request_date, host, endpoint, params, headers, method, payload=""):
request_date_simple = request_date[:8]
params['AWSAccessKeyId'] = self._access_key
params['Timestamp'] = request_date
params['X-Amz-Credential'] = self._get_credential_scope(request_date_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_string_to_sign(self, algorithm, request_date, canonical_request):\n\n credential_scope = self._get_credential_scope(request_date[:8])\n credential_scope = credential_scope[credential_scope.find('/') + 1:]\n\n string_to_sign = [algorithm, request_date, credential_scope]\n\n hashe... | [
"0.6846015",
"0.6731231",
"0.667491",
"0.64305484",
"0.6391785",
"0.6302286",
"0.62220293",
"0.61804056",
"0.61541927",
"0.6071629",
"0.60565513",
"0.604355",
"0.6013004",
"0.5908359",
"0.589369",
"0.58902836",
"0.58849347",
"0.58397555",
"0.57792586",
"0.57484794",
"0.570183... | 0.7506217 | 0 |
Method used to obtain string to sign used for generating the signature. | def get_string_to_sign(self, algorithm, request_date, canonical_request):
credential_scope = self._get_credential_scope(request_date[:8])
credential_scope = credential_scope[credential_scope.find('/') + 1:]
string_to_sign = [algorithm, request_date, credential_scope]
hasher = hashlib.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(self) -> str:\n raise NotImplementedError(\"Please implement algorithm specific sign() method\")",
"def __sign(self, text):\n signature = HMAC.new(self.sign_key, text.encode('utf-8'), SHA256).digest()\n return base64.standard_b64encode(signature)",
"def create_signature(se... | [
"0.7251439",
"0.7210858",
"0.70219463",
"0.69491535",
"0.69241947",
"0.6920218",
"0.68707025",
"0.68668616",
"0.68524265",
"0.6809875",
"0.6745836",
"0.6579323",
"0.65052414",
"0.64820176",
"0.6458968",
"0.64129406",
"0.63713336",
"0.6367581",
"0.6336072",
"0.6287036",
"0.627... | 0.61664903 | 34 |
Method used to sign a given request. It returns the signed url that can be used for http request. | def sign_request(self, host, endpoint, params, headers, method, payload="", time=time):
request_date = time.strftime('%Y%m%dT%H%M%SZ', time.gmtime())
signature = self.calculate_signature(request_date, host, endpoint, params, headers, method, payload, time)
canonical_query = [
aws_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sign_request(secret, method, url, timestamp, content_hash=None):\n message = f'{timestamp}{url}{method}{content_hash}'\n\n return hmac.new(secret.encode('utf-8'), message.encode('utf-8'), hashlib.sha512).hexdigest()",
"def sign_url(self, url, expiration=None):\n if not expiration:\n ... | [
"0.67683136",
"0.6737258",
"0.67081034",
"0.6659473",
"0.6515048",
"0.6442675",
"0.64291984",
"0.6335722",
"0.6208652",
"0.61549515",
"0.61477005",
"0.61239326",
"0.6045519",
"0.60326856",
"0.59893775",
"0.59644914",
"0.59600127",
"0.59396875",
"0.5934094",
"0.59250677",
"0.5... | 0.68016744 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.