query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns a driver object of the chrome web driver. This can be used for crawling.
def get_driver_with_options(): #options = get_driver_options() #return webdriver.Chrome(options=options) return webdriver.Chrome()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chrome():\n driver = Driver()\n driver.browser = 'chrome'\n return Chrome(driver)", "def get_chrome_driver():\n\n driver_path = Path(r'C:\\Users\\15314\\OneDrive\\Desktop') / 'chromedriver.exe'\n options = webdriver.chrome.options.Options()\n options.set_headless(headless=True)\n driver ...
[ "0.8257605", "0.79149836", "0.78454745", "0.7808107", "0.7653399", "0.7500122", "0.73545384", "0.7312083", "0.7186286", "0.7022509", "0.7020654", "0.7012933", "0.6935616", "0.6907823", "0.6884662", "0.68749017", "0.6870857", "0.68530726", "0.67593426", "0.67363876", "0.670191...
0.74528474
6
Clicks the "show more" button when scrolling down the review page of a play store app Tested yet with review pages only.
def click_button_xpath(driver, platform): xpath = settings.platforms[platform]['search_listings']['show_more_xpath'] time.sleep(1) show_more_button = driver.find_elements_by_xpath(xpath)[0] driver.execute_script("arguments[0].click();", show_more_button)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_more(self):\r\n delay = WebDriverWait(driver, 5)\r\n try:\r\n ReadMore = delay.until(EC.element_to_be_clickable((By.XPATH, \".//div[@id='see_more_pager']//a[.= 'Lihat Hasil Selanjutnya'] \")))\r\n ReadMore.click()\r\n except:\r\n try:\r\n ...
[ "0.7033098", "0.6344363", "0.60130936", "0.5971481", "0.5927033", "0.59119856", "0.5804481", "0.57168674", "0.5628345", "0.5611567", "0.5599046", "0.54855263", "0.54716974", "0.54516166", "0.543418", "0.5370538", "0.5298097", "0.52818733", "0.52784103", "0.5269796", "0.526903...
0.6422785
1
boolean check for whether a string is a zmq url
def is_url(url): if '://' not in url: return False proto, addr = url.split('://', 1) if proto.lower() not in ['tcp','pgm','epgm','ipc','inproc']: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_url(string):\n return \"http\" in string", "def is_url(string):\n try:\n urlparse(string)\n return True\n except:\n return False", "def _is_url(s: str) -> bool:\n\n return urlparse(s).netloc != \"\"", "def __isUrl(self, url):\n if type(url)==str:\n r...
[ "0.81032103", "0.7645922", "0.7644091", "0.7643658", "0.7643011", "0.7352943", "0.72288644", "0.7144033", "0.7083735", "0.70466423", "0.70048374", "0.6976797", "0.6920094", "0.6914505", "0.69056535", "0.6895562", "0.68839", "0.6835494", "0.68054456", "0.6716606", "0.6712718",...
0.75069827
5
Join components of url into a relative url Use to prevent double slash when joining subpath. This will leave the initial and final / in place
def url_path_join(*pieces): initial = pieces[0].startswith('/') final = pieces[-1].endswith('/') striped = [s.strip('/') for s in pieces] result = '/'.join(s for s in striped if s) if initial: result = '/' + result if final: result = result + '/' if result == '//': result = '/' return re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def urljoin(base, *path):\n return reduce(_join, path, base)", "def url_path_join(*pieces):\n initial = pieces[0].startswith(\"/\")\n final = pieces[-1].endswith(\"/\")\n stripped = [s.strip(\"/\") for s in pieces]\n result = \"/\".join(s for s in stripped if s)\n if initial:\n result = ...
[ "0.75034314", "0.7498832", "0.7475863", "0.74634165", "0.74325925", "0.7365204", "0.73354787", "0.73097575", "0.73073596", "0.72961533", "0.7290866", "0.7187557", "0.71870315", "0.7176675", "0.71697366", "0.7167138", "0.7140325", "0.7076596", "0.7072414", "0.7021766", "0.7021...
0.7462581
4
Convert a string into a literal value that can be used in Python source. This just calls C{repr}. No point in getting all complex when the language already gives us what we need.
def QuotedEscaped (s): return repr(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cython_literal(self, lit):\n if isinstance(lit, Number):\n cy_lit = str(lit).replace('-', 'Neg').replace('+', 'Pos')\\\n .replace('.', 'point')\n elif isinstance(lit, basestring):\n cy_lit = repr(lit)\n return cy_lit", "def cpp_literal(se...
[ "0.72240233", "0.71256787", "0.6996777", "0.6996777", "0.66892284", "0.6533683", "0.6347035", "0.6261261", "0.61884165", "0.6187074", "0.6153223", "0.61215895", "0.59685224", "0.58493763", "0.5841717", "0.57748306", "0.56707436", "0.56689525", "0.5663161", "0.5645122", "0.561...
0.0
-1
Default implementation for _XMLIdentifierToPython For historical reasons, this converts the identifier from a str to unicode in the system default encoding. This should have no practical effect.
def _DefaultXMLIdentifierToPython (identifier): return six.text_type(identifier)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _SetXMLIdentifierToPython (xml_identifier_to_python):\n global _XMLIdentifierToPython\n if xml_identifier_to_python is None:\n xml_identifier_to_python = _DefaultXMLIdentifierToPython\n _XMLIdentifierToPython = xml_identifier_to_python", "def _unicodeify(self, value, encoding=\"utf8\"):\n ...
[ "0.6642679", "0.6174144", "0.60445756", "0.5969381", "0.5914155", "0.59118557", "0.587203", "0.58548003", "0.58026296", "0.57193226", "0.5715238", "0.57140726", "0.57060766", "0.565981", "0.56537277", "0.56176376", "0.5602993", "0.55988634", "0.5581407", "0.55747074", "0.5570...
0.76331604
0
Convert a string into something suitable to be a Python identifier. The string is processed by L{_XMLIdentifierToPython}. Following this, dashes, spaces, and periods are replaced by underscores, and characters not permitted in Python identifiers are stripped. Furthermore, any leading underscores are removed. If the res...
def MakeIdentifier (s, camel_case=False): s = _XMLIdentifierToPython(s) s = _PrefixUnderscore_re.sub('', _NonIdentifier_re.sub('', _UnderscoreSubstitute_re.sub('_', s))) if camel_case: s = _CamelCase_re.sub(lambda _m: _m.group(0)[1].upper(), s) if _PrefixDigit_re.match(s): s = 'n' + s ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_python_identifier(string):\n # Todo: check for variable uniqueness\n # perhaps maintain a list of current variables and their translations??\n # Todo: check that the output is actually a valid python identifier\n\n string = string.lower()\n\n # remove leading and trailing whitespace\n s...
[ "0.8302692", "0.6752775", "0.6718251", "0.6598083", "0.6587029", "0.63822687", "0.62174153", "0.6135094", "0.60881364", "0.6069373", "0.60202104", "0.58889824", "0.5888", "0.5884226", "0.5868551", "0.58431655", "0.5817622", "0.57959217", "0.57879376", "0.57620525", "0.5743887...
0.71453947
1
Return the set of nodes calculated to be roots (i.e., those that have no incoming edges). This caches the roots calculated in a previous invocation unless the C{reset} keyword is given the value C{True}.
def roots (self, reset=False): if reset or (self.__roots is None): self.__roots = set() for n in self.__nodes: if not (n in self.__reverseMap): self.__roots.add(n) return self.__roots
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roots(self):\n if not self.__roots:\n self.__roots = set()\n for n in self.__nodes:\n if n not in self.__reverse_map:\n self.__roots.add(n)\n return self.__roots", "def roots(self) -> List[str]:\n return [node for node, degree in se...
[ "0.75745994", "0.66823053", "0.6606786", "0.65892243", "0.6557205", "0.65282804", "0.6425244", "0.62325907", "0.62034404", "0.61831456", "0.61707497", "0.6147587", "0.6117938", "0.6115766", "0.60967505", "0.60475665", "0.5984837", "0.5928481", "0.58924735", "0.58659506", "0.5...
0.81035554
0
Return the set of nodes in the graph. The node collection data structure is a set containing node objects, whatever they may be.
def nodes (self): return self.__nodes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodes(self):\n\n return list(set(self._graph.keys() + [x for x in itertools.chain.from_iterable(self._graph.values())]))", "def get_nodeset(self):\n return set(self.nodeset) # return the nodeset", "def nodes(self):\n nodes = list()\n for node in self._nodes:\n if isi...
[ "0.8089959", "0.79780483", "0.7861936", "0.7711382", "0.7673762", "0.75728124", "0.7571405", "0.7556265", "0.7542568", "0.74974424", "0.74076253", "0.74076253", "0.73716974", "0.731814", "0.7315418", "0.7305688", "0.7289411", "0.7246893", "0.7241622", "0.71766764", "0.7159215...
0.69518363
33
Return the stronglyconnected components of the graph. The data structure is a set, each element of which is itself a set containing one or more nodes from the graph.
def scc (self, reset=False): if reset or (self.__scc is None): self.tarjan(reset) return self.__scc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strongly_connected_components(self):\n for node in self.graph:\n node.data.visited = False\n\n reverse_graph = self.reverse_graph()\n dfs_reverse_graph = DFS(reverse_graph.graph, generate_stack=True)\n dfs_reverse_graph.search()\n\n dfs_graph = DFS(self.graph, gene...
[ "0.7985178", "0.7698458", "0.76961863", "0.7609017", "0.7442105", "0.742956", "0.72614646", "0.69919074", "0.6983941", "0.69524926", "0.69312733", "0.68971956", "0.6861848", "0.6823889", "0.68053895", "0.6686502", "0.66422856", "0.6598884", "0.6594531", "0.65940416", "0.64684...
0.0
-1
Return the stronglyconnected component to which the given node belongs. Any keywords suppliend when invoking this method are passed to the L{sccMap} method.
def sccForNode (self, node, **kw): return self.sccMap(**kw).get(node)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strongly_connected_components(self):\n for node in self.graph:\n node.data.visited = False\n\n reverse_graph = self.reverse_graph()\n dfs_reverse_graph = DFS(reverse_graph.graph, generate_stack=True)\n dfs_reverse_graph.search()\n\n dfs_graph = DFS(self.graph, gene...
[ "0.690451", "0.68742985", "0.6473766", "0.64694965", "0.6450434", "0.6265773", "0.615741", "0.60335255", "0.6008124", "0.59753853", "0.59593517", "0.58773434", "0.5864113", "0.58441275", "0.5814417", "0.5794216", "0.5786024", "0.5770247", "0.5719518", "0.56839013", "0.5667406...
0.80238163
0
Return the nodes of the graph as a sequence of root sets.
def rootSetOrder (self): order = [] nodes = set(self.__nodes) edge_map = {} for (d, srcs) in six.iteritems(self.__edgeMap): edge_map[d] = srcs.copy() while nodes: freeset = set() for n in nodes: if not (n in edge_map): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodes(self):\n\n return list(set(self._graph.keys() + [x for x in itertools.chain.from_iterable(self._graph.values())]))", "def get_nodes(self):\n all_nodes = [] \n if not self._root is None:\n all_nodes.append(self._root)\n i = 0\n while i < len(all_node...
[ "0.7568372", "0.73262656", "0.72023416", "0.7110979", "0.7023111", "0.70091593", "0.69215655", "0.69215655", "0.6888474", "0.6885874", "0.6873253", "0.6856722", "0.683893", "0.68324894", "0.68254215", "0.6821848", "0.6817674", "0.6773258", "0.67581", "0.6743985", "0.67398155"...
0.0
-1
Retrieve the contents of the uri as raw data.
def DataFromURI (uri, archive_directory=None): from pyxb.utils.six.moves.urllib.request import urlopen stream = None exc = None # Only something that has a colon is a non-file URI. Some things # that have a colon are a file URI (sans schema). Prefer urllib2, # but allow urllib (which apparent...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_raw_data(url):\n\n req = requests.get(url, stream=True)\n req.raw.decode_content = True\n return req.raw", "def get_raw_data(self):\n return self.content", "def content(self):\n if hasattr(self.raw_content, 'read'):\n if hasattr(self.raw_content, 'seek'):\n...
[ "0.6983671", "0.6981274", "0.6734178", "0.65938586", "0.6462509", "0.64124036", "0.64124036", "0.6373317", "0.63549626", "0.6221609", "0.6131318", "0.60972846", "0.60972846", "0.6080169", "0.60431385", "0.6040495", "0.59788984", "0.59753805", "0.5974625", "0.5908641", "0.5903...
0.0
-1
Return a file object used to write binary data into the given file. Use the C{tag} keyword to preserve the contents of existing files that are not supposed to be overwritten. To get a writable file but leaving any existing contents in place, set the C{preserve_contents} keyword to C{True}. Normally, existing file conte...
def OpenOrCreate (file_name, tag=None, preserve_contents=False): (path, leaf) = os.path.split(file_name) if path: try: os.makedirs(path) except Exception as e: if not (isinstance(e, (OSError, IOError)) and (errno.EEXIST == e.errno)): raise fp = open(fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_write(self, filename, contents, append=True, create=True):\n return self._file_model.file_write(filename, contents, append=append, create=create)", "def file(self):\n file = BytesIO(b\"the_file\")\n file.name = self.name\n return File(file)", "def write_file(filename: str, ...
[ "0.61206645", "0.54896116", "0.54544973", "0.5446193", "0.54175335", "0.5410322", "0.5409091", "0.54074293", "0.5352646", "0.53195566", "0.5262908", "0.5253602", "0.52367777", "0.52204037", "0.5197529", "0.5163391", "0.51554316", "0.51535887", "0.51448315", "0.51125944", "0.5...
0.6841961
0
Define an optional field of the specified `field_type`.
def optional_field( field_type: Union[Type[_T], str], relation_verbose_name: Optional[str] = None ) -> Optional[_T]: metadata = {} if relation_verbose_name: metadata["relation_verbose_name"] = relation_verbose_name assert not isinstance(field_type, str) or field_type == "self" return attr....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _gen_basic_field(name_of_field, name_of_type, the_type):\n def validate(self, x):\n return None if x is None else the_type(x)\n\n doc = \"A field which can be {name_of_type} or None\".format(name_of_type=name_of_type)\n\n return Field(name_of_field, (), {'validate': validate, '__doc__': doc})",...
[ "0.6912172", "0.6548607", "0.5983148", "0.5933199", "0.5766476", "0.5714636", "0.57088166", "0.57029545", "0.5693993", "0.56425905", "0.5640413", "0.5617874", "0.56139416", "0.55398256", "0.5530448", "0.551866", "0.55133075", "0.5423735", "0.5400708", "0.536897", "0.5339176",...
0.7133128
0
Validate that the given `value` is a positive integer (``None`` accepted if `none_allowed`).
def validate_positive_integer( value: Any, none_allowed: bool, display_name: str ) -> None: if none_allowed and value is None: return if not isinstance(value, int): raise TypeError(f"{display_name} must be a positive integer") if value <= 0: raise ValueError(f"{display_name} mus...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self, value):\n super(PositiveInteger, self).validate(value)\n if value is not None and value < 0:\n raise ValidationError('must be positive integer')\n\n return True", "def must_be_positive_or_zero(cls, value):\n if value < 0:\n raise ValueError('mu...
[ "0.7604798", "0.74878687", "0.7477893", "0.7372281", "0.7327428", "0.7310186", "0.7309169", "0.72575694", "0.72093", "0.7166242", "0.71568584", "0.7155701", "0.7137333", "0.71311134", "0.71014625", "0.7099577", "0.70873487", "0.70630044", "0.70425266", "0.6931459", "0.6927795...
0.884364
0
Validate that the given `value` is a uuid (version 4) (``None`` accepted if `none_allowed`).
def validate_uuid(value: Any, none_allowed: bool, display_name: str) -> None: if none_allowed and value is None: return if not isinstance(value, UUID) or value.version != 4: raise TypeError(f"{display_name} must be a UUID version 4")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validateUuid(sValue, aoNilValues = tuple([None, '']), fAllowNull = True):\n if sValue in aoNilValues:\n return (sValue, None if fAllowNull else 'Mandatory.');\n\n try:\n sValue = str(uuid.UUID(sValue));\n except:\n return (sValue, 'Invalid UUID value.');\n ...
[ "0.7557076", "0.7478994", "0.69724876", "0.6930316", "0.6930316", "0.67378175", "0.6720659", "0.6699453", "0.6679053", "0.6581491", "0.6578702", "0.65757734", "0.6468944", "0.63455117", "0.62802315", "0.6190816", "0.6187551", "0.6185069", "0.61406916", "0.6130624", "0.6036289...
0.8942554
0
Check if the `other` object is the same as the current entity.
def __eq__(self, other: Any) -> bool: return self.__class__ is other.__class__ and self.identifier == other.identifier
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_same_as(self, other) -> bool:\n return self.x == other.x and self.y == other.y", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def isEqual (self, other) :\n return self.id == other.getIdent ()", "...
[ "0.7627001", "0.7524863", "0.75003135", "0.74242216", "0.7374001", "0.73416567", "0.73283696", "0.7320224", "0.73065877", "0.7293747", "0.7282203", "0.7267234", "0.7267234", "0.72443", "0.7168728", "0.7168728", "0.71605027", "0.7157209", "0.71495193", "0.71488017", "0.7118426...
0.70562375
27
Returns the MAC addr of the default route interface.
def get_my_mac(): mac_set = get_my_mac_set(iface_filter=get_default_route()[1]) return mac_set.pop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mac_address():\n eth0_interface = 'eth0'\n addresses = netifaces.ifaddresses(eth0_interface)[netifaces.AF_LINK][0]\n mac_address = addresses['addr']\n return mac_address", "def _get_mac_address():\n if not sys.platform.startswith('linux'):\n raise RuntimeError(\n ...
[ "0.7658759", "0.74536973", "0.7277858", "0.72755444", "0.7194526", "0.71769273", "0.7160586", "0.7160586", "0.70613533", "0.7003071", "0.69405645", "0.6910481", "0.66923755", "0.66786265", "0.6658495", "0.66388994", "0.6506183", "0.6499232", "0.64577436", "0.6418158", "0.6375...
0.63501954
22
Returns a set of MAC addresses of the current host.
def get_my_mac_set(iface_filter=None): out_set = set() if sys.platform.startswith("win"): from scapy.arch.windows import NetworkInterface if type(iface_filter) == NetworkInterface: out_set.add(iface_filter.mac) for iface in sc.get_if_list(): if iface_filter is not None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mac_address_table(self):\n\n mac_address_table = []\n command = '/interface bridge host print terse'\n\n output = self._send_command(command)\n\n for host in parse_terse_output(output):\n mac_address_table.append({\n 'mac': cast_mac(host.get('mac-addres...
[ "0.7482564", "0.6907314", "0.6590226", "0.65625256", "0.6528473", "0.6510169", "0.64578533", "0.6432203", "0.6377891", "0.6288591", "0.628722", "0.6238919", "0.61721426", "0.612203", "0.61172384", "0.6117105", "0.611112", "0.6107273", "0.6101588", "0.61014223", "0.6100259", ...
0.6956676
1
Returns max value even if one value is None. Python cannot compare None and int, so build a wrapper around it.
def smart_max(v1, v2): if v1 is None: return v2 if v2 is None: return v1 return max(v1, v2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_or_none(val1, val2):\n return max(val1, val2, key=lambda x: -sys.maxint if x is None else x)", "def _null_max(a, b):\n if a is None:\n return b\n if b is None:\n return a\n return max(a, b)", "def safe_max(*args, **kwargs):\n non_nones = [v for v in args if v is not None]\n if len(non...
[ "0.80553114", "0.75645834", "0.7535309", "0.73482525", "0.73250914", "0.7310397", "0.71636283", "0.7039921", "0.6897146", "0.683178", "0.683178", "0.66911846", "0.6678974", "0.6672838", "0.65168035", "0.6475494", "0.6462417", "0.64038867", "0.6399651", "0.63938457", "0.638854...
0.6923149
8
Returns a new min_max_tuple with value considered.
def get_min_max_tuple(min_max_tuple, value): min_v, max_v = min_max_tuple min_v = smart_min(min_v, value) max_v = smart_max(max_v, value) return (min_v, max_v)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def minmax(xs):\n min_val = None\n max_val = None\n for x in xs:\n if min_val is None or x < min_val:\n min_val = x\n if max_val is None or x > max_val:\n max_val = x\n return (min_val, max_val)", "def min_max(items):\n return min(items), max(items)", "def get...
[ "0.6693996", "0.64518523", "0.64440703", "0.6297684", "0.62571377", "0.62511533", "0.62077963", "0.6191093", "0.60693395", "0.60650694", "0.606241", "0.6000497", "0.5987081", "0.596118", "0.59477913", "0.5943709", "0.59234643", "0.5913458", "0.59077615", "0.58547777", "0.5853...
0.8177951
0
Read data from the specified file and return a DataFrame with initialized Woodwork typing information.
def read_file( filepath=None, content_type=None, name=None, index=None, time_index=None, semantic_tags=None, logical_types=None, use_standard_tags=True, column_origins=None, validate=True, **kwargs, ): if content_type is None: inferred_type, _ = guess_type(filepat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(filename, replace_columns=True):\n f = open(filename)\n lines = f.readlines()\n f.close()\n\n # Extract column names from the odt file.\n for i, line in enumerate(lines):\n if line.startswith('# Columns:'):\n columns = []\n odt_section = i # Should be removed a...
[ "0.6507035", "0.65043277", "0.6450428", "0.64499086", "0.6407715", "0.64070654", "0.6400475", "0.636086", "0.63339907", "0.6281543", "0.62003183", "0.6192413", "0.6171629", "0.61666185", "0.61514276", "0.6145966", "0.6128902", "0.6121019", "0.60953605", "0.6094487", "0.608278...
0.5963747
35
Checks if the given string is an url path. Returns a boolean.
def _is_url(string): return "http" in string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_url(string):\n try:\n urlparse(string)\n return True\n except:\n return False", "def _isurl(self, path):\n\n # We do this here to reduce the 'import numpy' initial import time.\n from urllib.parse import urlparse\n\n # BUG : URLs require a scheme string ('ht...
[ "0.7862628", "0.7810629", "0.767805", "0.7643565", "0.75058174", "0.7505675", "0.7447057", "0.7316432", "0.7258737", "0.7161608", "0.71375453", "0.712712", "0.7124779", "0.7047876", "0.69866467", "0.6979022", "0.6970283", "0.69291806", "0.6908584", "0.68603164", "0.6845472", ...
0.7715387
2
Reformats LatLong columns to be tuples of floats. Uses np.nan for null values.
def _reformat_to_latlong(latlong, use_list=False): if _is_null_latlong(latlong): return np.nan if isinstance(latlong, str): try: # Serialized latlong columns from csv or parquet will be strings, so null values will be # read as the string 'nan' in pandas and Dask and 'Na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _to_latlong_float(val):\n if _is_null_latlong(val):\n return np.nan\n\n try:\n return float(val)\n except (ValueError, TypeError):\n raise ValueError(\n f\"Latitude and Longitude values must be in decimal degrees. The latitude or longitude represented by {val} cannot be...
[ "0.62581193", "0.61285114", "0.60195297", "0.5976948", "0.5868812", "0.58154327", "0.58131707", "0.5779865", "0.5701041", "0.5647569", "0.56311095", "0.55860037", "0.5583961", "0.5559613", "0.5548943", "0.55404603", "0.553762", "0.55290985", "0.5450382", "0.5439959", "0.54382...
0.7167407
0
Check if image is monochrome (1 channel or 3 identical channels)
def is_greyscale(im): if im.mode not in ("L", "RGB"): raise ValueError("Unsuported image mode") if im.mode == "RGB": rgb = im.split() if ImageChops.difference(rgb[0],rgb[1]).getextrema()[1]<50: return True if ImageChops.difference(rgb[1],rgb[2]).getextrema()[1]<50: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_grayscale(img):\n return len(img.shape) == GS", "def is_rgb(img: np.ndarray) -> bool:\n\n return len(img.shape) >= 1 and img.shape[-1] == 3", "def is_rgb(im):\n if(im.ndim == 3):\n return True\n else:\n return False", "def is_grayscale(self):\n return self.r == self.g ...
[ "0.6841092", "0.6761836", "0.6705805", "0.66970956", "0.66970956", "0.66915894", "0.66832644", "0.66789466", "0.6668601", "0.66212636", "0.6512574", "0.64841646", "0.6445938", "0.62805843", "0.6196331", "0.6193798", "0.6140048", "0.61379707", "0.607563", "0.5938107", "0.58921...
0.6241654
14
Pull all values of specified key from nested JSON.
def extract_values(obj, key): arr = [] def extract(obj, arr, key): """Recursively search for values of key in JSON tree.""" if isinstance(obj, dict): for k, v in obj.items(): if isinstance(v, (dict, list)): extract(v, arr, key) eli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_values(obj, key): \n arr = [] \n def extract(obj, arr, key): \n \"\"\"Recursively search for values of key in JSON tree.\"\"\" \n if isinstance(obj, dict): \n for k, v in obj.items(): \n if isinstance(v, (dict, list)): \n extract(v, arr, ...
[ "0.7464168", "0.7443741", "0.7369895", "0.7284909", "0.7274706", "0.64360756", "0.6146865", "0.6104974", "0.6104974", "0.6104974", "0.6104974", "0.6104974", "0.60903376", "0.60786164", "0.6048849", "0.60177237", "0.59510297", "0.58260304", "0.5792954", "0.5788423", "0.5784647...
0.73674846
4
Compute sigmoid focal loss between logits and onehot labels logits and onehot_labels must have same shape [batchsize, num_classes] and the same data type (float16, 32, 64)
def focal_loss_binary_v1(logits, labels, *args, **kargs): config = args[0] alpha = config.alpha gamma = config.gamma name = config.name scope = config.scope with tf.name_scope(scope, 'focal_loss') as sc: precise_logits = tf.cast(logits, tf.float32) onehot_labels = tf.cast(labels...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def focal_loss_sigmoid(labels, logits, alpha=0.5, gamma=2):\n\n prob = logits.sigmoid()\n labels = torch.nn.functional.one_hot(labels.squeeze().long(), num_classes=prob.shape[1])\n\n cross_ent = torch.clamp(logits, min=0) - logits * labels + torch.log(1+torch.exp(-torch.abs(logits)))\n prob_t = (la...
[ "0.7240234", "0.7053479", "0.6910648", "0.6879288", "0.6874337", "0.68407536", "0.6780927", "0.6735924", "0.6692267", "0.6682686", "0.66726583", "0.6653518", "0.6648617", "0.66462076", "0.6583057", "0.65666443", "0.65384763", "0.6518688", "0.6515234", "0.6501828", "0.64899045...
0.6911841
2
Returns the article with the matching ID. If the input is invalid or the article is not found, empty list is returned.
async def read(articleid=True, uid=False): # Load Settings settings = await fetch_settings() table = settings["table"] if uid: connection = await connect() row = await connection.fetch(f""" SELECT * FROM "{table}" WHERE "UID" = $1; """, str(uid)) await connectio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_article_by_id(article_id):\n return Article.query.get(article_id)", "def article_by_id(self, id):\n return self.es.get(index=self.index, doc_type=self.doc_type, id=id)", "def get_article(db:Session, article_id:int):\n return db.query(ArticleModel).filter(ArticleModel.id==article_id).fi...
[ "0.7299674", "0.72322524", "0.66822433", "0.6633324", "0.6590151", "0.65629405", "0.65505624", "0.6432341", "0.6406346", "0.63084596", "0.618541", "0.6159589", "0.61246026", "0.6113103", "0.6112983", "0.61097807", "0.61086154", "0.6098706", "0.60838187", "0.60618377", "0.5965...
0.5591262
37
Try to get an item which is not in cache.
def test_not_in_cache(self): cache = LRUCache(5) cache.put(1, 'aaa') with pytest.raises(KeyError): cache.get(2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cache_get_non_existent_item(self):\n self.assertEqual(self.cache.get('ghost'), None)\n self.assertEqual(self.cache.get('ghost', 'never exists'), 'never exists')", "def cache_get(item: str) -> object:\n\titem = str(item)\n\tcache = cache_find(item)\n\n\t# cache_find() will return none if th...
[ "0.7817607", "0.7279909", "0.72218347", "0.6908121", "0.6884229", "0.6844522", "0.6797734", "0.6797734", "0.67853546", "0.66918856", "0.66252756", "0.65928084", "0.6575667", "0.6556451", "0.65513223", "0.65501046", "0.64767206", "0.6476355", "0.64720345", "0.6445206", "0.6433...
0.61973614
37
Returns the isotope specific mass of an element given it's symbol.
def get_mass_of_element(label: str, average=False): masses = {"H": [1.00782503223, 1.007975], "D": [2.01410177812, 1.007975], "T": [3.0160492779, 1.007975], "HE3": [3.0160293201, 4.002602], "HE": [4.00260325413, 4.002602], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mass(element):\n return pt.elements.isotope(element).mass", "def get_mass(elem):\n return mass[get_num(elem)]", "def mass_number(isotope):\n\n try:\n isotope = isotope_symbol(isotope)\n mass_numb = Isotopes[isotope][\"mass_number\"]\n except TypeError:\n raise(\"Incorre...
[ "0.81476235", "0.7638916", "0.7026116", "0.7023117", "0.70116776", "0.6974709", "0.6889708", "0.67309386", "0.66481125", "0.6505008", "0.6422049", "0.64141816", "0.6231803", "0.6203267", "0.62013227", "0.6162327", "0.612443", "0.6095404", "0.60924655", "0.6050567", "0.6003955...
0.61135614
17
Creates an instance of FullSlateQAgent.
def create_agent(sess, environment, eval_mode, summary_writer=None): kwargs = { 'observation_space': environment.observation_space, 'action_space': environment.action_space, 'summary_writer': summary_writer, 'eval_mode': eval_mode, } return full_slate_q_agent.FullSlateQAgent(sess, **kwargs...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, agent: AEA) -> None:\n self._agent = agent\n super().__init__()", "def __init__(self, agent):\n self.agent = agent", "def make_agent(cls, feature_dim: int):\n params = LinUCBTrainerParameters()\n policy_network = LinearRegressionUCB(input_dim=feature_dim)\n...
[ "0.54705834", "0.54017335", "0.5360143", "0.53524786", "0.532081", "0.52880126", "0.5275774", "0.5245605", "0.5162603", "0.5136954", "0.5133092", "0.506478", "0.5050614", "0.5041798", "0.5029602", "0.50225794", "0.5000415", "0.49467543", "0.494372", "0.49293464", "0.49257118"...
0.7672317
0
build pytorch sparse tensor from scipy sparse matrix
def _build_sparse_matrix(L): shape = L.shape i = torch.LongTensor(np.vstack((L.row, L.col)).astype(int)) v = torch.FloatTensor(L.data) return torch.sparse.FloatTensor(i, v, torch.Size(shape))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_sparse(sparse_mx, args):\n sparse_mx = sparse_mx.tocoo().astype(np.float32)\n\n indices = tensor(np.vstack((sparse_mx.row, sparse_mx.col)), args, torch.long)\n values = tensor(sparse_mx.data, args)\n shape = torch.Size(sparse_mx.shape)\n return torch.sparse.FloatTensor(indices, values, shap...
[ "0.796601", "0.7868917", "0.7575538", "0.7542745", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7536977", "0.7524836", "0.7500391", "0.7500391", "0.7469076", "0...
0.71739733
29
Returns a series that is the sum of self and other. Other must be of type series.
def __add__( self, other ) : try : other = float( other ) c_ls = self.copy( ) for l, c_l in enumerate( c_ls ) : c_ls.coefficients[l] += other except : self.checkSameSeriesType( other ) c_l1, c_l2 = self, other if( len( self ) < len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iadd__(self, other):\n\n other_data = self._setup_numeric(other)\n self.data[:] = self.data + other_data\n\n return self", "def add(self, other):\n return Rational(self.numerator * other.denominator + other.numerator * self.denominator,\n self.denominator * other....
[ "0.6732401", "0.67292297", "0.67142594", "0.66830236", "0.66806585", "0.6671922", "0.6629293", "0.6621051", "0.6610413", "0.6592071", "0.65873456", "0.6580911", "0.65693367", "0.65573466", "0.65534055", "0.65260255", "0.65138066", "0.65138066", "0.65107846", "0.65107846", "0....
0.7240741
0
Returns a string representation of the Legendre coefficients of self.
def __str__( self ) : return( ' '.join( [ "%g" % c_l for c_l in self.coefficients ] ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) -> str:\n polynomial = \"\"\n for i in range(self.degree, -1, -1):\n if self.coefficients[i] == 0:\n continue\n elif self.coefficients[i] > 0:\n if polynomial:\n polynomial += \" + \"\n else:\n ...
[ "0.7132573", "0.7088107", "0.7008161", "0.6643579", "0.6630837", "0.65799516", "0.6563335", "0.6466858", "0.64041", "0.6261458", "0.61700726", "0.60786355", "0.60670334", "0.6052568", "0.60470456", "0.59455264", "0.59455264", "0.5886966", "0.5853961", "0.5853961", "0.5837405"...
0.7432365
0
Returns the (l+1)^th Legendre coefficient. Returns 0 if l is greater than lMax. This is like __getitem__ but allows for l to be greater than lMax.
def getCoefficientSafely( self, l ) : if( l >= len( self ) ) : return( 0. ) return( self.coefficients[l] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def L(self) -> float:\n return self._L", "def get_index_lm(l, m):\n return (l+1)**2 -1 -l + m", "def lmax(self):\n return self._get_mean_and_samples_attribute('lmax')", "def rough_l_max(L):\r\n # TODO: Check if L is sparse or not, and handle the situation accordingly\r\n\r\n l_max ...
[ "0.5956594", "0.56653345", "0.56390405", "0.549751", "0.5469573", "0.5406137", "0.5384759", "0.5371135", "0.532755", "0.5325025", "0.5284894", "0.5221713", "0.5215056", "0.5202324", "0.5152489", "0.51466537", "0.51410526", "0.5139852", "0.5134509", "0.51142156", "0.5101439", ...
0.61501306
0
This method returns a series instance that is the mirror of self about mu = 0. That is, returns a Legendre series which represent self's pdf(mu).
def invert( self ) : series_ = self.copy( ) for l in xrange( 1, len( series_ ), 2 ) : series_.coefficients[l] *= -1 return( series_ )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate( self, mu ) :\n\n P = 0.\n for l, c_l in enumerate( self.coefficients ) : P += ( l + 0.5 ) * c_l * Legendre( l, mu, checkXRange = False ) \n return( P )", "def Legendre( n, mu, checkXRange = True ) :\n\n if( n < 0 ) : raise ValueError( \"\\nError, n = %d < 0\" % n )\n if( ...
[ "0.5843213", "0.57312196", "0.53982913", "0.5381649", "0.5314024", "0.5301381", "0.52957344", "0.5271874", "0.5208762", "0.519065", "0.5190122", "0.515166", "0.5136359", "0.51294404", "0.51028275", "0.5095762", "0.50956875", "0.5048561", "0.50120205", "0.5002445", "0.49968487...
0.5081817
17
This method returns the XML string representation of self.
def toXML( self, indent = '', **kwargs ) : return( '\n'.join( self.toXMLList( **kwargs ) ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_xml(self):\n return etree.tostring(self.get_etree())", "def xml_string(self):\n if self._xml_string is not None:\n return self._xml_string\n\n return etree.tostring(self._xml_node)", "def xml_string(self):\r\n if self._xml_string is not None:\r\n return...
[ "0.8714798", "0.82712334", "0.8227302", "0.81430227", "0.8142118", "0.7979049", "0.795583", "0.795583", "0.7886356", "0.788343", "0.7847425", "0.7836799", "0.7793108", "0.76542884", "0.7642132", "0.7564833", "0.75299317", "0.7519748", "0.7339653", "0.7315094", "0.7206009", ...
0.70262665
32
This method returns self as a list of strings which converts to the XML string representation of self via the python statement '\n'.join( XMLList ).
def toXMLList( self, indent = '', **kwargs ) : indent2 = indent + kwargs.get( 'incrementalIndent', ' ' ) attributesStr = baseModule.xDataFunctional.attributesToXMLAttributeStr( self ) if( None in self.fixedDomain( ) ) : attributesStr += ' domainMin="%s" domainMax="%s"' % ( self.domainMin, sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toXML(self):\n return self._xmlpre+\"\\n\".join(map(lambda f:f.toXML(),self._items))+self._xmlpost", "def toXML( self, indent = '', **kwargs ) :\n\n return( '\\n'.join( self.toXMLList( **kwargs ) ) )", "def toXML_strList( self, indent = \"\", **kwargs ) :\n\n attrs = self.standardXML_a...
[ "0.7436939", "0.7417716", "0.7324204", "0.721946", "0.69914997", "0.6972634", "0.68538475", "0.68122447", "0.6602612", "0.6596324", "0.6501499", "0.63801146", "0.63736784", "0.63727415", "0.63483125", "0.63483125", "0.6346497", "0.6341804", "0.6306528", "0.624068", "0.6221831...
0.6835477
7
Translate a series XML element into its python xData class.
def parseXMLNode( cls, xDataElement, xPath, linkData, axes = None, **kwargs ) : xPath.append( xDataElement.tag ) domainMin, domainMax = cls.fixedDomain( ) attrs = { 'label' : None, 'index' : None, 'value' : None, 'domainMin' : domainMin, 'domainMax' : domainMax, 'lowerIndex' : 0 } attr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _xml_to_series(self, xml):\n d = self._xml_to_dict(xml)\n d = d['Data']\n if isinstance(d, basestring):\n raise EmptyXMLError('Provided xml has no content.')\n shows = d['Series'] #list of dicts\n if self.get_first:\n if isinstance(shows, list):\n ...
[ "0.7209701", "0.5524327", "0.5493264", "0.5473774", "0.5464128", "0.5341623", "0.5281256", "0.52495944", "0.5248997", "0.5244229", "0.51978624", "0.51956004", "0.5122658", "0.5092953", "0.5086773", "0.5048923", "0.502929", "0.4988998", "0.49827087", "0.49827087", "0.49813077"...
0.6444945
1
Returns the key's algorithm. Returns the key's algorithm. For example, "DSA" indicates that this key is a DSA key and "AES" indicates that this key is an AES key.
def get_algorithm(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_algorithm(self) -> str:\n return pulumi.get(self, \"key_algorithm\")", "def algorithm(self) -> str:\n return pulumi.get(self, \"algorithm\")", "def algorithm(self) -> str:\n return pulumi.get(self, \"algorithm\")", "def host_key_algorithm(self) -> Optional[pulumi.Input[str]]:\n ...
[ "0.84255755", "0.75325805", "0.75325805", "0.7440511", "0.7440511", "0.7440511", "0.7440511", "0.72322077", "0.72157735", "0.71145105", "0.7000427", "0.7000427", "0.6930746", "0.6767155", "0.67049617", "0.6699912", "0.6699233", "0.66160226", "0.6573479", "0.6413303", "0.61284...
0.6505716
19
The queryset method is provided so that it can be overridden.
def queryset(self, ordering=None): qs = self.model._default_manager.get_query_set() if not ordering: ordering = self.ordering or () # otherwise we might try to *None, which is bad ;) if ordering: qs = qs.order_by(*ordering) return qs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self, request, queryset):\n\n return queryset", "def get_queryset(self):\n return None", "def get_queryset(self):\n return None", "def get_queryset(self) -> QuerySet:\n raise NotImplementedError()", "def get_queryset(self):\r\n return self.model.objects.a...
[ "0.81146026", "0.8041351", "0.8041351", "0.8002094", "0.76750034", "0.7618564", "0.7516059", "0.74419713", "0.73497534", "0.7269164", "0.7256817", "0.7184655", "0.71785027", "0.71441925", "0.7104195", "0.7047709", "0.7024951", "0.6992142", "0.6982073", "0.6956003", "0.6942959...
0.0
-1
A string representation of the ModelInsert to be used in the markup of our editor.
def nav_title(self): return self.model._meta.module_name.title()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n msg = [\n f'{self.model=}',\n f'{self.field=}',\n f'{self.fxx=}',\n f'{self.date=}',\n f'{self.priority=}',\n ]\n return '\\n'.join(msg)"...
[ "0.67001086", "0.6655306", "0.66115713", "0.65009993", "0.6498507", "0.64522177", "0.6450394", "0.64110154", "0.6365881", "0.63304186", "0.62966365", "0.6292392", "0.6285196", "0.6281116", "0.62788236", "0.6260246", "0.6245304", "0.62451434", "0.6235632", "0.6235632", "0.6227...
0.0
-1
Converts a "CamelCasedName" to "Camel Case Name".
def space_out_camel_case(camel): chars = [] for char in camel: if len(chars) >= 2 and chars[-1] != ' ': if char.isupper() and chars[-1].islower(): chars.append(' ') elif char.islower() and chars[-1].isupper() and chars[-2].isupper(): chars...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_camel_case(name):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', name)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()", "def name_to_camel_case(name: str) -> str:\n\n s = name.lower().split('-')\n\n if len(name) == 0:\n return name\n\n return s[0] + ...
[ "0.8697703", "0.843491", "0.8326707", "0.8243454", "0.8046422", "0.80459934", "0.79421145", "0.7935976", "0.7869358", "0.78269863", "0.7812251", "0.7740994", "0.77106375", "0.76953745", "0.7690271", "0.7606156", "0.7602473", "0.7591027", "0.7572725", "0.74933773", "0.74553585...
0.65566933
99
Month difference between two date
def month_difference(start_date, end_date): diff = get_date_difference(start_date, end_date, date_format=app_constant.DATE_FORMAT) return (diff.years * 12) + diff.months
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diff_month(d1, d2):\n return ceil(abs((d1.year - d2.year) * 12 + d1.month - d2.month))", "def month_diff(date1, date2):\n # First make sure, that date2 > date1\n if date1.daysTo(date2) < 0:\n date_tmp = date1\n date1 = date2\n date2 = date_tmp\n years = date2.year() - date1.y...
[ "0.82325315", "0.8005704", "0.741271", "0.70641917", "0.65974706", "0.6472219", "0.64395374", "0.6343015", "0.6343015", "0.6265528", "0.62616324", "0.622663", "0.6211122", "0.6019535", "0.6005004", "0.5913367", "0.5909849", "0.58972967", "0.58922505", "0.5863856", "0.5855514"...
0.80673754
1
Convert a given time to a specified Timezone
def convert_timezone(date_time, tz=pytz.timezone('UTC'), datetime_format=app_constant.DATE_TIME_ZONE_FORMAT): date_time = _get_date_time(date_time=date_time, datetime_format=datetime_format) return date_time.astimezone(tz)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def localize_time(self, apitime):\n return self.feedzone.localize(apitime).astimezone(self.localzone)", "def convert_timezone(time):\n if time is None:\n return None\n from_zone = tz.tzutc()\n to_zone = tz.tzlocal()\n try:\n utc = datetime.strptime(time, \"%Y-%m-%dT%H:%M:%S.%fZ\"...
[ "0.69090134", "0.65010804", "0.641043", "0.6359306", "0.6335926", "0.62799233", "0.6257645", "0.6246228", "0.61895317", "0.61705077", "0.6158007", "0.61537564", "0.6142579", "0.61303157", "0.6061626", "0.60292166", "0.5995043", "0.59764725", "0.5971496", "0.5970153", "0.59701...
0.6869383
1
Convert a Stanza Doc to a spaCy Doc.
def __call__(self, text): if not text: return Doc(self.vocab) elif text.isspace(): return Doc(self.vocab, words=[text], spaces=[False]) snlp_doc = self.snlp(text) text = snlp_doc.text snlp_tokens, snlp_heads = self.get_tokens_with_heads(snlp_doc) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pos_tag_doc(self, doc):\n\n return self.spacy(doc, tag=True, parse=False)", "def spacy2Document(spacy_output):\n\n d = LingData()\n d.setNLPID(\"spacy\")\n\n # generate the flat list of tokens in the document\n for token in spacy_output:\n t = toLingDataToken(token)\n d.addTo...
[ "0.65967274", "0.62569404", "0.60934687", "0.59265536", "0.5842362", "0.5476757", "0.54641235", "0.53098583", "0.53098583", "0.530009", "0.52783155", "0.51491964", "0.5110935", "0.5090491", "0.5075722", "0.5042811", "0.5037792", "0.5030325", "0.50129277", "0.50013834", "0.499...
0.4635611
44
Tokenize a stream of texts.
def pipe(self, texts): for text in texts: yield self(text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(text):\n sentence = Sentence(text)\n return sentence.tokens()", "def tokenize(self, raw_text):\n # TODO implement\n raw_tokens = word_tokenize(raw_text.decode('utf8'))\n return self.filter_tokens(raw_tokens)\n # return self.split_by(raw_tokens, '-')", "def tokeniz...
[ "0.6972144", "0.6878096", "0.6754484", "0.66774136", "0.6632644", "0.66119075", "0.65991056", "0.6565779", "0.6549146", "0.65140474", "0.64442205", "0.6435342", "0.6427228", "0.64252615", "0.6397074", "0.63926095", "0.638249", "0.6379741", "0.6365185", "0.6360599", "0.6302514...
0.0
-1
Get Stanza's pretrained word embedding for given token.
def token_vector(self, token): unit_id = self.svecs.vocab.unit2id(token.text) return self.svecs.emb[unit_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def embed_word(self):\n return self.emb.get_keras_embedding(trainable = self.trainable_emb,\n input_length = self.sent_maxlen)", "def embed_word(self):\n return self.emb.get_keras_embedding(dropout = self.emb_dropout,\n ...
[ "0.66952914", "0.6684175", "0.64566797", "0.6257592", "0.6242103", "0.62221485", "0.6134039", "0.6131169", "0.605735", "0.60233706", "0.5972393", "0.59586847", "0.5947365", "0.5943483", "0.59075576", "0.58292437", "0.5815401", "0.58041406", "0.5802354", "0.5739737", "0.573806...
0.52482116
81
Like bisect.bisect_right, but works on functions. Return the index where to insert item x in list a, assuming a is sorted.
def bisect_right(func, val, low, high): a = low b = high while b > a: guess = (a+b)//2 if val >= func(guess): a = guess+1 else: b = guess return a
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_gt_index(a, x):\n i = bisect_right(a, x)\n if i < len(a):\n return i\n raise ValueError", "def bisect_keep_right(a, fn):\n lo = 0\n hi = len(a)\n while lo < hi:\n mid = (lo + hi) // 2\n if fn(a[mid:]):\n lo = mid + 1\n else:\n hi = mid\...
[ "0.7142199", "0.7103383", "0.70921564", "0.707852", "0.7020369", "0.6890925", "0.68828535", "0.6873553", "0.68617415", "0.68513507", "0.6836348", "0.67377377", "0.66642696", "0.65970486", "0.6552446", "0.64633733", "0.6312089", "0.6254765", "0.6208589", "0.6143075", "0.603459...
0.63163966
16
Verify self.filekind is a supported filekind.
def check_filekind(self): assert self.filekind in self.obs_package.FILEKINDS, \ "Invalid filekind " + repr(self.filekind) + " in " + repr(self.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _IsFile(self, kind, path):\n\n return { Database.TEST : self._IsTestFile,\n Database.RESOURCE : self._IsResourceFile,\n Database.SUITE : self._IsSuiteFile } [kind] (path)", "def test_allowed_file(self):\r\n u = Uploader()\r\n for ext in u.allowed_extension...
[ "0.64936244", "0.6368033", "0.63460654", "0.61710685", "0.61701775", "0.61468863", "0.60850877", "0.6062987", "0.60531515", "0.60286754", "0.6024042", "0.6004679", "0.5960114", "0.59362644", "0.59286594", "0.59258145", "0.59241706", "0.59177876", "0.59172714", "0.590702", "0....
0.8553937
0
A subclasssafe repr which includes required parameters except for 'mapping' which is implied by the classname.
def __repr__(self): rep = self.__class__.__name__ + "(" rep += repr(self.filename) rep += ", " rep = rep[:-2] + ")" return rep
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n args = [self.name]\n if self.propertiesstr:\n args.append(self.propertiesstr)\n args = map(repr, args)\n return \"%s(%s)\" % (type(self).__name__, \", \".join(args))", "def __repr__(self):\n args = []\n if self.name != defaultname:\n ...
[ "0.7597881", "0.7584449", "0.7495437", "0.73655", "0.7239932", "0.710881", "0.7055924", "0.69361496", "0.6904115", "0.68714964", "0.685295", "0.68377435", "0.6808689", "0.67595285", "0.67349494", "0.6729093", "0.66988355", "0.66902626", "0.6686592", "0.6657674", "0.6649637", ...
0.0
-1
Get the references mentioned by the closure of this mapping but not in the cache.
def missing_references(self): return [ ref for ref in self.reference_names() if not config.file_in_cache(self.name, self.observatory) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def references(self) -> Collection[Access]:\n # we don't want to publicly expose the mutable version of this\n return self.__accesses", "def missing_mappings(self):\n return [ mapping for mapping in self.mapping_names() if not config.file_in_cache(self.name, self.observatory) ]", "def get_...
[ "0.5917911", "0.5849297", "0.5824473", "0.58160526", "0.5787286", "0.5781524", "0.5726434", "0.56811655", "0.5641355", "0.5490074", "0.5472923", "0.54542756", "0.54375136", "0.53960466", "0.5391382", "0.5391382", "0.5377214", "0.53681505", "0.5359045", "0.53483653", "0.534032...
0.6933123
0
Return the string representation of this mapping, i.e. pretty serialization. This is currently limited to initially creating rmaps, not rewriting them since it is based on internal representations and therefore loses comments.
def format(self): if self.comment: return "header = {0}\n\ncomment = {1}\n\nselector = {2}\n" .format( self._format_header(), self._format_comment(), self._format_selector()) else: return "header = {0}\n\nselector = {1}\n".format(self._format_header(), self._forma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump(self) -> str:\n return '\\n'.join(map(str, self._mappings.values()))", "def dump_map(self) -> str:\n return utils.to_json(self.mapping)", "def to_str(self) -> str:\n return pprint.pformat(self.dict())", "def to_str(self):\r\n return pprint.pformat(self.to_dict())", "def...
[ "0.79474795", "0.7814941", "0.7383358", "0.72989494", "0.72989494", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", "0.72544736", ...
0.0
-1
Return the code string for the mapping header.
def _format_header(self): return self._format_dict(self.header)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _extract_code(header):\n code = \"\"\n matcher = re.compile(\">([^\\s]*).*\")\n m = matcher.match(header)\n try:\n code = m.group(1)\n except AttributeError as e:\n raise ValueError(f\"No code in header: {header}\") from e\n return (code.lower())", "def code(self) -> str:\n ...
[ "0.685242", "0.6815781", "0.6815781", "0.66704834", "0.66704834", "0.66704834", "0.66616994", "0.65887505", "0.65712225", "0.65712225", "0.65712225", "0.65712225", "0.6516436", "0.6516436", "0.6516436", "0.6516436", "0.6414705", "0.6414705", "0.6414705", "0.6414705", "0.62989...
0.0
-1
Return an inmemory copy of this rmap as a new object.
def copy(self): return self.from_string(self.format(), self.filename, ignore_checksum=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self) -> 'Map':\n return self.__class__(self)", "def copy(self):\n return self.__class__(*self.maps[:-1], self.maps[-1].copy())", "def copy(self):\n cpy = self._copyBase(MapEvalTree(self[:]))\n cpy.cachesize = self.cachesize # member specific to MapEvalTree\n return...
[ "0.7539535", "0.70756036", "0.7063901", "0.69762677", "0.69151205", "0.6899967", "0.68468034", "0.6713913", "0.66372114", "0.6632951", "0.66171056", "0.65902823", "0.6583907", "0.6566887", "0.65535843", "0.6543269", "0.6524498", "0.6511671", "0.64668494", "0.64515644", "0.644...
0.0
-1
Return a 'pure data' dictionary representation of this mapping and it's children suitable for conversion to json. If `recursive` is nonzero, return that many levels of the hierarchy starting with this one. If recursive is zero, only return the filename and header of the next levels down, not the contents.
def todict(self, recursive=10): # dict required here for subsequent update. selections = dict([(key, val.todict(recursive-1)) if recursive-1 else (val.basename, val.header) for (key,val) in self.selections.normal_items()]) selections.update...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def todict(self, recursive=10):\n nested = self.selector.todict_flat()\n return {\n \"header\" : { key : self.header[key] for key in self.header },\n \"text_descr\" : self.obs_package.TEXT_DESCR[self.filekind],\n \"parameters\" : tuple(nested[\"parameters\...
[ "0.6563336", "0.6272748", "0.6204542", "0.6141629", "0.6061648", "0.6052795", "0.60331994", "0.603217", "0.59721714", "0.59569734", "0.59464496", "0.59462386", "0.58574337", "0.5791486", "0.572643", "0.5703174", "0.5666113", "0.56604475", "0.565065", "0.5646841", "0.564678", ...
0.6310611
1
Return a JSON representation of this mapping and it's children.
def tojson(self, recursive=10): return json.dumps(self.todict(recursive=recursive))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toJSON(self):\n\t\treturn json.dumps(self.root, default=lambda o: o.__dict__)", "def json(self):\n return json.dumps(self, default=lambda o: o.__dict__,\n sort_keys=True, indent=4)", "def to_dict(self):\n d = {'Name': self.name}\n if self._children:\n ...
[ "0.7305289", "0.71867734", "0.71564966", "0.7068548", "0.7068548", "0.7068548", "0.70458394", "0.70458394", "0.70276153", "0.70186067", "0.6979341", "0.6950104", "0.68744373", "0.68294626", "0.680055", "0.6786559", "0.6766333", "0.6766333", "0.6757407", "0.6750073", "0.673961...
0.68623036
13
Return the full path (in cache or absolute) of `filename` as determined by the current environment.
def locate_file(self, filename): return locate_file(filename, self.observatory)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_abs_filename(filename):\n absolute_current_dir = os.path.abspath(os.path.dirname(__file__))\n return os.path.join(absolute_current_dir, filename)", "def get_abs_path(filename):\n dirname = os.path.dirname(os.path.abspath(__file__))\n return os.path.join(dirname, filename)", "def getPath(fil...
[ "0.7651311", "0.75702167", "0.7496601", "0.73335075", "0.7290136", "0.7274325", "0.72494704", "0.7221216", "0.7181128", "0.7128718", "0.71173835", "0.704928", "0.70390624", "0.7036771", "0.7003301", "0.6949869", "0.69301736", "0.6926948", "0.6916549", "0.68840206", "0.6824637...
0.0
-1
Return the single reference file basename appropriate for `header_in` selected by this ReferenceMapping.
def _get_best_ref(self, header_in): header_in = dict(header_in) log.verbose("Getting bestrefs:", self.basename, verbosity=55) expr_header = utils.condition_header_keys(header_in) self.check_rmap_omit(expr_header) # Should bestref be omitted based on rmap_omit expr? self.check...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def basename(self):\n return self._getbyspec(\"basename\")[0]", "def basename(self):\n return get_basename(self.filename)", "def basename(self):\n return self.name.basename", "def basename(self):\n return os.path.basename(self.filepath)", "def get_file_basename(self):\n r...
[ "0.6580733", "0.6361837", "0.63229275", "0.6290651", "0.6271766", "0.6257614", "0.6214331", "0.60836715", "0.60500205", "0.60349244", "0.60340255", "0.60092133", "0.5975874", "0.5960335", "0.5958281", "0.5940904", "0.5915092", "0.591501", "0.58816713", "0.5859509", "0.5853816...
0.0
-1
Return the list of reference file basenames associated with this ReferenceMapping.
def reference_names(self): return [name for name in self.selector.reference_names() if not is_special_value(name)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mapping_names(self):\n return [self.basename]", "def filenames(self):\n names = []\n for furi in np.asarray(self.fileuris).flat:\n names.append(furi)\n return names", "def get_reference_housenumber_paths() -> List[str]:\n Config.__get()\n assert Config._...
[ "0.72517836", "0.7085553", "0.6623731", "0.64200705", "0.63682485", "0.63540596", "0.63540596", "0.6315137", "0.6271564", "0.62680906", "0.6234775", "0.6202142", "0.61822695", "0.6161746", "0.6111911", "0.5999768", "0.599912", "0.5956905", "0.59318477", "0.58923733", "0.58842...
0.0
-1
Return a 'pure data' dictionary representation of this mapping and it's children suitable for conversion to json. `recursive` is ignored.
def todict(self, recursive=10): nested = self.selector.todict_flat() return { "header" : { key : self.header[key] for key in self.header }, "text_descr" : self.obs_package.TEXT_DESCR[self.filekind], "parameters" : tuple(nested["parameters"]), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict(self):\r\n def node_to_dict(node):\r\n if len(node.children)==0:\r\n return node.info\r\n else:\r\n info_dict = node.info.copy()\r\n info_dict['children'] = []\r\n for c in node.children:\r\n inf...
[ "0.6972573", "0.6909221", "0.68576676", "0.6811422", "0.6789981", "0.67803043", "0.67141736", "0.6671803", "0.6619471", "0.661328", "0.65686363", "0.6470383", "0.6460556", "0.6457675", "0.64259434", "0.631434", "0.6295591", "0.62757254", "0.62687325", "0.6258878", "0.62569636...
0.587117
60
Load any `mapping`, ignoring the cache. Returns a unique object for each call. Slow but safe for any use, reads every file and returns a new copy. Return a PipelineContext, InstrumentContext, or ReferenceMapping.
def load_mapping(mapping, **keys): keys["loader"] = load_mapping return _load_mapping.uncached(mapping, **keys)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_mapping(mapping, **keys):\n if mapping.endswith(\".pmap\"):\n cls = PipelineContext\n elif mapping.endswith(\".imap\"):\n cls = InstrumentContext\n elif mapping.endswith(\".rmap\"):\n cls = ReferenceMapping\n else:\n if config.S3_ENABLED:\n m = Mapping.f...
[ "0.7033116", "0.6688804", "0.61699647", "0.6006327", "0.582595", "0.56813157", "0.56762385", "0.56305736", "0.55469227", "0.55223274", "0.5485086", "0.54406196", "0.5389387", "0.5326323", "0.53235817", "0.53080964", "0.5259044", "0.52405286", "0.52151686", "0.51678425", "0.51...
0.63241136
2
Return True IFF `filename` is one of the special values which does not correspond to a file, e.g. N/A. >>> is_special_value("foo.fits") False >>> is_special_value("N/A") True
def is_special_value(filename): return MappingSelectionsDict.is_special_value(str(filename))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_filename_safe(value):\n return value == str_to_filename(value)", "def test_09_is_allowed_file_no_ext(self):\n\n filename = \"somename\"\n is_allowed = utils.is_allowed_file(filename)\n self.assertFalse(is_allowed)", "def is_filename_safe(filename: str) -> bool:\n allowed_f...
[ "0.64880186", "0.6151668", "0.6040881", "0.60315907", "0.6031464", "0.59940237", "0.59470975", "0.59439623", "0.5933223", "0.59257495", "0.59082377", "0.59082377", "0.5886398", "0.58448243", "0.58448243", "0.584331", "0.584331", "0.58404434", "0.5823541", "0.5823541", "0.5823...
0.810885
0
Adds a sequence of tokens to this ngram.
def add(self, tokens): for token in tokens: self.vocab.add(token) for leader, token in generate_ngrams(tokens, self.size, include_terminator = self.size != 1): if leader not in self.frequencies: self.frequencies[leader] = Frequency() self.frequencie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_tokens(self, tokens):\n if self.pad:\n tokens = [START_OF_SEQ] * self.order + tokens + [END_OF_SEQ]\n\n for i in range(len(tokens) - self.order):\n current_state = tuple(tokens[i:i + self.order])\n next_state = tokens[i + self.order]\n self.add_stat...
[ "0.75078684", "0.7305936", "0.6542211", "0.6363472", "0.6322069", "0.6322069", "0.63194484", "0.6162834", "0.6157025", "0.6140424", "0.6065426", "0.6058867", "0.6050981", "0.6041897", "0.6028869", "0.5976654", "0.5961985", "0.5961429", "0.5950294", "0.58862704", "0.5872447", ...
0.7533841
0
Generatees ngrams as pairs of leaders and tokens. If include_terminator is true an additional token and leader will be returned for the end of the sentence with the last token as None.
def generate_ngrams(tokens, ngram_size, *, include_terminator = False): if ngram_size <= 0: raise Exception("ngram size must be positive") if not include_terminator: for token_index in range(len(tokens)): leader = get_leader(tokens, token_index, ngram_size - 1) toke...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_ngrams(self, tokens):\n ngrams = []\n for i in range(len(tokens)- self.N + 1):\n ngrams.append(tuple(tokens[i:i+self.N]))\n return ngrams", "def build_ngrams(tokens, n=2):\n ngrams = zip(*(islice(group, idx, None) for idx, group in enumerate(tee(tokens, n))))\n re...
[ "0.560517", "0.55146813", "0.5456382", "0.54148364", "0.5371505", "0.53318053", "0.52578", "0.5249324", "0.5203259", "0.5085066", "0.50800323", "0.50681764", "0.5032283", "0.5019726", "0.50194144", "0.5006687", "0.49998164", "0.4996819", "0.49888602", "0.49744505", "0.4973431...
0.7815241
0
Finds all primes in range [1,n].
def eratosthenes_sieve(n): numbers = [True for i in range(n + 1)] p = 2 while (p**2 <= n): if numbers[p]: for i in range(p**2, n + 1, p): numbers[i] = False p += 1 primes = compress(range(2, n + 1),numbers[2:]) return list(primes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]", "def get_primes(n):\n\n return list(primes_sieve(n))", "def make_primes(n):\n out_list = []\n for i in range(2, n):\n if is_prime(i):\n out_list.append(i)\n return out_list", "def find_n_primes(n):\n prim...
[ "0.86469895", "0.82977706", "0.8233397", "0.8232103", "0.8216812", "0.80644727", "0.79715544", "0.79453987", "0.79171306", "0.79137146", "0.7912284", "0.7912284", "0.78986275", "0.7895275", "0.78930616", "0.7892848", "0.7891296", "0.78706557", "0.783415", "0.7817763", "0.7792...
0.7621685
30
Test case for update_record
def test_update_record(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_case(self):\n pass", "def test_patch_record(self):\n pass", "def test_record_update(app_static, app_live):\n time.sleep(SLEEP_TIME)\n record = dict(app_live.get(OBJ)[0])\n update_value = \"0.00\" if record[UPDATE_KEY] != \"0.00\" else \"1.00\"\n data = {\"id\": record[...
[ "0.7946309", "0.7794273", "0.7644227", "0.7496466", "0.7496466", "0.7496466", "0.7472344", "0.7388909", "0.72927755", "0.7211169", "0.714157", "0.7070297", "0.70664746", "0.70474994", "0.70445114", "0.70120186", "0.7008943", "0.69905704", "0.6927306", "0.6923109", "0.6922989"...
0.9378655
0
Update DataFrame column from string to datatime
def updatetotimeformat(tweetdf, colname): for i in range(len(tweetdf)): tweetdf.loc[i,colname] = parser.parse(tweetdf.loc[i,colname]) return tweetdf
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_datetime(self, dataframe, timestamp_key='UNIXTIME'):\n def convert_data(timestamp):\n return datetime.fromtimestamp(float(timestamp) / 1e3, UTC_TZ)\n try:\n converted = dataframe[timestamp_key].apply(convert_data)\n dataframe['DATETIME'] = converted\n ...
[ "0.6576167", "0.6310115", "0.6253117", "0.62048435", "0.5986647", "0.5973783", "0.593974", "0.59374064", "0.59224397", "0.5899999", "0.589413", "0.58337736", "0.57693267", "0.5692432", "0.5614722", "0.5538695", "0.55318815", "0.54667735", "0.5456263", "0.5433656", "0.5428522"...
0.6806321
0
Return current max possible score
def max_score(self): return self.raw_possible
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_score(self):\r\n return self.lcp.get_max_score()", "def max_score(self):\n return self.points", "def max_score(self):\n return max(self._extract_set('score') or [0])", "def max_score(self):\r\n max_score = None\r\n if self.check_if_done_and_scored():\r\n ...
[ "0.83607095", "0.82570076", "0.8182481", "0.81650966", "0.79798025", "0.79700476", "0.79324347", "0.78165346", "0.77685696", "0.7742203", "0.76821244", "0.7658756", "0.7647138", "0.7617604", "0.76009655", "0.75978607", "0.7399104", "0.7327616", "0.7321057", "0.7310825", "0.73...
0.8704153
0
Test if get_json_data throws Error 404.
def test_get_json_data_throw_not_found_error(self): response = self.app.test_client().get('/test/get_json_data/99999') self.assertEqual(response.json['status'], 'failure') self.assertEqual(response.json['error'], 'Test not found')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testNotFound(self):\n response = requests.get(url=self.invalid_url)\n headers = response.headers\n json_data = response.json()\n\n self.assertEqual(response.status_code, 404, WRONG_STATUS_CODE_MSG)\n self.assertEqual(\n headers['Content-Type'], 'application/json', ...
[ "0.77060896", "0.7534178", "0.7487082", "0.731388", "0.72731125", "0.7251993", "0.722905", "0.71868604", "0.7117255", "0.71160656", "0.7105604", "0.70935243", "0.707169", "0.70526576", "0.7050873", "0.7020117", "0.6991725", "0.6990176", "0.6933643", "0.6896658", "0.6866621", ...
0.8633553
0
Test if it'll return a 404 on a non existent test.
def test_get_nonexistent_test(self): response = self.app.test_client().get('/test/99999') self.assertEqual(response.status_code, 404) self.assert_template_used('test/test_not_found.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_existing_url(client):\n response = client.get('/not-exists')\n assert response.status_code == 404", "def test_get_404(self):\n url = self.baseurl + \"/do-not-implement-this-page-it-is-not-found\"\n try:\n req = urllib2.urlopen(url, None, 3)\n self.assertTrue...
[ "0.8165085", "0.8049307", "0.8038956", "0.799371", "0.79879606", "0.78720796", "0.7839402", "0.7789028", "0.7788226", "0.7763643", "0.7756521", "0.77174175", "0.7707059", "0.7660243", "0.7599413", "0.7591642", "0.75879985", "0.7513415", "0.7468065", "0.74625045", "0.7425017",...
0.78959966
5
Returns torrent client API version.
def method_get_version(self) -> str: # pragma: nocover raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version(self):\n return self.api_version", "def get_version(self):\n return self.__make_api_call('get/version')", "def get_api_version(self):\n major, minor, patch = self.client.config['api_version']\n return '%s.%s.%s' % (major, minor, patch)", "def GetVersion(self):\n ...
[ "0.78064674", "0.76813656", "0.7661497", "0.75911033", "0.7587933", "0.75630313", "0.75506276", "0.7464854", "0.7457695", "0.74385077", "0.74318", "0.7428514", "0.7354802", "0.73113", "0.72949046", "0.7292924", "0.72704196", "0.72546375", "0.7234231", "0.7234231", "0.7234231"...
0.0
-1
Given a sequence [A, B, C] of size n, creates a new sequence of the same size where each new item is the pair of the item at a given position paired up with next item.
def make_round_pairs(sequence): length = len(sequence) return [ (sequence[i], sequence[(i + 1) % length]) for i in range(length) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_pairs(sequence):\n length = len(sequence)\n return [\n (sequence[i], sequence[i + 1])\n for i in range(length - 1)\n ]", "def gen_sequence(a, b, c):\n i = 1\n while True:\n yield a * i**2 + b * i + c\n i += 1", "def window(seq, n=2):\n it = iter(seq)\n ...
[ "0.6895533", "0.63150525", "0.63032806", "0.63032806", "0.6104639", "0.60620105", "0.6022076", "0.60071945", "0.59853053", "0.5976079", "0.5930208", "0.59097314", "0.59072196", "0.58934146", "0.5870297", "0.58660096", "0.5795893", "0.5791655", "0.5769116", "0.5760917", "0.575...
0.6257828
4
Given a sequence [A, B, C] of size n, creates a new sequence of size n 1 where each element is the pair of the element paired up with next item. [(A, B), (B, C)].
def make_pairs(sequence): length = len(sequence) return [ (sequence[i], sequence[i + 1]) for i in range(length - 1) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pairwise(s):\n return [(s[i - 1], s[i]) for i in range(1, len(s))]", "def pairs(lst):\r\n\tfor i in range(1, len(lst), 2):\r\n\t\tyield lst[i-1], lst[i]", "def pairwise(lst):\r\n if not lst: return\r\n\r\n for i in range(len(lst)-1):\r\n yield lst[i], lst[i+1]\r\n yield lst[-1], None", ...
[ "0.6647065", "0.6605497", "0.6511508", "0.6460928", "0.6441834", "0.63978654", "0.63488936", "0.63446945", "0.6314862", "0.62877", "0.62877", "0.62877", "0.62877", "0.6272627", "0.6254846", "0.6254846", "0.6252398", "0.6245274", "0.6228544", "0.6206464", "0.62000936", "0.61...
0.742209
0
Reshaping happens during the call to forward.
def reshape(self, bottom, top): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, input):\n batch_size = input.size(0)\n shape = (batch_size, *self.shape)\n out = input.reshape(shape)\n return out", "def _reshape(self):\n self._frame._setup(width=self._width,height=self._height,\n startx=self._x,starty=self._y)", ...
[ "0.7052694", "0.66112494", "0.6553348", "0.6553348", "0.6445214", "0.6263273", "0.6219224", "0.62077326", "0.6204762", "0.612587", "0.612587", "0.6098139", "0.6093421", "0.6090613", "0.60858375", "0.60803044", "0.6076111", "0.60631406", "0.60622656", "0.60548824", "0.60481465...
0.57463765
88
Returns a list of primes < n, sorted by length and digit
def e_sieve(n): sieve = [True] * n for i in xrange(3, int(n**0.5)+1, 2): if sieve[i]: sieve[i*i::2*i] = [False]*((n-i*i-1)/(2*i)+1) primes_of_length = dict() for i in range(1, len(str(n))): primes_of_length[i] = [[]]*10 for j in range(1, 10): primes_of_len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_primes(n):\n primeList = []\n for i in range(n):\n if is_prime(i):\n primeList.append(i)\n return primeList", "def n_length_primes(n):\n assert n > 0, \"Cannot generate a list of %d length primes.\" % n\n a = []\n for i in range(10**(n-1), 10**n):\n if is_prime(i):\n ...
[ "0.7782975", "0.7782333", "0.7754201", "0.77479", "0.7745342", "0.76620096", "0.76518625", "0.7648402", "0.76306117", "0.7629798", "0.76070654", "0.7606282", "0.7568125", "0.7483783", "0.74646497", "0.7384399", "0.7381496", "0.73769975", "0.7351073", "0.7291742", "0.726924", ...
0.0
-1
Convert network prediction into a quantile prediction.
def to_quantiles(self, y_pred: torch.Tensor) -> torch.Tensor: if y_pred.ndim == 2: y_pred = y_pred.unsqueeze(-1) return y_pred
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_quantiles(self, y_pred: torch.Tensor) -> torch.Tensor:\n return self.metrics[0].to_quantiles(y_pred)", "def to_prediction(self, y_pred: torch.Tensor) -> torch.Tensor:\n if y_pred.ndim == 3:\n if self.quantiles is None:\n idx = y_pred.size(-1) // 2\n else:...
[ "0.69405204", "0.66854614", "0.63962317", "0.6220067", "0.6220067", "0.6220067", "0.62083036", "0.61750406", "0.6122583", "0.60333264", "0.60130334", "0.59850204", "0.5856626", "0.5762192", "0.57340574", "0.56476927", "0.5630361", "0.5611544", "0.5575561", "0.55525225", "0.55...
0.69842494
0
Convert network prediction into a quantile prediction. Will use first metric in ``metrics`` attribute to calculate result.
def to_quantiles(self, y_pred: torch.Tensor) -> torch.Tensor: return self.metrics[0].to_quantiles(y_pred)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_quantiles(self, y_pred: torch.Tensor) -> torch.Tensor:\n if y_pred.ndim == 2:\n y_pred = y_pred.unsqueeze(-1)\n return y_pred", "def _predict_quantiles(self, fh, X, alpha, legacy_interface=False):\n # X is ignored\n y_pred = self.forecaster_.predict(fh=fh, X=None)\n ...
[ "0.64407766", "0.6166652", "0.6106042", "0.6106042", "0.6106042", "0.60184526", "0.6003432", "0.5676995", "0.55563223", "0.5442841", "0.54117227", "0.5411699", "0.53962255", "0.53373915", "0.5334559", "0.5313909", "0.5313356", "0.5305422", "0.53017294", "0.5263997", "0.522271...
0.71505016
0
Compute my distance from the origin
def distance_from_origin(self): return ((self.x ** 2) + (self.y ** 2)) ** 0.5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) **0.5", "def distance_to_origin(self):\n return np.sqrt(self.x ** 2 + self.y ** 2)", "def distance_from_origin(self) -> float:\n return self._distance_from_origin", "def distanceFromOrigin(self):\n return ((sel...
[ "0.85651153", "0.8497203", "0.83239484", "0.8296965", "0.8215538", "0.7733896", "0.74213135", "0.737899", "0.72927284", "0.7264867", "0.7259701", "0.72560894", "0.72475415", "0.7231078", "0.7207231", "0.7149887", "0.71417105", "0.71378225", "0.71354437", "0.71315557", "0.7130...
0.8566417
6
Return the halfway point between myself and the target
def halfway(self, target): mx = (self.x + target.x)/2 my = (self.y + target.y)/2 return Point(mx, my)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def halfway(self, target):\r\n mx = (self.x + target.x)/2\r\n my = (self.y + target.y)/2\r\n return Point(mx, my)", "def halfway(self, target):\n mx = (self.x + target.x) / 2\n my = (self.y + target.y) / 2\n return Point(mx, my)", "def goal(target, prediction):\n ...
[ "0.8789036", "0.87399906", "0.7259315", "0.6758469", "0.6579334", "0.6313658", "0.615805", "0.60153526", "0.59883934", "0.58936673", "0.58650094", "0.58640325", "0.585778", "0.58406675", "0.5820845", "0.580087", "0.5799157", "0.5790215", "0.5785922", "0.5784319", "0.5782862",...
0.87813574
3
numerically stable log_softmax implementation that prevents overflow
def log_prob_from_logits(x): axis = len(x.get_shape()) - 1 m = tf.reduce_max(x, axis, keep_dims=True) return x - m - tf.log(tf.reduce_sum(tf.exp(x - m), axis, keep_dims=True))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stablesoftmax(x):\r\n shiftx = x - np.max(x)\r\n exps = np.exp(shiftx)\r\n return exps / np.sum(exps)", "def log_softmax(input, dim, inplace=False):\n return FunctionLib.apply(\n 'LogSoftmax', input.device, [input],\n outputs=[input if inplace else None], axis=dim)", "def log_soft...
[ "0.77298", "0.77168965", "0.77082556", "0.76411545", "0.76040596", "0.7375868", "0.7343657", "0.7335469", "0.7319122", "0.7316114", "0.7291785", "0.72785354", "0.72421026", "0.7237872", "0.7236452", "0.7203207", "0.7203207", "0.7200916", "0.719867", "0.7190057", "0.71697676",...
0.7334381
8
get all the none zero numbers
def get_none_zero_list(line): new_line = [] for dummy_i in range(0,len(line)): if line[dummy_i] != 0: new_line.append(line[dummy_i]) return new_line
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_zeros(self):\n return self.serie.isin([0]).sum()", "def get_nonzeros(self):\n return self.tape.get_nonzeros(self.machine.eval_symbol,\n self.machine.eval_state(self.state))", "def get_zeros(self):\n zero_values = self.df[self.col_name].isin([0]).sum(axis=0)...
[ "0.7489233", "0.7051678", "0.6850389", "0.67750067", "0.6606803", "0.6591398", "0.65698874", "0.6564203", "0.65258455", "0.6493081", "0.63906497", "0.636943", "0.6283294", "0.6272019", "0.6255472", "0.62469995", "0.6233126", "0.62146306", "0.61789566", "0.61694115", "0.610810...
0.69763607
2
get a list with all zero
def get_zero_list(line): zero_list = [] for dummy_i in range(0, len(line)): if line[dummy_i] == 0: zero_list.append(0) return zero_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_zero(p):\n\n return [pi == 0 for pi in p]", "def get_zeros(self):\n return self.serie.isin([0]).sum()", "def all_zeroes(self):\n\n return self.__all_zeroes__", "def zeros(n):\n return [0 for i in range(n)]", "def get_none_zero_list(line):\n new_line = []\n for dummy_i in r...
[ "0.7527247", "0.7473732", "0.74616665", "0.72223026", "0.7157325", "0.70764", "0.69731575", "0.69689333", "0.6843033", "0.6677035", "0.6616913", "0.6585737", "0.65591115", "0.6550359", "0.6548953", "0.65457416", "0.653905", "0.64571196", "0.64464927", "0.64382565", "0.6329977...
0.7374514
3
Get the height of the board.
def get_grid_height(self): # replace with your code return self._grid_height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(self):\n return self.board.shape[0]", "def getHeight(self):\n return self.height", "def getHeight(self):\n return self.height", "def getHeight(self):\n return self._height", "def get_grid_height(self):\n return self._height", "def get_grid_height(self):\n ...
[ "0.85058457", "0.7827244", "0.7827244", "0.7790992", "0.77879226", "0.77879226", "0.7767336", "0.7767336", "0.7767336", "0.7767336", "0.77655625", "0.7762097", "0.775954", "0.77538955", "0.7741838", "0.77374107", "0.77206814", "0.76960677", "0.76933795", "0.76933795", "0.7693...
0.74177706
75
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s' % (self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.7801624", "0.77112937", "0.767426", "0.767426", "0.7524702", "0.74020135", "0.7398639", "0.7378346", "0.7328583", "0.7270028", "0.7244434", "0.7233179", "0.7205981", "0.7174358", "0.7165676", "0.7108926", "0.70379156", "0.70379156", "0.7012156", "0.69865996", "0.6968002", ...
0.6755977
55
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s' % (self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.78016543", "0.7712146", "0.7675692", "0.7675692", "0.7525264", "0.740416", "0.7396687", "0.73751175", "0.732573", "0.72692174", "0.7241136", "0.7235689", "0.72075593", "0.7174236", "0.71677464", "0.710979", "0.70352644", "0.70352644", "0.70127875", "0.6987778", "0.6966356"...
0.6754608
54
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s' % (self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.7801624", "0.77112937", "0.767426", "0.767426", "0.7524702", "0.74020135", "0.7398639", "0.7378346", "0.7328583", "0.7270028", "0.7244434", "0.7233179", "0.7205981", "0.7174358", "0.7165676", "0.7108926", "0.70379156", "0.70379156", "0.7012156", "0.69865996", "0.6968002", ...
0.6755977
56
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s, %s: %s' % (self.first_author, self.year, self.title)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.78016543", "0.7712146", "0.7675692", "0.7675692", "0.7525264", "0.740416", "0.7396687", "0.73751175", "0.732573", "0.72692174", "0.7241136", "0.7235689", "0.72075593", "0.7174236", "0.71677464", "0.710979", "0.70352644", "0.70352644", "0.70127875", "0.6987778", "0.6966356"...
0.0
-1
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s' % (self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.7801624", "0.77112937", "0.767426", "0.767426", "0.7524702", "0.74020135", "0.7398639", "0.7378346", "0.7328583", "0.7270028", "0.7244434", "0.7233179", "0.7205981", "0.7174358", "0.7165676", "0.7108926", "0.70379156", "0.70379156", "0.7012156", "0.69865996", "0.6968002", ...
0.6755977
53
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s / %s - %s' % (self.qualifier_name, self.stratigraphic_qualifier, self.level)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.78016543", "0.7712146", "0.7675692", "0.7675692", "0.7525264", "0.740416", "0.7396687", "0.73751175", "0.732573", "0.72692174", "0.7241136", "0.7235689", "0.72075593", "0.7174236", "0.71677464", "0.710979", "0.70352644", "0.70352644", "0.70127875", "0.6987778", "0.6966356"...
0.0
-1
String for representing the Model object (in Admin site etc.)
def __str__(self): if self.reference is None: return '%s - %s - %s' % (self.name, self.qualifier, self.location) else: return '%s - %s - %s - %s' % (self.name, self.qualifier, self.location, self.reference)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.7801624", "0.77112937", "0.767426", "0.767426", "0.7524702", "0.74020135", "0.7398639", "0.7378346", "0.7328583", "0.7270028", "0.7244434", "0.7233179", "0.7205981", "0.7174358", "0.7165676", "0.7108926", "0.70379156", "0.70379156", "0.7012156", "0.69865996", "0.6968002", ...
0.0
-1
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s | %s' % (self.name_one, self.name_two)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.78016543", "0.7712146", "0.7675692", "0.7675692", "0.7525264", "0.740416", "0.7396687", "0.73751175", "0.732573", "0.72692174", "0.7241136", "0.7235689", "0.72075593", "0.7174236", "0.71677464", "0.710979", "0.70352644", "0.70352644", "0.70127875", "0.6987778", "0.6966356"...
0.0
-1
String for representing the Model object (in Admin site etc.)
def __str__(self): return '%s: %s' % (self.binning_scheme.ts_name, self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return super().__str__() + self.model.__str__()", "def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')", "def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"", "def __str_...
[ "0.7801624", "0.77112937", "0.767426", "0.767426", "0.7524702", "0.74020135", "0.7398639", "0.7378346", "0.7328583", "0.7270028", "0.7244434", "0.7233179", "0.7205981", "0.7174358", "0.7165676", "0.7108926", "0.70379156", "0.70379156", "0.7012156", "0.69865996", "0.6968002", ...
0.0
-1
Helper function that returns a dictionary with keys dpos, rotation from a raw input array. The first three elements are taken to be displacement in position, and a quaternion indicating the change in rotation with respect to .
def _make_input(self, action, old_quat): return { "dpos": action[:3], # IK controller takes an absolute orientation in robot base frame "rotation": T.quat2mat(T.quat_multiply(old_quat, action[3:7])), }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quaternion2rot3d(quat):\n q01 = quat[0] * quat[1]\n q02 = quat[0] * quat[2]\n q03 = quat[0] * quat[3]\n q11 = quat[1] * quat[1]\n q12 = quat[1] * quat[2]\n q13 = quat[1] * quat[3]\n q22 = quat[2] * quat[2]\n q23 = quat[2] * quat[3]\n q33 = quat[3] * quat[3]\n\n # Obtain the rotati...
[ "0.625625", "0.61586386", "0.6103831", "0.5944928", "0.58292276", "0.5763483", "0.57279813", "0.5696604", "0.5662355", "0.56512725", "0.5570072", "0.5568872", "0.55359674", "0.55227655", "0.55147916", "0.54981565", "0.54951155", "0.5437573", "0.5435121", "0.5415344", "0.54141...
0.577964
5
Returns the total from the inserted coins.
def payment_transaction(): print("Please insert coins.") payment = dict(quarters=int(input("How many quarters?:")) * 0.25, dime=int(input("How many dimes?: ")) * 0.10, nickles=int(input("How many nickles?: ")) * 0.05, pennies=int(input("How many pennies?:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_coins(self):\n print(\"Please insert coins.\")\n for coin in self.COIN_VALUES:\n self.money_received += int(input(f\"How many {coin}?: \")) * self.COIN_VALUES[coin]\n return self.money_received", "def get_total(self):\n\n base_price = 5\n total = (1 + int(self.tax)) * int(...
[ "0.6778034", "0.6634102", "0.66010493", "0.659427", "0.6579422", "0.6553819", "0.6552106", "0.65307105", "0.65197414", "0.6518301", "0.64949673", "0.64945525", "0.6466936", "0.6466936", "0.64489615", "0.6425284", "0.64176804", "0.6413573", "0.63965064", "0.6382907", "0.636799...
0.6002329
62
wall constructor taking coordinates of two diagonally opposed points of the wall we consider that the width is null
def __init__(self, coordinates): self.coordinates = coordinates
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_boundary_wall(self, height, width) -> None:\n for x in range(0, width):\n Wall(self, x, 0)\n Wall(self, x, height - 1)\n for y in range(1, height - 1):\n Wall(self, 0, y)\n Wall(self, width - 1, y)", "def add_walls(self):\n for x in range(...
[ "0.72221106", "0.68333375", "0.6824171", "0.68057823", "0.6713546", "0.66135395", "0.661195", "0.6610027", "0.6578747", "0.64780056", "0.6410548", "0.6404219", "0.63855517", "0.6350937", "0.634037", "0.6237284", "0.6136797", "0.60747224", "0.606391", "0.60148156", "0.5952303"...
0.0
-1
Extracts the starting age from the spoiler logs dicts.
def extract_age(spoiler_logs): return [0 if log["randomized_settings"]['starting_age'] == "child" else 1 for log in spoiler_logs]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_spawn(spoiler_logs, ages):\n spawns = [[log['entrances'][\"Child Spawn -> KF Links House\"], \n log['entrances'][\"Adult Spawn -> Temple of Time\"]] for log in spoiler_logs]\n \n return [[xx['region'] if isinstance(xx, dict) else xx for xx in x] for x in spawns]", "def oldest()...
[ "0.56041646", "0.5446686", "0.54392344", "0.53755945", "0.5363894", "0.534055", "0.5318432", "0.52772635", "0.5261191", "0.5216402", "0.5192486", "0.51863116", "0.5176638", "0.51354337", "0.5112253", "0.5093963", "0.50713646", "0.50247675", "0.5003254", "0.49770254", "0.49599...
0.74757224
0
Given num_people in circle, kill [kill_every]th person, return survivor.
def find_survivor(num_people, kill_every): # 1 represents alive, 0 represents dead people = [1 for person in xrange(num_people)] # track kills so we know when only one is left dead_count = 0 # for a 0-indexed list, start at position -1 position = -1 # continue kills until only one left ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def survivors_selection(self):\n q = 5\n new_population = []\n for i in range(self._population_size):\n batch = []\n for j in range(q):\n r = random.randint(0, (self._child2population_ratio + 1) * self._population_size - 1)\n if r < self._pop...
[ "0.5692708", "0.5506005", "0.5275919", "0.5144234", "0.51234853", "0.5113955", "0.50657177", "0.50389415", "0.50237817", "0.5021013", "0.49488246", "0.4881141", "0.4862901", "0.48557314", "0.48286477", "0.4793314", "0.47832945", "0.47830445", "0.47760513", "0.47736254", "0.47...
0.81542957
0
Calculate the mean intracluster distance for sample i.
def _intra_cluster_distance(distances_row, labels, i): mask = labels == labels[i] mask[i] = False if not np.any(mask): # cluster of size 1 return 0 a = np.mean(distances_row[mask]) return a
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __cluster_simi(self, i, j):\n sum_ = 0.\n for si in self.__indexclusters[i]:\n for sj in self.__indexclusters[j]:\n simi = self.__sample_simi(si, sj)\n sum_ += simi\n return sum_ / (len(self.__indexclusters[i]) * len(self.__indexclusters[j]))", "d...
[ "0.62086725", "0.6169589", "0.61312467", "0.60572255", "0.5976423", "0.59217167", "0.5884832", "0.5834737", "0.5797622", "0.57780486", "0.575429", "0.5702418", "0.57006186", "0.5698821", "0.5696123", "0.5643952", "0.5616608", "0.5607622", "0.5513053", "0.5504014", "0.55019957...
0.62878674
0