The table blow shows 10 consecutive CoSQA rows (rows 6981 to 6990, inclusive) from the same page as before. All rows have either subtle errors are are outright incorrect.
| Query | Code |
|---|---|
| python how to tell methods and properties of an object | def get_public_members(obj): |
| """ | |
| Retrieves a list of member-like objects (members or properties) that are publicly exposed. |
:param obj: The object to probe. :return: A dictionary of attribute names and their values. """ return { attr: getattr(obj, attr) for attr in dir(obj) if not attr.startswith("_") and not hasattr(getattr(obj, attr), 'call') } | | function to inverse matrix python | def inh(table): """Inverse hyperbolic sine transformation.""" t = [] for i in table: t.append(np.ndarray.tolist(np.arcsinh(i))) return t | | python how to turn a string into a list | def path_to_list(pathstr): """Convert a path string to a list of path elements.""" return [elem for elem in pathstr.split(os.path.pathsep) if elem] | | function you can use after dot python | def exit_if_missing_graphviz(self): """Detect the presence of the dot utility to make a PNG graph.""" out, err = utils.capture_shell("which dot") if "dot" not in out: ui.error(c.MESSAGES["dot_missing"]) | | python how to unpack scroll bar in grid | def __grid_widgets(self): """Places all the child widgets in the appropriate positions.""" scrollbar_column = 0 if self.__compound is tk.LEFT else 2 self._canvas.grid(row=0, column=1, sticky="nswe") self._scrollbar.grid(row=0, column=scrollbar_column, sticky="ns") | | generate 100 unique 15 numbers in python | def _uniqueid(n=30): """ Return a unique string with length n.
:parameter int N: number of characters in the unique ID :return: the unique ID :rtype: str """ return ''.join( random.SystemRandom().choice( string.ascii_uppercase + string.ascii_lowercase ) for _ in range(n) ) | | python how to use matplot histogram and not show plot | def plot(self): """Plot the empirical histogram versus the best-fit distribution's PDF.""" plt.plot(self.bin_edges, self.hist, self.bin_edges, self.best_pdf) | | generate a dotfile in python d tree | def to_dotfile(self): """ Writes a DOT graphviz file of the domain structure and returns the filename. """ domain = self.get_domain() filename = "%s.dot" % self.class.name nx.write_dot(domain, filename) return filename | | python how to write an empty line in write | def write_line(self, line, count=1): """Writes the line and count newlines after the line.""" self.write(line) self.write_newlines(count) | | generate a list with gap python | def _gaps_from(intervals): """ From a list of intervals, extract a list of sorted gaps in the form of [(g, i)] where g is the size of the i-th gap. """ sliding_window = zip(intervals, intervals[1:]) gaps = [b[0] - a[1] for a, b in sliding_window] return gaps |
The process for creating a retrieval dataset from a dataset with $N$ question-answer pairs is fairly straightforward:
To repurpose this dataset for retrieval, we simply apply the following setup:
$$ d_i = \begin{cases} c_i,\quad\text{if context $c_i$ exists}\\ a_i,\quad\text{otherwise} \end{cases} $$
Relevance scores of $1$ are assigned to each pair $(q_i, d_i)$ in this new retrieval dataset, while relevance scores of $0$ are assigned to all pairs $(q_i, d_i)$ such that $i≠j$.
In this system, each repository and its corresponding issues becomes a single retrieval dataset:
We can now define relevance scores $R$ for all pairs of elements in $Q$ and $F$: