query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Given a string, returns a list of tokens.
def _tokenize(self, text): if not text: return [] text = PUNCTUATION_CHARS.sub(' ', text) words = [ t[:128].lower() for t in text.split() if len(t) >= MIN_WORD_LENGTH and t.lower() not in STOP_WORDS ] return words
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_tokens(s: str) ->List[str]:\n return [] if not s else _normalize_text(s).split()", "def tokenize(self, input_string: str) -> List[str]:", "def get_token_list(text):\n return text.split()", "def tokenise_str(input_str):\n t = Tokeniser(input_str)\n tokens = []\n while True:\n toke...
[ "0.8296236", "0.8088405", "0.805548", "0.8036202", "0.79076993", "0.7897329", "0.76947147", "0.76728004", "0.7658737", "0.7647021", "0.75925446", "0.7510745", "0.7509149", "0.750788", "0.74941856", "0.7490048", "0.7433535", "0.7428624", "0.7364464", "0.7284027", "0.71597904",...
0.6451587
91
Ability to add a new donor to the neo database or if the donor exists, we can still add a new donation
def add_donor_neo(self, new_first_name, new_last_name, new_email, donation_amount): with self.driver.session() as session: transaction_id = new_email + '_1' if not self.donor_exists_neo(new_email, session): try: full_name = new_first_name + ' ' + new_last_name cyph = "CREATE (n:Donor {email:'%s', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_donor():\n logger.info('+++ Adding/Updating Donors')\n Main.connect_db()\n database.execute_sql('PRAGMA foreign_keys = ON;')\n name = input(\"Type donor first and last name: \")\n location = input(\"Type donor location (optional): \")\n try:\n don = floa...
[ "0.78216445", "0.7539791", "0.73935664", "0.7205716", "0.7150446", "0.7144435", "0.71018386", "0.7087724", "0.6904157", "0.68812627", "0.68335396", "0.6670825", "0.6639124", "0.6392329", "0.63684034", "0.63230246", "0.63022447", "0.6267651", "0.6165239", "0.6163705", "0.60284...
0.7548321
1
Adds a new donation to database
def add_donation_neo(self, email, donation_amount): with self.driver.session() as session: try: cyph = """ MATCH (d1:Donor {email: '%s'}) CREATE (d1)-[donate:DONATION]->({donation_amount: '%s'}) RETURN d1 """ % (email, donation_amount) session.run(cyph) except Exception as e: print(f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_donation(donor_name, donation):\n try:\n database.connect()\n database.execute_sql('PRAGMA foreign_keys = ON;')\n new_donation = Donations.create(\n donation_date=datetime.today(),\n donation_amount=decimal.Decimal(donation),\n donated_by=donor_name\...
[ "0.79306567", "0.73333097", "0.7305688", "0.7191388", "0.70920557", "0.6986661", "0.689348", "0.6860455", "0.6839993", "0.683262", "0.63774407", "0.6357008", "0.629449", "0.62885594", "0.62445986", "0.6239353", "0.6216765", "0.6165338", "0.6146872", "0.61235166", "0.6052725",...
0.68401486
8
Creates thank you message for donor
def thank_you_message(self, name, donation_amount): thank_you_message = "\nThank you {0:s} for you generous donation of ${1:.2f}.\n".format(name, round(donation_amount,2)) return thank_you_message
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_thankyou_message(donor):\n message = '''Dear {}, \n Thank you so much for your generosity with your most recent donation of ${}. \n It will be put to very good use.\n Sincerely.'''\n return message.format(donor[\"name\"], donor[\"donations\"][-1])", "def createThank...
[ "0.78450173", "0.7814776", "0.7809823", "0.77496356", "0.76782066", "0.7339795", "0.72114575", "0.71790093", "0.7063729", "0.70534915", "0.69376266", "0.6932777", "0.6929319", "0.6914824", "0.68592894", "0.6729701", "0.6714347", "0.66973317", "0.667985", "0.6654785", "0.65866...
0.79461265
0
Ability to delete donors and their donations
def delete_donation_neo(self, del_email): with self.driver.session() as session: try: cyph = """ MATCH (d:Donor {email: '%s'}) DELETE d """ % (del_email) print("{} has been removed from the database\n".format(del_email)) except Exception as e: print(f'Error deleting = {email}') print...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_donation_only():\n logger.info('+++ Delete donor\\'s donation')\n Main.connect_db(\"Donation\")\n database.execute_sql('PRAGMA foreign_keys = ON;')\n name = input(\"Provide donor\\'s name to delete her/his donation: \")\n try:\n with database.transaction():\...
[ "0.7970806", "0.7706708", "0.7630103", "0.7215614", "0.6978524", "0.6936026", "0.6767486", "0.6550948", "0.62019694", "0.61149335", "0.6048085", "0.6009219", "0.5966587", "0.587839", "0.587839", "0.587839", "0.587839", "0.5817038", "0.5799233", "0.5786121", "0.57740706", "0...
0.6306153
8
Determines if donor already exists in database
def donor_exists_neo(self, find_email): with self.driver.session() as session: current_donor = False try: cyph = "MATCH (d:Donor) RETURN d.email" result = session.run(cyph) for record in result: if record == find_email: current_donor = True except Exception as e: print(f'Error occu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_donor():\n mailroom.add_donor(\"New Donor\")\n assert \"New Donor\" in mailroom.donor_db\n assert mailroom.donor_db[\"New Donor\"] == []", "def exists_in_db(self) -> bool:\n query = \"\"\"SELECT * \n FROM Users \n WHERE Username=?;\"\"\"\n r...
[ "0.6315744", "0.61401653", "0.6123745", "0.61120445", "0.6107127", "0.6106686", "0.60144544", "0.60120237", "0.5959177", "0.5942381", "0.59352463", "0.59045386", "0.5903837", "0.5841208", "0.5828623", "0.58223695", "0.58148646", "0.5811007", "0.57154214", "0.57095027", "0.568...
0.6127379
2
Writes to a file. The donors name and total donations will be stored in the contents of the file, while the file name will be the donors email address
def write_to_file(self): with self.driver.session() as session: try: file_name = None donor_file_name = None full_file_name = None complete_file_name = None cyph = "MATCH (d:Donor) RETURN d.email" result = session.run(cyph) for donor in result: donor_file_name = donor['email'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def thank_donor(filename, donorname, donation):\n\n try:\n with open(filename, 'w') as fhandle:\n fhandle.write(\"Hello {}! On behalf of our staff here at OMGBBQMMX,\"\n \"I want to thank you for your generous gift\"\n \" of ${:.2f}!\".format(d...
[ "0.7609048", "0.69219613", "0.684354", "0.67753285", "0.6684142", "0.66822964", "0.6401604", "0.6285119", "0.61633074", "0.6058355", "0.5994589", "0.59464794", "0.59464794", "0.5921532", "0.59101367", "0.5903182", "0.58954483", "0.5859477", "0.5850165", "0.5848873", "0.583684...
0.78757757
0
Lists the donor names
def show_donors(self): with self.driver.session() as session: str_build = "" try: cyph = """ MATCH (d:Donor) RETURN d.full_name as full_name, d.email as email """ result = session.run(cyph) for record in result: str_build += record['full_name'] + ' -- ' + record['email'] + '\n' e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_donor_list():\n print(data_base.donor_names)", "def print_donors_names():\n update_lists()\n print(\"\\nDonors\")\n print(\"-\"*20)\n for donor in donor_names_list:\n print(donor.fullname)\n print()", "def donor_names():\n names = list()\n for name in donor_db:\n ...
[ "0.8647445", "0.86091745", "0.8363628", "0.8294543", "0.8261974", "0.8257272", "0.82436097", "0.80702305", "0.803861", "0.7964824", "0.7918102", "0.7860304", "0.77405304", "0.7726965", "0.7726133", "0.76032156", "0.7543694", "0.7516772", "0.723975", "0.7172248", "0.69706887",...
0.76344997
15
while response set cookie for language
def process_response(self, request, response): if self.global_country: country=self.global_country response.set_cookie("country", country, max_age = 365 * 24 * 60 * 60) if self.global_ip: ip=self.global_ip response.set_cookie("ip", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setlang(request):\n form = SetLanguageForm(request.POST or None)\n if form.is_valid():\n user_language = form.cleaned_data['language']\n translation.activate(user_language)\n response = HttpResponseRedirect(form.cleaned_data['next'])\n response.set_cookie(settings.LANGUAGE_COO...
[ "0.7516885", "0.7478308", "0.72495776", "0.69879985", "0.68315995", "0.6607537", "0.6452192", "0.6432934", "0.641338", "0.6400235", "0.6345029", "0.63328326", "0.6302819", "0.61197734", "0.6103292", "0.60396004", "0.6007966", "0.5945108", "0.5934018", "0.59221303", "0.5814043...
0.6811134
5
return naive score for game state based on of walls and path lengths only. higher score corresponds to better position (diff in of walls) weights[0] + (diff in path lengths) weights[1]
def state_score_naive(self, game_state, player, weights): # walls score other_players = [p for p in game_state.players if p != player] my_walls = player.num_walls their_walls = max([p.num_walls for p in other_players]) walls_diff = (my_walls - their_walls) # path length s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heuristic(self):\n game_score = (self.get_game_score(), 0.85)\n road_score = (self.get_longest_road_score(), 0.05)\n steps_score = (self.get_steps_available_score(), 0.05)\n reachable_nodes_score = (self.get_reachable_nodes_score(), 0.05)\n heuristics = [game_score, road_scor...
[ "0.6490086", "0.62768745", "0.62624353", "0.62273395", "0.62246174", "0.6164314", "0.61350363", "0.6130807", "0.61227393", "0.61055684", "0.61046237", "0.61025846", "0.60932904", "0.60541034", "0.6036763", "0.6027954", "0.60177416", "0.5984697", "0.5966657", "0.59622574", "0....
0.8018729
0
AlphaBeta Pruning implementation (on NegaMax)
def AlphaBeta(self, game_stack, player, alpha=-INF, beta=INF, minmax=1, depth=2, timeout=None, start_time=None, print_space=" "): game_state = game_stack.current if not start_time: start_time = time() if depth == 0: self.PLY_COUNT += 1 return minmax * self.sco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def beta_gen_posmnt(p):\n return np.array([0.0]*int(0.7*p) + [1.0]*(p-int(0.7*p)))", "def beta_gen_mnt(p):\n return np.array([-1.0]*int(0.7*p) + [1.0]*(p-int(0.7*p)))", "def postProb(self, alpha, beta):\n gamma = None\n\n # -------------------------------------------->\n\n # Your Cod...
[ "0.67056215", "0.6483943", "0.64357585", "0.62955046", "0.6291677", "0.6284179", "0.6258347", "0.6231488", "0.61820066", "0.6167159", "0.6158907", "0.6139848", "0.6135066", "0.61235833", "0.601133", "0.59865373", "0.5951708", "0.59455574", "0.59320253", "0.58954567", "0.58905...
0.6229659
8
Create a PayrollPaymentEmployer with wrong total_amount value, then verify returned total_amount
def test_create_payment_verify_amounts(self): test_shift, _, __ = self._make_shift( shiftkwargs={'status': 'OPEN', 'starting_at': timezone.now(), 'ending_at': timezone.now() + timedelta(hours=8), 'minimum_hourly_rate': 15, 'minimum_allowed_rating': 0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_give_custom_raise(self):\n self.employee.give_raise(self.raise_amount)\n self.assertEqual(70000, self.employee.salary)", "async def test_fail_neagative_amount(self, conn, user_with_wallet):\n amount = Decimal('-3')\n\n with pytest.raises(ValueError) as exc:\n await...
[ "0.5898568", "0.58648705", "0.5838532", "0.58208466", "0.58103573", "0.5786868", "0.57268757", "0.56974876", "0.5693337", "0.5691926", "0.56397843", "0.5626107", "0.56111336", "0.55956995", "0.55766904", "0.55225456", "0.54991996", "0.548934", "0.54852116", "0.54828364", "0.5...
0.688794
0
Get list of all pcodes
def get_pcode_list(self) -> List[str]: return self.pcodes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def codes(self):\n return [card.code for card in self.cards]", "def list():\n\n return cache.codeTableList()", "def codelists():\n return CodelistSet()", "def get_codecs_list():\n for codec in CODECS_IN_FILE.iterkeys():\n print codec", "def pin_code(self) -> List[PinCodeSummary]:\n ...
[ "0.7085422", "0.67058885", "0.6575384", "0.64375883", "0.63980293", "0.63528806", "0.63204837", "0.62434506", "0.6118487", "0.60903996", "0.6030338", "0.5979887", "0.5978733", "0.5978733", "0.5930405", "0.5930405", "0.59237957", "0.5913762", "0.5907415", "0.5897931", "0.58778...
0.8819543
0
Get admin level for country
def get_admin_level(self, countryiso3: str) -> int: admin_level = self.admin_level_overrides.get(countryiso3) if admin_level: return admin_level return self.admin_level
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAdminLevel(self):\n return self.__adminLevel", "def get_info_admin(self):\n return self.get_info(\"HS_ADMIN\")", "def get_level(rol):\n\treturn rol.level", "def getLevels():", "def filter_geolevels(self):\n return self.filter_nodes('/DistrictBuilder/GeoLevels/GeoLevel')", "def...
[ "0.7194143", "0.62322676", "0.6219481", "0.5948711", "0.5923398", "0.5905333", "0.5884878", "0.5834538", "0.5793904", "0.578613", "0.57844114", "0.57259613", "0.5718732", "0.56983316", "0.5696867", "0.5683486", "0.564767", "0.564153", "0.54959315", "0.54895085", "0.5484118", ...
0.8416659
0
Get pcode length for country
def get_pcode_length(self, countryiso3: str) -> Optional[int]: return self.pcode_lengths.get(countryiso3)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_admin1_pcode_length(\n self, countryiso3: str, pcode: str, logname: Optional[str] = None\n ) -> Optional[str]:\n pcode_length = len(pcode)\n country_pcodelength = self.pcode_lengths.get(countryiso3)\n if not country_pcodelength:\n return None\n if (\n ...
[ "0.68004125", "0.6439432", "0.6337102", "0.6254802", "0.6157772", "0.5911685", "0.5899071", "0.589627", "0.5870338", "0.5854779", "0.58445597", "0.581861", "0.57889104", "0.57889104", "0.5745525", "0.56837547", "0.568266", "0.5626178", "0.56086004", "0.5606755", "0.5604039", ...
0.80896854
0
Initialise storage of fuzzy matches, ignored and errors for logging purposes
def init_matches_errors(self) -> None: self.matches = set() self.ignored = set() self.errors = set()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, matches=None):\n super(MatchWarehouse, self).__init__()\n\n if matches is None:\n matches = []\n\n self.matches = matches", "def __init__(self):\n\t\tself.relevances = None", "def __init__ (self, id, finder, matches):\n\t\tself.id = id\n\t\t# self.inCitesName ...
[ "0.6078395", "0.5936211", "0.5737165", "0.57187974", "0.5703025", "0.5700027", "0.56937253", "0.568053", "0.56125456", "0.5599211", "0.55830574", "0.55691487", "0.5546313", "0.551677", "0.5515388", "0.5489945", "0.54630363", "0.5452383", "0.5444116", "0.5426767", "0.5419853",...
0.6887651
0
Standardise pcode length by country and match to an internal pcode. Only works for admin1 pcodes.
def convert_admin1_pcode_length( self, countryiso3: str, pcode: str, logname: Optional[str] = None ) -> Optional[str]: pcode_length = len(pcode) country_pcodelength = self.pcode_lengths.get(countryiso3) if not country_pcodelength: return None if ( pcod...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def country(alpha_2_code: str) -> None:", "def fuzzy_pcode(\n self, countryiso3: str, name: str, logname: Optional[str] = None\n ) -> Optional[str]:\n if (\n self.countries_fuzzy_try is not None\n and countryiso3 not in self.countries_fuzzy_try\n ):\n if l...
[ "0.6864307", "0.6568446", "0.65547794", "0.6446121", "0.62882507", "0.57468176", "0.5739177", "0.56350464", "0.55212307", "0.54924", "0.5483948", "0.5448059", "0.5415295", "0.5406929", "0.53253376", "0.5275046", "0.5250778", "0.5247884", "0.5236473", "0.52082604", "0.51733947...
0.80784714
0
Fuzzy match name to pcode
def fuzzy_pcode( self, countryiso3: str, name: str, logname: Optional[str] = None ) -> Optional[str]: if ( self.countries_fuzzy_try is not None and countryiso3 not in self.countries_fuzzy_try ): if logname: self.ignored.add((logname, countr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_specific_name(name: str, specific_names: list) -> str:\n c = clean_specific_name(name)\n if c == \"\":\n return c\n else:\n y = \"\"\n for x in specific_names:\n matchlist = x.variations.split(\";\")\n if c in matchlist:\n y = x.name\n ...
[ "0.6168389", "0.6139129", "0.6071032", "0.6048621", "0.59267986", "0.58842015", "0.5867975", "0.58635634", "0.5857726", "0.5808192", "0.57797605", "0.5777386", "0.5750848", "0.57491803", "0.5741692", "0.57101977", "0.5661098", "0.56402546", "0.5632278", "0.5581385", "0.557990...
0.7084574
0
Get pcode for a given name
def get_pcode( self, countryiso3: str, name: str, fuzzy_match: bool = True, logname: Optional[str] = None, ) -> Tuple[Optional[str], bool]: pcode = self.admin_name_mappings.get(name) if pcode and self.pcode_to_iso3[pcode] == countryiso3: return pco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_code_by_name(self, name):\n raise NotImplementedError()", "def get_postal_code_by_name(self, name):\n raise NotImplementedError()", "def get_sup_code_by_name(self, name):\n raise NotImplementedError()", "def _find_ebcdic_codec(code_name):\n return _codec_name_to_info_map.get(c...
[ "0.76149344", "0.71305525", "0.7036313", "0.6844629", "0.6432484", "0.62965965", "0.6239966", "0.6187343", "0.615493", "0.61534536", "0.6089407", "0.6023287", "0.5992889", "0.5931902", "0.5912679", "0.5907507", "0.5907507", "0.5907507", "0.5907507", "0.59067315", "0.58612806"...
0.5588202
39
Output log of matches
def output_matches(self) -> List[str]: output = list() for match in sorted(self.matches): line = f"{match[0]} - {match[1]}: Matching ({match[4]}) {match[2]} to {match[3]} on map" logger.info(line) output.append(line) return output
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runTest(self):\n import logging\n lg_name = expector.logger_name\n lg = logging.getLogger(lg_name)\n start_level = logging.getLevelName('DEBUG_9')\n end_level = logging.getLevelName('CRITICAL_0')\n for lvl in range(start_...
[ "0.6703418", "0.6613801", "0.65900517", "0.63869303", "0.6369023", "0.6115638", "0.6093751", "0.59988856", "0.59654194", "0.5937717", "0.59080356", "0.5785938", "0.57386744", "0.5726134", "0.5710062", "0.5642616", "0.5638629", "0.5636376", "0.56320333", "0.5589491", "0.558415...
0.75522673
0
Output log of ignored
def output_ignored(self) -> List[str]: output = list() for ignored in sorted(self.ignored): if len(ignored) == 2: line = f"{ignored[0]} - Ignored {ignored[1]}!" else: line = f"{ignored[0]} - {ignored[1]}: Ignored {ignored[2]}!" logger.i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testIgnore(self):\n\n self.logger.accept('c',self.logger.foo)\n self.logger.accept('c',self.logger.bar)\n self.logger.ignore('c',self.logger.foo)\n messager.send('c')\n # Only one method should have been called.\n self.assertEqual(len(self.logger.log),1)\n # bar...
[ "0.66159654", "0.6615568", "0.6563683", "0.6467158", "0.642576", "0.6407278", "0.62708443", "0.6197979", "0.6185305", "0.61736274", "0.6127977", "0.6110092", "0.6082548", "0.60412055", "0.5980595", "0.59517694", "0.5947568", "0.5855487", "0.5855487", "0.5846926", "0.5795751",...
0.74344534
0
Output log of errors
def output_errors(self) -> List[str]: output = list() for error in sorted(self.errors): if len(error) == 2: line = f"{error[0]} - Could not find {error[1]} in map names!" else: line = f"{error[0]} - {error[1]}: Could not find {error[2]} in map name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_error(err):\n print(err)", "def log_error(e):\n\tprint(e)", "def log_error(e):\n\tprint(e)", "def log_error(e):\r\n print(e)", "def log_error(e):\r\n print(e)", "def log_error(e):\n print(e)", "def log_error(e):\n print(e)", "def log_error(e):\n print(e)", "def log_err...
[ "0.8219414", "0.7850174", "0.7850174", "0.77893627", "0.77893627", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7695965", "0.7679648", "0.74775964", "0.7343273", "0.72861683", "0.7283898", "0.7275389", "0.72702074"...
0.67894155
52
Computes the shape of the output tensor from conv2d operation with the given configuration
def conv2d_output_shape(input_shape, filter_shape, stride, padding): filter_shape = tf.TensorShape(filter_shape).as_list() filter_out = filter_shape[-1] filter_patch_shape = np.array(filter_shape[0:2]) input_shape_list = tf.TensorShape(input_shape).as_list() batch = input_shape_list[:-3] input_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv2d_output_shape(height, width, filter_height, filter_width, out_channels, stride):\n return (out_channels, ((height - filter_height) / stride + 1), ((width - filter_width) / stride + 1))", "def conv2d_config(input_shape, output_shape, filter_shape):\n input_shape = tf.TensorShape(input_shape).as_li...
[ "0.7141855", "0.71263766", "0.6783022", "0.67609066", "0.67609066", "0.67609066", "0.67482084", "0.6741996", "0.6541284", "0.65386385", "0.65204185", "0.65130126", "0.63841397", "0.63688713", "0.635444", "0.6350265", "0.634245", "0.63358814", "0.6334195", "0.6312138", "0.6307...
0.6493665
12
Based on the desired input, output and filter shape, figure out the correct 2D convolution configuration to use including the type (normal or full convolution), stride size, padding type/size
def conv2d_config(input_shape, output_shape, filter_shape): input_shape = tf.TensorShape(input_shape).as_list() if len(input_shape) == 4: batch_size = input_shape[0] else: batch_size = None input_shape = np.array(input_shape[-3:]) output_shape = np.array(tf.TensorShape(output_shape)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv2d(input, filters, image_shape=None, filter_shape=None,\r\n border_mode='valid', subsample=(1, 1), **kargs):\r\n\r\n #accept Constant value for image_shape and filter_shape.\r\n if image_shape is not None:\r\n image_shape = list(image_shape)\r\n for i in xrange(len(image_shape...
[ "0.7666712", "0.75563943", "0.7253493", "0.7151335", "0.70599556", "0.7046664", "0.7006856", "0.69941896", "0.6992957", "0.6988655", "0.69146556", "0.69121355", "0.6907195", "0.6892754", "0.6884804", "0.6874693", "0.6851518", "0.6826805", "0.6826221", "0.6782795", "0.67820716...
0.8330773
0
Given the desired shapes of the input, output and filter tensors, returns the shape of the appropriate convolution filter and a correctly configured op function. The returned op function should be called with the input tensor and weight tensor, and returns a result of 2D convolution that matches the desired output_shap...
def get_convolution_op(input_shape, output_shape, kernel_shape): filter_shape, strides, padding, padded_shape, conv_type, padding_type = conv2d_config(input_shape, output_shape, kernel_shape) if conv_type == 'NORMAL': def conv_op(inputs, weight, name='generic_convolution'): with tf.name_scop...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv2d_config(input_shape, output_shape, filter_shape):\n input_shape = tf.TensorShape(input_shape).as_list()\n if len(input_shape) == 4:\n batch_size = input_shape[0]\n else:\n batch_size = None\n\n input_shape = np.array(input_shape[-3:])\n output_shape = np.array(tf.TensorShape(...
[ "0.78144246", "0.73072946", "0.7246472", "0.7105872", "0.70898974", "0.6981136", "0.680611", "0.6795094", "0.6774584", "0.66701835", "0.66502523", "0.6645472", "0.64855754", "0.64839745", "0.64172703", "0.64024395", "0.63939494", "0.6378876", "0.63567823", "0.6335626", "0.630...
0.79986364
0
L2 normalize weights of the given tensor along specified dimension(s).
def normalize_weights(w, dims=(0,), bias=1e-5): with tf.name_scope('normalization'): return w / (tf.sqrt(tf.reduce_sum(tf.square(w), dims, keep_dims=True) + bias))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def L2_norm(x, axis=-1):\n return keras.backend.l2_normalize(x, axis=axis)", "def norm2d(w_in):\n return nn.BatchNorm2d(num_features=w_in, eps=cfg.BN.EPS, momentum=cfg.BN.MOM)", "def normalize(w: torch.Tensor):\n\n if w.dim() > 1:\n return _matrix(w)\n\n return _vector(w)", "def l2_normali...
[ "0.6906336", "0.6751098", "0.6747886", "0.67012024", "0.66678435", "0.6618368", "0.659822", "0.65933174", "0.6558486", "0.6515114", "0.6459915", "0.64257294", "0.64257294", "0.6387475", "0.6333754", "0.6331633", "0.63164073", "0.63137084", "0.6294328", "0.625288", "0.62514037...
0.7061722
0
Creates and returns a variable initialized with random_normal_initializer, suitable for use as a weight. In the current variable scope, creates (if necessary) and returns a named variable with `tf.random_normal_initializer`.
def weight_variable(shape, name='weight', mean=0.0, stddev=None, initializer=None, constrain=None, dtype=tf.float32): if stddev is None: raise ValueError('stddev not specified!') if initializer is None: initializer = tf.random_normal_initializer(mean=mean, stddev=stddev) weights = tf.get_var...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_random_normal():\n tf.reset_default_graph()\n tf.random.set_random_seed(0)\n rnormal_class = INITIALIZER_REGISTRY['normal']\n rnormal_obj = rnormal_class({\"mean\":0.5, \"std\":0.1})\n tf_init = rnormal_obj.get_entity_initializer(init_type='tf')\n var1 = tf.get_variable(shape=(1000, 100)...
[ "0.71384406", "0.6798357", "0.6797846", "0.67852306", "0.6762905", "0.66798437", "0.66715586", "0.6670965", "0.66580564", "0.66332424", "0.6632297", "0.6625665", "0.6625665", "0.6625665", "0.66211706", "0.6609821", "0.65978444", "0.6589735", "0.6589735", "0.6588253", "0.65617...
0.62627494
58
Creates and returns a variable initialized with random_normal_initializer, suitable for use as a bias. In the current variable scope, creates (if necessary) and returns a named variable with `tf.random_normal_initializer`.
def bias_variable(shape, name='bias', value=0.0, initializer=None, constrain=None, dtype=tf.float32): if initializer is None: initializer = tf.constant_initializer(value=value) biases = tf.get_variable(name, shape=shape, initializer=initializer, dtype=dtype) if constrain is not None: constra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_random_normal():\n tf.reset_default_graph()\n tf.random.set_random_seed(0)\n rnormal_class = INITIALIZER_REGISTRY['normal']\n rnormal_obj = rnormal_class({\"mean\":0.5, \"std\":0.1})\n tf_init = rnormal_obj.get_entity_initializer(init_type='tf')\n var1 = tf.get_variable(shape=(1000, 100)...
[ "0.6998297", "0.69813174", "0.6714513", "0.670017", "0.66862786", "0.6548433", "0.65048385", "0.65048385", "0.64924836", "0.6492119", "0.6483953", "0.6455169", "0.6425284", "0.6387288", "0.6375163", "0.63635606", "0.63576484", "0.6350683", "0.63267416", "0.63231707", "0.63061...
0.0
-1
Find docs root, or call pytest.skip
def docs_root(): start, result = get_docs_root() if result is None: pytest.skip(f"No directory '{DOCS_DIR}' found from '{start}'") yield result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_docs_paths():\n assert os.path.exists('test/examples/docs/paths-root-api.md')\n assert os.path.exists('test/examples/docs/paths-subpath1.md')\n assert os.path.exists('test/examples/docs/paths-subpath1.md')", "def test_docdir(self):\n self.chck_triple('docdir')", "def test_all_doc_tests...
[ "0.7076463", "0.67410463", "0.6464617", "0.6399846", "0.63957447", "0.6295307", "0.62140745", "0.613874", "0.60084933", "0.59414864", "0.5931416", "0.59260744", "0.5925133", "0.58925974", "0.5859824", "0.5841973", "0.58112466", "0.58080333", "0.57987845", "0.57556814", "0.571...
0.7885804
0
See if EDB can be instantiated, or call pytest.skip
def electrolytedb(): if not check_for_mongodb(): pytest.skip("MongoDB is required")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_init(self):\n self.assertIsNotNone(DatabaseIntermediary(), self.ec.db)", "def test_410_000_non_existant_db(self):\n with TDC() as temp_dir:\n file = Path(temp_dir) / 'database.db'\n self.assertFalse(file.exists(),'Database file exists pre test')\n eng = Eng...
[ "0.6687451", "0.65198994", "0.6487531", "0.64061683", "0.63104695", "0.6235148", "0.61678445", "0.6162714", "0.6143305", "0.61321855", "0.6115058", "0.6095546", "0.60929483", "0.6084231", "0.60771376", "0.606847", "0.6052603", "0.60399115", "0.6036643", "0.60104144", "0.58981...
0.7219592
0
Gets the configs of this ContainerSettingsDTO.
def configs(self): return self._configs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configs(self):\n\n return self.__configs", "def config(self) -> dict:\n return self._configs", "def configs(self) -> list[Config]:\n return self._configs", "def get_configurations(self, obj):\n configs = obj.configs.all()\n serializer = SimpleExportConfigSerializer(conf...
[ "0.77744806", "0.7518531", "0.7510472", "0.6783861", "0.6663737", "0.66454476", "0.66389966", "0.65157944", "0.6432543", "0.64156866", "0.6349658", "0.6349236", "0.6326783", "0.63180244", "0.63180244", "0.63180244", "0.6313971", "0.6289116", "0.6289116", "0.62610984", "0.6259...
0.7751695
1
Sets the configs of this ContainerSettingsDTO.
def configs(self, configs): self._configs = configs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_config(self, cfg):\n\n cfg.add_section(self.name)\n for attr, value in self.__dict__.items():\n if value not in [\"false\", \"none\", \"0\"] and attr != \"name\":\n attr = attr.replace(\"_\", \"-\")\n\n # key-mgmt=none is a mandatory assignment for WE...
[ "0.58845645", "0.5880515", "0.57816756", "0.57437843", "0.571305", "0.5670474", "0.56298476", "0.56061596", "0.55737495", "0.55698293", "0.55454767", "0.5534653", "0.5534653", "0.5534653", "0.55141705", "0.5474932", "0.53934497", "0.5365268", "0.5358987", "0.53561044", "0.535...
0.6992886
0
Gets the resources of this ContainerSettingsDTO.
def resources(self): return self._resources
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resources(self) -> \"Resources\":\n return self._resources", "def resources(self):\n return self.__resources", "def resources(self):\n\n return self.FIXTURE.resources_collection(self)", "def getResources(self):\n\t\treturn deepcopy(self.server.resources)", "def get_resources(self):\n ...
[ "0.70779085", "0.6902169", "0.68907344", "0.68118805", "0.66041344", "0.65386146", "0.65386146", "0.6473444", "0.6443075", "0.64375347", "0.640277", "0.640277", "0.640277", "0.640277", "0.6349583", "0.6308077", "0.62795025", "0.6172169", "0.6101895", "0.604156", "0.6012091", ...
0.7176668
2
Sets the resources of this ContainerSettingsDTO.
def resources(self, resources): self._resources = resources
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resources(self, value):\n self._resource_objects = value", "def resources(self, resources):\n\n self._resources = resources", "def resources(self, resources):\n\n self._resources = resources", "def resources(self, resources):\n\n self._resources = resources", "def resources(...
[ "0.6526639", "0.6505281", "0.6505281", "0.6505281", "0.6505281", "0.5930606", "0.5805928", "0.55509865", "0.55400944", "0.5351522", "0.5343026", "0.5336851", "0.5330234", "0.5276501", "0.5266615", "0.5266615", "0.5239786", "0.5237074", "0.52323866", "0.51405156", "0.51136523"...
0.6537196
0
Returns the model properties as a dict
def to_dict(self): result = {} for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict(self):\n return self.properties", "def to_dict(self):\n return self.properties", "def get_properties(self):\n return self.properties", "def asdict(self):\n return self._prop_dict", "def json(self):\n rv = {\n prop: getattr(self, prop)\n f...
[ "0.7751993", "0.7751993", "0.73391134", "0.7334895", "0.7297356", "0.727818", "0.7159078", "0.71578115", "0.71494967", "0.71494967", "0.71283495", "0.71275014", "0.7122587", "0.71079814", "0.7060394", "0.7043251", "0.7034103", "0.70233124", "0.69635814", "0.69586295", "0.6900...
0.0
-1
Returns the string representation of the model
def to_str(self): import simplejson as json if six.PY2: import sys reload(sys) sys.setdefaultencoding("utf-8") return json.dumps(sanitize_for_serialization(self), ensure_ascii=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self) -> str:\n # noinspection PyUnresolvedReferences\n opts = self._meta\n if self.name_field:\n result = str(opts.get_field(self.name_field).value_from_object(self))\n else:\n ...
[ "0.85856134", "0.7814518", "0.77898884", "0.7751367", "0.7751367", "0.7712228", "0.76981676", "0.76700574", "0.7651133", "0.7597206", "0.75800353", "0.7568254", "0.7538184", "0.75228703", "0.7515832", "0.7498764", "0.74850684", "0.74850684", "0.7467648", "0.74488163", "0.7442...
0.0
-1
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, ContainerSettingsDTO): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.80886984", "0.80886984", "0.8055307", "0.7983415", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", "0.79673034", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
_uniform_order_statistic_cdf(i, n, x) > Pr[U_(i) < x] Let U_1, ..., U_n ~ Uniform[0,1] be n independent random variables and let U_(1) < ... < U_(n) denote the same variables in sorted order. Then U_{(i)} ~ Beta(i, ni+1) This function returns the Cumulative Distribution function of U_(i), i.e. the return value is Pr[U_...
def _uniform_order_statistic_cdf(i, n, x): return betainc(i, n-i+1, x)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uniform_cdf(x):\n if x <0: return 0 #uniform random is never less than 0\n elif x < 1: return x #e.g. P(x <= 0.4) = 0.4\n else: return 1 #uniform random is always less than 1", "def uniform_cdf(x: float) -> float:\n if x < 0: return 0 # uniform random is never les...
[ "0.6810556", "0.66873217", "0.6532582", "0.61932427", "0.6031655", "0.5951562", "0.58816993", "0.5845623", "0.5833746", "0.5804201", "0.5792395", "0.57640696", "0.571037", "0.5705995", "0.5701245", "0.5682896", "0.56571573", "0.56272", "0.5618689", "0.5618689", "0.55853397", ...
0.82678026
0
Probability of having Mn_plus < x under the null hypothesis that X_1,...X_n ~ U[0,1]
def Mn_plus_distribution(n, x): b_bounds = Mn_plus_bounds(n, x) return 1.0 - crossprob.ecdf1_new_b(b_bounds) #return 1.0 - crossprob.ecdf2(b_bounds, [1]*len(b_bounds), True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prob_extinct(Z0, t, n, s, u):\n p = 1\n for k in range(len(Z0)):\n p *= Phi_k(Phit(t - 1, List([0.] * n), s, u), k, s, u) ** Z0[k]\n return p", "def prob1(n):\n#raise NotImplementedError(\"Problem 1 Incomplete\")\n if n == 0 :\n raise ValueError(\"Sampling 0 points is not defined.\"...
[ "0.62147534", "0.62030524", "0.6169988", "0.6028174", "0.60157955", "0.59990734", "0.5986832", "0.5863503", "0.5770678", "0.5767007", "0.5748054", "0.571745", "0.5708238", "0.570814", "0.57026434", "0.5689939", "0.56877863", "0.56754845", "0.5674975", "0.5674324", "0.5639557"...
0.6315941
0
Binary search for x such that Mn_plus_distribution(n,x) = alpha
def inverse_Mn_plus(n, alpha, debug_prints): low = 0.0 high = 1.0 last_range = None for i in range(N_BINARY_SEARCH_STEPS_MAX): if last_range == (low, high): if debug_prints: print('last_range == (low, high)') break last_range = (low, high) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Mn_plus_distribution(n, x):\n b_bounds = Mn_plus_bounds(n, x)\n return 1.0 - crossprob.ecdf1_new_b(b_bounds)\n #return 1.0 - crossprob.ecdf2(b_bounds, [1]*len(b_bounds), True)", "def uniform_search(fun, a, b, E, n=3, counter=0):\n if b - a < E:\n return (b + a) / 2, counter\n step = (b ...
[ "0.6465277", "0.6061245", "0.5888871", "0.5797817", "0.5765356", "0.5671757", "0.5607599", "0.5555103", "0.55197906", "0.5511107", "0.55038816", "0.54853624", "0.54679406", "0.54563314", "0.5429234", "0.5415453", "0.5410396", "0.540519", "0.5405174", "0.53945506", "0.53716695...
0.68880993
0
Return epidemic curves for region.
def epidemic_curve(self, disease=None, **kwargs) -> pd.DataFrame: disease = get_disease(disease) return disease.epidemic_curve(self.region, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def curves(self):\n return self._curve_reg", "def get_ergodic_region(self):\n return [self.f1(self.rho),self.f0(self.rho)]", "def pcurve(self, edge):\n crv, umin, umax = BRep_Tool().CurveOnSurface(\n edge.topods_shape(), self.topods_shape()\n )\n return crv, Interv...
[ "0.63937724", "0.612072", "0.5898211", "0.5730005", "0.549379", "0.5446748", "0.54353255", "0.53812855", "0.52399015", "0.52078134", "0.5206522", "0.52010757", "0.5192675", "0.51835597", "0.51711965", "0.51685727", "0.516798", "0.51506317", "0.51501995", "0.5141728", "0.51417...
0.66410077
0
Return an object with all disease params associated with region.
def disease_params(self, disease=None, **kwargs) -> DiseaseParams: disease = get_disease(disease) return disease.params(region=self.region, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getInstancesD(region):\n instances = getInstances(region)\n instancesDicts = {\"id\": i.id,\n \"KEEP-tag\": getKeepTag(i),\n \"instance_type\": i.instance_type,\n \"state\": i.state,\n \"launch_time\": i.launch_time,\n ...
[ "0.6466593", "0.5933232", "0.5927578", "0.5650755", "0.5570527", "0.53803927", "0.5303424", "0.5287746", "0.52594393", "0.5248532", "0.5245481", "0.51979876", "0.5142148", "0.5135589", "0.5133899", "0.5121197", "0.51110876", "0.50974685", "0.50969887", "0.5096218", "0.5084624...
0.6674379
0
Compute R(t) from the epidemic curves. This is function is just a
def estimate_Rt(self, model, disease=None, **kwargs) -> pd.DataFrame: return self._estimate_R(fit.estimate_Rt, model, disease, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roty(t):\n c = np.cos(t)\n s = np.sin(t)\n return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]])", "def r(o, t):\n return o*t**0.5", "def roty(t):\n c = np.cos(t)\n s = np.sin(t)\n return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]])", "def roty(self, t):\n c = np.cos(...
[ "0.64894414", "0.64871705", "0.6484093", "0.6472015", "0.6465407", "0.64194566", "0.63979536", "0.63979536", "0.63979536", "0.63979536", "0.6347835", "0.6246034", "0.6158998", "0.61556244", "0.612081", "0.60464966", "0.6039824", "0.6020548", "0.59570783", "0.5941917", "0.5919...
0.0
-1
Compute R0 from the epidemic curves. This is function is just a
def estimate_R0(self, model, disease=None, **kwargs) -> ValueStd: return self._estimate_R(fit.estimate_R0, model, disease, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def r0(self):\n return self.p[0] / self.p[1]", "def get_rzero(self):\n return self.get_resistance() * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))", "def get_rzero(self):\n return self.get_resistance() * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))", "def rv_from_r0v0(mu, R0,...
[ "0.68317735", "0.66767144", "0.66767144", "0.6511206", "0.6323862", "0.62401706", "0.6164973", "0.6043738", "0.6029561", "0.6011732", "0.59364796", "0.5933048", "0.58857876", "0.5882551", "0.5879773", "0.5853732", "0.5850941", "0.5838167", "0.5831559", "0.580826", "0.57869303...
0.57600397
22
Compute K(t) from the epidemic curves. This is function is just a
def estimate_Kt(self, disease=None, **kwargs) -> pd.DataFrame: return self._estimate_K(fit.estimate_Kt, disease, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _k(self, T):\n RT = Rgas * T\n return (self.parameters.A1 / np.exp(self.parameters.E1 / RT),\n self.parameters.A2 / np.exp(self.parameters.E2 / RT))", "def E2K(E):\n return sqrt(E/2.0723)", "def K(p, E):\n R_loss, E_loss = p\n K_ = (8.0/pi**2)*R_loss*E_loss**2 * E / ((...
[ "0.72949606", "0.68840677", "0.66543484", "0.66317314", "0.6623678", "0.65630686", "0.6497177", "0.6467203", "0.64360315", "0.6280468", "0.6248467", "0.6202558", "0.61973745", "0.6180712", "0.61469555", "0.61094", "0.60734826", "0.6054075", "0.6050879", "0.6050879", "0.604047...
0.0
-1
Compute K from the epidemic curves. This is function is just a
def estimate_K(self, disease=None, **kwargs) -> ValueStd: return self._estimate_K(fit.estimate_K, disease, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def E2K(E):\n return sqrt(E/2.0723)", "def energyK(k):\r\n C1 = 9.7846113e-07\r\n C2 = 12.263868e0 \r\n E = (-1.0 + np.sqrt(1.0 + 4.0 * C1 * C2**2 * k**2))/(2.0 * C1)\r\n return E", "def K(p, E):\n R_loss, E_loss = p\n K_ = (8.0/pi**2)*R_loss*E_loss**2 * E / ((2.0*E_loss/pi)**2 + E**2)**2\...
[ "0.73452586", "0.7132003", "0.69813544", "0.693446", "0.6920138", "0.69113845", "0.66754484", "0.6447015", "0.6447015", "0.6443218", "0.6425994", "0.6422214", "0.6419491", "0.63766694", "0.63710374", "0.6330453", "0.63301593", "0.6309316", "0.6291866", "0.6286026", "0.6263551...
0.0
-1
Returns a different string depending on the divisiblity of `n`
def fizz_buzz(n: int) -> str: if (n % 3 == 0) and (n % 5 == 0): return "fizz buzz" elif n % 5 == 0: return "buzz" elif n % 3 == 0: return "fizz" else: return str(n)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fo_shizzle_my_nizzle(n): \n if n < 0:\n n = \"fo\"\n elif n >= 1 and n < 50: \n n = \"shizzle\"\n elif n >= 50 and n <= 100:\n n = \"my\"\n elif n % 2 == 0 and n % 3 == 0 and n > 100:\n n = \"nizzle\"\n else:\n n = \"\"\n return n", "def diviseur(n):\n ...
[ "0.7259928", "0.70827156", "0.6592846", "0.6526491", "0.65242153", "0.6451256", "0.6427033", "0.628177", "0.6251375", "0.62362874", "0.6216677", "0.6185278", "0.61813086", "0.617128", "0.6162179", "0.6160973", "0.6146254", "0.61411893", "0.6123887", "0.61186016", "0.6115077",...
0.6117437
20
Init VendingMachine with the following data
def __init__(self): self.initSt = InitState(self) #The init state of vending machine self.acSt = AcceptCoinsState(self) #the state of accepting coins vending machine self.current = self.initSt #set current state as init state self.coins = {10: 0, 5: 0, 2: 0, 1: 0} #the coins the ven...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, machine, vm_name):\n self.machine = machine\n self.vm_name = vm_name", "def setup(self):\n self.machine = Machine(['a', 'b', 'c', '_'])", "def __init__(self, nodeid, sessionID):\r\n \r\n # iv = b\"1234567890123456\" is an aexample\r\n # \r\n s...
[ "0.64964634", "0.6405333", "0.60457885", "0.6045047", "0.60447496", "0.6022202", "0.5988322", "0.5986985", "0.59785813", "0.5976598", "0.5906512", "0.5897219", "0.5891987", "0.588027", "0.588027", "0.58712804", "0.58700997", "0.58614844", "0.5843164", "0.58296406", "0.5817777...
0.6518033
0
This method trigger the deal after inserting coins
def choosePrd(self, prd): if prd not in vmdata.prdStore: return False, "Product out of range", {} try: ret = self.current.choosePrd(prd) return ret except: logging.error("Choose product %s error"%(prd)) self.backCoins()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eat_coin(self):\r\n self.app.coins.remove(self.grid_pos)\r\n self.current_score += 1", "def on_update(self):\n \n # update physics engine\n \n \n # use code from pick up coins lab to pick up coins\n # you don't need all of the code from that lab(no game...
[ "0.63398266", "0.582722", "0.580853", "0.58076984", "0.5788367", "0.5782806", "0.57482123", "0.56948876", "0.56943834", "0.5643464", "0.56421494", "0.5631409", "0.5612311", "0.5608628", "0.5595058", "0.55880266", "0.5550543", "0.55434036", "0.5534455", "0.55266035", "0.549147...
0.0
-1
Insert coins during one transaction
def insertCoins(self, coin, num): if coin not in self.coins or not isinstance(num, int) or num < 1: return False, 'Coin out of range', {} try: return self.current.insertCoins(coin, num) except: logging.error("Insert coins %d, %d error"%(coin, num)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_coins(user, amount, transaction=0):\n # below line of code creates table row for user if none exists\n UserCoins.objects.get_or_create(user=user)\n user_row = UserCoins.objects.get(user=user)\n old_coins_value = user_row.coins\n user_row.coins = old_coins_value + amount\n user_row.save()\...
[ "0.698471", "0.6537541", "0.6379954", "0.6226484", "0.62245494", "0.60380703", "0.60310745", "0.59967124", "0.5985816", "0.5949179", "0.592391", "0.58924115", "0.58773446", "0.5870351", "0.5863376", "0.58586454", "0.58495915", "0.58109194", "0.580317", "0.5770436", "0.5767409...
0.67508155
1
Return coins and reset the status of the vending machine
def backCoins(self): return self.current.backCoins()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(connection, info, args, world) :\n money = shelve.open(\"money-%s.db\" % (world.hostnicks[connection.host]), writeback=True)\n money[info[\"sender\"]] = {\"money\":100000, \"maxmoney\":100000, \"items\":[], \"coinchance\":[True for x in range(50)] + [False for x in range(50)]}\n money.sync()\n ...
[ "0.63253546", "0.62539476", "0.6113882", "0.59066904", "0.58940727", "0.58258957", "0.58069503", "0.57796663", "0.5688194", "0.56394464", "0.5608245", "0.55719984", "0.55197906", "0.5474569", "0.54321903", "0.5383666", "0.53704965", "0.5327827", "0.53227025", "0.530484", "0.5...
0.50810355
50
Used by admin users to add products
def adminAddPrdStore(self, prd, num): if not self.__checkProduct(prd, num): return False, "parameter error", {} try: ret = vmdata.addPrdStore(prd, num) return True, "Add success, current product store", ret[1] except: logging.error("Add product er...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_products():\n result = order_obj.add_products(request.forms) \n return result", "def add(self, product):\n pass", "def add_product(self):\n self.owner.new_product(self.barcode, self.description, self.price, self._add_product_callback)", "def add_new_product():\n name = request....
[ "0.7568157", "0.7366292", "0.71982646", "0.7197333", "0.706601", "0.70291626", "0.69708", "0.6937126", "0.6903837", "0.68985265", "0.6838576", "0.6837676", "0.6822912", "0.68202525", "0.6811099", "0.67708844", "0.6762318", "0.6730638", "0.67175245", "0.66974807", "0.6647193",...
0.6243066
59
Used by admin users to add coins
def adminAddCoinStore(self, coin, num): if not self.__checkCoin(coin, num): return False, "parameter error", {} try: ret = vmdata.addCoinStore(coin, num) return True, "Add success, current product store", ret[1] except: logging.error("Add coin err...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deposit_coins(user_id: int, coins: int):\r\n if not Wealth.collection.find_one({\"_id\": user_id}):\r\n return\r\n Wealth.collection.update_one({\"_id\": user_id}, {\"$inc\": {\r\n \"Bank\": coins,\r\n \"coins\": -coins\r\n }})", "def add_coins(user, amo...
[ "0.708093", "0.6987229", "0.6967438", "0.6810342", "0.6771658", "0.66988325", "0.66147524", "0.6549308", "0.65241677", "0.64579535", "0.6348769", "0.6284205", "0.6229427", "0.62180835", "0.6186924", "0.6175652", "0.61401165", "0.61207336", "0.61193335", "0.6108365", "0.607669...
0.62727094
12
Used by admin users to reduce products
def adminSubPrdStore(self, prd, num): if not self.__checkProduct(prd, num): return False, "parameter error", {} try: ret = vmdata.subPrdStore(prd, num) if not ret[0]: return False, "sub error", ret[1] return True, "Sub success", ret[1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product(self):\n return None", "def product(self):\n return None", "def extra_products(self, target):\r\n return []", "def products(request):\n\n if not request.user.is_superuser:\n messages.error(request, 'Sorry, only store owners can do that.')\n return redirect(revers...
[ "0.61422783", "0.61422783", "0.5951879", "0.59135807", "0.58547384", "0.5834483", "0.57707554", "0.57575434", "0.5754968", "0.5750889", "0.5703468", "0.57012475", "0.5608239", "0.5608239", "0.5551132", "0.5551132", "0.5537394", "0.5537394", "0.552811", "0.55109894", "0.549228...
0.0
-1
Used by admin users to reduce coins
def adminSubCoinStore(self, coin, num): if not self.__checkCoin(coin, num): return False, "parameter error", {} try: ret = vmdata.subCoinStore(coin, num) if not ret[0]: return False, "sub error", ret[1] return True, "Sub success", ret[1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deposit_coins(user_id: int, coins: int):\r\n if not Wealth.collection.find_one({\"_id\": user_id}):\r\n return\r\n Wealth.collection.update_one({\"_id\": user_id}, {\"$inc\": {\r\n \"Bank\": coins,\r\n \"coins\": -coins\r\n }})", "async def admin_credit(...
[ "0.6545462", "0.6495932", "0.6430529", "0.6413446", "0.62744", "0.622206", "0.62024534", "0.6192329", "0.617924", "0.6165376", "0.6081028", "0.60735565", "0.60004836", "0.59908026", "0.5972307", "0.5934436", "0.5923204", "0.5914647", "0.5882787", "0.587087", "0.58633214", "...
0.0
-1
Check product parameters range
def __checkProduct(self, prd, num): if prd not in vmdata.prdStore or not isinstance(num, int) or num < 1: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_binning_parameter_range(x_min, x_max, ws_unit):\n if ws_unit == 'dSpacing' and not 0 < x_min < x_max < 20:\n # dspacing within (0, 20)\n x_range_is_wrong = True\n elif ws_unit == 'TOF' and not 1000 < x_min < x_max < 1000000:\n # TOF withi...
[ "0.66242605", "0.65069777", "0.6448718", "0.62934124", "0.62767833", "0.62111557", "0.61934936", "0.6188206", "0.6166588", "0.60972905", "0.60848993", "0.60469574", "0.60454434", "0.6029421", "0.59773415", "0.5949658", "0.5946287", "0.59168977", "0.59074026", "0.58674496", "0...
0.61208093
9
Check coin parameters range
def __checkCoin(self, coin, num): if coin not in vmdata.coinStore or not isinstance(num, int) or num < 1: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self):\n self.lower_bound(5e-4)\n self.upper_bound(5e2)", "def test_random_100_balance_remains_between_1_and_negative_1(bst_100_rand):\n assert bst_100_rand.balance() in range(-1, 2)", "def bet_check(m):\n try:\n value = float(m.content)\n ...
[ "0.63133484", "0.6164184", "0.6117925", "0.6082434", "0.5993639", "0.5973079", "0.5938973", "0.5933883", "0.5921676", "0.587952", "0.5829214", "0.5785488", "0.5763044", "0.57502514", "0.5746472", "0.572833", "0.56756526", "0.5673943", "0.5661126", "0.5655516", "0.56466657", ...
0.56853634
16
Likelihood ratio estimation through parameterized or morphingaware versions of CARL, CASCAL, ROLR, and RASCAL.
def flow_inference(algorithm='maf', training_sample='baseline', # 'baseline', 'basis', 'random' use_smearing=False, denominator=0, alpha=None, training_sample_size=None, do_neyman=False, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def like_ratio(null_model, alt_model, df=1):\n D = -2 * (null_model.llf - alt_model.llf)\n return {\"D\" : D, \"p_val\" : 1 - sp.stats.chi2.cdf(D, df)}", "def make_rat():\n rats_path = os.path.dirname(__file__)\n models_path = os.path.join(rats_path, '..', 'models')\n recon22_path = os.path.join(m...
[ "0.5733507", "0.5639946", "0.5637987", "0.56333137", "0.5599177", "0.559191", "0.5533927", "0.5457731", "0.53801686", "0.5363262", "0.53165144", "0.525987", "0.5256534", "0.52348727", "0.5225394", "0.5209382", "0.5192248", "0.5166432", "0.5155094", "0.51527745", "0.51475775",...
0.0
-1
This method searches the current room to use if a room exists in that direction
def find_next_room(self, direction): name_of_room = getattr(self.current_location, direction) return globals()[name_of_room]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_current_room(self, all_rooms, room_to_find):\n\t\t# essentially loops like this are the bridge between the 'surface' grid and the 'room type' grid.\n\t\t# since they aren't the same object, we have to find the -corresponding- room in the second grid \n\t\t# by matching coordinates with the first grid, whi...
[ "0.6759879", "0.67582697", "0.672917", "0.6539422", "0.65294915", "0.64002275", "0.6318787", "0.6184047", "0.61720496", "0.5984885", "0.596243", "0.5929839", "0.58770704", "0.5874649", "0.5789557", "0.57715446", "0.57471704", "0.57250327", "0.57210284", "0.5715025", "0.566129...
0.64043075
6
Return all subsribers for supplied team.
def subscribed(cls, team): return cls.query( cls.status == 'subscribe', cls.team == team.lower() ).fetch(100)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAllTeams(self):\n return []", "def get_teams():", "def get_people(team):", "def get_all_teams(self):\n return self._db.Teams.find({})", "def teams(self):\n return self._get_by_class(Team)", "def get_teams(self):\n url = 'teams'\n result = self.get(url)\n r...
[ "0.63358724", "0.6321975", "0.6177048", "0.6088357", "0.604312", "0.5971021", "0.58856934", "0.588073", "0.587088", "0.5865922", "0.5714778", "0.57009053", "0.569305", "0.5687428", "0.5685705", "0.5673648", "0.56649804", "0.5646325", "0.56376255", "0.5625711", "0.55905354", ...
0.65085346
0
Get SubscriberUpdate models for supplied date and team.
def get_updates(cls, date, team): return cls.query( cls.date == date, cls.team == team.lower() ).order(-cls.name).fetch(100)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_updates(self, *args, **kwargs):\n\n updates_data = api.get_updates(\n *args,\n api_key=self.__creds.api_key_v2, \n **kwargs)\n return [en.Update(creds=self.__creds, **update_data) for update_data in updates_data]", "def subscribed(cls, team):\n return...
[ "0.5327516", "0.51273704", "0.5070071", "0.49457774", "0.49449366", "0.4896177", "0.4709884", "0.4666596", "0.4608635", "0.46072033", "0.45786855", "0.45358518", "0.45247075", "0.4524169", "0.44930673", "0.44742814", "0.4457868", "0.44363648", "0.44342363", "0.44187498", "0.4...
0.68186045
0
Returns the latest Update entity for a team.
def latest(cls, team): return cls.query( cls.team == team.lower() ).order(-cls.date).get()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_team(self):\n try:\n team_id = self.request.GET.get('team')\n if team_id is not None:\n team_id = int(team_id)\n return self.get_available_teams().get(pk=team_id)\n return self.get_available_teams().latest()\n except (Team.DoesNot...
[ "0.64540523", "0.6395068", "0.6357223", "0.6178414", "0.6149434", "0.584595", "0.58045524", "0.56917953", "0.55864483", "0.5518969", "0.55044276", "0.55032736", "0.5442801", "0.53913397", "0.5334119", "0.525284", "0.5211612", "0.52074313", "0.51889384", "0.5177728", "0.516420...
0.6974967
0
Convert redis type string to internal num type
def redis_type_to_id(key_type): if key_type == b'string' or key_type == 'string': return REDIS_TYPE_ID_STRING elif key_type == b'hash' or key_type == 'hash': return REDIS_TYPE_ID_HASH elif key_type == b'list' or key_type == 'list': return REDIS_TYPE_ID_LIST elif key_type == b'set...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type_id_to_redis_type(type_id):\n if type_id == REDIS_TYPE_ID_STRING:\n return 'string'\n elif type_id == REDIS_TYPE_ID_HASH:\n return 'hash'\n elif type_id == REDIS_TYPE_ID_LIST:\n return 'list'\n elif type_id == REDIS_TYPE_ID_SET:\n return 'set'\n elif type_id == RE...
[ "0.6211685", "0.6147296", "0.61201614", "0.6111445", "0.60996497", "0.6079422", "0.6075973", "0.60422283", "0.6009427", "0.5990054", "0.5963593", "0.59623456", "0.58752596", "0.5865986", "0.58636194", "0.5804187", "0.5778503", "0.5744982", "0.5733826", "0.5726639", "0.5723849...
0.6015907
8
Convert internal type id to Redis string type
def type_id_to_redis_type(type_id): if type_id == REDIS_TYPE_ID_STRING: return 'string' elif type_id == REDIS_TYPE_ID_HASH: return 'hash' elif type_id == REDIS_TYPE_ID_LIST: return 'list' elif type_id == REDIS_TYPE_ID_SET: return 'set' elif type_id == REDIS_TYPE_ID_ZS...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redis_type_to_id(key_type):\n if key_type == b'string' or key_type == 'string':\n return REDIS_TYPE_ID_STRING\n elif key_type == b'hash' or key_type == 'hash':\n return REDIS_TYPE_ID_HASH\n elif key_type == b'list' or key_type == 'list':\n return REDIS_TYPE_ID_LIST\n elif key_t...
[ "0.7281548", "0.6359385", "0.6330965", "0.6315196", "0.620949", "0.6206852", "0.6145703", "0.61406946", "0.61188096", "0.6073481", "0.60497135", "0.5980722", "0.59672964", "0.5944503", "0.5940098", "0.5937949", "0.5930817", "0.59159756", "0.5902758", "0.58981353", "0.5855464"...
0.77587336
0
Pytest fixture function that manages the test's Setup and Teardown. Creates the Chrome WebDriver and quits it once all test cases are done.
def driver(): driver = webdriver.Chrome(chrome_options=ChromeOptions(), project_name="Examples", job_name="Pytest Example") yield driver driver.quit()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def driver():\n utils.LOG.info(\"********** This is the SETUP fixture to run before your scope of your fixture *********\")\n\n driver = webdriver.Chrome()\n #driver.maximize_window()\n driver.implicitly_wait(20) # read more about this\n utils.LOG.info(\"********** SETUP fixture completed ********...
[ "0.75688964", "0.7323094", "0.69764626", "0.68279016", "0.6701204", "0.6666269", "0.6654348", "0.6607365", "0.6592694", "0.6541534", "0.6508086", "0.64661705", "0.6380483", "0.63782114", "0.631984", "0.631984", "0.631984", "0.6288537", "0.62832713", "0.6267276", "0.62633723",...
0.70041144
2
A simple login test on TestProject's example webpage.
def test_pytest_example(driver): driver.get("https://example.testproject.io/web/") driver.find_element(By.CSS_SELECTOR, "#name").send_keys("John Smith") driver.find_element(By.CSS_SELECTOR, "#password").send_keys("12345") driver.report().step(description="Login Information provided", message="Step Messa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_login(self):\n url_extend = 'user_auth/login/'\n self.browser.get(self.url + url_extend)\n\n # enter the username and password.\n username_field = self.browser.find_element_by_name('user_name')\n username_field.send_keys('user4')\n password_field = self.browser.fi...
[ "0.7941793", "0.78163457", "0.7807648", "0.7766768", "0.7709462", "0.76726735", "0.7657916", "0.7585869", "0.75743407", "0.7525438", "0.7520207", "0.7486687", "0.74707264", "0.74223596", "0.7418195", "0.7385501", "0.73773074", "0.7370986", "0.7370986", "0.7370536", "0.7370472...
0.7295911
26
Interpolates forward rates as described by EIOPA (constant forward rates between liquid maturities).
def compute_fwd_interpolation(fwd, swap_rate_end, zero_rates_known, start_tenor, end_tenor): left_side_1 = sum([1. / ((1+rate)**(t+1)) for t, rate in enumerate(zero_rates_known)]) left_side_2 = sum([1. / ((1+fwd)**t) for t in range(1, end_tenor - start_tenor + 1)]) left_side = left_side_1 + (1. / (1+zero_ra...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x):\n\n x, _ = equiangular_calculator(x, self.ratio)\n x = x.permute(0, 3, 1, 2)\n x = F.interpolate(x, scale_factor=(self.kernel_size, self.kernel_size), mode=\"nearest\")\n x = reformat(x)\n return x", "def forward(self, inputs, *args):\n\n x = equian...
[ "0.6238013", "0.6139308", "0.6042924", "0.58140945", "0.5716752", "0.5711481", "0.5675065", "0.55090857", "0.55012673", "0.5476397", "0.54607135", "0.5423852", "0.5368643", "0.5358152", "0.5297584", "0.5252634", "0.52459544", "0.52129716", "0.5212295", "0.5173325", "0.5163943...
0.55001736
9
Error function for numeric procedure required to interpolate between observed liquid market rates
def error_fwd_interpolation(fwd, args): swap_rate_end = args[0] zero_rates_known = args[1] start_tenor = args[2] end_tenor = args[3] res = compute_fwd_interpolation(fwd, swap_rate_end, zero_rates_known, start_tenor, end_tenor) return np.abs(res-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def InterpolationDerivs(self, , p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=.....
[ "0.6493209", "0.6388022", "0.6387018", "0.6266598", "0.6249921", "0.6218584", "0.6218584", "0.6084873", "0.6061963", "0.5992245", "0.5981275", "0.587319", "0.58647186", "0.5848457", "0.58446187", "0.58008885", "0.57904935", "0.57511055", "0.5745589", "0.57400787", "0.57338953...
0.5600322
29
Interpolates forward rates according to methodology described by EIOPA review 2020.
def interpolate_fwd(fwd, swap_rate_end, zero_rates_known, start_tenor, end_tenor): # Optimization tolerance TOLERANCE = 1e-10 # Number of assets number_of_fwds = len(fwd) # Long only weights to be assigned bound = (-1.0, 1.0) bounds = tuple(bound for asset in range(number_of_fwds)) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_fwd_interpolation(fwd, swap_rate_end, zero_rates_known, start_tenor, end_tenor):\n left_side_1 = sum([1. / ((1+rate)**(t+1)) for t, rate in enumerate(zero_rates_known)])\n left_side_2 = sum([1. / ((1+fwd)**t) for t in range(1, end_tenor - start_tenor + 1)])\n left_side = left_side_1 + (1. / (1...
[ "0.6569869", "0.62380683", "0.612322", "0.60542387", "0.59801924", "0.5959159", "0.5850267", "0.58480006", "0.58421123", "0.5837055", "0.58172905", "0.57659614", "0.5594517", "0.552902", "0.5475251", "0.5455717", "0.5445001", "0.5406332", "0.53968203", "0.53896534", "0.537996...
0.5463714
15
Based on swap rates with maturity of 112, 15, 20, 25, 30, 40 and 50 years this function builds the forward and zero rates.
def compute_interpolated_zero(swap_rates_market, liquid_maturities): # Creates dummy to start interpolation fwd_dummy = np.array([0.01]) # Number of liquid maturities N = len(liquid_maturities) # Construct zero rates zero_rates_market = np.array(swap_to_zero(swap_rates_market)) # Starting...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ir_swap_price(\n pay_leg_coupon_rates,\n receive_leg_coupon_rates,\n pay_leg_notional,\n receive_leg_notional,\n pay_leg_daycount_fractions,\n receive_leg_daycount_fractions,\n pay_leg_discount_factors,\n receive_leg_discount_factors,\n dtype=None,\n name=None):\n name = name or ...
[ "0.5754347", "0.5727606", "0.5654784", "0.55211216", "0.54715455", "0.5470292", "0.5455846", "0.5371805", "0.53362787", "0.5269734", "0.5238103", "0.52345854", "0.5223124", "0.5214334", "0.52131945", "0.5193604", "0.519102", "0.5184465", "0.5176747", "0.5168708", "0.5165751",...
0.561613
3
Extracts main (interpolated) forwards.
def extract_fwds(zero_rates_market_interpolated, liquid_maturities, fsp=20): # Number of liquid maturities N = len(liquid_maturities) # Init forwards_pre_fsp = [zero_rates_market_interpolated[0]] forwards_llfr = [] # Loop through each liquid rate pair and calculate required fwds for liquid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, s):", "def forward(self, feats):\n return multi_apply(self.forward_single, feats, self.scales)", "def forward(self, x):\n return self.main(x)", "def forward(self, x):\n x = self.main(x)\n return x", "def forward(self, x):\n x = self.main(x)\n retu...
[ "0.58453393", "0.57004464", "0.5586817", "0.54956955", "0.54956955", "0.5482774", "0.54595333", "0.5456534", "0.53696126", "0.5369079", "0.53439564", "0.5339681", "0.5339387", "0.5324448", "0.529431", "0.529431", "0.5288541", "0.5217213", "0.52059764", "0.52056926", "0.518720...
0.0
-1
Calculates last liquid forward rate (llfr) as described by EIOPA review 2020.
def compute_llfr(fwd, volume=np.array([3.3, 1.45 , 6, 0.3, 0.4]), va=0.0): weight = volume / volume.sum() fwds_incl_va = fwd.copy() fwds_incl_va[0] = fwds_incl_va[0] + va / 10000.0 llfr = fwds_incl_va * weight return np.array([llfr.sum()])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rate_last(self):\n diff = (self.time - self.lasts[0][0]).total_seconds()\n try:\n return (self.pos - self.lasts[0][1]) / FAC / diff\n except ZeroDivisionError:\n return 0.0", "def dalf(x):\n # if pitch_start_time - ramp_constant_time <= x <= pitch_end_tim...
[ "0.65461475", "0.6008428", "0.5917937", "0.58921546", "0.58872676", "0.5785662", "0.5776639", "0.5763312", "0.57632715", "0.5741426", "0.5687872", "0.56605965", "0.5606835", "0.56042325", "0.56025577", "0.55816513", "0.5580824", "0.55693424", "0.5567322", "0.5562409", "0.5557...
0.64999485
1
Constructs zero curve from forwards until FPS potentially including VA.
def compute_curve_with_va(forwards_pre_fsp, liquid_maturities, fsp=20, va=0): # Number of liquid maturities smaller than or equal to fsp N = len(liquid_maturities[liquid_maturities <= fsp]) # Input check assert N == len(forwards_pre_fsp) # Add va to all forwards forwards_pre_fsp_incl_va = forw...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p0(self):\n return self.lerp(0)", "def create_frame_curve(self):\n self.frame_curve = pm.curve(\n d=1,\n p=[(-0.5, 0.5, 0),\n (0.5, 0.5, 0),\n (0.5, -0.5, 0),\n (-0.5, -0.5, 0),\n (-0.5, 0.5, 0)],\n k=[0, 1...
[ "0.589822", "0.572195", "0.5697178", "0.55745435", "0.55424744", "0.55227065", "0.54740256", "0.53965265", "0.5392993", "0.5370394", "0.5370394", "0.53350204", "0.5327178", "0.53230256", "0.53219426", "0.53208303", "0.53037494", "0.52395266", "0.52135026", "0.5201853", "0.518...
0.59569997
0
Extrapolates forward rates beyond fsp.
def extrapolate_fwds(h, ufr, llfr, alpha=0.10): fwd_fsp_fsp_plus_h = np.log(1 + ufr) + (llfr - np.log(1 + ufr)) * big_b(h, alpha) return fwd_fsp_fsp_plus_h
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extrapolate_zero(known_zero_rates, ufr, llfr, alpha=0.10, fsp=20):\n # FSP\n z_fsp = known_zero_rates[fsp - 1]\n\n # Extrapolated zero rates\n extrapolated_zero_rates = known_zero_rates[0:fsp]\n\n # Regardless of fsp we want to calculate the extrapolated rates with a maturity of up to 120y\n ...
[ "0.6829397", "0.6423884", "0.6068097", "0.57890594", "0.568882", "0.5671934", "0.56580126", "0.55252653", "0.53781027", "0.53780746", "0.53566414", "0.53493655", "0.5346056", "0.5340317", "0.53385156", "0.53342044", "0.53287864", "0.53210545", "0.53121793", "0.5300634", "0.52...
0.5588407
7
Extrapolation of zero rates beyond fsp.
def extrapolate_zero(known_zero_rates, ufr, llfr, alpha=0.10, fsp=20): # FSP z_fsp = known_zero_rates[fsp - 1] # Extrapolated zero rates extrapolated_zero_rates = known_zero_rates[0:fsp] # Regardless of fsp we want to calculate the extrapolated rates with a maturity of up to 120y up_to = 120 -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alternative_extrapolation(input_rates, input_liquid, ufr, fsp=20, alpha=None, va=0.0, volume_traded=np.array([3.3, 1.45, 6, 0.3, 0.4])):\n\n # Assign base variables\n liquid_maturities = np.where(input_liquid == 1)[0] + 1\n liquid_rates_swap = input_rates[np.where(input_liquid == 1)]\n\n # Interpol...
[ "0.69276035", "0.5971338", "0.59490603", "0.58849704", "0.5847047", "0.5700037", "0.567109", "0.56408817", "0.5596573", "0.55785406", "0.5571876", "0.54841083", "0.54795015", "0.54718083", "0.5468277", "0.54417115", "0.5404876", "0.5370664", "0.53702486", "0.53702486", "0.533...
0.7663408
0
Wrapper function for alternative extrapolation method of SII curves.
def alternative_extrapolation(input_rates, input_liquid, ufr, fsp=20, alpha=None, va=0.0, volume_traded=np.array([3.3, 1.45, 6, 0.3, 0.4])): # Assign base variables liquid_maturities = np.where(input_liquid == 1)[0] + 1 liquid_rates_swap = input_rates[np.where(input_liquid == 1)] # Interpolated liquid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_call_extrapolate(self):\r\n # Verified with iNEXT. Differs slightly from their output because\r\n # they've slightly modified Colwell 2012 equation 9, and we're using\r\n # the original one. SE estimates differ because they use a different\r\n # technique. SE estimates have bee...
[ "0.71791005", "0.7067241", "0.6778083", "0.6618005", "0.6510769", "0.6202282", "0.6159978", "0.60935664", "0.60661864", "0.6060986", "0.57496494", "0.5613285", "0.55799556", "0.5557901", "0.5470048", "0.5429654", "0.5418731", "0.5347211", "0.5327384", "0.5314399", "0.5223685"...
0.60445786
10
Displays a list of frames as a gif, with controls
def display_frames_as_gif(frames, video_name): Writer = animation.writers['ffmpeg'] writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800) #plt.figure(figsize=(frames[0].shape[1] / 72.0, frames[0].shape[0] / 72.0), dpi = 72) patch = plt.imshow(frames[0]) plt.axis('off') def animate(i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_frames_as_gif(frames):\n fig=e.cube.show_layout(frames[0]) \n print(\"Drawn\")\n def animate(i):\n return e.cube.update_plot(frames[i])\n anim = animation.FuncAnimation(fig, animate, frames = len(frames), interval=50,blit=True)", "def save_gif(frames):\n print(\"Saving gif image...
[ "0.79926205", "0.712358", "0.70423585", "0.68678", "0.67844933", "0.67759246", "0.6595854", "0.6579575", "0.6552716", "0.6483145", "0.6471368", "0.63823175", "0.63685465", "0.63645715", "0.63480055", "0.6285726", "0.627497", "0.626504", "0.625118", "0.62405115", "0.6230932", ...
0.7612498
1
return two sets of interlaced points on a grid
def generate_interlacing_grids(npts_per_dim, period=1.0): dmin, dmax = 0.0, period dx = (dmax - dmin) / float(npts_per_dim) mesh1_points = generate_3d_regular_mesh(npts_per_dim, dmin=dmin, dmax=dmax) mesh2_points = mesh1_points + dx / 2.0 return mesh1_points, mesh2_points
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_xy_grid(nx, ny):\n\tfor n in [nx, ny]:\n\t\tif not isodd(n):\n\t\t\traise Exception(\"[get_xy_grid] only accept odd number\")\n\n\tx, y = np.mgrid[-(nx-1)/2:(nx+1)/2, -(ny-1)/2:(ny+1)/2]\n\n\treturn x, y", "def interpolate2Dtwice(xMarkers, yMarkers, zGrid1, zGrid2, x, y):\n xi1, xi2 = boundingIndices(...
[ "0.6272886", "0.6254148", "0.6237068", "0.62227887", "0.6202159", "0.6166538", "0.6152766", "0.6146862", "0.6137873", "0.6135714", "0.6124222", "0.6115503", "0.6111334", "0.6072697", "0.6068382", "0.6062725", "0.6059968", "0.60572535", "0.60526454", "0.60401374", "0.6024314",...
0.6034714
20
return a set of aligned vectors, all pointing in a random direction
def generate_aligned_vectors(npts, dim=3): vector = normalized_vectors(np.random.random(dim)) vectors = np.tile(vector, npts).reshape((npts, dim)) return vectors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_direction_vector(return_angles=False):\n xi1 = np.random.rand()\n xi2 = np.random.rand()\n\n # theta = np.arccos(np.sqrt(1.0-xi1))\n theta = np.arccos(1.0 - (xi1 * 1))\n phi = xi2 * 2 * np.pi\n\n xs = np.sin(theta) * np.cos(phi)\n ys = np.sin(theta) * np.sin(phi)\n zs = np.cos(th...
[ "0.6540196", "0.62269187", "0.6188842", "0.60956556", "0.6033184", "0.6019711", "0.60028493", "0.5829907", "0.5784078", "0.5723453", "0.57149637", "0.5707661", "0.56773955", "0.5647822", "0.56467783", "0.5645228", "0.5593463", "0.55786777", "0.55786777", "0.5567715", "0.55242...
0.7055325
0
test limiting cases for angles
def test_limits(): # generate two locusts of points npts = 100 epsilon = 0.000 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # calculate dot product between...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_calculate_angle():\n r1 = np.array([0, 0, -1])\n r2 = np.array([0, 0, 0])\n r3 = np.array([1, 0, 0])\n\n expected_angle = 90\n calculated_angle = molecool.calculate_angle(r1, r2, r3, degrees = True)\n\n assert expected_angle == calculated_angle", "def angle(self) -> int:", "def are_a...
[ "0.6906851", "0.68449503", "0.68379426", "0.68331456", "0.6660919", "0.6512919", "0.64631695", "0.6456861", "0.6456473", "0.644694", "0.644351", "0.6420581", "0.64152783", "0.6370782", "0.63657296", "0.6345425", "0.63399", "0.63275623", "0.63104635", "0.62225735", "0.62179047...
0.0
-1
test weighting function 1
def test_1(): # generate two locusts of points npts = 100 epsilon = 0.001 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # generate orientation vectors for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weight(self):", "def calculate_weighted_results():\n pass", "def test_uniform_weight(self):\n knn = Knn(n_neighbors=3)\n distances = np.array([2,.3,4])\n weights = knn._uniform_weights(distances)\n assert np.allclose(weights, np.array([[1,2], [1,.3], [1,4]])), \"uniform_weigh...
[ "0.73714566", "0.7123341", "0.6829374", "0.680461", "0.6790045", "0.67825454", "0.67806804", "0.6723462", "0.6723462", "0.6723462", "0.6719857", "0.6540802", "0.6534843", "0.65198624", "0.6481385", "0.6477132", "0.6477132", "0.64727527", "0.6458373", "0.6447511", "0.64215034"...
0.0
-1
test weighting function 2
def test_2(): # generate two locusts of points npts = 100 epsilon = 0.001 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # generate orientation vectors for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weight(self):", "def calculate_weighted_results():\n pass", "def test_weighting_implementation():\n\n # generate two locusts of points\n npts = 100\n epsilon = 0.05\n # cluster 1\n coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon)\n # cluster 2\n coords2 = ...
[ "0.7371318", "0.71170366", "0.70228744", "0.68594384", "0.6806028", "0.67597073", "0.67457837", "0.67457837", "0.67457837", "0.65772045", "0.656665", "0.65407264", "0.6496334", "0.6491459", "0.6470032", "0.6445329", "0.63893735", "0.63880396", "0.6378849", "0.6377924", "0.637...
0.62296915
33
test weighting function 3
def test_3(): # generate two locusts of points npts = 100 epsilon = 0.001 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # generate orientation vectors for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weight(self):", "def calculate_weighted_results():\n pass", "def get_weights(self):", "def test_weighting_implementation():\n\n # generate two locusts of points\n npts = 100\n epsilon = 0.05\n # cluster 1\n coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon)\n ...
[ "0.7288798", "0.69924444", "0.694409", "0.6898504", "0.6888629", "0.67308354", "0.6707292", "0.66294175", "0.66133493", "0.6611797", "0.65326566", "0.64846253", "0.6484031", "0.6476585", "0.6476585", "0.6476585", "0.6470052", "0.64547884", "0.6435763", "0.6435763", "0.6359459...
0.5902195
76
test weighting function 4
def test_4(): # generate two locusts of points npts = 100 epsilon = 0.001 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # generate orientation vectors for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weight(self):", "def calculate_weighted_results():\n pass", "def get_weights(self):", "def test_uniform_weight(self):\n knn = Knn(n_neighbors=3)\n distances = np.array([2,.3,4])\n weights = knn._uniform_weights(distances)\n assert np.allclose(weights, np.array([[1,2], [1,.3...
[ "0.7499339", "0.7153941", "0.7074379", "0.6822712", "0.6750941", "0.67482257", "0.6722642", "0.6673965", "0.6658167", "0.6591322", "0.6591322", "0.6591322", "0.6574595", "0.6569873", "0.65067506", "0.6452795", "0.6449612", "0.6447217", "0.6440972", "0.64174354", "0.6394711", ...
0.0
-1
test for randomly distributed points and orientations
def test_randoms(): # generate two locusts of points npts = 200 epsilon = 0.3 # #cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.0, 0.0, 0.0, epsilon=epsilon) coords2 = generate_locus_of_3d_points(npts, 0.0, 0.0, 0.0, epsilon=epsilon) # generate orientation vectors for cluster 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sample(self):\n seed = 5\n space = Space()\n probs = (0.1, 0.2, 0.3, 0.4)\n categories = (\"asdfa\", 2, 3, 4)\n dim1 = Categorical(\"yolo\", OrderedDict(zip(categories, probs)), shape=(2, 2))\n space.register(dim1)\n dim2 = Integer(\"yolo2\", \"uniform\", -...
[ "0.69025135", "0.65352213", "0.6435743", "0.6376336", "0.6124563", "0.609741", "0.6038022", "0.59814715", "0.59803987", "0.5945724", "0.59441704", "0.59350026", "0.59291923", "0.5912027", "0.5902897", "0.58836824", "0.5881404", "0.587735", "0.58478856", "0.5842835", "0.583063...
0.63306016
4
test that indexing is correct for weighting
def test_weighting_implementation(): # generate two locusts of points npts = 100 epsilon = 0.05 # cluster 1 coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon) # cluster 2 coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon) # generate ori...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_jw_sparse_index(self):\n expected = [1, 2]\n calculated_indices = jw_number_indices(1, 2)\n self.assertEqual(expected, calculated_indices)\n\n expected = [3]\n calculated_indices = jw_number_indices(2, 2)\n self.assertEqual(expected, calculated_indices)", "def t...
[ "0.6318438", "0.6158431", "0.6118839", "0.6073662", "0.60615355", "0.60282147", "0.59491366", "0.5904143", "0.5842916", "0.58375335", "0.58189875", "0.57899994", "0.57887036", "0.57805324", "0.57619214", "0.5730078", "0.57193065", "0.57058245", "0.5704713", "0.5696307", "0.56...
0.60835993
3
test to make sure the result is the same with and without threading for each weighting function
def test_threading(): npts = 100 random_coords = np.random.random((npts, 3)) random_vectors = np.random.random((npts, 3)) * 2.0 - 1.0 period = np.array([1.0, 1.0, 1.0]) rbins = np.linspace(0.0, 0.3, 5) weights1 = np.ones((npts, 4)) weights1[:, 1] = random_vectors[:, 0] weights1[:, 2] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_weighted_results():\n pass", "def worker_train():\n py_work = np.zeros(model.layer1_size, dtype=np.float32)\n\n while True:\n job = jobs.get(block=True)\n if job is None: # data finished, exit\n jobs.task_done()\n ...
[ "0.6262015", "0.6210178", "0.60807836", "0.59742224", "0.59612995", "0.5931349", "0.5925256", "0.58842444", "0.58681244", "0.5854552", "0.5833443", "0.5815058", "0.5808932", "0.57820576", "0.57739794", "0.5763834", "0.57565004", "0.57565004", "0.57518077", "0.5739305", "0.573...
0.6526756
0
test to make sure the unweighted counts result is the same as npairs_3d
def test_unweighted_counts(): npts = 100 random_coords = np.random.random((npts, 3)) random_vectors = np.random.random((npts, 3)) * 2.0 - 1.0 period = np.array([1.0, 1.0, 1.0]) rbins = np.linspace(0.0, 0.3, 5) weights1 = np.ones((npts, 4)) weights1[:, 1] = random_vectors[:, 0] weights...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_3():\n\n # generate two locusts of points\n npts = 100\n epsilon = 0.001\n # #cluster 1\n coords1 = generate_locus_of_3d_points(npts, 0.1, 0.1, 0.1, epsilon=epsilon)\n # cluster 2\n coords2 = generate_locus_of_3d_points(npts, 0.9, 0.9, 0.9, epsilon=epsilon)\n\n # generate orientati...
[ "0.6804071", "0.6675446", "0.6558152", "0.6553596", "0.6355471", "0.59420466", "0.5904359", "0.5867944", "0.5852378", "0.5840163", "0.57754296", "0.5756164", "0.5666417", "0.5629368", "0.56008625", "0.5580319", "0.55392295", "0.55317265", "0.55268514", "0.55140775", "0.550797...
0.8235178
0
test to compare pair counter to a pure python implemnetation.
def test_compare_to_pure_python_result(): npts = 4 random_coords = np.random.random((npts, 3)) random_vectors = normalized_vectors(np.random.random((npts, 3)) * 2.0 - 1.0) weights1 = np.ones((npts, 4)) weights1[:, 1] = random_vectors[:, 0] weights1[:, 2] = random_vectors[:, 1] weights1[:, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _test_pairs(self, idx0, idx1):\n pass", "def count_same(pairs):\n same_count = 0\n for x, y in pairs:\n if x == y:\n same_count = same_count + 1\n return same_count", "def _handle_pairs(truth, pred, first_ix, times_to_compare):\n next_ix = first_ix\n while next_ix < ...
[ "0.6499323", "0.6344855", "0.6174727", "0.6168542", "0.59215033", "0.5901002", "0.5844632", "0.5778292", "0.5734901", "0.5727326", "0.57088107", "0.5699264", "0.5697362", "0.56867206", "0.5683028", "0.56674826", "0.56516165", "0.56231296", "0.5622853", "0.5622853", "0.5612172...
0.0
-1
Construct a new CPU.
def __init__(self): self.ram = [0] * 256 self.reg = [0] * 8 self.pc = 0 self.running = True self.flags = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_cpu():\n return CPU()", "def __new__(cls, cpu):\n assert CpuMap.len() > cpu\n if not CpuMap.arr:\n CpuMap.arr = CpuMap._cpus()\n return CpuMap.arr[cpu]", "def __init__(__self__, *,\n cpu: Optional[pulumi.Input[str]] = None,\n memory:...
[ "0.8730429", "0.6449802", "0.61884964", "0.61884964", "0.6187806", "0.5995889", "0.5966882", "0.595886", "0.5928992", "0.59178156", "0.5896253", "0.5896253", "0.5882893", "0.5811475", "0.58060795", "0.5780409", "0.5775764", "0.5713248", "0.5670305", "0.5633612", "0.5601664", ...
0.5210048
59
Load a program into memory.
def load(self): filename = sys.argv[1] address = 0 try: with open(filename) as f: for line in f: line = line.split("#")[0].strip() if line != '': # print(line) self.ram[address] =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(self):\n \"\"\"Load a program into memory.\"\"\"\n\n if len(sys.argv) != 2:\n print(\"format: ls8.py [filename]\")\n sys.exit(1)\n\n program = sys.argv[1]\n address = 0\n\n # For now, we've just hardcoded a program:\n\n # program = [\n ...
[ "0.81634724", "0.79999995", "0.7945554", "0.7740165", "0.7578849", "0.7500425", "0.74218637", "0.73366326", "0.7264755", "0.72317487", "0.7057533", "0.7013016", "0.6947519", "0.6935771", "0.68992066", "0.6871278", "0.6856455", "0.68479383", "0.6750691", "0.66874295", "0.65626...
0.64359754
25
Handy function to print out the CPU state. You might want to call this from run() if you need help debugging.
def trace(self): print(f"TRACE: %02X | %02X %02X %02X |" % ( self.pc, #self.fl, #self.ie, self.ram_read(self.pc), self.ram_read(self.pc + 1), self.ram_read(self.pc + 2) ), end='') for i in range(8): print(" %02...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_cpu_state(self):\n print(\"PC:\", hex(self.pc))\n print(\"SP:\", hex(self.sp))\n print(\"A:\", hex(self.a))\n print(\"X:\", hex(self.x))\n print(\"Y:\", hex(self.y))\n print(\"P:\", bin(self.p))", "def print_state(self):\n print('\\nthe current state is:...
[ "0.8351183", "0.68789357", "0.67998874", "0.67704004", "0.6622825", "0.6336701", "0.62946373", "0.6276415", "0.61891097", "0.6150171", "0.60719436", "0.5984655", "0.5952339", "0.5935385", "0.5929185", "0.5927485", "0.59036016", "0.58895147", "0.5857599", "0.5806091", "0.57888...
0.5564623
57
Return a prettyprinted XML string for the Element.
def prettyPrintXML(elem): rough_string = tostring(elem, 'utf-8') reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prettify(self, elem):\n rough_string = ElementTree.tostring(elem, 'utf8')\n root = etree.fromstring(rough_string)\n return etree.tostring(root, pretty_print=True)", "def prettify(self, elem):\n try:\n rough_string = ET.tostring(elem, 'utf8')\n except Exception:\n...
[ "0.8320833", "0.8254816", "0.81777155", "0.8125781", "0.79858375", "0.7983392", "0.7959291", "0.79083174", "0.78842366", "0.78842366", "0.7799259", "0.77578247", "0.77566487", "0.7750094", "0.7749699", "0.7749699", "0.7743164", "0.7696672", "0.76804864", "0.76804864", "0.7680...
0.74251306
37
Convert list to string and strip out everything not alphanumeric or underscore Adding a space after the \w keeps a white space when replacing with ''
def convertListToString(list): return re.sub(r'[^\w ]', '', str(list))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createtext(lst):\n newlst = []\n for item in lst:\n item = item.replace(\"_!\",\"\")\n newlst.append(item)\n text = ' '.join(newlst)\n # Lower-casing\n return text.lower()", "def sanitize(mystr):\n retainlist = \"_-\"\n return re.sub(r'[^\\w' + retainlist + ...
[ "0.70441335", "0.67255616", "0.67114735", "0.6680449", "0.65896875", "0.65511245", "0.65050983", "0.64905286", "0.64250445", "0.64132965", "0.63415235", "0.63278353", "0.62990576", "0.62973416", "0.62399995", "0.6236533", "0.62267345", "0.6199033", "0.6196927", "0.6192598", "...
0.74973476
0
Write a PNG chunk to the output file, including length and checksum.
def write_chunk(self, outfile, tag, data): outfile.write(struct.pack("!i", len(data))) outfile.write(tag) outfile.write(data) checksum = zlib.crc32(tag) checksum = zlib.crc32(data, checksum) outfile.write(struct.pack("!i", checksum))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_png(buffer, width, height, fileobj, dpi=None): # real signature unknown; restored from __doc__\n pass", "def copy_png_fp(\n fin: IO[bytes], fout: IO[bytes], filter_chunks: Optional[Callable[[bytes], bool]] = None, verify_crc: bool = False\n) -> None:\n\n filter_chunks = filter_chunks or (lambd...
[ "0.6895723", "0.6447106", "0.6395438", "0.6121259", "0.5775687", "0.5769704", "0.5765281", "0.5763943", "0.5708255", "0.5695277", "0.5687847", "0.567902", "0.56631494", "0.5661123", "0.56535745", "0.55994725", "0.55849624", "0.5570907", "0.5559315", "0.5556116", "0.554733", ...
0.6341038
3
Initialize a DecisionSupervisor instance.
def __init__(self): # Define the set of state identifiers self.state = { 0: states.FindWall(), 1: states.FollowWall(), 2: states.TurnToWall(), 3: states.AvoidWall(), 4: states.AvoidObstacles(), 5: states.GoToSample(), 6:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, estimator, target_language='java',\n target_method='predict', **kwargs):\n super(DecisionTreeClassifier, self).__init__(\n estimator, target_language=target_language,\n target_method=target_method, **kwargs)\n self.estimator = estimator", "de...
[ "0.59564227", "0.5945482", "0.58487767", "0.57880265", "0.5686964", "0.56799275", "0.55700696", "0.5561293", "0.55600226", "0.55399656", "0.5519745", "0.5513815", "0.55039734", "0.55000854", "0.5485623", "0.5476553", "0.547578", "0.54478437", "0.54260653", "0.5421856", "0.540...
0.0
-1
Check if given event has occurred.
def is_event(self, Rover, name): func = self.event.get(name) return func(Rover)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_event_status(self):\n pass", "def event_check(self):\r\n if len(self.event_queue) > 0:\r\n event = self.event_queue.pop(0) # oldest\r\n self.event_queue_proc(event)\r\n return True\r\n return False", "def has_event(self):\n return self....
[ "0.7654162", "0.72810465", "0.7219387", "0.7180435", "0.7048035", "0.6992752", "0.6874013", "0.6846661", "0.67762643", "0.6768121", "0.67378837", "0.66558546", "0.6580509", "0.6545788", "0.65428126", "0.65428126", "0.6531857", "0.6466347", "0.64581686", "0.64473647", "0.64034...
0.6898288
6
Check if either events have occurred.
def either_events(self, Rover, name1, name2): func1 = self.event.get(name1) func2 = self.event.get(name2) return func1(Rover) or func2(Rover)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_event_status(self):\n pass", "def both_events(self, Rover, name1, name2):\n func1 = self.event.get(name1)\n func2 = self.event.get(name2)\n return func1(Rover) and func2(Rover)", "def event_check(self):\r\n if len(self.event_queue) > 0:\r\n event = self.e...
[ "0.706401", "0.66520953", "0.65679574", "0.64521164", "0.63444453", "0.63211894", "0.6298124", "0.62498295", "0.6214975", "0.62132365", "0.6204186", "0.60979587", "0.60976624", "0.60758334", "0.6062037", "0.6035241", "0.60278326", "0.602027", "0.6019511", "0.6019247", "0.6019...
0.6606034
2
Check if both events have occurred.
def both_events(self, Rover, name1, name2): func1 = self.event.get(name1) func2 = self.event.get(name2) return func1(Rover) and func2(Rover)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_event_status(self):\n pass", "def __le__(self, other: Event) -> bool:\n return self.timestamp <= other.timestamp", "def either_events(self, Rover, name1, name2):\n func1 = self.event.get(name1)\n func2 = self.event.get(name2)\n return func1(Rover) or func2(Rover)", ...
[ "0.6898676", "0.6448902", "0.64360255", "0.6405506", "0.64001495", "0.63844377", "0.6315303", "0.6301358", "0.6233651", "0.6232503", "0.6225918", "0.62225395", "0.62174076", "0.6212137", "0.6169394", "0.6145492", "0.60770476", "0.6058647", "0.6055802", "0.6047041", "0.6041531...
0.7315005
0