query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
Load split date generated by random_basket_split. Load split data generated by random_basket_split from Onedrive, with test_rate = 0.1 and by_user = False.
def load_random_basket_split( self, test_rate=0.1, random=False, n_negative=100, by_user=False, n_test=10, download=False, force_redo=False, ): processed_random_basket_split_path = os.path.join( self.processed_path, "random_basket" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_temporal_basket_split(\n self,\n test_rate=0.1,\n n_negative=100,\n by_user=False,\n n_test=10,\n download=False,\n force_redo=False,\n ):\n processed_temporal_basket_split_path = os.path.join(\n self.processed_path, \"temporal_basket\"...
[ "0.7133687", "0.6738833", "0.6610602", "0.6159445", "0.6154813", "0.60758346", "0.60122156", "0.5912948", "0.5853551", "0.58316445", "0.5824674", "0.57067055", "0.5702897", "0.56952745", "0.5664727", "0.5542511", "0.55377877", "0.55364096", "0.5526718", "0.5458896", "0.544800...
0.7202106
0
Load split date generated by temporal_split. Load split data generated by temporal_split from Onedrive, with test_rate = 0.1 and by_user = False.
def load_temporal_split( self, test_rate=0.1, n_negative=100, by_user=False, n_test=10, download=False, force_redo=False, ): processed_temporal_split_path = os.path.join(self.processed_path, "temporal") if not os.path.exists(processed_temporal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_temporal_basket_split(\n self,\n test_rate=0.1,\n n_negative=100,\n by_user=False,\n n_test=10,\n download=False,\n force_redo=False,\n ):\n processed_temporal_basket_split_path = os.path.join(\n self.processed_path, \"temporal_basket\"...
[ "0.61022234", "0.5993563", "0.5898714", "0.5798527", "0.5767174", "0.57360524", "0.57025963", "0.5627453", "0.5621393", "0.55719185", "0.55060846", "0.54760337", "0.542432", "0.53775305", "0.5343805", "0.5313419", "0.5296359", "0.52889276", "0.52823937", "0.5257456", "0.52428...
0.70669204
0
Load split date generated by temporal_basket_split. Load split data generated by temporal_basket_split from Onedrive, with test_rate = 0.1 and by_user = False.
def load_temporal_basket_split( self, test_rate=0.1, n_negative=100, by_user=False, n_test=10, download=False, force_redo=False, ): processed_temporal_basket_split_path = os.path.join( self.processed_path, "temporal_basket" ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_temporal_split(\n self,\n test_rate=0.1,\n n_negative=100,\n by_user=False,\n n_test=10,\n download=False,\n force_redo=False,\n ):\n processed_temporal_split_path = os.path.join(self.processed_path, \"temporal\")\n\n if not os.path.exists(...
[ "0.6929598", "0.6464343", "0.6333801", "0.59288585", "0.5863091", "0.57801324", "0.57486594", "0.57221323", "0.5668923", "0.5663037", "0.5595724", "0.55237585", "0.5407653", "0.539132", "0.5381109", "0.5299281", "0.52730423", "0.5249947", "0.5209016", "0.51939607", "0.5168936...
0.7343281
0
Load split data by config dict.
def load_split(self, config): data_split_str = config["data_split"] split_paras = {} split_paras["test_rate"] = config["test_rate"] if "test_rate" in config else 0.1 split_paras["random"] = config["random"] if "random" in config else False split_paras["download"] = config["downlo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_data(self, cfg):\r\n\r\n if self._split == \"train\":\r\n self._annotations = self._load_lists(cfg.EGO4D_STA.TRAIN_LISTS)\r\n elif self._split == \"val\":\r\n self._annotations = self._load_lists(cfg.EGO4D_STA.VAL_LISTS)\r\n else:\r\n self._annotation...
[ "0.7136112", "0.6749958", "0.6747291", "0.64401364", "0.63209045", "0.61296487", "0.60909754", "0.6089914", "0.60346705", "0.60188866", "0.59833723", "0.59761685", "0.59455794", "0.5926599", "0.58674985", "0.58601004", "0.5841006", "0.58348364", "0.58224136", "0.57684314", "0...
0.79225177
0
Return a fake bucket object for the given model class.
def bucket_for_modelcls(self, modelcls): bucket_name = self.bucket_name(modelcls) return FakeRiakBucket(self._state, bucket_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def riak_object(self, modelcls, key):\n bucket_name = self.bucket_name(modelcls)\n riak_object = FakeRiakObject(self._state, bucket_name, key)\n riak_object.set_content_type(\"application/json\")\n riak_object.set_data({'$VERSION': modelcls.VERSION})\n return riak_object", "def...
[ "0.66789925", "0.6196018", "0.6026476", "0.5923624", "0.5913924", "0.59030366", "0.5856308", "0.5819066", "0.58131045", "0.57993364", "0.57706445", "0.5769229", "0.5739091", "0.5715317", "0.56394327", "0.5605846", "0.55638534", "0.55497086", "0.5537596", "0.53611326", "0.5357...
0.8668611
0
Create and return a fake RiakObject.
def riak_object(self, modelcls, key): bucket_name = self.bucket_name(modelcls) riak_object = FakeRiakObject(self._state, bucket_name, key) riak_object.set_content_type("application/json") riak_object.set_data({'$VERSION': modelcls.VERSION}) return riak_object
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_object():\n return object()", "def construct_fake(self, name: str) -> ResponsibleFake:\n fake: NaiveFake = getattr(self.faker, name)\n return lru_cache(maxsize=None)(lambda _: fake())", "def _mkObject(self):\n return ImmutableObject(\n store=self.store,\n ...
[ "0.6498993", "0.6185029", "0.6068252", "0.5993571", "0.59780276", "0.5866788", "0.58306056", "0.5774978", "0.57056415", "0.566206", "0.5632154", "0.5630083", "0.56242526", "0.55080545", "0.55028653", "0.54455763", "0.5429836", "0.54195917", "0.54066926", "0.5395255", "0.53947...
0.71742576
0
If in async mode, add some delay to catch code that doesn't properly wait for the deferred to fire.
def _with_async_delay(self, func, *args, **kw): if self._is_sync: return func(*args, **kw) # Add some latency to catch things that don't wait on deferreds. We # can't use deferLater() here because we want to keep track of the # delayed call object. d = Deferred() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_deferred(self):\n self.deferred_executor.process()", "def execute_deferred(fn):\n\n pass", "async def _timeToRun(self) -> None:\n d: Deferred[None] = Deferred()\n self._waiting.append(d)\n await d", "def wait_for_defered(defered, timeout=5.0):\n @wait_for(timeout=...
[ "0.6407433", "0.6054961", "0.5931694", "0.59257764", "0.586519", "0.5810578", "0.58012944", "0.5783409", "0.5758944", "0.5752723", "0.5665321", "0.56585205", "0.5654886", "0.5620103", "0.5618915", "0.5618915", "0.5594411", "0.5590306", "0.55107504", "0.550138", "0.5490843", ...
0.61031705
1
Construct and return an index page object.
def _return_index_page(self, bucket_name, index_name, start_value, end_value, return_terms, max_results, results, continuation): if not return_terms: results = [key for _, key in results] return FakeMemoryIndexPage(self, continuation, res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index():\n\n return {\n 'page': 'index',\n }", "def get_index():\n return render_template('index.html')", "def index():\n return render_template('pages/index.html', isNav=True)", "def index_page(data):\n main_index = [html.H1(\"INDEX\"),\n html.Div([html.A(\"Charact...
[ "0.71548754", "0.64618194", "0.6436049", "0.6369808", "0.6298626", "0.6282117", "0.6282117", "0.6282117", "0.62155414", "0.6210448", "0.6186697", "0.61463696", "0.60686356", "0.606648", "0.6062112", "0.60497737", "0.60472274", "0.60227215", "0.6021287", "0.6020807", "0.600525...
0.67040664
1
Test to verify we can successfully create a new NPC object
def test_NPC_post_successful(self): client = APIClient() class_lookup = { 1: "Rogue", 2: "Paladin", 3: "Cleric", 4: "Barbarian", 5: "Warlock" } race_lookup = { 1: "Human", 2: "Dragonborn", 3...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_new(self):\n obj = Game.new(self._creator, self._ds)\n self.assertIsInstance(obj, Game, \"Game instance not initialized.\")\n self.assertHasAttribute(obj, 'uid', \"Game has no unique ID.\")\n self.assertHasAttributes(obj, [\n 'players', 'spectators', 'state', 'points...
[ "0.6854737", "0.6848042", "0.68137944", "0.67878354", "0.67403334", "0.6688225", "0.66370744", "0.6625862", "0.66257757", "0.66257757", "0.6584136", "0.6575232", "0.6548104", "0.6523475", "0.65218157", "0.6479944", "0.6471372", "0.64576745", "0.64287883", "0.63746697", "0.635...
0.74615973
0
It will render either the last 10 news items or all of them, depending on the keyword archive.
def index(request, archive=False): context = {'archive':archive} posts = Post.objects.all() if not archive: posts = posts[:10] context['posts'] = posts if request.user.is_authenticated(): #These are the new news items the logged in user has context['new_posts'] = NewBlog.obje...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_archives():\n if not session.get('logged_in'): \n latest = Post.query.filter_by(visible=True)\n else:\n latest = Post.query\n latest = latest.order_by(Post.id.desc()).limit(10)\n months = Post.query.get_months()\n tags = Tag.query.order_by(Tag.name).all()\n #: Needed for ca...
[ "0.66486454", "0.66125673", "0.64189005", "0.62656194", "0.61706954", "0.6150045", "0.60625744", "0.6050601", "0.5968591", "0.59586847", "0.5903161", "0.5878132", "0.58350307", "0.5815076", "0.5810166", "0.5732592", "0.5732581", "0.57017016", "0.5642253", "0.56308407", "0.562...
0.68119586
0
Use ansible's TaskQueueManager to run tasks on hosts. Defined this method as a static method on purpose so that scripts may use this method to run ansible tasks without initializing instances of AnsibleHosts or AnsibleHost.
def run_tasks( hosts, loader, inventory_manager, variable_manager, options={ "forks": 6, "connection": "smart", "verbosity": 2, "become_method": "sudo" }, passwords={"vault...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self, host_list, module_name, module_args):\n # create play with tasks\n play_source = dict(\n name=\"Ansible Play\",\n hosts=host_list,\n gather_facts='no',\n tasks=[dict(action=dict(module=module_name, args=module_args))]\n )\n play ...
[ "0.71461415", "0.7090448", "0.64184934", "0.61296886", "0.6108584", "0.6062001", "0.6039702", "0.5981033", "0.5961828", "0.59389055", "0.5914672", "0.58420664", "0.58240324", "0.57676196", "0.564648", "0.56343764", "0.56221795", "0.55787176", "0.55706334", "0.54865986", "0.54...
0.70941687
1
Log ansible modules to be executed.
def _log_modules(self, caller_info, module_info, verbosity): if verbosity <= 0: # Do not log anything return filename, line_number, function_name, lines, index = caller_info if isinstance(self, AnsibleHosts): hosts_str = json.dumps(self.hostnames) elif isin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(self, msg):\n self.ansible.log(msg)", "def test_03_module_logger(self):\n module_logger = get_module_logger(self.__module__)\n module_logger.info('Info in Module {}'.format(self.__module__))", "def _run_ansible_module(self, *args, **kwargs):\n caller_info = kwargs.pop(\"call...
[ "0.7009652", "0.64670175", "0.6137437", "0.6028057", "0.5934864", "0.5867709", "0.58524936", "0.5779044", "0.55871576", "0.5526636", "0.5510478", "0.5477527", "0.54404324", "0.54341674", "0.54166883", "0.5373122", "0.53594613", "0.5356248", "0.5343266", "0.5331971", "0.530893...
0.663032
1
Log ansible module results.
def _log_results(self, caller_info, module_info, results, verbosity): if verbosity <= 0: # Do not log anything return if isinstance(self, AnsibleHosts): hosts_str = json.dumps(self.hostnames) elif isinstance(self, AnsibleHost): hosts_str = json.dumps(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(self, msg):\n self.ansible.log(msg)", "def _log_modules(self, caller_info, module_info, verbosity):\n if verbosity <= 0: # Do not log anything\n return\n\n filename, line_number, function_name, lines, index = caller_info\n\n if isinstance(self, AnsibleHosts):\n...
[ "0.6625791", "0.6181472", "0.61071557", "0.6099287", "0.6000015", "0.59062815", "0.58921254", "0.5707888", "0.5687938", "0.5610681", "0.5593121", "0.550199", "0.5477372", "0.5452468", "0.5418416", "0.54073703", "0.53965336", "0.53927475", "0.5379991", "0.5375399", "0.53749096...
0.653757
1
Check ansible module results.
def _check_results(self, caller_info, module_info, results, module_ignore_errors, verbosity): if module_ignore_errors: return filename, line_number, function_name, lines, index = caller_info caller_str = "{}::{}#{}".format(filename, function_name, line_number) if isinstance...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n\n # the AnsibleModule object will be our abstraction for working with Ansible.\n # This includes instantiation, a couple of common attr that will be the\n # args/params passed to the execution, as well as if the module\n # supports check mode\n module = AnsibleModule(\n argument...
[ "0.7035868", "0.65649945", "0.63886446", "0.63381404", "0.6333369", "0.6272333", "0.61568916", "0.61397576", "0.6133934", "0.6107778", "0.6067837", "0.601987", "0.60109967", "0.5993061", "0.5962051", "0.5924178", "0.59025234", "0.58850336", "0.5859732", "0.58180624", "0.57735...
0.6653182
1
Run ansible module. DO NOT call this function directly. Use instance_name.() instead. This class has "__getattr__" defined. This function will be called when an attribute is not found in the instance. This function will parse the attribute name and consider the attribute name as an Ansible module name. Then it will cal...
def _run_ansible_module(self, *args, **kwargs): caller_info = kwargs.pop("caller_info", None) if not caller_info: previous_frame = inspect.currentframe().f_back caller_info = inspect.getframeinfo(previous_frame) module_args = copy.deepcopy(args) module_kwargs = c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getattr__(self, attr):\n if not module_loader.has_plugin(attr):\n raise UnsupportedAnsibleModule(\"Unsupported ansible module \\\"{}\\\"\".format(attr))\n self.module_name = attr\n\n return self._run_ansible_module", "def run_module(self, module_name, args=[], kwargs={}):\n ...
[ "0.77540916", "0.6646788", "0.5633474", "0.5528462", "0.5466303", "0.5463101", "0.5456096", "0.5366184", "0.53633046", "0.53427565", "0.53082246", "0.53075224", "0.5284655", "0.5284655", "0.52691853", "0.5227956", "0.52182996", "0.5189134", "0.51711935", "0.516153", "0.514621...
0.6936579
1
Run ansible module specified by `module_name`.
def run_module(self, module_name, args=[], kwargs={}): if not module_loader.has_plugin(module_name): raise UnsupportedAnsibleModule("Unsupported ansible module \"{}\"".format(module_name)) self.module_name = module_name previous_frame = inspect.currentframe().f_back caller_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_ansible_module(self, *args, **kwargs):\n caller_info = kwargs.pop(\"caller_info\", None)\n if not caller_info:\n previous_frame = inspect.currentframe().f_back\n caller_info = inspect.getframeinfo(previous_frame)\n\n module_args = copy.deepcopy(args)\n mod...
[ "0.75557333", "0.6654302", "0.66351384", "0.64992267", "0.6433729", "0.6184073", "0.6183975", "0.6131884", "0.611866", "0.60535264", "0.6025238", "0.58155006", "0.57438225", "0.5732917", "0.57273674", "0.57205576", "0.57085866", "0.56579196", "0.5643088", "0.5642193", "0.5628...
0.7977094
0
Load a module with arguments into a list. This method load a module with arguments into a list. Method `self.run_loaded_modules` can run the loaded modules in a single play. Comparing with `self.run_module` or `self._run_ansible_module`, special keyword arguments are not supported in `kwargs` of `self.load_module`. The...
def load_module(self, module_name, args=[], kwargs={}, module_attrs={}): self._loaded_modules.append( { "module_name": module_name, "args": args, "kwargs": kwargs, "module_attrs": module_attrs } )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadModule(*args, allModules: bool=True, load: AnyStr=\"\", scan: bool=True,\n **kwargs)->List[AnyStr]:\n pass", "def load_module(cls, *args, **kwargs): # real signature unknown\n pass", "def load_module(cls, *args, **kwargs): # real signature unknown\n pass", "def load_mod...
[ "0.7526992", "0.6800753", "0.6800753", "0.6800753", "0.6727341", "0.659455", "0.6575501", "0.64525557", "0.6025746", "0.5977205", "0.5977205", "0.5885488", "0.58690804", "0.5834087", "0.58114254", "0.5699735", "0.5674411", "0.5667683", "0.5610617", "0.5578631", "0.5534352", ...
0.7061555
1
Clear the list of loaded ansible modules.
def clear_loaded_modules(self): self._loaded_modules = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_modules(self) -> None:\n self.modules = {}\n self.update_modules()\n self.parse_modules()", "def clearList(self):\r\n self.addons.clear()", "def unload_all():\n module_utils.unload_package_modules(__name__)", "def clear(self):\r\n with PluginStore.mutex:\r\n ...
[ "0.68010104", "0.6701567", "0.66162837", "0.65335584", "0.63375634", "0.6336604", "0.6234657", "0.6062446", "0.605322", "0.60396117", "0.596826", "0.5857965", "0.58533", "0.5817778", "0.57520074", "0.574207", "0.56880206", "0.5674843", "0.567305", "0.5635878", "0.5623788", ...
0.7931102
0
Tool for getting ansible.inventory.host.Host object from self.inventories using ansible inventory manager.
def get_inv_host(self, hostname, strict=False): if strict: # Only get host with hostname from self.ans_inv_hosts for _host in self.ans_inv_hosts: if _host.name == hostname: return _host else: return None else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ansible_inventory(self):\n path_inventory = u'%s/inventories/%s' % (self.ansible_path, self.environment)\n path_lib = u'%s/library/beehive/' % (self.ansible_path)\n runner = Runner(inventory=path_inventory, verbosity=self.verbosity, \n module=path_lib)\n res =...
[ "0.7104992", "0.6289332", "0.6042384", "0.5963869", "0.5929493", "0.590701", "0.5815771", "0.5768301", "0.5764911", "0.5737428", "0.57358813", "0.5725008", "0.5690255", "0.56714857", "0.5659333", "0.5652734", "0.564978", "0.56496686", "0.5606734", "0.5598386", "0.559378", "...
0.6820544
1
Tool for getting visible variables of specified host. Variables may be defined in inventory files, any group_vars and host_vars files. Both ansible inventory manager and variable managers are used under the hood.
def get_host_visible_vars(self, hostname, strict=False): _host = self.get_inv_host(hostname, strict=strict) if not _host: return {} return self.vm.get_vars(host=_host)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_host_vars(self, host, vault_password=None):\n use_keychain = host.get_variables().get(\"use_keychain\")\n hostname = host.get_variables().get('inventory_hostname')\n if '-l' in sys.argv:\n # Check if only limited set of hosts is required for this run and get password only fo...
[ "0.69271773", "0.6585922", "0.64885944", "0.623751", "0.62139", "0.6080665", "0.5962397", "0.57060534", "0.5664389", "0.5655992", "0.55767846", "0.53442526", "0.53242475", "0.5320545", "0.5307548", "0.5286596", "0.5281534", "0.52441394", "0.51855075", "0.51800096", "0.5178212...
0.74784786
0
Tool for getting visible variable value of specified host. Variable may be defined in inventory files, any group_vars and host_vars files. Both ansible inventory manager and variable managers are used under the hood.
def get_host_visible_var(self, hostname, var, strict=False): return self.get_host_visible_vars(hostname, strict=strict).get(var, None)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_host_var(self, hostname, var, strict=False):\n return self.get_host_vars(hostname, strict).get(var, None)", "def get_host_visible_vars(self, hostname, strict=False):\n _host = self.get_inv_host(hostname, strict=strict)\n if not _host:\n return {}\n return self.vm.ge...
[ "0.6701593", "0.6527898", "0.6228895", "0.6226399", "0.60589486", "0.6026758", "0.5883179", "0.5808856", "0.5720936", "0.5681497", "0.5645566", "0.5620774", "0.55991036", "0.5584286", "0.5564279", "0.5540426", "0.5439333", "0.5398093", "0.5271716", "0.52648276", "0.52448946",...
0.7208586
0
Test parsing single subcategory
def test_parse_single_entry(self): entry = dedent( """ Main topic text # SUBTOPICS ## creating extra stuff Help on creating extra stuff. """, indent=0, ) expected = { None: "Main topic text", "creating extra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_extract_categories():\n pass", "def test_add_child_category(self):\n self.add_success(self.test_data['pants'])\n rv = self.get('pants')\n assert in_response(rv, 'This category is empty.')\n self.add_success(self.test_data['jeans'])\n rv = self.get('pants')\n ...
[ "0.684854", "0.6316532", "0.6271284", "0.6258647", "0.618775", "0.61750966", "0.6107724", "0.6096469", "0.6048929", "0.601986", "0.59748644", "0.59086543", "0.5866881", "0.58603185", "0.58043706", "0.5776574", "0.57665586", "0.57611483", "0.57332945", "0.57319903", "0.5727717...
0.691666
0
Open network connection to projector and perform handshake
def connect(self): self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: if self.print_send: print(' - connecting...') self.socket.settimeout(1) self.socket.connect(self.host_port) if self.print_send: print...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _connect(self):\n hostport = self.getHost()\n channelOpenData = forwarding.packOpen_direct_tcpip((self.host, self.port), (hostport.host, hostport.port))\n self.connector.connection.openChannel(self, channelOpenData)", "def connect():", "def start(self):\n self.protocol.makeConne...
[ "0.7299446", "0.6917918", "0.6790771", "0.6790771", "0.6779495", "0.67675763", "0.67099863", "0.6703264", "0.6702018", "0.66886103", "0.6676126", "0.6648941", "0.66488427", "0.6629851", "0.66179246", "0.6616294", "0.66152376", "0.6598392", "0.6581775", "0.6581488", "0.6579761...
0.7252354
1
Constructs a Configuration, validating the values in `dictionary`, expecting paths to be within `location`.
def load_from_dict( cls, dictionary: Dict[str, Any], *, location: Path ) -> "Configuration": schema = { "type": "object", "additionalProperties": False, "required": ["destination", "namespace", "requirements"], "properties": { "destina...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_config(location):\n if not os.path.exists(location):\n full_path = os.path.abspath(location)\n logging.fatal('Config not found - expected a configfile at: [{loc}] - exiting.'.format(loc=full_path))\n sys.exit(1)", "def __init__(self, location=None, parent=None, **kwargs):\n ...
[ "0.5855621", "0.5390428", "0.5295843", "0.52190936", "0.51966506", "0.51655555", "0.513441", "0.5131885", "0.5109062", "0.5101511", "0.5075852", "0.50618964", "0.49730387", "0.49712208", "0.4969562", "0.49658695", "0.49602363", "0.4941562", "0.49261326", "0.4875033", "0.48718...
0.74685436
0
Merge prior included and prior excluded.
def _merge_prior_knowledge(included, excluded, return_labels=True): prior_indices = np.array(np.append(included, excluded), dtype=np.int) if return_labels: prior_included_labels = np.ones((len(included),), dtype=int) prior_excluded_labels = np.zeros((len(excluded),), dtype=int) labels...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mergeWith(self, others):", "def get_includes_and_excludes(self):\n # Get set of all targeting objects\n all_targets = set(self.flatten())\n # Get set of all included objects\n includes = set(self._get_includes())\n # Get the items from all_targets which are not in includes\...
[ "0.57685333", "0.56419486", "0.5227683", "0.52121437", "0.5194166", "0.5123063", "0.50769234", "0.5051112", "0.5050305", "0.50063145", "0.499131", "0.4983844", "0.49534607", "0.49036402", "0.4899939", "0.48961824", "0.48901093", "0.48372585", "0.48168328", "0.47843125", "0.47...
0.57996094
0
Do the systematic review, writing the results to the log file.
def review(self, *args, **kwargs): with open_logger(self.log_file) as logger: self._do_review(logger, *args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_execute_review_7(self):\n review.execute_review(self.alchemist, self.test_dir,\n self.review_test_dir.name,\n s_report=True)\n\n self.assertTrue(self.review_test_dir.is_dir())\n\n summary_report_file = self.review_test_dir.join...
[ "0.61790246", "0.5947005", "0.5930345", "0.58846945", "0.58361524", "0.58097017", "0.5804036", "0.57742125", "0.5749535", "0.57159483", "0.5710579", "0.56914544", "0.5666339", "0.56594294", "0.56581706", "0.56380177", "0.56280166", "0.5621518", "0.5610359", "0.5588208", "0.55...
0.74211633
0
Dump the self object to a pickle fill (using dill). Keras models Cannot be dumped, so they are written to a separate h5 file. The model is briefly popped out of the object to allow the rest to be written to a file. Do not rely on this method for long term storage of the class, since library changes could easily break i...
def save(self, pickle_fp): if isinstance(self.model, KerasClassifier) and self.model_trained: model_fp = os.path.splitext(pickle_fp)[0]+".h5" self.model.model.save(model_fp) current_model = self.model.__dict__.pop("model", None) with open(pickle_fp, "wb") as fp: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dumpme(self) :\n fileName = \"./data/oP4_ModelBuilder.dump\"\n with open(fileName,\"wb\") as dumpedFile:\n oPickler = pickle.Pickler(dumpedFile)\n oPickler.dump(self)", "def dump_me(self, fileName=None) :\n if fileName is None :\n fileName = \"./data/oP4_ModelBuilder.du...
[ "0.7791074", "0.7213516", "0.70645314", "0.700601", "0.6976124", "0.6913192", "0.68760085", "0.67957646", "0.6676232", "0.66475046", "0.6638419", "0.66007686", "0.6592473", "0.6590952", "0.65060467", "0.65038276", "0.6476411", "0.64687264", "0.6468542", "0.64482504", "0.64430...
0.72972
1
Create a BaseReview object from a pickle file, and optiona h5 file.
def load(cls, pickle_fp): with open(pickle_fp, "rb") as fp: my_instance = dill.load(fp) try: model_fp = os.path.splitext(pickle_fp)[0]+".h5" current_model = load_model(model_fp) setattr(my_instance.model, "model", current_model) except Exception: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_hdf5_with_structure(file):\n n_classes = 80\n n_boxes = 5\n anchors = [[0.738768, 0.874946], [2.42204, 2.65704], [4.30971, 7.04493], [10.246, 4.59428], [12.6868, 11.8741]]\n\n yolov2 = YOLOv2(n_classes=n_classes, n_boxes=n_boxes)\n chainer.serializers.load_hdf5(file, yolov2)\n model = YO...
[ "0.63541585", "0.6183295", "0.60280734", "0.60085624", "0.5933018", "0.59211874", "0.59164983", "0.5908618", "0.5876573", "0.5753792", "0.5744421", "0.5674579", "0.56636107", "0.5659608", "0.5636618", "0.5631149", "0.56228226", "0.5595656", "0.5590055", "0.558378", "0.5551614...
0.6273821
1
Iterate through given lines iterator (file object or list of lines) and return ngram frequencies. The return value is a dict mapping the length of the ngram to a collections.Counter object of ngram tuple and number of times that ngram occurred. Returned dict includes ngrams of length min_length to max_length.
def count_ngrams(lines, min_length=2, max_length=4): lengths = range(min_length, max_length + 1) ngrams = {length: collections.Counter() for length in lengths} queue = collections.deque(maxlen=max_length) # Helper function to add n-grams at start of current queue to dict def add_queue(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_ngrams(self, lines, min_length=2, max_length=4):\n self.lengths = range(min_length, max_length + 1)\n self.ngrams = {length: collections.Counter() for length in lengths}\n self.queue = collections.deque(maxlen=max_length)", "def count_ngrams(lines, min_length=1, max_length=4):\n ...
[ "0.7684961", "0.76285505", "0.73904157", "0.680265", "0.67729276", "0.67621726", "0.6700955", "0.6661531", "0.66487426", "0.659852", "0.6427865", "0.6388674", "0.63881356", "0.6381354", "0.63468874", "0.63448745", "0.6335181", "0.6334952", "0.63114697", "0.6289899", "0.628243...
0.78236645
0
Gets the loss function corresponding to a given dataset type.
def get_loss_func(args: Namespace) -> nn.Module: if args.dataset_type == 'classification': return nn.BCEWithLogitsLoss(reduction='none') if args.dataset_type == 'regression': return nn.MSELoss(reduction='none') if args.dataset_type == 'multiclass': return nn.CrossEntropyLoss(reduct...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_loss_fn(kind):\n if kind == 'classic':\n loss_fn = classic_gan_losses\n elif kind == 'nonsaturating':\n loss_fn = nonsaturating_gan_losses\n elif kind == 'wasserstein':\n loss_fn = wasserstein_gan_losses\n elif kind == 'hinge':\n loss_fn = hinge_gan_losses\n retur...
[ "0.69792575", "0.66915447", "0.6646129", "0.65072674", "0.6405765", "0.6325996", "0.6304869", "0.6197979", "0.6126718", "0.60966563", "0.6041246", "0.60170287", "0.5949288", "0.59453076", "0.5903173", "0.5843568", "0.5805806", "0.57782596", "0.5755673", "0.5743353", "0.572834...
0.7877732
0
Computes the accuracy of a binary prediction task using a given threshold for generating hard predictions. Alternatively, computes accuracy for a multiclass prediction task by picking the largest probability.
def accuracy(targets: List[int], preds: Union[List[float], List[List[float]]], threshold: float = 0.5) -> float: if type(preds[0]) == list: # multiclass hard_preds = [p.index(max(p)) for p in preds] else: hard_preds = [1 if p > threshold else 0 for p in preds] # binary prediction...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accuracy(targets: List[int],\n preds: Union[List[float], List[List[float]]],\n threshold: float = 0.5) -> float:\n if type(preds[0]) == list: # multiclass\n hard_preds = [p.index(max(p)) for p in preds]\n else:\n hard_preds = [1 if p > threshold else 0 for p in pred...
[ "0.7709991", "0.7511051", "0.7276398", "0.70488864", "0.70320666", "0.69131315", "0.6908888", "0.68309194", "0.6726362", "0.67168456", "0.6644039", "0.6570016", "0.64819574", "0.6433799", "0.643102", "0.64011323", "0.6399237", "0.6395455", "0.6382157", "0.63656", "0.63620985"...
0.7749667
0
Builds a PyTorch Optimizer.
def build_optimizer(model: nn.Module, args: Namespace) -> Optimizer: params = [{'params': model.parameters(), 'lr': args.init_lr, 'weight_decay': 0}] return Adam(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_optimizer(cfg: CfgNode, model: torch.nn.Module) -> torch.optim.Optimizer:\n norm_module_types = (\n torch.nn.BatchNorm1d,\n torch.nn.BatchNorm2d,\n torch.nn.BatchNorm3d,\n torch.nn.SyncBatchNorm,\n # NaiveSyncBatchNorm inherits from BatchNorm2d\n torch.nn.Grou...
[ "0.6598968", "0.6491794", "0.64786536", "0.6437391", "0.63047016", "0.61300355", "0.60748035", "0.6072925", "0.598902", "0.5971825", "0.59371614", "0.5908207", "0.5907911", "0.5886632", "0.5873024", "0.58706564", "0.5867648", "0.58661216", "0.5852822", "0.5833402", "0.579277"...
0.66013163
0
Builds a PyTorch learning rate scheduler.
def build_lr_scheduler(optimizer: Optimizer, args: Namespace, total_epochs: List[int] = None) -> _LRScheduler: # Learning rate scheduler return NoamLR( optimizer=optimizer, warmup_epochs=[args.warmup_epochs], total_epochs=total_epochs or [args.epochs] * args.num_lr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scheduler_creator(optimizer, config):\n return torch.optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.9)", "def make_lr_scheduler(lr: float, final_lr: float, n_epochs: int,\n verbose: int = 1) -> keras.callbacks.LearningRateScheduler:\n schedule = build_schedule(lr, final_...
[ "0.7930454", "0.7270104", "0.72256047", "0.7176108", "0.7084193", "0.70634633", "0.7060095", "0.70600694", "0.7007854", "0.69914424", "0.6941896", "0.6919559", "0.69080704", "0.6861845", "0.6807765", "0.67986774", "0.6795805", "0.6786529", "0.67793083", "0.67793083", "0.67736...
0.7315069
1
[load data from bhav csv to redis]
def load_bhav_data_csv(self, filepath: str) -> None: # create redis pipeline pipeline = self.redis.pipeline(transaction=True) pipeline.flushdb() total_items_counter = 0 with open(filepath, "r") as csv_file: csv_dict_reader = csv.DictReader(csv_file) for ro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _from_redis(self):\n\n # OSM ways and nodes tables\n logging.info(\"Loading OSM ways from redis\")\n self._ways = self._gdf_from_redis(self._bbid + \"_ways\", geometry='geometry')\n if self._ways is None:\n raise Exception(\"No ways data found for this bbid, please provid...
[ "0.58576435", "0.5733669", "0.5632679", "0.55542535", "0.55144584", "0.55141103", "0.5494096", "0.54575187", "0.54455847", "0.5430424", "0.5416055", "0.53992265", "0.53853184", "0.5379547", "0.5354384", "0.5348096", "0.5341777", "0.5267653", "0.524234", "0.52345383", "0.52292...
0.7339843
0
Recursive function to find some child of a node which is an EDU and does not have the excluded ID
def seek_other_edu_child(nodes, source, exclude, block): if source == "0": return None else: # Check if this is already an EDU if nodes[source].kind == "edu" and source != exclude and source not in block: return source # Loop through children of this node children_to_search = [child for child in nodes[s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getedunode(tree):\n # Post-order depth-first traversal\n post_nodelist = postorder_DFT(tree, [])\n # EDU list\n edulist = []\n for node in post_nodelist:\n if (node.lnode is None) and (node.rnode is None):\n edulist.append(node)\n return edulist", "def find_child(self, dat...
[ "0.5483303", "0.5378936", "0.5361327", "0.53357214", "0.5319795", "0.5279911", "0.5267122", "0.52607787", "0.523028", "0.5167194", "0.5160421", "0.51143736", "0.50915647", "0.5079196", "0.5073051", "0.506199", "0.5061287", "0.5005479", "0.49868023", "0.49814376", "0.4978803",...
0.68042105
0
add mode to operation with the needed resource for the mode. if it is a new mode number, create it. save the resource in all_resources list.
def add_mode(self, mode_number, resource, start, dur): # save all needed resources for every mode in all_resources dictionary if resource not in self.all_resources: self.all_resources[resource] = [mode_number] else: self.all_resources[resource].append(mode_number) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_resource(self, resource, resource_start, resource_dur):\n self.resources.append(resource)\n resource.add_mode(self.op_number, self.mode_number, resource_start, resource_dur)", "def append(self, mode):\n _logger().log(5, 'adding mode %r', mode.name)\n self._modes[mode.name] = m...
[ "0.66186523", "0.6348235", "0.60964996", "0.6094024", "0.59525174", "0.586816", "0.5593441", "0.558757", "0.5558178", "0.5470928", "0.5463765", "0.53962845", "0.5395574", "0.53228295", "0.52790344", "0.52721536", "0.52546984", "0.5246441", "0.52185845", "0.5198046", "0.519473...
0.8622642
0
return the shortest mode of this operation
def get_shortest_mode(self): return min(self.modes, key=lambda mode: mode.tim)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mode(self) -> int:", "def mode(self):\n mode = max(self.data, key=self.data.count)\n return mode", "def mode(y):\n if len(y)==0:\n return -1\n else:\n return stats.mode(y.flatten())[0][0]", "def mode(self):\n return self._summarize(lambda c: c.mode)", "def mode(...
[ "0.6880954", "0.6422389", "0.6374043", "0.6300473", "0.6297785", "0.6273692", "0.62567586", "0.61943084", "0.6140916", "0.61289376", "0.6082044", "0.60252184", "0.5934511", "0.59279275", "0.58770746", "0.58483845", "0.58428395", "0.5790417", "0.57883215", "0.5787133", "0.5763...
0.7509745
0
Test that a given password policy is valid according to the second stars' rules.
def test_validate_second_star_policy(policy: str, expected: bool): assert day2.validate_second_star_policy(policy) == expected
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_pwd_policy2(processed):\n policy, letter, pwd = processed\n idx1 = policy[0] - 1\n idx2 = policy[-1] - 1\n return (pwd[idx1] == letter) ^ (pwd[idx2] == letter)", "def check_pwd_policy1(processed):\n policy, letter, pwd = processed\n return pwd.count(letter) in policy", "def test_che...
[ "0.7291398", "0.69760734", "0.6725762", "0.6681516", "0.6674957", "0.660869", "0.659909", "0.6551593", "0.64916486", "0.64302176", "0.6377811", "0.63685375", "0.6358652", "0.6352963", "0.6323817", "0.62727654", "0.6260491", "0.6254762", "0.6252222", "0.6249409", "0.6229831", ...
0.7226481
1
Validating second star logic.
def test_second_star(): assert day2.second_star("answers/day2.txt") == 558
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_second_star_policy(policy: str, expected: bool):\n assert day2.validate_second_star_policy(policy) == expected", "def second_star():\n contents = read_file('Day5.txt')\n answer = 0\n for line in contents:\n line = line.lower().strip()\n if line:\n if is_nice...
[ "0.621566", "0.58884156", "0.58762884", "0.58503526", "0.5788506", "0.5668393", "0.5585831", "0.5523089", "0.5478568", "0.53456324", "0.53296465", "0.5269895", "0.52459335", "0.52417326", "0.52202207", "0.5220058", "0.5152928", "0.5149961", "0.5147231", "0.51171714", "0.50622...
0.640009
0
send a twitter mention to brid.gy
def bridgy_twitter(location): r = send_mention( 'http://' + DOMAIN_NAME +'/e/' + location, 'https://brid.gy/publish/twitter', endpoint='https://brid.gy/publish/webmention' ) location = 'http://' + DOMAIN_NAME +'/e/' + location syndication = r.json() app.logger.info(syndicatio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mention(cls, user, message, mentioned):\r\n pass", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_tweet(tweet_text):\n twitter.update_status(status=tweet_text)", "def send_twee...
[ "0.70912", "0.6978928", "0.6978928", "0.6978928", "0.6951119", "0.6886675", "0.68542016", "0.67850006", "0.67706645", "0.67391354", "0.6737515", "0.66903025", "0.66903025", "0.66689706", "0.6652939", "0.66358626", "0.65524536", "0.6468319", "0.6412316", "0.6400552", "0.639498...
0.73339784
0
do not useold image fetcher
def image_fetcher_depricated(year, month, day, name): entry = 'data/{year}/{month}/{day}/image/{name}'.format(year=year, month=month, day=day, type=type, name=name) img = open(entry) return send_file(img)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image_url():", "def getimgs():", "def __init__(self, do, token, url, agent):\n super(Image, self).__init__(token, agent)\n self.do = do\n self.uri = \"%s/images\" % url", "def still_image_url(self) -> str:\n\t\treturn 'grab.jpg?oid={0}'.format(self._oid)", "def _collect_img_lin...
[ "0.6818959", "0.6404207", "0.6400739", "0.6391003", "0.63238287", "0.6299582", "0.62419873", "0.6237364", "0.6231113", "0.6231113", "0.6231113", "0.618493", "0.61705214", "0.6151717", "0.61488676", "0.6111828", "0.6104901", "0.610253", "0.60901284", "0.60603756", "0.60417", ...
0.6506369
1
Gets all entries posted during a specific year
def time_search_year(year): entries = [] cur = g.db.execute( """ SELECT entries.location FROM entries WHERE CAST(strftime('%Y',entries.published)AS INT) = {year} ORDER BY entries.published DESC """.format(year=int(year))) for (row,) in cur.fetchall(): if os.p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_year_filtering(self):\n # Get a valid date\n entry = Entry.objects.get(id=1)\n params = {\"year\": entry.publication_date.year}\n\n self._test_filtering(**params)", "def get_year(cls, year):\n try:\n qs = cls.query.get_year(year=year)\n records = ...
[ "0.65764904", "0.6450242", "0.6227139", "0.61741126", "0.6167132", "0.6156517", "0.6050582", "0.59865075", "0.5983737", "0.5917482", "0.59003574", "0.5878821", "0.58784777", "0.58771783", "0.5831988", "0.58086705", "0.5777024", "0.5765258", "0.5722472", "0.5717026", "0.570293...
0.6742848
0
Gets all entries posted during a specific month
def time_search_month(year, month): entries = [] cur = g.db.execute( """ SELECT entries.location FROM entries WHERE CAST(strftime('%Y',entries.published)AS INT) = {year} AND CAST(strftime('%m',entries.published)AS INT) = {month} ORDER BY entries.published DESC """...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_overview(items, month_long):\n events = []\n for item in items:\n dt = datetime.strptime(item['Date'], '%m/%d/%Y')\n if filters.month_l_filter(dt.month) == month_long:\n events.append(item)\n return events", "def events_in_month(request, year, month):\n month = date...
[ "0.6802178", "0.65576446", "0.6284594", "0.61810654", "0.60744697", "0.596643", "0.5957704", "0.59408075", "0.5850851", "0.5822639", "0.58131397", "0.5804216", "0.57973576", "0.57808834", "0.577851", "0.57757276", "0.5738202", "0.5736317", "0.5650376", "0.56443286", "0.562900...
0.6839035
0
Solves the Constrained Optimization Problem Given the gradients, compute the alphas for the COP and returns them in a list.
def solve(self, gradients): return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_gradients(self, loss, params):\n # check asserts\n assert isinstance(params, list), '\"params\" should be a list type.'\n \n # compute gradients\n grads = T.grad(loss, params)\n if self.clipnorm is not None:\n grad_l2norm = T.sqrt(sum([T.sum(T.square...
[ "0.59999377", "0.58975494", "0.5767106", "0.56787324", "0.5576172", "0.5534451", "0.55323696", "0.5529321", "0.5500675", "0.54990476", "0.53855956", "0.5367587", "0.5359784", "0.53419304", "0.5329323", "0.5328156", "0.53161484", "0.5316089", "0.5308615", "0.52978164", "0.5271...
0.6094127
0
trend_filter(y, lambda = 0, order = 3) finds the solution of the l1 trend estimation problem minimize (1/2)||yx||^2+lambda||Dx||_1, with variable x, and problem data y and lambda, with lambda >0. D is the second difference matrix, with rows [0... 1 2 1 ...0] and the dual problem minimize (1/2)||D'z||^2y'D'z subject to ...
def trend_filter(y, lambd = 0, order = 3): # PARAMETERS alpha = 0.01 #backtracking linesearch parameter (0,0.5] beta = 0.5 # backtracking linesearch parameter (0,1) mu = 2 # IPM parameter: t update max_iter = 40 # IPM parameter: max iteration of IPM max_ls_iter = 20 # IPM parameter: max ite...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trend_filter(rets_data, lambda_value):\r\n #USING CVXPY convex optimiser\r\n n_periods = rets_data.shape[0]\r\n rets = rets_data.to_numpy()\r\n\r\n D_full = np.diag([1]*n_periods) - np.diag([1]*(n_periods-1), 1)\r\n D = D_full[0:n_periods-1,]\r\n beta = cp.Variable(n_periods)\r\n lambd = c...
[ "0.6355593", "0.5376776", "0.5302288", "0.5244712", "0.5239487", "0.52225435", "0.52082145", "0.5153994", "0.51186603", "0.50843084", "0.50812143", "0.5067192", "0.50605345", "0.5042903", "0.50331384", "0.50325465", "0.5032164", "0.5014226", "0.5008059", "0.50057834", "0.5000...
0.70413655
0
Looks at all tag lists and concats into a matrix outputs
def make_tag_matrix(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_movie_tag_matrix(self):\n data_frame = genre_tag.get_genre_data()\n tag_df = data_frame.reset_index()\n unique_tags = tag_df.tag.unique()\n idf_data = tag_df.groupby(['movieid'])['tag'].apply(set)\n tf_df = tag_df.groupby(['movieid'])['tag'].apply(lambda x: ','.join(x)).r...
[ "0.5701825", "0.5668501", "0.5660716", "0.5623673", "0.5541165", "0.5530826", "0.54011905", "0.5388603", "0.5365625", "0.52665615", "0.5246975", "0.52286", "0.52226275", "0.5177595", "0.5173128", "0.5165793", "0.5156149", "0.5126925", "0.5114938", "0.5112256", "0.50849825", ...
0.67757803
0
Puts all imports in a standard format If import is "import a, b, c" then method will put a, b, and c in separate entries. If import is "from a import b" then method will put a.b into the list. This is also true for "from _ as _". Also removes "as _" at the end of imports so there is no ambiguity.
def clean_imports(import_list): mod_lst = [] while import_list: if ',' in import_list[0]: if import_list[0][0:6] == 'import': temp_ = import_list[0][6:].split(',') for i in temp_: import_list.append('import ' + i) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse_import_list(self):\n imports = []\n brackets = False\n continue_kw = [\",\", \";\", \"\\n\", ')'] \\\n + list(set(keyword.kwlist) - set(['as']))\n while True:\n defunct = False\n token_type, tok = self.next()\n if tok == '(': # pyt...
[ "0.63375807", "0.6333035", "0.6242245", "0.6186043", "0.6157611", "0.5983975", "0.59371877", "0.584444", "0.5828029", "0.5757452", "0.57384795", "0.5724127", "0.5671354", "0.56650764", "0.56525475", "0.56257075", "0.56121284", "0.5602591", "0.5598451", "0.558749", "0.5533677"...
0.72232276
0
Draw the default networkx graph
def draw_graph_default(graph): nx.draw_networkx(graph, with_labels=True) plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self):\n nx.draw_networkx(self.rc)", "def draw(self):\n\t\tnx_graph = self.parse_graph()\n\t\tpos = nx.spring_layout(nx_graph, k=0.15, iterations=20) # to spread out the nodes\n\n\t\tnx.draw(nx_graph, pos, edge_color=\"black\", width=1, linewidths=1, node_size=500, node_color=\"pink\", alpha=0.9,...
[ "0.7919437", "0.7764581", "0.74634933", "0.7393788", "0.72745425", "0.7213948", "0.71052366", "0.7100083", "0.7098655", "0.7086878", "0.70481366", "0.7043933", "0.7035017", "0.7025723", "0.70026743", "0.69983006", "0.6953662", "0.69463474", "0.6936123", "0.6900292", "0.689664...
0.8451594
0
Gathers all imports that will be nodes for the graph Takes a file as input and from there processes the file so that the output is a list of all the possible nodes as well as their paths. An example of this would be having numpy and linspace as the two nodes in the graph and it would be displayed in the list as numpy.l...
def gather_nodes(filename): # process the file with open(filename) as f: content = f.readlines() # remove any extra whitespace from both ends content = [i.lstrip().rstrip() for i in content] # gather just the import lines all_imports = [line for line in content if line[0:6] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _imports_into_edges(self, filepath):\n edgelist = []\n for imp in self.get_imports(self.sourcepath / filepath):\n internal_file = False\n for _intern in self.internal:\n if imp in _intern:\n imp = _intern\n internal_file =...
[ "0.6789332", "0.6467016", "0.6419514", "0.6361303", "0.62989897", "0.62435204", "0.6131774", "0.6125948", "0.6103109", "0.61010754", "0.606573", "0.6044264", "0.60404086", "0.6021456", "0.5990777", "0.5990201", "0.59765095", "0.5975766", "0.5964688", "0.59557897", "0.5954681"...
0.7581742
0
Creates input list then lowers it and also checks it is only letters >>> create_input_list("Japan, South Africa, pakistan") ["japan", "south africa", "pakistan"]
def create_input_list(prompt): list_countries = input(prompt).split(", ") list_countries = [x.lower() for x in list_countries] return list_countries
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keep_lowercase(str_list):", "def separate_list_input(input_: str) -> List[str]:\n no_commas = input_.replace(\",\", \" \")\n # Each string is naturally unicode, this causes problems with M2Crypto SANs\n # TODO: check if above is still true when M2Crypto is gone ^\n return [str(string) for string ...
[ "0.6320133", "0.6278571", "0.62713885", "0.6207304", "0.6195942", "0.6000138", "0.59812003", "0.57564145", "0.57519066", "0.5724541", "0.57224125", "0.5715764", "0.56915665", "0.56763303", "0.56632733", "0.56419736", "0.5632977", "0.5510618", "0.55077595", "0.55041385", "0.55...
0.7727037
0
Checks that user inputted country is in list of accepted country names. If not, they must retry entering whole list. >>> check_country(["japan", "singapore", "india"]) ['japan', 'singapore', 'india'] >>> check_country(["space", "singapore", "india"]) Please make sure you entered the correct country names
def check_country(input_list): country_list = open("countries.txt").read().splitlines() country_list = [x.lower() for x in country_list] while True: if not all(x in country_list for x in input_list): print("Please make sure you entered the correct country names") input_list...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validateCountry(self, country_name):\n if country_name in self.travel_db.countries:\n return True\n else:\n return False", "def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is T...
[ "0.7024101", "0.62138045", "0.617862", "0.6122707", "0.60352933", "0.6022922", "0.59852684", "0.5973596", "0.58436495", "0.5806124", "0.5785807", "0.56680405", "0.56628275", "0.5576247", "0.5553671", "0.55498075", "0.5516413", "0.54437375", "0.5365109", "0.5342215", "0.533820...
0.80790645
0
Returns the block containing addr. If the block is not present, it calls read on the next level store.
def _load_block(self, addr): ret_block = None tag, set_index, offset = self._decompose(addr) if set_index not in self._d: self._d[set_index] = [] block_list = self._d[set_index] for tag_, block in block_list: if tag == tag_: self._track(a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self, addr: str) -> dict:\n for block in self.__mem:\n if block['address'] == addr:\n return block\n\n return {}", "def getBlock(self, addr: ghidra.program.model.address.Address) -> ghidra.program.model.mem.MemoryBlock:\n ...", "def get_block(self, chunk,...
[ "0.71545273", "0.6975174", "0.66679907", "0.65838784", "0.6459256", "0.634004", "0.633193", "0.63195604", "0.6292701", "0.6288051", "0.6278899", "0.62583405", "0.6253954", "0.6194434", "0.61794126", "0.60847723", "0.6075524", "0.6063847", "0.6043325", "0.6032997", "0.5892681"...
0.76011753
0
Writes the block containing addr.
def _write_block(self, addr, block, direct=True): self._track(addr, read=False) tag, set_index, offset = self._decompose(addr) if set_index not in self._d: self._d[set_index] = [] block_list = self._d[set_index] inserted = False for i, entry in enumerate(bloc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_block_data(self, addr, reg, data):\n raise NotImplementedError()", "def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int:", "def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int:", "def writeto_mem(self, addr: int, memaddr: int, buf: bytes, /, *, addrsize: i...
[ "0.6783767", "0.658146", "0.658146", "0.6315466", "0.6315466", "0.621557", "0.6205037", "0.61565256", "0.61290956", "0.602502", "0.6000028", "0.59711957", "0.58247846", "0.5681205", "0.56791246", "0.566333", "0.5585867", "0.55725205", "0.5468893", "0.5438787", "0.5419565", ...
0.6955682
0
Setup method for Grids REST API. Sets up any database connections or other prerequisites.
def setup(config, *args, **kwargs): cfg_rest = config.get('rest',{}).get('grids',{}) db_cfg = cfg_rest.get('database',{}) # add indexes db = pymongo.MongoClient(**db_cfg).grids if 'grid_id_index' not in db.grids.index_information(): db.grids.create_index('grid_id', name='grid_id_index', uni...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup():\n global connection\n connection = MySQLdb.connect(host=config.get('mysql.host'),\n user=config.get('mysql.user'),\n passwd=config.get('mysql.password'),\n db=config.get('mysql.db'),\n ...
[ "0.69929224", "0.68753135", "0.6732736", "0.6715896", "0.66752124", "0.6565553", "0.64716566", "0.64533854", "0.6439636", "0.64312804", "0.632284", "0.6285714", "0.6282729", "0.62525094", "0.62398857", "0.6237679", "0.6235256", "0.6223723", "0.620033", "0.6194059", "0.6190396...
0.7135885
0
Update a grid entry. Body should contain the grid data to update. Note that this will perform a merge (not replace).
async def patch(self, grid_id): data = json.loads(self.request.body) if not data: raise tornado.web.HTTPError(400, reason='Missing update data') data['last_update'] = nowstr() ret = await self.db.grids.find_one_and_update({'grid_id':grid_id}, {'$set':data}, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_grid_from_sail_form(self, post_url: str,\n grid_component: Dict[str, Any], new_grid_save_value: Dict[str, Any],\n context: Dict[str, Any], uuid: str,\n context_label: str = None) -> Dict[str, Any]:\n ...
[ "0.67547053", "0.61716086", "0.5904463", "0.5894299", "0.57934475", "0.57144254", "0.5703705", "0.5615451", "0.5613429", "0.55766696", "0.55619353", "0.5559711", "0.5554974", "0.554294", "0.554294", "0.554294", "0.5521593", "0.5515253", "0.55052656", "0.5440518", "0.54231566"...
0.677131
0
Transforms each element `V` into a tuple `(K, V)`. `K` is the projection of `V` by `keys`, which is equal to the tuple produced by the `Project` transform.
def IndexBy(*keys): return "IndexBy" >> beam.Map(lambda r: (tuple(r[k] for k in keys), r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Project(*keys):\n return \"Project\" >> beam.Map(lambda r: tuple(r[k] for k in keys))", "def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:\n my_tuple = (k, v*v)\n\n return my_tuple", "def to_tuple(self) -> Tuple[Any]:\n return tuple(self[k] for k in self.keys())", "def to_tupl...
[ "0.72535384", "0.53463095", "0.5257933", "0.5257933", "0.5147331", "0.5128732", "0.51225805", "0.50841254", "0.50720644", "0.5030997", "0.5024805", "0.49972284", "0.4976981", "0.49555498", "0.49529418", "0.49438566", "0.49248445", "0.49203864", "0.49174932", "0.49004233", "0....
0.55218637
1
Transforms each element `V` into a tuple `(K, V)`. The difference between `IndexBySingle(key)` and `IndexBy(key)` with a single
def IndexBySingle(key): return "IndexBySingle" >> beam.Map(lambda r: (r[key], r))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self, x):\r\n return tuple(x)", "def IndexBy(*keys):\n return \"IndexBy\" >> beam.Map(lambda r: (tuple(r[k] for k in keys), r))", "def __getitem__(self, key):\n return tuple(self._mapping[key])", "def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:\n my_tuple = (k, v*v)\...
[ "0.60922354", "0.60166097", "0.57944596", "0.57863474", "0.57379335", "0.57327056", "0.5623573", "0.54659075", "0.5372417", "0.53676397", "0.5335588", "0.5312971", "0.52960134", "0.52922773", "0.52922773", "0.5284726", "0.52737004", "0.52715224", "0.52523285", "0.5218947", "0...
0.64144003
0
Rename columns according to `from_to_key_mapping`.
def RenameFromTo(from_to_key_mapping): def rename(row): res = dict(row) for k1, k2 in from_to_key_mapping.items(): if k1 in res: v = res.pop(k1) res[k2] = v return res return "Rename" >> beam.Map(rename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rename_columns(columns, mapper, keep_original):\n for name, rename in mapper.items():\n if name in columns:\n columns[rename] = org_copy.deepcopy(columns[name])\n if 'parent' in columns[name]:\n parents = columns[name]['pare...
[ "0.6434023", "0.6402961", "0.6393669", "0.60778624", "0.59697354", "0.59653217", "0.59624434", "0.593743", "0.592301", "0.5879087", "0.57664126", "0.5764425", "0.5706599", "0.56312495", "0.5626173", "0.56260186", "0.5605588", "0.5603266", "0.5598767", "0.55849487", "0.5567215...
0.7920267
0
Filters over an assembly file and gives the IDA pro comments Requires a UTF8 set of strings.
def filter_comments(asm_utf): comments = [] # removes nones a = filter(lambda x: x != None, asm_utf) # splits on comment token comments = [re.split(";", line) for line in a] # takes only those that have a comment token comments = list(filter(lambda x: len(x) > 1, comments)) # strips the ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_process_asm_file(assembly_file):\r\n line_counter = 0\r\n marker_dictionary = load_constants()\r\n commands_list = list()\r\n for command in assembly_file.readlines():\r\n command = command.split(\"/\")[0] # getting rid of comments\r\n command = \"\".join(command.split()) # gett...
[ "0.5961627", "0.56810504", "0.5566075", "0.5412007", "0.54119974", "0.5345376", "0.53153485", "0.52601546", "0.5240575", "0.52389747", "0.5202761", "0.520113", "0.5141318", "0.51237476", "0.5102175", "0.50320864", "0.50298184", "0.5020066", "0.50187165", "0.49976897", "0.4995...
0.66711164
0
Extracts the comments from the file and saves them in the document `doc`
def save_comments(doc): global collection if doc.get('ida_comments', ''): print('Comments already extracted for document [%s], skipping.' % doc['id']) else: print('Saving comments for document [%s].' % doc['id']) asm = open_asm(doc['id']) #asm = [to_ut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_comments(comments_file, output_filename=direc+\"/comments.txt\"):\r\n if not os.path.exists(output_filename.split(\"/\")[0]):\r\n os.makedirs(output_filename.split(\"/\")[0])\r\n\r\n print(\"Extracting comments from \" + comments_file + \"...\")\r\n comments_dict = {}\r\n with open(o...
[ "0.70212615", "0.6491964", "0.6416174", "0.6369594", "0.63566494", "0.6265086", "0.60980767", "0.60809886", "0.59321374", "0.59143645", "0.5802501", "0.57628584", "0.56938124", "0.56853855", "0.5670586", "0.5666101", "0.56338197", "0.5611259", "0.5610039", "0.56060696", "0.55...
0.6811905
1
Saves the comments of the dataset into the database. This one operates based on the files that are in your directory.
def save_local_files(name_file): global collection name_file = name_file.split('.')[0] document = collection.find({'id': name_file}) if document.count() > 0 and document[0].get('ida_comments', ''): print('Comments already extracted for document [%s], skipping.' % document[0]['id']...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_comments(doc):\n global collection\n if doc.get('ida_comments', ''):\n print('Comments already extracted for document [%s], skipping.' %\n doc['id'])\n else:\n print('Saving comments for document [%s].' % doc['id'])\n asm = open_asm(doc['id'])\n ...
[ "0.6435595", "0.6312839", "0.61528647", "0.609396", "0.6069065", "0.59417987", "0.5806655", "0.5718646", "0.5655849", "0.5637166", "0.5607151", "0.55327106", "0.5474431", "0.54364747", "0.5433956", "0.54319423", "0.5426752", "0.54210436", "0.54060376", "0.5382915", "0.5359376...
0.65737236
0
Launch the media player with stream uri.
def launch_player(stream_uri): cmd = [ config.get('player', 'launch_cmd'), '"%s"' % stream_uri, ] + ['--{}'.format(p) for p in config.get('player', 'parameters').split(',')] subprocess.call(' '.join(cmd), shell=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open(self, uri):\n try:\n self.player.OpenUri(uri)\n except AttributeError as ex:\n raise UnsupportedOperation(\n f'{self.name} does not support opening URIs') from ex", "def play(self, stream_url):\n print(\"Ready to play \" + stream_url)\n se...
[ "0.7129495", "0.71098995", "0.6763526", "0.64070755", "0.6260351", "0.624757", "0.6157602", "0.6134986", "0.6100802", "0.60167456", "0.5987899", "0.5957909", "0.5939217", "0.5891497", "0.584083", "0.58141446", "0.580812", "0.5790475", "0.57633907", "0.57625705", "0.57599914",...
0.7956524
0
Random orthogonal weights Used by norm_weights(below), in which case, we are ensuring that the rows are orthogonal (i.e W = U \Sigma V, U has the same of rows, V has the same of cols)
def ortho_weight(ndim): W = numpy.random.randn(ndim, ndim) u, s, v = numpy.linalg.svd(W) return u.astype('float32')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ortho_weight(ndim):\n W = rng_np.randn(ndim, ndim)\n u, _, _ = np.linalg.svd(W)\n return u.astype('float32')", "def orthogonal_weight_tensor(shape):\n if len(shape) == 2 :\n if shape[0] == shape[1] :\n M = rng_np.randn(*shape).astype(np.float32)\n Q, R = np.linalg.qr(...
[ "0.72828364", "0.6974768", "0.68845916", "0.66035664", "0.659437", "0.65169877", "0.64774096", "0.64329475", "0.64217156", "0.6396008", "0.6323675", "0.6312961", "0.6248349", "0.6240783", "0.6206433", "0.6184517", "0.6155063", "0.61467236", "0.6141991", "0.6136662", "0.610007...
0.7145966
1
Connect to a running Quicken. Exits if unable to connect.
def connect(quicken_path: str = QUICKEN_EXE) -> Application: print("Connecting to Quicken", end="") tries = 0 while tries < MAX_TRIES: try: print(".", end="", flush=True) quicken = Application().connect(path=quicken_path) except ProcessNotFoundError: tries...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self) -> None:\n self.terminate()\n self._new_client().connect(\n hostname=self.ip,\n port=self.port,\n username=self.username,\n password=self.password,\n look_for_keys=False,\n allow_agent=False)", "def connect(self):\n...
[ "0.66176707", "0.6467609", "0.63279045", "0.6277428", "0.6249217", "0.6218416", "0.6204633", "0.6191149", "0.6153156", "0.61359715", "0.6128265", "0.61268306", "0.61261153", "0.61195517", "0.6083524", "0.6077736", "0.6041318", "0.6038033", "0.6034769", "0.60110307", "0.600610...
0.75798625
0
Takes a DNA sequence and transforms it into a RNA sequence.
def to_rna(seq): seq=seq.replace('A','U') seq=seq.replace('T','A') seq=seq.replace('C',"P") seq=seq.replace('G','C') seq=seq.replace('P','G') return seq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_rna(dna):\r\n return dna.translate(str.maketrans('ATGC','UACG'))", "def translate_sequence(rna_sequence, genetic_code):\n #Crate an empty list to store AA sequence:\n AA_list = []\n # Convert all rna_sequence to upper case:\n rna_sequence=rna_sequence.upper()\n # Convert all rna_sequence...
[ "0.7669018", "0.75413525", "0.7380885", "0.7314864", "0.7216778", "0.71945727", "0.71105105", "0.70800424", "0.69325453", "0.6911802", "0.69019145", "0.6812737", "0.67335016", "0.6728875", "0.67027515", "0.66922444", "0.6666653", "0.6590273", "0.6528604", "0.6417373", "0.6373...
0.79545945
0
Returns full filter name using information from name and filter_path provided.
def _get_full_filter_name(name, filter_path): filename = os.path.basename(filter_path) file_only = os.path.splitext(filename)[0] filter_name = "{}.{}".format(file_only, name) return filter_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_filter_name(self):\n pass", "async def get_filter(self, **kwargs: Any) -> str:\n return self._telescope.filter_name", "def name(self) -> StringFilter:\n return self.__name", "def get_exact_filter_by_name(self, name):\n for entry in self.filters:\n if (entry['typ...
[ "0.7273906", "0.6495935", "0.6320404", "0.60196054", "0.5943108", "0.5935446", "0.59197485", "0.5804569", "0.5769412", "0.57038975", "0.56500113", "0.5647518", "0.5580368", "0.55199283", "0.5509952", "0.5478552", "0.54714257", "0.54514235", "0.5424941", "0.5420056", "0.541518...
0.83885926
0
Convert value provided into datetime object or None if not successful. The purpose of this method is to attempt to convert the value provided using the datetime format string also provided into a datetime object. If the value provided doesn't correspond to the datetime format provided then the datetime strptime method ...
def _get_datetime_from_format(dt_value, dt_format): result = None try: result = datetime.datetime.strptime(dt_value, dt_format) except ValueError: pass return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_datetime(datetime_str: Text) -> datetime.datetime:\n for str_format in cfg.datetime_str_formats:\n try:\n datetime_object = datetime.datetime.strptime(datetime_str, str_format)\n return datetime_object\n except ValueError:\n continue", "def try_strptime...
[ "0.6947664", "0.6938862", "0.6867406", "0.66824174", "0.66588503", "0.66575724", "0.66326183", "0.65770185", "0.65647686", "0.6552498", "0.65447265", "0.64434665", "0.6437222", "0.64192605", "0.63708764", "0.633034", "0.6298367", "0.62121534", "0.6170873", "0.61637217", "0.61...
0.74563617
0
Returns list of event history matching event labels specified.
def _get_all_event_history(device_event_file_path, event_labels, timeout=10.0): result = [] timedout = False file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path, timeout) if not file_exists: timedout = True return result, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_history(self, event_labels=None, count=None, timeout=10.0):\n if event_labels:\n self.verify_event_labels(\n event_labels,\n error_message=\"{} get_event_history failed.\".format(\n self._device_name))\n timedout = False\n try:\n if count:\n hi...
[ "0.6621818", "0.6082841", "0.6029266", "0.59327793", "0.5852928", "0.57673913", "0.5739131", "0.5739131", "0.56805325", "0.5663487", "0.5648216", "0.56215566", "0.56196284", "0.56168085", "0.5608801", "0.55719745", "0.5566846", "0.5565052", "0.554374", "0.5525908", "0.5512215...
0.64784175
1
Wait up to the timeout period for the event file to be created.
def _wait_for_event_file(event_file_path, timeout): start_time = time.time() end_time = start_time + timeout while True: timeout_remaining = end_time - time.time() if timeout_remaining <= 0: return (False, 0) elif os.path.exists(event_file_path): return (True, timeout_remaining) else...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heartbeat(self):\n timeout_at = time.time() + self.timeout\n\n try:\n os.utime(self.filename, (timeout_at, timeout_at))\n\n except OSError as err:\n if err.errno == errno.ENOENT:\n _LOGGER.warning('Lost lease file: %r', self.file...
[ "0.608407", "0.5938035", "0.5922863", "0.5837459", "0.5825981", "0.57994986", "0.57297707", "0.571166", "0.5705782", "0.5664646", "0.5608379", "0.56036955", "0.5554165", "0.5551678", "0.55417126", "0.5517896", "0.54916334", "0.5488666", "0.5487971", "0.5443709", "0.54428506",...
0.71993464
0
Returns count of event history matching event label specified.
def get_event_history_count(self, event_label, timeout=10.0): self.verify_event_labels( [event_label], error_message="%s get_event_history_count failed." % self._device_name) try: count, timedout = _get_event_history_count( self.event_file_path, event_label, timeout=timeout) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_count_by_label(self, label=None):\n if label is None:\n return len(self.data)\n else:\n return sum(1 for d in self.data if d.pred == label)", "def _get_event_history_count(device_event_file_path, event_label, timeout=10.0):\n result = 0\n timedout = False\n\n file_e...
[ "0.6927206", "0.6786222", "0.6022322", "0.5747557", "0.57219446", "0.5649946", "0.5648868", "0.5637877", "0.56110364", "0.55659515", "0.5556555", "0.5548814", "0.55457515", "0.5541466", "0.54923534", "0.54807", "0.547581", "0.5464675", "0.5451758", "0.54230654", "0.5416428", ...
0.7249028
0
Takes an event label pattern, and returns a dictionary of matching event labels.
def get_event_label_dict(self, pattern=None): if pattern is None: return {key: value.pattern for key, value in self._filters_dict.items()} else: try: result_dict = {} regex = re.compile(pattern) for event_label in list(filter(regex.match, list(self._filters_dict))): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_labels(self, pattern=None):\n\n if pattern is None:\n return list(self._filters_dict.keys())\n else:\n try:\n regex = re.compile(pattern)\n return list(filter(regex.match, list(self._filters_dict.keys())))\n except Exception as err:\n raise errors.ParserError...
[ "0.705301", "0.5967765", "0.56136435", "0.54736334", "0.5449883", "0.5353754", "0.53004324", "0.5285208", "0.522042", "0.5197204", "0.50947785", "0.5073371", "0.49641836", "0.49383032", "0.4924246", "0.491624", "0.49161154", "0.4893664", "0.4855615", "0.48546898", "0.481552",...
0.8060473
0
Takes an event label pattern, and returns a list of matching event labels.
def get_event_labels(self, pattern=None): if pattern is None: return list(self._filters_dict.keys()) else: try: regex = re.compile(pattern) return list(filter(regex.match, list(self._filters_dict.keys()))) except Exception as err: raise errors.ParserError( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_label_dict(self, pattern=None):\n\n if pattern is None:\n return {key: value.pattern for key, value in self._filters_dict.items()}\n else:\n try:\n result_dict = {}\n regex = re.compile(pattern)\n for event_label in list(filter(regex.match, list(self._filters_dict...
[ "0.62472373", "0.5896674", "0.5756939", "0.56767726", "0.56703365", "0.5641349", "0.5620617", "0.5609375", "0.55089414", "0.5484202", "0.53388613", "0.53148586", "0.5300112", "0.52978414", "0.5287111", "0.52725494", "0.5258854", "0.52532655", "0.523032", "0.52248114", "0.5203...
0.8007184
0
Load JSON filter file specified.
def load_filter_file(self, filter_path): logger.debug("Adding filter file {}", filter_path) try: with open(filter_path, "r") as filter_file: try: json_filter_data = json.load(filter_file) except Exception as err: msg = "Unable to parse filter file {} as a json file. {!r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_filter_directory(self, filter_path):\n try:\n logger.debug(\"Adding filters from directory {}\", filter_path)\n for filter_file in os.listdir(filter_path):\n if filter_file.endswith(\".json\"):\n filter_file_path = os.path.join(filter_path, filter_file)\n self.load_f...
[ "0.6793281", "0.66293055", "0.6573929", "0.63865566", "0.63719606", "0.6308072", "0.62924355", "0.6278985", "0.62667835", "0.61862415", "0.6185541", "0.61825424", "0.61428314", "0.6138989", "0.61013216", "0.6093863", "0.60882455", "0.60664535", "0.6053399", "0.60379034", "0.6...
0.7409831
0
Parser line against filters and write JSON result to event_file provided.
def process_line(self, event_file, raw_log_line, header_length=29, log_filename=""): event_data = {} for filter_name, regex in self._filters_dict.items(): match = regex.search(raw_log_line) if match: match_data = ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_filter_spec(filters, filename):\n data = export_filters(filters)\n with open(filename, 'w') as fp:\n json.dump(data, fp, indent = 4)", "def filter_json_file(filename, filters_list):\n filename = filename.replace(\" \", \"\")\n print(\"Filters List {}\".format(filters_list))\n if i...
[ "0.61318433", "0.59134746", "0.5879075", "0.5599995", "0.5580844", "0.5461981", "0.54279864", "0.5343064", "0.5231513", "0.52051693", "0.51518404", "0.51461333", "0.51446676", "0.51235896", "0.506409", "0.50508374", "0.5050683", "0.5035986", "0.5034059", "0.5006907", "0.49897...
0.70475507
0
Verifies event_labels in correct format and exist.
def verify_event_labels(self, event_labels, error_message=""): if event_labels is not None and not isinstance(event_labels, list): raise errors.ParserError("{} Expecting event_labels to be a list " "or None but received {} instead.".format( err...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_validity_label(labels):\n # Event is None -> All other values are None\n if labels[3] == 0:\n for i in xrange(5):\n if labels[i] != 0:\n return False\n return True\n \n # If two roles have the same object return False\n for i in xrange(3):\n f...
[ "0.6702047", "0.64607334", "0.63460994", "0.6305003", "0.6098443", "0.60897875", "0.6071821", "0.59971875", "0.5907106", "0.58770484", "0.5840349", "0.5821878", "0.58109576", "0.58091444", "0.58057487", "0.57937926", "0.57756233", "0.57385564", "0.5728577", "0.5722915", "0.57...
0.78669137
0
Waits up to timeout seconds for event labels to appear in device logs.
def wait_for_event_labels(self, event_labels, raise_error=False, timeout=20.0, start_datetime=None): self.verify_event_labels( event_labels, error_message="{} wait_for_event_labels failed....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_for_event_timeout(event):\n received = event.wait(2)\n name = threading.current_thread().getName()\n print \"Waited with timeout, got {}, name {}\".format(received, name)", "def listen(self, timeout=2):\n start = time.monotonic()\n while (time.monotonic()-start) < timeout:\n ...
[ "0.6301212", "0.585833", "0.5724939", "0.56652474", "0.55515707", "0.5549659", "0.5532575", "0.54798186", "0.5474939", "0.54436684", "0.53312016", "0.5307921", "0.5296047", "0.5280927", "0.527302", "0.52095646", "0.5194303", "0.51938176", "0.5153732", "0.51507413", "0.514181"...
0.69714695
0
Adds filter dictionary expression from filter_path specified.
def _add_filter(self, filter_list, filter_path): if "name" not in filter_list: raise errors.ParserError( "Loading filter-file {} failed. " "Missing 'name' key in filter object '{!r}'.".format( filter_path, filter_list)) if "regex_match" not in filter_list: raise err...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_filter(self, filter):\n self._filters.append(filter.as_dict())", "def add_filter(self, name: str, value: any):\n self.filters[name] = value", "def _add_filters(self, filter_list, filter_path):\n if not isinstance(filter_list, list):\n raise errors.ParserError(\n \"Loading...
[ "0.6170425", "0.6151738", "0.59039634", "0.5895332", "0.58122355", "0.56957275", "0.56685686", "0.554609", "0.5538691", "0.55265987", "0.5505833", "0.5505171", "0.5495749", "0.54955846", "0.5494427", "0.54883003", "0.5422577", "0.53739333", "0.5323809", "0.51964414", "0.51853...
0.67896575
0
Adds filters loaded from file_name to list of filters to use.
def _add_filters(self, filter_list, filter_path): if not isinstance(filter_list, list): raise errors.ParserError( "Loading filter-file {} failed. " "Expecting value of 'filter_list' entry to be a list " "but instead its a {}.".format(filter_path, type(filter_list))) for cur_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_filters(self, names, interp=True, lamb=None, filterLib=None):\n with self as s:\n filters = [s._load_filter(fname, interp=interp, lamb=lamb)\n for fname in names]\n return(filters)", "def load_filters(self, names, interp=True, lamb=None, filterLib=None):\n ...
[ "0.6986275", "0.6970435", "0.6918564", "0.6674499", "0.65343827", "0.65334064", "0.65036386", "0.630778", "0.6270512", "0.61921537", "0.6088287", "0.60821855", "0.60370624", "0.59813523", "0.59784156", "0.59227353", "0.5910277", "0.59046036", "0.59046036", "0.59046036", "0.58...
0.7120908
0
Loads every .json file found in filter_path specified.
def _load_filter_directory(self, filter_path): try: logger.debug("Adding filters from directory {}", filter_path) for filter_file in os.listdir(filter_path): if filter_file.endswith(".json"): filter_file_path = os.path.join(filter_path, filter_file) self.load_filter_file(filt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_json_files(self, filter_fn=None):\n def filter_function(f):\n return f is not None and f.endswith(\".json\")\n if not filter_fn:\n filter_fn = filter_function\n files = self.filter_files(None,filter_fn)\n dicts = []\n for f in files:\n w...
[ "0.73628515", "0.6963622", "0.6615014", "0.6268389", "0.6248232", "0.62429833", "0.6187038", "0.617747", "0.6000327", "0.59399736", "0.58981717", "0.5885145", "0.5863954", "0.58593535", "0.58425856", "0.5793319", "0.5789873", "0.57630044", "0.571526", "0.57100266", "0.5706684...
0.7727016
0
Locates a datetime.datetime closest to target datetime.
def _nearest_datetime(self, datetime_list, target_datetime): if not datetime_list: raise errors.ParserError( "Input parameter datetime_list length is zero. Required" " parameters: [datetime.datetime], datetime.datetime") work_list = [entry for entry in datetime_list if entry < target_d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _closest_date(target_dt, date_list, before_target=None) -> datetime.date | None:\n\n def time_before(d):\n return target_dt - d if d <= target_dt else datetime.timedelta.max\n\n def time_after(d):\n return d - target_dt if d >= target_dt else datetime.timedelta.max\n\n def any_time(d):\n...
[ "0.6702089", "0.6500694", "0.64598507", "0.585127", "0.57860357", "0.56574386", "0.5651094", "0.56321347", "0.56310844", "0.55818236", "0.5565437", "0.554823", "0.54743797", "0.5420503", "0.5417901", "0.526718", "0.52564967", "0.52448344", "0.52256316", "0.5214709", "0.519476...
0.7585258
0
Function that creates wiki pages from a template by looking at teams that are registered for a challenge. The teams that have a wiki made for them Are stored into a trackerTable that has columns wikiSynId, and teamId
def create_team_wikis(syn, synid, templateid, tracker_table_synid): challenge_ent = syn.get(synid) challenge_obj = utils.get_challenge(challenge_ent) registered_teams = syn._GET_paginated( "/challenge/{}/challengeTeam".format(challenge_obj['id'])) for i in registered_teams: submitted_te...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_wiki_index_page(request):\n if isinstance(request.group, Team):\n # Find wiki index.\n try:\n page = request.group.content_objects(WikiPage).get(slug=DEFAULT_INDEX)\n except WikiPage.DoesNotExist:\n page = None\n return {\n 'team_wiki_index_p...
[ "0.59659106", "0.5459703", "0.5446284", "0.5292902", "0.5168371", "0.51078725", "0.5103085", "0.5090617", "0.5079518", "0.507277", "0.50709975", "0.5061508", "0.505984", "0.5059186", "0.50466794", "0.50433093", "0.5030929", "0.50159186", "0.4994493", "0.49905354", "0.49869752...
0.8026079
0
Archive the submissions for the given evaluation queue and store them in the destination synapse folder.
def archive_writeup(syn, evaluation, stat="VALIDATED", reArchive=False): if type(evaluation) != synapseclient.Evaluation: evaluation = syn.getEvaluation(evaluation) print("\n\nArchiving", evaluation.id, evaluation.name) print("-" * 60) for sub, status in syn.getSubmissionBundles(evaluation, st...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(self, results):\n filename = self.get_archive_file_path(results)\n results.dump(filename)", "def _archive(self,pools=['backup','archive'],verbose=True,dry_run=False):\n\t\tif type(pools) is not list:\n\t\t\tpools = [pools]\n\n\t\t_start = datetime.today()\n\t\tself.archive_bytes = 0\n\t\t...
[ "0.5692195", "0.56353605", "0.5609163", "0.5514673", "0.5481283", "0.546587", "0.5450681", "0.54277956", "0.5391405", "0.5389693", "0.5242145", "0.5174583", "0.5116506", "0.5114481", "0.5114352", "0.51136255", "0.51075226", "0.5086116", "0.50756234", "0.50755244", "0.50661904...
0.6239523
0
This function verifies that the core connection information (Base URL and API credentials) has been defined.
def verify_core_connection(): if not base_url or not api_credentials: retrieve_connection_info() return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def check_config(self) -> None:\n try:\n await self._check_api()\n except aiohttp.ClientError as e:\n raise ConnectionError(str(e))", "def _check_settings(self):\n if self.api_key is None:\n raise ImproperlyConfigured(\"You must provide an API key.\")",...
[ "0.7091963", "0.691162", "0.6798902", "0.6735169", "0.6727152", "0.6715415", "0.6694974", "0.65938854", "0.6511822", "0.64764845", "0.64648366", "0.64648366", "0.6392897", "0.6391157", "0.63395435", "0.6293454", "0.6261399", "0.6242068", "0.6227387", "0.6191004", "0.61778796"...
0.87422466
1
This function validates a lookup type to ensure that it is acceptable to the primary function call.
def _validate_lookup_type(_lookup_type, _retrieval_value='id'): _accepted_lookup_values = { 'id': ('email', 'username'), 'username': ('id', 'email'), 'email': ('id', 'username') } if _retrieval_value == "id": if _lookup_type not in _accepted_lookup_values.get(_retrieval_value...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CheckType(self, *args, **kwargs):\n pass", "def validate(t):\n return _dispatcher[type(t)](t)", "def _validate_type(self, key, type_):\n if type_ is None:\n type_ = \"\"\n \n if not isinstance(type_, (str, unicode)):\n raise TypeError(\"FileLink.type sho...
[ "0.6280784", "0.60769475", "0.60204196", "0.5949436", "0.5938662", "0.5920147", "0.5846806", "0.58452845", "0.5788779", "0.57818824", "0.577826", "0.57727426", "0.57689863", "0.57664907", "0.57622844", "0.5745901", "0.5737489", "0.5723846", "0.5698527", "0.5692912", "0.56907"...
0.7827961
0
This function obtains the primary email address for a user by looking up their User ID or username.
def get_primary_email(lookup_value, lookup_type="id"): lookup_type = _validate_lookup_type(lookup_type, 'email') user_data = core.get_data('people', lookup_value, lookup_type, return_json=True) primary_email = user_data['emails'][0]['value'] return primary_email
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_email_address(user_id: UserID) -> str:\n email_address = db.session \\\n .query(DbUser.email_address) \\\n .filter_by(id=user_id) \\\n .scalar()\n\n if email_address is None:\n raise ValueError(\n f\"Unknown user ID '{user_id}' or user has no email address\"\n ...
[ "0.77690506", "0.77565724", "0.76010233", "0.7498759", "0.7349504", "0.7336229", "0.72988003", "0.72099537", "0.7158339", "0.70910954", "0.7052061", "0.7027128", "0.69666564", "0.69346976", "0.69088876", "0.6837055", "0.6816422", "0.6793141", "0.67788017", "0.67773724", "0.67...
0.77739346
0
This function constructs the URL to a user's profile.
def get_profile_url(lookup_value, lookup_type="id"): if lookup_type == "username": username = lookup_value else: username = get_username(lookup_value, lookup_type) profile_url = f"{base_url}/people/{username}" return profile_url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile_url(self):\n return reverse(\"auth_profile\", args=[self.user.username])", "def get_absolute_url(self):\n return '/profile/%s' % self.id", "def get_absolute_url(self):\n\n return reverse('profile', args=[str(self.user.username)])", "def get_absolute_url(self):\n return...
[ "0.8227132", "0.7430972", "0.71914357", "0.6894003", "0.6826512", "0.6684108", "0.6663101", "0.6608801", "0.6577758", "0.6514719", "0.6459156", "0.64151084", "0.6401612", "0.63838965", "0.63838965", "0.63838965", "0.6374063", "0.6371142", "0.6349622", "0.6319628", "0.6292984"...
0.7533327
1
This function identifies the content count for an individual REST API call.
def _get_paginated_content_count(_user_uri, _start_index, _count=100): _content_uri = f"{base_url}/contents?filter=author({_user_uri})&count={_count}&startIndex={_start_index}" _response = core.get_request_with_retries(_content_uri) if _response.status_code == 200: _response_json = _response.json() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'count')\r\n\r\n return http.Request('GET', url), parsers.parse_json", "def get_resource_count(har_json):\n entries = har_json['log']['entries']\n\n resource_type_counts = Counter()\n\n for entry in entries:\n resource = en...
[ "0.68372214", "0.6524679", "0.6381083", "0.634387", "0.6243201", "0.6172337", "0.61580133", "0.6127514", "0.6106211", "0.6097753", "0.6074798", "0.6067487", "0.60662615", "0.60662615", "0.60662615", "0.60662615", "0.6049658", "0.60130095", "0.6008954", "0.6006984", "0.5984527...
0.67813146
1
This function obtains the number of content items created by a particular user.
def get_user_content_count(user_id, start_index=0): # Define the variable to track the total content count and structure the user URI total_count = 0 user_uri = f"{base_url}/people/{user_id}" # Get the content count for the first 100 results and increment the total count accordingly content_count =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_usage_count(request, user_id):\n board_count = Member.objects.filter(user_id=user_id, is_creator=True).count()\n return Response({\"board_count\": board_count})", "def get_total_items(self, user: User, transforms: Optional[List[Callable]] = None) -> int:", "def count_revisions_by_user(self):\n ...
[ "0.6730025", "0.6686577", "0.6600662", "0.6510088", "0.6475355", "0.6426317", "0.6405162", "0.63020605", "0.6255534", "0.61494267", "0.6139892", "0.6139045", "0.60678715", "0.6058692", "0.60302025", "0.6009511", "0.6008887", "0.59358513", "0.59263605", "0.5913929", "0.5907688...
0.74049693
0
This function performs the API call to get the users followed from a single GET request.
def _get_followed(_user_id, _ignore_exceptions=False, _start_index=0, _count=100): _following_url = f"{base_url}/people/{_user_id}/@following?count={_count}" + \ f"&startIndex={_start_index}" _response = core.get_request_with_retries(_following_url) if _response.status_c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follows(self):\r\n request = http.Request('GET', '{0}/follows/'.format(self.get_url()))\r\n\r\n return request, parsers.parse_json", "def get_followings(request):\n user_id = request.GET.get(\"user_id\")\n if not user_id:\n return {\"error\": \"User Id should be provided\"}, 400\n ...
[ "0.74524915", "0.7451734", "0.7411945", "0.7273588", "0.7230201", "0.7144421", "0.7144421", "0.7144421", "0.7020813", "0.70104915", "0.70104915", "0.70104915", "0.70104915", "0.6976389", "0.6941813", "0.6930851", "0.6921965", "0.68312484", "0.6744993", "0.6698979", "0.6666516...
0.75183386
0
This function returns the most recent logins that have occurred in the environment.
def get_recent_logins(count=100, start_index=0): # Verify that the core connection has been established verify_core_connection() # Perform and parse the query query_url = f"{base_url}/people?sort=lastLoggedIn&" + \ f"fields=jive,emails,name&count={count}&startIndex={start_index}" re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rolling_log_history():\n current_tag = get_current_tag()\n return get_log_history(current_tag)", "def last_log(self) -> List:\n logs_list: List = os.listdir(LOGS_BASE_PATH)\n full_list = [os.path.join(LOGS_BASE_PATH, i) for i in logs_list]\n time_sorted_list: List = sorted(full...
[ "0.62533057", "0.6127016", "0.5962094", "0.5580813", "0.55602443", "0.55220354", "0.5503221", "0.5459608", "0.54517496", "0.5433043", "0.5422859", "0.53946495", "0.53740424", "0.5363544", "0.5360245", "0.5341821", "0.5305654", "0.52805936", "0.5263784", "0.52597564", "0.52460...
0.6475265
0
Utility function to run operations in a thread but honors the thread limit
def run_in_a_thread(func, args, limit): def get_active_threads(): active = 0 for t in Utility.__THREADS: if t.isAlive(): active += 1 else: Utility.__THREADS.remove(t) return active while get_acti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_time_limit(arg):\n pass", "async def test_exectution_limit_throttle(coresys: CoreSys, loop: asyncio.BaseEventLoop):\n\n class TestClass:\n \"\"\"Test class.\"\"\"\n\n def __init__(self, coresys: CoreSys):\n \"\"\"Initialize the test class.\"\"\"\n self.coresys = ...
[ "0.6147261", "0.60309714", "0.6018473", "0.59771776", "0.59549063", "0.5948192", "0.5915713", "0.58854884", "0.5860164", "0.5856046", "0.5856046", "0.5810252", "0.57848454", "0.5737032", "0.5730728", "0.56780916", "0.5657357", "0.5654869", "0.56539977", "0.56539977", "0.56349...
0.7635067
0
Creates CIRD range notation (network) based on the currently configures network interfaces/adapters If scanning range was set at run time, it will just use that one
def __get_scanning_range(self): if self.__network is not None: return [self.__network] networks = [] interfaces = netifaces.interfaces() for data in interfaces: ips = netifaces.ifaddresses(data) for key, interface_data in ips.items(): f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dhcp_range(options, index):\n second_octet = 160 + index\n return \"192.%s.1.2-192.%s.255.254\" % (second_octet, second_octet)", "def change_default_range(networks, number_excluded_ips,\n cut_from_start=True):\n for default_network in filter(\n lamb...
[ "0.6023686", "0.581812", "0.58151424", "0.5770609", "0.5480118", "0.5452671", "0.5420384", "0.54121625", "0.53247935", "0.5291674", "0.52649754", "0.52291876", "0.52005047", "0.5171426", "0.51680905", "0.5166946", "0.5145584", "0.514271", "0.51361144", "0.51302284", "0.512298...
0.626305
0
Scans a given IP for specific open ports
def __scan_for_open_ports(self, ip, ports_to_scan): ip = str(ip) def run_scan(_port): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(self.__timeout) result = sock.connect_ex((ip, _port)) if result...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan_ports(ip: Union[str, IPvAnyAddress]) -> ScanResults:\n if ip == 'localhost':\n ip = '127.0.0.1'\n ip = str(ip)\n\n nmap = nmap3.NmapScanTechniques()\n scan_result = nmap.nmap_tcp_scan(ip, args='-p0-')\n ports = scan_result[ip]['ports']\n\n # TODO: TEMP: Remove this line, debug onl...
[ "0.7841557", "0.7183356", "0.7178773", "0.6932479", "0.6745885", "0.665516", "0.6618246", "0.6496563", "0.6426189", "0.64072084", "0.63629407", "0.6334954", "0.6320099", "0.62818193", "0.6240517", "0.62234575", "0.6187895", "0.61846787", "0.61596686", "0.61544794", "0.6149629...
0.78269833
1
Returns a map of what ports we can potentially hack services on and what exploits can do it
def get_vulnerable_ports(self): self.__get_vulnerable_ports(modules.__path__[0]) return self.__vulnerable_ports
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_ports():\n ports = [config('admin-port'), config('service-port')]\n return list(set(ports))", "def _get_exposed_ports(debug_port):\n if not debug_port:\n return None\n\n return {\n # container port : host port\n debug_port: debug_port\n }"...
[ "0.6631425", "0.658254", "0.6252307", "0.62312484", "0.619172", "0.6132367", "0.6076404", "0.60520476", "0.6033354", "0.602421", "0.60065967", "0.5940211", "0.5909571", "0.588566", "0.58268833", "0.5826848", "0.5793208", "0.57583857", "0.5735731", "0.5727579", "0.56883043", ...
0.6643077
0
play gradients norm_grad = np.linalg.norm(gradient) tone = self.f + (norm_grad 500.0) samples = self.generate_tone(self.fs, tone, self.duration).astype(np.float32)
def __call__(self, gradient): audio_out = self.modem.convert_data_to_audio(gradient.flatten()) decoded_gradients = self.modem.convert_audio_to_floats(audio_out) # if you want to regret being alive, # self.stream.write(audio_out.tobytes()) return decoded_gradients.reshape(gradie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateSound(amps_samples, channel_fs, sampleRate):\r\n\r\n samples_to_gen = len(amps_samples[0]) \r\n nb_channels = len(amps_samples)\r\n duration = samples_to_gen / sampleRate # in s\r\n\r\n \r\n t = np.linspace(0.0, duration, samples_to_gen) # Produces length of samples\r\n\r\n sines = ...
[ "0.57237077", "0.5707015", "0.5682976", "0.56029904", "0.55295414", "0.5526577", "0.55244416", "0.5501788", "0.5442099", "0.5416417", "0.5373929", "0.5359383", "0.5344165", "0.5339903", "0.53293294", "0.53061014", "0.5304661", "0.5303725", "0.53028196", "0.5297751", "0.528846...
0.66777045
0
Checks if there are 3 digits the same. returns the repeating digit and its indices.
def check_if_has_3_repeated_digits(prime: str) -> (str, list): num_dict = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0} for digit in prime: num_dict[int(digit)] += 1 for k, v in num_dict.items(): if v > 2: repeating_digit = k indices = [i for i, x in e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_digits(n):\n \"*** YOUR CODE HERE ***\"\n count = 0\n for k in range(0, 10):\n if has_digit(n, k):\n count = count + 1\n return count", "def unique_digits(n):\n #return len(set(str(n)))\n f = sorted(list(str(n)))\n return len([x for i,x in enumerate(f) if x not i...
[ "0.62621343", "0.62330055", "0.6103015", "0.6061804", "0.5992376", "0.5973955", "0.59315914", "0.59144604", "0.5909071", "0.58491397", "0.57401156", "0.5738626", "0.5728421", "0.5718985", "0.5690673", "0.5680208", "0.56766343", "0.5627409", "0.5604609", "0.56018883", "0.56004...
0.7790202
0
Adds an extra axis to a data slab.
def addExtraAxis(slab,newaxis=None,axis=0,verbose=False): import cdms2 as cdms import MV2 as MV if newaxis is None: newaxis=cdms.createAxis([1,]) newaxis.units='' # add new axis to axis list of input <slab> axislist=slab.getAxisList() axislist.insert(axis,newaxis) #------...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_extra_dim(self, params: ExtraBytesParams) -> None:\n self.add_extra_dims([params])", "def _appendAxisDefinition(self, axis):\n length = len(axis)\n\n self.na_dict[\"NX\"].append(length)\n self.na_dict[\"XNAME\"].append(xarray_utils.getBestName(axis))\n\n # If only one i...
[ "0.6279864", "0.5876645", "0.57838917", "0.56708485", "0.5641856", "0.55798954", "0.55050075", "0.54636085", "0.5369209", "0.53418547", "0.5340863", "0.5319793", "0.5302775", "0.52753866", "0.5257759", "0.5241214", "0.5231386", "0.52094215", "0.51454324", "0.5124852", "0.5124...
0.79540575
0
Assess if a Mapbox tileset_id is valid
def validate_tileset_id(tileset_id): pattern = r"^[a-z0-9-_]{1,32}\.[a-z0-9-_]{1,32}$" return re.match(pattern, tileset_id, flags=re.IGNORECASE)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tile_is_set(index, level_map):\n return level_map[index] != -1", "def tile_exists_utm(boundsSrc, boundsTile):\n\n\n boundsSrcBox = box(*boundsSrc)\n boundsTileBox = box(*boundsTile)\n\n return boundsSrcBox.intersects(boundsTileBox)", "def test_room_has_tiles(self):\n self.assertEqual(sel...
[ "0.6637304", "0.62335414", "0.6161379", "0.6090846", "0.6027421", "0.5894052", "0.58873093", "0.5880936", "0.5848466", "0.5831871", "0.58296573", "0.58248645", "0.58103555", "0.5810162", "0.57029486", "0.56911117", "0.566734", "0.5657201", "0.5626586", "0.56132966", "0.560689...
0.72017473
0
Assess if Docker should be used based on the value of args.
def should_use_docker(dockerize_pip: DockerizePipArgTypeDef = None) -> bool: if isinstance(dockerize_pip, bool): return dockerize_pip if isinstance(dockerize_pip, str): if dockerize_pip == "non-linux" and not sys.platform.startswith("linux"): return True try: ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_docker(self) -> bool:\n from hubble.executor.helper import is_valid_docker_uri\n\n uses = getattr(self.args, 'uses', '')\n return is_valid_docker_uri(uses)", "def docker_allow_fallback():\n return False", "def req_build(container):\n try:\n return 'dock...
[ "0.75592434", "0.6791129", "0.641314", "0.63690114", "0.6301101", "0.61071885", "0.60725427", "0.60477525", "0.58751506", "0.5770867", "0.5769221", "0.5697177", "0.5614681", "0.55873924", "0.55785286", "0.55209535", "0.5489136", "0.545635", "0.53722596", "0.5362115", "0.53584...
0.6928599
1
Return a hash of all of the given files at the given root.
def _calculate_hash(files: Iterable[str], root: str) -> str: file_hash = hashlib.md5() for file_name in sorted(files): file_path = os.path.join(root, file_name) file_hash.update((file_name + "\0").encode()) with open(file_path, "rb") as file_: # pylint: disable=cell-var-from-...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_files(verbose, debug):\n\n found = []\n h = hashlib.new('md5')\n for pattern in FILES_PATTERNS:\n for f in glob.iglob(pattern, flags=FLAGS):\n name = f.replace('\\\\', '/')\n found.append(name)\n if verbose:\n print('FILES:')\n for f in sorted(found):\n ...
[ "0.7420318", "0.73666245", "0.7317427", "0.72091985", "0.71523035", "0.7038823", "0.6978035", "0.69414365", "0.6797267", "0.6717443", "0.6710734", "0.65908384", "0.65727043", "0.65698576", "0.65642035", "0.65586007", "0.6522981", "0.6504305", "0.6416056", "0.63652515", "0.632...
0.8427298
0