query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Returns a query result dictionary, given an ACE Record instance and a dictionary of the XPath queries that need to be executed on this record.
def query_dict_for_record(record, touched_queries): result = dict() if len(touched_queries) > 0: parsed_record = etree.parse(StringIO(record.test_data_xml())) result.update(dict((q_name, {'query': q_value, 'result': list(x.text for x in etree.ETXPath(q_value)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_records_query(query):\n result, hits, output = execute_basic(TYPE_RECORD, query)\n for rec in hits.get('hits', []):\n record = rec.get('_source')\n record['score'] = rec.get('_score')\n record['text'] = rec.get('highlight', {}).get('text')\n output['results'].append(re...
[ "0.57072085", "0.5547496", "0.5542535", "0.55252427", "0.5523193", "0.5461427", "0.5346732", "0.53411245", "0.53293097", "0.53058386", "0.5295658", "0.5276403", "0.52639025", "0.51895535", "0.51621974", "0.5137885", "0.51368797", "0.51255596", "0.51243746", "0.512335", "0.510...
0.755422
0
Returns list for each ACERecord supplied, each specifying fromto which node+terminal between which this record was obtained, together with a query result dictionary.
def perform_queries(records, project_type, project, msgflow): all_queries = subdirs_file_content_to_dict(os.path.join(data_dir, project_type, project, msgflow), split_by_line=False, subdict_by_path=True) result = list({'from': {'node': record.source_node, 'terminal...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_records(self):\n logging.debug('Return all records in table')\n if not self._dbconnect or not self._cursor:\n raise Exception('Invalid call to Context Manager method!')\n\n self._cursor.execute(\"\"\"SELECT * FROM {}\"\"\".format(self._name))\n rows = self._cursor.fet...
[ "0.6234349", "0.59395957", "0.5783132", "0.5760269", "0.56434655", "0.5625844", "0.5620573", "0.5597441", "0.55879647", "0.549597", "0.5477377", "0.53048503", "0.52551764", "0.51955223", "0.51800114", "0.5148783", "0.5139155", "0.513071", "0.51090914", "0.51068676", "0.510563...
0.54963076
9
Endpoint to exercise a message. The message is injected into the flow. For this recording and injection must be temporarily enabled on the flow. Test data is obtained, after which instances of ACERecord are created and sorted on flowSequenceNumber. For each record, an object is created with the fromto node+terminal inf...
def post(self, project_type, project, msgflow, node): result = dict() try: ace_conn.start_recording(project_type, project, msgflow) ace_conn.start_injection(project_type, project, msgflow) ace_conn.inject(project_type, project, msgflow, node, request.data) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_echo(self):\n self.add_item(\"skill\", \"fetchai/echo:0.5.0\")\n\n process = self.run_agent()\n is_running = self.is_running(process)\n assert is_running, \"AEA not running within timeout!\"\n\n # add sending and receiving envelope from input/output files\n sender...
[ "0.5372232", "0.5337886", "0.5229061", "0.51248443", "0.5084246", "0.5082173", "0.5059913", "0.50520146", "0.5048308", "0.50415814", "0.5012191", "0.5003331", "0.49835372", "0.49795404", "0.49769887", "0.49708155", "0.49585548", "0.49475357", "0.49267948", "0.48812303", "0.48...
0.5756279
0
Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits . It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The force option simply sets the answer to default. The ...
def query_yes_no(question, default="yes", force=False): valid = {"yes":True, "y":True, "ye":True, "no":False, "n":False} if default == None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_yes_no(question, default=\"yes\"):\n valid = {\"yes\":\"yes\", \"y\":\"yes\", \"ye\":\"yes\",\n \"no\":\"no\", \"n\":\"no\"}\n if default == None:\n prompt = \" [y/n] \"\n elif default == \"yes\":\n prompt = \" [Y/n] \"\n elif default == \"no\":\n promp...
[ "0.82480913", "0.8201619", "0.8161579", "0.81534576", "0.81376886", "0.81355315", "0.81342065", "0.8133191", "0.8133191", "0.8130005", "0.8128684", "0.8128684", "0.8128684", "0.8128684", "0.8128684", "0.81278366", "0.81278366", "0.81278366", "0.81278366", "0.81278366", "0.812...
0.85351175
0
Prompt a statement requiring an interactive from the user.
def query_ok(statement="", force=False): prompt = " [press <enter> to continue] " while True: sys.stdout.write(statement + prompt) if not force: ok = raw_input().lower() else: ok = "" if ok == "": return True else: sys.stdou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ask(self, prompt: str) -> str:\n raise NotImplementedError", "def prompt_user(prompt):\r\n # raw_input returns the empty string for \"enter\"\r\n yes = set(['yes', 'y'])\r\n no = set(['no','n'])\r\n\r\n try:\r\n print(prompt)\r\n choice = raw_input().lower()\r\n # woul...
[ "0.6755771", "0.67360723", "0.6700402", "0.66866815", "0.66583824", "0.66383564", "0.65155077", "0.65145904", "0.6495161", "0.64846927", "0.6434562", "0.63812006", "0.6373911", "0.63394517", "0.63238543", "0.62432694", "0.6237048", "0.62323844", "0.6148552", "0.61435086", "0....
0.62230843
18
Perform a directory walk
def walk(rootdir): flist = [] for root, dirs, files in os.walk(rootdir): flist = flist + [os.path.join(root, x) for x in files] return flist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def walk(dir, callback):\n\n dir = abspath(dir)\n for file in listdir(dir):\n nfile = join(dir, file)\n if isdir(nfile):\n walk(nfile, callback)\n else:\n callback(nfile)", "def walk(dirname): \n for name in os.listdir(dirname):\n path = os.path.join(dir...
[ "0.76540864", "0.7646833", "0.75663054", "0.73219824", "0.72194135", "0.7084689", "0.68280494", "0.68234414", "0.67714447", "0.67714447", "0.6764872", "0.66485465", "0.6637909", "0.6593982", "0.6566981", "0.6565008", "0.6515065", "0.6490184", "0.6445862", "0.6416494", "0.6369...
0.5934327
50
Perform a filtered directory walk.
def filtered_walk(rootdir, filter_fn, include_dirs=None, exclude_dirs=None, get_dirs=False): flist = [] dlist = [] for root, dirs, files in os.walk(rootdir): if include_dirs and len(set(root.split(os.sep)).intersection(set(include_dirs))) == 0: ## Also try re.search in case we have patte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter(self):\n self._printer('Standard Walk')\n count = Counter(length=3)\n for directory in self.directory:\n self._printer('Searching ' + directory)\n for root, directories, files in os.walk(directory, topdown=self.topdown):\n root = root[len(str(dir...
[ "0.7196122", "0.6588966", "0.6396584", "0.6380269", "0.6349008", "0.63149124", "0.61969244", "0.61103547", "0.60762525", "0.6074421", "0.60585856", "0.6046986", "0.60449713", "0.6044598", "0.60307413", "0.6027791", "0.60122037", "0.599719", "0.5978354", "0.5976603", "0.597657...
0.6661728
1
Make a directory if it doesn't exist, handling concurrent race conditions.
def safe_makedir(dname): if not os.path.exists(dname): # we could get an error here if multiple processes are creating # the directory at the same time. Grr, concurrency. try: os.makedirs(dname) except OSError: if not os.path.isdir(dname): rais...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_dir_if_needed(dir) :\n\tif not exists(dir) :\n\t\tos.makedirs(dir)", "def mkDir(path):\n if not os.path.exists(path):\n try:\n os.makedirs(path)\n except OSError:\n # In a race between two threads, this thread may have lost,\n # in which case the directo...
[ "0.8121099", "0.7892072", "0.788025", "0.7782501", "0.7757828", "0.7722888", "0.7703332", "0.7641113", "0.7607421", "0.75588185", "0.75113726", "0.7501842", "0.7485724", "0.74761015", "0.74720377", "0.74711245", "0.74672055", "0.74672055", "0.74634916", "0.74364537", "0.74195...
0.7507635
11
Context manager to temporarily change to a new directory.
def chdir(new_dir): cur_dir = os.getcwd() # FIXME: currently assuming directory exists safe_makedir(new_dir) os.chdir(new_dir) try: yield finally: os.chdir(cur_dir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def use_dir(new_dir):\n owd = os.getcwd()\n os.chdir(new_dir)\n\n try:\n yield\n finally:\n os.chdir(owd)", "def cd_manager(self, new_wd):\n old_wd = self.cwd\n self.cd(new_wd)\n yield self.cwd\n self.cd(old_wd)", "def __enter__(self):\n self.savedPa...
[ "0.7735854", "0.75990963", "0.752381", "0.7449731", "0.7449731", "0.744947", "0.73910314", "0.727928", "0.71958107", "0.71416557", "0.71343964", "0.71328884", "0.7042217", "0.70238966", "0.701297", "0.69625574", "0.6961247", "0.69471306", "0.692629", "0.6924177", "0.6918348",...
0.74439114
6
Transform option list to a dictionary.
def opt_to_dict(opts): if isinstance(opts, dict): return args = list(itertools.chain.from_iterable([x.split("=") for x in opts])) opt_d = {k: True if v.startswith('-') else v for k,v in zip(args, args[1:]+["--"]) if k.startswith('-')} return opt_d
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_options(option_list: List[str]) -> Dict[str, Union[int, float, str]]:\n d = dict()\n for o in option_list:\n o = o.split('=')\n if len(o) != 3:\n raise OptionParsingError(\"Not enough elements in the parsed options. Need 3 elements.\")\n key = o[0]\n val = o[1...
[ "0.6948613", "0.661204", "0.6580496", "0.65647084", "0.65088916", "0.6373278", "0.6370471", "0.63431555", "0.6230479", "0.6225121", "0.61512506", "0.6135905", "0.60848534", "0.6042554", "0.6006351", "0.5991005", "0.59683454", "0.58970153", "0.5887909", "0.5887085", "0.5885839...
0.6884359
1
Remove unwanted options from an option list.
def prune_option_list(opts, keys): opt_d = opt_to_dict(opts) for k in keys: if k in opt_d: del opt_d[k] return [k for item in opt_d.iteritems() for k in item]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _sanitize(self, opts_list):\n for opt in opts_list:\n if len(opt.strip()) == 0:\n opts_list.remove(opt)\n return opts_list", "def remove_all(self):\n self._options.clear()\n self._programs.clear()", "def replace_unacceptable_options(options, is_request)...
[ "0.7164903", "0.62534535", "0.62313527", "0.6177054", "0.6156464", "0.61167467", "0.598523", "0.5968531", "0.5958963", "0.5934466", "0.5840218", "0.5644665", "0.5616773", "0.55490786", "0.55408776", "0.551189", "0.5459334", "0.54491204", "0.54466665", "0.54283345", "0.5392538...
0.7166121
0
Make a paper plot for the Ohmic (or linear) mobility of the RTA, lowfield, and fulldrift solutions.
def linear_mobility_paperplot(fieldVector,df): vcm = np.array(fieldVector) * 1e-2 lw = 1.5 mu_1 = [] mu_2 = [] mu_3 = [] meanE_1 = [] meanE_2 = [] meanE_3 = [] for ee in fieldVector: chi_1_i = np.load(pp.outputLoc + 'Steady/' + 'chi_' + '1_' + "E_{:.1e}.npy".format(ee)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def small_signal_mobility_paperplot(fieldVector, freqVector, df):\n vcm = np.array(fieldVector)*1e-2\n n = utilities.calculate_density(df)\n lw = 1.5\n fig, ax = plt.subplots()\n for freq in freqVector:\n cond = []\n mu_3 = []\n for ee in fieldVector:\n chi_3_i = np.l...
[ "0.6821178", "0.64246243", "0.6286595", "0.626816", "0.6249688", "0.6224722", "0.6198306", "0.6154236", "0.613358", "0.61210513", "0.6096487", "0.6086529", "0.6069941", "0.598622", "0.59854215", "0.5982351", "0.59644985", "0.59618616", "0.59519553", "0.59491116", "0.59424275"...
0.65401083
1
Make and save a paper plot for the small signal AC conductivity and save to file.
def small_signal_mobility_paperplot(fieldVector, freqVector, df): vcm = np.array(fieldVector)*1e-2 n = utilities.calculate_density(df) lw = 1.5 fig, ax = plt.subplots() for freq in freqVector: cond = [] mu_3 = [] for ee in fieldVector: chi_3_i = np.load(pp.outputL...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(file_name):\n setup()\n plt.savefig(file_name)", "def sac_paper_plot(log_dir, det_policy_sublocation,act_0,act_1,act_2,is_tri,actions_to_plot_large=10,\n actions_to_plot_small = 100,actions_per_log = 6000, custom_colors=None,prot_linewidth=2.7,\n reward_linewi...
[ "0.63829935", "0.61786145", "0.61507136", "0.6035337", "0.6032561", "0.6008468", "0.59910804", "0.588599", "0.58742714", "0.5847295", "0.5822006", "0.57927346", "0.57869285", "0.57778376", "0.57364345", "0.57148474", "0.570858", "0.5702769", "0.5675583", "0.56593865", "0.5654...
0.55942696
25
Make a paper plot for the momentum KDE of the lowfield, and fulldrift solutions.
def momentum_kde_paperplot(fields): fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, sharex=True) axisList = [ax1,ax2,ax3] i =0 props = dict(boxstyle='round', facecolor='wheat', alpha=0.5) for ee in fields: ee_Vcm = ee/100 textstr = r'$E_{k_x}\, = \, %.1f \, V \, cm^{-1}$' % ee_Vcm ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def momentum_kde2_paperplot(fields):\n plt.figure(figsize=(2.65, 2.5))\n ax = plt.axes([0.18, 0.17, 0.8, 0.8])\n colorList = [med_color, high_color]\n lw = 1.5\n i = 0\n meankx_2 = []\n meankx_3 = []\n k_ax = np.load(pp.outputLoc + 'Momentum_KDE/' + 'k_ax_' + '2_' + \"E_{:.1e}.npy\".format(...
[ "0.7816318", "0.70826715", "0.6468687", "0.61942935", "0.6098648", "0.60919285", "0.59449416", "0.58786696", "0.5867492", "0.58451384", "0.5830002", "0.58245164", "0.5811453", "0.5785101", "0.5761999", "0.57525295", "0.57412106", "0.5740107", "0.5730716", "0.5714857", "0.5704...
0.73915446
1
Make a paper plot for the momentum KDE of the lowfield, and fulldrift solutions.
def momentum_kde2_paperplot(fields): plt.figure(figsize=(2.65, 2.5)) ax = plt.axes([0.18, 0.17, 0.8, 0.8]) colorList = [med_color, high_color] lw = 1.5 i = 0 meankx_2 = [] meankx_3 = [] k_ax = np.load(pp.outputLoc + 'Momentum_KDE/' + 'k_ax_' + '2_' + "E_{:.1e}.npy".format(fields[0])) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def momentum_kde_paperplot(fields):\n fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, sharex=True)\n axisList = [ax1,ax2,ax3]\n i =0\n\n props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)\n for ee in fields:\n ee_Vcm = ee/100\n textstr = r'$E_{k_x}\\, = \\, %.1f \\, V \\, cm^{-1...
[ "0.73927927", "0.7082678", "0.64685386", "0.6194481", "0.60984546", "0.6091529", "0.5944429", "0.5879228", "0.58678186", "0.5845622", "0.5829439", "0.5824676", "0.58108956", "0.5784534", "0.57618827", "0.57524467", "0.57417613", "0.57405406", "0.57309103", "0.57143843", "0.57...
0.7817756
0
Make a energy plot for the momentum KDE of the lowfield, and fulldrift solutions.
def energy_kde_paperplot(fields,df): plt.figure() i = 0 colorList = ['dodgerblue','tomato'] lw = 2 meanE_2 = [] meanE_3 = [] mup = np.min(df['energy [eV]']) - pp.mu chi_0 = np.load(pp.outputLoc + 'Steady/' + 'chi_' + '2_' + "E_{:.1e}.npy".format(fields[0])) g_en_axis, _, _, _, _, _,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def momentum_kde2_paperplot(fields):\n plt.figure(figsize=(2.65, 2.5))\n ax = plt.axes([0.18, 0.17, 0.8, 0.8])\n colorList = [med_color, high_color]\n lw = 1.5\n i = 0\n meankx_2 = []\n meankx_3 = []\n k_ax = np.load(pp.outputLoc + 'Momentum_KDE/' + 'k_ax_' + '2_' + \"E_{:.1e}.npy\".format(...
[ "0.7072073", "0.6860298", "0.6784533", "0.6767711", "0.6717085", "0.64930975", "0.6264038", "0.62380916", "0.6227457", "0.62017035", "0.6190444", "0.61265624", "0.60596615", "0.6039065", "0.60338074", "0.59825134", "0.59809995", "0.5952686", "0.5921822", "0.5920559", "0.59139...
0.7414247
0
Data from square 1 is carried 0 steps, since it's at the access port.
def test_first_pos() -> None: assert sw.walk_to(1) == sw.Coordinate(0, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data(self):\n self.dev.write(1, 'A0')\n digit1, digit2 = self.dev.read(0x81, 64)[:2]\n # Save the data as voltage between 0.0 and 5.0\n self.data0.append((digit1 + 256*digit2)*5.0/1024)", "def readOneData(self):\n\t\tpass", "def test_op_one_int(self):\n\n device = pym...
[ "0.5967737", "0.55366534", "0.54499793", "0.5377072", "0.5333435", "0.515353", "0.5136547", "0.5088798", "0.50717396", "0.5071443", "0.5071443", "0.5071443", "0.50584936", "0.50543225", "0.5038344", "0.5021923", "0.49890968", "0.49433732", "0.49217415", "0.49207532", "0.49158...
0.0
-1
Data from square 1024 must be carried 31 steps.
def test_pos_1024() -> None: assert sw.walk_to(1024).distance == 31
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processing_data(raw_data):\n data = np.frombuffer(raw_data, np.uint8)\n data = np.reshape(data, [data.shape[0]//1029, -1])\n data = data[:, 5:]\n data = np.reshape(data, [1, -1])\n data = 256 * data[0, 0::2] + data[0, 1::2]\n data = 10 * (data / 65535)\n data = np.reshape(data, [-1, 8]).T\...
[ "0.63460886", "0.5817549", "0.5816994", "0.5768104", "0.5681826", "0.566487", "0.5664062", "0.566259", "0.56563985", "0.5567269", "0.5552219", "0.5543385", "0.55432326", "0.551347", "0.550619", "0.5491778", "0.54823196", "0.54610217", "0.5449745", "0.5424971", "0.5361107", ...
0.0
-1
Returns the nth item
def nth(iterable, index): return next(itertools.islice(iterable, index, None))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nth(n, seq):\n try:\n return seq[n]\n except TypeError:\n return next(itertools.islice(seq, n, None))", "def nth(iterable, n, default=None):\n return next(islice(iterable, n, None), default)", "def nth(iterable, n, default=None):\n return next(islice(iterable, n, None), default)",...
[ "0.7396352", "0.72852194", "0.72852194", "0.72852194", "0.7229926", "0.7180901", "0.70936525", "0.69702876", "0.6887761", "0.6603851", "0.6541124", "0.6488166", "0.6476991", "0.64401025", "0.64200073", "0.6405436", "0.63758516", "0.6363515", "0.63572127", "0.62999797", "0.629...
0.7512134
0
Square 2 has one adjacent filled square (with 1), so it stores 1.
def test_sum_pos_2() -> None: # Note: We take 1 step (first item) - thus end up on square 2 # (square 1 being home). assert nth(sw.sum_walk(), 0) == 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def square2_checker(self, x, y, row2, col2):\n \n self.x = x\n self.y = y\n self.row2 = row2\n self.col2 = col2\n\n return abs(self.x - self.row2) == 1 and self.col2 == self.y \\\n or abs(self.y - self.col2) == 1 and self.row2 == self.x", "def secondMove(bo...
[ "0.6059381", "0.5955183", "0.584613", "0.56877613", "0.5649856", "0.5645991", "0.5626221", "0.55715334", "0.55336505", "0.551319", "0.5499531", "0.5469189", "0.5469189", "0.5468453", "0.54598105", "0.54315805", "0.5426739", "0.5424086", "0.5397284", "0.53963614", "0.5382417",...
0.56117094
7
Square 3 has both of the above squares as neighbors and stores 2.
def test_sum_pos_3() -> None: # 2nd step - 3rd square assert nth(sw.sum_walk(), 1) == 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def neighbours2((u,v)):\r\n\r\n return ((u-1, v+1), (u,v+1), (u+1,v+1), \r\n (u-1,v), (u+1,v),\r\n (u-1,v-1), (u,v-1), (u+1,v-1))", "def get_neighbors(self):\n return list(map(self.game.square, [self.position - self.game.rules[\"row_len\"], self.position + 1, self.position + self....
[ "0.647665", "0.6442566", "0.63085395", "0.6278189", "0.6266447", "0.62343496", "0.62111956", "0.6209179", "0.61452353", "0.61067104", "0.60986245", "0.6090197", "0.60811675", "0.6070315", "0.60668266", "0.6024939", "0.60212654", "0.6002938", "0.6001121", "0.59865355", "0.5985...
0.0
-1
Square 4 has all three squares as neighbors and stores 4.
def test_sum_pos_4() -> None: # Third step, 4th square. assert nth(sw.sum_walk(), 2) == 4
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def neighbors_of_4(mapdata, x, y):\n four_neigh = set()\n # if PathPlanner.is_cell_walkable(mapdata, x, y) == True:\n if (PathPlanner.is_cell_walkable(mapdata, x+1, y)):\n four_neigh |= {(x+1,y)}\n if (PathPlanner.is_cell_walkable(mapdata, x-1, y)):\n four_neigh |=...
[ "0.7066604", "0.69850945", "0.6465638", "0.6417407", "0.62720263", "0.61062175", "0.6052148", "0.6043467", "0.6038454", "0.60289276", "0.6002066", "0.59915555", "0.5958216", "0.59563166", "0.5903847", "0.5899874", "0.58866215", "0.5883123", "0.58689153", "0.58309054", "0.5781...
0.0
-1
Square 5 has the first and fourth squares as neighbors, so stores 5.
def test_sum_pos_5() -> None: # Fourth step, 5th square. assert nth(sw.sum_walk(), 3) == 5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def problem5(self, s):\n points = 0\n\n points = self.neighbor( 10, 10, s.nearest_neighbor)*3\n points += self.neighbor(100, 10, s.nearest_neighbor)*3\n points += self.neighbor( 10, 100, s.nearest_neighbor)*3\n points += self.neighbor(100, 100, s.nearest_neighbor)*3\n p...
[ "0.6525291", "0.64248365", "0.64212275", "0.63307184", "0.6300695", "0.6289579", "0.6257782", "0.62313396", "0.6211605", "0.6194239", "0.6168775", "0.6109721", "0.6094891", "0.60934365", "0.6090234", "0.60810983", "0.60609305", "0.6054976", "0.6004933", "0.5993476", "0.596606...
0.6007456
18
First value larger than 4 in a location is 5, in location 5.
def test_sum_larger_than_4() -> None: assert sw.sum_bigger_than(4) == 5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _replace_center_with_one_if_five_neighbors_are_different_than_0(values):\n greater_than_0 = 0\n for entry in values:\n if entry > 0:\n greater_than_0 += 1\n if greater_than_0 >= 5:\n return 1\n else:\n return 0", "def test_nearest_lo...
[ "0.58578753", "0.576571", "0.5746794", "0.550913", "0.5417282", "0.535983", "0.5356827", "0.53275746", "0.527239", "0.52406675", "0.52343464", "0.5229549", "0.51876897", "0.5177736", "0.5175734", "0.5174075", "0.5165948", "0.5136667", "0.5136667", "0.51265985", "0.51261836", ...
0.0
-1
Count amount of calls of a method
def count_calls(method: Callable) -> Callable: k = method.__qualname__ @wraps(method) def wrapper(self, *args, **kwargs): """ Wrapper method """ self._redis.incr(k) return method(self, *args, **kwargs) return wrapper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_count(self):\n return len(self.mock_calls)", "def count_calls(func):\n\n @functools.wraps(func)\n def wrapper_count_calls(*args, **kwargs):\n wrapper_count_calls.num_calls += 1\n print(f\"Call {wrapper_count_calls.num_calls} of {func.__name__!r}\")\n return func(*args, ...
[ "0.7700084", "0.76074284", "0.75858516", "0.7440649", "0.7427044", "0.7417465", "0.733295", "0.7280602", "0.7223752", "0.7223752", "0.7223752", "0.7223752", "0.72111034", "0.71857244", "0.7170684", "0.7122875", "0.7097699", "0.70863014", "0.6910949", "0.6898251", "0.6898251",...
0.7264558
8
Store history of inputs and outputs for a function
def call_history(method: Callable) -> Callable: i_keys = method.__qualname__ + ":inputs" o_keys = method.__qualname__ + ":outputs" @wraps(method) def wrapper(self, *args, **kwargs): """ Set list keys to wrapped function """ self._redis.rpush(i_keys, str(args)) r ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def history():", "def storeState(self):\n\n self.action_history[self.trial] = self.action\n self.ball_history[self.trial] = self.ballcolor", "def show_input_history(self):\n # copy with user multifilter\n pass", "def fit_history(self) -> FitResultHelper:\n pass", "def sav...
[ "0.6308154", "0.61945885", "0.60563385", "0.6010466", "0.5976015", "0.5948027", "0.5906661", "0.5841546", "0.5819957", "0.57499707", "0.5747726", "0.5735471", "0.57344973", "0.56674623", "0.5651438", "0.5611321", "0.56106305", "0.56016344", "0.55927086", "0.5590723", "0.55736...
0.58278376
8
Set list keys to wrapped function
def wrapper(self, *args, **kwargs): self._redis.rpush(i_keys, str(args)) r = method(self, *args, **kwargs) self._redis.rpush(o_keys, str(r)) return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_handler(key):\n def wrapper(func):\n func.set_key = key\n return func\n\n return wrapper", "def set_function_list(self, L):\n\t\tself.function_list = L", "def __call__(self, f):\n def w(*args, **kwargs):\n if not isinstance(self.keys, list):\n ...
[ "0.6521831", "0.65043116", "0.63858986", "0.636023", "0.6356911", "0.6136244", "0.6033099", "0.6012478", "0.600189", "0.5885888", "0.5881756", "0.5840017", "0.58237225", "0.5802475", "0.57107884", "0.5709828", "0.5692243", "0.566112", "0.56496793", "0.56439", "0.561974", "0...
0.5244141
56
Ouput log of actions taken on method
def replay(method: Callable) -> None: counter_key = method.__qualname__ i_keys = method.__qualname__ + ':inputs' o_keys = method.__qualname__ + ':outputs' this = method.__self__ counter = this.get_str(counter_key) history = list(zip(this.get_list(i_keys), this.get_list(o_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logtool(self, action, **options):\n pass", "def _info(self, func):\n self.logger.info(\"llamando a %s\" % func)", "def on_a(self):\r\n self.log()", "def log(self, message):", "def LogCommand(self): \n # Retrieve the args for the command.\n posname, kwname, args...
[ "0.70196855", "0.6802665", "0.67890334", "0.67452294", "0.66154486", "0.6548533", "0.6539033", "0.6537761", "0.6509257", "0.64813614", "0.6400591", "0.6360071", "0.63514966", "0.63387394", "0.63154525", "0.6285869", "0.6239835", "0.6236979", "0.6204017", "0.6194011", "0.61785...
0.0
-1
Instantiate a empty Redis
def __init__(self): self._redis = redis.Redis(host="localhost", port=6379) self._redis.flushdb()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, host, port):\n self.r = redis.StrictRedis(host=host, port=port)", "def __init__(self, host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD):\n self.db = redis.StrictRedis(host=host, port=port, password=password, decode_responses=True)", "def __init__(self, config):\n ...
[ "0.77647334", "0.7516936", "0.7490148", "0.7289205", "0.72216445", "0.7121275", "0.69119596", "0.68894404", "0.6873963", "0.6847636", "0.6805552", "0.6770867", "0.6766439", "0.67155826", "0.6714582", "0.6684755", "0.66187555", "0.6604865", "0.6604865", "0.65435404", "0.649048...
0.749138
2
Store any type of data in Redis
def store(self, data: Union[str, bytes, int, float]) -> str: k = str(uuid.uuid4()) self._redis[k] = data return k
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(self, data: Union[str, bytes, int, float]) -> str:\n key = str(uuid.uuid4())\n self._redis.set(key, data)\n return key", "def redis_save(key: object, value: object) -> object:\n if key is not None and value is not None:\n red.redis.set(json.dumps(key), json.dumps(value))"...
[ "0.74398786", "0.7203963", "0.68926376", "0.64535683", "0.6436974", "0.6225524", "0.61990386", "0.61871934", "0.61752015", "0.6131745", "0.6131207", "0.6122489", "0.6113348", "0.6100349", "0.6039475", "0.5939632", "0.59025615", "0.5878599", "0.58582723", "0.5839085", "0.58303...
0.7362231
1
Get value in db with callback format
def get(self, key: str, fn: Optional[Callable] = None) ->\ Union[str, bytes, int, float]: return fn(self._redis.get(key)) if fn else self._redis.get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_callback(self, value):\n if value:\n # Should be a DBRef\n return self.model.find_one({\"_id\": value.id})\n return value", "def db_values(self, db):", "def _db(self, value):", "def get_value(self):", "def getvalue(self):\n ...", "def getvalue(self):\n ...
[ "0.76099515", "0.6539641", "0.645696", "0.63717", "0.62489164", "0.62489164", "0.61767685", "0.61688983", "0.6150886", "0.6079202", "0.6064559", "0.5916899", "0.58600366", "0.5854786", "0.58326894", "0.58202755", "0.57832086", "0.57406497", "0.57007426", "0.5685605", "0.56768...
0.0
-1
bytes from store to list
def get_list(self, k: str) -> List: return self._redis.lrange(k, 0, -1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def network_bytes(self) -> List[bytes]:", "def get_list_of_bytes2(self):\n pass", "def flatten_list_bytes(list_of_data):\n if not PY34:\n list_of_data = (bytes(data) if isinstance(data, memoryview) else\n data for data in list_of_data)\n return b''.join(list_of_data)", "def get...
[ "0.70149946", "0.66737", "0.64794904", "0.64504474", "0.6314454", "0.6131867", "0.6043757", "0.5994261", "0.59164953", "0.5910397", "0.59022194", "0.5876766", "0.5868104", "0.5842442", "0.5833972", "0.5811272", "0.580573", "0.57865405", "0.5774859", "0.5770557", "0.57333845",...
0.0
-1
method function for test
def add(left: int, right: int) -> int: return left + right
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def test():", "def test():", "def test(self):", "def test(self):", "def test(self):\n pass", "def tests():", "def _test(self):\n pass", "def _test(self):\n pass", "def ...
[ "0.85272825", "0.85272825", "0.85272825", "0.85272825", "0.85272825", "0.823295", "0.823295", "0.8142115", "0.8142115", "0.8089903", "0.8033258", "0.80181545", "0.80181545", "0.80181545", "0.7949432", "0.7901211", "0.78332204", "0.78264356", "0.7823471", "0.7760016", "0.77569...
0.0
-1
test of Server class
def test_server(): logger = PythonLogger(LogLevel.TRACE) name = 'add' logger = PythonLogger() executor = FunctionMethodExecutor(logger, name, add) method_server = SimpleMethodServer(logger, [executor]) server_config = ServerConfig() server_config.tcp_acceptors = [TCPAcceptorConfig()] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_server_info(self):\n pass", "def server():", "def server():", "def test_setup_server(self):\r\n\r\n self.server_socket = setup_server()\r\n host, port = self.server_socket.getsockname()\r\n # Not much to test here, if we get something back it should work\r\n self.a...
[ "0.7765244", "0.7660035", "0.7660035", "0.7556732", "0.7359465", "0.7205023", "0.7127771", "0.71062976", "0.7015855", "0.7012502", "0.69685245", "0.69648224", "0.693817", "0.68814826", "0.6859551", "0.68455327", "0.6837512", "0.6823868", "0.6778921", "0.67439336", "0.6717929"...
0.65524065
36
Return range of a native type.
def native_type_range(fmt): if fmt == 'c': lh = (0, 256) elif fmt == '?': lh = (0, 2) elif fmt == 'f': lh = (-(1<<63), 1<<63) elif fmt == 'd': lh = (-(1<<1023), 1<<1023) else: for exp in (128, 127, 64, 63, 32, 31, 16, 15, 8, 7): try: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_range(self) -> Union[int, float]:\n return self.proto.detect_range", "def get_range(self, rel_name):\n return self._declaration[rel_name].range_type", "def GetScalarRange(self):\n ...", "def range(self):\n return self.timerange()", "def native_type_range(fmt):\n if fmt...
[ "0.7174355", "0.689528", "0.68078554", "0.6694855", "0.66533893", "0.6612708", "0.6558848", "0.65285164", "0.6527802", "0.65069115", "0.65069115", "0.6480364", "0.63700145", "0.6348342", "0.6348342", "0.62516916", "0.62408125", "0.61799943", "0.61763644", "0.6166519", "0.6139...
0.6626005
5
Return random item for a type specified by a mode and a single format character.
def randrange_fmt(mode, char, obj): x = randrange(*fmtdict[mode][char]) if char == 'c': x = bytes([x]) if obj == 'numpy' and x == b'\x00': # http://projects.scipy.org/numpy/ticket/1925 x = b'\x01' if char == '?': x = bool(x) if char == 'f' or char == 'd': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randitems(n, obj='ndarray', mode=None, char=None):\n if mode is None:\n mode = choice(cap[obj][MODE])\n if char is None:\n char = choice(tuple(fmtdict[mode]))\n multiplier = choice(cap[obj][MULT])\n fmt = mode + '#' + char * int(multiplier if multiplier else 1)\n items = gen_items(...
[ "0.6796878", "0.6796878", "0.60390544", "0.60390544", "0.5697757", "0.56245166", "0.55712277", "0.5493748", "0.5452205", "0.537199", "0.5334354", "0.5267052", "0.52179533", "0.5095594", "0.5086428", "0.5081015", "0.5081015", "0.5054717", "0.50137657", "0.50027424", "0.4957444...
0.5423713
9
Return single random item.
def gen_item(fmt, obj): mode, chars = fmt.split('#') x = [] for c in chars: x.append(randrange_fmt(mode, c, obj)) return x[0] if len(x) == 1 else tuple(x)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRandom(self) -> int:\n return random.choice(self.items)", "def random(self):\n try:\n return self.order_by('?')[0]\n except IndexError:\n raise self.model.DoesNotExist", "def read_random_item(user_id: int, db: Session = Depends(get_db)):\n # Call function to...
[ "0.75377405", "0.7337129", "0.7262384", "0.7241162", "0.72338086", "0.72156364", "0.7190311", "0.71842796", "0.7049892", "0.70360816", "0.7027471", "0.70067525", "0.6985511", "0.697375", "0.697375", "0.697375", "0.697375", "0.69379413", "0.6930757", "0.69288605", "0.6924486",...
0.0
-1
Return a list of random items (or a scalar).
def gen_items(n, fmt, obj): if n == 0: return gen_item(fmt, obj) lst = [0] * n for i in range(n): lst[i] = gen_item(fmt, obj) return lst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample(self):\n return self.items[self.np_random.choice(len(self.items))]", "def generator(self, random, args):\r\n if self.duplicates:\r\n max_count = [self.capacity // item[0] for item in self.items]\r\n return [random.randint(0, m) for m in max_count]\r\n else:\r...
[ "0.7186447", "0.68290174", "0.67713726", "0.6744953", "0.6688288", "0.6684551", "0.661171", "0.6610131", "0.6610131", "0.6610131", "0.6610131", "0.65993875", "0.6582984", "0.6574758", "0.65567404", "0.6546218", "0.65396774", "0.6507699", "0.65028495", "0.65009904", "0.6481836...
0.0
-1
Return random format, items, item.
def randitems(n, obj='ndarray', mode=None, char=None): if mode is None: mode = choice(cap[obj][MODE]) if char is None: char = choice(tuple(fmtdict[mode])) multiplier = choice(cap[obj][MULT]) fmt = mode + '#' + char * int(multiplier if multiplier else 1) items = gen_items(n, fmt, obj)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_item(fmt, obj):\n mode, chars = fmt.split('#')\n x = []\n for c in chars:\n x.append(randrange_fmt(mode, c, obj))\n return x[0] if len(x) == 1 else tuple(x)", "def gen_item(fmt, obj):\n mode, chars = fmt.split('#')\n x = []\n for c in chars:\n x.append(randrange_fmt(mod...
[ "0.6775782", "0.6775782", "0.6505952", "0.6253222", "0.6138426", "0.60967493", "0.5961111", "0.59302914", "0.592502", "0.5770306", "0.5770306", "0.5770306", "0.57691205", "0.5754582", "0.5659331", "0.5654171", "0.562061", "0.5578145", "0.557014", "0.55524075", "0.5522926", ...
0.64387965
3
Iterate through supported mode/char combinations.
def iter_mode(n, obj='ndarray'): for mode in cap[obj][MODE]: for char in fmtdict[mode]: yield randitems(n, obj, mode, char)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n return iter([v for k, v in sorted(self._modes.items())])", "def modes(self):\n try:\n order = self._current_order\n except AttributeError:\n raise AttributeError('Cannot iterate over modes without iterating over orders!') from None\n mode = ...
[ "0.62502277", "0.60794157", "0.594942", "0.5905437", "0.5903358", "0.5762716", "0.56345135", "0.5598813", "0.5586852", "0.5512914", "0.550523", "0.5503041", "0.54652876", "0.5426214", "0.54166454", "0.5404549", "0.53661305", "0.5359288", "0.5355193", "0.53164005", "0.5308114"...
0.68199724
0
Yield (format, items, item) for all possible modes and format characters plus one random compound format string.
def iter_format(nitems, testobj='ndarray'): for t in iter_mode(nitems, testobj): yield t if testobj != 'ndarray': return yield struct_items(nitems, testobj)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeNamesFromFormats(formats):\n i = getIter(formats)\n if not i:\n return\n\n try:\n c = 0\n item = i.next()\n while item:\n c = c +1\n name = 'c%s' % c\n if isinstance(item, str):\n yield name\n else:\n ...
[ "0.59636045", "0.55950534", "0.5526537", "0.5526537", "0.5512344", "0.5512344", "0.5500678", "0.5500678", "0.54459256", "0.5404356", "0.54026484", "0.5386869", "0.5325779", "0.52617586", "0.52564883", "0.5248751", "0.5190863", "0.5118963", "0.50866807", "0.50587744", "0.50531...
0.64417255
0
format suitable for memoryview
def is_memoryview_format(fmt): x = len(fmt) return ((x == 1 or (x == 2 and fmt[0] == '@')) and fmt[x-1] in MEMORYVIEW)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format(self, data):", "def asformat(self, format):", "def format(self):\n ...", "def format_data(self, data):", "def test_repr_format(self):\n shape = (3, 4, 5)\n index = (0, 2, 1)\n t = View(shape=shape, index=index)\n assert t.repr_format(1.0) == \"View(shape=(3, 4,...
[ "0.6637037", "0.6513249", "0.6481153", "0.6379912", "0.6364625", "0.61014384", "0.5993504", "0.59295833", "0.5911117", "0.5828893", "0.5821409", "0.5821409", "0.57990885", "0.5798701", "0.5766792", "0.576159", "0.5759765", "0.5703525", "0.5594841", "0.55925876", "0.55827713",...
0.5712799
17
Tuple items (representing structs) are regarded as atoms.
def atomp(lst): return not isinstance(lst, list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tuple(x):\n pass", "def as_tuple(self):\n return (self.oid, self.type, self.value)", "def astuple(self):\n try:\n return tuple([x.astuple() for x in self])\n except Exception:\n pass\n return tuple([x for x in self])", "def single_element_tuple():\n single = (1,)\n print(...
[ "0.62056684", "0.6184957", "0.6157319", "0.6060547", "0.60536045", "0.6001506", "0.5986729", "0.5916221", "0.58694434", "0.5864544", "0.584824", "0.5791348", "0.57505023", "0.57495034", "0.57297975", "0.5720588", "0.5687215", "0.5687215", "0.56623316", "0.5627032", "0.5608446...
0.0
-1
Product of list elements.
def prod(lst): if len(lst) == 0: return 0 x = lst[0] for v in lst[1:]: x *= v return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prod(lst):\n return reduce(mul, lst, 1)", "def listMul(l):\n \n # initialization for variable prod\n prod = 1.0\n \n for element in l:\n prod *= element # a *= b is equivalent to a = a * b\n \n return prod", "def list_product(lst):\n prod = 1\n for val in lst:\n ...
[ "0.7628697", "0.7593564", "0.75456065", "0.7424486", "0.72949135", "0.725921", "0.72151756", "0.7156667", "0.71171826", "0.71168196", "0.7099029", "0.70157486", "0.70081353", "0.7006188", "0.69586205", "0.69586205", "0.69586205", "0.69568986", "0.68286026", "0.6814557", "0.68...
0.7144101
8
Calculate strides of a contiguous array. Layout is 'C' or 'F' (Fortran).
def strides_from_shape(ndim, shape, itemsize, layout): if ndim == 0: return () if layout == 'C': strides = list(shape[1:]) + [itemsize] for i in range(ndim-2, -1, -1): strides[i] *= strides[i+1] else: strides = [itemsize] + list(shape[:-1]) for i in range(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strides_from_shape(ndim, shape, itemsize, layout):\n if ndim == 0:\n return ()\n if layout == 'C':\n strides = list(shape[1:]) + [itemsize]\n for i in range(ndim - 2, -1, -1):\n strides[i] *= strides[i + 1]\n else:\n strides = [itemsize] + list(shape[:-1])\n ...
[ "0.6671998", "0.6667623", "0.63901645", "0.62995565", "0.6209812", "0.62079126", "0.6108434", "0.60595614", "0.60080725", "0.5996222", "0.5996222", "0.5860129", "0.57919973", "0.57440704", "0.56975204", "0.56885684", "0.56631756", "0.5634464", "0.56175673", "0.5605618", "0.55...
0.6674238
0
Convert flat item list to the nested list representation of a multidimensional C array with shape 's'.
def _ca(items, s): if atomp(items): return items if len(s) == 0: return items[0] lst = [0] * s[0] stride = len(items) // s[0] if s[0] else 0 for i in range(s[0]): start = i*stride lst[i] = _ca(items[start:start+stride], s[1:]) return lst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_2D_list(list_2d):\n return [item for sub in list_2d for item in sub]", "def flatten_list(l):\n obj = []\n\n def recurse(ll):\n if isinstance(ll, list) or isinstance(ll, np.ndarray):\n for i, _ in enumerate(ll):\n recurse(ll[i])\n else:\n obj...
[ "0.59607273", "0.5784534", "0.573234", "0.56969345", "0.56966835", "0.5667547", "0.5642063", "0.56420296", "0.56246406", "0.56184787", "0.5595709", "0.5550527", "0.55375654", "0.55223006", "0.55164844", "0.5515455", "0.55008477", "0.549687", "0.549088", "0.5466289", "0.544795...
0.5428784
22
Convert flat item list to the nested list representation of a multidimensional Fortran array with shape 's'.
def _fa(items, s): if atomp(items): return items if len(s) == 0: return items[0] lst = [0] * s[0] stride = s[0] for i in range(s[0]): lst[i] = _fa(items[i::stride], s[1:]) return lst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_2D_list(list_2d):\n return [item for sub in list_2d for item in sub]", "def _unflatten(updates, flat):\n updates_flat, treedef = tree_flatten(updates)\n offsets = []\n for update in updates_flat:\n size = np.prod(update.shape)\n if offsets:\n offsets.append(size + offsets...
[ "0.58835673", "0.5798904", "0.57985276", "0.57891816", "0.57352287", "0.57273215", "0.5620075", "0.5616092", "0.56024605", "0.5555752", "0.5553258", "0.5551791", "0.5545441", "0.5536632", "0.5493388", "0.549334", "0.54808545", "0.547685", "0.546228", "0.5439881", "0.54281837"...
0.52800167
43
Generate all possible tuples of indices.
def indices(shape): iterables = [range(v) for v in shape] return product(*iterables)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_indices(max_passes: int) -> Iterable[Tuple[int, int]]:\n base_indices = (0, max_passes)\n pw_indices = (max_passes, max_passes * 2)\n ip_indices = (max_passes * 2, max_passes * 3)\n strand_indices = (max_passes * 3, max_passes * 4)\n ccs_indices = (max_passes * 4, max_passes * 4 + 1)\n sn_indices = (...
[ "0.67532384", "0.674835", "0.6640834", "0.6628575", "0.65287274", "0.6371146", "0.6330858", "0.6324179", "0.62465256", "0.6200598", "0.6156113", "0.6150643", "0.60295343", "0.6006623", "0.60026", "0.5961674", "0.59433466", "0.59391856", "0.59216404", "0.59216404", "0.5907448"...
0.6601521
4
Convert multidimensional index to the position in the flat list.
def getindex(ndim, ind, strides): ret = 0 for i in range(ndim): ret += strides[i] * ind[i] return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ind2coord(self, index):\n\n # assert (index >= 0)\n # assert(index < self.n - 1)\n\n col = index // self.rows\n row = index % self.rows\n\n return [row, col]", "def mapping(index: Union[int, List[int]]) -> Union[int, List[int]]:\n if isinstance(index, int):\n ...
[ "0.6243093", "0.6141841", "0.6127711", "0.6079915", "0.6027663", "0.59269977", "0.59215206", "0.5921272", "0.59085566", "0.5885764", "0.5852488", "0.5829429", "0.578314", "0.576795", "0.5765309", "0.5744594", "0.57069933", "0.56776106", "0.5675322", "0.5675175", "0.56736", ...
0.0
-1
Transpose flat item list that is regarded as a multidimensional
def transpose(src, shape): if not shape: return src ndim = len(shape) sstrides = strides_from_shape(ndim, shape, 1, 'C') dstrides = strides_from_shape(ndim, shape[::-1], 1, 'C') dest = [0] * len(src) for ind in indices(shape): fr = getindex(ndim, ind, sstrides) to = getin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transpose(lst):\n return list(zip(*lst))", "def transpose(a: List[List[T]]) -> List[List[T]]:\n return list(map(list, zip(*a)))", "def transpose(grid):\n return map(list, zip(*grid))", "def _transpose(self, result_list):\n first_result = result_list[0]\n\n # The case where op i...
[ "0.7321097", "0.70771873", "0.7029112", "0.6656462", "0.66194856", "0.6589029", "0.6555851", "0.63927984", "0.6380234", "0.6366075", "0.6365707", "0.63310295", "0.6277107", "0.6261174", "0.62221223", "0.6198896", "0.6186384", "0.61600924", "0.61566144", "0.61444175", "0.61380...
0.5523381
92
flatten list or return scalar
def flatten(lst): if atomp(lst): # scalar return lst return _flatten(lst)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lflatten(*lst):\n return flatten(list(lst))", "def _flatten_one(x):\n return x[0] if is_iterable(x) else x", "def flatten(x): # przerobić na lambda?\n if x==[]:\n return None\n else:\n return x[0]", "def flatten():", "def flatten(lst):\n if atomp(lst):\n return lst\n...
[ "0.7351641", "0.7303014", "0.71548724", "0.7148735", "0.7075203", "0.69926786", "0.6866925", "0.68362427", "0.68152994", "0.6766912", "0.67421544", "0.6731956", "0.66912895", "0.66828746", "0.6666743", "0.6657045", "0.6656961", "0.66309655", "0.66255593", "0.6615", "0.6612183...
0.83005923
0
Compare the structure of llst[lslices] and rlst[rslices].
def cmp_structure(llst, rlst, lslices, rslices): lshape = slice_shape(llst, lslices) rshape = slice_shape(rlst, rslices) if (len(lshape) != len(rshape)): return -1 for i in range(len(lshape)): if lshape[i] != rshape[i]: return -1 if lshape[i] == 0: return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmp_structure(llst, rlst, lslices, rslices):\n lshape = slice_shape(llst, lslices)\n rshape = slice_shape(rlst, rslices)\n if len(lshape) != len(rshape):\n return -1\n for i in range(len(lshape)):\n if lshape[i] != rshape[i]:\n return -1\n if lshape[i] == 0:\n ...
[ "0.8107347", "0.5830058", "0.5787684", "0.57273674", "0.5708086", "0.547884", "0.54676497", "0.5341118", "0.53267294", "0.5325244", "0.5295086", "0.52857417", "0.52715236", "0.52042264", "0.5128856", "0.50830114", "0.50252223", "0.5011563", "0.50000906", "0.49984854", "0.4990...
0.8097147
1
Verify that the parameters represent a valid array within
def verify_structure(memlen, itemsize, ndim, shape, strides, offset): if offset % itemsize: return False if offset < 0 or offset+itemsize > memlen: return False if any(v % itemsize for v in strides): return False if ndim <= 0: return ndim == 0 and not shape and not strid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_array(t):\n basetype = t.type\n if is_array(basetype):\n raise ArrayOfArrayError(t)\n validate(basetype)", "def _validate_array_params(array_params):\n if isinstance(array_params, dict):\n # Shallow check; make sure each antenna position is a 3-vector.\n if all(len(...
[ "0.7270341", "0.69448113", "0.683705", "0.6811981", "0.6776789", "0.67708015", "0.6727861", "0.6655488", "0.6578328", "0.6572302", "0.65476936", "0.6494485", "0.64726275", "0.64687735", "0.64408755", "0.6395904", "0.6385423", "0.635954", "0.63554", "0.63529444", "0.63336235",...
0.0
-1
Location of an item in the underlying memory.
def memory_index(indices, t): memlen, itemsize, ndim, shape, strides, offset = t p = offset for i in range(ndim): p += strides[i]*indices[i] return p
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loc(self):\n return self._loc", "def loc(self):\n return self._loc", "def item_location(self, item_location):\n\n self._item_location = item_location", "def location(self, item):\n return reverse(item)", "def findItem(self, item):\n found_location = self.__find(item)\n\n ...
[ "0.64741904", "0.64741904", "0.6460164", "0.630083", "0.6235623", "0.61925596", "0.61581695", "0.61156976", "0.6103149", "0.6092022", "0.60529405", "0.6024192", "0.6024192", "0.6024192", "0.60195667", "0.59354365", "0.59073675", "0.5875071", "0.5874959", "0.58549565", "0.5850...
0.0
-1
The structure 't' is overlapping if at least one memory location is visited twice while iterating through all possible tuples of indices.
def is_overlapping(t): memlen, itemsize, ndim, shape, strides, offset = t visited = 1<<memlen for ind in indices(shape): i = memory_index(ind, t) bit = 1<<i if visited & bit: return True visited |= bit return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_overlapping(t):\n memlen, itemsize, ndim, shape, strides, offset = t\n visited = 1 << memlen\n for ind in indices(shape):\n i = memory_index(ind, t)\n bit = 1 << i\n if visited & bit:\n return True\n visited |= bit\n return False", "def listOfOverlappingT...
[ "0.71436214", "0.6230163", "0.54177374", "0.53693205", "0.526794", "0.52386534", "0.5171279", "0.5169592", "0.5149605", "0.5122925", "0.5052315", "0.50437593", "0.5038537", "0.5037338", "0.5033946", "0.49886644", "0.49637598", "0.49573925", "0.495004", "0.49486208", "0.493795...
0.7153341
0
Create a random slice of len slicelen that fits into listlen.
def randslice_from_slicelen(slicelen, listlen): maxstart = listlen - slicelen start = randrange(maxstart+1) maxstep = (listlen - start) // slicelen if slicelen else 1 step = randrange(1, maxstep+1) stop = start + slicelen * step s = slice(start, stop, step) _, _, _, control = slice_indices(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randslice_from_slicelen(slicelen, listlen):\n maxstart = listlen - slicelen\n start = randrange(maxstart + 1)\n maxstep = (listlen - start) // slicelen if slicelen else 1\n step = randrange(1, maxstep + 1)\n stop = start + slicelen * step\n s = slice(start, stop, step)\n _, _, _, control =...
[ "0.83833927", "0.80226773", "0.714893", "0.7132235", "0.6567857", "0.6413113", "0.62118304", "0.61636114", "0.6134608", "0.6101278", "0.61010647", "0.6062314", "0.60282576", "0.6016087", "0.59929234", "0.5939068", "0.59296066", "0.59249735", "0.59247345", "0.5907804", "0.5882...
0.8387383
0
Create two sets of slices for an array x with shape 'shape' such that shapeof(x[lslices]) == shapeof(x[rslices]).
def randslice_from_shape(ndim, shape): lslices = [0] * ndim rslices = [0] * ndim for n in range(ndim): l = shape[n] slicelen = randrange(1, l+1) if l > 0 else 0 lslices[n] = randslice_from_slicelen(slicelen, l) rslices[n] = randslice_from_slicelen(slicelen, l) return tupl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randslice_from_shape(ndim, shape):\n lslices = [0] * ndim\n rslices = [0] * ndim\n for n in range(ndim):\n l = shape[n]\n slicelen = randrange(1, l + 1) if l > 0 else 0\n lslices[n] = randslice_from_slicelen(slicelen, l)\n rslices[n] = randslice_from_slicelen(slicelen, l)\n...
[ "0.6905628", "0.65749097", "0.6485385", "0.6485385", "0.6428866", "0.64170295", "0.64149487", "0.6344559", "0.6343766", "0.6329222", "0.62940896", "0.6255896", "0.62288624", "0.6182799", "0.59876955", "0.5903534", "0.58359647", "0.5818925", "0.5786385", "0.5780439", "0.572824...
0.6896135
1
Create (lshape, rshape, tuple(lslices), tuple(rslices)) such that shapeof(x[lslices]) == shapeof(y[rslices]), where x is an array with shape 'lshape' and y is an array with shape 'rshape'.
def rand_aligned_slices(maxdim=5, maxshape=16): ndim = randrange(1, maxdim+1) minshape = 2 n = randrange(100) if n >= 95: minshape = 0 elif n >= 90: minshape = 1 all_random = True if randrange(100) >= 80 else False lshape = [0]*ndim; rshape = [0]*ndim lslices = [0]*ndim; ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_shapes(arrs):\n #temp = [(name, np.asarray(a), deg) for name, a, deg in arrs]\n #ndim = max([a.ndim - deg for _, a, deg in arrs])\n\n temp = [a for name, a, deg in arrs]\n for i in range(len(temp)):\n if np.isscalar(temp[i]):\n temp[i] = np.array(temp[i])\n ndim = max([a....
[ "0.6327064", "0.6313743", "0.6305719", "0.63030237", "0.6290705", "0.6188022", "0.6066026", "0.60396975", "0.60346824", "0.59923345", "0.59665436", "0.590952", "0.58448064", "0.5815266", "0.5795022", "0.57507616", "0.57300574", "0.57165897", "0.56608945", "0.56530553", "0.561...
0.52202415
53
Return a list of random items for structure 't' with format 'fmtchar'.
def randitems_from_structure(fmt, t): memlen, itemsize, _, _, _, _ = t return gen_items(memlen//itemsize, '#'+fmt, 'numpy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randitems_from_structure(fmt, t):\n memlen, itemsize, _, _, _, _ = t\n return gen_items(memlen // itemsize, '#' + fmt, 'numpy')", "def gen_item(fmt, obj):\n mode, chars = fmt.split('#')\n x = []\n for c in chars:\n x.append(randrange_fmt(mode, c, obj))\n return x[0] if len(x) == 1 el...
[ "0.75925416", "0.6998413", "0.6998413", "0.61594206", "0.61594206", "0.5678781", "0.55998796", "0.55998796", "0.5551217", "0.55419385", "0.5459458", "0.5367428", "0.53579396", "0.53160495", "0.5218872", "0.51369077", "0.5077376", "0.5070219", "0.5048697", "0.50483674", "0.503...
0.7437101
1
Return ndarray from the tuple returned by rand_structure()
def ndarray_from_structure(items, fmt, t, flags=0): memlen, itemsize, ndim, shape, strides, offset = t return ndarray(items, shape=shape, strides=strides, format=fmt, offset=offset, flags=ND_WRITABLE|flags)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_rand_array(self):\n return np.random.random((self.w + 1, self.h + 1, 2))", "def random_array(size_tuple):\n\n output = np.random.rand(\n size_tuple[0], size_tuple[1])\n\n return output", "def _get_rand_array(self):\n return np.random.random((self.w, self.h))", "def _get_ra...
[ "0.7160795", "0.6981562", "0.687871", "0.68413705", "0.6571761", "0.6536121", "0.64408153", "0.62637174", "0.6254054", "0.6222539", "0.61559474", "0.6148007", "0.6124988", "0.61171156", "0.6101302", "0.6100603", "0.60837346", "0.6055601", "0.60541236", "0.604905", "0.6042505"...
0.0
-1
Return numpy_array from the tuple returned by rand_structure()
def numpy_array_from_structure(items, fmt, t): memlen, itemsize, ndim, shape, strides, offset = t buf = bytearray(memlen) for j, v in enumerate(items): struct.pack_into(fmt, buf, j*itemsize, v) return numpy_array(buffer=buf, shape=shape, strides=strides, dtype=fmt, offset=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_array(size_tuple):\n\n output = np.random.rand(\n size_tuple[0], size_tuple[1])\n\n return output", "def _get_rand_array(self):\n return np.random.random((self.w + 1, self.h + 1, 2))", "def _get_rand_array(self):\n pass", "def _get_rand_array(self):\n return np.ra...
[ "0.715556", "0.71340054", "0.70975256", "0.6925855", "0.6733625", "0.6368195", "0.6337332", "0.63088566", "0.6258198", "0.60780334", "0.607233", "0.6022399", "0.6017903", "0.59449095", "0.5937947", "0.59133595", "0.58726776", "0.5857207", "0.58105093", "0.57880354", "0.573006...
0.0
-1
Interpret the raw memory of 'exporter' as a list of items with size 'itemsize'. If shape=None, the new structure is assumed to be 1D with n itemsize = bytelen. If shape is given, the usual constraint for contiguous arrays prod(shape) itemsize = bytelen applies. On success, return (items, shape). If the constraints cann...
def cast_items(exporter, fmt, itemsize, shape=None): bytelen = exporter.nbytes if shape: if prod(shape) * itemsize != bytelen: return None, shape elif shape == []: if exporter.ndim == 0 or itemsize != bytelen: return None, shape else: n, r = divmod(bytelen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cast_items(exporter, fmt, itemsize, shape=None):\n bytelen = exporter.nbytes\n if shape:\n if prod(shape) * itemsize != bytelen:\n return None, shape\n elif shape == []:\n if exporter.ndim == 0 or itemsize != bytelen:\n return None, shape\n else:\n n, r = ...
[ "0.77506953", "0.49568605", "0.48241737", "0.48023552", "0.47398067", "0.4713811", "0.47077888", "0.46982223", "0.4669957", "0.4669957", "0.4669957", "0.4669957", "0.46594286", "0.4643557", "0.459365", "0.4521161", "0.45037562", "0.44983464", "0.4494086", "0.4490511", "0.4454...
0.77280533
1
Generate shapes to test casting.
def gencastshapes(): for n in range(32): yield [n] ndim = randrange(4, 6) minshape = 1 if randrange(100) > 80 else 2 yield [randrange(minshape, 5) for _ in range(ndim)] ndim = randrange(2, 4) minshape = 1 if randrange(100) > 80 else 2 yield [randrange(minshape, 5) for _ in range(ndim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_shapes(data_dir):\n dataset.create_shapes(10, 10, 1, data_dir=data_dir)\n img_path = os.path.join(data_dir, \"ellipse/0.png\")\n assert os.path.exists(img_path)\n img = imageio.imread(img_path)\n assert img.shape == (10, 10, 4)", "def create_random_shapes(shapesList):\n for _ in...
[ "0.67064095", "0.66619724", "0.6262542", "0.6234531", "0.6208814", "0.61593676", "0.6048804", "0.60143715", "0.60028", "0.5992972", "0.59387314", "0.5908916", "0.5902789", "0.586213", "0.58594203", "0.5833996", "0.5833996", "0.582378", "0.58225274", "0.58054274", "0.5756805",...
0.6170885
5
Generate all possible slices for a single dimension.
def genslices(n): return product(range(-n, n+1), range(-n, n+1), range(-n, n+1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_slices(self, dim=None, sample=None):\n \n if dim is None:\n dim = self.D\n if sample is None:\n sample = range(1, int(self.poolSize)+1)\n labelsCube = self.labelledCube(dim, sample)\n init = [range(3)] * (dim-1)\n slice_colors = ['yellow', ...
[ "0.68956304", "0.6782944", "0.6318284", "0.61906445", "0.6138602", "0.606376", "0.6022408", "0.6019132", "0.5987078", "0.5982537", "0.5982537", "0.5952053", "0.5952053", "0.5930457", "0.59301263", "0.59170926", "0.5881405", "0.5880028", "0.58595836", "0.5842746", "0.58289135"...
0.55072
39
Generate all possible slice tuples for 'shape'.
def genslices_ndim(ndim, shape): iterables = [genslices(shape[n]) for n in range(ndim)] return product(*iterables)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randslice_from_shape(ndim, shape):\n lslices = [0] * ndim\n rslices = [0] * ndim\n for n in range(ndim):\n l = shape[n]\n slicelen = randrange(1, l + 1) if l > 0 else 0\n lslices[n] = randslice_from_slicelen(slicelen, l)\n rslices[n] = randslice_from_slicelen(slicelen, l)\n...
[ "0.7245465", "0.7242757", "0.6539281", "0.6419186", "0.64133", "0.6405746", "0.6356059", "0.63555807", "0.6354344", "0.62147045", "0.6181078", "0.6152246", "0.6074758", "0.6030818", "0.60114497", "0.60114497", "0.59410995", "0.5884168", "0.5851655", "0.57941407", "0.57577944"...
0.61784625
12
Generate random slice for a single dimension of length n. If zero=True, the slices may be empty, otherwise they will be nonempty.
def rslice(n, allow_empty=False): minlen = 0 if allow_empty or n == 0 else 1 slicelen = randrange(minlen, n+1) return randslice_from_slicelen(slicelen, n)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rslice(n, allow_empty=False):\n minlen = 0 if allow_empty or n == 0 else 1\n slicelen = randrange(minlen, n + 1)\n return randslice_from_slicelen(slicelen, n)", "def get_slice(self, n):\n if n == 0:\n return slice(self._lo_atom, self._lo_atom + self._n_atoms)\n raise IndexEr...
[ "0.77326006", "0.70148605", "0.6813906", "0.6813906", "0.6412858", "0.63864595", "0.62999004", "0.6264508", "0.61941475", "0.6164201", "0.616065", "0.6156945", "0.6141035", "0.61246413", "0.61231834", "0.605221", "0.60043675", "0.60013884", "0.59873164", "0.5930526", "0.59282...
0.77208936
1
Generate random slices for a single dimension.
def rslices(n, allow_empty=False): for _ in range(5): yield rslice(n, allow_empty)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def samples_multidimensional_uniform(bounds, points_count):\n dim = len(bounds)\n Z_rand = np.zeros(shape=(points_count, dim))\n for k in range(0,dim):\n Z_rand[:,k] = np.random.uniform(low=bounds[k][0], high=bounds[k][1], size=points_count)\n print('shape: ', Z_rand.shape)\n return Z_rand", ...
[ "0.6748864", "0.66025615", "0.6602007", "0.65602344", "0.6382453", "0.637084", "0.6325425", "0.63170785", "0.63101554", "0.6257017", "0.62307423", "0.6230162", "0.61685413", "0.6137612", "0.6112374", "0.60909176", "0.6086134", "0.6047355", "0.6043131", "0.6034215", "0.6028377...
0.57534003
41
Generate random slice tuples for 'shape'.
def rslices_ndim(ndim, shape, iterations=5): # non-empty slices for _ in range(iterations): yield tuple(rslice(shape[n]) for n in range(ndim)) # possibly empty slices for _ in range(iterations): yield tuple(rslice(shape[n], allow_empty=True) for n in range(ndim)) # invalid slices ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randslice_from_shape(ndim, shape):\n lslices = [0] * ndim\n rslices = [0] * ndim\n for n in range(ndim):\n l = shape[n]\n slicelen = randrange(1, l+1) if l > 0 else 0\n lslices[n] = randslice_from_slicelen(slicelen, l)\n rslices[n] = randslice_from_slicelen(slicelen, l)\n ...
[ "0.81737244", "0.8173164", "0.70365703", "0.6893058", "0.66185147", "0.6588831", "0.65197295", "0.64492506", "0.64458674", "0.6420841", "0.6409542", "0.6335667", "0.63094866", "0.6286346", "0.62749714", "0.62746143", "0.62283", "0.6214", "0.6178123", "0.6170837", "0.6170837",...
0.59845704
36
Print ndarray for debugging.
def ndarray_print(nd): try: x = nd.tolist() except (TypeError, NotImplementedError): x = nd.tobytes() if isinstance(nd, ndarray): offset = nd.offset flags = nd.flags else: offset = 'unknown' flags = 'unknown' print("ndarray(%s, shape=%s, strides=%s, su...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ndarray_print(nd):\n try:\n x = nd.tolist()\n except (TypeError, NotImplementedError):\n x = nd.tobytes()\n if isinstance(nd, ndarray):\n offset = nd.offset\n flags = nd.flags\n else:\n offset = 'unknown'\n flags = 'unknown'\n print(\n \"ndarray(%...
[ "0.7679877", "0.68368405", "0.6631245", "0.6609683", "0.65994364", "0.65967774", "0.6263622", "0.62557095", "0.62557095", "0.62557095", "0.62557095", "0.6235029", "0.6219768", "0.6178411", "0.61287254", "0.6089198", "0.6083977", "0.60370946", "0.60179627", "0.6011618", "0.598...
0.7686053
0
idf should be genespecific
def process_arc_df(idf, ymax, y_interval=0): odf = idf.copy() odf['y_interval'] = y_interval odf['mid_point'] = (odf['sc_t'] + odf['aclv_t']) / 2 order = odf['alen'].argsort().argsort() odf['order'] = order # take log to squash the difference in between # arc_height = np.log(order + 1) + 0....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_idf(term, documents):\n\n number_of_docs = len(documents)\n documents_containing_term = len([document for document in documents if term in document])\n\n idf = math.log10(number_of_docs / documents_containing_term)\n\n return round(idf, 5)", "def calc_idf(self, nd):\n # collect idf sum to calc...
[ "0.6475487", "0.6212292", "0.6194341", "0.6188523", "0.6082829", "0.60702246", "0.6049595", "0.6043377", "0.60023904", "0.59861237", "0.59745646", "0.59393996", "0.5885963", "0.58711284", "0.5846038", "0.57972324", "0.5784424", "0.5780035", "0.57797086", "0.57674223", "0.5752...
0.0
-1
connect annotated clv to the below ax where predicted clvs are
def plot_connector(ax, arc_df): # gene = get_property(arc_df, 'gene_name') clvs = arc_df['aclv_t'].values.tolist() scs = arc_df['sc_t'].values.tolist() # lowest = -0.1 if (gene, dise) in MAIN_PLOT_GD_PAIRS_COMPLEX else -0.8 lowest = -1 # for i in clvs + scs: for i in clvs: # -0.25 i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lca(self, v, w):", "def get_vshape(self, dmax, plot=True):\n '''\n\n '''\n dists_label = np.linspace(0.001, dmax, 200)\n dists = np.concatenate([[0], np.linspace(0.001, dmax, 200)])/np.sqrt(2)\n dists_xy = np.stack([dists, dists], 1)\n dist_mat = self.get_distance_ma...
[ "0.56138206", "0.5608647", "0.54186684", "0.5302264", "0.5283774", "0.52464485", "0.5216876", "0.5174231", "0.5168294", "0.51151377", "0.5091749", "0.5072296", "0.5069256", "0.5067856", "0.50639397", "0.50111675", "0.50003016", "0.5000205", "0.49753287", "0.49463645", "0.4932...
0.0
-1
Is (x0, y0) on a shared diagonal with (x1, y1)?
def share_diagonal(x0,y0,x1,y1): return abs(x0 - x1) == abs(y0 - y1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def share_diagonal(x0, y0, x1, y1):\r\n dy = abs(y1 - y0) # Calc the absolute y distance\r\n dx = abs(x1 - x0) # CXalc the absolute x distance\r\n return dx == dy # They clash if dx == dy\r", "def share_diagonal(x0, y0, x1, y1):\r\n dy = abs(y1 - y0) # Calc the absolute ...
[ "0.8518046", "0.8518046", "0.8502754", "0.84337777", "0.7760696", "0.70689964", "0.70689964", "0.706408", "0.6565794", "0.65179807", "0.6373702", "0.63458717", "0.63303655", "0.6296012", "0.6293987", "0.62332195", "0.62295103", "0.61589813", "0.61407775", "0.6136831", "0.6124...
0.88636863
0
Return True if the queen at column c clashes with any queen to its left.
def col_clashes(bs, c): for i in range(c): if share_diagonal(i,bs[i], c,bs[c]): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isfree(col,queens):\n if col in queens:\n return False\n elif any([ abs(col-col1)==len(queens)-index for index,col1 in enumerate(queens)]):\n #c[r]==c[j]; r-j==c[r]-c[j]; r-j==c[j]-c[r]\n # col is the colomn to check; len(queens) just be the row index of col, dont subtract 1\n ...
[ "0.77055407", "0.72922397", "0.7145801", "0.70153964", "0.6985228", "0.6902115", "0.66958386", "0.65576535", "0.6551649", "0.6548673", "0.6523149", "0.6523149", "0.6522317", "0.6519715", "0.65155363", "0.6512403", "0.6512403", "0.65036315", "0.6501785", "0.64987516", "0.64938...
0.0
-1
Determine whether we have any queens clashing on the diagonals. We're assuming here that the_board is a permutation of column numbers, so we're not explicitly checking row or column clashes.
def has_clashes(the_board): for c in range(1, len(the_board)): if col_clashes(the_board, c): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multipleQueensAlongDiagonals(board):\n if (multipleQueensOnRightDiagonals(board) or\n multipleQueensOnLeftDiagonals(board)):\n return True\n\n return False", "def diag_win(board):\n\tif board[1][1] != EMPTY and (board[1][1] == board[0][2] == board[2][0] or board[1][1] == board[0][0] =...
[ "0.7737763", "0.77164614", "0.76054054", "0.75930977", "0.75839365", "0.75839365", "0.75591165", "0.75591165", "0.7456546", "0.73946005", "0.7344994", "0.7342945", "0.72782034", "0.71962905", "0.7145917", "0.7118199", "0.70307064", "0.6995394", "0.6990177", "0.69780976", "0.6...
0.7583776
6
Return the schema of a Data Type.
def __call__(self, cls_or_name: Union[str, Type]) -> Type[DTSchema]: if isinstance(cls_or_name, type): n = cls_or_name.__name__ else: n = cls_or_name if hasattr(self, n): return getattr(self, n) raise ValueError(f"Could not find type {cls_or_name}")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _schema_type(self) -> Optional[type]:\n return SeriesSchema", "def get_schema(self):\n response = self.client.get(self._get_collection_url('schema'))\n\n return response.get('schema', {})", "def get_schema(self):\r\n return self.__schema", "def get_schema_type(arg_schema: Dict...
[ "0.72283876", "0.70753324", "0.69580424", "0.6946455", "0.69358844", "0.69223475", "0.68721735", "0.6850955", "0.68285525", "0.68234205", "0.6798246", "0.67978346", "0.6782011", "0.6762986", "0.67275816", "0.6727343", "0.67157215", "0.6694789", "0.6689674", "0.66346025", "0.6...
0.0
-1
Parse a formatted string and return the names of the args and their types. Will raise a ValueError if the type is not a pyopenapi3 `Field` or an already defined Component Parameter type. In the case that the type represents a `Field`, then its type will be returned, respectively. Otherwise, if it is an already defined ...
def parse_name_and_type_from_fmt_str( formatted_str: str, allowed_types: Optional[Dict[str, Component]] = None ) -> Generator[Tuple[str, Type[Field]], None, None]: for _, arg_name, _type_name, _ in Formatter().parse(formatted_str): if arg_name is not None: try: as...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_type(self, param):\n\n def evaluate(instance):\n if isinstance(instance, (Struct, Enum)):\n return instance.name\n if isinstance(instance, (Integer, Float)):\n return 'Number'\n return type(instance).__name__\n\n if isinstance...
[ "0.5762772", "0.56126136", "0.5612374", "0.5606245", "0.5510904", "0.5498231", "0.54389805", "0.5416661", "0.5379599", "0.53538597", "0.5281033", "0.52633864", "0.522637", "0.51833683", "0.5179722", "0.5152138", "0.51198363", "0.51118517", "0.50726426", "0.5072116", "0.507044...
0.74992687
0
Convert a custom object to a schema. This is done by create a reference to the object. Any nonreference object should be created by the Components builder. param `obj` must be a subtype of `data_types.Component`. Its type will determine what kind of component it is, e.g. '/components/ schemas/...' or '/components/param...
def convert_objects_to_schema(obj: Type[Component]) -> ReferenceObject: cmp_type: str = 'schemas' # default component type if hasattr(obj, '__cmp_type__'): cmp_type = obj.__cmp_type__.lower() # type: ignore return create_reference(obj.__name__, cmp_type)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_schema(obj):\n\n if not isinstance(obj, Schema):\n if isinstance(obj, dict):\n return DictStructure(obj)\n elif isinstance(obj, list):\n return ListStructure(obj)\n elif isinstance(obj, (int, float, str, bool)) or (obj is None):\n return Value(obj)\...
[ "0.6243453", "0.5825912", "0.57944256", "0.57603896", "0.56610686", "0.5654507", "0.5639352", "0.5597519", "0.5585299", "0.5489156", "0.5368194", "0.53657424", "0.5364657", "0.5353328", "0.5295786", "0.5216217", "0.5193709", "0.516745", "0.51386046", "0.5135405", "0.5110169",...
0.81769264
0
'Inject' the `Component` class into the custom, user defined, soontobe Component, class. This will help when building a property that involves a user defined custom Component. param `cmp_type` is some subtype of `data_types.Component`, e.g. whether it is a Schema component or Parameter component.
def inject_component(cls, cmp_type: Type[ComponentType]): if issubclass(cls, Component): return cls else: injected = type( "Injected", (cls, cmp_type), {attr_name: attr for attr_name, attr in cls.__dict__.items()} ) injected.__qualname__ = f'Co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_comp(self, name, ctype):\n\n name = self.name + '.' + name\n\n assert name not in self.components, 'A component named \\'{}\\' already exists for node \\'{}\\''.format(\n name, self.name)\n\n try:\n cls = co.str_to_comp(ctype)\n except AttributeError:\n ...
[ "0.6341976", "0.60763973", "0.60763973", "0.5894654", "0.5816849", "0.5718252", "0.56145835", "0.56028533", "0.5554072", "0.55418164", "0.5510925", "0.54735297", "0.54278535", "0.5406879", "0.5326886", "0.5326886", "0.5322498", "0.52880853", "0.518145", "0.51773274", "0.51618...
0.7875679
0
Init by server url
def init(server_host_and_port): global __obj_starter_api __obj_starter_api = PrivateApi(api_url=server_host_and_port)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, server_url='http://192.241.215.92:8011'):\n assert isinstance(server_url, str)\n self.server_url = server_url", "def __init__(self, url):\n self.url = url\n self.admin_url = os.path.join(url, \"__admin\")\n self.admin_mapping_url = os.path.join(self.admin_url...
[ "0.7656898", "0.70661646", "0.6904823", "0.689395", "0.67538166", "0.66310674", "0.66245764", "0.6576854", "0.65653795", "0.6529327", "0.6493813", "0.63935435", "0.6388721", "0.6376249", "0.63753974", "0.6375212", "0.63577634", "0.6355919", "0.6355919", "0.6355919", "0.635494...
0.68095416
4
Build and submit task to server
def build_submit(service_id, data=None): return submit( build_task(service_id, data) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_task():", "def task():", "def run(self):\n if self.type_task == \"Api-request\":\n self.config = ConfigApiRequestTask(**self.dynamic_configs)\n self.task = ApiRequestTask(\n priority=0, # fixed priority\n config=self.config\n )\n ...
[ "0.70684713", "0.66794336", "0.6674396", "0.66026026", "0.6517576", "0.65075755", "0.6490517", "0.64522195", "0.6393312", "0.6379747", "0.63695216", "0.6331631", "0.6319318", "0.62970674", "0.6277401", "0.62158525", "0.6213745", "0.6209379", "0.6209379", "0.6204134", "0.62009...
0.66046375
3
If the algorithm is allowed to modify the lists.
def add_numbers(head1,head2): if not head2 and head1 : return head1 elif not head1 and head2 : return head2 elif not head1 and not head2 : return head2 else : return reverse(add(reverse(head1),reverse(head2)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkLists(self):\n self.x = self.checkList(self.x)\n self.y = self.checkList(self.y)\n return", "def can_be_modified(self):\n return self.state in {RequestState.pending, RequestState.accepted}", "def _set_listonly(self, value):\n if not value and self.__listonly:\n ...
[ "0.6362258", "0.61513126", "0.61318016", "0.60871756", "0.59612465", "0.5935387", "0.5869912", "0.5833893", "0.5829071", "0.5793278", "0.5785526", "0.5719487", "0.5713861", "0.57039505", "0.57035685", "0.56947637", "0.5652734", "0.56144464", "0.56124794", "0.55669487", "0.556...
0.0
-1
Determine all of the local ip addresses for this machine This allows us to flag traffic as inbound or outbound.
def detect_local_ips(self): result = set() for ifaceName in interfaces(): try: address = [i['addr'] for i in ifaddresses(ifaceName)[AF_INET]] except: pass result.add(address[0]) return tuple(result)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ips():\r\n local_ips = []\r\n public_ips = []\r\n \r\n # list of iface names, 'lo0', 'eth0', etc.\r\n for iface in netifaces.interfaces():\r\n # list of ipv4 addrinfo dicts\r\n ipv4s = netifaces.ifaddresses(iface).get(netifaces.AF_INET, [])\r\n for entry in ipv4s:\r\n ...
[ "0.73083735", "0.72061265", "0.704093", "0.6923851", "0.6890017", "0.6762811", "0.6715329", "0.67115986", "0.66833586", "0.6657584", "0.66189605", "0.66133195", "0.66041005", "0.6584781", "0.6563698", "0.6518723", "0.64804894", "0.647476", "0.645703", "0.63811326", "0.6353452...
0.74796903
0
Sorts an iterable of packets and removes the duplicates
def iter_packets(iterable): prev = None for i in sorted(iterable, key=attrgetter('seq')): if prev is None or prev.seq != i.seq: prev = i yield i
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_grouped_packets(self, grouped_packets):\n for group in grouped_packets:\n group.sort(key=lambda x: x.time, reverse=False)\n return grouped_packets", "def insertOrderedPacket(self, packet:Rudp.Packet, packets:list) -> list:\n i = 0\n for i in range(len(packets)):\n ...
[ "0.6647256", "0.61278707", "0.60170823", "0.5986823", "0.596562", "0.5906093", "0.5628137", "0.5617985", "0.560249", "0.5601702", "0.5557772", "0.5519489", "0.55179644", "0.55005574", "0.5492273", "0.54918206", "0.5472187", "0.5472187", "0.54687566", "0.543962", "0.54305553",...
0.6355191
1
Hashes a packet to determine the tcp stream it is part of
def hash_packet(eth, outbound=False): ip = eth.data tcp = ip.data return '%s:%i' % (ipaddr_string(ip.dst if outbound else ip.src), tcp.sport if outbound else tcp.dport )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_packet(packet):\n if packet.proto == 6:\n #*** Is TCP:\n packet_tuple = (packet.ip_src,\n packet.ip_dst,\n packet.proto,\n packet.tp_src,\n packet.tp_dst,\n packet.tp_seq_src,\n ...
[ "0.7895792", "0.661901", "0.63492525", "0.6196242", "0.6103663", "0.6019841", "0.5995078", "0.5981094", "0.59252846", "0.5890868", "0.58816797", "0.58208543", "0.5804756", "0.5796329", "0.5782937", "0.5778316", "0.574992", "0.568126", "0.56439674", "0.5617276", "0.5610319", ...
0.72170126
1
Looks in the buffer to see if we have the next packet, if so append it and continue till there are no packets left.
def _check_buffer(self): count = 0 for packet in self.remove_buffered_packets(): self._append_packet(packet) count += 1 if count > 0: logging.debug('Removed %i items from the buffer, %i left.' % (count, len(self.buffer)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_buffer(self, packet):\n # If the buffer is currently empty, the we should send the next packet\n # (i.e. this packet) as soon as it finishes transmitting (which will take\n # time + sizeofpacket/transmissionrate)\n if (len(self.buffer) == 0):\n self.next_packet_sen...
[ "0.74713373", "0.71250594", "0.6726249", "0.6618854", "0.6465137", "0.6395793", "0.6097378", "0.60572255", "0.60321057", "0.596553", "0.5958994", "0.5956344", "0.594581", "0.5886289", "0.5877437", "0.5875217", "0.5834494", "0.5769007", "0.5697798", "0.56975275", "0.56848884",...
0.6629113
3
Iterates over next packets in the buffer and removes them
def remove_buffered_packets(self): seq = self.next_seq while True: p = self.buffer.pop(seq, None) if p is None: break else: seq += len(p.data) yield p
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_packets(self, verbose=False):\n while True:\n try:\n packet, address = self._socket.recvfrom(10240)\n except:\n break\n\n if verbose:\n logger.debug(\"dropped %d bytes from %s:%d\", len(packet), address[0], address[1])", ...
[ "0.67283076", "0.66058624", "0.63236773", "0.6317739", "0.6310936", "0.62291014", "0.61791795", "0.60786915", "0.60678726", "0.59578645", "0.5947683", "0.5928341", "0.5889969", "0.5796768", "0.5776283", "0.5721672", "0.571722", "0.57118416", "0.5706474", "0.5685877", "0.56655...
0.7841867
0
Appends a packet to the end of the list of received packets and processes it
def _append_packet(self, packet): self.next_seq += len(packet.data) if self.headers is not None: if self.packets is None: self.packets = StringIO.StringIO() self.packets.write(packet.data) self.http_bytes_loaded += len(packet.data) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def packet_queue(self, pkt):\n \n pkt.pos = 0\n pkt.to_process = pkt.packet_length\n \n self.out_packet.append(pkt)\n return NC.ERR_SUCCESS", "def process(self, packet):\n pass", "def add_to_buffer(self, packet):\n # If the buffer is currently empty, the ...
[ "0.7200842", "0.6791505", "0.65107197", "0.6466896", "0.6292419", "0.62873334", "0.6270652", "0.6237618", "0.62123734", "0.6207645", "0.6195065", "0.6191263", "0.60909575", "0.60606736", "0.60586536", "0.6052133", "0.60464114", "0.60459393", "0.60107774", "0.5988574", "0.5982...
0.63934094
4
This will eventually provide a way for a callback receive packets in order
def _handle_ordered_packet(self, packet): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callback(self, packet, sender=None):\n pass", "def _pkt_handle(self, pkt):\n\n # snag any left over data from last read()\n # Parse the header to get type\n offset, payload_len, subtype, nxp_sniffer = lowpan.message.parse_header(pkt[0])\n\n\n # Extract the raw message bytes...
[ "0.7107678", "0.64932233", "0.644447", "0.6367621", "0.6333254", "0.6190142", "0.61311525", "0.6129073", "0.6126829", "0.61010754", "0.60605866", "0.6048082", "0.6015961", "0.6012906", "0.59732354", "0.59732354", "0.59718686", "0.5969053", "0.5905559", "0.5835373", "0.5826865...
0.5721915
28
Check the status of a job.
def check_status(self, job_uuid): project = self._project project_id = project.get_uuid() if type(project) is Project else project code, response = self._rest.get(f'/projects/{project_id}/jobs/{job_uuid}/status') if code != 200: raise RuntimeError("Server status code: %s; Res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_job_status(self, jobid=None):\n\n if jobid is None:\n if hasattr(self, 'current_job'):\n jobid = self.current_job\n else:\n jobid = self.current_job\n\n response = self._request(\n 'GET', CosmoSim.QUERY_URL + '/{}'.format(jobid)...
[ "0.79731226", "0.7944931", "0.7796605", "0.77694833", "0.775386", "0.77262664", "0.76045054", "0.748808", "0.7468982", "0.737767", "0.72872686", "0.72710776", "0.7249173", "0.7246472", "0.7232544", "0.7220014", "0.7208316", "0.71444625", "0.7134333", "0.7080739", "0.70677483"...
0.71159524
19
Get the results of a job.
def get_results(self, job_uuid): project = self._project project_id = project.get_uuid() if type(project) is Project else project code, response = self._rest.get(f'/projects/{project_id}/jobs/{job_uuid}/result') if code != 200: raise RuntimeError("Server status code: %s; Res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_results(self, job_id):\n ujs = self.__ujs_client()\n res = ujs.get_results(job_id)\n return res", "def getResults(self):\n if self.__jobInfo.results is not None:\n return json.loads(self.__jobInfo.results)\n else:\n return None", "def get_results(self, job, ...
[ "0.76884747", "0.7678061", "0.7445121", "0.74429166", "0.7372573", "0.735825", "0.70753413", "0.70528066", "0.70358944", "0.69135725", "0.6910701", "0.67281175", "0.67259216", "0.6709659", "0.6699838", "0.6654707", "0.6602226", "0.659859", "0.659859", "0.65819", "0.6562158", ...
0.6844862
11
rss232 standard baud rates 300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200 230400
def BaudGen(clk, reset, rx_tick, tx_tick, clk_freq=100000000, baudrate=9600, rx_div=16): tx_tick_max = int(round(clk_freq/baudrate)) tick_count_reg = Signal(intbv(0, min=0, max=tx_tick_max)) tick_count_next = Signal(intbv(0, min=0, max=tx_tick_max)) rx_div_count_reg = Signal(intbv(0, min=0, max=rx_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, port, baudrate):\n return", "def __init__(self, id: int, baudrate: int=9600, bits: int=8, parity: int=None, stop: int=1, tx: Pin=None, rx: Pin=None):", "def baudrate_cmd(self, baudrate):\r\n if baudrate is 19200:\r\n baudrate = \"F\"\r\n else:\r\n b...
[ "0.6666518", "0.65934765", "0.63405526", "0.6223233", "0.61509335", "0.61282706", "0.6121142", "0.6112411", "0.60013664", "0.5970437", "0.591027", "0.58561224", "0.58513325", "0.58400947", "0.58149344", "0.5779933", "0.5740304", "0.5728582", "0.5727158", "0.5721995", "0.57059...
0.5508608
39
Given n number of trials, p the probability of successes, what is the probability of having less than or equal to x successes? Your function should raise a ValueError if x is higher than n.
def bin_cdf(n, p, x): # p C (bin_dist) ** 0 ) *(1-bin_dist)** p # n = (p)=20 # x = x = 1 = r # nCr = n! / r!(n-r) def bin_dist(n, p, x): """ Given n number of trials, p the probability of success, what is the probability of having x successes? Your function shoul...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_bernoulli_trials(n, p):\n # Initialize number of successes: n_success\n n_success = 0\n\n\n # Perform trials\n for i in range(n):\n # Choose random number between zero and one: random_number\n random_number = np.random.random()\n\n # If less than p, it's a success so ad...
[ "0.8051699", "0.80322367", "0.8030806", "0.80230564", "0.7710508", "0.7604674", "0.7147401", "0.7144347", "0.69072294", "0.68672615", "0.6867023", "0.6762666", "0.6749791", "0.67391", "0.67163926", "0.67021275", "0.6657762", "0.65597177", "0.65574616", "0.6515296", "0.6502586...
0.5732656
99
Given n number of trials, p the probability of success, what is the probability of having x successes? Your function should raise a ValueError if x is higher than n. If you need to compute combinations, you can import the function "comb" from the package "scipy.special"
def bin_dist(n, p, x): def factorial(x): if x >= 0: factorial = 1 for i in range(1, x + 1): factorial = float(factorial * i) # print(f' The factorial of {x} is {factorial}') return factorial ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_bernoulli_trials(n, p):\n # Initialize number of successes: n_success\n n_success = 0\n\n\n # Perform trials\n for i in range(n):\n # Choose random number between zero and one: random_number\n random_number = np.random.random()\n\n # If less than p, it's a success so ad...
[ "0.7992995", "0.7988638", "0.7983567", "0.7979973", "0.78188634", "0.7754114", "0.7721174", "0.70337445", "0.7027335", "0.69186896", "0.6905595", "0.69036245", "0.6807177", "0.6772495", "0.6591704", "0.65804875", "0.65346736", "0.6518955", "0.65020025", "0.6491071", "0.647253...
0.66633165
14
Given n total number of items, what is the number of possible ways to choose r items from it?
def combination(n, r): numerator = factorial(n) denominator = factorial(r) subtracted_answer = factorial(n-r) answer = numerator/(denominator * subtracted_answer) print(answer) return answer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_ways(n):\r\n return number_of_ways_helper([1, 5, 10, 25], n)", "def main():\n\n import sys\n sys.setrecursionlimit(10**7)\n from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html\n # accumulate() returns iterator! t...
[ "0.72152823", "0.6937321", "0.6853795", "0.67474264", "0.67017275", "0.6627513", "0.6490569", "0.64309037", "0.6399863", "0.6383735", "0.6378631", "0.63440573", "0.63363504", "0.6292473", "0.6291534", "0.6279435", "0.62197953", "0.6189228", "0.6186623", "0.61849743", "0.61371...
0.0
-1
Move a die through a list of positions.
def move(self, *positions, show_length=True) -> str: move_parts = [] move_count = len(positions) pips = prev_x = prev_y = 0 for i, (x, y) in enumerate(positions): if i == 0: pips = self.dice.pop((x, y)) else: dx = x - prev_x ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def throw(self, move):\n for dice_index in move:\n self.dice[dice_index - 1] = random.randint(1,6)", "def move_tie_fighters(self):\n for i in range(len(self.tie_fighters)):\n self.tie_fighters[i].move_tie_fighter()", "def migration(self):\n\n coordinates = self.get_ra...
[ "0.66328007", "0.596524", "0.5870962", "0.58515584", "0.5819032", "0.57985187", "0.5759108", "0.57562107", "0.574448", "0.57078034", "0.56926847", "0.56588614", "0.5642412", "0.5605683", "0.5596673", "0.5586302", "0.55856097", "0.5582289", "0.5575625", "0.55608356", "0.555548...
0.63560057
1
Record the joint character between a pair of cells.
def add_joint(joint: str, x1: int, y1: int, x2: int, y2: int) -> str: return joint
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def junction_char(self):\n ...", "def _put_chr_at(self, char, row, col, color, adjustment_x=.19, adjustment_y=.19):\n self._goto_piece_xy(row, col, adjustment_x, adjustment_y)\n self.pen.color(color)\n self.pen.write(char, font=(\"Courier\", round(self.square_side_size * .7),\n ...
[ "0.6033239", "0.5642616", "0.5578127", "0.5315496", "0.52856386", "0.5230224", "0.5207506", "0.51857436", "0.51733494", "0.5166131", "0.51407605", "0.5093636", "0.5047172", "0.50447404", "0.50364846", "0.50296426", "0.5018322", "0.499095", "0.49901915", "0.49538672", "0.49527...
0.5760053
1
Split all dominoes into separate cells. Useful for Dominosa.
def split_all(self): for domino in self.dominoes[:]: self.split(domino)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_split_cell_splits_neighbours(mock_amg):\n\n # split the centre cell in the mock grid\n # this will create 4 more cells at tier 1\n mock_amg.cells[4].split()\n\n # now split the bottom right of these cells\n # this should force the east and south cells to also be split\n mock_amg.cells[4]...
[ "0.54147345", "0.53187776", "0.5316432", "0.53141034", "0.50757587", "0.50472033", "0.5007801", "0.49147692", "0.49121788", "0.4892322", "0.48909703", "0.48512492", "0.48459086", "0.48424825", "0.48366407", "0.48032853", "0.47910866", "0.47892538", "0.47808278", "0.47771978", ...
0.7638271
0
Build a display string for the board's current state.
def display(self, cropped=False, cropping_bounds=None): xmin, xmax, ymin, ymax = self.get_bounds(cropped) if cropping_bounds is not None: cropping_bounds[:] = [xmin, ymin, xmax, ymax] width = xmax-xmin+1 height = ymax-ymin+1 marker_display = self.display_markers() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n board = ''\n board_2 = ''\n\n for row in self.from_grid:\n for space in row:\n board += ' ' + space\n board += '\\n'\n\n for row in self.to_grid:\n for space in row:\n board_2 += ' ' + space\n ...
[ "0.7867957", "0.7523896", "0.73911226", "0.73753697", "0.7373144", "0.7246394", "0.7220203", "0.7215452", "0.7110438", "0.71008956", "0.7092637", "0.70639235", "0.7059323", "0.7039391", "0.7023496", "0.7022453", "0.7006166", "0.69822073", "0.6949946", "0.6925835", "0.69216865...
0.0
-1
Adjust the display grid before it gets assembled.
def adjust_display(self, display: typing.List[typing.List[str]]):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _prepare_grid(self):\n raise NotImplementedError", "def update_positions(self, grid):\r\n self.grid = grid", "def apply(self):\n self.grid_size = self.values[0]", "def configure_grid(self):\r\n\r\n for r in range(3):\r\n self.rowconfigure(r, weight=1)\r\n for...
[ "0.67337763", "0.65539414", "0.6454927", "0.64203435", "0.63934195", "0.63931537", "0.63745236", "0.63429075", "0.6283407", "0.6222548", "0.62183297", "0.620335", "0.6120996", "0.6119752", "0.6101794", "0.60955167", "0.6091233", "0.60688007", "0.6063356", "0.6054027", "0.6035...
0.0
-1
Iterate through self.extra_dominoes, start at random position. a generator of dominoes.
def choose_extra_dominoes(self, random): dominoes = self.extra_dominoes[:] count = len(dominoes) start = random.randrange(count) for i in range(count): yield dominoes[(i + start) % count]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_and_flip_extra_dominoes(self, random):\n for domino in self.choose_extra_dominoes(random):\n if domino.head.pips == domino.tail.pips:\n yield domino, False\n else:\n flip_first = random.randint(0, 1)\n for j in range(2):\n ...
[ "0.6895019", "0.62940025", "0.5725973", "0.53913283", "0.51478684", "0.5122216", "0.5106027", "0.51026565", "0.5055542", "0.50077224", "0.49957895", "0.4972248", "0.49301994", "0.49140477", "0.49055457", "0.48926997", "0.4876082", "0.48698455", "0.48647448", "0.48630825", "0....
0.8736248
0