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
Constructs a new ForwardModelConfig object. melt_time_assumption [string] Standard, Justin, Nicolas, Brodan surface_absorption_method [string] Standard, SurfaceRay %%% TODO ADD SURFACE ABSOPRTION OPTIONS
def __init__(self, melt_time_assumption='standard', surface_absorption_method='standard', show_code_settings=False, show_material_properties=False, show_general_figures=False, show_debugging_figures=False, show_console_output=False): self.melt_time_assumption = melt_time_assumpt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_from_pytorch_model(\n model,\n granularity='model',\n backend=None,\n default_precision='ap_fixed<16,6>',\n default_reuse_factor=1,\n inputs_channel_last=False,\n transpose_outputs=True,\n):\n\n config = {}\n\n model_config = {}\n model_config['Precision'] = default_precisi...
[ "0.55748653", "0.55468255", "0.5516905", "0.5361332", "0.53580886", "0.5343956", "0.53185076", "0.5280618", "0.5267336", "0.5253649", "0.5222042", "0.5199192", "0.5198464", "0.5180985", "0.51743776", "0.5171447", "0.5146382", "0.51347345", "0.51333064", "0.5097539", "0.509253...
0.5753696
0
will search through the memcache plugins looking for the value
def get_underhanded(self,key): for plugin in self.server.plugins: if isinstance(plugin,MemcachedPlugin) and not plugin is self: v = plugin._get_data(key) if v: return v return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _cache_get(self, metric_name):\n pass", "def __getitem__(self, key):\n if key in self.plugin:\n return self.plugin[key]\n else:\n log.warning(\"\"\"Plugin \"%s\" is not loaded.\"\"\" % key)\n return False", "def _cache_has(self, metric_name):\n p...
[ "0.5861849", "0.5824819", "0.582168", "0.56680787", "0.5588516", "0.55791724", "0.5575592", "0.5492284", "0.5480194", "0.5414675", "0.53459626", "0.5293929", "0.5278885", "0.5275149", "0.52654344", "0.5207049", "0.5197373", "0.5163468", "0.51460314", "0.51380885", "0.51380885...
0.6807539
0
Will set the value in all the memcache plugins
def set_underhanded(self,key,v): for plugin in self.server.plugins: if isinstance(plugin,MemcachedPlugin) and not plugin is self: plugin._set_data(key,v) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_cache(self, val):\n pass", "def set(key, value):\n instance_cache.set(key, value, expiry=CacheLayers.INSTANCE_SECONDS)\n memcache.set(key, CacheLayers.compress(value))\n\n logging.info(\"Set BingoCache in instance cache and memcache\")", "def _cache_set(self, metric_name, me...
[ "0.72271734", "0.63500375", "0.6253346", "0.6222583", "0.61493415", "0.6139049", "0.6078674", "0.6062992", "0.6054272", "0.6045957", "0.6044916", "0.59507203", "0.5915748", "0.5901811", "0.583196", "0.58220387", "0.5818306", "0.58072776", "0.5781747", "0.5775088", "0.57301795...
0.7425552
0
incr hte value in all the memcache plugins
def incr_underhanded(self, key, value): for plugin in self.server.plugins: if isinstance(plugin,MemcachedPlugin) and not plugin is self: v = plugin._incr_data(key,value) if v is False: return False return v
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _increment_counter(metric: str):\n if metric not in db:\n db[metric] = 0\n db[metric] += 1", "def increment_metric_counter(metric_name, redis_db):\n if TEST_MODE:\n print 'Simulate redis incremet, key is %s' % metric_name\n return\n if redis_db:\n try:\n red...
[ "0.6108457", "0.60304403", "0.5916617", "0.58441824", "0.57996726", "0.5761565", "0.5700244", "0.569412", "0.56885254", "0.56528026", "0.5644458", "0.5640885", "0.5638863", "0.5619427", "0.55992365", "0.5591836", "0.5558801", "0.5550321", "0.5547342", "0.55319196", "0.5492971...
0.7399691
0
A loaded model is accessible through the models attribute self.models['WelcomeModel'].get_users() self.models['WelcomeModel'].add_message() 'messages = self.models['WelcomeModel'].grab_messages()' 'user = self.models['WelcomeModel'].get_user()' 'to pass information on to a view it's the same as it was with Flask' 'retu...
def index(self): print "Starting Wall" print "Retrieving name" print session['user_id'] full_name = self.models['Wall_m'].full_name(session['user_id']) # Grab user'sname print full_name full_name = full_name[0]['full_name'] print full_name messages = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def welcome():\n result = WelcomeModel()\n return WelcomeSchema().dump(result), 200", "def load_model(self):\n pass", "def user():\n user = UserModel()\n user.email = \"lemmy@imotorhead.com\"\n user.first_name = \"Ian\"\n user.last_name = \"Kilmister\"\n user.phone = \"800.333.7680\...
[ "0.5819913", "0.5800606", "0.57768744", "0.5657488", "0.5607867", "0.5570077", "0.5519755", "0.54735416", "0.5472467", "0.53654766", "0.5363623", "0.5337791", "0.5308452", "0.5305975", "0.5303038", "0.5247501", "0.5243935", "0.52371436", "0.52057004", "0.51946175", "0.5193104...
0.64910567
0
Displays profile image in list view
def display_image(obj): # Hard code 30x30 due to Django admin template list size. return format_html( '<img src=%s alt="Profile picture" width="30" height="30" />' % (obj.image.url if obj.image else static("images/users/default-profile.jpg")) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_thumb_tag(self):\n u = self.user\n uf = self.app.url_for\n image = None\n if u.image is not None and u.image!=\"\":\n try:\n image = uf(\"asset\", asset_id = self.app.module_map.uploader.get(u.image).variants['userlist']._id)\n except Asse...
[ "0.7129653", "0.6621689", "0.65483373", "0.64459544", "0.64231795", "0.6406237", "0.61998725", "0.6183474", "0.6164791", "0.6151082", "0.61323947", "0.61049163", "0.6097735", "0.60965633", "0.60905015", "0.608497", "0.60434407", "0.6034201", "0.5944758", "0.59322846", "0.5925...
0.7441247
0
Displays group image in list view
def display_image(obj): # Hard code 30x30 due to Django admin template list size. return format_html( '<img src=%s alt="Group image" width="30" height="30" />' % (obj.image.url if obj.image else static("images/groups/default-group_image.jpg")) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateImageGroups(self):\n self.img_grps = self.splitImages()\n grps = self.img_grps\n self.detail.clear()\n detail = \"Available Groups : \\n\"\n if len(grps) >= 1:\n for i in range(len(grps)):\n detail += \"Group \"+ str(i+1)+ \" : \" + str(grps[i]...
[ "0.67873013", "0.61053944", "0.5827434", "0.58180577", "0.58005536", "0.5799835", "0.5786416", "0.57812566", "0.5739298", "0.56683576", "0.56477755", "0.5643974", "0.5611059", "0.5608953", "0.5590662", "0.55623174", "0.5552397", "0.55360246", "0.5502761", "0.5491897", "0.5491...
0.74690145
0
Acknowledge an event. This mostly prevents it from appearing as a notification in the control portal.
def ack_event(self, event_id): return self.client.call('Notification_Occurrence_Event', 'acknowledgeNotification', id=event_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def acknowledge(self, *event_messages, bus_client: \"BusClient\"):\n pass", "async def ack_event(self, envelope: Envelope, multiple: bool = False) -> None:\n await self.channel.basic_client_ack(\n delivery_tag=envelope.delivery_tag, multiple=multiple\n )", "def consume_ack...
[ "0.71408135", "0.6650102", "0.6531436", "0.6373774", "0.6107316", "0.59808743", "0.5902426", "0.5897589", "0.587971", "0.5873229", "0.5840613", "0.5838206", "0.58347017", "0.5802624", "0.5793075", "0.57760483", "0.57705283", "0.57547593", "0.5724207", "0.5721719", "0.5696814"...
0.75321144
0
Gets all topLevelBillingItems from a specific invoice
def get_billing_items(self, identifier): mask = """mask[ id, description, hostName, domainName, oneTimeAfterTaxAmount, recurringAfterTaxAmount, createDate, categoryCode, category[name], location[name], children[id, category[name], description, oneTime...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_invoices(self, limit=50, closed=False, get_all=False):\n mask = \"mask[invoiceTotalAmount, itemCount]\"\n _filter = {\n 'invoices': {\n 'createDate': {\n 'operation': 'orderBy',\n 'options': [{\n 'name': 's...
[ "0.6152694", "0.5945346", "0.5934046", "0.5782881", "0.5729265", "0.56248087", "0.55893815", "0.5585731", "0.55699754", "0.55301505", "0.54623544", "0.5224209", "0.51400495", "0.5106192", "0.50598925", "0.5006302", "0.4988618", "0.49616304", "0.49364957", "0.49304697", "0.490...
0.76552004
0
Gets all the topLevelBillingItems currently active on the account
def get_account_billing_items(self, create=None, category=None, mask=None): if mask is None: mask = """mask[ orderItem[id,order[id,userRecord[id,email,displayName,userStatus]]], nextInvoiceTotalRecurringAmount, location, hourlyFlag ]""" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_billing_items(self, identifier):\n\n mask = \"\"\"mask[\n id, description, hostName, domainName, oneTimeAfterTaxAmount, recurringAfterTaxAmount, createDate,\n categoryCode,\n category[name],\n location[name],\n children[id, category[name], descr...
[ "0.6923196", "0.59697765", "0.575805", "0.55222267", "0.54914856", "0.54847604", "0.5479203", "0.5464327", "0.5416195", "0.5392103", "0.5338329", "0.5332863", "0.5317097", "0.5314769", "0.530184", "0.52650356", "0.52415794", "0.5230439", "0.52152693", "0.52067727", "0.5179667...
0.6207125
1
Gets details about a billing item of a billing invoice item
def get_billing_item_from_invoice(self, identifier, mask=None): if mask is None: mask = self._DEFAULT_BILLING_ITEM_MASK return self.client.call('Billing_Invoice_Item', 'getBillingItem', id=identifier, mask=mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_item_detail(self, identifier):\n\n try:\n return self.get_billing_item(identifier)\n except SoftLayerAPIError as exception:\n if exception.faultCode == 404:\n return self.get_billing_item_from_invoice(identifier)\n raise", "def billing_info(se...
[ "0.747619", "0.6612933", "0.65272003", "0.6444234", "0.6372723", "0.63039535", "0.62579304", "0.61760277", "0.6146966", "0.61223006", "0.6106007", "0.60972404", "0.6024911", "0.5936995", "0.591735", "0.58626056", "0.584625", "0.5836164", "0.57351714", "0.5716773", "0.564585",...
0.6754242
1
Gets details about a billing item
def get_item_detail(self, identifier): try: return self.get_billing_item(identifier) except SoftLayerAPIError as exception: if exception.faultCode == 404: return self.get_billing_item_from_invoice(identifier) raise
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing_info(self):\r\n return BillingInfo(self)", "def billing_info(self):\n return self._billing_info", "def get_item_detail(item_id):\n pass", "def test_get_item_details(self, mock_requests_get):\n details = resources.get_item_details(21787)\n\n item = details.item\n ...
[ "0.71415", "0.7107744", "0.6803434", "0.6749558", "0.659843", "0.659465", "0.643434", "0.63999027", "0.6279766", "0.6278677", "0.62494195", "0.6229148", "0.607944", "0.6023624", "0.59558743", "0.58664674", "0.5841172", "0.5824495", "0.5813543", "0.5807874", "0.5747145", "0....
0.73750615
0
Cancels a specific billing item with a reason
def cancel_item(self, identifier, reason="No longer needed", note=None): if note is None: user = self.client.call('Account', 'getCurrentUser', mask="mask[id,displayName,email,username]") note = f"Cancelled by {user.get('username')} with the SLCLI" return self.client.call('Billi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel_iscsi(self, volume_id, reason='unNeeded', immediate=False):\r\n iscsi = self.get_iscsi(\r\n volume_id,\r\n mask='mask[id,capacityGb,username,password,billingItem[id]]')\r\n billingitemid = iscsi['billingItem']['id']\r\n self.client['Billing_Item'].cancelItem(\r...
[ "0.64898145", "0.6267665", "0.62393314", "0.613966", "0.60649246", "0.60628843", "0.605218", "0.6040305", "0.60325646", "0.60303295", "0.6017538", "0.5957014", "0.59519744", "0.5944692", "0.5911409", "0.5907279", "0.589325", "0.58856344", "0.5848772", "0.5805888", "0.5784104"...
0.7135717
0
Gets all Network Message delivery accounts.
def get_network_message_delivery_accounts(self): _mask = """vendor,type""" return self.client['SoftLayer_Account'].getNetworkMessageDeliveryAccounts(mask=_mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_accounts(self, **kwargs):\r\n if 'mask' not in kwargs:\r\n items = [\r\n 'id',\r\n 'name',\r\n 'status',\r\n 'nodes',\r\n ]\r\n kwargs['mask'] = \"mask[%s]\" % ','.join(items)\r\n\r\n return self.cli...
[ "0.6393254", "0.6058889", "0.5955604", "0.59420675", "0.5911932", "0.5811731", "0.5708601", "0.5696645", "0.5667549", "0.56392014", "0.5572698", "0.55056137", "0.5470599", "0.5457768", "0.5435201", "0.5434758", "0.54334044", "0.54284346", "0.54216", "0.53893256", "0.53873765"...
0.7625109
0
Gets all active virtual licenses account.
def get_active_virtual_licenses(self): _mask = """billingItem[categoryCode,createDate,description], key,id,ipAddress, softwareDescription[longDescription,name,manufacturer], subnet""" return self.client['SoftLayer_Account'].getActiveVirtualLi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_active_account_licenses(self):\n\n _mask = \"\"\"billingItem,softwareDescription\"\"\"\n\n return self.client['SoftLayer_Account'].getActiveAccountLicenses(mask=_mask)", "def getLicenseList(self):\n\n res = self.getRequest('licenses')\n licenses = list()\n if res:\n ...
[ "0.70768636", "0.7066329", "0.67577124", "0.6587934", "0.6521783", "0.6378101", "0.62645566", "0.6172615", "0.6158004", "0.61289406", "0.61268145", "0.60705614", "0.59099764", "0.5833182", "0.575935", "0.57415587", "0.5683667", "0.56785446", "0.5653936", "0.55529094", "0.5528...
0.7763799
0
Gets all active account licenses.
def get_active_account_licenses(self): _mask = """billingItem,softwareDescription""" return self.client['SoftLayer_Account'].getActiveAccountLicenses(mask=_mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getLicenseList(self):\n\n res = self.getRequest('licenses')\n licenses = list()\n if res:\n for item in iter(res['items']):\n lic = vsdModels.License(**item)\n licenses.append(lic)\n\n return licenses", "def licenses(self) -> Sequence[str]:...
[ "0.7861078", "0.71985483", "0.69386154", "0.6938354", "0.683766", "0.68374085", "0.67376196", "0.6720445", "0.6710225", "0.66815954", "0.6480126", "0.6431303", "0.6139715", "0.6136153", "0.6113095", "0.5931691", "0.5891424", "0.58749723", "0.57937604", "0.5751224", "0.5697592...
0.77403265
1
Gets all the bandwidth pools on an account
def get_bandwidth_pools(self, mask=None): if mask is None: mask = """mask[totalBandwidthAllocated,locationGroup, id, name, projectedPublicBandwidthUsage, billingCyclePublicBandwidthUsage[amountOut,amountIn], billingItem[id,nextInvoiceTotalRecurringAmount]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPools(self):\n data = self.connect('get','pools',None)\n return data", "async def get_pools(self) -> List[CachingPool]:\n return await self._pool_fetcher.get_pools()", "def _get_pools(self, settings):\n available_pools = []\n pool_names = []\n connections_settin...
[ "0.67564046", "0.62494147", "0.61360097", "0.60639644", "0.6058265", "0.59158266", "0.5863608", "0.5797169", "0.57879007", "0.57614666", "0.5639632", "0.5638623", "0.560408", "0.5593524", "0.55859154", "0.55794644", "0.55160934", "0.55071217", "0.5502424", "0.54691947", "0.54...
0.7169589
0
Gets a count of all servers in a bandwidth pool Getting the server counts individually is significantly faster than pulling them in with the get_bandwidth_pools api call.
def get_bandwidth_pool_counts(self, identifier): mask = "mask[id, bareMetalInstanceCount, hardwareCount, virtualGuestCount]" counts = self.client.call('SoftLayer_Network_Bandwidth_Version1_Allotment', 'getObject', id=identifier, mask=mask) total = counts.get('ba...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size(self):\r\n return sum(pool.size() for pool in self.host_to_pool.values())", "def GetCount(self):\n return self._server.get_count()", "def pool_size(self):\n if self.options.pool_size == 0:\n return 2 * len(self._server_list)\n return self.options.pool_size", "d...
[ "0.6395078", "0.639499", "0.62641287", "0.5990051", "0.5832889", "0.57936007", "0.57703495", "0.57055616", "0.5694063", "0.56690514", "0.5653518", "0.55464286", "0.55361897", "0.55235845", "0.5510581", "0.55027544", "0.54552627", "0.5423698", "0.54092693", "0.54071426", "0.54...
0.70085955
0
Gets a provisioning hooks.
def get_provisioning_scripts(self): return self.client.call('Account', 'getPostProvisioningHooks')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getHooks(self):\n return self.__hooks", "def get_hooks(name):\n register_all_hooks()\n return _hooks.get(name, [])", "def hooks(self):\n return tuple(self.__hooks.keys())", "def get_hooks(self, hook: str) -> List[Callable]:\n return [getattr(self, name) for name in self.__plugi...
[ "0.7128997", "0.6813157", "0.68028045", "0.6693627", "0.6646672", "0.6605815", "0.6558671", "0.64401966", "0.62955916", "0.62785494", "0.6213821", "0.6204111", "0.61900604", "0.61900604", "0.61534446", "0.6140655", "0.6011057", "0.600348", "0.59504527", "0.5949015", "0.582567...
0.7333691
0
Shortcut to get cache_manager addon preferences
def addon_prefs_get(context: bpy.types.Context) -> bpy.types.AddonPreferences: return context.preferences.addons["anim_setup"].preferences
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPreferences():\n prefs = bpy.context.preferences.addons[NAME].preferences\n return prefs", "def preference():\n preference = bpy.context.preferences.addons[name].preferences\n return preference", "def cm(cache=[]):\n if not cache:\n cache.append(ConfigurationManager())\n return ...
[ "0.6643568", "0.6164972", "0.6081864", "0.58676964", "0.5818826", "0.57918006", "0.5773904", "0.57635087", "0.5757454", "0.57280153", "0.57192975", "0.57166415", "0.5701409", "0.5689562", "0.56641775", "0.56282645", "0.56282645", "0.5623923", "0.55973434", "0.55694", "0.55190...
0.66311264
1
Return the value of the given stateaction pair
def get_state_action_value(self, state, action): raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_value(self, state, action):\n return self.value_function[to_table_index(state, action)]", "def getQValue(self, state, action):\n \"*** YOUR CODE HERE ***\"\n\n return self.values[(str(state), action)]", "def getValue(self, state):\n return self.values[state]", "def getQValu...
[ "0.80276626", "0.7872588", "0.76328826", "0.75749767", "0.75744814", "0.7549472", "0.7418124", "0.73807997", "0.73807997", "0.73807997", "0.73807997", "0.73456675", "0.7332363", "0.73264176", "0.73264176", "0.73264176", "0.73264176", "0.73264176", "0.73264176", "0.73264176", ...
0.795146
1
Return an np.array with the values of each action at the given state
def get_all_state_action_values(self, state): return torch.tensor([[self.get_state_action_value(state, action) for action in range(self.action_space.n)]]).float()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_state_action_values(self, state, state_values):\n action_values = []\n\n for action in self.grid.actions:\n probs = self.grid.state_actions[state][action]\n state_action_values = self.get_state_values(state, state_values)\n action_values.append(sum([p * b for ...
[ "0.73736566", "0.7121883", "0.70356697", "0.69397134", "0.69185406", "0.68723077", "0.67115843", "0.66186494", "0.66168016", "0.6564694", "0.6518128", "0.6488189", "0.64872617", "0.6472288", "0.6432845", "0.6415775", "0.64135164", "0.64100045", "0.6406626", "0.6401399", "0.63...
0.76700497
0
create one order line item
def create_order_line_item(cls, order, invoice_line_item): order_line_item = cls( order_line_item_id=str(uuid.uuid4().int), order=order, invoice_line_item=invoice_line_item, product=invoice_line_item.product, quantity=invoice_line_item.quantity ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_order():", "def create(self, values):\n res = super(PurchaseOrderLine, self).create(values)\n states = ['purchase', 'done']\n if res.order_id.state in states:\n raise UserError(_('You can not create an additional purchase order line in a confirmed order '))\n ret...
[ "0.68382525", "0.6682892", "0.6548729", "0.65128845", "0.64668953", "0.6373227", "0.63635635", "0.6360986", "0.6316091", "0.6273517", "0.62665236", "0.6239777", "0.62015444", "0.61846673", "0.6161077", "0.6147953", "0.6127971", "0.6125744", "0.61254907", "0.60938317", "0.6074...
0.7364095
0
Validates the presence of the CLEANUP_LABEL and its values in a list of labels, raises ValueError otherwise
def validate_cleanup_in(labels): if CLEANUP_LABEL not in labels: raise ValueError("Cleanup label (%s) missing in pod labels." % CLEANUP_LABEL) if labels[CLEANUP_LABEL] not in CLEANUP_VALUES: raise ValueError( "Cleanup value %s not permitted. Use one of: %s" % (labels[CLEA...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_sanity(self):\n # ensure numeric labels\n try:\n list(map(int, flatten(self.labels[:1])))\n except ValueError as ve:\n error(\"Non-numeric label encountered: {}\".format(ve))\n except TypeError as ve:\n warning(\"Non-collection labelitem encoun...
[ "0.6698342", "0.66343915", "0.63469636", "0.6159356", "0.6035514", "0.59548664", "0.5923593", "0.5908667", "0.5836684", "0.58320177", "0.58224463", "0.5822256", "0.5822256", "0.58083415", "0.5801615", "0.57459205", "0.5715245", "0.5709651", "0.56885856", "0.56879073", "0.5670...
0.79507273
0
Returns a random port, exclusions possible via parameter set
def rand_port(except_ports=None): if except_ports is None: except_ports = [] max_port_int = 65535 if len(set(except_ports)) > max_port_int >= max(except_ports): raise ValueError( "Cannot generate randomPort when all possible port numbers are exempt" ) # choose random ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createPort():\n\n starting_interval = 0\n ending_interval = 65535\n port = randint(starting_interval, ending_interval)\n return port", "def generate_new_port(n):\n ports = sample(portsPool,n)\n for p in ports:\n ind = portsPool.index(p)\n del portsPool[ind]\n return ports",...
[ "0.67183334", "0.662854", "0.659142", "0.6523813", "0.64168155", "0.64105636", "0.639417", "0.63269585", "0.6282659", "0.6281016", "0.624315", "0.61483", "0.6047048", "0.5981397", "0.5919755", "0.59116197", "0.590874", "0.58993083", "0.5888901", "0.58814454", "0.58575827", ...
0.77935
0
Create mock for LIVISI login.
def mocked_livisi_login(): return patch( "homeassistant.components.livisi.config_flow.AioLivisi.async_set_token" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_start_new_verification(self):\r\n user = UserFactory.create(username=\"rusty\", password=\"test\")\r\n self.client.login(username=\"rusty\", password=\"test\")", "def test_get_login(self):\n login = Login(self.client, 123)\n\n self.assertEqual(login.id, 123)\n self.ass...
[ "0.68408084", "0.68017936", "0.67128634", "0.6615558", "0.6606319", "0.6568284", "0.65361714", "0.6485376", "0.6467578", "0.64658", "0.6450552", "0.6434976", "0.6406752", "0.6350427", "0.6317787", "0.63006455", "0.62698996", "0.62626636", "0.6260469", "0.6254094", "0.62511486...
0.7251048
0
Create mock data for LIVISI controller.
def mocked_livisi_controller(): return patch( "homeassistant.components.livisi.config_flow.AioLivisi.async_get_controller", return_value=DEVICE_CONFIG, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_initialization(self, create_controller: Controller) -> None:\n pass", "def setUp(self):\n self.data = DatabaseIntermediary()", "def setUp(self):\n self.client = APIClient()\n\n self.speciality = models.Speciality.objects.create(\n name='Speciality'\n )\n\n...
[ "0.60595906", "0.5908655", "0.588172", "0.5871097", "0.5850077", "0.5814449", "0.57985973", "0.57669646", "0.5741265", "0.5737485", "0.5698321", "0.56932724", "0.56909657", "0.5662723", "0.56569046", "0.56569046", "0.56569046", "0.56569046", "0.56569046", "0.56569046", "0.565...
0.6246136
0
Create mock for LIVISI setup entry.
def mocked_livisi_setup_entry(): return patch( "homeassistant.components.livisi.async_setup_entry", return_value=True, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp...
[ "0.64558464", "0.64558464", "0.64558464", "0.64558464", "0.64558464", "0.64558464", "0.6400841", "0.6392369", "0.6374439", "0.63366705", "0.63170975", "0.6301264", "0.62422764", "0.62139213", "0.6213025", "0.6212005", "0.6205747", "0.6205747", "0.619228", "0.61879796", "0.616...
0.7041195
0
Multiplies the term frequency (tf) with the inverse document frequency (idf) to return the tfidf
def get_tf_idf(term, document, documents): tf_idf = get_tf(term, document) * get_idf(term, documents) return round(tf_idf, 5)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _tfidf(term_frequency: int, document_frequency: int, document_count: int) -> float:\n if term_frequency == 0:\n return 0\n else:\n tf = 1 + np.log(term_frequency)\n idf = np.log(document_count / document_frequency)\n return tf * idf", "def calc_tf_idf...
[ "0.84478635", "0.81231076", "0.7729778", "0.7700121", "0.7696099", "0.7685472", "0.7620046", "0.74928373", "0.7489668", "0.7485096", "0.7441081", "0.73898596", "0.7385134", "0.7357741", "0.73311794", "0.7319226", "0.7296906", "0.72713435", "0.7238135", "0.72304106", "0.721231...
0.8173197
1
Calculates the score of a term in a document based on its position. Terms that appear earlier in the document are score higher.
def get_positional_score(term, document): score = 0 number_of_words_in_doc = len(document.split()) for position, word in enumerate(document.split()): if word.lower() == term.lower(): score += (number_of_words_in_doc - position) / number_of_words_in_doc return round(score, 5)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answer(document, search_terms):\n idx = {k: [] for k in search_terms}\n doc = document.split()\n [idx[term].append(i) for i, term in enumerate(doc, start=1) if term in search_terms]\n min_score = sys.maxint\n winning_slice = None\n for term in idx.keys(): # ignore duplicate terms\n fo...
[ "0.70714647", "0.6810209", "0.67525667", "0.67525667", "0.66404283", "0.65762305", "0.653853", "0.6511128", "0.6495046", "0.64873844", "0.63907325", "0.6371521", "0.6264078", "0.6224283", "0.6223177", "0.61510754", "0.6149143", "0.6130282", "0.6129364", "0.61181056", "0.61028...
0.7993231
0
Given the API ID for a GEE layer on Resource Watch, this function will clear the layer cache. If the cache is not cleared, when you view the dataset on Resource Watch, old and new tiles will be mixed together.
def flushTileCache(layer_id): # generate the API url for this layer's cache apiUrl = 'http://api.resourcewatch.org/v1/layer/{}/expire-cache'.format(layer_id) # create headers to send with the request to clear the cache headers = { 'Content-Type': 'application/json', 'Authorization': os.getenv('a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flushTileCache(layer_id):\n # generate the API url for this layer's cache\n apiUrl = 'http://api.resourcewatch.org/v1/layer/{}/expire-cache'.format(layer_id)\n # create headers to send with the request to clear the cache\n headers = {\n 'Content-Type': 'application/json',\n 'Authorization': o...
[ "0.7679626", "0.62814665", "0.5842842", "0.5833658", "0.5833109", "0.57534224", "0.573081", "0.570053", "0.55585086", "0.55561376", "0.55560607", "0.5550327", "0.5518862", "0.55163455", "0.5510354", "0.5497515", "0.54739076", "0.54729617", "0.5465945", "0.54627556", "0.542982...
0.7669758
1
All message activities towards the bot enter this function.
async def on_message_activity(self, turn_context: TurnContext): TurnContext.remove_recipient_mention(turn_context.activity) turn_context.activity.text = turn_context.activity.text.strip() if not self.unlocked: await turn_context.send_activity("De bot is gedeactiveerd en kan dus niet...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def messages(self, ctx):\n\n\t\tawait self.message_leaderboard(ctx, \"messages\")", "async def on_message_activity(self, turn_context: TurnContext):\n reply = MessageFactory.list([])\n # Get the state properties from the turn context.\n welcome_user_state = await self.user_state_access...
[ "0.67243636", "0.648738", "0.61207706", "0.61096483", "0.605643", "0.5990261", "0.5930036", "0.5889592", "0.5889592", "0.5889592", "0.5886627", "0.58227986", "0.58148575", "0.58063346", "0.57552063", "0.569512", "0.5689415", "0.566552", "0.56436557", "0.56391877", "0.56043863...
0.7144678
0
FFT of v padded on the right with 2tau1 0s, used for multiplication below
def vfft(self): # we could cache this, but so fast it isn't really necessary # TODO: maybe it should be cached after all now that we don't need other stuff? return rfft(self.v, 4*self.tau-3)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ufft2(inarray):\n return ufftn(inarray, 2)", "def fft1(x):\n assert x.size(-1) == 2\n x = ifftshift(x, dim=(-2,))\n x = torch.fft(x, 1, normalized=True)\n x = fftshift(x, dim=(-2,))\n return x", "def convf(u, v, nf, dt):\n U = np.fft.fft(u, n=nf)\n V = np.fft.fft(v, n=nf)\n C = U...
[ "0.5909728", "0.59049565", "0.58655864", "0.5834553", "0.5826718", "0.5802623", "0.5723108", "0.5679379", "0.567855", "0.5667368", "0.56547946", "0.5498447", "0.54929113", "0.5492728", "0.5486339", "0.54821134", "0.5479368", "0.54417783", "0.543284", "0.54169565", "0.5405335"...
0.6579955
0
Given a nested dict of ATI Jacobians that maps unknowns > targets, e.g. an asymptotic H_U matrix, get the inverse H_U^(1) as a nested dict. This is implemented by inverting the FFTbased multiplication that was implemented above
def invert_jacdict(jacdict, unknowns, targets, tau, test_invertible=False): k = len(unknowns) assert k == len(targets) # stack the k^2 Jacobians relating unknowns to targets into an A matrix A = jac.pack_asymptotic_jacobians(jacdict, unknowns, targets, tau) if test_invertible: # use windi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invert(data_dict, keys = 'all'):\n if keys.lower() == 'all':\n to_fix_keys = set(data_dict.keys()) - set({'time'})\n \n else:\n to_fix_keys = np.array([keys]).flatten()\n \n out = data_dict.copy()\n tmp = dict()\n \n for key in to_fix_keys:\n tmp.update({key...
[ "0.58155334", "0.5399745", "0.5310238", "0.53086656", "0.5305253", "0.5250937", "0.5212625", "0.5209139", "0.51955724", "0.5156739", "0.5155153", "0.515414", "0.51440793", "0.51347655", "0.50888896", "0.50720143", "0.506503", "0.50603753", "0.50432646", "0.50033295", "0.50025...
0.6764515
0
Checks that the version of the Solr core ``core`` matches the one in the schema.
def solr_version_check(core): expected_version = SCHEMA[core].version solr_uri = config.CFG.get("solr", "uri") u = urllib2.urlopen("%s/%s/schema/version" % (solr_uri, core)) content = loads(u.read()) seen_version = content["version"] if not seen_version == expected_version: raise Version...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_solr_cores_version(cores):\n map(solr_version_check, cores)", "def test_compare_schemas_major(self):\n status = schema_utils.compare_schemas(\n self.base_schema,\n self.major_removed_value\n )\n\n assert status == schema_utils.Update.major", "def test_sch...
[ "0.6779413", "0.5996153", "0.5828003", "0.57171905", "0.57140726", "0.56064177", "0.55985236", "0.55739886", "0.5499899", "0.54828817", "0.5461677", "0.5393078", "0.53798366", "0.53707933", "0.5345438", "0.5344237", "0.5337947", "0.5317535", "0.5295003", "0.5281345", "0.52062...
0.8537369
0
Checks multiple Solr cores for version compatibility
def check_solr_cores_version(cores): map(solr_version_check, cores)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solr_version_check(core):\n expected_version = SCHEMA[core].version\n solr_uri = config.CFG.get(\"solr\", \"uri\")\n u = urllib2.urlopen(\"%s/%s/schema/version\" % (solr_uri, core))\n content = loads(u.read())\n seen_version = content[\"version\"]\n if not seen_version == expected_version:\n ...
[ "0.6550377", "0.5824256", "0.57431936", "0.5562315", "0.55221343", "0.5507001", "0.5468929", "0.5466075", "0.54544914", "0.5420395", "0.54134506", "0.5408198", "0.53689283", "0.5358959", "0.5356279", "0.5342606", "0.5332946", "0.5316136", "0.52860075", "0.5266541", "0.5238733...
0.8674924
0
Creates a connection to an AMQP server.
def create_amqp_connection(): # type: () -> amqp.Connection cget = partial(config.CFG.get, "rabbitmq") return amqp.Connection( host=cget("host"), userid=cget("user"), password=cget("password"), virtual_host=cget("vhost"), )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_connection(self):\n if self.conn:\n raise Exception(\"Connection already open\")\n cfg = self.config[self.MODULE_NAME]['amqp']['connection']\n log.debug(str(cfg))\n self.conn = pika.AsyncoreConnection(pika.ConnectionParameters(\n credentials = pika.PlainCredentials(cfg['login']...
[ "0.7788483", "0.77012485", "0.7328935", "0.69165313", "0.6882219", "0.66203946", "0.6586621", "0.6561489", "0.6474302", "0.64725894", "0.64424944", "0.6413152", "0.6287743", "0.61842525", "0.6181223", "0.6165761", "0.61318046", "0.61280894", "0.60530525", "0.6042496", "0.6028...
0.8125475
0
Used to start a new timer with given delay.
def start(self, delay=None): if self._timer: raise Exception('Timer already exists. Use restart instead.') if not delay: delay = self.delay self._timer = Timer(delay, self.callback) # Starting the call in daemon mode so that it exits when the parent # ex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restart(self, delay=None):\n if self._timer:\n self._timer.cancel()\n if not delay:\n delay = self.delay\n self._timer = Timer(delay, self.callback)\n self._timer.daemon = True\n self._timer.start()", "def schedule(self, sleep_time, delay):\n se...
[ "0.6963895", "0.68689024", "0.6696189", "0.6620824", "0.6589489", "0.65471387", "0.6501219", "0.6496462", "0.6325117", "0.6295213", "0.6292513", "0.6286179", "0.62726414", "0.6266713", "0.62522584", "0.6246776", "0.6226407", "0.6194945", "0.61825365", "0.60937047", "0.6007753...
0.7768124
0
Used to cancel an already running timer.
def cancel(self): if self._timer: self._timer.cancel() self._timer = None else: raise Exception('Cannot cancel timer. No timer started.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _async_cancel_timer(self) -> None:\n if self._timer:\n self._timer.cancel()\n self._timer = None", "def _cancel(self):\n self.waiter.set_result_if_pending(None)\n \n timer = self.timer\n if (timer is not None):\n self.timer = None\n ...
[ "0.8081997", "0.799912", "0.78773856", "0.78552437", "0.7820463", "0.7676346", "0.759786", "0.7569698", "0.7459538", "0.74300826", "0.7420995", "0.7330113", "0.7265205", "0.72101563", "0.7163342", "0.7074851", "0.70103073", "0.6979206", "0.6962197", "0.6945083", "0.6945083", ...
0.8618206
0
Used to restart the timer and schedule a call after ``delay`` seconds. It will cancel any existing scheduled calls. If there are no existing timers scheduled it just starts a new timer.
def restart(self, delay=None): if self._timer: self._timer.cancel() if not delay: delay = self.delay self._timer = Timer(delay, self.callback) self._timer.daemon = True self._timer.start()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start(self, delay=None):\n if self._timer:\n raise Exception('Timer already exists. Use restart instead.')\n\n if not delay:\n delay = self.delay\n\n self._timer = Timer(delay, self.callback)\n # Starting the call in daemon mode so that it exits when the parent...
[ "0.7109396", "0.63238716", "0.6171984", "0.6101533", "0.60576695", "0.60144913", "0.5958865", "0.59566396", "0.5858446", "0.5857999", "0.58413327", "0.579634", "0.56573534", "0.5615492", "0.55685216", "0.55625427", "0.55562544", "0.5488137", "0.5480548", "0.5475354", "0.54637...
0.78188497
0
Return True if path exists
def Exists(self, path: str) -> bool: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists(self, path):", "def exists(path: str) -> bool:\n pass", "def path_exists(path):\r\n return os.path.exists(path)", "def path_exists(self, path):\n try:\n os.stat(path)\n except OSError:\n return False\n return True", "def file_exists(cls, path: Path)...
[ "0.8757863", "0.87178504", "0.8693969", "0.8656877", "0.86241084", "0.86228925", "0.8573195", "0.8506621", "0.8483986", "0.8331406", "0.8308598", "0.82679445", "0.8235729", "0.8215931", "0.8203297", "0.81965387", "0.8185852", "0.8148072", "0.8068592", "0.80582017", "0.8027614...
0.88555646
0
Rename a file from oldname to newname
def RenameFile(self, oldname: str, newname: str) -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rename(oldname, newname):", "def rename_file(path, old_name, new_name):\n \n old_file = os.path.join(path, old_name)\n new_file = os.path.join(path, new_name)\n os.rename(old_file, new_file)", "def rename(old, new):", "def rename(old, new):", "def rename_file (self):\n\t\tassert self.__file...
[ "0.8632374", "0.84979236", "0.8134407", "0.8134407", "0.80457723", "0.7937986", "0.792142", "0.79126793", "0.7826042", "0.77334446", "0.7610196", "0.7591717", "0.7557788", "0.74950385", "0.7452874", "0.74074626", "0.7406878", "0.74068093", "0.73771876", "0.73677063", "0.73240...
0.9007254
0
Write string or bytes to file
def write(self, data: Union[str, bytes]) -> None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(file, string, codec='utf8'):\n if isinstance(string, str):\n file.write(string)\n elif isinstance(string, unicode):\n file.write(string.encode(codec))", "def write_file(filename, string):\n import sys\n #ugly fix, hopefully we can find a better one\n if sys.version_info[0] ...
[ "0.75504446", "0.7326269", "0.73217624", "0.72515404", "0.71031237", "0.7054103", "0.70479435", "0.70056266", "0.69976777", "0.6991522", "0.69794124", "0.69662696", "0.69615513", "0.69577014", "0.6878844", "0.6875704", "0.6846947", "0.6843987", "0.6836143", "0.6828241", "0.68...
0.7581854
0
V.ExtendGraph(vtkMutableGraphHelper, vtkGraph) > int
def ExtendGraph(self, vtkMutableGraphHelper, vtkGraph): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extend_labeled_graph(graph):\n la = community.best_partition(graph)\n nx.set_node_attributes(graph, la, 'community')\n nodes = graph.nodes(data=True)\n # nx.write_graphml(graph,'./data_2/clean_data/comm_graph.graphml')\n\n a = list(set(list(la.values())))\n temp = {}\n for comm in a:\n ...
[ "0.60209775", "0.5857831", "0.574126", "0.5714577", "0.5583012", "0.5544032", "0.54564947", "0.54549074", "0.544287", "0.5436056", "0.5405247", "0.53960377", "0.5376054", "0.5341909", "0.5317724", "0.52974075", "0.5286928", "0.52845", "0.52735144", "0.5271774", "0.5251576", ...
0.880304
0
return a set of tuples representing a reachable province and the path taken to get there for a given unit
def reachable_province(self, ctx): return self.reachable_tiles(ctx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possible(self):\n return [tuple(path) for path in nx.all_shortest_paths(self._gpm.Graph, source=self.source, target=self.target)]", "def all_DU_paths(CG, T):\n path_to_visit = []\n path_not_visited = []\n for var in CG.var:\n vert_var_in_defv=set()\n vert_var_in_refv=set()\n ...
[ "0.5669924", "0.55684626", "0.55611545", "0.5506771", "0.53537774", "0.52936685", "0.5282749", "0.521364", "0.520592", "0.5202676", "0.5176759", "0.51723063", "0.5166985", "0.5161609", "0.5159562", "0.5154347", "0.514914", "0.514904", "0.51467544", "0.51268536", "0.5124956", ...
0.63907313
0
Loads the DNA sequence string at the address
def get_sequence(address): ref = '' with open(address,'rU') as ref_file: next(ref_file) # skip header lines for line in ref_file: ref = ref + line.strip() return ref
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_sequence(sequence_id, database='uniprot'):\n if sequence_id.startswith('UPI'):\n database = 'uniparc'\n url_template = 'http://www.uniprot.org/uniparc/{}.fasta'\n elif sequence_id.startswith('UniRef'):\n database = 'uniref'\n url_template = 'http://www.uniprot.org/uniref...
[ "0.57280564", "0.56917346", "0.5657723", "0.5638905", "0.56204945", "0.5606745", "0.56067204", "0.551535", "0.54936063", "0.544783", "0.5424682", "0.53981584", "0.5347417", "0.5342145", "0.53326404", "0.53095555", "0.530096", "0.52704895", "0.52681744", "0.52631825", "0.52602...
0.6768632
0
Returns a list of the same length as distances where each element is probability that the read came from locus corresponding to that distance such that sum(list) = 1 Currently adds 1 to each distance, takes the inverse then normalizes vector
def probability(distances): v = [1.0/(d + 1) for d in distances] s = sum(v) return [i/s for i in v]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize(p,L): \r\n Norm = []\r\n for k in L:\r\n x = k - p\r\n norm = x.dot(x)**0.5\r\n if norm != 0:\r\n Norm.append(x/norm)\r\n else:\r\n print('warning: attempt to normalize 0')\r\n \r\n return Norm", "def normalize(dist):\n return...
[ "0.6440643", "0.6266799", "0.609463", "0.6016089", "0.6015959", "0.5988844", "0.59724295", "0.5963558", "0.5931813", "0.58614933", "0.58591545", "0.5857181", "0.58184135", "0.57240236", "0.5697465", "0.56647426", "0.56549835", "0.5632636", "0.56282187", "0.56282187", "0.56162...
0.68233
0
Process state dict before sending to client, e.g. to cpu, to sparse, keep values only.
def process_state_dict_to_client(self) -> dict: clean_state_dict = self.clean_dict_to_client() if not self.client_is_sparse: return clean_state_dict if self.is_adj_round(): for layer, prefix in zip(self.model.prunable_layers, self.model.prunable_layer_prefixes): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_state_dict_to_server(self) -> dict:\n clean_state_dict = self.cleanup_state_dict_to_server()\n\n if self.is_sparse:\n for key, param in clean_state_dict.items():\n if param.is_sparse:\n clean_state_dict[key] = param._values()\n\n if self...
[ "0.76180154", "0.6854445", "0.66149974", "0.65147287", "0.62516", "0.62313724", "0.61112785", "0.6069947", "0.60409844", "0.5974067", "0.5947056", "0.5947056", "0.591974", "0.5886285", "0.5876976", "0.5823361", "0.5823361", "0.58231163", "0.58231163", "0.5822161", "0.5803041"...
0.7053615
1
Clean up state dict before process, e.g. remove entries, transpose. To be overridden by subclasses.
def cleanup_state_dict_to_server(self) -> dict: clean_state_dict = copy_dict(self.model.state_dict()) # not deepcopy if self.is_sparse: for layer, prefix in zip(self.model.param_layers, self.model.param_layer_prefixes): key = prefix + ".bias" if isinstance(la...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __cleanState__(self, stateDict):\n for k in list(stateDict.keys()):\n if k.startswith('_'):\n stateDict.pop(k)\n return stateDict", "def _clean(self):\n map(self.__delitem__, self.keys())\n self._original = []\n self._columns = {}\n self._mo...
[ "0.71951675", "0.68752795", "0.68131024", "0.6417723", "0.64059037", "0.63677466", "0.6339097", "0.6327316", "0.6237535", "0.62354624", "0.6199999", "0.61758786", "0.6175496", "0.61518264", "0.61102843", "0.610255", "0.60923934", "0.6078373", "0.6065815", "0.6062268", "0.6054...
0.7233356
0
Process state dict before sending to server, e.g. keep values only, extra param in adjustment round.
def process_state_dict_to_server(self) -> dict: clean_state_dict = self.cleanup_state_dict_to_server() if self.is_sparse: for key, param in clean_state_dict.items(): if param.is_sparse: clean_state_dict[key] = param._values() if self.is_adj_round...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_state_dict_to_client(self) -> dict:\n clean_state_dict = self.clean_dict_to_client()\n if not self.client_is_sparse:\n return clean_state_dict\n\n if self.is_adj_round():\n for layer, prefix in zip(self.model.prunable_layers, self.model.prunable_layer_prefixes...
[ "0.6597636", "0.6589529", "0.63318616", "0.6201117", "0.5979139", "0.5970754", "0.5893874", "0.5880639", "0.58603626", "0.5851453", "0.5837013", "0.5800075", "0.5800075", "0.5800006", "0.5800006", "0.578738", "0.5785772", "0.57822657", "0.5777867", "0.57579994", "0.57440424",...
0.7382162
0
Function to be used as a decorator for measuring time elapsed.
def time_elapsed(fun): def wrapper(*args, **kwargs): t0 = time.time() fun(*args, **kwargs) print("\nTime elapsed = %s" % (time.time() - t0)) return wrapper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def elapsed(func):\n def call_elapsed(*args, **kwargs):\n start_time = time.time()\n func(*args, **kwargs)\n sys.__stdout__.write('Time elapsed: %s'\n % (time.time() - start_time,))\n return make_decorator(func)(call_elapsed)", "def timed(func):\n @wraps(...
[ "0.827335", "0.8096769", "0.7943362", "0.7897353", "0.7849219", "0.7806063", "0.77799284", "0.77593815", "0.7678783", "0.7669037", "0.7585005", "0.755756", "0.7538161", "0.75191116", "0.7516911", "0.7505306", "0.75011796", "0.74958384", "0.7489623", "0.7487912", "0.74834543",...
0.82400656
1
Basic list processing. Using a data directory, a file list, start and end on that list, and a function to be applied to the data directory and a relative path from the list.
def process_list(data_dir, filelist, start, end, crash, fun): print("$ python3 %s\n" % ' '.join(sys.argv)) for n, fname in elements(filelist, start, end): print_element(n, fname) if crash: fun(data_dir, fname) else: try: fun(data_dir, fname) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_by_list( dataset_file ):\n three_paths = []\n # From one input path, build the three paths to send on to move_and_record:\n with open( dataset_file, 'r' ) as f:\n for line in f:\n vnh = line.strip()\n three_paths.append( ( os.path.join('/p/css03/scratch/',vnh),\n ...
[ "0.59321105", "0.58461875", "0.5798538", "0.5792798", "0.5771745", "0.5754246", "0.5739142", "0.57320946", "0.5729682", "0.56914705", "0.56519324", "0.564612", "0.5645171", "0.5587724", "0.5561564", "0.5547579", "0.55469304", "0.55424505", "0.5532638", "0.5530215", "0.5530215...
0.7580944
0
Generator over the lines in filelist, only yielding lines from line niumber start up to and including end.
def elements(filelist, start, end): process = False n = 1 with open(filelist) as fh: for line in fh: fname = line.strip() if n == start: process = True if n > end: return if process: yield (n, fname) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_list(self):\n # XXX better docstring for this one\n\n if self.plaintext:\n fin = io.StringIO(self.plaintext)\n else:\n try:\n filename = os.path.join(self.plaintext_dir, '%s.list' % self.list_name)\n fin = io.open(filename, encoding=...
[ "0.661907", "0.6601885", "0.64462453", "0.6376909", "0.6133469", "0.6096831", "0.60324067", "0.6029716", "0.6018468", "0.6017219", "0.6010689", "0.5964823", "0.58906317", "0.5870396", "0.58433306", "0.57549626", "0.57345665", "0.5725584", "0.5724956", "0.57210445", "0.5689125...
0.72599405
0
Ensure the directory part of all file names exists.
def ensure_directory(*fnames): for fname in fnames: directory = os.path.split(fname)[0] if not os.path.exists(directory): os.makedirs(directory)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_ensure_dir_exists(self):\n pass", "def _check_dirs(self):\r\n for dir in [self.papers_dir,\r\n self.buffer_dir]:\r\n if not os.path.exists(dir):\r\n message = f'Dir not exists: {dir}. Making it.'\r\n logging.warning(message)\r\n ...
[ "0.7356267", "0.71693665", "0.7007526", "0.69387996", "0.6898358", "0.68749064", "0.68032044", "0.67036724", "0.6685586", "0.66848123", "0.663925", "0.6629318", "0.66166574", "0.66119087", "0.6604366", "0.66002417", "0.65705216", "0.6567934", "0.65654266", "0.65576756", "0.65...
0.7486347
0
Return an array of shape (h, w) where h w = arr.size If arr is of shape (n, nrows, ncols), n sublocks of shape (nrows, ncols), then the returned array preserves the "physical" layout of the sublocks.
def unblockshaped(arr, h, w): n, nrows, ncols = arr.shape return (arr.reshape(h//nrows, -1, nrows, ncols) .swapaxes(1,2) .reshape(h, w))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blockshaped(arr, nrows, ncols):\r\n\t h, w = arr.shape\r\n\t return (arr.reshape(h//nrows, nrows, -1, ncols)\r\n\t .swapaxes(1,2)\r\n\t .reshape(-1, nrows, ncols))", "def blockshaped(arr, nrows, ncols):\n h, w = arr.shape\n return (arr.reshape(h//nrows, nrows, -1, ncol...
[ "0.69460547", "0.6816731", "0.6816731", "0.6816731", "0.58214104", "0.55275667", "0.5430478", "0.5429076", "0.5418111", "0.5407741", "0.5375328", "0.5324775", "0.5278403", "0.52337265", "0.5231", "0.5219745", "0.51644814", "0.51599187", "0.51588565", "0.51561743", "0.51494306...
0.69714326
0
Create a string of labels for making kraus matrices
def createlabel(q, n): # When using dec2base function make sure to pad the string with the right number of zeros e.g for base 3 dec2base # gives 1 rather than 01 if we were dealing with 2 qubits. # The number of kraus matrices or labels is n^q label = [] for i in range(pow(n, q)): label.ap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def labels(self):\n\n param=self\n\n l=len(param)\n\n sweep_label=[]\n\n for index,name in enumerate(param.names):\n\n sweep_label.append((\\\n ''.join([c for c in name if c.isupper()]))\\\n .replace(\"IDT\",\"\")\\\n .replace(\"S\",\"\")\\\n ...
[ "0.67619133", "0.663309", "0.6551996", "0.64509314", "0.6398122", "0.63851887", "0.637231", "0.6331695", "0.6312578", "0.6312468", "0.6250509", "0.6233009", "0.6200263", "0.6166632", "0.6158342", "0.6139826", "0.6134953", "0.61154574", "0.6100781", "0.60787743", "0.60545135",...
0.66556007
1
This generates a string that is used to construct tensor products terms in Hamiltonian with a certain kind of interaction term. For example suppose we have an ising Hamiltonian with 4 qubits. We generate strings in a list 1100, 0110,0011. The zero will be used to tensor an identity and the 1 will be used to tensor the ...
def generatehamiltoniantring(n, s, onestring=None, pos=None, pad=None): label = [] if onestring is None: if isinstance(s, str): for i in range(0, n): strs = s strs = strs.ljust(n-i, '0') strs = strs.rjust(n, '0') label.append(st...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generatetensorstring(n, *args):\n out = ''\n label = 0\n arg = array(args) - 1\n\n for i in range(0, n):\n if i in arg:\n label += 1\n out += str(label)\n else:\n out += '0'\n return out", "def generate_str (obj):\n d = obj.dim(obj)\n units ...
[ "0.67071134", "0.6188811", "0.61187154", "0.60962516", "0.60897434", "0.5981579", "0.59358764", "0.57879096", "0.57309914", "0.57123774", "0.5700587", "0.56701165", "0.5653385", "0.5609417", "0.55606216", "0.55426735", "0.55394495", "0.5516998", "0.5511794", "0.550661", "0.54...
0.6213781
1
Removes specific words from files and returns the file with same name but bad lines are removed
def remove_line(file, string=[]): with open(file, 'r') as f, open('tmp.txt', '+a') as new_f: for line in f: clean = True for word in string: if word in line: clean = False if clean is True: new_f.write(line) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_GOs(self):\n\n file = open(self.filename, 'r')\n new_file = open(self.temp_filename, 'w')\n for line in file:\n if \"GO\" not in line and \"go\" not in line:\n new_file.write(line)\n file.close()\n new_file.close()\n self.overwrite_file...
[ "0.6530023", "0.64687544", "0.64657426", "0.643936", "0.63439274", "0.6255501", "0.6159948", "0.6086295", "0.6086085", "0.60616916", "0.60099834", "0.5958632", "0.5916732", "0.58726555", "0.58483857", "0.5817161", "0.5817054", "0.5814065", "0.58092576", "0.5801109", "0.580010...
0.6500035
1
Checks if parameter is output parameter. Returns True if parameter has key 'gisprompt.age' == 'new', False otherwise.
def isOutput(parameter): try: if '@age' in parameter['gisprompt'].keys(): return (parameter['gisprompt']['@age'] == 'new') else: return False except KeyError: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_output(self, output):\n return output == self.output", "def check(self) -> Tuple[bool, str]:\n if self[\"changed\"]:\n return True, \"\"\n else:\n return False, \"The \" + self[\"name\"] + \" parameter have to be set\"", "def params_ok(): \n \n if ...
[ "0.5807495", "0.56992525", "0.557156", "0.5501243", "0.54481214", "0.5438", "0.5403741", "0.53788143", "0.53770506", "0.5369349", "0.53541017", "0.5340148", "0.5340148", "0.5340148", "0.530699", "0.52968436", "0.5277953", "0.5249121", "0.5176042", "0.5163241", "0.5161659", ...
0.924517
0
From the game result string, extract the winner's id.
def _determine_winner(game_result): return next(line for line in game_result.splitlines() if re.compile(_WINNING_RANK_STRING).search(line)).split(_SPACE_DELIMITER)[_BOT_ID_POSITION]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_uniprot_id(uniprot_result):\n id_lines = [l for l in uniprot_result.split('\\n') if l.startswith('ID')]\n\n for id_line in id_lines:\n return id_line.split()[1]\n\n return None", "def get_run_id_from_result(model_result):\n if 'ml_flow' not in model_result:\n return None...
[ "0.6389786", "0.6329488", "0.61289394", "0.5958591", "0.5893738", "0.5817661", "0.5805153", "0.58014286", "0.5724729", "0.56584716", "0.56151605", "0.5602205", "0.55870014", "0.55432886", "0.55321854", "0.54670435", "0.54463226", "0.54409176", "0.5419892", "0.53860986", "0.53...
0.7051588
0
Runs number_of_runs games using the designated bots and binary, recording the tally of wins per player
def play_games(binary, map_width, map_height, bot_commands, number_of_runs): print("Comparing Bots!") result = {} if not(len(bot_commands) == 4 or len(bot_commands) == 2): raise IndexError("The number of bots specified must be either 2 or 4.") for current_run in range(0, number_of_runs): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_match(bots, nr_of_games) -> dict:\n\n start, game_results = datetime.now().timestamp(), _run_games(nr_of_games, bots)\n match_duration = datetime.now().timestamp() - start\n\n match_json = _match_result(game_results, match_duration)\n _print_match_end_score(match_json, match_duration)\n ret...
[ "0.6457276", "0.6405058", "0.63816977", "0.6365274", "0.6318773", "0.62803453", "0.6180857", "0.6159016", "0.6089046", "0.59996665", "0.59805876", "0.5962676", "0.59359556", "0.59175366", "0.59158796", "0.5890217", "0.5871049", "0.5856832", "0.58529985", "0.58124524", "0.5800...
0.7698103
0
Construct a Game bean beanContext is an instance of nova.beanContext.BeanContext
def createBean(self, beanContext): currentTime = DateTime.now() return game.Game().construct(self.serialNum(), self.startTime(), self.endTime(), currentTime, nextProductionTime(currentTime, self), \ self.deathProbeCost(), self.spyProbeCost(), self.factoryCost(), self.speedCost(), self.rangeCost(), self.pro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self,context=''):\n if context=='': \n context_name=self.__class__.__name__\n else: \n context_name=context+'.'+self.__class__.__name__ \n if not (context_name in self.__class__._nInstancesContextList):\n self.__class__._nInstancesContextList.appen...
[ "0.5429802", "0.5398456", "0.52547485", "0.51466453", "0.5145113", "0.5114401", "0.5002459", "0.49618447", "0.49233636", "0.49038294", "0.4899187", "0.48675564", "0.48630452", "0.48493588", "0.4817039", "0.4813379", "0.48067135", "0.48053434", "0.48048058", "0.480347", "0.479...
0.77193683
0
Return the 'Nobody' player for the game
def nobody(self): return self._mk_store.fetchObjectsOfClass(Player, clauses="WHERE gameId = %d AND name = 'Nobody'" % self.sqlObjRef())[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def opponent(self, player):\r\n # player = core.BLACK (can do this for any static var)\r\n if player == core.BLACK:\r\n return core.WHITE\r\n else:\r\n return core.BLACK", "def get_opponent(self):\n for cell in self.__state.board.find_workers():\n play...
[ "0.7179082", "0.71346235", "0.70811814", "0.7037287", "0.6971815", "0.69505286", "0.6927338", "0.68758464", "0.68403226", "0.6769221", "0.67114675", "0.6703061", "0.6703061", "0.6701386", "0.6669454", "0.66185004", "0.6609078", "0.6556283", "0.6543647", "0.6519385", "0.651381...
0.80251557
0
Draw something to a surface. The offset is a x and y tuple which offsets the final position.
def draw(self, screen, offsets: tuple): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, offset: IntegerPosition2D, canvas: Canvas) -> None:\n canvas_position: IntegerPosition2D\n if not self.buffer:\n canvas_position = IntegerPosition2D(0, 0)\n else:\n row: int = self.buffer.get_row(self.index)\n column: int = self.buffer.get_column...
[ "0.71174616", "0.6813651", "0.6532218", "0.6521753", "0.6519349", "0.6490653", "0.6319898", "0.6258449", "0.6215199", "0.6161956", "0.6161956", "0.61448157", "0.6084019", "0.60630345", "0.60574555", "0.6041663", "0.59853274", "0.5980514", "0.59275645", "0.5915207", "0.5913053...
0.70662737
1
Add a thing to a specific section. Leaving out index will append it, otherwise will insert at specific index.
def add_to_drawn(section: str, thing: Base, index: int=None): if index is None: drawn[section].append(thing) else: drawn[section].insert(index, thing)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_new_section(self, name, context=...):\n ...", "def add_section(self, section, lyrics):\n self.sections[section] = lyrics", "def add_section(self, section_name: str) -> None:\n pass", "def add_section(self, section_name: str) -> None:\n pass", "def add_section(self, secti...
[ "0.6761237", "0.66035444", "0.6566462", "0.6566462", "0.6247197", "0.61579007", "0.61553264", "0.60965484", "0.6061076", "0.6059241", "0.6051624", "0.604102", "0.6035189", "0.60212517", "0.6017513", "0.6003912", "0.599046", "0.59664154", "0.5942525", "0.59222454", "0.58979625...
0.76561177
0
Remove a thing from a specific section using a specific index.
def remove_from_drawn(section: str, index: int): del drawn[section][index]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(self, index):\n raise NotImplementedError()", "def delete_at_index(self, index: int) -> T:\n pass", "def delete_at_index(self, index: int) -> T:\n pass", "def removeRow(self, index: int) -> None:\n ...", "def __delitem__(self, index: Any) -> None:\n del self.co...
[ "0.70469296", "0.69429576", "0.69429576", "0.6858212", "0.67361236", "0.66979665", "0.6678134", "0.66500795", "0.6619056", "0.6598444", "0.6516929", "0.6505775", "0.6504128", "0.6432966", "0.6431581", "0.6431434", "0.63970387", "0.63944894", "0.639437", "0.6385715", "0.631306...
0.7609031
0
Tests whether network rejects invalid hidden_layers inputted from user
def test_user_hidden_layers_input_rejections(): inputs_that_should_fail = [[["linearr", 33]], [["linear", 12, 33]], [["gru", 2, 33]], [["lstm", 2, 33]], [["lstmr", 33]], [["gruu", 33]], [["gru", 33], ["xxx", 33]], [["linear", 33], ["gru", 12], ["gru", 33]] ] for input in inputs_th...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_RNN_layers_valid(self):\n error_msg_layer_type = \"First element in a layer specification must be one of {}\".format(self.valid_RNN_hidden_layer_types)\n error_msg_layer_form = \"Layer must be of form [layer_name, hidden_units]\"\n error_msg_layer_list = \"Layers must be provided as ...
[ "0.7171822", "0.63561493", "0.610897", "0.6082803", "0.6039953", "0.6018404", "0.57547784", "0.5728571", "0.57113945", "0.5701364", "0.5636148", "0.5581209", "0.55617243", "0.5515967", "0.55017126", "0.5476648", "0.54517835", "0.54494756", "0.5427705", "0.5413505", "0.5391189...
0.69881386
1
Tests that create_hidden_layers works correctly
def test_hidden_layers_created_correctly(): layers = [["gru", 25], ["lstm", 23], ["linear", 5], ["linear", 10]] rnn = RNN(input_dim=5, layers_info=layers, hidden_activations="relu", output_activation="relu") assert type(rnn.hidden_layers[0]) == nn.GRU assert rnn.hidden_layers[0].input_si...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_visibility(self, data, visible):\n layer = Points(data)\n assert layer.visible is True\n\n layer = Points(data, visible=visible)\n assert layer.visible is visible\n\n layer.visible = not visible\n assert layer.visible is not visible", "def build_layers(self):\n ...
[ "0.6285836", "0.619946", "0.617445", "0.6167124", "0.5950911", "0.5936817", "0.58561146", "0.5794933", "0.5788519", "0.5737324", "0.5709296", "0.570217", "0.56971806", "0.5679431", "0.56654364", "0.5664339", "0.56596035", "0.56536275", "0.56391835", "0.56333864", "0.56308633"...
0.7149164
0
Tests that create_output_layers works correctly
def test_output_layers_created_correctly(): layers = [["gru", 25], ["lstm", 23], ["linear", 5], ["linear", 10]] rnn = RNN(input_dim=5, layers_info=layers, hidden_activations="relu", output_activation="relu") assert rnn.output_layers[0].in_features == 5 assert rnn.output_layers[0].out_features == 10 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_output_head_layers():\n for output_dim in [[[\"linear\", 3],[\"linear\", 9]], [[\"linear\", 4], [\"linear\", 20]], [[\"linear\", 1], [\"linear\", 1]]]:\n nn_instance = RNN(input_dim=5, layers_info=[[\"gru\", 20], [\"lstm\", 8], output_dim],\n hidden_activations=\"relu\",...
[ "0.70297605", "0.69095945", "0.67008126", "0.6463796", "0.64326644", "0.62291646", "0.615556", "0.615226", "0.60517156", "0.6034557", "0.60170466", "0.6016979", "0.60113925", "0.60038334", "0.5999134", "0.5999134", "0.5973484", "0.5926574", "0.59118354", "0.5879324", "0.58793...
0.7599407
0
Tests whether network rejects an invalid output_dim input from user
def test_output_dim_user_input(): inputs_that_should_fail = [-1, "aa", ["dd"], [2], 0, 2.5, {2}] for input_value in inputs_that_should_fail: with pytest.raises(AssertionError): RNN(input_dim=3, layers_info=[2, input_value], hidden_activations="relu", output_activation="relu") with p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(input_, output):\n global number_of_neurons_by_layer\n if len(output) != number_of_neurons_by_layer[-1]:\n raise IndexError(\n f\"\\033[91mDesired output length is incorrect. It must be {number_of_neurons_by_layer[-1]}.\\033[m\")\n output = np.array(output).reshape(len(output),...
[ "0.6838607", "0.6454841", "0.63032913", "0.6283632", "0.6166759", "0.61523336", "0.6115839", "0.608904", "0.6088475", "0.6049992", "0.60479885", "0.60479844", "0.6031168", "0.6017515", "0.601701", "0.5978786", "0.59750605", "0.5965413", "0.59618676", "0.5956854", "0.59553415"...
0.71197593
0
Tests whether network rejects an invalid hidden_activations or output_activation from user
def test_activations_user_input(): inputs_that_should_fail = [-1, "aa", ["dd"], [2], 0, 2.5, {2}, "Xavier_"] for input_value in inputs_that_should_fail: with pytest.raises(AssertionError): RNN(input_dim=4, layers_info=[["linear", 2]], hidden_activations=input_value, output_ac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_hidden_layers_input_rejections():\n inputs_that_should_fail = [[[\"linearr\", 33]], [[\"linear\", 12, 33]], [[\"gru\", 2, 33]], [[\"lstm\", 2, 33]], [[\"lstmr\", 33]],\n [[\"gruu\", 33]], [[\"gru\", 33], [\"xxx\", 33]], [[\"linear\", 33], [\"gru\", 12], [\"gru\", 33]]...
[ "0.646115", "0.588715", "0.5790413", "0.5729977", "0.5634677", "0.56261045", "0.5624805", "0.56081295", "0.55690366", "0.55218625", "0.5504632", "0.5499097", "0.5493358", "0.54845136", "0.54714316", "0.5470243", "0.54539776", "0.544579", "0.5414394", "0.53987086", "0.53792995...
0.6299433
1
Tests whether network outputs data that has gone through correct activation function
def test_output_activation(): RANDOM_ITERATIONS = 20 input_dim = 100 for _ in range(RANDOM_ITERATIONS): data = torch.randn((25, 10, 100)) RNN_instance = RNN(layers_info=[["lstm", 20], ["gru", 5], ["linear", 10], ["linear", 3]], hidden_activations="relu", input_dim=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sigmoid_activation(self):\n self.assertEqual([0.5, 0.5], list(\n af.Sigmoid().output(np.array([0, 0]))))\n self.assertEqual([0.25, 0.25], list(\n af.Sigmoid().derivative(np.array([0, 0]))))", "def test_output_activation_return_return_final_seq_only_off():\n RANDOM_...
[ "0.68730205", "0.67846847", "0.66975826", "0.6651164", "0.661632", "0.6461441", "0.63807184", "0.63212496", "0.6313192", "0.63074267", "0.62492007", "0.62348425", "0.6229038", "0.6172399", "0.61524916", "0.61336595", "0.61072147", "0.60924554", "0.60870665", "0.6061939", "0.6...
0.72898424
0
Tests whether setting a y range works correctly
def test_y_range(): for _ in range(100): val1 = random.random() - 3.0*random.random() val2 = random.random() + 2.0*random.random() lower_bound = min(val1, val2) upper_bound = max(val1, val2) rnn = RNN(layers_info=[["lstm", 20], ["gru", 5], ["lstm", 25]], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_y_range_user_input():\n invalid_y_range_inputs = [ (4, 1), (2, 4, 8), [2, 4], (np.array(2.0), 6.9)]\n for y_range_value in invalid_y_range_inputs:\n with pytest.raises(AssertionError):\n print(y_range_value)\n rnn = RNN(layers_info=[[\"lstm\", 20], [\"gru\", 5], [\"lstm\...
[ "0.69887966", "0.6787549", "0.6728513", "0.6704412", "0.66581345", "0.6623556", "0.65083843", "0.6419491", "0.64088297", "0.6408696", "0.6345011", "0.6308929", "0.62689686", "0.62398374", "0.62286705", "0.61892277", "0.6184476", "0.6139843", "0.6135049", "0.6135049", "0.61283...
0.7210425
0
Tests that check_input_data_into_forward_once method only runs once
def test_check_input_data_into_forward_once(): rnn = RNN(layers_info=[["lstm", 20], ["gru", 5], ["lstm", 25]], hidden_activations="relu", input_dim=5, output_activation="relu", initialiser="xavier") data_not_to_throw_error = torch.randn((1, 4, 5)) data_to_throw...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_forward(self):\n validate_forward()", "def check_Data(self):\r\n \r\n if self._target_data is None:\r\n self.processData()", "def has_buffered_inputs(self):", "def forward_once(self, x):\n\t\t#x = F.normalize(self.network(x), p=2)\n\t\tx = self.network(x)\n\t\treturn ...
[ "0.61968815", "0.58582073", "0.5682138", "0.5575721", "0.5539609", "0.5531701", "0.5507432", "0.5409996", "0.53948504", "0.5367557", "0.5359325", "0.533804", "0.5321757", "0.52892125", "0.5246141", "0.52032685", "0.51893234", "0.51822394", "0.5180504", "0.5171261", "0.5169993...
0.6379902
0
Tests whether network rejects invalid y_range inputs
def test_y_range_user_input(): invalid_y_range_inputs = [ (4, 1), (2, 4, 8), [2, 4], (np.array(2.0), 6.9)] for y_range_value in invalid_y_range_inputs: with pytest.raises(AssertionError): print(y_range_value) rnn = RNN(layers_info=[["lstm", 20], ["gru", 5], ["lstm", 25]], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_invalid_target(self):\n y_valid = np.random.randint(2, size=100)\n y_invalid = np.random.uniform(size=100)\n\n oz = ClassBalance()\n\n with pytest.raises(YellowbrickValueError):\n oz.fit(y_invalid)\n\n with pytest.raises(YellowbrickValueError):\n oz...
[ "0.69277006", "0.67759", "0.66113496", "0.6391974", "0.6369389", "0.63201374", "0.63130033", "0.62934816", "0.626229", "0.624285", "0.62060905", "0.6107401", "0.60435826", "0.6005684", "0.5997749", "0.5965224", "0.59253037", "0.59052044", "0.5887826", "0.58822834", "0.5843428...
0.81492263
0
Tests that it raises an error if we try to do an embedding on negative data
def test_error_when_provide_negative_data_for_embedding(): N = 250 X = torch.randn((N, 5, 15)) X[0:125, 0, 3] += 20.0 y = X[:, 0, 3] > 5.0 y = y.float() with pytest.raises(AssertionError): rnn = RNN(layers_info=[["gru", 20], ["lstm", 8], ["linear", 1]], input_dim=15, hi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_extract_incorrect_embeddings():\n with pytest.raises(ValueError):\n model = BERTopic(language=\"Unknown language\")\n model._extract_embeddings([\"Some document\"])", "def test_embedder_raises_exception_for_incorrect_input_type(self):\n embed = layers.Embed(num_embeddings=10, feature...
[ "0.7797407", "0.69551307", "0.6756526", "0.6376604", "0.620987", "0.61232376", "0.6023977", "0.59729695", "0.59117335", "0.58505356", "0.5842247", "0.5827982", "0.5789328", "0.5751712", "0.56799704", "0.5669994", "0.56527793", "0.56489265", "0.56377167", "0.5577644", "0.55776...
0.7570276
1
Tests whether create_embedding_layers method works correctly
def test_embedding_layers(): for embedding_in_dim_1, embedding_out_dim_1, embedding_in_dim_2, embedding_out_dim_2 in zip(range(5, 8), range(3, 6), range(1, 4), range(24, 27)): nn_instance = RNN(input_dim=15, layers_info=[["gru", 20], ["lstm", 8], ["linear", 1]], embedding_dimensions...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_embedding_matrix_shape(self):\n num_embeddings = 10\n features = 5\n embed = layers.Embed(num_embeddings=num_embeddings, features=features)\n inputs = np.expand_dims(np.arange(features, dtype=np.int64), 1)\n variables = embed.init(jax.random.PRNGKey(0), inputs)\n embedding_matrix = varia...
[ "0.6754671", "0.66972744", "0.6680853", "0.65963113", "0.65625614", "0.64607567", "0.6458213", "0.643751", "0.64041454", "0.6341409", "0.62876004", "0.62862927", "0.6283644", "0.6279857", "0.61914355", "0.61818564", "0.61757904", "0.617194", "0.6163812", "0.6151228", "0.61408...
0.7215121
0
Tests whether dropout layer reads in probability correctly
def test_dropout(): rnn = RNN(layers_info=[["lstm", 20], ["gru", 10], ["linear", 20], ["linear", 1]], hidden_activations="relu", output_activation="sigmoid", dropout=0.9999, initialiser="xavier", input_dim=15) assert rnn.dropout_layer.p == 0.9999 assert ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _Dropout(self, name, drop_prob):\n return super()._Dropout(name, keep_prob=1.0 - drop_prob)", "def compute_dropout(self, activations, dropout_prob = 0.5):\n # handle error\n if dropout_prob < 0 or dropout_prob > 1:\n dropout_prob = 0.5\n # scale the activations (see http://...
[ "0.67629886", "0.6578518", "0.6430722", "0.62942684", "0.62148696", "0.62001896", "0.61766964", "0.616204", "0.6118928", "0.6095642", "0.6074857", "0.60608095", "0.6050995", "0.60476774", "0.60386544", "0.59819704", "0.5975472", "0.59751296", "0.5924714", "0.5882051", "0.5881...
0.6646074
1
Tests whether network outputs of correct shape
def test_output_shapes(): rnn = RNN(layers_info=[["gru", 20], ["lstm", 8], ["linear", 3]], hidden_activations="relu", initialiser="xavier", input_dim=15) output = rnn(X) assert output.shape == (N, 3) rnn = RNN(layers_info=[["gru", 20], ["lstm", 8], ["linear", 7]], hidden_act...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unet_verify_output_shape(simple_unet_data):\n unet = models.UNet()\n output = unet(simple_unet_data)\n print(\"Input shape:\", simple_unet_data.shape)\n print(\"Output shape:\", output.shape)\n assert simple_unet_data.shape == output.shape", "def dimension_check():\n print(\"### DIMENS...
[ "0.7367588", "0.7063788", "0.69999754", "0.69562316", "0.6948631", "0.68892664", "0.68857855", "0.6879901", "0.6879901", "0.68292147", "0.6785833", "0.6736189", "0.6731217", "0.6698011", "0.6661939", "0.6600723", "0.6569839", "0.6545449", "0.6511452", "0.6490843", "0.6480389"...
0.7374896
0
Tests whether the output head layers get created properly
def test_output_head_layers(): for output_dim in [[["linear", 3],["linear", 9]], [["linear", 4], ["linear", 20]], [["linear", 1], ["linear", 1]]]: nn_instance = RNN(input_dim=5, layers_info=[["gru", 20], ["lstm", 8], output_dim], hidden_activations="relu", output_activation=["softm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gz_batch(self):\n assert self.design.layout.layers[0].name == 'top'", "def test_output_head_shapes_correct():\n N = 20\n X = torch.randn((N, 10, 4)) * -20.0\n for _ in range(25):\n nn_instance = RNN(input_dim=4,\n layers_info=[[\"gru\", 20], [\"lstm\", 8], [\"linear\", ...
[ "0.64709437", "0.6327445", "0.62262976", "0.6176358", "0.61338794", "0.6049259", "0.5949284", "0.5947901", "0.5946794", "0.594015", "0.5908161", "0.5864121", "0.582288", "0.58142173", "0.5809196", "0.5793423", "0.57716125", "0.5731328", "0.57262856", "0.5711052", "0.569529", ...
0.73129505
0
Decorator to set waiting cursor while function is running.
def waiting_cursor(function): def new_function(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: function(self) except Exception as e: raise e print("Error {}".format(e.args[0])) finally: QApplication.restoreOverrideCu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_cursor(win):\n win.app.setOverrideCursor(gui.QCursor(core.Qt.WaitCursor))\n yield\n win.app.restoreOverrideCursor()", "def wait(func):\n def decorator(self, pkt: str) -> None:\n init_time = time.perf_counter()\n func(self, pkt)\n while time.perf_counter()...
[ "0.621839", "0.6173325", "0.60418564", "0.5873782", "0.58133435", "0.5802555", "0.56343734", "0.5622056", "0.55775356", "0.5572662", "0.55615383", "0.5531714", "0.54737693", "0.5402359", "0.5394669", "0.5377479", "0.5330632", "0.5328029", "0.53188837", "0.53006744", "0.530067...
0.7422905
0
Override inherited QMainWindow resize event. Saves the window geometry.
def resizeEvent(self, event): self.settings.setValue("geometry", self.saveGeometry()) super().resizeEvent(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resizeEvent(self, *args, **kwargs):\n self.windowMoved.emit()", "def resizeEvent(self, event):\r\n QDialog.resizeEvent(self, event)\r\n self.emit(SIGNAL(\"size_change(QSize)\"), self.size())", "def resizeEvent(self, event):\n self.resized.emit()\n return super(PiWndow, se...
[ "0.7568738", "0.73874474", "0.73514515", "0.7263355", "0.7208239", "0.7027689", "0.6980282", "0.6977833", "0.6970731", "0.6908289", "0.6868141", "0.682982", "0.6793767", "0.6758908", "0.6676213", "0.6672818", "0.6643312", "0.64994204", "0.6469828", "0.6464748", "0.64348876", ...
0.78121006
0
Override inherited QMainWindow move event. Saves the window geometry.
def moveEvent(self, event): self.settings.setValue("geometry", self.saveGeometry()) super().moveEvent(event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moveEvent(self, *args, **kwargs):\n self.windowMoved.emit()", "def resizeEvent(self, *args, **kwargs):\n self.windowMoved.emit()", "def ev_windowmoved(self, event: WindowMoved) -> None:", "def _positionWindow(self):\n\t\tscreen = QtGui.QDesktopWidget().screenGeometry()\n\t\tself.setGeometry...
[ "0.7606414", "0.71723086", "0.71219075", "0.6784356", "0.66384774", "0.663542", "0.65639585", "0.65360874", "0.6531752", "0.6499311", "0.64266163", "0.6333455", "0.63130426", "0.62280285", "0.6225158", "0.62186563", "0.61726123", "0.6161794", "0.6124457", "0.61130536", "0.599...
0.7580476
1
Check data type and source to see if the bridge map is needed.
def needs_bridging(self, has_verbal_autopsy): sources_to_bridge_map = [ "India_SCD_states_rural", "India_CRS", "India_MCCD_states_ICD9", "India_MCCD_states_ICD10", "India_Maharashtra_SCD", "India_MCCD_Orissa_ICD10", "India_MCCD_Delhi_ICD10", "ICD9_BTL", "Russia_FM...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_base_type(cls, data):\n return _mapping_resolver.get_type(data) == \"MAPPING\"", "def checkMap(self):\n return True", "def _sanity_check_datasource(ds):\n if len(ds) != 1:\n raise SanityCheckError('GeoJSON should have only 1 layer.')\n # TODO: add more checks", "def check_Da...
[ "0.5886268", "0.5826029", "0.5767964", "0.57115424", "0.5651457", "0.5650617", "0.56332195", "0.5626689", "0.5591905", "0.5586229", "0.556025", "0.55439883", "0.55269843", "0.5517739", "0.5505605", "0.5470142", "0.54573935", "0.5434472", "0.5417162", "0.5383413", "0.5376976",...
0.60287815
0
Determine the sheet name needed based on the source.
def get_sheet_name(self, has_verbal_autopsy): source_to_sheet = { "India_MCCD_Orissa_ICD10": "India_MCCD_states_ICD10", "India_MCCD_Delhi_ICD10": "India_MCCD_states_ICD10", "Thailand_Public_Health_Statistics": "ICD10_tabulated", "India_SRS_states_report": "India_S...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sheet_name(self):\n\n xl = pd.ExcelFile(self.excel_file)\n sheet_names = xl.sheet_names\n for item in sheet_names:\n if re.match('(.*)Current primers', item, re.IGNORECASE): # Only extracts most recent primers.\n sheet_name = item\n return shee...
[ "0.7164989", "0.6308564", "0.61821693", "0.603946", "0.59906214", "0.5879506", "0.58683854", "0.5754971", "0.57401884", "0.5708304", "0.57011294", "0.55058926", "0.54911", "0.5414342", "0.5403765", "0.53900576", "0.5371769", "0.5352899", "0.53527546", "0.5343347", "0.5297994"...
0.7110151
1
Replace the acause with the bridge code.
def acause_to_bridge_code(self, df): df['swap'] = 0 df.loc[ (df['acause'] != df['bridge_code']) & (df['bridge_code'].notnull()), 'swap' ] = 1 df.loc[df['swap'] == 1, 'acause'] = df['bridge_code'] self.causes_not_in_bridge_map(df) return...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_cause():", "def _fix_up(self, cls, code_name):", "def replacement(exception):\n assert exception.__class__.__name__ == \"LinterFailure\"\n return exception.replacement", "def errorCodeCause(self, cause):\n pass", "def fixup(self):\n raise Exception(\"Fixup not implemented yet!...
[ "0.56187624", "0.5339114", "0.53007525", "0.5278467", "0.51992387", "0.5144127", "0.5144127", "0.4979441", "0.4972489", "0.49498683", "0.48308125", "0.48117915", "0.47808516", "0.47630504", "0.4756997", "0.47563353", "0.47268003", "0.46959338", "0.46171212", "0.4606202", "0.4...
0.63376826
0
Print causes that aren't in the bridge map, but are in the data.
def causes_not_in_bridge_map(self, df): check = set(df.loc[df['bridge_code'].isnull(), 'acause']) if len(check) > 0: print("These acauses are not in the bridge map: {}".format(check))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_out_unexplained(self):\n for node in self.vertices:\n for arc in self.out_arcs_lists[node]:\n s = self.arc_info[arc]['start']\n t = self.arc_info[arc]['destin']\n w = self.arc_info[arc]['unexplained_flow']\n print(\"({} {}) une...
[ "0.5635357", "0.5168932", "0.5168312", "0.51084465", "0.50421125", "0.5012694", "0.49809542", "0.49573722", "0.49084926", "0.4888484", "0.48796296", "0.48676422", "0.48665074", "0.4809346", "0.47892943", "0.47808835", "0.47711042", "0.47605914", "0.47398275", "0.4732302", "0....
0.7070158
0
Group by final columns, summing across deaths.
def collapse_and_sum_by_deaths(self, df): df = df.groupby(self.id_cols, as_index=False)[self.data_col].sum() self.assert_unique_cols_unique(df) return df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _aggregate(group_df):\n out = {}\n for col in data_columns:\n # The name of the error column (if it exists)\n error_col = f\"{col}_moe\"\n\n # remove any NaN rows\n subset = group_df.dropna(subset=[col], how=\"any\")\n\n # aggregat if we had ...
[ "0.5318467", "0.5297273", "0.5217793", "0.5203764", "0.5133742", "0.50570774", "0.5016997", "0.49657285", "0.49467602", "0.4945261", "0.49407688", "0.49390042", "0.48924458", "0.48900697", "0.4883349", "0.48651448", "0.48445007", "0.4817701", "0.48097548", "0.47966254", "0.47...
0.75622433
0
Test that columns that should uniquely identify the dataframe do.
def assert_unique_cols_unique(self, df): assert not df.duplicated(self.unique_cols).any()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkcolumnstest(chosen_columns, chosen_df):\n if not all([item in chosen_columns for item in chosen_df.columns]):\n raise ValueError('Columns do not match')", "def verify_columns_in_dataframe(df, columns):\n\n if not isinstance(columns, list):\n columns = [columns]\n return set(column...
[ "0.7065261", "0.68916535", "0.67887884", "0.6769533", "0.67213285", "0.6651365", "0.6554256", "0.64366084", "0.64201415", "0.64169556", "0.640995", "0.63906235", "0.63551354", "0.63454103", "0.6342936", "0.63194436", "0.6296456", "0.62885845", "0.626959", "0.6255762", "0.6241...
0.81844956
0
Binarize a feature to minimize the difference in sum of squares between the two resulting groups.
def binarize_feature(f): f = f - f.mean() f2 = (f.order() ** 2) split = f.ix[(f2.cumsum() - (f2.sum() / 2.)).abs().idxmin()] return f > split
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binarize(self):\n # Loop through the ratings and binarize based on overall average rating\n rating_sum = np.sum(self.ratings)\n rating_count = np.count_nonzero(self.ratings)\n rating_avg = (1.0 * rating_sum) / rating_count\n\n def binary_transform(x, rating_avg):\n if x == 0.0:\...
[ "0.5834405", "0.5714596", "0.56099087", "0.53564245", "0.5345524", "0.5343635", "0.53198165", "0.5301293", "0.5279895", "0.52382255", "0.52295107", "0.5213143", "0.5212723", "0.51760197", "0.51498497", "0.51463294", "0.5144221", "0.5110803", "0.5091475", "0.50752646", "0.5073...
0.64920145
0
Screens out redundant pathways with high correlation above _cutoff_. Pathways are ranked based on lack of correlation to the background signal. Then if two pathways have high correlation the lower ranked pathway is removed.
def remove_redundant_pathways(pathways, rna, cutoff=.7, binarize=False): #bg = H.screen_feature(background, spearman_pandas, pathways) dx = pd.DataFrame({p: ttest_rel(rna.df.ix[l.index].T.dot(l)) for p,l in rna.loadings.iteritems()}).T dx = dx.t.abs() dd = pathways.ix[dx.index[::-1]].T.c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __generate_all_shortest_paths(self,cutoff = 10):\n if cutoff < 1:\n cutoff = 10\n self.__logger.info(\"cutoff value must be a positive integer. Set back to default value: 10\")\n\n all_pair_shortest_paths = nx.all_pairs_shortest_path(self.G, cutoff=cutoff)\n for item ...
[ "0.58749056", "0.5758001", "0.5598225", "0.5390486", "0.5309527", "0.5248357", "0.5210141", "0.5127525", "0.5095731", "0.5082875", "0.5073413", "0.5005037", "0.498891", "0.4978641", "0.49535555", "0.49215704", "0.492009", "0.48521635", "0.48403457", "0.48393774", "0.4787763",...
0.6945232
0
Replace a function for the duration of the test. Use the monkey patch fixture to replace a function for the duration of a test. Useful when you want to provide fake methods instead of mocks during testing. This should be used instead of self.stubs.Set (which is based on mox) going forward.
def stub_out(self, old, new): self.useFixture(fixtures.MonkeyPatch(old, new))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch(original_module):\n def wrap(override_fn):\n original_fn = getattr(original_module, override_fn.__name__)\n setattr(original_module, override_fn.__name__, partial(override_fn, original_fn))\n\n # Don't actually modify the function being decorated.\n return override_fn\n ...
[ "0.66126996", "0.6246913", "0.59958524", "0.59808385", "0.5970251", "0.5970251", "0.59676784", "0.5964168", "0.5732706", "0.5707334", "0.568837", "0.56609994", "0.5626188", "0.56159544", "0.5610572", "0.55929077", "0.555881", "0.55573034", "0.55572486", "0.5480746", "0.547858...
0.698745
1
Use python mock to mock an object attribute Mocks the specified objects attribute with the given value. Automatically performs 'addCleanup' for the mock.
def mock_object(self, obj, attr_name, new_attr=None, **kwargs): if not new_attr: new_attr = mock.Mock() patcher = mock.patch.object(obj, attr_name, new_attr, **kwargs) patcher.start() self.addCleanup(patcher.stop) return new_attr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch_object(mocker):\n\n def _object(obj_to_patch, attribute, return_value):\n mock_func = mocker.patch.object(obj_to_patch, attribute)\n if return_value is not None:\n mock_func.return_value = return_value\n\n return _object", "def mock_side_effect(self, original_object, attr...
[ "0.6999446", "0.64985067", "0.6480005", "0.61804056", "0.6107706", "0.6030694", "0.59762293", "0.58769643", "0.58677036", "0.58640003", "0.5860096", "0.585139", "0.5840659", "0.58258325", "0.5818307", "0.58063465", "0.58023256", "0.57815766", "0.5776021", "0.5776021", "0.5748...
0.7388397
1
ROI on the surface or volume with a given centre and radius
def py_SurfStatROI(centre, radius, surf): sys.exit("Function py_SurfStatROI is under development")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def objects_radius(self, centre, radius):", "def extract_roi_from_volume(volume, in_center, output_shape, fill = 'random'):\n input_shape = volume.shape \n if(fill == 'random'):\n output = np.random.normal(0, 1, size = output_shape)\n else:\n output = np.zeros(output_shape)\n r0max = ...
[ "0.6983759", "0.6608037", "0.6608037", "0.6565604", "0.6497947", "0.6497947", "0.6379288", "0.6208821", "0.61896527", "0.6177499", "0.61722773", "0.6139702", "0.607727", "0.6039256", "0.59929496", "0.5988569", "0.5976138", "0.597191", "0.5934677", "0.5894657", "0.5884144", ...
0.7116994
0
Gets the latest season and season type in the games data
def _get_latest_season_and_type(df): if df is None or len(df) == 0: return (None, None) if not isinstance(df, pd.DataFrame): raise ValueError(f"Type of df is {type(df)}, it should be pandas.DataFrame") df = df[df['state_of_game'] == 'POST'] latest_season = df['season'].max() season...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latestGamePack(team):\n lgr= get('schedule', {'ver':'v1', 'sportId':1, 'date':today, 'teamId':team, 'fields':['dates','games','gamePk'] })\n return lgr['dates'][0]['games'][0]['gamePk']", "def getseason(data):\n ## Season key is the most reliable\n season = data.get(\"season\")\n if season:\n ...
[ "0.6553931", "0.6546608", "0.6442716", "0.64363", "0.6434008", "0.6398952", "0.62399364", "0.6105547", "0.6082319", "0.6062433", "0.59988546", "0.59488773", "0.59089303", "0.5888597", "0.5820921", "0.5803751", "0.57766825", "0.5746373", "0.57297796", "0.5726727", "0.5723362",...
0.7470444
0
Uses the semantic ordering of season types to get the latest/max
def _get_latest_season_type(season_types_list): if not isinstance(season_types_list, (list, tuple)): raise ValueError(f"type of {type(season_types_list)} for season_type_list not list or tuple") latest_season_type = season_types_list[0] if len(season_types_list) > 1: for season_type in seas...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_latest_season_and_type(df):\n if df is None or len(df) == 0:\n return (None, None)\n\n if not isinstance(df, pd.DataFrame):\n raise ValueError(f\"Type of df is {type(df)}, it should be pandas.DataFrame\")\n\n df = df[df['state_of_game'] == 'POST']\n latest_season = df['season'].m...
[ "0.672219", "0.5860014", "0.57655185", "0.57589823", "0.55447674", "0.5494647", "0.5436334", "0.5394017", "0.53333473", "0.5325742", "0.52458227", "0.52447414", "0.52128184", "0.5152866", "0.51410383", "0.5102868", "0.5095066", "0.5065986", "0.5064631", "0.50637007", "0.50637...
0.71224105
0
Removes the latest season and season type from df.
def _truncate_games_df(df, season, season_type): return df[(df['season'] != season) | (df['type'] != season_type)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _drop_last_season_championship_matches(self, df: pd.DataFrame) -> pd.DataFrame:\n max_season = df[\"season\"].max()\n\n if self._resume:\n # Check if max season changed\n if max_season != self._model_settings[\"max_season\"]:\n raise ValueError(\"Current max s...
[ "0.6965733", "0.63223386", "0.6169938", "0.5764446", "0.5585531", "0.5310778", "0.5301593", "0.52592826", "0.5258071", "0.52488506", "0.5140651", "0.5111419", "0.50804186", "0.5079051", "0.5058062", "0.49890277", "0.4945572", "0.4936485", "0.49139735", "0.48739588", "0.481331...
0.7332864
0
Drops rows from the games table that are of season and season_type.
def _truncate_games_table(db_conn, season, season_type): delete_statement = f"DELETE FROM games WHERE season = {season} and type = '{season_type}'" logging.info(f"Truncating games table with statement: {delete_statement}") db_conn.execute(delete_statement)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _truncate_games_df(df, season, season_type):\n return df[(df['season'] != season) | (df['type'] != season_type)]", "def update_season_table(session, sched_tbl, season_df):\n date = datetime.date(datetime.now())\n update_query = session.query(sched_tbl).filter(sched_tbl.start_time < date,\n ...
[ "0.762441", "0.6251675", "0.61136353", "0.5862718", "0.56220615", "0.54519236", "0.5399716", "0.537986", "0.53599685", "0.5343498", "0.5125028", "0.51231134", "0.50927806", "0.5061084", "0.50600594", "0.5034044", "0.502096", "0.49832642", "0.4961268", "0.4951709", "0.49427244...
0.7035129
1
Runs the nflscrapr R script for the given season and type
def _extract_games_data(season, season_type): nflscrapr.run( 'games', season=season, season_type=season_type ) nflscrapr_output = etl_tools.extract_from_csv(config.GAMES_DUMP_CSV_PATH) return nflscrapr_output
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scrape():\n league_year = Config.get_property(\"league_year\")\n\n # Create table\n season_data = client.season_schedule(league_year)\n season_data = br_enum_to_string(season_data)\n return season_data", "def get_schedules_for_season(self, season, season_type=\"REG\"):\n try:\n ...
[ "0.58400744", "0.5825069", "0.5700488", "0.56795895", "0.5633705", "0.550612", "0.5492933", "0.54907745", "0.5442901", "0.5320366", "0.52981234", "0.5222515", "0.51775146", "0.5153715", "0.5135699", "0.5109447", "0.50783205", "0.5008098", "0.50059414", "0.5002093", "0.4990885...
0.61678904
0
Runs the workflow for extracting and loading games data. Finds the starting point for extracting new data Extracts new data using the nflscrapr module Loads to database
def run(): games_db_conn = db.get_db_eng() games_query = "SELECT * FROM GAMES" games_data = etl_tools.extract_from_db(games_db_conn, games_query) _data_integrity_check(games_data) latest_season, latest_season_type = _get_latest_season_and_type(games_data) logging.info(f"Latest season and type i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_and_preprocess(self):\n print('Preparing steering angle database.')\n print('Downloading...')\n self.download()\n print('Preprocessing...')\n self.preprocess()", "def scrape_all():\n\n # Scrape team information by season\n for team in scrape_utils.team_names(...
[ "0.6121077", "0.6028184", "0.59892666", "0.59821534", "0.5883398", "0.585514", "0.58488256", "0.583428", "0.5776301", "0.577098", "0.57684034", "0.5755793", "0.57253456", "0.5703388", "0.56687576", "0.56505823", "0.56160414", "0.560584", "0.56016344", "0.5601598", "0.55712277...
0.72591263
0