query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Simulate printing each design, until there are none left. Move each design to completed_models after printing.
def print_models(unprinted_designs, completed_models): while unprinted_designs: current_design = unprinted_designs.pop() # Simulate creating a 3d print from the design. print("Printing model: " + current_design) completed_models.append(current_design)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_models (unprinted_designs,completed_models):\n \n while unprinted_designs:\n current_design = unprinted_designs.pop()\n #Simulate creating a 3D print from the desig.\n print (\"printing model: \" + current_design)\n completed_models.append (current_design)", "def print...
[ "0.83719826", "0.83719486", "0.82855046", "0.8230399", "0.80913585", "0.79925144", "0.74432874", "0.690036", "0.68810475", "0.68694586", "0.68694586", "0.68694586", "0.67919457", "0.6589304", "0.61238146", "0.58934677", "0.57532626", "0.57419646", "0.57194996", "0.5676091", "...
0.8240983
4
Show all the models that were printed.
def show_completed_models(completed_models): print("\nThe following models have been printed:") for completed_model in completed_models: print(completed_model)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_completed_models(completed_models):\r\n print(\"\\nThe following models have been printed:\")\r\n for completed_model in completed_models:\r\n print(completed_model)", "def show_completed_models(completed_models):\n\tprint(\"\\n The following models has been printed \")\n\tfor completed_mod...
[ "0.7550581", "0.7505565", "0.74779797", "0.7463235", "0.7299305", "0.689944", "0.6806887", "0.67993057", "0.6793462", "0.67158437", "0.6685057", "0.6670043", "0.6669607", "0.6669607", "0.663256", "0.66235834", "0.66213685", "0.66103745", "0.6587718", "0.6491061", "0.6472574",...
0.75561774
2
Build a dictionary containing everything we know about a user.
def build_profile(first, last, **user_info): profile = {} profile['first_name'] = first profile['last_name'] = last for key, value in user_info.items(): profile[key] = value return profile
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_user_info(user):\r\n return {\r\n 'username': user.username,\r\n 'email': user.email,\r\n 'first_name': user.first_name,\r\n 'last_name': user.last_name,\r\n }", "def extract_user_info(user):\r\n return {\r\n 'username': user...
[ "0.739899", "0.739899", "0.73685396", "0.7349614", "0.7152368", "0.7149312", "0.6997632", "0.68651915", "0.6837776", "0.68375385", "0.68306404", "0.68195456", "0.67827326", "0.6781717", "0.67752063", "0.6750619", "0.6731149", "0.6635023", "0.6614327", "0.6569148", "0.65338075...
0.6014076
69
Register the message handlers that every journal should support.
def register_message_handlers(journal): journal.dispatcher.register_message_handler( DumpQuorumMessage, _dumpquorumhandler)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _register_handlers(self):\n DBG(\"\\nregister handlers\")\n for hook, handler in self.handlers:\n g.registerHandler(hook, handler)\n\n signal_manager.connect(self.c, 'body_changed', self._after_body_key)", "def _register_handlers(self):\n import handlers as th\n ...
[ "0.72620213", "0.70435107", "0.66157293", "0.65716064", "0.6314305", "0.62207043", "0.6180045", "0.60054207", "0.6003531", "0.5998502", "0.5990488", "0.59491366", "0.5929773", "0.5925832", "0.5805171", "0.58019876", "0.5768111", "0.575978", "0.5712927", "0.5671215", "0.566424...
0.8429424
0
Constructor for DumpQuorumMessage class.
def __init__(self, minfo=None): if minfo is None: minfo = {} super(DumpQuorumMessage, self).__init__(minfo) self.IsSystemMessage = False self.IsForward = True self.IsReliable = True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump(self):\n result = super(DumpQuorumMessage, self).dump()\n return result", "def __init__(self):\n super().__init__()\n\n self.__encoded_msg = ''", "def __init__(self, msg):\n\n self.msg = msg", "def __init__(self, msg):\n self.msg = msg", "def __init__(self...
[ "0.7168633", "0.57381815", "0.5708409", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.56985074", "0.569133", "0.5681516", "0.5638713", "0.5632342", "0.5632342", "0.5...
0.7561885
0
Returns a dict with information about the dump quorum message.
def dump(self): result = super(DumpQuorumMessage, self).dump() return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumps(self) -> Dict[str, Any]:\n return {\n \"commitId\": self.commit_id,\n \"parentCommitId\": self.parent_commit_id,\n \"message\": self.message,\n \"committer\": self.committer.dumps(),\n }", "def __init__(self, minfo=None):\n if minfo is No...
[ "0.6006111", "0.567213", "0.5670017", "0.5648441", "0.5578808", "0.53971803", "0.5394207", "0.5387473", "0.53841007", "0.5374053", "0.5371038", "0.53614724", "0.53580964", "0.5316283", "0.5305731", "0.52922034", "0.52715415", "0.51807743", "0.5176574", "0.51549894", "0.513852...
0.7622692
0
The entry endpoint of our API.
def api_root(request, format=None): return Response({ 'users': reverse('user-list', request=request), 'groups': reverse('group-list', request=request), 'pools': reverse('pool-list', request=request), })
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api():\n\treturn \"The API call\"", "def home():\n return(\n f\"Available Routes: <br/>\"\n\n f\"For Precipitation: /api/v1.0/precipitation<br/>\"\n f\"Returns Jsonify dictionary of dates and Precepitation<br/><br/>\"\n\n f\"For list of Stations: /api/v1.0/stations<br/>\"\n ...
[ "0.6402737", "0.6304572", "0.6296278", "0.6259337", "0.61859983", "0.6181998", "0.6150856", "0.6121735", "0.6036392", "0.6036392", "0.6036392", "0.5975089", "0.59478664", "0.5932474", "0.5926881", "0.59074867", "0.5892754", "0.5886604", "0.5877651", "0.58573645", "0.5808704",...
0.0
-1
List all pools, or create a new pool.
def pool_list(request, format=None): if request.method == 'GET': pools = storage.models.Pool.objects.all() serializer = serializers.PoolSerializer(pools) return Response(serializer.data) elif request.method == 'POST': serializer = serializers.PoolSerializer(data=request.DATA) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pool_list(call=None):\n if call == \"action\":\n raise SaltCloudSystemExit(\n \"This function must be called with -f, --function argument.\"\n )\n ret = {}\n session = _get_session()\n pools = session.xenapi.pool.get_all()\n for pool in pools:\n pool_record = sess...
[ "0.70111126", "0.6758204", "0.6567126", "0.65345985", "0.645883", "0.6388487", "0.6305644", "0.62771875", "0.61912704", "0.61358166", "0.6108212", "0.6096144", "0.6054042", "0.6049037", "0.604506", "0.6033518", "0.602757", "0.59318095", "0.59190464", "0.5901486", "0.5883244",...
0.64396614
5
Retrieve a known stored filter object from the db
def retrieve_filter(self, filter_id): LOG.debug("Retrieve filter {}".format(filter_id)) filter_obj = self.filter_collection.find_one({"_id": ObjectId(filter_id)}) # use _id to preselect the currently loaded filter, and drop it while we are at it filter_obj.update([("filters", filter_obj.pop("_id", None))]) return filter_obj
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter():\n return get_filter_data(db, MyTable)", "def get_instance(self, data):\n if self.transient:\n return None\n props = get_primary_keys(self.opts.model)\n filters = {prop.key: data.get(prop.key) for prop in props}\n if None not in filters.values():\n ...
[ "0.6960243", "0.62703", "0.62410784", "0.61514443", "0.6141893", "0.61203706", "0.60491437", "0.60114807", "0.585763", "0.5800049", "0.578962", "0.5782984", "0.5733101", "0.5730981", "0.571787", "0.5717332", "0.5716527", "0.5708957", "0.5699338", "0.5699338", "0.5699338", "...
0.6990458
0
Store away filter settings for later use.
def stash_filter( self, filter_obj, institute_obj, case_obj, user_obj, category="snv", link=None ): LOG.info( "Stashing filter for user '%s' and institute %s.", user_obj.get("email"), institute_obj.get("display_name"), ) LOG.info("Filter object {}".format(filter_obj)) institute_id = institute_obj.get("_id") filter_dict = {"institute_id": institute_id, "category": category} # make up a default display name filter_dict["display_name"] = ( institute_obj.get("display_name") + "-" + case_obj.get("display_name") ) for (element, value) in filter_obj.lists(): if value == [""]: continue if element in ["save_filter", "filters", "csrf_token"]: continue if element == "filter_display_name": # filter display_name if given # will appear as the only element in an array filter_dict["display_name"] = value[0] continue filter_dict[element] = value result = self.filter_collection.insert_one(filter_dict) filter_id = result.inserted_id # log event subject = institute_obj["display_name"] # link e.g. to the variants view where filter was created if link is None: variants_target_from_category = { "sv": "variants.sv_variants", "cancer": "variants.cancer_variants", "snv": "variants.variants", } target = variants_target_from_category.get(category) case_name = case_obj.get("display_name") # filter dict already contains institute_id=institute_id, link = url_for(target, case_name=case_name, **filter_dict) self.create_event( institute=institute_obj, case=case_obj, user=user_obj, link=link, category="case", verb="filter_stash", subject=subject, level="global", ) return filter_id
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_filters(self, options):\n if options.keywords:\n self.filters[\"keywords\"] = string_to_list(options.keywords)\n if options.features:\n self.filters[\"features\"] = string_to_list(options.features)\n if options.authors:\n self.filters[\"authors\"] = st...
[ "0.702972", "0.6695293", "0.6549355", "0.6472333", "0.6450351", "0.6393664", "0.63646764", "0.62200606", "0.616542", "0.61460763", "0.6126508", "0.61021346", "0.6078377", "0.60579336", "0.6051252", "0.60247004", "0.60106236", "0.60073197", "0.59548503", "0.59348184", "0.59262...
0.0
-1
Obtain a cursor for all filters available to an institute in a category.
def filters(self, institute_id, category="snv"): filters_res = self.filter_collection.find( {"institute_id": institute_id, "category": category} ) return filters_res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select(self, eng_category):\r\n sql_select_query = \"SELECT Name, URL, Ingredients FROM \"+ str(eng_category)\r\n self.mycursor.execute(sql_select_query)\r\n records = self.mycursor.fetchall()\r\n \r\n return records", "def filter():\n return get_filter_data(db, MyTable)...
[ "0.5364717", "0.53382677", "0.5266764", "0.5199028", "0.51203734", "0.51203734", "0.5113741", "0.508854", "0.5086552", "0.5083298", "0.50145316", "0.49857625", "0.4980039", "0.49589002", "0.49563545", "0.49544093", "0.49255437", "0.48955005", "0.48900995", "0.48809904", "0.48...
0.6988995
0
Synchronize IDA's cursor with GDB
def j(*args): try: pc = int(gdb.selected_frame().pc()) pwndbg.ida.Jump(pc) except Exception: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_pdb():\r\n import ctypes\r\n ctypes.windll.kernel32.AllocConsole()\r\n import sys\r\n sys.stdout = open('CONOUT$', 'wt')\r\n sys.stdin = open('CONIN$', 'rt')\r\n import pdb\r\n pdb.set_trace()", "def gdb_breakpoint():\n _gdb_python_call_gen('gdb_breakpoint')()", "def set_trace...
[ "0.618987", "0.61721236", "0.5961415", "0.5940629", "0.5920072", "0.59150904", "0.58346677", "0.5826086", "0.58243257", "0.5765665", "0.56860536", "0.56628925", "0.56359243", "0.5516654", "0.5512976", "0.55124795", "0.5501486", "0.5466048", "0.5450095", "0.5408604", "0.539628...
0.48803896
61
Select and print stack frame that called this one. An argument says how many frames up to go.
def up(n=1): f = gdb.selected_frame() for i in range(n): o = f.older() if o: o.select() bt = pwndbg.commands.context.context_backtrace(with_banner=False) print('\n'.join(bt)) j()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_frame(self, arg):\n if not arg:\n # Just display the frame, without handling sticky.\n self.print_stack_entry(self.stack[self.curindex])\n return\n\n try:\n arg = int(arg)\n except (ValueError, TypeError):\n print(\n ...
[ "0.73913187", "0.68238056", "0.6653886", "0.65766746", "0.6376097", "0.63759094", "0.6302292", "0.627555", "0.625705", "0.6184294", "0.6113973", "0.60998887", "0.6060529", "0.60272187", "0.5915152", "0.5864522", "0.5844503", "0.57457596", "0.5740299", "0.5735211", "0.5721572"...
0.668176
2
Select and print stack frame called by this one. An argument says how many frames down to go.
def down(n=1): f = gdb.selected_frame() for i in range(n): o = f.newer() if o: o.select() bt = pwndbg.commands.context.context_backtrace(with_banner=False) print('\n'.join(bt)) j()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_frame(self, arg):\n if not arg:\n # Just display the frame, without handling sticky.\n self.print_stack_entry(self.stack[self.curindex])\n return\n\n try:\n arg = int(arg)\n except (ValueError, TypeError):\n print(\n ...
[ "0.74253505", "0.6774561", "0.6765047", "0.6575413", "0.65482455", "0.6473951", "0.630916", "0.6290664", "0.6155866", "0.6132151", "0.6068907", "0.60600847", "0.60045964", "0.5957227", "0.5937258", "0.59002703", "0.5870945", "0.58447737", "0.58314973", "0.5798143", "0.5762033...
0.6162764
8
Copy `in_tree` to `out_tree`, checking selection(in_tree) for each event.
def tree_copy_selection(in_tree, out_tree, selection): for entry in in_tree: if selection(entry): out_tree.Fill()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_tree_checker(src, dst):\n copy_tree(src, dst)\n return True", "def execute(self, context):\n\n # go to subtree, select all except input and output groups and mark nodes to be copied\n group_node = context.active_node\n sub_tree = group_node.group_tree\n\n ...
[ "0.62684405", "0.5746463", "0.5593152", "0.5558629", "0.5449127", "0.5425309", "0.53680193", "0.5225137", "0.51527005", "0.5107789", "0.5051202", "0.504769", "0.5014795", "0.50122386", "0.49738657", "0.49728838", "0.49718148", "0.496103", "0.49524227", "0.4934227", "0.4934111...
0.78454643
0
Copy `in` to `out` for events where event.`key` does not exist in `keys` `keys` is the set of keys seen so far.
def tree_copy_duplicate_removal(in_tree, out_tree, key, keys): for entry in in_tree: key_value = getattr(entry, key) if not key_value in keys: out_tree.Fill() keys.add(key_value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_missing_values(events):\n ret = deepcopy(events)\n srchd, key_events = [], []\n for evt in events:\n _tmp = [(j, e) for j, e in enumerate(events) if e['key']\n == evt['key'] and not e['key'] in srchd]\n if _tmp != []:\n key_events.append(_tmp)\n sr...
[ "0.623754", "0.6082424", "0.5918844", "0.59167224", "0.56955945", "0.5677415", "0.5673033", "0.5609741", "0.55079687", "0.55027145", "0.5486954", "0.5394884", "0.53932744", "0.5390138", "0.53668404", "0.53537357", "0.533538", "0.52792567", "0.5232413", "0.5232282", "0.5213723...
0.663589
0
Returns a list of all the keys in a directory, only taking the most recent TKey.GetCycle() per TKey.GetName().
def most_recent_cycle_keys(directory): most_recent = {} # Generate a list of (name, (cyclenum, keyobject)) values all_keys = list(directory.GetListOfKeys()) keys = ((k.GetName(), (k.GetCycle(), k)) for k in all_keys) for name, cyclekey in keys: most_recent[name] = (max(cyclekey, most_recent[name]) if name in most_recent else cyclekey) # Just the key objects, sorted in name order. recent_keys = [most_recent[name][-1] for name in sorted(most_recent.keys())] # Return all_keys so that we don't lose anything return all_keys, recent_keys
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _keys(self):\n for name in listdir(abspath(self._path)):\n key, ext = splitext(name)\n if ext == \".pkl\":\n yield key", "def list(self):\n entries = []\n regex = re.compile('^%s' % self.directory)\n\n for obj in self.driver.list(self.directory...
[ "0.701094", "0.67127836", "0.6352646", "0.6343178", "0.63064986", "0.6274958", "0.6232864", "0.6204033", "0.6202406", "0.6179034", "0.61675316", "0.6141725", "0.61349463", "0.6060003", "0.60563046", "0.603784", "0.6035911", "0.6027133", "0.59946287", "0.5978249", "0.59718513"...
0.6699988
2
Convert the numpy array representing the GOL grid to a QImage.
def numpy_to_qimage(np_array: np.ndarray, show_age: bool): # Only support 2D array of bytes assert len(np_array.shape) == 2 and np_array.dtype == np.uint8 width = np_array.shape[1] height = np_array.shape[0] bytes_per_line = width image = QImage(np_array, width, height, bytes_per_line, QImage.Format_Indexed8) # Maps array values to color if show_age: image.setColorTable(colors.AGE_COLOR_TABLE) else: image.setColorTable(colors.BINARY_COLOR_TABLE) return image
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertNumpy2Image(self, array):\n cv2image = cv2.cvtColor(array, cv2.COLOR_BGR2RGBA)\n img = Image.fromarray(cv2image)\n imgtk = ImageTk.PhotoImage(image=img)\n return imgtk", "def make_image(self, save=False):\n\n # image_grid = np.full((self.size_x, self.size_y), '#88888...
[ "0.6397902", "0.6196134", "0.60192525", "0.59758794", "0.5931983", "0.5765702", "0.5721111", "0.5687924", "0.56588805", "0.5628664", "0.55947673", "0.55882084", "0.5583067", "0.55810326", "0.55731523", "0.5548744", "0.5506583", "0.54962564", "0.54832053", "0.54686344", "0.546...
0.68053734
0
my_map list of lists specifying obstacle positions path [(x1, y1), (x2, y2), ...] list of the steps take by the agent goals [(x1, y1), (x2, y2), ...] list of goal locations
def __init__(self, my_map, paths, starts, goals, agent_goals, predictions): self.my_map = my_map self.paths = paths self.starts = starts self.goals = goals self.agent_goals = agent_goals self.num_of_agents = len(starts) self.predictions = predictions self.CPU_time = 0 # compute heuristics for the low-level search self.heuristics = [] for goal in self.goals: self.heuristics.append(compute_heuristics(my_map, goal))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_goal(self):\r\n\t\t# Creates a flat list of correct values\r\n\t\ttempList = [x for x in range(self.n**2)]\r\n\r\n\t\t# Nests those lists into a NxN\r\n\t\tBoardClass.goal = [tempList[self.n*i:self.n*(i+1)] for i in range(self.n)]\r\n\r\n\t\t# Creates a dictionary for the intended location of any spec...
[ "0.6306571", "0.62811714", "0.62330747", "0.6082783", "0.6031487", "0.59971946", "0.59853303", "0.59514654", "0.5945449", "0.58769524", "0.5866137", "0.5830052", "0.57840186", "0.5759361", "0.57322335", "0.5720972", "0.57009214", "0.56796384", "0.56514007", "0.5645225", "0.56...
0.5904296
9
Prepare paths specified as config. The input is a list of either strings, or 2tuples (source, target). Where single strings are supplied, the basenames are used as targets. Where targets are given explicitly, they must not be absolute paths. Returns a list of 2tuples, or throws ConfigError if something is wrong in the input.
def process_path_specs(specs): processedSpecs = [] for spec in specs: if not isinstance(spec, (list, tuple)): source = spec target = None elif len(spec) != 2: raise ConfigError("path spec must be a list or tuple of " "length two") else: source, target = spec source = os.path.normpath(source) if not target: target = os.path.basename(source) elif os.path.isabs(target): raise ConfigError("target path for include file may not be " "an absolute path") processedSpecs.append((source, target)) return processedSpecs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_paths(src, dst, paths, *, exclude=None):\n files = []\n\n for path in paths:\n if isinstance(path, tuple):\n files += copy_path(src, dst, path[0], path[1], exclude=exclude)\n else:\n files += copy_path(src, dst, path, exclude=exclude)\n\n return files", "def ...
[ "0.5550079", "0.5392351", "0.5171191", "0.5132501", "0.5108284", "0.5076208", "0.5054015", "0.5015645", "0.4951827", "0.4932448", "0.49286622", "0.49249643", "0.48797044", "0.48406097", "0.48093775", "0.4735485", "0.47257975", "0.47036657", "0.47026363", "0.46804345", "0.4679...
0.6430958
0
Return the path to a resource file shipped with cx_Freeze. This is used to find our base executables and initscripts when they are just specified by name.
def get_resource_file_path(dirName, name, ext): if os.path.isabs(name): return name name = os.path.normcase(name) fullDir = os.path.join(os.path.dirname(cx_Freeze.__file__), dirName) if os.path.isdir(fullDir): for fileName in os.listdir(fullDir): checkName, checkExt = \ os.path.splitext(os.path.normcase(fileName)) if name == checkName and ext == checkExt: return os.path.join(fullDir, fileName)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_filename(name):\n return pkg_resources.resource_filename(__name__, name)", "def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.path.abspath(os.pat...
[ "0.7262757", "0.72428066", "0.7147131", "0.7135437", "0.70946133", "0.70946133", "0.70946133", "0.70946133", "0.70946133", "0.70946133", "0.70946133", "0.7087055", "0.7067677", "0.70555377", "0.705534", "0.705534", "0.705534", "0.705534", "0.705534", "0.705534", "0.705534", ...
0.69520795
40
Return the file names of libraries that need not be included because they would normally be expected to be found on the target system or because they are part of a package which requires independent installation anyway.
def _GetDefaultBinExcludes(self): if sys.platform == "win32": return ["comctl32.dll", "oci.dll", "cx_Logging.pyd"] else: return ["libclntsh.so", "libwtc9.so"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def library_directories(self):\n\n status, stdout, stderr = self.__xcall__(['--libs-only-L'])\n\n if status != 0:\n raise RuntimeError(\"error querying --libs-only-L for package `%s': %s\" % (self.name, stderr))\n\n retval = []\n for token in stdout.split():\n retval.append(token[2:])\n\n ...
[ "0.7460289", "0.73898304", "0.71631336", "0.7133726", "0.70093113", "0.68778294", "0.67150843", "0.6555115", "0.6427538", "0.6418846", "0.6387556", "0.6331555", "0.62914765", "0.6284729", "0.62831557", "0.6266173", "0.622727", "0.616253", "0.6143471", "0.6061587", "0.6038263"...
0.6424925
9
Return the file names of libraries which must be included for the frozen executable to work.
def _GetDefaultBinIncludes(self): if sys.platform == "win32": pythonDll = "python%s%s.dll" % sys.version_info[:2] return [pythonDll, "gdiplus.dll", "mfc71.dll", "msvcp71.dll", "msvcr71.dll"] else: soName = distutils.sysconfig.get_config_var("INSTSONAME") if soName is None: return [] pythonSharedLib = self._RemoveVersionNumbers(soName) return [pythonSharedLib]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def libraries(self):\n\n status, stdout, stderr = self.__xcall__(['--libs-only-l'])\n\n if status != 0:\n raise RuntimeError(\"error querying --libs-only-l for package `%s': %s\" % (self.name, stderr))\n\n retval = []\n for token in stdout.split():\n retval.append(token[2:])\n\n return uni...
[ "0.6991022", "0.6678766", "0.6654032", "0.66060007", "0.6492413", "0.6385442", "0.6274169", "0.62589043", "0.62560844", "0.62152314", "0.6175629", "0.61445343", "0.61295563", "0.61234623", "0.61047596", "0.6061235", "0.6051311", "0.6039806", "0.6035648", "0.603107", "0.601471...
0.6333758
6
Return the paths of directories which contain files that should not be included, generally because they contain standard system libraries.
def _GetDefaultBinPathExcludes(self): if sys.platform == "win32": import cx_Freeze.util systemDir = cx_Freeze.util.GetSystemDir() windowsDir = cx_Freeze.util.GetWindowsDir() return [windowsDir, systemDir, os.path.join(windowsDir, "WinSxS")] elif sys.platform == "darwin": return ["/lib", "/usr/lib", "/System/Library/Frameworks"] else: return ["/lib", "/lib32", "/lib64", "/usr/lib", "/usr/lib32", "/usr/lib64"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removeduppaths():\r\n # This ensures that the initial path provided by the interpreter contains\r\n # only absolute pathnames, even if we're running from the build directory.\r\n L = []\r\n known_paths = set()\r\n for dir in sys.path:\r\n # Filter out duplicate paths (on case-insensitive ...
[ "0.68841964", "0.66146666", "0.6608054", "0.6544238", "0.6524269", "0.65076166", "0.64406294", "0.64142877", "0.63882494", "0.6343896", "0.6316815", "0.6312666", "0.6243478", "0.6181976", "0.6178829", "0.6160177", "0.615914", "0.61474144", "0.61427253", "0.61281586", "0.61181...
0.7017395
0
Return the file's dependencies using platformspecific tools (the imagehlp library on Windows, otool on Mac OS X and ldd on Linux); limit this list by the exclusion lists as needed
def _GetDependentFiles(self, path): dependentFiles = self.dependentFiles.get(path) if dependentFiles is None: if sys.platform == "win32": origPath = os.environ["PATH"] os.environ["PATH"] = origPath + os.pathsep + \ os.pathsep.join(sys.path) import cx_Freeze.util try: dependentFiles = cx_Freeze.util.GetDependentFiles(path) except cx_Freeze.util.BindError: # Sometimes this gets called when path is not actually a library # See issue 88 dependentFiles = [] os.environ["PATH"] = origPath else: dependentFiles = [] if sys.platform == "darwin": command = 'otool -L "%s"' % path splitString = " (compatibility" dependentFileIndex = 0 else: command = 'ldd "%s"' % path splitString = " => " dependentFileIndex = 1 for line in os.popen(command): parts = line.expandtabs().strip().split(splitString) if len(parts) != 2: continue dependentFile = parts[dependentFileIndex].strip() if dependentFile == os.path.basename(path): continue if dependentFile in ("not found", "(file not found)"): fileName = parts[0] if fileName not in self.linkerWarnings: self.linkerWarnings[fileName] = None message = "WARNING: cannot find %s\n" % fileName sys.stdout.write(message) continue if dependentFile.startswith("("): continue pos = dependentFile.find(" (") if pos >= 0: dependentFile = dependentFile[:pos].strip() if dependentFile: dependentFiles.append(dependentFile) if sys.platform == "darwin": # Make library paths absolute. This is needed to use # cx_Freeze on OSX in e.g. a conda-based distribution. # Note that with @rpath we just assume Python's lib dir, # which should work in most cases. dirname = os.path.dirname(path) dependentFiles = [p.replace('@loader_path', dirname) for p in dependentFiles] dependentFiles = [p.replace('@rpath', sys.prefix + '/lib') for p in dependentFiles] dependentFiles = self.dependentFiles[path] = \ [f for f in dependentFiles if self._ShouldCopyFile(f)] return dependentFiles
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetFilesForTool(self):\n return ['tools/valgrind/android/vg-chrome-wrapper.sh',\n 'tools/valgrind/memcheck/suppressions.txt',\n 'tools/valgrind/memcheck/suppressions_android.txt']", "def GetFilesForTool(self):\n return ['tools/valgrind/android/vg-chrome-wrapper-tsan.sh',\n ...
[ "0.6188307", "0.60172987", "0.594588", "0.58179677", "0.57686013", "0.57123476", "0.56695175", "0.5656404", "0.56266695", "0.56120116", "0.5609849", "0.5595345", "0.5572678", "0.55723906", "0.5521513", "0.55099297", "0.5491542", "0.5476667", "0.5474204", "0.54685295", "0.5443...
0.5495714
16
Return true if the file should be copied to the target machine. This is done by checking the binPathIncludes, binPathExcludes, binIncludes and binExcludes configuration variables using first the full file name, then just the base file name, then the file name without any version numbers. Files are included unless specifically excluded but inclusions take precedence over exclusions.
def _ShouldCopyFile(self, path): # check for C runtime, if desired path = os.path.normcase(path) dirName, fileName = os.path.split(path) if fileName.startswith("msvcr") and fileName.endswith(".dll"): self.msvcRuntimeDir = dirName return self.includeMSVCR # check the full path if path in self.binIncludes: return True if path in self.binExcludes: return False # check the file name by itself (with any included version numbers) if fileName in self.binIncludes: return True if fileName in self.binExcludes: return False # check the file name by itself (version numbers removed) name = self._RemoveVersionNumbers(fileName) if name in self.binIncludes: return True if name in self.binExcludes: return False # check the path for inclusion/exclusion for path in self.binPathIncludes: if dirName.startswith(path): return True for path in self.binPathExcludes: if dirName.startswith(path): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditional_copy(asciitest_out_dir, doc_file):\n # path join uses backslash win32 which is not cmake compatible\n\n filename = save_cmake_filename(doc_file)\n\n filename1 = os.path.join(asciitest_out_dir, filename + \".temp\").replace(\"\\\\\",\"/\")\n filename2 = os.path.join(asciitest_out_dir, fi...
[ "0.5926794", "0.576537", "0.5734732", "0.563512", "0.55802953", "0.5525144", "0.5376832", "0.5344218", "0.5341193", "0.5339224", "0.5329194", "0.53072923", "0.5279975", "0.5243441", "0.5227413", "0.5205067", "0.51915103", "0.51590645", "0.5157132", "0.51411957", "0.512988", ...
0.80116713
0
Create the module which consists of declaration statements for each of the values.
def Create(self, finder): today = datetime.datetime.today() sourceTimestamp = 0 for module in finder.modules: if module.file is None: continue if module.inZipFile: continue if not os.path.exists(module.file): raise ConfigError("no file named %s (for module %s)", module.file, module.name) timestamp = os.stat(module.file).st_mtime sourceTimestamp = max(sourceTimestamp, timestamp) sourceTimestamp = datetime.datetime.fromtimestamp(sourceTimestamp) self.values["BUILD_TIMESTAMP"] = today.strftime(self.timeFormat) self.values["BUILD_HOST"] = socket.gethostname().split(".")[0] self.values["SOURCE_TIMESTAMP"] = \ sourceTimestamp.strftime(self.timeFormat) module = finder._AddModule(self.moduleName) sourceParts = [] names = list(self.values.keys()) names.sort() for name in names: value = self.values[name] sourceParts.append("%s = %r" % (name, value)) source = "\n".join(sourceParts) module.code = compile(source, "%s.py" % self.moduleName, "exec") return module
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_module(self, body: list, **kwargs):\n return ast.Module(body=body)", "def genH(self,fp):\n id = 0\n for nm in GetOsekObjects('NM'):\n if(self == nm):\n break\n else:\n id += 1\n fp.write('\\n#define %s %s\\n'%(self.name,id...
[ "0.5886545", "0.58752614", "0.585057", "0.57920617", "0.5724532", "0.5722173", "0.56763613", "0.5671061", "0.5638687", "0.55701363", "0.556386", "0.55578065", "0.5548401", "0.553911", "0.5494058", "0.54860514", "0.54860514", "0.54849756", "0.5464117", "0.5413439", "0.54076755...
0.48852018
95
Test that a dotted path is properly converted to a file address.
def test_get_file_path(self): path = self.corpus.get_file_path('chatterbot.corpus.english') self.assertIn( os.path.join('chatterbot_corpus', 'data', 'english'), path )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_valid_pathname(self):\n self.assertTrue(Util.is_pathname_valid('./myrandomvalidfilename.dat'))\n self.assertTrue(Util.is_pathname_valid('myrandomvalidfilename.dat'))", "def test_expand_path_3(self):\n partial_path = \"/fake/path\"\n input_path = \".\" + partial_path\n ...
[ "0.64686894", "0.63700265", "0.63254786", "0.6183657", "0.6174094", "0.6157679", "0.6133528", "0.60470575", "0.6045977", "0.6009044", "0.5981257", "0.5977913", "0.5938566", "0.5925104", "0.5923361", "0.5874661", "0.5874289", "0.5859754", "0.58453584", "0.5831364", "0.58010995...
0.0
-1
Read and convert to example, returns None if no data is available.
def read_and_convert(self, result_file): if self._example_pointer == self._num_examples: return None path_to_image_file = self._path_to_image_files[self._example_pointer] # Get image index index = int(path_to_image_file.split('/')[-1].split('.')[0]) self._example_pointer += 1 label_of_digits = result_file[index].strip().split(' ') # for digits: 10 represents no digit, for letters: 0 represents no letter digits = [10, 10, 10, 10] letters = [0, 0, 0, 0, 0] idd = 0 idl = 0 for i in range(len(label_of_digits)): if i in [0, 4, 5, 6]: digits[idd] = int(label_of_digits[i]) # label 10 is essentially digit zero idd += 1 if i in [1, 2, 3, 7, 8]: letters[idl] = int(label_of_digits[i]) idl += 1 image = Image.open(path_to_image_file) image = image.resize([96, 24]) image = np.array(image).tobytes() example = tf.train.Example(features=tf.train.Features(feature={ 'image': ExampleReader._bytes_feature(image), 'digits': tf.train.Feature(int64_list=tf.train.Int64List(value=digits)), 'letters': tf.train.Feature(int64_list=tf.train.Int64List(value=letters)) })) return example
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def example_to_data(self, example):\n raise NotImplementedError", "def _read_one_example(\n top_example_dir_name, full_storm_id_string, storm_time_unix_sec,\n source_name, radar_field_name, include_sounding):\n\n if source_name == radar_utils.GRIDRAD_SOURCE_ID:\n num_radar_rows = N...
[ "0.7003179", "0.6128065", "0.59333533", "0.562596", "0.560513", "0.559558", "0.5577824", "0.5567824", "0.55473655", "0.55461675", "0.5537794", "0.55172545", "0.55114156", "0.55060756", "0.5497584", "0.5480115", "0.5461704", "0.54357123", "0.5398757", "0.53854465", "0.5373124"...
0.6061454
2
Print the list of toppings that have been requested.
def make_pizza(*toppings): print(toppings)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toppings(request, pizza_id):\r\n pizza = Pizza.objects.get(id=pizza_id)\r\n toppings = pizza.topping_set.order_by('name')\r\n context = {'pizza': pizza, 'toppings': toppings}\r\n return render(request, 'pizzas/toppings.html', context)", "def printResults(self):\n for tweet in self.tweets:\...
[ "0.6459545", "0.6434612", "0.64327085", "0.6416531", "0.61851096", "0.61739594", "0.60970765", "0.6081574", "0.60734904", "0.60210615", "0.60160345", "0.5975071", "0.59174913", "0.5913153", "0.5871116", "0.58542", "0.58345544", "0.58035886", "0.57819474", "0.5701928", "0.5669...
0.5833372
18
Summarize the pizza we are about to make.
def make_pizza(*toppings): print("\nMaking a pizza with the following toppings:") for topping in toppings: print(f"- {topping}")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_summarize_recipe(self):\n pass", "def summarize_food_data(unprocessed_food_list: List[str]) -> List[Dict[str, str]]:\n summary: List[Dict[str, str]] = []\n item_count_data: Dict[str, int] = {}\n\n for item in unprocessed_food_list:\n if item not in item_count_data:\n it...
[ "0.600868", "0.6002266", "0.593303", "0.59114504", "0.5896875", "0.5879344", "0.58790183", "0.5830151", "0.58242345", "0.58242345", "0.58150595", "0.5803258", "0.57938284", "0.57802445", "0.57720184", "0.57685405", "0.57685405", "0.5758228", "0.5754923", "0.57318443", "0.5714...
0.59282035
3
Summarize the pizza we are about to make.
def make_pizza(size, *toppings): print(f"\nMaking {size}-inch pizza with the following toppings:") for topping in toppings: print(f"- {topping}")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_summarize_recipe(self):\n pass", "def summarize_food_data(unprocessed_food_list: List[str]) -> List[Dict[str, str]]:\n summary: List[Dict[str, str]] = []\n item_count_data: Dict[str, int] = {}\n\n for item in unprocessed_food_list:\n if item not in item_count_data:\n it...
[ "0.600868", "0.6002266", "0.59282035", "0.59114504", "0.5896875", "0.5879344", "0.58790183", "0.5830151", "0.58242345", "0.58242345", "0.58150595", "0.5803258", "0.57938284", "0.57802445", "0.57720184", "0.57685405", "0.57685405", "0.5758228", "0.5754923", "0.57318443", "0.57...
0.593303
2
Takes a user and a group name, and returns `True` if the user is in that group.
def is_in_group(user, group_name): return is_in_group_user_id(user.id, group_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_user_in_group(user, group):\n users = group.get_users()\n if user in users:\n return True\n return False", "def is_in_group(user, group_name):\n return user.groups.filter(name__exact=group_name).exists()", "def is_in_group(user, group_name):\n return Group.objects.get(name=group_na...
[ "0.90404195", "0.89909446", "0.8921993", "0.88956964", "0.8691311", "0.8651488", "0.85226196", "0.8471016", "0.8424121", "0.83981097", "0.83976525", "0.8325658", "0.8266118", "0.8199991", "0.81931895", "0.7539715", "0.7505139", "0.7332905", "0.726839", "0.7217727", "0.7149777...
0.90948594
0
Takes a user id and a group name, and returns `True` if the user is in that group.
def is_in_group_user_id(user_id, group_name): try: return Group.objects.get(name=group_name).user_set.filter(id=user_id).exists() except Group.DoesNotExist: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_in_group(user, group_name):\n return is_in_group_user_id(user.id, group_name)", "def is_in_group(user, group_name):\n return Group.objects.get(name=group_name).user_set.filter(id=user.id).exists()", "def is_user_in_group(user, group):\n users = group.get_users()\n if user in users:\n ...
[ "0.9006803", "0.8860701", "0.8772584", "0.87357795", "0.85706574", "0.85022044", "0.8340125", "0.8216126", "0.8146766", "0.810608", "0.8100358", "0.803607", "0.7980639", "0.79746544", "0.7930329", "0.7888287", "0.74050176", "0.7149647", "0.71302086", "0.70612216", "0.70261055...
0.8786698
2
Perform single crossovers on a given population.
def __init__(self, population_fraction, max_crossover_probability, **kwargs): if not (0 < population_fraction <= 1.0): raise ValueError("num_crossover_fraction must be in ]0. 1]") for val in max_crossover_probability: if not (0 < val <= 1.0): raise ValueError( "max_crossover_probability values must be between ]0. 1]") self.population_fraction = population_fraction self.max_crossover_probability = max_crossover_probability super(SingleCrossover, self).__init__(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crossover(self):\n self.sort_population()\n elite_amount = round(self.elite_rate * self.population_size)\n # preserve from the top\n new_population = [ele for ele in self.population if ele.ttl > 0]\n for individual in new_population:\n if individual.ttl > 0:\n ...
[ "0.736195", "0.72073233", "0.7123464", "0.705394", "0.6893509", "0.6868745", "0.6859749", "0.6791421", "0.67872", "0.66507554", "0.6649494", "0.66126937", "0.6332303", "0.63217306", "0.6302329", "0.6289073", "0.62873167", "0.62827295", "0.6282539", "0.624641", "0.6236538", ...
0.55216956
55
'If you create a Lambda function that processes events from streambased services (Amazon Kinesis Streams), the number of shards per stream is the unit of concurrency. If your stream has 100 active shards, there will be 100 Lambda functions running concurrently. Then, each Lambda function processes events on a shard in the order that they arrive.' Therefore, for checkpointing logic, we should make the primary
def handler(event, context): debug = False rewind = False dry_run = False table = _ensure_dynamo_table() consumer_id = 'test-consumer' if debug: state = table.scan() print "Active leases in Dynamo:", state["Count"] for item in state["Items"]: print json.dumps(item, indent=4, sort_keys=True) lease = None shard = None try: visitors = set() last_timestamp = None for i, record in enumerate(event.get('Records', [])): event_id, data = (record['eventID'], record['kinesis']['data']) shard, checkpoint = event_id.split(u':') if rewind: print "Rewinding to checkpoint 0" _clear_consumer_lease(table, consumer_id, shard) rewind = False if lease is None: lease = _get_consumer_lease(table, consumer_id, shard) \ or {"checkpoint": "0"} if checkpoint <= lease["checkpoint"]: # replayed event, we should skip it print "Replayed event; skipping" continue # => decode from b64 raw_event = base64.b64decode(data) # => parse from JSON json_event = json.loads(raw_event) # => extract out visitor id and timestamp if present visitor = json_event.get("visitor_site_id", "N/A") visitors.add(visitor) last_timestamp = json_event.get("ts_action", "N/A") # => do something with the data result = process(json_event) if result: pass # => checkpoint the shard lease["checkpoint"] = checkpoint logger.info("Saw {} unique visitors in batch ending with {}".format( len(visitors), last_timestamp)) if not dry_run: _put_consumer_lease(table, consumer_id, shard, lease) except Exception as ex: # do not save consumer checkpoints because error happened # instead, we should probably log something about the error # in the consumer lease, to allow the Lambda to retry a fixed # number of times, before finally "giving up" and skipping # the records raise "^ some form of error handling required" if ex: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lambda_handler(event, context):\n\n mytime, lambda_name, env_vars = lambda_init.init_lambda(context)\n stage = env_vars[\"stage\"]\n consumer_master_past_lambda = env_vars[\"consumer_master_past_name\"]\n\n apps, test_params = init_apps_from_test_params(event)\n filters = init_filters()\n\n s...
[ "0.6036465", "0.5968453", "0.5582644", "0.54831797", "0.5460034", "0.54361176", "0.5364517", "0.53256035", "0.52649206", "0.5256149", "0.5254377", "0.5188891", "0.5165099", "0.5165099", "0.5149605", "0.51353747", "0.51282066", "0.51216805", "0.5100538", "0.50952226", "0.50934...
0.61084247
0
Create a Render object.
def __init__(self, *args, **kwargs): super(ShotRenderCrawler, self).__init__(*args, **kwargs) parts = self.var("name").split("_") locationParts = parts[0].split("-") # Add the job var once job names on disk match job code names in shotgun self.setVar('seq', locationParts[1], True) self.setVar('shot', parts[0], True) self.setVar('step', parts[1], True) self.setVar('pass', parts[2], True) self.setVar('renderName', '{}-{}'.format( self.var('step'), self.var('pass') ), True )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self):\n raise NotImplementedError(\"Renderer is an abstract class\")", "def make(self):\n\t\tif RENDER_VIEWS > 1:\n\t\t\tself._make()", "def render(self):\n return self", "def render(self):\n raise RenderNotImplemented('Render function is not implemented.')", "def SyncRende...
[ "0.6394629", "0.621124", "0.61963266", "0.6114999", "0.5978222", "0.5978222", "0.5938133", "0.593024", "0.5887697", "0.56696737", "0.5659791", "0.5651973", "0.5642207", "0.5623252", "0.55697376", "0.55697376", "0.55697376", "0.55697376", "0.55697376", "0.55697376", "0.553905"...
0.0
-1
Test if the path holder contains a shot render.
def test(cls, pathHolder, parentCrawler): if not super(ShotRenderCrawler, cls).test(pathHolder, parentCrawler): return False renderType = pathHolder.baseName().split(".")[0].split("_")[-1] return renderType == "sr"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point_is_shot(self, point: Point):\n return point in self.shot_locations", "def test(cls, pathHolder, parentCrawler):\n if not super(TurntableCrawler, cls).test(pathHolder, parentCrawler):\n return False\n\n renderType = pathHolder.baseName().split(\".\")[0].split(\"_\")[-1]\n...
[ "0.66429377", "0.6288864", "0.6145428", "0.6053248", "0.6007993", "0.5842656", "0.5803181", "0.5795196", "0.57627773", "0.5747576", "0.56485415", "0.56485415", "0.5615542", "0.55867237", "0.5571235", "0.55255395", "0.55035883", "0.54886705", "0.5453938", "0.545361", "0.542327...
0.7443225
0
Find links in jsoncompatible data.
def find_links(obj): if isinstance(obj, dict): for key, value in obj.iteritems(): for url in find_links(value): yield url elif isinstance(obj, list): for item in obj: for url in find_links(item): yield url else: try: if is_link(str(obj)): yield obj except Exception: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_urls(json_dict):\n url_list = []\n count = 0\n for i in json_dict[\"items\"]:\n if i[\"is_answered\"]:\n url_list.append(i[\"link\"])\n count += 1\n if count == 3 or count == len(i):\n break\n \n for i in url_list:\n wb.open(i)", "def g...
[ "0.64437044", "0.6328608", "0.6288369", "0.62582314", "0.5989727", "0.5896046", "0.58893055", "0.58317786", "0.58317786", "0.5802547", "0.5788355", "0.57476854", "0.5663333", "0.5635389", "0.5627574", "0.5625349", "0.56044173", "0.5590741", "0.55799675", "0.5561591", "0.55544...
0.66384387
0
Load the correct backend driver for data persistent.
def _load_driver(backend, **kargs): bk_module = importlib.import_module('backend', __package__) driver_cls = getattr(bk_module, str.capitalize(backend) + 'Backend') return driver_cls(**kargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_backend(cls) -> IBackend:\n cls.Lock.acquire()\n try:\n return cls._load_backend()\n finally:\n cls.Lock.release()", "def set_backend(self, backend):\n if backend not in AVAILABLE_BACKENDS:\n raise StorageError(f'Unrecognized backend {backend}...
[ "0.64767873", "0.6454533", "0.6352563", "0.6303405", "0.6164173", "0.59922636", "0.5975386", "0.58862835", "0.58696896", "0.5819013", "0.58041245", "0.5792222", "0.5769137", "0.575706", "0.5755538", "0.5722598", "0.5693296", "0.5691711", "0.5683557", "0.5676043", "0.5659401",...
0.7439424
0
Get the table name to save data from the url.
def _get_table_name(url): try: return urlparse(url).path.strip('/').split('/')[1] except IndexError: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tablename(self):\n _, tail = os.path.split(self.url)\n return tail[:-4]", "def table_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"table_name\")", "def table_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"table_name\")", "def table_name(self) -> pu...
[ "0.72730315", "0.6656085", "0.6656085", "0.6656085", "0.65448517", "0.64656055", "0.6451091", "0.6374937", "0.6281148", "0.6230515", "0.61168766", "0.60657483", "0.6009189", "0.5981553", "0.5945678", "0.5933731", "0.5901814", "0.5891688", "0.5882904", "0.58783686", "0.5870253...
0.7577692
0
Check if this url contains an item detail.
def item_url(url): return all(map(lambda x: str.isdigit(x), str(url.strip('/').split('/')[-1])))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_details(self):\n return hasattr(self, 'details')", "def is_view_price_list_detail_present(self):\n return self.is_element_present(self.view_price_list_detail_locator)", "def is_item_complete(self, item):\n return (item.get('id') and\n item.get('name') and\n ...
[ "0.6802034", "0.6584066", "0.64352536", "0.62934774", "0.6240942", "0.6176948", "0.612433", "0.61073184", "0.59965223", "0.59712005", "0.5829178", "0.5820094", "0.58197546", "0.58129585", "0.5806847", "0.5757746", "0.57442445", "0.57396597", "0.572949", "0.5726727", "0.571683...
0.0
-1
Save data from response to backend persistent driver. Only save the detail item from a url, filter out the overall items like
def save(self, response): url = response.url if self.item_url(url): table_name = self._get_table_name(url) if table_name: data = response.json() self.backend.save(table_name, data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_detail(self, response):\n\n self.logger.log(self.log_lvl, 'scraping data @ {}'.format(response.url))\n\n item_list = list()\n image_urls = list()\n # extract image\n try:\n pattern = re.compile(r\"(.*imagearray:)(.*)(,.*displaymode.*)\", re.MULTILINE | re.DOT...
[ "0.5922734", "0.5857825", "0.5833559", "0.5798279", "0.5555864", "0.55542606", "0.5488991", "0.5482613", "0.54276925", "0.5380093", "0.53528607", "0.5344608", "0.53070605", "0.5304953", "0.5301043", "0.5283759", "0.52696395", "0.5248865", "0.52482927", "0.5235908", "0.5224081...
0.690983
0
Tests basic whitelist functionality
def test_whitelist(self): p = self.load_policy({ 'name': 'test-key-vault', 'resource': 'azure.keyvault', 'filters': [ {'type': 'value', 'key': 'name', 'op': 'glob', 'value_type': 'normalize', 'value': 'cckeyvault1*'}, {'not': [ {'type': 'whitelist', 'key': 'principalName', 'users': ['account1@sample.com']} ]} ] }) resources = p.run() self.assertEqual(len(resources), 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_to_whitelist(self):\n\n self.feature_test.add_to_whitelist(3)\n self.assertTrue(3 in Feature(\"testing\").whitelist)", "def test_add_to_whitelist_with_string(self):\n email = 'example@example.com'\n self.feature_test.add_to_whitelist(email)\n self.assertTrue(email ...
[ "0.7257275", "0.69541496", "0.6669898", "0.6634256", "0.63836783", "0.61440814", "0.607428", "0.6058461", "0.60226995", "0.60136276", "0.59704053", "0.59617037", "0.5960837", "0.59211046", "0.59204555", "0.59204555", "0.5909409", "0.59081924", "0.5890749", "0.5881475", "0.587...
0.67256504
2
Tests that a keyvault with 0 access policies is processed properly and doesn't raise an exception.
def test_whitelist_zero_access_policies(self): p = self.load_policy({ 'name': 'test-key-vault', 'resource': 'azure.keyvault', 'filters': [ {'type': 'value', 'key': 'name', 'op': 'glob', 'value_type': 'normalize', 'value': 'cckeyvault2*'}, {'not': [ {'type': 'whitelist', 'key': 'principalName', 'users': ['account1@sample.com']} ]} ] }) resources = p.run() self.assertEqual(len(resources), 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_authz_file_empty_raises(self):\n self.env.config.set('authz_policy', 'authz_file', '')\n self.assertRaises(ConfigurationError, self.check_permission,\n 'WIKI_VIEW', 'änon', None, None)", "def noaccess(self):\n self.assertEqual(self.client.get(self.ENDPOINT)....
[ "0.615517", "0.6075056", "0.6071155", "0.6068709", "0.59903747", "0.5970702", "0.59659946", "0.5951002", "0.5945882", "0.5927157", "0.59155506", "0.5856525", "0.58519167", "0.5801739", "0.5789592", "0.5782919", "0.5781346", "0.577808", "0.5775319", "0.576997", "0.57695985", ...
0.7272632
0
Filters a list of elements. 'viewer' is the viewer that we are filtering elements for. 'parent' is the parent element. 'elements' is the list of elements to filter. Returns a list containing only those elements for which 'select' returns True.
def filter(self, viewer, parent, elements): return [e for e in elements if self.select(viewer, parent, e)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select(self, viewer, parent, element):\n\n return True", "def filter_by_reviewers(reviews, selected_reviewers):\n return [x for x in reviews if x.reviewer in selected_reviewers]", "def validate(elements):\n return list(filter(lambda el: el.is_valid, elements))", "def select(elements, val...
[ "0.53416806", "0.5286004", "0.516275", "0.51596725", "0.5059366", "0.5055007", "0.50266373", "0.49372914", "0.4907756", "0.47648945", "0.47609642", "0.46878317", "0.46518713", "0.46268824", "0.46157223", "0.4608182", "0.4597628", "0.45550662", "0.45305058", "0.45274553", "0.4...
0.87938285
0
Returns True if the element is 'allowed' (ie. NOT filtered). 'viewer' is the viewer that we are filtering elements for. 'parent' is the parent element. 'element' is the element to select. By default we return True.
def select(self, viewer, parent, element): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_element_in_view(self, element: Element) -> bool:\n return self.find_element_view(element=element) is not None", "def tag_visible(element):\n\n if element.parent.name in ['style', 'script', 'head', 'title', 'meta', '[document]']:\n return False\n if isinstance(element, Comment):\n ...
[ "0.59139556", "0.57015985", "0.5638367", "0.54528904", "0.5326502", "0.52207935", "0.5189183", "0.51695454", "0.5162016", "0.51491517", "0.50781363", "0.49656478", "0.49402714", "0.49008185", "0.48731193", "0.48402408", "0.4839491", "0.48392522", "0.48301572", "0.48110285", "...
0.6605754
0
Is the filter affected by changes to an element's trait? 'element' is the element. 'trait_name' is the name of the trait. Returns True if the filter would be affected by changes to the trait named 'trait_name' on the specified element. By default we return False.
def is_filter_trait(self, element, trait_name): return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_element_in_view(self, element: Element) -> bool:\n return self.find_element_view(element=element) is not None", "def has_visibility(trait, visibility_name):\n\n return trait.visibility == getattr(schema.Trait.Visibility, visibility_name)", "def contains(self, element) -> bool:\n\n return ...
[ "0.5432807", "0.5380321", "0.5154928", "0.50004315", "0.49823684", "0.4972386", "0.49546346", "0.49431932", "0.4915069", "0.4896147", "0.48712415", "0.48191318", "0.48169592", "0.47890756", "0.4781882", "0.47721133", "0.47471988", "0.47195056", "0.47182444", "0.46942788", "0....
0.7937278
0
A BFS solution that runs in O(N)
def bfs(self, root: TreeNode) -> int: if not root: return 0 queue = deque([(root, 1)]) while queue: node, level = queue.popleft() if not node.left and not node.right: return level if node.left: queue.append((node.left, level + 1)) if node.right: queue.append((node.right, level + 1)) return -1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bfs(graph,start):\n #keeps track of nodes to be visited\n queue = []\n #keeps track of nodes already visited\n explored = []\n queue.append(start)\n while queue:\n #remove first node from queue\n curr_node = queue.pop(0)\n #check if node is visited\n if curr_node not in explored:\n explo...
[ "0.7630348", "0.7485004", "0.7482269", "0.746009", "0.73893636", "0.7359191", "0.7313912", "0.72900593", "0.7280733", "0.7267169", "0.72345245", "0.72265714", "0.71806186", "0.71715397", "0.7168454", "0.7154696", "0.713683", "0.7130648", "0.7121028", "0.706812", "0.706548", ...
0.0
-1
A DFS solution that runs in O(N) in time and space
def dfs(self, root: TreeNode) -> int: if not root: return 0 def dfs(node): if not node: return float('inf') if not node.left and not node.right: return 1 return min(dfs(node.left), dfs(node.right)) + 1 return dfs(root)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterativeDeepeningSearch(problem):\n from util import Stack\n \n for max_depth in range(0, 10000000):\n # print max_depth\n st = Stack()\n mapper = {}\n mapper[(problem.getStartState(), 0)] = None #map of (childpos, depth): (parentpos, direction, depth)\n st.push((pr...
[ "0.7127771", "0.71177804", "0.70137775", "0.6997336", "0.6967545", "0.6946851", "0.6918456", "0.69104403", "0.68680465", "0.68369263", "0.68138105", "0.6810762", "0.6806383", "0.6798006", "0.6774225", "0.675221", "0.673416", "0.67276394", "0.6717568", "0.66977406", "0.6696019...
0.0
-1
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
def minDepth(self, root: TreeNode) -> int: return self.bfs(root)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_depth(node):\n if not node:\n return 0\n elif (not node.left) and (not node.right):\n # found leaf\n return 1\n elif not node.left:\n # if the root has only 1 child, this prevents the minimum depth from\n # equaling zero\n return min_depth(node.right) + 1\...
[ "0.8461286", "0.8181243", "0.71641576", "0.7144373", "0.6993832", "0.6950117", "0.6907654", "0.6858466", "0.68347263", "0.6743698", "0.67391497", "0.6727257", "0.6615435", "0.6594133", "0.657416", "0.6555998", "0.6510495", "0.64694285", "0.646406", "0.6413745", "0.6391296", ...
0.86733794
0
Converts the complex number `c` to a string in Fortranformat, i.e. (Re c, Im c). If c is iterable, it returns a string of the form [(Re c_1, Im c_1), ...].
def str_complex(c, kindstr=''): if hasattr(c, '__iter__'): return '[' + ', '.join([str_complex(c_i, kindstr) for c_i in c]) + ']' else: c = complex(c) return '({}{}, {}{})'.format(c.real, kindstr, c.imag, kindstr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complex_vct_str ( vct , format = '%.5g%-+.5gj' ) :\n try :\n lst = [] \n for c in vct :\n cc = complex ( c )\n item = format % ( cc.real , cc.imag )\n lst.append ( cc ) \n return '[ ' + ', '.join ( lst ) + ' ]' \n except TypeError :\n ...
[ "0.7047887", "0.58852553", "0.5754803", "0.5726591", "0.57228047", "0.56523186", "0.56442934", "0.56111693", "0.5576192", "0.55657303", "0.5538955", "0.55268145", "0.5501663", "0.54070234", "0.5394753", "0.53852344", "0.536029", "0.535686", "0.53531355", "0.53468204", "0.5337...
0.7722821
0
Select PORT update events, notify the observers upon a port update in APPL_DB/CONFIG_DB or a XCVR insertion/removal in STATE_DB
def handle_port_update_event(sel, asic_context, stop_event, logger, port_change_event_handler): if not stop_event.is_set(): (state, _) = sel.select(SELECT_TIMEOUT_MSECS) if state == swsscommon.Select.TIMEOUT: return if state != swsscommon.Select.OBJECT: logger.log_warning('sel.select() did not return swsscommon.Select.OBJECT') return for port_tbl in asic_context.keys(): while True: (key, op, fvp) = port_tbl.pop() if not key: break if not validate_port(key): continue fvp = dict(fvp) if fvp is not None else {} if 'index' not in fvp: fvp['index'] = '-1' port_index = int(fvp['index']) port_change_event = None if op == swsscommon.SET_COMMAND: port_change_event = PortChangeEvent(key, port_index, asic_context[port_tbl], PortChangeEvent.PORT_SET, fvp) elif op == swsscommon.DEL_COMMAND: port_change_event = PortChangeEvent(key, port_index, asic_context[port_tbl], PortChangeEvent.PORT_DEL, fvp) if port_change_event is not None: port_change_event_handler(port_change_event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _port_status_handler(self, ev):\n msg = ev.msg\n reason = msg.reason\n port_no = msg.desc.port_no\n dpid = msg.datapath.id\n ofproto = msg.datapath.ofproto\n\n reason_dict = {ofproto.OFPPR_ADD: \"added\",\n ofproto.OFPPR_DELETE: \"deleted\",\n ...
[ "0.62168676", "0.6123209", "0.60724276", "0.60613334", "0.60579395", "0.6057897", "0.60528636", "0.59052724", "0.58132577", "0.5790811", "0.5715928", "0.5668344", "0.56622344", "0.5567299", "0.55424833", "0.54548216", "0.5438808", "0.5418422", "0.5405286", "0.5364919", "0.534...
0.6788266
0
Select CONFIG_DB PORT table changes, once there is a port configuration add/remove, notify observers
def handle_port_config_change(sel, asic_context, stop_event, port_mapping, logger, port_change_event_handler): if not stop_event.is_set(): (state, _) = sel.select(SELECT_TIMEOUT_MSECS) if state == swsscommon.Select.TIMEOUT: return if state != swsscommon.Select.OBJECT: logger.log_warning('sel.select() did not return swsscommon.Select.OBJECT') return read_port_config_change(asic_context, port_mapping, logger, port_change_event_handler)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_port( self ):\n # disconnect and delete controller\n self.delete_controller()\n \n # update port\n self.update_port()", "def check_device_changes(self):\n\n #---------------------------------------------------------------------------\n # USB ports\n ...
[ "0.60486573", "0.601688", "0.6003362", "0.5990358", "0.5919747", "0.5897559", "0.5824499", "0.5805411", "0.57939553", "0.5755642", "0.5738589", "0.57356256", "0.56507355", "0.5590035", "0.55844575", "0.5562933", "0.5554786", "0.55488783", "0.5544349", "0.5528714", "0.55249166...
0.6089049
0
Get port mapping from CONFIG_DB
def get_port_mapping(namespaces): port_mapping = PortMapping() for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) config_db = daemon_base.db_connect("CONFIG_DB", namespace=namespace) port_table = swsscommon.Table(config_db, swsscommon.CFG_PORT_TABLE_NAME) for key in port_table.getKeys(): if not validate_port(key): continue _, port_config = port_table.get(key) port_config_dict = dict(port_config) port_change_event = PortChangeEvent(key, port_config_dict['index'], asic_id, PortChangeEvent.PORT_ADD) port_mapping.handle_port_change_event(port_change_event) return port_mapping
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getDbPort():\n\n if \"DB_PORT\" in controller.CONF.keys():\n return controller.CONF[\"DB_PORT\"]\n\n return basedefs.DB_PORT", "def db_port(self) -> Optional[int]:\n return pulumi.get(self, \"db_port\")", "def get_all_port(self, conf, dpid):\n\t\tpass", "def get_port_binding():\n ...
[ "0.6964796", "0.6683577", "0.653418", "0.65336806", "0.6416702", "0.628645", "0.6283446", "0.6275742", "0.6270378", "0.6266905", "0.62222916", "0.6177558", "0.60762554", "0.60760283", "0.597032", "0.59239864", "0.5915565", "0.59000075", "0.58872294", "0.5862604", "0.5836161",...
0.6833719
1
Add a class that doesn't descend from Pickleable to the pickle whitelist
def addClassToPickleWhitelist(cls): unpickleWhitelist_.add(cls)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_class(self, module, name):\n raise pickle.UnpicklingError(\"global '%s.%s' is forbidden\" %\n (module, name))", "def test__pickle_unpickle(self):\n pass", "def __reduce__(self) -> NoReturn:\n raise TypeError(\n \"can't...
[ "0.5848995", "0.5714878", "0.5440713", "0.5331448", "0.53248143", "0.5274852", "0.5263136", "0.5262969", "0.5250038", "0.52005446", "0.5171152", "0.515845", "0.5151149", "0.51253116", "0.51061636", "0.51053673", "0.5073575", "0.5070191", "0.5066985", "0.5048813", "0.50263953"...
0.8570413
0
Override the serializer to use 'override' as the identifier for instances of 'cls' This is primarily to shorted the amount of data in the representation and to allow the representation to remain constant even if classes are moving around or changing names. override may not be a tuple
def addOverride(cls, override): assert cls not in locationTypeOverrides_ assert not isinstance(override, tuple) locationTypeOverrides_[cls] = override locationTypes_[override] = cls
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(cls, *args, **kwargs):\n return serialize_cls(cls)(*args, **kwargs)", "def serialize_cls(cls):\n return _create_wrapper_cls(cls)", "def default_serializer(_cls: Type[Any], obj: Any) -> Any:", "def __call__(\n self, cls: Type, key: Optional[str] = None, override: bool = False, show_...
[ "0.6116893", "0.6029395", "0.5879258", "0.5812591", "0.5711086", "0.55567217", "0.55458784", "0.5513836", "0.5463761", "0.5428988", "0.5375427", "0.5358711", "0.5357488", "0.5266866", "0.5182065", "0.5126839", "0.51204216", "0.5094683", "0.5066752", "0.5049762", "0.5035309", ...
0.5931994
2
Convert 'x' from a simplified form to the full CG form.
def toComplex(simpleObject): if simpleObject[0] == ENCODING_SIMPLE_PYTHON: return simpleObject[1] if simpleObject[0] == ENCODING_INT: return int(simpleObject[1]) if simpleObject[0] == ENCODING_UNICODE: return unicode(simpleObject[1], 'utf-8') if simpleObject[0] == ENCODING_LONG: return long(simpleObject[1]) if simpleObject[0] == ENCODING_TUPLE: return tuple([toComplex(x) for x in simpleObject[1]]) if simpleObject[0] == ENCODING_LIST: return [toComplex(x) for x in simpleObject[1]] if simpleObject[0] == ENCODING_DICT: return dict((toComplex(k), toComplex(v)) for k,v in simpleObject[1]) elif simpleObject[0] == ENCODING_OBJECT: clsModuleAndName = simpleObject[1][0] args = simpleObject[1][1] cls = classFromModuleAndName(clsModuleAndName) kwds = toComplex(args) try: return cls(**kwds) except: raise UserWarning("Failed to construct instance of %s with %s" % (cls, kwds)) raise UserWarning("Badly encoded object")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _to_clips_value(cls, x):\n return x", "def _canon_cg(expr):\n return expr.replace(CG, _canon_cg_core)", "def reconstruct(self, x):\n return self.inverse_transform(self.transform(x))", "def construct(self, x):\n return self.double_conv(x)", "def call(self, x):\n self._chec...
[ "0.62322056", "0.5949095", "0.5794452", "0.57718503", "0.56907374", "0.5687841", "0.56126106", "0.5525381", "0.55237037", "0.55102", "0.5448745", "0.5415053", "0.5387446", "0.53741324", "0.5301165", "0.517558", "0.5163078", "0.515195", "0.5121617", "0.51215816", "0.5120705", ...
0.0
-1
`sam list stackoutputs` command entry point
def cli(self, stack_name, output, config_file, config_env): do_cli(stack_name=stack_name, output=output, region=self.region, profile=self.profile)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_cli(stack_name, output, region, profile):\n from samcli.commands.list.stack_outputs.stack_outputs_context import StackOutputsContext\n\n with StackOutputsContext(\n stack_name=stack_name, output=output, region=region, profile=profile\n ) as stack_output_context:\n stack_output_context...
[ "0.7447414", "0.7092905", "0.6619107", "0.6294256", "0.62495506", "0.6235097", "0.6223217", "0.5894003", "0.58861333", "0.58443314", "0.57637775", "0.5655446", "0.56269765", "0.56182945", "0.5560416", "0.5491101", "0.5430899", "0.5425569", "0.5410986", "0.54088354", "0.538655...
0.5937543
7
Implementation of the ``cli`` method
def do_cli(stack_name, output, region, profile): from samcli.commands.list.stack_outputs.stack_outputs_context import StackOutputsContext with StackOutputsContext( stack_name=stack_name, output=output, region=region, profile=profile ) as stack_output_context: stack_output_context.run()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():", "def cli():"...
[ "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233", "0.85499233"...
0.0
-1
Plot an image along with its histogram and cumulative histogram.
def plot_img_and_hist(image, axes, bins=256): image = img_as_float(image) ax_img, ax_hist = axes ax_cdf = ax_hist.twinx() # Display image ax_img.imshow(image, cmap=plt.cm.gray) ax_img.set_axis_off() # Display histogram ax_hist.hist(image.ravel(), bins=bins, histtype='step', color='black') ax_hist.ticklabel_format(axis='y', style='scientific', scilimits=(0, 0)) ax_hist.set_xlabel('Pixel intensity') ax_hist.set_xlim(0, 1) ax_hist.set_yticks([]) # Display cumulative distribution img_cdf, bins = exposure.cumulative_distribution(image, bins) ax_cdf.plot(bins, img_cdf, 'r') ax_cdf.set_yticks([]) return ax_img, ax_hist, ax_cdf
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_img_and_hist(image, axes, bins=256):\n# image = img_as_float(image)\n ax_img, ax_hist = axes\n ax_cdf = ax_hist.twinx()\n\n # Display image\n ax_img.imshow(image, cmap=plt.cm.gray);\n ax_img.set_axis_off()\n\n # Display histogram\n ax_hist.hist(image.ravel(), bins=bins, histtype='...
[ "0.7969631", "0.78266644", "0.7776819", "0.74996084", "0.7412575", "0.72977114", "0.68852156", "0.6873014", "0.6869999", "0.668876", "0.66544735", "0.66544735", "0.66544735", "0.66200167", "0.652162", "0.6493563", "0.64923745", "0.6483739", "0.64781225", "0.6413293", "0.63585...
0.7809336
3
Download metadata catalogues necessary for downloading via FORCE if user confirms.
def download_catalogues(directory): while True: answer = input(f"\nTo download datasets via FORCE, it is necessary to have " f"metadata catalogues stored in a local directory (size ~9 GB).\n " f"More information: https://force-eo.readthedocs.io/en/latest/howto/level1-csd.html#downloading-the-metadata-catalogues \n" f"Do you want to download the latest catalogues into {directory}? (y/n)") if answer in ['y', 'yes']: print("\n#### Starting download...") utils.isdir_mkdir(directory) out = Client.execute(FORCE_PATH, ["force-level1-csd", "-u", directory], options=["--cleanenv"], stream=True) for line in out: print(line, end='') elif answer in ['n', 'no']: print("\n#### Download cancelled...") sys.exit() else: print(f"\n{answer} is not a valid answer!") continue
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _download_metadata():\n if not os.path.isfile(L1000FWD_METADATA):\n if not os.path.exists('L1000FWD'):\n os.mkdir('L1000FWD')\n response = requests.get('https://amp.pharm.mssm.edu/l1000fwd/download/Drugs_metadata.csv', stream=True)\n if response.status_code != 200:\n ...
[ "0.6125075", "0.6057573", "0.5919949", "0.59092546", "0.58205396", "0.57917017", "0.5775783", "0.5760028", "0.5726218", "0.56873673", "0.5681924", "0.5636815", "0.5625458", "0.5623649", "0.5623649", "0.56185186", "0.55663484", "0.55158645", "0.5502782", "0.54930496", "0.54860...
0.5666497
11
Recursively searches for 'datacubedefinition.prj' in a level2 directory and returns its parent directory.
def _get_datacubeprj_dir(directory): prj_path = [] for path in Path(directory).rglob('datacube-definition.prj'): prj_path.append(path) if len(prj_path) < 1: raise FileNotFoundError(f"'datacube-definition.prj' not found in {directory}") elif len(prj_path) > 1: raise RuntimeError(f"'datacube-definition.prj' multiple copies found in {directory}") else: return prj_path[0].parent
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_parent_path(self):\n return os.path.join(os.getcwd(), \"src\", \"data\", \"genes\")", "def find_in_parent_dir(fname):\n p = os.path.abspath(os.path.curdir)\n \n while not os.path.exists(os.path.join(p, project_conf_name)):\n oldp, p = p, os.path.dirname(p)\n if p == oldp:\n...
[ "0.59310746", "0.5910224", "0.5907544", "0.56730086", "0.567043", "0.54829234", "0.5468787", "0.5349158", "0.53045815", "0.52922255", "0.52142084", "0.52010685", "0.519746", "0.51958925", "0.51642823", "0.5158747", "0.51506376", "0.51362514", "0.5133889", "0.51276433", "0.511...
0.72337234
0
send 1 to enable motor
def timer_callback(self): self.i += 1 ms=MotorState() ms.state=1 self.motor_state_pub.publish(ms)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable_motor():\n print('Enabling motor')\n start_motor = '{\"id\" : \"Motor1\", \"enabled\" : \"1\"}'\n SERIAL_PARENT.send(start_motor)\n OUTGOING.append(start_motor)", "def enable_motor(self, enabled):\r\n self.enabled = enabled\r\n\r\n # Set motors in neutral if disabling.\r\n ...
[ "0.8308927", "0.72755456", "0.71145564", "0.69568515", "0.68919075", "0.6866074", "0.6863435", "0.68514323", "0.683486", "0.6831353", "0.68029517", "0.6771648", "0.6737354", "0.6695286", "0.66666657", "0.6659766", "0.66348124", "0.66312325", "0.6606162", "0.65834403", "0.6577...
0.0
-1
Create the list of dictionaries
def load_training_data(vocab, directory): top_level = os.listdir(directory) dataset = [] for d in top_level: if d[-1] == '/': label = d[:-1] subdir = d else: label = d subdir = d+"/" files = os.listdir(directory+subdir) for f in files: bow = create_bow(vocab, directory+subdir+f) dataset.append({'label': label, 'bow': bow}) return dataset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_list_dict(list_of_nodes: List['Part']):\n list_of_part_dict = list()\n\n return list_of_part_dict", "def codebook_json_data_factory() -> List[Dict[str, Any]]:\n codebook_data = [\n {\n Features.CODEWORD: [\n {Indices.ROUND.value: 0, Indices.CH.value: 0...
[ "0.69087183", "0.67974454", "0.6580766", "0.65108544", "0.64887786", "0.6461656", "0.64098716", "0.64027894", "0.64027894", "0.6329244", "0.63245296", "0.6318974", "0.62794995", "0.62457955", "0.6242187", "0.6208534", "0.61998814", "0.6194605", "0.6188527", "0.61769027", "0.6...
0.0
-1
Create a vocabulary from the training directory return a sorted vocabulary list
def create_vocabulary(directory, cutoff): top_level = os.listdir(directory) a = cutoff vocab = {} for d in top_level: subdir = d if d[-1] == '/' else d+'/' files = os.listdir(directory+subdir) for f in files: with open(directory+subdir+f,'r', encoding="utf-8") as doc: for word in doc: word = word.strip() if not word in vocab and len(word) > 0: vocab[word] = 1 elif len(word) > 0: vocab[word] += 1 return sorted([word for word in vocab if vocab[word] >= cutoff])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_vocabulary(vocabulary_path, json_vocab_path):\n if not gfile.Exists(vocabulary_path):\n print(\"Transform vocabulary to %s\" % vocabulary_path)\n with gfile.GFile(json_vocab_path, mode=\"rb\") as f:\n jvocab = json.load(f)\n vocab = jvocab['w2id']\n voca...
[ "0.72303003", "0.7164037", "0.71459424", "0.7054131", "0.7033178", "0.700483", "0.68919396", "0.68904585", "0.68769383", "0.6866679", "0.6859989", "0.6854887", "0.6839105", "0.6836058", "0.68341655", "0.6810794", "0.6810794", "0.6805193", "0.6802589", "0.6783411", "0.6731821"...
0.7643122
0
Create a single dictionary for the data
def create_bow(vocab, filepath): bow = {} # TODO: add your code here wordcount = 0 wordcountnone = 0 c = 0 for i in vocab: c+=1 with open(filepath, 'r', encoding="utf-8") as doc: ############################################### for word in doc: word = word.strip() if(c==1): if (word not in vocab): wordcountnone += 1 if(i == str(word)): wordcount += 1 #print(wordcount) if(wordcount > 0): bow[i] = wordcount wordcount = 0 if(wordcountnone != 0): bow[None] = wordcountnone return bow
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data_to_create_object(self):\n return {}", "def as_dict(self) -> dict[str, Any]:\n return {\n \"type\": self.type,\n \"timestamp\": self.timestamp,\n \"data\": self.data or {},\n }", "def dict(self):\n d = {}\n d['template_id'] = self....
[ "0.74594545", "0.6839548", "0.675466", "0.66805357", "0.666756", "0.6639752", "0.6629121", "0.65938157", "0.658765", "0.6585759", "0.6554827", "0.6547288", "0.65392995", "0.65266854", "0.651302", "0.64879346", "0.6485962", "0.64473516", "0.6439832", "0.6439223", "0.64320755",...
0.0
-1
return the prior probability of the label in the training set => frequency of DOCUMENTS
def prior(training_data, label_list): smooth = 1 # smoothing factor logprob = {} # TODO: add your code here numfile1 = 0 numfile2 = 0 for dic in training_data: if(dic["label"] == label_list[0]): numfile1 += 1 elif(dic["label"] == label_list[1]): numfile2 += 1 numtotal = numfile1 + numfile2 prob1 = (numfile1+smooth)/(numtotal+2) prob2 = (numfile2 + smooth) / (numtotal + 2) logprob[label_list[0]] = math.log(prob1) logprob[label_list[1]] = math.log(prob2) return logprob
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predictability(self):\n temp = self.probs\n for n in range(10):\n temp = temp.dot(temp)\n final = temp[0,:]\n #Let's assume that all words have unique initial letters\n probs = map(len, self.words)\n probs = array(probs)\n probs = (probs + self.probs....
[ "0.71765524", "0.7150891", "0.71340966", "0.6940001", "0.6911364", "0.68786913", "0.6726276", "0.6663634", "0.66374254", "0.6611508", "0.6575516", "0.6557912", "0.6525762", "0.65140253", "0.64985853", "0.64976215", "0.64904463", "0.6479281", "0.64610314", "0.6453354", "0.6435...
0.71356946
2
return the class conditional probability of label over all words, with smoothing
def p_word_given_label(vocab, training_data, label): smooth = 1 # smoothing factor word_prob = {} # TODO: add your code here total_word = 0 word_prob[None] = 0 for dic in training_data: for index0, i0 in enumerate(dic['bow']): if (list(dic['bow'])[index0] in word_prob): continue; word_prob[list(dic['bow'])[index0]] = 0 #word_prob[None] = 0 if(dic["label"] == label): for index, i in enumerate(dic["bow"]): if(list(dic['bow'])[index] in vocab): if(list(dic['bow'])[index] in word_prob): word_prob[list(dic['bow'])[index]] += dic["bow"][i] else: word_prob[list(dic['bow'])[index]] = dic["bow"][i] else: if(None in word_prob): word_prob[None] += dic["bow"][i] else: word_prob[None] = 0 total_word += dic["bow"][i] #word_prob [None] = 5 for h in word_prob: word_prob[h] = math.log((word_prob[h] + smooth*1)) - math.log((total_word + smooth*(len(vocab) +1))) return word_prob
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predictability(self):\n temp = self.probs\n for n in range(10):\n temp = temp.dot(temp)\n final = temp[0,:]\n #Let's assume that all words have unique initial letters\n probs = map(len, self.words)\n probs = array(probs)\n probs = (probs + self.probs....
[ "0.7158563", "0.68635947", "0.6840666", "0.66153693", "0.6609253", "0.6576637", "0.6564863", "0.653211", "0.6521681", "0.6498006", "0.6471072", "0.640781", "0.63957083", "0.6352886", "0.6348521", "0.6348173", "0.634401", "0.634401", "0.6340316", "0.63331866", "0.6293823", "...
0.7195733
0
Check if the string is palindrome.
def isPalindrome(string): for i in range(len(string)//2): if string[i] != string[(i*-1)-1]: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_palindrome(string):\n return", "def check_palindrome(s):\n return s[::-1] == s", "def is_palindrome(string):\n return string[::-1] == string", "def is_palindrome_v1(s):\n return reverse(s) == s", "def is_palindrome(string):\n if string == string[::-1]:\n return True\n return...
[ "0.89631575", "0.88805836", "0.8844723", "0.87995744", "0.8799044", "0.8768949", "0.8720113", "0.87144065", "0.86752564", "0.8644568", "0.8638425", "0.8585656", "0.85773665", "0.8561977", "0.8518276", "0.8494618", "0.84669435", "0.84236455", "0.8422641", "0.8409156", "0.84011...
0.84398353
17
Find all pairs of unique indices which form a palindrome.
def palindromePairs(lst): results = [] for i, e1 in enumerate(lst): for j, e2 in enumerate(lst): if i != j: if isPalindrome(e1+e2): results.append((i, j)) return results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindromePairs(self, words: List[str]) -> List[List[int]]:\n d = {w : i for i, w in enumerate(words)}\n \n res = []\n for idx, word in enumerate(words):\n for i in range(len(word)+1):\n str1 = word[:i]\n str2 = word[i:]\n # fi...
[ "0.7363634", "0.7076098", "0.70694715", "0.6878793", "0.67712194", "0.67707276", "0.67490494", "0.65257967", "0.6466228", "0.63992494", "0.63456815", "0.633291", "0.6321037", "0.62712246", "0.6258766", "0.6231323", "0.6217285", "0.62059194", "0.6202977", "0.6194959", "0.61816...
0.78059846
0
Sets the properties mean, count and sum for an object if a reduceRegion operation returns no values in earth engine one cannot join the result list with a list of the zones without setting a nodata (9999) value first
def ensure_default_properties(obj): obj = ee.Dictionary(obj) default_properties = ee.Dictionary({"mean": -9999,"count": -9999,"sum":-9999}) return default_properties.combine(obj)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def region_stats(ds, mask, region_name):\n agg = ds.where(mask == arctic_mask_region[region_name]).mean(dim=['x','y'])\n if 'latitude' in agg:\n agg = agg.drop('latitude')\n if 'longitude' in agg:\n agg = agg.drop('longitude')\n return agg", "def addOverallMeans(results, fieldNames, fie...
[ "0.58719265", "0.5710536", "0.5359844", "0.5348019", "0.5338033", "0.52508754", "0.5220636", "0.5190192", "0.5181222", "0.5081943", "0.5053021", "0.5022049", "0.5003427", "0.5002751", "0.4982933", "0.496246", "0.496002", "0.49582618", "0.49564335", "0.4926023", "0.49112692", ...
0.5071645
10
filter results by key server side function.
def mapList(results, key): newResult = results.map(lambda x: ee.Dictionary(x).get(key)) return newResult
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_by(self, key: str, *args, **kwargs):\n filter_ = self.filters.get(key)\n if not filter_:\n raise ValueError(key)\n return filter_(*args, **kwargs)", "def filter_keys_c(func):\n return partial(filter_keys, func)", "def filter(self, key):\n with suppress(KeyEr...
[ "0.7041496", "0.67481804", "0.66853714", "0.6602866", "0.6594346", "0.6538373", "0.62875813", "0.625645", "0.6235937", "0.61752564", "0.617185", "0.6147107", "0.61328727", "0.6030898", "0.59337604", "0.5894746", "0.58756953", "0.58703166", "0.5859899", "0.5856352", "0.5783209...
0.0
-1
Convert a dictionary to an earth engine feature server side
def dict_to_feature(d): f = ee.Feature(None,ee.Dictionary(d)) return f
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _preprocess(self, feature_dict):\n return feature_dict", "def from_dict(cls, dikt) -> 'Features':\n return util.deserialize_model(dikt, cls)", "def dict_to_feature(feature_dict, keys, max_value=None):\n feature = []\n for key, val in feature_dict.items(): # First level\n if key not ...
[ "0.6012967", "0.5905541", "0.58329165", "0.57612747", "0.5738102", "0.5726723", "0.5687374", "0.56813467", "0.5624164", "0.56068397", "0.5599818", "0.5524402", "0.548304", "0.5466543", "0.5398618", "0.53919345", "0.53797644", "0.5355627", "0.53457856", "0.5333529", "0.5318250...
0.78169143
0
Convert volume to flux
def volumeToFlux(volume_image): image = ee.Image(volume_image) flux_image = image.divide(ee.Image(AREA_PFAF6_30MIN)).multiply(1e6).copyProperties(image) flux_image = flux_image.set("units","m") flux_image = flux_image.set("convertedToFlux", 1) return flux_image
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertflux(self, *args, **kwargs):\n return _image.image_convertflux(self, *args, **kwargs)", "def flux(source, freq=0.0, deltafreq=0.0, daysback=0.0) :\n x = queryFlux(source,freq,deltafreq,daysback)\n return x.flux", "def flux(self, x):\n return self.cal_spec.get_flux(self(x))", "d...
[ "0.6863947", "0.65460765", "0.6410462", "0.63754797", "0.6337502", "0.63291806", "0.63291806", "0.62562454", "0.61814946", "0.61583227", "0.60439867", "0.60325944", "0.592126", "0.5912541", "0.5898983", "0.5894703", "0.58924603", "0.58740014", "0.5857131", "0.58522546", "0.58...
0.8054486
0
filters an imagecollection based on year and month
def filter_ic(ic,year,month): ic_filtered = (ic.filter(ee.Filter.eq("month",month)) .filter(ee.Filter.eq("year",year))) image = ee.Image(ic_filtered.first()) return(image)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _filter_temporal(self, start_date: str, end_date: str) -> 'ImageCollection':\n process_id = 'filter_daterange'\n args = {\n 'imagery': self.graph,\n 'extent': [start_date, end_date]\n }\n\n return self.graph_add_process(process_id, args)", "def fi...
[ "0.6298117", "0.5903462", "0.58848464", "0.5747459", "0.5735303", "0.5665092", "0.54974794", "0.5486667", "0.5385302", "0.5352185", "0.5291872", "0.5263054", "0.5232077", "0.52078956", "0.519673", "0.51886106", "0.5142435", "0.510914", "0.50958353", "0.50748765", "0.50723386"...
0.77574176
0
Zonal statistics with rasters as input and rasters and lists as output
def zonalStatsToRaster(image,zonesImage,geometry,maxPixels,reducerType): # reducertype can be mean, max, sum, first. Count is always included for QA # the resolution of the zonesimage is used for scale reducer = ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"mean"),ee.Reducer.mean(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"max"),ee.Reducer.max(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"sum"),ee.Reducer.sum(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"first"),ee.Reducer.first(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"mode"),ee.Reducer.mode(),"error")))) ) reducer = ee.Reducer(reducer).combine(reducer2= ee.Reducer.count(), sharedInputs= True).group(groupField=1, groupName="zones") scale = zonesImage.projection().nominalScale().getInfo() zonesImage = zonesImage.select(zonesImage.bandNames(),["zones"]) totalImage = ee.Image(image).addBands(zonesImage) resultsList = ee.List(totalImage.reduceRegion( geometry= geometry, reducer= reducer, scale= scale, maxPixels=maxPixels ).get("groups")) resultsList = resultsList.map(ensure_default_properties); zoneList = mapList(resultsList, 'zones'); countList = mapList(resultsList, 'count'); valueList = mapList(resultsList, reducerType); valueImage = zonesImage.remap(zoneList, valueList).select(["remapped"],[reducerType]) countImage = zonesImage.remap(zoneList, countList).select(["remapped"],["count"]) newImage = zonesImage.addBands(countImage).addBands(valueImage) return newImage,zoneList,valueList,countList
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zonal_stats(src_poly, src_raster, operator=['mean'], features=None):\n assert src_raster.geo_transform is not None, \"src_raster.geo_transform should not be None\"\n assert isinstance(operator, list), \"operator should be a list of string. ex: ['mean']\"\n features = list(range(src_raster.bands)) if f...
[ "0.68493986", "0.6522732", "0.62442964", "0.62096614", "0.6187095", "0.60611725", "0.60029554", "0.5962458", "0.5880883", "0.58487236", "0.5846595", "0.5792119", "0.57755446", "0.57681596", "0.5670428", "0.55730975", "0.5560811", "0.5551571", "0.55226356", "0.55010265", "0.54...
0.71548915
0
Zonal statistics with rasters as input and rasters and lists as output
def zonalStatsToFeatureCollection(image,zonesImage,geometry,maxPixels,reducerType): # reducertype can be mean, max, sum, first. Count is always included for QA # the resolution of the zonesimage is used for scale reducer = ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"mean"),ee.Reducer.mean(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"max"),ee.Reducer.max(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"sum"),ee.Reducer.sum(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"first"),ee.Reducer.first(), ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,"mode"),ee.Reducer.mode(),"error")))) ) reducer = ee.Reducer(reducer).combine(reducer2= ee.Reducer.count(), sharedInputs= True).group(groupField=1, groupName="zones") scale = zonesImage.projection().nominalScale().getInfo() zonesImage = zonesImage.select(zonesImage.bandNames(),["zones"]) totalImage = ee.Image(image).addBands(zonesImage) resultsList = ee.List(totalImage.reduceRegion( geometry= geometry, reducer= reducer, scale= scale, maxPixels=maxPixels ).get("groups")) resultsList = resultsList.map(ensure_default_properties); fc = ee.FeatureCollection(resultsList.map(dict_to_feature)) return fc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zonalStatsToRaster(image,zonesImage,geometry,maxPixels,reducerType):\n # reducertype can be mean, max, sum, first. Count is always included for QA\n # the resolution of the zonesimage is used for scale\n\n reducer = ee.Algorithms.If(ee.Algorithms.IsEqual(reducerType,\"mean\"),ee.Reducer.mean(),\n e...
[ "0.71548915", "0.68493986", "0.6522732", "0.62442964", "0.62096614", "0.60611725", "0.60029554", "0.5962458", "0.5880883", "0.58487236", "0.5846595", "0.5792119", "0.57755446", "0.57681596", "0.5670428", "0.55730975", "0.5560811", "0.5551571", "0.55226356", "0.55010265", "0.5...
0.6187095
5
Export a google earth engine featureCollection to an asset folder
def export_table_to_cloudstorage(fc,description,fileNamePrefix): task = ee.batch.Export.table.toCloudStorage( collection = ee.FeatureCollection(fc), description = description, bucket = GCS_BUCKET, fileNamePrefix = GCS_OUTPUT_PATH + fileNamePrefix, fileFormat = "CSV" ) task.start()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export_geojson(self):\n outputfile = tkinter.filedialog.asksaveasfilename(\n defaultextension=\".geojson\",\n filetypes=((\"geo json\", \"*.geojson\"),\n (\"All Files\", \"*.*\")))\n if outputfile:\n self.tabs.window.aistracker.create_geojson...
[ "0.61912423", "0.61882675", "0.59939873", "0.5933762", "0.5790404", "0.5758867", "0.5716076", "0.5666679", "0.56646466", "0.56428987", "0.5607236", "0.5524524", "0.5473312", "0.5465263", "0.54639006", "0.54507273", "0.54334444", "0.53373575", "0.533101", "0.5320749", "0.53174...
0.539379
17
Initializing an instance of Square
def __init__(self, size): self.__size = size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_init(self):\n s1 = Square(4)\n self.assertEqual(s1.width, 4)\n self.assertEqual(s1.height, 4)\n self.assertEqual(s1.id, 1)\n self.assertEqual(s1.x, 0)\n self.assertEqual(s1.y, 0)\n\n s2 = Square(5, 2, 3, 47)\n self.assertEqual(s2.width, 5)\n s...
[ "0.731118", "0.7260903", "0.70362157", "0.7032253", "0.7006199", "0.68428224", "0.6766883", "0.67145604", "0.6702565", "0.6646152", "0.65749985", "0.63614845", "0.6321423", "0.63113105", "0.624146", "0.6238611", "0.62014264", "0.60820174", "0.6076275", "0.6062393", "0.6061413...
0.0
-1
Instantiate an Invalid Data Error.
def __init__(self, data_file_name: str, message: str) -> None: super().__init__( "Invalid data error. " "The file '{}' contained data of the wrong format: {}".format( data_file_name, message ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, message=\"\"):\n super(DataError, self).__init__(message)", "def from_data(cls, data):\n errors = data.get('errors')\n if not errors or len(errors) == 0:\n return cls('Unknown error!')\n\n # For simplicity, we'll just include the first error.\n err...
[ "0.7352192", "0.6801983", "0.65621036", "0.646361", "0.64199716", "0.6389275", "0.6367765", "0.63524276", "0.63038003", "0.6254848", "0.62355447", "0.6224742", "0.6218904", "0.6123961", "0.61025405", "0.6082676", "0.6062875", "0.6062328", "0.60509044", "0.6037686", "0.6018284...
0.64582944
4
Instantiate a Missing Data Error.
def __init__(self, message: str) -> None: super().__init__( "Data requested from a class could not be found: {}".format(message) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, message=\"\"):\n super(DataError, self).__init__(message)", "def data_missing(data):\n return type(data)._from_sequence([None, data[0]])", "def test_create_data_lookup_error(self):\n with self.assertRaises(LookupError):\n _ = create_data({\"name\": \"fake_data\"})...
[ "0.7335149", "0.65505475", "0.65356326", "0.62742686", "0.62742686", "0.62742686", "0.6204105", "0.6189645", "0.6147461", "0.6143845", "0.6142353", "0.6132027", "0.60576224", "0.60308665", "0.6008944", "0.5981049", "0.5965471", "0.5946241", "0.5938257", "0.59336597", "0.58896...
0.60894585
12
Instantiate a resolution mismatch error.
def __init__(self, message: str) -> None: super().__init__( "Due to the nature of the load data, an integer multiple of resolutions, " "or divsions of resolutions, must be supplied with the '--resolution' or " "'-r' flag.\nI appreciate that this is poor coding, but at least I took " "the time to write a custom exception for it :p .\n Error message: " f"{message}" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, name, pattern_factory):\n\t\tsuper(AlreadyRegisteredError, self).__init__(name, pattern_factory)", "def __init__(self, error = ''):\n IPRO_Error.__init__(self, error)", "def __init__(self, error = ''):\n IPRO_Error.__init__(self, error)", "def __init__(self, error = ''):\n ...
[ "0.64293504", "0.62001663", "0.62001663", "0.62001663", "0.61242396", "0.61132437", "0.60633713", "0.5971559", "0.589876", "0.5896457", "0.58818203", "0.587032", "0.5862494", "0.5797569", "0.57908887", "0.57661104", "0.57357174", "0.57350785", "0.57019705", "0.5677138", "0.56...
0.5793322
14
Instantiate the daily profile class..
def __init__(self, profile: Dict[datetime.time, float] = None) -> None: if profile is None: profile = dict() if not isinstance(profile, dict): raise ProgrammerJudgementFault( "The input daily profile provided is not a mapping of the correct type." ) self._profile = profile
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, name):\n self.__username = name\n self.__startDate = datetime.now().date().today() # This attributes will not be change ever once it has been initialized.", "def __init__(self, dt=60*60*24):\n pass", "def __init__(self, student, start_date, day_periods):\n self...
[ "0.6303617", "0.6276865", "0.61957604", "0.6129965", "0.60512453", "0.5994838", "0.59334636", "0.5906946", "0.57980454", "0.57551837", "0.5752836", "0.57355404", "0.5726834", "0.5710793", "0.5709311", "0.56886977", "0.5673901", "0.5655608", "0.5648033", "0.5615956", "0.559050...
0.6949065
0
Return an irradiance value from the profile.
def __getitem__(self, index: datetime.time) -> float: # If the index is in the profile, return the index. if index in self._profile: return self._profile[index] # If the index is not in the profile, then the closest value needs to be # determined. If there is a tie, this does not matter. delta_t_to_t_map = { ( abs( time.hour * 3600 + time.minute * 60 + time.second - (index.hour * 3600 + index.minute * 60 + index.second) ) ): time for time in self._profile } return self._profile[delta_t_to_t_map[min(delta_t_to_t_map)]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def irradiance(self) -> float:\n\n if self.declination > 0:\n return self._irradiance\n return 0", "def internal_rate_of_return(proforma):\n return np.irr(proforma['Yearly Net Value'].values)", "def getIR2() -> int:\n pass", "def emissivity_profile(R):\n E = R**(-3.0)*(1...
[ "0.68686956", "0.5816468", "0.5590658", "0.5589434", "0.5456386", "0.5432771", "0.5328536", "0.5325384", "0.52494484", "0.52432454", "0.5228382", "0.5184835", "0.5157474", "0.5141578", "0.5102126", "0.5093269", "0.5086786", "0.5064944", "0.5061839", "0.5061839", "0.50400925",...
0.0
-1
Sets an item in the profile.
def __setitem__(self, index: datetime.time, value: float) -> None: self._profile[index] = value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_item(self, item):\n self.item = item", "def set_item(self, item):\n self.item = item", "def SetItem(self, item):\r\n\r\n self._item = item", "def setItem(self, item):\n self.setItem(0, item)", "def set(self, item, value):\r\n raise NotImplementedError", "def set...
[ "0.77816904", "0.77816904", "0.7673996", "0.7493998", "0.72386533", "0.68001693", "0.66733706", "0.6579954", "0.6452752", "0.6452752", "0.6386416", "0.62725997", "0.6261532", "0.6182471", "0.616033", "0.6158893", "0.6145247", "0.6110622", "0.60548663", "0.6047665", "0.6031433...
0.5924909
24
Updates the internal profile with the mapping provided.
def update(self, profile: Dict[datetime.time, float]) -> None: if self._profile is None: self._profile = profile else: self._profile.update(profile)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, mapping):\n if not ismapping(mapping):\n raise TypeError(\"mapping type required\")\n field_names = getpyattr(type(self), 'field_names')\n for key, value in mapping.items():\n if key in field_names:\n setattr(self, key, value)", "def upda...
[ "0.63624704", "0.609009", "0.60749924", "0.5952606", "0.59126085", "0.5860821", "0.5851326", "0.58165675", "0.57689905", "0.5755722", "0.57045287", "0.56417894", "0.5599517", "0.55890405", "0.5579434", "0.55684793", "0.55682325", "0.5558063", "0.55190516", "0.5518738", "0.549...
0.7125943
0
The density of air varies as a function of temperature.
def density_of_air(self) -> float: return self.pressure / (SPECIFIC_GAS_CONSTANT_OF_AIR * self.ambient_temperature)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def air_density(self):\n return self.flow_field.air_density", "async def air_density(self, temperature, station_pressure):\n if temperature is not None and station_pressure is not None:\n kelvin = temperature + 273.15\n pressure = station_pressure\n r_specific = 287...
[ "0.7871237", "0.77620345", "0.73548687", "0.7349471", "0.6937895", "0.6883913", "0.6820493", "0.6713705", "0.6696069", "0.66546506", "0.6654112", "0.6648508", "0.6641304", "0.6609871", "0.65910405", "0.6577765", "0.6577765", "0.6577765", "0.6552875", "0.654293", "0.65178937",...
0.7765341
1
The dynamic viscosity of air varies as a function of temperature.
def dynamic_viscosity_of_air(self) -> float: return (1.458 * (10 ** (-6)) * (self.ambient_temperature**1.5)) / ( self.ambient_temperature + 110.4 )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kinematic_viscosity_of_air(self) -> float:\n\n return self.dynamic_viscosity_of_air / self.density_of_air", "def latent_heat_vapourisation(self, tair):\n return (2.501 - 0.00237 * tair) * 1E06", "def air_density(self):\n return self.flow_field.air_density", "def thermal_expansivity_o...
[ "0.7093741", "0.6370206", "0.617513", "0.6122823", "0.61151516", "0.6091893", "0.6021482", "0.59835947", "0.592721", "0.5878499", "0.58544457", "0.5826623", "0.58215696", "0.5811718", "0.58073586", "0.56892794", "0.56720847", "0.56465936", "0.5620597", "0.5558093", "0.5547346...
0.82398015
0
Return the heat capacity of air in Joules perkilogram Kelvin. The heat capacity of air varies with a function of temperature and is given by an empiricallyderived formula.
def heat_capacity_of_air(self) -> float: return 1002.5 + 275 * (10 ** (-6)) * (self.ambient_temperature - 200) ** 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heatCapacity(self, Tk=None, Tc=None):\n Tk = getTk(Tc, Tk)\n self.checkPropertyTempRange(\"heat capacity\", Tk)\n return (\n sum(\n [\n +1.38642e-13 * Tk**4,\n -6.47481e-10 * Tk**3,\n +1.02345e-06 * Tk**2,\n...
[ "0.72807765", "0.70755357", "0.67571175", "0.6657788", "0.6539134", "0.63971967", "0.63434315", "0.6203374", "0.62022215", "0.61694735", "0.61694306", "0.6157651", "0.61571056", "0.61204106", "0.6098233", "0.60910946", "0.6065617", "0.6051415", "0.60473984", "0.6033305", "0.6...
0.77720433
0
The irradiance should only be definied if the sun is above the horizon.
def irradiance(self) -> float: if self.declination > 0: return self._irradiance return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rad_field_initial_condition(self):\n\n # revert in viewing direct\n angle, _ = f.convert_direction(self.receiver_elevation, self.receiver_azimuth)\n # Looking at the sky\n if angle < 90:\n I_init = (\n self.sun_intensity\n * f.delta_func(self...
[ "0.634991", "0.565729", "0.5482073", "0.5471151", "0.543911", "0.5316347", "0.52773964", "0.5272393", "0.52664614", "0.52653426", "0.52644473", "0.519665", "0.51890105", "0.5169418", "0.50999045", "0.5082697", "0.5082697", "0.508089", "0.5074152", "0.50740224", "0.5064365", ...
0.5284681
6
The kinematic viscosity of air varies as a function of temperature.
def kinematic_viscosity_of_air(self) -> float: return self.dynamic_viscosity_of_air / self.density_of_air
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dynamic_viscosity_of_air(self) -> float:\n\n return (1.458 * (10 ** (-6)) * (self.ambient_temperature**1.5)) / (\n self.ambient_temperature + 110.4\n )", "def latent_heat_vapourisation(self, tair):\n return (2.501 - 0.00237 * tair) * 1E06", "def dispersion(self, k):\n ...
[ "0.7809844", "0.62890047", "0.62317854", "0.6194581", "0.61644995", "0.61163557", "0.600697", "0.5984969", "0.5790677", "0.575207", "0.5744783", "0.5729746", "0.5714137", "0.57019544", "0.5691392", "0.56809", "0.56597465", "0.56572974", "0.5655333", "0.56213343", "0.56118655"...
0.8016766
0
Determines the radiative temperature of the sky. The "sky," as a black body, has a radiative temperature different to that of the surrounding air, or the ambient temperature. This function converts between them and outputs the sky's radiative temperature.
def sky_temperature(self) -> float: return 0.0552 * (self.ambient_temperature**1.5)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sky_ir_temperature(self) -> float:\n self.serial.write(b\"S!\")\n sky_ir_temp = self.__extract_int(self.__read_response(1)[0], b\"!1\")\n\n return round(sky_ir_temp / 100, 2)", "def temperature() -> float:", "def temperature(self):\n names = ['anc_air_temperature']\n ...
[ "0.677967", "0.65615", "0.64276695", "0.6416784", "0.64141804", "0.6408829", "0.62878555", "0.6222289", "0.6220975", "0.61991245", "0.6182677", "0.61740917", "0.61678636", "0.6091844", "0.60883605", "0.6079088", "0.6072627", "0.6015334", "0.60076296", "0.59943837", "0.5990562...
0.77121866
0
The thermal conductivity of air varies as a function of temperature.
def thermal_conductivity_of_air(self) -> float: # This more accurate equation is not used by the paper. # return (0.02646 * self.ambient_temperature ** 1.5) / ( # self.ambient_temperature + 254.4 * (10 ** (-12 / self.ambient_temperature)) # ) # The reference suggests this equation is accurate to 1%. return 0.02646 * (self.ambient_temperature / 300) ** 0.8646
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def thermal_expansivity_of_air(self) -> float:\n\n return 1 / self.ambient_temperature", "def thermal_conductivity(temperature):\n a0 = -4.1236\n a1 = 13.788\n a2 = -26.068\n a3 = 26.272\n a4 = -14.663\n a5 = 4.4954\n a6 = -0.6905\n a7 = 0.0397\n ...
[ "0.79880536", "0.764283", "0.7523666", "0.75130093", "0.7090662", "0.70669293", "0.7042304", "0.6954361", "0.6936385", "0.6905874", "0.6894696", "0.68758714", "0.6788131", "0.6774004", "0.677208", "0.67583066", "0.6724294", "0.67135936", "0.66866106", "0.66677165", "0.6657772...
0.8359033
0
The thermal expansion coefficient of air varies as a function of temperature.
def thermal_expansivity_of_air(self) -> float: return 1 / self.ambient_temperature
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def thermal_conductivity_of_air(self) -> float:\n\n # This more accurate equation is not used by the paper.\n # return (0.02646 * self.ambient_temperature ** 1.5) / (\n # self.ambient_temperature + 254.4 * (10 ** (-12 / self.ambient_temperature))\n # )\n\n # The reference sug...
[ "0.7279272", "0.68165576", "0.6797786", "0.6684487", "0.66219014", "0.6579864", "0.6570214", "0.6559898", "0.649577", "0.64194864", "0.63722163", "0.6345614", "0.6337939", "0.6337814", "0.6305888", "0.6286312", "0.6284374", "0.6271602", "0.6268423", "0.62625694", "0.62529576"...
0.76827806
0
Determines the convective heat transfer coefficient, either free, or forced. In the absence of any wind, the "free" wind_heat_transfer_coefficient is returned. If there is wind present, then this parameter is known as the "forced" wind_heat_transfer_coefficient.
def wind_heat_transfer_coefficient(self) -> float: return 3.8 + 2 * self.wind_speed # return 4.5 + 2.9 * self.wind_speed
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def thermalConductivity(self, Tk=None, Tc=None):\n Tk = getTk(Tc, Tk)\n self.checkPropertyTempRange(\"thermal conductivity\", Tk)\n thermalConductivity = (\n 2.13014e-08 * Tk**3\n - 6.31916e-05 * Tk**2\n + 1.11629e-01 * Tk\n - 2.00043e00\n )\n...
[ "0.6343963", "0.59971076", "0.59249985", "0.5791971", "0.576443", "0.5683115", "0.565232", "0.55878526", "0.5570194", "0.54607165", "0.5381237", "0.52986056", "0.5273817", "0.5269059", "0.5203606", "0.5199913", "0.5169069", "0.5163147", "0.5161178", "0.51067317", "0.510497", ...
0.69990456
0
Return a nice representation of the weather conditions.
def __repr__(self) -> str: return ( "WeatherConditions(" f"ambient_temperature: {self.ambient_temperature:.3f}K, " f"azimuthal_angle: {self.azimuthal_angle}deg, " f"declination: {self.declination}deg, " f"density: {self.density_of_air:.3f}kg/m^3, " f"dynamic_viscosity: {self.dynamic_viscosity_of_air:.3f}kg/m*s, " f"heat_capacity: {self.heat_capacity_of_air}:.3fJ/kg*K, " f"irradiance: {self.irradiance:.3f}W/m^2, " f"kinematic_viscosity: {self.kinematic_viscosity_of_air:.3f}m^2/s, " f"sky_temperature: {self.sky_temperature:.3f}K, " f"thermal_conductivity: {self.thermal_conductivity_of_air:.3f}W/m*K, " f"thermal_expansion_coefficient: {self.thermal_expansivity_of_air:.3f}K^-1, " f"wind_heat_transfer_coefficient: {self.wind_heat_transfer_coefficient:2f}W/m*K, " f"wind_speed: {self.wind_speed:.3f}m/s, " ")" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditions(self, json):\n conditions = str(json['forecast']['simpleforecast']['forecastday'][0]['conditions'])\n return conditions", "def genWeather():\n\n weather = random.choice(weather_conditions.keys())\n condition = weather_conditions[weather]\n (tMax, tMin) = condition[\"temperat...
[ "0.63701195", "0.6170547", "0.6153412", "0.6075571", "0.59051156", "0.5875144", "0.582113", "0.5815576", "0.5801642", "0.5736014", "0.5721063", "0.5704934", "0.56886274", "0.5640063", "0.56320167", "0.5610608", "0.5609194", "0.55756634", "0.5571646", "0.5566451", "0.5524659",...
0.79582655
0
A generator function for looping through various times.
def time_iterator( *, first_time: datetime.datetime, last_time: datetime.datetime, resolution: int, timezone: datetime.timezone, ) -> Generator[datetime.datetime, None, None]: current_time = first_time while current_time < last_time: yield current_time.replace(tzinfo=timezone) current_time += relativedelta( hours=resolution // 3600, minutes=(resolution // 60) % 60, seconds=resolution % 60, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def times(self):\n \n class IterTimes:\n def __init__(self, st):\n self.c = 0\n self.st = st\n \n def __iter__(self):\n return self\n \n def next(self):\n t = self.st.time(self.c)\n ...
[ "0.7211171", "0.7095168", "0.676974", "0.66167104", "0.66167104", "0.66167104", "0.6530617", "0.6517885", "0.64912164", "0.64652574", "0.6435925", "0.64267135", "0.6413881", "0.6370479", "0.6354844", "0.63290936", "0.62823224", "0.62550485", "0.6254462", "0.62441665", "0.6222...
0.597769
39
Names of endogenous variables
def endog_names(self): return self.data.ynames
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getMeteorologicalVariableNames(self, product):\r\n return []", "def variables(self):\n return [i.name for i in self.inputs + self.outputs]", "def getOthVarNames( self ):\n\n if self.othVarNames:\n return self.othVarNames.keys()\n\n n = self.adb.get( \"nOthVars\" )\n...
[ "0.64263195", "0.6372972", "0.63582456", "0.6340898", "0.6314623", "0.625726", "0.62262017", "0.62185633", "0.61736417", "0.61590856", "0.61525357", "0.61390096", "0.6113262", "0.6112568", "0.6102501", "0.60962504", "0.6091112", "0.6083438", "0.6079277", "0.6068774", "0.60612...
0.6065987
20
Names of exogenous variables
def exog_names(self): return self.data.xnames
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def variable_names(self):\n \n return [x['variable'] for x in self.variable_dicts()]", "def get_all_variables_names(self):\n return self.project.get_variable_names() + self.design.get_variable_names()", "def get_variable_names(self):\n return [var[1] for var in self.variables]", "...
[ "0.69048613", "0.6785922", "0.67740816", "0.6711591", "0.6687262", "0.6663156", "0.6635133", "0.66310126", "0.6589906", "0.6581961", "0.6580228", "0.6575236", "0.6552368", "0.6544824", "0.6535504", "0.6525284", "0.6511582", "0.64991194", "0.64609987", "0.641673", "0.6381078",...
0.5873568
61