Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Testmetrics.html 28 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
  1. ---
  2. title: Title
  3. keywords: fastai
  4. sidebar: home_sidebar
  5. summary: "summary"
  6. ---
  7. <!--
  8. #################################################
  9. ### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
  10. #################################################
  11. # file to edit: nbs/Testmetrics.ipynb
  12. # command to build the docs after a change: nbdev_build_docs
  13. -->
  14. <div class="container" id="notebook-container">
  15. <div class="cell border-box-sizing code_cell rendered">
  16. </div>
  17. <div class="cell border-box-sizing code_cell rendered">
  18. <div class="input">
  19. <div class="inner_cell">
  20. <div class="input_area">
  21. <div class=" highlight hl-ipython3"><pre><span></span><span class="o">!</span>pip install codemetrics
  22. </pre></div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="output_wrapper">
  27. <div class="output">
  28. <div class="output_area">
  29. <div class="output_subarea output_stream output_stdout output_text">
  30. <pre>Collecting codemetrics
  31. Downloading codemetrics-0.9.6.tar.gz (55 kB)
  32. |████████████████████████████████| 55 kB 1.0 MB/s eta 0:00:011
  33. Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from codemetrics) (1.17.1)
  34. Requirement already satisfied: click&gt;=6.0 in /usr/local/lib/python3.6/dist-packages (from codemetrics) (7.1.1)
  35. Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from codemetrics) (1.0.3)
  36. Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from codemetrics) (4.45.0)
  37. Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/dist-packages (from codemetrics) (2.8.0)
  38. Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from codemetrics) (0.22.2.post1)
  39. Requirement already satisfied: lizard in /usr/local/lib/python3.6/dist-packages (from codemetrics) (1.17.3)
  40. Requirement already satisfied: pytz&gt;=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas-&gt;codemetrics) (2019.3)
  41. Requirement already satisfied: six&gt;=1.5 in /usr/lib/python3/dist-packages (from python-dateutil-&gt;codemetrics) (1.11.0)
  42. Requirement already satisfied: scipy&gt;=0.17.0 in /usr/local/lib/python3.6/dist-packages (from scikit-learn-&gt;codemetrics) (1.4.1)
  43. Requirement already satisfied: joblib&gt;=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn-&gt;codemetrics) (0.14.1)
  44. Building wheels for collected packages: codemetrics
  45. Building wheel for codemetrics (setup.py) ... done
  46. Created wheel for codemetrics: filename=codemetrics-0.9.6-py2.py3-none-any.whl size=28080 sha256=e23664c753faeed783a7a3234b9605980ba10d8e13196b32c2ee38265bc032cb
  47. Stored in directory: /root/.cache/pip/wheels/e5/5e/e6/beec95ac46274bf5a3f5e83553d6bb40b9a752c6585deff9f4
  48. Successfully built codemetrics
  49. Installing collected packages: codemetrics
  50. Successfully installed codemetrics-0.9.6
  51. <span class="ansi-yellow-fg">WARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.
  52. You should consider upgrading via the &#39;/usr/bin/python3 -m pip install --upgrade pip&#39; command.</span>
  53. </pre>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="cell border-box-sizing code_cell rendered">
  60. <div class="input">
  61. <div class="inner_cell">
  62. <div class="input_area">
  63. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">json</span>
  64. <span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
  65. <span class="kn">from</span> <span class="nn">pathlib</span> <span class="k">import</span> <span class="n">Path</span>
  66. <span class="n">pd</span><span class="o">.</span><span class="n">set_option</span><span class="p">(</span><span class="s1">&#39;max_colwidth&#39;</span><span class="p">,</span><span class="mi">300</span><span class="p">)</span>
  67. <span class="kn">from</span> <span class="nn">pprint</span> <span class="k">import</span> <span class="n">pprint</span>
  68. <span class="kn">import</span> <span class="nn">re</span>
  69. </pre></div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="cell border-box-sizing code_cell rendered">
  75. <div class="input">
  76. <div class="inner_cell">
  77. <div class="input_area">
  78. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">java_files</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="s1">&#39;test_data/java/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s1">&#39;**/*.gz&#39;</span><span class="p">))</span>
  79. </pre></div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="cell border-box-sizing code_cell rendered">
  85. <div class="input">
  86. <div class="inner_cell">
  87. <div class="input_area">
  88. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">columns_long_list</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;repo&#39;</span><span class="p">,</span> <span class="s1">&#39;path&#39;</span><span class="p">,</span> <span class="s1">&#39;url&#39;</span><span class="p">,</span> <span class="s1">&#39;code&#39;</span><span class="p">,</span>
  89. <span class="s1">&#39;code_tokens&#39;</span><span class="p">,</span> <span class="s1">&#39;docstring&#39;</span><span class="p">,</span> <span class="s1">&#39;docstring_tokens&#39;</span><span class="p">,</span>
  90. <span class="s1">&#39;language&#39;</span><span class="p">,</span> <span class="s1">&#39;partition&#39;</span><span class="p">]</span>
  91. <span class="n">columns_short_list</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;code_tokens&#39;</span><span class="p">,</span> <span class="s1">&#39;docstring_tokens&#39;</span><span class="p">,</span>
  92. <span class="s1">&#39;language&#39;</span><span class="p">,</span> <span class="s1">&#39;partition&#39;</span><span class="p">]</span>
  93. <span class="k">def</span> <span class="nf">jsonl_list_to_dataframe</span><span class="p">(</span><span class="n">file_list</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns_long_list</span><span class="p">):</span>
  94. <span class="sd">&quot;&quot;&quot;Load a list of jsonl.gz files into a pandas DataFrame.&quot;&quot;&quot;</span>
  95. <span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">pd</span><span class="o">.</span><span class="n">read_json</span><span class="p">(</span><span class="n">f</span><span class="p">,</span>
  96. <span class="n">orient</span><span class="o">=</span><span class="s1">&#39;records&#39;</span><span class="p">,</span>
  97. <span class="n">compression</span><span class="o">=</span><span class="s1">&#39;gzip&#39;</span><span class="p">,</span>
  98. <span class="n">lines</span><span class="o">=</span><span class="kc">True</span><span class="p">)[</span><span class="n">columns</span><span class="p">]</span>
  99. <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">file_list</span><span class="p">],</span> <span class="n">sort</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
  100. </pre></div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="cell border-box-sizing code_cell rendered">
  106. <div class="input">
  107. <div class="inner_cell">
  108. <div class="input_area">
  109. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">java_df</span> <span class="o">=</span> <span class="n">jsonl_list_to_dataframe</span><span class="p">(</span><span class="n">java_files</span><span class="p">)</span>
  110. </pre></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <div class="cell border-box-sizing code_cell rendered">
  116. <div class="input">
  117. <div class="inner_cell">
  118. <div class="input_area">
  119. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">java_test</span> <span class="o">=</span> <span class="n">java_df</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  120. </pre></div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="cell border-box-sizing code_cell rendered">
  126. <div class="input">
  127. <div class="inner_cell">
  128. <div class="input_area">
  129. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">java_test</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
  130. </pre></div>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="output_wrapper">
  135. <div class="output">
  136. <div class="output_area">
  137. <div class="output_html rendered_html output_subarea output_execute_result">
  138. <div>
  139. <style scoped>
  140. .dataframe tbody tr th:only-of-type {
  141. vertical-align: middle;
  142. }
  143. .dataframe tbody tr th {
  144. vertical-align: top;
  145. }
  146. .dataframe thead th {
  147. text-align: right;
  148. }
  149. </style>
  150. <table border="1" class="dataframe">
  151. <thead>
  152. <tr style="text-align: right;">
  153. <th></th>
  154. <th>repo</th>
  155. <th>path</th>
  156. <th>url</th>
  157. <th>code</th>
  158. <th>code_tokens</th>
  159. <th>docstring</th>
  160. <th>docstring_tokens</th>
  161. <th>language</th>
  162. <th>partition</th>
  163. </tr>
  164. </thead>
  165. <tbody>
  166. <tr>
  167. <th>2134</th>
  168. <td>aws/aws-sdk-java</td>
  169. <td>aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/ExamplesCustomizer.java</td>
  170. <td>https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/ExamplesCustomizer.java#L61-L71</td>
  171. <td>public ServiceExamples applyCustomizationsToExamples(ServiceExamples serviceExamples) {\n if (customizationConfig == null) return serviceExamples;\n\n serviceExamples.getOperationExamples().entrySet()\n .forEach(e -&gt; {\n String operationName = e.ge...</td>
  172. <td>[public, ServiceExamples, applyCustomizationsToExamples, (, ServiceExamples, serviceExamples, ), {, if, (, customizationConfig, ==, null, ), return, serviceExamples, ;, serviceExamples, ., getOperationExamples, (, ), ., entrySet, (, ), ., forEach, (, e, -&gt;, {, String, operationName, =, e, ., get...</td>
  173. <td>Apply the configured {@link CustomizationConfig} to the given service\nexamples.\n\n@param serviceExamples The service examples.\n\n@return The customized service examples.</td>
  174. <td>[Apply, the, configured, {, @link, CustomizationConfig, }, to, the, given, service, examples, .]</td>
  175. <td>java</td>
  176. <td>train</td>
  177. </tr>
  178. <tr>
  179. <th>26920</th>
  180. <td>aws/aws-sdk-java</td>
  181. <td>aws-java-sdk-dms/src/main/java/com/amazonaws/services/databasemigrationservice/model/CreateEventSubscriptionRequest.java</td>
  182. <td>https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dms/src/main/java/com/amazonaws/services/databasemigrationservice/model/CreateEventSubscriptionRequest.java#L378-L385</td>
  183. <td>public void setSourceIds(java.util.Collection&lt;String&gt; sourceIds) {\n if (sourceIds == null) {\n this.sourceIds = null;\n return;\n }\n\n this.sourceIds = new java.util.ArrayList&lt;String&gt;(sourceIds);\n }</td>
  184. <td>[public, void, setSourceIds, (, java, ., util, ., Collection, &lt;, String, &gt;, sourceIds, ), {, if, (, sourceIds, ==, null, ), {, this, ., sourceIds, =, null, ;, return, ;, }, this, ., sourceIds, =, new, java, ., util, ., ArrayList, &lt;, String, &gt;, (, sourceIds, ), ;, }]</td>
  185. <td>&lt;p&gt;\nThe list of identifiers of the event sources for which events will be returned. If not specified, then all\nsources are included in the response. An identifier must begin with a letter and must contain only ASCII letters,\ndigits, and hyphens; it cannot end with a hyphen or contain two cons...</td>
  186. <td>[&lt;p, &gt;, The, list, of, identifiers, of, the, event, sources, for, which, events, will, be, returned, ., If, not, specified, then, all, sources, are, included, in, the, response, ., An, identifier, must, begin, with, a, letter, and, must, contain, only, ASCII, letters, digits, and, hyphens, ;, it...</td>
  187. <td>java</td>
  188. <td>train</td>
  189. </tr>
  190. <tr>
  191. <th>3814</th>
  192. <td>overturetool/overture</td>
  193. <td>core/interpreter/src/main/java/org/overture/interpreter/runtime/Breakpoint.java</td>
  194. <td>https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/interpreter/src/main/java/org/overture/interpreter/runtime/Breakpoint.java#L180-L217</td>
  195. <td>public void check(ILexLocation execl, Context ctxt)\n\t{\n\t\t// skips if breakpoint is disabled\n\t\t// if(!enabled){\n\t\t// return;\n\t\t// }\n\n\t\tlocation.hit();\n\t\thits++;\n\n\t\tThreadState state = ctxt.threadState;\n\n\t\tif (Settings.dialect != Dialect.VDM_SL)\n\t\t{\n\t\t\tstate.res...</td>
  196. <td>[public, void, check, (, ILexLocation, execl, ,, Context, ctxt, ), {, // skips if breakpoint is disabled, // if(!enabled){, // return;, // }, location, ., hit, (, ), ;, hits, ++, ;, ThreadState, state, =, ctxt, ., threadState, ;, if, (, Settings, ., dialect, !=, Dialect, ., VDM_SL, ), {, state, ...</td>
  197. <td>Check whether to stop. The implementation in Breakpoint is used to check for the "step" and "next" commands,\nusing the stepline, nextctxt and outctxt fields. If the current line is different to the last step line, and the\ncurrent context is not "above" the next context or the current context e...</td>
  198. <td>[Check, whether, to, stop, ., The, implementation, in, Breakpoint, is, used, to, check, for, the, step, and, next, commands, using, the, stepline, nextctxt, and, outctxt, fields, ., If, the, current, line, is, different, to, the, last, step, line, and, the, current, context, is, not, above, the,...</td>
  199. <td>java</td>
  200. <td>train</td>
  201. </tr>
  202. <tr>
  203. <th>15992</th>
  204. <td>hexagonframework/spring-data-ebean</td>
  205. <td>src/main/java/org/springframework/data/ebean/repository/query/StringQuery.java</td>
  206. <td>https://github.com/hexagonframework/spring-data-ebean/blob/dd11b97654982403b50dd1d5369cadad71fce410/src/main/java/org/springframework/data/ebean/repository/query/StringQuery.java#L114-L123</td>
  207. <td>public ParameterBinding getBindingFor(int position) {\r\n\r\n for (ParameterBinding binding : bindings) {\r\n if (binding.hasPosition(position)) {\r\n return binding;\r\n }\r\n }\r\n\r\n throw new IllegalArgumentException(String.format("N...</td>
  208. <td>[public, ParameterBinding, getBindingFor, (, int, position, ), {, for, (, ParameterBinding, binding, :, bindings, ), {, if, (, binding, ., hasPosition, (, position, ), ), {, return, binding, ;, }, }, throw, new, IllegalArgumentException, (, String, ., format, (, "No parameter binding found for p...</td>
  209. <td>Returns the {@link ParameterBinding} for the given position.\n\n@param position\n@return</td>
  210. <td>[Returns, the, {, @link, ParameterBinding, }, for, the, given, position, .]</td>
  211. <td>java</td>
  212. <td>train</td>
  213. </tr>
  214. <tr>
  215. <th>29309</th>
  216. <td>mgormley/pacaya</td>
  217. <td>src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java</td>
  218. <td>https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/CkyPcfgParser.java#L185-L208</td>
  219. <td>private static final void processCellLeftChild(final CnfGrammar grammar, final Chart chart, final int start,\n final int end, final ChartCell cell, final Scorer scorer) {\n // Apply binary rules.\n for (int mid = start + 1; mid &lt;= end - 1; mid++) {\n ChartCell...</td>
  220. <td>[private, static, final, void, processCellLeftChild, (, final, CnfGrammar, grammar, ,, final, Chart, chart, ,, final, int, start, ,, final, int, end, ,, final, ChartCell, cell, ,, final, Scorer, scorer, ), {, // Apply binary rules., for, (, int, mid, =, start, +, 1, ;, mid, &lt;=, end, -, 1, ;, mid...</td>
  221. <td>Process a cell (binary rules only) using the left-child to constrain the set of rules we consider.\n\nThis follows the description in (Dunlop et al., 2010).</td>
  222. <td>[Process, a, cell, (, binary, rules, only, ), using, the, left, -, child, to, constrain, the, set, of, rules, we, consider, .]</td>
  223. <td>java</td>
  224. <td>train</td>
  225. </tr>
  226. </tbody>
  227. </table>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. <div class="cell border-box-sizing code_cell rendered">
  235. <div class="input">
  236. <div class="inner_cell">
  237. <div class="input_area">
  238. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">java_test</span><span class="p">[</span><span class="s1">&#39;code&#39;</span><span class="p">][</span><span class="mi">26920</span><span class="p">]</span>
  239. </pre></div>
  240. </div>
  241. </div>
  242. </div>
  243. <div class="output_wrapper">
  244. <div class="output">
  245. <div class="output_area">
  246. <div class="output_text output_subarea output_execute_result">
  247. <pre>&#39;public void setSourceIds(java.util.Collection&lt;String&gt; sourceIds) {\n if (sourceIds == null) {\n this.sourceIds = null;\n return;\n }\n\n this.sourceIds = new java.util.ArrayList&lt;String&gt;(sourceIds);\n }&#39;</pre>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. <div class="cell border-box-sizing code_cell rendered">
  254. <div class="input">
  255. <div class="inner_cell">
  256. <div class="input_area">
  257. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">codemetrics</span> <span class="k">as</span> <span class="nn">cm</span>
  258. </pre></div>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. <div class="cell border-box-sizing code_cell rendered">
  264. <div class="input">
  265. <div class="inner_cell">
  266. <div class="input_area">
  267. <div class=" highlight hl-ipython3"><pre><span></span><span class="o">!</span>pip install radon
  268. </pre></div>
  269. </div>
  270. </div>
  271. </div>
  272. <div class="output_wrapper">
  273. <div class="output">
  274. <div class="output_area">
  275. <div class="output_subarea output_stream output_stdout output_text">
  276. <pre>Requirement already satisfied: radon in /usr/local/lib/python3.6/dist-packages (4.1.0)
  277. Requirement already satisfied: flake8-polyfill in /usr/local/lib/python3.6/dist-packages (from radon) (1.0.2)
  278. Requirement already satisfied: colorama==0.4.1 in /usr/local/lib/python3.6/dist-packages (from radon) (0.4.1)
  279. Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from radon) (0.18.2)
  280. Requirement already satisfied: mando&lt;0.7,&gt;=0.6 in /usr/local/lib/python3.6/dist-packages (from radon) (0.6.4)
  281. Requirement already satisfied: flake8 in /usr/local/lib/python3.6/dist-packages (from flake8-polyfill-&gt;radon) (3.8.3)
  282. Requirement already satisfied: six in /usr/lib/python3/dist-packages (from mando&lt;0.7,&gt;=0.6-&gt;radon) (1.11.0)
  283. Requirement already satisfied: mccabe&lt;0.7.0,&gt;=0.6.0 in /usr/local/lib/python3.6/dist-packages (from flake8-&gt;flake8-polyfill-&gt;radon) (0.6.1)
  284. Requirement already satisfied: pycodestyle&lt;2.7.0,&gt;=2.6.0a1 in /usr/local/lib/python3.6/dist-packages (from flake8-&gt;flake8-polyfill-&gt;radon) (2.6.0)
  285. Requirement already satisfied: importlib-metadata; python_version &lt; &#34;3.8&#34; in /usr/local/lib/python3.6/dist-packages (from flake8-&gt;flake8-polyfill-&gt;radon) (1.6.1)
  286. Requirement already satisfied: pyflakes&lt;2.3.0,&gt;=2.2.0 in /usr/local/lib/python3.6/dist-packages (from flake8-&gt;flake8-polyfill-&gt;radon) (2.2.0)
  287. Requirement already satisfied: zipp&gt;=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version &lt; &#34;3.8&#34;-&gt;flake8-&gt;flake8-polyfill-&gt;radon) (3.1.0)
  288. <span class="ansi-yellow-fg">WARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.
  289. You should consider upgrading via the &#39;/usr/bin/python3 -m pip install --upgrade pip&#39; command.</span>
  290. </pre>
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="cell border-box-sizing code_cell rendered">
  297. <div class="input">
  298. <div class="inner_cell">
  299. <div class="input_area">
  300. <div class=" highlight hl-ipython3"><pre><span></span><span class="o">!</span>pip install metrics
  301. </pre></div>
  302. </div>
  303. </div>
  304. </div>
  305. <div class="output_wrapper">
  306. <div class="output">
  307. <div class="output_area">
  308. <div class="output_subarea output_stream output_stdout output_text">
  309. <pre>Collecting metrics
  310. Downloading metrics-0.3.3.tar.gz (18 kB)
  311. Collecting Pygments==2.2.0
  312. Downloading Pygments-2.2.0-py2.py3-none-any.whl (841 kB)
  313. |████████████████████████████████| 841 kB 5.5 MB/s eta 0:00:01
  314. Collecting pathspec==0.5.5
  315. Downloading pathspec-0.5.5.tar.gz (21 kB)
  316. Collecting pathlib2&gt;=2.3.0
  317. Downloading pathlib2-2.3.5-py2.py3-none-any.whl (18 kB)
  318. Requirement already satisfied: six in /usr/lib/python3/dist-packages (from pathlib2&gt;=2.3.0-&gt;metrics) (1.11.0)
  319. Building wheels for collected packages: metrics, pathspec
  320. Building wheel for metrics (setup.py) ... done
  321. Created wheel for metrics: filename=metrics-0.3.3-py2.py3-none-any.whl size=21630 sha256=7b91941ad67cd8e10cbd124398fe4e61566ec018adeea43ea1d918f8f407a707
  322. Stored in directory: /root/.cache/pip/wheels/4b/ae/0a/4580500bf20b0bba431c3f5eb11aabf0d8d46ded2c493b45d5
  323. Building wheel for pathspec (setup.py) ... done
  324. Created wheel for pathspec: filename=pathspec-0.5.5-py3-none-any.whl size=22215 sha256=b6353b3f760c4415b6f0feb8abf54c52b1739609d8edde1d3c3d978e68bcea3d
  325. Stored in directory: /root/.cache/pip/wheels/0c/01/e5/cb28cf959e8a5cb9969cd05a90fb3443602dcd000c288e65f0
  326. Successfully built metrics pathspec
  327. Installing collected packages: Pygments, pathspec, pathlib2, metrics
  328. Attempting uninstall: Pygments
  329. Found existing installation: Pygments 2.4.2
  330. Uninstalling Pygments-2.4.2:
  331. Successfully uninstalled Pygments-2.4.2
  332. Successfully installed Pygments-2.2.0 metrics-0.3.3 pathlib2-2.3.5 pathspec-0.5.5
  333. <span class="ansi-yellow-fg">WARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.
  334. You should consider upgrading via the &#39;/usr/bin/python3 -m pip install --upgrade pip&#39; command.</span>
  335. Note: you may need to restart the kernel to use updated packages.
  336. </pre>
  337. </div>
  338. </div>
  339. </div>
  340. </div>
  341. </div>
  342. <div class="cell border-box-sizing code_cell rendered">
  343. <div class="input">
  344. <div class="inner_cell">
  345. <div class="input_area">
  346. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">radon.raw</span> <span class="k">import</span> <span class="n">analyze</span>
  347. </pre></div>
  348. </div>
  349. </div>
  350. </div>
  351. </div>
  352. <div class="cell border-box-sizing code_cell rendered">
  353. <div class="input">
  354. <div class="inner_cell">
  355. <div class="input_area">
  356. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">analyze</span><span class="p">(</span><span class="s2">&quot;&quot;&quot;//test function</span><span class="se">\n</span><span class="s2">public void setSourceIds(java.util.Collection&lt;String&gt; sourceIds) {</span><span class="se">\n</span><span class="s2"> if (sourceIds == null) {</span><span class="se">\n</span><span class="s2"> this.sourceIds = null;</span><span class="se">\n</span><span class="s2"> return;</span><span class="se">\n</span><span class="s2"> }</span><span class="se">\n\n</span><span class="s2"> this.sourceIds = new java.util.ArrayList&lt;String&gt;(sourceIds);</span><span class="se">\n</span><span class="s2"> }&quot;&quot;&quot;</span><span class="p">)</span>
  357. </pre></div>
  358. </div>
  359. </div>
  360. </div>
  361. <div class="output_wrapper">
  362. <div class="output">
  363. <div class="output_area">
  364. <div class="output_text output_subarea output_execute_result">
  365. <pre>Module(loc=9, lloc=5, sloc=8, comments=0, multi=0, blank=1, single_comments=0)</pre>
  366. </div>
  367. </div>
  368. </div>
  369. </div>
  370. </div>
  371. <div class="cell border-box-sizing code_cell rendered">
  372. <div class="input">
  373. <div class="inner_cell">
  374. <div class="input_area">
  375. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">metrics</span>
  376. </pre></div>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. <div class="cell border-box-sizing code_cell rendered">
  382. <div class="input">
  383. <div class="inner_cell">
  384. <div class="input_area">
  385. <div class=" highlight hl-ipython3"><pre><span></span><span class="nb">dir</span><span class="p">(</span><span class="n">metrics</span><span class="p">)</span>
  386. </pre></div>
  387. </div>
  388. </div>
  389. </div>
  390. <div class="output_wrapper">
  391. <div class="output">
  392. <div class="output_area">
  393. <div class="output_text output_subarea output_execute_result">
  394. <pre>[&#39;METRICS_FILENAME&#39;,
  395. &#39;__builtins__&#39;,
  396. &#39;__cached__&#39;,
  397. &#39;__doc__&#39;,
  398. &#39;__file__&#39;,
  399. &#39;__loader__&#39;,
  400. &#39;__name__&#39;,
  401. &#39;__package__&#39;,
  402. &#39;__path__&#39;,
  403. &#39;__spec__&#39;,
  404. &#39;__version__&#39;,
  405. &#39;unicode_literals&#39;]</pre>
  406. </div>
  407. </div>
  408. </div>
  409. </div>
  410. </div>
  411. <div class="cell border-box-sizing code_cell rendered">
  412. <div class="input">
  413. <div class="inner_cell">
  414. <div class="input_area">
  415. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">metrics</span> <span class="k">import</span> <span class="n">sloc</span>
  416. </pre></div>
  417. </div>
  418. </div>
  419. </div>
  420. </div>
  421. <div class="cell border-box-sizing code_cell rendered">
  422. <div class="input">
  423. <div class="inner_cell">
  424. <div class="input_area">
  425. <div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">metrics</span>
  426. </pre></div>
  427. </div>
  428. </div>
  429. </div>
  430. </div>
  431. <div class="cell border-box-sizing code_cell rendered">
  432. <div class="input">
  433. <div class="inner_cell">
  434. <div class="input_area">
  435. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">sloc</span><span class="p">)</span>
  436. </pre></div>
  437. </div>
  438. </div>
  439. </div>
  440. <div class="output_wrapper">
  441. <div class="output">
  442. <div class="output_area">
  443. <div class="output_subarea output_stream output_stdout output_text">
  444. <pre>Help on module metrics.sloc in metrics:
  445. NAME
  446. metrics.sloc
  447. DESCRIPTION
  448. Source Lines of Code (SLOC)
  449. This type of metric counts the lines but excludes empty lines and comments.
  450. In literature this is also referred as physical lines of code.
  451. CLASSES
  452. metrics.metricbase.MetricBase(builtins.object)
  453. SLOCMetric
  454. class SLOCMetric(metrics.metricbase.MetricBase)
  455. | Compute the SLOC Metric for the whole source file.
  456. |
  457. | Method resolution order:
  458. | SLOCMetric
  459. | metrics.metricbase.MetricBase
  460. | builtins.object
  461. |
  462. | Methods defined here:
  463. |
  464. | __init__(self, context)
  465. | Initialize self. See help(type(self)) for accurate signature.
  466. |
  467. | display_header(self)
  468. | Display header for SLOC metric
  469. |
  470. | display_metrics(self, metrics)
  471. | Display Source Lines of Code metric (SLOC)
  472. |
  473. | display_separator(self)
  474. | Display separator for SLOC metric
  475. |
  476. | get_metrics(self)
  477. | Calculate ratio_comment_to_code and return with the other values
  478. |
  479. | process_token(self, tok)
  480. | count comments and non-empty lines that contain code
  481. |
  482. | reset(self)
  483. | Reset metric counter.
  484. |
  485. | ----------------------------------------------------------------------
  486. | Data descriptors defined here:
  487. |
  488. | metrics
  489. | Calculate ratio_comment_to_code and return with the other values
  490. |
  491. | ----------------------------------------------------------------------
  492. | Methods inherited from metrics.metricbase.MetricBase:
  493. |
  494. | process_file(self, language, key, token_list)
  495. | Initiate processing for each token.
  496. |
  497. | Override this if you want tt control the processing of the tokens yourself.
  498. |
  499. | ----------------------------------------------------------------------
  500. | Data descriptors inherited from metrics.metricbase.MetricBase:
  501. |
  502. | __dict__
  503. | dictionary for instance variables (if defined)
  504. |
  505. | __weakref__
  506. | list of weak references to the object (if defined)
  507. DATA
  508. print_function = _Feature((2, 6, 0, &#39;alpha&#39;, 2), (3, 0, 0, &#39;alpha&#39;, 0)...
  509. token_types = [&#39;Keyword&#39;, &#39;Name&#39;, &#39;Punctuation&#39;, &#39;Operator&#39;, &#39;Literal&#39;...
  510. unicode_literals = _Feature((2, 6, 0, &#39;alpha&#39;, 2), (3, 0, 0, &#39;alpha&#39;, ...
  511. FILE
  512. /usr/local/lib/python3.6/dist-packages/metrics/sloc.py
  513. </pre>
  514. </div>
  515. </div>
  516. </div>
  517. </div>
  518. </div>
  519. </div>
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...