query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Discover if the origins and destinations include valid fields we can use in the Route analysis. Any fields with the correct names and data types matching valid fields recognized by the Route solver for the Stops input can be used in the analysis. Compare the input origins and destinations fields with the list of suppor... | def _populate_input_data_transfer_fields(self):
# Valid fields for the Route Stops input are described here:
# https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/route-input-data-types.htm
# Do not transfer RouteName or Sequence as these are explicitly controlled by this tool. Do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _insert_stops_one_to_one(self): # pylint: disable=too-many-locals\r\n # Use an insertCursor to insert Stops into the Route analysis\r\n destinations = {}\r\n destination_rows = []\r\n with self.rt_solver.insertCursor(\r\n arcpy.nax.RouteInputDataType.Stops,\r\n ... | [
"0.6113399",
"0.5643113",
"0.54353887",
"0.5379565",
"0.5359705",
"0.53044266",
"0.5218753",
"0.5165528",
"0.51130545",
"0.5098658",
"0.5056272",
"0.5042018",
"0.50327575",
"0.5018349",
"0.50022423",
"0.49981675",
"0.49830243",
"0.49737117",
"0.49564588",
"0.4953842",
"0.4924... | 0.69479537 | 0 |
Solve the Route in chunks and postprocess the results. | def solve_route_in_parallel(self):
# Validate Route settings. Essentially, create a dummy Route class instance and set up the
# solver object to ensure this at least works. Do this up front before spinning up a bunch of parallel processes
# that are guaranteed to all fail.
self._vali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_route(inputs, chunk):\r\n rt = Route(**inputs)\r\n if inputs[\"pair_type\"] is helpers.PreassignedODPairType.one_to_one:\r\n rt.logger.info(f\"Processing origins OID {chunk[0]} to {chunk[1]} as job id {rt.job_id}\")\r\n elif inputs[\"pair_type\"] is helpers.PreassignedODPairType.many_to_m... | [
"0.6792837",
"0.5855412",
"0.5633914",
"0.548248",
"0.54527795",
"0.532048",
"0.53184384",
"0.52948433",
"0.52264017",
"0.5213624",
"0.51902413",
"0.51709",
"0.51507914",
"0.5139252",
"0.51372004",
"0.5116195",
"0.5072712",
"0.507154",
"0.50373584",
"0.50307095",
"0.5008679",... | 0.6839286 | 0 |
Merge the routes calculated in each separate process into a single feature class. Create an empty final output feature class and populate it using InsertCursor, as this tends to be faster than using the Merge geoprocessing tool. | def _post_process_route_fcs(self):
# Create the final output feature class
desc = arcpy.Describe(self.route_fcs[0])
helpers.run_gp_tool(
LOGGER,
arcpy.management.CreateFeatureclass, [
os.path.dirname(self.out_routes),
os.path.basenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _export_to_feature_class(self, chunk_definition):\r\n # Make output gdb\r\n rt_workspace = self._create_output_gdb()\r\n\r\n # Export routes\r\n output_routes = os.path.join(rt_workspace, f\"Routes_{chunk_definition[0]}_{chunk_definition[1]}\")\r\n self.logger.debug(f\"Export... | [
"0.60113615",
"0.5859844",
"0.5772984",
"0.5617712",
"0.5504301",
"0.5316391",
"0.5313953",
"0.5273943",
"0.5268024",
"0.5257252",
"0.52431345",
"0.52355766",
"0.52347904",
"0.52220434",
"0.52174675",
"0.5180655",
"0.5177188",
"0.5174838",
"0.51718193",
"0.5159236",
"0.511246... | 0.71977544 | 0 |
Read arguments passed in via subprocess and run the parallel Route. This script is intended to be called via subprocess via the solve_large_route_pair_analysis.py module, which does essential preprocessing and validation. Users should not call this script directly from the command line. We must launch this script via s... | def launch_parallel_rt_pairs():
# Create the parser
parser = argparse.ArgumentParser(description=globals().get("__doc__", ""), fromfile_prefix_chars='@')
# Define Arguments supported by the command line utility
# --pair-type parameter
help_string = "The type of origin-destination pair assig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_route_in_parallel(self):\r\n # Validate Route settings. Essentially, create a dummy Route class instance and set up the\r\n # solver object to ensure this at least works. Do this up front before spinning up a bunch of parallel processes\r\n # that are guaranteed to all fail.\r\n ... | [
"0.64769953",
"0.62038994",
"0.57405895",
"0.554428",
"0.55252844",
"0.551435",
"0.55140823",
"0.55098575",
"0.54549307",
"0.5444846",
"0.54388684",
"0.54316586",
"0.5404963",
"0.53763914",
"0.5359437",
"0.5330171",
"0.5305152",
"0.53005004",
"0.53004366",
"0.5288501",
"0.527... | 0.68828976 | 0 |
Get the tokenized format_string. Tokenizing is resource intensive so we only do it once and cache it | def tokens(self, format_string):
if format_string not in self.format_string_cache:
tokens = list(re.finditer(self.reg_ex, format_string))
self.format_string_cache[format_string] = tokens
return self.format_string_cache[format_string] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_format(self, token):\n if token in self._formats:\n return self._formats[token]\n\n if self._style is None:\n result = self._get_format_from_document(token, self._document)\n else:\n result = self._get_format_from_style(token, self._style)\n\n s... | [
"0.7031436",
"0.5833799",
"0.5587852",
"0.55370355",
"0.55229795",
"0.5514945",
"0.5489987",
"0.5487361",
"0.5463768",
"0.5454155",
"0.54331946",
"0.53677803",
"0.5347152",
"0.5261837",
"0.5218769",
"0.52003187",
"0.5194947",
"0.51801944",
"0.5157241",
"0.5129288",
"0.5112594... | 0.7236307 | 0 |
Parses the format_string and returns a set of color names. | def get_color_names(self, format_string):
names = set()
# Tokenize the format string and process them
for token in self.tokens(format_string):
if token.group("command"):
name = dict(parse_qsl(token.group("command"))).get("color")
if (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reformatColor(self, colorStr):\n if type(colorStr) is str:\n if colorStr.startswith('#'):\n colorStr = colorStr.replace('#', '')\n else:\n raise Exception('color is not hex format')\n r = int(colorStr[:2], 16)\n g = int(colorStr[2... | [
"0.61174923",
"0.60446614",
"0.60343224",
"0.6032042",
"0.5956374",
"0.5867158",
"0.5859119",
"0.5769622",
"0.57691973",
"0.57649046",
"0.5756081",
"0.5748874",
"0.5739813",
"0.5683501",
"0.5625979",
"0.5616915",
"0.5559172",
"0.55575323",
"0.5540814",
"0.5540103",
"0.5533907... | 0.8132206 | 0 |
Parses the format_string and returns a set of placeholders. | def get_placeholders(self, format_string):
placeholders = set()
# Tokenize the format string and process them
for token in self.tokens(format_string):
if token.group("placeholder"):
placeholders.add(token.group("key"))
elif token.group("command"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_placeholder_formats_list(self, format_string):\n placeholders = []\n # Tokenize the format string and process them\n for token in self.tokens(format_string):\n if token.group(\"placeholder\"):\n placeholders.append((token.group(\"key\"), token.group(\"format\"... | [
"0.7910855",
"0.694886",
"0.64524835",
"0.6108374",
"0.60248744",
"0.601687",
"0.60016334",
"0.5864088",
"0.57037616",
"0.55861354",
"0.55645305",
"0.554253",
"0.5510738",
"0.55103034",
"0.5497989",
"0.5479562",
"0.5358258",
"0.5325262",
"0.5298705",
"0.5236709",
"0.5222342",... | 0.7691594 | 1 |
Parses the format_string and returns a list of tuples (placeholder, format). | def get_placeholder_formats_list(self, format_string):
placeholders = []
# Tokenize the format string and process them
for token in self.tokens(format_string):
if token.group("placeholder"):
placeholders.append((token.group("key"), token.group("format")))
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_placeholder_formats(self, format_string, placeholder_formats):\n # Tokenize the format string and process them\n output = []\n for token in self.tokens(format_string):\n if (\n token.group(\"placeholder\")\n and (not token.group(\"format\"))\... | [
"0.65669346",
"0.62842053",
"0.6130616",
"0.61288065",
"0.60436875",
"0.5937322",
"0.5901326",
"0.58831894",
"0.5852524",
"0.57953036",
"0.5765644",
"0.57541496",
"0.57023305",
"0.56520545",
"0.56048083",
"0.5603498",
"0.5459637",
"0.5429871",
"0.5376852",
"0.53540975",
"0.53... | 0.784211 | 0 |
Update a format string adding formats if they are not already present. | def update_placeholder_formats(self, format_string, placeholder_formats):
# Tokenize the format string and process them
output = []
for token in self.tokens(format_string):
if (
token.group("placeholder")
and (not token.group("format"))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddFormat(self, format):\n self._legacy = False\n if format:\n self._format = format",
"def addIfMissing(self, format):\n self.setdefault(format.name, format)",
"def _translate_fmts(self):\n fmt_info = []\n fmt_append = fmt_info.append\n \n isvalid = self._is_v... | [
"0.64630926",
"0.62091905",
"0.5800091",
"0.5796576",
"0.5712765",
"0.57114947",
"0.57108057",
"0.55900645",
"0.5558063",
"0.55575746",
"0.543823",
"0.5434389",
"0.5409675",
"0.54084057",
"0.5407691",
"0.53960705",
"0.5389524",
"0.5365024",
"0.536046",
"0.53591377",
"0.534718... | 0.6789656 | 0 |
Parse the format string into blocks containing Literals, Placeholders etc that we can cache and reuse. | def build_block(self, format_string):
first_block = Block(None, py3_wrapper=self.py3_wrapper)
block = first_block
# Tokenize the format string and process them
for token in self.tokens(format_string):
value = token.group(0)
if token.group("block_start"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse(self, fmtstr):\n def _match_brace(string, start_pos, pair='[]'):\n \"\"\"Pairing brackets (used internally in _parse method)\"\"\"\n depth = 1\n if string[start_pos] != pair[0]:\n return None\n for index, char in enumerate(string[start_po... | [
"0.64509463",
"0.61767745",
"0.6141088",
"0.6093478",
"0.59834534",
"0.59391457",
"0.5813534",
"0.5672864",
"0.565769",
"0.5619488",
"0.5604256",
"0.5531012",
"0.5529596",
"0.55168927",
"0.54857767",
"0.545964",
"0.5454546",
"0.5443225",
"0.54375136",
"0.54195976",
"0.5334066... | 0.73439676 | 0 |
Format a string, substituting place holders which can be found in param_dict, attributes of the supplied module, or provided via calls to the attr_getter function. | def format(
self,
format_string,
module=None,
param_dict=None,
force_composite=False,
attr_getter=None,
):
if param_dict is None:
param_dict = {}
# if the processed format string is not in the cache then create it.
if format_string... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_param(string, param, value, param_format=None):\n\n if param_format == \"json\":\n return sub(r\"(?P<json_replacement>\\\"%s\\\"\\s*:\\s*)\\\"\\s*\\\"\" %\n escape(str(param)), \"\\\\1\\\"%s\\\"\" % value, string)\n elif param_format == \"h... | [
"0.5990877",
"0.59723574",
"0.57197136",
"0.5632017",
"0.56243557",
"0.5579166",
"0.54825616",
"0.5474345",
"0.5385853",
"0.5365595",
"0.5335425",
"0.5315145",
"0.5266371",
"0.5259829",
"0.52348405",
"0.52140254",
"0.5195806",
"0.5177217",
"0.5099359",
"0.5097019",
"0.5095286... | 0.6764331 | 0 |
set integer value from commands | def _set_int(self, commands, name):
if name in commands:
try:
value = int(commands[name])
setattr(self, name, value)
except ValueError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setInteger(self, value):",
"def setInteger(self, value):",
"def set_num(self, num):\n self.cmd_num = num",
"def setInteger(self, value: int):\n self.value = value",
"def setInt(self, addr: ghidra.program.model.address.Address, value: int) -> None:\n ...",
"def getint(self, strcom... | [
"0.71163434",
"0.71163434",
"0.67835045",
"0.62937844",
"0.61526585",
"0.6076695",
"0.6070734",
"0.6059233",
"0.59684515",
"0.5945891",
"0.5915541",
"0.58779633",
"0.5800634",
"0.5786643",
"0.5786482",
"0.5768864",
"0.57324964",
"0.5721998",
"0.56996304",
"0.5692422",
"0.5685... | 0.8104841 | 0 |
create a new sub block to the current block and return it. the sub block is added to the current block. | def new_block(self):
child = Block(self, py3_wrapper=self.py3_wrapper)
self.add(child)
return child | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_new_block(self):\n block = BasicBlock()\n self.blocks.append(block)\n return block",
"def newblock(self, parent=None):\n block = ControlBlock()\n self.blocks.add(block)\n if parent:\n parent.add_child(block)\n return block",
"def newblock(self... | [
"0.7300657",
"0.7137283",
"0.700307",
"0.67426383",
"0.65247345",
"0.64328855",
"0.64139366",
"0.6404519",
"0.6204402",
"0.61623967",
"0.6048261",
"0.5963573",
"0.59493285",
"0.5928946",
"0.5925224",
"0.5924873",
"0.59158665",
"0.5912983",
"0.5904347",
"0.58974856",
"0.586256... | 0.73637503 | 0 |
Gives a pawn on the position x,y or returns empty if none exists | def getPawn(self,x,y):
if(self.gameState[x,y]==EMPTY):
return
return Pawn(x,y,self.gameState[x,y]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_a_pawn(self, player, pos_x, pos_y)-> bool:\n if not pos_x in range(0, len(self.grid)) \\\n or not pos_y in range(0, len(self.grid)):\n return False\n if self.grid[pos_x][pos_y].color is None:\n for index_x in range(-1, 2):\n for index_y in range(-1,... | [
"0.6292175",
"0.628745",
"0.61434907",
"0.61041254",
"0.6023498",
"0.60125977",
"0.59928966",
"0.5978027",
"0.5957675",
"0.59455156",
"0.5943654",
"0.5890515",
"0.58391374",
"0.5811578",
"0.5807527",
"0.57815",
"0.57768774",
"0.57580405",
"0.5754607",
"0.57248765",
"0.5722037... | 0.8193444 | 0 |
needed for search Gets the number pawns on the board of a color. | def count(self,color):
count = 0
for y in range(0,HEIGHT):
for x in range(0,WIDTH):
if(self.gameState[x,y]==color):
count+=1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_colors(board, color):\n n = 0\n for cell in board:\n if cell == color:\n n += 1\n elif cell == cinv(color):\n n -= 1\n return n",
"def sum_color(self, board, color):\n sum_of_color = 0\n for i in range(board.size):\n for j in range(b... | [
"0.71357477",
"0.67711115",
"0.6714085",
"0.6677235",
"0.65223455",
"0.6421733",
"0.63733757",
"0.63176304",
"0.6308519",
"0.6277486",
"0.62195385",
"0.6203734",
"0.6190637",
"0.6115216",
"0.61102915",
"0.6102846",
"0.60874075",
"0.6083563",
"0.60525626",
"0.6047749",
"0.6038... | 0.6866677 | 1 |
Tells if a position is in the game bounds | def inBounds(self,pos):
return ((pos.x<WIDTH) & (pos.x>=0) & (pos.y<HEIGHT) & (pos.y>=0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_bounds(self, position):\n row, col = position\n return ((row >= 0 and row < self.height) and\n (col >= 0 and col < self.width))",
"def is_in_bounds(pos):\n return PLAYFIELD_PADDING[0] < pos[0] < PLAYFIELD_PADDING[0] +\\\n BLOCK_NUM_WIDTH * Block.WIDTH and PLA... | [
"0.8121233",
"0.78420454",
"0.783356",
"0.7815986",
"0.77785796",
"0.77391034",
"0.7499602",
"0.74738336",
"0.7412133",
"0.7395001",
"0.7287691",
"0.7282496",
"0.72665375",
"0.72362554",
"0.7205017",
"0.7162476",
"0.71581644",
"0.71300095",
"0.71250474",
"0.7091146",
"0.70606... | 0.8067338 | 1 |
Takes a pawn and returns it's relative move position | def movePos(self,p,intMove):
return pos(p.pos.x-(intMove*self.intPlayer(p.color)),p.pos.y+self.intPlayer(p.color)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_pawn(pos, game):\n #Convert coordinates to row and column\n row = int(pos[1]//(SQUARESIZE+FENCEWIDTH))\n col = int(pos[0]//(SQUARESIZE+FENCEWIDTH))\n #Make move\n game.move_pawn(game.get_player_turn(), (col,row))",
"def get_move(board, player):\r\n row, col = 0, 0\r\n return row, co... | [
"0.70455617",
"0.68026656",
"0.6782019",
"0.6533234",
"0.6489556",
"0.64045006",
"0.63270336",
"0.6322109",
"0.6290889",
"0.6268482",
"0.6268482",
"0.62472296",
"0.6150574",
"0.6125518",
"0.61029345",
"0.60926723",
"0.6087858",
"0.60839784",
"0.60775626",
"0.6045745",
"0.6034... | 0.6875913 | 1 |
Transforms message into PlatformMessage object | def parse(cls, message):
if isinstance(message, PlatformMessage):
inst = PlatformMessage.parse(message.serialize())
return inst
inst = PlatformMessage()
if message is not None:
assert isinstance(message, (list, tuple)), "Message is expected to be a list ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_to_python(self, raw_message):\n return self.Message(self, raw_message)",
"def get_interface(cls, message):\r\n if message is not None:\r\n if isinstance(message, PlatformMessage):\r\n return message.interface\r\n assert isinstance(message, (list, tup... | [
"0.66961044",
"0.61725485",
"0.61444753",
"0.6085341",
"0.60676634",
"0.59354925",
"0.5832414",
"0.58319014",
"0.58083576",
"0.57996356",
"0.5798074",
"0.5764045",
"0.57599103",
"0.5742993",
"0.5738603",
"0.57220566",
"0.5719687",
"0.5718132",
"0.57123685",
"0.5708723",
"0.57... | 0.7441321 | 0 |
Return sender of serialized message | def get_sender(cls, message):
if message is not None:
if isinstance(message, PlatformMessage):
return message.sender
assert isinstance(message, (list, tuple)), "Message is expected to be a list or a tuple"
assert len(message) >= 4, "Message's length expec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_sender_id(self):\n return self.__sender_id",
"def get_sender_email(message):\r\n message_headers = message['payload']['headers']\r\n for header in message_headers:\r\n if header['name'] == 'From':\r\n return header['value']",
"def sender(self):\n key, alt = ('Sen... | [
"0.7114796",
"0.6647468",
"0.6598164",
"0.6566656",
"0.65436935",
"0.65187633",
"0.65110844",
"0.65012693",
"0.6501094",
"0.64227396",
"0.640637",
"0.6369679",
"0.6141742",
"0.6132606",
"0.61057776",
"0.6090527",
"0.6054466",
"0.6002109",
"0.5983544",
"0.5983544",
"0.59530574... | 0.7315821 | 0 |
Return args of serialized message | def get_args(cls, message):
if message is not None:
if isinstance(message, PlatformMessage):
return message.args
assert isinstance(message, (list, tuple)), "Message is expected to be a list or a tuple"
assert len(message) >= 4, "Message's length expected ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _func_serialize(self, args):\n return args",
"def func_deserialize(self, args): # pragma: no cover\n if len(args) == 0:\n return []\n x = eval(args.decode(\"utf-8\"))\n return x",
"def toArgs(self):\n # FIXME - undocumented exception\n post_args = self.... | [
"0.6681042",
"0.6476981",
"0.6381497",
"0.6343124",
"0.63172007",
"0.6315931",
"0.6190981",
"0.61659044",
"0.61323375",
"0.61323375",
"0.61323375",
"0.6127745",
"0.60635227",
"0.6060811",
"0.5984353",
"0.59649163",
"0.5958156",
"0.593882",
"0.59370756",
"0.5936084",
"0.591632... | 0.7136301 | 0 |
Return kwargs of serialized message | def get_kwargs(cls, message):
if message is not None:
if isinstance(message, PlatformMessage):
return message.kwargs
assert isinstance(message, (list, tuple)), "Message is expected to be a list or a tuple"
assert len(message) >= 4, "Message's length expec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toArgs(self):\n # FIXME - undocumented exception\n post_args = self.toPostArgs()\n kvargs = {}\n for k, v in post_args.items():\n if not k.startswith('openid.'):\n raise ValueError(\n 'This message can only be encoded as a POST, because i... | [
"0.6532804",
"0.63777333",
"0.6250696",
"0.61953866",
"0.60052204",
"0.60052204",
"0.59744835",
"0.59685344",
"0.59614235",
"0.59334373",
"0.59222966",
"0.5830837",
"0.5793464",
"0.579085",
"0.57832605",
"0.57062554",
"0.5704295",
"0.57024705",
"0.56911284",
"0.5642286",
"0.5... | 0.721355 | 0 |
Returns conversation for a thread | def conversation(self, thread):
assert isinstance(thread, int) and 0 <= thread < len(self._threads), "Thread {} don't exists at channel {}!".\
format(thread, self.name)
return self._threads[thread]["conversation"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_thread_for_message(id):\n query = 'SELECT thread_id from messages WHERE id like %s'\n return __perform__(query, (id,), method='fetchone')",
"def find_all_messages_in_thread_for_person(cnx: db_connector, thread_id: int, is_singlechat: bool):\n result = []\n cursor = cnx.cursor(buffered... | [
"0.65898234",
"0.6572362",
"0.6492414",
"0.64143395",
"0.6396454",
"0.60996646",
"0.60811704",
"0.6057928",
"0.58519685",
"0.57067835",
"0.5651671",
"0.5620204",
"0.55983543",
"0.5575817",
"0.55702025",
"0.55671215",
"0.55500007",
"0.5483425",
"0.54719275",
"0.5438706",
"0.54... | 0.8358802 | 0 |
Checks whether or not reply to message m2 should be faked If m1's field is None then m2's field value is not compared at all | def _fake_message_compare(m1, m2):
m1 = m1.serialize()
m2 = m2.serialize()
diff = False
for i in range(len(m1)):
if m1[i] is None:
continue
if m1[i] != m2[i]:
diff = True
break
return not diff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNoneAssignment(self):\n class MyMessage(messages.Message):\n\n my_field = messages.StringField(1)\n\n m1 = MyMessage()\n m2 = MyMessage()\n m2.my_field = None\n self.assertEquals(m1, m2)",
"def __eq__(self, other):\n if not isinstance(other, SendMmsReq... | [
"0.61221015",
"0.60199493",
"0.5698596",
"0.56491196",
"0.56256944",
"0.55935615",
"0.5585704",
"0.55634177",
"0.55492973",
"0.55470234",
"0.55111665",
"0.5495307",
"0.546077",
"0.5453699",
"0.5440305",
"0.5392359",
"0.5371638",
"0.5361735",
"0.5357879",
"0.53478",
"0.5341549... | 0.7252573 | 0 |
Returns running state for specified platform | def is_running(self, platform):
if platform not in self._platforms:
raise ValueError("Platform {} is not registered".format(platform))
return self._platforms[platform].running | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n data = self.coordinator.data[self._host_name][self._node_name][self._vm_id]\n if data[\"status\"] == \"running\":\n return STATE_ON\n return STATE_OFF",
"def running_state(self) -> int | None:\n return self.cluster.get(\"running_state\")",
"def running(... | [
"0.61530626",
"0.60770965",
"0.6040421",
"0.60027874",
"0.5839394",
"0.58060783",
"0.5787307",
"0.57715446",
"0.57025546",
"0.56921524",
"0.56680083",
"0.55934256",
"0.55586237",
"0.553357",
"0.5515652",
"0.55087674",
"0.5503442",
"0.5490447",
"0.5443907",
"0.54368734",
"0.54... | 0.6958679 | 0 |
Checks whether all platforms are running or not | def all_is_running(self):
return all(p.running for p in self._platforms.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_platform():\n system = platform.system()\n distro = platform.platform()\n is_raspberry_pi = False\n try:\n info = open(\"/proc/cpuinfo\").read()\n except FileNotFoundError:\n is_raspberry_pi = False\n else:\n # bcm2708: Raspberry Pi 1\n # bcm2709: Raspberry P... | [
"0.7448283",
"0.7354531",
"0.69025147",
"0.68859076",
"0.6782263",
"0.6772269",
"0.67584515",
"0.6750433",
"0.6750433",
"0.67330426",
"0.6725543",
"0.6633071",
"0.6604187",
"0.65855706",
"0.65599746",
"0.6514661",
"0.65100974",
"0.6507308",
"0.650659",
"0.6505434",
"0.643089"... | 0.7654313 | 0 |
Checks whether all platforms are stopped or not | def all_is_stopped(self):
return all(not p.running for p in self._platforms.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emergency_stop(self):\r\n eprint(\"Emergency platforms stop\")\r\n stop_list = []\r\n for p in self._platforms:\r\n stop_list.append(self._platforms[p])\r\n\r\n success = True\r\n while len(stop_list) > 0: # NOTE: stop platforms in reverse order\r\n p = ... | [
"0.75852925",
"0.7146642",
"0.6602631",
"0.65657175",
"0.628147",
"0.62783736",
"0.61895704",
"0.61452276",
"0.60707706",
"0.60059714",
"0.5987051",
"0.5946374",
"0.5929576",
"0.5919849",
"0.5919849",
"0.5917849",
"0.58654445",
"0.58415127",
"0.582378",
"0.58181137",
"0.57904... | 0.82884616 | 0 |
Registers new platform (or at least tries). If new platform depends on platforms that were not registered yet then registration of this platform would be deferred. Registration would be continued after registering all the platforms that this platform depends on | def register_platform(self, factory, kind, parent=None, wait=None):
self._try_register_platform(factory, kind, parent, wait) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _register_hardware_platform(\n hass: HomeAssistant, integration_domain: str, platform: HardwareProtocol\n) -> None:\n if integration_domain == DOMAIN:\n return\n if not hasattr(platform, \"async_info\"):\n raise HomeAssistantError(f\"Invalid hardware platform {platform}\")\n has... | [
"0.71603966",
"0.7015166",
"0.6779148",
"0.65924436",
"0.6380313",
"0.6261706",
"0.6097711",
"0.5934751",
"0.58920646",
"0.5801316",
"0.5635861",
"0.56350684",
"0.5605743",
"0.55982506",
"0.5503871",
"0.5495337",
"0.5468214",
"0.54491985",
"0.5402476",
"0.536305",
"0.5344545"... | 0.7204478 | 0 |
Runs through platforms which registration were deferred and tries to register them again | def _check_awaiting(self):
# TODO: check for wait loops
for w in list(self._awaiting.values()):
self._try_register_platform(w["instance"], w["kind"], w["parent"], w["wait"], awaiting=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_process_hardware_platforms(hass: HomeAssistant) -> None:\n hass.data[DOMAIN][\"hardware_platform\"] = {}\n\n await async_process_integration_platforms(hass, DOMAIN, _register_hardware_platform)",
"def _try_register_platform(self, factory, kind, parent, wait, awaiting=False):\r\n name... | [
"0.667766",
"0.6472627",
"0.64608395",
"0.6125786",
"0.6103623",
"0.585542",
"0.5823268",
"0.5784557",
"0.57517254",
"0.56858265",
"0.5681627",
"0.5622832",
"0.5608007",
"0.55615294",
"0.5553192",
"0.55258495",
"0.5492156",
"0.54448736",
"0.54345196",
"0.5424958",
"0.53986436... | 0.6857937 | 0 |
Unregisters platform instance. Can recursively unregister all instance's nested platforms. If recursion is not used and by the instant unregister is called there is still nested platforms then exception would be rised | def unregister_platform_instance(self, instance, recursive=False):
platform_to_remove = None
for k, v in self._platforms.items():
if v == instance:
platform_to_remove = k
break
if platform_to_remove is None:
raise ValueError("No plat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unregister_platform(self, name, recursive=False):\r\n if name in dict(self._platforms):\r\n self.unregister_platform_instance(self._platforms[name], recursive)",
"def unregister_platform(self, platform_uuid):\n return self.do_rpc('unregister_platform', platform_uuid=platform_uuid)",
... | [
"0.8009664",
"0.6706928",
"0.6103871",
"0.5728736",
"0.57112795",
"0.568827",
"0.5645297",
"0.5567026",
"0.5547235",
"0.55387",
"0.55205977",
"0.5519004",
"0.5469608",
"0.54393387",
"0.5368441",
"0.5361209",
"0.53546786",
"0.53507906",
"0.5317688",
"0.52915245",
"0.5263275",
... | 0.8235111 | 0 |
Creates Platform's instance Should be called when conditions for creation this very instance are met platforms that this instance depends on should be already registered | def finish_registration(self):
base_platform = self._args.get("base_platform", None)
lcls = {}
try:
exec("from platforms.{}.main import RootClass as rc; cl = rc".format(base_platform), globals(), lcls)
except ModuleNotFoundError as e:
eprint("Package 'platfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_platform(self, id):\n p = Platform(self, id, [])\n self.platforms[id] = p\n return p",
"def platform_init(self):\n if isinstance(self.imu, MockImuController) or isinstance(self.pwm_controller, MockPWMController):\n print(\"Mock components detected, creating mock ant... | [
"0.6996833",
"0.6901165",
"0.6643392",
"0.66429996",
"0.6620305",
"0.66013455",
"0.65052664",
"0.64866644",
"0.6392875",
"0.6308356",
"0.6216505",
"0.6207374",
"0.61393857",
"0.6117521",
"0.60896856",
"0.60258096",
"0.6019131",
"0.6019086",
"0.60079926",
"0.5970026",
"0.59591... | 0.706969 | 0 |
Coverage summary tupple with amount of cases and covered cases May be used to determine coverage percentage | def coverage(self):
return 0, 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_project_test_coverage(self) -> None:\n print_statistics = {}\n total_number_columns = 0\n number_columns_without_tests = 0\n\n for model_name in self.dbt_tests.keys():\n columns = self.dbt_tests[model_name]\n\n model_number_columns = 0\n model_co... | [
"0.71685416",
"0.68137187",
"0.6776906",
"0.6677319",
"0.6650848",
"0.6639017",
"0.6626381",
"0.65998113",
"0.6589576",
"0.65476686",
"0.6533306",
"0.6496852",
"0.6492893",
"0.64699256",
"0.64314204",
"0.64311635",
"0.64148486",
"0.63928735",
"0.6356816",
"0.63496864",
"0.633... | 0.7372552 | 0 |
Encodes the input sequence and returns the hidden state from the last step of the encoder RNN. | def encode(self, x):
_, hid = self.encoder(x) #All RNN classes output a tuple of 2 objects: the output of the RNN first and the hidden state from the last item in
return hid #the input sequence second. We're only interested in the hidden state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encode(self):\n with tf.variable_scope('passage_encoding'):\n self.sep_p_encodes, _ = rnn('bi-lstm', self.p_emb, self.p_length, self.hidden_size)\n with tf.variable_scope('question_encoding'):\n self.sep_q_encodes, _ = rnn('bi-lstm', self.q_emb, self.q_length, self.hidden_s... | [
"0.683423",
"0.6820723",
"0.6807832",
"0.675225",
"0.66331315",
"0.66327035",
"0.65157163",
"0.6451546",
"0.643727",
"0.6415194",
"0.6381192",
"0.6375881",
"0.6340776",
"0.6330177",
"0.6329643",
"0.63056594",
"0.62932295",
"0.6283715",
"0.62812126",
"0.6278949",
"0.6253341",
... | 0.7965193 | 0 |
Start a web app at the given port for serving the jigna view for the given template and context. | def start_web_app(template, context, port=8000):
from tornado.ioloop import IOLoop
from jigna.web_app import WebApp
ioloop = IOLoop.instance()
app = WebApp(template=template, context=context)
app.listen(port)
print 'Starting the web app on port %s ...' % port
ioloop.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serve(port):\n app.run(host='0.0.0.0', port=port, debug=True)",
"def run():\n return render_template('index.html')",
"def serve() -> None:\n uvicorn.run(\n \"bartender.web.application:get_app\",\n workers=settings.workers_count,\n host=settings.host,\n port=settings.por... | [
"0.6824245",
"0.6593554",
"0.65677285",
"0.65660465",
"0.6564316",
"0.6545133",
"0.65020066",
"0.6479876",
"0.6479806",
"0.6458077",
"0.64405406",
"0.64051074",
"0.6399282",
"0.6394062",
"0.63920164",
"0.63898516",
"0.6380909",
"0.6349641",
"0.62751275",
"0.62736714",
"0.6271... | 0.8381516 | 0 |
Builds a differentiable augmentation pipeline based on its class type. | def build_aug(aug_type, **kwargs):
if aug_type not in _AUGMENTATIONS:
raise ValueError(f'Invalid augmentation type: `{aug_type}`!\n'
f'Types allowed: {list(_AUGMENTATIONS)}.')
return _AUGMENTATIONS[aug_type](**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_pipeline(preprocessors, classifier):\n if isinstance(preprocessors, list):\n # support only preprocessing of lenght 2\n return make_pipeline(preprocessors[0], preprocessors[1], classifier)\n if preprocessors is None:\n return make_pipeline(classifier)\n\n return make_pipelin... | [
"0.618366",
"0.57090163",
"0.554121",
"0.55004793",
"0.5495945",
"0.54675126",
"0.54427373",
"0.5428508",
"0.53878695",
"0.5384956",
"0.5383808",
"0.53803486",
"0.53243446",
"0.5311842",
"0.5292812",
"0.5282065",
"0.5245183",
"0.52103126",
"0.5209436",
"0.5195009",
"0.5174649... | 0.5901364 | 1 |
Test the functionality of the KafkaGroupIODataset when the existing consumer group reads data from a new topic. | def test_kafka_group_io_dataset_primary_cg_new_topic():
dataset = tfio.experimental.streaming.KafkaGroupIODataset(
topics=["key-test"],
group_id="cgtestprimary",
servers="localhost:9092",
configuration=[
"session.timeout.ms=7000",
"max.poll.interval.ms=8000",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_group_io_dataset_resume_primary_cg_new_topic():\n import tensorflow_io.kafka as kafka_io\n\n # Write new messages to the topic\n for i in range(10, 100):\n message = f\"D{i}\"\n kafka_io.write_kafka(message=message, topic=\"key-test\")\n # Read only the newly sent 90 messag... | [
"0.7862941",
"0.73936385",
"0.70595884",
"0.68379927",
"0.68281376",
"0.6740333",
"0.6714614",
"0.6704045",
"0.6651035",
"0.6603814",
"0.64650786",
"0.6370465",
"0.6314179",
"0.60142636",
"0.5972484",
"0.5948897",
"0.5936028",
"0.5844628",
"0.5811538",
"0.58090895",
"0.580786... | 0.76525635 | 1 |
Test the functionality of the KafkaGroupIODataset when the consumer group is yet to catch up with the newly added messages only (Instead of reading from the beginning). | def test_kafka_group_io_dataset_resume_primary_cg():
import tensorflow_io.kafka as kafka_io
# Write new messages to the topic
for i in range(10, 100):
message = f"D{i}"
kafka_io.write_kafka(message=message, topic="key-partition-test")
# Read only the newly sent 90 messages
dataset =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_group_io_dataset_resume_primary_cg_new_topic():\n import tensorflow_io.kafka as kafka_io\n\n # Write new messages to the topic\n for i in range(10, 100):\n message = f\"D{i}\"\n kafka_io.write_kafka(message=message, topic=\"key-test\")\n # Read only the newly sent 90 messag... | [
"0.76577485",
"0.73002553",
"0.6971321",
"0.6940536",
"0.6914675",
"0.6828621",
"0.6707299",
"0.6647323",
"0.6454408",
"0.64065754",
"0.62465376",
"0.6183665",
"0.61425513",
"0.6138433",
"0.6063199",
"0.6052937",
"0.60468554",
"0.5998803",
"0.5994782",
"0.59467036",
"0.592855... | 0.7597071 | 1 |
Test the functionality of the KafkaGroupIODataset when the consumer group is yet to catch up with the newly added messages only (Instead of reading from the beginning) from the new topic. | def test_kafka_group_io_dataset_resume_primary_cg_new_topic():
import tensorflow_io.kafka as kafka_io
# Write new messages to the topic
for i in range(10, 100):
message = f"D{i}"
kafka_io.write_kafka(message=message, topic="key-test")
# Read only the newly sent 90 messages
dataset =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_group_io_dataset_resume_primary_cg():\n import tensorflow_io.kafka as kafka_io\n\n # Write new messages to the topic\n for i in range(10, 100):\n message = f\"D{i}\"\n kafka_io.write_kafka(message=message, topic=\"key-partition-test\")\n # Read only the newly sent 90 messag... | [
"0.74266845",
"0.72838503",
"0.69508654",
"0.69229776",
"0.6898682",
"0.6788215",
"0.66945463",
"0.65659136",
"0.64467585",
"0.6332732",
"0.62817466",
"0.62599236",
"0.6245761",
"0.61413795",
"0.6088383",
"0.6065624",
"0.6036422",
"0.60189974",
"0.6011775",
"0.598527",
"0.594... | 0.7933696 | 0 |
Test the functionality of the `auto.offset.reset` configuration at global and topic level | def test_kafka_group_io_dataset_auto_offset_reset():
dataset = tfio.experimental.streaming.KafkaGroupIODataset(
topics=["key-partition-test"],
group_id="cgglobaloffsetearliest",
servers="localhost:9092",
configuration=[
"session.timeout.ms=7000",
"max.poll.in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_reset_time(self):\n pass",
"def test_reset():\n dev = _aws_device(wires=2)\n dev._circuit = CIRCUIT\n dev._task = TASK\n\n dev.reset()\n assert dev.circuit is None\n assert dev.task is None",
"def reset_topic(bot, trigger):\n global report\n\n if get_state():\n ... | [
"0.58305633",
"0.5826309",
"0.57031226",
"0.56880814",
"0.5674384",
"0.56572354",
"0.55940706",
"0.55784523",
"0.5553939",
"0.5552377",
"0.5534695",
"0.5404209",
"0.54005706",
"0.5393411",
"0.53927755",
"0.53910935",
"0.53739655",
"0.5346079",
"0.5346079",
"0.5346079",
"0.534... | 0.6541038 | 0 |
Test the functionality of the KafkaGroupIODataset when the consumer is configured to have an invalid stream_timeout value which is less than the message_timeout value. | def test_kafka_group_io_dataset_invalid_stream_timeout():
STREAM_TIMEOUT = -20
try:
tfio.experimental.streaming.KafkaGroupIODataset(
topics=["key-partition-test", "key-test"],
group_id="cgteststreaminvalid",
servers="localhost:9092",
stream_timeout=STREAM... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_group_io_dataset_stream_timeout_check():\n import tensorflow_io.kafka as kafka_io\n\n def write_messages_background():\n # Write new messages to the topic in a background thread\n time.sleep(6)\n for i in range(100, 200):\n message = f\"D{i}\"\n kafka... | [
"0.7494565",
"0.68445444",
"0.61413234",
"0.6002265",
"0.59668875",
"0.5940467",
"0.59011936",
"0.58735675",
"0.58508337",
"0.58345395",
"0.57948846",
"0.57629395",
"0.57347316",
"0.57000494",
"0.5662307",
"0.5627969",
"0.5604364",
"0.5560788",
"0.5560788",
"0.55548257",
"0.5... | 0.83997965 | 0 |
Test the functionality of the KafkaGroupIODataset when the consumer is configured to have a valid stream_timeout value and thus waits for the new messages from kafka. | def test_kafka_group_io_dataset_stream_timeout_check():
import tensorflow_io.kafka as kafka_io
def write_messages_background():
# Write new messages to the topic in a background thread
time.sleep(6)
for i in range(100, 200):
message = f"D{i}"
kafka_io.write_kafka... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_group_io_dataset_invalid_stream_timeout():\n\n STREAM_TIMEOUT = -20\n try:\n tfio.experimental.streaming.KafkaGroupIODataset(\n topics=[\"key-partition-test\", \"key-test\"],\n group_id=\"cgteststreaminvalid\",\n servers=\"localhost:9092\",\n ... | [
"0.790406",
"0.6366534",
"0.6356977",
"0.61877793",
"0.60831314",
"0.60248893",
"0.5973552",
"0.59520674",
"0.5936202",
"0.58431596",
"0.57945126",
"0.5725716",
"0.5712746",
"0.570165",
"0.5689419",
"0.56843454",
"0.5650357",
"0.55747294",
"0.557346",
"0.5550135",
"0.5498954"... | 0.8004889 | 0 |
Test the functionality of batch.num.messages property of KafkaBatchIODataset/KafkaGroupIODataset. | def test_kafka_mini_dataset_size():
import tensorflow_io.kafka as kafka_io
# Write new messages to the topic
for i in range(200, 10000):
message = f"D{i}"
kafka_io.write_kafka(message=message, topic="key-partition-test")
BATCH_NUM_MESSAGES = 5000
dataset = tfio.experimental.streami... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kafka_batch_io_dataset():\n\n dataset = tfio.experimental.streaming.KafkaBatchIODataset(\n topics=[\"mini-batch-test\"],\n group_id=\"cgminibatchtrain\",\n servers=None,\n stream_timeout=5000,\n configuration=[\n \"session.timeout.ms=7000\",\n \"... | [
"0.64023566",
"0.6360138",
"0.63011515",
"0.6271337",
"0.61075103",
"0.6065402",
"0.60378826",
"0.60176194",
"0.59386075",
"0.5936413",
"0.59298617",
"0.59279746",
"0.5922301",
"0.5909433",
"0.5898732",
"0.58711314",
"0.58583987",
"0.58453405",
"0.5823402",
"0.5822543",
"0.58... | 0.684737 | 0 |
Test the functionality of the KafkaBatchIODataset by training a model directly on the incoming kafka message batch(of type tf.data.Dataset), in an onlinetraining fashion. | def test_kafka_batch_io_dataset():
dataset = tfio.experimental.streaming.KafkaBatchIODataset(
topics=["mini-batch-test"],
group_id="cgminibatchtrain",
servers=None,
stream_timeout=5000,
configuration=[
"session.timeout.ms=7000",
"max.poll.interval.ms=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, batch):\n pass",
"def train(self, batch_training=False):\n raise NotImplementedError",
"def train(self, num_batches: int):",
"def train(train_dataset: torch.utils.data.Dataset, test_dataset: torch.utils.data.Dataset,\n training_config: dict = train_config, global_config... | [
"0.725532",
"0.704524",
"0.6841591",
"0.6800355",
"0.67653406",
"0.67564285",
"0.66826314",
"0.6670544",
"0.6661017",
"0.6658394",
"0.65870076",
"0.6586631",
"0.65774953",
"0.65341204",
"0.6532416",
"0.6496773",
"0.6493735",
"0.64827245",
"0.6464911",
"0.64211214",
"0.6411292... | 0.7809584 | 0 |
Hook to be use by subclasses to define default ACLs in context. | def __base_acl__(self) -> list:
_acls = [
(Allow, 'g:briefy_qa', ['add', 'delete', 'edit', 'list', 'view'])
]
return _acls | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __acl__():",
"def get_acl(registry=None):",
"def load_acl(self):\n macl_class = self.app.config.get('MACL_CLASS', None)\n macl_dict = self.app.config.get('MACL_DEFINITION', None)\n default_roles = self.app.config.get('MACL_DEFAULT_ROLES', None)\n\n if default_roles is not None:\... | [
"0.6822682",
"0.6064362",
"0.6048131",
"0.6034133",
"0.58422464",
"0.5725353",
"0.57216316",
"0.5718573",
"0.5646452",
"0.55869544",
"0.5586848",
"0.55686396",
"0.55665946",
"0.545657",
"0.5445769",
"0.5405563",
"0.5397825",
"0.53963953",
"0.5391042",
"0.5391042",
"0.5389581"... | 0.62626284 | 1 |
Checks if a token network is followed by the pathfinding service. | def follows_token_network(self, token_network_address: Address) -> bool:
assert is_checksum_address(token_network_address)
return token_network_address in self.token_networks.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_request_to_token_url(self, request):\n if not self.token_url:\n return False\n\n if self.token_url == request.path:\n return True\n\n request.match(self.token_url)\n\n if request.matchdict:\n return True\n\n return False",
"def reach(sel... | [
"0.5835548",
"0.5597924",
"0.5571266",
"0.5485773",
"0.5480768",
"0.5480768",
"0.54687196",
"0.5454214",
"0.5441436",
"0.5436674",
"0.5424187",
"0.5416221",
"0.53875804",
"0.5344155",
"0.5312403",
"0.529961",
"0.5279912",
"0.5251868",
"0.52469206",
"0.52468187",
"0.5241061",
... | 0.67394125 | 0 |
Returns the `TokenNetwork` for the given address or `None` for unknown networks. | def _get_token_network(self, token_network_address: Address) -> Optional[TokenNetwork]:
assert is_checksum_address(token_network_address)
if not self.follows_token_network(token_network_address):
return None
else:
return self.token_networks[token_network_address] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_network(address: str, netmask: str) -> IPv4Network:\n net = IPv4Network(f\"{address}/{netmask}\", strict=False)\n return net",
"def _get_network(name):\n\n if name not in _NAME_TO_NETS:\n raise ValueError('Network name [%s] not recognized.' % name)\n return _NAME_TO_NETS[name].model",
"def g... | [
"0.63604003",
"0.61137646",
"0.610317",
"0.59229994",
"0.57684386",
"0.5742403",
"0.5735001",
"0.5647258",
"0.5518795",
"0.55021477",
"0.5481944",
"0.539838",
"0.53970176",
"0.5341332",
"0.52976215",
"0.5289916",
"0.5274275",
"0.52362585",
"0.5219444",
"0.52164847",
"0.521336... | 0.8030924 | 0 |
!TXT! Return the URL for the online feedback service | def get_feedback_url(self):
return self.get_setting('service_feedback_url') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def support_url(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"support_url\")",
"def Url(self) -> str:",
"def feedback():\n return render_template(\"feedback.html\")",
"def get_url():\n config = configparser.RawConfigParser()\n config.read(\"speech.cfg\")\n region = config.get('a... | [
"0.61752695",
"0.61325103",
"0.6079804",
"0.6072169",
"0.6037325",
"0.59497833",
"0.5917915",
"0.5912349",
"0.5900737",
"0.58638495",
"0.5862365",
"0.58503306",
"0.583637",
"0.58221316",
"0.5819276",
"0.580274",
"0.5801738",
"0.5754639",
"0.57428956",
"0.57399815",
"0.5739981... | 0.78211945 | 0 |
Load CliMAF standard operators. Invoked by standard CliMAF setup The operators list also show in variable 'cscripts' They are documented elsewhere | def load_standard_operators():
#
# Compute scripts
#
cscript('select' ,scriptpath+'mcdo.sh "${operator}" "${out}" "${var}" "${period_iso}" "${domain}" "${alias}" "${units}" "${missing}" ${ins} ',
commuteWithTimeConcatenation=True, commuteWithSpaceConcatenation=True)
#
cscript('c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _basic_operators_init():\n global BASIC_OPERATORS\n\n BASIC_OPERATORS = {\n \"angle_between\": {\n \"node\": \"angleBetween\",\n \"inputs\": [\n [\"vector1X\", \"vector1Y\", \"vector1Z\"],\n [\"vector2X\", \"vector2Y\", \"vector2Z\"],\n ... | [
"0.5800942",
"0.54121894",
"0.5350327",
"0.52697974",
"0.5171791",
"0.5129815",
"0.511153",
"0.5089675",
"0.5077119",
"0.50660294",
"0.50468045",
"0.5024355",
"0.5013382",
"0.5007174",
"0.5001452",
"0.49958974",
"0.49821275",
"0.497245",
"0.49616897",
"0.49017334",
"0.4900833... | 0.7239035 | 0 |
Fit the model from data in X. PCA is fit to estimate the rotation and UniformSampler is fit to transformed data. | def fit(self, X, y=None):
self.pca_ = self._make_pca()
transformed = self.pca_.fit_transform(X)
self.sampler_ = UniformSampler(n_rows=self.n_rows).fit(transformed)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit_transform(self, X, y=None):\n X = np.asfortranarray(X, dtype=np.float64)\n Q = np.empty(\n (self.n_components, X.shape[1]), dtype=np.float64, order='F')\n U = np.empty(\n (X.shape[0], self.n_components), dtype=np.float64, order='F')\n w = np.empty(self.n_co... | [
"0.74559265",
"0.7146048",
"0.7100563",
"0.7100563",
"0.7100563",
"0.7031072",
"0.6953819",
"0.68829376",
"0.6859341",
"0.6859341",
"0.6859318",
"0.6813972",
"0.67715836",
"0.6764781",
"0.67534685",
"0.6715386",
"0.66989195",
"0.6691517",
"0.6683969",
"0.6655785",
"0.6646973"... | 0.7536608 | 0 |
This function deletes duplicate values from a singly linked list | def remove_dups(ll: SinglyLinkedList):
seen = set()
current = ll.head
prev = None
while current is not None:
if current.data in seen:
prev.next = current.next
temp = current
current = current.next
temp.next = None
else:
seen.add... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_dup2(linkedlist):",
"def remove_duplicates_slow(linked_list):\n current = linked_list.head\n while current:\n runner = current\n while runner:\n if runner.next_node and runner.next_node.value == current.value:\n # delete this duplicate\n run... | [
"0.84461933",
"0.8152717",
"0.8094504",
"0.8059363",
"0.78755367",
"0.7790879",
"0.7774575",
"0.7728998",
"0.76568514",
"0.7549787",
"0.74926317",
"0.7353447",
"0.7180826",
"0.7150074",
"0.71448135",
"0.71269375",
"0.7072273",
"0.70498395",
"0.695619",
"0.6727125",
"0.6698436... | 0.8174585 | 1 |
Create a board with distinct regions. Each region is continuous and separated from all other regions by at least two cells. The regions are generated using a Dirichlet process in which new cells are added to existed regions with a probability proportional to their boundary. | def make_partioned_regions(shape, alpha=1.0, max_regions=5, min_regions=2):
ring = np.array([[1,1,1],[1,0,1],[1,1,1]], dtype=np.int16)
adjacent = np.array([ # Diagonals don't count as adjacent
[-1,0,0,1],
[0,-1,1,0]], dtype=np.int16).T
nearby = np.meshgrid([-2,-1,0,1,2], [-2,-1,0,1,2])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_grains(self, cells):\n\t\tfor cell_num in range(cells):\n\t\t\trandom_row = random.randrange(0,self.space.shape[0],1)\n\t\t\tsample_cell = np.random.choice(self.space[random_row],1)\n\t\t\tsample_cell = sample_cell[0]\n\t\t\twhile sample_cell.state != 0:\n\t\t\t\trandom_row = random.randrange(0,self.s... | [
"0.61022526",
"0.607753",
"0.59886265",
"0.5929426",
"0.59226096",
"0.58879864",
"0.5817077",
"0.5783131",
"0.57591105",
"0.57534856",
"0.5751205",
"0.575003",
"0.57356465",
"0.57249886",
"0.57249135",
"0.5723089",
"0.56941694",
"0.56906545",
"0.5687791",
"0.56527513",
"0.564... | 0.71277833 | 0 |
Create a fence around unmasked regions such that nothing inside the regions can escape. Note that this is a little bit more aggressive than it strictly needs to be. | def build_fence(mask, shuffle=True):
mask = mask.astype(np.int32)
_i = np.array([-1,-1,-1,0,0,0,1,1,1], dtype=np.int32)
_j = np.array([-1,0,1,-1,0,1,-1,0,1], dtype=np.int32)
neighbors = ndimage.convolve(mask, np.ones((3,3)), mode='wrap')
fence = np.zeros_like(mask)
edge_i, edge_j = np.nonzero(ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_spurious_landmarks(self):\r\n \r\n remove = np.argwhere(self.lm_counter < 0)\r\n self.lm = np.delete(self.lm, remove, axis=0)\r\n self.lm_cvar = np.delete(self.lm_cvar, remove, axis=0)\r\n self.lm_counter = np.delete(self.lm_counter, remove)\r\n \r\n retu... | [
"0.5550262",
"0.5375474",
"0.52712905",
"0.52280205",
"0.522766",
"0.5217894",
"0.5148621",
"0.51361966",
"0.513452",
"0.51226854",
"0.5100473",
"0.5098816",
"0.5098428",
"0.5061148",
"0.5000526",
"0.4992203",
"0.49582353",
"0.49527928",
"0.49484676",
"0.49470642",
"0.4946795... | 0.56984526 | 0 |
Add agents and exits to the board. This modifies both the board and regions in place. | def add_agents_and_exit(board, regions, agents, agent_types):
agent_vals = []
point_tables = []
agent_names = []
agent_types = {'default': DEFAULT_AGENT, **agent_types}
for agent_type in _fix_random_values(agents):
agent_type = _fix_random_values(agent_type)
if agent_type not in agen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_simulation(self,agent):\n self.agents[agent.name] = agent\n self.network.add_node(agent)\n \n #agent given a grid queue at initialization\n grid_queue = [gq for gq in self.grid_queues.values() if gq.accepts(agent)][agent.sex]\n agent.grid_queue = grid_queue.inde... | [
"0.5694394",
"0.5502142",
"0.5498129",
"0.5477356",
"0.5419938",
"0.53479344",
"0.5290117",
"0.52449757",
"0.52416706",
"0.51957417",
"0.5178578",
"0.5174868",
"0.51587874",
"0.5111144",
"0.5063345",
"0.5056426",
"0.50496",
"0.50238144",
"0.50177455",
"0.49965593",
"0.4988289... | 0.716102 | 0 |
Randomly generate a new SafeLife game board. Generation proceeds by creating several different random "regions", and then filling in each region with one of several types of patterns or tasks. Regions can be surrounded by fences / walls to make it harder for patterns to spread from one region to another. Each set of pa... | def gen_game(
board_shape=(25,25), min_performance=-1, partitioning={},
starting_region=None, later_regions=None, buffer_region=None,
named_regions={}, agents=['default'], agent_types={}, **etc):
board_shape = _fix_random_values(board_shape)
min_performance = _fix_random_values(min_perfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(self):\n for i in range(4):\n random_first = randomize_first_box()\n self.randomize(random_first)\n for i in range(9):\n random_pos = randomize_position()\n self.randomize(random_pos)\n self.board.solve()",
"def draw_random_setup(types... | [
"0.68248934",
"0.64361274",
"0.6384287",
"0.6220165",
"0.614266",
"0.613112",
"0.6068092",
"0.6057356",
"0.6054699",
"0.6002918",
"0.5973913",
"0.5956003",
"0.59538376",
"0.59481156",
"0.59429073",
"0.59363997",
"0.59216344",
"0.59191567",
"0.59100956",
"0.58849156",
"0.58718... | 0.64837104 | 1 |
override this to do logic on input_update messages | def do_on_input_update(self, msg_id, payload, player):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_input_changed(self):\n self.message.data = self.dataInput.toPlainText()\n self.validate_data_input(self.message.dlc)",
"def update(self, msg):\n pass",
"def process_IN_MODIFY(self, event):",
"def handle_input(self, event):\n pass",
"def oppdater(self, input):\n r... | [
"0.7064037",
"0.68353105",
"0.679278",
"0.6780095",
"0.6757028",
"0.66975",
"0.6632578",
"0.6601894",
"0.65531427",
"0.6519125",
"0.64932",
"0.6461436",
"0.645683",
"0.64120686",
"0.6398695",
"0.63841844",
"0.6377531",
"0.63212633",
"0.6266965",
"0.6207796",
"0.6190815",
"0... | 0.79876757 | 0 |
Zoom in on a specific station on a map | def station_on_map(request, station_number):
data_stations = stations_with_data()
station_number = int(station_number)
down, problem, up = status_lists()
station = get_object_or_404(Station, number=station_number)
center = station.latest_location()
if center['latitude'] is None and center['lon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom_to(self):\n # Will seek user feedback. QGIS will\n # Pan to first layer loaded",
"def zoomIn(self, x, y):\n\n # set view state\n (map_x, map_y) = self.getMapCoordsFromView((x,y))\n self.view_offset_x = map_x*2 - self.view_width/2\n self.view_offset_y = map_y*2 -... | [
"0.62788576",
"0.6039453",
"0.58890414",
"0.58117414",
"0.5672202",
"0.5654756",
"0.56279266",
"0.55998397",
"0.55568296",
"0.55527616",
"0.5512002",
"0.54508984",
"0.5449918",
"0.5449918",
"0.5449918",
"0.5449918",
"0.54433745",
"0.54276776",
"0.5427263",
"0.53882915",
"0.53... | 0.6076124 | 1 |
Show all stations from a subcluster on a map | def stations_on_map(request, country=None, cluster=None, subcluster=None):
data_stations = stations_with_data()
down, problem, up = status_lists()
if country:
get_object_or_404(Country, name=country)
if cluster:
get_object_or_404(Cluster, name=cluster, parent=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_on_map(request, station_number):\n\n data_stations = stations_with_data()\n station_number = int(station_number)\n down, problem, up = status_lists()\n\n station = get_object_or_404(Station, number=station_number)\n center = station.latest_location()\n if center['latitude'] is None an... | [
"0.67217124",
"0.6456021",
"0.6094351",
"0.59413135",
"0.57239014",
"0.56707394",
"0.5667912",
"0.5660193",
"0.56526005",
"0.56276786",
"0.5618511",
"0.56184906",
"0.5581086",
"0.55698586",
"0.5552247",
"0.5542267",
"0.5477948",
"0.5476224",
"0.54496205",
"0.5442602",
"0.5442... | 0.7505736 | 0 |
Helper shortcut for creating subcommands. Accepts arguments for `add_subparsers`, creating a new subparser and returning a partial function wrapping `add_subcommand` for the new subparser. If the `dest` argument isn't specified, it defaults to `'subcmd'`. Example cmd_foo = CommandParser('foo', 'Does foo stuff') foo_add... | def make_adder(self, *args, **kwargs):
kwargs.setdefault("dest", "subcmd")
subp = self.add_subparsers(*args, **kwargs)
return partial(self.add_subcommand, subp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subcommand(self, func=None, **subcommand_options):\n\n def decorator(subcommand_func):\n subcommand_sig = inspect.signature(subcommand_func)\n\n @functools.wraps(subcommand_func)\n def wrapped(args):\n\n final_args = []\n final_kwargs = {}\n... | [
"0.7137559",
"0.6991422",
"0.69432056",
"0.6767474",
"0.66648597",
"0.6645159",
"0.6587919",
"0.6517023",
"0.6504958",
"0.6392979",
"0.6344873",
"0.63118166",
"0.623115",
"0.62270325",
"0.62064266",
"0.6119958",
"0.61081535",
"0.60894066",
"0.60719246",
"0.6052931",
"0.600301... | 0.84089714 | 0 |
Helper method for adding subcommands. Wrapper around `add_parser` that simplifies adding subcommands to ZeroBot commands. The same string is used for both the `description` and `help` parameters of `add_parser`. | def add_subcommand(
subp: _SubParsersAction, name: str, description: Optional[str] = None, **kwargs
) -> "CommandParser":
desc_help = {"description": description, "help": description}
return subp.add_parser(name, **desc_help, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_subcommands(cls, parser: argparse.ArgumentParser) -> None:\n if cls.SUBCOMMANDS:\n subparsers = parser.add_subparsers(title=\"subcommands\", metavar=\"\", dest='cmd')\n for subcmd_class in cls.SUBCOMMANDS:\n parsers = subcmd_class.get_args()\n subc... | [
"0.76693493",
"0.7625279",
"0.761014",
"0.74660397",
"0.7304024",
"0.7300243",
"0.6937958",
"0.687252",
"0.6824965",
"0.68249416",
"0.6797736",
"0.6796231",
"0.67945975",
"0.6792037",
"0.6770885",
"0.67248243",
"0.6711912",
"0.66614723",
"0.6639564",
"0.66390103",
"0.6635527"... | 0.81267315 | 0 |
The invoked subcommand name, if one was invoked. For subcommands with aliases, the name returned is always the canonical name that the aliases are associated with. For this reason, this attribute should be preferred to extracting the subcommand name from `ParsedCommand.args`. | def subcmd(self) -> Optional[str]:
return self._subcmd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_name(self):\n return None",
"def get_commandname(self):\n for line in self.helplines:\n if \"Usage:\" in line and self.parser_type is 'optparse':\n tmp = line.split()\n return tmp[1]\n if \"usage:\" in line and self.parser_type is 'arg... | [
"0.6581749",
"0.6499524",
"0.6446358",
"0.6352551",
"0.6317428",
"0.62414986",
"0.6189401",
"0.6147004",
"0.6130716",
"0.61187094",
"0.60870796",
"0.60323155",
"0.5961086",
"0.5867416",
"0.5867416",
"0.5861084",
"0.58426297",
"0.58400583",
"0.5821133",
"0.58019865",
"0.579916... | 0.6821528 | 0 |
Get the name of a nested subcommand. Like the `subcmd` property, the name returned is always the canonical name for the subcommand. The `depth` parameter determines how many levels of nesting to traverse; the default of ``2`` gets the first nested subcommand. As a consequence, a value of ``1`` is the same as `subcmd`. | def nested_subcmd(self, depth: int = 2) -> Optional[str]:
# pylint: disable=protected-access
current = 0
subparser = self.parser
try:
while current < depth:
action = subparser._actions[0]
if isinstance(action, _SubParsersAction):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subcmd(self, name: str) -> \"CommandHelp\":\n try:\n return self.subcmds[name]\n except KeyError:\n # Try looking up by alias\n for sub_name, sub_help in self.subcmds.items():\n for alias in sub_help.aliases:\n if name == alia... | [
"0.61825335",
"0.5816208",
"0.57917714",
"0.5630253",
"0.55556434",
"0.55294657",
"0.54540044",
"0.5216835",
"0.5201424",
"0.49779016",
"0.49343693",
"0.48652846",
"0.48608866",
"0.48450202",
"0.4835011",
"0.47898704",
"0.47898704",
"0.47851962",
"0.476425",
"0.472209",
"0.47... | 0.80556154 | 0 |
Get the `CommandHelp` object for the given subcommand. `name` may be an alias, in which case it is resolved to the appropriate subcommand. | def get_subcmd(self, name: str) -> "CommandHelp":
try:
return self.subcmds[name]
except KeyError:
# Try looking up by alias
for sub_name, sub_help in self.subcmds.items():
for alias in sub_help.aliases:
if name == alias:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_subcommand(self, name):\n try:\n subcommand_class = self.subcommands[name]\n except KeyError:\n self.print_command_unkown_error(name)\n sys.exit(1)\n return subcommand_class(self.prog, name, self.argv[2:], self.stdout)",
"def HelpForCmd(self, name):... | [
"0.70336854",
"0.70271784",
"0.664786",
"0.6645423",
"0.647728",
"0.6419414",
"0.6092256",
"0.60677403",
"0.6052447",
"0.5968284",
"0.59641016",
"0.5962373",
"0.5933287",
"0.5915913",
"0.59141576",
"0.5910189",
"0.59012985",
"0.5898384",
"0.5896387",
"0.5896387",
"0.5896387",... | 0.78726345 | 0 |
Guard the given spatial reference object against axis swapping, when running with GDAL 3. Does nothing if GDAL < 3. Modifies the object in place. | def preventGdal3axisSwap(sr):
if hasattr(sr, 'SetAxisMappingStrategy'):
sr.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_axis(ogr_geom):\n\n osr_sref = ogr_geom.GetSpatialReference()\n sref = SpatialRef.from_osr(osr_sref)\n if (sref.epsg == 4326) and GDAL_3_ENABLED and (osr_sref.GetAxisMappingStrategy() == 1):\n ogr_geom.SwapXY()\n osr_sref.SetAxisMappingStrategy(0)\n ogr_geom.AssignSpatialRefe... | [
"0.60711205",
"0.57531947",
"0.54899454",
"0.54608077",
"0.5264879",
"0.52497613",
"0.5123439",
"0.51041955",
"0.50515485",
"0.50315267",
"0.5019805",
"0.4985836",
"0.49436423",
"0.4911243",
"0.48981285",
"0.48816335",
"0.4864694",
"0.4860169",
"0.48571274",
"0.48423705",
"0.... | 0.6333744 | 0 |
Given a polygon Geometry object in lat/long, work out what would be a suitable projection to use with this area, in order to avoid things like the international date line wraparound, or the north/sourth pole discontinuities. This only makes sense for tiled products, as opposed to long strips which cross multiple zones,... | def findSensibleProjection(geom):
coords = getCoords(geom)
y = coords[:, 1]
x = coords[:, 0]
yMin = y.min()
yMax = y.max()
if (yMax - yMin) > 90:
# We are crossing a lot of latitude, which suggests that we have a
# long strip> In this case, we don't even bother to suggest an EPS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polygon_area(polygon):\n if not PYPROJ_INSTALLED:\n raise ImportError(\"`pyproj` must be installed to use this feature!\")\n poly = wkt_loads(polygon)\n poly_area = shapely.ops.transform(\n partial(\n pyproj.transform,\n pyproj.Proj(init='EPSG:4326'),\n p... | [
"0.6414271",
"0.63134813",
"0.62757397",
"0.60515285",
"0.603324",
"0.59443223",
"0.59352905",
"0.5911644",
"0.58656824",
"0.57909673",
"0.5745204",
"0.57246166",
"0.57246166",
"0.5703267",
"0.5702607",
"0.5696144",
"0.56794995",
"0.5671271",
"0.56611097",
"0.5648878",
"0.561... | 0.693248 | 0 |
Make a pair of ogr.CoordinateTransformation objects, for transforming between the two given EPSG projections. Return a tuple (tr1to2, tr2to1) | def makeTransformations(epsg1, epsg2):
sr1 = osr.SpatialReference()
sr1.ImportFromEPSG(epsg1)
preventGdal3axisSwap(sr1)
sr2 = osr.SpatialReference()
sr2.ImportFromEPSG(epsg2)
preventGdal3axisSwap(sr2)
tr1to2 = osr.CoordinateTransformation(sr1, sr2)
tr2to1 = osr.CoordinateTransformation(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_proj(p1, p2, x, y, nocopy=False):\n\n try:\n # This always makes a copy, even if projections are equivalent\n return _transform_internal(p1, p2, x, y, always_xy=True)\n except TypeError:\n if proj_is_same(p1, p2):\n if nocopy:\n return x, y\n ... | [
"0.6856417",
"0.683055",
"0.6792389",
"0.6792389",
"0.67460185",
"0.64127856",
"0.64124286",
"0.63331443",
"0.6282391",
"0.62185615",
"0.6211598",
"0.61743957",
"0.6105238",
"0.60964894",
"0.6039987",
"0.59297293",
"0.591202",
"0.5792901",
"0.5790143",
"0.57694685",
"0.570458... | 0.8401615 | 0 |
Given a geometry as a lat/long polygon, find the lat/long centroid, by first projecting into the preferred EPSG, so as to avoid discontinuities. The preferredEpsg is one in which the polygon ought to make sense (as found, hopefully, by the findSensibleProjection() function). Returns a pair [centroidX, centroidY] in lat... | def findCentroid(geom, preferredEpsg):
(projTr, llTr) = makeTransformations(4326, preferredEpsg)
geomProj = copyGeom(geom)
geomProj.Transform(projTr)
geomCentroid = geomProj.Centroid()
geomCentroid.Transform(llTr)
centroidDict = eval(geomCentroid.ExportToJson())
centroidXY = centro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_polygon_centroid_2d(polygon):\r\n return geometry.gmComputePolygonCentroid(polygon)",
"def findSensibleProjection(geom):\n coords = getCoords(geom)\n y = coords[:, 1]\n x = coords[:, 0]\n yMin = y.min()\n yMax = y.max()\n if (yMax - yMin) > 90:\n # We are crossing a lot of... | [
"0.6208906",
"0.60699695",
"0.5872511",
"0.5834941",
"0.5801932",
"0.5733032",
"0.56430256",
"0.5637194",
"0.5616599",
"0.5605853",
"0.55601245",
"0.5548161",
"0.55228645",
"0.5449253",
"0.5448886",
"0.5407162",
"0.5400743",
"0.5362452",
"0.526248",
"0.52553886",
"0.5202955",... | 0.7754564 | 0 |
Return a copy of the geometry. OGR does not provide a good method for doing this. | def copyGeom(geom):
geomJson = geom.ExportToJson()
newGeom = ogr.CreateGeometryFromJson(geomJson)
return newGeom | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_with_copy(geometry):\n geometry = pygeos.apply(geometry, lambda x: x) # makes a copy\n pygeos.prepare(geometry)\n return geometry",
"def getGeometry(self):\n return self.geometry",
"def getGeometry(self):\n return self.geometry",
"def geometry(self):\n return self.... | [
"0.7537405",
"0.73882526",
"0.73882526",
"0.7358205",
"0.7358205",
"0.7251656",
"0.71966004",
"0.71324015",
"0.7120845",
"0.6842374",
"0.6735027",
"0.6728724",
"0.67227095",
"0.6678602",
"0.6662164",
"0.6536648",
"0.65043837",
"0.6306422",
"0.6269604",
"0.6267922",
"0.6248901... | 0.74882305 | 1 |
Return the coordinates of the given OGR geometry. Assumes that this is a single polygon, and returns a numpy array of the x, y coords, of shape (numPts, 2). If the polygon has holes, they will be discarded this is just the outer polygon. If the geometry is a MultiPoint geom, also return a 2d array of coords. | def getCoords(geom):
geomDict = eval(geom.ExportToJson())
coords = geomDict['coordinates']
if geomDict['type'] == 'Polygon':
coordsArray = numpy.array(coords[0])
elif geomDict['type'] == 'MultiPoint':
coordsArray = numpy.array(coords)
else:
coordsArray = None
return coord... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geomFromInteriorPoints(coords):\n if isinstance(coords, numpy.ndarray):\n coords = coords.tolist()\n geomDict = {'type':'MultiPoint', 'coordinates':coords}\n geomPoints = ogr.CreateGeometryFromJson(repr(geomDict))\n return geomPoints",
"def point_coords(geom):\n # Return a tuple with th... | [
"0.6378374",
"0.6318399",
"0.6230891",
"0.6092643",
"0.598644",
"0.59413916",
"0.5929878",
"0.5911129",
"0.5879037",
"0.5745938",
"0.56728566",
"0.5662459",
"0.5643619",
"0.56382567",
"0.560755",
"0.5599817",
"0.55802184",
"0.5575683",
"0.557035",
"0.55689305",
"0.55629367",
... | 0.72319037 | 0 |
Given a MultiPoint geometry object in lat/long, create a polygon of the convex hull of these points. First project the lat/long points into the preferred EPSG, so that when we find the convex hull, we are not crossing any discontinuities such as the international date line. Return a single polygon geometry in lat/long. | def polygonFromInteriorPoints(geom, preferredEpsg):
(projTr, llTr) = makeTransformations(4326, preferredEpsg)
geomProj = copyGeom(geom)
geomProj.Transform(projTr)
geomOutline = geomProj.ConvexHull()
geomOutline.Transform(llTr)
return geomOutline | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convex_hull(self):\n if isinstance(self.crs, GeographicalCRS):\n raise CRSError(\"not implemented for geographical coordinate \"\n \"systems. Project to a projected coordinate system.\")\n\n points = [pt for pt in self]\n\n # Find the lowermost (left?) ... | [
"0.7075242",
"0.6431152",
"0.64101326",
"0.63916564",
"0.63589376",
"0.627315",
"0.61870193",
"0.6043088",
"0.6030819",
"0.59753376",
"0.5926664",
"0.59115064",
"0.5896636",
"0.589403",
"0.5877571",
"0.5867895",
"0.58546466",
"0.5851499",
"0.5834695",
"0.58292884",
"0.5810926... | 0.7046996 | 1 |
Given a Polygon Geometry object, in lat/long, detect whether it crosses the dateline. Do this in the projection of the preferred EPSG, so we remove (reduce?) the ambiguity about inside/outside. | def crossesDateline(geom, preferredEpsg):
(xMin, xMax, yMin, yMax) = geom.GetEnvelope()
(projTr, llTr) = makeTransformations(4326, preferredEpsg)
geomProj = copyGeom(geom)
geomProj.Transform(projTr)
dateLineGeom = ogr.Geometry(wkt='LINESTRING(180 {}, 180 {})'.format(yMin, yMax))
try:
da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_inside_polygon(xxx_todo_changeme,poly):\n (x,y) = xxx_todo_changeme\n n = len(poly)\n inside = False\n\n p1x, p1y = poly[0]\n for i in range(n + 1):\n p2x, p2y = poly[i % n]\n if y > min(p1y, p2y):\n if y <= max(p1y, p2y):\n if x <= max(p1x, p2x):\n ... | [
"0.69540954",
"0.6897939",
"0.6799872",
"0.6788985",
"0.67285305",
"0.66589004",
"0.6657012",
"0.6512406",
"0.64687806",
"0.64495367",
"0.64015037",
"0.63911974",
"0.6390966",
"0.6381956",
"0.6351574",
"0.62924826",
"0.62201375",
"0.61754906",
"0.611618",
"0.6106009",
"0.6104... | 0.7383287 | 0 |
Given a Polygon Geometry object in lat/long, determine whether it crosses the date line, and if so, split it into a multipolygon with a part on either side. Use the given preferred EPSG to perform calculations. Return a new Geometry in lat/long. | def splitAtDateline(geom, preferredEpsg):
crosses = crossesDateline(geom, preferredEpsg)
if crosses:
(projTr, llTr) = makeTransformations(4326, preferredEpsg)
coords = getCoords(geom)
(x, y) = (coords[:, 0], coords[:, 1])
(yMin, yMax) = (y.min(), y.max())
xMinPositive = N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossesDateline(geom, preferredEpsg):\n (xMin, xMax, yMin, yMax) = geom.GetEnvelope()\n (projTr, llTr) = makeTransformations(4326, preferredEpsg)\n\n geomProj = copyGeom(geom)\n geomProj.Transform(projTr)\n dateLineGeom = ogr.Geometry(wkt='LINESTRING(180 {}, 180 {})'.format(yMin, yMax))\n try... | [
"0.67136943",
"0.63109124",
"0.5897794",
"0.56662834",
"0.5617019",
"0.5594572",
"0.5547453",
"0.55368793",
"0.5471673",
"0.5448653",
"0.54439175",
"0.54206467",
"0.5395042",
"0.53801703",
"0.5376376",
"0.5372196",
"0.5371982",
"0.5348414",
"0.53426564",
"0.53149515",
"0.5310... | 0.76047856 | 0 |
Test that invalid tokens works | def test_invalid_tokens(self):
self.assertTrue(1 + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unused_token_is_valid(self):\n assert self.token.is_valid()",
"def test_regex_invalid_tokens(self):\n tokens = (\n \"\",\n \"lemon wins\",\n \"..\",\n \"x.y\",\n \"x.y.\",\n \".y.z\",\n \".y.\",\n \"..z... | [
"0.8261625",
"0.7524087",
"0.74162",
"0.72980505",
"0.7251938",
"0.7226254",
"0.714365",
"0.71125466",
"0.70883507",
"0.70597327",
"0.7019325",
"0.7010936",
"0.7009519",
"0.6961416",
"0.6934247",
"0.68621945",
"0.6833543",
"0.6818326",
"0.68157536",
"0.6811885",
"0.6800639",
... | 0.87907505 | 0 |
Proxy to turn of transcypt when calling img.get/set methods | def image_proxy(img):
def _set(*args):
__pragma__("noalias", "set")
value = img.set(*args)
__pragma__("alias", "set", "py_set")
return value
def _get(*args):
__pragma__("noalias", "get")
value = img.get(*args)
__pragma__("alias", "get", "py_get")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, img, *args, **kwargs):\n raise NotImplementedError",
"def __call__(self, img, *args, **kwargs):\n raise NotImplementedError",
"def __init__(self, img, settings):\r\n self.img_orig = img\r\n self.settings = settings",
"def _apply_transform(self, img: np.ndarray):... | [
"0.6246118",
"0.6246118",
"0.62181085",
"0.6194361",
"0.6194361",
"0.60827804",
"0.606501",
"0.6059099",
"0.59579223",
"0.59201604",
"0.5910337",
"0.58504593",
"0.5800288",
"0.5793381",
"0.5784016",
"0.5776674",
"0.5700956",
"0.56607634",
"0.5656199",
"0.56306195",
"0.5605271... | 0.7732635 | 0 |
We need to run this before the actual draw to insert and update p5 env variables | def pre_draw(p5_instance, draw_func):
global _CTX_MIDDLE, _DEFAULT_FILL, _DEFAULT_LEADMULT, _DEFAULT_STROKE, _DEFAULT_TEXT_FILL
global ADD, ALT, ARROW, AUTO, AUDIO, AXES, BACKSPACE, BASELINE, BEVEL, BEZIER, BLEND, BLUR, BOLD, BOLDITALIC
global BOTTOM, BURN, CENTER, CHORD, CLAMP, CLOSE, CONTROL, CORNER, COR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_draw(self):\n pass",
"def pointsSetUp(self):\r\n self.background.draw(self.surface)\r\n for i in range(len(self.points)):\r\n self.points[i].organize()\r\n self.points[i].update()\r\n self.points[i].addNumber(i)\r\n self.points[i].setActi... | [
"0.6523757",
"0.6017574",
"0.5880544",
"0.5814766",
"0.57777816",
"0.5713455",
"0.5674024",
"0.56632835",
"0.56570673",
"0.5616937",
"0.56138486",
"0.5583289",
"0.5570645",
"0.55119085",
"0.5494234",
"0.546833",
"0.54369044",
"0.54284686",
"0.54177946",
"0.5411796",
"0.540187... | 0.6062119 | 1 |
Injects the p5js's skecth instance as a global variable to setup and draw functions | def global_p5_injection(p5_sketch):
def decorator(f):
def wrapper():
global _P5_INSTANCE
_P5_INSTANCE = p5_sketch
return pre_draw(_P5_INSTANCE, f)
return wrapper
return decorator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\r\n #this happens just once\r\n size(width, height) #instead of create_canvas\r",
"def __init__(self, parent):\n super(P5, self).__init__(parent)\n self.shapes = []\n self.scenes = []\n self.current_scene = 0\n self.objects = []\n self.lighting = True\... | [
"0.6492295",
"0.6341241",
"0.6277463",
"0.6121529",
"0.5968284",
"0.5964794",
"0.5882622",
"0.5853329",
"0.5788281",
"0.5773192",
"0.5767879",
"0.5749697",
"0.5735698",
"0.5676923",
"0.56400704",
"0.5595668",
"0.55945295",
"0.558435",
"0.5566732",
"0.55556136",
"0.55504155",
... | 0.63667154 | 1 |
Computes the DOS for each site of an slab, only for 2d | def slabldos(h,energies=np.linspace(-1.0,1.0,40),delta=None,nk=40):
if h.dimensionality!=2: raise # nope
ds = ldosmap(h,energies=energies,delta=delta,nk=nk)
if len(ds[0])!=len(h.geometry.z):
print("Wrong dimensions",len(ds[0]),len(h.geometry.z))
raise
f = open("DOSMAP.OUT","w")
f.write("# energy, ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_msd(pos_x, pos_y, pos_z):\n particles = pos_x.shape[0]\n N = pos_x.shape[1] \n tamsd = np.zeros(shape = (particles, N - 1)) \n\n for p in np.arange(start = 0, stop = particles, step = 1): \n for n in np.arange(start = 1, stop = N, step = 1): \n sumdis = np.array([((pos_x[p, i... | [
"0.5823131",
"0.56665945",
"0.5654268",
"0.56067395",
"0.5549059",
"0.5487201",
"0.5425105",
"0.53680533",
"0.5335588",
"0.5313948",
"0.53035074",
"0.52599955",
"0.52019894",
"0.51405936",
"0.5140454",
"0.51258785",
"0.5124321",
"0.5116561",
"0.5109169",
"0.5090838",
"0.50795... | 0.63072735 | 0 |
Calculate many LDOS, by diagonalizing the Hamiltonian | def multi_ldos(h,es=[0.0],delta=0.001,nrep=3,nk=2,numw=3,random=False):
print("Calculating eigenvectors in LDOS")
if h.is_sparse: # sparse Hamiltonian
from bandstructure import smalleig
print("SPARSE Matrix")
evals,ws = [],[] # empty list
ks = klist.kmesh(h.dimensionality,nk=nk) # get grid
hk = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonals_in_hd():\n number_of_pairs = 100000\n angles_for_d = {}\n for d in (10, 100, 1000):\n number_of_corners = 2 ** d - 1\n first_corner = [random.randint(0, number_of_corners) for _ in range(0, number_of_pairs)]\n second_corner = [random.randint(0, number_of_corners) for _ i... | [
"0.6510543",
"0.6441997",
"0.616607",
"0.6134413",
"0.607191",
"0.59936696",
"0.59168214",
"0.58911335",
"0.5871839",
"0.58278966",
"0.5818667",
"0.58146787",
"0.5806394",
"0.5788211",
"0.57797736",
"0.57464814",
"0.57270575",
"0.5663071",
"0.56431705",
"0.56420153",
"0.56268... | 0.68332195 | 0 |
Write LDOS in a file | def write_ldos(x,y,dos,output_file="LDOS.OUT",z=None):
fd = open(output_file,"w") # open file
fd.write("# x, y, local density of states\n")
ii = 0
for (ix,iy,idos) in zip(x,y,dos): # write everything
fd.write(str(ix) +" "+ str(iy) + " "+ str(idos))
if z is not None: fd.write(" "+str(z[ii]))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_file(l_dta, outputfile):\n l_dta2 = []\n for row in l_dta:\n s = '\\t'.join(row)\n l_dta2.append(s)\n s_dta = \"\\r\\n\".join(l_dta2)\n try:\n with open(outputfile, 'w') as fd:\n fd.write(s_dta)\n except (IOError,) as e:\n tracker()\n return None",... | [
"0.63052565",
"0.5946495",
"0.5859641",
"0.58320624",
"0.58302605",
"0.57833433",
"0.5733278",
"0.5729144",
"0.5711805",
"0.56135124",
"0.5603127",
"0.55708736",
"0.55650675",
"0.55446815",
"0.5522803",
"0.552071",
"0.55121875",
"0.5507822",
"0.5500877",
"0.5473531",
"0.54703... | 0.6843431 | 0 |
Calculates the LDOS of a cell with a defect, writting the n neighring cells | def ldos_defect(h,v,e=0.0,delta=0.001,n=1):
raise # still not finished
import green
# number of repetitions
rep = 2*n +1
# calculate pristine green function
g,selfe = green.supercell_selfenergy(h,e=e,delta=delta,nk=100,nsuper=rep)
# now calculate defected green function
ez = e + 1j*delta # complex ener... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slabldos(h,energies=np.linspace(-1.0,1.0,40),delta=None,nk=40):\n if h.dimensionality!=2: raise # nope\n ds = ldosmap(h,energies=energies,delta=delta,nk=nk)\n if len(ds[0])!=len(h.geometry.z): \n print(\"Wrong dimensions\",len(ds[0]),len(h.geometry.z))\n raise\n f = open(\"DOSMAP.OUT\",\"w\")\n f.wr... | [
"0.6147432",
"0.5673565",
"0.5628075",
"0.5538174",
"0.5529582",
"0.54913837",
"0.54828596",
"0.5471573",
"0.54613155",
"0.5456147",
"0.5440528",
"0.5422581",
"0.54167837",
"0.5389832",
"0.5379038",
"0.53487825",
"0.53432304",
"0.53047895",
"0.53021795",
"0.52806985",
"0.5250... | 0.572953 | 1 |
Associates the specified blobs with the given encryption keys. | def WriteBlobEncryptionKeys(
self,
key_names: Dict[rdf_objects.BlobID, str],
) -> None:
self.blob_keys.update(key_names) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume_encryption_keys(self, volume_encryption_keys):\n\n self._volume_encryption_keys = volume_encryption_keys",
"def test_blob_key_stored():\n\tbackup_and_restore(\n\t\tlambda context: put_keys(lib.SET, BLOB_KEYS, \"foobar\", True),\n\t\tNone,\n\t\tlambda context: check_keys(lib.SET, BLOB_KEYS, \"fo... | [
"0.5732032",
"0.55105233",
"0.54380447",
"0.5313522",
"0.5286251",
"0.5265419",
"0.5222959",
"0.52177703",
"0.5150052",
"0.51047397",
"0.5063412",
"0.50368476",
"0.49367145",
"0.49267337",
"0.49244836",
"0.4919951",
"0.49074957",
"0.49044165",
"0.49000615",
"0.4885995",
"0.48... | 0.7061965 | 0 |
Retrieves encryption keys associated with blobs. | def ReadBlobEncryptionKeys(
self,
blob_ids: Collection[rdf_objects.BlobID],
) -> Dict[rdf_objects.BlobID, Optional[str]]:
return dict(zip(blob_ids, map(self.blob_keys.get, blob_ids))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_keys(self):\n bucket = self.resource.Bucket(self.bucketname)\n return [key.key for key in bucket.objects.all()]",
"def get_encrypted_data_keys(self, data_key, encryption_context):\n encrypted_data_keys = [message.header.EncryptedDataKey(b'aws-kms',\n ... | [
"0.6437575",
"0.6124688",
"0.61170375",
"0.5970704",
"0.5920652",
"0.5918394",
"0.5872749",
"0.5832748",
"0.58217853",
"0.58021",
"0.5690256",
"0.56733716",
"0.5656133",
"0.56275576",
"0.56275576",
"0.5610084",
"0.56076646",
"0.55941993",
"0.55817664",
"0.55722076",
"0.557199... | 0.7701036 | 0 |
Parses data list and returns the number of person IDs and the number of camera views. | def parse_data(self, data):
pids = set()
cams = set()
for info in data:
pids.add(info[1])
cams.add(info[2])
return len(pids), len(cams) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_cams(self, data):\n cams = set()\n for items in data:\n camid = items[2]\n cams.add(camid)\n return len(cams)",
"def get_num_pids(self, data):\n pids = set()\n for items in data:\n pid = items[1]\n pids.add(pid)\n r... | [
"0.6483834",
"0.5873225",
"0.56902164",
"0.559616",
"0.5581715",
"0.55694574",
"0.55310565",
"0.5526454",
"0.5519276",
"0.5515513",
"0.55004495",
"0.543157",
"0.53432065",
"0.5338561",
"0.5330016",
"0.5312213",
"0.5268463",
"0.5256779",
"0.52174443",
"0.520235",
"0.5201785",
... | 0.6852167 | 0 |
Combines train, query and gallery in a dataset for training. | def combine_all(self):
combined = copy.deepcopy(self.train)
def _combine_data(data):
for img_path, pid, camid in data:
if pid in self._junk_pids:
continue
#pdb.set_trace()
pid = self.dataset_name + "_" + str(pid)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_all(self):\n if self._train_only:\n return\n\n combined = copy.deepcopy(self.train)\n\n # relabel pids in gallery (query shares the same scope)\n g_pids = set()\n for items in self.gallery:\n pid = items[1]\n if pid in self._junk_pids:... | [
"0.69598746",
"0.67574775",
"0.6717249",
"0.66458243",
"0.66314375",
"0.65966815",
"0.65671974",
"0.65517074",
"0.65076643",
"0.64948964",
"0.64792395",
"0.6467504",
"0.6462277",
"0.64389426",
"0.64315575",
"0.641234",
"0.6410118",
"0.6398891",
"0.63852507",
"0.63804436",
"0.... | 0.69694567 | 0 |
Assigns every training point a weight equal to 1/N, where N is the number of training points. Returns a dictionary mapping points to weights. | def initialize_weights(training_points):
N = len(training_points)
ans = {}
for p in training_points:
ans[p] = make_fraction(1, N)
return ans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_weights(n):\n return np.array([1/n for _ in range(n)])",
"def uniform_weights(n):\n return np.ones((n, 1)) / n",
"def update_weights(point_to_weight, misclassified_points, error_rate):\n for p in point_to_weight:\n if p in misclassified_points:\n point_to_weight[p] *= mak... | [
"0.6437919",
"0.6396687",
"0.624045",
"0.61508226",
"0.6023781",
"0.6023781",
"0.5951131",
"0.59024775",
"0.58835477",
"0.58784914",
"0.5861894",
"0.58606887",
"0.5855883",
"0.5820768",
"0.5816859",
"0.5815168",
"0.58121",
"0.57764375",
"0.57757556",
"0.5774974",
"0.5753624",... | 0.8002009 | 0 |
Given a dictionary mapping training points to their weights, and another dictionary mapping classifiers to the training points they misclassify, returns a dictionary mapping classifiers to their error rates. | def calculate_error_rates(point_to_weight, classifier_to_misclassified):
ans = {}
for c in classifier_to_misclassified:
misclassified = classifier_to_misclassified[c]
ans[c] = 0
for p in misclassified:
ans[c] += point_to_weight[p]
return ans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(point_to_weight, misclassified_points, error_rate):\n for p in point_to_weight:\n if p in misclassified_points:\n point_to_weight[p] *= make_fraction(1,2)*make_fraction(1, error_rate)\n else:\n point_to_weight[p] *= make_fraction(1,2)*make_fraction(1, 1-err... | [
"0.6313117",
"0.5606973",
"0.55354184",
"0.55307525",
"0.5491061",
"0.54466426",
"0.5413339",
"0.5376725",
"0.5321494",
"0.5300928",
"0.5286332",
"0.52586734",
"0.5237726",
"0.5230793",
"0.52304846",
"0.5226977",
"0.5218962",
"0.5217092",
"0.51976115",
"0.5183116",
"0.5169867... | 0.76960677 | 0 |
Given a dictionary mapping classifiers to their error rates, returns the best classifier, or raises NoGoodClassifiersError if best classifier has error rate 1/2. best means 'smallest error rate' if use_smallest_error is True, otherwise 'error rate furthest from 1/2'. | def pick_best_classifier(classifier_to_error_rate, use_smallest_error=True):
best_classifier = None
if use_smallest_error:
best_classifier = min(classifier_to_error_rate, key=classifier_to_error_rate.get)
else:
best_classifier = max(classifier_to_error_rate, key=lambda x : abs(classifier_to_erro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_best_classifier(data, possible_classifiers, target_classifier):\n best_disorder_score = 10000000\n best_classifier = None\n try:\n for classifier in possible_classifiers:\n total_disorder = average_test_disorder(data, classifier, target_classifier)\n if total_disorder... | [
"0.65992683",
"0.6348734",
"0.60387164",
"0.56676745",
"0.5634381",
"0.5621993",
"0.55739546",
"0.55624396",
"0.5539638",
"0.5454468",
"0.5443642",
"0.5441887",
"0.5408296",
"0.53730357",
"0.531757",
"0.526106",
"0.5247903",
"0.52269906",
"0.52153784",
"0.52098244",
"0.519527... | 0.80622786 | 0 |
Given a classifier's error rate (a number), returns the voting power (aka alpha, or coefficient) for that classifier. | def calculate_voting_power(error_rate):
if error_rate == 0:
return INF
if error_rate == 1:
return -INF
return 0.5*ln(make_fraction(1-error_rate, error_rate)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exponential_vote(score, category):\n status = \"\"\n\n try:\n max_vote = constants.MAX_VOTE[category]\n except:\n max_vote = constants.MAX_TASK_REQUEST\n\n else:\n power = constants.EXP_POWER\n weight = pow(\n score / 100.0,\n power - (score / 100.0... | [
"0.6483174",
"0.60067403",
"0.58584934",
"0.57399225",
"0.5617777",
"0.55273247",
"0.5520179",
"0.5502458",
"0.5488472",
"0.54872227",
"0.5482623",
"0.5475527",
"0.5460961",
"0.5439238",
"0.54219",
"0.54015714",
"0.53638995",
"0.53533477",
"0.53349483",
"0.5307904",
"0.529213... | 0.7368655 | 0 |
Given an overall classifier H, a list of all training points, and a dictionary mapping classifiers to the training points they misclassify, returns a set containing the training points that H misclassifies. H is represented as a list of (classifier, voting_power) tuples. | def get_overall_misclassifications(H, training_points, classifier_to_misclassified):
misclassified = []
for p in training_points:
score = 0
for tup in H:
c = tup[0]
voting_power = tup[1]
if p in classifier_to_misclassified[c]:
score -= voting_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def misclassified_training_points(svm):\n wrong = []\n for point in svm.training_points:\n if point.classification is not classify(svm, point):\n wrong.append(point)\n return set(wrong)",
"def digits_make_classifiers_to_misclassified(X,Y,classifiers,ids_to_points):\n\toutput = {key: []... | [
"0.7052224",
"0.6119313",
"0.54236513",
"0.5231023",
"0.5223641",
"0.51209354",
"0.510333",
"0.5085148",
"0.5023613",
"0.5006669",
"0.49687526",
"0.4961643",
"0.49522075",
"0.49459502",
"0.49397606",
"0.49372053",
"0.49112162",
"0.48705956",
"0.48250222",
"0.48217845",
"0.481... | 0.85402024 | 0 |
Given an overall classifier H, a list of all training points, a dictionary mapping classifiers to the training points they misclassify, and a mistake tolerance (the maximum number of allowed misclassifications), returns False if H misclassifies more points than the tolerance allows, otherwise True. H is represented as ... | def is_good_enough(H, training_points, classifier_to_misclassified, mistake_tolerance=0):
misclassified = get_overall_misclassifications(H, training_points, classifier_to_misclassified)
if len(misclassified) > mistake_tolerance:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_overall_misclassifications(H, training_points, classifier_to_misclassified):\n misclassified = []\n\n for p in training_points:\n score = 0\n for tup in H:\n c = tup[0]\n voting_power = tup[1]\n if p in classifier_to_misclassified[c]:\n sc... | [
"0.68727624",
"0.59430206",
"0.58152044",
"0.5540413",
"0.55316037",
"0.5448521",
"0.5405066",
"0.5398594",
"0.5388817",
"0.5313519",
"0.53004795",
"0.5284414",
"0.5269668",
"0.5265305",
"0.5240204",
"0.5234198",
"0.520831",
"0.5201402",
"0.5200734",
"0.51976657",
"0.5176463"... | 0.7659174 | 0 |
Given a dictionary mapping training points to their old weights, a list of training points misclassified by the current weak classifier, and the error rate of the current weak classifier, returns a dictionary mapping training points to their new weights. This function is allowed (but not required) to modify the input d... | def update_weights(point_to_weight, misclassified_points, error_rate):
for p in point_to_weight:
if p in misclassified_points:
point_to_weight[p] *= make_fraction(1,2)*make_fraction(1, error_rate)
else:
point_to_weight[p] *= make_fraction(1,2)*make_fraction(1, 1-error_rate)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_error_rates(point_to_weight, classifier_to_misclassified):\n ans = {}\n for c in classifier_to_misclassified:\n misclassified = classifier_to_misclassified[c]\n ans[c] = 0\n for p in misclassified:\n ans[c] += point_to_weight[p]\n return ans",
"def keypoint_... | [
"0.67305875",
"0.58836514",
"0.5748413",
"0.5478308",
"0.54563385",
"0.53294194",
"0.5201591",
"0.51845413",
"0.5084596",
"0.50814384",
"0.5060465",
"0.50252044",
"0.5015587",
"0.50075173",
"0.49619642",
"0.49579272",
"0.49395669",
"0.4937159",
"0.49219316",
"0.490734",
"0.48... | 0.78441054 | 0 |
Performs the Adaboost algorithm for up to max_rounds rounds. Returns the resulting overall classifier H, represented as a list of (classifier, voting_power) tuples. | def adaboost(training_points, classifier_to_misclassified,
use_smallest_error=True, mistake_tolerance=0, max_rounds=INF):
point_to_weight = initialize_weights(training_points)
H = [] # (classifier, voting_power)
while True:
# exit conditions
if is_good_enough(H, training_points... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modelAdaBoost():\n num_estimators = [1,5,10,50,100,150]\n learning_rate = 0.1\n max_depth = 3\n base_estimate = DecisionTreeClassifier(max_depth=max_depth)\n random_state = 20 # Do not change this random_state\n \n obj_boost = []\n \n \"\"\" \n Create a list of objects for the cla... | [
"0.5816989",
"0.5509983",
"0.541834",
"0.53876275",
"0.53350043",
"0.5324034",
"0.5317509",
"0.5210553",
"0.51253355",
"0.51249367",
"0.5117827",
"0.50774145",
"0.50676054",
"0.5053001",
"0.5049434",
"0.50463754",
"0.50307447",
"0.5024344",
"0.50045466",
"0.4988225",
"0.49871... | 0.6702093 | 0 |
Create a plane through a given point with given normal and surface material | def __init__(self, point, normal, material):
self.point = point
self.norm = unit(normal)
self.mat = material | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_point_plane(point, plane):\n base, normal = plane\n normal = normalize_vector(normal)\n vector = subtract_vectors(point, base)\n snormal = scale_vector(normal, dot_vectors(vector, normal))\n return subtract_vectors(point, snormal)",
"def plot_plane(unit_normal, x_array, y_array, fore):... | [
"0.6926132",
"0.67918247",
"0.66280645",
"0.6622853",
"0.6570255",
"0.6499382",
"0.64442146",
"0.6332076",
"0.62797856",
"0.62646264",
"0.6246257",
"0.6151091",
"0.6120761",
"0.6096576",
"0.60693115",
"0.59628874",
"0.5912617",
"0.58920056",
"0.58715844",
"0.585937",
"0.58575... | 0.683124 | 1 |
Returns a hit, or None if the ray is parallel to the plane | def intersect(self, ray):
t = None
hit = None
angle = ray.dir.dot(self.norm)
if angle != 0:
t = (self.point - ray.start).dot(self.norm) / angle
if angle < 0:
hit = Hit(self, ray, t, float('inf'), self.norm, self.mat)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rayIntersection(self, ray):\n #t = \"what we are trying to find\"\n l = -ray.mDirection\n l0 = ray.mOrigin\n n = self.mNormal\n p0 = self.mDistance * n\n #p = l0 + l * t\n\n if l.dot(n) > 0:\n v = p0 - l0\n t = -(v.dot(n) / l.dot(n))\n ... | [
"0.724688",
"0.7169482",
"0.7158089",
"0.71482855",
"0.67915195",
"0.67516196",
"0.67201257",
"0.66962445",
"0.6689992",
"0.6683316",
"0.65686566",
"0.6530607",
"0.64233273",
"0.6218107",
"0.6107053",
"0.60904384",
"0.60822034",
"0.60539466",
"0.60471374",
"0.5973455",
"0.595... | 0.7633641 | 0 |
return the number of scalar components | def getNumberOfScalarComponents(self):
return self.numberOfComponents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_components(self):\n return 1",
"def n_components(self):\n return self._components.shape[0]",
"def n_cs(self):\n return np.size(self._cs, 0)",
"def components(self):\n return self.num_components",
"def __len__(self):\n num_x, num_y = self.conv_dims()\n return ... | [
"0.74888134",
"0.7376706",
"0.7100258",
"0.70853853",
"0.70716816",
"0.6938483",
"0.69184744",
"0.68926495",
"0.68802017",
"0.68690693",
"0.6788687",
"0.67648643",
"0.6762822",
"0.6739765",
"0.67380327",
"0.67363364",
"0.671714",
"0.6700786",
"0.66510797",
"0.6639145",
"0.663... | 0.8905581 | 0 |
Set the color transfer function | def setColorTransferFunction(self, ctf):
self.ctf = ctf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_color(self):\r\n \r\n \r\n colorset = self.colorset\r\n \r\n self.grfx[0].colorset = colorset\r\n pass",
"def setColorDiffuse(*args):",
"def getColorTransferFunction(self):\n\t\treturn self.ctf",
"def set_color(self):\n self.image[self.x, self.y] = self.color\n if s... | [
"0.67156917",
"0.6633878",
"0.6617592",
"0.63400304",
"0.6332681",
"0.6234133",
"0.62047946",
"0.6202683",
"0.61825573",
"0.60994345",
"0.6095942",
"0.601829",
"0.5967596",
"0.5921991",
"0.5918888",
"0.5858037",
"0.5846267",
"0.5846243",
"0.5836248",
"0.5822841",
"0.5788105",... | 0.81864583 | 0 |
Return a flag indicating whether the images are 2D or 3D images | def is3DImage(self):
return self.is3D | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_depth_image(self):\n return False",
"def is_2d(self) -> bool:\n return self.layers == 1 and self.times == 1",
"def check_niimg_3d(niimg, dtype=None):\n return check_niimg(niimg, ensure_ndim=3, dtype=dtype)",
"def is3_d(self):\n return self.container['is3_d']",
"def are_compat... | [
"0.68862396",
"0.65322673",
"0.6502295",
"0.64808524",
"0.64616615",
"0.64155763",
"0.63741845",
"0.6256185",
"0.62417966",
"0.6234979",
"0.6150245",
"0.6141367",
"0.60545796",
"0.6043418",
"0.603095",
"0.60253567",
"0.5992711",
"0.5932484",
"0.5897953",
"0.5897953",
"0.58671... | 0.7844598 | 0 |
set the filenames that will be read | def setFilenames(self, filenames):
self.filenames = filenames
if len(filenames) == 0:
return
if not self.dimensions:
self.retrieveImageInfo(filenames[0])
if not self.checkImageDimensions(filenames):
raise Logging.GUIError("Image dimensions do not match", \
"Some of the selected files have di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_filename(self, file_name):",
"def setfiles(self, filelist):\r\n self._filelist=filelist\r\n self._energy=self.readenergy(filelist)",
"def filenames(self):\n pass",
"def fileset(self):\n pass",
"def __init__(self, files):\n self.files = files and [NamedFile(data=d, filenam... | [
"0.6955265",
"0.6887402",
"0.6878499",
"0.67892617",
"0.6675026",
"0.6572736",
"0.65357256",
"0.65231085",
"0.64586145",
"0.64167434",
"0.6371263",
"0.6240702",
"0.6175739",
"0.6168266",
"0.61507344",
"0.6141928",
"0.61352116",
"0.6123154",
"0.6068659",
"0.6062177",
"0.605273... | 0.72363704 | 0 |
Set a flag indicating whether the image should be flipped vertically | def setVerticalFlip(self, flag):
if self.ext.lower() in ["png", "jpg", "jpeg"]:
self.flipVertically = not flag
else:
self.flipVertically = flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_vertical(img):\r\n #reading image\r\n im = Image.open(\"filename\")\r\n\r\n #flipping image vertically\r\n newimg = im.transpose(PIL.Image.FLIP_TOP_BOTTOM)\r\n return img",
"def flip_image_vertical(image):\n return cv.flip(image, 1)",
"def flip_image(img, vert=True):\n if vert:\n ... | [
"0.73209965",
"0.70142406",
"0.68551445",
"0.66779745",
"0.66683435",
"0.666765",
"0.65579903",
"0.64983195",
"0.64376324",
"0.64257395",
"0.6424698",
"0.6389282",
"0.63263226",
"0.63111866",
"0.63103646",
"0.630324",
"0.6244989",
"0.61426216",
"0.6092576",
"0.60797507",
"0.6... | 0.8431753 | 0 |
Set a flag indicating whether the image should be flipped horizontally | def setHorizontalFlip(self, flag):
self.flipHorizontally = flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_horizontal(img):\r\n #reading image\r\n im = Image.open(\"filename\")\r\n\r\n #flipping image horizontally\r\n newimg = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)\r\n \r\n return img",
"def flip_image_horizontal(image):\n return cv.flip(image, 0)",
"def flip(self, horizontally):\n\t\... | [
"0.7160271",
"0.6985837",
"0.6883737",
"0.6870575",
"0.6787338",
"0.67704475",
"0.6695351",
"0.6677402",
"0.6635156",
"0.6454874",
"0.64387655",
"0.64263225",
"0.6393341",
"0.6339728",
"0.63132757",
"0.6289396",
"0.61795443",
"0.61762446",
"0.61736774",
"0.6157254",
"0.614742... | 0.83549047 | 0 |
check that each image in the list has the same dimensions | def checkImageDimensions(self, filenames):
s = None
hashStr = filenames[:]
hashStr.sort()
hashStr = str(hashStr)
# check to see if there's already a result of the check for these filenames in the cache
if hashStr in self.dimensionCheck:
Logging.info("Using cached result for dimensions check: %s"%(str(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images_are_present(file_info):\n currentdir = os.path.join(WORKDIR, file_info['folder'])\n if not os.path.exists(currentdir):\n return False\n count = len([x for x in os.listdir(currentdir) if x.endswith('.png')])\n if count != file_info['size']:\n print([x for x in os.listdir(current... | [
"0.66642034",
"0.6607947",
"0.65018415",
"0.6470456",
"0.64090717",
"0.63401216",
"0.6332631",
"0.63291144",
"0.6313849",
"0.6313849",
"0.62913483",
"0.6274798",
"0.62315774",
"0.6190616",
"0.6132303",
"0.6132303",
"0.6086374",
"0.60784054",
"0.6073663",
"0.60491264",
"0.6013... | 0.66137314 | 1 |
return a VTK image reader based on file extension | def getReaderByExtension(self, ext, isRGB = 0):
assert ext in self.extMapping, "Extension not recognized: %s" % ext
mpr = self.extMapping[ext]
prefix="vtk"
# If it's a tiff file, we use our own, extended TIFF reader
if self.extMapping[ext] == "TIFF":
mpr = "ExtTIFF"
prefix="vtkbxd"
self.rdrstr = "%s.v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getReadersFromFilenames(self):\n\t\tfor i in self.readers:\n\t\t\tdel i\n\t\tself.readers = []\n\n\t\tif not self.filenames:\n\t\t\traise Logging.GUIError(\"No files could be found\", \\\n\t\t\t\t\t\t\t\t\t\"For some reason, no files were listed to be imported.\")\t\t \n\t\t\t\t\t\n\t\tfiles = self.filenames\n... | [
"0.64241487",
"0.5978514",
"0.59677935",
"0.5905505",
"0.5868323",
"0.5654292",
"0.5641504",
"0.5602225",
"0.5563264",
"0.55544156",
"0.55478626",
"0.55258757",
"0.5498806",
"0.54907084",
"0.5490219",
"0.5475998",
"0.5461645",
"0.5444304",
"0.54409236",
"0.541251",
"0.5400047... | 0.75270355 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.