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
Psuedo code Input > Prediction file for Hand fingers, Foot fingers, Wrists and Hand IP joints, including the joint IDS and Labels for the Joint patches Specify type of prediction file associated Mapping file with the relevent column names to be given to the Prediction files Patient ID list in the test set without JPG e...
def get_final_submission_file(check, joint_type, prediction_type, mapping_file, PATIENT_ID_LIST): if joint_type in ['wrist', 'hand_ip']: check['Patient_ID'] = check['Joint_image_ID'].str.split("-", expand=True)[0] check['limb_name'] = check['Joint_image_ID'].str.split("-", expand=True)[1] c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_prediction_files(test_path, joint_model_path_mapping, \n mapping_file, column_mapping, erosion_cols, narrowing_cols,\n image_batch_array):\n final_prediction_file = pd.DataFrame()\n for joint_type in joint_model_path_mapping.keys():\n #Dependenc...
[ "0.6452809", "0.6112587", "0.60888916", "0.5927397", "0.57991815", "0.57063586", "0.570142", "0.5666835", "0.564199", "0.55971783", "0.55657035", "0.5562128", "0.5553663", "0.55453753", "0.5528446", "0.55203456", "0.5500955", "0.54734284", "0.5465235", "0.54608107", "0.545193...
0.63650596
1
Input > Joints_path list, test_images_path, joint_image_mapping_dict, Joint_models_mapping_dict, column_mapping_file, all_columns_in_prediction_file, erosion_cols, narrowing_cols Output > Final prediction file
def get_prediction_files(test_path, joint_model_path_mapping, mapping_file, column_mapping, erosion_cols, narrowing_cols, image_batch_array): final_prediction_file = pd.DataFrame() for joint_type in joint_model_path_mapping.keys(): #Dependency ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prediction_on_a_image(self, input, output,model_saved_path):\n\n # load the saved model\n if os.path.isfile(model_saved_path) is False:\n raise IOError('trained model: %s not exist' % model_saved_path)\n\n clf = joblib.load(model_saved_path)\n\n # split a large image to m...
[ "0.6435797", "0.6232507", "0.6202622", "0.6168823", "0.610853", "0.6075219", "0.60701376", "0.59988964", "0.59893507", "0.5942194", "0.5939883", "0.59264386", "0.5884487", "0.586431", "0.58536273", "0.5851021", "0.5831872", "0.58216083", "0.5813369", "0.57918495", "0.57680726...
0.77874124
0
Post event to be handled soon. event is added to the queue of events. Returns a future which resolves when the handlers of event (and all events generated during those handlers) have completed.
def post_event(self, event): self.events.append(event) LOG.debug('added event %s, pending=%s', event, len(self.events)) self.new_events.set() if not self.future: self.future = self.loop.create_task(self._run()) return self.future
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(self, event):\n self.queue.append(event)\n if not self.timer.active:\n self.timer.start(0)", "async def async_event(self, event: str, *args, **kwargs):\n for cb in self.event_handlers[event]:\n asyncio.ensure_future(cb(*args, **kwargs), loop=self.loop)", "def...
[ "0.63777775", "0.5939097", "0.58807236", "0.5833932", "0.57796127", "0.57294", "0.5588496", "0.55545306", "0.55531657", "0.5538416", "0.54770935", "0.54513687", "0.5438502", "0.54271317", "0.53740555", "0.5281197", "0.5272974", "0.52166337", "0.51939887", "0.5176778", "0.5132...
0.7938265
0
Call handler with event and log any exception. If handler returns an awaitable, then it is wrapped in a coroutine that will log any exception from awaiting it.
def _run_handler(self, handler, event): result = None try: result = handler(event) except Exception as e: self._handle_exception(exception=e, csbot_event=event) future = maybe_future(result, log=LOG) if future: future = asyncio.ensure_future(se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _finish_async_handler(self, future, event):\n try:\n await future\n except Exception:\n self._handle_exception(future=future, csbot_event=event)", "async def async_event(self, event: str, *args, **kwargs):\n for cb in self.event_handlers[event]:\n a...
[ "0.63058764", "0.6174067", "0.6004698", "0.59819067", "0.58673775", "0.5824148", "0.5802255", "0.5801053", "0.5701408", "0.56969553", "0.56919044", "0.5686786", "0.56483066", "0.5608801", "0.55929786", "0.5576457", "0.5542828", "0.55036867", "0.54677594", "0.5460901", "0.5440...
0.7370603
0
Await future and log any exception.
async def _finish_async_handler(self, future, event): try: await future except Exception: self._handle_exception(future=future, csbot_event=event)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def execute(self):\n raise Exception()", "def testErrorInBackgroundThread(self):\n\n @utils.make_async()\n def async_fn():\n raise ValueError()\n\n future = async_fn() # pylint: disable=assignment-from-no-return\n self.assertIsNotNone(future.exception())", "async def catch(ct...
[ "0.642071", "0.638245", "0.6251586", "0.6118219", "0.60101193", "0.59224", "0.58167124", "0.5713835", "0.57081807", "0.56897527", "0.56892884", "0.56729466", "0.5663251", "0.5662886", "0.56512076", "0.56512076", "0.56466603", "0.56410694", "0.56410694", "0.563678", "0.5625149...
0.65945333
0
Run the event runner loop. Process events and await futures until all events and handlers have been processed.
async def _run(self): # Use self as context manager so an escaping exception doesn't break # the event runner instance permanently (i.e. we clean up the future) with self: # Run until no more events or lingering futures while len(self.events) + len(self.futures) > 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def run(self):\n main_loop = asyncio.get_event_loop()\n # so many threads, name this so it's identifiable\n pfx = 'ThreadPoolExecutor-GPSEventConsumer'\n # NOTE: there should only be one thread pool executor worker\n # from here since this method is only called once f...
[ "0.7254807", "0.7202866", "0.7164827", "0.7100885", "0.7014749", "0.6896003", "0.6826913", "0.6826913", "0.6808971", "0.6806834", "0.6802213", "0.6734104", "0.67174125", "0.67041916", "0.6674844", "0.6667677", "0.6632959", "0.66083944", "0.65708864", "0.6569524", "0.6500508",...
0.83766496
0
Create a new event by extending an existing event. The main purpose of this classmethod is to duplicate an event as a new
def extend(cls, event, event_type=None, data=None): # Duplicate event information e = cls(event.bot, event.event_type, event) e.datetime = event.datetime # Apply optional updates if event_type is not None: e.event_type = event_type ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_new_event(self):\n pass", "def create_and_add_event(self, event_data):\n event = event_from_dict(event_data)\n self.add_event(event)", "def new_event(self, subject=None):\n return self.event_constructor(parent=self, subject=subject)", "def add_event(self, event):\r\n ...
[ "0.76387453", "0.7066055", "0.7061383", "0.6994105", "0.69634664", "0.67789704", "0.67600316", "0.675919", "0.6746592", "0.6685822", "0.66261363", "0.6548796", "0.6519028", "0.64953583", "0.6487255", "0.6453388", "0.6417329", "0.6315655", "0.625218", "0.6226371", "0.6163615",...
0.72256994
1
Parse self["data"] into a list of arguments using
def arguments(self): return parse_arguments(self['data'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataargs(self):\n return self.argsbytype(Data)", "def _get_data(data, *args):\n args = list(args)\n for i, arg in enumerate(args):\n if isinstance(arg, str):\n try:\n array = data[arg]\n except KeyError:\n pass\n else:\n ...
[ "0.69571596", "0.6678059", "0.64262795", "0.63850576", "0.6377891", "0.6344651", "0.63404816", "0.6304164", "0.6209068", "0.6185096", "0.6158283", "0.6117261", "0.6110096", "0.61075896", "0.61063814", "0.60817206", "0.6040554", "0.6037762", "0.60048777", "0.6003468", "0.59970...
0.80011284
0
Submitted value, or field value converted to string. Return value is always either None or a string.
def value(self): v = None if not self.field.is_readonly() and self.params is not None: # submitted value. do not deserialize here since that requires # valid data, which we might not have try: v = self._serialized_value() except for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(self, value):\n return six.text_type(value) if value is not None else None", "def string(self, value):\n # respect {None}\n if value is None:\n # by leaving it alone\n return None\n # my value knows\n return str(value)", "def get_prep_value(s...
[ "0.73051864", "0.6908195", "0.68916774", "0.6865482", "0.67856824", "0.666047", "0.6604883", "0.654142", "0.65066075", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", "0.6481636", ...
0.7549297
0
Builds deck for a player, up to an initial amount of 28, then the deck is shuffled. Player HP is also set.
def buildDeck(self, resources): for key,value in resources.deckData.items(): self.deck.append(resources.cards[value[self.playerClass]]) random.shuffle(self.deck) self.HP = self.getHP() # Set HP
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deal(self, num_cards=7):\n self.deck.shuffle()\n for player in self.players:\n for i in range(num_cards):\n self.hands[player].append(self.deck.draw())", "def shuffle_deck(self):\n deck = [i for i in range(0, 52)]\n shuffle(deck)\n self.deck = [car...
[ "0.6741587", "0.6563657", "0.64864135", "0.6475658", "0.6411751", "0.6405804", "0.6396871", "0.6348072", "0.6344112", "0.63338083", "0.6302131", "0.6275488", "0.62533754", "0.62221074", "0.6218451", "0.62025386", "0.61736405", "0.60988444", "0.60585016", "0.6055875", "0.60481...
0.7007146
0
Player draws up to 6 cards. If one player has their deck size (HP) reach zero, the party returns the bonfire to rest. Returns None.
def draw(self): while len(self.hand) < 6: # While player doesn't have 6 cards in hand if self.HP == 0: print("You died.") break else: self.hand.append(self.deck.pop(0)) # Draw from their deck self.HP = self.getHP() # Update ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_for_dealer(self):\n while self.dealer.sum_cards() < 17:\n self.dealer.hit(self.deck)\n else:\n self.round_winner = True\n self.print_hands()\n self.determine_winner()", "def deal(self):\n self.dealer.hit(self.deck)\n self.dealer.hit...
[ "0.6820574", "0.6675827", "0.6639533", "0.6582552", "0.65190935", "0.64521515", "0.64255106", "0.63192964", "0.6313044", "0.623093", "0.62305516", "0.6229016", "0.62131596", "0.62110484", "0.61697", "0.6148618", "0.6126031", "0.6123875", "0.612196", "0.6086727", "0.60738724",...
0.7461767
0
Takes the player choice for blocking enemy attack and returns stamina cards used in tribute, discards those cards, and calculates damage to HP.
def blockOption(self, equipChoice, optionChoice, enemy): selectedCard = self.handLookup[equipChoice] # Chosen equipment cost = selectedCard.choices[optionChoice-1]["cost"] # Get choice cost of chosen equipment _, _, tributed = self.tribute(cost,self.getStaminas()) # Get stamina ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attack(self): # need to check defenders handcount\n \"\"\"Always returns a list of values\"\"\"\n if self.AI:\n # return rand.randint(0,len(self.currentHand))\n Error(\"AI not yet implemented for Attacking\")\n else:\n print(\"Select card from... \")\n ...
[ "0.6801302", "0.62297225", "0.61685", "0.60756403", "0.5966792", "0.5926669", "0.5905519", "0.5888406", "0.58872026", "0.5871714", "0.58653486", "0.58496016", "0.5837962", "0.58232135", "0.57980007", "0.5777925", "0.5733257", "0.57151943", "0.5698213", "0.56847453", "0.567770...
0.69556713
0
This method is called by the fitmethod of the Study class (and the step method of the OnlineStudy class) and processes multidimensional data and missing data and passes it to the pdfmethod of the child class.
def processedPdf(self, grid, dataSegment): # if self.multipyLikelihoods == True, multi-dimensional data is processed one dimension at a time; # likelihoods are then multiplied if len(dataSegment.shape) == 2 and self.multiplyLikelihoods: return np.prod(np.array([self.processedPdf(grid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(self):\n\n log.info(\"Feature Engineering of pred_analys_record_personal_access data of school: \" + self.school_kind.value)\n log.debug(\"QuadrimestersFeatureEngineering.process()\")\n\n global pr_plan_subject_call, pr_scholarship_per_year\n\n analys_record_personal_access ...
[ "0.59602", "0.59289175", "0.5915554", "0.5790265", "0.575495", "0.57407445", "0.56456745", "0.56024194", "0.55994195", "0.5537111", "0.55345386", "0.5516686", "0.5507349", "0.5505056", "0.547796", "0.546884", "0.54688334", "0.5463802", "0.5457776", "0.5454287", "0.5454287", ...
0.61073893
0
Recursively breaks a field name down into parts and explains each piece. If you're having trouble with this method after adding new fields, you'll need to modify explanations{} to have longer prefixes, or modify this algorithm so that it doesn't shortcut down a dead end.
def explain(field_name, explained_parts=None): if explained_parts is None: # It's import you don't initialize this in the signature, it side-effects the result since [] is mutable explained_parts = [] if not field_name: return ' '.join(explained_parts) if field_name in explanations.keys():...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getFieldDescr(fieldName, descr):\n i = getIter(descr)\n if not i:\n return\n\n try:\n sw = ''\n item = i.next()\n while item:\n if fieldName == item[0]:\n yield item\n break\n if isinstance(item[1], list):\n ...
[ "0.600366", "0.58492136", "0.5713403", "0.5536898", "0.5404048", "0.5352846", "0.5304695", "0.5208051", "0.5127929", "0.5127686", "0.5087193", "0.50792104", "0.50773495", "0.50728786", "0.50624657", "0.504394", "0.5038912", "0.50262856", "0.50262856", "0.49511275", "0.4943381...
0.7475187
0
Returns the string representation of geoWithin Predicate
def toString(self): return "geoWithin"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def geoWithin(self, value):\n\n withinP = P(self.toString(), value)\n\n return withinP", "def _geography_query(self, kwargs):\n out = \"\"\n zipcode = _make_list(kwargs.pop(\"zipcode\", []))\n state = _make_list(kwargs.pop(\"state\", []))\n\n if len(zipcode) == 0:\n ...
[ "0.66554356", "0.59498376", "0.5864763", "0.574556", "0.5736718", "0.5608447", "0.5546443", "0.53091973", "0.5187631", "0.5168707", "0.51492494", "0.5138175", "0.51245826", "0.5104673", "0.5083362", "0.50477594", "0.50404865", "0.49990416", "0.4997174", "0.49612996", "0.49598...
0.8116409
0
Calls the Gremlin Python's P serializer to query based on geoWithin predicate.
def geoWithin(self, value): withinP = P(self.toString(), value) return withinP
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toString(self):\n return \"geoWithin\"", "def _geography_query(self, kwargs):\n out = \"\"\n zipcode = _make_list(kwargs.pop(\"zipcode\", []))\n state = _make_list(kwargs.pop(\"state\", []))\n\n if len(zipcode) == 0:\n if len(state) == 0:\n m = \"B...
[ "0.6045918", "0.58803606", "0.57122064", "0.5432058", "0.5380709", "0.5359083", "0.53562033", "0.5280021", "0.5237334", "0.52000767", "0.51730746", "0.5148021", "0.5127227", "0.50954694", "0.5058732", "0.5042963", "0.50306225", "0.50011295", "0.49822965", "0.4964808", "0.4931...
0.67113745
0
Returns the number of turns
def get_turn_count(self): return self.turns.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queryNumberOfTurns(self):\n return self._readInt('How many turns are allowed', 1, 20)", "def count_turns(spline):\n func = spline(spline._data[0])\n turns = sum(abs(diff(sign(diff(func))))) / 2\n return turns", "def number_moves(game, player):\n return float(len(game.get_legal_moves(player))...
[ "0.78999853", "0.7248229", "0.7198308", "0.7175771", "0.71716595", "0.70344955", "0.7021542", "0.68060476", "0.6778092", "0.6643127", "0.6598187", "0.658766", "0.6572543", "0.655296", "0.6548049", "0.65468264", "0.654489", "0.65307075", "0.6517666", "0.64986134", "0.6475051",...
0.8442857
0
Returns the current turn object
def get_current_turn(self): return self.turns.latest('number')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_turn(self):\n return self._turn", "def get_turn(self):\n return self._turn", "def get_turn(self):\n return self.__turn_info['turn']", "def turn(self):\n return self._turn", "def _get_turn(self):\n raise NotImplementedError", "def take_turn(self):\n ...
[ "0.81394243", "0.78229415", "0.7649427", "0.7611649", "0.75193805", "0.7093884", "0.68818766", "0.6854612", "0.68373203", "0.6784732", "0.6764563", "0.6762484", "0.65933603", "0.65624225", "0.6416349", "0.6409199", "0.63828576", "0.63617027", "0.6352374", "0.6344493", "0.6235...
0.81231004
1
Returns the profile of player with number number
def get_player(self, number): num = int(number) assert (num in [1, 2]) return self.player_1 if num == 1 else self.player_2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_profile(self, season, player):\n try:\n try:\n player = int(player)\n except ValueError:\n player = player.lower()\n player_list = season.get_season_data()[\"proPlayers\"]\n for p in player_list:\n if p[\"id\"]...
[ "0.73623365", "0.63989824", "0.6339155", "0.63131523", "0.6261965", "0.6076653", "0.60517156", "0.602942", "0.6025451", "0.6021757", "0.6000625", "0.59968203", "0.5976823", "0.59533954", "0.59464854", "0.59027654", "0.58847964", "0.58822036", "0.58598495", "0.58583844", "0.58...
0.72105163
1
Spend a list of resources times a quantity
def spend_resources(self, costs, quantity, commit=False): for cost in costs: resource_state, _ = ResourceState.objects.get_or_create(state=self, resource=cost.resource) resource_state.quantity -= cost.amount * quantity resource_state.clean() if commit: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _tattle_quantity(resource, quantity, resourcesalloweddict, resourcesuseddict):\n\n\n # I assume that the quantity will never be negative\n if quantity < 0:\n # This will cause the program to exit and log things if logging is\n # enabled. -Brent\n tracebackrepy.handle_internalerror(\"Resource '\" + r...
[ "0.7007656", "0.62894166", "0.607634", "0.58854413", "0.5831086", "0.5826854", "0.58267397", "0.5728178", "0.5661012", "0.5641281", "0.5628317", "0.559935", "0.55952686", "0.5518467", "0.5454475", "0.5439002", "0.54094326", "0.53723085", "0.53654456", "0.5351171", "0.53347737...
0.6944909
1
Syncs the two game states territory states
def sync_territories(self): for territory_state in self.territory.all(): territory_state.sync()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_to_state(self, game_state):\n pass", "def sync(self):\r\n\r\n # Ensure to rerun only once to avoid infinite loops\r\n # caused by a constantly changing state value at each run.\r\n #\r\n # Example: state.value += 1\r\n if self._state[\"is_rerun\"]:\r\n ...
[ "0.62418735", "0.613196", "0.60901403", "0.6071716", "0.6071286", "0.6043107", "0.6039186", "0.6004152", "0.59452325", "0.5843397", "0.57821834", "0.5779569", "0.57712054", "0.57594866", "0.5722311", "0.5716433", "0.565815", "0.56492245", "0.5639808", "0.5601062", "0.5586798"...
0.6725441
0
Checks to see if territory is in the list of valid moves
def validate_invasion(self, player, territory): current_territory = [ts.territory for ts in self.territory.filter(player=player)] valid_coordinates = [] for t in current_territory: valid_coordinates += t.get_valid_moves() valid_moves = [territory.arena.get_by_coordinates(coor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _valid_move_exists(self):\n lst = []\n for i_row in range(self._num_rows):\n for i_col in range(self._num_cols):\n if self._valid_placement(i_row, i_col)[0]:\n lst.append((i_row, i_col))\n\n return lst != [] #If lst != [], then the list has ele...
[ "0.7332985", "0.6881685", "0.68751353", "0.6783665", "0.6695776", "0.66830444", "0.6670404", "0.6632804", "0.6620421", "0.6592103", "0.65920484", "0.655748", "0.6539025", "0.6517217", "0.6486003", "0.64778334", "0.64716", "0.6465377", "0.64507514", "0.6432437", "0.64253485", ...
0.7932066
0
Run resolve on all non aggressor conflicts
def resolve_conflicts(self, commit=True): pass # pragma: no cover
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self):\n pass # pragma: no cover", "def cannot_resolve ( self, *deps, **kw ):\n return self._do_resolve_weak_greedy ( deps, kw, greedy=True ) is None", "def _resolve(self):\n pass", "def refine_conflict(self):\n self._raise_not_supported()", "def resolve(self):\n ...
[ "0.649119", "0.64645964", "0.6330911", "0.61206424", "0.61193615", "0.5969999", "0.5926146", "0.59256685", "0.58660144", "0.58282864", "0.58218884", "0.5761563", "0.57612854", "0.5757742", "0.5737829", "0.56250614", "0.56009394", "0.5558108", "0.5533665", "0.55117965", "0.551...
0.7163751
0
Applies a turn to the current game state. If validate is false, the changes will actually apply.
def apply_turn(self, turn, commit=False): for move in turn.moves.all(): if move.action.name == "Refine": try: resource = Resource.objects.get(name=move.object) except ObjectDoesNotExist: raise ValidationError('invalid resource n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply(self, gameState):\n pass", "def doTurn(self, gamestate):\n raise NotImplementedError(\"Please Implement this method\")", "def on_turn(self, turn_state):\n game_state = gamelib.GameState(self.config, turn_state)\n gamelib.debug_write('Performing turn {} of your custom algo ...
[ "0.62988377", "0.6104162", "0.5727057", "0.56437874", "0.5579283", "0.5559477", "0.55152905", "0.54980105", "0.5470038", "0.54695195", "0.5461002", "0.5459019", "0.53441286", "0.5333498", "0.5322068", "0.52924395", "0.5278224", "0.5273518", "0.52611625", "0.525438", "0.522579...
0.63033277
0
Visualize generator outputs during training.
def visualize_training_generator(train_step_num, start_time, data_np): print('Training step: %i' % train_step_num) time_since_start = (time.time() - start_time) / 60.0 print('Time since start: %f m' % time_since_start) print('Steps per min: %f' % (train_step_num / time_since_start)) plt.axis('off') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summarize(self):\n info(\"Running \" + self.title + \" generator\")", "def visualize_input_batch(input_gen):\n # Get a batch from the generator\n batch_inputs, batch_targets = input_gen[0]\n\n plt_num = 1\n for specgram in batch_inputs:\n plt.subplot(4, 8, plt_num)\n plt.pcol...
[ "0.6684696", "0.6677125", "0.65397733", "0.644812", "0.6431353", "0.6366485", "0.631945", "0.625001", "0.6122771", "0.6086541", "0.6056006", "0.6014803", "0.6014631", "0.60081434", "0.5982955", "0.59719384", "0.5969197", "0.593211", "0.5920369", "0.5908951", "0.5868416", "0...
0.7401334
1
Replaces ['edges']['node'][key].... LIST DICT With a list of dictionaries.
def unedgify(edgy_node): if isinstance(edgy_node, dict): if 'edges' in edgy_node: edgy_node = edgy_node['edges'] index = 0 while index < len(edgy_node): if isinstance(edgy_node[index], dict) and\ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alter_request_edges(self, jdata):\n if isinstance(jdata, list):\n for entry in jdata:\n self._alter_request_edges(entry)\n if isinstance(jdata, dict):\n for key in jdata:\n if key == \"edges\":\n ed...
[ "0.6582003", "0.6121654", "0.61054724", "0.60526276", "0.5965597", "0.58205706", "0.5722239", "0.5563796", "0.55238426", "0.5506362", "0.5503895", "0.5487864", "0.54789925", "0.5447871", "0.5440131", "0.5433833", "0.53522164", "0.53177744", "0.5297655", "0.52762824", "0.52558...
0.6330603
1
Flatten json reply, starting at root, down to stopkey, skipping edges and node key. Each key is named with the levels traversed prepended (each named level seperated by the seperator parameter..
def _flatten_json(node, stop_prefix, seperator='/', prefix='/', depth=0): node_list = [] field_dict = {} # print(f"{' ' * depth}>>> {prefix}") node_type = type(node) if node_type == list: for entry in node: sub_list, sub_fields = _flat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_reply_fields(self): \n def alter_request_edges(self, jdata):\n \"\"\"\n From the jsonified request template, converts\n \"edges\" : { \"node\" : { \"key1\" : value1, ... } }\n to something resembling a reply message body:\n \"edges\" :...
[ "0.57246554", "0.56630063", "0.5519827", "0.54915553", "0.5363287", "0.53452796", "0.5301155", "0.5234358", "0.5230756", "0.52139026", "0.51935834", "0.5151927", "0.5140372", "0.51388234", "0.5130907", "0.5125722", "0.5070616", "0.50508225", "0.501891", "0.501222", "0.5011708...
0.72282904
0
Overrides parent json_reply should be a list, even if only one item is expected to be returned. This eases dict versus list confusion at the cost of doing only_entry = list[0]. NewGQL.single_entry_to_dict can be used to work around this...
def send_query(self, rt, json_reply, errors=None): #assert isinstance(json_reply, list) json_data = {} status_code = super().send_query(rt, json_data, errors) #assert False, "NewGQL:lumpy: " + pprint.pformat(json_data) if not errors is None and len(errors) > 0 and len(j...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json(self) -> Dict[str, Union[List, Dict, str, int, float]]:", "def send_query(self, rt, json_reply, errors=None):\n json_data = {}\n status_code = super().send_query(rt, json_data, errors)\n if not errors is None and len(errors) > 0 and len(json_data) == 0:\n if self.debug:\n...
[ "0.5709016", "0.5585073", "0.5562244", "0.54932714", "0.5428954", "0.5278154", "0.52647865", "0.5218151", "0.52132314", "0.5192519", "0.51023906", "0.5065698", "0.50417995", "0.5033844", "0.501986", "0.5014751", "0.4994871", "0.4975139", "0.4968441", "0.49481666", "0.49329504...
0.59781104
0
Renders previously loaded template using provided variables and checks the output for any remaining unpopulated variables. If template is fully populated, then the string is returned; otherwise None is returned If None is passed for 'variables', the variables (if any) passed to the constructor are used
def render_template(self, variables=None): if self._template is None: return None if variables is None: variables = self._variables if variables is None: return None rendered = self._template.render(variables) lines = rendered.splitlines() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self, template: str, **vars) -> str:", "def render(template, variables={}):\r\n\treturn prettify( parse(template).render(dict(variables.items())) )", "def render(self, variables):\n variables = variables or {}\n try:\n rendered = render_template(self.template, variables)\n ...
[ "0.71185875", "0.69990546", "0.69178617", "0.68848175", "0.66923153", "0.6503275", "0.6360033", "0.6249965", "0.62209004", "0.6162319", "0.61391014", "0.6134411", "0.6086305", "0.6061894", "0.6059795", "0.5991738", "0.5980039", "0.59705883", "0.5961944", "0.595867", "0.585882...
0.7931702
0
gets all songs in the database
def get_all_songs(self): to_send = self.db.get_all_songs() to_send = '$'.join(to_send) self.send_message(to_send)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_songs():\r\n return [Song.song_json(song) for song in Song.query.all()]", "def get_all_songs() -> Generator[dict, None, None]:\n\n logging.debug(\"Fetching from server\")\n\n api = _get_api()\n\n for song_page in api.get_all_songs(incremental=True):\n for song in song_page:\n ...
[ "0.83335763", "0.76143295", "0.7583582", "0.75702846", "0.733306", "0.72895616", "0.7025953", "0.68873256", "0.6813044", "0.6768362", "0.6753794", "0.6689431", "0.66821235", "0.664009", "0.65769887", "0.6503209", "0.6482488", "0.6467034", "0.6399742", "0.63967174", "0.6365747...
0.78697675
1
gets a ll songs in a certain playlist
def get_all_songs_in_pl(self, playlist): to_send = self.db.get_songs(playlist) to_send = DOLLAR.join(to_send) self.send_message(to_send)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_playlist(self, part=\"snippet\", max_results=7, playlist_id=\"\", playlist_url=\"\"):\n\n url = self.url_api.get_playlist_url(playlist_id, part, max_results, playlist_url)\n\n response = await self.session.get(url)\n search_results = await response.json()\n return search_r...
[ "0.7005062", "0.6855771", "0.68111265", "0.678139", "0.6765325", "0.6729876", "0.66993207", "0.66967416", "0.66881865", "0.6678532", "0.6606882", "0.66016716", "0.6589963", "0.65839064", "0.6580221", "0.6523943", "0.6460416", "0.6455791", "0.64556265", "0.64472276", "0.643927...
0.7167852
0
makes sure the database holds only all the songs that are saved on the server
def update_db(self): songs = self.db.get_all_songs() for song in songs: if choose_song(song) == ERROR: self.db.delete_song(song) files = [] for song in glob.glob("songs\*.wav"): to_append = song.split('\\')[ONE][:-4] files.append(to_app...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_lyrics_and_song_data_to_database(artist, song):\n if exists('song_database.txt'):\n f = open('song_database.txt', 'r+')\n song_list = pickle.load(f)\n current_entry = Song_data(artist, song)\n if current_entry.id in [previous_entry.id for previous_entry in song_list]:\n ...
[ "0.67025226", "0.6479613", "0.6242768", "0.61535203", "0.6138302", "0.61283684", "0.6106789", "0.6097679", "0.60542685", "0.6041125", "0.5993153", "0.5944019", "0.5907425", "0.58730775", "0.5856106", "0.58265555", "0.5781104", "0.5781104", "0.5748337", "0.5746634", "0.5742373...
0.7584374
0
sends the data from a song file chosen by the pick song method manages skips and pauses
def stream_song(self, path, e): if path == ERROR: self.send_streaming_message(INVALID_REQ) return # sends metadata sample_rate, channels, my_format = get_metadata(path) to_send = sample_rate + DOLLAR + channels + DOLLAR + my_format skip_amount = get_byte_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_music(self):\n song_index = -1\n if self.num_songs == 0:\n sys.stdout.write(\"No songs found\\n\")\n sys.exit(0)\n \n # FIXME: spacebar/pause is an mplayer-specific command\n sys.stdout.write(\"Press spacebar to pause songs\\n\")\n sys.stdou...
[ "0.63670707", "0.6213236", "0.61902916", "0.6176572", "0.616231", "0.6063421", "0.59786844", "0.59717894", "0.58996093", "0.58812207", "0.58651114", "0.5827203", "0.5821394", "0.57919437", "0.577601", "0.57699543", "0.574729", "0.5700667", "0.56969917", "0.56618667", "0.56551...
0.63651294
1
receives a message from the client on the streaming socket
def receive_streaming_msg(self): size, client_streaming_address = self.server_socket_streaming.recvfrom( HEADER_SIZE) data, client_streaming_address = self.server_socket_streaming.recvfrom( int(size)) data = data.decode() data = data.split(DOLLAR) self.cli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive(self, message):", "def receive_message(datagram, connection):", "def receive_message(self, message):", "def s_recv(self, *args):\n # size = 1024\n\n self.client_socket.recv(1024).decode()\n try:\n message = self.client_socket.recv(size).decode()\n return...
[ "0.73116195", "0.72673017", "0.72066325", "0.71862984", "0.7133554", "0.71286106", "0.7056134", "0.7043954", "0.7022612", "0.69718623", "0.6953962", "0.69407356", "0.6939204", "0.6925608", "0.6892592", "0.6891527", "0.6880756", "0.6806273", "0.67571265", "0.6731784", "0.67308...
0.73815745
0
sends a message to the client on the streaming socket
def send_streaming_message(self, data): header, data = format_msg(data) self.server_socket_streaming.sendto(header, self.client_streaming_address) self.server_socket_streaming.sendto(data, self.client_streami...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send(msg): # event is passed by binders.\n # print(\"i sended: \" + msg)\n msg = msg + \";\"\n client_socket.send(bytes(msg, \"utf8\"))", "def _send(self, message):\n self.sock.sendall('%s\\n' % message)", "def send(self, message):\n self.sock.send(message)", "def send_message(sel...
[ "0.76693493", "0.7532365", "0.75213253", "0.7510763", "0.733329", "0.7325135", "0.71832246", "0.7170515", "0.7036858", "0.6963489", "0.6923069", "0.6912909", "0.69025975", "0.68995726", "0.68943626", "0.68779916", "0.68776894", "0.6876777", "0.6876777", "0.6859493", "0.684827...
0.76085424
1
handles the streaming socket
def handle_stream_client(self, event): try: while True: client_req = self.receive_streaming_msg() self.choose_action(client_req[ZERO], client_req[ONE:], event) except socket.error as e: print('stream', e)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_do(self,input, connstream):\r\n pass", "def onRecv(self, data):\n self.stream += data\n while self.handleStream(): pass", "def try_connection_streaming():\n global streaming\n global s\n\n while 1:\n if not streaming:\n s = socket.socket(socket.AF_INET...
[ "0.72525764", "0.6975537", "0.6767934", "0.670281", "0.6686921", "0.6684621", "0.653186", "0.6504173", "0.64962226", "0.64932156", "0.643082", "0.63829136", "0.6364212", "0.6335096", "0.63101", "0.6306359", "0.63042086", "0.62866133", "0.6269818", "0.6238305", "0.6228382", ...
0.7301505
0
checks if a song is valid
def song_check(song): msg = choose_song(song) return msg != ERROR
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_song(song):\n attrs = [\"default_arrangement\", \"composer\", \"copyright\", \"youtube\", \"ccli\"]\n for a in attrs:\n if getattr(song, a) in [None, \"None\"]:\n setattr(song, a, \"\")\n return song", "def dict_is_song(info_dict):\n if \"full album\" in info_dict[\"tit...
[ "0.6768272", "0.67256397", "0.63133204", "0.6208941", "0.6187303", "0.61763865", "0.6057333", "0.6021721", "0.5955062", "0.59522796", "0.59170073", "0.58977324", "0.588956", "0.5871845", "0.58559376", "0.58466023", "0.58416474", "0.58130026", "0.58010113", "0.57467175", "0.57...
0.76571316
0
chooses the file of the requested song and checks if its valid
def choose_song(my_name): my_name = my_name.split(ET)[ZERO] path = '' for filename in os.listdir(str(Path.cwd()) + '/songs'): name = filename.split('\\')[-1] name = name.split('.')[ZERO] name = name.split(ET)[ZERO] if filename.endswith(".wav") and my_name == name: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_song(self):\r\n path = input(\"Give file path:\\t\") # Request file path\r\n path = path.replace('\\\\', '/')\r\n if self.path_song_re.match(path) and not self.path_storage_re.match(\r\n path): # Check that the path leads to a song that is not already found in Storage\...
[ "0.6678291", "0.64492947", "0.6440768", "0.6266978", "0.6173423", "0.5964455", "0.5962769", "0.59265965", "0.58712107", "0.58399254", "0.5804429", "0.580124", "0.57960665", "0.5666136", "0.56573963", "0.5655825", "0.5647215", "0.5641787", "0.56244606", "0.5610763", "0.5595705...
0.6747894
0
Sets the two strings as self attributes
def __init__(self, string1, string2): self.s1 = string1 self.s2 = string2 return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign(self, *args):\n return _libsbml.string_assign(self, *args)", "def setString(self, name: unicode, value: unicode) -> None:\n ...", "def __setitem__(self, *args):\n return _libsbml.string___setitem__(self, *args)", "def __init__(self, character_1, character_2):\n self.cha...
[ "0.68755347", "0.64528203", "0.63047785", "0.6177934", "0.6091614", "0.60072654", "0.6002702", "0.57791895", "0.5748481", "0.5733964", "0.5710848", "0.56949204", "0.5691965", "0.5641852", "0.5637632", "0.55759424", "0.5549072", "0.5542582", "0.5541545", "0.55246353", "0.55246...
0.73090506
0
This function builds upon the initialized NW matrix and scores the remaining cells based on a scoring function defined below. Match +1 Mismatch 1 Insertion/Deletion 1
def needleman_wunsch_fill(self): matrix = self.init_needleman_wunsch_matrix() # Building on the previous definition def score_cell(i,j): """ This is our first example of a nested definition. This scoreing definition will return the score of a position (i, j) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_evaluate(board):\n\n #Logic for new_evaluate function:\n #1)Traverse through each of the columns\n #2)For each of the columns, find the top most element.\n\t #If the topmost element = Current Player\n\t\t \t#3)Find the possible number of continuous elements of the same type in all the 4 dire...
[ "0.61598885", "0.6152146", "0.6105311", "0.60020965", "0.5953582", "0.5924587", "0.58886313", "0.58205605", "0.58086807", "0.5807978", "0.5691563", "0.5676771", "0.5628673", "0.562708", "0.559512", "0.5576646", "0.5575047", "0.55559814", "0.55497605", "0.5539092", "0.552056",...
0.62432593
0
Fills in a matrix using the SmithWaterman Algorithm. This algorithm builds upon an empty matrix from self.empty_matrix() Match +3 Mismatch 3 Insertion/Deletion 2
def smith_waterman_fill(self): matrix = self.empty_matrix() # Building on the previous definition def score_cell(i,j): """ This scoreing definition will return the score of a position (i, j) based on the left, upper, and upper left values. Your s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fill_matrix(self):\n\n print(\"Creating Needleman-Wunsch matrix..\")\n\n for i in range(self.matrix.shape[0]):\n for j in range(self.matrix.shape[1]):\n\n if i < len(self.seq_2) and j < len(self.seq_1):\n self.matrix[0, i + 2] = self.seq_2[i]\n ...
[ "0.6857754", "0.65306705", "0.61515105", "0.6121789", "0.5995892", "0.5769913", "0.5764404", "0.5726386", "0.56596535", "0.56553143", "0.5633248", "0.5588313", "0.5581182", "0.55666405", "0.5564708", "0.5529368", "0.5505706", "0.5503179", "0.55016387", "0.5478611", "0.5467572...
0.7673634
0
Checks a string using list comprehension for any unallowed characters (DNA can only contain C, T, A, and G) and returns True if it only contains those 4 characters, and False otherwise
def is_dna(string): DNA = ['A','T','G','C'] return False if False in [ str in DNA for str in string] else True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_dna(s):\n import re\n return re.match(\"^[ctga]*$\", s.lower()) is not None", "def is_valid_sequence(dna):\n num_char = 0\n \n for char in dna:\n if not char in 'ATCG':\n num_char += 1\n\n return num_char == 0", "def is_valid_sequence(dna):\n \n nucleotide...
[ "0.71171063", "0.7057893", "0.7023524", "0.69977343", "0.6948012", "0.6924203", "0.6900828", "0.688649", "0.6771554", "0.676768", "0.6742306", "0.6742306", "0.6727338", "0.6723598", "0.6641118", "0.66375893", "0.6611652", "0.6584004", "0.6557327", "0.65256286", "0.65249205", ...
0.7165868
0
The Sequence Read Archive (SRA) is the worlds largest database of raw sequencing data. This definition takes in the run_id of one dataset and downloads the xml metadata from the URL below.
def get_sra_xml(sra_run_id): url = "http://www.ncbi.nlm.nih.gov/Traces/sra/?run={}&experimental=1&retmode=xml".format(sra_run_id) return ur.urlopen(url).read().decode()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_SRA(SRA):\n\n print(\"Downloading SRA archive\")\n output = subprocess.run(['prefetch', '-f', 'yes', SRA], stderr=subprocess.STDOUT)\n\n print(\"Extracting FASTQ data\")\n output = subprocess.run(['fastq-dump', '--gzip', NCBI_DIR+SRA+'.sra'], stderr=subprocess.STDOUT)", "def download_scn...
[ "0.6630981", "0.56077945", "0.52005404", "0.5048312", "0.5038356", "0.5000408", "0.494224", "0.4939431", "0.49187613", "0.48845223", "0.48750106", "0.48395583", "0.48338595", "0.4805425", "0.4793083", "0.47892526", "0.47866112", "0.47768515", "0.4767941", "0.4751645", "0.4741...
0.6490357
1
Using the string returned from get_sra_xml(), finds the file size of the sra run (it is in bytes), convert it to gigabytes and returns it as a float.
def get_filesize(string): string = get_sra_xml('SRR3403834') pattern = re.compile(r'size.*?([0-9.-]+)') size = re.search(pattern,string) return float(size.group(1))/(10**9)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str2gib_size(s):\n size_in_bytes = str2size(s)\n return size_in_bytes // units.Gi", "def get_gsize(self):\n gsize_file = Genome(self.genome).get_fasize()\n gsize = 0\n with open(gsize_file, 'rt') as fi:\n for a in fi:\n c, n = a.strip().split('\\t')\n ...
[ "0.66322345", "0.6489912", "0.629065", "0.61724347", "0.6036596", "0.60259104", "0.5836922", "0.5834286", "0.5794334", "0.5732803", "0.5726563", "0.5719832", "0.57184273", "0.57104427", "0.5626326", "0.56160927", "0.56136477", "0.56062245", "0.5592328", "0.5562631", "0.555219...
0.7624412
0
Uniprot is a database of protein sequence data. Given the uniprot_id of a protein, and using urllib, return only the sequence (not the header) from the fasta entry. Be sure to remove new line characters from the protein sequence.
def get_protein_fasta(uniprot_id): url = "http://www.uniprot.org/uniprot/{}.fasta".format(uniprot_id) string = re.split("\n",ur.urlopen(url).read().decode(),1)[1] return re.sub("\n","",string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _query_uniprot(self):\n import requests\n import json\n\n response = requests.get(f\"https://www.ebi.ac.uk/proteins/api/proteins/{self.uniprot_id}\")\n if response.status_code != 200:\n raise ValueError(f\"Failed to fetch sequence for UniProt ID {self.uniprot_id}\")\n\n ...
[ "0.6770931", "0.6744979", "0.6308878", "0.6264417", "0.6226714", "0.6125985", "0.603721", "0.6001783", "0.5898801", "0.5793773", "0.57380795", "0.55711734", "0.5540643", "0.5459736", "0.543617", "0.542267", "0.54091847", "0.5408769", "0.5404713", "0.5403443", "0.53986025", ...
0.80296135
0
Handle /admin BOTNAME groups.
def admin(frame): ctx, msg, modconf = frame.ctx, frame.msg, frame.value text = frame.text if text.startswith('remove '): text = text[len('remove '):] group = modconf['groups'].pop(text) if group: msg.add('Removed <b>%s</b>.', group['name']) else: msg....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin_group_name(self):\n return self.short_name+\"_admins\"", "def _do_group(self, req):\n # process forms/commands\n message=''\n args={}\n if req.method == 'POST':\n group = req.args.get('group')\n user = req.args.get('user')\n if req.arg...
[ "0.6137315", "0.5829673", "0.57322437", "0.5643985", "0.5643664", "0.5582239", "0.55163443", "0.55132663", "0.55008686", "0.5491486", "0.547285", "0.54273677", "0.53894246", "0.53679776", "0.5336848", "0.5309741", "0.53069013", "0.52996963", "0.5266148", "0.52576065", "0.5239...
0.6020039
1
Try to convert an invite link to a normalized group info dict.
def get_private_group(invite_link): info = fetch_opengraph(invite_link) if not info.get('title'): return return { 'desc': info['description'], 'id': '', 'invite_link': invite_link, 'location': '', 'name': info['title'], 'type': '', 'username'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_groups(self):\n url = \"https://m.facebook.com/groups/?seemore\"\n groups = dict()\n self.get(url)\n br = self.find_elements_by_class_name(\"br\")\n for b in br:\n try:\n notis = int(b.text[-2:])\n group_name = b.text[:-2]\n ...
[ "0.517901", "0.513678", "0.48270226", "0.48230493", "0.48119035", "0.477078", "0.4739038", "0.47067904", "0.4694599", "0.46744752", "0.4612216", "0.45921275", "0.45904633", "0.45676985", "0.4557188", "0.4533524", "0.45222214", "0.45121306", "0.44993135", "0.44971037", "0.4456...
0.6614859
0
.dispose() method has to be overwritten
def dispose(self) -> None:
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispose(self):", "def dispose(self):\n \n pass", "def dispose(self):\n \n pass", "def dispose(self):\n \n pass", "def dispose(self) -> None:\n ...", "def dispose(self) -> None:\n ...", "def __del__(self):\r\n Phidget.dispose(self)", "def close(se...
[ "0.8699241", "0.85070086", "0.85070086", "0.85070086", "0.8479358", "0.8479358", "0.74748003", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.74172395", "0.73475516", "0.73475516", "0.73398584", ...
0.86383885
1
Gets a list of tweets text from new tweets
def get_all_new_tweets_text(all_new_tweets): all_tweets_text = [] for tweet in all_new_tweets: all_tweets_text.append(tweet["text"]) return all_tweets_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_tweets(self):\n auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)\n auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)\n api = tweepy.API(auth)\n search = api.search(self.term, lang='en', count=100)\n\n print(f\"Getting tweets that mention '{self.term}', \"\n ...
[ "0.80900824", "0.7840294", "0.76366055", "0.76337266", "0.7551472", "0.75239027", "0.7467188", "0.7337158", "0.72931546", "0.72884405", "0.7280429", "0.7237989", "0.72370994", "0.7122122", "0.71130705", "0.7112942", "0.70650834", "0.7064144", "0.6923186", "0.68402296", "0.682...
0.8343693
0
This uses kmeans clustering from sklearn to cluster the text
def cluster_text(list_of_text): print("Clustering text info saved the clustering.txt") vectorizer = TfidfVectorizer(stop_words="english") transform = vectorizer.fit_transform(list_of_text) true_k = 70 model = MiniBatchKMeans(n_clusters=true_k, init="k-means++", max_iter=100, n_init=1) model.fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cluster_texts(self, texts, k=3):\n self.vectorizer = TfidfVectorizer(\n tokenizer=self.tokenize,\n max_features=1500,\n # stop_words=stopwords.words('english'),\n stop_words=stopwords.words('french'),\n max_df=0.7,\n min_df=5,\n ...
[ "0.80755776", "0.78117853", "0.7784393", "0.73356616", "0.7314256", "0.7246182", "0.7165065", "0.7134931", "0.7060133", "0.7049777", "0.70201993", "0.7003604", "0.69499934", "0.69242144", "0.6733776", "0.6726454", "0.6714874", "0.6711142", "0.6685221", "0.66580725", "0.664507...
0.7944314
1
Return a tuple of setting overrides and filter setting overrides.
def overrides(self) -> tuple[dict[str, Any], dict[str, Any]]: settings = {} if self.actions: settings = self.actions.overrides if self.validations: settings |= self.validations.overrides filter_settings = {} if self.extra_fields: filter_settin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overridden_settings(settings):\n\tfor name, defvalue in iter_default_settings():\n\t\tvalue = settings[name]\n\t\tif not isinstance(defvalue, dict) and value != defvalue:\n\t\t\tyield name, value", "def filters(self):\n return {\n 'dict_merge': do_merge,\n 'list_merge': do_list_m...
[ "0.57678306", "0.56968725", "0.5632948", "0.5622094", "0.5546283", "0.55134726", "0.54978704", "0.5462584", "0.54387146", "0.54189605", "0.53607893", "0.5346664", "0.5330304", "0.53215945", "0.5294289", "0.52874136", "0.5234117", "0.5194314", "0.5170891", "0.5122683", "0.5109...
0.7863869
0
Test that all notebooks have a README file and exist in the Notebooks README
def test_readme(): notebooks_readme = Path("notebooks/README.md").read_text() for item in Path("notebooks").iterdir(): if item.is_dir(): # item is a notebook directory notebook_dir = item.relative_to("notebooks") if str(notebook_dir)[0].isdigit(): assert "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_readme():\n notebooks_readme = Path(\"notebooks/README.md\").read_text()\n for item in Path(\"notebooks\").iterdir():\n if item.is_dir():\n # item is a notebook directory\n notebook_dir = item.relative_to(\"notebooks\")\n if str(notebook_dir)[0].isdigit():\n ...
[ "0.84932977", "0.7544229", "0.7391602", "0.7069715", "0.7045903", "0.69971013", "0.69138455", "0.68067497", "0.67855847", "0.6779798", "0.664926", "0.6495415", "0.6486912", "0.6418669", "0.63326275", "0.63236487", "0.62972254", "0.62196004", "0.6173313", "0.6153282", "0.60647...
0.8487342
1
Start NAT/forwarding between Mininet and external network
def startNAT( root, inetIntf='eth0', subnet='10.0/8' ): # Identify the interface connecting to the mininet network localIntf = root.defaultIntf() # Flush any currently active rules root.cmd( 'iptables -F' ) root.cmd( 'iptables -t nat -F' ) # Create default entries for unmatched traffic ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def startNAT( root, inetIntf='eth0', subnet='10.0/8' ):\n\n # Identify the interface connecting to the mininet network\n localIntf = root.defaultIntf()\n\n # Flush any currently active rules\n root.cmd( 'iptables -F' )\n root.cmd( 'iptables -t nat -F' )\n\n # Create default entries for unmatched...
[ "0.77827805", "0.6417874", "0.63306487", "0.62255615", "0.6049808", "0.598135", "0.5978718", "0.59429884", "0.58593285", "0.5847773", "0.5845221", "0.5778126", "0.57734984", "0.57672155", "0.5743469", "0.57392", "0.57132363", "0.56723225", "0.56719965", "0.5645201", "0.563830...
0.7841383
0
Stop NAT/forwarding between Mininet and external network
def stopNAT( root ): # Flush any currently active rules root.cmd( 'iptables -F' ) root.cmd( 'iptables -t nat -F' ) # Instruct the kernel to stop forwarding root.cmd( 'sysctl net.ipv4.ip_forward=0' ) # Restart network-manager root.cmd( 'service network-manager start' )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop_network_nat(self):\n\t\tcmd = [\"/sbin/iptables\",\"-t\",\"nat\",\"-F\"]\n\t\toutput = self.check_output_safe(cmd)\n\t\tself.log.info(\"iptalbes fllushed.\")", "def terminate(self):\n set_sysctl(self, 'net.ipv4.ip_forward', 0)\n set_sysctl(self, 'net.ipv6.conf.all.forwarding', 0)\n ...
[ "0.7397143", "0.6978335", "0.68682563", "0.6578304", "0.6549062", "0.63032037", "0.6155334", "0.6085599", "0.60566014", "0.60209864", "0.5981955", "0.59808886", "0.5976862", "0.59688973", "0.59138983", "0.58977747", "0.58969647", "0.5877942", "0.58264965", "0.5824945", "0.581...
0.8041262
0
Information of a particular city
def get_city_info(g, city_name): flag = 0 for key in g.city_dict: if(g.city_dict[key].get_name() == city_name): print g.city_dict[key].get_info() flag = 1 if(flag == 0): print ("Invalid Input")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def describe_city(city, country='Japan'):\n print(city.title() + \" is in \" + country.title() + \".\")", "def GetCity():\n IPinfoRequest = requests.get('https://ipinfo.io/')\n IPinfo = IPinfoRequest.json()\n City = IPinfo['city']\n return(City)", "def describe_city(city, country='Germany'):\n\t...
[ "0.7865156", "0.7803083", "0.7562243", "0.74817765", "0.73955154", "0.7350799", "0.72346854", "0.72346854", "0.718548", "0.7154424", "0.71036947", "0.71036947", "0.71036947", "0.71036947", "0.71036947", "0.70965576", "0.70949167", "0.7089018", "0.70808816", "0.7074711", "0.69...
0.7887442
0
Distance and endpoints of the shortest flight
def shortest_flight(g): min_distance = sys.maxsize min_destination = None min_key = None for key in g.city_dict: for flight in g.city_dict[key].get_flights_out(): if(flight[1] < min_distance): min_key = key min_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_flight(self):\r\n distance = sys.maxsize\r\n for code, _list in self.edges.items():\r\n for edge in _list:\r\n if edge.distance < distance:\r\n distance = edge.distance\r\n start = edge.start\r\n destinati...
[ "0.80924", "0.7039065", "0.69204646", "0.6892927", "0.685671", "0.6775612", "0.6712751", "0.67004436", "0.66280985", "0.6590464", "0.6513728", "0.64817667", "0.6442849", "0.64342743", "0.6408278", "0.6403769", "0.63956237", "0.6349547", "0.6348799", "0.6346172", "0.62758625",...
0.71584094
1
Calculates city with the most population
def biggest_city(g): max_size = None max_city = None for key in g.city_dict: if(g.city_dict[key].get_population() > max_size): max_size = g.city_dict[key].get_population() max_city = g.city_dict[key].get_name() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def biggest_city(self):\r\n biggest = 0\r\n for code, node in self.vertices.items():\r\n if node.population > biggest:\r\n biggest = node.population\r\n city_code = node.code\r\n name = node.name\r\n return city_code, name, biggest", "d...
[ "0.7939295", "0.7459826", "0.66501385", "0.6581757", "0.6321317", "0.6314292", "0.6286039", "0.612683", "0.60822093", "0.5897155", "0.5845319", "0.58175606", "0.576518", "0.57540154", "0.57485676", "0.5716536", "0.56947905", "0.56902903", "0.5678531", "0.56753916", "0.5675145...
0.8050712
0
Calculates city with the least population
def smallest_city(g): min_size = sys.maxsize min_city = None for key in g.city_dict: if(g.city_dict[key].get_population() < min_size): min_size = g.city_dict[key].get_population() min_city = g.city_dict[key].get_name() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def smallest_city(self):\r\n smallest = sys.maxsize\r\n for code, node in self.vertices.items():\r\n if node.population < smallest:\r\n smallest = node.population\r\n city_code = node.code\r\n name = node.name\r\n return city_code, name, ...
[ "0.7566412", "0.69761807", "0.66607636", "0.6573004", "0.64256054", "0.62284577", "0.6148973", "0.6051773", "0.5951048", "0.58668745", "0.5837032", "0.57403487", "0.5663557", "0.56505865", "0.5614399", "0.56039196", "0.558469", "0.5568027", "0.5567533", "0.5562814", "0.555345...
0.77132154
0
Calculates the average population across all cities
def average_city(g): average = 0 ctr = 0 for key in g.city_dict: average = average + g.city_dict[key].get_population() ctr = ctr + 1 return (average / ctr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_city_size(self):\r\n average = 0\r\n total = 0\r\n for code, node in self.vertices.items():\r\n average += node.population\r\n total += 1\r\n return average // total", "def average_precipitation(city_data: List[Dict[int, float]]) \\\r\n -> Dict...
[ "0.69376004", "0.66798574", "0.61722463", "0.5971917", "0.5949967", "0.58891904", "0.57850957", "0.5760481", "0.57532877", "0.56610864", "0.5604759", "0.56037", "0.5483743", "0.54731727", "0.54726595", "0.5390924", "0.5352103", "0.53166336", "0.53091574", "0.5263747", "0.5257...
0.8493628
0
List of continents and sub cities
def continents(g): continents = [] for key in g.city_dict: if(g.city_dict[key].get_continent() not in continents): continents.append(g.city_dict[key].get_continent()) for continent in continents: print("{}: ").format(continent) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def continents_and_cities(self):\r\n list_all = col.defaultdict(list)\r\n for code, node in self.vertices.items():\r\n list_all[node.continent].append(node.name)\r\n return list_all", "def cities(self) -> Iterable[City]:\n return self._cities.values()", "def cities(self):...
[ "0.7641191", "0.6872682", "0.6840664", "0.6700589", "0.6554303", "0.64212865", "0.6374759", "0.6357035", "0.6239268", "0.6191495", "0.6129705", "0.611577", "0.61056924", "0.6043817", "0.6030427", "0.59857637", "0.59751445", "0.59136474", "0.5905265", "0.58951104", "0.58677673...
0.7494422
1
Calculates the hub cities
def hub_city(g): max_flights = None hub_cities = [] for key in g.city_dict: if(len(g.city_dict[key].get_flights_in()) > max_flights): max_flights = len((g.city_dict[key]).flights_in) for key in g.city_dict: if(len(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hubs(self):\r\n cities = col.defaultdict(int)\r\n for code, _list in self.edges.items():\r\n for edge in _list:\r\n cities[code] += 1\r\n heap = [(-value, key) for key, value in cities.items()]\r\n largest = heapq.nsmallest(5, heap)\r\n largest = [(k...
[ "0.6245692", "0.58840376", "0.57459503", "0.5728825", "0.56564677", "0.56357723", "0.5563709", "0.55345", "0.55310136", "0.5493579", "0.54820573", "0.5466315", "0.544892", "0.54430956", "0.5442331", "0.54416835", "0.5439803", "0.5434287", "0.54281354", "0.54195577", "0.541574...
0.66845423
0
Removes routes in either one or both directions depending on choice
def remove_route(g, origin, destination, choice_dir): origin_code = g.convert[origin] destination_code = g.convert[destination] # Removes both directions and returns if(choice_dir == "y"): for key in g.city_dict: if(key == origin_code): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_route(self, start, destination):\r\n if start in self.edges and destination in self.edges:\r\n for edge in self.edges[start]:\r\n if edge.destination == destination:\r\n self.edges[start].remove(edge)\r\n for edge in self.edges[destination]:...
[ "0.63235706", "0.62767", "0.60863006", "0.6013067", "0.58284384", "0.5816146", "0.56094426", "0.5469338", "0.5461441", "0.54449695", "0.53999275", "0.53933597", "0.53749657", "0.5370711", "0.5322262", "0.5310696", "0.5229889", "0.5217318", "0.52148515", "0.5191691", "0.517635...
0.6972738
0
Edits a particular city's information
def edit_city(g, city_name, option, value): city_code = g.convert[city_name] if(option == "country"): g.city_dict[city_code].set_country(value) if(option == "continent"): g.city_dict[city_code].set_continent(value) if(option == "timezone"): g.city_dict[...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def city_update(self):\n self.city = self.city_finder(self.location.__str__())", "def put_update_city(city_id):\n city = storage.get(\"City\", city_id)\n if city is None:\n abort(404)\n kwargs = request.get_json()\n if kwargs is None:\n return ('Not a JSON', 400)\n for k, v in...
[ "0.76798195", "0.7203858", "0.71742404", "0.7104565", "0.70437074", "0.7042058", "0.6885845", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.68707865", "0.6813071", "0.6634013", "0.6486274", "0.6452047", "0.6...
0.76292413
1
Helper function for route info. Calculates Time
def route_info_helper(g, origin, destination, distance): time = 0 acceleration = 1406.25 if(distance > 400): time = time + 0.53 + 0.53 distance = distance - 400 time = time + distance / 750 else: half = distance / 2.0 time = time + 2 (math.sqrt((2 * half) / ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_time(network, road_id):\n return network[0][road_id][4]", "def get_time_of_route(network, route):\n result = 0\n for road_id in route:\n result += get_time(network,road_id)\n return result", "def GetArrivalTimeOfTour(PathInfo):\r\n\tif not PathInfo:\r\n\t\treturn None \r\n\tif len(PathInfo) < 2:...
[ "0.6904649", "0.689016", "0.67284244", "0.66258335", "0.6544766", "0.64865255", "0.641994", "0.64139676", "0.64094126", "0.633791", "0.63105553", "0.6259277", "0.6244252", "0.6244252", "0.6242538", "0.6225357", "0.6214253", "0.61964345", "0.61957103", "0.61768657", "0.6168867...
0.71413535
0
Validates a large collection of webaccessible VOTable files. Generates a report as a directory tree of HTML files.
def make_validation_report( urls=None, destdir="astropy.io.votable.validator.results", multiprocess=True, stilts=None, ): from astropy.utils.console import ProgressBar, Spinner, color_print if stilts is not None: if not os.path.exists(stilts): raise ValueError(f"{stilts} doe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_valids():\n har_path = os.path.join(PLT_SRC, 'data/replay/*')\n valid_path = '../data/filtered_stats/valids.txt'\n\n har_files = [f for f in glob(har_path)] # Include pc files?\n urls = \\\n [urlsafe_b64decode(f.split('/')[-1].split('.')[0]) for f in har_files]\n with open(valid_pa...
[ "0.5945655", "0.5838945", "0.57658255", "0.569241", "0.554993", "0.55264246", "0.55122614", "0.5475122", "0.54121584", "0.540897", "0.538099", "0.5370284", "0.53646624", "0.53545636", "0.5348482", "0.53253406", "0.5267732", "0.52437747", "0.5219449", "0.517951", "0.5170713", ...
0.6486661
0
Build a word cooccurrence list for the given corpus. This function is a tuple generator, where each element (representing a cooccurrence pair) is of the form (i_main, i_context, cooccurrence) where `i_main` is the ID of the main word in the cooccurrence and `i_context` is the ID of the context word, and `cooccurrence` ...
def _build_cooccur(self): vocab_size = len(self._vocabulary) # Collect cooccurrences internally as a sparse matrix for passable # indexing speed; we'll convert into a list later cooccurrences = sparse.lil_matrix((vocab_size, vocab_size), dtype=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cooc_pipeline(self, minimum_offsets: int = 20) -> Cooc:\n # pass list of texts processed by NLP functions to the co-occurrence function, alongside list of times, and occurrence threshold\n offset_dict, lookup = cooc_offsets(self.post_nlp, self.list_times(),\n ...
[ "0.61815953", "0.59851664", "0.5900069", "0.58935595", "0.58741456", "0.5799038", "0.5701696", "0.5609933", "0.56035453", "0.55801284", "0.5532043", "0.551528", "0.5493789", "0.5406064", "0.537881", "0.5376263", "0.53535634", "0.5348014", "0.5334142", "0.5324124", "0.53139424...
0.6868452
0
Run a single iteration of GloVe training using the given cooccurrence data and the previously computed weight vectors / biases and accompanying gradient histories. `data` is a prefetched data / weights list where each element is of the form (v_main, v_context, b_main, b_context, gradsq_W_main, gradsq_W_context, gradsq_...
def _run_iter(self, data): global_cost = 0 # We want to iterate over data randomly so as not to unintentionally # bias the word vector contents shuffle(data) for (v_main, v_context, b_main, b_context, gradsq_W_main, gradsq_W_context, gradsq_b_main, gradsq_b_contex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train(self, data, batch_size=20, corruption_rate=0.3,\n learning_rate=0.1, n_epochs=15, stop_diff=None):\n\n n_training = data.get_value(borrow=True).shape[0]\n n_train_batches = n_training / batch_size\n\n index = T.lscalar() # index into mini-batch\n\n cost, updates ...
[ "0.56437624", "0.55223954", "0.54434454", "0.53713495", "0.5334377", "0.5333032", "0.5331442", "0.52819765", "0.5254428", "0.5253803", "0.5228929", "0.5216955", "0.5193256", "0.5178512", "0.5162818", "0.5137324", "0.5114395", "0.5095115", "0.50922", "0.507456", "0.5068848", ...
0.7024565
0
Train GloVe vectors on the given generator `cooccurrences`, where each element is of the form (word_i_id, word_j_id, x_ij) where `x_ij` is a cooccurrence value $X_{ij}$ as presented in the matrix defined by `build_cooccur` and the Pennington et al. (2014) paper itself. If `iter_callback` is not `None`, the provided fun...
def _train(self, iter_callback=None): vocab_size = len(self._vocabulary) # Word vector matrix. This matrix is (2V) * d, where N is the size # of the corpus vocabulary and d is the dimensionality of the word # vectors. All elements are initialized randomly in the range (-0.5, # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def k_fold_cBow(data, save_path=None, name=None, v_size=50, epochs=30, k=10, reg=1):\n \n tokenized_data_text = [data[k][0] for k in range(len(data))] # data\n \n ### Train Word2Vec ###\n cores = 4 # Threads used for training\n\n # Initialize the model\n w2v_model = Word2Vec(size=v_size,...
[ "0.52923024", "0.5203833", "0.51532567", "0.5121628", "0.5083303", "0.50537884", "0.5020545", "0.5013356", "0.49854818", "0.4979154", "0.4925047", "0.48568016", "0.4842685", "0.47676906", "0.47466868", "0.47280526", "0.47125867", "0.4681158", "0.4681158", "0.4681158", "0.4670...
0.62753546
0
Merge the mainword and contextword vectors for a weight matrix using the provided merge function (which accepts a mainword and contextword vector and returns a merged version). By default, `merge_fun` returns the mean of the two vectors.
def _merge_main_context(self, W, merge_fun=lambda m, c: np.mean([m, c], axis=0), normalize=True): vocab_size = int(len(W) / 2) for i, row in enumerate(W[:vocab_size]): merged = merge_fun(row, W[i + vocab_size]) if normalize: merged /= ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_words(word_list, merge_method = None, **kwargs):\n \n for word in word_list:\n word['minframe'] = word['frame']\n word['maxframe'] = word['frame']\n \n if merge_method is None:\n for word in word_list:\n word['merge_size'] = 1\n return word_list\n ...
[ "0.5275809", "0.522954", "0.51816005", "0.5153573", "0.51036894", "0.5002368", "0.4994195", "0.4987917", "0.49496958", "0.49032155", "0.49016565", "0.4878636", "0.48507038", "0.4836894", "0.48192373", "0.48120636", "0.4773416", "0.47690493", "0.47202617", "0.4701574", "0.4699...
0.7576404
0
Check that the learner model copies the parameters to the actor model.
def test_parameters_copied_to_actor_model(self): # Reset models. self.model.load_state_dict(self.initial_model_dict) self.actor_model.load_state_dict(self.initial_actor_model_dict) polybeast.learn(*self.learn_args) np.testing.assert_equal( _state_dict_to_numpy(self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_weights_update(self):\n # Reset models.\n self.model.load_state_dict(self.initial_model_dict)\n self.actor_model.load_state_dict(self.initial_actor_model_dict)\n\n polybeast.learn(*self.learn_args)\n\n model_state_dict = self.model.state_dict(keep_vars=True)\n act...
[ "0.6381396", "0.6288694", "0.619524", "0.6183236", "0.61661863", "0.60990614", "0.6015996", "0.59244156", "0.58983153", "0.58655375", "0.58491224", "0.5843454", "0.58418316", "0.580938", "0.5806636", "0.5787176", "0.5748513", "0.57426196", "0.56631523", "0.56100136", "0.55832...
0.7869059
0
Check that gradients get updated after one iteration.
def test_gradients_update(self): # Reset models. self.model.load_state_dict(self.initial_model_dict) self.actor_model.load_state_dict(self.initial_actor_model_dict) # There should be no calculated gradient yet. for p in self.model.parameters(): self.assertIsNone(p.gr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_gradient_convergence(self):\n pass", "def check_gradient(f, x, delta=1e-5, tol=1e-4):\n assert isinstance(x, CP.cp.ndarray), (\n f'{CP.cp.ndarray.__name__} expected, {type(x).__name__} found')\n assert x.dtype == CP.cp.float, (\n f'{CP.cp.float.__name__} expected, {x.dtype.__n...
[ "0.7099907", "0.67376345", "0.671461", "0.6675888", "0.66655296", "0.6591444", "0.6557734", "0.6551219", "0.6547603", "0.65425277", "0.65198237", "0.6509093", "0.6471482", "0.64100033", "0.634781", "0.6343587", "0.63154864", "0.6293847", "0.62596756", "0.62356067", "0.6215048...
0.69025034
1
Check that the loss is not zero after one iteration.
def test_non_zero_loss(self): # Reset models. self.model.load_state_dict(self.initial_model_dict) self.actor_model.load_state_dict(self.initial_actor_model_dict) polybeast.learn(*self.learn_args) self.assertNotEqual(self.stats["total_loss"], 0.0) self.assertNotEqual(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_loss(self, loss):\n assert not np.isnan(loss), \"Model diverged with loss = NaN\"", "def check_loss(self, loss):\r\n if loss in loss_functions:\r\n return loss\r\n else:\r\n raise InvalidNeuralNetwork()", "def loss_check(self):\n if sum(x >= y for x, y i...
[ "0.76585907", "0.69313073", "0.67380106", "0.65259504", "0.6461813", "0.64466727", "0.6370304", "0.6364635", "0.63278115", "0.63026285", "0.6255894", "0.6242863", "0.62231886", "0.6204156", "0.61995053", "0.61885244", "0.6179706", "0.607027", "0.60386175", "0.6000047", "0.599...
0.7524927
1
Create entity via REST API call to FIWARE Orion instance
def create_entity(self, data): url = '{}/ngsi-ld/v1/entities'.format(self.url) return self.post(url, data=data, headers=self.headers_ld)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(self, **kwargs):\n url_str = self.base_url\n newheaders = self.get_headers()\n payload = kwargs['definition']\n resp, body = self.client.json_request('POST', url_str,\n data=payload,\n h...
[ "0.647187", "0.6426464", "0.64068145", "0.6189531", "0.6153188", "0.6112099", "0.60812044", "0.6074476", "0.60674065", "0.60651594", "0.6061145", "0.60606164", "0.60606164", "0.6057648", "0.60275805", "0.5970802", "0.5970802", "0.5943055", "0.59327745", "0.59327745", "0.59122...
0.6630035
0
Get list of subscriptions
def get_subscriptions(self): url = '{}/v2/subscriptions'.format(self.url) r = requests.get(url, headers=self.headers_v2) return r.json()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_subscriptions(self):\n return self.subscriptions.all()", "def list(cls, **kwargs):\n response = Yola().list_subscriptions(**kwargs)\n return [cls(**sub) for sub in response['results']]", "def listSubscriptions() -> object:\n\n db = Db()\n return db.Subscriptions.objects().to_...
[ "0.8398169", "0.8375198", "0.8325919", "0.8277738", "0.8259095", "0.79059505", "0.78718024", "0.77910763", "0.7774858", "0.7725947", "0.7718782", "0.76882046", "0.7623318", "0.7581791", "0.7498807", "0.7496328", "0.7492321", "0.74787927", "0.7477246", "0.74727875", "0.7406269...
0.85034156
0
Return version of Orion
def get_version(self): url = '{}/version'.format(self.url) try: r = requests.get(url) if r.status_code == 200: return r.json()['orionld version'] except Exception as e: pass return ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def version(self):", "def _get_version(self):", "def get_version():\n return 1", "def get_version():\n return magpy.get_version()", "def get_version(self):\n pass", "def version():\n return Tns.exec_command(command='--version')", "def version():\n\n pass", "def os_version(s...
[ "0.6403556", "0.6304644", "0.6249486", "0.6248122", "0.621764", "0.6158724", "0.6140235", "0.61192226", "0.61056864", "0.60843223", "0.60843223", "0.60843223", "0.605601", "0.605601", "0.605601", "0.605601", "0.60488", "0.6042052", "0.6013787", "0.599189", "0.599189", "0.59...
0.6533337
0
Iteratively improve guess with update until close(guess) is true.
def improve(update, close, guess=1, max_updates=100): k = 0 while not close(guess) and k < max_updates: guess = update(guess) k = k + 1 return guess
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def improve(update, close, guess = 1):\n\twhile not close(guess):\n\t\tguess = update(guess)\n\treturn guess", "def play_best_guess(self, game):\n\n\n # create a list of cells\n cells = [game.board[i][j]\n for i in xrange(game.rows)\n for j in xrange(game.cols)]\n\n ...
[ "0.8605954", "0.5961708", "0.56332797", "0.55135024", "0.54814464", "0.54635817", "0.54419863", "0.54349303", "0.53940094", "0.5347436", "0.5339664", "0.533806", "0.5333433", "0.53092515", "0.5292316", "0.528817", "0.5286", "0.52593684", "0.5253878", "0.52402186", "0.5236549"...
0.83155674
1
Whether x is within tolerance of y.
def approx_eq(x, y, tolerance=1e-15): return abs(x - y) < tolerance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def within_tolerance(x, y, tolerance): \r\n return abs(x) <= tolerance and abs(y) <= tolerance", "def approx_eq(x, y, tolerance = 0.000001):\n\treturn abs(x - y) < tolerance", "def is_close(x, y, thresh=1e-8):\n\n diff = x - y\n return diff > (-thresh) and diff < thresh", "def fp_eq(x: float, y: ...
[ "0.87317413", "0.83025366", "0.7623505", "0.7550511", "0.74117655", "0.71859026", "0.7165169", "0.71050906", "0.7098003", "0.7080783", "0.70350116", "0.69452155", "0.6945068", "0.69150317", "0.69057274", "0.68689567", "0.68311256", "0.6811364", "0.68053854", "0.6792282", "0.6...
0.8320757
1
Return a zero of the function f with derivative df.
def find_zero(f, df): def near_zero(x): return approx_eq(f(x), 0) return improve(newton_update(f, df), near_zero)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zzX_zero_of(f, d=0):\n return zzX_zero(poly_level(f)-d)", "def find_zero(f,p1,d):\n if p1 > 10:\n p1 = 0.5\n c = p1 - f(p1)*d/(f(p1+d)-f(p1)) # simple\n \n # we can do this in case derivative diverges because our function is symmetric\n if c < 0:\n c = -c\n \n global n_o...
[ "0.710459", "0.69687253", "0.68732387", "0.6862347", "0.6778152", "0.6637142", "0.6637142", "0.6579491", "0.6576675", "0.6561542", "0.65527314", "0.6465958", "0.6439708", "0.6392126", "0.6368971", "0.63685733", "0.6347817", "0.6342038", "0.63330156", "0.6315682", "0.63055897"...
0.72815776
0
Return an update function for f with derivative df.
def newton_update(f, df): def update(x): return x - f(x) / df(x) return update
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fundemental_derivative(tab, spec, *XYf):\n if tab._backend != 'vdw':\n raise ValueError('This derived variable is only compatible with the vdw backend!')\n XYf_DT = XYf[:]\n rho = XYf_DT[0]\n units = EosUnits(tab.Pt_DT._requested_units, 'cgs')\n Pt = tab.get_table('P{s}_DT', spec)(*XYf_DT...
[ "0.70165133", "0.7001049", "0.68691164", "0.6799847", "0.67967254", "0.6793361", "0.6780204", "0.67798835", "0.66769856", "0.6591627", "0.64793384", "0.6459531", "0.64474493", "0.6438183", "0.6437626", "0.64252317", "0.64010054", "0.6396581", "0.6385963", "0.6326162", "0.6312...
0.8139031
0
Return the nth root of a. >>> nth_root_of_a(2, 64) 8.0 >>> nth_root_of_a(3, 64) 4.0 >>> nth_root_of_a(6, 64) 2.0
def nth_root_of_a(n, a): return find_zero(lambda x: pow(x, n) - a, lambda x: n * pow(x, n-1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _nth_root(value, n_root):\n return value ** (1 / n_root)", "def nthRoot(x,n):\n return op.pow(x,1/n)", "def _nth_root(value, n_root) -> float:\r\n\r\n root_value = 1 / float(n_root)\r\n return Decimal(value) ** Decimal(root_value)", "def nth_root(n):\n def actual_root(x):\n \"\"\"Re...
[ "0.75692934", "0.7431182", "0.71742463", "0.7150281", "0.701514", "0.6856103", "0.66949475", "0.6634981", "0.65308344", "0.6389557", "0.6271755", "0.60599667", "0.60268474", "0.5992309", "0.5910207", "0.59078914", "0.59013754", "0.5822415", "0.57628083", "0.5756869", "0.57355...
0.8411243
0
Return where f with derivative df intersects g with derivative dg.
def intersect(f, df, g, dg): "*** YOUR CODE HERE ***"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def half_gcdex(f, g):\n lev, dom, per, F, G = f.unify(g)\n s, h = dmp_half_gcdex(F, G, dom)\n return per(s), per(h)", "def test_dg_ds(self):\n dfn = lambda x: self.model.g(x, self.e, self.t, self.T)\n nderiv = differentiate(dfn, self.s)\n cderiv = self.model.dg_ds(self.s, self.e, se...
[ "0.5994133", "0.5864072", "0.5811879", "0.5788354", "0.57705534", "0.57565135", "0.5746735", "0.5746611", "0.5694095", "0.5664176", "0.56258017", "0.56158626", "0.55997485", "0.5587861", "0.55736214", "0.5568215", "0.5549245", "0.5547094", "0.5545913", "0.55298674", "0.552239...
0.686747
0
Return a quadratic polynomial axx + bx + c. >>> q_and_dq = quadratic(1, 6, 8) xx + 6x + 8 >>> q_and_dq(1.0, False) value at 1 15.0 >>> q_and_dq(1.0, True) derivative at 1 8.0 >>> q_and_dq(1.0, False) value at 1 3.0 >>> q_and_dq(1.0, True) derivative at 1 4.0
def quadratic(a, b, c): A, B, C = K(a), K(b), K(c) AXX = mul_fns(A, mul_fns(X, X)) BX = mul_fns(B, X) return add_fns(AXX, add_fns(BX, C))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quadratic(x, a, b, c):\n y = a*(x**2)+b*x+c\n return y", "def quadratic(self, a, b, c):\n if a == 0 and b == 0:\n return [\"inf\"]\n elif a == 0 and b != 0:\n # form b*y + c = 0\n return [-c / b]\n elif (b ** 2 - 4 * a * c) > 0:\n # stand...
[ "0.6952538", "0.6378851", "0.62913656", "0.62190676", "0.6207759", "0.6149846", "0.6093402", "0.6068831", "0.60618824", "0.60612655", "0.5956198", "0.59523714", "0.59189296", "0.59132314", "0.5912714", "0.5909905", "0.5901354", "0.58848184", "0.58415854", "0.5825126", "0.5822...
0.6709867
1
Takes a FQDN, removes common hosts prepended to it in the subdomain, and returns it.
def _remove_common_hosts(fqdn): fqdn_parts = fqdn.split(".", 1) common_hosts = ["*", "www", "mail", "cpanel", "webmail", "webdisk", "autodiscover"] if len(fqdn_parts) > 1: if fqdn_parts[0] in common_hosts: return fqdn_parts[1] return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_tld(domain):\n try:\n tld = extract(domain).suffix\n domain = ''.join(domain.rsplit(tld, 1)).strip('.')\n\n except Exception as e:\n LOGGING.warning(\n 'Error stripping TLD ({0}): {1}'.format(\n domain, str(e)))\n\n return domain", "def resolve_d...
[ "0.63369846", "0.63136166", "0.62881714", "0.6275267", "0.62363964", "0.6232156", "0.6210748", "0.6196768", "0.61805403", "0.60748434", "0.60158795", "0.60005623", "0.5959053", "0.59369665", "0.59220135", "0.5896945", "0.5876433", "0.5860491", "0.5798876", "0.5790115", "0.577...
0.7917956
0
Break apart domain parts and return a dictionary representing the individual attributes like subdomain, domain, and tld.
def _fqdn_parts(fqdn): parts = tldextract.extract(fqdn) result = {} result['subdomain'] = parts.subdomain result['domain'] = parts.domain result['tld'] = parts.suffix return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_domain(domain):\n domain.ns_converted = []\n for ns in domain.ns :\n if isinstance(ns, objects.DomainHostAttr) :\n ns_item = {\n 'hostname' : ns.hostname,\n 'ips' : []\n }\n\n for hostaddr in ns.hostAddr :\n ns_it...
[ "0.6395861", "0.61714053", "0.60660917", "0.5869068", "0.5863042", "0.5801565", "0.5781437", "0.57460326", "0.5744908", "0.5694288", "0.5593569", "0.55888236", "0.55611366", "0.5516715", "0.5470856", "0.5468458", "0.5464931", "0.5463847", "0.5461036", "0.54528266", "0.5445931...
0.7670125
0
Look for presence of keywords anywhere in the FQDN i.e. 'account' would match on 'dswaccounting.tk'.
def _fe_keyword_match(self, sample): result = OrderedDict() for item in self._keywords: result[item + "_kw"] = 1 if item in sample['fqdn'] else 0 return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fe_keyword_match_fqdn_words(self, sample):\n result = OrderedDict()\n\n for item in self._fqdn_keywords:\n result[item + \"_kw_fqdn_words\"] = 1 if item in sample['fqdn_words'] else 0\n\n return result", "def has_keyword(tweet, keywords):\n temp = tweet.lower()\n for ke...
[ "0.67603284", "0.6288145", "0.6264384", "0.6124197", "0.5734106", "0.5692253", "0.56600755", "0.5550627", "0.55482304", "0.5501343", "0.5489396", "0.5480573", "0.54303133", "0.5422775", "0.53625435", "0.5313793", "0.5302733", "0.5277682", "0.52748245", "0.52583617", "0.522925...
0.636286
1
Compare FQDN words (previous regex on special characters) against a list of common phishing keywords, look for exact match on those words. Probably more decisive in identifying phishing domains.
def _fe_keyword_match_fqdn_words(self, sample): result = OrderedDict() for item in self._fqdn_keywords: result[item + "_kw_fqdn_words"] = 1 if item in sample['fqdn_words'] else 0 return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fe_check_phishing_similarity_words(self, sample):\n result = OrderedDict()\n\n for key in self._similarity_words:\n result[key + \"_lev_1\"] = 0\n\n for word in sample['fqdn_words']:\n if distance(word, key) == 1:\n result[key + \"_lev_1\"]...
[ "0.6091038", "0.577696", "0.5764494", "0.57121223", "0.5633178", "0.5504832", "0.54945046", "0.5456745", "0.54504764", "0.53892124", "0.53840774", "0.5322143", "0.5296676", "0.52959716", "0.5292845", "0.52882844", "0.5262858", "0.52622586", "0.52457976", "0.5243344", "0.51923...
0.6419068
0
Takes domain name from FQDN and computes entropy (randomness, repeated characters, etc).
def _fe_compute_domain_entropy(sample): # Compute entropy of domain. result = OrderedDict() p, lns = Counter(sample['domain']), float(len(sample['domain'])) entropy = -sum(count / lns * math.log(count / lns, 2) for count in list(p.values())) result['entropy'] = entropy r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entropy(strength=256, wordlist=wordlist):\n return os.urandom(strength // 8)", "def entropy(string):\n p, lns = Counter(string), float(len(string))\n return -sum(count/lns * math.log(count/lns, 2) for count in p.values())", "def hash_gen(n):\n domain = \"abcdefghijklmnopqrstuvwxyz\"\n temp =...
[ "0.6293822", "0.6074984", "0.6020162", "0.5919624", "0.59022033", "0.5828968", "0.570825", "0.56989056", "0.569766", "0.5616749", "0.55834776", "0.55808234", "0.5574519", "0.5499094", "0.5492154", "0.54726064", "0.54315686", "0.54142773", "0.53726447", "0.5372522", "0.5370425...
0.6353545
0
Takes a list of words from the FQDN (split by special characters) and checks them for similarity against words commonly disguised as phishing words. This method only searches for a distance of 1. i.e. 'pavpal' = 1 for 'paypal', 'verifycation' = 1 for 'verification', 'app1eid' = 1 for 'appleid'.
def _fe_check_phishing_similarity_words(self, sample): result = OrderedDict() for key in self._similarity_words: result[key + "_lev_1"] = 0 for word in sample['fqdn_words']: if distance(word, key) == 1: result[key + "_lev_1"] = 1 ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matchCompanies(toPredictCompanies, toCompareCompanies):\n toPredictCompanies = str(toPredictCompanies).split(\"|\")\n toCompareCompanies = str(toCompareCompanies).strip(\"|\").split(\"|\")\n\n # toCompareLikeCompanies = []\n\n # for company in toCompareCompanies:\n # toCompareLikeCompanies =...
[ "0.6157263", "0.61049163", "0.60544884", "0.5936826", "0.59270567", "0.5918244", "0.58946455", "0.58762765", "0.5852237", "0.58351666", "0.58249515", "0.58216745", "0.58107185", "0.5793", "0.5785313", "0.5782636", "0.576584", "0.57646227", "0.57545584", "0.57255167", "0.57215...
0.6878959
0
Compute number of periods several subdomains could be indicative of a phishing domain.
def _fe_number_of_periods(sample): result = OrderedDict() result['num_periods'] = sample['fqdn'].count(".") return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countSubDomain(subdomain):\r\n if not subdomain:\r\n return 0\r\n else:\r\n return len(subdomain.split('.'))", "def count_domain_certs_since(domain, days=7):\n all_certs = fetch_domain_certs(domain)\n count = 0\n now = jstime.utcnow()\n domains = set()\n start_date = now.sh...
[ "0.73734283", "0.6363252", "0.6047416", "0.5975989", "0.59162605", "0.590691", "0.5840889", "0.5783803", "0.5761523", "0.5740268", "0.5684617", "0.5681019", "0.5658028", "0.5633492", "0.55681723", "0.5556087", "0.54854655", "0.54635584", "0.5415911", "0.5372303", "0.53621453"...
0.6399894
1
evaluate single user statistic against consensus
def evaluate_user(user_name, path_annots, path_out, path_dataset=None, tp_consensus='mean', visual=False): tissue_sets = list_sub_folders(path_annots) path_visu = path_out if visual else None stats = [] for p_set in tissue_sets: paths = list_sub_folders(p_set, '*_scale-*pc') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_analyse(args):\n\n pd.set_option('display.max_columns', None)\n pd.set_option('display.width', None)\n\n score = 'score'\n\n # Read in the results, and add a boolean target column.\n df = pd.read_csv(args.results, index_col=0)\n df['target'] = df['verify_speaker'] == df['enrol_speaker']\n\...
[ "0.6377215", "0.6260066", "0.6040133", "0.60060644", "0.59876806", "0.59181154", "0.59099674", "0.5897153", "0.58943975", "0.5878483", "0.5876605", "0.58761567", "0.5865876", "0.58499384", "0.58498347", "0.5839647", "0.58274853", "0.581546", "0.5811723", "0.5805026", "0.57998...
0.6638993
0
Convert a string to 'ladcase' (Alternating uppercase and lowercase)
def ladcased(normal): ladified = '' for i, c in enumerate(normal): ladified += c.lower() if (i % 2 == 0) else c.upper() return ladified
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LCase(text):\n return text.lower()", "def spinalcase(string):\n\n return re.sub(r\"_\", \"-\", snakecase(string))", "def change_case(word):\n return word.upper() if case == \"upper\" else word.lower()", "def camel(s):\n return s[0].upper() + s[1:]", "def camel_case_to_lower_case_undersc...
[ "0.7075611", "0.68091935", "0.680499", "0.6754427", "0.6674417", "0.65716505", "0.65413034", "0.6531418", "0.6530767", "0.6467329", "0.64634377", "0.64441127", "0.64405614", "0.64318335", "0.6384469", "0.6383467", "0.6319232", "0.630749", "0.6303444", "0.63025665", "0.6282669...
0.7378206
0
Delete the command message sent by the user
def delete_command(update): try: update.message.delete() except error.BadRequest: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def delete(self):\n return await self.set_message(text='')", "def delete_command(self, message, db_session):\n user = self.ts.get_user(message)\n msg_list = self.ts.get_human_readable_message(message).split(' ')\n command_str = msg_list[1][1:].lower()\n db_commands = db_s...
[ "0.7814841", "0.7263464", "0.71322507", "0.7130819", "0.70133436", "0.6992076", "0.694922", "0.6897082", "0.6836792", "0.6830423", "0.68269277", "0.6786749", "0.67781705", "0.6774464", "0.6771238", "0.6770795", "0.6763575", "0.6745461", "0.6731808", "0.67163926", "0.6675833",...
0.7603203
1
wrapper to run noise jobs
def run_noise_jobs(jobtime=60, on_the_fly=True, delay_submit=False): pos = 'S5' filelist = get_list('./%s.txt' % pos) jobdir = './job' job_idx = 0 for line in filelist: runno = int(line) # phase 1 basedir = "/nfs/slac/g/exo_data6/groups/Energy/data/WIPP/selection/2017_Ph...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_experiment():\n pass", "def do_work(self):", "def task():", "def multi_run_wrapper(args):\n\treturn img_preprocessing(*args)", "def custom():\n run(\"example\")", "def run(_):\n pass", "def run_job(job, interrupt_if_necessary):", "def main():\n first_notes_and_song()\n bad_sing...
[ "0.65611124", "0.6356343", "0.63032246", "0.60580665", "0.60263705", "0.6025089", "0.6022546", "0.59839165", "0.5979172", "0.5963987", "0.5963987", "0.59164506", "0.58901995", "0.5887724", "0.5880279", "0.5864977", "0.5857818", "0.5842847", "0.57759076", "0.5771728", "0.57424...
0.674493
0
this function is depricated in evaluation part of the code , please use cross_time_index only keep values that are in both timeseries with same timestamp
def cross_timeseries(series1, series2): ts_new1 = [] val_new1 = [] ts_new2 = [] val_new2 = [] for i in range(len(series1[1])): # for j in range(len(series2[1])): if series1[1][i] in series2[1]: ts_new1.append(series1[1][i]) val_new1.append(series1[0][i]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_time_index(df1, df2):\n series = pd.core.series.Series\n crossed_index = df1.index.intersection(df2.index)\n\n if type(df1) == series and type(df2) == series:\n df1 = df1[crossed_index]\n df2 = df2[crossed_index]\n elif type(df1) == series and type(df2) != series:\n df1 =...
[ "0.69184124", "0.6039055", "0.5632819", "0.55458146", "0.54509735", "0.54410505", "0.54047483", "0.5396788", "0.53862023", "0.5343398", "0.5336726", "0.5325228", "0.5325126", "0.5295715", "0.5281427", "0.52501625", "0.524079", "0.523888", "0.5229048", "0.52252024", "0.5158102...
0.6949659
0
cross Index of Dataframe or Series to get same timestamps in both variables
def cross_time_index(df1, df2): series = pd.core.series.Series crossed_index = df1.index.intersection(df2.index) if type(df1) == series and type(df2) == series: df1 = df1[crossed_index] df2 = df2[crossed_index] elif type(df1) == series and type(df2) != series: df1 = df1[crossed_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_timeseries(series1, series2):\n\n ts_new1 = []\n val_new1 = []\n\n ts_new2 = []\n val_new2 = []\n\n for i in range(len(series1[1])):\n # for j in range(len(series2[1])):\n if series1[1][i] in series2[1]:\n ts_new1.append(series1[1][i])\n val_new1.append(...
[ "0.65439165", "0.598058", "0.5822184", "0.5686274", "0.5596564", "0.5486955", "0.544059", "0.5430933", "0.5426533", "0.5350268", "0.53090304", "0.53070986", "0.5256891", "0.5231159", "0.52165365", "0.51977074", "0.519006", "0.5176994", "0.5156888", "0.5139948", "0.5134614", ...
0.68857735
0
creates a numpy.array of daily timestamp between date1 and date2
def daily_date_range(date1, date2): num_days = (date2-date1).days return np.array([datetime(date1.year, date1.month, date1.day, 0)+timedelta(days=i) for i in range(num_days)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tstamps_for_daterange(self, start_date, end_date):\n\n img_offsets = np.array([timedelta(hours=h) for h in self.h_steps])\n\n timestamps = []\n diff = end_date - start_date\n for i in range(diff.days + 1):\n daily_dates = start_date + timedelta(days=i) + img_offsets\n ...
[ "0.62646705", "0.6251543", "0.6244625", "0.58896583", "0.58510077", "0.5696359", "0.5563263", "0.55348426", "0.55319935", "0.542548", "0.5410174", "0.5364342", "0.53538656", "0.53444016", "0.533278", "0.52783984", "0.52664703", "0.52501595", "0.52376074", "0.52373147", "0.523...
0.7559687
0
calculates the latest synoptic date [00, 06, 12, 18]
def latest_synop_time()-> datetime: utc = datetime.utcnow() if utc.hour < 1: utc = utc - timedelta(days=1) utc = utc.replace(hour=18) elif utc.hour < 7: utc = utc.replace(hour=0) elif utc.hour < 13: utc = utc.replace(hour=6) elif utc.hour < 19: utc = utc.repl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_secdate(self):\r\n \r\n # Since 2017\r\n self.start_date = datetime.datetime(2017,1,1) + (datetime.datetime(2017,12,31) - datetime.datetime(2017,1,1))/2 \r\n self.end_date = datetime.datetime(2050,1,1)\r\n self.ktime = (self.end_date - self.start_date).days + 1\r\n ...
[ "0.5545438", "0.5482487", "0.5446347", "0.54212517", "0.54021597", "0.53924286", "0.531854", "0.5259258", "0.52245414", "0.52208966", "0.5196707", "0.5196569", "0.517578", "0.51637954", "0.51488984", "0.51444995", "0.51331955", "0.51175916", "0.5115149", "0.51032466", "0.5101...
0.59996945
0
This function performs KNN prediction on a given set of known data split into test and training data.
def KNN(x_train, x_test, y_train, k=3): knn = KNeighborsClassifier(n_neighbors=k) knn.fit(x_train, y_train) y_pred = knn.predict(x_test) return y_pred
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, testFeatures): \r\n\r\n if(not self._fitCalled):\r\n print('The fit method has not been called yet')\r\n return None\r\n\r\n l,d = testFeatures.shape\r\n n,d = self.data.shape \r\n\r\n \"\"\" Fill and return this in your implementation. \"\"\"\r\n predictions = np.e...
[ "0.7330793", "0.7309704", "0.7270616", "0.7259386", "0.72563416", "0.7157462", "0.7127439", "0.7102847", "0.7047425", "0.6993454", "0.6953368", "0.6921302", "0.6848991", "0.6845109", "0.6812495", "0.6762994", "0.6747782", "0.66979706", "0.66886985", "0.668627", "0.6682093", ...
0.739547
0
This function takes in a matrix of predicted classifications and the number of rows and returns predictions based on the most common classification. It returns an array of predictions.
def ensemble(all_predict, size): mode_pred = np.zeros(shape=(size,1)) for i in range(np.shape(all_predict)[1]): pred= mode(all_predict[:,i]) # break ties randomly if pred[1] == 1: pred_val = random.randrange(2) else: pred_val = pred[0] mode_pred[i,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self):\n probabilities = self.probability_array()\n # THIS ASSUMES the classifiers are in order: 0th column of the\n # probabilities corresponds to label = 0, ..., 9th col is for 9.\n classes = np.argmax(probabilities, axis=1)\n return classes", "def predict ( self,...
[ "0.7057203", "0.6765373", "0.6741487", "0.6657502", "0.6527239", "0.6499049", "0.6492929", "0.64783335", "0.64658946", "0.6462367", "0.6431978", "0.63866305", "0.63668454", "0.6364946", "0.63647115", "0.6357904", "0.63144946", "0.6279442", "0.62669575", "0.62625736", "0.62522...
0.6766824
1
Returns a container by name, creating it if it doesn't exist yet
def get_container_by_name(self, container_name, is_source): if container_name not in self.containers: self.containers[container_name] = self.create_container(container_name, is_source) return self.containers[container_name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_container(self, name):\r\n try:\r\n return self.cf.get_container(name)\r\n except pyrax.exceptions.NoSuchContainer:\r\n c = self.cf.create_container(name)\r\n self.cf.make_container_public(name)\r\n return c", "def _create_container(self, containe...
[ "0.81037134", "0.78478223", "0.7752401", "0.753348", "0.7238788", "0.6823964", "0.67822766", "0.67822766", "0.67822766", "0.67822766", "0.67822766", "0.6777807", "0.6599799", "0.6450874", "0.6445211", "0.64139134", "0.6369507", "0.63672", "0.6336047", "0.6293579", "0.62300074...
0.7924567
1