Mislabelled CoSQA examples

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 |

Formalized description: repurposing QA datasets for retrieval

The process for creating a retrieval dataset from a dataset with $N$ question-answer pairs is fairly straightforward:

  1. Let $Q=\{q_1, q_2, …, q_N\}$ denote the set of questions, e.g. “What axis does a 1d average pooling layer in PyTorch operate on?”
  2. Let $A = \{a_1, a_2, …, a_N\}$ denote the set of answers, e.g. “The final axis, assuming that the input tensor rank 2 or 3.”
  3. For some questions, there is additional context. Let $C = \{c_1, c_2, …, c_N\}$ denote the optional set of contexts that then answer can be pulled from, e.g. implementations of 1D average pooling.

To repurpose this dataset for retrieval, we simply apply the following setup:

  1. The set of queries is equivalent to the set of questions $Q$.
  2. Define the documents $D=\{d_1, d_2, … d_N\}$ such that:

$$ 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$.

Formalized description: leveraging code repositories and issues for retrieval

In this system, each repository and its corresponding issues becomes a single retrieval dataset:

  1. Let $Q=\{q_1, q_2,…, q_N\}$ be the set of GitHub issue descriptions for a particular repository.
  2. Let $F_i = \{f_{i1}, f_{i2},…, f_{iK}\}$ be the set of code files associated with issue $q_i$ where $K_i$ is the number of files for issue $q_i$.
  3. Let $F=\Cup_{i=1}^{N} F_i$ be the set of all files in the repository.

We can now define relevance scores $R$ for all pairs of elements in $Q$ and $F$: