semeru/code-code-galeras-code-completion-from-docstring-3k-deduped
248
1[2 {3 "id": 167770,4 "commit_id": "f65417656ba8c59438d832b6e2a431f78d40c21c",5 "repo": "pandas",6 "path": "pandas/core/groupby/groupby.py",7 "file_name": "groupby.py",8 "fun_name": "rolling",9 "commit_message": "TYP: more return annotations in core/ (#47618)\n\n* TYP: more return annotations in core/\r\n\r\n* from __future__ import annotations\r\n\r\n* more __future__",10 "code": "def rolling(self, *args, **kwargs) -> RollingGroupby:\n \n from pandas.core.window import RollingGroupby\n\n return RollingGroupby(\n self._selected_obj,\n *args,\n _grouper=self.grouper,\n _as_index=self.as_index,\n **kwargs,\n )\n",11 "url": "https://github.com/pandas-dev/pandas.git",12 "language": "Python",13 "ast_errors": "",14 "n_ast_errors": 0,15 "ast_levels": 9,16 "n_whitespaces": 101,17 "n_words": 18,18 "vocab_size": 17,19 "complexity": 1,20 "nloc": 12,21 "token_counts": 48,22 "n_ast_nodes": 71,23 "n_identifiers": 13,24 "random_cut": "def rolling(self, *args, **kwargs) -> RollingGroupby:\n \n from pandas.core.window import RollingGroupby\n\n",25 "d_id": 40113,26 "documentation": {27 "docstring": "\n Return a rolling grouper, providing rolling functionality per group.\n ",28 "n_words": 9,29 "vocab_size": 8,30 "n_whitespaces": 24,31 "language": "en"32 }33 },34 {35 "id": 176730,36 "commit_id": "2a05ccdb07cff88e56661dee8a9271859354027f",37 "repo": "networkx",38 "path": "networkx/generators/degree_seq.py",39 "file_name": "degree_seq.py",40 "fun_name": "expected_degree_graph",41 "commit_message": "Remove redundant py2 numeric conversions (#5661)\n\n* Remove redundant float conversion\r\n\r\n* Remove redundant int conversion\r\n\r\n* Use integer division\r\n\r\nCo-authored-by: Miroslav Šedivý <6774676+eumiro@users.noreply.github.com>",42 "code": "def expected_degree_graph(w, seed=None, selfloops=True):\n r\n n = len(w)\n G = nx.empty_graph(n)\n\n # If there are no nodes are no edges in the graph, return the empty graph.\n if n == 0 or max(w) == 0:\n return G\n\n rho = 1 / sum(w)\n # Sort the weights in decreasing order. The original order of the\n # weights dictates the order of the (integer) node labels, so we\n # need to remember the permutation applied in the sorting.\n order = sorted(enumerate(w), key=itemgetter(1), reverse=True)\n mapping = {c: u for c, (u, v) in enumerate(order)}\n seq = [v for u, v in order]\n last = n\n if not selfloops:\n last -= 1\n for u in range(last):\n v = u\n if not selfloops:\n v += 1\n factor = seq[u] * rho\n p = min(seq[v] * factor, 1)\n while v < n and p > 0:\n if p != 1:\n r = seed.random()\n v += math.floor(math.log(r, 1 - p))\n if v < n:\n q = min(seq[v] * factor, 1)\n if seed.random() < q / p:\n G.add_edge(mapping[u], mapping[v])\n v += 1\n p = q\n return G\n\n",43 "url": "https://github.com/networkx/networkx.git",44 "language": "Python",45 "ast_errors": "",46 "n_ast_errors": 0,47 "ast_levels": 17,48 "n_whitespaces": 417,49 "n_words": 179,50 "vocab_size": 97,51 "complexity": 13,52 "nloc": 100,53 "token_counts": 240,54 "n_ast_nodes": 375,55 "n_identifiers": 35,56 "random_cut": "def expected_degree_graph(w, seed=None, selfloops=True):\n r\n n = len(w)\n G = nx.empty_graph(n)\n\n # If there are no nodes are no edges in the graph, return the empty graph.\n if n == 0 or max(w) == 0:\n return G\n\n rho = 1 / sum(w)\n # Sort the weights in decreasing order. The original order of the\n # weights dictates the order of the (integer) node labels, so we\n # need to remember the permutation applied in the sorting.\n order = sorted(enumerate(w), key=itemgetter(1), reverse=True)\n mapping = {c: u for c, (u, v) in enumerate(order)}\n seq = [v for u, v in order]\n last = n\n if not selfloops:\n last -= 1\n for u in range(last):\n v = u\n if not selfloops:\n v += 1\n factor = seq[u] * rho\n p = min(seq[v] * factor, 1)\n while v < n and p > 0:\n if p != 1:\n r = seed.random()\n v += math.floor(math.log(r, 1 - p))\n if v < n:\n q = min(seq[v] * factor, 1)\n if seed.random() < q / p:\n G.add_edge(mapping[u",57 "d_id": 42064,58 "documentation": {59 "docstring": "Returns a random graph with given expected degrees.\n\n Given a sequence of expected degrees $W=(w_0,w_1,\\ldots,w_{n-1})$\n of length $n$ this algorithm assigns an edge between node $u$ and\n node $v$ with probability\n\n .. math::\n\n p_{uv} = \\frac{w_u w_v}{\\sum_k w_k} .\n\n Parameters\n ----------\n w : list\n The list of expected degrees.\n selfloops: bool (default=True)\n Set to False to remove the possibility of self-loop edges.\n seed : integer, random_state, or None (default)\n Indicator of random number generation state.\n See :ref:`Randomness<randomness>`.\n\n Returns\n -------\n Graph\n\n Examples\n --------\n >>> z = [10 for i in range(100)]\n >>> G = nx.expected_degree_graph(z)\n\n Notes\n -----\n The nodes have integer labels corresponding to index of expected degrees\n input sequence.\n\n The complexity of this algorithm is $\\mathcal{O}(n+m)$ where $n$ is the\n number of nodes and $m$ is the expected number of edges.\n\n The model in [1]_ includes the possibility of self-loop edges.\n Set selfloops=False to produce a graph without self loops.\n\n For finite graphs this model doesn't produce exactly the given\n expected degree sequence. Instead the expected degrees are as\n follows.\n\n For the case without self loops (selfloops=False),\n\n .. math::\n\n E[deg(u)] = \\sum_{v \\ne u} p_{uv}\n = w_u \\left( 1 - \\frac{w_u}{\\sum_k w_k} \\right) .\n\n\n NetworkX uses the standard convention that a self-loop edge counts 2\n in the degree of a node, so with self loops (selfloops=True),\n\n .. math::\n\n E[deg(u)] = \\sum_{v \\ne u} p_{uv} + 2 p_{uu}\n = w_u \\left( 1 + \\frac{w_u}{\\sum_k w_k} \\right) .\n\n References\n ----------\n .. [1] Fan Chung and L. Lu, Connected components in random graphs with\n given expected degree sequences, Ann. Combinatorics, 6,\n pp. 125-145, 2002.\n .. [2] Joel Miller and Aric Hagberg,\n Efficient generation of networks with given expected degrees,\n in Algorithms and Models for the Web-Graph (WAW 2011),\n Alan Frieze, Paul Horn, and Paweł Prałat (Eds), LNCS 6732,\n pp. 115-126, 2011.\n ",60 "n_words": 298,61 "vocab_size": 173,62 "n_whitespaces": 524,63 "language": "en"64 }65 },66 {67 "id": 19151,68 "commit_id": "4c58179509e6f6047789efb0a95c2b0e20cb6c8f",69 "repo": "mlflow",70 "path": "mlflow/models/evaluation/base.py",71 "file_name": "base.py",72 "fun_name": "save",73 "commit_message": "Improve evaluation api (#5256)\n\n* init\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update doc\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update doc\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* address comments\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update doc\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* add shap limitation on value type\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* fix format\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>\r\n\r\n* update\r\n\r\nSigned-off-by: Weichen Xu <weichen.xu@databricks.com>",74 "code": "def save(self, path):\n \n os.makedirs(path, exist_ok=True)\n with open(os.path.join(path, \"metrics.json\"), \"w\") as fp:\n json.dump(self.metrics, fp)\n\n artifacts_metadata = {\n artifact_name: {\n \"uri\": artifact.uri,\n \"class_name\": _get_fully_qualified_class_name(artifact),\n }\n for artifact_name, artifact in self.artifacts.items()\n }\n with open(os.path.join(path, \"artifacts_metadata.json\"), \"w\") as fp:\n json.dump(artifacts_metadata, fp)\n\n artifacts_dir = os.path.join(path, \"artifacts\")\n os.mkdir(artifacts_dir)\n\n for artifact_name, artifact in self.artifacts.items():\n artifact._save(os.path.join(artifacts_dir, artifact_name))\n",75 "url": "https://github.com/mlflow/mlflow.git",76 "language": "Python",77 "ast_errors": "",78 "n_ast_errors": 0,79 "ast_levels": 13,80 "n_whitespaces": 208,81 "n_words": 49,82 "vocab_size": 36,83 "complexity": 3,84 "nloc": 17,85 "token_counts": 153,86 "n_ast_nodes": 253,87 "n_identifiers": 22,88 "random_cut": "def save(self, path):\n \n os.makedirs(path,",89 "d_id": 2897,90 "documentation": {91 "docstring": "Write the evaluation results to the specified local filesystem path",92 "n_words": 10,93 "vocab_size": 9,94 "n_whitespaces": 9,95 "language": "en"96 }97 },98 {99 "id": 89933,100 "commit_id": "3255fa4ebb9fbc1df6bb063c0eb77a0298ca8f72",101 "repo": "sentry",102 "path": "tests/sentry/integrations/slack/test_message_builder.py",103 "file_name": "test_message_builder.py",104 "fun_name": "test_build_group_generic_issue_attachment",105 "commit_message": "feat(integrations): Support generic issue type alerts (#42110)\n\nAdd support for issue alerting integrations that use the message builder\r\n(Slack and MSTeams) for generic issue types.\r\n\r\n\r\nPreview text for Slack alert:\r\n<img width=\"350\" alt=\"Screen Shot 2022-12-08 at 4 07 16 PM\"\r\nsrc=\"https://user-images.githubusercontent.com/29959063/206593405-7a206d88-a31a-4e85-8c15-1f7534733ca7.png\">\r\n\r\nSlack generic issue alert shows the `occurrence.issue_title` and the\r\n\"important\" evidence value\r\n<img width=\"395\" alt=\"Screen Shot 2022-12-08 at 4 11 20 PM\"\r\nsrc=\"https://user-images.githubusercontent.com/29959063/206593408-6942d74d-4238-4df9-bfee-601ce2bc1098.png\">\r\n\r\nMSTeams generic issue alert shows the `occurrence.issue_title` and the\r\n\"important\" evidence value\r\n<img width=\"654\" alt=\"Screen Shot 2022-12-08 at 4 13 45 PM\"\r\nsrc=\"https://user-images.githubusercontent.com/29959063/206593410-2773746a-16b3-4652-ba2c-a7d5fdc76992.png\">\r\n\r\n\r\nFixes #42047",106 "code": "def test_build_group_generic_issue_attachment(self):\n \n event = self.store_event(\n data={\"message\": \"Hello world\", \"level\": \"error\"}, project_id=self.project.id\n )\n event = event.for_group(event.groups[0])\n occurrence = self.build_occurrence(level=\"info\")\n occurrence.save(project_id=self.project.id)\n event.occurrence = occurrence\n\n event.group.type = GroupType.PROFILE_BLOCKED_THREAD\n\n attachments = SlackIssuesMessageBuilder(group=event.group, event=event).build()\n\n assert attachments[\"title\"] == occurrence.issue_title\n assert attachments[\"text\"] == occurrence.evidence_display[0].value\n assert attachments[\"fallback\"] == f\"[{self.project.slug}] {occurrence.issue_title}\"\n assert attachments[\"color\"] == \"#2788CE\" # blue for info level\n",107 "url": "https://github.com/getsentry/sentry.git",108 "language": "Python",109 "ast_errors": "",110 "n_ast_errors": 0,111 "ast_levels": 12,112 "n_whitespaces": 154,113 "n_words": 51,114 "vocab_size": 38,115 "complexity": 1,116 "nloc": 14,117 "token_counts": 137,118 "n_ast_nodes": 249,119 "n_identifiers": 25,120 "random_cut": "def test_build_group_generic_issue_attachment(self):\n \n event = self.store_event(\n data={\"message\": \"Hello world\", \"level\": \"error\"}, project_id=self.project.id\n )\n event = event.for_group(event.groups[0])\n occurrence = self.build_occurrence(level=\"info\")\n occurrence.save(project_id=self.project.id)\n event.occurrence = occurrence\n\n event.group.type = GroupType.PROFILE_BLOCKED_THREAD\n\n attachments = SlackIssuesMessageBuilder(group=event.group, event=event).build()\n\n assert attachments[\"title\"] == occurrence.issue_title\n assert attachments[\"text\"] == occurrence.evidence_display[0].value\n assert attachments[\"fallback\"] == f\"[{self.project.slug}] {occurrence.issue_title}\"\n assert attachments[\"color\"] =",121 "d_id": 18592,122 "documentation": {123 "docstring": "Test that a generic issue type's Slack alert contains the expected values",124 "n_words": 12,125 "vocab_size": 12,126 "n_whitespaces": 11,127 "language": "en"128 }129 },130 {131 "id": 179114,132 "commit_id": "b3bc4e734528d3b186c3a38a6e73e106c3555cc7",133 "repo": "DeepFaceLive",134 "path": "xlib/image/ImageProcessor.py",135 "file_name": "ImageProcessor.py",136 "fun_name": "apply",137 "commit_message": "ImageProcessor.py refactoring",138 "code": "def apply(self, func, mask=None) -> 'ImageProcessor':\n \n img = orig_img = self._img\n img = func(img).astype(orig_img.dtype)\n if img.ndim != 4:\n raise Exception('func used in ImageProcessor.apply changed format of image')\n\n if mask is not None:\n mask = self._check_normalize_mask(mask)\n img = ne.evaluate('orig_img*(1-mask) + img*mask').astype(orig_img.dtype)\n\n self._img = img\n return self\n",139 "url": "https://github.com/iperov/DeepFaceLive.git",140 "language": "Python",141 "ast_errors": "",142 "n_ast_errors": 0,143 "ast_levels": 13,144 "n_whitespaces": 127,145 "n_words": 45,146 "vocab_size": 34,147 "complexity": 3,148 "nloc": 21,149 "token_counts": 82,150 "n_ast_nodes": 137,151 "n_identifiers": 14,152 "random_cut": "def apply(self, func, mask=None) -> 'ImageProcessor':\n \n img = orig_img = self._img\n img = func(img).astype(orig_img.dtype)\n if img.ndim != 4:\n raise Exception('func used in ImageProcessor.apply changed format of image')\n\n if mask is not None:\n ",153 "d_id": 42906,154 "documentation": {155 "docstring": "\n apply your own function on internal image\n\n image has NHWC format. Do not change format, but dims can be changed.\n\n func callable (img) -> img\n\n example:\n\n .apply( lambda img: img-[102,127,63] )\n ",156 "n_words": 31,157 "vocab_size": 30,158 "n_whitespaces": 79,159 "language": "en"160 }161 },162 {163 "id": 39007,164 "commit_id": "843dba903757d592f7703a83ebd75eb3ffb46f6f",165 "repo": "recommenders",166 "path": "recommenders/models/rbm/rbm.py",167 "file_name": "rbm.py",168 "fun_name": "predict",169 "commit_message": "removed time from returning args",170 "code": "def predict(self, x):\n \n\n # start the timer\n self.timer.start()\n\n v_, _ = self.eval_out() # evaluate the ratings and the associated probabilities\n vp = self.sess.run(v_, feed_dict={self.vu: x})\n \n # stop the timer\n self.timer.stop()\n\n log.info(\"Done inference, time %f2\" % self.timer.interval)\n\n return vp\n",171 "url": "https://github.com/microsoft/recommenders.git",172 "language": "Python",173 "ast_errors": "",174 "n_ast_errors": 0,175 "ast_levels": 12,176 "n_whitespaces": 110,177 "n_words": 38,178 "vocab_size": 30,179 "complexity": 1,180 "nloc": 7,181 "token_counts": 65,182 "n_ast_nodes": 111,183 "n_identifiers": 17,184 "random_cut": "def predict(self, x):\n \n\n # start the timer\n self.timer.start()\n\n v_, _ = self",185 "d_id": 7073,186 "documentation": {187 "docstring": "Returns the inferred ratings. This method is similar to recommend_k_items() with the\n exceptions that it returns all the inferred ratings\n\n Basic mechanics:\n\n The method samples new ratings from the learned joint distribution, together with\n their probabilities. The input x must have the same number of columns as the one used\n for training the model, i.e. the same number of items, but it can have an arbitrary number\n of rows (users).\n\n Args:\n x (numpy.ndarray, int32): Input user/affinity matrix. Note that this can be a single vector, i.e.\n the ratings of a single user.\n\n Returns:\n numpy.ndarray, float:\n - A matrix with the inferred ratings.\n - The elapsed time for predediction.\n ",188 "n_words": 108,189 "vocab_size": 73,190 "n_whitespaces": 226,191 "language": "en"192 }193 },194 {195 "id": 218569,196 "commit_id": "8198943edd73a363c266633e1aa5b2a9e9c9f526",197 "repo": "XX-Net",198 "path": "python3.10.4/Lib/json/decoder.py",199 "file_name": "decoder.py",200 "fun_name": "raw_decode",201 "commit_message": "add python 3.10.4 for windows",202 "code": "def raw_decode(self, s, idx=0):\n \n try:\n obj, end = self.scan_once(s, idx)\n except StopIteration as err:\n raise JSONDecodeError(\"Expecting value\", s, err.value) from None\n return obj, end\n",203 "url": "https://github.com/XX-net/XX-Net.git",204 "language": "Python",205 "ast_errors": "",206 "n_ast_errors": 0,207 "ast_levels": 11,208 "n_whitespaces": 74,209 "n_words": 24,210 "vocab_size": 21,211 "complexity": 2,212 "nloc": 6,213 "token_counts": 48,214 "n_ast_nodes": 76,215 "n_identifiers": 11,216 "random_cut": "def raw_decode(self, s, idx=0):\n \n try:\n obj, end = self.scan_once(s, idx)\n except StopIteration as err:\n raise JSONDecodeError(\"Expecting value\", s, err.val",217 "d_id": 55394,218 "documentation": {219 "docstring": "Decode a JSON document from ``s`` (a ``str`` beginning with\n a JSON document) and return a 2-tuple of the Python\n representation and the index in ``s`` where the document ended.\n\n This can be used to decode a JSON document from a string that may\n have extraneous data at the end.\n\n ",220 "n_words": 50,221 "vocab_size": 36,222 "n_whitespaces": 85,223 "language": "en"224 }225 },226 {227 "id": 176561,228 "commit_id": "aa1f40a93a882db304e9a06c2a11d93b2532d80a",229 "repo": "networkx",230 "path": "networkx/algorithms/bridges.py",231 "file_name": "bridges.py",232 "fun_name": "has_bridges",233 "commit_message": "Improve bridges documentation (#5519)\n\n* Fix bridges documentation\r\n\r\n* Revert source code modification\r\n\r\n* Revert raise errors for multigraphs",234 "code": "def has_bridges(G, root=None):\n \n try:\n next(bridges(G))\n except StopIteration:\n return False\n else:\n return True\n\n\n@not_implemented_for(\"multigraph\")\n@not_implemented_for(\"directed\")",235 "url": "https://github.com/networkx/networkx.git",236 "language": "Python",237 "ast_errors": "@not_implemented_for(\"multigraph\")\n@not_implemented_for(\"directed\")",238 "n_ast_errors": 1,239 "ast_levels": 11,240 "n_whitespaces": 45,241 "n_words": 14,242 "vocab_size": 13,243 "complexity": 2,244 "nloc": 7,245 "token_counts": 28,246 "n_ast_nodes": 70,247 "n_identifiers": 7,248 "random_cut": "def has_bridges(G, root=None):\n \n try:\n next(bridges",249 "d_id": 41965,250 "documentation": {251 "docstring": "Decide whether a graph has any bridges.\n\n A *bridge* in a graph is an edge whose removal causes the number of\n connected components of the graph to increase.\n\n Parameters\n ----------\n G : undirected graph\n\n root : node (optional)\n A node in the graph `G`. If specified, only the bridges in the\n connected component containing this node will be considered.\n\n Returns\n -------\n bool\n Whether the graph (or the connected component containing `root`)\n has any bridges.\n\n Raises\n ------\n NodeNotFound\n If `root` is not in the graph `G`.\n\n NetworkXNotImplemented\n If `G` is a directed graph.\n\n Examples\n --------\n The barbell graph with parameter zero has a single bridge::\n\n >>> G = nx.barbell_graph(10, 0)\n >>> nx.has_bridges(G)\n True\n\n On the other hand, the cycle graph has no bridges::\n\n >>> G = nx.cycle_graph(5)\n >>> nx.has_bridges(G)\n False\n\n Notes\n -----\n This implementation uses the :func:`networkx.bridges` function, so\n it shares its worst-case time complexity, $O(m + n)$, ignoring\n polylogarithmic factors, where $n$ is the number of nodes in the\n graph and $m$ is the number of edges.\n\n ",252 "n_words": 167,253 "vocab_size": 106,254 "n_whitespaces": 318,255 "language": "en"256 }257 },258 {259 "id": 61338,260 "commit_id": "f638f5d0e6c8ebed0e69a6584bc7f003ec646580",261 "repo": "transferlearning",262 "path": ".venv/lib/python3.8/site-packages/pip/_internal/utils/wheel.py",263 "file_name": "wheel.py",264 "fun_name": "wheel_metadata",265 "commit_message": "upd; format",266 "code": "def wheel_metadata(source, dist_info_dir):\n # type: (ZipFile, str) -> Message\n \n path = f\"{dist_info_dir}/WHEEL\"\n # Zip file path separators must be /\n wheel_contents = read_wheel_metadata_file(source, path)\n\n try:\n wheel_text = wheel_contents.decode()\n except UnicodeDecodeError as e:\n raise UnsupportedWheel(f\"error decoding {path!r}: {e!r}\")\n\n # FeedParser (used by Parser) does not raise any exceptions. The returned\n # message may have .defects populated, but for backwards-compatibility we\n # currently ignore them.\n return Parser().parsestr(wheel_text)\n\n",267 "url": "https://github.com/jindongwang/transferlearning.git",268 "language": "Python",269 "ast_errors": "",270 "n_ast_errors": 0,271 "ast_levels": 12,272 "n_whitespaces": 112,273 "n_words": 65,274 "vocab_size": 57,275 "complexity": 2,276 "nloc": 8,277 "token_counts": 49,278 "n_ast_nodes": 103,279 "n_identifiers": 13,280 "random_cut": "def wheel_metadata(source, dist_info_dir):\n # type: (ZipFile, str) -> Message\n \n path = f\"{dist_info_dir}/WHEEL\"\n # Zip file path separators must be /\n wheel_contents = read_wheel_metadata_file(source, path)\n\n try:\n wheel_text = wheel_contents.decode()\n except UnicodeDecodeError as e:\n raise UnsupportedWheel(f\"error decoding {path!r}: {e!r}\")\n\n # FeedParser (used by Parser) does not raise any exceptions. The returned\n # message may have .defects populated, but for backwards-compatibility",281 "d_id": 12520,282 "documentation": {283 "docstring": "Return the WHEEL metadata of an extracted wheel, if possible.\n Otherwise, raise UnsupportedWheel.\n ",284 "n_words": 13,285 "vocab_size": 13,286 "n_whitespaces": 19,287 "language": "en"288 }289 },290 {291 "id": 104416,292 "commit_id": "e35be138148333078284b942ccc9ed7b1d826f97",293 "repo": "datasets",294 "path": "src/datasets/table.py",295 "file_name": "table.py",296 "fun_name": "remove_column",297 "commit_message": "Update docs to new frontend/UI (#3690)\n\n* WIP: update docs to new UI\r\n\r\n* make style\r\n\r\n* Rm unused\r\n\r\n* inject_arrow_table_documentation __annotations__\r\n\r\n* hasattr(arrow_table_method, \"__annotations__\")\r\n\r\n* Update task_template.rst\r\n\r\n* Codeblock PT-TF-SPLIT\r\n\r\n* Convert loading scripts\r\n\r\n* Convert docs to mdx\r\n\r\n* Fix mdx\r\n\r\n* Add <Tip>\r\n\r\n* Convert mdx tables\r\n\r\n* Fix codeblock\r\n\r\n* Rm unneded hashlinks\r\n\r\n* Update index.mdx\r\n\r\n* Redo dev change\r\n\r\n* Rm circle ci `build_doc` & `deploy_doc`\r\n\r\n* Rm unneeded files\r\n\r\n* Update docs reamde\r\n\r\n* Standardize to `Example::`\r\n\r\n* mdx logging levels doc\r\n\r\n* Table properties inject_arrow_table_documentation\r\n\r\n* ``` to ```py mdx\r\n\r\n* Add Tips mdx\r\n\r\n* important,None -> <Tip warning={true}>\r\n\r\n* More misc\r\n\r\n* Center imgs\r\n\r\n* Update instllation page\r\n\r\n* `setup.py` docs section\r\n\r\n* Rm imgs since they are in hf.co\r\n\r\n* Update docs/source/access.mdx\r\n\r\nCo-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>\r\n\r\n* Update index mdx\r\n\r\n* Update docs/source/access.mdx\r\n\r\nCo-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>\r\n\r\n* just `Dataset` obj\r\n\r\n* Addedversion just italics\r\n\r\n* Update ReadInstruction doc example syntax\r\n\r\n* Change docstring for `prepare_for_task`\r\n\r\n* Chore\r\n\r\n* Remove `code` syntax from headings\r\n\r\n* Rm `code` syntax from headings\r\n\r\n* Hashlink backward compatability\r\n\r\n* S3FileSystem doc\r\n\r\n* S3FileSystem doc updates\r\n\r\n* index.mdx updates\r\n\r\n* Add darkmode gifs\r\n\r\n* Index logo img css classes\r\n\r\n* Index mdx dataset logo img size\r\n\r\n* Docs for DownloadMode class\r\n\r\n* Doc DownloadMode table\r\n\r\n* format docstrings\r\n\r\n* style\r\n\r\n* Add doc builder scripts (#3790)\r\n\r\n* add doc builder scripts\r\n\r\n* fix docker image\r\n\r\n* Docs new UI actions no self hosted (#3793)\r\n\r\n* No self hosted\r\n\r\n* replace doc injection by actual docstrings\r\n\r\n* Docstring formatted\r\n\r\nCo-authored-by: Quentin Lhoest <lhoest.q@gmail.com>\r\nCo-authored-by: Mishig Davaadorj <dmishig@gmail.com>\r\n\r\nCo-authored-by: Lysandre Debut <lysandre.debut@reseau.eseo.fr>\r\nCo-authored-by: Mishig Davaadorj <dmishig@gmail.com>\r\n\r\n* Rm notebooks from docs actions since they dont exi\r\n\r\n* Update tsting branch\r\n\r\n* More docstring\r\n\r\n* Chore\r\n\r\n* bump up node version\r\n\r\n* bump up node\r\n\r\n* ``` -> ```py for audio_process.mdx\r\n\r\n* Update .github/workflows/build_documentation.yml\r\n\r\nCo-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>\r\n\r\n* Uodate dev doc build\r\n\r\n* remove run on PR\r\n\r\n* fix action\r\n\r\n* Fix gh doc workflow\r\n\r\n* forgot this change when merging master\r\n\r\n* Update build doc\r\n\r\nCo-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>\r\nCo-authored-by: Quentin Lhoest <lhoest.q@gmail.com>\r\nCo-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>\r\nCo-authored-by: Lysandre Debut <lysandre.debut@reseau.eseo.fr>",298 "code": "def remove_column(self, i, *args, **kwargs):\n \n table = self.table.remove_column(i, *args, **kwargs)\n name = self.table.column_names[i]\n blocks = []\n for tables in self.blocks:\n blocks.append(\n [\n t.remove_column(t.column_names.index(name), *args, **kwargs) if name in t.column_names else t\n for t in tables\n ]\n )\n return ConcatenationTable(table, blocks)\n",299 "url": "https://github.com/huggingface/datasets.git",300 "language": "Python",301 "ast_errors": "",302 "n_ast_errors": 0,303 "ast_levels": 16,304 "n_whitespaces": 172,305 "n_words": 40,306 "vocab_size": 29,307 "complexity": 4,308 "nloc": 12,309 "token_counts": 96,310 "n_ast_nodes": 145,311 "n_identifiers": 14,312 "random_cut": "def remove_column(self, i, *args, **kwargs):\n \n table = self.table.remove_column(i, *args, **kwargs)\n name = self.table.column_names[i]\n blocks = []\n for tables in self.blocks:\n blocks.append(\n [\n t.remove_colu",313 "d_id": 21852,314 "documentation": {315 "docstring": "\n Create new Table with the indicated column removed.\n\n Args:\n i (:obj:`int`):\n Index of column to remove.\n\n Returns:\n :class:`datasets.table.Table`:\n New table without the column.\n ",316 "n_words": 23,317 "vocab_size": 21,318 "n_whitespaces": 104,319 "language": "en"320 }321 },322 {323 "id": 264886,324 "commit_id": "3a461d02793e6f9d41c2b1a92647e691de1abaac",325 "repo": "netbox",326 "path": "netbox/dcim/tests/test_models.py",327 "file_name": "test_models.py",328 "fun_name": "test_cable_cannot_terminate_to_a_wireless_interface",329 "commit_message": "Update Cable instantiations to match new signature",330 "code": "def test_cable_cannot_terminate_to_a_wireless_interface(self):\n \n wireless_interface = Interface(device=self.device1, name=\"W1\", type=InterfaceTypeChoices.TYPE_80211A)\n cable = Cable(a_terminations=[self.interface2], b_terminations=[wireless_interface])\n with self.assertRaises(ValidationError):\n cable.clean()\n",331 "url": "https://github.com/netbox-community/netbox.git",332 "language": "Python",333 "ast_errors": "",334 "n_ast_errors": 0,335 "ast_levels": 11,336 "n_whitespaces": 53,337 "n_words": 14,338 "vocab_size": 13,339 "complexity": 1,340 "nloc": 5,341 "token_counts": 57,342 "n_ast_nodes": 95,343 "n_identifiers": 18,344 "random_cut": "def test_cable_cannot_terminate_to_a_wireless_interface(self):\n \n wireless_interface = Interface(device=self.device1, name=\"W1\", type=InterfaceTypeChoices.TYPE_80211A)\n cable = Cable(a_terminations=[self.interface2], b_terminations=[wireless_interface])\n with self.assertRaises(ValidationError):\n cable.clean()\n",345 "d_id": 77897,346 "documentation": {347 "docstring": "\n A cable cannot terminate to a wireless interface\n ",348 "n_words": 8,349 "vocab_size": 8,350 "n_whitespaces": 23,351 "language": "en"352 }353 },354 {355 "id": 204838,356 "commit_id": "9c19aff7c7561e3a82978a272ecdaad40dda5c00",357 "repo": "django",358 "path": "django/db/backends/base/creation.py",359 "file_name": "creation.py",360 "fun_name": "get_test_db_clone_settings",361 "commit_message": "Refs #33476 -- Reformatted code with Black.",362 "code": "def get_test_db_clone_settings(self, suffix):\n \n # When this function is called, the test database has been created\n # already and its name has been copied to settings_dict['NAME'] so\n # we don't need to call _get_test_db_name.\n orig_settings_dict = self.connection.settings_dict\n return {\n **orig_settings_dict,\n \"NAME\": \"{}_{}\".format(orig_settings_dict[\"NAME\"], suffix),\n }\n",363 "url": "https://github.com/django/django.git",364 "language": "Python",365 "ast_errors": "",366 "n_ast_errors": 0,367 "ast_levels": 11,368 "n_whitespaces": 114,369 "n_words": 43,370 "vocab_size": 38,371 "complexity": 1,372 "nloc": 6,373 "token_counts": 35,374 "n_ast_nodes": 63,375 "n_identifiers": 7,376 "random_cut": "def get_test_db_clone_settings(self, suffix):\n \n # When this function is called, the test database has been created\n # already and its name has been copied to",377 "d_id": 50917,378 "documentation": {379 "docstring": "\n Return a modified connection settings dict for the n-th clone of a DB.\n ",380 "n_words": 13,381 "vocab_size": 12,382 "n_whitespaces": 28,383 "language": "en"384 }385 },386 {387 "id": 217907,388 "commit_id": "8198943edd73a363c266633e1aa5b2a9e9c9f526",389 "repo": "XX-Net",390 "path": "python3.10.4/Lib/imaplib.py",391 "file_name": "imaplib.py",392 "fun_name": "open",393 "commit_message": "add python 3.10.4 for windows",394 "code": "def open(self, host='', port=IMAP4_PORT, timeout=None):\n \n self.host = host\n self.port = port\n self.sock = self._create_socket(timeout)\n self.file = self.sock.makefile('rb')\n\n",395 "url": "https://github.com/XX-net/XX-Net.git",396 "language": "Python",397 "ast_errors": "",398 "n_ast_errors": 0,399 "ast_levels": 9,400 "n_whitespaces": 52,401 "n_words": 17,402 "vocab_size": 14,403 "complexity": 1,404 "nloc": 5,405 "token_counts": 50,406 "n_ast_nodes": 83,407 "n_identifiers": 10,408 "random_cut": "def open(self, host='', port=IMAP4_PORT, timeout=None):\n \n self.host = host\n self.port = port\n self.sock = self._create_socket(timeout)\n self.file = self.sock.makefile('rb')\n\n",409 "d_id": 55005,410 "documentation": {411 "docstring": "Setup connection to remote server on \"host:port\"\n (default: localhost:standard IMAP4 port).\n This connection will be used by the routines:\n read, readline, send, shutdown.\n ",412 "n_words": 23,413 "vocab_size": 22,414 "n_whitespaces": 59,415 "language": "en"416 }417 },418 {419 "id": 183574,420 "commit_id": "7f27e70440c177b2a047b7f74a78ed5cd5b4b596",421 "repo": "textual",422 "path": "src/textual/_terminal_features.py",423 "file_name": "_terminal_features.py",424 "fun_name": "synchronized_output_end_sequence",425 "commit_message": "[terminal buffering] Address PR feedback",426 "code": "def synchronized_output_end_sequence(self) -> str:\n \n if self.synchronised_output:\n return TERMINAL_MODES_ANSI_SEQUENCES[Mode.SynchronizedOutput][\"end_sync\"]\n return \"\"\n",427 "url": "https://github.com/Textualize/textual.git",428 "language": "Python",429 "ast_errors": "",430 "n_ast_errors": 0,431 "ast_levels": 10,432 "n_whitespaces": 42,433 "n_words": 10,434 "vocab_size": 9,435 "complexity": 2,436 "nloc": 13,437 "token_counts": 25,438 "n_ast_nodes": 45,439 "n_identifiers": 7,440 "random_cut": "def synchronized_output_end_sequence(self) -> str:\n \n if self.synchronised_output:\n return",441 "d_id": 44257,442 "documentation": {443 "docstring": "\n Returns the ANSI sequence that we should send to the terminal to tell it that\n it should stop buffering the content we're about to send.\n If the terminal doesn't seem to support synchronised updates the string will be empty.\n\n Returns:\n str: the \"synchronised output stop\" ANSI sequence. It will be ab empty string\n if the terminal emulator doesn't seem to support the \"synchronised updates\" mode.\n ",444 "n_words": 65,445 "vocab_size": 41,446 "n_whitespaces": 127,447 "language": "en"448 }449 },450 {451 "id": 162681,452 "commit_id": "f6021faf2a8e62f88a8d6979ce812dcb71133a8f",453 "repo": "AutoEq",454 "path": "frequency_response.py",455 "file_name": "frequency_response.py",456 "fun_name": "_band_penalty_coefficients",457 "commit_message": "Improved quality regularization to a point where it works well. 10 kHz to 20 kHz is RMSE is calculated from the average levels. Split neo PEQ notebook by band and Q.",458 "code": "def _band_penalty_coefficients(self, fc, q, gain, filter_frs):\n \n ref_frs = biquad.digital_coeffs(self.frequency, 192e3, *biquad.peaking(fc, q, gain, fs=192e3))\n est_sums = np.sum(filter_frs, axis=1)\n ref_sums = np.sum(ref_frs, axis=1)\n penalties = np.zeros((len(fc),))\n mask = np.squeeze(ref_sums) != 0.0\n penalties[mask] = est_sums[mask] / ref_sums[mask]\n return 10 * (1 - np.expand_dims(penalties, 1))\n",459 "url": "https://github.com/jaakkopasanen/AutoEq.git",460 "language": "Python",461 "ast_errors": "",462 "n_ast_errors": 0,463 "ast_levels": 12,464 "n_whitespaces": 98,465 "n_words": 42,466 "vocab_size": 34,467 "complexity": 1,468 "nloc": 8,469 "token_counts": 121,470 "n_ast_nodes": 176,471 "n_identifiers": 23,472 "random_cut": "def _band_penalty_coefficients(self, fc, q, gain, filter_frs):\n \n ref_frs = biquad.digital_coeffs(self.frequenc",473 "d_id": 39253,474 "documentation": {475 "docstring": "Calculates penalty coefficients for filters if their transition bands extend beyond Nyquist frequency\n\n The calculation is based on ratio of frequency response integrals between 44.1 kHz and 192 kHz\n\n Args:\n fc: Filter center frequencies, 1-D array\n q: Filter qualities, 1-D array\n gain: Filter gains, 1-D array\n filter_frs: Filter frequency responses, 2-D array, one fr per row\n\n Returns:\n Column array of penalty coefficients, one per filter\n ",476 "n_words": 65,477 "vocab_size": 50,478 "n_whitespaces": 148,479 "language": "en"480 }481 },482 {483 "id": 261153,484 "commit_id": "02b04cb3ecfc5fce1f627281c312753f3b4b8494",485 "repo": "scikit-learn",486 "path": "sklearn/ensemble/tests/test_voting.py",487 "file_name": "test_voting.py",488 "fun_name": "test_predict_on_toy_problem",489 "commit_message": "TST use global_random_seed in sklearn/ensemble/tests/test_voting.py (#24282)\n\nCo-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>",490 "code": "def test_predict_on_toy_problem(global_random_seed):\n \n clf1 = LogisticRegression(random_state=global_random_seed)\n clf2 = RandomForestClassifier(n_estimators=10, random_state=global_random_seed)\n clf3 = GaussianNB()\n\n X = np.array(\n [[-1.1, -1.5], [-1.2, -1.4], [-3.4, -2.2], [1.1, 1.2], [2.1, 1.4], [3.1, 2.3]]\n )\n\n y = np.array([1, 1, 1, 2, 2, 2])\n\n assert_array_equal(clf1.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n assert_array_equal(clf2.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n assert_array_equal(clf3.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n\n eclf = VotingClassifier(\n estimators=[(\"lr\", clf1), (\"rf\", clf2), (\"gnb\", clf3)],\n voting=\"hard\",\n weights=[1, 1, 1],\n )\n assert_array_equal(eclf.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n\n eclf = VotingClassifier(\n estimators=[(\"lr\", clf1), (\"rf\", clf2), (\"gnb\", clf3)],\n voting=\"soft\",\n weights=[1, 1, 1],\n )\n assert_array_equal(eclf.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n\n",491 "url": "https://github.com/scikit-learn/scikit-learn.git",492 "language": "Python",493 "ast_errors": "",494 "n_ast_errors": 0,495 "ast_levels": 12,496 "n_whitespaces": 201,497 "n_words": 104,498 "vocab_size": 48,499 "complexity": 1,500 "nloc": 23,501 "token_counts": 357,502 "n_ast_nodes": 469,503 "n_identifiers": 22,504 "random_cut": "def test_predict_on_toy_problem(global_random_seed):\n \n clf1 = LogisticRegression(random_state=global_random_seed)\n clf2 = RandomForestClassifier(n_estimators=10, random_state=global_random_seed)\n clf3 = GaussianNB()\n\n X = np.array(\n [[-1.1, -1.5], [-1.2, -1.4], [-3.4, -2.2], [1.1, 1.2], [2.1, 1.4], [3.1, 2.3]]\n )\n\n y = np.array([1, 1, 1, 2, 2, 2])\n\n assert_array_equal(clf1.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n assert_array_equal(clf2.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n assert_array_equal(clf3.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n\n eclf = VotingClassifier(\n estimators=[(\"lr\", clf1), (\"rf\", clf2), (\"gnb\", clf3)],\n voting=\"hard\",\n weights=[1, 1, 1],\n )\n assert_array_equal(eclf.fit(X, y).predict(X), [1, 1, 1, 2, 2, 2])\n\n eclf = VotingClassifier(\n estimators=[(\"lr\", clf1), (\"rf\", clf2), (\"gnb\", clf3)],\n voting=\"soft\",\n weights=[1, 1, 1],\n )\n assert_array",505 "d_id": 76664,506 "documentation": {507 "docstring": "Manually check predicted class labels for toy dataset.",508 "n_words": 8,509 "vocab_size": 8,510 "n_whitespaces": 7,511 "language": "en"512 }513 },514 {515 "id": 260448,516 "commit_id": "5a850eb044ca07f1f3bcb1b284116d6f2d37df1b",517 "repo": "scikit-learn",518 "path": "sklearn/feature_extraction/_dict_vectorizer.py",519 "file_name": "_dict_vectorizer.py",520 "fun_name": "fit_transform",521 "commit_message": "MAINT Param validation for Dictvectorizer (#23820)",522 "code": "def fit_transform(self, X, y=None):\n \n self._validate_params()\n return self._transform(X, fitting=True)\n",523 "url": "https://github.com/scikit-learn/scikit-learn.git",524 "language": "Python",525 "ast_errors": "",526 "n_ast_errors": 0,527 "ast_levels": 8,528 "n_whitespaces": 29,529 "n_words": 8,530 "vocab_size": 8,531 "complexity": 1,532 "nloc": 3,533 "token_counts": 28,534 "n_ast_nodes": 45,535 "n_identifiers": 7,536 "random_cut": "def fit_transform(self, X, y=None):\n \n self._validate_params()\n return self._tran",537 "d_id": 76257,538 "documentation": {539 "docstring": "Learn a list of feature name -> indices mappings and transform X.\n\n Like fit(X) followed by transform(X), but does not require\n materializing X in memory.\n\n Parameters\n ----------\n X : Mapping or iterable over Mappings\n Dict(s) or Mapping(s) from feature names (arbitrary Python\n objects) to feature values (strings or convertible to dtype).\n\n .. versionchanged:: 0.24\n Accepts multiple string values for one categorical feature.\n\n y : (ignored)\n Ignored parameter.\n\n Returns\n -------\n Xa : {array, sparse matrix}\n Feature vectors; always 2-d.\n ",540 "n_words": 78,541 "vocab_size": 69,542 "n_whitespaces": 217,543 "language": "en"544 }545 },546 {547 "id": 321150,548 "commit_id": "0877fb0d78635692e481c8bde224fac5ad0dd430",549 "repo": "qutebrowser",550 "path": "qutebrowser/browser/webengine/webenginetab.py",551 "file_name": "webenginetab.py",552 "fun_name": "_on_feature_permission_requested",553 "commit_message": "Run scripts/dev/rewrite_enums.py",554 "code": "def _on_feature_permission_requested(self, url, feature):\n \n page = self._widget.page()\n grant_permission = functools.partial(\n page.setFeaturePermission, url, feature,\n QWebEnginePage.PermissionPolicy.PermissionGrantedByUser)\n deny_permission = functools.partial(\n page.setFeaturePermission, url, feature,\n QWebEnginePage.PermissionPolicy.PermissionDeniedByUser)\n\n permission_str = debug.qenum_key(QWebEnginePage, feature)\n\n if not url.isValid():\n # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-85116\n is_qtbug = (qtutils.version_check('5.15.0',\n compiled=False,\n exact=True) and\n self._tab.is_private and\n feature == QWebEnginePage.Feature.Notifications)\n logger = log.webview.debug if is_qtbug else log.webview.warning\n logger(\"Ignoring feature permission {} for invalid URL {}\".format(\n permission_str, url))\n deny_permission()\n return\n\n if feature not in self._options:\n log.webview.error(\"Unhandled feature permission {}\".format(\n permission_str))\n deny_permission()\n return\n\n if (\n feature in [QWebEnginePage.Feature.DesktopVideoCapture,\n QWebEnginePage.Feature.DesktopAudioVideoCapture] and\n qtutils.version_check('5.13', compiled=False) and\n not qtutils.version_check('5.13.2', compiled=False)\n ):\n # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-78016\n log.webview.warning(\"Ignoring desktop sharing request due to \"\n \"crashes in Qt < 5.13.2\")\n deny_permission()\n return\n\n question = shared.feature_permission(\n url=url.adjusted(QUrl.UrlFormattingOption.RemovePath),\n option=self._options[feature], msg=self._messages[feature],\n yes_action=grant_permission, no_action=deny_permission,\n abort_on=[self._tab.abort_questions])\n\n if question is not None:\n page.featurePermissionRequestCanceled.connect(\n functools.partial(self._on_feature_permission_cancelled,\n question, url, feature))\n",555 "url": "https://github.com/qutebrowser/qutebrowser.git",556 "language": "Python",557 "ast_errors": "",558 "n_ast_errors": 0,559 "ast_levels": 14,560 "n_whitespaces": 761,561 "n_words": 125,562 "vocab_size": 84,563 "complexity": 10,564 "nloc": 44,565 "token_counts": 301,566 "n_ast_nodes": 470,567 "n_identifiers": 54,568 "random_cut": "def _on_feature_permission_requested(self, url, feature):\n \n page = self._widget.page()\n grant_permission = functools.partial(\n page.setFeaturePermission, url, feature,\n QWebEnginePage.PermissionPolicy.PermissionGrantedByUser)\n deny_permission = functools.partial(\n page.setFeaturePermission, url, feature,\n QWebEnginePage.PermissionPolicy.PermissionDeniedByUser)\n\n permission_str = debug.qenum_key(QWebEnginePage, feature)\n\n if not url.isValid():\n # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-85116\n is_qtbug = (qtutils.version_check('5.15.0',\n compiled=False,\n exact=True) and\n self._tab.is_private and\n feature == QWebEnginePage.Feature.Notifications)\n logger = log.webview.debug if is_qtbug else log.webview.warning\n logger(\"Ignoring feature permission {} for invalid URL {}\".format(\n permission_str, url))\n deny_permission()\n return\n\n if feature not in self._options:\n log.webview.error(\"Unhandled feature permission {}\".format(\n permission_str))\n deny_permission()\n return\n\n if (\n feature in [QWebEnginePage.Feature.DesktopVideoCapture,\n QWebEnginePage.Feature.DesktopAudioVideoCapture] and\n qtutils.version_check('5.13', compiled=",569 "d_id": 117565,570 "documentation": {571 "docstring": "Ask the user for approval for geolocation/media/etc..",572 "n_words": 7,573 "vocab_size": 6,574 "n_whitespaces": 6,575 "language": "en"576 }577 },578 {579 "id": 222643,580 "commit_id": "8198943edd73a363c266633e1aa5b2a9e9c9f526",581 "repo": "XX-Net",582 "path": "python3.10.4/Lib/distutils/command/bdist_msi.py",583 "file_name": "bdist_msi.py",584 "fun_name": "add_find_python",585 "commit_message": "add python 3.10.4 for windows",586 "code": "def add_find_python(self):\n \n\n start = 402\n for ver in self.versions:\n install_path = r\"SOFTWARE\\Python\\PythonCore\\%s\\InstallPath\" % ver\n machine_reg = \"python.machine.\" + ver\n user_reg = \"python.user.\" + ver\n machine_prop = \"PYTHON.MACHINE.\" + ver\n user_prop = \"PYTHON.USER.\" + ver\n machine_action = \"PythonFromMachine\" + ver\n user_action = \"PythonFromUser\" + ver\n exe_action = \"PythonExe\" + ver\n target_dir_prop = \"TARGETDIR\" + ver\n exe_prop = \"PYTHON\" + ver\n if msilib.Win64:\n # type: msidbLocatorTypeRawValue + msidbLocatorType64bit\n Type = 2+16\n else:\n Type = 2\n add_data(self.db, \"RegLocator\",\n [(machine_reg, 2, install_path, None, Type),\n (user_reg, 1, install_path, None, Type)])\n add_data(self.db, \"AppSearch\",\n [(machine_prop, machine_reg),\n (user_prop, user_reg)])\n add_data(self.db, \"CustomAction\",\n [(machine_action, 51+256, target_dir_prop, \"[\" + machine_prop + \"]\"),\n (user_action, 51+256, target_dir_prop, \"[\" + user_prop + \"]\"),\n (exe_action, 51+256, exe_prop, \"[\" + target_dir_prop + \"]\\\\python.exe\"),\n ])\n add_data(self.db, \"InstallExecuteSequence\",\n [(machine_action, machine_prop, start),\n (user_action, user_prop, start + 1),\n (exe_action, None, start + 2),\n ])\n add_data(self.db, \"InstallUISequence\",\n [(machine_action, machine_prop, start),\n (user_action, user_prop, start + 1),\n (exe_action, None, start + 2),\n ])\n add_data(self.db, \"Condition\",\n [(\"Python\" + ver, 0, \"NOT TARGETDIR\" + ver)])\n start += 4\n assert start < 500\n",587 "url": "https://github.com/XX-net/XX-Net.git",588 "language": "Python",589 "ast_errors": "",590 "n_ast_errors": 0,591 "ast_levels": 14,592 "n_whitespaces": 784,593 "n_words": 167,594 "vocab_size": 86,595 "complexity": 3,596 "nloc": 42,597 "token_counts": 304,598 "n_ast_nodes": 469,599 "n_identifiers": 20,600 "random_cut": "def add_find_python(self):\n \n\n start = 402\n for ver in self.versions:\n install_path = r\"SOFTWARE\\Python\\PythonCore\\%s\\InstallPath\" % ver\n machine_reg = \"python.machine.\" + ver\n user_reg = \"python.user.\" + ver\n machine_prop = \"PYTHON.MACHINE.\" + ver\n user_prop = \"PYTHON.USER.\" + ver\n machine_action = \"Pyth",601 "d_id": 56684,602 "documentation": {603 "docstring": "Adds code to the installer to compute the location of Python.\n\n Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the\n registry for each version of Python.\n\n Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,\n else from PYTHON.MACHINE.X.Y.\n\n Properties PYTHONX.Y will be set to TARGETDIRX.Y\\\\python.exe",604 "n_words": 45,605 "vocab_size": 28,606 "n_whitespaces": 79,607 "language": "en"608 }609 },610 {611 "id": 61961,612 "commit_id": "f638f5d0e6c8ebed0e69a6584bc7f003ec646580",613 "repo": "transferlearning",614 "path": ".venv/lib/python3.8/site-packages/pip/_vendor/distlib/database.py",615 "file_name": "database.py",616 "fun_name": "write_exports",617 "commit_message": "upd; format",618 "code": "def write_exports(self, exports):\n \n rf = self.get_distinfo_file(EXPORTS_FILENAME)\n with open(rf, 'w') as f:\n write_exports(exports, f)\n",619 "url": "https://github.com/jindongwang/transferlearning.git",620 "language": "Python",621 "ast_errors": "",622 "n_ast_errors": 0,623 "ast_levels": 11,624 "n_whitespaces": 45,625 "n_words": 13,626 "vocab_size": 13,627 "complexity": 1,628 "nloc": 4,629 "token_counts": 32,630 "n_ast_nodes": 57,631 "n_identifiers": 8,632 "random_cut": "def write_exports(self, exports):\n \n rf = self",633 "d_id": 12781,634 "documentation": {635 "docstring": "\n Write a dictionary of exports to a file in .ini format.\n :param exports: A dictionary of exports, mapping an export category to\n a list of :class:`ExportEntry` instances describing the\n individual export entries.\n ",636 "n_words": 32,637 "vocab_size": 25,638 "n_whitespaces": 100,639 "language": "en"640 }641 },642 {643 "id": 267337,644 "commit_id": "621e782ed0c119d2c84124d006fdf253c082449a",645 "repo": "ansible",646 "path": "lib/ansible/executor/task_executor.py",647 "file_name": "task_executor.py",648 "fun_name": "_get_action_handler_with_module_context",649 "commit_message": "Add toggle to fix module_defaults with module-as-redirected-action on a per-module basis (#77265)\n\n* If there is a platform specific handler, prefer the resolved module over the resolved action when loading module_defaults\r\n\r\nAdd a toggle for action plugins to prefer the resolved module when loading module_defaults\r\n\r\nAllow moving away from modules intercepted as actions pattern\r\n\r\nFixes #77059",650 "code": "def _get_action_handler_with_module_context(self, connection, templar):\n \n module_collection, separator, module_name = self._task.action.rpartition(\".\")\n module_prefix = module_name.split('_')[0]\n if module_collection:\n # For network modules, which look for one action plugin per platform, look for the\n # action plugin in the same collection as the module by prefixing the action plugin\n # with the same collection.\n network_action = \"{0}.{1}\".format(module_collection, module_prefix)\n else:\n network_action = module_prefix\n\n collections = self._task.collections\n\n # Check if the module has specified an action handler\n module = self._shared_loader_obj.module_loader.find_plugin_with_context(\n self._task.action, collection_list=collections\n )\n if not module.resolved or not module.action_plugin:\n module = None\n if module is not None:\n handler_name = module.action_plugin\n # let action plugin override module, fallback to 'normal' action plugin otherwise\n elif self._shared_loader_obj.action_loader.has_plugin(self._task.action, collection_list=collections):\n handler_name = self._task.action\n elif all((module_prefix in C.NETWORK_GROUP_MODULES, self._shared_loader_obj.action_loader.has_plugin(network_action, collection_list=collections))):\n handler_name = network_action\n display.vvvv(\"Using network group action {handler} for {action}\".format(handler=handler_name,\n action=self._task.action),\n host=self._play_context.remote_addr)\n else:\n # use ansible.legacy.normal to allow (historic) local action_plugins/ override without collections search\n handler_name = 'ansible.legacy.normal'\n collections = None # until then, we don't want the task's collection list to be consulted; use the builtin\n\n handler = self._shared_loader_obj.action_loader.get(\n handler_name,\n task=self._task,\n connection=connection,\n play_context=self._play_context,\n loader=self._loader,\n templar=templar,\n shared_loader_obj=self._shared_loader_obj,\n collection_list=collections\n )\n\n if not handler:\n raise AnsibleError(\"the handler '%s' was not found\" % handler_name)\n\n return handler, module\n\n",651 "url": "https://github.com/ansible/ansible.git",652 "language": "Python",653 "ast_errors": "",654 "n_ast_errors": 0,655 "ast_levels": 15,656 "n_whitespaces": 685,657 "n_words": 191,658 "vocab_size": 117,659 "complexity": 8,660 "nloc": 38,661 "token_counts": 264,662 "n_ast_nodes": 420,663 "n_identifiers": 41,664 "random_cut": "def _get_action_handler_with_module_context(self, connection, templar):\n \n module_collection, separator, module_name = self._task.action.rpartition(\".\")\n module_prefix = module_name.split('_')[0]\n if module_collection:\n # For network modules, which look for one action plugin per platform, look for the\n # action plugin in the same collection as the module by prefixing the action plugin\n # with the same collecti",665 "d_id": 78856,666 "documentation": {667 "docstring": "\n Returns the correct action plugin to handle the requestion task action and the module context\n ",668 "n_words": 15,669 "vocab_size": 12,670 "n_whitespaces": 30,671 "language": "en"672 }673 },674 {675 "id": 262500,676 "commit_id": "c17ff17a18f21be60c6916714ac8afd87d4441df",677 "repo": "TTS",678 "path": "TTS/tts/layers/losses.py",679 "file_name": "losses.py",680 "fun_name": "forward",681 "commit_message": "Fix SSIM loss",682 "code": "def forward(self, y_hat, y, length):\n \n mask = sequence_mask(sequence_length=length, max_len=y.size(1)).unsqueeze(2)\n y_norm = sample_wise_min_max(y, mask)\n y_hat_norm = sample_wise_min_max(y_hat, mask)\n ssim_loss = self.loss_func((y_norm * mask).unsqueeze(1), (y_hat_norm * mask).unsqueeze(1))\n\n if ssim_loss.item() > 1.0:\n print(f\" > SSIM loss is out-of-range {ssim_loss.item()}, setting it 1.0\")\n ssim_loss == 1.0\n\n if ssim_loss.item() < 0.0:\n print(f\" > SSIM loss is out-of-range {ssim_loss.item()}, setting it 0.0\")\n ssim_loss == 0.0\n\n return ssim_loss\n\n",683 "url": "https://github.com/coqui-ai/TTS.git",684 "language": "Python",685 "ast_errors": "",686 "n_ast_errors": 0,687 "ast_levels": 13,688 "n_whitespaces": 161,689 "n_words": 61,690 "vocab_size": 40,691 "complexity": 3,692 "nloc": 12,693 "token_counts": 122,694 "n_ast_nodes": 203,695 "n_identifiers": 18,696 "random_cut": "def forward(self, y_hat, y, length):\n \n mask = sequence_mask(sequence_length=length, max_len=y.size(1)).unsqueeze(2)\n y_norm = sample_wise_min_max(y, mask)\n y_hat_norm = sample_wise_min_max(y_hat, mask)\n ssim_loss = self.loss_func((y_norm * mask).unsqueeze(1), (y_hat_norm * mask).unsqueeze(1))\n\n if ssim_loss.item() > 1.0:\n print(f\" > SSIM loss is out-of-range {ssim_loss.item()}, setting it 1.0\")\n ssim_loss == 1.0\n\n if ssim_loss.item() < 0.0:\n print(f\" > SSIM loss is out-of-range {ssim_loss.item()}, setting it 0.0\")\n",697 "d_id": 77241,698 "documentation": {699 "docstring": "\n Args:\n y_hat (tensor): model prediction values.\n y (tensor): target values.\n length (tensor): length of each sample in a batch for masking.\n\n Shapes:\n y_hat: B x T X D\n y: B x T x D\n length: B\n\n Returns:\n loss: An average loss value in range [0, 1] masked by the length.\n ",700 "n_words": 50,701 "vocab_size": 39,702 "n_whitespaces": 157,703 "language": "en"704 }705 },706 {707 "id": 202989,708 "commit_id": "7346c288e307e1821e3ceb757d686c9bd879389c",709 "repo": "django",710 "path": "django/core/management/__init__.py",711 "file_name": "__init__.py",712 "fun_name": "get_commands",713 "commit_message": "Refs #32355 -- Removed unnecessary list() calls before reversed() on dictviews.\n\nDict and dictviews are iterable in reversed insertion order using\r\nreversed() in Python 3.8+.",714 "code": "def get_commands():\n \n commands = {name: 'django.core' for name in find_commands(__path__[0])}\n\n if not settings.configured:\n return commands\n\n for app_config in reversed(apps.get_app_configs()):\n path = os.path.join(app_config.path, 'management')\n commands.update({name: app_config.name for name in find_commands(path)})\n\n return commands\n\n",715 "url": "https://github.com/django/django.git",716 "language": "Python",717 "ast_errors": "",718 "n_ast_errors": 0,719 "ast_levels": 13,720 "n_whitespaces": 67,721 "n_words": 31,722 "vocab_size": 22,723 "complexity": 5,724 "nloc": 8,725 "token_counts": 77,726 "n_ast_nodes": 126,727 "n_identifiers": 15,728 "random_cut": "def get_commands():\n \n commands = {name: 'django.core' for name in find_commands(__path__[0])}\n\n if not settings.configured:\n return commands\n\n for app_config in reversed(apps.get_app_configs()):\n path = os.path.join(app_config.path, 'management')\n commands.update({n",729 "d_id": 50200,730 "documentation": {731 "docstring": "\n Return a dictionary mapping command names to their callback applications.\n\n Look for a management.commands package in django.core, and in each\n installed application -- if a commands package exists, register all\n commands in that package.\n\n Core commands are always included. If a settings module has been\n specified, also include user-defined commands.\n\n The dictionary is in the format {command_name: app_name}. Key-value\n pairs from this dictionary can then be used in calls to\n load_command_class(app_name, command_name)\n\n If a specific version of a command must be loaded (e.g., with the\n startapp command), the instantiated module can be placed in the\n dictionary in place of the application name.\n\n The dictionary is cached on the first call and reused on subsequent\n calls.\n ",732 "n_words": 115,733 "vocab_size": 79,734 "n_whitespaces": 161,735 "language": "en"736 }737 },738 {739 "id": 223611,740 "commit_id": "8198943edd73a363c266633e1aa5b2a9e9c9f526",741 "repo": "XX-Net",742 "path": "python3.10.4/Lib/email/_parseaddr.py",743 "file_name": "_parseaddr.py",744 "fun_name": "getphraselist",745 "commit_message": "add python 3.10.4 for windows",746 "code": "def getphraselist(self):\n \n plist = []\n\n while self.pos < len(self.field):\n if self.field[self.pos] in self.FWS:\n self.pos += 1\n elif self.field[self.pos] == '\"':\n plist.append(self.getquote())\n elif self.field[self.pos] == '(':\n self.commentlist.append(self.getcomment())\n elif self.field[self.pos] in self.phraseends:\n break\n else:\n plist.append(self.getatom(self.phraseends))\n\n return plist\n",747 "url": "https://github.com/XX-net/XX-Net.git",748 "language": "Python",749 "ast_errors": "",750 "n_ast_errors": 0,751 "ast_levels": 15,752 "n_whitespaces": 193,753 "n_words": 35,754 "vocab_size": 26,755 "complexity": 6,756 "nloc": 14,757 "token_counts": 119,758 "n_ast_nodes": 196,759 "n_identifiers": 13,760 "random_cut": "def getphraselist(self):\n \n plist = []\n\n while self.pos < len(self.field):\n if self.field[self.pos] in self.FWS:\n self.pos += 1\n elif self.field[self.pos] == '\"':\n plist.append(self.getquote())\n elif self.field[self.pos] == '(':\n s",761 "d_id": 57004,762 "documentation": {763 "docstring": "Parse a sequence of RFC 2822 phrases.\n\n A phrase is a sequence of words, which are in turn either RFC 2822\n atoms or quoted-strings. Phrases are canonicalized by squeezing all\n runs of continuous whitespace into one space.\n ",764 "n_words": 37,765 "vocab_size": 30,766 "n_whitespaces": 66,767 "language": "en"768 }769 },770 {771 "id": 109724,772 "commit_id": "8387676bc049d7b3e071846730c632e6ced137ed",773 "repo": "matplotlib",774 "path": "lib/matplotlib/axes/_secondary_axes.py",775 "file_name": "_secondary_axes.py",776 "fun_name": "set_location",777 "commit_message": "Clean up code in SecondaryAxis",778 "code": "def set_location(self, location):\n \n\n # This puts the rectangle into figure-relative coordinates.\n if isinstance(location, str):\n _api.check_in_list(self._locstrings, location=location)\n self._pos = 1. if location in ('top', 'right') else 0.\n elif isinstance(location, numbers.Real):\n self._pos = location\n else:\n raise ValueError(\n f\"location must be {self._locstrings[0]!r}, \"\n f\"{self._locstrings[1]!r}, or a float, not {location!r}\")\n\n self._loc = location\n\n if self._orientation == 'x':\n # An x-secondary axes is like an inset axes from x = 0 to x = 1 and\n # from y = pos to y = pos + eps, in the parent's transAxes coords.\n bounds = [0, self._pos, 1., 1e-10]\n else: # 'y'\n bounds = [self._pos, 0, 1e-10, 1]\n\n # this locator lets the axes move in the parent axes coordinates.\n # so it never needs to know where the parent is explicitly in\n # figure coordinates.\n # it gets called in ax.apply_aspect() (of all places)\n self.set_axes_locator(\n _TransformedBoundsLocator(bounds, self._parent.transAxes))\n",779 "url": "https://github.com/matplotlib/matplotlib.git",780 "language": "Python",781 "ast_errors": "",782 "n_ast_errors": 0,783 "ast_levels": 15,784 "n_whitespaces": 363,785 "n_words": 142,786 "vocab_size": 97,787 "complexity": 5,788 "nloc": 17,789 "token_counts": 130,790 "n_ast_nodes": 230,791 "n_identifiers": 19,792 "random_cut": "def set_location(self, location):\n \n\n # This puts the rectangle ",793 "d_id": 23720,794 "documentation": {795 "docstring": "\n Set the vertical or horizontal location of the axes in\n parent-normalized coordinates.\n\n Parameters\n ----------\n location : {'top', 'bottom', 'left', 'right'} or float\n The position to put the secondary axis. Strings can be 'top' or\n 'bottom' for orientation='x' and 'right' or 'left' for\n orientation='y'. A float indicates the relative position on the\n parent axes to put the new axes, 0.0 being the bottom (or left)\n and 1.0 being the top (or right).\n ",796 "n_words": 71,797 "vocab_size": 51,798 "n_whitespaces": 170,799 "language": "en"800 }801 },802 {803 "id": 153347,804 "commit_id": "e7cb2e82f8b9c7a68f82abdd3b6011d661230b7e",805 "repo": "modin",806 "path": "modin/core/execution/ray/implementations/pandas_on_ray/partitioning/partition.py",807 "file_name": "partition.py",808 "fun_name": "length",809 "commit_message": "REFACTOR-#4251: define public interfaces in `modin.core.execution.ray` module (#3868)\n\nSigned-off-by: Anatoly Myachev <anatoly.myachev@intel.com>",810 "code": "def length(self):\n \n if self._length_cache is None:\n if len(self.call_queue):\n self.drain_call_queue()\n else:\n self._length_cache, self._width_cache = _get_index_and_columns.remote(\n self.oid\n )\n if isinstance(self._length_cache, ObjectIDType):\n self._length_cache = ray.get(self._length_cache)\n return self._length_cache\n",811 "url": "https://github.com/modin-project/modin.git",812 "language": "Python",813 "ast_errors": "",814 "n_ast_errors": 0,815 "ast_levels": 14,816 "n_whitespaces": 149,817 "n_words": 24,818 "vocab_size": 19,819 "complexity": 4,820 "nloc": 11,821 "token_counts": 70,822 "n_ast_nodes": 115,823 "n_identifiers": 14,824 "random_cut": "def length(self):\n \n if self._length_cache is None:\n if len(self.call_queue):\n self.drain_call_queue()\n else:\n self._length_cache, self._width_cache = _get_index_and_columns.remote(\n self.oid\n ",825 "d_id": 35383,826 "documentation": {827 "docstring": "\n Get the length of the object wrapped by this partition.\n\n Returns\n -------\n int\n The length of the object.\n ",828 "n_words": 18,829 "vocab_size": 14,830 "n_whitespaces": 65,831 "language": "en"832 }833 },834 {835 "id": 195939,836 "commit_id": "0f6dde45a1c75b02c208323574bdb09b8536e3e4",837 "repo": "sympy",838 "path": "sympy/polys/densearith.py",839 "file_name": "densearith.py",840 "fun_name": "dmp_l2_norm_squared",841 "commit_message": "Add `l2_norm_squared` methods.",842 "code": "def dmp_l2_norm_squared(f, u, K):\n \n if not u:\n return dup_l2_norm_squared(f, K)\n\n v = u - 1\n\n return sum([ dmp_l2_norm_squared(c, v, K) for c in f ])\n\n",843 "url": "https://github.com/sympy/sympy.git",844 "language": "Python",845 "ast_errors": "",846 "n_ast_errors": 0,847 "ast_levels": 10,848 "n_whitespaces": 44,849 "n_words": 25,850 "vocab_size": 23,851 "complexity": 3,852 "nloc": 5,853 "token_counts": 44,854 "n_ast_nodes": 67,855 "n_identifiers": 8,856 "random_cut": "def dmp_l2_norm_squared(f, u, K):\n \n if not u:\n return dup_l2_norm_squared(f, K)\n\n v = u - 1\n\n return s",857 "d_id": 47480,858 "documentation": {859 "docstring": "\n Returns squared l2 norm of a polynomial in ``K[X]``.\n\n Examples\n ========\n\n >>> from sympy.polys import ring, ZZ\n >>> R, x,y = ring(\"x,y\", ZZ)\n\n >>> R.dmp_l2_norm_squared(2*x*y - x - 3)\n 14\n\n ",860 "n_words": 30,861 "vocab_size": 27,862 "n_whitespaces": 55,863 "language": "en"864 }865 },866 {867 "id": 266740,868 "commit_id": "a06fa496d3f837cca3c437ab6e9858525633d147",869 "repo": "ansible",870 "path": "test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py",871 "file_name": "__init__.py",872 "fun_name": "cloud_filter",873 "commit_message": "ansible-test - Code cleanup and refactoring. (#77169)\n\n* Remove unnecessary PyCharm ignores.\r\n* Ignore intentional undefined attribute usage.\r\n* Add missing type hints. Fix existing type hints.\r\n* Fix docstrings and comments.\r\n* Use function to register completion handler.\r\n* Pass strings to display functions.\r\n* Fix CompositeAction handling of dest argument.\r\n* Use consistent types in expressions/assignments.\r\n* Use custom function to keep linters happy.\r\n* Add missing raise for custom exception.\r\n* Clean up key/value type handling in cloud plugins.\r\n* Use dataclass instead of dict for results.\r\n* Add custom type_guard function to check lists.\r\n* Ignore return type that can't be checked (yet).\r\n* Avoid changing types on local variables.",874 "code": "def cloud_filter(args, targets): # type: (IntegrationConfig, t.Tuple[IntegrationTarget, ...]) -> t.List[str]\n \n if args.metadata.cloud_config is not None:\n return [] # cloud filter already performed prior to delegation\n\n exclude = [] # type: t.List[str]\n\n for provider in get_cloud_providers(args, targets):\n provider.filter(targets, exclude)\n\n return exclude\n\n",875 "url": "https://github.com/ansible/ansible.git",876 "language": "Python",877 "ast_errors": "",878 "n_ast_errors": 0,879 "ast_levels": 9,880 "n_whitespaces": 72,881 "n_words": 40,882 "vocab_size": 32,883 "complexity": 3,884 "nloc": 7,885 "token_counts": 45,886 "n_ast_nodes": 74,887 "n_identifiers": 9,888 "random_cut": "def cloud_filter(args, targets): # type: (IntegrationConfig, t.Tuple[IntegrationTarget, ...]) -> t.List[str]\n \n if args.metadata.cloud_config is not None:\n return [] # cloud filter already performed prior to delegation\n\n exclude = [] # type: t.List[str]\n\n for provider in get_cloud_providers(",889 "d_id": 78551,890 "documentation": {891 "docstring": "Return a list of target names to exclude based on the given targets.",892 "n_words": 13,893 "vocab_size": 13,894 "n_whitespaces": 12,895 "language": "en"896 }897 },898 {899 "id": 215087,900 "commit_id": "f1c37893caf90738288e789c3233ab934630254f",901 "repo": "salt",902 "path": "tests/pytests/unit/modules/test_aixpkg.py",903 "file_name": "test_aixpkg.py",904 "fun_name": "test_upgrade_available_none",905 "commit_message": "Working tests for install",906 "code": "def test_upgrade_available_none():\n \n\n chk_upgrade_out = (\n \"Last metadata expiration check: 22:5:48 ago on Mon Dec 6 19:26:36 EST 2021.\"\n )\n\n dnf_call = MagicMock(return_value={\"retcode\": 100, \"stdout\": chk_upgrade_out})\n version_mock = MagicMock(return_value=\"6.6-2\")\n with patch(\"pathlib.Path.is_file\", return_value=True):\n with patch.dict(\n aixpkg.__salt__,\n {\"cmd.run_all\": dnf_call, \"config.get\": MagicMock(return_value=False)},\n ), patch.object(aixpkg, \"version\", version_mock):\n result = aixpkg.upgrade_available(\"info\")\n assert dnf_call.call_count == 1\n libpath_env = {\"LIBPATH\": \"/opt/freeware/lib:/usr/lib\"}\n dnf_call.assert_any_call(\n \"/opt/freeware/bin/dnf check-update info\",\n env=libpath_env,\n ignore_retcode=True,\n python_shell=False,\n )\n assert not result\n\n",907 "url": "https://github.com/saltstack/salt.git",908 "language": "Python",909 "ast_errors": "",910 "n_ast_errors": 0,911 "ast_levels": 16,912 "n_whitespaces": 252,913 "n_words": 64,914 "vocab_size": 56,915 "complexity": 1,916 "nloc": 21,917 "token_counts": 124,918 "n_ast_nodes": 217,919 "n_identifiers": 19,920 "random_cut": "def test_upgrade_available_none():\n \n\n chk_upgrade_out = (\n \"Last metadata ex",921 "d_id": 53805,922 "documentation": {923 "docstring": "\n test upgrade available where a valid upgrade is not available\n ",924 "n_words": 10,925 "vocab_size": 8,926 "n_whitespaces": 17,927 "language": "en"928 }929 },930 {931 "id": 87293,932 "commit_id": "361b7f444a53cc34cad8ddc378d125b7027d96df",933 "repo": "sentry",934 "path": "tests/sentry/event_manager/test_event_manager.py",935 "file_name": "test_event_manager.py",936 "fun_name": "test_too_many_boosted_releases_do_not_boost_anymore",937 "commit_message": "feat(ds): Limit the amount of boosted releases to 10 (#40501)\n\nLimits amount of boosted releases to 10 releases\r\notherwise do not add any more releases to hash set of listed releases",938 "code": "def test_too_many_boosted_releases_do_not_boost_anymore(self):\n \n release_2 = Release.get_or_create(self.project, \"2.0\")\n release_3 = Release.get_or_create(self.project, \"3.0\")\n\n for release_id in (self.release.id, release_2.id):\n self.redis_client.set(f\"ds::p:{self.project.id}:r:{release_id}\", 1, 60 * 60 * 24)\n self.redis_client.hset(\n f\"ds::p:{self.project.id}:boosted_releases\",\n release_id,\n time(),\n )\n\n with self.options(\n {\n \"dynamic-sampling:boost-latest-release\": True,\n }\n ):\n self.make_release_transaction(\n release_version=release_3.version,\n environment_name=self.environment1.name,\n project_id=self.project.id,\n checksum=\"b\" * 32,\n timestamp=self.timestamp,\n )\n assert self.redis_client.hgetall(f\"ds::p:{self.project.id}:boosted_releases\") == {\n str(self.release.id): str(time()),\n str(release_2.id): str(time()),\n }\n assert self.redis_client.get(f\"ds::p:{self.project.id}:r:{release_3.id}\") is None\n\n",939 "url": "https://github.com/getsentry/sentry.git",940 "language": "Python",941 "ast_errors": "",942 "n_ast_errors": 0,943 "ast_levels": 14,944 "n_whitespaces": 373,945 "n_words": 56,946 "vocab_size": 46,947 "complexity": 2,948 "nloc": 27,949 "token_counts": 185,950 "n_ast_nodes": 342,951 "n_identifiers": 27,952 "random_cut": "def test_too_many_boosted_releases_do_not_boost_anymore(self):\n \n release_2 = Release.get_or_create(",953 "d_id": 18273,954 "documentation": {955 "docstring": "\n This test tests the case when we have already too many boosted releases, in this case we want to skip the\n boosting of anymore releases\n ",956 "n_words": 25,957 "vocab_size": 22,958 "n_whitespaces": 47,959 "language": "en"960 }961 },962 {963 "id": 176175,964 "commit_id": "5dfd57af2a141a013ae3753e160180b82bec9469",965 "repo": "networkx",966 "path": "networkx/algorithms/link_analysis/hits_alg.py",967 "file_name": "hits_alg.py",968 "fun_name": "hits",969 "commit_message": "Use scipy.sparse array datastructure (#5139)\n\n* Step 1: use sparse arrays in nx.to_scipy_sparse_matrix.\r\n\r\nSeems like a reasonable place to start.\r\nnx.to_scipy_sparse_matrix is one of the primary interfaces to\r\nscipy.sparse from within NetworkX.\r\n\r\n* 1: Use np.outer instead of mult col/row vectors\r\n\r\nFix two instances in modularitymatrix where a new 2D array was being\r\ncreated via an outer product of two \\\"vectors\\\".\r\n\r\nIn the matrix case, this was a row vector \\* a column vector. In the\r\narray case this can be disambiguated by being explicit with np.outer.\r\n\r\n* Update _transition_matrix in laplacianmatrix module\r\n\r\n - A few instances of matrix multiplication operator\r\n - Add np.newaxis + transpose to get shape right for broadcasting\r\n - Explicitly convert e.g. sp.sparse.spdiags to a csr_array.\r\n\r\n* Update directed_combinitorial_laplacian w/ sparse array.\r\n\r\n - Wrap spdiags in csr_array and update matmul operators.\r\n\r\n* Rm matrix-specific code from lgc and hmn modules\r\n\r\n - Replace .A call with appropriate array semantics\r\n - wrap sparse.diags in csr_array.\r\n\r\n* Change hits to use sparse array semantics.\r\n\r\n - Replace * with @\r\n - Remove superfluous calls to flatten.\r\n\r\n* Update sparse matrix usage in layout module.\r\n - Simplify lil.getrowview call\r\n - Wrap spdiags in csr_array.\r\n\r\n* lil_matrix -> lil_array in graphmatrix.py.\r\n\r\n* WIP: Start working on algebraic connectivity module.\r\n\r\n* Incorporate auth mat varname feedback.\r\n\r\n* Revert 1D slice and comment for 1D sparse future.\r\n\r\n* Add TODOs: rm csr_array wrapper around spdiags etc.\r\n\r\n* WIP: cleanup algebraicconn: tracemin_fiedler.\r\n\r\n* Typo.\r\n\r\n* Finish reviewing algebraicconnectivity.\r\n\r\n* Convert bethe_hessian matrix to use sparse arrays.\r\n\r\n* WIP: update laplacian.\r\n\r\nUpdate undirected laplacian functions.\r\n\r\n* WIP: laplacian - add comment about _transition_matrix return types.\r\n\r\n* Finish laplacianmatrix review.\r\n\r\n* Update attrmatrix.\r\n\r\n* Switch to official laplacian function.\r\n\r\n* Update pagerank to use sparse array.\r\n\r\n* Switch bipartite matrix to sparse arrays.\r\n\r\n* Check from_scipy_sparse_matrix works with arrays.\r\n\r\nModifies test suite.\r\n\r\n* Apply changes from review.\r\n\r\n* Fix failing docstring tests.\r\n\r\n* Fix missing axis for in-place multiplication.\r\n\r\n* Use scipy==1.8rc2\r\n\r\n* Use matrix multiplication\r\n\r\n* Fix PyPy CI\r\n\r\n* [MRG] Create plot_subgraphs.py example (#5165)\r\n\r\n* Create plot_subgraphs.py\r\n\r\nhttps://github.com/networkx/networkx/issues/4220\r\n\r\n* Update plot_subgraphs.py\r\n\r\nblack\r\n\r\n* Update plot_subgraphs.py\r\n\r\nlint plus font_size\r\n\r\n* Update plot_subgraphs.py\r\n\r\nadded more plots\r\n\r\n* Update plot_subgraphs.py\r\n\r\nremoved plots from the unit test and added comments\r\n\r\n* Update plot_subgraphs.py\r\n\r\nlint\r\n\r\n* Update plot_subgraphs.py\r\n\r\ntypos fixed\r\n\r\n* Update plot_subgraphs.py\r\n\r\nadded nodes to the plot of the edges removed that was commented out for whatever reason\r\n\r\n* Update plot_subgraphs.py\r\n\r\nrevert the latest commit - the line was commented out for a reason - it's broken\r\n\r\n* Update plot_subgraphs.py\r\n\r\nfixed node color issue\r\n\r\n* Update plot_subgraphs.py\r\n\r\nformat fix\r\n\r\n* Update plot_subgraphs.py\r\n\r\nforgot to draw the nodes... now fixed\r\n\r\n* Fix sphinx warnings about heading length.\r\n\r\n* Update examples/algorithms/plot_subgraphs.py\r\n\r\n* Update examples/algorithms/plot_subgraphs.py\r\n\r\nCo-authored-by: Ross Barnowski <rossbar@berkeley.edu>\r\nCo-authored-by: Dan Schult <dschult@colgate.edu>\r\n\r\n* Add traveling salesman problem to example gallery (#4874)\r\n\r\nAdds an example of the using Christofides to solve the TSP problem to the example galery.\r\n\r\nCo-authored-by: Ross Barnowski <rossbar@berkeley.edu>\r\n\r\n* Fixed inconsistent documentation for nbunch parameter in DiGraph.edges() (#5037)\r\n\r\n* Fixed inconsistent documentation for nbunch parameter in DiGraph.edges()\r\n\r\n* Resolved Requested Changes\r\n\r\n* Revert changes to degree docstrings.\r\n\r\n* Update comments in example.\r\n\r\n* Apply wording to edges method in all graph classes.\r\n\r\nCo-authored-by: Ross Barnowski <rossbar@berkeley.edu>\r\n\r\n* Compatibility updates from testing with numpy/scipy/pytest rc's (#5226)\r\n\r\n* Rm deprecated scipy subpkg access.\r\n\r\n* Use recwarn fixture in place of deprecated pytest pattern.\r\n\r\n* Rm unnecessary try/except from tests.\r\n\r\n* Replace internal `close` fn with `math.isclose`. (#5224)\r\n\r\n* Replace internal close fn with math.isclose.\r\n\r\n* Fix lines in docstring examples.\r\n\r\n* Fix Python 3.10 deprecation warning w/ int div. (#5231)\r\n\r\n* Touchups and suggestions for subgraph gallery example (#5225)\r\n\r\n* Simplify construction of G with edges rm'd\r\n\r\n* Rm unused graph attribute.\r\n\r\n* Shorten categorization by node type.\r\n\r\n* Simplify node coloring.\r\n\r\n* Simplify isomorphism check.\r\n\r\n* Rm unit test.\r\n\r\n* Rm redundant plotting of each subgraph.\r\n\r\n* Use new package name (#5234)\r\n\r\n* Allowing None edges in weight function of bidirectional Dijkstra (#5232)\r\n\r\n* added following feature also to bidirectional dijkstra: The weight function can be used to hide edges by returning None.\r\n\r\n* changed syntax for better readability and code duplicate avoidance\r\n\r\nCo-authored-by: Hohmann, Nikolas <nikolas.hohmann@tu-darmstadt.de>\r\n\r\n* Add an FAQ about assigning issues. (#5182)\r\n\r\n* Add FAQ about assigning issues.\r\n\r\n* Add note about linking issues from new PRs.\r\n\r\n* Update dev deps (#5243)\r\n\r\n* Update minor doc issues with tex notation (#5244)\r\n\r\n* Add FutureWarnings to fns that return sparse matrices\r\n\r\n - biadjacency_matrix.\r\n - bethe_hessian_matrix.\r\n - incidence_matrix.\r\n - laplacian functions.\r\n - modularity_matrix functions.\r\n - adjacency_matrix.\r\n\r\n* Add to_scipy_sparse_array and use it everywhere.\r\n\r\nAdd a new conversion function to preserve array semantics internally\r\nwhile not altering behavior for users.\r\n\r\nAlso adds FutureWarning to to_scipy_sparse_matrix.\r\n\r\n* Add from_scipy_sparse_array. Supercedes from_scipy_sparse_matrix.\r\n\r\n* Handle deprecations in separate PR.\r\n\r\n* Fix docstring examples.\r\n\r\nCo-authored-by: Mridul Seth <mail@mriduls.com>\r\n\r\nCo-authored-by: Jarrod Millman <jarrod.millman@gmail.com>\r\nCo-authored-by: Andrew Knyazev <andrew.knyazev@ucdenver.edu>\r\nCo-authored-by: Dan Schult <dschult@colgate.edu>\r\nCo-authored-by: eskountis <56514439+eskountis@users.noreply.github.com>\r\nCo-authored-by: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com>\r\nCo-authored-by: NikHoh <nikhoh@web.de>\r\nCo-authored-by: Hohmann, Nikolas <nikolas.hohmann@tu-darmstadt.de>\r\nCo-authored-by: Sultan Orazbayev <contact@econpoint.com>\r\nCo-authored-by: Mridul Seth <mail@mriduls.com>",970 "code": "def hits(G, max_iter=100, tol=1.0e-8, nstart=None, normalized=True):\n \n import numpy as np\n import scipy as sp\n import scipy.sparse.linalg # call as sp.sparse.linalg\n\n if len(G) == 0:\n return {}, {}\n A = nx.adjacency_matrix(G, nodelist=list(G), dtype=float)\n\n if nstart is None:\n u, s, vt = sp.sparse.linalg.svds(A, k=1, maxiter=max_iter, tol=tol)\n else:\n nstart = np.array(list(nstart.values()))\n u, s, vt = sp.sparse.linalg.svds(A, k=1, v0=nstart, maxiter=max_iter, tol=tol)\n\n a = vt.flatten().real\n h = A @ a\n if normalized:\n h = h / h.sum()\n a = a / a.sum()\n hubs = dict(zip(G, map(float, h)))\n authorities = dict(zip(G, map(float, a)))\n return hubs, authorities\n\n",971 "url": "https://github.com/networkx/networkx.git",972 "language": "Python",973 "ast_errors": "",974 "n_ast_errors": 0,975 "ast_levels": 15,976 "n_whitespaces": 175,977 "n_words": 90,978 "vocab_size": 56,979 "complexity": 4,980 "nloc": 20,981 "token_counts": 226,982 "n_ast_nodes": 339,983 "n_identifiers": 39,984 "random_cut": "def hits(G, max_iter=100, tol=1.0e-8, nstart=None, normalized=True):\n \n import numpy as np\n import scipy as sp\n imp",985 "d_id": 41745,986 "documentation": {987 "docstring": "Returns HITS hubs and authorities values for nodes.\n\n The HITS algorithm computes two numbers for a node.\n Authorities estimates the node value based on the incoming links.\n Hubs estimates the node value based on outgoing links.\n\n Parameters\n ----------\n G : graph\n A NetworkX graph\n\n max_iter : integer, optional\n Maximum number of iterations in power method.\n\n tol : float, optional\n Error tolerance used to check convergence in power method iteration.\n\n nstart : dictionary, optional\n Starting value of each node for power method iteration.\n\n normalized : bool (default=True)\n Normalize results by the sum of all of the values.\n\n Returns\n -------\n (hubs,authorities) : two-tuple of dictionaries\n Two dictionaries keyed by node containing the hub and authority\n values.\n\n Raises\n ------\n PowerIterationFailedConvergence\n If the algorithm fails to converge to the specified tolerance\n within the specified number of iterations of the power iteration\n method.\n\n Examples\n --------\n >>> G = nx.path_graph(4)\n >>> h, a = nx.hits(G)\n\n Notes\n -----\n The eigenvector calculation is done by the power iteration method\n and has no guarantee of convergence. The iteration will stop\n after max_iter iterations or an error tolerance of\n number_of_nodes(G)*tol has been reached.\n\n The HITS algorithm was designed for directed graphs but this\n algorithm does not check if the input graph is directed and will\n execute on undirected graphs.\n\n References\n ----------\n .. [1] A. Langville and C. Meyer,\n \"A survey of eigenvector methods of web information retrieval.\"\n http://citeseer.ist.psu.edu/713792.html\n .. [2] Jon Kleinberg,\n Authoritative sources in a hyperlinked environment\n Journal of the ACM 46 (5): 604-32, 1999.\n doi:10.1145/324133.324140.\n http://www.cs.cornell.edu/home/kleinber/auth.pdf.\n ",988 "n_words": 248,989 "vocab_size": 152,990 "n_whitespaces": 446,991 "language": "en"992 }993 },994 {995 "id": 45823,996 "commit_id": "26e8d6d7664bbaae717438bdb41766550ff57e4f",997 "repo": "airflow",998 "path": "airflow/providers/ftp/hooks/ftp.py",999 "file_name": "ftp.py",1000 "fun_name": "test_connection",1001 "commit_message": "Updates FTPHook provider to have test_connection (#21997)\n\n* Updates FTP provider to have test_connection\r\n\r\nCo-authored-by: eladkal <45845474+eladkal@users.noreply.github.com>",1002 "code": "def test_connection(self) -> Tuple[bool, str]:\n \n try:\n conn = self.get_conn()\n conn.pwd\n return True, \"Connection successfully tested\"\n except Exception as e:\n return False, str(e)\n\n",1003 "url": "https://github.com/apache/airflow.git",1004 "language": "Python",1005 "ast_errors": "",1006 "n_ast_errors": 0,1007 "ast_levels": 11,1008 "n_whitespaces": 87,1009 "n_words": 22,1010 "vocab_size": 21,1011 "complexity": 2,1012 "nloc": 8,1013 "token_counts": 41,1014 "n_ast_nodes": 71,1015 "n_identifiers": 10,1016 "random_cut": "def test_connection(self) -> Tuple[bool, str]:\n \n try:\n conn = se",1017 "d_id": 8731,1018 "documentation": {1019 "docstring": "Test the FTP connection by calling path with directory",1020 "n_words": 9,1021 "vocab_size": 9,1022 "n_whitespaces": 8,1023 "language": "en"1024 }1025 },1026 {1027 "id": 285727,1028 "commit_id": "1661ddd44044c637526e9a1e812e7c1863be35fc",1029 "repo": "OpenBBTerminal",1030 "path": "openbb_terminal/cryptocurrency/crypto_controller.py",1031 "file_name": "crypto_controller.py",1032 "fun_name": "call_price",1033 "commit_message": "Integrate live feeds from Pyth (#2178)\n\n* added dependency\r\n\r\n* added pyth models\r\n\r\n* dependencies\r\n\r\n* docs\r\n\r\n* some improvements to this pyth command (#2433)\r\n\r\n* some improvements to this pyth command\r\n\r\n* minor improv\r\n\r\n* dependencies\r\n\r\n* tests\r\n\r\nCo-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>; COlin",1034 "code": "def call_price(self, other_args):\n \n parser = argparse.ArgumentParser(\n add_help=False,\n formatter_class=argparse.ArgumentDefaultsHelpFormatter,\n prog=\"price\",\n description=,\n )\n parser.add_argument(\n \"-s\",\n \"--symbol\",\n required=\"-h\" not in other_args,\n type=str,\n dest=\"symbol\",\n help=\"Symbol of coin to load data for, ~100 symbols are available\",\n )\n if other_args and \"-\" not in other_args[0][0]:\n other_args.insert(0, \"-s\")\n\n ns_parser = self.parse_known_args_and_warn(parser, other_args)\n\n if ns_parser:\n\n if ns_parser.symbol in pyth_model.ASSETS.keys():\n console.print(\n \"[param]If it takes too long, you can use 'Ctrl + C' to cancel.\\n[/param]\"\n )\n pyth_view.display_price(ns_parser.symbol)\n else:\n console.print(\"[red]The symbol selected does not exist.[/red]\\n\")\n",1035 "url": "https://github.com/OpenBB-finance/OpenBBTerminal.git",1036 "language": "Python",1037 "ast_errors": "",1038 "n_ast_errors": 0,1039 "ast_levels": 13,1040 "n_whitespaces": 352,1041 "n_words": 74,1042 "vocab_size": 64,1043 "complexity": 5,1044 "nloc": 26,1045 "token_counts": 131,1046 "n_ast_nodes": 221,1047 "n_identifiers": 28,1048 "random_cut": "def call_price(self, other_args):\n \n parser = argparse.ArgumentParser(\n add_help=False,\n formatter_class=argparse.ArgumentDefaultsHelpFormatter,\n prog=\"price\",\n description=,\n )\n parser.add_argument(\n \"-s\",\n \"--symbol\",\n required=\"-h\" not in other_args,\n type=str,\n dest=\"symbol\",\n help=\"Symbol of coin to load data for, ~100 symbols are availa",1049 "d_id": 85397,1050 "documentation": {1051 "docstring": "Process price commandDisplay price and interval of confidence in real-time. [Source: Pyth]",1052 "n_words": 12,1053 "vocab_size": 11,1054 "n_whitespaces": 11,1055 "language": "en"1056 }1057 },1058 {1059 "id": 104238,1060 "commit_id": "6ed6ac9448311930557810383d2cfd4fe6aae269",1061 "repo": "datasets",1062 "path": "src/datasets/utils/py_utils.py",1063 "file_name": "py_utils.py",1064 "fun_name": "_single_map_nested",1065 "commit_message": "Better TQDM output (#3654)\n\n* Show progress bar when generating examples\r\n\r\n* Consistent utils.is_progress_bar_enabled calls\r\n\r\n* Fix tqdm in notebook\r\n\r\n* Add missing params to DatasetDict.map\r\n\r\n* Specify total in tqdm progress bar in map\r\n\r\n* Fix total computation\r\n\r\n* Small fix\r\n\r\n* Add desc to map_nested\r\n\r\n* Add more precise descriptions to download\r\n\r\n* Address comments\r\n\r\n* Fix docstring\r\n\r\n* Final changes\r\n\r\n* Minor change",1066 "code": "def _single_map_nested(args):\n \n function, data_struct, types, rank, disable_tqdm, desc = args\n\n # Singleton first to spare some computation\n if not isinstance(data_struct, dict) and not isinstance(data_struct, types):\n return function(data_struct)\n\n # Reduce logging to keep things readable in multiprocessing with tqdm\n if rank is not None and logging.get_verbosity() < logging.WARNING:\n logging.set_verbosity_warning()\n # Print at least one thing to fix tqdm in notebooks in multiprocessing\n # see https://github.com/tqdm/tqdm/issues/485#issuecomment-473338308\n if rank is not None and not disable_tqdm and any(\"notebook\" in tqdm_cls.__name__ for tqdm_cls in tqdm.__mro__):\n print(\" \", end=\"\", flush=True)\n\n # Loop over single examples or batches and write to buffer/file if examples are to be updated\n pbar_iterable = data_struct.items() if isinstance(data_struct, dict) else data_struct\n pbar_desc = (desc + \" \" if desc is not None else \"\") + \"#\" + str(rank) if rank is not None else desc\n pbar = utils.tqdm(pbar_iterable, disable=disable_tqdm, position=rank, unit=\"obj\", desc=pbar_desc)\n\n if isinstance(data_struct, dict):\n return {k: _single_map_nested((function, v, types, None, True, None)) for k, v in pbar}\n else:\n mapped = [_single_map_nested((function, v, types, None, True, None)) for v in pbar]\n if isinstance(data_struct, list):\n return mapped\n elif isinstance(data_struct, tuple):\n return tuple(mapped)\n else:\n return np.array(mapped)\n\n",1067 "url": "https://github.com/huggingface/datasets.git",1068 "language": "Python",1069 "ast_errors": "",1070 "n_ast_errors": 0,1071 "ast_levels": 13,1072 "n_whitespaces": 316,1073 "n_words": 182,1074 "vocab_size": 107,1075 "complexity": 17,1076 "nloc": 21,1077 "token_counts": 259,1078 "n_ast_nodes": 398,1079 "n_identifiers": 38,1080 "random_cut": "def _single_map_nested(args):\n \n function, data_struct, types, rank, disable_tqdm, desc = args\n\n # Singleton first to spare some computation\n if not isinstance(data_struct, dict) and not isinstance(data_struct, types):\n return function(data_struct)\n\n # Reduce logging to keep things readable in multiprocessing with tqdm\n if rank is not None and logging.get_verbosity() < logging.WARNING:\n logging.set_verbosity_warning()\n # Print at least one thing to fix tqdm in notebooks in multiprocessing\n # see https://github.com/tqdm/tqdm/issues/485#issuecomment-473338308\n if rank is not None and not disable_tqdm and any(\"notebook\" in tqdm_cls.__name__ for tqdm_cls in tqdm.__mro__):\n print(\" \", end=\"\", flush=True)\n\n # Loop over single examples or batches and write to buffer/file if examples are to be updated\n pbar_iterable = data_struct.items() if isinstance(data_struct, dict) else data_struct\n pbar_desc = (desc + \" \" if desc is not None else \"\") + \"#\" + str(rank) if rank is not None else desc\n pbar = utils.tqdm(pbar_iterable, dis",1081 "d_id": 21793,1082 "documentation": {1083 "docstring": "Apply a function recursively to each element of a nested data struct.",1084 "n_words": 12,1085 "vocab_size": 11,1086 "n_whitespaces": 11,1087 "language": "en"1088 }1089 },1090 {1091 "id": 207334,1092 "commit_id": "9c19aff7c7561e3a82978a272ecdaad40dda5c00",1093 "repo": "django",1094 "path": "tests/admin_scripts/tests.py",1095 "file_name": "tests.py",1096 "fun_name": "test_unified",1097 "commit_message": "Refs #33476 -- Reformatted code with Black.",1098 "code": "def test_unified(self):\n \n self.write_settings(\"settings_to_diff.py\", sdict={\"FOO\": '\"bar\"'})\n args = [\"diffsettings\", \"--settings=settings_to_diff\", \"--output=unified\"]\n out, err = self.run_manage(args)\n self.assertNoOutput(err)\n self.assertOutput(out, \"+ FOO = 'bar'\")\n self.assertOutput(out, \"- SECRET_KEY = ''\")\n self.assertOutput(out, \"+ SECRET_KEY = 'django_tests_secret_key'\")\n self.assertNotInOutput(out, \" APPEND_SLASH = True\")\n",1099 "url": "https://github.com/django/django.git",1100 "language": "Python",1101 "ast_errors": "",1102 "n_ast_errors": 0,1103 "ast_levels": 11,1104 "n_whitespaces": 99,1105 "n_words": 35,1106 "vocab_size": 26,1107 "complexity": 1,1108 "nloc": 9,1109 "token_counts": 77,1110 "n_ast_nodes": 140,1111 "n_identifiers": 11,1112 "random_cut": "def test_unified(self):\n \n ",1113 "d_id": 51930,1114 "documentation": {1115 "docstring": "--output=unified emits settings diff in unified mode.",1116 "n_words": 7,1117 "vocab_size": 7,1118 "n_whitespaces": 6,1119 "language": "en"1120 }1121 },1122 {1123 "id": 139848,1124 "commit_id": "eb2692cb32bb1747e312d5b20e976d7a879c9588",1125 "repo": "ray",1126 "path": "python/ray/runtime_context.py",1127 "file_name": "runtime_context.py",1128 "fun_name": "runtime_env",1129 "commit_message": "[runtime env] runtime env inheritance refactor (#24538)\n\n* [runtime env] runtime env inheritance refactor (#22244)\r\n\r\nRuntime Environments is already GA in Ray 1.6.0. The latest doc is [here](https://docs.ray.io/en/master/ray-core/handling-dependencies.html#runtime-environments). And now, we already supported a [inheritance](https://docs.ray.io/en/master/ray-core/handling-dependencies.html#inheritance) behavior as follows (copied from the doc):\r\n- The runtime_env[\"env_vars\"] field will be merged with the runtime_env[\"env_vars\"] field of the parent. This allows for environment variables set in the parent’s runtime environment to be automatically propagated to the child, even if new environment variables are set in the child’s runtime environment.\r\n- Every other field in the runtime_env will be overridden by the child, not merged. For example, if runtime_env[\"py_modules\"] is specified, it will replace the runtime_env[\"py_modules\"] field of the parent.\r\n\r\nWe think this runtime env merging logic is so complex and confusing to users because users can't know the final runtime env before the jobs are run.\r\n\r\nCurrent PR tries to do a refactor and change the behavior of Runtime Environments inheritance. Here is the new behavior:\r\n- **If there is no runtime env option when we create actor, inherit the parent runtime env.**\r\n- **Otherwise, use the optional runtime env directly and don't do the merging.**\r\n\r\nAdd a new API named `ray.runtime_env.get_current_runtime_env()` to get the parent runtime env and modify this dict by yourself. Like:\r\n```Actor.options(runtime_env=ray.runtime_env.get_current_runtime_env().update({\"X\": \"Y\"}))```\r\nThis new API also can be used in ray client.",1130 "code": "def runtime_env(self):\n \n\n return RuntimeEnv.deserialize(self._get_runtime_env_string())\n",1131 "url": "https://github.com/ray-project/ray.git",1132 "language": "Python",1133 "ast_errors": "",1134 "n_ast_errors": 0,1135 "ast_levels": 9,1136 "n_whitespaces": 18,1137 "n_words": 4,1138 "vocab_size": 4,1139 "complexity": 1,1140 "nloc": 2,1141 "token_counts": 17,1142 "n_ast_nodes": 31,1143 "n_identifiers": 5,1144 "random_cut": "def runtime_env(self):\n \n",1145 "d_id": 31793,1146 "documentation": {1147 "docstring": "Get the runtime env of the current job/worker.\n\n If this API is called in driver or ray client, returns the job level runtime\n env.\n If this API is called in workers/actors, returns the worker level runtime env.\n\n Returns:\n A new ray.runtime_env.RuntimeEnv instance.\n\n To merge from the current runtime env in some specific cases, you can get the\n current runtime env by this API and modify it by yourself.\n\n Example:\n >>> # Inherit current runtime env, except `env_vars`\n >>> Actor.options( # doctest: +SKIP\n ... runtime_env=ray.get_runtime_context().runtime_env.update(\n ... {\"env_vars\": {\"A\": \"a\", \"B\": \"b\"}})\n ... ) # doctest: +SKIP\n ",1148 "n_words": 95,1149 "vocab_size": 60,1150 "n_whitespaces": 205,1151 "language": "en"1152 }1153 },1154 {1155 "id": 187407,1156 "commit_id": "d1a8d1597d4fe9f129a72fe94c1508304b7eae0f",1157 "repo": "streamlink",1158 "path": "src/streamlink/stream/dash.py",1159 "file_name": "dash.py",1160 "fun_name": "sleeper",1161 "commit_message": "stream.dash: update DASHStreamWorker.iter_segments\n\n- Refactor DASHStreamWorker.iter_segments()\n- Replace dash_manifest.sleeper() with SegmentedStreamWorker.wait(),\n and make the worker thread shut down immediately on close().\n- Prevent unnecessary wait times for static manifest types by calling\n close() after all segments were put into the writer's queue.",1162 "code": "def sleeper(self, duration):\n \n s = time()\n yield\n time_to_sleep = duration - (time() - s)\n if time_to_sleep > 0:\n self.wait(time_to_sleep)\n",1163 "url": "https://github.com/streamlink/streamlink.git",1164 "language": "Python",1165 "ast_errors": "",1166 "n_ast_errors": 0,1167 "ast_levels": 11,1168 "n_whitespaces": 65,1169 "n_words": 19,1170 "vocab_size": 16,1171 "complexity": 2,1172 "nloc": 6,1173 "token_counts": 36,1174 "n_ast_nodes": 63,1175 "n_identifiers": 7,1176 "random_cut": "def sleeper(self, duration):\n \n s = time()\n yield\n time_to_sleep = duration - (time() - s)\n if time_to_sleep > 0:\n s",1177 "d_id": 45770,1178 "documentation": {1179 "docstring": "\n Do something and then wait for a given duration minus the time it took doing something\n ",1180 "n_words": 16,1181 "vocab_size": 15,1182 "n_whitespaces": 31,1183 "language": "en"1184 }1185 },1186 {1187 "id": 109399,1188 "commit_id": "a17f4f3bd63e3ca3754f96d7db4ce5197720589b",1189 "repo": "matplotlib",1190 "path": "lib/matplotlib/tests/test_colors.py",1191 "file_name": "test_colors.py",1192 "fun_name": "test_BoundaryNorm",1193 "commit_message": "MNT: convert tests and internal usage way from using mpl.cm.get_cmap",1194 "code": "def test_BoundaryNorm():\n \n\n boundaries = [0, 1.1, 2.2]\n vals = [-1, 0, 1, 2, 2.2, 4]\n\n # Without interpolation\n expected = [-1, 0, 0, 1, 2, 2]\n ncolors = len(boundaries) - 1\n bn = mcolors.BoundaryNorm(boundaries, ncolors)\n assert_array_equal(bn(vals), expected)\n\n # ncolors != len(boundaries) - 1 triggers interpolation\n expected = [-1, 0, 0, 2, 3, 3]\n ncolors = len(boundaries)\n bn = mcolors.BoundaryNorm(boundaries, ncolors)\n assert_array_equal(bn(vals), expected)\n\n # with a single region and interpolation\n expected = [-1, 1, 1, 1, 3, 3]\n bn = mcolors.BoundaryNorm([0, 2.2], ncolors)\n assert_array_equal(bn(vals), expected)\n\n # more boundaries for a third color\n boundaries = [0, 1, 2, 3]\n vals = [-1, 0.1, 1.1, 2.2, 4]\n ncolors = 5\n expected = [-1, 0, 2, 4, 5]\n bn = mcolors.BoundaryNorm(boundaries, ncolors)\n assert_array_equal(bn(vals), expected)\n\n # a scalar as input should not trigger an error and should return a scalar\n boundaries = [0, 1, 2]\n vals = [-1, 0.1, 1.1, 2.2]\n bn = mcolors.BoundaryNorm(boundaries, 2)\n expected = [-1, 0, 1, 2]\n for v, ex in zip(vals, expected):\n ret = bn(v)\n assert isinstance(ret, int)\n assert_array_equal(ret, ex)\n assert_array_equal(bn([v]), ex)\n\n # same with interp\n bn = mcolors.BoundaryNorm(boundaries, 3)\n expected = [-1, 0, 2, 3]\n for v, ex in zip(vals, expected):\n ret = bn(v)\n assert isinstance(ret, int)\n assert_array_equal(ret, ex)\n assert_array_equal(bn([v]), ex)\n\n # Clipping\n bn = mcolors.BoundaryNorm(boundaries, 3, clip=True)\n expected = [0, 0, 2, 2]\n for v, ex in zip(vals, expected):\n ret = bn(v)\n assert isinstance(ret, int)\n assert_array_equal(ret, ex)\n assert_array_equal(bn([v]), ex)\n\n # Masked arrays\n boundaries = [0, 1.1, 2.2]\n vals = np.ma.masked_invalid([-1., np.NaN, 0, 1.4, 9])\n\n # Without interpolation\n ncolors = len(boundaries) - 1\n bn = mcolors.BoundaryNorm(boundaries, ncolors)\n expected = np.ma.masked_array([-1, -99, 0, 1, 2], mask=[0, 1, 0, 0, 0])\n assert_array_equal(bn(vals), expected)\n\n # With interpolation\n bn = mcolors.BoundaryNorm(boundaries, len(boundaries))\n expected = np.ma.masked_array([-1, -99, 0, 2, 3], mask=[0, 1, 0, 0, 0])\n assert_array_equal(bn(vals), expected)\n\n # Non-trivial masked arrays\n vals = np.ma.masked_invalid([np.Inf, np.NaN])\n assert np.all(bn(vals).mask)\n vals = np.ma.masked_invalid([np.Inf])\n assert np.all(bn(vals).mask)\n\n # Incompatible extend and clip\n with pytest.raises(ValueError, match=\"not compatible\"):\n mcolors.BoundaryNorm(np.arange(4), 5, extend='both', clip=True)\n\n # Too small ncolors argument\n with pytest.raises(ValueError, match=\"ncolors must equal or exceed\"):\n mcolors.BoundaryNorm(np.arange(4), 2)\n\n with pytest.raises(ValueError, match=\"ncolors must equal or exceed\"):\n mcolors.BoundaryNorm(np.arange(4), 3, extend='min')\n\n with pytest.raises(ValueError, match=\"ncolors must equal or exceed\"):\n mcolors.BoundaryNorm(np.arange(4), 4, extend='both')\n\n # Testing extend keyword, with interpolation (large cmap)\n bounds = [1, 2, 3]\n cmap = mpl.colormaps['viridis']\n mynorm = mcolors.BoundaryNorm(bounds, cmap.N, extend='both')\n refnorm = mcolors.BoundaryNorm([0] + bounds + [4], cmap.N)\n x = np.random.randn(100) * 10 + 2\n ref = refnorm(x)\n ref[ref == 0] = -1\n ref[ref == cmap.N - 1] = cmap.N\n assert_array_equal(mynorm(x), ref)\n\n # Without interpolation\n cmref = mcolors.ListedColormap(['blue', 'red'])\n cmref.set_over('black')\n cmref.set_under('white')\n cmshould = mcolors.ListedColormap(['white', 'blue', 'red', 'black'])\n\n assert mcolors.same_color(cmref.get_over(), 'black')\n assert mcolors.same_color(cmref.get_under(), 'white')\n\n refnorm = mcolors.BoundaryNorm(bounds, cmref.N)\n mynorm = mcolors.BoundaryNorm(bounds, cmshould.N, extend='both')\n assert mynorm.vmin == refnorm.vmin\n assert mynorm.vmax == refnorm.vmax\n\n assert mynorm(bounds[0] - 0.1) == -1 # under\n assert mynorm(bounds[0] + 0.1) == 1 # first bin -> second color\n assert mynorm(bounds[-1] - 0.1) == cmshould.N - 2 # next-to-last color\n assert mynorm(bounds[-1] + 0.1) == cmshould.N # over\n\n x = [-1, 1.2, 2.3, 9.6]\n assert_array_equal(cmshould(mynorm(x)), cmshould([0, 1, 2, 3]))\n x = np.random.randn(100) * 10 + 2\n assert_array_equal(cmshould(mynorm(x)), cmref(refnorm(x)))\n\n # Just min\n cmref = mcolors.ListedColormap(['blue', 'red'])\n cmref.set_under('white')\n cmshould = mcolors.ListedColormap(['white', 'blue', 'red'])\n\n assert mcolors.same_color(cmref.get_under(), 'white')\n\n assert cmref.N == 2\n assert cmshould.N == 3\n refnorm = mcolors.BoundaryNorm(bounds, cmref.N)\n mynorm = mcolors.BoundaryNorm(bounds, cmshould.N, extend='min')\n assert mynorm.vmin == refnorm.vmin\n assert mynorm.vmax == refnorm.vmax\n x = [-1, 1.2, 2.3]\n assert_array_equal(cmshould(mynorm(x)), cmshould([0, 1, 2]))\n x = np.random.randn(100) * 10 + 2\n assert_array_equal(cmshould(mynorm(x)), cmref(refnorm(x)))\n\n # Just max\n cmref = mcolors.ListedColormap(['blue', 'red'])\n cmref.set_over('black')\n cmshould = mcolors.ListedColormap(['blue', 'red', 'black'])\n\n assert mcolors.same_color(cmref.get_over(), 'black')\n\n assert cmref.N == 2\n assert cmshould.N == 3\n refnorm = mcolors.BoundaryNorm(bounds, cmref.N)\n mynorm = mcolors.BoundaryNorm(bounds, cmshould.N, extend='max')\n assert mynorm.vmin == refnorm.vmin\n assert mynorm.vmax == refnorm.vmax\n x = [1.2, 2.3, 4]\n assert_array_equal(cmshould(mynorm(x)), cmshould([0, 1, 2]))\n x = np.random.randn(100) * 10 + 2\n assert_array_equal(cmshould(mynorm(x)), cmref(refnorm(x)))\n\n",1195 "url": "https://github.com/matplotlib/matplotlib.git",1196 "language": "Python",1197 "ast_errors": "",1198 "n_ast_errors": 0,1199 "ast_levels": 12,1200 "n_whitespaces": 1100,